Repository navigation
fix(evidence): preserve caller ownership across emit paths - #304
Conversation
There was a problem hiding this comment.
Reviewed head 466b49fcfda4e338329597d87c5930631d18e838 (merge-base 06e4e28). COMMENTED, not APPROVE: spec not authored or adopted by a trusted human: a person decides — governing issue #297 was authored by app/ocsi-architect and its timeline shows no agent:ready label applied by any human (only severity:high and spec:draft, both by ocsi-architect[bot]). The code itself passes every acceptance criterion below; once a maintainer adopts #297, this head is ready.
Contract (#297 acceptance, verbatim)
RED: on main
7405dc61d919e7eee7033dea6e4324eda58ee669, a test that sets the ambient current to session B (repo B) and executes thememory_decaydry run for session A (repo A) reads back an evidence line stampedrepo=<B-key>— the test fails.
Evidence: checked out 7405dc6 (index + worktree), ran bun test test/emitter-evidence-attribution.test.ts against the PR's test file: 0 pass / 12 fail, failing at checkOwner test/emitter-evidence-attribution.test.ts:78 with Expected: undefined / Received: "ba0beae100cb" — the ambient stranger repo's key on the line, exactly the misstamp the ticket describes.
GREEN:
bun run testpasses; the line is stampedrepo=<A-key>; the same assertion holds forconsolidate_propose,frontier_injectedandepoch_recompute(each driven with a mismatched ambient current).
Evidence: at head, bun run test: 1021 pass / 19 skip / 0 fail (12646 expect(), 1040 tests, 23.94s). The new suite drives all six real emit paths for resolved and unresolved callers with ambient current set to a different repo (test/emitter-evidence-attribution.test.ts:99-106 covers decay_dry_run, decay_applied full and partial, consolidate_propose, frontier_injected, epoch_recompute); checkOwner asserts repo/repoPath equal the caller's scope and reads back through memory_evidence (caller sees, stranger and other-unresolved session do not): 12 pass / 0 fail / 110 expect().
Commands run at head (measured)
bun run typecheck— exit 0, no errorsbun run lint— 493 warnings, identical to merge-base06e4e28baseline (measured on the same machine)bun run test— 1021 pass / 19 skip / 0 failbun run test:e2e— 30 pass / 0 fail (src/ changed)- CI re-check at filing time:
lintpass,testpass,test-windowspass,smokepass;headRefOid=466b49fcfda4e338329597d87c5930631d18e838(unchanged from review)
Code review
All six sites named in the issue are threaded, each capturing before the first await: src/tools/decay.ts:22 (dry run + applied + partial), src/tools/consolidate.ts:24, src/inject/digest.ts:49, src/inject/epochs.ts:189; record() consumes the pre-captured context (src/evidence/record.ts:121) and the unresolved-owner privacy-label branch (src/evidence/record.ts:128-132) keeps sid on the line when the scope is null, so an unresolved caller's line stays private instead of reading legacy/global. The partial-decay test fails only the second file's publish via spyOn(publish,"writeAtomic") and asserts the first row really retired (superseded_by === "decay") — the real partial path, not a mocked receipt. No assertion deleted, no .skip, no tolerance widened: the test file is purely additive (+171).
P0/P1: none. Nit: when a digest input carries no sessionID, sid is "?" and captureEvidenceContext("?") falls back to the ambient call exactly as before the change (src/evidence/record.ts:86-92) — pre-existing documented behavior, not a regression.
Spec anchor
Recomputed #297 body hash with the triager pipeline: 7130ec157680844a. No prior osi-spec-hash: comment exists, so the spec is frozen. The reviewer app cannot post issue comments (403 Resource not accessible by integration on POST issues/297/comments — no issues:write), so the anchor is recorded here; a maintainer or the triager should post osi-spec-hash: 7130ec157680844a on #297.
|
The independent review verified the implementation and all acceptance tests; approval is held because #297 is still an architect-authored draft awaiting human adoption. @abogartz, if you want this to proceed, could you adopt #297 through your normal process? The review records the proposed spec anchor as |
|
🎉 This PR is included in version 0.15.37 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Closes #297. Evidence from decay, consolidation, the open-thread frontier and epoch recomputation could receive whichever session was ambient when the operation finished. That could expose the line to the wrong repo while hiding it from the caller.
Capture the calling session's existing
EvidenceContextbefore the first await and pass it, together withsid, at all six emit sites. Resolved callers retain their own repo stamp while ordinary sid/call metadata stays suppressed. The context also preserves a private sid for unresolved callers: passing only record's fourth argument withincludeContext=falsewould omit both repo and sid, making those lines read as legacy/global. This uses the existing writer behavior without changing its policy.The new regression suite drives all six real emit paths with a different ambient session, for both resolved and unresolved callers (12 tests, 110 assertions). It checks persisted ownership fields and reads events through
memory_evidence: the caller can see them; another repo and another unresolved session cannot. Partial decay is exercised by failing the second file's publication after the first row actually retires. All 12 tests fail on original base7405dc6and pass with this fix.Rebased onto latest main
06e4e28after #303 merged. Validation of that combined tree on Windows, Bun 1.4.4:bun run test: 1,008 pass, 32 skip, 0 fail (29.19s).bun run test:e2e: 30 pass, 0 fail (16.32s).bun run typecheck,bun run lint, andgit diff origin/main...HEAD --check: pass.The mismatched-session scenarios use the local test harness; no live multi-repo host reproduction is claimed. Taking this at WhollyMindless's request. Please feel free to defer or reject the PR if you prefer another approach. No agent labels were changed.