@soleur/opencode 3.405.9 → 3.405.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,7 +26,7 @@ You verify that every new surface is debuggable from a keyboard without SSH or `
26
26
 
27
27
  ### Step 1: Diff inventory
28
28
 
29
- Run `bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" origin/main...HEAD` and partition its list into (exit 2/127 = inventory unknown: treat every category below as in scope, never as an empty diff):
29
+ Run `bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" origin/main...HEAD` and partition its list into (non-zero exit = inventory unknown: treat every category below as in scope, never as an empty diff):
30
30
 
31
31
  - **Inngest functions**: any file under `apps/web-platform/server/inngest/functions/cron-*.ts` or `*-on-*.ts`
32
32
  - **Server routes / handlers**: `app/api/**/route.ts`, `server/**/*.ts`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soleur/opencode",
3
- "version": "3.405.9",
3
+ "version": "3.405.11",
4
4
  "description": "Soleur AI organization plugin for OpenCode",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,8 +11,11 @@
11
11
  # CONTRACT
12
12
  # Plain mode exit 0 = the list (possibly empty) is on stdout; exit 2 = git failed or usage was wrong. On a
13
13
  # non-zero exit stdout is NOT a list and must not be read as "nothing changed".
14
- # --match ERE grep exit semantics: 0 = at least one path matches (the matches are printed), 1 = none match,
15
- # 2 = git or usage failure. A git failure is NEVER folded into "none match".
14
+ # --match ERE 0 = at least one path matches (the matches are printed), 42 = none match, 2 = git, usage, read or
15
+ # write failure.
16
+ # A git failure is NEVER folded into "none match". Not grep's 1: bash exits 1 on an unbound variable under
17
+ # `set -u` (in the caller's line or in here), and routing that into "none match" would skip the gate. Callers
18
+ # test `[ $? -eq 42 ]` and read every other non-zero rc (1, 126, 127, 128+N) as unknown.
16
19
  # No arguments, or a flag this helper owns but does not support, exits 2 with a usage line on stderr; the helper never
17
20
  # defaults to a diff target of its own.
18
21
  #
@@ -23,7 +26,7 @@
23
26
  # or a committed `ignore=all` is not listed; (4) a bare `$(git diff | tr)` pipe turns a git failure into an empty list.
24
27
  # So: NUL-delimited (`-z`), `--no-renames`, `--ignore-submodules=none`, `git -C <top>` (so `diff.relative=true` cannot
25
28
  # make the names cwd-relative), and `set -o pipefail` so a git failure is a failure. In `--match` mode git runs FIRST and
26
- # its status is checked, then grep reads a here-string: never `grep -q` on a pipe (SIGPIPE 141 would read as failure).
29
+ # its status is checked, then grep reads it through a pipe from printf: never `grep -q` (SIGPIPE 141 would read as failure).
27
30
  #
28
31
  # A name holding a newline cannot be one line of a one-name-per-line list (it would split into extra "paths", and a
29
32
  # gate that ALLOWS on a match can be satisfied by a fragment), so such a diff exits 2: callers treat 2 as unknown and
@@ -85,11 +88,13 @@ fi
85
88
 
86
89
  # Byte locale throughout: the list is raw bytes now, and under a UTF-8 locale GNU grep reports a name holding an
87
90
  # invalid UTF-8 byte as "binary file matches" instead of printing it.
88
- if [ "$(LC_ALL=C tr -dc '\n' <"$tmp" | wc -c)" -gt 0 ]; then
91
+ # Every read of the temp file is checked: a failed read is an empty list, which would read as 42 ("none match").
92
+ nl="$(LC_ALL=C tr -dc '\n' <"$tmp" | wc -c)" || { printf 'changed-paths: cannot read the diff list\n' >&2; exit 2; }
93
+ if [ "$nl" -gt 0 ]; then
89
94
  printf 'changed-paths: a changed path contains a newline; it cannot be listed one per line\n' >&2
90
95
  exit 2
91
96
  fi
92
- out="$(LC_ALL=C tr '\0' '\n' <"$tmp")"
97
+ out="$(LC_ALL=C tr '\0' '\n' <"$tmp")" || { printf 'changed-paths: cannot read the diff list\n' >&2; exit 2; }
93
98
 
94
99
  if [ "$have_match" -eq 0 ]; then
95
100
  # A failed write (full disk, closed pipe) is a failure: a truncated list at rc 0 reads as a shorter diff.
@@ -97,8 +102,13 @@ if [ "$have_match" -eq 0 ]; then
97
102
  exit 0
98
103
  fi
99
104
 
100
- [ -n "$out" ] || exit 1
105
+ [ -n "$out" ] || exit 42
101
106
  # printf into grep (no -q, so grep reads everything and never SIGPIPEs the writer); a here-string would spill to a
102
- # temp file for a large list and an unwritable TMPDIR would skip grep entirely and read as rc 1.
107
+ # temp file for a large list and an unwritable TMPDIR would skip grep entirely and read as 42. A printf failure is
108
+ # unknown (2), including the SIGPIPE a grep that dies early (bad ERE, signal) can send it on a large list; only grep's
109
+ # own 1 is "none match" (42); after a clean printf every other grep status (2 = bad ERE, 128+N) passes through.
103
110
  printf '%s\n' "$out" | LC_ALL=C grep -E -e "$match"
