feat(review): Tripwires — passive alerts when a diff touches sensitive code#862
Open
backnotprop wants to merge 2 commits into
Open
feat(review): Tripwires — passive alerts when a diff touches sensitive code#862backnotprop wants to merge 2 commits into
backnotprop wants to merge 2 commits into
Conversation
…ode (#slop-free-zones) A repo-committed .plannotator/tripwires.json declares sensitive files (globs) and optional symbols. When a review diff touches them — adds, edits, deletions, renames, even binary or chmod-only changes — the hit surfaces passively in the review UI: an amber glyph in the diff gutter, the file tree, and the file header, plus an entry in the annotation sidebar with the rule's note and click-to-jump. Core design: - packages/shared/tripwires.ts: pure, zero-import evaluation engine. Glob matching runs on a linear backtracking-free NFA (immune to ReDoS from hostile configs — relevant in fork-PR mode) with a 256-char glob cap. Unified-diff parser tracks both sides, rename headers, /dev/null, C-quoted paths, binary stanzas, and mode-only changes. 48 unit tests. - Hits are injected as external annotations (source "tripwire") and re-evaluated on every patch change: diff switch, PR switch, PR scope. Fail-open everywhere: a malformed config never breaks a review. - Dual runtime: Bun server + Pi server (shared module vendored via vendor.sh); clearBySource added to both annotation handlers. - Tripwires are informational only — excluded from feedback sent to the agent and from annotation count badges. - Docs guide + launch blog post on the marketing site. Includes this repo's own tripwires.json (dogfooding): annotation pipeline, review server core, Pi vendor list, feedback submission path.
879ed46 to
5739004
Compare
Re-orients tripwire config around a private global store with repo-level opt-in, and adds the management surface: - Global default: <dataDir>/tripwires/<project-key>.json, keyed by normalized remote URL (clones, worktrees, and PR checkouts share one file) with git-common-dir fallback for remote-less repos (incl. a git<2.31 fallback). Auto-created empty on first review. - Repo .plannotator/tripwires.json honored as team opt-in, never created implicitly; merged additively after global rules with id dedup. - plannotator tripwires list|add|validate|path. `add` is dual-mode: structured flags write directly (global default, --repo for the committed file — the one explicit repo write); free text prints agent instructions (explore repo -> globs/symbols -> write -> validate). - plannotator review --tripwires/-t prints a live scan (rules + which wires the current diff trips) and --add-tripwire <description...> prints the add instructions; both short-circuit before any server or browser startup, in all three runtimes (Bun/OpenCode/Pi). PR scans short-circuit before paying for a checkout. - Review-phase fixes: ReDoS-safe report dedup, launch-repo keying in PR mode, NUL bytes in dedup keys escaped (file was binary-classified). - Docs + skill + blog updated to the global-first story. 1354 tests pass; e2e smoke covers add/add --repo/list/validate/prompt and both review flags.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Tripwires let you declare slop-free zones — files and symbols that should never be casually touched. When a code-review diff crosses one, the hit surfaces passively in the review UI:
No banners, no modals, no approve-gating. Tripwires are informational only: excluded from feedback sent to the agent and from annotation count badges.
Where rules live (two layers, global-first)
~/.plannotator/tripwires/<project-key>.json, private to your machine, auto-created empty on first review. Keyed by normalized remote URL so your clone, every worktree, and PR checkouts share one file (git-common-dir fallback for remote-less repos, incl. git <2.31). Nothing is ever written into your repo..plannotator/tripwires.jsonis honored if present and merged after global rules. Plannotator only creates it via the explicittripwires add --repo.{ "rules": [ { "globs": ["src/billing/**"], "symbols": ["chargeCustomer"], "note": "Money path" } ] }Any touch trips: added/edited/deleted lines, renames, file deletions, binary changes, chmod-only changes. Symbol rules fire when the symbol appears in any changed line or its enclosing function context.
Managing rules
In-agent:
/plannotator-review --tripwires(-t) prints a live scan instead of opening the UI;--add-tripwire <description...>prints rule-authoring instructions for the agent. Both short-circuit before any server/browser startup, in all three runtimes (Claude Code/OpenCode/Pi); PR scans short-circuit before paying for a checkout.How it works
packages/shared/tripwires.ts— pure evaluation engine (vendored to Pi). Glob matching on a linear backtracking-free NFA (ReDoS-immune; relevant since fork-PR mode can evaluate hostile configs) with a 256-char glob cap. Diff parser handles both sides, renames,/dev/null, C-quoted paths, binary stanzas, mode-only changes.source: "tripwire"), cleared + re-evaluated on every patch change in both runtimes. Fail-open everywhere — both layers fail independently; a malformed config never breaks a review.Verification
--repo/list/validate, both review flags, no-browser short-circuit