Skip to content

fix: blocked-writes list follows evidence visibility (#306) - #311

Merged
abogartz merged 4 commits into
mainfrom
fix-issue-306-20261105T0115Z
Nov 5, 2026
Merged

abogartz merged 4 commits into
mainfrom
fix-issue-306-20261105T0115Z

Conversation

@ocsi-fixer

@ocsi-fixer ocsi-fixer Bot commented Nov 5, 2026

Copy link
Copy Markdown

Closes #306

What

blockedRecent read today+yesterday write_blocked evidence with no visibility filter, so memory_status and the terminal /memory panel showed other repositories' session ids and gate reasons while memory_evidence correctly hid them. Now every line is filtered through evidenceVisibleTo — the same predicate memory_evidence uses — with the caller's Reader.

Changes

  • src/status/write.ts: blockedRecent(limit, reader = ADMIN_READER, callerSid?) filters each parsed line through evidenceVisibleTo. Default ADMIN_READER keeps the historical unfiltered read for out-of-plugin callers; plugin surfaces pass their own reader. New blockedReaderFor(rootDir?) resolves the terminal panel's reader from the active session's root directory (the TUI process owns no session→repo map; resolveRepo is deterministic for the same path on this machine, hence the same key the server stamped with). Unresolvable root fails closed to global-only.
  • src/tools/status-tool.ts: the memory_status call site passes the existing reportReader + sid (the quarantine list beside it already used reportReader); the tool description now states aggregate STORE counts are machine-wide by decision.
  • src/tui/panel.tsx: the panel resolves the reader from data.session.root(activeSid) and passes it to blockedRecent; unknown root fails closed.
  • README.md: documents that aggregate STORE counts are machine-wide (Policy: scope blocked-write details and define global status metrics #213 B) while the blocked-writes list follows each reader's visibility.

The ticket named src/index.ts and src/injection-epochs.ts as the call sites; #168 (merged) moved the memory_status tool to src/tools/status-tool.ts and the TUI surface is src/tui/panel.tsx (src/injection-epochs.ts became src/inject/epochs.ts, which assembles the status payload but never the blocked list — the panel reads evidence directly so a block surfaces without waiting for an epoch). The reader is passed at both actual consumers.

Acceptance evidence

  • RED: test/status-blocked-visibility-306.test.ts seeds a repo-B write_blocked line with distinctive sid ses-BLEEDS-306 plus a repo-A line, then runs the real memory_status tool as a repo-A session. On main 06e4e28 (measured in a clean worktree of that sha): 3 fail / 0 pass, failing exactly because the repo-B sid prints in repo-A's report.
  • GREEN: repo-A status omits ses-BLEEDS-306 and shows its own ses-OWNED-A-306; ADMIN_READER sees both; repo-B's status shows its own, not A's; the STORE line is byte-identical between the repo-A and repo-B reports (counts machine-wide, deliberately not scoped); blockedReaderFor(a) deep-equals readerFromSid("ses-a") (the tool's own reader) and yields the same blocked set; blockedReaderFor(undefined) → global-only shows only the session-less line, never everything. New tests: 6 pass.
  • No existing assertion weakened: no test edited or skipped; the blockedRecent default preserves the unfiltered semantics the existing status.test.ts / write-evidence.test.ts cases rely on.

Commands run (measured)

  • bun run typecheck — exit 0
  • bun run lint — exit 0, no new warnings in changed files
  • bun run test — 1015 pass / 19 skip / 0 fail
  • bun run test:e2e — 30 pass / 0 fail (src/ changed)

Deliberately not changed

  • summarizeStore / STORE aggregation — counts stay machine-wide by decision.
  • StatusPayload shape — the panel keeps reading evidence directly so a fresh block surfaces via the evidence watcher without waiting for an epoch recompute.
  • src/index.ts — its blockedRecent import is dead since Proposal: separate responsibilities in plugin setup (src/index.ts) #168; removing it is unrelated cleanup.
  • No label on any issue other than the fix:* swap; no review, no merge.

blockedRecent now filters write_blocked lines through evidenceVisibleTo
with the caller's Reader, the same rule memory_evidence uses. The
memory_status tool passes its reportReader; the terminal panel resolves
the active session's repository from its root (blockedReaderFor) and
fails closed to global-only when unresolvable. Aggregate STORE counts
stay machine-wide by decision and are now documented as such in the
tool description and README.
@ocsi-triager ocsi-triager Bot added the review:requested Human-admitted for autonomous review by ocsi-reviewer label Nov 5, 2026
ocsi-reviewer[bot]
ocsi-reviewer Bot previously requested changes Nov 5, 2026

@ocsi-reviewer ocsi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed at head f43b8fdccd47b0676e84b5be6312e4e629e73cc0.

Verdict driver: required context red

Final gate re-check at filing, one breath:

$ gh pr view 311 --json headRefOid
{"headRefOid":"f43b8fdccd47b0676e84b5be6312e4e629e73cc0"}
$ gh pr checks 311 --json name,bucket
[{"bucket":"pass","name":"lint"},{"bucket":"pass","name":"test"},{"bucket":"fail","name":"test-windows"},{"bucket":"pass","name":"smoke"}]

test-windows failed at 02:46:50Z (run 41957127714, job 127014605318). Failing line, verbatim:

(fail) calls ledger is capped and lifetime counters keep the counts truthful [5013.15ms]
  ^ this test timed out after 5000ms.

Summary: 1004 pass / 29 skip / 1 fail. The failing test is test/bounded-session-ledgers.test.ts:67 — untouched by this PR (PR files: README.md, src/status/write.ts, src/tools/status-tool.ts, src/tui/panel.tsx, two new test files). A 5s timeout on a loaded shared runner, not attributable to the diff. Still: a red required context decides the verdict; an approve is the machine's ready-for-merge signal and cannot be filed on red. Push any commit (even empty) to re-trigger; when the check is green at this head this verdict falls and I dismiss it.

Contract #306 (abogartz authored, agent:ready applied by abogartz; spec hash cbe6da30d3ca5562 == anchor, frozen)

  • RED: scenario test — seed a repo-B write_blocked line with a distinctive sid plus repo-B rows; a repo-A memory_status prints the repo-B sid. Fails on main for exactly that reason.
  • GREEN: repo-A status omits the line and shows only its own blocked writes; the admin/global reader still sees all; STORE counts are identical before and after for every reader (counts deliberately not scoped); TUI payload agrees with the tool.
  • No existing assertion weakened; bun run typecheck && bun run lint && bun run test green, bun run test:e2e since src/ changed.

Criterion 1 — evidenced. Differential at merge-base 06e4e28: test/status-blocked-visibility-306.test.ts copied onto main, bun test → 0 pass / 3 fail; the leak assertion fails at :146 (expect(ca).not.toContain("ses-BLEEDS-306")) — exactly the unfiltered-read reason the ticket names.

Criterion 2 — evidenced at head. All 6 new tests pass: repo-A omits B's line and keeps its own (status-blocked-visibility-306.test.ts:87); admin sees all, B keeps own history (:105); STORE line byte-identical across readers (:125, expect(storeLine(ca)).toBe(storeLine(cb))); panel reader equals the tool reader (status-blocked-reader-306.test.ts:67, expect(panelReader).toEqual(toolReader)); no-root fails closed to global-only (:91).

Criterion 3 — evidenced. git diff origin/main...HEAD --numstat: test files 99+0 and 149+0 — purely additive, no assertion removed, no .skip, no widened tolerance. Local at head: bun run typecheck clean; bun run lint 231 files clean; bun run test 1015 pass / 19 skip / 0 fail; bun run test:e2e 30 pass / 0 fail.

Implementation notes

  • Both blockedRecent call sites pass a reader: src/tools/status-tool.ts:64 (reportReader, sid) and src/tui/panel.tsx:99 (blockedReaderFor(rootDir), activeSid). No third caller exists (grep blockedRecent( src/).
  • Default ADMIN_READER (src/status/write.ts:110-113) preserves the historical unfiltered read for out-of-plugin callers — verified against the two-site census.
  • blockedReaderFor fails closed to {kind:"global-only"} on absent or unresolvable root (src/status/write.ts:152-159); evidenceVisibleTo gives global-only false for repo-stamped lines (src/store/model/visibility.ts:107), so unknown is never everything.
  • Issue text pointed at src/index.ts / src/injection-epochs.ts; the actual call sites in the tree are status-tool.ts / tui/panel.tsx — the fix covers the real surface, nit only.
  • README documents machine-wide STORE counts per decision #213 B (README.md:209).

Findings

  • P0 (blocking, CI): test-windows red at this head — quoted above; not attributable to the diff.
  • nit: issue file references stale (see above); no action needed.

Everything except the red Windows check is satisfied and evidenced. Green the check and this verdict is dismissed.

@ocsi-fixer

ocsi-fixer Bot commented Nov 5, 2026

Copy link
Copy Markdown
Author

Rework at df4dade addressing the CHANGES_REQUESTED on f43b8fd:

  • P0 (CI, ocsi-reviewer): test-windows red at f43b8fd — the failing test (test/bounded-session-ledgers.test.ts:67, 5s timeout) is untouched by this PR's diff. Per the review's instruction, pushed an empty commit to re-trigger the required check. No source change: the contract findings were all marked satisfied at f43b8fd.
  • nit (stale issue file references): no action, per the review.

Proof re-run locally at df4dade (tree identical to f43b8fd): bun run typecheck exit 0; bun run lint exit 0; bun run test 1015 pass / 19 skip / 0 fail; bun run test:e2e 30 pass / 0 fail. The pre-push merge gate also ran all green.

@ocsi-reviewer
ocsi-reviewer Bot dismissed their stale review November 5, 2026 04:12

Resolved at df4dade: test-windows now green (run for this head passes). The CR was filed only for the red test-windows check (bounded-session-ledgers.test.ts:67 timeout, run 41957127714); the failure no longer reproduces.

@ocsi-reviewer ocsi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed head df4dade (diff key a46f3cdbc1dab09b, unchanged from the head I verified; f43b8fd→df4daded is a merge of main only).

Verdict correction. My prior CHANGES_REQUESTED 5779491286 was filed only for the red test-windows check (bounded-session-ledgers.test.ts:67 timeout 5000ms, run 41957127714 — untouched test, loaded-runner timeout, not attributable to the diff). The check is now green at this head; the failure no longer reproduces, so I dismissed that review as a fallen finding before filing this approve.

Contract — #306 blocked-writes visibility (authored and adopted by abogartz; spec hash cbe6da30d3ca5562 == osi-spec-hash anchor, frozen). Acceptance criteria, evidenced at the identical diff key:

  1. RED at merge-base 06e4e28: 0/3, leak assertion fails at :146 — quoted in prior review.
  2. GREEN at head: 6/6, including STORE-line identity and panel/tool reader equality.
  3. Tests additive: 99+/0− and 14+/0− across the two test files; no existing assertion weakened, no skips.

Commands and measured numbers (prior pass at this same diff key): typecheck 0 errors, lint 231 clean, bun run test 1015 pass / 19 skip / 0 fail, e2e 30/0.

Final-gate re-check at filing (verbatim): headRefOid df4dade; checks: lint pass, test pass, test-windows pass, smoke pass.

No P0/P1 findings. One nit carried: issue file refs stale (index.ts/injection-epochs.ts vs real status-tool.ts/panel.tsx); fix covers the real surface. Human merges.

@abogartz
abogartz self-requested a review as a code owner November 5, 2026 16:01
@abogartz
abogartz merged commit 0561d05 into main Nov 5, 2026
7 of 8 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.15.38 🎉

The release is available on:

Your semantic-release bot 📦🚀

@abogartz
abogartz deleted the fix-issue-306-20261105T0115Z branch November 19, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released review:requested Human-admitted for autonomous review by ocsi-reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memory_status blocked-writes follow evidence visibility; STORE counts documented machine-wide (decision #213 B)

1 participant