104
- exit $?
111
+ st=("${PIPESTATUS[@]}")
112
+ [ "${st[0]}" -eq 0 ] || exit 2
113
+ [ "${st[1]}" -ne 1 ] || exit 42
114
+ exit "${st[1]}"
@@ -176,7 +176,7 @@ CRITICAL: You MUST output the ## Session Summary section in EXACTLY the format a
176
176
 
177
177
  **Parse subagent output and write session-state.md:**
178
178
 
179
- After the subagent returns, **verify the subagent stayed in scope**: run `bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" origin/main...HEAD` and confirm every listed path matches `^knowledge-base/project/(plans|specs)/`; exit 2/127 = scope unverified: treat as a breach and re-diff, never as in scope. **Bare-repo stale-ref guard:** the local `origin/main` ref can lag the actual main HEAD, making the three-dot diff list files from unrelated already-merged branches — a false scope-breach signal. If the diff shows files you never touched, re-diff against the branch's actual base SHA (the same helper on `<base-sha>..HEAD`, where `<base-sha>` is the fresh branch's parent) or `git fetch origin main` first, before concluding the subagent breached scope. If files outside that regex were touched (workflow YAML, source code, CHANGELOG, etc.), the subagent exceeded its plan-only mandate — the Session Summary's "Decisions" became statements of intent rather than fact. Read each out-of-scope file from disk and reconcile against the plan's claims before trusting Step 3 onward; do NOT trust the Session Summary's reconciliation narrative ("Adopted the on-disk output text", "Already applied as uncommitted local changes") without verifying via `git diff <file>` first. **Why:** #3937 — plan-deepen subagent committed source-code edits AND its Session Summary claimed on-disk text it had not actually written (`pre-recorded` vs prescribed `not applicable`), costing two reconciliation commits. See [[2026-05-17-planning-subagent-exceeded-scope-and-summary-vs-disk-drift]].
179
+ After the subagent returns, **verify the subagent stayed in scope**: run `bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" origin/main...HEAD` and confirm every listed path matches `^knowledge-base/project/(plans|specs)/`; non-zero exit = scope unverified: treat as a breach and re-diff, never as in scope. **Bare-repo stale-ref guard:** the local `origin/main` ref can lag the actual main HEAD, making the three-dot diff list files from unrelated already-merged branches — a false scope-breach signal. If the diff shows files you never touched, re-diff against the branch's actual base SHA (the same helper on `<base-sha>..HEAD`, where `<base-sha>` is the fresh branch's parent) or `git fetch origin main` first, before concluding the subagent breached scope. If files outside that regex were touched (workflow YAML, source code, CHANGELOG, etc.), the subagent exceeded its plan-only mandate — the Session Summary's "Decisions" became statements of intent rather than fact. Read each out-of-scope file from disk and reconcile against the plan's claims before trusting Step 3 onward; do NOT trust the Session Summary's reconciliation narrative ("Adopted the on-disk output text", "Already applied as uncommitted local changes") without verifying via `git diff <file>` first. **Why:** #3937 — plan-deepen subagent committed source-code edits AND its Session Summary claimed on-disk text it had not actually written (`pre-recorded` vs prescribed `not applicable`), costing two reconciliation commits. See [[2026-05-17-planning-subagent-exceeded-scope-and-summary-vs-disk-drift]].
180
180
 
181
181
  After the subagent returns, check for a `## Session Summary` heading in the output. In both arms, after that arm writes session-state.md, Read [operator-constraints.md](${CLAUDE_PLUGIN_ROOT}/skills/one-shot/references/operator-constraints.md) and append the brief's `## Operator Constraints`; later writes only append.
182
182
 
@@ -369,3 +369,4 @@ NEVER CODE! Just research and write the plan.
369
369
  - **A plan that proposes a flag or argv as an implementation lever on a repo script must read the script's actual argv first — "the flag that should exist" is a capability claim verified against the parser, not inferred from the suite's shape.** Grep the script's argument handling (`--only`, `getopts`, the `usage`/help text) or run `--help`; it settles in seconds what a wrong claim costs a ruling cycle to catch. **Why:** #12626 — the plan prescribed a `--rows` row-splitting lever on `approval-guard1-mutation`; the battery's argv is `[--only|--list|--check-anchors]`, and only the batched CTO ruling caught it. See `knowledge-base/project/learnings/2026-11-11-a-completed-but-failing-leg-filed-as-did-not-complete.md` SE#4.
370
370
  - **A plan that pins a Terraform forget (`removed { destroy = false }`) must state the property in the provider's DELETE key (an email, a name) and pin a CLOSED SET over every file Terraform would load — every tracked `.tf`/`.tf.json` in the repo, minus dotfiles Terraform ignores, with heredocs found by a raw scan — never a search for the bad label or literal.** When the property is "no managed resource of type T", the set is the allowed occurrences of the type token (only the forget's `from` line); when other instances of T stay managed, enumerate the allowed addresses instead. Reuse the `FIX B handed` describe in `plugins/soleur/test/terraform-target-parity.test.ts` and its mirror, Guard G4a in `tests/scripts/test-infra-privileged-tier-census.sh`, rather than rebuilding the scan from prose. Labels miss `import`, `local.`/`var.` values, case, unquoted labels, modules and other roots; and a second guard that shares the first one's file reader and string stripper shares its blind spots. **Why:** #12813 — a dotfile `.tf` and a quote-confused heredoc each kept the test and that census guard green while Terraform planned a DELETE of the sole Better Stack Admin. See `knowledge-base/project/learnings/2026-11-16-my-forget-pin-checked-labels-while-the-provider-deletes-by-email.md`.
