pS-usage: captures held by live ReaSampler 9000 instances are un-prunable — instances publish usage_<guid> ext-state records (ComponentState v11), prune unions live holds into referenced

This commit is contained in:
2026-07-28 12:56:36 -04:00
parent f988ded543
commit 5886ae1456
19 changed files with 1282 additions and 10 deletions
+31
View File
@@ -383,6 +383,35 @@ static void testDeletePlanDeduplicatesConfirmed() {
CHECK((plan == std::vector<std::string>{"b/a.wav", "b/b.wav"}));
}
// --- mergeReferenced: the pS-usage referenced-union (bank refs instance holds) -----
// The load-bearing property: a file held ONLY by a sampler instance (not referenced by
// any bank — e.g. its bank entry was deleted while the instance kept its v10 ref) joins
// `referenced` through the union, so pruneOrphans can never emit it. Removing the hold
// (the instance went away — liveness filtered its record out upstream) reclaims it again.
static void testMergeReferencedProtectsInstanceHeldFile() {
const std::vector<std::string> present{"b/held.wav", "b/orphan.wav"};
const std::vector<std::string> owned{"b/held.wav", "b/orphan.wav"};
const std::vector<std::string> bankRefs{}; // no bank references either file
const std::vector<std::string> withHold =
pruneOrphans(present, mergeReferenced(bankRefs, {"b/held.wav"}), owned);
CHECK((withHold == std::vector<std::string>{"b/orphan.wav"}));
const std::vector<std::string> withoutHold =
pruneOrphans(present, mergeReferenced(bankRefs, {}), owned);
CHECK(withoutHold.size() == 2); // no live hold -> both reclaim (no permanent block)
}
// Order-preserving exact-string de-dup: primary first, then the extras not already seen.
static void testMergeReferencedOrderDedupAndExactMatch() {
const std::vector<std::string> merged = mergeReferenced(
{"b/a.wav", "b/b.wav", "b/a.wav"}, {"b/b.wav", "b/c.wav", "B/A.WAV"});
// Case differs -> distinct entry (exact-string convention, never case-folded here).
CHECK((merged == std::vector<std::string>{"b/a.wav", "b/b.wav", "b/c.wav", "B/A.WAV"}));
CHECK(mergeReferenced({}, {}).empty());
}
int main() {
testNullTestAllReferenced();
testFormulaMixedPopulations();
@@ -411,6 +440,8 @@ int main() {
testDeletePlanNeverSweepsUnconfirmed();
testDeletePlanEmptyInputs();
testDeletePlanDeduplicatesConfirmed();
testMergeReferencedProtectsInstanceHeldFile();
testMergeReferencedOrderDedupAndExactMatch();
if (g_fail == 0) std::printf("prune_reconcile_tests: ALL PASS\n");
else std::printf("prune_reconcile_tests: %d FAILURE(S)\n", g_fail);