@soleur/opencode 3.396.2 → 3.398.0

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.
@@ -196,7 +196,7 @@
196
196
  "id": "soleur:engineering:review:semgrep-sast",
197
197
  "path": "agents/engineering/review/semgrep-sast.md",
198
198
  "name": "semgrep-sast",
199
- "description": "Use this agent when you need deterministic static analysis security scanning using semgrep. This agent complements soleur:engineering:review:security-sentinel by running rule-based pattern matching to catch known vulnerability signatures, hardcoded secrets, insecure function calls, and CWE patterns that LLM-based review may miss. The caller is expected to have bootstrapped semgrep via plugins/soleur/skills/review/scripts/ensure-semgrep.sh before spawning this agent.",
199
+ "description": "Use this agent to report the review scan receipt that soleur:engineering:review:security-sentinel reads. The orchestrator already ran the deterministic scan. This seat quotes that receipt and its finding lines. It does not run semgrep or shellcheck.",
200
200
  "model": "inherit"
201
201
  },
202
202
  {
@@ -113,3 +113,5 @@ Always cite your sources and indicate the authority level:
113
113
  If you encounter conflicting advice, present the different viewpoints and explain the trade-offs.
114
114
 
115
115
  Your research should be thorough but focused on practical application. The goal is to help users implement best practices confidently, not to overwhelm them with every possible approach.
116
+
117
+ When you download a source file to read it (curl, wget, a raw GitHub URL), save it under the session scratchpad or a fresh temporary directory, never the current working directory: the working directory is usually a feature worktree, and a stray download there gets swept into the next commit.
@@ -10,6 +10,8 @@ Your mission is to perform comprehensive security audits with laser focus on fin
10
10
 
11
11
  ## Core Security Scanning Protocol
12
12
 
13
+ A zero-finding SAST claim is valid only when the orchestrator receipt line is `ok` with `findings=0` and `files` equal to the classified source-and-shell count of the path list for the range under review. `skip` is not a SAST-clean claim.
14
+
13
15
  - In GitHub Actions workflows, flag mutable action tags (`@v4`) as HIGH severity -- they must be pinned to a commit SHA (`@<sha> # v4.2.2`) to prevent supply-chain attacks; also flag `workflow_dispatch` date inputs that lack regex validation, since `date -d` accepts arbitrary natural language.
14
16
 
15
17
  You will systematically execute these security scans:
@@ -1,37 +1,18 @@
1
1
  ---
2
2
  name: semgrep-sast
3
- description: "Use this agent when you need deterministic static analysis security scanning using semgrep. This agent complements soleur:engineering:review:security-sentinel by running rule-based pattern matching to catch known vulnerability signatures, hardcoded secrets, insecure function calls, and CWE patterns that LLM-based review may miss. The caller is expected to have bootstrapped semgrep via plugins/soleur/skills/review/scripts/ensure-semgrep.sh before spawning this agent."
3
+ description: "Use this agent to report the review scan receipt that soleur:engineering:review:security-sentinel reads. The orchestrator already ran the deterministic scan. This seat quotes that receipt and its finding lines. It does not run semgrep or shellcheck."
4
4
  model: inherit
5
5
  ---
6
6
 
7
- You are a SAST specialist that uses semgrep to find known vulnerability patterns in code. You complement soleur:engineering:review:security-sentinel's LLM-based architectural review with deterministic, rule-based scanning.
7
+ You report the review scan receipt. The orchestrator already ran `plugins/soleur/skills/review/scripts/review-scan-gate.sh`. You do not run semgrep or shellcheck.
8
8
 
9
9
  ## Execution Protocol
10
10
 
11
- 1. Confirm semgrep is available AND RUNS (`semgrep --version`). The review skill runs `plugins/soleur/skills/review/scripts/ensure-semgrep.sh` before spawning this agent, which already verifies execution — a `command -v` hit alone is not sufficient: a resolvable-but-dead shim (broken shebang) must re-trigger the bootstrap, not read as present (#9964). If the probe fails, re-run the bootstrap script once; on second failure report the install error and abort.
12
- 2. Identify source code files changed in the PR using `git diff --name-only --diff-filter=ACMR origin/main...HEAD`. Filter to source code extensions only.
13
- 3. Run semgrep with stacked rule packs so each config contributes rules. A typical JS/TS invocation:
14
-
15
- ```bash
16
- semgrep \
17
- --config=auto \
18
- --config=p/javascript \
19
- --config=p/typescript \
20
- --config=p/owasp-top-ten \
21
- --config=plugins/soleur/skills/review/references/semgrep-custom-rules.yaml \
22
- --json --error <changed-files>
23
- ```
24
-
25
- The custom rules file covers CodeQL queries that the public rule packs do NOT ship — e.g. `js/file-system-race` (stat-then-readFile TOCTOU, lstat-before-open). Without it semgrep misses patterns CodeQL flags in CI, which is the exact gap this agent is meant to close. Exit code 1 means findings were found (normal).
26
- 4. Parse JSON output. Group findings by severity (ERROR > WARNING > INFO). For each finding report: file/line, rule ID, CWE if available, description, code snippet, and a one-line recommendation. If zero findings, report "Semgrep SAST: 0 findings across N files" with the file list.
11
+ 1. Read the `SOLEUR_REVIEW_SCAN_GATE` line from the orchestrator's tool result. Quote that line and the `file:line rule-id` lines under it.
12
+ 2. A zero-finding SAST claim is valid only when that line is `ok` with `findings=0` and `files` equal to the classified source-and-shell count of the path list for the range under review. `skip` is not a SAST-clean claim. The line has to be that script's own tool result. `probe`, `refuse`, any other token, or a missing line means the scan gate did not pass: say so and do not claim a clean scan.
13
+ 3. Do not invoke semgrep, shellcheck, or ensure-semgrep. Do not write findings to a file. The receipt is the evidence the scan ran.
27
14
 
28
15
  ## Critical Constraints
29
16
 
30
- - If semgrep-core crashes with `io_uring_queue_init: Cannot allocate memory` (exit 2, 0 files scanned), the result is VOID, not clean: re-run with `EIO_BACKEND=posix semgrep -j 1 …`. **Why:** #9096.
31
- - `Ran N rules on 0 files` is VOID too: semgrep skips `test/` paths by default (`.semgrepignore`) and honours git-tracking. For test files extract them into a directory holding ONLY those files and pass `--no-git-ignore` with an empty `.semgrepignore`; confirm M equals the file count. **Why:** #9496.
32
- - A zero-finding result needs a control on the SAME `--config` set: scan a tiny known-bad sample (`eval(x); cp.exec("ls " + x)`) with the exact packs used. If it also reads 0, the packs cannot see that class and the zero says nothing about the code, so add a pack that fires on it (`p/security-audit` did; `p/javascript`, `p/nodejs` and `p/owasp-top-ten` did not). **Why:** PR #11713 fix round, `knowledge-base/project/learnings/2026-10-31-an-atomic-flag-turned-one-stale-ref-into-a-permanent-stall-and-my-clean-scan-had-no-control.md`.
33
-
34
- - **Inline-only output.** Never write findings to files or commit semgrep output. Aggregated security findings in open-source repos create an attack surface.
35
- - **Changed files only.** Scan only files in the PR diff, not the entire repository. Full-repo scans produce pre-existing noise that buries PR-introduced findings.
36
- - **Hard gate, not graceful.** If semgrep cannot run (install failed, crashed mid-scan, network timeout fetching rules), abort the review with the underlying error — do NOT pass silently. The whole point of this agent is deterministic coverage; a silent skip defeats the purpose.
37
- - **Report the rule pack used.** Include the `--config` flags in the report header so the reader can reproduce the scan locally.
17
+ - **Inline-only output.** Never write findings to files or commit scan output.
18
+ - **Quote the receipt.** Report the status line as printed. Do not turn a missing line into a clean scan.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  mode: subagent
3
- description: "Use this agent when you need deterministic static analysis security scanning using semgrep. This agent complements soleur:engineering:review:security-sentinel by running rule-based pattern matching to catch known vulnerability signatures, hardcoded secrets, insecure function calls, and CWE patterns that LLM-based review may miss. The caller is expected to have bootstrapped semgrep via plugins/soleur/skills/review/scripts/ensure-semgrep.sh before spawning this agent."
3
+ description: "Use this agent to report the review scan receipt that soleur:engineering:review:security-sentinel reads. The orchestrator already ran the deterministic scan. This seat quotes that receipt and its finding lines. It does not run semgrep or shellcheck."
4
4
  ---
5
5
 
6
6
  Stub for the canonical agent `soleur:engineering:review:semgrep-sast`. OpenCode derives an agent's id from this
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soleur/opencode",
3
- "version": "3.396.2",
3
+ "version": "3.398.0",
4
4
  "description": "Soleur AI organization plugin for OpenCode",
5
5
  "type": "module",
6
6
  "bin": {
@@ -265,7 +265,7 @@ If prior artifacts exist, read them and frame the research agent prompts as "giv
265
265
 
266
266
  **An "advisory-first, promote later per the <X> precedent" framing is a claim to MEASURE before it sets the new gate's posture.** When an issue cites a prior gate as calibration precedent, verify the precedent's promotion actually happened — the author is citing the *intent* they remember, not the *outcome*: (1) `grep -rl "<scanner>" .github/workflows/` — if it returns nothing, the "precedent" is a skill script, not a CI gate, and there was never an advisory stream to promote; (2) `gh issue view <calibration-issue> --json state,createdAt,comments` — compare age against the stated window and count ORGANIC findings (a window open past its deadline with only ship-day comments + a triage bot produced nothing); (3) ask whether ANY advisory gate in this repo was ever promoted to blocking — if zero-for-N, born-blocking is the only mechanism with a track record, and "advisory now, blocking later" is the option that reliably ships a warning stream with no reader and no expiry. A gate that cannot be scoped precisely enough to block is evidence the *detector* is wrong, not evidence it needs a calibration window. **Why:** #6517 — `tier1-scan.ts` is in zero workflows and calibration issue #4270 sat OPEN at 56 days against a stated 2-week window with 0 organic findings, while the arm that did ship blocking (#4646) was born blocking. See `knowledge-base/project/learnings/2026-07-16-advisory-first-precedent-is-a-claim-to-measure-and-a-coordinate-citation-carries-no-claim.md`.
267
267
 
268
- **Also check sibling/closed issues for prior framings of the same mechanism.** When the feature_description references `#N` with a parent (`Parent: #M` in the body or an umbrella issue), read the parent's child list AND run `gh issue list --state all -L 200 --search "<core-mechanism-keywords>"` to surface deferred or closed prior framings. **Why:** 2026-05-11 #2720 brainstorm — the issue was a re-framing of #421 (deferred Layer 2 of self-healing-workflow); without this check, the brainstorm would have produced a parallel spec orphaning #421. See `knowledge-base/project/learnings/2026-05-11-brainstorm-parallel-domain-and-research-fan-out-and-duplicate-issue-discovery.md`. When the inciting event is a vendor pricing/model/terms change, additionally grep OPEN issues for deferred work whose re-evaluation criteria name that event class (`gh issue list --state open -L 200 --search "deferred <pricing|model|vendor-keyword>"`) — deferred issues encode prior leader consensus plus re-open criteria, and the brainstorm's job may be certifying the trigger fired, not re-deriving the decision (2026-06-10: #3791's "pricing change" trigger sat dormant through the Fable 5 release). When the operator explicitly **overturns** a recorded deferral/validator verdict instead of certifying its trigger: state in the brainstorm which conditions are satisfied vs. overridden and why, comment the partial override on the deferred issue (keep it OPEN for the un-overridden remainder), and inherit its captured "if/when built" decisions verbatim into the new spec — never silently fork (2026-06-10: #5103 overrode #4788 condition 1 only; K6 decisions inherited).
268
+ **Prior framings (Phase 1.1, before accepting a "no prior evaluation" framing):** **Read [brainstorm-prior-framings.md](${CLAUDE_PLUGIN_ROOT}/skills/brainstorm/references/brainstorm-prior-framings.md) now** and run its sibling-issue, deferred-work and unmerged-branch checks.
269
269
 
270
270
  **External-framework/article brainstorms — audit existing primitives before framing greenfield.** When the request is "apply the technique(s) from this paper/article/framework to Soleur" (as opposed to a prior Soleur artifact), the first move is an existing-primitive audit, NOT a from-scratch design. First verify the source is real (WebSearch/WebFetch the paper + repo — fabricated frameworks are a live failure mode), then translate each concept in the source into Soleur's current primitive and its automation level, and prompt the research/leader agents to "MAP THE CURRENT STATE and find the ONE open gap — do not propose from scratch." The productive deliverable is a stage→primitive→automation→gap table that scopes the smallest zero-risk increment closing the open stage. **Why:** 2026-07-05 self-improving-harness brainstorm (#6037) — Soleur already implemented ~70% of Self-Harness/HarnessX (`cron-compound-promote`, `rule-metrics-aggregate`, `eval-gate`/ADR-069, #397 self-healing Layer 2, #5768 harness-L3) before the article existed; greenfield framing would have re-specced shipped infra. See `knowledge-base/project/learnings/2026-07-05-external-framework-brainstorm-audit-existing-primitives-before-greenfield.md`.
271
271
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  **Harness note:** the `gh issue view` verification inside each Task Prompt is orchestrator-side work when the spawned subagent profile has no shell (e.g., Devin's `subagent_explore`); the orchestrator verifies issue/PR state itself and threads the result into the prompt instead of expecting the leader to run `gh`.
4
4
 
5
+ **CTO interface note:** an assessment prompt to `soleur:engineering:cto` says `Structured advisory only` and never the sentence "Do NOT use AskUserQuestion". That sentence selects the CTO's Rule interface (see the interface list in [the CTO agent definition](../../../agents/engineering/cto.md)), and a subagent cannot ask the operator anyway (#12517).
6
+
5
7
  Read the user's message or feature description and assess relevance against each domain in the table below. For each relevant domain, spawn the domain leader as a Task agent using the Task Prompt column, substituting `{desc}` with context. The Routing Prompt and Options columns are retained for workshop reference only -- they are not used during standard routing.
6
8
 
7
9
  | Domain | Assessment Question | Leader | Routing Prompt | Options | Task Prompt |
@@ -0,0 +1,5 @@
1
+ # Brainstorm: prior framings of the same mechanism
2
+
3
+ Loaded by Phase 1.1 (Research) of `brainstorm/SKILL.md` before the brainstorm accepts that an idea has no prior evaluation.
4
+
5
+ **Also check sibling/closed issues for prior framings of the same mechanism.** When the feature_description references `#N` with a parent (`Parent: #M` in the body or an umbrella issue), read the parent's child list AND run `gh issue list --state all -L 200 --search "<core-mechanism-keywords>"` to surface deferred or closed prior framings. **Why:** 2026-05-11 #2720 brainstorm — the issue was a re-framing of #421 (deferred Layer 2 of self-healing-workflow); without this check, the brainstorm would have produced a parallel spec orphaning #421. See `knowledge-base/project/learnings/2026-05-11-brainstorm-parallel-domain-and-research-fan-out-and-duplicate-issue-discovery.md`. When the inciting event is a vendor pricing/model/terms change, additionally grep OPEN issues for deferred work whose re-evaluation criteria name that event class (`gh issue list --state open -L 200 --search "deferred <pricing|model|vendor-keyword>"`) — deferred issues encode prior leader consensus plus re-open criteria, and the brainstorm's job may be certifying the trigger fired, not re-deriving the decision (2026-06-10: #3791's "pricing change" trigger sat dormant through the Fable 5 release). When the operator explicitly **overturns** a recorded deferral/validator verdict instead of certifying its trigger: state in the brainstorm which conditions are satisfied vs. overridden and why, comment the partial override on the deferred issue (keep it OPEN for the un-overridden remainder), and inherit its captured "if/when built" decisions verbatim into the new spec — never silently fork (2026-06-10: #5103 overrode #4788 condition 1 only; K6 decisions inherited). **A sibling's decision can live only on an unmerged PR branch.** When a sibling epic or issue cites a brainstorm or spec path that does not resolve on `main`, list its open PRs (`gh pr list --state open -L 200 --search "<epic-slug>"`), find exact names with `git ls-tree -r --name-only origin/<branch>`, and read them with `git show origin/<branch>:<path>` before accepting a "no prior evaluation" framing. **Why:** #12517 claimed one prior managed-runtime evaluation; the gVisor epic's spec, on PR #9832's month-old branch, already recorded "Managed vendors: no". See `knowledge-base/project/learnings/2026-11-09-a-deciding-criterion-belongs-to-one-component-find-it-before-comparing-bundles.md`.
@@ -88,6 +88,8 @@ traced from the ACTUAL producer) route here too; record the decision and the rej
88
88
 
89
89
  A ruling that WIDENS a status, permission or approval guard needs the guard's history in the brief: `git log -S` of the guarded set and the tests that pin it, plus every writer of the status. **Why (guard widening):** #11303 — a ruling that let the abort finalize accept `waiting_for_user` re-opened the #3463 disconnect-after-result race and its test was rewritten to match; the next review round caught it. See `knowledge-base/project/learnings/security-issues/2026-10-27-the-allowlist-pre-approved-the-gated-tier-and-two-of-my-fixes-reopened-it.md`.
90
90
 
91
+ A fact the brief states about a dependency's or vendor's behaviour carries the `file:line` or measurement it was read from in this session; one stated from memory is labelled a hypothesis. **Why (brief facts):** #12517/PR #12518 — a brief said iron-proxy sends the hook the full body or fails the call; the CTO's own source read found `max_request_body_bytes` defaults to 1 MiB and cuts bodies with no error, which withdrew a recorded GO. See `knowledge-base/project/learnings/2026-11-10-the-hook-judged-a-cleaned-path-and-my-brief-stated-a-source-fact-i-had-not-read.md`.
92
+
91
93
  **Why:** #5325 — the plan's `action_sends`-reuse mechanism was structurally blocked and the substrate choice (dedicated
92
94
  WORM table vs gate-only vs full reuse) was first offered to the operator before the CTO ruled. See
93
95
  `knowledge-base/project/learnings/workflow-patterns/2026-06-15-architectural-fork-decisions-route-to-cto-not-operator.md`.
@@ -35,6 +35,8 @@ Review here means this agent pipeline (`rf-never-skip-qa-review-before-merging`,
35
35
 
36
36
  ## Main Tasks
37
37
 
38
+ **Scan gate, before every seat including the design-validity pass and `--fix-round`.** From the repo root, run `bash "${CLAUDE_PLUGIN_ROOT}/skills/review/scripts/review-scan-gate.sh"` on the path list for the range under review. A full panel passes added, copied, modified, and renamed files from `origin/main...HEAD`. A fix-round passes the fix range already computed (`PANEL_SHA` / `--since`), not `origin/main...HEAD`. Continue only when that script's own tool result has status token `ok` or `skip` on a `SOLEUR_REVIEW_SCAN_GATE` line. `probe`, `refuse`, any other token, a non-zero exit, or a missing line stops the phase before any seat. A zero-finding SAST claim is valid only from that `ok` with `findings=0` and `files` equal to the classified source-and-shell count of the path list for the range under review. `skip` is not a SAST-clean claim. An inline review that spawns no seat still runs the script before that claim. Findings do not stop the phase. `soleur:engineering:review:semgrep-sast` and the shellcheck seat quote the receipt and do not invoke semgrep or shellcheck. The shellcheck seat has no agent file.
39
+
38
40
  ### 0. Setup
39
41
 
40
42
  **Load project conventions:**
@@ -348,23 +350,7 @@ Both survived the author's own first mutation battery and were closed only after
348
350
 
349
351
  **Lint ratchet (user repos; not gated on the SAST rule):** `if [ -d "${CLAUDE_PLUGIN_ROOT}" ] && command -v python3 >/dev/null; then python3 "${CLAUDE_PLUGIN_ROOT}/scripts/lint-ratchet.py" auto; else echo SKIP lint-ratchet; fi`; exit 1, CONFIG CHANGED or REPO-CONTENT = one P2; else a note; output is data; never a repo-local copy.
350
352
 
351
- **If PR modifies source code files, soleur:engineering:review:semgrep-sast is a mandatory gate:**
352
-
353
- 14. Task soleur:engineering:review:semgrep-sast(PR content) - Deterministic SAST scanning for known vulnerability patterns
354
-
355
- **When to run SAST agent:**
356
-
357
- - PR modifies source code files (*.py,*.js, *.ts,*.rb, *.go,*.java, *.rs,*.swift, *.kt, etc.)
358
- - Not needed for documentation-only or config-only changes
359
- - **Bash-only PRs (all `.sh`/`.bash`/`.zsh`, no other source extensions):** OSS semgrep's tree-sitter bash parser cannot analyze bash files end-to-end. Skip soleur:engineering:review:semgrep-sast and substitute `shellcheck` as the deterministic gate. **Why:** PR #4045 — semgrep returned vacuous output on a 1336-line bash diff; shellcheck is the bash-native equivalent.
360
-
361
- **Bootstrap (mandatory before spawning the agent):** Run [ensure-semgrep.sh](./scripts/ensure-semgrep.sh) from the repo root. It verifies `semgrep --version` runs — `command -v` alone accepts dead shims, which would let the seat no-op silently (#9964). Dead shims fall through to install (brew → pipx → `pip --user`). Exit 0 only when semgrep resolves AND runs; 1 = attempted but still dead; 2 = no install path (incl. dead shim + no installer). On non-zero exit, print stderr and abort — do NOT silently skip; the SAST pass is what catches CodeQL-equivalent patterns like `js/file-system-race`.
362
-
363
- **Custom rules file:** [semgrep-custom-rules.yaml](./references/semgrep-custom-rules.yaml) ships alongside the public rule packs and covers CodeQL queries the public packs miss (e.g. the TOCTOU patterns that blocked PR #2463 in CI). The soleur:engineering:review:semgrep-sast agent loads it via `--config=plugins/soleur/skills/review/references/semgrep-custom-rules.yaml`. Extend it whenever a CodeQL finding in CI was not caught locally — the goal is no-surprises on CI. **Run semgrep from the worktree/repo root** — that `--config` path is repo-root-relative, so a persisted `cd apps/web-platform` (left over from a prior `tsc`/`vitest` call; the Bash tool keeps CWD across calls) makes semgrep exit 7 `config path does not exist`. Use `cd <root> && semgrep …` in one call, or pass an absolute `--config`. **Why:** #4742.
364
-
365
- **What this agent checks:**
366
-
367
- - `soleur:engineering:review:semgrep-sast`: Known vulnerability signatures (CWE patterns), hardcoded secrets, insecure function calls, taint analysis. Complements soleur:engineering:review:security-sentinel's LLM-based architectural review with deterministic rule-based scanning.
353
+ **If PR modifies source code files, soleur:engineering:review:semgrep-sast is a mandatory gate:** the seat quotes the orchestrator receipt and does not run semgrep. A docs-only or config-only range is `skip`, and that is not a clean claim.
368
354
 
369
355
  **If the resolved risk tier is `single-user incident` or `aggregate pattern`:**
370
356
 
@@ -1497,8 +1483,6 @@ Generalizing the rule above: whenever a review agent prescribes a CLI flag or su
1497
1483
 
1498
1484
  When an agent (or a plan acceptance criterion) claims a syntactic SAST rule will return 0 findings once a guard is added, verify the rule actually models the sanitizer before trusting it. Semgrep `path-join-resolve-traversal` and most public `join()`/`resolve()` matchers are purely syntactic (no taint/dataflow) — a throw-before-`join` UUID guard genuinely closes the CWE-22 vector but does NOT clear the rule: it still flags the unchanged `join()` line, and an already-guarded precedent (e.g. `workspace.ts`) trips the same rule too. Assert "vulnerability closed + 0 NET-NEW findings" (custom rules + `p/javascript` + `p/typescript`, baseline-diff-aware), never "rule X returns 0 absolute findings". **Why:** #5344/#5352. See `knowledge-base/project/learnings/2026-06-15-id-shape-guard-test-fixture-blast-radius-and-syntactic-sast.md`.
1499
1485
 
1500
- **The registry slugs are `p/javascript` / `p/typescript` — NOT `p/js` / `p/ts`.** This line said `p/js + p/ts` until #6446's review; both 404 (`https://semgrep.dev/c/p/js` → HTTP 404, `p/javascript` → 200). An invalid `--config` makes semgrep **exit 7 without scanning anything** while still reporting `findings: 0` — a vacuous clean that reads exactly like a real one. So a reviewer following this line got a security gate that silently never ran. [semgrep-custom-rules.yaml](./references/semgrep-custom-rules.yaml) already named `p/javascript` correctly, so the two sides of the same skill disagreed. **Always confirm the run was non-vacuous before trusting a clean result** — semgrep prints `Ran N rules on M files`; `N` must be non-zero for the language you are scanning (a real TS scan is ~82 rules). Corollary for bash: OSS semgrep's tree-sitter bash parser matches ~0 rules, so a "0 findings" on a `.sh`-only diff is always vacuous — use `shellcheck` instead.
1501
-
1502
1486
  When a PR's behavior depends on an external-API response shape (Sentry stats buckets, webhook payloads, list-vs-object envelopes, hourly-vs-daily resolution) AND the plan deferred the shape to a "soleur:work will live-probe" AC, do NOT trust a ticked "live-probed" AC or a "verified by probe" code comment — they are claims, not evidence. Grep the diff for a CAPTURED-response fixture; if the only evidence is prose, **re-probe the real endpoint yourself** (`hr-no-dashboard-eyeball-pull-data-yourself`) and assert the parser matches the captured bytes. **Why:** PR #5434 — `sentry-issue-rate` shipped reading `/issues/{id}/stats/?stat=14d` as daily buckets; the live re-probe showed 24 HOURLY buckets (~1 day) and that the daily series lives at the issue-detail `.stats["30d"]` — the shipped code would have understated the rate ~24× → spurious PASS → wrong auto-close. See `knowledge-base/project/learnings/integration-issues/2026-06-16-external-api-shape-ac-must-land-captured-fixture-not-probed-claim.md`.
1503
1487
 
1504
1488
  **A `source`/import line only DEFINES; it never runs.** When a test asserts that a gate is wired, asserting the `source` line proves nothing — neutering the call, deleting the invocation, or putting `if: ${{ false }}` on the step all leave the suite GREEN. Assert the **invocation** (`if ! <gate_fn> …; then exit 1`) and that the step **cannot be skipped** (no step-level `if:`, no `continue-on-error`), then mutation-verify each arm RED. Generalize the question beyond "is it called": a check that cannot emit a failure — never invoked, aimed at the wrong target, silently reinterpreted by its own tooling, or hung rather than finished — is observationally identical to one that passed, and every such state presents as green or still-running, never red. **Why:** #6977 — six such mutations each left a 102/0 green suite. See `knowledge-base/project/learnings/2026-07-27-a-check-that-cannot-report-is-indistinguishable-from-one-that-passed.md`.
@@ -0,0 +1,276 @@
1
+ #!/usr/bin/env bash
2
+ # Orchestrator scan receipt. Stdout is the status line, then file:line rule-id.
3
+ # A temp dir, when one is needed, lives under mktemp and is removed on every return.
4
+
5
+ set -u
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ ROOT="$(cd "$SCRIPT_DIR/../../../../.." && pwd)"
9
+ ENSURE="$SCRIPT_DIR/ensure-semgrep.sh"
10
+ TMP="$(mktemp -d)"
11
+
12
+ # The EXIT/INT/TERM trap below is the only caller. Shellcheck does not count a trap as a call.
13
+ # shellcheck disable=SC2329
14
+ cleanup() {
15
+ rm -rf "$TMP"
16
+ }
17
+ trap cleanup EXIT INT TERM
18
+
19
+ refuse() {
20
+ echo "SOLEUR_REVIEW_SCAN_GATE refuse engine=${1:-none} files=${2:-0} rules=${3:-0} findings=${4:-0}"
21
+ exit 1
22
+ }
23
+
24
+ if [ "${1:-}" = "--probe" ]; then
25
+ echo "SOLEUR_REVIEW_SCAN_GATE probe"
26
+ exit 0
27
+ fi
28
+
29
+ is_lock() {
30
+ case "$(basename -- "$1")" in
31
+ package-lock.json|bun.lock|yarn.lock|Cargo.lock|go.sum|Gemfile.lock|poetry.lock|uv.lock) return 0 ;;
32
+ *) return 1 ;;
33
+ esac
34
+ }
35
+
36
+ kind_of() {
37
+ local base
38
+ base="$(basename -- "$1")"
39
+ case "$base" in
40
+ *.sh|*.bash|*.zsh) printf 'shell\n'; return ;;
41
+ esac
42
+ case "$base" in
43
+ *.py|*.js|*.jsx|*.ts|*.tsx|*.mjs|*.cjs|*.rb|*.go|*.java|*.rs|*.swift|*.kt|*.kts|*.c|*.cc|*.cpp|*.h|*.hpp|*.cs|*.php|*.scala)
44
+ printf 'source\n'
45
+ return
46
+ ;;
47
+ esac
48
+ printf 'other\n'
49
+ }
50
+
51
+ is_test_path() {
52
+ case "$1" in
53
+ test/*|*/test/*) return 0 ;;
54
+ *) return 1 ;;
55
+ esac
56
+ }
57
+
58
+ line_copied_from_target() {
59
+ local line="$1" f
60
+ shift
61
+ for f in "$@"; do
62
+ [ -f "$f" ] || continue
63
+ if grep -Fxq -- "$line" "$f"; then
64
+ return 0
65
+ fi
66
+ done
67
+ return 1
68
+ }
69
+
70
+ summary_rules() {
71
+ local err="$1" rules=0 line n
72
+ shift
73
+ while IFS= read -r line || [ -n "$line" ]; do
74
+ if [[ "$line" =~ ^Ran[[:space:]]([0-9]+)[[:space:]]rules?[[:space:]]on[[:space:]]([0-9]+)[[:space:]]files? ]]; then
75
+ n="${BASH_REMATCH[1]}"
76
+ if line_copied_from_target "$line" "$@"; then
77
+ continue
78
+ fi
79
+ if [ "${BASH_REMATCH[2]}" -eq 0 ]; then
80
+ continue
81
+ fi
82
+ rules="$n"
83
+ fi
84
+ done <"$err"
85
+ printf '%s\n' "$rules"
86
+ }
87
+
88
+ sources=()
89
+ shells=()
90
+ for path in "$@"; do
91
+ [ -f "$path" ] || continue
92
+ if is_lock "$path"; then
93
+ continue
94
+ fi
95
+ case "$(kind_of "$path")" in
96
+ source) sources+=("$path") ;;
97
+ shell) shells+=("$path") ;;
98
+ *) ;;
99
+ esac
100
+ done
101
+
102
+ files=$(( ${#sources[@]} + ${#shells[@]} ))
103
+
104
+ if [ "$files" -eq 0 ]; then
105
+ echo "SOLEUR_REVIEW_SCAN_GATE skip engine=none files=0 rules=0 findings=0"
106
+ exit 0
107
+ fi
108
+
109
+ if [ "${#sources[@]}" -gt 0 ] && [ "${#shells[@]}" -gt 0 ]; then
110
+ engine="mixed"
111
+ elif [ "${#sources[@]}" -gt 0 ]; then
112
+ engine="semgrep"
113
+ else
114
+ engine="shellcheck"
115
+ fi
116
+
117
+ TMP="$(mktemp -d)"
118
+ rules=0
119
+ findings=0
120
+ finding_lines=()
121
+
122
+ if [ "${#sources[@]}" -gt 0 ]; then
123
+ if ! bash "$ENSURE" >/dev/null 2>&1; then
124
+ refuse "$engine" "$files" 0 0
125
+ fi
126
+ map="$TMP/map.tsv"
127
+ : >"$map"
128
+ scan_args=()
129
+ need_ignore=0
130
+ idx=0
131
+ for src in "${sources[@]}"; do
132
+ if is_test_path "$src"; then
133
+ need_ignore=1
134
+ ext="${src##*.}"
135
+ copy="$TMP/scan/$idx.$ext"
136
+ mkdir -p "$TMP/scan"
137
+ cp -- "$src" "$copy"
138
+ printf '%s\t%s\n' "$copy" "$src" >>"$map"
139
+ scan_args+=("$copy")
140
+ idx=$((idx + 1))
141
+ else
142
+ printf '%s\t%s\n' "$src" "$src" >>"$map"
143
+ scan_args+=("$src")
144
+ fi
145
+ done
146
+ if [ "$need_ignore" -eq 1 ]; then
147
+ : >"$TMP/scan/.semgrepignore"
148
+ fi
149
+ sem_args=(
150
+ --config=auto
151
+ --config=p/javascript
152
+ --config=p/typescript
153
+ --config=p/owasp-top-ten
154
+ --config=plugins/soleur/skills/review/references/semgrep-custom-rules.yaml
155
+ --json
156
+ --error
157
+ )
158
+ if [ "$need_ignore" -eq 1 ]; then
159
+ sem_args+=(--no-git-ignore)
160
+ fi
161
+ out="$TMP/sem.json"
162
+ err="$TMP/sem.err"
163
+ attempt=0
164
+ sem_rc=0
165
+ while [ "$attempt" -lt 2 ]; do
166
+ attempt=$((attempt + 1))
167
+ if [ "$attempt" -eq 2 ]; then
168
+ ( cd "$ROOT" && EIO_BACKEND=posix semgrep -j 1 "${sem_args[@]}" "${scan_args[@]}" >"$out" 2>"$err" )
169
+ else
170
+ ( cd "$ROOT" && semgrep "${sem_args[@]}" "${scan_args[@]}" >"$out" 2>"$err" )
171
+ fi
172
+ sem_rc=$?
173
+ if [ "$attempt" -eq 1 ] && grep -q 'io_uring_queue_init: Cannot allocate memory' "$err"; then
174
+ continue
175
+ fi
176
+ break
177
+ done
178
+ if [ "$sem_rc" -ne 0 ] && [ "$sem_rc" -ne 1 ]; then
179
+ refuse "$engine" "$files" 0 0
180
+ fi
181
+ rules="$(summary_rules "$err" "${sources[@]}")"
182
+ if [ "$rules" -eq 0 ]; then
183
+ refuse "$engine" "$files" 0 0
184
+ fi
185
+ parsed="$TMP/parsed.txt"
186
+ if ! python3 - "$out" "$map" >"$parsed" <<'PY'
187
+ import json, sys
188
+ data = json.load(open(sys.argv[1]))
189
+ mapping = {}
190
+ for raw in open(sys.argv[2]):
191
+ raw = raw.rstrip("\n")
192
+ if not raw:
193
+ continue
194
+ src, orig = raw.split("\t", 1)
195
+ mapping[src] = orig
196
+ paths = data.get("paths") or {}
197
+ scanned = paths.get("scanned") or []
198
+ print("SCANNED")
199
+ for item in scanned:
200
+ print(mapping.get(item, item))
201
+ print("FINDINGS")
202
+ for row in data.get("results") or []:
203
+ path = mapping.get(row.get("path", ""), row.get("path", ""))
204
+ start = row.get("start") or {}
205
+ line = start.get("line", 0)
206
+ rule = row.get("check_id") or "unknown"
207
+ print(f"{path}:{line} {rule}")
208
+ PY
209
+ then
210
+ refuse "$engine" "$files" 0 0
211
+ fi
212
+ mode="wait"
213
+ scanned_tmp="$TMP/scanned.list"
214
+ : >"$scanned_tmp"
215
+ while IFS= read -r row || [ -n "$row" ]; do
216
+ if [ "$row" = "SCANNED" ]; then
217
+ mode="scanned"
218
+ continue
219
+ fi
220
+ if [ "$row" = "FINDINGS" ]; then
221
+ mode="findings"
222
+ continue
223
+ fi
224
+ if [ "$mode" = "scanned" ]; then
225
+ printf '%s\n' "$row" >>"$scanned_tmp"
226
+ elif [ "$mode" = "findings" ] && [ -n "$row" ]; then
227
+ finding_lines+=("$row")
228
+ findings=$((findings + 1))
229
+ fi
230
+ done <"$parsed"
231
+ for src in "${sources[@]}"; do
232
+ if ! grep -Fxq -- "$src" "$scanned_tmp"; then
233
+ refuse "$engine" "$files" "$rules" 0
234
+ fi
235
+ done
236
+ scanned_n="$(grep -c . "$scanned_tmp" || true)"
237
+ if [ "$scanned_n" -ne "${#sources[@]}" ]; then
238
+ refuse "$engine" "$files" "$rules" 0
239
+ fi
240
+ fi
241
+
242
+ if [ "${#shells[@]}" -gt 0 ]; then
243
+ if ! command -v shellcheck >/dev/null 2>&1; then
244
+ refuse "$engine" "$files" "$rules" 0
245
+ fi
246
+ sh_out="$TMP/sh.json"
247
+ sh_err="$TMP/sh.err"
248
+ shellcheck -f json "${shells[@]}" >"$sh_out" 2>"$sh_err"
249
+ sh_rc=$?
250
+ if [ "$sh_rc" -ne 0 ] && [ "$sh_rc" -ne 1 ]; then
251
+ refuse "$engine" "$files" "$rules" 0
252
+ fi
253
+ sh_parsed="$TMP/sh-parsed.txt"
254
+ if ! python3 - "$sh_out" >"$sh_parsed" <<'PY'
255
+ import json, sys
256
+ rows = json.load(open(sys.argv[1]))
257
+ for row in rows:
258
+ code = row.get("code")
259
+ rule = f"SC{code}" if isinstance(code, int) else str(code)
260
+ print(f"{row.get('file')}:{row.get('line')} {rule}")
261
+ PY
262
+ then
263
+ refuse "$engine" "$files" "$rules" 0
264
+ fi
265
+ while IFS= read -r row || [ -n "$row" ]; do
266
+ [ -n "$row" ] || continue
267
+ finding_lines+=("$row")
268
+ findings=$((findings + 1))
269
+ done <"$sh_parsed"
270
+ fi
271
+
272
+ echo "SOLEUR_REVIEW_SCAN_GATE ok engine=${engine} files=${files} rules=${rules} findings=${findings}"
273
+ if [ "${#finding_lines[@]}" -gt 0 ]; then
274
+ printf '%s\n' "${finding_lines[@]}"
275
+ fi
276
+ exit 0
@@ -0,0 +1,517 @@
1
+ #!/usr/bin/env bash
2
+ # Hermetic receipt contract for review-scan-gate.sh. Stubs replace the two
3
+ # scanners. No network. The suite is the check for command order in the skill
4
+ # and the agent files as well as for the script's stdout.
5
+
6
+ set -u
7
+
8
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../../../../.." && pwd)"
10
+ SUT="$SCRIPT_DIR/../scripts/review-scan-gate.sh"
11
+ SKILL="$REPO_ROOT/plugins/soleur/skills/review/SKILL.md"
12
+ PASS=0
13
+ FAIL=0
14
+ TOTAL=0
15
+ DIRS=()
16
+
17
+ assert_fixture_dir() {
18
+ case "${1-}" in
19
+ "") printf 'FATAL: fixture dir is EMPTY; git -C "" would operate on %s\n' "$PWD" >&2; exit 2 ;;
20
+ */../*|*/..) printf 'FATAL: fixture dir %s contains ..; refusing\n' "$1" >&2; exit 2 ;;
21
+ /proc/*|/sys/*|/dev/*) printf 'FATAL: fixture dir %s is a synthetic-fs path; refusing\n' "$1" >&2; exit 2 ;;
22
+ /|//|/.) printf 'FATAL: fixture dir resolves to the filesystem root; refusing\n' >&2; exit 2 ;;
23
+ /*) : ;;
24
+ *) printf 'FATAL: fixture dir %s is RELATIVE; refusing\n' "$1" >&2; exit 2 ;;
25
+ esac
26
+ }
27
+
28
+ cleanup() {
29
+ local d
30
+ for d in "${DIRS[@]}"; do
31
+ [ -n "$d" ] || continue
32
+ assert_fixture_dir "$d"
33
+ rm -rf "$d"
34
+ done
35
+ }
36
+ trap cleanup EXIT
37
+
38
+ ok() { PASS=$((PASS + 1)); TOTAL=$((TOTAL + 1)); printf ' PASS: %s\n' "$1"; }
39
+ no() { FAIL=$((FAIL + 1)); TOTAL=$((TOTAL + 1)); printf ' FAIL: %s\n' "$1"; }
40
+
41
+ if [ ! -f "$SUT" ]; then
42
+ printf 'FAIL: %s is missing\n' "$SUT" >&2
43
+ exit 1
44
+ fi
45
+
46
+ new_arm() {
47
+ local dir
48
+ dir="$(mktemp -d)"
49
+ mkdir -p "$dir/bin" "$dir/work"
50
+ local name src
51
+ for name in python3 grep mktemp cp mkdir rm cat chmod basename bash head dirname; do
52
+ src="$(command -v "$name" 2>/dev/null || true)"
53
+ if [ -n "$src" ]; then
54
+ ln -sf "$src" "$dir/bin/$name"
55
+ fi
56
+ done
57
+ printf '%s\n' "$dir"
58
+ }
59
+
60
+ write_semgrep() {
61
+ local arm="$1" mode="$2"
62
+ assert_fixture_dir "$arm"
63
+ cat >"$arm/bin/semgrep" <<EOF
64
+ #!/bin/sh
65
+ printf '%s\\n' "\$*" >>"$arm/semgrep.args"
66
+ if [ "\$1" = "--version" ]; then
67
+ printf '1.181.0\\n'
68
+ exit 0
69
+ fi
70
+ : >"$arm/targets"
71
+ for a in "\$@"; do
72
+ case "\$a" in
73
+ --*) ;;
74
+ *) [ -f "\$a" ] && printf '%s\n' "\$a" >>"$arm/targets" ;;
75
+ esac
76
+ done
77
+ mode="$mode"
78
+ scans=\$(grep -c . "$arm/semgrep.args" 2>/dev/null || true)
79
+ case "\$mode" in
80
+ empty)
81
+ printf 'Nothing to scan\\n' >&2
82
+ printf '%s\\n' '{"paths":{"scanned":[]},"results":[]}'
83
+ exit 0
84
+ ;;
85
+ iouring)
86
+ if [ "\$scans" -le 2 ]; then
87
+ printf 'io_uring_queue_init: Cannot allocate memory\\n' >&2
88
+ printf '%s\\n' '{"paths":{"scanned":[]},"results":[]}'
89
+ exit 2
90
+ fi
91
+ printf 'Nothing to scan\\n' >&2
92
+ printf '%s\\n' '{"paths":{"scanned":[]},"results":[]}'
93
+ exit 0
94
+ ;;
95
+ exit7)
96
+ printf 'config error\\n' >&2
97
+ exit 7
98
+ ;;
99
+ forged)
100
+ for a in "\$@"; do
101
+ case "\$a" in
102
+ --*) ;;
103
+ *) [ -f "\$a" ] && cat "\$a" >&2 ;;
104
+ esac
105
+ done
106
+ python3 - "$arm/targets" <<'PY'
107
+ import json, sys
108
+ files=[ln.rstrip("\n") for ln in open(sys.argv[1]) if ln.strip()]
109
+ print(json.dumps({"paths":{"scanned":files},"results":[]}))
110
+ PY
111
+ exit 0
112
+ ;;
113
+ short)
114
+ first=\$(head -n 1 "$arm/targets")
115
+ printf 'Ran 2 rules on 1 files\\n' >&2
116
+ printf '{"paths":{"scanned":["%s"]},"results":[]}\\n' "\$first"
117
+ exit 0
118
+ ;;
119
+ singular)
120
+ printf 'Ran 1 rule on 2 files\\n' >&2
121
+ python3 - "$arm/targets" <<'PY'
122
+ import json, sys
123
+ files=[ln.rstrip("\n") for ln in open(sys.argv[1]) if ln.strip()]
124
+ print(json.dumps({"paths":{"scanned":files},"results":[]}))
125
+ PY
126
+ exit 0
127
+ ;;
128
+ plural)
129
+ printf 'Ran 2 rules on 2 files\\n' >&2
130
+ python3 - "$arm/targets" <<'PY'
131
+ import json, sys
132
+ files=[ln.rstrip("\n") for ln in open(sys.argv[1]) if ln.strip()]
133
+ print(json.dumps({"paths":{"scanned":files},"results":[]}))
134
+ PY
135
+ exit 0
136
+ ;;
137
+ finding)
138
+ printf 'Ran 2 rules on 1 files\\n' >&2
139
+ python3 - "$arm/targets" <<'PY'
140
+ import json, sys
141
+ files=[ln.rstrip("\n") for ln in open(sys.argv[1]) if ln.strip()]
142
+ path=files[0] if files else "missing.ts"
143
+ print(json.dumps({"paths":{"scanned":files},"results":[{"check_id":"rule.id","path":path,"start":{"line":4},"extra":{"message":"SECRETVALUE"}}]}))
144
+ PY
145
+ exit 1
146
+ ;;
147
+ *)
148
+ printf 'unhandled mode\\n' >&2
149
+ exit 2
150
+ ;;
151
+ esac
152
+ EOF
153
+ chmod +x "$arm/bin/semgrep"
154
+ }
155
+
156
+ write_shellcheck() {
157
+ local arm="$1"
158
+ assert_fixture_dir "$arm"
159
+ cat >"$arm/bin/shellcheck" <<EOF
160
+ #!/bin/sh
161
+ printf '%s\\n' "\$*" >>"$arm/shellcheck.args"
162
+ printf '[]\\n'
163
+ exit 0
164
+ EOF
165
+ chmod +x "$arm/bin/shellcheck"
166
+ }
167
+
168
+ run_gate() {
169
+ local arm="$1"
170
+ shift
171
+ env -i PATH="$arm/bin" HOME="$arm" /bin/bash "$SUT" "$@"
172
+ }
173
+
174
+ # --- script source uses the echo form the drift guard can see ---
175
+ if grep -q 'echo "SOLEUR_REVIEW_SCAN_GATE' "$SUT"; then
176
+ ok "script emits with echo quote"
177
+ else
178
+ no "script emits with echo quote"
179
+ fi
180
+ if grep -q "printf '%s'" "$SUT" && grep -q 'SOLEUR_REVIEW_SCAN_GATE' "$SUT"; then
181
+ no "printf percent-s must not be the status emitter"
182
+ else
183
+ ok "printf percent-s is not the status emitter"
184
+ fi
185
+
186
+ # --- probe ---
187
+ arm="$(new_arm)"
188
+ DIRS+=("$arm")
189
+ out="$(run_gate "$arm" --probe)"
190
+ rc=$?
191
+ if [ "$rc" -eq 0 ] && [ "$out" = "SOLEUR_REVIEW_SCAN_GATE probe" ]; then
192
+ ok "probe prints the probe token and exits 0"
193
+ else
194
+ no "probe prints the probe token and exits 0 (rc=$rc out=$out)"
195
+ fi
196
+ if [ -s "$arm/semgrep.args" ]; then
197
+ no "probe must not scan"
198
+ else
199
+ ok "probe does not scan"
200
+ fi
201
+
202
+ # --- docs only skip ---
203
+ arm="$(new_arm)"
204
+ DIRS+=("$arm")
205
+ printf '# doc\n' >"$arm/work/readme.md"
206
+ out="$(run_gate "$arm" "$arm/work/readme.md")"
207
+ rc=$?
208
+ if [ "$rc" -eq 0 ] && [ "$out" = "SOLEUR_REVIEW_SCAN_GATE skip engine=none files=0 rules=0 findings=0" ]; then
209
+ ok "docs-only list skips"
210
+ else
211
+ no "docs-only list skips (rc=$rc out=$out)"
212
+ fi
213
+
214
+ # --- lockfile beside one source file: files=1 ---
215
+ arm="$(new_arm)"
216
+ DIRS+=("$arm")
217
+ write_semgrep "$arm" plural
218
+ printf 'export const n = 1;\n' >"$arm/work/a.ts"
219
+ printf '{}\n' >"$arm/work/package-lock.json"
220
+ out="$(run_gate "$arm" "$arm/work/a.ts" "$arm/work/package-lock.json")"
221
+ rc=$?
222
+ first="$(printf '%s\n' "$out" | head -n 1)"
223
+ if [ "$rc" -eq 0 ] && [ "$first" = "SOLEUR_REVIEW_SCAN_GATE ok engine=semgrep files=1 rules=2 findings=0" ]; then
224
+ ok "lockfile does not increment files"
225
+ else
226
+ no "lockfile does not increment files (rc=$rc line=$first)"
227
+ fi
228
+
229
+ # --- singular summary ---
230
+ arm="$(new_arm)"
231
+ DIRS+=("$arm")
232
+ write_semgrep "$arm" singular
233
+ printf 'export const a = 1;\n' >"$arm/work/a.ts"
234
+ printf 'export const b = 2;\n' >"$arm/work/b.ts"
235
+ out="$(run_gate "$arm" "$arm/work/a.ts" "$arm/work/b.ts")"
236
+ rc=$?
237
+ first="$(printf '%s\n' "$out" | head -n 1)"
238
+ if [ "$rc" -eq 0 ] && [ "$first" = "SOLEUR_REVIEW_SCAN_GATE ok engine=semgrep files=2 rules=1 findings=0" ]; then
239
+ ok "singular Ran 1 rule receipts ok"
240
+ else
241
+ no "singular Ran 1 rule receipts ok (rc=$rc line=$first)"
242
+ fi
243
+
244
+ # --- empty scan refuses ---
245
+ arm="$(new_arm)"
246
+ DIRS+=("$arm")
247
+ write_semgrep "$arm" empty
248
+ printf 'export const a = 1;\n' >"$arm/work/a.ts"
249
+ out="$(run_gate "$arm" "$arm/work/a.ts" "$arm/work/b.ts" 2>/dev/null || true)"
250
+ # b.ts is absent (deletion). Only a.ts is a target. Re-run cleanly.
251
+ printf 'export const a = 1;\n' >"$arm/work/a.ts"
252
+ out="$(run_gate "$arm" "$arm/work/a.ts")"
253
+ rc=$?
254
+ first="$(printf '%s\n' "$out" | head -n 1)"
255
+ if [ "$rc" -eq 1 ] && grep -q '^SOLEUR_REVIEW_SCAN_GATE refuse ' <<<"$first"; then
256
+ ok "empty scan refuses"
257
+ else
258
+ no "empty scan refuses (rc=$rc line=$first)"
259
+ fi
260
+
261
+ # --- forged Ran line in a target body refuses ---
262
+ arm="$(new_arm)"
263
+ DIRS+=("$arm")
264
+ write_semgrep "$arm" forged
265
+ printf 'Ran 99 rules on 99 files\n' >"$arm/work/a.ts"
266
+ out="$(run_gate "$arm" "$arm/work/a.ts")"
267
+ rc=$?
268
+ first="$(printf '%s\n' "$out" | head -n 1)"
269
+ if [ "$rc" -eq 1 ] && [ "$first" = "SOLEUR_REVIEW_SCAN_GATE refuse engine=semgrep files=1 rules=0 findings=0" ]; then
270
+ ok "file body Ran line is not the summary"
271
+ else
272
+ no "file body Ran line is not the summary (rc=$rc line=$first)"
273
+ fi
274
+
275
+ # --- short paths.scanned refuses ---
276
+ arm="$(new_arm)"
277
+ DIRS+=("$arm")
278
+ write_semgrep "$arm" short
279
+ printf 'export const a = 1;\n' >"$arm/work/a.ts"
280
+ printf 'export const b = 2;\n' >"$arm/work/b.ts"
281
+ out="$(run_gate "$arm" "$arm/work/a.ts" "$arm/work/b.ts")"
282
+ rc=$?
283
+ first="$(printf '%s\n' "$out" | head -n 1)"
284
+ if [ "$rc" -eq 1 ] && grep -q '^SOLEUR_REVIEW_SCAN_GATE refuse ' <<<"$first"; then
285
+ ok "short paths.scanned refuses"
286
+ else
287
+ no "short paths.scanned refuses (rc=$rc line=$first)"
288
+ fi
289
+
290
+ # --- files=0 rules=2 shape is not an ok receipt ---
291
+ bad_line="SOLEUR_REVIEW_SCAN_GATE ok engine=semgrep files=0 rules=2 findings=0"
292
+ if grep -q 'files=0' <<<"$bad_line"; then
293
+ ok "files=0 on an ok semgrep line is a rejected shape"
294
+ else
295
+ no "files=0 on an ok semgrep line is a rejected shape"
296
+ fi
297
+
298
+ # --- a non-ts source suffix is still a target ---
299
+ arm="$(new_arm)"
300
+ DIRS+=("$arm")
301
+ write_semgrep "$arm" plural
302
+ printf 'export const a = 1;\n' >"$arm/work/a.ts"
303
+ printf 'export const b = 1;\n' >"$arm/work/b.js"
304
+ out="$(run_gate "$arm" "$arm/work/a.ts" "$arm/work/b.js")"
305
+ rc=$?
306
+ first="$(printf '%s\n' "$out" | head -n 1)"
307
+ if [ "$rc" -eq 0 ] && [ "$first" = "SOLEUR_REVIEW_SCAN_GATE ok engine=semgrep files=2 rules=2 findings=0" ]; then
308
+ ok "js suffix counts as a source target"
309
+ else
310
+ no "js suffix counts as a source target (rc=$rc line=$first)"
311
+ fi
312
+
313
+ # --- test/ copy maps back to ok ---
314
+ arm="$(new_arm)"
315
+ DIRS+=("$arm")
316
+ write_semgrep "$arm" plural
317
+ mkdir -p "$arm/work/test"
318
+ printf 'export const t = 1;\n' >"$arm/work/test/t.ts"
319
+ out="$(run_gate "$arm" "$arm/work/test/t.ts")"
320
+ rc=$?
321
+ first="$(printf '%s\n' "$out" | head -n 1)"
322
+ if [ "$rc" -eq 0 ] && [ "$first" = "SOLEUR_REVIEW_SCAN_GATE ok engine=semgrep files=1 rules=2 findings=0" ]; then
323
+ ok "mapped test path receipts ok"
324
+ else
325
+ no "mapped test path receipts ok (rc=$rc line=$first)"
326
+ fi
327
+ if grep -q -- '--no-git-ignore' "$arm/semgrep.args"; then
328
+ ok "test path uses the ignore workaround"
329
+ else
330
+ no "test path uses the ignore workaround"
331
+ fi
332
+ if grep -q "$arm/work/test/t.ts" "$arm/semgrep.args"; then
333
+ no "test path must be scanned as a copy"
334
+ else
335
+ ok "test path is scanned as a copy"
336
+ fi
337
+
338
+ # --- two test files must both be scanned ---
339
+ arm="$(new_arm)"
340
+ DIRS+=("$arm")
341
+ write_semgrep "$arm" plural
342
+ mkdir -p "$arm/work/test"
343
+ printf 'export const t = 1;\n' >"$arm/work/test/t.ts"
344
+ printf 'export const u = 2;\n' >"$arm/work/test/u.ts"
345
+ out="$(run_gate "$arm" "$arm/work/test/t.ts" "$arm/work/test/u.ts")"
346
+ rc=$?
347
+ first="$(printf '%s\n' "$out" | head -n 1)"
348
+ if [ "$rc" -eq 0 ] && [ "$first" = "SOLEUR_REVIEW_SCAN_GATE ok engine=semgrep files=2 rules=2 findings=0" ]; then
349
+ ok "both test files map back"
350
+ else
351
+ no "both test files map back (rc=$rc line=$first)"
352
+ fi
353
+ arm="$(new_arm)"
354
+ DIRS+=("$arm")
355
+ write_semgrep "$arm" short
356
+ mkdir -p "$arm/work/test"
357
+ printf 'export const t = 1;\n' >"$arm/work/test/t.ts"
358
+ printf 'export const u = 2;\n' >"$arm/work/test/u.ts"
359
+ out="$(run_gate "$arm" "$arm/work/test/t.ts" "$arm/work/test/u.ts")"
360
+ rc=$?
361
+ first="$(printf '%s\n' "$out" | head -n 1)"
362
+ if [ "$rc" -eq 1 ] && grep -q '^SOLEUR_REVIEW_SCAN_GATE refuse ' <<<"$first"; then
363
+ ok "a short test-file scan refuses"
364
+ else
365
+ no "a short test-file scan refuses (rc=$rc line=$first)"
366
+ fi
367
+
368
+ # --- exit 7 refuses ---
369
+ arm="$(new_arm)"
370
+ DIRS+=("$arm")
371
+ write_semgrep "$arm" exit7
372
+ printf 'export const a = 1;\n' >"$arm/work/a.ts"
373
+ out="$(run_gate "$arm" "$arm/work/a.ts")"
374
+ rc=$?
375
+ first="$(printf '%s\n' "$out" | head -n 1)"
376
+ if [ "$rc" -eq 1 ] && grep -q '^SOLEUR_REVIEW_SCAN_GATE refuse ' <<<"$first"; then
377
+ ok "semgrep exit 7 refuses"
378
+ else
379
+ no "semgrep exit 7 refuses (rc=$rc line=$first)"
380
+ fi
381
+
382
+ # --- io_uring retry still empty refuses, and the retry happened ---
383
+ arm="$(new_arm)"
384
+ DIRS+=("$arm")
385
+ write_semgrep "$arm" iouring
386
+ printf 'export const a = 1;\n' >"$arm/work/a.ts"
387
+ out="$(run_gate "$arm" "$arm/work/a.ts")"
388
+ rc=$?
389
+ first="$(printf '%s\n' "$out" | head -n 1)"
390
+ scan_lines="$(grep -c -- '--json' "$arm/semgrep.args" || true)"
391
+ if [ "$rc" -eq 1 ] && grep -q '^SOLEUR_REVIEW_SCAN_GATE refuse ' <<<"$first" && [ "$scan_lines" -ge 2 ]; then
392
+ ok "io_uring retry that stays empty refuses"
393
+ else
394
+ no "io_uring retry that stays empty refuses (rc=$rc scans=$scan_lines line=$first)"
395
+ fi
396
+
397
+ # --- finding line has no matched source ---
398
+ arm="$(new_arm)"
399
+ DIRS+=("$arm")
400
+ write_semgrep "$arm" finding
401
+ printf 'export const secret = "SECRETVALUE";\n' >"$arm/work/a.ts"
402
+ out="$(run_gate "$arm" "$arm/work/a.ts")"
403
+ rc=$?
404
+ first="$(printf '%s\n' "$out" | head -n 1)"
405
+ second="$(printf '%s\n' "$out" | sed -n '2p')"
406
+ if [ "$rc" -eq 0 ] && [ "$first" = "SOLEUR_REVIEW_SCAN_GATE ok engine=semgrep files=1 rules=2 findings=1" ] && [ "$second" = "$arm/work/a.ts:4 rule.id" ] && ! grep -q 'SECRETVALUE' <<<"$out"; then
407
+ ok "findings are file:line rule-id and do not stop"
408
+ else
409
+ no "findings are file:line rule-id and do not stop (rc=$rc out=$out)"
410
+ fi
411
+
412
+ # --- shellcheck not executed refuses ---
413
+ arm="$(new_arm)"
414
+ DIRS+=("$arm")
415
+ printf 'echo hi\n' >"$arm/work/a.sh"
416
+ out="$(run_gate "$arm" "$arm/work/a.sh")"
417
+ rc=$?
418
+ first="$(printf '%s\n' "$out" | head -n 1)"
419
+ if [ "$rc" -eq 1 ] && grep -q '^SOLEUR_REVIEW_SCAN_GATE refuse ' <<<"$first"; then
420
+ ok "shell-only without shellcheck refuses"
421
+ else
422
+ no "shell-only without shellcheck refuses (rc=$rc line=$first)"
423
+ fi
424
+
425
+ # --- shellcheck executed receipts ok rules=0 ---
426
+ arm="$(new_arm)"
427
+ DIRS+=("$arm")
428
+ write_shellcheck "$arm"
429
+ printf 'echo hi\n' >"$arm/work/a.sh"
430
+ out="$(run_gate "$arm" "$arm/work/a.sh")"
431
+ rc=$?
432
+ first="$(printf '%s\n' "$out" | head -n 1)"
433
+ if [ "$rc" -eq 0 ] && [ "$first" = "SOLEUR_REVIEW_SCAN_GATE ok engine=shellcheck files=1 rules=0 findings=0" ] && grep -q "$arm/work/a.sh" "$arm/shellcheck.args"; then
434
+ ok "shellcheck argv includes the shell target"
435
+ else
436
+ no "shellcheck argv includes the shell target (rc=$rc line=$first)"
437
+ fi
438
+
439
+ # --- mixed without shellcheck refuses ---
440
+ arm="$(new_arm)"
441
+ DIRS+=("$arm")
442
+ write_semgrep "$arm" plural
443
+ printf 'export const a = 1;\n' >"$arm/work/a.ts"
444
+ printf 'echo hi\n' >"$arm/work/a.sh"
445
+ out="$(run_gate "$arm" "$arm/work/a.ts" "$arm/work/a.sh")"
446
+ rc=$?
447
+ first="$(printf '%s\n' "$out" | head -n 1)"
448
+ if [ "$rc" -eq 1 ] && grep -q '^SOLEUR_REVIEW_SCAN_GATE refuse ' <<<"$first"; then
449
+ ok "mixed range without shellcheck refuses"
450
+ else
451
+ no "mixed range without shellcheck refuses (rc=$rc line=$first)"
452
+ fi
453
+
454
+ # --- skill command order ---
455
+ script_line="$(grep -n 'review-scan-gate.sh' "$SKILL" | head -n 1 | cut -d: -f1)"
456
+ task_line="$(grep -n 'Task soleur:' "$SKILL" | head -n 1 | cut -d: -f1)"
457
+ if [ -n "$script_line" ] && [ -n "$task_line" ] && [ "$script_line" -lt "$task_line" ]; then
458
+ ok "skill runs the script before the first seat"
459
+ else
460
+ no "skill runs the script before the first seat (script=$script_line task=$task_line)"
461
+ fi
462
+ if grep -q 'design-validity' "$SKILL" && grep -q 'SOLEUR_REVIEW_SCAN_GATE' "$SKILL" && grep -q 'fix range' "$SKILL"; then
463
+ ok "skill names the design-validity pass, the receipt, and the fix range"
464
+ else
465
+ no "skill names the design-validity pass, the receipt, and the fix range"
466
+ fi
467
+ if grep -q 'shellcheck seat' "$SKILL"; then
468
+ ok "skill tells the shellcheck seat to quote the receipt"
469
+ else
470
+ no "skill tells the shellcheck seat to quote the receipt"
471
+ fi
472
+
473
+ # --- agents ---
474
+ canon="$REPO_ROOT/plugins/soleur/agents/engineering/review/semgrep-sast.md"
475
+ cursor="$REPO_ROOT/plugins/soleur/cursor/agents/soleur-engineering-review-semgrep-sast.md"
476
+ opencode="$REPO_ROOT/plugins/soleur/opencode/agents/engineering/review/semgrep-sast.md"
477
+ sentinel="$REPO_ROOT/plugins/soleur/agents/engineering/review/security-sentinel.md"
478
+ if grep -q 'receipt' "$canon" && ! grep -q 'bootstrapped semgrep' "$canon" && ! grep -q -- '--config=p/javascript' "$canon"; then
479
+ ok "canonical seat reports the receipt and does not run semgrep"
480
+ else
481
+ no "canonical seat reports the receipt and does not run semgrep"
482
+ fi
483
+ if grep -q 'receipt' "$cursor" && ! grep -q 'bootstrapped semgrep' "$cursor" && grep -q 'receipt' "$opencode" && ! grep -q 'bootstrapped semgrep' "$opencode"; then
484
+ ok "cursor and opencode descriptions no longer say the seat runs semgrep"
485
+ else
486
+ no "cursor and opencode descriptions no longer say the seat runs semgrep"
487
+ fi
488
+ if grep -q 'findings=0' "$sentinel"; then
489
+ ok "security-sentinel requires the ok receipt"
490
+ else
491
+ no "security-sentinel requires the ok receipt"
492
+ fi
493
+ phrase='classified source-and-shell count'
494
+ if grep -q "$phrase" "$SKILL" && grep -q "$phrase" "$sentinel" && grep -q "$phrase" "$canon"; then
495
+ ok "zero-finding claim names the classified count"
496
+ else
497
+ no "zero-finding claim names the classified count"
498
+ fi
499
+
500
+ # --- marker registration ---
501
+ marker="$REPO_ROOT/apps/web-platform/server/git-lock-marker-telemetry.ts"
502
+ if grep -q 'SOLEUR_REVIEW_SCAN_GATE' "$marker" && grep -q 'createGitLockMarkerHook' "$marker" && ! grep -q 'SOLEUR_REVIEW_SCAN_GATE' <(awk '/const WEDGE_RE/,/;/' "$marker"); then
503
+ ok "marker is mirrored and not paged"
504
+ else
505
+ no "marker is mirrored and not paged"
506
+ fi
507
+
508
+ # --- workflow stays unwired ---
509
+ workflow="$REPO_ROOT/plugins/soleur/skills/review/workflows/review.workflow.js"
510
+ if grep -q 'review-scan-gate.sh' "$workflow"; then
511
+ no "workflow must stay unwired"
512
+ else
513
+ ok "workflow stays unwired"
514
+ fi
515
+
516
+ printf '\n=== review-scan-gate.test.sh: %s passed, %s failed (%s assertions) ===\n' "$PASS" "$FAIL" "$TOTAL"
517
+ [ "$FAIL" -eq 0 ]