@soleur/opencode 3.410.1 → 3.410.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soleur/opencode",
3
- "version": "3.410.1",
3
+ "version": "3.410.3",
4
4
  "description": "Soleur AI organization plugin for OpenCode",
5
5
  "type": "module",
6
6
  "bin": {
@@ -27,9 +27,12 @@ at once — so the retained-scope probe is the load-bearing half, not the widen.
27
27
 
28
28
  ## Usage
29
29
 
30
- The deterministic core is a read-only probe script,
30
+ The deterministic core is a probe script,
31
31
  [cf-token-scope.sh](./scripts/cf-token-scope.sh). It only ever probes — run it as
32
- often as needed; it mutates nothing.
32
+ often as needed; it mutates nothing. The `rulesets` and `default-token` profiles
33
+ send GETs only. The two account-migration profiles (`redirects-dns`, `zone-rest`)
34
+ also send write verbs, but only with a fixed body that cannot validate (see
35
+ [Migration profiles](#migration-profiles-12931)).
33
36
 
34
37
  ### Preflight: verify the plugin install before any snapshot
35
38
 
@@ -64,6 +67,11 @@ bash "${CLAUDE_PLUGIN_ROOT}/skills/cf-token-scope/scripts/cf-token-scope.sh" \
64
67
 
65
68
  # Print the probe commands without running them (token stays unexpanded):
66
69
  bash "${CLAUDE_PLUGIN_ROOT}/skills/cf-token-scope/scripts/cf-token-scope.sh" --dry-run
70
+
71
+ # #12931 account migration: write-probe the NEW-account tokens once per phase,
72
+ # before that phase's rehearsal. --staged reads the <KEY>_NEXT staging keys (Phase 0).
73
+ bash "${CLAUDE_PLUGIN_ROOT}/skills/cf-token-scope/scripts/cf-token-scope.sh" --profile redirects-dns --staged
74
+ bash "${CLAUDE_PLUGIN_ROOT}/skills/cf-token-scope/scripts/cf-token-scope.sh" --profile zone-rest --staged
67
75
  ```
68
76
 
69
77
  The token (`CF_API_TOKEN_RULESETS` or `CF_API_TOKEN`, resolved by `--profile`),
@@ -169,6 +177,47 @@ its own `TARGET_PRESENT` handling and never consults this classifier. The baseli
169
177
  summary's verbatim literal (a stable grep target for the data channel):
170
178
  `NOTE: LB scope not-yet-widened — expected BEFORE the #11181 widen; re-run with --expect-lb-scopes after it`.
171
179
 
180
+ ## Migration profiles (#12931)
181
+
182
+ `redirects-dns` and `zone-rest` prove that the NEW-account tokens can WRITE what
183
+ their migration phase applies. A GET proves read access only (the 2026-07-24
184
+ config-rules scope-gap post-mortem). They follow CTO ruling L49:
185
+
186
+ - **One fixed invalid body.** Every write sends `INVALID_BODY`, a literal that is
187
+ not JSON, so no endpoint can validate it. The script refuses to run if it ever
188
+ parses as JSON. It never sends an empty-rules ruleset: that body validates and
189
+ wipes a live entrypoint.
190
+ - **Deny control first.** Each write row first sends the same body with a sibling
191
+ token that lacks the scope. That request must answer `403`. Only then does the
192
+ granted token's `400` count as `authorized`. If the denied token gets `400`, the
193
+ endpoint may check the body before authorization, so the row is `inconclusive`
194
+ and the grant token is not probed.
195
+ - **Any `2xx` is fatal.** The run reads that endpoint back with the grant token,
196
+ prints a sanitized summary, prints `probe=<profile> verdict=fatal-mutation` and
197
+ exits `4`.
198
+ - **Write verbs are PUT, POST and PATCH only.** DELETE is never sent.
199
+ - **Known-present controls.** GET controls must return `success:true` with a parsed
200
+ `.result`. `redirects-dns` lists the new zone's and account's rulesets and reports
201
+ each phase entrypoint as `entrypoint-present id=<id>` (import it) or
202
+ `entrypoint-absent` (ADR-136 whole-list audit). It reads them from the parsed
203
+ list, never from a 404.
204
+ - **Ids.** The NEW account and zone ids are built in. They are not read from
205
+ Doppler, because `CF_ZONE_ID`/`CF_ACCOUNT_ID` hold the old ids until the swap.
206
+ `--account-id`/`--zone-id` override them, and the OLD ids are refused.
207
+
208
+ | profile | write row | grant token | deny control |
209
+ |---|---|---|---|
210
+ | redirects-dns | zone entrypoints `http_request_dynamic_redirect`, `http_response_headers_transform`, `http_config_settings`, `http_request_cache_settings`, `http_request_firewall_custom` (PUT) | `CF_API_TOKEN_RULESETS` | `CF_API_TOKEN_PAGES` |
211
+ | redirects-dns | account entrypoint `http_request_redirect` (PUT), `rules/lists` (POST) | `CF_API_TOKEN_RULESETS` | `CF_API_TOKEN_PAGES` |
212
+ | redirects-dns | `zones/<zone>/dns_records` (POST) | `CF_API_TOKEN` | `CF_API_TOKEN_PAGES` |
213
+ | redirects-dns | `accounts/<acct>/pages/projects` (POST) | `CF_API_TOKEN_PAGES` | `CF_API_TOKEN_RULESETS` |
214
+ | zone-rest | `zones/<zone>/settings` (PATCH) | `CF_API_TOKEN_ZONE_SETTINGS` | `CF_API_TOKEN_BOT_MANAGEMENT` |
215
+ | zone-rest | `zones/<zone>/bot_management` (PUT) | `CF_API_TOKEN_BOT_MANAGEMENT` | `CF_API_TOKEN_ZONE_SETTINGS` |
216
+
217
+ Doppler is not probed: it is not a Cloudflare scope. The last stdout line is
218
+ `probe=<profile> verdict=pass|denied|inconclusive|fatal-mutation`. Record it in
219
+ the PR thread. Any verdict other than `pass` blocks that phase's dispatch.
220
+
172
221
  ## Exit codes
173
222
 
174
223
  - `0` — every retained scope authorized (and, per profile: the rulesets target,
@@ -180,7 +229,10 @@ summary's verbatim literal (a stable grep target for the data channel):
180
229
  absent Doppler secret, or a refused internal table-integrity tripwire (source
181
230
  drift only, unreachable by argv; stderr-only and names the corruption).
182
231
  - `3` — probe failed: a scope was dropped, degraded, or denied (assert mode: an
183
- LB row still `403` or anomalous).
232
+ LB row still `403` or anomalous; migration profiles: a write denied, or a
233
+ control not established).
234
+ - `4` — migration profiles only: an invalid-body write probe answered `2xx`. The
235
+ endpoint was read back and the run aborted. Treat it as a possible mutation.
184
236
  - `78` — the script REFUSED to run under shell tracing (`-x`) — a refusal, not a
185
237
  probe verdict; see the STREAM CONTRACT in the script header (#7797).
186
238
 
@@ -3,9 +3,11 @@
3
3
  # and confirm a newly-added scope is live (rulesets profile: --target-entrypoint;
4
4
  # default-token profile: --expect-lb-scopes).
5
5
  #
6
- # Deterministic, read-only probe. The widen itself is driven by Playwright MCP
7
- # per the skill (SKILL.md) — this script never touches the browser and never
8
- # mutates anything (no Doppler write, no infra apply).
6
+ # Deterministic probe, read-only except the two migration profiles
7
+ # (redirects-dns, zone-rest), which send PUT/POST/PATCH with one fixed invalid
8
+ # body that can never validate (see MIGRATION PROFILES). The widen itself is
9
+ # driven by Playwright MCP per the skill (SKILL.md) — this script never touches
10
+ # the browser, never writes Doppler and never applies infra.
9
11
  #
10
12
  # It runs the selected profile's retained-scope probe set — the ADR-130 set
11
13
  # against CF_API_TOKEN_RULESETS by default, the CF_API_TOKEN ledger + LB
@@ -34,6 +36,26 @@
34
36
  # and account Filter Lists are not, so a surgical single-permission drop of those
35
37
  # can pass. The probe issues GET, so it attests READ reachability, not :Edit
36
38
  # retention. See SKILL.md § Sharp Edges.
39
+ #
40
+ # MIGRATION PROFILES (#12931, CTO ruling L49): `redirects-dns` and `zone-rest`
41
+ # probe the NEW-account tokens a Cloudflare account migration phase must WRITE
42
+ # with, once per phase before that phase's rehearsal. A GET cannot prove :Edit
43
+ # (the 2026-07-24 config-rules scope-gap post-mortem), so these two profiles are
44
+ # the ONE place this script sends a write verb, and only under four rules:
45
+ # 1. the body is the fixed literal INVALID_BODY, which is not JSON and so can
46
+ # never validate against any endpoint (never an empty-rules ruleset body:
47
+ # that PUT validates and replaces a live entrypoint with nothing);
48
+ # 2. any 2xx answer is a FATAL abort (exit 4) followed by an immediate GET
49
+ # read-back of that endpoint, so a mutation that should be impossible is
50
+ # surfaced with its evidence rather than discovered later;
51
+ # 3. every write row first sends the same body with a KNOWN-DENIED token (a
52
+ # sibling token that lacks the scope) and must see 403 before the granted
53
+ # token's 400 counts as "authorized" — otherwise the endpoint may be
54
+ # validating the body before authorization and a 400 proves nothing;
55
+ # 4. method is PUT/POST/PATCH only, never DELETE.
56
+ # Each profile also runs known-present GET controls (success:true + parsed
57
+ # .result), and redirects-dns lists every ruleset in the new zone and account so
58
+ # a hand-made entrypoint is recorded by id (ADR-136 whole-list audit).
37
59
 
38
60
  set -euo pipefail
39
61
 
@@ -77,7 +99,7 @@ API="https://api.cloudflare.com/client/v4"
77
99
  # token gets a deterministic retained-scope re-check too (the ruling's binding
78
100
  # precondition). Profiles only — a raw --token-var knob would run one profile's
79
101
  # URLs against another token's capabilities and is refused by design (SKILL.md).
80
- PROFILES=(rulesets default-token)
102
+ PROFILES=(rulesets default-token redirects-dns zone-rest)
81
103
  PROFILE="rulesets"
82
104
 
83
105
  profile_token_secret() {
@@ -88,6 +110,55 @@ profile_token_secret() {
88
110
  esac
89
111
  }
90
112
 
113
+ # Migration profiles bind several tokens each (one per Doppler key, CTO F11), so
114
+ # they resolve through their row tables rather than profile_token_secret.
115
+ is_migration_profile() { [[ "$1" == "redirects-dns" || "$1" == "zone-rest" ]]; }
116
+
117
+ # Account / zone ids for the migration profiles (#12931). They are NOT read from
118
+ # Doppler: during Phase 0 CF_ZONE_ID / CF_ACCOUNT_ID still hold the OLD ids, and
119
+ # the whole point is to probe the NEW ones before the swap. Ids are not secrets.
120
+ NEW_ACCT_ID="66d4f93f7397f196544e9fe84c3557c2"
121
+ NEW_ZONE_ID="951ce525552201ec6c696b24251abed7"
122
+ OLD_ACCT_ID="4d5ba6f096b2686fbdd404167dd4e125"
123
+ OLD_ZONE_ID="5af02a2f394e9ba6e0ea23c381a26b67"
124
+
125
+ # The ONE write-probe body (CTO L49). Not JSON, so no endpoint can parse it, let
126
+ # alone validate it. A runtime tripwire below refuses to run if it ever parses.
127
+ readonly INVALID_BODY='<cf-token-scope:invalid-write-probe-body:not-json:never-valid>'
128
+
129
+ # Write-probe rows: label|method|url-template|grant-token-key|deny-token-key.
130
+ # The deny key names a sibling token that must NOT hold the row's scope (its 403
131
+ # is the control that makes the grant token's 400 mean "authorized"). Read-back
132
+ # on a 2xx is a GET of the same URL with the grant token.
133
+ MIG_WRITE_REDIRECTS_DNS=(
134
+ "zones/<zone>/rulesets/phases/http_request_dynamic_redirect/entrypoint|PUT|$API/zones/\$ZONE/rulesets/phases/http_request_dynamic_redirect/entrypoint|CF_API_TOKEN_RULESETS|CF_API_TOKEN_PAGES"
135
+ "zones/<zone>/rulesets/phases/http_response_headers_transform/entrypoint|PUT|$API/zones/\$ZONE/rulesets/phases/http_response_headers_transform/entrypoint|CF_API_TOKEN_RULESETS|CF_API_TOKEN_PAGES"
136
+ "zones/<zone>/rulesets/phases/http_config_settings/entrypoint|PUT|$API/zones/\$ZONE/rulesets/phases/http_config_settings/entrypoint|CF_API_TOKEN_RULESETS|CF_API_TOKEN_PAGES"
137
+ "zones/<zone>/rulesets/phases/http_request_cache_settings/entrypoint|PUT|$API/zones/\$ZONE/rulesets/phases/http_request_cache_settings/entrypoint|CF_API_TOKEN_RULESETS|CF_API_TOKEN_PAGES"
138
+ "zones/<zone>/rulesets/phases/http_request_firewall_custom/entrypoint|PUT|$API/zones/\$ZONE/rulesets/phases/http_request_firewall_custom/entrypoint|CF_API_TOKEN_RULESETS|CF_API_TOKEN_PAGES"
139
+ "accounts/<acct>/rulesets/phases/http_request_redirect/entrypoint|PUT|$API/accounts/\$ACCT/rulesets/phases/http_request_redirect/entrypoint|CF_API_TOKEN_RULESETS|CF_API_TOKEN_PAGES"
140
+ "accounts/<acct>/rules/lists|POST|$API/accounts/\$ACCT/rules/lists|CF_API_TOKEN_RULESETS|CF_API_TOKEN_PAGES"
141
+ "zones/<zone>/dns_records|POST|$API/zones/\$ZONE/dns_records|CF_API_TOKEN|CF_API_TOKEN_PAGES"
142
+ "accounts/<acct>/pages/projects|POST|$API/accounts/\$ACCT/pages/projects|CF_API_TOKEN_PAGES|CF_API_TOKEN_RULESETS"
143
+ )
144
+ MIG_WRITE_ZONE_REST=(
145
+ "zones/<zone>/settings|PATCH|$API/zones/\$ZONE/settings|CF_API_TOKEN_ZONE_SETTINGS|CF_API_TOKEN_BOT_MANAGEMENT"
146
+ "zones/<zone>/bot_management|PUT|$API/zones/\$ZONE/bot_management|CF_API_TOKEN_BOT_MANAGEMENT|CF_API_TOKEN_ZONE_SETTINGS"
147
+ )
148
+ # Known-present GET controls: label|url-template|token-key|want-type. Each must be
149
+ # an authorized 200 with success:true and a parsed .result of want-type, so a
150
+ # degraded 200 or a 404 is never read as "empty".
151
+ MIG_CTRL_REDIRECTS_DNS=(
152
+ "zones/<zone>/rulesets|$API/zones/\$ZONE/rulesets|CF_API_TOKEN_RULESETS|array"
153
+ "accounts/<acct>/rulesets|$API/accounts/\$ACCT/rulesets|CF_API_TOKEN_RULESETS|array"
154
+ )
155
+ MIG_CTRL_ZONE_REST=(
156
+ "zones/<zone>/settings|$API/zones/\$ZONE/settings|CF_API_TOKEN_ZONE_SETTINGS|array"
157
+ )
158
+ # Entrypoints the redirects-dns whole-list audit reports present/absent (ADR-136).
159
+ MIG_AUDIT_ZONE_PHASES=(http_request_dynamic_redirect http_response_headers_transform http_config_settings http_request_cache_settings http_request_firewall_custom)
160
+ MIG_AUDIT_ACCT_PHASES=(http_request_redirect)
161
+
91
162
  # default-token probe rows: class|label|url-template|want_type|scheme.
92
163
  # The $ZONE/$ACCT placeholders are printed VERBATIM by --dry-run and substituted
93
164
  # after secret acquisition on the run path — print/run parity from ONE table
@@ -129,8 +200,10 @@ usage() {
129
200
  cat <<'EOF'
130
201
  Usage:
131
202
  cf-token-scope.sh [--profile <rulesets|default-token>] [--target-entrypoint <phase>] [--expect-lb-scopes] [--dry-run]
203
+ cf-token-scope.sh --profile <redirects-dns|zone-rest> [--staged] [--account-id <id>] [--zone-id <id>] [--dry-run]
132
204
 
133
- Runs a retained-scope probe set for a NAMED PROFILE (read-only). Profiles only —
205
+ Runs a retained-scope probe set for a NAMED PROFILE (read-only, except the
206
+ migration profiles' fixed-invalid-body write probes). Profiles only —
134
207
  no raw token-var knob. The widen itself is driven via Playwright MCP — see SKILL.md.
135
208
 
136
209
  profiles:
@@ -138,6 +211,12 @@ no raw token-var knob. The widen itself is driven via Playwright MCP — see SKI
138
211
  default-token CF_API_TOKEN ledger abilities (Tunnel, Access, DNS, Notifications)
139
212
  + two Load-Balancer readiness rows (the #11181 widen precondition
140
213
  and post-check)
214
+ redirects-dns #12931 account migration, phase redirects-dns: invalid-body WRITE
215
+ probes (zone rulesets, account rulesets + lists, DNS, Pages) on the
216
+ NEW account/zone, each behind a known-denied 403 control, plus the
217
+ whole-list entrypoint audit
218
+ zone-rest #12931 account migration, phase zone-rest: invalid-body WRITE
219
+ probes for zone settings and bot management
141
220
 
142
221
  Flags:
143
222
  --target-entrypoint <phase> Also probe <phase> and assert the target scope is
@@ -146,6 +225,10 @@ Flags:
146
225
  --expect-lb-scopes Assert mode (default-token profile): LB rows must be
147
226
  authorized, else exit 3. Without it a baseline run
148
227
  reports 403 LB rows as not-yet-widened, exit-neutral.
228
+ --staged Migration profiles: read each token from its
229
+ <KEY>_NEXT staging key (Phase 0, before the swap).
230
+ --account-id / --zone-id Migration profiles: override the NEW account / zone
231
+ id (32 hex). The OLD ids are refused.
149
232
  --dry-run Print the selected profile's probe commands (token
150
233
  unexpanded) and run nothing.
151
234
  -h, --help Show this help.
@@ -157,13 +240,19 @@ Exit codes:
157
240
  missing prerequisite binary, absent Doppler secret, or a refused internal
158
241
  table-integrity tripwire (source drift; stderr-only, names the corruption)
159
242
  3 probe failed — a scope was dropped, degraded, or denied (assert mode: an LB
160
- row still 403 or anomalous)
243
+ row still 403 or anomalous; migration profiles: a write denied, or a
244
+ control not established, so a 400 could not be trusted)
245
+ 4 FATAL (migration profiles): an invalid-body write probe answered 2xx; the
246
+ endpoint was read back and the run aborted. Treat as a possible mutation.
161
247
  78 refused to run under shell tracing — a refusal, not a probe verdict (#7797)
162
248
  EOF
163
249
  }
164
250
 
165
251
  TARGET=""
166
252
  DRY_RUN=0
253
+ STAGED=0
254
+ MIG_ACCT_ARG=""
255
+ MIG_ZONE_ARG=""
167
256
  while [[ $# -gt 0 ]]; do
168
257
  case "$1" in
169
258
  --target-entrypoint)
@@ -188,6 +277,14 @@ while [[ $# -gt 0 ]]; do
188
277
  fi
189
278
  PROFILE="$2"; shift 2 ;;
190
279
  --expect-lb-scopes) LB_EXPECT=1; shift ;;
280
+ --staged) STAGED=1; shift ;;
281
+ --account-id|--zone-id)
282
+ if [[ -z "${2:-}" ]]; then
283
+ echo "cf-token-scope: $1 requires a 32-hex id" >&2
284
+ exit 2
285
+ fi
286
+ if [[ "$1" == "--account-id" ]]; then MIG_ACCT_ARG="$2"; else MIG_ZONE_ARG="$2"; fi
287
+ shift 2 ;;
191
288
  --dry-run) DRY_RUN=1; shift ;;
192
289
  -h|--help) usage; exit 0 ;;
193
290
  *) echo "cf-token-scope: unknown argument: $1" >&2; usage >&2; exit 2 ;;
@@ -212,7 +309,75 @@ if [[ -n "$TARGET" && ! "$TARGET" =~ ^[a-z_]+$ ]]; then
212
309
  echo "cf-token-scope: --target-entrypoint must be a ruleset phase name ([a-z_]+)" >&2
213
310
  exit 2
214
311
  fi
312
+ if is_migration_profile "$PROFILE"; then
313
+ if [[ -n "$TARGET" || "$LB_EXPECT" == "1" ]]; then
314
+ echo "cf-token-scope: --target-entrypoint / --expect-lb-scopes do not apply to migration profile '$PROFILE'" >&2
315
+ exit 2
316
+ fi
317
+ MIG_ACCT="${MIG_ACCT_ARG:-$NEW_ACCT_ID}"
318
+ MIG_ZONE="${MIG_ZONE_ARG:-$NEW_ZONE_ID}"
319
+ # The ids interpolate into probe URLs: hex-only, the same retarget concern as the
320
+ # --target-entrypoint charset gate. The OLD ids are refused outright: probing the
321
+ # old account would attest the wrong tokens' scope and read as a green phase.
322
+ for mig_id in "$MIG_ACCT" "$MIG_ZONE"; do
323
+ if [[ ! "$mig_id" =~ ^[0-9a-f]{32}$ ]]; then
324
+ echo "cf-token-scope: --account-id / --zone-id must be 32 lowercase hex characters" >&2
325
+ exit 2
326
+ fi
327
+ done
328
+ if [[ "$MIG_ACCT" == "$OLD_ACCT_ID" || "$MIG_ZONE" == "$OLD_ZONE_ID" ]]; then
329
+ echo "cf-token-scope: refusing the OLD account/zone id — migration profiles probe the NEW account (#12931)" >&2
330
+ exit 2
331
+ fi
332
+ elif [[ "$STAGED" == "1" || -n "$MIG_ACCT_ARG" || -n "$MIG_ZONE_ARG" ]]; then
333
+ echo "cf-token-scope: --staged / --account-id / --zone-id are migration-profile flags (redirects-dns, zone-rest)" >&2
334
+ exit 2
335
+ fi
336
+
337
+ # Runtime tripwire (L49): the write-probe body must never parse as JSON. Checked
338
+ # before anything else runs so a source edit that made it valid can never send it.
339
+ if command -v jq >/dev/null 2>&1 && printf '%s' "$INVALID_BODY" | jq -e . >/dev/null 2>&1; then
340
+ echo "cf-token-scope: INVALID_BODY parses as JSON (table corruption — a write probe must never carry a body that can validate)" >&2
341
+ exit 2
342
+ fi
343
+
344
+ # Row-table accessors for the migration profiles (print one row per line).
345
+ mig_write_rows() {
346
+ case "$1" in
347
+ redirects-dns) printf '%s\n' "${MIG_WRITE_REDIRECTS_DNS[@]}" ;;
348
+ zone-rest) printf '%s\n' "${MIG_WRITE_ZONE_REST[@]}" ;;
349
+ esac
350
+ }
351
+ mig_ctrl_rows() {
352
+ case "$1" in
353
+ redirects-dns) printf '%s\n' "${MIG_CTRL_REDIRECTS_DNS[@]}" ;;
354
+ zone-rest) printf '%s\n' "${MIG_CTRL_ZONE_REST[@]}" ;;
355
+ esac
356
+ }
357
+ mig_key() { if [[ "$STAGED" == "1" ]]; then printf '%s_NEXT' "$1"; else printf '%s' "$1"; fi; }
358
+ # Quoted replacements, same '&' reason as the default-token run path.
359
+ mig_url() { local u="${1//\$ZONE/"$MIG_ZONE"}"; printf '%s' "${u//\$ACCT/"$MIG_ACCT"}"; }
360
+
361
+ if is_migration_profile "$PROFILE" && [[ "$DRY_RUN" -eq 1 ]]; then
362
+ printf '%s\n' "# dry-run — migration profile $PROFILE on account <acct>=$MIG_ACCT zone <zone>=$MIG_ZONE (nothing executed)"
363
+ printf '%s\n' "# write probes send ONLY the invalid body; any 2xx aborts (exit 4) after a read-back"
364
+ printf '%s\n' "INVALID_BODY='$INVALID_BODY'"
365
+ while IFS='|' read -r c_label c_url c_key c_want; do
366
+ [[ -n "$c_label" ]] || continue
367
+ printf '%s\n' "# control $c_label (want 200, success:true, .result $c_want)"
368
+ printf '%s\n' "curl --disable --noproxy '*' -sS --max-time 15 -H @<(printf 'Authorization: Bearer %s' \"\$$(mig_key "$c_key")\") $(mig_url "$c_url")"
369
+ done < <(mig_ctrl_rows "$PROFILE")
370
+ while IFS='|' read -r w_label w_method w_url w_grant w_deny; do
371
+ [[ -n "$w_label" ]] || continue
372
+ printf '%s\n' "# write $w_label: deny control $(mig_key "$w_deny") must answer 403, then grant $(mig_key "$w_grant") must answer 400"
373
+ for w_key in "$w_deny" "$w_grant"; do
374
+ printf '%s\n' "curl --disable --noproxy '*' -sS --max-time 15 -X $w_method -H 'Content-Type: application/json' --data-binary \"\$INVALID_BODY\" -H @<(printf 'Authorization: Bearer %s' \"\$$(mig_key "$w_key")\") $(mig_url "$w_url")"
375
+ done
376
+ done < <(mig_write_rows "$PROFILE")
377
+ exit 0
378
+ fi
215
379
 
