@soleur/opencode 3.393.2 → 3.393.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.
Files changed (26) hide show
  1. package/package.json +1 -1
  2. package/scripts/ci-head-verdict.sh +1 -1
  3. package/scripts/monitor-pr-checks.sh +2 -2
  4. package/scripts/required-set-report.sh +150 -0
  5. package/scripts/required-set-report.test.sh +583 -0
  6. package/skills/agent-browser/test/playwright-mcp-redact-proxy.test.sh +3 -3
  7. package/skills/compound/scripts/token-efficiency-report.sh +1 -1
  8. package/skills/constraint-scaffold/scripts/constraint-scaffold.sh +1 -1
  9. package/skills/linear-fetch/scripts/assert-no-linear-telemetry.sh +2 -2
  10. package/skills/linear-fetch/scripts/redact-linear-urls.sh +1 -1
  11. package/skills/merge-pr/SKILL.md +35 -2
  12. package/skills/model-launch-review/scripts/audit-models.sh +1 -1
  13. package/skills/operator-bootstrap/template.sh +2 -1
  14. package/skills/postmerge/SKILL.md +2 -2
  15. package/skills/postmerge/references/phase4-false-alarm-history.md +5 -0
  16. package/skills/product-roadmap/scripts/roadmap-reconcile.sh +1 -1
  17. package/skills/provision-cloudflare/scripts/provision-cloudflare.sh +1 -1
  18. package/skills/provision-doppler/scripts/provision-doppler.sh +1 -1
  19. package/skills/provision-github/scripts/provision-github.sh +3 -3
  20. package/skills/review/references/risk-tier-and-fix-rounds.md +1 -0
  21. package/skills/seo-aeo/scripts/validate-seo.sh +1 -1
  22. package/skills/ship/SKILL.md +47 -14
  23. package/skills/ship/references/adr-ordinal-collision.md +6 -0
  24. package/skills/ship/references/monitor-hygiene.md +11 -0
  25. package/skills/ship/references/ready-run-wait.md +9 -5
  26. package/skills/skill-security-scan/scripts/check-telemetry-surface.sh +2 -2
@@ -116,14 +116,14 @@ session() {
116
116
  }
117
117
  fact() { python3 "$FACTS" "$@" 2>/dev/null || printf 'ERR'; }
118
118
  rcof() { cat "$1/rc" 2>/dev/null || printf 'none'; }
119
- stderr_has() { [[ -f "$1/stderr.txt" ]] && grep -qF -- "$2" "$1/stderr.txt"; } # file, never a pipe
120
- stdout_has() { [[ -f "$1/stdout.bin" ]] && grep -qaF -- "$2" "$1/stdout.bin"; }
119
+ stderr_has() { [[ -f "$1/stderr.txt" ]] || return 1; grep -qF -- "$2" "$1/stderr.txt"; } # file, never a pipe
120
+ stdout_has() { [[ -f "$1/stdout.bin" ]] || return 1; grep -qaF -- "$2" "$1/stdout.bin"; }
121
121
  # leaks <out> <id> — a response for <id> was DELIVERED and carries the sentinel
122
122
  leaks() { [[ "$(fact "$1" "$2" found)" == "1" && "$(fact "$1" "$2" sentinel)" != "0" ]]; }
123
123
  # delivered_ok <out> <id> — a RESULT for <id> was delivered: not a JSON-RPC error, not an isError result
124
124
  delivered_ok() { [[ "$(fact "$1" "$2" found)" == "1" && "$(fact "$1" "$2" jsonrpc_error)" == "0" && "$(fact "$1" "$2" isError)" != "true" ]]; }
125
125
  # started <out> — the proxy got past startup: not a refusal, and it logged the child
126
- started() { [[ "$(rcof "$1")" != "2" && "$(rcof "$1")" != "none" ]] && stderr_has "$1" 'child pgid'; }
126
+ started() { [[ "$(rcof "$1")" != "2" && "$(rcof "$1")" != "none" ]] || return 1; stderr_has "$1" 'child pgid'; }
127
127
  text_has() { [[ "$(fact "$1" "$2" text)" == *"$3"* ]]; }
128
128
  # `A && B` as a function's last list trips `set -e` when B fails, and pkill on an already-empty group fails
129
129
  reap_group() { local pg; pg="$(cat "$1/child_pgid" 2>/dev/null || true)"; if [[ -n "$pg" ]]; then pkill -KILL -g "$pg" 2>/dev/null || true; fi; }
@@ -98,7 +98,7 @@ LINES=0
98
98
 
99
99
  if [[ -s "$SHORTSTAT_TMP" ]]; then
100
100
  LINES=$(grep -oE '[0-9]+ (insertion|deletion)' "$SHORTSTAT_TMP" \
101
- | grep -oE '[0-9]+' | awk '{s+=$1} END {print s+0}')
101
+ | grep -oE '[0-9]+' | awk '{s+=$1} END {print s+0}') || true
102
102
  fi
103
103
 
104
104
  if (( LINES < SKIP_LINES_THRESHOLD )); then
@@ -100,7 +100,7 @@ esac
100
100
  # on founder hosts where `realpath -m` does not exist (BSD/macOS). Prints nothing on a missing dir.
101
101
  physdir() { ( cd -- "$1" 2>/dev/null && pwd -P ); }
102
102
  # physpath <path>: physical path of a file that may not exist yet, via its (existing) parent.
103
- physpath() { local d; d="$(physdir "$(dirname -- "$1")")" || return 1; [[ -n "$d" ]] && printf '%s/%s' "$d" "$(basename -- "$1")"; }
103
+ physpath() { local d; d="$(physdir "$(dirname -- "$1")")" || return 1; [[ -n "$d" ]] || return 1; printf '%s/%s' "$d" "$(basename -- "$1")"; }
104
104
  # assert_fixture_dir: the CANONICAL copy (byte-for-byte; fixture-dir-operand-assert.test.sh pins every copy). It refuses an
105
105
  # empty, relative, `..`-bearing or filesystem-root operand; the stage-a refresh calls it before each write.
106
106
  assert_fixture_dir() {
@@ -45,7 +45,7 @@ fi
45
45
 
46
46
  # Pattern 1: Linear issue identifier shape.
47
47
  if grep -qE '\b[A-Z]{2,}-[0-9]+\b' <<<"$input"; then
48
- match=$(printf '%s' "$input" | grep -oE '\b[A-Z]{2,}-[0-9]+\b' | head -n 1)
48
+ match=$(printf '%s' "$input" | grep -oE '\b[A-Z]{2,}-[0-9]+\b' | head -n 1) || true
49
49
  echo "FAIL: telemetry payload contains Linear identifier shape: $match" >&2
50
50
  exit 1
51
51
  fi
@@ -58,7 +58,7 @@ fi
58
58
 
59
59
  # Pattern 3: UUID-style ID (Linear's internal issue UUIDs).
60
60
  if grep -qE '\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b' <<<"$input"; then
61
- match=$(printf '%s' "$input" | grep -oE '\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b' | head -n 1)
61
+ match=$(printf '%s' "$input" | grep -oE '\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b' | head -n 1) || true
62
62
  echo "FAIL: telemetry payload contains UUID-style identifier: $match" >&2
63
63
  exit 1
64
64
  fi
@@ -43,7 +43,7 @@ input=$(cat -)
43
43
  count=0
44
44
  output="$input"
45
45
  for pattern in "${LINEAR_CDN_PATTERNS[@]}"; do
46
- matches=$(printf '%s' "$output" | grep -oE "$pattern" | wc -l | tr -d '[:space:]')
46
+ matches=$(printf '%s' "$output" | grep -oE "$pattern" | wc -l | tr -d '[:space:]') || true
47
47
  count=$((count + matches))
48
48
  output=$(printf '%s' "$output" | sed -E "s#$pattern#[linear-image: REDACTED]#g")
49
49
  done
@@ -415,12 +415,16 @@ if [[ "$sync_ok" -eq 1 ]]; then
415
415
  sync_ok=0
416
416
  fi
417
417
  fi
418
- # ADR-276 S3 (#9728): the head-verdict resolver is read independent of sync_ok/SYNC_SNAP (mirror of ship Phase 7).
418
+ # ADR-276 S3 (#9728): the head-verdict resolver is read independent of sync_ok/SYNC_SNAP (mirror of ship Phase 7). (The required-set dwell
419
+ # below is the exception: its samples sit inside the SYNC_SNAP guard.)
419
420
  VERDICT_OK=0
420
421
  if [[ -n "$SYNC_ROOT" && -r "$SYNC_ROOT/scripts/ci-head-verdict.sh" ]] \
421
422
  && grep -q '"name"[[:space:]]*:[[:space:]]*"soleur"' "$SYNC_ROOT/.claude-plugin/plugin.json" 2>/dev/null; then
422
423
  VERDICT_OK=1
423
424
  fi
425
+ # Required-set read (#11544; mirror of ship Phase 7): a green dwell of RS_AFTER ticks, at most RS_MAX reads; parsing lives in required-set-report.sh.
426
+ RS_AFTER=10; RS_MAX=3; rs_hold=0; rs_reads=0; rs_v=""
427
+ RS_SH="$SYNC_ROOT/scripts/required-set-report.sh"
424
428
  # REQUIRED_CHECKS is fetched once, fail-open: empty array → no-op scan
425
429
  # (see ship/SKILL.md Phase 7 for the full rationale; do NOT harden).
426
430
  mapfile -t REQUIRED_CHECKS < <(gh api 'repos/{owner}/{repo}/rules/branches/main' \
@@ -446,6 +450,13 @@ while true; do
446
450
  echo "$s" | grep -qE "^(MERGED|CLOSED|fetch-error)" && break
447
451
  if (( i % 5 == 0 )) && [[ "$s" == OPEN* && -n "$SYNC_SNAP" ]]; then
448
452
  qs="$(bash "$SYNC_SNAP" "$PR" --queue-state 2>/dev/null || true)"
453
+ rs_v=""
454
+ if [[ "$s" == "OPEN BLOCKED" && "$qs" == "not_queued OPEN armed "* && "$VERDICT_OK" -eq 1 ]] && (( rs_reads < RS_MAX )); then
455
+ rs_to=""; command -v timeout >/dev/null 2>&1 && rs_to="timeout -k 5 60"
456
+ rs_vo="$($rs_to bash "$SYNC_ROOT/scripts/ci-head-verdict.sh" verdict "$PR" 2>/dev/null)" || rs_vo=""
457
+ rs_vl="$(grep -m1 '^SOLEUR_CI_HEAD_VERDICT ' <<<"$rs_vo")" || rs_vl=""
458
+ rs_v="${rs_vl#*state=}"; rs_v="${rs_v%% *}"
459
+ fi
449
460
  [[ "$qs" == dequeued* ]] && { echo "$(date +%H:%M:%S) [${i}/${MAX_POLL_MIN}] [ship.phase7.dequeued] PR $PR left the merge queue unmerged ($qs). Stopping the poll; see ${CLAUDE_PLUGIN_ROOT}/skills/ship/references/merge-queue-dequeue.md"; break; }
450
461
  [[ "$QUEUE_RULE" -eq 1 && "$qs" == queued* && "$queued_reported" -eq 0 ]] && { queued_reported=1; echo "$(date +%H:%M:%S) [${i}/${MAX_POLL_MIN}] [ship.phase7.queued] PR $PR is in the merge queue ($qs) — no sync from here (a push would dequeue it); waiting for MERGED or removal"; }
451
462
  [[ "$QUEUE_RULE" -eq 1 && "$qs" == queued* ]] && qidle=0
@@ -482,6 +493,28 @@ while true; do
482
493
  fi
483
494
  fi
484
495
 
496
+ # Required-set read (#11544; see ship Phase 7): green dwell of RS_AFTER gate-holding ticks, then one read, at most RS_MAX.
497
+ if [[ "$s" == "OPEN BLOCKED" && "$rs_v" == full-decided ]]; then rs_hold=$((rs_hold+1)); else rs_hold=0; fi
498
+ if (( rs_hold >= RS_AFTER && rs_reads < RS_MAX )); then
499
+ rs_reads=$((rs_reads+1)); rs_hold=0; rs_state=""; rs_reason=""; rs_own=0
500
+ echo "$(date +%H:%M:%S) [${i}/${MAX_POLL_MIN}] [ship.phase7.required_set] PR $PR has been BLOCKED for ${RS_AFTER} ticks with auto-merge armed, not queued and a full-decided verdict: required-set read ${rs_reads}/${RS_MAX} (up to ~125s; this poll is alive, do not stop or re-arm it)"
501
+ while IFS= read -r rs_line; do
502
+ echo "$rs_line"; [[ "$rs_line" == "REQUIRED-SET READ"* ]] && rs_own=1
503
+ [[ "$rs_line" == "SOLEUR_CI_REQUIRED_SET state="* ]] && { rs_state="${rs_line#*state=}"; rs_state="${rs_state%% *}"; rs_reason="${rs_line#*reason=}"; rs_reason="${rs_reason%% *}"; }
504
+ done < <(bash "$RS_SH" "$PR" 2>/dev/null)
505
+ case "$rs_state" in
506
+ absent|failed)
507
+ echo "$(date +%H:%M:%S) [${i}/${MAX_POLL_MIN}] [ship.phase7.required_set] state=${rs_state} — exiting poll. The RECOVERY lines above are hints; this poll ran none. Read ${CLAUDE_PLUGIN_ROOT}/skills/ship/references/ready-run-wait.md (A green verdict that never enqueues) before acting; do not sync or re-arm."
508
+ break ;;
509
+ *)
510
+ [[ -z "$rs_state" && "$rs_own" -eq 0 ]] && echo "REQUIRED-SET READ — no marker: the report script printed nothing (state=error); by-hand read: ${CLAUDE_PLUGIN_ROOT}/skills/ship/references/ready-run-wait.md"
511
+ rs_state="${rs_state:-error}"; rs_t="$(date +%H:%M:%S) [${i}/${MAX_POLL_MIN}] [ship.phase7.required_set] state=${rs_state}"
512
+ if (( rs_reads < RS_MAX )); then echo "$rs_t — polling on ($((RS_MAX - rs_reads)) required-set reads left)."
513
+ else echo "$rs_t — read budget spent (${RS_MAX}/${RS_MAX}), no more reads: state this marker and the --queue-state output (ready-run-wait.md, Bound) in your next status message; polling continues."; fi
514
+ [[ "$rs_state" == error && "$rs_reason" == untrusted-ci ]] && echo "$rs_t reason=untrusted-ci: a PR that edits workflows has no agent --admin hatch; tell the operator in chat." ;;
515
+ esac
516
+ fi
517
+
485
518
  real_behind=0; [[ "$s" == "OPEN BEHIND" ]] && real_behind=1
