@soleur/opencode 3.382.3 → 3.382.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 +1 -1
- package/skills/incident/SKILL.md +230 -4
- package/skills/incident/scripts/dry-run.sh +4 -0
- package/skills/incident/scripts/pull-card.sh +79 -0
- package/skills/incident/test/fixtures/pull-card-synthetic.json +3 -0
- package/skills/incident/test/pull-card.test.sh +626 -0
- package/skills/incident/test/redact-sentinel.test.sh +27 -11
package/package.json
CHANGED
package/skills/incident/SKILL.md
CHANGED
|
@@ -39,12 +39,238 @@ All prod-touching steps are advisory + ack-gated per `hr-menu-option-ack-not-pro
|
|
|
39
39
|
|
|
40
40
|
## Headless / Dry-run modes
|
|
41
41
|
|
|
42
|
-
- `--headless`: suppress interactive prompts. On any blocking ack, exit non-zero with a structured error message instead of waiting. Phase 8 still requires `status: resolved`.
|
|
43
|
-
- `--dry-run <fixture.json>`:
|
|
42
|
+
- `--headless`: do not perform a live pull. Print three `SOLEUR_INCIDENT_PULL` lines with `verdict=never-ran` and no log body, then suppress interactive prompts. On any blocking ack, exit non-zero with a structured error message instead of waiting. Write no post-mortem. Phase 8 still requires `status: resolved`.
|
|
43
|
+
- `--dry-run <fixture.json>`: do not perform a live pull. [scripts/dry-run.sh](./scripts/dry-run.sh) prints three `SOLEUR_INCIDENT_PULL` lines with `verdict=never-ran` and fills fields only from the fixture. It does not implement `--headless`. Dry-run never writes to `post-mortems/` and never invokes `compound-capture`; it emits the would-be PIR to stdout.
|
|
44
44
|
|
|
45
45
|
## Phase 0 — Capture facts
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
Skip the fence below on `--dry-run` and `--headless`. Those modes print three `SOLEUR_INCIDENT_PULL` lines with `verdict=never-ran` and no log body, and they do not call Doppler or the readers. `--dry-run` fills the nineteen fields only from the fixture.
|
|
48
|
+
|
|
49
|
+
On a live run, the founder may supply an optional window, an optional Sentry issue id, and an optional complaint sentence. The complaint is a claim. It is never passed as `--grep`. Scan it with the sentinel the Phase 6 fence assigns to `SENTINEL` before it is printed or copied onto the card. Copy that one assignment into this shell. Do not add a second copy of the path to this file. If the complaint matches, omit that sentence, print no offset line, still show the rest of the card, and start the nineteen-field interview. A match is not Phase 6's iterate-until-clean loop.
|
|
50
|
+
|
|
51
|
+
Skill-side window allowlist. A supplied window is one quoted word and the only `--since` for Better Stack and Supabase. Better Stack accepts `^[0-9]+[hmd]$`, `^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$`, or `^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$` (the space form only as that one quoted word). Supabase accepts `^[0-9]+[mhd]$` or `^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$`. A refused window does not exec: that source is `verdict=never-ran` `reason=usage`. When the window is omitted, Better Stack runs `doppler run -p soleur -c prd_terraform -- env -u BS_TABLE -u BS_TABLE_S3 scripts/betterstack-query.sh --table t520508_soleur_inngest_vector_prd_3_logs --since 1h`. The fence passes that same `--table` literal and unsets `BS_TABLE` and `BS_TABLE_S3`, so an inherited table cannot change the query while the card still names this one. Supabase runs `doppler run -p soleur -c prd -- scripts/supabase-logs-query.sh --ref ifsccnjhymdmidffkzhl --since 24h`. Sentry has no `--since`. Its card line says `window=n/a`.
|
|
52
|
+
|
|
53
|
+
An issue id must match `^[A-Za-z0-9_-]+$`. An id outside that grammar, or an id that starts with `-`, is not executed (`verdict=never-ran` `reason=usage`). The refused id is not printed. With no issue id, the card contains `sentry: not-queried reason=no-issue-id` and `doppler run -p soleur -c prd -- scripts/sentry-issue.sh` is not executed. Do not pass `--redact`, `--host-events`, or `--liveness`.
|
|
54
|
+
|
|
55
|
+
The `prd_terraform` Doppler config is the wrong config for Sentry and for Supabase.
|
|
56
|
+
|
|
57
|
+
The application ref `ifsccnjhymdmidffkzhl` is always the Supabase command. A second Supabase command, with the same `--since` and `-c prd`, runs only when the founder gives the project name `soleur-inngest-prd` or the ref `pigsfuxruiopinouvjwy`: `doppler run -p soleur -c prd -- scripts/supabase-logs-query.sh --ref pigsfuxruiopinouvjwy --since <the same window>`. The word inngest alone does not add this second command. Do not replace the application query. The application card line that ran carries `ref=ifsccnjhymdmidffkzhl`. A `reason=usage` line and a Doppler `reason=wrapper` line do not carry `ref=`. When the second command runs, its result is a separate card line carrying `ref=pigsfuxruiopinouvjwy`, and the marker stays the application exit. Otherwise the application line says the other ref was not queried.
|
|
58
|
+
|
|
59
|
+
Better Stack names table `t520508_soleur_inngest_vector_prd_3_logs` and `limit=100`. Do not decode `.raw`. Do not pass `--no-archive`. Exit 3 is `verdict=never-ran`. Exit 2 and exit 78 are `verdict=unverified` `reason=credential-refused`. Do not print stderr. Exit 0 with an empty body is `exit=0` and `stdout-empty`. That does not say the table or the archive had no rows. It is not health and it is not disproof of the complaint. Exit 0 with a body counts lines containing `"raw"`, and `truncated=true` only when that count is 100. Any other Better Stack exit is `verdict=unverified` `reason=reader-exit-N`, and the body is not rows.
|
|
60
|
+
|
|
61
|
+
Supabase copies the stdout `verdict=` and `reason=` pair and does not copy `rows=`. Do not count stdout log lines. Exit 0 is marker `verdict=queried` together with that reason. Exit 1 is marker `verdict=unverified`, the script's pair is copied once, and this skill does not run the command again. Exit 2 is `verdict=unverified` with the script's `reason=`. Exit 3 keeps the script's data verdict on the card and the marker `verdict=queried`. `reason=ZERO_SOURCE_COVERAGE_UNESTABLISHED` is not disproof of the complaint.
|
|
62
|
+
|
|
63
|
+
Sentry exit 77 is `verdict=unverified` `reason=401`. Exit 78 is `verdict=unverified` `reason=credential-refused`. Exit 1 is `verdict=unverified` `reason=reader-exit-1`. No retry, the body is not shown, and the skill does not halt. Any reader exit this section does not name is `verdict=unverified` `reason=reader-exit-N`.
|
|
64
|
+
|
|
65
|
+
Each source gets a line. One failure does not skip the others or the nineteen-field interview. If the `doppler` binary is missing, Better Stack and Supabase are `verdict=never-ran` `reason=wrapper`. Sentry is `reason=wrapper` only when an issue id was going to be executed. With no issue id, Sentry stays `not-queried` `reason=no-issue-id`. An id outside the grammar stays `reason=usage`. If `prd` cannot be read and `prd_terraform` can, Better Stack still runs and Sentry and Supabase are `verdict=never-ran` `reason=wrapper`. Do not parse wrapper stdout as rows. Do not start `doppler login`. Do not run [scripts/ensure-doppler.sh](../../../../scripts/ensure-doppler.sh). Do not re-exec. A Better Stack or Supabase line that ran, or that the Doppler wrapper skipped, appends `window=` of the allowlisted value or the default. A `reason=usage` line does not print the refused window.
|
|
66
|
+
|
|
67
|
+
Print one stdout marker per source, with no log body: `SOLEUR_INCIDENT_PULL source=<betterstack|sentry|supabase> verdict=<queried|not-queried|unverified|never-ran>`. A `reason=` suffix is allowed. The verdict set does not grow.
|
|
68
|
+
|
|
69
|
+
The card is those coverage lines plus at most one hypothesis sentence assembled only from coverage fields (source, window, table or ref, exit, the Better Stack line count, truncated, and the Supabase `verdict=` and `reason=`). It does not rank causes, name a service, an error, or a user count, or say the complaint is false, or say what would disprove the complaint. If nothing can be said that way, the card says `hypotheses=none`. Three source lines and `hypotheses=none` are shown. The card does not assign `affected_user_count`, `data_categories_breached`, `risk_to_subjects`, `revenue_impact`, `detected_at`, `detection_method`, or `monitoring_detected_at`. Do not infer a user count from a line count, and do not print a pull time or offer one for `monitoring_detected_at`. The pull does not feed the `mttd-transposed` halt.
|
|
70
|
+
|
|
71
|
+
The card is not written under `post-mortems/`. When the founder confirms the card, copy its one coverage sentence into the root-cause field. `hypotheses=none` copies nothing. Do not copy into the 5-whys, the breach fields, or the Art. 33 tokens. Confirming the card is not `ACK-ART33`, not `ACK-ART34`, and not `COMMIT-PIR`.
|
|
72
|
+
|
|
73
|
+
Run this fence from the worktree root that contains `scripts/`, as one shell. Create each stdout temp with `mktemp -p /tmp` outside the repository, mode `0600`. The `EXIT` trap removes the temps and does not exit. `INT`, `TERM`, and `HUP` remove the temps and exit 130, 143, and 129, so a stopped pull does not start the remaining readers. `EXIT INT TERM HUP` is the set that deletes the temps. If a temp path is inside the worktree, halt with `SOLEUR_INCIDENT_HALT reason=temp-inside-worktree` and do not start a reader. Redirect stdout on the reader command and discard stderr. Do not print the temp path on the pass path or the fail path. Do not `Read` or `cat` the temp. `pull-card.sh` is the only reader of that temp. Show the card only when the sentinel exits 0. A zero-byte card emits `SOLEUR_INCIDENT_PULL` with `reason=card-empty`, shows nothing, does not print `SOLEUR_INCIDENT_HALT`, and starts the nineteen-field interview. Sentinel exit 1 on the card emits `SOLEUR_INCIDENT_PULL` with `reason=card-redaction-failed`, prints no offset line, does not print the temp path, does not print `SOLEUR_INCIDENT_HALT`, does not enter Phase 6's iterate-until-clean loop, and still starts the interview. Phase 6's loop is unchanged. Exit 2 prints `SOLEUR_INCIDENT_HALT` and shows nothing.
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Paste the Phase 6 SENTINEL assignment above the readability check before running this fence.
|
|
77
|
+
# Each fence is its own shell, so the later assignment does not survive. Do not add a second copy of the sentinel path to this file.
|
|
78
|
+
set +e
|
|
79
|
+
# Exact token only. A default arm is banned, and nounset aborts before this halt.
|
|
80
|
+
set +u
|
|
81
|
+
if [[ -z "${CLAUDE_PLUGIN_ROOT}" ]]; then
|
|
82
|
+
echo "SOLEUR_INCIDENT_HALT reason=plugin-root-unverified"
|
|
83
|
+
exit 2
|
|
84
|
+
fi
|
|
85
|
+
set -u
|
|
86
|
+
bs_out="$(mktemp -p /tmp)"
|
|
87
|
+
sb_out="$(mktemp -p /tmp)"
|
|
88
|
+
sb2_out="$(mktemp -p /tmp)"
|
|
89
|
+
sy_out="$(mktemp -p /tmp)"
|
|
90
|
+
card="$(mktemp -p /tmp)"
|
|
91
|
+
complaint_out="$(mktemp -p /tmp)"
|
|
92
|
+
chmod 0600 "$bs_out" "$sb_out" "$sb2_out" "$sy_out" "$card" "$complaint_out"
|
|
93
|
+
repo_phys="$(pwd -P)"
|
|
94
|
+
for tmp in "$bs_out" "$sb_out" "$sb2_out" "$sy_out" "$card" "$complaint_out"; do
|
|
95
|
+
case "$tmp" in
|
|
96
|
+
"$repo_phys"|"$repo_phys"/*)
|
|
97
|
+
echo "SOLEUR_INCIDENT_HALT reason=temp-inside-worktree"
|
|
98
|
+
exit 2
|
|
99
|
+
;;
|
|
100
|
+
esac
|
|
101
|
+
done
|
|
102
|
+
trap 'rm -f "$bs_out" "$sb_out" "$sb2_out" "$sy_out" "$card" "$complaint_out"' EXIT
|
|
103
|
+
trap 'rm -f "$bs_out" "$sb_out" "$sb2_out" "$sy_out" "$card" "$complaint_out"; exit 130' INT
|
|
104
|
+
trap 'rm -f "$bs_out" "$sb_out" "$sb2_out" "$sy_out" "$card" "$complaint_out"; exit 143' TERM
|
|
105
|
+
trap 'rm -f "$bs_out" "$sb_out" "$sb2_out" "$sy_out" "$card" "$complaint_out"; exit 129' HUP
|
|
106
|
+
if [[ -z "${SENTINEL:-}" || ! -r "${SENTINEL}" ]]; then
|
|
107
|
+
echo "SOLEUR_INCIDENT_HALT reason=sentinel-unreadable"
|
|
108
|
+
exit 2
|
|
109
|
+
fi
|
|
110
|
+
window="${INCIDENT_WINDOW:-}"
|
|
111
|
+
issue_id="${INCIDENT_SENTRY_ISSUE_ID:-}"
|
|
112
|
+
sb_project="${INCIDENT_SUPABASE_PROJECT:-}"
|
|
113
|
+
bs_since="1h"
|
|
114
|
+
sb_since="24h"
|
|
115
|
+
bs_skip=""
|
|
116
|
+
sb_skip=""
|
|
117
|
+
if [[ -n "$window" ]]; then
|
|
118
|
+
if [[ "$window" =~ ^[0-9]+[hmd]$ || "$window" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$ || "$window" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}\ [0-9]{2}:[0-9]{2}:[0-9]{2}$ ]]; then
|
|
119
|
+
bs_since="$window"
|
|
120
|
+
else
|
|
121
|
+
bs_skip="usage"
|
|
122
|
+
fi
|
|
123
|
+
if [[ "$window" =~ ^[0-9]+[mhd]$ || "$window" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$ ]]; then
|
|
124
|
+
sb_since="$window"
|
|
125
|
+
else
|
|
126
|
+
sb_skip="usage"
|
|
127
|
+
fi
|
|
128
|
+
fi
|
|
129
|
+
tf_ok=0
|
|
130
|
+
prd_ok=0
|
|
131
|
+
if ! command -v doppler >/dev/null 2>&1; then
|
|
132
|
+
tf_ok=0
|
|
133
|
+
prd_ok=0
|
|
134
|
+
else
|
|
135
|
+
doppler run -p soleur -c prd_terraform -- true >/dev/null 2>&1
|
|
136
|
+
tf_rc=$?
|
|
137
|
+
doppler run -p soleur -c prd -- true >/dev/null 2>&1
|
|
138
|
+
prd_rc=$?
|
|
139
|
+
if [[ "$tf_rc" -eq 0 ]]; then tf_ok=1; fi
|
|
140
|
+
if [[ "$prd_rc" -eq 0 ]]; then prd_ok=1; fi
|
|
141
|
+
fi
|
|
142
|
+
bs_line=""
|
|
143
|
+
sb_line=""
|
|
144
|
+
sy_line=""
|
|
145
|
+
if [[ -n "$bs_skip" ]]; then
|
|
146
|
+
echo "SOLEUR_INCIDENT_PULL source=betterstack verdict=never-ran reason=usage"
|
|
147
|
+
bs_line="betterstack verdict=never-ran reason=usage"
|
|
148
|
+
elif [[ "$tf_ok" -ne 1 ]]; then
|
|
149
|
+
echo "SOLEUR_INCIDENT_PULL source=betterstack verdict=never-ran reason=wrapper"
|
|
150
|
+
bs_line="betterstack verdict=never-ran reason=wrapper window=${bs_since}"
|
|
151
|
+
else
|
|
152
|
+
doppler run -p soleur -c prd_terraform -- env -u BS_TABLE -u BS_TABLE_S3 scripts/betterstack-query.sh --table t520508_soleur_inngest_vector_prd_3_logs --since "$bs_since" >"$bs_out" 2>/dev/null
|
|
153
|
+
bs_rc=$?
|
|
154
|
+
bs_line="$(bash "${CLAUDE_PLUGIN_ROOT}/skills/incident/scripts/pull-card.sh" betterstack "$bs_rc" "$bs_out")"
|
|
155
|
+
bs_line="${bs_line} window=${bs_since}"
|
|
156
|
+
if [[ "$bs_rc" -eq 0 ]]; then
|
|
157
|
+
echo "SOLEUR_INCIDENT_PULL source=betterstack verdict=queried"
|
|
158
|
+
elif [[ "$bs_rc" -eq 3 ]]; then
|
|
159
|
+
echo "SOLEUR_INCIDENT_PULL source=betterstack verdict=never-ran"
|
|
160
|
+
elif [[ "$bs_rc" -eq 2 || "$bs_rc" -eq 78 ]]; then
|
|
161
|
+
echo "SOLEUR_INCIDENT_PULL source=betterstack verdict=unverified reason=credential-refused"
|
|
162
|
+
else
|
|
163
|
+
echo "SOLEUR_INCIDENT_PULL source=betterstack verdict=unverified reason=reader-exit-${bs_rc}"
|
|
164
|
+
fi
|
|
165
|
+
fi
|
|
166
|
+
if [[ -n "$sb_skip" ]]; then
|
|
167
|
+
echo "SOLEUR_INCIDENT_PULL source=supabase verdict=never-ran reason=usage"
|
|
168
|
+
sb_line="supabase verdict=never-ran reason=usage"
|
|
169
|
+
elif [[ "$prd_ok" -ne 1 ]]; then
|
|
170
|
+
echo "SOLEUR_INCIDENT_PULL source=supabase verdict=never-ran reason=wrapper"
|
|
171
|
+
sb_line="supabase verdict=never-ran reason=wrapper window=${sb_since}"
|
|
172
|
+
else
|
|
173
|
+
doppler run -p soleur -c prd -- scripts/supabase-logs-query.sh --ref ifsccnjhymdmidffkzhl --since "$sb_since" >"$sb_out" 2>/dev/null
|
|
174
|
+
sb_rc=$?
|
|
175
|
+
sb_line="$(bash "${CLAUDE_PLUGIN_ROOT}/skills/incident/scripts/pull-card.sh" supabase "$sb_rc" "$sb_out")"
|
|
176
|
+
sb_reason=""
|
|
177
|
+
case "$sb_line" in
|
|
178
|
+
*reason=*) sb_reason="${sb_line##*reason=}" ;;
|
|
179
|
+
esac
|
|
180
|
+
if [[ -z "$sb_reason" ]]; then
|
|
181
|
+
echo "SOLEUR_INCIDENT_PULL source=supabase verdict=unverified reason=reader-exit-${sb_rc}"
|
|
182
|
+
elif [[ "$sb_rc" -eq 0 || "$sb_rc" -eq 3 ]]; then
|
|
183
|
+
echo "SOLEUR_INCIDENT_PULL source=supabase verdict=queried reason=${sb_reason}"
|
|
184
|
+
elif [[ "$sb_rc" -eq 1 || "$sb_rc" -eq 2 ]]; then
|
|
185
|
+
echo "SOLEUR_INCIDENT_PULL source=supabase verdict=unverified reason=${sb_reason}"
|
|
186
|
+
else
|
|
187
|
+
echo "SOLEUR_INCIDENT_PULL source=supabase verdict=unverified reason=reader-exit-${sb_rc}"
|
|
188
|
+
fi
|
|
189
|
+
sb_line="${sb_line} ref=ifsccnjhymdmidffkzhl window=${sb_since}"
|
|
190
|
+
if [[ "$sb_project" == "soleur-inngest-prd" || "$sb_project" == "pigsfuxruiopinouvjwy" ]]; then
|
|
191
|
+
doppler run -p soleur -c prd -- scripts/supabase-logs-query.sh --ref pigsfuxruiopinouvjwy --since "$sb_since" >"$sb2_out" 2>/dev/null
|
|
192
|
+
sb2_rc=$?
|
|
193
|
+
sb2_line="$(bash "${CLAUDE_PLUGIN_ROOT}/skills/incident/scripts/pull-card.sh" supabase "$sb2_rc" "$sb2_out")"
|
|
194
|
+
sb2_line="${sb2_line} ref=pigsfuxruiopinouvjwy window=${sb_since}"
|
|
195
|
+
sb_line="${sb_line}"$'\n'"${sb2_line}"
|
|
196
|
+
else
|
|
197
|
+
sb_line="${sb_line} other-ref=not-queried"
|
|
198
|
+
fi
|
|
199
|
+
fi
|
|
200
|
+
if [[ -z "$issue_id" ]]; then
|
|
201
|
+
echo "SOLEUR_INCIDENT_PULL source=sentry verdict=not-queried reason=no-issue-id"
|
|
202
|
+
sy_line="sentry: not-queried reason=no-issue-id window=n/a"
|
|
203
|
+
elif [[ "$issue_id" == -* || ! "$issue_id" =~ ^[A-Za-z0-9_-]+$ ]]; then
|
|
204
|
+
echo "SOLEUR_INCIDENT_PULL source=sentry verdict=never-ran reason=usage"
|
|
205
|
+
sy_line="sentry verdict=never-ran reason=usage window=n/a"
|
|
206
|
+
elif [[ "$prd_ok" -ne 1 ]]; then
|
|
207
|
+
echo "SOLEUR_INCIDENT_PULL source=sentry verdict=never-ran reason=wrapper"
|
|
208
|
+
sy_line="sentry verdict=never-ran reason=wrapper window=n/a"
|
|
209
|
+
else
|
|
210
|
+
doppler run -p soleur -c prd -- scripts/sentry-issue.sh "$issue_id" >"$sy_out" 2>/dev/null
|
|
211
|
+
sy_rc=$?
|
|
212
|
+
sy_line="$(bash "${CLAUDE_PLUGIN_ROOT}/skills/incident/scripts/pull-card.sh" sentry "$sy_rc" "$sy_out")"
|
|
213
|
+
if [[ "$sy_rc" -eq 0 ]]; then
|
|
214
|
+
echo "SOLEUR_INCIDENT_PULL source=sentry verdict=queried"
|
|
215
|
+
sy_line="sentry verdict=queried window=n/a"
|
|
216
|
+
elif [[ "$sy_rc" -eq 77 ]]; then
|
|
217
|
+
echo "SOLEUR_INCIDENT_PULL source=sentry verdict=unverified reason=401"
|
|
218
|
+
sy_line="sentry verdict=unverified reason=401 window=n/a"
|
|
219
|
+
elif [[ "$sy_rc" -eq 78 ]]; then
|
|
220
|
+
echo "SOLEUR_INCIDENT_PULL source=sentry verdict=unverified reason=credential-refused"
|
|
221
|
+
sy_line="sentry verdict=unverified reason=credential-refused window=n/a"
|
|
222
|
+
else
|
|
223
|
+
echo "SOLEUR_INCIDENT_PULL source=sentry verdict=unverified reason=reader-exit-${sy_rc}"
|
|
224
|
+
sy_line="sentry verdict=unverified reason=reader-exit-${sy_rc} window=n/a"
|
|
225
|
+
fi
|
|
226
|
+
fi
|
|
227
|
+
# An inherited xtrace would print the complaint before the sentinel scans it.
|
|
228
|
+
# The assignment stays below set +x. Nothing above this line expands the complaint.
|
|
229
|
+
set +x
|
|
230
|
+
complaint="${INCIDENT_COMPLAINT:-}"
|
|
231
|
+
complaint_keep=""
|
|
232
|
+
if [[ -n "$complaint" ]]; then
|
|
233
|
+
printf '%s\n' "$complaint" > "$complaint_out"
|
|
234
|
+
bash "$SENTINEL" "$complaint_out" >/dev/null 2>&1
|
|
235
|
+
complaint_rc=$?
|
|
236
|
+
if [[ "$complaint_rc" -eq 0 ]]; then
|
|
237
|
+
complaint_keep="$complaint"
|
|
238
|
+
elif [[ "$complaint_rc" -ne 1 ]]; then
|
|
239
|
+
echo "SOLEUR_INCIDENT_HALT reason=sentinel-exit-2"
|
|
240
|
+
exit 2
|
|
241
|
+
fi
|
|
242
|
+
fi
|
|
243
|
+
{
|
|
244
|
+
printf '%s\n' "$bs_line"
|
|
245
|
+
printf '%s\n' "$sb_line"
|
|
246
|
+
printf '%s\n' "$sy_line"
|
|
247
|
+
if [[ -n "$complaint_keep" ]]; then
|
|
248
|
+
printf 'complaint: %s\n' "$complaint_keep"
|
|
249
|
+
fi
|
|
250
|
+
# Before the card sentinel, replace this single hypotheses=none line only when one sentence can be built from the coverage fields above. Leave hypotheses=none otherwise.
|
|
251
|
+
printf '%s\n' "hypotheses=none"
|
|
252
|
+
} > "$card"
|
|
253
|
+
if [[ ! -s "$card" ]]; then
|
|
254
|
+
echo "SOLEUR_INCIDENT_PULL source=betterstack verdict=unverified reason=card-empty"
|
|
255
|
+
echo "SOLEUR_INCIDENT_PULL source=sentry verdict=unverified reason=card-empty"
|
|
256
|
+
echo "SOLEUR_INCIDENT_PULL source=supabase verdict=unverified reason=card-empty"
|
|
257
|
+
else
|
|
258
|
+
bash "$SENTINEL" "$card" >/dev/null 2>&1
|
|
259
|
+
sent_rc=$?
|
|
260
|
+
if [[ "$sent_rc" -eq 0 ]]; then
|
|
261
|
+
cat "$card"
|
|
262
|
+
elif [[ "$sent_rc" -eq 1 ]]; then
|
|
263
|
+
echo "SOLEUR_INCIDENT_PULL source=betterstack verdict=unverified reason=card-redaction-failed"
|
|
264
|
+
echo "SOLEUR_INCIDENT_PULL source=sentry verdict=unverified reason=card-redaction-failed"
|
|
265
|
+
echo "SOLEUR_INCIDENT_PULL source=supabase verdict=unverified reason=card-redaction-failed"
|
|
266
|
+
else
|
|
267
|
+
echo "SOLEUR_INCIDENT_HALT reason=sentinel-exit-2"
|
|
268
|
+
exit 2
|
|
269
|
+
fi
|
|
270
|
+
fi
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
> **No-SSH fact-pulling (Soleur vision — `hr-no-dashboard-eyeball-pull-data-yourself`).** The operator is non-technical: NEVER ask them to SSH, run `df -h`, or read a dashboard, and do NOT trust the report's stated *mechanism*. The pull at the start of this phase is the only live read. Do not run a second pull from this note. This includes NEVER asking the operator to paste verbatim error output, run `grep`/`stat`/`git config` probes, or eyeball logs — the operator decides, they do not retrieve. If a needed signal has no no-SSH read path, **BUILD one** — add a monitored stdout `SOLEUR_*` marker in the emitting code (or emit to a GitHub issue/DB/endpoint) so the next occurrence self-reports, rather than deferring to the operator. **Why:** #4886 — the incident report blamed ENOSPC; the real cause (a dirty-clone `.claude/settings.json` blocking `git pull`) was one Sentry-issue read away. #5934 — the worktree-wedge diagnosis twice asked the operator to paste `grep`/`stat` output that the observability layer held once instrumented (`SOLEUR_GIT_CONFIG_TARGET_MASKED`, `SOLEUR_GIT_WORKTREE_VERIFY_FAILED`). See [[2026-06-03-no-ssh-prod-signal-toolchain-never-hand-the-operator-an-ssh-task]] and [[2026-07-08-self-pull-observability-in-diagnostic-loops-never-ask-operator-to-fetch]].
|
|
48
274
|
|
|
49
275
|
<!-- -->
|
|
50
276
|
> **Unreachable host with no log-shipping — READ before you MUTATE (`hr-no-dashboard-eyeball-pull-data-yourself` extended to diagnosis).** When the failing surface is a host that answers nothing (no SSH, no Vector/journald shipping, no Sentry emit), the self-serve read path is the **provider API + rescue mode** — it is NOT an operator-console task. Ladder, in order: (1) **Provider API reads** — `GET /servers/{id}` (status, `private_net`), `/metrics?type=cpu,disk,network`, `/actions`. Query the **BOOT window**, not the current window: an unreachable-but-idle host reads `net=0/disk=0` and looks "dead" when it merely has no clients. (2) **Rescue-mode disk read** (Hetzner: `enable_rescue` with `{"type":"linux64","ssh_keys":[<id>]}` to inject a registered key whose private half is in your agent → key auth, no `sshpass`; scope SSH in by `set_rules` allowing ONLY your egress IP on `:22` and restore `{"rules":[]}` immediately after; `reboot` → SSH → `lsblk` (the OS disk is NOT necessarily `sda` — an attached volume can take it) → mount the boot partition → read `/var/log/cloud-init-output.log`, `grep -iE 'error|fail' /var/log/cloud-init.log`, `/var/lib/cloud/data/status.json`). (3) **Only then mutate**, and only via the sanctioned destroy-guarded dispatch (`apply-web-platform-infra.yml apply_target=…`) — **never a hand-rolled `terraform apply`**: an out-of-band apply on an unverified hypothesis diverges prod from `main` and makes the guarded recovery abort `out_of_scope=1`, blocking the real fix. Guard aborts are information — read their counters (`out_of_scope=`, `server_replaced=`, `volume_created=`) to learn which recovery path actually fits. And `Apply complete` is not proof: `GET` the resource to confirm the provider's reality. **Why:** #6400 — four hypotheses (credential → firewall → store OOM → boot) were mutated-then-tested over hours; a rescue read of `cloud-init.log` named the real cause (a transient IMDS failure left the host with no private NIC) in one shot, and a hypothesis-driven firewall apply blocked the sanctioned recreate three times. See [[2026-07-15-infra-incident-diagnose-before-mutate-and-no-out-of-band-applies]].
|
|
@@ -222,7 +448,7 @@ Selected runbook slugs auto-populate Phase 4 `triggers[]` verbatim (SpecFlow Imp
|
|
|
222
448
|
| `{{DETECTION_METHOD}}` | Phase 0 `detection_method` enum: `monitoring \| external \| manual` |
|
|
223
449
|
| `{{MTTD}}` | Computed locally; `Unknown (external/manual report)` when not monitoring-detected |
|
|
224
450
|
| `{{TRIGGERED_BY}}` | Phase 0 `triggered_by` enum: `user \| system \| market \| provider` |
|
|
225
|
-
| `{{ROOT_CAUSE_HYPOTHESIS}}` | TBD
|
|
451
|
+
| `{{ROOT_CAUSE_HYPOTHESIS}}` | The one coverage sentence copied when the founder confirms the pull card. `hypotheses=none` leaves `TBD` for the Phase 7 review. The 5-whys stay founder-written. |
|
|
226
452
|
| `{{RESOLUTION}}` | Phase 0 `resolution` (operator prose; default `TBD`) |
|
|
227
453
|
| `{{ROOT_CAUSE_5WHYS}}` | Phase 7 review (operator fills; default `TBD`) |
|
|
228
454
|
| `{{VERSION_TRIGGERED}}` | Phase 0 `version_triggered` (repo + version/PR/SHA; default `TBD`) |
|
|
@@ -138,6 +138,10 @@ fi
|
|
|
138
138
|
rm -f "${early_input_check}"
|
|
139
139
|
|
|
140
140
|
# --- Phase 0 ---
|
|
141
|
+
# Live readers stay in the skill. This harness does not call them.
|
|
142
|
+
echo "SOLEUR_INCIDENT_PULL source=betterstack verdict=never-ran"
|
|
143
|
+
echo "SOLEUR_INCIDENT_PULL source=sentry verdict=never-ran"
|
|
144
|
+
echo "SOLEUR_INCIDENT_PULL source=supabase verdict=never-ran"
|
|
141
145
|
echo "=== Phase 0: facts captured ==="
|
|
142
146
|
echo " title: ${title}"
|
|
143
147
|
echo " detected_at: ${detected_at}"
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# One coverage line from a reader stdout temp.
|
|
3
|
+
# Does not print the path, a log line, rows=, or a decoded body.
|
|
4
|
+
# The incident marker is printed by the skill, not by this script.
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
if [[ $# -ne 3 ]]; then
|
|
8
|
+
echo "usage: pull-card.sh <betterstack|sentry|supabase> <exit-code> <stdout-path>" >&2
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
source_name="$1"
|
|
13
|
+
exit_code="$2"
|
|
14
|
+
stdout_path="$3"
|
|
15
|
+
|
|
16
|
+
case "$source_name" in
|
|
17
|
+
betterstack|sentry|supabase) ;;
|
|
18
|
+
*)
|
|
19
|
+
echo "usage: source must be betterstack, sentry, or supabase" >&2
|
|
20
|
+
exit 1
|
|
21
|
+
;;
|
|
22
|
+
esac
|
|
23
|
+
|
|
24
|
+
if ! [[ "$exit_code" =~ ^[0-9]+$ ]]; then
|
|
25
|
+
echo "usage: exit code must be numeric" >&2
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
case "$source_name" in
|
|
30
|
+
betterstack)
|
|
31
|
+
table="t520508_soleur_inngest_vector_prd_3_logs"
|
|
32
|
+
if [[ "$exit_code" -eq 0 ]]; then
|
|
33
|
+
if [[ ! -s "$stdout_path" ]]; then
|
|
34
|
+
printf 'betterstack table=%s limit=100 exit=0 stdout-empty\n' "$table"
|
|
35
|
+
else
|
|
36
|
+
count="$(grep -c '"raw"' "$stdout_path" 2>/dev/null || true)"
|
|
37
|
+
count="${count:-0}"
|
|
38
|
+
if [[ "$count" -eq 100 ]]; then
|
|
39
|
+
printf 'betterstack table=%s limit=100 exit=0 raw=%s truncated=true\n' "$table" "$count"
|
|
40
|
+
else
|
|
41
|
+
printf 'betterstack table=%s limit=100 exit=0 raw=%s\n' "$table" "$count"
|
|
42
|
+
fi
|
|
43
|
+
fi
|
|
44
|
+
else
|
|
45
|
+
printf 'betterstack table=%s limit=100 exit=%s\n' "$table" "$exit_code"
|
|
46
|
+
fi
|
|
47
|
+
;;
|
|
48
|
+
supabase)
|
|
49
|
+
pair=""
|
|
50
|
+
if [[ -r "$stdout_path" ]]; then
|
|
51
|
+
# Human stdout is log lines, then one verdict line last. An earlier line can carry both tokens. Keep the last complete pair. Do not copy rows=.
|
|
52
|
+
pair="$(awk '
|
|
53
|
+
{
|
|
54
|
+
v = ""
|
|
55
|
+
r = ""
|
|
56
|
+
for (i = 1; i <= NF; i++) {
|
|
57
|
+
if ($i ~ /^verdict=/) v = $i
|
|
58
|
+
if ($i ~ /^reason=/) r = $i
|
|
59
|
+
}
|
|
60
|
+
if (v != "" && r != "") {
|
|
61
|
+
last_v = v
|
|
62
|
+
last_r = r
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
END {
|
|
66
|
+
if (last_v != "" && last_r != "") print last_v, last_r
|
|
67
|
+
}
|
|
68
|
+
' "$stdout_path" 2>/dev/null || true)"
|
|
69
|
+
fi
|
|
70
|
+
if [[ -n "$pair" ]]; then
|
|
71
|
+
printf 'supabase %s\n' "$pair"
|
|
72
|
+
else
|
|
73
|
+
printf 'supabase exit=%s\n' "$exit_code"
|
|
74
|
+
fi
|
|
75
|
+
;;
|
|
76
|
+
sentry)
|
|
77
|
+
printf 'sentry exit=%s window=n/a\n' "$exit_code"
|
|
78
|
+
;;
|
|
79
|
+
esac
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
{"dt":"2026-01-01T00:00:00Z","raw":"{\"event_message\":\"workspace 11111111-2222-4333-8444-555555555555 address 203.0.113.50 mail fixture-pull@example.invalid\",\"message\":\"workspace 11111111-2222-4333-8444-555555555555 address 203.0.113.50 mail fixture-pull@example.invalid\"}"}
|
|
2
|
+
verdict=COVERED reason=FULLY_COVERED
|
|
3
|
+
{"exception":{"values":[{"value":"workspace 11111111-2222-4333-8444-555555555555 address 203.0.113.50 mail fixture-pull@example.invalid"}]}}
|
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Coverage card for the incident skill pull. Synthesized fixtures only.
|
|
3
|
+
# No Doppler and no live readers. Headless stays skill prose: this file does
|
|
4
|
+
# not claim dry-run.sh implements --headless.
|
|
5
|
+
set -uo pipefail
|
|
6
|
+
|
|
7
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
+
SKILL_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
9
|
+
REPO_ROOT="$(cd "${SKILL_DIR}/../../../.." && pwd)"
|
|
10
|
+
|
|
11
|
+
SKILL="${SKILL_DIR}/SKILL.md"
|
|
12
|
+
PRINTER="${SKILL_DIR}/scripts/pull-card.sh"
|
|
13
|
+
DRY_RUN="${SKILL_DIR}/scripts/dry-run.sh"
|
|
14
|
+
SENTINEL="${SKILL_DIR}/scripts/redact-sentinel.sh"
|
|
15
|
+
FIXTURE="${SCRIPT_DIR}/fixtures/pull-card-synthetic.json"
|
|
16
|
+
DRY_FIXTURE="${SCRIPT_DIR}/fixtures/dry-run-incident.json"
|
|
17
|
+
MARKER_TS="${REPO_ROOT}/apps/web-platform/server/git-lock-marker-telemetry.ts"
|
|
18
|
+
|
|
19
|
+
UUID_LIT='11111111-2222-4333-8444-555555555555'
|
|
20
|
+
IPV4_LIT='203.0.113.50'
|
|
21
|
+
EMAIL_LIT='fixture-pull@example.invalid'
|
|
22
|
+
TABLE='t520508_soleur_inngest_vector_prd_3_logs'
|
|
23
|
+
|
|
24
|
+
PASS=0
|
|
25
|
+
FAIL=0
|
|
26
|
+
|
|
27
|
+
# Byte-for-byte with plugins/soleur/test/test-helpers.sh. An inline case is not recognised.
|
|
28
|
+
assert_fixture_dir() {
|
|
29
|
+
case "${1-}" in
|
|
30
|
+
"") printf 'FATAL: fixture dir is EMPTY; git -C "" would operate on %s\n' "$PWD" >&2; exit 2 ;;
|
|
31
|
+
*/../*|*/..) printf 'FATAL: fixture dir %s contains ..; refusing\n' "$1" >&2; exit 2 ;;
|
|
32
|
+
/proc/*|/sys/*|/dev/*) printf 'FATAL: fixture dir %s is a synthetic-fs path; refusing\n' "$1" >&2; exit 2 ;;
|
|
33
|
+
/|//|/.) printf 'FATAL: fixture dir resolves to the filesystem root; refusing\n' >&2; exit 2 ;;
|
|
34
|
+
/*) : ;;
|
|
35
|
+
*) printf 'FATAL: fixture dir %s is RELATIVE; refusing\n' "$1" >&2; exit 2 ;;
|
|
36
|
+
esac
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
TMP_DIR="$(mktemp -d)"
|
|
40
|
+
assert_fixture_dir "$TMP_DIR"
|
|
41
|
+
trap 'rm -rf "${TMP_DIR}"' EXIT INT TERM HUP
|
|
42
|
+
|
|
43
|
+
pass() { echo "PASS: $1"; PASS=$((PASS + 1)); }
|
|
44
|
+
fail() { echo "FAIL: $1"; FAIL=$((FAIL + 1)); }
|
|
45
|
+
|
|
46
|
+
need_file() {
|
|
47
|
+
if [[ -f "$1" ]]; then
|
|
48
|
+
pass "present ${1##*/}"
|
|
49
|
+
else
|
|
50
|
+
fail "missing ${1##*/}"
|
|
51
|
+
fi
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# Fixed-string presence. The label is the needle.
|
|
55
|
+
has() {
|
|
56
|
+
local needle="$1" file="$2"
|
|
57
|
+
if grep -qF -- "$needle" "$file"; then
|
|
58
|
+
pass "has ${needle}"
|
|
59
|
+
else
|
|
60
|
+
fail "missing ${needle}"
|
|
61
|
+
fi
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
lacks() {
|
|
65
|
+
local needle="$1" file="$2" label="$3"
|
|
66
|
+
if grep -qF -- "$needle" "$file"; then
|
|
67
|
+
fail "${label} contains ${needle}"
|
|
68
|
+
else
|
|
69
|
+
pass "${label} lacks ${needle}"
|
|
70
|
+
fi
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# --- skill text -----------------------------------------------------------
|
|
74
|
+
need_file "$SKILL"
|
|
75
|
+
|
|
76
|
+
has 'This skill should be used when scaffolding a redaction-gated post-incident report (PIR) after a production incident.' "$SKILL"
|
|
77
|
+
has 'doppler run -p soleur -c prd_terraform -- env -u BS_TABLE -u BS_TABLE_S3 scripts/betterstack-query.sh --table t520508_soleur_inngest_vector_prd_3_logs --since 1h' "$SKILL"
|
|
78
|
+
has 'doppler run -p soleur -c prd -- scripts/supabase-logs-query.sh --ref ifsccnjhymdmidffkzhl --since 24h' "$SKILL"
|
|
79
|
+
has 'doppler run -p soleur -c prd -- scripts/sentry-issue.sh' "$SKILL"
|
|
80
|
+
has "$TABLE" "$SKILL"
|
|
81
|
+
has 'limit=100' "$SKILL"
|
|
82
|
+
has 'soleur-inngest-prd' "$SKILL"
|
|
83
|
+
has 'pigsfuxruiopinouvjwy' "$SKILL"
|
|
84
|
+
has 'The word inngest alone does not add' "$SKILL"
|
|
85
|
+
has 'sentry: not-queried reason=no-issue-id' "$SKILL"
|
|
86
|
+
has 'window=n/a' "$SKILL"
|
|
87
|
+
has 'verdict=never-ran' "$SKILL"
|
|
88
|
+
has 'reason=usage' "$SKILL"
|
|
89
|
+
has 'reason=card-empty' "$SKILL"
|
|
90
|
+
has 'reason=card-redaction-failed' "$SKILL"
|
|
91
|
+
has 'reason=credential-refused' "$SKILL"
|
|
92
|
+
has 'reason=401' "$SKILL"
|
|
93
|
+
has 'reason=wrapper' "$SKILL"
|
|
94
|
+
has 'reason=reader-exit-' "$SKILL"
|
|
95
|
+
has 'stdout-empty' "$SKILL"
|
|
96
|
+
has 'hypotheses=none' "$SKILL"
|
|
97
|
+
has 'truncated=true' "$SKILL"
|
|
98
|
+
has '0600' "$SKILL"
|
|
99
|
+
has 'EXIT INT TERM HUP' "$SKILL"
|
|
100
|
+
has 'mktemp' "$SKILL"
|
|
101
|
+
has 'Do not `Read` or `cat` the temp' "$SKILL"
|
|
102
|
+
has '^[0-9]+[hmd]$' "$SKILL"
|
|
103
|
+
has '^[0-9]+[mhd]$' "$SKILL"
|
|
104
|
+
has 'Skill-side window allowlist' "$SKILL"
|
|
105
|
+
has '^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$' "$SKILL"
|
|
106
|
+
has '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$' "$SKILL"
|
|
107
|
+
has '^[A-Za-z0-9_-]+$' "$SKILL"
|
|
108
|
+
has 'not executed' "$SKILL"
|
|
109
|
+
has 'does not exec' "$SKILL"
|
|
110
|
+
has 'reason=ZERO_SOURCE_COVERAGE_UNESTABLISHED' "$SKILL"
|
|
111
|
+
has 'not disproof' "$SKILL"
|
|
112
|
+
has 'do not print a pull time' "$SKILL"
|
|
113
|
+
has 'doppler login' "$SKILL"
|
|
114
|
+
has 'ensure-doppler.sh' "$SKILL"
|
|
115
|
+
has 'never passed as `--grep`' "$SKILL"
|
|
116
|
+
has 'Do not pass `--no-archive`' "$SKILL"
|
|
117
|
+
has 'SOLEUR_INCIDENT_PULL source=<betterstack|sentry|supabase>' "$SKILL"
|
|
118
|
+
has 'When the founder confirms the card, copy its one coverage sentence into the root-cause field.' "$SKILL"
|
|
119
|
+
has 'not `ACK-ART33`' "$SKILL"
|
|
120
|
+
has 'not `ACK-ART34`' "$SKILL"
|
|
121
|
+
has 'not `COMMIT-PIR`' "$SKILL"
|
|
122
|
+
has 'The card is not written under `post-mortems/`.' "$SKILL"
|
|
123
|
+
has 'No action items — incident fully resolved in the source PR with no residual work.' "$SKILL"
|
|
124
|
+
|
|
125
|
+
lacks 'BETTERSTACK_LOGS_TOKEN' "$SKILL" "skill"
|
|
126
|
+
|
|
127
|
+
# Reader command lines do not carry --grep, --no-archive, or the wrong Doppler config.
|
|
128
|
+
cmd_bad=0
|
|
129
|
+
while IFS= read -r line; do
|
|
130
|
+
case "$line" in
|
|
131
|
+
*'--grep'*|*'--no-archive'*) cmd_bad=1 ;;
|
|
132
|
+
esac
|
|
133
|
+
case "$line" in
|
|
134
|
+
*betterstack-query.sh*)
|
|
135
|
+
case "$line" in
|
|
136
|
+
*prd_terraform*) ;;
|
|
137
|
+
*) cmd_bad=1 ;;
|
|
138
|
+
esac
|
|
139
|
+
;;
|
|
140
|
+
*supabase-logs-query.sh*|*sentry-issue.sh*)
|
|
141
|
+
case "$line" in
|
|
142
|
+
*prd_terraform*) cmd_bad=1 ;;
|
|
143
|
+
esac
|
|
144
|
+
;;
|
|
145
|
+
esac
|
|
146
|
+
done < <(grep -F 'doppler run' "$SKILL" || true)
|
|
147
|
+
if [[ "$cmd_bad" -eq 0 ]]; then
|
|
148
|
+
pass "reader commands use the Doppler split and carry no --grep or --no-archive"
|
|
149
|
+
else
|
|
150
|
+
fail "a reader command uses the wrong Doppler config or carries --grep or --no-archive"
|
|
151
|
+
fi
|
|
152
|
+
|
|
153
|
+
# The pull commands sit before both blockquotes' diagnose ladder and before the field list.
|
|
154
|
+
awk '
|
|
155
|
+
/^## Phase 0 / { phase=NR }
|
|
156
|
+
/betterstack-query.sh/ && !cmd { cmd=NR }
|
|
157
|
+
/No-SSH fact-pulling/ && !nossh { nossh=NR }
|
|
158
|
+
/Unreachable host/ && !host { host=NR }
|
|
159
|
+
/^1\. `title`/ && !field { field=NR }
|
|
160
|
+
END {
|
|
161
|
+
if (phase && cmd && nossh && host && field && phase < cmd && cmd < nossh && nossh < host && host < field)
|
|
162
|
+
print "ok"
|
|
163
|
+
else
|
|
164
|
+
print "bad phase=" phase " cmd=" cmd " nossh=" nossh " host=" host " field=" field
|
|
165
|
+
}
|
|
166
|
+
' "$SKILL" > "${TMP_DIR}/order.txt"
|
|
167
|
+
if grep -qx 'ok' "${TMP_DIR}/order.txt"; then
|
|
168
|
+
pass "pull command precedes the diagnose ladder and the nineteen-field list"
|
|
169
|
+
else
|
|
170
|
+
fail "pull order $(cat "${TMP_DIR}/order.txt")"
|
|
171
|
+
fi
|
|
172
|
+
|
|
173
|
+
awk '
|
|
174
|
+
/^## Phase 0 / { grab=1 }
|
|
175
|
+
/^## Phase 1 / { grab=0 }
|
|
176
|
+
grab { print }
|
|
177
|
+
' "$SKILL" > "${TMP_DIR}/phase0.txt"
|
|
178
|
+
for needle in '0600' 'mktemp' 'EXIT INT TERM HUP' 'prd_terraform' 'stdout-empty' 'reason=card-empty'; do
|
|
179
|
+
if grep -qF -- "$needle" "${TMP_DIR}/phase0.txt"; then
|
|
180
|
+
pass "phase 0 has ${needle}"
|
|
181
|
+
else
|
|
182
|
+
fail "phase 0 missing ${needle}"
|
|
183
|
+
fi
|
|
184
|
+
done
|
|
185
|
+
|
|
186
|
+
anchor='${CLAUDE_PLUGIN_ROOT}/skills/incident/scripts/redact-sentinel.sh'
|
|
187
|
+
anchor_n=$(grep -Fc "$anchor" "$SKILL" || true)
|
|
188
|
+
if [[ "$anchor_n" -eq 1 ]]; then
|
|
189
|
+
pass "deployed-root sentinel anchor appears once"
|
|
190
|
+
else
|
|
191
|
+
fail "deployed-root sentinel anchor count=${anchor_n}"
|
|
192
|
+
fi
|
|
193
|
+
|
|
194
|
+
action='No action items — incident fully resolved in the source PR with no residual work.'
|
|
195
|
+
action_n=$(grep -Fc "$action" "$SKILL" || true)
|
|
196
|
+
if [[ "$action_n" -eq 1 ]]; then
|
|
197
|
+
pass "no-action-items sentence appears once"
|
|
198
|
+
else
|
|
199
|
+
fail "no-action-items sentence count=${action_n}"
|
|
200
|
+
fi
|
|
201
|
+
|
|
202
|
+
# card-empty and card-redaction-failed do not halt; exit 2 does.
|
|
203
|
+
python3 - "$SKILL" <<'PY'
|
|
204
|
+
import pathlib, sys
|
|
205
|
+
text = pathlib.Path(sys.argv[1]).read_text()
|
|
206
|
+
sys.exit(0 if "reason=card-empty" in text and "does not print `SOLEUR_INCIDENT_HALT`" in text else 1)
|
|
207
|
+
PY
|
|
208
|
+
if [[ $? -eq 0 ]]; then
|
|
209
|
+
pass "card-empty does not print the halt marker"
|
|
210
|
+
else
|
|
211
|
+
fail "card-empty halt prohibition missing"
|
|
212
|
+
fi
|
|
213
|
+
python3 - "$SKILL" <<'PY'
|
|
214
|
+
import pathlib, sys
|
|
215
|
+
text = pathlib.Path(sys.argv[1]).read_text()
|
|
216
|
+
ok = "reason=card-redaction-failed" in text and "prints no offset line" in text and "does not print `SOLEUR_INCIDENT_HALT`" in text
|
|
217
|
+
sys.exit(0 if ok else 1)
|
|
218
|
+
PY
|
|
219
|
+
if [[ $? -eq 0 ]]; then
|
|
220
|
+
pass "card redaction failure prints no offset and no halt"
|
|
221
|
+
else
|
|
222
|
+
fail "card redaction failure prose missing"
|
|
223
|
+
fi
|
|
224
|
+
|
|
225
|
+
# --- dry-run --------------------------------------------------------------
|
|
226
|
+
need_file "$DRY_RUN"
|
|
227
|
+
lacks 'doppler run' "$DRY_RUN" "dry-run.sh"
|
|
228
|
+
lacks 'betterstack-query.sh' "$DRY_RUN" "dry-run.sh"
|
|
229
|
+
lacks 'supabase-logs-query.sh' "$DRY_RUN" "dry-run.sh"
|
|
230
|
+
lacks 'sentry-issue.sh' "$DRY_RUN" "dry-run.sh"
|
|
231
|
+
headless_n=$(grep -Fc -- '--headless' "$DRY_RUN" || true)
|
|
232
|
+
if [[ "$headless_n" -eq 1 ]] && grep -qF 'compound-capture --headless' "$DRY_RUN"; then
|
|
233
|
+
pass "dry-run.sh names --headless only on the compound-capture handoff"
|
|
234
|
+
else
|
|
235
|
+
fail "dry-run.sh --headless count=${headless_n} (the harness does not implement headless)"
|
|
236
|
+
fi
|
|
237
|
+
|
|
238
|
+
for src in betterstack sentry supabase; do
|
|
239
|
+
if grep -qF "echo \"SOLEUR_INCIDENT_PULL source=${src} verdict=never-ran\"" "$DRY_RUN"; then
|
|
240
|
+
pass "dry-run.sh echoes never-ran for ${src} with no leading indent"
|
|
241
|
+
else
|
|
242
|
+
fail "dry-run.sh missing column-0 never-ran echo for ${src}"
|
|
243
|
+
fi
|
|
244
|
+
done
|
|
245
|
+
|
|
246
|
+
if [[ -x "$DRY_RUN" || -f "$DRY_RUN" ]]; then
|
|
247
|
+
dry_out="${TMP_DIR}/dry.out"
|
|
248
|
+
if bash "$DRY_RUN" "$DRY_FIXTURE" >"$dry_out" 2>"${TMP_DIR}/dry.err"; then
|
|
249
|
+
dry_rc=0
|
|
250
|
+
else
|
|
251
|
+
dry_rc=$?
|
|
252
|
+
fi
|
|
253
|
+
if [[ "$dry_rc" -eq 0 ]]; then
|
|
254
|
+
pass "dry-run exits 0"
|
|
255
|
+
else
|
|
256
|
+
fail "dry-run exits ${dry_rc}"
|
|
257
|
+
fi
|
|
258
|
+
awk '
|
|
259
|
+
/=== Phase 0: facts captured ===/ { found=1; exit }
|
|
260
|
+
/SOLEUR_INCIDENT_PULL source=betterstack verdict=never-ran/ { b=1 }
|
|
261
|
+
/SOLEUR_INCIDENT_PULL source=sentry verdict=never-ran/ { s=1 }
|
|
262
|
+
/SOLEUR_INCIDENT_PULL source=supabase verdict=never-ran/ { u=1 }
|
|
263
|
+
END { print (found && b && s && u) ? "ok" : "bad" }
|
|
264
|
+
' "$dry_out" > "${TMP_DIR}/dry-order.txt"
|
|
265
|
+
if grep -qx ok "${TMP_DIR}/dry-order.txt"; then
|
|
266
|
+
pass "three never-ran markers precede the Phase 0 facts marker"
|
|
267
|
+
else
|
|
268
|
+
fail "dry-run marker order"
|
|
269
|
+
fi
|
|
270
|
+
if grep -qF 'affected_user_count: 1' "$dry_out"; then
|
|
271
|
+
pass "dry-run affected_user_count stays the fixture value"
|
|
272
|
+
else
|
|
273
|
+
fail "dry-run affected_user_count is not the fixture value"
|
|
274
|
+
fi
|
|
275
|
+
fi
|
|
276
|
+
|
|
277
|
+
# --- printer --------------------------------------------------------------
|
|
278
|
+
need_file "$FIXTURE"
|
|
279
|
+
if grep -qF "$UUID_LIT" "$FIXTURE" && grep -qF "$IPV4_LIT" "$FIXTURE" && grep -qF "$EMAIL_LIT" "$FIXTURE" \
|
|
280
|
+
&& grep -qF 'event_message' "$FIXTURE" && grep -qF '\"message\"' "$FIXTURE"; then
|
|
281
|
+
pass "fixture carries the synthesized secret shapes inside event_message and message"
|
|
282
|
+
else
|
|
283
|
+
fail "fixture is missing a synthesized secret shape"
|
|
284
|
+
fi
|
|
285
|
+
if grep -qF 'rows=' "$FIXTURE"; then
|
|
286
|
+
fail "fixture pairs a coverage line with rows="
|
|
287
|
+
else
|
|
288
|
+
pass "fixture has no rows= value"
|
|
289
|
+
fi
|
|
290
|
+
|
|
291
|
+
if [[ ! -f "$PRINTER" ]]; then
|
|
292
|
+
fail "pull-card.sh missing — printer cases not executed"
|
|
293
|
+
else
|
|
294
|
+
if grep -qF 'echo "SOLEUR_INCIDENT_PULL' "$PRINTER" || grep -qF "printf 'SOLEUR_INCIDENT_PULL" "$PRINTER"; then
|
|
295
|
+
fail "pull-card.sh echoes SOLEUR_INCIDENT_PULL"
|
|
296
|
+
else
|
|
297
|
+
pass "pull-card.sh does not echo SOLEUR_INCIDENT_PULL"
|
|
298
|
+
fi
|
|
299
|
+
|
|
300
|
+
run_printer() {
|
|
301
|
+
local label="$1" source_name="$2" code="$3" body="$4"
|
|
302
|
+
if bash "$PRINTER" "$source_name" "$code" "$body" >"${TMP_DIR}/printer.out" 2>"${TMP_DIR}/printer.err"; then
|
|
303
|
+
pass "${label} exits 0"
|
|
304
|
+
else
|
|
305
|
+
fail "${label} exits $?"
|
|
306
|
+
fi
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
empty="${TMP_DIR}/empty-body.txt"
|
|
310
|
+
: > "$empty"
|
|
311
|
+
run_printer "betterstack empty" betterstack 0 "$empty"
|
|
312
|
+
cp "${TMP_DIR}/printer.out" "${TMP_DIR}/bs-empty.out"
|
|
313
|
+
has "betterstack table=${TABLE} limit=100 exit=0 stdout-empty" "${TMP_DIR}/bs-empty.out"
|
|
314
|
+
lacks 'no rows' "${TMP_DIR}/bs-empty.out" "empty betterstack"
|
|
315
|
+
lacks 'archive' "${TMP_DIR}/bs-empty.out" "empty betterstack"
|
|
316
|
+
lacks 'absent' "${TMP_DIR}/bs-empty.out" "empty betterstack"
|
|
317
|
+
lacks "$TMP_DIR" "${TMP_DIR}/bs-empty.out" "empty betterstack"
|
|
318
|
+
|
|
319
|
+
run_printer "betterstack fixture" betterstack 0 "$FIXTURE"
|
|
320
|
+
cp "${TMP_DIR}/printer.out" "${TMP_DIR}/bs-fix.out"
|
|
321
|
+
has "betterstack table=${TABLE} limit=100 exit=0 raw=1" "${TMP_DIR}/bs-fix.out"
|
|
322
|
+
lacks 'truncated=true' "${TMP_DIR}/bs-fix.out" "one-line betterstack"
|
|
323
|
+
lacks "$UUID_LIT" "${TMP_DIR}/bs-fix.out" "betterstack fixture"
|
|
324
|
+
lacks "$IPV4_LIT" "${TMP_DIR}/bs-fix.out" "betterstack fixture"
|
|
325
|
+
lacks "$EMAIL_LIT" "${TMP_DIR}/bs-fix.out" "betterstack fixture"
|
|
326
|
+
lacks 'rows=' "${TMP_DIR}/bs-fix.out" "betterstack fixture"
|
|
327
|
+
lacks "$TMP_DIR" "${TMP_DIR}/bs-fix.out" "betterstack fixture"
|
|
328
|
+
lacks 'affected_user_count' "${TMP_DIR}/bs-fix.out" "betterstack fixture"
|
|
329
|
+
|
|
330
|
+
run_printer "betterstack exit 3" betterstack 3 "$FIXTURE"
|
|
331
|
+
cp "${TMP_DIR}/printer.out" "${TMP_DIR}/bs-3.out"
|
|
332
|
+
has "betterstack table=${TABLE} limit=100 exit=3" "${TMP_DIR}/bs-3.out"
|
|
333
|
+
lacks 'raw=' "${TMP_DIR}/bs-3.out" "betterstack exit 3"
|
|
334
|
+
lacks "$UUID_LIT" "${TMP_DIR}/bs-3.out" "betterstack exit 3"
|
|
335
|
+
lacks 'stdout-empty' "${TMP_DIR}/bs-3.out" "betterstack exit 3"
|
|
336
|
+
|
|
337
|
+
hundred="${TMP_DIR}/hundred.txt"
|
|
338
|
+
: > "$hundred"
|
|
339
|
+
n=0
|
|
340
|
+
while [[ "$n" -lt 100 ]]; do
|
|
341
|
+
printf '%s\n' '{"dt":"t","raw":"{}"}' >> "$hundred"
|
|
342
|
+
n=$((n + 1))
|
|
343
|
+
done
|
|
344
|
+
run_printer "betterstack truncated" betterstack 0 "$hundred"
|
|
345
|
+
cp "${TMP_DIR}/printer.out" "${TMP_DIR}/bs-100.out"
|
|
346
|
+
has "betterstack table=${TABLE} limit=100 exit=0 raw=100 truncated=true" "${TMP_DIR}/bs-100.out"
|
|
347
|
+
|
|
348
|
+
run_printer "supabase fixture" supabase 0 "$FIXTURE"
|
|
349
|
+
cp "${TMP_DIR}/printer.out" "${TMP_DIR}/sb.out"
|
|
350
|
+
has 'supabase verdict=COVERED reason=FULLY_COVERED' "${TMP_DIR}/sb.out"
|
|
351
|
+
lacks 'rows=' "${TMP_DIR}/sb.out" "supabase fixture"
|
|
352
|
+
lacks "$UUID_LIT" "${TMP_DIR}/sb.out" "supabase fixture"
|
|
353
|
+
lacks "$EMAIL_LIT" "${TMP_DIR}/sb.out" "supabase fixture"
|
|
354
|
+
lacks 'absent' "${TMP_DIR}/sb.out" "supabase fixture"
|
|
355
|
+
lacks 'disproof' "${TMP_DIR}/sb.out" "supabase fixture"
|
|
356
|
+
|
|
357
|
+
printf '%s\n' 'verdict=COVERED reason=FULLY_COVERED rows=0' > "${TMP_DIR}/bad-covered.txt"
|
|
358
|
+
run_printer "supabase covered-with-rows" supabase 0 "${TMP_DIR}/bad-covered.txt"
|
|
359
|
+
cp "${TMP_DIR}/printer.out" "${TMP_DIR}/sb-bad.out"
|
|
360
|
+
lacks 'rows=' "${TMP_DIR}/sb-bad.out" "covered-with-rows"
|
|
361
|
+
lacks 'absent' "${TMP_DIR}/sb-bad.out" "covered-with-rows"
|
|
362
|
+
|
|
363
|
+
printf '%s\n' 'rows=4 evidence' > "${TMP_DIR}/stderr-shape.txt"
|
|
364
|
+
printf '%s\n' 'verdict=INCONCLUSIVE reason=ZERO_SOURCE_COVERAGE_UNESTABLISHED' >> "${TMP_DIR}/stderr-shape.txt"
|
|
365
|
+
run_printer "supabase zero-source" supabase 3 "${TMP_DIR}/stderr-shape.txt"
|
|
366
|
+
cp "${TMP_DIR}/printer.out" "${TMP_DIR}/sb-zero.out"
|
|
367
|
+
has 'supabase verdict=INCONCLUSIVE reason=ZERO_SOURCE_COVERAGE_UNESTABLISHED' "${TMP_DIR}/sb-zero.out"
|
|
368
|
+
lacks 'rows=' "${TMP_DIR}/sb-zero.out" "zero-source"
|
|
369
|
+
lacks 'disproof' "${TMP_DIR}/sb-zero.out" "zero-source"
|
|
370
|
+
lacks 'absent' "${TMP_DIR}/sb-zero.out" "zero-source"
|
|
371
|
+
|
|
372
|
+
printf '%s\n' 'log line verdict=COVERED reason=FULLY_COVERED rows=4' > "${TMP_DIR}/last-pair.txt"
|
|
373
|
+
printf '%s\n' 'verdict=INCONCLUSIVE reason=ZERO_SOURCE_COVERAGE_UNESTABLISHED' >> "${TMP_DIR}/last-pair.txt"
|
|
374
|
+
run_printer "supabase last pair" supabase 0 "${TMP_DIR}/last-pair.txt"
|
|
375
|
+
cp "${TMP_DIR}/printer.out" "${TMP_DIR}/sb-last.out"
|
|
376
|
+
has 'supabase verdict=INCONCLUSIVE reason=ZERO_SOURCE_COVERAGE_UNESTABLISHED' "${TMP_DIR}/sb-last.out"
|
|
377
|
+
lacks 'FULLY_COVERED' "${TMP_DIR}/sb-last.out" "last pair"
|
|
378
|
+
lacks 'rows=' "${TMP_DIR}/sb-last.out" "last pair"
|
|
379
|
+
|
|
380
|
+
run_printer "sentry fixture" sentry 0 "$FIXTURE"
|
|
381
|
+
cp "${TMP_DIR}/printer.out" "${TMP_DIR}/sy.out"
|
|
382
|
+
has 'sentry exit=0 window=n/a' "${TMP_DIR}/sy.out"
|
|
383
|
+
lacks "$UUID_LIT" "${TMP_DIR}/sy.out" "sentry"
|
|
384
|
+
lacks "$IPV4_LIT" "${TMP_DIR}/sy.out" "sentry"
|
|
385
|
+
lacks "$EMAIL_LIT" "${TMP_DIR}/sy.out" "sentry"
|
|
386
|
+
lacks "$TMP_DIR" "${TMP_DIR}/sy.out" "sentry"
|
|
387
|
+
lacks 'affected_user_count' "${TMP_DIR}/sy.out" "sentry"
|
|
388
|
+
|
|
389
|
+
if [[ -f "$SENTINEL" ]]; then
|
|
390
|
+
if bash "$SENTINEL" "$FIXTURE" >"${TMP_DIR}/sentinel-raw.out" 2>&1; then
|
|
391
|
+
fail "raw fixture did not trip the sentinel — the secret assertion is vacuous"
|
|
392
|
+
else
|
|
393
|
+
raw_rc=$?
|
|
394
|
+
if [[ "$raw_rc" -eq 1 ]]; then
|
|
395
|
+
pass "raw fixture trips the sentinel"
|
|
396
|
+
else
|
|
397
|
+
fail "raw fixture sentinel rc=${raw_rc}"
|
|
398
|
+
fi
|
|
399
|
+
fi
|
|
400
|
+
if bash "$SENTINEL" "${TMP_DIR}/bs-fix.out" >"${TMP_DIR}/sentinel-card.out" 2>&1; then
|
|
401
|
+
pass "printer stdout passes the sentinel"
|
|
402
|
+
else
|
|
403
|
+
fail "printer stdout fails the sentinel rc=$?"
|
|
404
|
+
fi
|
|
405
|
+
else
|
|
406
|
+
fail "sentinel missing"
|
|
407
|
+
fi
|
|
408
|
+
fi
|
|
409
|
+
|
|
410
|
+
# --- marker ---------------------------------------------------------------
|
|
411
|
+
if grep -qF 'SOLEUR_INCIDENT_PULL\b' "$MARKER_TS"; then
|
|
412
|
+
pass "MARKER_RE names SOLEUR_INCIDENT_PULL word-boundary"
|
|
413
|
+
else
|
|
414
|
+
fail "MARKER_RE missing SOLEUR_INCIDENT_PULL word-boundary"
|
|
415
|
+
fi
|
|
416
|
+
python3 - "$MARKER_TS" <<'PY'
|
|
417
|
+
import pathlib, sys
|
|
418
|
+
lines = pathlib.Path(sys.argv[1]).read_text().splitlines()
|
|
419
|
+
idx = next((i for i, line in enumerate(lines) if r"SOLEUR_INCIDENT_PULL\b" in line), None)
|
|
420
|
+
window = "\n".join(lines[idx:idx + 16]) if idx is not None else ""
|
|
421
|
+
ok = "MIRRORED-NOT-PAGED" in window and "PostToolUse(Bash)" in window
|
|
422
|
+
sys.exit(0 if ok else 1)
|
|
423
|
+
PY
|
|
424
|
+
if [[ $? -eq 0 ]]; then
|
|
425
|
+
pass "marker comment names the PostToolUse hook beside the new alternation"
|
|
426
|
+
else
|
|
427
|
+
fail "marker comment missing beside SOLEUR_INCIDENT_PULL"
|
|
428
|
+
fi
|
|
429
|
+
if grep -qF 'SOLEUR_INCIDENT_PULL' < <(grep -F 'const WEDGE_RE' "$MARKER_TS"); then
|
|
430
|
+
fail "WEDGE_RE contains SOLEUR_INCIDENT_PULL"
|
|
431
|
+
else
|
|
432
|
+
pass "WEDGE_RE does not contain SOLEUR_INCIDENT_PULL"
|
|
433
|
+
fi
|
|
434
|
+
|
|
435
|
+
# Temp idiom the skill requires: outside the repo, mode 0600, gone after EXIT.
|
|
436
|
+
repo_phys="$(cd "$REPO_ROOT" && pwd -P)"
|
|
437
|
+
trap_path="${TMP_DIR}/trap-path.txt"
|
|
438
|
+
bash -c 'f=$(mktemp); chmod 0600 "$f"; trap "rm -f \"\$f\"" EXIT INT TERM HUP; printf "%s\n" "$f"' > "$trap_path"
|
|
439
|
+
held="$(cat "$trap_path")"
|
|
440
|
+
assert_fixture_dir "$(dirname "$held")"
|
|
441
|
+
if [[ ! -e "$held" ]]; then
|
|
442
|
+
pass "trap removed the temp"
|
|
443
|
+
else
|
|
444
|
+
fail "trap left ${held}"
|
|
445
|
+
rm -f "$held"
|
|
446
|
+
fi
|
|
447
|
+
case "$held" in
|
|
448
|
+
"$repo_phys"/*) fail "temp was inside the repo" ;;
|
|
449
|
+
/*) pass "temp was outside the repo" ;;
|
|
450
|
+
*) fail "temp path was not absolute" ;;
|
|
451
|
+
esac
|
|
452
|
+
|
|
453
|
+
# Execute the Phase 0 fence. A stub doppler does not exec the readers.
|
|
454
|
+
fence="${TMP_DIR}/phase0-fence.sh"
|
|
455
|
+
awk '
|
|
456
|
+
/^```bash$/ { n++; if (n==1) grab=1; next }
|
|
457
|
+
/^```$/ && grab { exit }
|
|
458
|
+
grab { print }
|
|
459
|
+
' "$SKILL" > "$fence"
|
|
460
|
+
if [[ -s "$fence" ]]; then
|
|
461
|
+
pass "extracted the phase 0 fence"
|
|
462
|
+
else
|
|
463
|
+
fail "could not extract the phase 0 fence"
|
|
464
|
+
fi
|
|
465
|
+
stub_bin="${TMP_DIR}/bin"
|
|
466
|
+
mkdir -p "$stub_bin"
|
|
467
|
+
printf '%s\n' '#!/bin/bash' 'exit 0' > "${stub_bin}/doppler"
|
|
468
|
+
chmod 755 "${stub_bin}/doppler"
|
|
469
|
+
printf '%s\n' '#!/bin/bash' 'exit 2' > "${TMP_DIR}/sentinel-exit-2.sh"
|
|
470
|
+
printf '%s\n' '#!/bin/bash' 'exit 0' > "${TMP_DIR}/sentinel-exit-0.sh"
|
|
471
|
+
chmod 755 "${TMP_DIR}/sentinel-exit-2.sh" "${TMP_DIR}/sentinel-exit-0.sh"
|
|
472
|
+
plugin_root="${REPO_ROOT}/plugins/soleur"
|
|
473
|
+
(
|
|
474
|
+
cd "$REPO_ROOT" || exit 99
|
|
475
|
+
PATH="${stub_bin}:${PATH}" \
|
|
476
|
+
CLAUDE_PLUGIN_ROOT="$plugin_root" \
|
|
477
|
+
SENTINEL="${TMP_DIR}/sentinel-exit-2.sh" \
|
|
478
|
+
INCIDENT_SUPABASE_PROJECT=soleur-inngest-prd \
|
|
479
|
+
INCIDENT_COMPLAINT='checkout button failed' \
|
|
480
|
+
BS_TABLE=not_the_card_table \
|
|
481
|
+
bash -x "$fence" >"${TMP_DIR}/fence-halt.out" 2>"${TMP_DIR}/fence-halt.err"
|
|
482
|
+
printf '%s\n' "$?" > "${TMP_DIR}/fence-halt.rc"
|
|
483
|
+
)
|
|
484
|
+
halt_rc="$(cat "${TMP_DIR}/fence-halt.rc")"
|
|
485
|
+
if [[ "$halt_rc" -eq 2 ]]; then
|
|
486
|
+
pass "fence exits 2 when the complaint sentinel exits 2"
|
|
487
|
+
else
|
|
488
|
+
fail "fence complaint halt rc=${halt_rc}"
|
|
489
|
+
fi
|
|
490
|
+
if grep -qx 'SOLEUR_INCIDENT_HALT reason=sentinel-exit-2' "${TMP_DIR}/fence-halt.out"; then
|
|
491
|
+
pass "complaint halt is on stdout"
|
|
492
|
+
else
|
|
493
|
+
fail "complaint halt missing from stdout"
|
|
494
|
+
fi
|
|
495
|
+
if grep -qF 'checkout button failed' "${TMP_DIR}/fence-halt.out"; then
|
|
496
|
+
fail "complaint text reached stdout"
|
|
497
|
+
else
|
|
498
|
+
pass "complaint text stayed off stdout"
|
|
499
|
+
fi
|
|
500
|
+
if grep -qF 'checkout button failed' "${TMP_DIR}/fence-halt.err"; then
|
|
501
|
+
fail "complaint text reached the trace"
|
|
502
|
+
else
|
|
503
|
+
pass "complaint text stayed off the trace"
|
|
504
|
+
fi
|
|
505
|
+
python3 - "${TMP_DIR}/fence-halt.err" <<'PY'
|
|
506
|
+
import pathlib, sys
|
|
507
|
+
text = pathlib.Path(sys.argv[1]).read_text(errors="replace")
|
|
508
|
+
a = "ref=ifsccnjhymdmidffkzhl"
|
|
509
|
+
b = "ref=pigsfuxruiopinouvjwy"
|
|
510
|
+
lines = text.splitlines()
|
|
511
|
+
ok = False
|
|
512
|
+
for i, ln in enumerate(lines):
|
|
513
|
+
if a in ln and b in ln:
|
|
514
|
+
ia = ln.find(a)
|
|
515
|
+
ib = ln.find(b, ia + len(a))
|
|
516
|
+
if ib != -1 and "\\n" in ln[ia + len(a):ib]:
|
|
517
|
+
# Bash 5.3 keeps the traced newline as a one-line \n escape.
|
|
518
|
+
ok = True
|
|
519
|
+
elif a in ln and b not in ln and i + 1 < len(lines):
|
|
520
|
+
# Bash 5.2 prints that newline raw, so the assignment spans two trace
|
|
521
|
+
# lines and the opening quote is still open. A finished line (even
|
|
522
|
+
# quote count) is a separate command; a space join stays one line.
|
|
523
|
+
nxt = lines[i + 1]
|
|
524
|
+
if b in nxt and a not in nxt and ln.count("'") % 2 == 1:
|
|
525
|
+
ok = True
|
|
526
|
+
sys.exit(0 if ok else 1)
|
|
527
|
+
PY
|
|
528
|
+
if [[ $? -eq 0 ]]; then
|
|
529
|
+
pass "xtrace keeps the two supabase refs on separate lines"
|
|
530
|
+
else
|
|
531
|
+
fail "xtrace did not keep the two supabase refs on separate lines"
|
|
532
|
+
fi
|
|
533
|
+
if grep -qF -- '--table t520508_soleur_inngest_vector_prd_3_logs' "${TMP_DIR}/fence-halt.err" \
|
|
534
|
+
&& grep -qF -- 'env -u BS_TABLE -u BS_TABLE_S3' "${TMP_DIR}/fence-halt.err"; then
|
|
535
|
+
pass "xtrace pins the betterstack table and unsets BS_TABLE"
|
|
536
|
+
else
|
|
537
|
+
fail "xtrace did not pin the betterstack table"
|
|
538
|
+
fi
|
|
539
|
+
(
|
|
540
|
+
cd "$REPO_ROOT" || exit 99
|
|
541
|
+
PATH="${stub_bin}:${PATH}" \
|
|
542
|
+
CLAUDE_PLUGIN_ROOT="$plugin_root" \
|
|
543
|
+
SENTINEL="${TMP_DIR}/sentinel-exit-0.sh" \
|
|
544
|
+
INCIDENT_WINDOW='999w' \
|
|
545
|
+
bash -x "$fence" >"${TMP_DIR}/fence-usage.out" 2>"${TMP_DIR}/fence-usage.err"
|
|
546
|
+
)
|
|
547
|
+
if grep -qF 'reason=usage' "${TMP_DIR}/fence-usage.out" \
|
|
548
|
+
&& ! grep -qF '999w' "${TMP_DIR}/fence-usage.out" \
|
|
549
|
+
&& ! grep -qF 'window=1h' "${TMP_DIR}/fence-usage.out" \
|
|
550
|
+
&& ! grep -qF 'window=24h' "${TMP_DIR}/fence-usage.out"; then
|
|
551
|
+
pass "a refused window is usage and is not printed"
|
|
552
|
+
else
|
|
553
|
+
fail "refused window leaked or was not usage"
|
|
554
|
+
fi
|
|
555
|
+
(
|
|
556
|
+
cd "$REPO_ROOT" || exit 99
|
|
557
|
+
PATH="${stub_bin}:${PATH}" \
|
|
558
|
+
CLAUDE_PLUGIN_ROOT="$plugin_root" \
|
|
559
|
+
SENTINEL="${TMP_DIR}/sentinel-exit-0.sh" \
|
|
560
|
+
INCIDENT_SENTRY_ISSUE_ID='--redact' \
|
|
561
|
+
bash -x "$fence" >"${TMP_DIR}/fence-dash.out" 2>"${TMP_DIR}/fence-dash.err"
|
|
562
|
+
)
|
|
563
|
+
if grep -qF 'sentry verdict=never-ran reason=usage' "${TMP_DIR}/fence-dash.out" \
|
|
564
|
+
&& ! grep -qF 'sentry-issue.sh' "${TMP_DIR}/fence-dash.err" \
|
|
565
|
+
&& ! grep -qF -- '--redact' "${TMP_DIR}/fence-dash.out"; then
|
|
566
|
+
pass "a leading-dash issue id is usage and is not executed"
|
|
567
|
+
else
|
|
568
|
+
fail "leading-dash issue id was executed or printed"
|
|
569
|
+
fi
|
|
570
|
+
(
|
|
571
|
+
cd "$REPO_ROOT" || exit 99
|
|
572
|
+
env -u CLAUDE_PLUGIN_ROOT \
|
|
573
|
+
PATH="${stub_bin}:${PATH}" \
|
|
574
|
+
SENTINEL="${TMP_DIR}/sentinel-exit-0.sh" \
|
|
575
|
+
bash -x "$fence" >"${TMP_DIR}/fence-root.out" 2>"${TMP_DIR}/fence-root.err"
|
|
576
|
+
printf '%s\n' "$?" > "${TMP_DIR}/fence-root.rc"
|
|
577
|
+
)
|
|
578
|
+
root_rc="$(cat "${TMP_DIR}/fence-root.rc")"
|
|
579
|
+
if [[ "$root_rc" -eq 2 ]] \
|
|
580
|
+
&& grep -qx 'SOLEUR_INCIDENT_HALT reason=plugin-root-unverified' "${TMP_DIR}/fence-root.out" \
|
|
581
|
+
&& ! grep -qF 'betterstack-query.sh' "${TMP_DIR}/fence-root.err"; then
|
|
582
|
+
pass "an empty plugin root halts before a reader"
|
|
583
|
+
else
|
|
584
|
+
fail "empty plugin root did not halt before a reader rc=${root_rc}"
|
|
585
|
+
fi
|
|
586
|
+
|
|
587
|
+
# TERM during the Better Stack read must exit 143 and must not start Supabase.
|
|
588
|
+
printf '%s\n' '#!/bin/bash' 'if [[ "$*" == *betterstack-query.sh* ]]; then sleep 30; fi' 'exit 0' > "${stub_bin}/doppler"
|
|
589
|
+
chmod 755 "${stub_bin}/doppler"
|
|
590
|
+
python3 - "$fence" "$stub_bin" "$plugin_root" "${TMP_DIR}/sentinel-exit-0.sh" "$REPO_ROOT" <<'PY'
|
|
591
|
+
import os, signal, subprocess, sys, time
|
|
592
|
+
fence, stub_bin, plugin_root, sentinel, repo = sys.argv[1:]
|
|
593
|
+
env = os.environ.copy()
|
|
594
|
+
env["PATH"] = stub_bin + os.pathsep + env.get("PATH", "")
|
|
595
|
+
env["CLAUDE_PLUGIN_ROOT"] = plugin_root
|
|
596
|
+
env["SENTINEL"] = sentinel
|
|
597
|
+
for key in ("INCIDENT_WINDOW", "INCIDENT_SENTRY_ISSUE_ID", "INCIDENT_COMPLAINT", "INCIDENT_SUPABASE_PROJECT"):
|
|
598
|
+
env.pop(key, None)
|
|
599
|
+
proc = subprocess.Popen(
|
|
600
|
+
["bash", fence], cwd=repo, env=env,
|
|
601
|
+
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, start_new_session=True, text=True,
|
|
602
|
+
)
|
|
603
|
+
deadline = time.time() + 3
|
|
604
|
+
while time.time() < deadline:
|
|
605
|
+
if proc.poll() is not None:
|
|
606
|
+
break
|
|
607
|
+
time.sleep(0.05)
|
|
608
|
+
os.killpg(proc.pid, signal.SIGTERM)
|
|
609
|
+
rc = proc.wait(timeout=5)
|
|
610
|
+
out = proc.stdout.read() if proc.stdout is not None else ""
|
|
611
|
+
bad = rc != 143 or "source=supabase" in out
|
|
612
|
+
sys.exit(1 if bad else 0)
|
|
613
|
+
PY
|
|
614
|
+
if [[ $? -eq 0 ]]; then
|
|
615
|
+
pass "TERM during the pull exits 143 and does not start supabase"
|
|
616
|
+
else
|
|
617
|
+
fail "TERM during the pull did not stop the later readers"
|
|
618
|
+
fi
|
|
619
|
+
printf '%s\n' '#!/bin/bash' 'exit 0' > "${stub_bin}/doppler"
|
|
620
|
+
chmod 755 "${stub_bin}/doppler"
|
|
621
|
+
|
|
622
|
+
echo "pull-card.test.sh: ${PASS} passed, ${FAIL} failed"
|
|
623
|
+
if [[ "$FAIL" -ne 0 ]]; then
|
|
624
|
+
exit 1
|
|
625
|
+
fi
|
|
626
|
+
exit 0
|
|
@@ -1036,13 +1036,18 @@ fi
|
|
|
1036
1036
|
# substring test on the marker line alone sees nothing.
|
|
1037
1037
|
# W5 `>&"2"` and `1>&2` spellings.
|
|
1038
1038
|
# And W3, the growth gap: the reason table is hardcoded, so a NEW fail-closed halt added with
|
|
1039
|
-
# no marker passed silently.
|
|
1040
|
-
#
|
|
1039
|
+
# no marker passed silently. Distinct-reason cardinality false-fails a reason two phases share
|
|
1040
|
+
# (incident reuses plugin-root-unverified, sentinel-unreadable, and sentinel-exit-2). The floor
|
|
1041
|
+
# below walks each executable `exit 2` and requires a `SOLEUR_*_HALT reason=` in the arm since
|
|
1042
|
+
# the previous `exit 2`, inclusive of this exit's line. Guidance on stderr between the marker
|
|
1043
|
+
# and the exit still counts. An unmarked exit fails even when an earlier arm was marked.
|
|
1044
|
+
# Census of executable `exit 2` lines: incident 12, legal-generate 5, linear-fetch 5,
|
|
1045
|
+
# trigger-cron 2.
|
|
1041
1046
|
# ---------------------------------------------------------------------------
|
|
1042
1047
|
t22_missing=""
|
|
1043
1048
|
t22_on_stderr=""
|
|
1044
1049
|
t22_uncovered=""
|
|
1045
|
-
t22_specs="${INCIDENT_SKILL}:SOLEUR_INCIDENT_HALT:plugin-root-unverified,sentinel-unreadable,draft-alloc-failed,draft-empty,invalid-calendar-date,mttr-transposed,mttd-transposed
|
|
1050
|
+
t22_specs="${INCIDENT_SKILL}:SOLEUR_INCIDENT_HALT:plugin-root-unverified,temp-inside-worktree,sentinel-unreadable,sentinel-exit-2,draft-alloc-failed,draft-empty,invalid-calendar-date,mttr-transposed,mttd-transposed
|
|
1046
1051
|
${LEGAL_SKILL}:SOLEUR_LEGAL_GENERATE_HALT:plugin-root-unverified,sentinel-unreadable,draft-alloc-failed,draft-empty
|
|
1047
1052
|
${LINEAR_SKILL}:SOLEUR_LINEAR_FETCH_HALT:plugin-root-unverified,scrubber-unreadable,scrubber-nonzero-exit,redaction-empty-output,redaction-ineffective
|
|
1048
1053
|
${TRIGGER_SKILL}:SOLEUR_TRIGGER_CRON_HALT:plugin-root-unverified,producer-missing"
|
|
@@ -1093,22 +1098,33 @@ while IFS= read -r t22_spec; do
|
|
|
1093
1098
|
fi
|
|
1094
1099
|
done < <(printf '%s\n' "${t22_reasons}" | tr ',' '\n')
|
|
1095
1100
|
|
|
1096
|
-
# GROWTH FLOOR (W3): a new fail-closed halt must arrive with a marker
|
|
1097
|
-
#
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1101
|
+
# GROWTH FLOOR (W3): a new fail-closed halt must arrive with a marker in its own arm.
|
|
1102
|
+
# The arm is every executable line after the previous `exit 2` through this one. A guidance
|
|
1103
|
+
# echo between the marker and `exit 2` stays inside the arm. Resetting at the previous exit
|
|
1104
|
+
# keeps an earlier arm's marker from covering this one.
|
|
1105
|
+
t22_bare=$(printf '%s\n' "${t22_exec}" | awk -v prefix="${t22_prefix}" '
|
|
1106
|
+
BEGIN { arm = ""; bare = 0 }
|
|
1107
|
+
{
|
|
1108
|
+
arm = arm $0 "\n"
|
|
1109
|
+
if (index($0, "exit 2") > 0) {
|
|
1110
|
+
if (index(arm, prefix " reason=") == 0) bare++
|
|
1111
|
+
arm = ""
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
END { print bare + 0 }
|
|
1115
|
+
')
|
|
1116
|
+
if [[ "${t22_bare}" -gt 0 ]]; then
|
|
1117
|
+
t22_uncovered="${t22_uncovered} ${t22_file##*/skills/}(${t22_bare} unmarked exit 2)"
|
|
1102
1118
|
fi
|
|
1103
1119
|
done < <(printf '%s\n' "${t22_specs}")
|
|
1104
1120
|
|
|
1105
1121
|
if [[ -z "${t22_missing}" && -z "${t22_on_stderr}" && -z "${t22_uncovered}" ]]; then
|
|
1106
|
-
echo "PASS: Test 22: all
|
|
1122
|
+
echo "PASS: Test 22: all 24 fail-closed halts across the 4 gates (incident 12, legal-generate 5, linear-fetch 5, trigger-cron 2) emit a SOLEUR_*_HALT reason= marker on STDOUT from an executable line in the same arm — a repeated reason covers its own exit, and an exit with no marker in its arm fails"
|
|
1107
1123
|
PASS=$((PASS + 1))
|
|
1108
1124
|
else
|
|
1109
1125
|
[[ -n "${t22_missing}" ]] && echo "FAIL: Test 22: fail-closed halt with no SOLEUR_* marker EMITTED from an executable line at:${t22_missing} — a marker that appears only in prose or a comment is documentation, and a halt nobody can see in telemetry is indistinguishable from a run that never happened"
|
|
1110
1126
|
[[ -n "${t22_on_stderr}" ]] && echo "FAIL: Test 22: SOLEUR_* marker redirected to stderr at:${t22_on_stderr} — the human guidance belongs on stderr, but the MARKER is the machine-readable half and must go to stdout (check the brace group too: \`exit 2; } >&2\` redirects the whole arm)"
|
|
1111
|
-
[[ -n "${t22_uncovered}" ]] && echo "FAIL: Test 22:
|
|
1127
|
+
[[ -n "${t22_uncovered}" ]] && echo "FAIL: Test 22: an executable exit 2 has no SOLEUR_*_HALT reason= in its arm since the previous exit 2 at:${t22_uncovered} — a new halt was added without a marker, and the reason table above cannot notice that on its own"
|
|
1112
1128
|
FAIL=$((FAIL + 1))
|
|
1113
1129
|
fi
|
|
1114
1130
|
|