371
371
  - **A plan that adds a rule to a gate which reads text another interpreter will expand (a Bash PreToolUse hook, a CI shell lint) must list that interpreter's whole expansion and quoting set first, and close each class in one place rather than deny-listing spellings.** For bash: brace, tilde, parameter/`$[…]`, command, process substitution, pathname/extglob, backslash and `$'…'` quoting, and the target tool's own argv parsing (git long-option prefixes, commit pathspecs). Brief the first fix-round security seat to sweep that whole list, not to find one more instance. **Why:** #12806 — seven fix rounds each found the next form the cron hook read differently from bash; see `knowledge-base/project/learnings/2026-11-16-seven-fix-rounds-each-found-the-next-bash-expansion-the-hook-read-differently.md`.
372
+ - **An acceptance criterion that says "additions only" / "no `-` line" must be checked against every edit the plan itself prescribes in that file: an in-cell table append or an in-field frontmatter change is a one-line rewrite, so `git diff` shows a `-` line and the AC is unsatisfiable as written.** Write the carve-out into the AC by naming each rewritten line's content anchor (the table row's first cells, the frontmatter key), with the exact grep that drops only those lines, e.g. `git diff -U0 origin/main...HEAD -- <file> | grep -E '^-' | grep -vE '^--- (a/|/dev/null)' | grep -vF '<row anchor>'` printing nothing. Do not state it as "the `-` line is a prefix of its `+` line": a table row's closing pipe (space then `|`) and a replaced frontmatter value both break that. Do not match `^-[^-]` either: it misses a deleted `- item` line, which the diff shows as `-- item`. **Why:** #12742/PR #12884 — AC7 forbade any `-` line while Phase 4 step 2 prescribed an in-cell append to the runbook's #10538 row; the task was ticked anyway and review flagged it. See `knowledge-base/project/learnings/2026-11-18-an-ac-that-contradicts-the-prescribed-edit.md`.
@@ -112,7 +112,7 @@ Proceed once the tree is ready (worktree or current branch).
112
112
 
113
113
  Before spawning review agents, classify the PR to right-size the panel.
114
114
 
115
- 1. Run the helper below (NUL-delimited, rename-free, submodule-honest; rc 2 on failure) to write the list of changed files; show `head -n 200 "$REVIEW_TMP/review-changed.txt"`. Also capture status letters and line counts. Resolve the tmp path with `git rev-parse --git-dir` (in a worktree `.git` is a file, so `> .git/review-*.txt` fails with `Not a directory`):
115
+ 1. Run the helper below (NUL-delimited, rename-free, submodule-honest; non-zero exit on failure) to write the list of changed files; show `head -n 200 "$REVIEW_TMP/review-changed.txt"`. Also capture status letters and line counts. Resolve the tmp path with `git rev-parse --git-dir` (in a worktree `.git` is a file, so `> .git/review-*.txt` fails with `Not a directory`):
116
116
 
117
117
  ```bash
118
118
  REVIEW_TMP="$(git rev-parse --git-dir)"
@@ -121,7 +121,7 @@ Before spawning review agents, classify the PR to right-size the panel.
121
121
  git diff --numstat origin/main...HEAD > "$REVIEW_TMP/review-numstat.txt"
122
122
  ```
123
123
 
124
- If the helper fails (rc 2/127; marker printed, file removed), skip the decision tree: class = code (full panel) and run gdpr-gate (fail toward more review).
124
+ If the helper fails (marker printed, file removed), skip the decision tree: class = code (full panel) and run gdpr-gate (fail toward more review).
125
125
 
126
126
  All downstream `cat .git/review-*.txt` references in the predicates below must use `"$REVIEW_TMP/review-*.txt"` instead.
127
127
 