380
+ if ! is_migration_profile "$PROFILE"; then
216
381
  TOKEN_SECRET="$(profile_token_secret "$PROFILE")"
217
382
  if [[ -z "$TOKEN_SECRET" ]]; then
218
383
  # future-drift tripwire: unreachable while PROFILES and the case arms stay in
@@ -220,6 +385,7 @@ if [[ -z "$TOKEN_SECRET" ]]; then
220
385
  echo "cf-token-scope: profile '$PROFILE' resolves no token secret" >&2
221
386
  exit 2
222
387
  fi
388
+ fi
223
389
 
224
390
  if [[ "$DRY_RUN" -eq 1 ]]; then
225
391
  printf '%s\n' "# dry-run — would read the token read-only and probe (nothing executed):"
@@ -264,12 +430,14 @@ get_secret() {
264
430
  printf '%s' "$val"
265
431
  }
266
432
 
433
+ if ! is_migration_profile "$PROFILE"; then
267
434
  TOK="$(get_secret "$TOKEN_SECRET")"
268
435
  ZONE="$(get_secret "$ZONE_SECRET")"
269
436
  ACCT="$(get_secret "$ACCT_SECRET")"
270
- # shellcheck disable=SC2317 # invoked indirectly via the EXIT trap
437
+ # shellcheck disable=SC2317,SC2329 # invoked indirectly via the EXIT trap
271
438
  cleanup() { unset TOK ZONE ACCT; }
