Skip to content

fix: honor value rejections in viewer writes (#222) - #263

Merged
abogartz merged 2 commits into
abogartz:mainfrom
WhollyMindless:fix/222-viewer-rejections
Nov 3, 2026
Merged

abogartz merged 2 commits into
abogartz:mainfrom
WhollyMindless:fix/222-viewer-rejections

Conversation

@WhollyMindless

Copy link
Copy Markdown
Contributor

Closes #222.

The viewer could edit a live row into previously rejected content, or replay a rejected deleted entry through /api/restore-entry, without lifting the value rejection. Both paths appended the content despite the existing rejection ledger.

This takes the issue's trusted admin editor plus tombstone check option. A shared viewer check reuses probeRejection on the secret-redacted content that appendMemory will persist. Exact and near matches refuse before edit snapshots, appends, supersession or edit audit; restore-entry refuses before append. The HTTP response retains the existing 400/error shape, names the matching rejection hash and points to Rejections → un-reject without echoing the rejected prose. Rejection-ledger read failures propagate and refuse the write.

The viewer still permits deliberate admin edits without model-facing grounding/deduplication gates. Numeric/polarity corrections retain the existing rejection exceptions. Existing row ownership, edit metadata, snapshots and explicit release endpoints are preserved. Whole-snapshot rollback, #214/#221 policy, #207 restore metadata, and #209 unblock no-op behavior are separate; they are not changed here. The selected option needs no #220 gate decomposition and does not touch #168 session binding or #254 visibility changes.

Validation on Bun 1.4.4, base d286e7a:

  • Initial HTTP/direct-call regression file against unmodified main: 6 pass / 11 fail. It reproduced exact/near replays, forgotten-value replays, secret-redacted content replay and direct-edit bypass; positive unrelated/correction controls already passed.
  • Final new regression file: 19 pass / 0 fail, including explicit un-reject followed by successful retry, preserved edit metadata/retirement/snapshot, unchanged durable state on refusal, and unreadable-ledger refusal on both endpoints.
  • WSL Linux focused viewer/rejection/schema/quarantine/partial-outcome suites: 132 pass / 0 fail across 7 files.
  • Full Windows bun run gate: typecheck and lint pass (498 warnings / 131 infos), 881 unit tests pass / 26 skip / 0 fail, 30 real-host E2E tests pass / 0 fail. The new helper and test file have no lint diagnostics.
  • Existing tests/assertions are unchanged. No catalog mutant was added: the real HTTP regression cases fail directly on the pre-fix implementation. No full mutation sweep was run.

Ownership was claimed on #222 before implementation following the maintainer's Discord handoff. Please feel free to request the full-gate alternative, narrow the scope or reject this approach if you prefer a different viewer contract.

@ocsi-triager ocsi-triager Bot added the review:requested Human-admitted for autonomous review by ocsi-reviewer label Nov 3, 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 head 07f1267c530d0f244130f50298c264c2b5a16e1b (diff key ddd89e99919a7c600217e267e31272303972dabdc9415ee21fa984d723700326).

Contract — #222 (authored by repo owner abogartz, trusted human):

Viewer editor writes bypass the write gate: blocked content can be re-appended and stored
Fix direction: "Pick the invariant. Either run the same gate for viewer writes … or declare the viewer a trusted root-editor and give it a tombstone check so blocked content stays blocked."
"No test covers the viewer write endpoints."

Conformance (fix direction 2: trusted admin editor + value-rejection check):

  1. Edit path refuses rejected values — src/viewer/mutate.ts:79-81 calls assertViewerWriteAllowed before snapshot/append/retirement/audit. Differential at merge-base d286e7a with the issue's own repro: base POST /api/edit → 200, revivedRejectedRow=true; head → 400 previously_rejected (exact; hash e97ea54cd0f0), revivedRejectedRow=false.
  2. Restore path refuses — src/viewer/server.ts:319 checks before any append; covered via describe.each(["/api/edit","/api/restore-entry"]).
  3. Fail-closed — src/viewer/rejections.ts propagates probe errors; test "an unreadable rejection ledger refuses the write instead of granting it" (directory at ledger path, no mocks) → 400, store/snapshots/audit unchanged.
  4. Explicit release still the only lift — test "explicit un-reject permits retry…": /api/unreject → 200, retry stores with original edit metadata (tags/kw/issue/superseded_by/snapshot/audit).
  5. Tests cover the viewer write endpoints — new test/viewer-rejections.test.ts: 19 tests, both routes, exact + near-match (REWORDED), durability after prune, redacted-bytes check (ghp_ scrub), corrected numeric value and polarity changes allowed.

Invariant at server.ts:308-310 ("rejection is lifted only by an explicit release action") now holds for viewer writes; README documents the chosen invariant.

Commands run at head: bun run typecheck clean · bun run lint 498 warnings = baseline · bun run test 893 pass / 14 skip / 0 fail · bun run test:e2e 30 pass / 0 fail (src/ changed) · CI 4/4 green (lint, test, test-windows, smoke).

Test integrity: new file only; no .skip, no weakened assertions, no raised timeouts.

Findings: no P0/P1.

Spec anchor: #222 body hash 08f9a10bf214eece, no prior osi-spec-hash: comment found.

@abogartz
abogartz merged commit 49cf968 into abogartz:main Nov 3, 2026
4 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.15.12 🎉

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Viewer editor writes bypass the write gate: blocked content can be re-appended and stored

2 participants