@@ -368,7 +368,7 @@ Tier resolution + the no-double-invoke rule: [risk-tier-and-fix-rounds.md](refer
368
368
 
369
369
  **When to run gdpr-gate at review time:**
370
370
 
371
- - `bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match "$CANONICAL_REGEX" origin/main...HEAD` exits 0 (a match) or 2/127 (unknown: treat as a match) (mirrored regex source: `plugins/soleur/skills/gdpr-gate/SKILL.md` §"Path globs (canonical)").
371
+ - `bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match "$CANONICAL_REGEX" origin/main...HEAD` does not exit 42 (42 = no match): treat as a match (mirrored regex source: `plugins/soleur/skills/gdpr-gate/SKILL.md` §"Path globs (canonical)").
372
372
 
373
373
  **What this agent checks:**
374
374
 
@@ -54,7 +54,7 @@ Fix commits are the least-audited surface in the pipeline (learnings 2026-09-23,
54
54
  2. **Seat set per fix round:** `{seats that reported the findings these commits close} ∪ {path-mapped seats} ∪ {conditional seats}`, resolved mechanically:
55
55
 
56
56
  ```bash
57
- files=$(bash <plugin-root>/scripts/changed-paths.sh "$PANEL_SHA"..HEAD) || files=unknown # unknown (exit 2/127): skip the script, spawn the full class panel
57
+ files=$(bash <plugin-root>/scripts/changed-paths.sh "$PANEL_SHA"..HEAD) || files=unknown # unknown: skip the script, spawn the full class panel
58
58
  if [ "$files" = unknown ]; then echo 'fix diff unverifiable: spawn the full class panel'; else
59
59
  bash <plugin-root>/skills/review/scripts/fix-round-seats.sh \
60
60
  --files "$files" \
@@ -98,6 +98,7 @@ Two lessons from #9448 belong in every fix-agent and review-seat brief (full acc
98
98
  - **A fix to PROSE that prescribes a state machine (a runbook run sheet, an abort/retry/rollback ladder) is reviewed by walking the state space, not the sentence.** List every variable the procedure can be in (flag, pause, exemption, sentinel, stamp, per-host state, before/after the irreversible step) and name the action each sentence prescribes in each reachable state; two sentences prescribing different actions in one state, or none, is a P1 whatever the wording. Key every abort/retry on the failure table's first step, not on one variable. **Why:** #11812 - the first fix commit introduced 3 new P1 and the second round still found one. See `knowledge-base/project/learnings/2026-11-01-every-fix-to-the-run-sheet-covered-the-state-i-was-thinking-of-and-the-sheet-had-eight-more.md`.
99
99
 
100
100
  - **The Workflow tool needs the user's own request; the review skill's "opt-in Workflow port" pointer is not that.** Spawn fix-round seats with the Agent tool unless the user asked for a workflow in their own words. On #12515 a fix round was launched through the Workflow tool, noticed, stopped and respawned.
101
+ - **A fix-round predicate added to a fail-closed gate is a new input surface: list what it reads before writing it.** Brief the fix agent to name every external input the new code reads (PR bodies by branch name, git config such as `diff.relative`/`diff.external`/textconv, `.gitattributes`, file names), add one hostile-input row per input, and key any skip arm on the measured cause, never on the generic `unknown` the gate fires on. **Why:** #12809 — four rounds each opened a fail-open path in their own new code (fork PR body, config-driven diff, suffix-lookalike archive, a skip keyed on `unknown`). See `knowledge-base/project/learnings/2026-11-08-converting-changed-path-readers-moved-the-failure-to-newline-names-and-to-the-prose-that-calls-the-helper.md`.
101
102
  - **A floor that counts a conditional row adds it only when its precondition held.** A UTF-8 locale row counted in an unconditional projection floor would go red on a minimal CI image with a correct tree (found by the verifier seat on #12515); count the conditional rows separately and add them to the floor when they ran. See `knowledge-base/project/learnings/2026-11-10-a-fix-rounds-new-gates-and-rows-repeated-the-class-they-closed.md`.
102
103
  - **A fix-round seat runs no full battery or mutation run; the lead does (as above), and a seat's single named repro goes under `timeout`.** A seat inside a long tool call delivers nothing and sends no notice until that call exits, and it cannot act on a `SendMessage` meanwhile. Name what to read and give a tool-call cap (about 25). If a seat's last transcript block (read with `jq`, as SKILL.md says) is an old `tool_use`, stop it (TaskStop) and respawn it with a read-only brief. **Why:** #12518 — a seat briefed to "verify with the battery" hung about 3 h in a mutation run; the respawn with a read-only brief reported in under 2 minutes. See `knowledge-base/project/learnings/2026-11-11-a-deferred-battery-and-a-draft-light-ci-left-the-repo-wide-guards-for-the-ready-run.md`.
103
104
 
@@ -893,8 +893,8 @@ echo 'SOLEUR_RULE_APPLIED rule=wg-record-recurring-vendor-expense-before-ready n
893
893
  **Detection.** A recurring-vendor-cost signal fires when the change introduces any of: a new dependency in a `package.json` that the agent judges to be a *paid* vendor (`git diff origin/main...HEAD -- '*package.json' | grep -E '^\+'`), a new vendor credential env var (added `*_API_KEY`/`*_TOKEN`/`*_SECRET` lines in `.env.example` or Doppler-write steps), or a plan-tier string in the PR body. Capture the PR body and **strip fenced code blocks** before grepping — this gate body and the AGENTS rule quote `Pro`/`subscription`/`upgrade`, which inside ``` fences MUST NOT count. The block below is **self-contained**: it captures + strips the body itself rather than depending on the Undeferred Operator-Step Gate's `$PR_BODY_FILE` (defined later in this file — running these blocks in document order would otherwise leave it unset and the grep would silently no-op). Bash ERE has no `(?i)` — use `grep -iE`.
894
894
 
895
895
  ```bash
896
- # (a) Ledger edited in this change? Exact path only; `unknown` (exit 2/127) is NOT an edit.
897
- ledger_touched=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match '^knowledge-base/operations/expenses\.md$' --diff-filter=AMT origin/main...HEAD) || { [ $? -eq 1 ] || ledger_touched=unknown; }
896
+ # (a) Ledger edited in this change? Exact path only; `unknown` is NOT an edit.
897
+ ledger_touched=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match '^knowledge-base/operations/expenses\.md$' --diff-filter=AMT origin/main...HEAD) || { [ $? -eq 42 ] || ledger_touched=unknown; }
898
898
 
899
899
  # (b) Capture + fence-strip the PR body (self-contained; fail CLOSED on an
900
900
  # unbalanced ``` so an unclosed fence cannot silently drop the rest of the body).
@@ -936,7 +936,7 @@ SIGNAL=$(grep -niE "$SIGNAL_RE" "$PR_BODY_FILE" || true)
936
936
  **Detection:**
937
937
 
938
938
  ```bash
939
- gdpr_gate_touch=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match '^plugins/soleur/skills/gdpr-gate/' origin/main...HEAD) || { [ $? -eq 1 ] || gdpr_gate_touch=unknown; }
939
+ gdpr_gate_touch=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match '^plugins/soleur/skills/gdpr-gate/' origin/main...HEAD) || { [ $? -eq 42 ] || gdpr_gate_touch=unknown; }
940
940
  sui_plan=$(gh pr view --json body --jq .body \
941
941
  | grep -oE 'knowledge-base/project/(plans|specs)/[^[:space:])]+' | head -n 1 || true)
942
942
  sui_threshold=""
@@ -960,7 +960,7 @@ fi
960
960
 
961
961
  ```bash
962
962
  CANONICAL_REGEX='^(apps/web-platform/supabase/migrations/|apps/web-platform/lib/auth/|apps/web-platform/server/.*auth.*\.(ts|tsx|js)|apps/web-platform/app/api/.*\.(ts|tsx)$|.*\.sql$)'
963
- diff_match=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match "$CANONICAL_REGEX" origin/main...HEAD) || { [ $? -eq 1 ] || diff_match=unknown; }
963
+ diff_match=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match "$CANONICAL_REGEX" origin/main...HEAD) || { [ $? -eq 42 ] || diff_match=unknown; }
964
964
  crit_refs=$(gh pr view --json body --jq .body | grep -oE '(Closes|Ref) #[0-9]+' | head -n 5)