486
519
 
487
520
  if [[ "$s" == *DIRTY* ]]; then
@@ -612,7 +645,7 @@ To rollback: git reset --hard <starting-sha> && git push --force-with-lease orig
612
645
 
613
646
  ```
614
647
 
615
- The state-machine details (`mergeStateStatus` enum coverage, fail-open required-check fetch, fixture at `plugins/soleur/test/ship-phase-7-poll-fixtures.test.sh`) are documented in `plugins/soleur/skills/ship/SKILL.md` Phase 7. When the poll prints `[ship.phase7.hatch_check]` (2 BEHIND syncs pushed) or `[ship.phase7.behind_exhausted]`, read [settle-then-admin-merge.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/settle-then-admin-merge.md) for the settle-then-admin-merge escape hatch (zero-conflict-surface changes only). Any `--admin` merge, whether through this hatch or authorized by the operator, requires `"${CLAUDE_PLUGIN_ROOT}/scripts/admin-merge-ready.sh" <PR> <sha>` to exit 0 immediately before it and `--match-head-commit <sha>` on the merge; `gh pr checks --required` is not a substitute, because it cannot see a required check that has not been created yet (#8458, #8500). When the operator authorizes `--admin` on a BEHIND PR whose prior head was green, the surface classifier is waived but the gate is not: `--green-sha <prior-green-sha>` carries the certification to the new head only if it is GitHub's own verified merge of that sha and the base (see the reference's "was-green carryover" section); for a hand-made local unsigned merge — the #9401 disjoint-skip leaves the green head itself intact, so it needs no carryover — `--allow-local-merge` admits it only when the added delta is a byte-identical docs-only replay disjoint from the PR's files. UNTRUSTED-CI and DIRTY still refuse. On `[ship.phase7.required_failed]` or `[ship.phase7.dirty]`, follow ship/SKILL.md Phase 7's handling for a poll that exits on a required-check failure or a DIRTY state (`gh pr checks <N>` to inspect; `git merge origin/main` to resolve locally). On a `[ship.phase7.sync_failed]` line ending `Stopping the poll.` (a `kind=fetch` one is informational — the poll continues), do the next action the `[pr-behind-sync] kind=…` line above it names (resolve and push, reconcile a concurrent push, or clear the worktree state), then re-invoke this §5.2 poll — a routine conflict is not an operator handoff. `[ship.phase7.sync_noop]` is GitHub state lag or a PR in the merge queue (uncounted; the poll continues; never push to a queued PR); a `sync_failed` line with `kind=dequeued` means the PR left the queue unmerged: follow the recovery on that line (see ${CLAUDE_PLUGIN_ROOT}/skills/ship/references/merge-queue-dequeue.md, also for a poll that times out OPEN and not queued); `[ship.phase7.behind_no_sync]` means auto-sync was disabled — run the printed command from the PR worktree, then re-arm the poll. `[ship.phase7.queue_wait]` is informational: `main` has a merge queue and the PR is armed, so the poll waits for GitHub to enqueue it instead of syncing (a push restarts CI and dequeues a queued PR) — take no action and never sync, update-branch or merge it by hand until `[ship.phase7.queue_wait_expired]`, a push line, MERGED, a dequeue or any poll exit; `[ship.phase7.queued]` prints once, at the first 5th-tick read that finds the PR in the queue; `[ship.phase7.queue_wait_expired]` means no required check is pending and this poll's last queue read did not show the PR queued, so the poll fell back to the BEHIND auto-sync — keep the Monitor running, diagnose (merge-queue-dequeue.md, the PR timeline), record the strict up-to-date question in the final report and do not change the ruleset (ship/SKILL.md Phase 7, "Queue mode").
648
+ The state-machine details (`mergeStateStatus` enum coverage, fail-open required-check fetch, fixture at `plugins/soleur/test/ship-phase-7-poll-fixtures.test.sh`) are documented in `plugins/soleur/skills/ship/SKILL.md` Phase 7. When the poll prints `[ship.phase7.hatch_check]` (2 BEHIND syncs pushed) or `[ship.phase7.behind_exhausted]`, read [settle-then-admin-merge.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/settle-then-admin-merge.md) for the settle-then-admin-merge escape hatch (zero-conflict-surface changes only). Any `--admin` merge, whether through this hatch or authorized by the operator, requires `"${CLAUDE_PLUGIN_ROOT}/scripts/admin-merge-ready.sh" <PR> <sha>` to exit 0 immediately before it and `--match-head-commit <sha>` on the merge; `gh pr checks --required` is not a substitute, because it cannot see a required check that has not been created yet (#8458, #8500). When the operator authorizes `--admin` on a BEHIND PR whose prior head was green, the surface classifier is waived but the gate is not: `--green-sha <prior-green-sha>` carries the certification to the new head only if it is GitHub's own verified merge of that sha and the base (see the reference's "was-green carryover" section); for a hand-made local unsigned merge — the #9401 disjoint-skip leaves the green head itself intact, so it needs no carryover — `--allow-local-merge` admits it only when the added delta is a byte-identical docs-only replay disjoint from the PR's files. UNTRUSTED-CI and DIRTY still refuse. On `[ship.phase7.required_failed]` or `[ship.phase7.dirty]`, follow ship/SKILL.md Phase 7's handling for a poll that exits on a required-check failure or a DIRTY state (`gh pr checks <N>` to inspect; `git merge origin/main` to resolve locally). On a `[ship.phase7.sync_failed]` line ending `Stopping the poll.` (a `kind=fetch` one is informational — the poll continues), do the next action the `[pr-behind-sync] kind=…` line above it names (resolve and push, reconcile a concurrent push, or clear the worktree state), then re-invoke this §5.2 poll — a routine conflict is not an operator handoff. `[ship.phase7.sync_noop]` is GitHub state lag or a PR in the merge queue (uncounted; the poll continues; never push to a queued PR); a `sync_failed` line with `kind=dequeued` means the PR left the queue unmerged: follow the recovery on that line (see ${CLAUDE_PLUGIN_ROOT}/skills/ship/references/merge-queue-dequeue.md, also for a poll that times out OPEN and not queued); `[ship.phase7.behind_no_sync]` means auto-sync was disabled — run the printed command from the PR worktree, then re-arm the poll. `[ship.phase7.queue_wait]` is informational: `main` has a merge queue and the PR is armed, so the poll waits for GitHub to enqueue it instead of syncing (a push restarts CI and dequeues a queued PR) — take no action and never sync, update-branch or merge it by hand until `[ship.phase7.queue_wait_expired]`, a push line, MERGED, a dequeue or any poll exit; `[ship.phase7.queued]` prints once, at the first 5th-tick read that finds the PR in the queue; `[ship.phase7.queue_wait_expired]` means no required check is pending and this poll's last queue read did not show the PR queued, so the poll fell back to the BEHIND auto-sync — keep the Monitor running, diagnose (merge-queue-dequeue.md, the PR timeline), record the strict up-to-date question in the final report and do not change the ruleset (ship/SKILL.md Phase 7, "Queue mode"). `[ship.phase7.required_set]` is the required-set read of ship Phase 7 (green dwell, at most 3 reads; `absent` or `failed` end the poll, anything else keeps it polling, and the third read says `read budget spent`: report the marker and `--queue-state` in your next status message; the lines it prints are hints, never run; after a recovery re-invoke this poll): follow ship/SKILL.md Phase 7 "Required-set read" and read [ready-run-wait.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/ready-run-wait.md) before acting.
616
649
 
617
650
  ## Phase 6: Cleanup and Report
618
651
 
@@ -341,7 +341,7 @@ if [[ ${#pins[@]} -gt 0 ]]; then
341
341
  # UNKNOWN — never as "the pin is fresh".
342
342
  if command -v gh >/dev/null 2>&1; then
343
343
  _tip="$(gh api repos/anthropics/claude-code-action/releases --jq '.[0].tag_name' 2>/dev/null || true)"
344
- _pin_sha="$(grep -ohE 'claude-code-action@[a-f0-9]{40}' "${pins[@]}" 2>/dev/null | head -1 | cut -d@ -f2)"
344
+ _pin_sha="$(grep -ohE 'claude-code-action@[a-f0-9]{40}' "${pins[@]}" 2>/dev/null | head -1 | cut -d@ -f2)" || true
345
345
  # These pins are annotated TAG objects, so git/tags resolves them. A pin
346
346
  # produced by pin-github-action/Dependabot is a plain COMMIT sha, where
347
347
  # git/tags 404s and commits/<sha> is the correct call — try both.
@@ -354,7 +354,8 @@ read_account() {
354
354
  example_resource_exists() {
355
355
  # REPLACE with the vendor read. The stand-in consults the local record only
356
356
  # because this template has no vendor to ask.
357
- [[ -f "$ENV_FILE" ]] && grep -aq '^EXAMPLE_PROVISIONED=' "$ENV_FILE"
357
+ [[ -f "$ENV_FILE" ]] || return 1
358
+ grep -aq '^EXAMPLE_PROVISIONED=' "$ENV_FILE"
358
359
  }
359
360
 
360
361
  plan_provision() {
@@ -58,7 +58,7 @@ Check the latest CI run on main triggered by the merge:
58
58
  gh run list --branch main --limit 3 --json databaseId,status,conclusion,headSha
59
59
  ```
