From 679fbe2cbe2d489687a3c6438527e019b2cae5b2 Mon Sep 17 00:00:00 2001 From: 2SinceJuly <202121119+2SinceJuly@users.noreply.github.com> Date: Wed, 11 Nov 2026 15:43:17 +0800 Subject: [PATCH] fix(providers): attribute the atomic Evidence-and-Unknown mutation record recordEvidenceWithUnknown synthesizes its own rea.residual-unknown-mutation record, so the selection the session threads into recordUnknown and updateUnknown never reached it. The atomic comparison workflows therefore exported one record without provider_selection, contradicting the guarantee that every admitted record carries the recording session's selection. Thread the active binding through the atomic method as well; analyst-authored mutation records still keep analyst-inference authority and gain only the session selection. --- .../binary/BinarySessionInvestigation.test.ts | 26 +++++++++++++++++++ .../binary/BinarySessionRecords.ts | 9 ++++++- .../investigation/InvestigationRecords.ts | 13 +++++++--- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/application/binary/BinarySessionInvestigation.test.ts b/src/application/binary/BinarySessionInvestigation.test.ts index b5de976a08c..f0d882eaf3b 100644 --- a/src/application/binary/BinarySessionInvestigation.test.ts +++ b/src/application/binary/BinarySessionInvestigation.test.ts @@ -239,6 +239,32 @@ it("attributes an imported bundle to the recording session's provider selection" } }); +it("attributes the atomic Evidence-and-Unknown mutation record", async () => { + const [target] = await createBinarySessionTargets(); + const session = createTestBinarySession(createCacheProvider([])); + try { + expect((await session.open(target)).ok).toBe(true); + const recorded = session.recordEvidenceWithUnknown( + observation("atomic_unknown"), + unknownInput, + ); + if (!recorded.ok) throw recorded.error; + const mutation = session + .exportEvidenceBundle() + .records.filter((record) => record.operation === "record_unknown"); + // The atomic path synthesizes its mutation record rather than taking one + // from the caller, so it is the one write that can miss attribution. + expect(mutation).toHaveLength(1); + expect(mutation[0]?.provider_selection).toMatchObject({ + selection_source: expect.stringMatching( + /^(request|environment|auto-single-candidate)$/u, + ), + }); + } finally { + await session.dispose(); + } +}); + it("admits record Evidence before attributing it to the session", async () => { const [target] = await createBinarySessionTargets(); // A session with no authentication allowance must refuse a mutable record diff --git a/src/application/binary/BinarySessionRecords.ts b/src/application/binary/BinarySessionRecords.ts index 6ff28a78b1e..1145df7bed6 100644 --- a/src/application/binary/BinarySessionRecords.ts +++ b/src/application/binary/BinarySessionRecords.ts @@ -570,7 +570,14 @@ export abstract class BinarySessionRecords { ): Result { if (this.#investigationDisposed) return err(new AnalysisCancelledError("record_evidence_with_unknown")); - const recorded = this.#records.recordEvidenceWithUnknown(evidence, input); + // The mutation record carries the same session attribution as the sibling + // recordUnknown/updateUnknown paths; otherwise this atomic workflow is the + // one place an exported record has no provider selection. + const recorded = this.#records.recordEvidenceWithUnknown( + evidence, + input, + this.activeAnalysisBinding()?.providerSelection, + ); if (recorded.ok) this.#emitSnapshotChanged(); return recorded; } diff --git a/src/application/investigation/InvestigationRecords.ts b/src/application/investigation/InvestigationRecords.ts index 1a68d34bf53..5fb9a3c3b19 100644 --- a/src/application/investigation/InvestigationRecords.ts +++ b/src/application/investigation/InvestigationRecords.ts @@ -159,6 +159,7 @@ export class InvestigationRecords recordEvidenceWithUnknown( evidence: Evidence, input: RecordUnknownInput, + providerSelection?: ProviderSelectionProvenance, ): Result { const admitted = admitInvestigationAuthentication( input, @@ -169,10 +170,14 @@ export class InvestigationRecords return this.#evidence.recordWithUnknown( evidence, input, - unknownMutationEvidence(undefined, { - operation: "record_unknown", - input, - }), + unknownMutationEvidence( + undefined, + { + operation: "record_unknown", + input, + }, + providerSelection, + ), ); }