965
965
  ```
966
966
 
@@ -978,7 +978,7 @@ For each `crit_ref`, check `gh issue view <N> --json labels --jq '.labels[].name
978
978
 
979
979
  ### Counsel-Review CLO-Attestation Gate
980
980
 
981
- **Trigger:** the diff touches `docs/legal/`, `plugins/soleur/docs/pages/legal/` or `knowledge-base/legal/`, AND the referenced plan declares `brand_survival_threshold: single-user incident` or an added line in those directories carries a `[DRAFT — pending CLO/counsel review` marker. The reviewing authority is the `soleur:legal:clo` agent, not the operator. If it triggers, read [counsel-review-clo-attestation.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/counsel-review-clo-attestation.md) now and follow it; otherwise skip silently.
981
+ **Trigger:** on every ship, read [counsel-review-clo-attestation.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/counsel-review-clo-attestation.md) and run its block; follow it only when the block prints `COUNSEL_GATE=fire`. The reviewing authority is the `soleur:legal:clo` agent, not the operator.
982
982
 
983
983
  ### Deploy Pipeline Fix Drift Gate
984
984
 
@@ -1044,10 +1044,10 @@ DEPLOY_PIPELINE_FIX_TRIGGERS=(
1044
1044
  )
1045
1045
  DPF_REGEX='^apps/web-platform/infra/(ci-deploy\.sh|ci-deploy-wrapper\.sh|webhook\.service|cat-deploy-state\.sh|canary-bundle-claim-check\.sh|hooks\.json\.tmpl|deploy-inngest-bootstrap\.sudoers|infra-config-apply\.sh|infra-config-install\.sh|push-infra-config\.sh|cat-infra-config-state\.sh|inngest-enumerate-reminders\.sh|inngest-rearm-reminders\.sh|inngest-wiped-volume-verify\.sh|cat-inngest-verify-state\.sh|inngest-inventory\.sh|git-lock-chardevice-sweep\.sh|inngest-registry-probe\.sh|inngest-doublefire-probe\.sh|inngest-redis-bootstrap\.sh|inngest-cutover-flip\.sh|inngest-server-flip-guard\.sh|cat-inngest-cutover-state\.sh|soleur-doppler-token\.tmpl|10-vector-doppler-token\.conf|10-inngest-heartbeat-doppler-token\.conf|10-inngest-server-doppler-token\.conf|10-inngest-redis-doppler-token\.conf)$'
1046
1046
 
