@soleur/opencode 3.399.2 → 3.399.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soleur/opencode",
3
- "version": "3.399.2",
3
+ "version": "3.399.4",
4
4
  "description": "Soleur AI organization plugin for OpenCode",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env bash
2
+ # run-health-emit.sh — upsert a phase entry into run_health.json + snapshot prompt text.
3
+ # Usage:
4
+ # run-health-emit.sh --run-dir <dir> [--run-id <id>] [--issue <N>] [--branch <b>] [--harness <h>]
5
+ # --phase <name> --status <started|completed|failed|budget-capped>
6
+ # [--prompt-file <path>] [--error <msg>] [--reviewed-coverage <v>]
7
+ # Idempotent: re-invoking with the same phase updates the existing entry rather than duplicating.
8
+ # Storage is under .soleur/runs/<run-id>/ (gitignored). Emission failures are non-fatal: the
9
+ # script exits 0 on best-effort write errors after printing a warning to stderr.
10
+ set -u
11
+
12
+ RUN_DIR=""
13
+ RUN_ID=""
14
+ ISSUE=""
15
+ BRANCH=""
16
+ HARNESS="${SOLEUR_HARNESS:-unknown}"
17
+ PHASE=""
18
+ STATUS=""
19
+ PROMPT_FILE=""
20
+ ERROR_MSG=""
21
+ REVIEWED_COVERAGE=""
22
+
23
+ while [[ $# -gt 0 ]]; do
24
+ case "$1" in
25
+ --run-dir) RUN_DIR="$2"; shift 2 ;;
26
+ --run-id) RUN_ID="$2"; shift 2 ;;
27
+ --issue) ISSUE="$2"; shift 2 ;;
28
+ --branch) BRANCH="$2"; shift 2 ;;
29
+ --harness) HARNESS="$2"; shift 2 ;;
30
+ --phase) PHASE="$2"; shift 2 ;;
31
+ --status) STATUS="$2"; shift 2 ;;
32
+ --prompt-file) PROMPT_FILE="$2"; shift 2 ;;
33
+ --error) ERROR_MSG="$2"; shift 2 ;;
34
+ --reviewed-coverage) REVIEWED_COVERAGE="$2"; shift 2 ;;
35
+ *) echo "run-health-emit: unknown arg $1" >&2; shift ;;
36
+ esac
37
+ done
38
+
39
+ if [[ -z "$RUN_DIR" || -z "$PHASE" || -z "$STATUS" ]]; then
40
+ echo "run-health-emit: --run-dir, --phase, --status required" >&2
41
+ exit 0
42
+ fi
43
+
44
+ mkdir -p "$RUN_DIR/phase_prompts" 2>/dev/null || { echo "run-health-emit: cannot create $RUN_DIR" >&2; exit 0; }
45
+
46
+ HEALTH="$RUN_DIR/run_health.json"
47
+ NOW="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
48
+
49
+ # Resolve run metadata: prefer existing file, then args, then defaults.
50
+ if [[ -z "$RUN_ID" ]]; then
51
+ if [[ -f "$HEALTH" ]]; then
52
+ RUN_ID="$(python3 -c "import json,sys;print(json.load(open('$HEALTH')).get('run_id',''))" 2>/dev/null)"
53
+ fi
54
+ [[ -z "$RUN_ID" ]] && RUN_ID="$(basename "$RUN_DIR")"
55
+ fi
56
+ [[ -z "$BRANCH" ]] && BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)"
57
+ [[ -z "$ISSUE" ]] && ISSUE=""
58
+
59
+ python3 - "$HEALTH" "$RUN_ID" "$ISSUE" "$BRANCH" "$HARNESS" "$PHASE" "$STATUS" "$NOW" "$ERROR_MSG" "$REVIEWED_COVERAGE" "$PROMPT_FILE" "$RUN_DIR" <<'PY' 2>/dev/null || echo "run-health-emit: python write failed (non-fatal)" >&2
60
+ import json, os, sys, shutil
61
+
62
+ (health, run_id, issue, branch, harness, phase, status, now, err, rcov, prompt_file, run_dir) = sys.argv[1:13]
63
+
64
+ data = {}
65
+ if os.path.exists(health):
66
+ try:
67
+ with open(health) as f:
68
+ data = json.load(f)
69
+ except Exception:
70
+ data = {}
71
+
72
+ data.setdefault("run_id", run_id)
73
+ data.setdefault("issue", issue)
74
+ data.setdefault("branch", branch)
75
+ data.setdefault("harness", harness)
76
+ data.setdefault("started_at", now)
77
+ data.setdefault("phases", [])
78
+ data.setdefault("errors", [])
79
+ if rcov:
80
+ data["reviewed_coverage"] = rcov
81
+
82
+ # Find existing phase entry.
83
+ entry = None
84
+ for p in data["phases"]:
85
+ if p.get("phase") == phase:
86
+ entry = p
87
+ break
88
+ if entry is None:
89
+ entry = {"phase": phase, "started_at": now}
90
+ data["phases"].append(entry)
91
+
92
+ entry["status"] = status
93
+ if status in ("completed", "failed", "budget-capped"):
94
+ entry["ended_at"] = now
95
+ elif "started_at" not in entry:
96
+ entry["started_at"] = now
97
+
98
+ if err:
99
+ entry.setdefault("errors", []).append({"at": now, "msg": err})
100
+ data["errors"].append({"phase": phase, "at": now, "msg": err})
101
+
102
+ if status in ("completed", "failed", "budget-capped") and not data.get("completed_at"):
103
+ # only seal completed_at when terminal status on the final phase; leave open otherwise
104
+ pass
105
+
106
+ # Seal completed_at only when status is a terminal run status.
107
+ if status in ("completed", "failed", "budget-capped"):
108
+ # heuristic: seal if phase looks like a finalizer name
109
+ if phase.lower() in ("8", "ship", "done", "final", "exit", "terminate"):
110
+ data["completed_at"] = now
111
+ data["status"] = status
112
+
113
+ # Snapshot prompt file (append-only per attempt).
114
+ if prompt_file and os.path.exists(prompt_file):
115
+ pp_dir = os.path.join(run_dir, "phase_prompts")
116
+ os.makedirs(pp_dir, exist_ok=True)
117
+ base = os.path.join(pp_dir, f"{phase}.md")
118
+ if os.path.exists(base):
119
+ # find next attempt number
120
+ n = 2
121
+ while os.path.exists(os.path.join(pp_dir, f"{phase}.attempt-{n}.md")):
122
+ n += 1
123
+ dest = os.path.join(pp_dir, f"{phase}.attempt-{n}.md")
124
+ else:
125
+ dest = base
126
+ shutil.copyfile(prompt_file, dest)
127
+ entry["prompt_snapshot"] = os.path.relpath(dest, run_dir)
128
+
129
+ # Write atomically.
130
+ tmp = health + ".tmp"
131
+ with open(tmp, "w") as f:
132
+ json.dump(data, f, indent=2)
133
+ f.write("\n")
134
+ os.replace(tmp, health)
135
+ PY
136
+
137
+ exit 0
138
+ PY
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env bash
2
+ # Tests for run-health-emit.sh
3
+
4
+ set -uo pipefail
5
+ export TMPDIR="${TMPDIR:-/var/tmp}"
6
+
7
+ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ SUT="$DIR/run-health-emit.sh"
9
+
10
+ TMP="$(mktemp -d -t runhealth.XXXXXXXX)" || { echo "mktemp failed" >&2; exit 2; }
11
+ trap 'rm -rf "$TMP"' EXIT
12
+
13
+ passes=0; fails=0
14
+ pass() { passes=$((passes + 1)); printf ' ok %s\n' "$1"; }
15
+ fail() { fails=$((fails + 1)); printf ' FAIL %s\n' "$1"; [[ -n "${2:-}" ]] && printf ' %s\n' "$2"; return 0; }
16
+
17
+ # Case 1: creates run_health.json with required fields
18
+ RD="$TMP/run1"
19
+ printf 'prompt text' > "$TMP/p.md"
20
+ bash "$SUT" --run-dir "$RD" --run-id r1 --issue 12573 --branch b --harness opencode --phase 0 --status started --prompt-file "$TMP/p.md"
21
+ if [[ -f "$RD/run_health.json" ]] && python3 -c "import json,sys; d=json.load(open('$RD/run_health.json')); sys.exit(0 if d['run_id']=='r1' and d['issue']=='12573' and len(d['phases'])==1 else 1)"; then
22
+ pass "creates run_health.json with required fields"
23
+ else
24
+ fail "creates run_health.json with required fields"
25
+ fi
26
+
27
+ # Case 2: idempotent upsert (same phase updates, no duplicate)
28
+ bash "$SUT" --run-dir "$RD" --phase 0 --status completed
29
+ N=$(python3 -c "import json; print(len(json.load(open('$RD/run_health.json'))['phases']))")
30
+ if [[ "$N" == "1" ]]; then pass "idempotent upsert (no duplicate phase)"; else fail "idempotent upsert" "got $N"; fi
31
+
32
+ # Case 3: prompt snapshot created and not overwritten on retry
33
+ if [[ -f "$RD/phase_prompts/0.md" ]] && grep -q "prompt text" "$RD/phase_prompts/0.md"; then
34
+ pass "prompt snapshot created"
35
+ else
36
+ fail "prompt snapshot created"
37
+ fi
38
+
39
+ # Case 4: retry creates attempt-2 file, preserves original
40
+ printf 'retry prompt' > "$TMP/p2.md"
41
+ bash "$SUT" --run-dir "$RD" --phase 0 --status started --prompt-file "$TMP/p2.md"
42
+ if [[ -f "$RD/phase_prompts/0.attempt-2.md" ]] && grep -q "retry prompt" "$RD/phase_prompts/0.attempt-2.md" && grep -q "prompt text" "$RD/phase_prompts/0.md"; then
43
+ pass "retry preserves original snapshot"
44
+ else
45
+ fail "retry preserves original snapshot"
46
+ fi
47
+
48
+ # Case 5: missing required args exits 0 (non-fatal)
49
+ bash "$SUT" --run-dir "$RD" 2>/dev/null; rc=$?
50
+ if [[ "$rc" == "0" ]]; then pass "missing args non-fatal"; else fail "missing args non-fatal" "rc=$rc"; fi
51
+
52
+ echo "passes=$passes fails=$fails"
53
+ [[ "$fails" -eq 0 ]]
@@ -62,6 +62,7 @@ Fix commits are the least-audited surface in the pipeline (learnings 2026-09-23,
62
62
  The script's path→seat map is the single source for both consumers: it also defines the `none`-tier trigger-gating predicates (the seat fires iff the diff touches a path its map arm covers). Add `soleur:engineering:review:security-sentinel` whenever the fix diff touches `SENSITIVE_PATH_RE` — that arm is mechanical — OR adds guard/deny-shaped lines, which is lead judgment (the script maps paths only). A source-touching fix never resolves to zero seats — the script emits the `soleur:engineering:review:code-quality-analyst` floor on unmatched source paths, and lists them on stderr as `unmapped-paths:`; an empty fix diff emits nothing (`note: empty fix diff` on stderr) and legitimately spawns zero seats. Pass `--files` from the fix commits' own range (`git diff $PANEL_SHA <last-fix-sha>`), never `$PANEL_SHA..HEAD` after a merge of `origin/main`: the merge's files are other people's changes, and on #10285 they turned a 9-file fix round into a 147-file seat resolution.
63
63
  3. **Report-only spawn** against `git diff $PANEL_SHA..HEAD` — the FIX diff, not the branch diff. **Tally (#9403):** fix-round seats are review seats — `gate seats <N>` (N = the resolved seat count) before dispatch and `incr seats <N>` after, on the branch ledger; a `STOP` verdict is the classified-stop path (write `status: budget-capped` + `budget-capped: seats=<n>/<cap>` to the feature's `session-state.md` and halt — do not silently shrink the round).
64
64
  4. **Cap two targeted rounds.** A third needed round escalates to the full class panel over the cumulative fix diff — an unbounded targeted loop is the treadmill this mechanism exists to prevent.
65
+ When a round's findings against a pin test are SIBLING shapes of the last round's, the defect is the test's claim, not its coverage: rule its contract (what it guards, what it leaves open) and state the residuals in its header before fixing more shapes; a later shape inside a stated residual is recorded as "covered by R<n>". **Why:** #12348/PR #12561 — three rounds each re-found "a prior step or the env replaces what the gate runs"; stating the residuals (plus two class fixes) let the final pass terminate. See `knowledge-base/project/learnings/2026-11-11-each-fix-round-found-the-next-sibling-until-the-test-stated-its-residuals.md`.
65
66
  5. **One verification pass** after the last round: a single fresh-eyes verifier seat answers "does each fix commit close its finding, and did any fix introduce a defect in its own area?", plus the lead's affected-gate run (`scripts/test-all.sh --affected`; `TEST_GROUP=affected` is its deprecated alias, #8621).
66
67
  6. **Invocation:** `soleur:review <PR> --fix-round --since <sha>` runs only the targeted round + verification pass — `soleur:one-shot` Step 5 calls this after its resolver-agent commits land. `--since` is the panel snapshot; when it is absent (a bare invocation, or a rebase invalidated it) recover the base as **the parent of the oldest `review:`/`fix`-subject commit since the merge-base, else the merge-base itself** — and report which base was used. The fix round attests via `emit-review-trailer.sh --fix-round --since <base>` (`Reviewed-Fix-Round:`/`Reviewed-Fix-Range:` keys — never `Reviewed-Coverage:`). The range's effective head is derived by attestation-TRAILER presence, never by `review:`-prefixed subjects — `review: <summary> (P<N>)` is this repo's prescribed fix-commit subject, so a subject filter silently excludes real fixes. A standalone/fresh-session invocation has no access to the prior session's dedup ledger — without it the round degrades to path-mapped seats only (no `--finding-seats` union); that is the known, fail-safe direction and should be reported. A fix round attests ONLY via `--fix-round` keys: the branch-level `Reviewed-By-Soleur`/`Reviewed-Coverage` trailer must already exist from the main panel — absent, that is the anomaly (a fix round without a panel), report it, never emit a main trailer for a targeted round. Its commit subject is `review-fix-round:`, deliberately NOT matching the merge gate's legacy `review:` evidence regex — a targeted round is not branch-level review evidence.
67
68
 
@@ -24,6 +24,16 @@ Autonomous test-fix iteration loop. Run the test suite, diagnose failures, apply
24
24
  - NOT for writing new tests (use `atdd-developer`)
25
25
  - NOT for linting, type-checking, or non-test failures
26
26
 
27
+ ## Run Health Emission (Phase 1 prerequisite, #12573)
28
+
29
+ This skill MUST emit a sealed run-health artifact so the degraded-run forensics agent (#12574) can correlate prompts to failures from disk. Contract: `plugins/soleur/skills/one-shot/references/run-health-schema.md` (shared).
30
+
31
+ - Run id: `<branch>-tfl-<utc-timestamp>`; storage: `.soleur/runs/<run-id>/` (gitignored).
32
+ - At Phase 0 (after test command detection), initialize `RUN_DIR` and emit phase `0` status `started` (snapshot the detected command + args).
33
+ - At each iteration's Parse/Cluster/Fix boundaries and at every termination condition, emit the corresponding phase (`iter-N-parse`, `iter-N-fix`, `terminate`) with status.
34
+ - On termination (success or failure), emit phase `exit` with status `completed`/`failed` and record remaining failures via `--error`.
35
+ - Emission is best-effort and never blocks the loop (helper exits 0 on write errors).
36
+
27
37
  ## Phase 0: Detect and Confirm
28
38
 
29
39
  ### Detect Test Runner
@@ -90,7 +90,7 @@ template rather than shipping the monolith.
90
90
  | `supabase-loopback-warn.sh` | soleur-coupled | Supabase vendor stack check (ADR-153). |
91
91
  | `worktree-write-guard.sh` | generic-after-extraction | Blocks writes to the main checkout while worktrees exist — repo-generic idea (v2); couplings = `incidents.sh`/`hook-input.sh` sourcing. |
92
92
 
93
- ## Census — `scripts/lint-*` (48)
93
+ ## Census — `scripts/lint-*` (51)
94
94
 
95
95
  | File | Verdict | Rationale |
96
96
  |---|---|---|
@@ -104,6 +104,7 @@ template rather than shipping the monolith.
104
104
  | `lint-bot-synthetic-statuses.sh` | generic-after-extraction | `[skip ci]` ban on bot PRs is generic (v2); same named exemptions. |
105
105
  | `lint-conversations-update-callsites.sh` | soleur-coupled | `apps/web-platform/server` module boundary. |
106
106
  | `lint-credential-path-literals.py` | soleur-coupled | SCAN_DIRS = `plugins/` + `knowledge-base/`. |
107
+ | `lint-cve-safe-status.py` | soleur-coupled | `SCAN_ROOT` = `knowledge-base/`, file-count floor sized to this repo; ADR-322. |
107
108
  | `lint-diagnosis-claims.sh` | generic-after-extraction | "CI message may not name a cause the job did not measure" is generic (v2); scope names `apps/web-platform/infra/`. |
108
109
  | `lint-distribution-content.sh` | soleur-coupled | `knowledge-base/marketing/distribution-content/` marker lint. |
109
110
  | `lint-doppler-description-length.py` | soleur-coupled | Doppler description contract over `*.tf`. |
@@ -90,3 +90,5 @@ already carries — see
90
90
  - **A bash regex RANGE follows the locale, and a probe that tests a LINE must prove the token is absent from that line's prose.** `[[ x =~ ^[0-9a-f]{40}$ ]]` accepted 39 hex digits plus an accented letter under `LC_ALL=en_US.utf8` (bash 5.3) and rejected it under `C`/`C.UTF-8`: pin `LC_ALL=C` function-locally for any security-relevant validation and fixture a non-ASCII letter under a collating locale (a mutant that deletes the pin is killable only where that locale exists, so fail rather than skip on CI). A follow-through probe grepping a command line for `headSha` returned PASS on the unfixed tree because the same line carries the prose "by headSha/createdAt": parse the `--json` field list, require exactly one matching line, and run the probe once against the real file expecting the UNFIXED verdict plus a lookalike and a decoy-comment fixture. **Why:** #12320/PR #12350 — see `knowledge-base/project/learnings/2026-11-08-a-locale-ordered-regex-range-and-a-probe-that-matched-the-prose-on-its-own-line.md`.
91
91
 
92
92
  - **When a verification's VERDICT is the deliverable, do not bound its wall — a timeout kill is `unknown`, never pass or fail.** A `ratchet`/suite verify re-run under a self-imposed `timeout`/bounded exec was killed at 120 s mid-run and could have been misread either direction; re-run unbounded and let it finish. Bound the SUT's per-invocation calls (a `REPLAY_SUT_TIMEOUT`-style knob), never the verification harness itself. **Why:** PR #12419 — see `knowledge-base/project/learnings/performance-issues/mutant-side-runaway-read-as-pristine-site-cost-ci-replay-20261108.md` session error 4.
93
+
94
+ - **A suite run is evidence for the tree it ran on — re-run the touched suites after the LAST edit of the commit, comment-only edits included.** A comment can trip a strict substring pin: a test-all.sh comment naming an array that contains a refused prefix turned the lint's unit suite red at the pushed head, after the suite had run green one edit earlier. **Why:** #12348/PR #12561 — all 11 escalation seats found it; see `knowledge-base/project/learnings/2026-11-11-each-fix-round-found-the-next-sibling-until-the-test-stated-its-residuals.md`.