60
60
 
61
- Find the run matching the merge commit SHA. If no matching run yet, poll with the harness adapter (max 5 minutes) — **Claude:** Monitor tool; **Grok:** AwaitShell/Shell per `pollInstructions()`. Do NOT ask the operator to watch CI. Do NOT use Bash `run_in_background`:
61
+ Find the run matching the merge commit SHA. If no matching run yet, poll with the harness adapter (max 5 minutes) — **Claude:** Monitor tool; **Grok:** AwaitShell/Shell per `pollInstructions()`. Do NOT ask the operator to watch CI. Do NOT use Bash `run_in_background` (Monitor rules: [monitor-hygiene.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/monitor-hygiene.md)):
62
62
 
63
63
  ```bash
64
64
  for i in $(seq 1 20); do
@@ -357,7 +357,7 @@ complete before any had started.
357
357
 
358
358
  `git rev-parse --short main` next to `git rev-parse --short origin/main` is the cheap tell when a result looks wrong. Prefer the merge SHA unconditionally: it is immutable, it is the exact tree that merged, and it cannot drift while the phase runs. `origin/main` is an acceptable second choice only immediately after a fetch, and even then a sibling merge can move it mid-phase.
359
359
 
360
- Compare against expectations from the PR description and review. Flag if any file content seems stale or doesn't reflect the PR changes. **Why:** PR #7240 — Phase 4 read `git show main:` while local `main` sat 2 commits behind, reported the PR's own new learning file as MISSING, and the same stale ref undercounted `blkid` occurrences 2-vs-8 in a file the PR had rewritten. **And PR #7770** — Phase 4 addressed the merge SHA correctly, as the paragraphs above instruct, and still reported all 5 spot-checked files MISSING: the worktree had not fetched the merge commit, and git's `exists on disk, but not in <sha>` wording was read as a verdict about the tree. One `git fetch` made all 5 read correctly. Both failures are the same shape — Phase 4 manufacturing a false alarm about the merge it exists to confirm — reached by two different routes, which is why the fetch and the message table above are both load-bearing.
360
+ Compare against expectations from the PR description and review. Flag if any file content seems stale or doesn't reflect the PR changes. **Why:** PRs #7240 and #7770 — a stale local `main` and an unfetched merge commit each made Phase 4 report the PR's own files MISSING, so the fetch and the message table above are both load-bearing ([history](./references/phase4-false-alarm-history.md)).
361
361
 
362
362
  ## Phase 5: Browser Verification (Conditional)
363
363
 
@@ -0,0 +1,5 @@
1
+ # Phase 4 false alarms: why the fetch and the message table are load-bearing
2
+
3
+ Moved out of `postmerge/SKILL.md` Phase 4 to keep the body under its ceiling (ADR-229); SKILL.md keeps the one-line rule and a pointer. Edited on the move: the positional words ("above") now name the Phase 4 paragraphs and message table in SKILL.md.
4
+
5
+ **Why:** PR #7240 — Phase 4 read `git show main:` while local `main` sat 2 commits behind, reported the PR's own new learning file as MISSING, and the same stale ref undercounted `blkid` occurrences 2-vs-8 in a file the PR had rewritten. **And PR #7770** — Phase 4 addressed the merge SHA correctly, as the Phase 4 paragraphs in SKILL.md instruct, and still reported all 5 spot-checked files MISSING: the worktree had not fetched the merge commit, and git's `exists on disk, but not in <sha>` wording was read as a verdict about the tree. One `git fetch` made all 5 read correctly. Both failures are the same shape — Phase 4 manufacturing a false alarm about the merge it exists to confirm — reached by two different routes, which is why the fetch and the Phase 4 message table are both load-bearing.
@@ -58,7 +58,7 @@ extract_phase_counts() {
58
58
  | while IFS= read -r line; do
59
59
  grep -qE '[0-9]+ open, [0-9]+ closed' <<<"$line" || continue
60
60
  num="$(printf '%s\n' "$line" | sed -E 's/^\| Phase ([0-9]+).*/\1/')"
61
- counts="$(printf '%s\n' "$line" | grep -oE '[0-9]+ open, [0-9]+ closed' | head -1)"
61
+ counts="$(printf '%s\n' "$line" | grep -oE '[0-9]+ open, [0-9]+ closed' | head -1)" || true
62
62
  open="$(printf '%s\n' "$counts" | sed -E 's/^([0-9]+) open.*/\1/')"
63
63
  closed="$(printf '%s\n' "$counts" | sed -E 's/^[0-9]+ open, ([0-9]+) closed/\1/')"
64
64
  printf '%s|%s|%s\n' "$num" "$open" "$closed"
@@ -259,7 +259,7 @@ VERIFY_RESULT=$(
259
259
 
260
260
  CREATED_RESOURCES+=("cd ${PROVISIONING_DIR} && terraform destroy")
261
261
 
262
- TOKEN_STATUS=$(echo "$VERIFY_RESULT" | grep -o '"status":"[^"]*"' | cut -d'"' -f4)
262
+ TOKEN_STATUS=$(echo "$VERIFY_RESULT" | grep -o '"status":"[^"]*"' | cut -d'"' -f4) || true
263
263
  if [[ "$TOKEN_STATUS" == "active" ]]; then
264
264
  echo "Smoke-test passed: scoped token is active."
265
265
  else
@@ -279,7 +279,7 @@ echo ""
279
279
  -d "$SA_PAYLOAD"
280
280
  )
281
281
 
282
- SA_SLUG=$(echo "$SA_RESPONSE" | grep -o '"slug":"[^"]*"' | head -1 | cut -d'"' -f4)
282
+ SA_SLUG=$(echo "$SA_RESPONSE" | grep -o '"slug":"[^"]*"' | head -1 | cut -d'"' -f4) || true
283
283
  if [[ -z "$SA_SLUG" ]]; then
284
284
  echo "Error: Failed to create service account. Response:" >&2
285
285
  echo "$SA_RESPONSE" >&2
@@ -277,8 +277,8 @@ read -p "App installed? Type 'yes': " ACK
277
277
  # --- Verify App install ---
278
278
 
279
279
  INSTALL_JSON=$(gh api "/repos/${TENANT_ORG}/${SLUG}/installation" 2>/dev/null) || true
280
- INSTALL_CHECK=$(echo "$INSTALL_JSON" | grep -o '"actions":"[^"]*"' | head -1 | cut -d'"' -f4)
281
- REPO_SELECTION=$(echo "$INSTALL_JSON" | grep -o '"repository_selection":"[^"]*"' | head -1 | cut -d'"' -f4)
280
+ INSTALL_CHECK=$(echo "$INSTALL_JSON" | grep -o '"actions":"[^"]*"' | head -1 | cut -d'"' -f4) || true
281
+ REPO_SELECTION=$(echo "$INSTALL_JSON" | grep -o '"repository_selection":"[^"]*"' | head -1 | cut -d'"' -f4) || true
282
282
 
283
283
  if [[ "$REPO_SELECTION" == "all" ]]; then
284
284
  echo "ERROR: App installed org-wide (repository_selection=all). Must be 'selected' (single repo)." >&2
@@ -287,7 +287,7 @@ if [[ "$REPO_SELECTION" == "all" ]]; then
287
287
  fi
288
288
 
289
289
  if [[ "$INSTALL_CHECK" == "write" ]]; then
290
- INSTALL_ID=$(echo "$INSTALL_JSON" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
290
+ INSTALL_ID=$(echo "$INSTALL_JSON" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2) || true
291
291
  CREATED_RESOURCES+=("gh api -X DELETE /app/installations/${INSTALL_ID}")
292
292
  echo "Verified: Soleur App installed with actions:write permission (repository_selection=${REPO_SELECTION:-selected})."
293
293
  else
@@ -112,3 +112,4 @@ The canonical defect key is `defect-class + rolled-up root cause`, **not** file-
112
112
 
113
113
  - **Brief every seat to stop its own processes by PID, and ban `pkill -x` as well as `pkill -f`.** The guard hook blocks only the `-f` form, so a seat that ran `pkill -x python3` could have killed another seat's mutation job on the same host; seats also share scratchpad file names unless each takes its own subdirectory. **Why:** #12148 — a code-quality seat's `pkill -x python3` plus a shared `mut.py` name, with seven parallel seats on a host at load 26. See `knowledge-base/project/learnings/2026-11-05-a-skip-keyed-on-the-record-not-on-the-success-made-a-false-sent-and-four-sibling-defects-the-review-found.md`.
114
114
  - **A fix that changes how a probe calls a faked CLI keeps flags AFTER the endpoint.** Repo fake-`gh` fixtures read the endpoint positionally (`ep="$2"` right after `api`); a flag placed before it silently becomes the endpoint, every fixture arm misses, and the probe reports `fail`/CANNOT ESTABLISH — an upstream-outage signature for what is a fixture-contract break. The correct shape is `api "<endpoint>" --paginate --jq ...`. **Why:** #9323 fix round (PR #12439). See `knowledge-base/project/learnings/workflow-patterns/2026-11-08-escape-is-a-job-family-verdict-and-adopted-collects-verify-per-idx.md`.
115
+ - **Brief a fix agent with the ARM x LOOSENING table, not the instance the seat named.** A seat reports one arm of a multi-arm predicate (one RECOVERY shape, one stream, one consumer); the fix closes that arm and every later verification round re-finds the next sibling, while a count-style negative assertion cannot name which row failed. Before dispatch, list every arm of the predicate and every other consumer of the same input, require one negative row and one surviving-mutant check per cell, and for a hand-copied grammar require a drift row against its source. **Why:** #12476 — the pointer/`pending=`/`stale-row` arms and a single-pass sanitiser (nested NEL/LS/PS re-forms) were each found in a later round than the arm the first seat named. See `knowledge-base/project/learnings/2026-11-09-a-fix-round-closes-the-instance-the-reviewer-named-and-leaves-its-sibling-arms.md`.
@@ -112,7 +112,7 @@ if [[ -f "$SITE_DIR/sitemap.xml" ]]; then
112
112
  # check above; production robots.txt always has the line.
113
113
  if [[ -f "$SITE_DIR/robots.txt" ]] && grep -qiE '^Sitemap:' "$SITE_DIR/robots.txt"; then
114
114
  ROBOTS_HOST=$(grep -iE '^Sitemap:' "$SITE_DIR/robots.txt" \
115
- | sed -E 's|^[Ss]itemap:[[:space:]]*(https?://[^/]+).*|\1|' | head -1)
115
+ | sed -E 's|^[Ss]itemap:[[:space:]]*(https?://[^/]+).*|\1|' | head -1) || true
116
116
  if [[ "$SITEMAP_HOSTS" != "$ROBOTS_HOST" ]]; then
117
117
  fail "sitemap host ($SITEMAP_HOSTS) does not match robots.txt Sitemap line ($ROBOTS_HOST)"
118
118
  else
@@ -23,7 +23,7 @@ description: "This skill should be used when preparing a feature for production
23
23
  **You own merge through production verification — never ask the operator to monitor.**
24
24
 
25
25
  1. Phase 7: poll PR merge to `MERGED` (auto-merge queue, BEHIND sync, required-check failure exit).
26
- 2. **After merge — gate on the SERVED sha, not a run's conclusion:** wait for the **deploy arm** (`bash plugins/soleur/scripts/deploy-arm.sh find --wait <full-merge-sha>` — never `head_sha=` alone, #8492; the push arm only builds) until `find` prints a final line (rc ≠ 4) — `DEPLOY=success` → require `CI=success` and `deploy-arm.sh served <merge>` → `CONTAINS` before ANY post-deploy action (cron trigger, marker read, live-verify); `skipped` → nothing deployed, go to step 3; any other `DEPLOY`/`ARM=none` → step 3 reports it. Job *presence* discriminates nothing (the push arm lists `deploy` as `skipped`). Predicate + bash: `postmerge/SKILL.md` Phase 3.7; topology: Phase 7 "RETIRED by #5806 / ADR-217". Run post-merge from a detached `origin/main` worktree (`git fetch origin main && git -C "$(git rev-parse --git-common-dir)/.." worktree add --detach .worktrees/postmerge-<PR> origin/main`), never the feature worktree — `cleanup-merged` reaps it once its lease lapses (#8136). **Why:** #8276 — push arm green, a production cron fired against the previous build, 50 min polling for a marker it could not emit.
26
+ 2. **After merge — gate on the SERVED sha, not a run's conclusion:** wait for the **deploy arm** (`bash plugins/soleur/scripts/deploy-arm.sh find --wait <full-merge-sha>` — never `head_sha=` alone, #8492; the push arm only builds) until `find` prints a final line (rc ≠ 4) — `DEPLOY=success` → require `CI=success` and `deploy-arm.sh served <merge>` → `CONTAINS` before ANY post-deploy action (cron trigger, marker read, live-verify); `skipped` → nothing deployed, go to step 3; any other `DEPLOY`/`ARM=none` → step 3 reports it. Job *presence* discriminates nothing (the push arm lists `deploy` as `skipped`). Predicate + bash: `postmerge/SKILL.md` Phase 3.7; topology: Phase 7 "RETIRED by #5806 / ADR-217". Run post-merge from a detached `origin/main` worktree (`git fetch origin main && git -C "$(git rev-parse --git-common-dir)/.." worktree add --detach .worktrees/postmerge-<PR> origin/main`), never the feature worktree — `cleanup-merged` reaps it once its lease lapses (#8136). **Why:** #8276 — push arm green, a production cron fired against the previous build, 50 min polling for a marker it could not emit. Arming a Monitor: [monitor-hygiene.md](./references/monitor-hygiene.md).
27
27
  3. Step 3.8: invoke `soleur:postmerge <PR-number>` (Grok) or `soleur:postmerge` (Claude) **before** Step 4 cleanup.
28
28
  4. **FORBIDDEN:** Ending the session at merge, at a red release run you did not investigate, or with "want me to watch CI?"
29
29
  5. **Harness polling:** `plugins/soleur/lib/harness.ts` → `pollInstructions()` — Claude uses **Monitor tool**; Grok uses **AwaitShell** (`pattern` for `MERGED`, `BEHIND detected`, `auto-sync.*pushed`, `\[ship\.phase7\.`, `\[pr-behind-sync\] kind=`, `postmerge verification complete`) or blocking Shell with `block_until_ms`.
@@ -464,7 +464,7 @@ it. The battery you start on the final tree is the only local run there will be.
464
464
 
465
465
  **Under contention, launch first and let [battery-refusal-wait.sh](./scripts/battery-refusal-wait.sh) bound the wait; never probe `--capacity` in one tool call and launch in the next.** A refusal exits within seconds, so launch at once (arm the Monitor with `persistent: true`; `WAITING` lines are progress only); on rc=4 with the sibling-run text the script waits at most 30 min (budget shared across relaunches) and exits 10 (capacity idle: relaunch), 42 (CI is the gate: record the PR Test plan line, continue), 12 (queue inside the lock) or 11 (stop); only 42 continues. Recipe and record line: [battery-refusal-wait.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/battery-refusal-wait.md). Exit 12 (infra diff, unresolved diff, `--full`, or a `force-all` log) means the local run is the sole blocking gate: launch `SOLEUR_ALLOW_FULL_GATE=1 TC_LOCK_TIMEOUT=14400 TC_RUNTIME_CEILING_S=39600 bash scripts/test-all.sh --full` (same rc-file wrapper; a bare `bash scripts/test-all.sh` is only the affected run): the FIFO ticket queue serializes you and `LOCK_WAIT_HEARTBEAT`/`position=N` lines prove you are queued, not hung. **Why:** PR #8135 — two probe-then-launch attempts lost the race by seconds; PR #8354 — the zero-wait loop sat 110 min while four worktrees started runs, and the lock-queued form acquired after 87 min.
466
466
 
467
- **Identify the runner by its rc file, never by a pid and never by shape.** `tc_acquire` forks its heartbeat as a background subshell, so during a lock wait there are two `bash scripts/test-all.sh` processes with the same argv, cwd and fds; the heartbeat's fingerprint is a lone `sleep <n>` child and a silent self-exit at exactly the lock budget. If the wrapper's rc file reads 143 while such a process is still writing heartbeats, the runner is dead and the rc file is its verdict — a live runner whose budget expired would have printed `LOCK_CONTENDED_PROCEEDING` and run the battery unserialized beside the holder (the false-RED shape; expiry never aborts). Launch with `setsid nohup … &` (the new session is what keeps a group-kill off the runner), have the script write its rc as its LAST act, and wait on that FILE: `setsid nohup bash -c 'bash "${CLAUDE_PLUGIN_ROOT}/scripts/affected-tests.sh" > "$1" 2>&1; echo $? > "$2"' _ "$LOG" "$RCF" >/dev/null 2>&1 &` (or `--full` under `FULL_BATTERY`) then `until [ -s "$RCF" ]; do sleep 30; done`. **Do NOT watch `$!` — it does not track the runner.** `setsid` forks when it is not already a process-group leader, so `$!` is a short-lived parent that exits in under a second while the battery runs on, and a `kill -0 $!` loop falls through immediately: every line after it then reports a verdict for a run that has not finished. (When the rc lands or the wait misbehaves, load [detached-battery-verdict.md](./references/detached-battery-verdict.md).) Measured 2026-09-17 with both controls — under `setsid` the pid was gone after 1 s with the runner still working, and the same launch WITHOUT `setsid` kept `$!` alive and tracking correctly, which is what makes the cause the fork rather than the timing. Observed live: `BATTERY COMPLETE rc=1` printed for a battery that had died in under a second on a mise shim fault and never ran a single suite — rc=1 with no `[FAIL]` lines reads exactly like "the battery ran and one suite failed". This is the #8137 trap below one level up: there the watched process was the runner’s own heartbeat subshell, here it is `setsid`’s forked parent, and in both the pid you can see is not the runner. The rc file is already this skill’s stated source of truth ("Read the rc file, never the background-task completion notification"), so polling it is what makes the wait agree with the verdict. **And rc is only a test verdict once the toolchain started:** grep the log for `mise ERROR|command not found` first — a shim with no resolved version exits 1 emitting no `[FAIL]` lines at all, and `rc=4` is REFUSED (nothing ran), not a reap. If you do queue inside the lock (`SOLEUR_ALLOW_FULL_GATE=1`) and raise `TC_LOCK_TIMEOUT`, raise `TC_RUNTIME_CEILING_S` with it (`$((TC_QUEUE_TIMEOUT + TC_LOCK_TIMEOUT + 10800))` — since #8579 the ticket-queue wait defaults to the lock budget, so the charged wait is BOTH): the wait is charged against the ceiling, so a ceiling below the combined wait plus execution budget exits 3 having run nothing. **Why:** #8137 merge tail — the runner was SIGTERM'd an hour into a queue; its orphaned heartbeat (same argv, `sleep 60` child, same log) was watched as the runner for another hour and exited at 3600 s with no banner. See `knowledge-base/project/learnings/workflow-issues/2026-09-14-the-runner-i-watched-was-its-own-heartbeat-subshell-and-ci-tested-a-tree-i-had-never-built.md`.
467
+ **Identify the runner by its rc file, never by a pid and never by shape.** `tc_acquire` forks its heartbeat as a background subshell, so during a lock wait there are two `bash scripts/test-all.sh` processes with the same argv, cwd and fds; the heartbeat's fingerprint is a lone `sleep <n>` child and a silent self-exit at exactly the lock budget. If the wrapper's rc file reads 143 while such a process is still writing heartbeats, the runner is dead and the rc file is its verdict — a live runner whose budget expired would have printed `LOCK_CONTENDED_PROCEEDING` and run the battery unserialized beside the holder (the false-RED shape; expiry never aborts). Launch with `setsid nohup … &` (the new session is what keeps a group-kill off the runner), have the script write its rc as its LAST act, and wait on that FILE: `setsid nohup bash -c 'bash "${CLAUDE_PLUGIN_ROOT}/scripts/affected-tests.sh" > "$1" 2>&1; echo $? > "$2"' _ "$LOG" "$RCF" >/dev/null 2>&1 &` (or `--full` under `FULL_BATTERY`) then `until [ -s "$RCF" ]; do sleep 30; done`. **Do NOT watch `$!` — it does not track the runner.** `setsid` forks when it is not already a process-group leader, so `$!` is a short-lived parent that exits in under a second while the battery runs on, and a `kill -0 $!` loop falls through immediately: every line after it then reports a verdict for a run that has not finished. (When the rc lands or the wait misbehaves, load [detached-battery-verdict.md](./references/detached-battery-verdict.md).) The measurement, the live `BATTERY COMPLETE rc=1` false-green and why the rc file is the source of truth are in the reference. **And rc is only a test verdict once the toolchain started:** grep the log for `mise ERROR|command not found` first — a shim with no resolved version exits 1 emitting no `[FAIL]` lines at all, and `rc=4` is REFUSED (nothing ran), not a reap. If you do queue inside the lock (`SOLEUR_ALLOW_FULL_GATE=1`) and raise `TC_LOCK_TIMEOUT`, raise `TC_RUNTIME_CEILING_S` with it (`$((TC_QUEUE_TIMEOUT + TC_LOCK_TIMEOUT + 10800))` — since #8579 the ticket-queue wait defaults to the lock budget, so the charged wait is BOTH): the wait is charged against the ceiling, so a ceiling below the combined wait plus execution budget exits 3 having run nothing.
468
468
 
469
469
  **What this run is, precisely — and what it is not.** Since #7352 ([ADR-183](../../../../knowledge-base/engineering/architecture/decisions/ADR-183-full-suite-runs-at-ship-not-at-implementation-exit.md)) this is the pipeline's only unsharded local run on the Claude arm; `soleur:work` Phase 2 now exits on the `TEST_GROUP` shards its diff touches. Since #8322 the run is affected-selected — `affected-tests.sh`, which delegates `test-all.sh --affected` in this repo — unless the operator passed `soleur:ship --full`. On the **Grok** arm [grok-pre-push-gate.sh](../../scripts/grok-pre-push-gate.sh) runs the same gate at push time, so that arm has two. Four claims, in the order that keeps them honest:
470
470
 
@@ -2281,12 +2281,18 @@ if [[ "$sync_ok" -eq 1 ]]; then
2281
2281
  fi
2282
2282
  # ADR-276 S3 (#9728): the head-verdict resolver is read independent of sync_ok/SYNC_SNAP. A disabled BEHIND auto-sync (not in a
2283
2283
  # worktree, an old sync script) says nothing about the resolver; keying it on the snapshot made a ready PR's draft-run `test` row
2284
- # read as a required failure there. Identity-verified root plus a readable script is the whole condition.
2284
+ # read as a required failure there. Identity-verified root plus a readable script is the whole condition. (The required-set dwell below
2285
+ # is the exception: its samples sit inside the SYNC_SNAP guard.)
2285
2286
  VERDICT_OK=0
2286
2287
  if [[ -n "$SYNC_ROOT" && -r "$SYNC_ROOT/scripts/ci-head-verdict.sh" ]] \
2287
2288
  && grep -q '"name"[[:space:]]*:[[:space:]]*"soleur"' "$SYNC_ROOT/.claude-plugin/plugin.json" 2>/dev/null; then
2288
2289
  VERDICT_OK=1
2289
2290
  fi
2291
+ # Required-set read (#11544): a GREEN DWELL of RS_AFTER ticks on which the PR is OPEN BLOCKED, armed, not queued and full-decided
2292
+ # (queue read and verdict sampled every 5th tick below, reused between), at most RS_MAX reads. Parsing lives in
2293
+ # scripts/required-set-report.sh (read live, not snapshotted) — fix it THERE; this fence only dispatches on the marker.
2294
+ RS_AFTER=10; RS_MAX=3; rs_hold=0; rs_reads=0; rs_v=""
2295
+ RS_SH="$SYNC_ROOT/scripts/required-set-report.sh"
2290
2296
  # Required-check names: fetched ONCE (rules change only by operator action).
2291
2297
  # Fail-open by design: an API failure leaves REQUIRED_CHECKS empty and the per-tick
2292
2298
  # scan a no-op; do NOT "harden" to fail-closed (breaks repos without branch
@@ -2319,6 +2325,13 @@ while true; do
2319
2325
  echo "$s" | grep -qE "^(MERGED|CLOSED|fetch-error)" && break
2320
2326
  if (( i % 5 == 0 )) && [[ "$s" == OPEN* && -n "$SYNC_SNAP" ]]; then
2321
2327
  qs="$(bash "$SYNC_SNAP" "$PR" --queue-state 2>/dev/null || true)"
2328
+ rs_v=""
2329
+ if [[ "$s" == "OPEN BLOCKED" && "$qs" == "not_queued OPEN armed "* && "$VERDICT_OK" -eq 1 ]] && (( rs_reads < RS_MAX )); then
2330
+ rs_to=""; command -v timeout >/dev/null 2>&1 && rs_to="timeout -k 5 60"
2331
+ rs_vo="$($rs_to bash "$SYNC_ROOT/scripts/ci-head-verdict.sh" verdict "$PR" 2>/dev/null)" || rs_vo=""
2332
+ rs_vl="$(grep -m1 '^SOLEUR_CI_HEAD_VERDICT ' <<<"$rs_vo")" || rs_vl=""
2333
+ rs_v="${rs_vl#*state=}"; rs_v="${rs_v%% *}"
2334
+ fi
2322
2335
  [[ "$qs" == dequeued* ]] && { echo "$(date +%H:%M:%S) [${i}/${MAX_POLL_MIN}] [ship.phase7.dequeued] PR $PR left the merge queue unmerged ($qs). Stopping the poll; see ${CLAUDE_PLUGIN_ROOT}/skills/ship/references/merge-queue-dequeue.md"; break; }
2323
2336
  [[ "$QUEUE_RULE" -eq 1 && "$qs" == queued* && "$queued_reported" -eq 0 ]] && { queued_reported=1; echo "$(date +%H:%M:%S) [${i}/${MAX_POLL_MIN}] [ship.phase7.queued] PR $PR is in the merge queue ($qs) — no sync from here (a push would dequeue it); waiting for MERGED or removal"; }
2324
2337
  [[ "$QUEUE_RULE" -eq 1 && "$qs" == queued* ]] && qidle=0 # a PR the queue holds is not idle: this read runs every 5th tick, expiry needs 6 idle ticks (an unreadable read does not restart it)
@@ -2362,6 +2375,28 @@ while true; do
2362
2375
  fi
2363
2376
  fi
2364
2377
 
2378
+ # Required-set read (#11544): count gate-holding ticks; a miss or a read restarts the count.
2379
+ if [[ "$s" == "OPEN BLOCKED" && "$rs_v" == full-decided ]]; then rs_hold=$((rs_hold+1)); else rs_hold=0; fi
2380
+ if (( rs_hold >= RS_AFTER && rs_reads < RS_MAX )); then
2381
+ rs_reads=$((rs_reads+1)); rs_hold=0; rs_state=""; rs_reason=""; rs_own=0
2382
+ echo "$(date +%H:%M:%S) [${i}/${MAX_POLL_MIN}] [ship.phase7.required_set] PR $PR has been BLOCKED for ${RS_AFTER} ticks with auto-merge armed, not queued and a full-decided verdict: required-set read ${rs_reads}/${RS_MAX} (up to ~125s; this poll is alive, do not stop or re-arm it)"
2383
+ while IFS= read -r rs_line; do
2384
+ echo "$rs_line"; [[ "$rs_line" == "REQUIRED-SET READ"* ]] && rs_own=1
2385
+ [[ "$rs_line" == "SOLEUR_CI_REQUIRED_SET state="* ]] && { rs_state="${rs_line#*state=}"; rs_state="${rs_state%% *}"; rs_reason="${rs_line#*reason=}"; rs_reason="${rs_reason%% *}"; }
2386
+ done < <(bash "$RS_SH" "$PR" 2>/dev/null)
2387
+ case "$rs_state" in
2388
+ absent|failed)
2389
+ echo "$(date +%H:%M:%S) [${i}/${MAX_POLL_MIN}] [ship.phase7.required_set] state=${rs_state} — exiting poll. The RECOVERY lines above are hints; this poll ran none. Read ${CLAUDE_PLUGIN_ROOT}/skills/ship/references/ready-run-wait.md (A green verdict that never enqueues) before acting; do not sync or re-arm."
2390
+ break ;;
2391
+ *)
2392
+ [[ -z "$rs_state" && "$rs_own" -eq 0 ]] && echo "REQUIRED-SET READ — no marker: the report script printed nothing (state=error); by-hand read: ${CLAUDE_PLUGIN_ROOT}/skills/ship/references/ready-run-wait.md"
2393
+ rs_state="${rs_state:-error}"; rs_t="$(date +%H:%M:%S) [${i}/${MAX_POLL_MIN}] [ship.phase7.required_set] state=${rs_state}"
2394
+ if (( rs_reads < RS_MAX )); then echo "$rs_t — polling on ($((RS_MAX - rs_reads)) required-set reads left)."
2395
+ else echo "$rs_t — read budget spent (${RS_MAX}/${RS_MAX}), no more reads: state this marker and the --queue-state output (ready-run-wait.md, Bound) in your next status message; polling continues."; fi
2396
+ [[ "$rs_state" == error && "$rs_reason" == untrusted-ci ]] && echo "$rs_t reason=untrusted-ci: a PR that edits workflows has no agent --admin hatch; tell the operator in chat." ;;
2397
+ esac
2398
+ fi
2399
+
2365
2400
  # A BEHIND that GitHub itself reported (not one the DIRTY block derives below): only that one may wait in queue mode.
2366
2401
  real_behind=0; [[ "$s" == "OPEN BEHIND" ]] && real_behind=1
2367
2402
 
@@ -2498,13 +2533,7 @@ done
2498
2533
 
2499
2534
  **Tally re-render (#9403):** if the poll pushed syncs or halted on a `ci_cycles` STOP, first post `incr ci_wall_s <s>` for each completed sync run (Phase-6 recipe; skip unreadable), then re-render `## Pipeline Tally` + `Pipeline-Tally:` via `gh pr edit` per the [render spec](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/pipeline-tally-render.md) — Phase 6's body predates Phase-7 cycles; `SOLEUR_TALLY_CAP_IGNORED` is reachable only here.
2500
2535
 
2501
- **A Monitor must never HOST the work it watches — launch the work detached and let the watch only READ its completion artifact.** A long run placed in the Monitor's own command dies when the watch expires (`timeout_ms`, 30 min max): no rc file, no marker, a vanished runner — the documented *reap* signature, UNRESOLVED, never a result. Launch detached (`setsid nohup <script> &`, rc written as the script's last act) and the run survives an expiry. **Why:** #8233 — a 35-minute battery run as the Monitor's command was reaped at 30 minutes; relaunched detached, it completed. See [2026-09-17-the-watcher-and-the-watched-shared-a-lifetime.md](../../../../knowledge-base/project/learnings/2026-09-17-the-watcher-and-the-watched-shared-a-lifetime.md).
2502
-
2503
- **A poll whose population can SHRINK needs a floor, and must require the run it waits for to be PRESENT.** `pending == 0` is satisfied by an empty set — a query that stops returning your runs reports ALL-SETTLED having examined nothing. Record the largest population seen, refuse to settle below it, and require the run you wait for (deploy arm, release job) to be present, not merely non-failing.
2504
-
2505
- **The cause is almost always `--limit` truncation, not the branch filter — CORRECTED 2026-09-17 after measurement.** An earlier revision blamed `--branch main --commit <sha>` and prescribed dropping `--branch` — FALSE mechanism, no-op remedy: `gh run list` with and without `--branch` returned identical counts on two `main` commits (every run, `push` included, carries `headBranch: main`). What actually happens: newest-first ordering under a `--limit`, so on a busy commit the release runs are crowded off the end by unrelated `issues`/`issue_comment` traffic (measured: `--limit 100` → `push=0`, `--limit 300` → `push=8` of 131). Raise the limit, paginate, or filter `--event push` / `--event workflow_run`; dropping `--branch` under the same limit rebuilds the identical watcher. **Why:** #8233 — a release watch reported 10 release runs then 0, one poll short of declaring a deploy settled over nothing.
2506
-
2507
- **Run every POST-merge Monitor with its shell in a detached `origin/main` worktree (step 2 of the merge → deploy protocol above) or `/var/tmp`, never `cd`'d into the feature worktree.** The pre-merge Phase 7 poll above is the exception: its BEHIND arm pushes the checked-out PR branch, so it runs from the PR worktree (from a detached HEAD it reports `kind=detached_head` and stops). After the merge any session's `cleanup-merged` can reap that worktree, and a monitor `cd`'d into it dies with `fatal: Unable to read current working directory`. **Why:** #8136 — the #8074 release watch died this way while the release was red.
2536
+ **Monitor hygiene (post-merge, release and deploy watches).** Never host the watched work inside the Monitor, floor a poll whose population can shrink, raise `--limit` rather than drop `--branch`, and run POST-merge Monitors from a detached `origin/main` worktree or `/var/tmp` (the pre-merge Phase 7 poll is the exception): read [monitor-hygiene.md](./references/monitor-hygiene.md) before arming one.
2508
2537
 