1047
- dpf_match=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match "$DPF_REGEX" origin/main...HEAD) || { [ $? -eq 1 ] || dpf_match=unknown; }
1047
+ dpf_match=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match "$DPF_REGEX" origin/main...HEAD) || { [ $? -eq 42 ] || dpf_match=unknown; }
1048
1048
  ```
1049
1049
 
1050
- If `dpf_match` is non-empty, the gate fires; `unknown` (rc 2/127) also fires it (fail closed). Trigger condition is "≥1 match" — the gate fires once for the PR, not once per matched file.
1050
+ If `dpf_match` is non-empty, the gate fires; `unknown` also fires it (fail closed). Trigger condition is "≥1 match" — the gate fires once for the PR, not once per matched file.
1051
1051
 
1052
1052
  **If triggered:**
1053
1053
 
@@ -1304,7 +1304,7 @@ esac
1304
1304
  `plugins/soleur/skills/ship/scripts/ship-pir-action-items-gate.sh`,
1305
1305
  `plugins/soleur/test/ship-pir-action-items-gate.test.sh`, or
1306
1306
  `plugins/soleur/test/fixtures/ship-pir-action-items/`.
1307
- 2. **Every** path in `$list` is one of those, the test-all script or a `knowledge-base/project/{plans,specs,brainstorms,learnings}/` artifact: `LC_ALL=C grep -vE '^(scripts/(ship-incident-pir-gate(-mutation\.test)?|test-all)\.sh|plugins/soleur/(test/(ship-incident-pir-gate\.test\.ts|ship-pir-action-items-gate\.test\.sh|fixtures/(ship-incident-pir-gate|ship-pir-action-items)/.*)|skills/ship/scripts/ship-pir-action-items-gate\.sh)|knowledge-base/project/(plans|specs|brainstorms|learnings)/.*)$' <<<"$list"` prints nothing. Exit 2/127 from the helper = unknown = not contained: take the PIR path above. If this file is also
1307
+ 2. **Every** path in `$list` is one of those, the test-all script or a `knowledge-base/project/{plans,specs,brainstorms,learnings}/` artifact: `LC_ALL=C grep -vE '^(scripts/(ship-incident-pir-gate(-mutation\.test)?|test-all)\.sh|plugins/soleur/(test/(ship-incident-pir-gate\.test\.ts|ship-pir-action-items-gate\.test\.sh|fixtures/(ship-incident-pir-gate|ship-pir-action-items)/.*)|skills/ship/scripts/ship-pir-action-items-gate\.sh)|knowledge-base/project/(plans|specs|brainstorms|learnings)/.*)$' <<<"$list"` prints nothing. A non-zero exit from the helper = unknown = not contained: take the PIR path above. If this file is also
1308
1308
  changed, **every hunk** of `git diff -U0 origin/main...HEAD -- plugins/soleur/skills/ship/SKILL.md`
1309
1309
  must land inside this Phase 5.5 section — a section is not a path, so without that check
1310
1310
  conjunct 2 cannot tell a Phase 5.5 edit from a rewrite of the merge gate below it.
@@ -1656,11 +1656,11 @@ If an issue number is found, store it as `ISSUE_NUMBER` for use in the PR body b
1656
1656
  # matches nothing (verified: `close[sd]?.*after` MATCHES, `close[sd]?\b.*\bafter\b` does NOT).
1657
1657
  # A \b here makes this gate catch zero lines while reading as if it works.
1658
1658
  CLOSE_DEFER_RE='close[sd]?.*(after|once|when)|closes-after-apply|manual close after|close manually|post-merge.*(close|verif)'
1659
- plan_refs=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match '^knowledge-base/project/(plans|specs)/' origin/main...HEAD) || { [ $? -eq 1 ] || plan_refs=unknown; }
1660
- [[ $plan_refs == unknown ]] && echo 'unverifiable: use Ref #N' || { [[ -n $plan_refs ]] && tr '\n' '\0' <<<"$plan_refs" | xargs -0 grep -inE -e "$CLOSE_DEFER_RE" -- | head -5; }
1659
+ plan_refs=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match '^knowledge-base/project/(plans|specs)/' --diff-filter=AMT origin/main...HEAD) || { [ $? -eq 42 ] || plan_refs=unknown; }
1660
+ [[ $plan_refs == unknown ]] && echo 'unverifiable: use Ref #N' || { [[ -n $plan_refs ]] && { IFS=$'\n' read -r -d '' -a f <<<"$plan_refs"; h=$(grep -inE -e "$CLOSE_DEFER_RE" -- "${f[@]}"); r=$?; [ $r -gt 1 ] && echo 'unverifiable: use Ref #N' || grep -m 5 . <<<"$h"; }; }
1661
1661
  ```
1662
1662
 
1663
- Any hit or `unverifiable` (exit 2/127) ⇒ use **`Ref #N`**, not `Closes #N`, and close the issue yourself after the proof lands (`gh issue close N --comment "<live evidence>"`). Over-detection is deliberate and cheap here: a spurious hit costs one re-read of the keyword; a miss closes an issue whose work is not done.
1663
+ Any hit or `unverifiable` ⇒ use **`Ref #N`**, not `Closes #N`, and close the issue yourself after the proof lands (`gh issue close N --comment "<live evidence>"`). Over-detection is deliberate and cheap here: a spurious hit costs one re-read of the keyword; a miss closes an issue whose work is not done.
1664
1664
 
1665
1665
  Match the SHAPE (a close verb + an ordering word), not the canonical phrasing. The grep is wider than [work/SKILL.md](../work/SKILL.md)'s prose list ("Closes-after-apply", "manual close after", …) because a plan rarely uses those exact words — it writes *"close #N only **after** Phase 4.5 passes"*, where the markdown bold also defeats any regex that expects `after` to be followed by a space.
1666
1666
 
@@ -2168,7 +2168,7 @@ K=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/ci-head-verdict.sh" ready-count PR_NUMBE
2168
2168
 
2169
2169
  Arm through the arm check ONLY on exit 0; else report "readied but unarmed" with the last stdout line and follow [ready-run-wait.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/ready-run-wait.md) (a failed `ready-count` or `api-error` needs no undo). A non-draft PR goes straight to the arm.
2170
2170
 
2171
- If `bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match '^\.github/(workflows|actions)/' origin/main...HEAD` prints anything or exits 2/127, tell the operator in chat now: auto-merge is queued and polled as usual, but this PR has no agent `--admin` fallback (`UNTRUSTED-CI`), so if a BEHIND livelock sets in they will be asked to merge it. See [settle-then-admin-merge.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/settle-then-admin-merge.md). **Why:** #8611.
2171
+ If `bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match '^\.github/(workflows|actions)/' origin/main...HEAD` does not exit 42 (42 = no match), tell the operator in chat now: auto-merge is queued and polled as usual, but this PR has no agent `--admin` fallback (`UNTRUSTED-CI`), so if a BEHIND livelock sets in they will be asked to merge it. See [settle-then-admin-merge.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/settle-then-admin-merge.md). **Why:** #8611.
2172
2172
 
2173
2173
  Wrap the `gh pr merge` call in the merge-main lock so parallel sessions don't queue auto-merges in the same window:
2174
2174
 
@@ -34,7 +34,7 @@ Blocks PR-ready when the branch adds a NEW `ADR-NNN-*.md` whose ordinal `NNN` is
34
34
  can be cited from CODE.** Sweep the branch's whole diff, then classify each hit:
