Skip to content

Screen init's repo-derived rows for injection-shaped text - #372

Merged
abogartz merged 1 commit into
mainfrom
302-init-quarantine
Nov 9, 2026
Merged

abogartz merged 1 commit into
mainfrom
302-init-quarantine

Conversation

@abogartz

@abogartz abogartz commented Nov 9, 2026

Copy link
Copy Markdown
Owner

What this does

Three paths write memories from text the plugin did not compose: auto-capture (mines the conversation), import (reads a portable file), and /repo-init (reads the repository). The first two scan their candidate for injection-shaped text and tag a match quarantine, which keeps the row out of recall and out of the prompt. Init did not — it went straight to the write gate.

That matters because both halves of an init row are external text:

  • the scope is the checkout directory's name;
  • the command comes from package.json / Makefile.

So a clone sitting in a directory named eval (x) — which matches the dynamic_execute injection pattern — produced a memory that was promoted with no quarantine tag, and because init rows carry no [via ...] provenance marker it rode into every later session of that repository with nothing to distinguish it from a command the plugin had verified.

Init now calls the same quarantineCandidate scan the import path calls. A match is still stored — nothing is silently dropped — but it is tagged and withheld, exactly like a quarantined capture or import row, and it shows up in the viewer's quarantined filter for a human.

One extension beyond the ticket

The ticket named the script rows. The init stamp row interpolates the same directory name (Init stamp: repo=eval (x), head=…), so it gets the same scan; leaving it unscreened would have left one untagged injection-shaped row per init. The test pins that this does not break idempotency: init still reads its own quarantined stamp and reports Already initialized on the second run.

Tests

  • RED first: in a fixture directory named eval (x), the promoted script row carried ["init", "package.json"] — no quarantine tag.
  • GREEN: the script rows carry quarantine plus the matching quarantine:<id> tag, the stamp row is screened too, and the second init is still a no-op.
  • The clean fixture (plain repo directory, ordinary scripts) still promotes untagged rows, so nothing changed for a normal checkout.

bun run gate green: 1131 unit tests + 30 terminal/BDD tests against a real host, 0 fail. bunx tsc --noEmit clean; lint and format identical to main's baseline.

Closes #302.

Auto-capture and import screen their candidate for injection-shaped text; init
went straight to the write gate. Both halves of an init row are external text:
the scope is the checkout directory basename and the command comes from the
manifest, so a clone in a directory named "eval (x)" promoted a row with no
quarantine tag and no [via ...] marker, into every later session of the repo.

Init now calls quarantineCandidate, the same shape import uses. The stamp row is
screened too: it interpolates the same basename, and leaving it unscreened would
keep one untagged injection-shaped row per init. Screening does not break
idempotency — init still reads its own quarantined stamp.
@abogartz

abogartz commented Nov 9, 2026

Copy link
Copy Markdown
Owner Author

Adversarial self-review (author-side, not independent)

Followed the quarantined row through the gate and through initStamp. The PR is right, but the fix has a blind spot it does not mention, and one merge-order trap with #368.

Verified clean:

  • quarantineCandidate scans scope as well as content (the Quarantine: scan imported/captured scope text as well as content #205 widening), so a directory name that matches is caught even though it also interpolates into content. Hits merge and dedup; provenance tags survive.
  • Idempotency holds for the reason the test claims: initStamp() reads raw rows by the init-stamp tag with no visibility filter, so a withheld stamp still satisfies the HEAD check. The second-run "Already initialized" pin is the right pin.
  • Store-don't-drop is real: the quarantined row goes through the normal gate, lands in the day file, and is reachable by the viewer's quarantine filter.
  • Clean-fixture pin (plain repo dir promotes untagged) proves no behavior change for normal checkouts. CI green on all four jobs.

Findings:

  1. 🟡 The fix does not remediate stores already poisoned, and force cannot. Gate exact-dedup (gate.ts, exactPoll) compares type + content only — tags are not part of the match. So on a store that already holds the untagged row from a crafted checkout, a re-init (even force: true) produces a byte-identical candidate that collapses into the old untagged row: the quarantine tag never reaches the store and the row keeps injecting. The PR is still correct as scoped — new inits are screened — but Run init-captured rows through the quarantine scan #302 should not be the last word. File a follow-up: a one-time rescan that re-tags existing rows whose content or scope matches quarantinePatterns, or at minimum document memory_forget + re-init as the operator remedy.

  2. 🟡 Merge-order trap with Drop the code-graph integration from /repo-init #368. Both branches edit src/init/run.ts in the same two regions: the import block (Drop the code-graph integration from /repo-init #368 deletes graphEnabled, Screen init's repo-derived rows for injection-shaped text #372 adds quarantineCandidate beside it) and the stamp write (Drop the code-graph integration from /repo-init #368 rewrites stampContent, Screen init's repo-derived rows for injection-shaped text #372 wraps that runWriteGate call). Each is individually clean against main per merge-tree, but whichever lands second takes a mechanical conflict in run.ts. Suggest landing Screen init's repo-derived rows for injection-shaped text #372 first — its stamp-line wrap survives Drop the code-graph integration from /repo-init #368's stampContent rewrite as a two-line resolution, and the resolution is exactly what Drop the code-graph integration from /repo-init #368's reviewer already patterned.

Verdict: approve the code; finding 1 needs a follow-up ticket before #302 closes the risk, and finding 2 needs a merge order, not a code change.

@abogartz

abogartz commented Nov 9, 2026

Copy link
Copy Markdown
Owner Author

Finding 1 filed as #375 (re-tag rows stored before this screen; force cannot remediate them because exact-dedup matches type + content only). Finding 2 accepted as merge order: this PR lands before #368.

@abogartz
abogartz merged commit f4d32b8 into main Nov 9, 2026
4 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.22.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@abogartz

abogartz commented Nov 9, 2026

Copy link
Copy Markdown
Owner Author

Merged into main at f4d32b8 with admin override (solo author). Landed in the order the self-review set: this PR before #368. The review's follow-ups are tracked separately (#375 for the re-tag scan; the optional nits were left as written).

abogartz-opencode-self-improvement Bot pushed a commit that referenced this pull request Nov 12, 2026
## [0.23.1](v0.23.0...v0.23.1) (2026-11-12)

### Bug Fixes

* **init:** finish the re-tag when the gate collapses or retirement rejects ([61cc019](61cc019)), closes [#378](#378) [#155](#155)
* **init:** keep the init stamp out of the memory store ([#374](#374)) ([27e74e8](27e74e8))
* **init:** make the legacy init-stamp row inert, and make its migration report the truth ([805bc6c](805bc6c)), closes [pre-#374](https://github.com/pre-/issues/374)
* **init:** re-tag rows stored before the injection screen ([#375](#375)) ([ab1b3ac](ab1b3ac)), closes [#372](#372) [#372](#372)
@abogartz
abogartz deleted the 302-init-quarantine branch November 19, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run init-captured rows through the quarantine scan

1 participant