Skip to content

fix: retain operation attribution in lifecycle evidence - #202

Merged
abogartz merged 2 commits into
abogartz:mainfrom
WhollyMindless:fix/lifecycle-evidence
Oct 31, 2026
Merged

abogartz merged 2 commits into
abogartz:mainfrom
WhollyMindless:fix/lifecycle-evidence

Conversation

@WhollyMindless

Copy link
Copy Markdown
Contributor

Fixes #199. A session move during init or capture could leave gate evidence in the starting repository and lifecycle records in another repository. Init start/complete/skip, capture outcomes/refusals/partial receipts, and capture lag now share the gate operation's captured entry-time attribution.

Resolved operations keep lifecycle session/call metadata suppressed. A captured named-but-unresolved owner retains only its sid privacy label even when call metadata is suppressed: without either a repository stamp or that owner label, the evidence reader treats a line as legacy/global. The snapshot remains unresolved even if the session later binds. Ambient maintenance retains its captured process scope, and credential scrubbing remains at the evidence boundary.

Six regression tests exercise resolved, unresolved, and ambient init; a parked model call followed by a session move for capture promotion and refusal; real memory_evidence reads from both repositories; init skip; and suppressed unresolved evidence with a credential-shaped reason. All six fail against unchanged main bf9f4d2 and pass with the change. The refusal case uses a synthetic gate exception to isolate lifecycle attribution; existing lock/partial-write tests cover the real storage refusal behavior.

Windows / Bun 1.4.4 full gate passes: typecheck, lint (408 advisory warnings), 835 unit/scenario tests (11 skips) and 11 real-host E2E tests.

Scope: evidence ownership only. Viewer audit attribution, cancellation of in-flight capture at disposal, and the other findings from the concurrent reviews remain separate. This does not claim new live-host session-move verification or change durable row ownership.

Please feel free to decline or close this if per-event lifecycle attribution is intentional or you prefer another policy for the project.

@abogartz abogartz left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE (one non-blocking nit, N1 below)

Adversarial review at head 258be21 (base bf9f4d2). Issue #199 is the scope boundary recorded in the #189 approval; this PR makes the policy call #199 asked for (lifecycle records follow operation-entry attribution) and satisfies its acceptance list one-for-one: deterministic mid-async moves, memory_evidence reads from both repos, named-unresolved privacy preserved, intentional suppression preserved, ambient behavior preserved, scrubbing untouched, no cross-operation call-ID borrowing, and the README now documents the chosen trail instead of pointing at #199.

Body claims checked against the tree

  • Shared captured owner: record() now resolves attribution via the captured context when one is provided, and never re-resolves per event (src/evidence.ts:105). runInit captures in its third line, before the first await (src/init.ts:213) — so the tests' "suspended at first await" premise is deterministic, not a race I had to statistically win. All three init records pass the snapshot. In the capture path, gateContext(sid) sits in captureSession's synchronous prefix (after setCurrent/bindSessionProvisional, both sync), and every capture record — refused/partial/promoted/audit — threads captureGate.evidenceContext, including recordCaptureLag's new parameter.
  • {sid}-only privacy arm (src/evidence.ts:111): fires only when a context was captured, scope is null, and the owner is a named session other than the ambient ?. Resolved captures stay fully suppressed; context-less legacy callers are untouched (no context ⇒ unchanged empty). Credential scrubbing remains the last spread, so it still wins at the boundary.
  • "Snapshot remains unresolved even if the session later binds" — pinned by construction: the unresolved init arm rebinds the owner to B after capture and asserts the line carries no repo but sid=owner, visible to that session and invisible from B's reader.
  • Scope honesty: viewer audit attribution and disposal-cancellation are genuinely not claimed; ambient/runtime telemetry (epoch_recompute, decay_*, store_lock) still resolves per event, consistent with the stated boundary.

Verification (macOS, Bun 1.4.3; Windows leg via CI)

  • Red/green measured: all six regression tests fail on unchanged base bf9f4d2 (incl. the privacy-label assertion, where the base line visibly lacks sid=) and 6/6 pass at head.
  • Full gate at head: unit 835 pass / 11 skip / 0 fail (= base 829/11/0 + your 6), e2e 11/0, typecheck clean.
  • Lint: gate command biome lint is identical base vs head (408 warnings, 128 infos, exit 0). FYI, biome check reports two format diffs in the edited hunks of src/evidence.ts/src/init.ts — the repo gate and CI lint leg don't run format, so this matches existing repo state; run biome format on the two files if you want them tidy.
  • CI on 258be21: lint / test / smoke / test-windows all green; mergeStateStatus CLEAN.

N1 (nit, not blocking)

The no-target auto_capture_refused (src/index.ts:1552, the #152 pre-model bail when the instance has no workspace) now also receives the captured context, but no test exercises it — the refusal arm of test 2 pins the :1595 write-failure variant. The one-liner is the same pattern and fails safe, but it's the one changed call site living purely on the body's word. A capture against an instance with no workspace, or folded into the existing test 2 shape, would close it.

Not merging — the user merges by hand.

@abogartz
abogartz merged commit 4cb3edb into abogartz:main Oct 31, 2026
4 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.15.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow-up: init/capture lifecycle evidence can split from gate evidence after a session move

2 participants