35
35
 
36
36
  ```bash
37
- files=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" origin/main...HEAD) || files=$(git ls-files) # list unknown (exit 2/127): sweep every tracked file, never an empty list
37
+ files=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" origin/main...HEAD) || files=$(git ls-files) # list unknown: sweep every tracked file, never an empty list
38
38
  while IFS= read -r f; do [[ -f $f ]] && grep -Hn -- 'ADR-<old>' "$f"; done <<< "$files"
39
39
  ```
40
40
 
@@ -6,26 +6,63 @@ Moved verbatim out of `ship/SKILL.md` Phase 5.5 to stay under the SKILL.md body
6
6
 
7
7
  **The reviewing authority for legal-doc attestation is the `soleur:legal:clo` agent, NOT the human operator.** The Soleur user is a non-lawyer founder; deferring legal sign-off to them bottlenecks indefinitely and mis-allocates expertise (the `soleur:legal:clo` agent orchestrates `soleur:legal:legal-compliance-auditor` + `soleur:legal:legal-document-generator` and can cross-check prose against statute and against the implementing migration in one cycle). This is symmetric to how `soleur:plan` routes CPO sign-off to the CPO agent. See `knowledge-base/project/learnings/workflow-patterns/2026-05-18-clo-attestation-auto-route-instead-of-human-task.md` (the operator has corrected human-routed legal sign-off ≥3×).
8
8
 
9
- **Trigger:** the PR diff touches a legal-doc directory AND the change is legal-attestation-bearing:
9
+ **Trigger:** run this block on every ship; it prints `COUNSEL_GATE=fire` when the diff touches a legal-doc directory AND the change is legal-attestation-bearing:
10
10
 
