mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
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.
This commit is contained in:
1 parent
eeca98bb2b
commit
679fbe2cbe
3 files changed
+43
-5
No files matched your search
@@ -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
|
||||
|
||||
@@ -570,7 +570,14 @@ export abstract class BinarySessionRecords {
|
||||
): Result<ResidualUnknown | null, AnalysisError> {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -159,6 +159,7 @@ export class InvestigationRecords
|
||||
recordEvidenceWithUnknown(
|
||||
evidence: Evidence,
|
||||
input: RecordUnknownInput,
|
||||
providerSelection?: ProviderSelectionProvenance,
|
||||
): Result<ResidualUnknown | null, AnalysisError> {
|
||||
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,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user