Repository navigation
fix: viewer restore retains quarantine, provenance and deleted-row metadata (#207) - #280
Conversation
… and metadata (#207) Both deletion paths (logDeletion for memory_forget, the viewer's delete audit) now record tags, kw, issue and status alongside the #129 origin stamp. /api/data exposes them on deleted entries with a quarantined flag, the deleted-row UI badges quarantine, and restore-entry resolves the metadata — and the origin stamp — from the audit line itself keyed by the deleted ts, so a restore cannot silently release quarantine, drop import provenance, or honour a client-forged repo stamp. Legacy audit lines without metadata restore unchanged (documented fallback).
WhollyMindless
left a comment
There was a problem hiding this comment.
Reviewed 9b2dfcf3d9de1ff5820c8d70a132c4eb63b26c4f against #207. I filed the original issue; the bot authored this implementation. Changes requested: one unwired UI change and one remaining restore path. Windows / Bun 1.4.4, isolated checkout, synthetic stores.
The primary path works: restore with the audited ts preserves quarantine/import tags and remains non-injectable. The focused metadata/viewer suites pass 31 tests, 127 assertions. Additional independent probes found:
F1 — the quarantine badge never reaches the rendered row (page.html:234–250). stCell contains the new combined deleted/quarantined badges, but the returned row still interpolates ${stBadge}. I evaluated the shipped helpers, currentList() and render() with a minimal DOM stub and a deleted row having quarantined:true: the HTML contains status-deleted, but no status-quarantined. Please render stCell and assert the resulting row markup. The new test only searches the source for badge-construction strings, so it passes even though that construction is unused. The confirmation warning is separately wired; the list itself still fails the issue's visibility criterion.
F2 — omission of ts still restores a known quarantined entry as injectable (restoreEntryRoute). Real HTTP reproduction: append an import/quarantined row, delete it through the viewer mutation, then restore that same type/scope/content. With the original ts, response is 200 and the restored row retains tags, isInjectable=false. Omitting only ts, response is also 200, tags disappear and isInjectable=true. The authoritative audit still exists and carries all metadata. This is not an old audit entry lacking metadata; the request selects the metadata-free fallback despite the available record. It also contradicts the body/schema comment's broad claim that a client cannot launder quarantine away.
I recognize that the body explicitly preserves the no-ts client-replay fallback. Please distinguish legacy records from legacy requests: resolve available authoritative metadata for the latter, or refuse an unresolved restore rather than implicitly releasing quarantine. If retaining this behavior is a deliberate maintainer policy decision, please make that residual explicit instead of claiming #207's quarantine guarantee covers it. This reproduces the existing class of defect through the retained API path; it is not an agent-only or unauthenticated network bypass. No new issue or implementation claimed.
…or no-ts restore (#207) Rework of the reviewer findings on 9b2dfcf: F1: the row template interpolated stBadge, so the combined deleted+quarantined stCell never reached the DOM. Render stCell and assert the rendered row markup via the DOM-stub harness instead of string-searching the source. F2: restore-entry without ts fell to the metadata-free client replay even when the audit carried the row, laundering quarantine away. Distinguish legacy records from legacy requests: resolve the newest matching audit line by type/scope/content; client replay survives only for rows the audit does not carry at all.
|
Rework at F1 (quarantine badge never reached the rendered row): the row template interpolated F2 (omitting New tests: Proof at |
WhollyMindless
left a comment
There was a problem hiding this comment.
Rechecked 4c18678f2e2444776dfac9119e9d352524b97f96. F1 is closed; the exact no-ts F2 reproduction is fixed. One closely related F2 fallback remains, so changes are still requested.
Independent Windows/Bun 1.4.4 verification: 33 focused tests pass, 143 assertions. The original render probe now produces both deleted and quarantine badges. The original no-ts restore preserves import/quarantine tags and isInjectable=false.
Residual: an unknown explicit ts selects the metadata-free fallback even when the matching audit exists. Using the same synthetic quarantined row and actual HTTP requests, changing only the identity presentation gives:
| Restore request | HTTP | Restored quarantine |
|---|---|---|
Correct original ts |
200 | Preserved; not injectable |
Omit ts |
200 | Preserved; not injectable |
ts: "2000-01-01T00:00:00.000Z" (absent from audit) |
200 | Dropped; injectable |
The type/scope/content match an existing deletion record carrying all metadata in every case. body.ts ? deletionAuditFor(body.ts) : deletionAuditByRow(...) never tries the row lookup when an explicit ID misses, and an undefined result still selects client replay. Thus the new comment's guarantee that fallback applies only when the audit does not carry the row is not yet true.
Please refuse an unresolved explicit identity, or resolve the available matching record before choosing the legacy fallback. A genuinely unaudited legacy row can retain its compatibility policy separately. Pin the unknown-ID variant alongside the corrected omission case; no additional feature or endpoint is requested.
This is the same retained restore/quarantine class, not an unauthenticated or agent-only bypass. If the maintainer deliberately wants arbitrary unresolved-ID replay as an admin operation, please state that policy explicitly and narrow the quarantine guarantee. No implementation or new issue claimed.
…207) An explicit ts that matches no audit line selected the metadata-free client-replay fallback even when the audit carried a matching type/scope/content record, dropping quarantine tags and restoring the row injectable. Resolve by row identity before any fallback, and pin the unknown-ID variant with a test.
|
Rework at Residual F2 — unknown explicit Pinned as requested: new test "restore-entry with an UNKNOWN explicit ts still resolves a known quarantined row" alongside the corrected omission case. It fails at the previous head Proof (measured): focused suite 10 pass / 0 fail; |
WhollyMindless
left a comment
There was a problem hiding this comment.
Re-verified 9c754ce8467351d40120b46eb6004c40448dcb02. APPROVE — supersedes my earlier CHANGES_REQUESTED reviews; the reported UI and restore-fallback findings are closed. I authored #207; the bot authored this implementation.
Independent Windows / Bun 1.4.4 results in the isolated checkout:
- The original actual-render probe now produces both
status-deletedandstatus-quarantinedfor the quarantined deleted row. - Actual HTTP restore of the same audited quarantined row with (1) its correct
ts, (2) nots, or (3) an unknown explicit ISOts: all three return 200, retain import/quarantine tags, and produceisInjectable=false. The third case was injectable at the previous reviewed head. - Metadata and viewer suites: 34 pass, 151 assertions, including the new unknown-ID regression, legacy-record behavior and authoritative-origin assertions.
The incremental route change performs the type/scope/content audit lookup after an explicit-ID miss, before choosing client replay. The earlier rendered-row fix and the actual-render assertion remain intact. No further blocking finding in this verification. Scope is the reported restore cases and focused suites, not a fresh full gate or exhaustive audit-history/concurrency review.
At filing, lint, Linux tests and smoke pass; Windows CI is still pending, so this approval is the code-review verdict, not a claim that every merge check has finished. Merge timing remains the maintainer's decision.
There was a problem hiding this comment.
CHANGES_REQUESTED — required context test-windows is red at this head. The failure decides the verdict; the diff never overrides it. The diff itself verified clean (details below).
Re-check at filing (verbatim):
headRefOid: 9c754ce8467351d40120b46eb6004c40448dcb02
lint=pass, test=pass, smoke=pass, test-windows=fail
Failing job: workflow ci, job test-windows (run 41768508972), test\capture.test.ts:978:32 — capture model inheritance (#139) > capture evidence lines carry model= for the model that ran, Expected: "fake/session-model". Same signature as the red test at c9193f9 on #277: the known capture_lag race on main. Untouched by this diff, but a red head is not ready. CI green (or #277 landing plus rebase) re-triggers this review; I will dismiss this CR as a fallen finding when the failure no longer reproduces.
Contract
Closes #207 (author WhollyMindless, trusted human). Spec anchor 62be5c1748331af2 recomputed equal — frozen.
| # | Criterion (verbatim from #207) | Evidence at 9c754ce |
|---|---|---|
| 1 | "Preserve tags, provenance, keywords, issue and status in both deletion paths and restore them through the viewer." | src/store/files/deletions.ts +10 writes tags/kw/issue/status on the audit line; src/viewer/mutate.ts:212-217 same for the viewer delete audit; restoreEntryRoute (src/viewer/server.ts:473-489) resolves all four from the audit line. Tests: test/viewer-restore-metadata.test.ts:116 (logDeletion preserves), :157 (restore with ts), :245 (restore without ts). |
| 2 | "Make quarantine visible in deleted-entry UI and avoid implicitly treating restore as quarantine approval." | src/viewer/page.html deleted+quarantined renders both badges (stCell); restore modal warns "re-adds it STILL QUARANTINED"; /api/data deleted rows carry tags + quarantined (server.ts deletedRows + isQuarantined). Restored row isInjectable=false (test :157, :245). |
| 3 | "Resolve authoritative deletion data where possible rather than trusting client-supplied provenance." | src/viewer/server.ts:472-474: `(body.ts && deletionAuditFor(ts)) |
| 4 | "choose a fallback for old audit entries without this metadata" | Absent metadata writes nothing on delete; client-replay fallback (#129) survives only when no audit line matches — tested at :274-area legacy test; absent-ts legacy request now resolves the record. |
WhollyMindless review 5762720727 — disposition
- Held at 4c18678. Independent probe on macOS/Bun (same synthetic quarantined row, real HTTP): restore with
ts: "2000-01-01T00:00:00.000Z"+ matching type/scope/content →tags=undefined issue=undefined injectable=true. Quarantine released via wrong ts, exactly as reported. - Closed at 9c754ce. Mutation test: reverting
server.ts:472-474to the old ternary fails the new pin testrestore-entry with an UNKNOWN explicit ts still resolves a known quarantined row(1 fail, stated reason); fixed head 10 pass / 0 fail. WM's CR 5762720727 finding is verified resolved at this head — the block is WM's to clear.
Commands run (measured)
bun run typecheck— 0 errorsbun run lint— 131 infos, 0 errors; format cleanbun run test— 968 pass / 19 skip / 0 failbun run test:e2e— 30 pass / 0 failbun test test/viewer-restore-metadata.test.ts— 10/0; mutation revert of the fix → 1 fail- Diff scope via
git diff --numstat 67e23ee..HEAD: 6 files, tests purely additive (+367/−0 at 4c18678; +31 at 9c754ce). No.skip, no.only, no weakened assertions.
Findings
- P0: none in the diff at this head.
- P1: none in the diff at this head.
- Blocker:
test-windowsred at this head (capture race on main, not this PR's path).
|
Review-state clarification: my current verdict remains APPROVE at I attempted to formally dismiss my first old review via GitHub's review-dismissal API, but it returned HTTP 404. I cannot complete that state cleanup through the available access; the maintainer may need to dismiss those two historical reviews if the fixer counts them despite the later approval. I have not dismissed or changed anyone else's review. Separately, I checked the failing Windows job: its one failed test is |
|
Rework at head Findings disposition:
Measured at
|
Resolved at 784850d: verdict rested solely on red test-windows at 9c754ce (capture.test.ts:978:32 Expected fake/session-model, known main-side capture_lag race). At this head all four required checks pass incl test-windows; local capture.test.ts 41/0. PR content byte-identical to 9c754ce (head moved by merge of main only).
There was a problem hiding this comment.
Verdict: APPROVE at head 784850defc78fd370d9292f122083d773c6acf1f (diff key 24ae4544c796b774c182a97e8273863900dd375f8f31ab1031d39e1a60332975).
Contract: #207 (authored by trusted WhollyMindless), spec anchor 62be5c1748331af2 == current body hash → frozen. Scope criteria from the issue, verbatim, with evidence:
- "Preserve tags, provenance, keywords, issue and status in both deletion paths" —
src/store/files/deletions.ts:31-40(logDeletion writes tags/kw/issue/status) andsrc/viewer/mutate.ts:209-219(viewer audit writes the same set). Pinned by test/viewer-restore-metadata.test.ts (10 tests, green at this head). - "restore them through the viewer" —
src/viewer/server.tsrestoreEntryRoute resolvesDeletionAuditMetafrom the audit line viaauditMeta(ts-first, then type/scope/content fallbacks); restored row carries tags/kw/issue/status. - "Make quarantine visible in deleted-entry UI" —
src/viewer/page.htmldeleted-row status cell rendersquarantinedbadge whenm.quarantined;/api/datadeleted entries carryquarantined. - "avoid implicitly treating restore as quarantine approval" + "Resolve authoritative deletion data where possible rather than trusting client-supplied provenance" —
src/tools/schema.ts:244-256: metadata fields deliberately NOT inRestoreEntryBody; server replays only what the audit carries, so a client cannot launder quarantine or forge provenance. Legacy fallback (no audit line) documented and tested.
Why my prior CHANGES_REQUESTED (5762947109) is dismissed: it rested solely on red test-windows at 9c754ce — test\capture.test.ts:978:32 Expected "fake/session-model" Received "undefined", the known main-side capture_lag race (WM diagnosis 6622741630 concurs). At this head the failure does not reproduce: all four required checks pass, and locally bun test test/capture.test.ts = 41 pass / 0 fail. PR content is byte-identical to 9c754ce: git log 9c754ce..HEAD --no-merges shows only main's commits; the only test-tree delta from the merge is main's added test/viewer-unblock-noop.test.ts (+124, no test removed). Diff key moved because main's mutate.ts hunks (#209) shifted the base, not new PR work.
Commands run at this head (measured):
bun run typecheck→ 0 errorsbun run lint→ 0 errors, 131 infos (= baseline)bun run test→ 952 pass / 19 skip / 0 fail, 93 filesbun run test:e2e→ 30 pass / 0 fail- PR test files read: no deleted assertions, no
.skip, no widened tolerances.
Review-state note: WhollyMindless' two earlier CHANGES_REQUESTED on this PR were explicitly superseded by his own APPROVED 5762902609; no unresolved human changes-requested stands against this head.
Final gate re-check (verbatim): headRefOid 784850defc78fd370d9292f122083d773c6acf1f; checks [{"bucket":"pass","name":"lint"},{"bucket":"pass","name":"test"},{"bucket":"pass","name":"test-windows"},{"bucket":"pass","name":"smoke"}].
Findings: none P0/P1. Human merges.
|
A possible behavior to investigate before merge. This isn't a change request, and it doesn't change my earlier review. It's a note for the maintainer, who can decide whether it matters. At
Only rows written before metadata refusal, or edited by hand, should be able to hold such values. On main the audit line already copies Not established: this was one synthetic row on Windows. I didn't look for such rows in a real store. It came from an AI-assisted local review. |
|
Verified your measurement against the tree at 784850d — it holds, and I reproduced it independently on macOS/APFS. Repro (synthetic legacy row written directly to
Code confirms the mechanism: Two observations beyond your note:
Main already copies |
|
🎉 This PR is included in version 0.15.23 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Closes #207
What changed
Deletion paths retain the metadata. Both audit writers —
logDeletion(src/store/files/deletions.ts, thememory_forgetpath) and the viewer delete/edit audit (src/viewer/mutate.ts) — now recordtags,kw,issueandstatusalongside the #129 origin stamp, as comma-joined scalars matching the memory-line format. Absent metadata writes nothing, keeping legacy lines byte-identical in shape.Restore resolves the store's own record, not the client.
RestoreEntryBody(src/tools/schema.ts) gains an optionalts— the deleted row's identity — and deliberately NO metadata fields.restoreEntryRoute(src/viewer/server.ts) looks the deletion audit line up by that ts and restorestags/kw/issue/status— and therepo/repoPathorigin stamp — from the audit line itself. A client cannot launder a quarantined row into an injectable one or forge a provenance the audit does not carry. No ts, or no matching line: the documented legacy path (#129 client replay, no metadata), unchanged.Quarantine is visible.
/api/datadeleted entries now carrytagsand aquarantinedflag; the deleted-row UI renders aquarantinedbadge next todeleted, and the restore confirmation warns that the entry comes back STILL QUARANTINED — releasing quarantine stays the deliberate, reason-requiredrelease-quarantineaction.Acceptance criteria → evidence (test/viewer-restore-metadata.test.ts)
quarantine, kw, issue, statusopen)isInjectable(restored) === false— the restored row stays withheld from injectionAll requirements taken from the issue body; no comment amended the contract (only the triager's spec-hash anchor,
osi-spec-hash: 62be5c1748331af2, which matches the current body).Proof (measured)
67e23ee49fe7251fe47cf54342fa76060e78e67f): 0 pass / 7 fail (defect present, each test fails for its stated reason). On this branch: 7 pass / 0 fail.bun run typecheck: clean.bun run lint: exit 0.bun run test: 946 pass / 19 skip / 0 fail (965 tests, 92 files).bun run test:e2e: 30 pass / 0 fail (30 tests, 8 files).Deliberately not changed
editedaudit action's semantics and the deleted-list inclusion of superseded versions (pre-existing behavior; the metadata addition is uniform across both actions).assertViewerWriteAllowed(Viewer editor writes bypass the write gate: blocked content can be re-appended and stored #222 rejection probe) — untouched.ts— kept byte-compatible so existing callers and tests behave exactly as before..github/workflows, no rulesets, no other tickets' files.