272
439
  trap cleanup EXIT
440
+ fi
273
441
 
274
442
  # Body-shape layer: a 200 is authorized ONLY with success==true AND .result of the
275
443
  # type the endpoint's scheme returns — a zone .../entrypoint returns a single
@@ -322,6 +490,159 @@ check() {
322
490
 
323
491
  report() { printf ' %-42s %s\n' "$1" "$2"; }
324
492
 
493
+ # ============================================================================
494
+ # Migration profiles (#12931, CTO L49) — run path. Exits; never falls through to
495
+ # the read-only profiles below.
496
+ if is_migration_profile "$PROFILE"; then
497
+ declare -A MIG_TOK=()
498
+ # shellcheck disable=SC2317,SC2329 # invoked indirectly via the EXIT trap
499
+ mig_cleanup() { MIG_TOK=(); unset MIG_TOK; }
500
+ trap mig_cleanup EXIT
501
+
502
+ # Acquire every token the profile's tables name, before the first request: a
503
+ # missing staging key must stop the run before any write probe is sent.
504
+ mig_need_keys=()
505
+ while IFS='|' read -r _l _u c_key _w; do [[ -n "$_l" ]] && mig_need_keys+=("$c_key"); done < <(mig_ctrl_rows "$PROFILE")
506
+ while IFS='|' read -r _l _m _u w_grant w_deny; do [[ -n "$_l" ]] && mig_need_keys+=("$w_grant" "$w_deny"); done < <(mig_write_rows "$PROFILE")
507
+ for base_key in "${mig_need_keys[@]}"; do
508
+ [[ -n "${MIG_TOK[$base_key]:-}" ]] && continue
509
+ MIG_TOK[$base_key]="$(get_secret "$(mig_key "$base_key")")"
510
+ done
511
+ unset _l _u _w _m
512
+
513
+ # mig_req <GET|PUT|POST|PATCH> <url> <token-key> — sets CODE + BODY. A write verb
514
+ # always carries INVALID_BODY and nothing else; the method allowlist is enforced
515
+ # here, at the one call site that can send a write.
516
+ mig_req() {
517
+ local method="$1" url="$2" key="$3" resp
518
+ CODE=""; BODY=""
519
+ case "$method" in
520
+ GET)
521
+ resp="$(curl --disable --noproxy '*' -sS --max-time 15 -w '\n%{http_code}' \
522
+ -H @<(printf 'Authorization: Bearer %s' "${MIG_TOK[$key]}") "$url" 2>/dev/null || true)" ;;
523
+ PUT|POST|PATCH)
524
+ resp="$(curl --disable --noproxy '*' -sS --max-time 15 -w '\n%{http_code}' -X "$method" \
525
+ -H 'Content-Type: application/json' --data-binary "$INVALID_BODY" \
526
+ -H @<(printf 'Authorization: Bearer %s' "${MIG_TOK[$key]}") "$url" 2>/dev/null || true)" ;;
527
+ *)
528
+ echo "cf-token-scope: write-probe method '$method' is not PUT/POST/PATCH (table corruption)" >&2
529
+ exit 2 ;;
530
+ esac
531
+ if [[ "$resp" != *$'\n'* ]]; then CODE="000"; return 0; fi
532
+ CODE="${resp##*$'\n'}"
533
+ BODY="${resp%$'\n'*}"
534
+ [[ "$CODE" =~ ^[0-9]+$ ]] || CODE="000"
535
+ return 0
536
+ }
537
+
538
+ # Only digits ride the verdict line (same rule as classify_target).
539
+ mig_errcode() {
540
+ local err
541
+ err="$(printf '%s' "$BODY" | jq -r '.errors[0].code // empty' 2>/dev/null || true)"
542
+ [[ "$err" =~ ^[0-9]+$ ]] && printf ', err %s' "$err"
543
+ return 0
544
+ }
545
+
546
+ # A 2xx to an invalid body should be impossible. Abort the whole run, read the
547
+ # endpoint back with the grant token, print a sanitized summary, exit 4.
548
+ mig_fatal() {
549
+ local label="$1" url="$2" key="$3" code="$4"
550
+ report "$label" "FATAL ($code to the invalid-body write probe)"
551
+ echo "FATAL: $label answered $code to the invalid-body write probe — a mutation may have landed. Reading it back:"
552
+ mig_req GET "$url" "$key"
553
+ printf ' read-back %s -> %s ' "$label" "$CODE"
554
+ printf '%s' "$BODY" | jq -c '
555
+ def safe: walk(if type == "string" then (if test("^[A-Za-z0-9_.:+-]{0,64}$") then . else "<redacted>" end) else . end);
556
+ {success, result: (.result | if type == "array" then {count: length, ids: ([.[] | .id?] | .[:20])}
557
+ elif type == "object" then {id, version, last_updated, rules: ((.rules // []) | length)}
558
+ else . end)} | safe' 2>/dev/null || printf '(unparseable body)'
559
+ printf '\n'
560
+ echo "probe=$PROFILE verdict=fatal-mutation"
561
+ exit 4
562
+ }
563
+
564
+ mig_staged_note=""
565
+ [[ "$STAGED" == "1" ]] && mig_staged_note=" (staged _NEXT keys)"
566
+ echo "cf-token-scope: migration profile $PROFILE — account ${MIG_ACCT:0:8}… zone ${MIG_ZONE:0:8}…$mig_staged_note"
567
+ MIG_DENIED=0
568
+ MIG_INCONCLUSIVE=0
569
+
570
+ # 1. Known-present controls (GET, fail-closed body shape).
571
+ MIG_CTRL_OK=1
572
+ while IFS='|' read -r c_label c_url c_key c_want; do
573
+ [[ -n "$c_label" ]] || continue
574
+ url="$(mig_url "$c_url")"
575
+ mig_req GET "$url" "$c_key"
576
+ if [[ "$CODE" == "200" ]] && authorized_body "$BODY" "$c_want"; then
577
+ report "control: $c_label" "authorized (200)"
578
+ case "$c_label" in
579
+ zones/*/rulesets) MIG_ZONE_LIST="$BODY" ;;
580
+ accounts/*/rulesets) MIG_ACCT_LIST="$BODY" ;;
581
+ esac
582
+ else
583
+ MIG_CTRL_OK=0; MIG_INCONCLUSIVE=1
584
+ if [[ "$CODE" == "200" ]]; then report "control: $c_label" "degraded (200 body not success/$c_want)"
585
+ else report "control: $c_label" "denied ($CODE$(mig_errcode))"; fi
586
+ fi
587
+ done < <(mig_ctrl_rows "$PROFILE")
588
+
589
+ # 2. Whole-list entrypoint audit (redirects-dns, ADR-136): only under authorized
590
+ # list controls, so an absent entry is read from a parsed list, never a 404.
591
+ if [[ "$PROFILE" == "redirects-dns" && "$MIG_CTRL_OK" == "1" ]]; then
592
+ mig_audit() {
593
+ local list="$1" kind="$2" phase="$3" id
594
+ id="$(printf '%s' "$list" | jq -r --arg k "$kind" --arg p "$phase" \
595
+ '[.result[] | select(.kind == $k and .phase == $p) | .id] | first // empty' 2>/dev/null || true)"
596
+ if [[ -z "$id" ]]; then report "audit: $phase" "entrypoint-absent"
597
+ elif [[ "$id" =~ ^[0-9a-f]{32}$ ]]; then report "audit: $phase" "entrypoint-present id=$id (import it, never overwrite)"
598
+ else report "audit: $phase" "entrypoint-present id=<malformed>"; fi
599
+ }
600
+ for ph in "${MIG_AUDIT_ZONE_PHASES[@]}"; do mig_audit "${MIG_ZONE_LIST:-}" zone "$ph"; done
601
+ for ph in "${MIG_AUDIT_ACCT_PHASES[@]}"; do mig_audit "${MIG_ACCT_LIST:-}" root "$ph"; done
602
+ fi
603
+
604
+ # 3. Write probes: deny control first (must be 403), then the grant token (400 =
605
+ # authorized). Any 2xx from either token is fatal.
606
+ while IFS='|' read -r w_label w_method w_url w_grant w_deny; do
607
+ [[ -n "$w_label" ]] || continue
608
+ url="$(mig_url "$w_url")"
609
+ mig_req "$w_method" "$url" "$w_deny"
610
+ if [[ "$CODE" == 2?? ]]; then mig_fatal "$w_label" "$url" "$w_grant" "$CODE"; fi
611
+ if [[ "$CODE" != "403" ]]; then
612
+ MIG_INCONCLUSIVE=1
613
+ if [[ "$CODE" == "400" ]]; then
614
+ report "$w_label" "inconclusive (deny control $(mig_key "$w_deny") got 400, not 403 — a 400 cannot prove scope here)"
615
+ else
616
+ report "$w_label" "inconclusive (deny control $(mig_key "$w_deny") got $CODE$(mig_errcode), not 403)"
617
+ fi
618
+ continue
619
+ fi
620
+ mig_req "$w_method" "$url" "$w_grant"
621
+ if [[ "$CODE" == 2?? ]]; then mig_fatal "$w_label" "$url" "$w_grant" "$CODE"; fi
622
+ case "$CODE" in
623
+ 400) report "$w_label" "authorized ($w_method 400 after a 403 control)" ;;
624
+ 401|403) MIG_DENIED=1; report "$w_label" "denied ($CODE$(mig_errcode))" ;;
625
+ *) MIG_INCONCLUSIVE=1; report "$w_label" "inconclusive ($w_method $CODE$(mig_errcode))" ;;
626
+ esac
627
+ done < <(mig_write_rows "$PROFILE")
628
+
629
+ echo
630
+ if [[ "$MIG_DENIED" == "1" ]]; then
631
+ echo "probe=$PROFILE verdict=denied"
632
+ echo "FAIL: a $PROFILE write scope is denied on the new account — do not dispatch this phase." >&2
633
+ exit 3
634
+ fi
635
+ if [[ "$MIG_INCONCLUSIVE" == "1" ]]; then
636
+ echo "probe=$PROFILE verdict=inconclusive"
637
+ echo "FAIL: a control was not established, so the $PROFILE write scopes are unproven — do not dispatch this phase." >&2
638
+ exit 3
639
+ fi
640
+ echo "probe=$PROFILE verdict=pass"
641
+ echo "PASS: every $PROFILE write scope authorized on the new account (invalid-body probes, nothing mutated)"
642
+ exit 0
643
+ fi
644
+
645
+
325
646
  # classify_target <label> — the ONLY neutrality mint site (plan Guard 2 assembly).