11
11
  ```bash
12
- legal_touch=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match '^(docs/legal/|plugins/soleur/docs/pages/legal/|knowledge-base/legal/)' origin/main...HEAD) || { [ $? -eq 1 ] || legal_touch=unknown; }
13
- # Scope the marker grep to legal-doc dirs ONLY — otherwise it self-fires on
14
- # this gate's own prose in ship/SKILL.md or on spec/tasks.md that quotes the
15
- # literal descriptively (false positive).
16
- draft_marker=$(git diff main...HEAD -- docs/legal/ plugins/soleur/docs/pages/legal/ knowledge-base/legal/ \
17
- | grep -E '^\+.*\[DRAFT — pending CLO/counsel review' | head -n 1 || true)
18
- sui_plan=$(gh pr view --json body --jq .body \
19
- | grep -oE 'knowledge-base/project/(plans|specs)/[^[:space:])]+' | head -n 1 || true)
20
- sui_threshold=""
21
- if [[ -n "$sui_plan" && -f "$sui_plan" ]]; then
22
- sui_threshold=$(grep -E '^brand_survival_threshold:\s*single-user incident' "$sui_plan" || true)
12
+ legal_touch=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match '^(docs/legal/|plugins/soleur/docs/pages/legal/|knowledge-base/legal/)' refs/remotes/origin/main...HEAD) || { [ $? -eq 42 ] || legal_touch=unknown; }
13
+ sui_plans=$(bash "${CLAUDE_PLUGIN_ROOT}/scripts/changed-paths.sh" --match '^knowledge-base/project/(plans|specs)/.*\.md$' --diff-filter=AMT refs/remotes/origin/main...HEAD) || { [ $? -eq 42 ] || sui_plans=unknown; }
14
+ # Every read keeps its own exit status: a failed read is `unknown`, never an empty "nothing found". All paths are repo-relative.
15
+ sui_top=$(git rev-parse --show-toplevel) || sui_top=.; sui_why=""
16
+ # No base to diff against (no refs/remotes/origin/main, or no merge base with it, as in a shallow clone): when HEAD's commit
17
+ # holds no legal doc AND the base ref is missing or its own tree holds none either, nothing legal changed. A base tree that
18
+ # holds legal docs HEAD lacks (a shallow clone of a branch deleting them all) fires, as does any other unknown.
19
+ if [ "$legal_touch" = unknown ] && ! git -C "$sui_top" merge-base refs/remotes/origin/main HEAD >/dev/null 2>&1 \
20
+ && sui_ls=$(git -C "$sui_top" ls-tree -r --name-only HEAD -- docs/legal/ plugins/soleur/docs/pages/legal/ knowledge-base/legal/) && [ -z "$sui_ls" ] \
21
+ && { ! git -C "$sui_top" rev-parse -q --verify 'refs/remotes/origin/main^{commit}' >/dev/null 2>&1 \
22
+ || { sui_ls=$(git -C "$sui_top" ls-tree -r --name-only refs/remotes/origin/main -- docs/legal/ plugins/soleur/docs/pages/legal/ knowledge-base/legal/) && [ -z "$sui_ls" ]; }; }; then
23
+ legal_touch=""; sui_why=" reason=no-legal-docs-tracked"
23
24
  fi
24
- # Gate fires when legal docs changed AND (single-user-incident OR a DRAFT marker is present)
25
- # legal_touch=unknown (helper exit 2/127: diff unverifiable) counts as touched, so the gate fires; it never skips.
25
+ # Scope the marker grep to legal-doc dirs ONLY, from the repo root, as text, relative-, colour-, driver- and textconv-free;
26
+ # otherwise it self-fires on this gate's own prose in ship/SKILL.md or on spec/tasks.md quoting the literal.
27
+ if legal_diff=$(git -C "$sui_top" diff --text --no-relative --no-color --no-ext-diff --no-textconv refs/remotes/origin/main...HEAD -- docs/legal/ plugins/soleur/docs/pages/legal/ knowledge-base/legal/); then
28
+ draft_marker=$(printf '%s\n' "$legal_diff" | grep -m 1 -E '^\+.*\[DRAFT — pending CLO/counsel review'); [ $? -le 1 ] || draft_marker=unknown
29
+ else draft_marker=unknown; fi
30
+ # Plan candidates: every plan/spec path this repo's own open PR cites (fork PRs of the same branch name are ignored; trailing
31
+ # punctuation stripped; no PR yet = none cited) plus the plans/specs this branch adds or edits. Any candidate declaring
32
+ # single-user incident sets the threshold; otherwise a failed read, a detached HEAD, or a cited path that is missing with no
33
+ # archived copy on the branch is unknown; no candidate at all skips.
34
+ sui_threshold=""; sui_unknown=""; sui_cited=""; sui_branch=$(git branch --show-current)
35
+ if [ -z "$sui_branch" ]; then sui_unknown=1
36
+ elif pr_body=$(gh pr list --head "$sui_branch" --state open --json body,isCrossRepository --jq '[.[] | select(.isCrossRepository | not) | .body] | join("\n")'); then
37
+ sui_cited=$(printf '%s\n' "$pr_body" | grep -oE 'knowledge-base/project/(plans|specs)/[^[:space:])]+' | sed -E "s/[\`'\".,;:/]+$//" | sort -u)
38
+ else sui_unknown=1; fi
39
+ [ "$sui_plans" != unknown ] || { sui_unknown=1; sui_plans=""; }
40
+ while IFS= read -r sui_p; do
41
+ [ -n "$sui_p" ] || continue
42
+ if [ ! -f "$sui_top/$sui_p" ] || [ ! -r "$sui_top/$sui_p" ]; then
43
+ # Archived copy (archive-kb names it <YYYYMMDD-HHMMSS>-<name>, exactly): plans/archive/<ts>-<name>.md, or a whole spec dir
44
+ # moved to specs/archive/<ts>-<dir>/<same file>.
45
+ sui_rest=${sui_p#knowledge-base/project/*/}; sui_head=${sui_rest%%/*}; sui_tail=${sui_rest#"$sui_head"}
46
+ [ -d "$sui_top/$sui_p" ] || awk -v a="${sui_p%%"/$sui_rest"}/archive/" -v h="$sui_head" -v t="$sui_tail" '
47
+ index($0, a) == 1 { r = substr($0, length(a) + 1); i = index(r, "/"); g = i ? substr(r, 1, i - 1) : r; m = i ? substr(r, i) : ""
48
+ if (g ~ /^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]-/ && substr(g, 17) == h && (t == "" || m == t)) f = 1 }
49
+ END { exit !f }' <<<"$sui_plans" || sui_unknown=1
50
+ continue
51
+ fi
52
+ grep -qE "^brand_survival_threshold:[[:space:]]*[\"']?single-user[- ][i]ncident" "$sui_top/$sui_p" && sui_threshold="$sui_p"
53
+ done <<<"$sui_cited"$'\n'"$sui_plans"
54
+ [ -n "$sui_threshold" ] || [ -z "$sui_unknown" ] || sui_threshold=unknown
55
+ # Fires when legal docs changed AND (single-user incident OR a DRAFT marker). Fail closed: an unknown legal_touch counts as
56
+ # touched, and an unknown draft_marker or sui_threshold counts as present. Each field says which: a value, unknown, or none.
57
+ sui_dm=none; [ -z "$draft_marker" ] || sui_dm=present; [ "$draft_marker" != unknown ] || sui_dm=unknown
58
+ if [[ -n $legal_touch && ( -n $sui_threshold || -n $draft_marker ) ]]; then
59
+ echo "COUNSEL_GATE=fire legal=$([ "$legal_touch" = unknown ] && echo unknown || echo changed) sui_threshold=${sui_threshold:-none} draft_marker=$sui_dm"
60
+ else echo "COUNSEL_GATE=skip$sui_why"; fi
26
61
  ```
27
62
 
28
- **If triggered (`legal_touch` non-empty AND (`sui_threshold` OR `draft_marker` non-empty)):**
63
+ **If the block prints `COUNSEL_GATE=fire`:**
64
+
65
+ 0. **A field reading `unknown` means a read failed, so nothing below may be decided on it yet.** For `legal=unknown` the base could not be read: run `git fetch origin main` (in a shallow clone, `git fetch --unshallow origin`) and run the block again. If a field is still `unknown`, hand the CLO agent no diff verdict: it may return BLOCKED with the failed read as the blocker, never DISCHARGED.
29
66
 
30
67
  1. **Invoke the `soleur:legal:clo` agent via Task** with: the diff, every changed legal artifact, and the implementing files it must cross-check against (migrations, RPC bodies, the consuming TS). Instruct it to produce/attest the counsel-review audit at `knowledge-base/legal/audits/<YYYY-MM>-counsel-review-<issue>.md` (house style: `2026-05-counsel-review-4353.md`), resolving lawful-basis, consent, retention, and Art. 6(1)(f) LIA questions, and to return a per-artifact verdict + an overall disposition (DISCHARGED or BLOCKED).
31
68
  2. **On DISCHARGED** — the CLO agent is the authority, so proceed without a human sign-off: