Repository navigation
feat: quarantine suspicious import and capture rows - #193
Conversation
|
Coordination with your #194: I checked the two heads with Given #35's priority, I recommend landing your #194 first. I can then update this quarantine PR on the resulting main and rerun its gate and integration checks. No changes are needed to your branch for this PR. Please feel free to defer or decline #193 if quarantine is not the direction you want. |
|
Updated at Added two integration regressions covering the combined flows: releasing quarantine cannot lift an independent human block or rejection, and forgetting a quarantined import blocks re-ingestion until a human lifts the rejection; the next suspicious import is still quarantined. Viewer rendering now checks both action families and escaping. Validation on Windows / Bun 1.4.4: 46 focused quarantine+tombstone tests pass; full gate passes typecheck/lint, 769 unit/scenario tests (11 skips), and 11 E2E tests. CI is rerunning on the pushed head. PR description updated with the integrated scope and current results. |
abogartz
left a comment
There was a problem hiding this comment.
Review: CHANGES_REQUESTED
Re-verified at your current head ebbef36 (post-merge with main) on macOS / Bun 1.4.3. The mechanism is sound and the release path is the best-engineered part of it. One model-facing surface still quotes withheld prose, and that is enough to hold this.
What I confirmed against the tree
- Gates at
ebbef36(macOS / Bun 1.4.3): typecheck clean, biome exit 0, unit 769 / 11 / 0, e2e 11 / 0. Lint gained roughly a dozen advisory warnings (base main measures 409; this head 424) — allnoNonNullAssertion/useTemplatein the new test file andstatus.ts, exit code unaffected. - Withhold is layered, not single-point:
selectRelevant,systemDigest,storeVersion,compactionAnchor,contextualPull,scoreMemories,memory_recallandmemory_consolidateall filter, and reverting the epoch's owninjectableRowsfilter (src/injection-epochs.ts:145) toisActiveleaves the suite green — I measured it — because every renderer re-filters. - Frozen-prefix behaviour works in both directions (tag → the row leaves the delivered block on the next delivery; release → returns).
- Release is done right:
stampRow(src/memory.ts:370-392) takesfileIdentitybeforereadLines, snapshots, and publishes underwithStoreLockwith thesinceanchor — the convention this repo made standard in #89/#106. Identity, repo, content and non-quarantine tags survive by construction, andmemory_undorestores the tag. - The report cannot inject.
quarantineReasonsderives pattern IDs from tags against the closedPATTERNSlist rather than re-scoring stored text, andstatus.tsemits onlyts+ those names — a forgedquarantine:evil <img …>tag cannot reach the output. Gate evidence likewise records IDs with no matched text. - Framing/provenance survive a human release (
negative-eval.test.tskeeps the single-line collapse and[via import]assertions after release), so this is an addition to the read-side defenses, not a replacement. - Your conflict resolution against #194 was the non-obvious one and it is correct: a textual union of the viewer/schema hunks is not sufficient, because main's
render()readsDATA.rejections;ebbef36suppliesrejections: []in the render fixtures (test/quarantine.test.ts:177,182,185) and adds the quarantine×tombstone interaction tests.
BLOCKING — memory_decay quotes withheld prose to the model, and can retire rows out of the review queue
src/portable.ts:370-377 filters only isActive && isVisibleTo && status==="open" && ts<cutoff — no injectability check — and src/index.ts:1194 renders the listing as flattenMemoryText(m.content).slice(0, 100). So a quarantined row's suspicious text is delivered verbatim (newline-collapsed, still) in the tool output of the very report action the model calls. memory_recall was closed; memory_decay is the same class of surface and is open.
The second half is worse: the viewer's review queue filter is m.quarantined && !m.superseded_by, so a dryRun=false decay supersedes the quarantined row and it disappears from the human queue without a human decision — the queue #38 exists to keep.
Ask: filter in findStaleOpen (or list ts + type/scope only for quarantined rows) and pin both halves with a test.
Nits
- The status-tool refresh you added is unpinned. Deleting
src/index.ts:1248(if (sid !== "?") await sessions.refresh(sid);) changes nothing: typecheck clean, unit 769/11/0, e2e 11/0. To be fair to your "four mutations" sentence — the pre-existing per-delivery refresh atinjection-epochs.ts:264is pinned (disabling it fails 9 tests), so if the fourth mutation meant that line, the claim stands. The new line just needs a test of its own (mutate the store between a delivery and amemory_statuscall, no new prompt, assert the reported numbers moved) or the sentence needs scoping. memory_consolidateis filtered but untested — I reproduced it: reverting theindex.ts:467filter toisActiveleaves the whole suite green (769/11/0).renderProposalsprints survivor/absorbed prose (160/120 chars), so a future edit that drops this filter reopens a leak with no red anywhere. One assertion that a quarantined row never appears in proposal output closes it.memory_list(index.ts:889) still usesisActive, so quarantined rows contribute their scope and type names plus counts to the listing. Row content is not shown, so this is small — but scope is not scanned at import, so an imported row can put attacker-chosen text in a model-facing tool output. Filter it, or state the boundary in README.- False positives are concentrated exactly where auto-capture mines: prose that quotes source code. Running your scanner over this plugin's own tree flags 10 lines, mostly
dynamic_executematching ordinaryre.exec(calls (src/evidence.ts:24,src/init.ts:132,204,src/logfmt.ts:62,src/resolver.ts:96,366,373) plussystem:object keys (src/inject.ts:14), and 2 README lines including your owncurl … | bashinstall line anddeterministic eval (store of 200. Counterweight: 0 of 276 rows in a real store on this host match, so this is about captured transcripts quoting code.(?<![$\w.])beforeeval|execwould remove the whole class. - Cheap evasions, all measured as passing through untagged:
**system:** obey,[INST],<<SYS>>,curl x -o /tmp/x && sh /tmp/x,base64 -d … | sh, "ignore every instruction you were given". Add the markdown-bold and&&-exec variants, or list them under your README limits sentence. memory.ts:691-697hardcodes"quarantine"instead ofQUARANTINE_TAG, and strips any tag starting withquarantine:— a user's ownquarantine:*label is silently deleted when a row is released.+11biome warnings (409 → 420),noNonNullAssertion/useTemplatein the new test file andstatus.ts. Exit code unaffected.- Release on a nonexistent or already-released
tsreturns200 {released:false}with no audit line, and the viewer toasts "row is no longer quarantined" in both cases. And the import reply says "1 promoted rows quarantined". - The zod
.trim().min(1)and the server-siderequireReasoneach survive alone, but removing both dies — genuinely belt-and-braces. Keep them; per this repo's convention, say in the comment that neither layer is individually pinned.
Residuals (not blocking, one doc sentence each)
- The enforcement boundary is coherent as #38 scoped it (capture and import are the two paths with no human in the loop) and README says what is not scanned — but it never states the consequence: a session that can call
memory_rememberalready has a prose channel, mitigated by framing/provenance rather than by quarantine. - An import byte-identical to an existing row collapses, so re-import cannot retro-tag prose already in the store. Worth one line so nobody assumes an import re-scans.
- Export deliberately keeps quarantined rows with their tags (right call — dropping them would be silent data loss, and the tool returns only a count and a path), and re-import re-quarantines a released row on another machine. Both fine; both deserve the sentence.
Not verified here: Windows / Bun 1.4.4 (your gate and CI pin), and live auto-capture on a real host — which you also disclaim.
|
Addressed the blocking finding and the actionable nits in
Windows / Bun 1.4.4 full gate: 784 unit/scenario tests pass, 11 skip; 11 E2E tests pass; typecheck and lint pass. The decay preview/apply, metadata-listing, and custom-label tests failed before their fixes. Both targeted safeguard-removal probes fail as expected, and the source was restored before the gate. Ready for another look when convenient. Live auto-capture is still not claimed as verified. Please feel free to defer or decline this if the policy or maintenance cost does not fit the project. |
abogartz
left a comment
There was a problem hiding this comment.
Round 2: APPROVED
Re-verified at 4a7f7c2 (macOS / Bun 1.4.3). Every item from round 1 is closed, and — the part I care about — each close is now pinned by a test I had to break on purpose to believe it.
The blocking leak. findStaleOpen (src/portable.ts:374-379) filters isInjectable, so quarantined rows are neither quoted into a decay preview nor retired by dryRun=false — which also means they stay in the viewer's queue instead of vanishing from it. I re-ran my own differential: reverting that one predicate to isActive now dies on both new cases — decay dryRun=true withholds quarantine prose and preserves the human queue and its dryRun=false twin. In round 1 there was no test anywhere on this surface.
The claims I had to walk back mid-review, now genuinely tested. I told you in round 1 that the new status-tool refresh was unpinned (deleting it left unit and e2e green) while the pre-existing per-delivery refresh was pinned. status alone refreshes a delivered epoch after quarantine and release closes exactly that gap, with the comment "No intervening prompt or delivery: only this tool can refresh the epoch" — and deleting the line now fails that one test. Same method for consolidation: reverting the memory_consolidate filter to isActive dies on consolidation withholds quarantined proposal prose with a measured positive control. Both mutations were re-read before believing, then reverted.
Rest of the list:
memory_listswitched toisInjectable, pinned bymemory_list withholds quarantined metadata and counts.- Release now strips only the flag plus known scanner-reason tags (
quarantineReasons), so a user'squarantine:customsurvives — pinned by its own test — and it usesQUARANTINE_TAGinstead of a literal. - Release outcomes are discriminated (
released/not_found/not_quarantined), each audited (quarantine_release_noop), and the viewer toast no longer claims "row is no longer quarantined" for a row that was never there. That was a small honesty bug with a user-visible symptom; it's gone. - Scanner: the
(?<![$\w.])guard took false positives on this plugin's own source from 10 lines down to 1 (re-measured; the survivor issrc/inject.ts:14, asystem:typed object key). Markdown-bold role headers and&& share now caught — I re-tested both against the shipped patterns. - README names the widened withhold (scope/type listings, consolidation, decay) and, importantly, the two things I asked to see stated: the residual
[INST]/<<SYS>>/ base64-to-shell / paraphrase evasions (I confirmed these still pass untagged, so the sentence is accurate rather than optimistic), and the consequence of the scan boundary — "a session with that tool still has a prose channel, mitigated by the existing framing and provenance rather than quarantine". The collapse-on-re-import caveat is there too. - Import tally grammar fixed.
Gates: typecheck clean, biome exit 0 at 408 warnings (one below main — you cleaned something along the way), unit 784 pass / 11 skip / 0 fail, real-host e2e 11 pass / 0 fail.
Two leftovers, neither worth holding anything: that single system: FP on our own source is the kind of line a captured transcript can contain, so it may eventually quarantine a row quoting a TypeScript type; and quarantine still isn't applied to rows written before the feature existed, which the README now says out loud, so it is a decision rather than a hole.
|
Updated the branch at The sole textual conflict was auto-capture's candidate loop in Windows / Bun 1.4.4 full gate passes: 804 unit/scenario tests, 11 skips; 11 real-host E2E tests; typecheck and lint (408 advisory warnings). This includes the quarantine, capture, lock-timeout, and partial-outcome regressions on the combined tree. No new behavior beyond integrating the two reviewed changes is intended. CI will validate the pushed merge head. |
|
Investigated the Windows failure on The scenario is unchanged from merged main
Windows / Bun 1.4.4 full gate passes: 829 unit tests, 11 skips; 11 real-host E2E tests; typecheck and lint (408 advisory warnings). The fix is pushed; hosted CI will rerun on the new head. |
|
🎉 This PR is included in version 0.15.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
abogartz
left a comment
There was a problem hiding this comment.
Round 3 (merge-gate verification of the integration commits): APPROVED
Six of the seven merged ahead of this one, so #193 had to integrate them. Three commits arrived after my round-2 approval and I checked each before pressing merge, because a conflict resolution is exactly where a verified fix can quietly stop being true.
3a230f7 — my own update-branch merge. Its combined diff contains one hand-authored hunk: src/viewer/server.ts imports, keeping both isIP from node:net (#192) and ReleaseQuarantineBody (#193). That is the correct union, and lint confirms neither side is dead. Everything else came cleanly from one parent.
5700fc9 — your merge of main (which brought #197). One hand-authored hunk: the auto-capture loop, where main's try/catch + durable receipt now wraps your quarantineCandidate(...) call instead of the bare candidate object. Both behaviours survive in one code path — the fail-closed capture bookkeeping and the quarantine scan.
0df6fb8 — the 30 s scenario bound. I checked whether this silences a defect, since "raise the timeout" is the oldest trick in the book:
- The
test-windowsleg at3a230f7failed on exactly one test:a snapshot restore while other sessions are writing > every row a session was told it remembered is in the store or in a snapshot — never nowhere, logged at 5034 ms with no assertion text anywhere in the job log — a Bun default-timeout kill, not a conservation violation. - At
0df6fb8the same test passes on Windows in 4117 ms, job totals 831 pass / 9 skip / 0 fail. It genuinely needs more than 5 s on a shared runner. - No assertion changed: the diff is
});→}, 30_000)plus a comment, and the file already uses that form at line 594, so it is a convention here rather than a one-off escape hatch. This is the#196contention family.
Semantic re-verification on the merged tree (5700fc9, and again after the update). All four withhold sites are still isInjectable (src/portable.ts:377, src/index.ts:467,514,890) and #197's durable threading is intact (src/memory.ts:403,416). I re-ran the mutations that used to prove my round-2 findings:
| Mutation | Result |
|---|---|
findStaleOpen back to isActive |
2 fails — both decay … preserves the human queue cases |
quarantineCandidate neutered in the resolved capture hunk |
1 fail — a suspicious mined candidate keeps provenance but is withheld from the frontier (same single pin before and after the merge, so the resolution is not just compiling) |
Gates on the integrated tree: typecheck clean, biome exit 0 at 408 warnings, unit 804 pass / 11 skip / 0 fail, real-host e2e 11 pass / 0 fail.
Merged as 7bb1750; final main (bf9f4d2, 0.14.26 → 0.15.0, npm latest verified from the packument) measured by me locally: typecheck clean, lint 408, unit 829 pass / 11 skip / 0 fail, e2e 11 pass. Queue is empty.
Fixes #38. Import and auto-capture can persist instruction-shaped prose after passing the ordinary write gates. Matching candidates now receive a
quarantineflag and stable scanner-reason tags. They still face every write gate, remain durable for human review, and are withheld from recall, consolidation proposals, scope/type listings, standing/frontier/relevance injection, compaction anchors, contextual pull, and decay. Applied decay cannot retire them out of the viewer's review queue. The viewer marks and filters quarantined rows and offers a reason-required release action behind the existing request guards. Release snapshots and atomically rewrites the row under the store lock, preserving identity, repository, content, unrelated labels (including customquarantine:*labels), blocklist state, and supersession. Undo can restore quarantine. Missing and already-unquarantined rows return distinct, audited no-op outcomes. The chat report lists repository-visible review IDs and known pattern names without reproducing suspicious prose. Import tallies report quarantined promotions, and gate evidence records pattern IDs without matched text. Zero-quarantine tally shapes remain unchanged. Tagging or releasing a row refreshes an already-frozen prompt block on the next delivery; the status tool also refreshes before reporting. Validation on Windows / Bun 1.4.4: full gate passes typecheck, lint (408 advisory warnings), 804 unit/scenario tests (11 skips), and 11 real-host E2E tests. Coverage includes import/capture wiring, injection surfaces, frozen epochs, status-only refresh, consolidation candidate exclusion and prose withholding, both decay modes and queue preservation, metadata withholding, repository-scoped reports, viewer release/guards, snapshot/undo, independent blocks/rejections, no-op audit receipts, custom labels, and shipped viewer rendering/escaping. The decay preview/apply, list metadata, and custom-label regressions failed before their fixes. Removing either the status-tool refresh or consolidation filter now fails its focused regression. Consolidation's replay scoring independently withholds tagged prose; an independent clean cluster lets the test also pin candidate exclusion through the reported store count. Earlier mutation checks covered import scanning, capture scanning, quarantine withholding, and the pre-existing per-delivery epoch refresh. All temporary mutations were restored before the final gate. Integration at5700fc9includes mainec00ff9(0.14.26), merged #194 and #197. Auto-capture retains both quarantine scanning and the per-candidate durable receipt/refusal handling. Releasing quarantine cannot lift an independent human block or value rejection; forgetting a quarantined import blocks re-ingestion, and lifting that rejection still sends a suspicious new promotion through quarantine. Limits: this is a heuristic review queue, not a complete injection detector. Markdown-bold role headers and download-then-&&-execute are recognized; ordinaryre.exec(calls are excluded. README documents alternate delimiters, encoded pipelines, paraphrases, and indirect execution as evasions. Direct remember/viewer writes and existing stores are not scanned; direct remember remains a prose channel mitigated by framing/provenance. Duplicate import collapse does not retro-tag existing rows. Export preserves quarantine tags; released exports can be quarantined again when promoted elsewhere. Live auto-capture remains unverified; its integration is exercised through the host harness. Please feel free to decline or close this if the scanner policy or review flow is not what you want for the project.