326
647
  # Called for default-token target rows only, after check() published
327
648
  # VERDICT/CODE/BODY and the caller captured its status into CHECK_RC. Neutrality
@@ -89,7 +89,7 @@ OK CNAME and sitemap present
89
89
  > served by Cloudflare Pages and DOES advance with these deploys — verify at the
90
90
  > apex, not at `pages.dev`. Until PR4b this block said the opposite and sent the
91
91
  > operator to the `pages.dev` hostname; that was correct then and is misdirection
92
- > now. `soleur-docs.pages.dev` still resolves and is still a useful
92
+ > now. `soleur-docs-40x.pages.dev` (the Soleur-account project since #12931) is a useful
93
93
  > origin-vs-edge discriminator, but it is not where a deploy is confirmed. See
94
94
  > `knowledge-base/engineering/operations/runbooks/cloudflare-pages-cutover.md`.
95
95
  ```
@@ -99,7 +99,7 @@ copy is the impoverished one. See
99
99
  - [ ] If DIFFERENT branch than the review target → offer to use worktree: "Use git-worktree skill for isolated Call `skill: git-worktree` with branch name
100
100
  - [ ] Fetch PR metadata using `gh pr view --json` for title, body, files, linked issues
101
101
  - [ ] Collision pre-check: `bash "${CLAUDE_PLUGIN_ROOT}/scripts/collision-precheck.sh" <N>` per linked issue — open PRs + foreign `proc.sh list_runs` rows; report hits before the panel (#10333)
102
- - [ ] `git fetch origin main && git merge-tree --write-tree origin/main HEAD >/dev/null; echo rc=$?` — a non-zero rc is a conflict with `main`; rebase BEFORE spawning the panel. A conflict found by a seat costs a rebase plus a second fix→CI round (PR #8052: `PROMOTED_FILES` collided with a sibling promotion, found by the code-quality seat).
102
+ - [ ] `git fetch origin main && git merge-tree --write-tree origin/main HEAD >/dev/null; echo rc=$?` — a non-zero rc is a conflict with `main`; rebase BEFORE spawning the panel. A conflict found by a seat costs a rebase plus a second fix→CI round (PR #8052: `PROMOTED_FILES` collided with a sibling promotion, found by the code-quality seat). A clean rc is not clean for a PR that deletes or rewrites content: see the merge-main bullet in [risk-tier-and-fix-rounds.md](references/risk-tier-and-fix-rounds.md) before the evidence comment.
103
103
  - [ ] Read `gh pr view --json mergeable,mergeStateStatus` BEFORE reading the check set as a verdict. GitHub cannot build a merge ref for a `CONFLICTING`/`DIRTY` PR, and **every `pull_request`-triggered workflow is then suppressed** — so the checks that do report (CodeQL, CLA, `push`-triggered jobs) are all green and the PR looks clean while the suites that would judge the diff never ran. An ABSENT check is not a passing one, and nothing on the PR page says so. **Why:** #8209/PR #8563 — a branch sat green-but-incomplete for a day; merging `origin/main` took the run from 4 checks to 57, two of which were red.
104
104
  - [ ] Use `gh pr checkout` or a manual checkout so the reviewed branch is current
105
105
  - [ ] Push the branch before spawning the panel (`git push -u origin $(git branch --show-current)`; review agents read remote state [rf-before-spawning-review-agents-push-the]) after running ship's `prepush-secret-scan.sh` (Bash `timeout: 400000`; 0/43 continue, else STOP). That push drives a CI cycle — `incr ci_cycles` after it (ship's convention).
@@ -97,6 +97,8 @@ Two lessons from #9448 belong in every fix-agent and review-seat brief (full acc
97
97
 
98
98
  - **A fix agent's "suite green" covers only the files it was given; brief it on the repo-global ratchets by name, and run the combined-tree gate BEFORE the fix-round panel.** Editing a floor means running `scripts/guard-vacuity-floor.test.sh` (its floor detector parses only `-lt|-le|-ge`, so a `-ne` rewrite drops the file from the promoted set); adding a test that reads outside `apps/web-platform` means registering it in `test/repo-wide-suites.ts` (`repo-wide-containment.test.ts`); refactoring a symbol another test pins as source text means `git grep` of the old literal across `test/`. The lead then runs the affected gate or those suites by name on the COMBINED tree before spawning seats, so the panel reviews a tree that already passes; an affected gate that prints `ran=- of=-` / `budget-deferred` (queued behind sibling runs) is no verdict. **Why:** #10892 — three disjoint-scope fix agents each reported green and together broke all three gates; two panel seats found them by running suites nobody had touched. See `knowledge-base/project/learnings/2026-10-23-fix-round-agents-reported-green-on-their-own-files-and-broke-three-repo-global-gates.md`.
99
99
 
100
+ - **A PR that DELETES or rewrites content must merge `origin/main` and re-run the suites that read it before the evidence comment — `git merge-tree` sees no conflict when a sibling PR asserts the very line this PR removes.** A filename overlap cannot find it (the sibling never touched the deleted file; it only names it). The check is to merge `origin/main` and run the affected gate on the merged tree. A content search is only a fast pre-filter, because a sibling that reaches the file by a glob or a computed path never shows in it: for each old path from `git diff --no-renames --ignore-submodules=none --name-only --diff-filter=DMR origin/main...HEAD` (a rename is a deletion of the old path) and each removed literal such as an id, run `git diff HEAD...origin/main | grep -F -- '<path-or-literal>'` and run every suite a hit names. **Why:** #12932 — #12876 merged a test pinning the moved zone's ruleset id and requiring the `seo-config-rules.tf` import this PR deleted; only CI on the merge ref saw it, plus two new kb-consumers rows.
101
+
100
102
  - **A seat's remediation advice and the lead's own "X is undocumented / only / never" are claims: read the enforcing script and the whole source sentence before writing either into a document.** A fix that adds a procedure (a removal order, an apply order) names a gate; open the gate. A negative about a doc (`cut -c1-300` hides the end of the line) is not evidence of absence. **Why:** #10976 fix round — a removal-checklist order taken from a seat contradicted `sentry-alert-reference-gate.sh` (one PR, with `[ack-destroy]`), and a README row said the SDK "documents only four" key sources when the next clause calls the rest legacy members current CLIs never emit; two seats found each. See `knowledge-base/project/learnings/2026-10-25-a-diagnostic-that-can-go-blind-must-say-so-and-my-docs-claimed-more-than-the-sdk-said.md`.
101
103
  - **A fix to PROSE that prescribes a state machine (a runbook run sheet, an abort/retry/rollback ladder) is reviewed by walking the state space, not the sentence.** List every variable the procedure can be in (flag, pause, exemption, sentinel, stamp, per-host state, before/after the irreversible step) and name the action each sentence prescribes in each reachable state; two sentences prescribing different actions in one state, or none, is a P1 whatever the wording. Key every abort/retry on the failure table's first step, not on one variable. **Why:** #11812 - the first fix commit introduced 3 new P1 and the second round still found one. See `knowledge-base/project/learnings/2026-11-01-every-fix-to-the-run-sheet-covered-the-state-i-was-thinking-of-and-the-sheet-had-eight-more.md`.
102
104