diff --git a/docs/superpowers/plans/2026-11-02-phase2-guards.md b/docs/superpowers/plans/2026-11-02-phase2-guards.md index 6004ff3..cbf8113 100644 --- a/docs/superpowers/plans/2026-11-02-phase2-guards.md +++ b/docs/superpowers/plans/2026-11-02-phase2-guards.md @@ -1,4 +1,8 @@ -# Phase 2 guards Implementation Plan — r2 +# Phase 2 guards Implementation Plan — r3 + +r3 = r2 + the confirmation pass (correctness CONCERNS(4), no BLOCKER); its +named changes are in § R3 CHANGES at the end, and take precedence over the +r2 text they amend. > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. @@ -876,3 +880,19 @@ MAJORs closed: MINORs closed: corr 9 (T63 list = approved.txt), corr 10 (ids T62/T63; flip test on a ghost entry holds red and green), corr 11 (widths wrapped), corr 12 (jq precedence, UI write = theme + switchModelsOnFlag move), corr 13 / rob 6 (literal temp path, `bash -n` before the swap, stale comment fixed), corr 14 (bench appends, ids selectable, full run in the background), corr 15 (untracked = payload), corr 18 / rob 11 (`.claude` free only under `/.claude/`, worktrees excluded; Task 9 Step 2 snapshots the live tree), rob 7 (one awk pass for numbers, 512 KiB cap, `--no-ext-diff --no-textconv --no-color`, "no commit" not cached), rob 9 (`sh -*c`, `bash -*c`, `dash -c`, `/usr/bin/bash`, `/usr/bin/sh`, `cat * .env*` rows), rob 10 (declined prompt handled in release STEP 5 and capitalize 5C), rob 12 (user warned at the gate), rob 13 (`sed -E`, shasum fallback, empty hash skips), rob 14 (Task 1 Step 5 `rtk rewrite` per ask form), simp 3 (release tag in the main loop, executor keeps `prep` only), simp 4 (`2|3)` arm, redaction kept), simp 5 (hunk-header numbering), simp 6 (agents not edited), simp 7 (`$.session.root()` inline, the `.catch` fails open). - corr 16 / rob 8 (`Bash(git -C * merge *)` asks on any `git -C … merge …` text, e.g. a sub-agent's commit message): `[USER]` dropped from gated answer 5; `git -C merge` stays a stated residual. - `[USER]` gated answer 7 grows: `cat * .env*` / `cat * */.env*` and the extra shell spellings are added when the bench approves them. + +## R3 CHANGES (confirmation pass, take precedence over the text above) + +- **Task 1 Step 7 gate (conf 1).** A rule is approved only when EVERY row naming it hits its `want` AND at least one of those rows expects ASKED or DENIED. "Keep A1 if it passed, else A1b" stands, under that rule. +- **Bench auto mode (conf 2).** run.sh also reads the stream-json `type=system subtype=init` event and appends its `permissionMode` as a 5th column; a row whose mode is not `auto` is invalid (re-run once, then drop that row's rule). The settings shape adds `"skipAutoPermissionPrompt": true` (the user's own auto setup, CHANGELOG 2.0.0). A control that is not RAN means "classifier-gated, rule unproven": that rule is dropped, the bench is not invalidated. HARD STOP stays only for M3/M3q not ASKED, or for M3q's control not RAN. +- **Task 6 phase2.jq path (conf 3).** The jq program lives at `.claude/tasks/plans/2026-11-02-phase2-bench/phase2.jq` (a free path for the guard, committed with the bench). `settings.pre.json`, `head.json`, `live.json` stay in the job temp dir, written by Bash redirects only. +- **T62b (conf 4).** `check T62b-flip-missing-twin "$(twins_missing "$T62F" | /usr/bin/grep -F ghost.key | sort | paste -sd' ' -)" "Bash(*/rtk read */ghost.key*) Bash(rtk read */ghost.key*)"` — holds red and green. +- **`/route off` drops the latch (conf 5).** In `handleCommand`'s `on|off` branch, next to `if (st.off) st.runMain = null`, add `if (st.off) st.skillRun = false`. New test `GUARD: /route off then on re-arms it`: typed /feat, `/route off`, `/route on`, write of `src/a.ts` → redirected. +- **Task 6 Step 3 check (conf 6).** Replace the `grep -c '^-[^-]'` line by a set check that no old entry left any list: + `jq -n --slurpfile o <(git show HEAD:settings.json) --slurpfile n "$J/head.json" '[["permissions","allow"],["permissions","ask"],["permissions","deny"],["autoMode","allow"],["autoMode","soft_deny"],["autoMode","hard_deny"]] | map(. as $p | ($o[0] | getpath($p)) - ($n[0] | getpath($p))) | add | length'` → `0`. Comma-only `-`/`+` pairs on the old last element of each list are expected. +- **code-limits (conf 7).** Suite expects `PASS=14`. T11 sends a content payload: `fire "$WORK/ours/new.ts" '../x' "$(jq -n --arg c "$big" '{content:$c}')"`. `over_lines` reads whole records and splits on the first tab: `while IFS= read -r rec; do n="${rec%%$'\t'*}"; line="${rec#*$'\t'}"; …`. Deviations recorded: matcher `Edit|Write` (NotebookEdit cannot report: `.ipynb` is outside the extension list); no temp HOME in the suite (the hook never reads HOME: it finds `lib/` from its own resolved path). +- **Task 7 stale text (conf 8).** release-executor.md becomes a single-span agent: description `(prep)`, the "BETWEEN your two spans" and "never chain into the other span" lines rewritten for one span, the OUTPUT block keeps `prep` only (no `finish `, no `main for finish`, no "finish never runs tests" line). release-candidate SKILL.md :29-30 ("A human gate sits BETWEEN the two spans") → "A human gate sits between the prep span and the finish (STEP 4)", :43 names the executor for prep only. capitalize: the declined-prompt line goes under 5C call 1 (finish), and STEP 6 gains the `persisted: no (finish prompt declined, branch kept)` variant. +- **Doc claims (conf 9).** CLAUDE.global.md gitflow insert: ` Ask rules prompt every \`gitflow.sh finish\` and \`git merge\` (a \`git -C merge\` is not covered).` The README "Static rule limits" coverage sentence is written by the controller from approved.txt (only the approved shapes are named). SETTINGS.md cites LRN-155 (2026-09-16, `node -e` probe on 2.1.273), not LRN-146. Task 8 Step 5 grep runs on `CLAUDE.global.md README.md USAGE.md templates skills rules` (not `lib/`: `lib/tests/model-routing.test.sh:67` names the old phrase on purpose). +- **Bench gaps (conf 10).** Rows added: `M3x ask Bash(bash *gitflow.sh finish*) bash "$HOME/nonexistent/lib/gitflow.sh" finish MEASURE` (if ASKED, M3q is redundant but harmless); `A2b deny Bash(awk *system*) awk '{print}' /dev/null RAN`. G1 runs with `--settings '{"permissions":{"allow":["Bash(*)","Agent(*)"],"ask":["Bash(git merge *)"],"defaultMode":"auto"},"skipAutoPermissionPrompt":true}'`. Task 9 Step 1 adds a live row `bash "$HOME/nonexistent/lib/gitflow.sh" finish` (ASKED). The long brief is a file the implementer writes in Task 1: `.claude/tasks/plans/2026-11-02-phase2-bench/long-brief.txt`, about 3000 characters, a pasted multi-paragraph feature request for `doctor.sh` (show the rtk version, warn under 0.23, add a test), in French like the measured briefs; Task 9 Step 2 replays it. +- **Guard edges (conf 11).** `isFreePath` returns false for any path containing `/../` or ending in `/..`. The Skill-hook latch is set after `next(e)` resolves and only when the answer has no `deny`. The registerGuard handler is wrapped so every line stays ≤ 80 columns. Stated limit: an unrowed typed skill latches through the typed-fallback path only when no sub-agent is live (register.ts typedPath); the model's own Skill call latches it anyway. +- **Task 10 folds (conf 12).** Step 2 also requeues TODO "Phase 2 folds: narrow the pre-commit `.claude/**` exemption" as still open (not in this phase's scope).