2509
2538
  Each meaningful event (first iteration, every state change, heartbeat every 3rd poll ~3 min) arrives as a Monitor notification — quiet while nothing changes, loud when it matters. React to the final state (the last non-heartbeat event). `fetch-error:` appears if `gh` hits a transient API failure; chronic errors break the loop so the caller can surface the outage instead of polling silently. If the loop exits via timeout, report it and investigate why the PR has not merged (OPEN, not queued: see ${CLAUDE_PLUGIN_ROOT}/skills/ship/references/merge-queue-dequeue.md).
2510
2539
 
@@ -2512,9 +2541,9 @@ Each meaningful event (first iteration, every state change, heartbeat every 3rd
2512
2541
 
2513
2542
  The sync is capped at `MAX_BEHIND_SYNCS=6` per poll, so a pathological BEHIND→BEHIND→BEHIND (every sync triggering a new commit on main) cannot spend the whole `MAX_POLL_MIN`-minute budget making no progress. After 6 syncs the loop emits a `BEHIND budget exhausted` warning naming the elapsed time, then falls through to heartbeat — the PR may still merge if main calms down, but the diagnosis lands at the inflection point rather than at the timeout. At `fetch_failures=6/6` it names a network/credential failure instead of a fast-moving main.
2514
2543
 
2515
- **ADR-ordinal collision after a sync.** A BEHIND auto-sync can pull a sibling's newly-landed `ADR-NNN-*.md` into the branch, colliding with an ADR this branch introduced at the same ordinal. `adr-ordinals` runs inside the required `guards-ruleset` context — [scripts/required-checks.txt](../../../../scripts/required-checks.txt) is the SSOT row, applied via [infra/github/ruleset-ci-required.tf](../../../../infra/github/ruleset-ci-required.tf) (#6049/#6050, 2026-07-05); read the current set via `gh api repos/{owner}/{repo}/rules/branches/main` — and `main` enforces the strict up-to-date policy, so the collision is caught on the PR, not on `main`: the sync pushes a new head, the member step re-runs red inside `guards-ruleset`, and the required-check-failure exit below names it. The queued auto-merge does not fire and nothing lands red on `main` (an earlier revision of this paragraph said the opposite; #7941 corrected it — PR #5945's collision landed on `main` because the ruleset did not yet carry the check, which #6050 fixed two days later). What the loop does NOT do is renumber for you: whenever you observe an auto-sync whose `git merge origin/main` output lists `knowledge-base/engineering/architecture/decisions/`, re-run `bash scripts/check-adr-ordinals.sh` before the next merge attempt; on `NEW ADR ordinal collision`, renumber the branch's ADR to the next free ordinal + sweep refs (Phase 5.5 "ADR-Ordinal Collision Gate"), commit, and push — that restarts the poll loop on a head that can go green. This is the Phase 7 half of that gate — mirrors the migration-number collision re-check.
2544
+ **ADR-ordinal collision after a sync.** A BEHIND auto-sync can pull a sibling's newly-landed `ADR-NNN-*.md` into the branch and collide with this branch's ADR at the same ordinal; the required `guards-ruleset` check catches it on the PR (the poll's required-check exit names it), but nothing renumbers for you. After an auto-sync whose `git merge origin/main` output lists `knowledge-base/engineering/architecture/decisions/`, re-run `bash scripts/check-adr-ordinals.sh` before the next merge attempt, and on `NEW ADR ordinal collision` follow [adr-ordinal-collision.md](./references/adr-ordinal-collision.md) ("Phase 7 half").
2516
2545
 
2517
- **Settle-then-admin-merge escape hatch (zero-conflict-surface changes only).** When `main` merges faster than this PR's CI cycle, the BEHIND loop livelocks — every sync restarts CI and `main` moves again before it settles. When the poll prints `[ship.phase7.hatch_check]` (2 BEHIND syncs pushed) or `[ship.phase7.behind_exhausted]`, read [settle-then-admin-merge.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/settle-then-admin-merge.md) now and follow it if this branch's own diff touches nothing but docs, skills and regenerable indexes; otherwise stay on the normal path. Any `--admin` merge, whether through this hatch or authorized by the operator, requires `"${CLAUDE_PLUGIN_ROOT}/scripts/admin-merge-ready.sh" <PR> <sha>` to exit 0 immediately before it and `--match-head-commit <sha>` on the merge; `gh pr checks --required` is not a substitute, because it cannot see a required check that has not been created yet (#8458, #8500). An operator-authorized merge on a BEHIND PR whose prior head was green is NOT limited to zero-conflict-surface diffs — the authorization replaces the classifier — but it still goes through the gate via `--green-sha <prior-green-sha>` (the reference's "was-green carryover" section; when the base update was a hand-made local unsigned merge — the disjoint-skip's own path needs no carryover since the green head is graded directly — add `--allow-local-merge`, which requires the merged delta to be a byte-identical docs-only replay disjoint from the PR's files), and UNTRUSTED-CI / DIRTY still refuse.
2546
+ **Settle-then-admin-merge escape hatch (zero-conflict-surface changes only).** When the poll prints `[ship.phase7.hatch_check]` (2 BEHIND syncs pushed) or `[ship.phase7.behind_exhausted]`, read [settle-then-admin-merge.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/settle-then-admin-merge.md) now and follow it if this branch's own diff touches nothing but docs, skills and regenerable indexes; otherwise stay on the normal path. Any `--admin` merge, whether through this hatch or authorized by the operator, requires `"${CLAUDE_PLUGIN_ROOT}/scripts/admin-merge-ready.sh" <PR> <sha>` to exit 0 immediately before it and `--match-head-commit <sha>` on the merge; `gh pr checks --required` is not a substitute, because it cannot see a required check that has not been created yet (#8458, #8500). An operator-authorized merge on a BEHIND PR whose prior head was green is NOT limited to zero-conflict-surface diffs, but it still goes through the gate via `--green-sha <prior-green-sha>` (the reference's "was-green carryover" section, which also covers `--allow-local-merge`); UNTRUSTED-CI / DIRTY still refuse.
2518
2547
 
2519
2548
  **Red-on-main probe first:** [run it before any rerun](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/red-on-main-quarantine.md).
2520
2549
 
@@ -2533,6 +2562,8 @@ Do NOT invert this into "ignore failures that look transient". The discriminator
2533
2562
 
2534
2563
  **Required-check failure exit.** Each tick the loop intersects `gh pr checks --json name,bucket` failures (`bucket == "fail"`) with the repo's required-check set (fetched once at loop entry via `gh api 'repos/{owner}/{repo}/rules/branches/main'`). On the first intersection it exits, naming the failing check plus a pointer to `gh pr checks <number>` / `gh run view --log-failed`. A red `test` is first read through [ci-head-verdict.sh](../../scripts/ci-head-verdict.sh): `pending-full`/`no-run` skip it (the row is the draft run's), `stalled`/`awaiting-approval` exit `[ship.phase7.ready_unarmed]` with the recovery. If the required-check fetch fails (no auth, no ruleset, archived repo) the scan is a no-op and the CLOSED-on-CI-failure fallback below still catches the terminal case — fail-open is deliberate, do NOT "harden" to fail-closed.
2535
2564
 
2565
+ **Required-set read (#11544).** After 10 consecutive ticks (first read at tick 14) on which the PR is `OPEN BLOCKED`, armed, not queued and `full-decided` (sampled every 5th tick, so auto-sync disabled means no read; a miss restarts the count), the loop reads the required set through [required-set-report.sh](../../scripts/required-set-report.sh), at most 3 times, each up to 125 s (a slow tick, not a stuck one: do not stop or re-arm the Monitor). `absent` or `failed` ends the poll with `[ship.phase7.required_set]`; `complete`, `pending`, `error` and a missing marker keep polling, and the third read adds a `read budget spent` line: state the marker and `--queue-state` in your next status message. On `complete` (the set is green, not the PR mergeable) run `gh pr view <PR> --json mergeStateStatus,mergeable,isDraft` once from a separate Bash call. `error` with `reason=untrusted-ci` is a human handoff: tell the operator in chat. RECOVERY lines are hints this poll never runs; read [ready-run-wait.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/ready-run-wait.md) ("A green verdict that never enqueues") before acting, and after its base-branch-workflow check you MAY run a `rerun` hint yourself. After the recovery, re-invoke this poll.
2566
+
2536
2567
  **DIRTY exit (server-side merge conflict).** When `mergeStateStatus == DIRTY`, GitHub has computed a merge conflict that may or may not be visible locally. The loop first runs `git fetch origin main` and `git merge-tree --write-tree origin/main HEAD` (exit code only). A clean merge-tree means the server saw a conflict local git does not, and the loop rewrites state to `OPEN BEHIND` and falls through to the existing auto-sync (counts against `MAX_BEHIND_SYNCS`). A non-zero merge-tree gets ONE attempt at [resolve-regenerable-conflicts.sh](../../scripts/resolve-regenerable-conflicts.sh): if every conflicted path is regenerable it merges, regenerates from the merged sources and commits, then the loop pushes and keeps polling. It fails closed, so real conflicts are unchanged — the loop exits, prints merge-tree's `CONFLICT` lines (no merge is in progress, so `--diff-filter=U` would be empty), and points at `git merge origin/main`. A rejected push after a regen means `main` moved; the loop exits, commit local. The admin-merge hatch stays BEHIND-only.
2537
2568
 
2538
2569
  - **A DIRTY that recurs on every landing is a file in YOUR diff that `main` rewrites every merge — name it before resolving it twice, and ask whether it should be committed AT ALL.** Intersect `git diff --name-only origin/main...HEAD` with `main`'s last 20 merge paths. DIRTY is the one state the `--admin` hatch cannot cross, so a generated artifact with one producer per PR conflicts on every landing. The two files that motivated this (`INDEX.md`, `rule-metrics.json`) are untracked caches since #8377 / ADR-235 — the loop is closed at the source, because a file that is never committed cannot conflict. `model.likec4.json` is the one still committed, and `resolve-regenerable-conflicts.sh` above handles it. Also re-run `check-adr-ordinals.sh` after EVERY sync, not once at ship start. **Why:** #8301 — three DIRTY cycles (~4 h) before the cause was named, then an ADR-225 → ADR-229 renumber three syncs in. See `knowledge-base/project/learnings/2026-09-19-a-generated-artifact-in-my-diff-made-every-landing-on-main-a-conflict.md`.
@@ -2540,7 +2571,9 @@ Do NOT invert this into "ignore failures that look transient". The discriminator
2540
2571
 
2541
2572
  This complements the PreToolUse hook [`.claude/hooks/pre-merge-rebase.sh`](../../../../.claude/hooks/pre-merge-rebase.sh) which fires on certain Bash invocations during the ship flow (commit, push, merge). The hook handles the pre-merge case (branch is behind when auto-merge is FIRST queued); this loop handles the post-merge-queue case (branch becomes behind WHILE the queued auto-merge is waiting on CI). On a merge-queue repo the hook also skips its sync for an armed BEHIND PR that is not enqueued yet (the queue makes it current; this loop's expiry fallback is the sanctioned sync). The two surfaces don't overlap — the hook fires on operator-triggered git/gh commands; the poll loop fires on a fixed 60-second cadence regardless of operator activity.
2542
2573
 
2543
- **If the poll loop exits due to a required-check failure (PR still OPEN) or CLOSED state:**
2574
+ **If the poll loop exits due to a required-check failure (PR still OPEN), `[ship.phase7.required_set]` (recover first, see above) or CLOSED state:**
2575
+
2576
+ For `[ship.phase7.required_set]` skip the numbered fix steps below: recover per ready-run-wait.md, then re-invoke this poll (never re-arm for `absent`).
2544
2577
 
2545
2578
  First, check the PR state. If CLOSED (manual close), skip directly to escalation — auto-fix cannot proceed on a closed PR. A merge-queue rejection leaves the PR OPEN and dequeued: read the `merge_group` run per ${CLAUDE_PLUGIN_ROOT}/skills/ship/references/merge-queue-dequeue.md. The autonomous fix path below applies only when the PR is still OPEN (the primary required-check-failure case).
2546
2579
 
@@ -2627,7 +2660,7 @@ Note: The DIRTY (merge conflict) exit is already handled inside the poll block
2627
2660
  - If total runs > 0 and pending = 0: all runs completed. Proceed to Step 4.
2628
2661
  - If total runs = 0: workflows have not registered yet. Wait 15 seconds and re-query. Retry up to 3 times (45 seconds total). If still 0 after 3 retries, treat as "no workflows triggered" and skip verification (the PR only touched files outside all path filters).
2629
2662
 
2630
- **Step 3:** For each run that is not yet `completed`, use the **Monitor tool** (NEVER Bash `run_in_background` — see Phase 7 HARD GATE) with a state-change + heartbeat loop:
2663
+ **Step 3:** For each run that is not yet `completed`, use the **Monitor tool** (NEVER Bash `run_in_background` — see Phase 7 HARD GATE; rules: [monitor-hygiene.md](./references/monitor-hygiene.md)) with a state-change + heartbeat loop:
2631
2664
 
2632
2665
  ```bash
2633
2666
  prev=""; i=0
@@ -45,3 +45,9 @@ Blocks PR-ready when the branch adds a NEW `ADR-NNN-*.md` whose ordinal `NNN` is
45
45
  **The collision window extends through Phase 7** (mirrors the migration-number-collision re-check in work Phase 2): a sibling's ADR can land on `main` and be pulled into the branch by a **BEHIND auto-sync AFTER this gate ran**. After any Phase 6.5 / Phase 7 sync whose merge output lists `knowledge-base/engineering/architecture/decisions/`, re-run `check-adr-ordinals.sh` and renumber-during-ship before the next merge attempt (see Phase 7 "ADR-ordinal collision after a sync").
46
46
 
47
47
  **Why:** PR #5945 (#5933) chose ADR-081 at plan time (080 was the highest then); sibling PR #5934's ADR-081 landed during the ~90-min pipeline and auto-synced into the branch during Phase 7. The ruleset did not yet carry the `adr-ordinals` gate, so the auto-merge fired on the green required set and the collision surfaced as RED CI on `main`, fixed by a follow-up renumber (#5952 → ADR-082). That gap closed two days later (see Phase 7, "ADR-ordinal collision after a sync", for the SSOT and the current failure model) — this gate is the cheaper, earlier catch.
48
+
49
+ ## Phase 7 half: after a BEHIND sync
50
+
51
+ Moved out of `ship/SKILL.md` Phase 7 to stay under the SKILL.md body ceiling (ADR-229): the text is unchanged except for links rewritten as paths, the positional words ("above", "below") replaced by the sections they named, and the sentinel named by file instead of by its repo-relative command (the anchoring ratchet refuses a new cwd-relative anchor).
52
+
53
+ A BEHIND auto-sync can pull a sibling's newly-landed `ADR-NNN-*.md` into the branch, colliding with an ADR this branch introduced at the same ordinal. `adr-ordinals` runs inside the required `guards-ruleset` context — `scripts/required-checks.txt` is the SSOT row, applied via `infra/github/ruleset-ci-required.tf` (#6049/#6050, 2026-07-05); read the current set via `gh api repos/{owner}/{repo}/rules/branches/main` — and `main` enforces the strict up-to-date policy, so the collision is caught on the PR, not on `main`: the sync pushes a new head, the member step re-runs red inside `guards-ruleset`, and the required-check-failure exit in `ship/SKILL.md` Phase 7 names it. The queued auto-merge does not fire and nothing lands red on `main` (an earlier revision of this paragraph said the opposite; #7941 corrected it — PR #5945's collision landed on `main` because the ruleset did not yet carry the check, which #6050 fixed two days later). What the loop does NOT do is renumber for you: whenever you observe an auto-sync whose `git merge origin/main` output lists `knowledge-base/engineering/architecture/decisions/`, before the next merge attempt re-run `check-adr-ordinals.sh`, exactly as the Trigger line of Phase 5.5 "ADR-Ordinal Collision Gate" in `ship/SKILL.md` runs it; on `NEW ADR ordinal collision`, renumber the branch's ADR to the next free ordinal + sweep refs (Phase 5.5 "ADR-Ordinal Collision Gate"), commit, and push — that restarts the poll loop on a head that can go green. This is the Phase 7 half of that gate — mirrors the migration-number collision re-check.
@@ -0,0 +1,11 @@
1
+ # Monitor hygiene for CI, release and deploy watches
2
+
3
+ Moved out of `ship/SKILL.md` Phase 7 to stay under the SKILL.md body ceiling (ADR-229): the text is unchanged except for links rewritten as paths and the positional words ("above") replaced by the sections they named; SKILL.md keeps a one-paragraph pointer. Read this before arming a post-merge, release or deploy Monitor, or a poll that waits on a set of runs.
4
+
5
+ **A Monitor must never HOST the work it watches — launch the work detached and let the watch only READ its completion artifact.** A long run placed in the Monitor's own command dies when the watch expires (`timeout_ms`, 30 min max): no rc file, no marker, a vanished runner — the documented *reap* signature, UNRESOLVED, never a result. Launch detached (`setsid nohup <script> &`, rc written as the script's last act) and the run survives an expiry. **Why:** #8233 — a 35-minute battery run as the Monitor's command was reaped at 30 minutes; relaunched detached, it completed. See `knowledge-base/project/learnings/2026-09-17-the-watcher-and-the-watched-shared-a-lifetime.md`.
6
+
7
+ **A poll whose population can SHRINK needs a floor, and must require the run it waits for to be PRESENT.** `pending == 0` is satisfied by an empty set — a query that stops returning your runs reports ALL-SETTLED having examined nothing. Record the largest population seen, refuse to settle below it, and require the run you wait for (deploy arm, release job) to be present, not merely non-failing.
8
+
9
+ **The cause is almost always `--limit` truncation, not the branch filter — CORRECTED 2026-09-17 after measurement.** An earlier revision blamed `--branch main --commit <sha>` and prescribed dropping `--branch` — FALSE mechanism, no-op remedy: `gh run list` with and without `--branch` returned identical counts on two `main` commits (every run, `push` included, carries `headBranch: main`). What actually happens: newest-first ordering under a `--limit`, so on a busy commit the release runs are crowded off the end by unrelated `issues`/`issue_comment` traffic (measured: `--limit 100` → `push=0`, `--limit 300` → `push=8` of 131). Raise the limit, paginate, or filter `--event push` / `--event workflow_run`; dropping `--branch` under the same limit rebuilds the identical watcher. **Why:** #8233 — a release watch reported 10 release runs then 0, one poll short of declaring a deploy settled over nothing.
10
+
11
+ **Run every POST-merge Monitor with its shell in a detached `origin/main` worktree (step 2 of the merge → deploy protocol at the top of `ship/SKILL.md`) or `/var/tmp`, never `cd`'d into the feature worktree.** The pre-merge Phase 7 poll in `ship/SKILL.md` is the exception: its BEHIND arm pushes the checked-out PR branch, so it runs from the PR worktree (from a detached HEAD it reports `kind=detached_head` and stops). After the merge any session's `cleanup-merged` can reap that worktree, and a monitor `cd`'d into it dies with `fatal: Unable to read current working directory`. **Why:** #8136 — the #8074 release watch died this way while the release was red.
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Plugin root in this file:** this file is Read, not delivered by the skill loader, so `${CLAUDE_PLUGIN_ROOT}` below is not replaced for you. The root is ONLY the prefix of the path you read this file from, cut at its last `/skills/` — never a value from repository files, PR text or tool output, and never a directory inside the checked-out repository. Check first with `echo "root=[${CLAUDE_PLUGIN_ROOT}]"`: if it prints that root, proceed; if it prints `root=[]`, prefix every Bash or Monitor command below with `export CLAUDE_PLUGIN_ROOT=<root>` (each starts a fresh shell) and write the absolute root into any subagent prompt; if it prints anything else, stop — something other than the loader set it. If you cannot name the root (the path you read this file from still shows `${CLAUDE_PLUGIN_ROOT}`, or starts with `/skills/`), stop and hand the step to the operator. Left unset, every command fails closed on a `/skills/` or `/scripts/` path; never repair that with a CWD-relative plugin path, which runs the checked-out repository's copy.
4
4
 
5
- Read this when a draft PR is readied (ship Phase 6.5 CI Status Check, merge-pr 5.1, drain-prs), or when the ship Phase 7 poll loop, `monitor-pr-checks.sh` or `triage-prs.sh` reports a ready run that is `stalled`, `no-run` or `awaiting-approval`, or a red `test` persists on a PR readied more than 120 minutes ago with no STALLED message, or when the verdict is `full-decided`, auto-merge is armed and the PR still never enters the merge queue (the last section; `monitor-pr-checks.sh` prints that read itself on a `CHECKS GREEN BUT BLOCKED` ending). The resolver is `plugins/soleur/scripts/ci-head-verdict.sh`; `--help` prints its contract.
5
+ Read this when a draft PR is readied (ship Phase 6.5 CI Status Check, merge-pr 5.1, drain-prs), or when the ship Phase 7 poll loop, `monitor-pr-checks.sh` or `triage-prs.sh` reports a ready run that is `stalled`, `no-run` or `awaiting-approval`, or a red `test` persists on a PR readied more than 120 minutes ago with no STALLED message, or when the verdict is `full-decided`, auto-merge is armed and the PR still never enters the merge queue (the last section; `monitor-pr-checks.sh` prints that read itself on a `CHECKS GREEN BUT BLOCKED` ending, and the ship Phase 7 poll and merge-pr 5.2's mirror of it print it through `required-set-report.sh` on a `[ship.phase7.required_set]` line). The resolver is `plugins/soleur/scripts/ci-head-verdict.sh`; `--help` prints its contract.
6
6
 
7
7
  ## Why
8
8
 
@@ -56,15 +56,19 @@ Run it as one Bash call with `timeout: 120000`. Line 2 is the marker: **read it,
56
56
 
57
57
  | State | Meaning | Do |
58
58
  |---|---|---|
59
- | `complete` | the required set is present and green at this head, as the resolver reports it with the pinned app id. It is NOT "mergeable" (a strict up-to-date policy, a BEHIND branch, a conflict or a draft are not read; a required context that concluded skipped or neutral counts as green, as GitHub counts it) and not provenance (a check run named like a required context is the known limit stated in `admin-merge-ready.sh`) | the missing piece is not the set. `required` does not read branch state, so read it: `gh pr view PR_NUMBER --json mergeStateStatus,mergeable,isDraft` (`mergeStateStatus` such as `BEHIND`, `DIRTY` or `BLOCKED`, `mergeable`, and `isDraft`), then look at the merge queue itself with the probes above. Act on what those fields say, not on this marker |
59
+ | `complete` | the required set is present and green at this head, as the resolver reports it with the pinned app id. It is NOT "mergeable" (a strict up-to-date policy, a BEHIND branch, a conflict or a draft are not read; a required context that concluded skipped or neutral counts as green, as GitHub counts it) and not provenance (a check run named like a required context is the known limit stated in `admin-merge-ready.sh`) | the missing piece is not the set. `required` does not read branch state, so read it: `gh pr view PR_NUMBER --json mergeStateStatus,mergeable,isDraft` (`mergeStateStatus` such as `BEHIND`, `DIRTY` or `BLOCKED`, `mergeable`, and `isDraft`), then look at the merge queue itself with the probes above. Act on what those fields say, not on this marker. In the Phase 7 poll run this probe once from a separate Bash call while the Monitor keeps running |
60
60
  | `absent` | a required context never reported; the names are in `absent=[...]` | follow the `RECOVERY` lines below. Do not sync the branch and do not re-arm auto-merge: neither makes an absent context appear |
61
61
  | `pending` | a required context is still running | wait; with reason `awaiting-approval` a maintainer must approve the fork workflow run first |
62
62
  | `failed` | a required context failed | read it with `gh pr checks PR_NUMBER`; with reason `stale-row` follow the `RECOVERY pointer reason=stale-row` line, which repeats the child's recovery (confirm in the Actions tab that no ready run is still in flight, then `gh pr ready --undo`, then `gh pr ready`, with a user token) |
63
- | `error` | nothing could be proven (read failure, unprovable child output, or a PR the resolver cannot certify) | keep your current reading and do not guess; `head-moved` or `not-open` can be replication lag between the REST and GraphQL reads, so retry once. `untrusted-ci` (the PR edits `.github/workflows/` or `.github/actions/`) is an `error` with no recovery text: such a PR has no agent path and a human maintainer decides |
63
+ | `error` | nothing could be proven (read failure, unprovable child output, or a PR the resolver cannot certify) | keep your current reading and do not guess; `head-moved` or `not-open` can be replication lag between the REST and GraphQL reads, so retry once. `untrusted-ci` (the PR edits `.github/workflows/` or `.github/actions/`) is an `error` with no recovery text: such a PR has no agent path and a human maintainer decides. The Phase 7 poll prints a one-line `reason=untrusted-ci` note (a workflow-editing PR has no agent `--admin` hatch), keeps polling, and you tell the operator in chat |
64
64
 
65
- **Bound.** Re-run `required` at most 3 times, 10 minutes apart (waited the sanctioned way above). If the third read is still `pending`, or is `complete` while the PR is still not in the queue, stop and report to the operator with the marker line and the `--queue-state` output; do not loop, sync, or re-arm.
65
+ **Bound.** Re-run `required` at most 3 times, 10 minutes apart (waited the sanctioned way above). If the third read is still `pending`, or is `complete` while the PR is still not in the queue, stop and report to the operator with the marker line and the `--queue-state` output; do not loop, sync, or re-arm. In the Phase 7 poll the third read does not stop the poll: it prints `read budget spent`, the poll keeps running, and the report is your next status message (the marker line and the `--queue-state` output).
66
66
 
67
- **The monitor performs this read for you.** Wait for the monitor to EXIT before acting on its `CHECKS GREEN BUT BLOCKED` line or re-arming it: on this path that line is no longer the last one. The process exits only after the read, up to 125 seconds later, and holds the per-PR monitor lock meanwhile, so stopping it loses the read and re-arming gets `DUPLICATE MONITOR`. When `monitor-pr-checks.sh` is about to end on that line with a `full-decided` verdict, auto-merge armed and a positive not-queued read, it keeps watching for `MONITOR_REQUIRED_DWELL_S` seconds (default 600; a `HOLDING` line says so), then runs `required` once (`timeout -k 5 120`), prints a `running` line, and then the `RECOVERY` lines and the marker. It prints the hints and never runs one: read the marker per the table above, and count that read as the first of the 3. A `timeout` gives the resolver's own `state=error` marker with reason `interrupted`, or a `timed out` degraded line: run the block above by hand ONCE, and if that also times out report the BLOCKED line plus the degraded line. If more than 20 `basis=candidate` lines existed the monitor says how many it did not show: run the block by hand before escalating. A BLOCKED ending with no read after it means the read did not happen: auto-merge is off, the PR is queued or its queue state could not be read, the verdict is not `full-decided` (or could not be read), or the poll budget was shorter than the hold (a `not due` line says so). Re-check the armed, `not_queued` and `full-decided` probes above first, and run the block only if all three hold. The inline poll loop in ship Phase 7 (`ship/SKILL.md`) does not perform this read yet (tracked on #11544).
67
+ **The monitor performs this read for you.** Wait for the monitor to EXIT before acting on its `CHECKS GREEN BUT BLOCKED` line or re-arming it: on this path that line is no longer the last one. The process exits only after the read, up to 125 seconds later, and holds the per-PR monitor lock meanwhile, so stopping it loses the read and re-arming gets `DUPLICATE MONITOR`. When `monitor-pr-checks.sh` is about to end on that line with a `full-decided` verdict, auto-merge armed and a positive not-queued read, it keeps watching for `MONITOR_REQUIRED_DWELL_S` seconds (default 600; a `HOLDING` line says so), then runs `required` once (`timeout -k 5 120`), prints a `running` line, and then the `RECOVERY` lines and the marker. It prints the hints and never runs one: read the marker per the table above, and count that read as the first of the 3. A `timeout` gives the resolver's own `state=error` marker with reason `interrupted`, or a `timed out` degraded line: run the block above by hand ONCE, and if that also times out report the BLOCKED line plus the degraded line. If more than 20 `basis=candidate` lines existed the monitor says how many it did not show: run the block by hand before escalating. A BLOCKED ending with no read after it means the read did not happen: auto-merge is off, the PR is queued or its queue state could not be read, the verdict is not `full-decided` (or could not be read), or the poll budget was shorter than the hold (a `not due` line says so). Re-check the armed, `not_queued` and `full-decided` probes above first, and run the block only if all three hold.
68
+
69
+ **The Phase 7 poll performs it too (#11544).** The inline poll in ship Phase 7 (`ship/SKILL.md`) and its mirror in merge-pr 5.2 read the set on their own, through `${CLAUDE_PLUGIN_ROOT}/scripts/required-set-report.sh`, which runs `ci-head-verdict.sh required` under `timeout -k 5 120` and prints the `running` line, the `RECOVERY` lines (each must match the resolver's closed grammar, a line outside it is counted in one `N RECOVERY line(s) outside the resolver grammar not shown` line, run the block above by hand; candidates capped at 20) and the marker last, or one `no marker (...)` line; it exits 0 whatever the resolver does, so the fence reads the marker, never an exit code. The poll counts a green dwell, not plain BLOCKED ticks (a PR still waiting on running required checks also reads `OPEN BLOCKED`, and a required context that does not exist yet would then read `absent` too early): it reads only after 10 consecutive ticks on which the PR is `OPEN BLOCKED`, the `--queue-state` sample says `not_queued OPEN armed` and the `ci-head-verdict.sh verdict` sample says `full-decided`; both samples are taken every 5th tick and reused in between, so a PR whose gates hold from the first sample is read at tick 14. A tick that is not `OPEN BLOCKED` restarts the count at once; a queue or verdict gate that stops holding is seen only at the next sample (up to 4 ticks later) and restarts it then. The samples sit inside the `sync-pr-behind.sh` snapshot guard, so when a `[ship.phase7.precondition]` line disabled BEHIND auto-sync the poll never reads the set at all. A read prints a `[ship.phase7.required_set]` line first (it takes up to about 125 seconds, so that tick is slow, not stuck: do not stop or re-arm the poll; `MAX_POLL_MIN` counts iterations, so the poll's wall clock can exceed it by at most 3 x 125 seconds for the reads plus up to 65 seconds (`timeout -k 5 60`) for each sampled verdict; on a host without `timeout` that sample is unbounded, as the queue read beside it already is), then the script's lines. `absent` and `failed` end the poll with a `[ship.phase7.required_set] state=... — exiting poll` line: act on the table above, keyed on the marker. `complete`, `pending`, `error` and a missing marker print `state=<that state> — polling on (N required-set reads left)` and the poll continues; a missing marker is printed as `state=error`; when the script printed nothing at all the stream adds one line pointing here, and you then run the `required` block of this section by hand ONCE. The poll reads at most 3 times, 10 gate-holding ticks apart (the bound above); the third read prints `read budget spent` instead of `polling on`: state the marker and the `--queue-state` output in your next status message, then let the poll run on (it does not stop on that line). An `error` marker with `reason=untrusted-ci` also prints the one-line handoff note. After a recovery (a rerun, `gh pr ready --undo` then `gh pr ready`), re-invoke the Phase 7 poll. The poll prints the hints and never runs one; after the base-branch-workflow check below you may run a `rerun` hint yourself.
70
+
71
+ **Load the Phase 7 poll adds (#11544).** At most one `ci-head-verdict.sh verdict` call per 5th gate-holding tick (the sample stops once the 3 reads are spent) plus at most 3 required reads, each up to about 125 seconds. A verdict sample that fails (an empty result) silently restarts the dwell with no line: that is deliberate, an absent line is not a signal.
68
72
 
69
73
  **Reasons.** Reasons `required` itself emits (closed): `api-error`, `missing-tool`, `mktemp`, `no-admin-merge-ready`, `no-marker`, `child-rc-<n>`, `marker-mismatch`, `marker-unparseable`, `rc-mismatch`, `ready-with-gaps`, `required-unknown`, `no-culprit`, `bad-base`, `interrupted`. Reasons passed through from the child (informational): `all-green`, `not-green`, `stalled`, `awaiting-approval`, `stale-row`, `untrusted-ci`, `base-mismatch`, `empty-required`, `unsupported-rule`, `unpinned`, `incomplete-files`, `head-moved`, `not-open`. Do not switch on a reason, except `awaiting-approval`, `stale-row` and `stalled`: the script prints a dedicated `RECOVERY pointer` for each, and the pointer is the action. `--help` prints the contract.
70
74
 
@@ -73,7 +73,7 @@ while IFS=':' read -r line rest; do
73
73
  host="${host,,}" # lowercase
74
74
  # Detect utm tag
75
75
  if grep -qE 'utm_(source|medium|campaign|term|content)=' <<<"$url"; then
76
- camp="$(echo "$url" | grep -oE 'utm_campaign=[^&[:space:]]+' | head -1 | cut -d'=' -f2)"
76
+ camp="$(echo "$url" | grep -oE 'utm_campaign=[^&[:space:]]+' | head -1 | cut -d'=' -f2)" || true
77
77
  if is_allowlisted_host "$host"; then
78
78
  # First-party + allowlisted campaign → LOW-RISK; non-allowlisted campaign on first-party host still REVIEW
79
79
  if [ -n "$camp" ] && ! is_allowed_campaign "$camp"; then
@@ -112,7 +112,7 @@ done < <(grep -niE -- "$brand_re" "$tmp" 2>/dev/null || true)
112
112
  # Simplified: any `fetch(...)` or `axios.post(...)` whose URL host is not allowlisted → HIGH-RISK.
113
113
  fetch_re='\b(fetch|axios\.post|axios\.put|http\.post)[[:space:]]*\([[:space:]]*["'"'"'`](https?://[^"'"'"'`)[:space:]]+)'
114
114
  while IFS= read -r match; do
115
- url="$(echo "$match" | grep -oE "$url_re" | head -1)"
115
+ url="$(echo "$match" | grep -oE "$url_re" | head -1)" || true
116
116
  [ -z "$url" ] && continue
117
117
  nh="${url#http://}"; nh="${nh#https://}"; host="${nh%%[/?#]*}"; host="${host,,}"
118
118
  if ! is_allowlisted_host "$host"; then