Repository navigation
fix: honor value rejections in viewer writes (#222) - #263
Conversation
There was a problem hiding this comment.
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):
- Edit path refuses rejected values —
src/viewer/mutate.ts:79-81callsassertViewerWriteAllowedbefore snapshot/append/retirement/audit. Differential at merge-based286e7awith the issue's own repro: basePOST /api/edit→ 200,revivedRejectedRow=true; head → 400previously_rejected (exact; hash e97ea54cd0f0),revivedRejectedRow=false. - Restore path refuses —
src/viewer/server.ts:319checks before any append; covered viadescribe.each(["/api/edit","/api/restore-entry"]). - Fail-closed —
src/viewer/rejections.tspropagates 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. - 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). - 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.
|
🎉 This PR is included in version 0.15.12 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
probeRejectionon the secret-redacted content thatappendMemorywill 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: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.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.