fix(review): embed asymmetry comment, single-lock assign-marker, dedup-collapse test

This commit is contained in:
2026-07-27 00:02:32 -04:00
parent 66d47fb410
commit 77e7c39171
3 changed files with 43 additions and 13 deletions
+24
View File
@@ -160,6 +160,29 @@ static void testFreshInstanceAppliesFirst() {
CHECK(d.consumedGeneration == 1);
}
// Re-import / dedup-collapse path: the extension ingests a sample that already exists in
// the bank (dedup collapse: the bank_generation counter does NOT advance because no new
// sample was added), but a new assign_request is still written with a HIGHER assign
// generation (the ingest disambiguator, independent of bank_generation).
//
// The consumeDecision must apply the request — its own generation is the "is this new?"
// discriminator, and it is strictly greater than lastConsumed. bank_generation does not
// enter consumeDecision at all; this test proves the two counters are fully independent.
static void testDedupCollapseAssignAppliesWhenBankGenerationUnchanged() {
// Simulate: bank_generation is 5 both before and after the dedup ingest (unchanged).
// The assign_request generation is 300 (new; lastConsumed was 200 from the prior assign).
// The existing sample resolves (it is in the bank — dedup kept it there).
const auto d = consumeDecision(makeReq("pool", "existing-sample-id", 300),
/*lastConsumed*/ 200, /*resolves*/ true,
/*isFocusedTarget*/ true);
CHECK(d.apply);
CHECK(d.bankId == "pool");
CHECK(d.sampleId == "existing-sample-id");
CHECK(d.consumedGeneration == 300); // marker advanced to the new assign generation
// bank_generation (5) is not a parameter here — this test documents its absence from
// consumeDecision: only the assign_request's own generation drives the consume decision.
}
int main() {
testParseAbsentAndMalformed();
testParseValid();
@@ -173,6 +196,7 @@ int main() {
testAppliedWhenNewTargetResolvable();
testSameIdNewGenerationReapplies();
testFreshInstanceAppliesFirst();
testDedupCollapseAssignAppliesWhenBankGenerationUnchanged();
if (g_fail == 0) std::printf("All tests passed.\n");
return g_fail ? 1 : 0;