@soleur/opencode 3.360.2 → 3.361.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soleur/opencode",
3
- "version": "3.360.2",
3
+ "version": "3.361.0",
4
4
  "description": "Soleur AI organization plugin for OpenCode",
5
5
  "type": "module",
6
6
  "bin": {
@@ -57,15 +57,23 @@ bash "${CLAUDE_PLUGIN_ROOT}/skills/cf-token-scope/scripts/cf-token-scope.sh"
57
57
  bash "${CLAUDE_PLUGIN_ROOT}/skills/cf-token-scope/scripts/cf-token-scope.sh" \
58
58
  --target-entrypoint http_config_settings
59
59
 
60
+ # default-token profile — the #11181 CF_API_TOKEN widen precondition + post-check:
61
+ bash "${CLAUDE_PLUGIN_ROOT}/skills/cf-token-scope/scripts/cf-token-scope.sh" --profile default-token
62
+ bash "${CLAUDE_PLUGIN_ROOT}/skills/cf-token-scope/scripts/cf-token-scope.sh" \
63
+ --profile default-token --expect-lb-scopes
64
+
60
65
  # Print the probe commands without running them (token stays unexpanded):
61
66
  bash "${CLAUDE_PLUGIN_ROOT}/skills/cf-token-scope/scripts/cf-token-scope.sh" --dry-run
62
67
  ```
63
68
 
64
- The token / zone / account (`CF_API_TOKEN_RULESETS`, `CF_ZONE_ID`,
65
- `CF_ACCOUNT_ID`) and Doppler config (`soleur` / `prd_terraform`) are hardcoded:
66
- the ADR-130 retained-scope URL set is meaningful only for the rulesets token, so
67
- a `--token-var` knob pointed elsewhere would run the wrong URLs against the wrong
68
- token.
69
+ The token (`CF_API_TOKEN_RULESETS` or `CF_API_TOKEN`, resolved by `--profile`),
70
+ zone / account (`CF_ZONE_ID`, `CF_ACCOUNT_ID`) and Doppler config
71
+ (`soleur` / `prd_terraform`) are **profiles only, no raw token-var knob**: each
72
+ probe set is meaningful only for the token it binds to, so a `--token-var` knob
73
+ pointed at an arbitrary secret would run the wrong URLs against the wrong token.
74
+ The named-profile table is the one sanctioned widening of that posture —
75
+ `default-token` pairs the production default `CF_API_TOKEN` (the `cloudflare`
76
+ provider alias) with its own ledger probe set.
69
77
 
70
78
  ## Execution — the 3-step widen flow
71
79
 
@@ -101,6 +109,19 @@ token.
101
109
  the tool prints "present", not "added" — confirm the transition against your
102
110
  step-1 baseline.
103
111
 
112
+ ### The same 3 steps for `CF_API_TOKEN` (the #11181 LB widen)
113
+
114
+ 1. **Pre-widen baseline:** `--profile default-token`. The four retained ledger
115
+ rows (Tunnel, Access, DNS, Notifications) must read `authorized (200)` — a
116
+ retained failure here means the widen precondition is unmet, halt. The two LB
117
+ target rows read `not-yet-widened (403)` and the run exits 0 with a `NOTE:`
118
+ line — that is the expected absent-scope state BEFORE the widen.
119
+ 2. **Widen** via the playbook to Zone `soleur.ai` → `Load Balancers: Edit` AND
120
+ Account → `Load Balancing: Monitors and Pools: Edit` (append, never rebuild).
121
+ 3. **Assert:** `--profile default-token --expect-lb-scopes` must exit 0 with
122
+ `PASS: LB scopes present`. `not-yet-widened` is neutral ONLY in the step-1
123
+ baseline — the widen is not verified until an assert run exits 0.
124
+
104
125
  ## Probe-set contract (three-layer fail-closed classifier)
105
126
 
106
127
  The probe set is the ADR-130 four-probe retained set plus Zone WAF — four **zone**
@@ -122,11 +143,46 @@ list (`accounts/<acct>/rulesets`). The classifier captures each response **body*
122
143
  other phase's `404` fails closed: 403-on-missing is unverified there, so a
123
144
  dropped scope that returned `404` must not read as green.
124
145
 
146
+ Profile `default-token` — the `CF_API_TOKEN` set (the two LB rows are the
147
+ readiness probes of exactly the granted permission surfaces of the #11181
148
+ ruling; GETs attest the READ half):
149
+
150
+ | class | label | GET | attests | trust404 |
151
+ |---|---|---|---|---|
152
+ | retained | accounts/<acct>/cfd_tunnel | `.../cfd_tunnel?per_page=1` | Tunnel | 0 |
153
+ | retained | accounts/<acct>/access/apps | `.../access/apps?per_page=1` | Access | 0 |
154
+ | retained | zones/<zone>/dns_records | `.../dns_records?per_page=1` | DNS, zone soleur.ai | 0 |
155
+ | retained | accounts/<acct>/notification_policies | `.../notification_policies?per_page=1` | Notifications | 0 |
156
+ | target | accounts/<acct>/lb/pools | `.../load_balancers/pools?per_page=1` | Account Monitors-and-Pools (read half) | 0 |
157
+ | target | zones/<zone>/load_balancers | `.../load_balancers?per_page=1` | Zone Load Balancers (read half) | 0 |
158
+
159
+ Every default-token row is `trust404=0` — all rows fail closed on 404 (the
160
+ verified-404 exception stays exclusive to `http_config_settings`). `target`-class
161
+ neutrality is minted at exactly ONE classifier site and ONLY in baseline mode: a
162
+ clean `403` prints `not-yet-widened (403)` (with the parsed `errors[0].code`
163
+ appended when present and numeric) and the run stays exit-neutral with a `NOTE:` summary;
164
+ any other anomaly (404, degraded 200, wrong-shape 200, 5xx, 000, empty) is a
165
+ hard fail in BOTH modes. In assert mode (`--expect-lb-scopes`) every target row
166
+ must be authorized or the run exits 3 naming the still-absent 403s. The `target`-class
167
+ vocabulary is default-token-local: the rulesets `--target-entrypoint` path keeps
168
+ its own `TARGET_PRESENT` handling and never consults this classifier. The baseline
169
+ summary's verbatim literal (a stable grep target for the data channel):
170
+ `NOTE: LB scope not-yet-widened — expected BEFORE the #11181 widen; re-run with --expect-lb-scopes after it`.
171
+
125
172
  ## Exit codes
126
173
 
127
- - `0` — every retained scope authorized (and the target, if given).
128
- - `2` — usage error, missing prerequisite (`curl` / `doppler` / `jq`), or an absent Doppler secret.
129
- - `3` — probe failed: a scope was dropped, degraded, or denied.
174
+ - `0` — every retained scope authorized (and, per profile: the rulesets target,
175
+ if given; in `default-token` baseline, LB rows authorized OR reported
176
+ `not-yet-widened`; in `--expect-lb-scopes` assert mode, all LB rows authorized).
177
+ - `2` — usage error (including an unknown `--profile`, a flag used with the
178
+ wrong profile, and a malformed `--target-entrypoint` phase name — all raised
179
+ before any secret read), missing prerequisite (`curl` / `doppler` / `jq`), an
180
+ absent Doppler secret, or a refused internal table-integrity tripwire (source
181
+ drift only, unreachable by argv; stderr-only and names the corruption).
182
+ - `3` — probe failed: a scope was dropped, degraded, or denied (assert mode: an
183
+ LB row still `403` or anomalous).
184
+ - `78` — the script REFUSED to run under shell tracing (`-x`) — a refusal, not a
185
+ probe verdict; see the STREAM CONTRACT in the script header (#7797).
130
186
 
131
187
  ## Sharp Edges
132
188
 
@@ -147,7 +203,21 @@ list (`accounts/<acct>/rulesets`). The classifier captures each response **body*
147
203
  ground truth (ADR-130).
148
204
  - **Update the scope ledger.** After a widen, add the new permission to the
149
205
  `apps/web-platform/infra/variables.tf` description of the widened token (ADR-130's
150
- scope ledger), in the feature PR that consumes the widen.
206
+ scope ledger), in the feature PR that consumes the widen. For the `CF_API_TOKEN`
207
+ LB widen that is the post-widen follow-on: the two permissions join the
208
+ `cf_api_token` description — and ADR-130 gains its one-paragraph amendment note
209
+ pinning that the `CF_API_TOKEN` retained-scope re-check is the `default-token`
210
+ profile probe set — in the PR that consummates the widen, never before the
211
+ dashboard act has actually run.
212
+ - **The LB readiness probes attest read reachability, not `:Edit`** — the same
213
+ one-click Read-vs-Edit trap as the rulesets probe: a dashboard REPLACE that
214
+ re-adds `Load Balancers` as Read-only returns an authorized `200` and reads as
215
+ green while the write capability was dropped. Visually confirm `Edit` on both
216
+ granted rows.
217
+ - **`not-yet-widened` is neutral ONLY in baseline mode.** The widen is not
218
+ verified until an `--expect-lb-scopes` run exits 0. Reading a green baseline
219
+ (post-widen) as proof of the transition is the same present-not-added trap the
220
+ rulesets flow documents.
151
221
  - **Never print the Bearer token.** The script passes it from a private fd (not
152
222
  argv), `--dry-run` leaves it unexpanded, and it runs no `set -x`. When driving
153
223
  the widen, keep the full-power-session leak constraints above.
@@ -104,6 +104,16 @@ the token being edited. While the browser session is live:
104
104
  3. Update the `variables.tf` scope ledger in the feature PR — see SKILL.md
105
105
  § Sharp Edges (a code edit, not this skill's runtime).
106
106
 
107
+ For a `CF_API_TOKEN` widen (the #11181 LB track) the flow uses the named profile
108
+ instead of `--target-entrypoint`: pre-widen baseline `cf-token-scope.sh --profile default-token`
109
+ (retained ledger green; both LB rows EXPECTED to read `not-yet-widened (403)` — the first live
110
+ baseline run records the LB status-family empiricism, the way #6746 did for rulesets phases;
111
+ a `404` there hard-fails by design, it may mean an un-subscribed LB add-on); the permissions to
112
+ append are Zone `soleur.ai` → `Load Balancers: Edit` AND Account → `Load Balancing:
113
+ Monitors and Pools: Edit` (append, never rebuild — same three-dot → Edit → Add more
114
+ path); post-widen assert `cf-token-scope.sh --profile default-token --expect-lb-scopes`
115
+ must exit 0 with `PASS: LB scopes present`. Steps 2 and 3 above apply unchanged.
116
+
107
117
  ## New-phase entrypoint enumeration (only when the widen enables a NEW phase)
108
118
 
109
119
  If the widen enables a ruleset phase the zone did not previously have, enumerate
@@ -1,27 +1,31 @@
1
1
  #!/usr/bin/env bash
2
2
  # cf-token-scope — verify a Cloudflare API token's retained scope after a widen,
3
- # and (with --target-entrypoint) confirm a newly-added scope is live.
3
+ # and confirm a newly-added scope is live (rulesets profile: --target-entrypoint;
4
+ # default-token profile: --expect-lb-scopes).
4
5
  #
5
6
  # Deterministic, read-only probe. The widen itself is driven by Playwright MCP
6
7
  # per the skill (SKILL.md) — this script never touches the browser and never
7
8
  # mutates anything (no Doppler write, no infra apply).
8
9
  #
9
- # It runs the ADR-130 retained-scope probe set against CF_API_TOKEN_RULESETS and
10
- # is fail-closed in three layers (per learning
10
+ # It runs the selected profile's retained-scope probe set — the ADR-130 set
11
+ # against CF_API_TOKEN_RULESETS by default, the CF_API_TOKEN ledger + LB
12
+ # readiness set with `--profile default-token` —
13
+ # and is fail-closed in three layers (per learning
11
14
  # 2026-07-23-live-api-fail-closed-guard-counts-degraded-200-as-empty-and-control-probe-must-cover-every-scheme):
12
15
  # 1. status — 403 / 000 / 5xx / empty / no-newline / non-numeric = FAIL.
13
16
  # 2. body-shape — a 200 passes ONLY when the JSON body has success==true AND
14
17
  # .result is an array. A degraded 200 (e.g.
15
18
  # {"success":false,...} OR {"success":true,"result":null}) is a
16
19
  # FAIL. Never key on `.result | length` — jq reads null as 0.
17
- # 3. per-scheme control — the probes span two schemes: four zone phases and one
18
- # account list. The account list is itself the account-scheme
19
- # control (must be an authorized 200; an account 404 = FAIL). A
20
- # zone 404 (ADR-130's "phase exists, empty") is trusted ONLY for
21
- # http_config_settings — the one phase whose 403-on-missing was
22
- # empirically verified — and only under an authorized zone
23
- # control (http_request_dynamic_redirect). Every other phase's
24
- # 404 fails closed (a dropped scope that 404s must not pass).
20
+ # 3. per-scheme control — the RULESETS profile spans two schemes: four zone
21
+ # phases and one account list. The account list is itself the
22
+ # account-scheme control (must be an authorized 200; an account
23
+ # 404 = FAIL). A zone 404 (ADR-130's "phase exists, empty") is
24
+ # trusted ONLY for http_config_settings — the one phase whose
25
+ # 403-on-missing was empirically verified — and only under an
26
+ # authorized zone control (http_request_dynamic_redirect). Every
27
+ # other phase's 404 fails closed (a dropped scope that 404s must
28
+ # not pass). The default-token profile carries no trust404 row.
25
29
  #
26
30
  # The probe set is a CANARY for the whole-list REPLACE failure mode (a dashboard
27
31
  # "save" that replaces rather than appends drops every scope at once → every probe
@@ -61,11 +65,52 @@ unset SSLKEYLOGFILE CURL_CA_BUNDLE SSL_CERT_FILE SSL_CERT_DIR CURL_HOME \
61
65
 
62
66
  DOPPLER_PROJECT="soleur"
63
67
  DOPPLER_CONFIG="prd_terraform"
64
- TOKEN_SECRET="CF_API_TOKEN_RULESETS"
65
68
  ZONE_SECRET="CF_ZONE_ID"
66
69
  ACCT_SECRET="CF_ACCOUNT_ID"
67
70
  API="https://api.cloudflare.com/client/v4"
68
71
 
72
+ # Profile table (the ONLY token binding; plan 2026-10-28, rulings R1/R2/D1).
73
+ # rulesets = the ADR-130 retained-scope set against CF_API_TOKEN_RULESETS — the
74
+ # default, exactly today's behavior. default-token = the production default
75
+ # CF_API_TOKEN (the `cloudflare` provider alias) probed over its ledgered
76
+ # abilities plus two Load-Balancer readiness rows, so a scope widen of THAT
77
+ # token gets a deterministic retained-scope re-check too (the ruling's binding
78
+ # precondition). Profiles only — a raw --token-var knob would run one profile's
79
+ # URLs against another token's capabilities and is refused by design (SKILL.md).
80
+ PROFILES=(rulesets default-token)
81
+ PROFILE="rulesets"
82
+
83
+ profile_token_secret() {
84
+ case "$1" in
85
+ rulesets) printf '%s' "CF_API_TOKEN_RULESETS" ;;
86
+ default-token) printf '%s' "CF_API_TOKEN" ;;
87
+ *) printf '' ;;
88
+ esac
89
+ }
90
+
91
+ # default-token probe rows: class|label|url-template|want_type|scheme.
92
+ # The $ZONE/$ACCT placeholders are printed VERBATIM by --dry-run and substituted
93
+ # after secret acquisition on the run path — print/run parity from ONE table
94
+ # (Guard 1 assembly). class=target rows are the two LB readiness probes (one
95
+ # per granted permission surface of the ruling; GETs attest the read half).
96
+ # Every row is trust404=0: the 403-on-missing verification stays exclusive to
97
+ # http_config_settings (ADR-130 #6746); LB endpoints fail closed on 404.
98
+ DT_ROWS=(
99
+ "retained|accounts/<acct>/cfd_tunnel|$API/accounts/\$ACCT/cfd_tunnel?per_page=1|array|account"
100
+ "retained|accounts/<acct>/access/apps|$API/accounts/\$ACCT/access/apps?per_page=1|array|account"
101
+ "retained|zones/<zone>/dns_records|$API/zones/\$ZONE/dns_records?per_page=1|array|zone"
102
+ "retained|accounts/<acct>/notification_policies|$API/accounts/\$ACCT/notification_policies?per_page=1|array|account"
103
+ "target|accounts/<acct>/lb/pools|$API/accounts/\$ACCT/load_balancers/pools?per_page=1|array|account"
104
+ "target|zones/<zone>/load_balancers|$API/zones/\$ZONE/load_balancers?per_page=1|array|zone"
105
+ )
106
+
107
+ LB_EXPECT=0
108
+ LB_OK=0
109
+ # LB_NOTED is a LATCH (set to 1, never incremented) — its siblings are counters.
110
+ LB_NOTED=0
111
+ LB_MISSING=0
112
+ LB_TOTAL=0
113
+
69
114
  # The ADR-130 retained-scope zone phases. http_request_dynamic_redirect is the
70
115
  # known-granted zone control (ADR-130 § Consequences: the 200 control probe).
71
116
  # http_request_firewall_custom (Zone WAF:Edit) is added to the retained set
@@ -83,23 +128,37 @@ trust404_for() { [[ "$1" == "http_config_settings" ]] && echo 1 || echo 0; }
83
128
  usage() {
84
129
  cat <<'EOF'
85
130
  Usage:
86
- cf-token-scope.sh [--target-entrypoint <phase>] [--dry-run]
131
+ cf-token-scope.sh [--profile <rulesets|default-token>] [--target-entrypoint <phase>] [--expect-lb-scopes] [--dry-run]
132
+
133
+ Runs a retained-scope probe set for a NAMED PROFILE (read-only). Profiles only —
134
+ no raw token-var knob. The widen itself is driven via Playwright MCP — see SKILL.md.
87
135
 
88
- Runs the ADR-130 retained-scope probe set against CF_API_TOKEN_RULESETS
89
- (read-only). The widen itself is driven via Playwright MCP — see SKILL.md.
136
+ profiles:
137
+ rulesets (default) ADR-130 retained-scope set against CF_API_TOKEN_RULESETS
138
+ default-token CF_API_TOKEN ledger abilities (Tunnel, Access, DNS, Notifications)
139
+ + two Load-Balancer readiness rows (the #11181 widen precondition
140
+ and post-check)
90
141
 
91
142
  Flags:
92
143
  --target-entrypoint <phase> Also probe <phase> and assert the target scope is
93
- present (use after a widen; confirm the
94
- 403->present transition against your baseline).
95
- --dry-run Print the probe commands (token unexpanded) and
96
- run nothing.
144
+ present (rulesets profile; use after a widen; confirm
145
+ the 403->present transition against your baseline).
146
+ --expect-lb-scopes Assert mode (default-token profile): LB rows must be
147
+ authorized, else exit 3. Without it a baseline run
148
+ reports 403 LB rows as not-yet-widened, exit-neutral.
149
+ --dry-run Print the selected profile's probe commands (token
150
+ unexpanded) and run nothing.
97
151
  -h, --help Show this help.
98
152
 
99
153
  Exit codes:
100
- 0 every retained scope authorized (and the target, if given)
101
- 2 usage error, missing prerequisite binary, or absent Doppler secret
102
- 3 probe failed — a scope was dropped, degraded, or denied
154
+ 0 every retained scope authorized (and, per profile: the rulesets target if
155
+ given; the default-token LB rows authorized, or 403-noted in baseline mode)
156
+ 2 usage error (including profile/flag mismatch and a malformed phase name),
157
+ missing prerequisite binary, absent Doppler secret, or a refused internal
158
+ table-integrity tripwire (source drift; stderr-only, names the corruption)
159
+ 3 probe failed — a scope was dropped, degraded, or denied (assert mode: an LB
160
+ row still 403 or anomalous)
161
+ 78 refused to run under shell tracing — a refusal, not a probe verdict (#7797)
103
162
  EOF
104
163
  }
105
164
 
@@ -113,12 +172,55 @@ while [[ $# -gt 0 ]]; do
113
172
  exit 2
114
173
  fi
115
174
  TARGET="$2"; shift 2 ;;
175
+ --profile)
176
+ if [[ -z "${2:-}" ]]; then
177
+ echo "cf-token-scope: --profile requires a profile name" >&2
178
+ exit 2
179
+ fi
180
+ known=0
181
+ for p in "${PROFILES[@]}"; do
182
+ [[ "$p" == "$2" ]] && known=1
183
+ done
184
+ if [[ "$known" == "0" ]]; then
185
+ echo "cf-token-scope: unknown profile: $2" >&2
186
+ usage >&2
187
+ exit 2
188
+ fi
189
+ PROFILE="$2"; shift 2 ;;
190
+ --expect-lb-scopes) LB_EXPECT=1; shift ;;
116
191
  --dry-run) DRY_RUN=1; shift ;;
117
192
  -h|--help) usage; exit 0 ;;
118
193
  *) echo "cf-token-scope: unknown argument: $1" >&2; usage >&2; exit 2 ;;
119
194
  esac
120
195
  done
121
196
 
197
+ # Cross-validation BEFORE any secret read or recipe print (Guard 1 assembly:
198
+ # usage errors never print recipes for a mispaired run and never cost a Doppler
199
+ # access; plan addendum 6 mirrors the existing arm shapes).
200
+ if [[ "$PROFILE" == "rulesets" && "$LB_EXPECT" == "1" ]]; then
201
+ echo "cf-token-scope: --expect-lb-scopes is a default-token profile flag" >&2
202
+ exit 2
203
+ fi
204
+ if [[ "$PROFILE" == "default-token" && -n "$TARGET" ]]; then
205
+ echo "cf-token-scope: --target-entrypoint is a rulesets profile flag" >&2
206
+ exit 2
207
+ fi
208
+ # charset gate (panel seat): TARGET interpolates into the probe URL path; a
209
+ # '?'/.. value would silently retarget the read-only probe to another endpoint
210
+ # (wrong attestation). Phase names are lowercase+underscore by Cloudflare contract.
211
+ if [[ -n "$TARGET" && ! "$TARGET" =~ ^[a-z_]+$ ]]; then
212
+ echo "cf-token-scope: --target-entrypoint must be a ruleset phase name ([a-z_]+)" >&2
213
+ exit 2
214
+ fi
215
+
216
+ TOKEN_SECRET="$(profile_token_secret "$PROFILE")"
217
+ if [[ -z "$TOKEN_SECRET" ]]; then
218
+ # future-drift tripwire: unreachable while PROFILES and the case arms stay in
219
+ # sync — if they ever diverge, an empty binding must refuse, never probe bare.
220
+ echo "cf-token-scope: profile '$PROFILE' resolves no token secret" >&2
221
+ exit 2
222
+ fi
223
+
122
224
  if [[ "$DRY_RUN" -eq 1 ]]; then
123
225
  printf '%s\n' "# dry-run — would read the token read-only and probe (nothing executed):"
124
226
  printf '%s\n' "TOK=\$(doppler secrets get $TOKEN_SECRET -p $DOPPLER_PROJECT -c $DOPPLER_CONFIG --plain)"
@@ -129,6 +231,14 @@ if [[ "$DRY_RUN" -eq 1 ]]; then
129
231
  # The recipes also carry `--disable` literally first (it aborts ~/.curlrc
130
232
  # parsing, and later is too late) and `--noproxy '*'`, so a copy-pasted probe
131
233
  # teaches the confined form rather than the one this change removes (#7873).
234
+ if [[ "$PROFILE" == "default-token" ]]; then
235
+ for row in "${DT_ROWS[@]}"; do
236
+ # shellcheck disable=SC2034 # class/want/scheme consumed on the run path of the SAME table
237
+ IFS='|' read -r r_class r_label r_url r_want r_scheme <<<"$row"
238
+ printf '%s\n' "curl --disable --noproxy '*' -sS --max-time 15 -H @<(printf 'Authorization: Bearer %s' \"\$TOK\") $r_url"
239
+ done
240
+ exit 0
241
+ fi
132
242
  for p in "${ZONE_PHASES[@]}" ${TARGET:+"$TARGET"}; do
133
243
  printf '%s\n' "curl --disable --noproxy '*' -sS --max-time 15 -H @<(printf 'Authorization: Bearer %s' \"\$TOK\") $API/zones/\$ZONE/rulesets/phases/$p/entrypoint"
134
244
  done
@@ -165,47 +275,109 @@ trap cleanup EXIT
165
275
  # type the endpoint's scheme returns — a zone .../entrypoint returns a single
166
276
  # ruleset OBJECT; the account /rulesets list returns an ARRAY. A degraded 200
167
277
  # ({"success":false,...} or {"success":true,"result":null}) fails either way (null
168
- # is neither object nor array). $2 is the expected type: object (zone) | array (account).
278
+ # is neither object nor array). $4 is the expected type (object|array); when it is
279
+ # omitted it derives from $2's scheme, so the rulesets call sites keep their exact
280
+ # today's semantics (plan addendum 10: want_type is an ADDED parameter, never a
281
+ # scheme replacement). CODE/BODY are published for classify_target (addendum 5);
282
+ # verdict semantics stay byte-identical.
169
283
  authorized_body() {
170
284
  printf '%s' "$1" | jq -e --arg t "$2" '.success == true and (.result | type == $t)' >/dev/null 2>&1
171
285
  }
172
286
 
173
287
  ZONE_CONTROL_OK=0
174
288
 
175
- # check <url> <scheme:zone|account> <trust404:0|1> — probes one URL, sets VERDICT,
176
- # returns 0 (pass: authorized / empty-404-under-control-when-trusted) or 1 (fail).
177
- # The Authorization header is passed from a private fd so the token never lands
178
- # in the process argv (readable via ps / /proc/<pid>/cmdline).
289
+ # check <url> <scheme:zone|account> <trust404:0|1> [want_type:object|array] — probes
290
+ # one URL, sets VERDICT + CODE + BODY, returns 0 (pass: authorized / empty-404-under
291
+ # -control-when-trusted) or 1 (fail). The Authorization header is passed from a
292
+ # private fd so the token never lands in the process argv (readable via
293
+ # ps / /proc/<pid>/cmdline).
179
294
  check() {
180
- local url="$1" scheme="$2" trust404="${3:-0}" resp code body want_type
181
- want_type="object"; [[ "$scheme" == "account" ]] && want_type="array"
295
+ local url="$1" scheme="$2" trust404="${3:-0}" want_type="${4:-}" resp
296
+ if [[ -z "$want_type" ]]; then
297
+ want_type="object"
298
+ if [[ "$scheme" == "account" ]]; then want_type="array"; fi
299
+ fi
300
+ CODE=""; BODY=""
182
301
  resp="$(curl --disable --noproxy '*' -sS --max-time 15 -w '\n%{http_code}' \
183
302
  -H @<(printf 'Authorization: Bearer %s' "$TOK") "$url" 2>/dev/null || true)"
184
303
  if [[ "$resp" != *$'\n'* ]]; then VERDICT="empty (no response)"; return 1; fi
185
- code="${resp##*$'\n'}"
186
- body="${resp%$'\n'*}"
187
- if [[ ! "$code" =~ ^[0-9]+$ ]]; then VERDICT="empty (non-numeric status)"; return 1; fi
188
- if [[ "$code" == "200" ]]; then
189
- if authorized_body "$body" "$want_type"; then VERDICT="authorized (200)"; return 0; fi
304
+ CODE="${resp##*$'\n'}"
305
+ BODY="${resp%$'\n'*}"
306
+ if [[ ! "$CODE" =~ ^[0-9]+$ ]]; then VERDICT="empty (non-numeric status)"; return 1; fi
307
+ if [[ "$CODE" == "200" ]]; then
308
+ if authorized_body "$BODY" "$want_type"; then VERDICT="authorized (200)"; return 0; fi
190
309
  VERDICT="degraded (200 body not success/$want_type)"; return 1
191
310
  fi
192
311
  # A 404 is trusted as "phase exists, empty" ONLY for an entrypoint whose
193
312
  # 403-on-missing semantics are verified (trust404=1) AND under an authorized
194
313
  # zone control. Every other 404 fails closed.
195
- if [[ "$code" == "404" ]]; then
314
+ if [[ "$CODE" == "404" ]]; then
196
315
  if [[ "$scheme" == "zone" && "$ZONE_CONTROL_OK" == "1" && "$trust404" == "1" ]]; then
197
316
  VERDICT="empty (404, verified phase exists)"; return 0
198
317
  fi
199
318
  VERDICT="denied (404, unverified — fail-closed)"; return 1
200
319
  fi
201
- VERDICT="denied ($code)"; return 1
320
+ VERDICT="denied ($CODE)"; return 1
202
321
  }
203
322
 
204
323
  report() { printf ' %-42s %s\n' "$1" "$2"; }
205
324
 
325
+ # classify_target <label> — the ONLY neutrality mint site (plan Guard 2 assembly).
326
+ # Called for default-token target rows only, after check() published
327
+ # VERDICT/CODE/BODY and the caller captured its status into CHECK_RC. Neutrality
328
+ # is a clean 403 in BASELINE mode only (addendum 2): degraded/wrong-shape/404/5xx
329
+ # never read as absent-scope, and LB_MISSING counts 403 only, so the still-absent
330
+ # wording is never asserted for a cause the probe did not establish. The function
331
+ # ends with an explicit return 0 (addendum 4): a trailing false [[ ]] test would
332
+ # otherwise abort the run mid-ledger under set -e. Retained-class rows never
333
+ # consult this — a retained 403 stays denied (403) + FAILED, whatever the profile.
334
+ classify_target() {
335
+ local label="$1"
336
+ if [[ "$CHECK_RC" == "0" ]]; then
337
+ report "$label" "$VERDICT"; LB_OK=$((LB_OK + 1)); return 0
338
+ fi
339
+ if [[ "$CODE" == "403" && "$LB_EXPECT" == "0" ]]; then
340
+ local err
341
+ err="$(printf '%s' "$BODY" | jq -r '.errors[0].code // empty' 2>/dev/null || true)"
342
+ # stdout is the documented data channel: only digits may ride the verdict line
343
+ # (a non-scalar errors[0].code could otherwise inject rows a grep-consumer reads).
344
+ [[ "$err" =~ ^[0-9]+$ ]] || err=""
345
+ report "$label" "not-yet-widened (403${err:+, err $err})"
346
+ LB_NOTED=1
347
+ return 0
348
+ fi
349
+ FAILED=1
350
+ report "$label" "$VERDICT"
351
+ if [[ "$LB_EXPECT" == "1" && "$CODE" == "403" ]]; then LB_MISSING=$((LB_MISSING + 1)); fi
352
+ return 0
353
+ }
354
+
206
355
  FAILED=0
356
+ # TARGET_PRESENT lives above the dispatch so the summary tail always reads an
357
+ # initialized value — defensive against branch reordering, not argv-reachable
358
+ # behavior (fix-round seats: cross-validation forces TARGET empty under
359
+ # default-token).
360
+ TARGET_PRESENT=0
207
361
 
208
- echo "cf-token-scope: probing CF_API_TOKEN_RULESETS retained scope (read-only)"
362
+ # Table-integrity pre-flight (structural seat, sandbox-mutant-verified): a class
363
+ # value outside {retained,target} must NEVER fall through to the target branch —
364
+ # that route mints neutrality for a retained row's genuine 403 loss. This is the
365
+ # runtime defense with no argv-reachable twin (D12d pins its presence); profile/
366
+ # table drift beyond this has CI pins (D-pc enumeration, D3 per-arm loop) rather
367
+ # than a second runtime arm here (fix-round consolidation: pin wins over
368
+ # tripwire).
369
+ if [[ "$PROFILE" == "default-token" ]]; then
370
+ for r_row in "${DT_ROWS[@]}"; do
371
+ r_class="${r_row%%|*}"
372
+ if [[ "$r_class" != "retained" && "$r_class" != "target" ]]; then
373
+ echo "cf-token-scope: DT_ROWS class '$r_class' is neither retained nor target (table corruption — neutrality eligibility must not fall through)" >&2
374
+ exit 2
375
+ fi
376
+ done
377
+ fi
378
+
379
+ if [[ "$PROFILE" == "rulesets" ]]; then
380
+ echo "cf-token-scope: probing $TOKEN_SECRET retained scope (read-only)"
209
381
 
210
382
  # 1. Zone control first — every zone 404's trust depends on it. The control must
211
383
  # be an authorized 200 (trust404=0: a control that only 404s proves nothing).
@@ -224,9 +396,11 @@ done
224
396
  check "$API/accounts/$ACCT/rulesets" account 0 || FAILED=1
225
397
  report "accounts/<acct>/rulesets" "$VERDICT"
226
398
 
227
- # 4. Target entrypoint (the newly-widened scope), if given. TARGET_PRESENT gates
228
- # the success line so it cannot print unless the target probe actually passed.
229
- TARGET_PRESENT=0
399
+ # 4. Target entrypoint (the newly-widened scope), if given. TARGET_PRESENT (hoisted
400
+ # above the dispatch) gates the success line so it cannot print unless the target
401
+ # probe actually passed. This rulesets path keeps its own handling; it never
402
+ # consults classify_target (plan addendum 8 — the target-class vocabulary is
403
+ # default-token-local).
230
404
  if [[ -n "$TARGET" ]]; then
231
405
  if check "$API/zones/$ZONE/rulesets/phases/$TARGET/entrypoint" zone "$(trust404_for "$TARGET")"; then
232
406
  TARGET_PRESENT=1
@@ -236,9 +410,43 @@ if [[ -n "$TARGET" ]]; then
236
410
  report "target: $TARGET" "$VERDICT"
237
411
  fi
238
412
 
413
+ else
414
+
415
+ # default-token profile: retained ledger rows, then the two LB readiness rows —
416
+ # iterated from DT_ROWS, the SAME table --dry-run printed (print/run parity).
417
+ echo "cf-token-scope: probing $TOKEN_SECRET retained + LB-readiness scope (read-only)"
418
+ for row in "${DT_ROWS[@]}"; do
419
+ IFS='|' read -r r_class r_label r_url r_want r_scheme <<<"$row"
420
+ # Quoted replacements: bash >= 5.2 treats '&' in an UNQUOTED substitution
421
+ # replacement as the matched text — an id containing '&' would splice a literal
422
+ # '$ZONE' back into the URL (panel seat, measured).
423
+ url="${r_url//\$ZONE/"$ZONE"}"
424
+ url="${url//\$ACCT/"$ACCT"}"
425
+ CHECK_RC=0
426
+ check "$url" "$r_scheme" 0 "$r_want" || CHECK_RC=1
427
+ if [[ "$r_class" == "retained" ]]; then
428
+ [[ "$CHECK_RC" == "0" ]] || FAILED=1
429
+ report "$r_label" "$VERDICT"
430
+ else
431
+ LB_TOTAL=$((LB_TOTAL + 1))
432
+ classify_target "$r_label"
433
+ fi
434
+ done
435
+
436
+ fi
437
+
239
438
  echo
240
439
  if [[ "$FAILED" -eq 0 ]]; then
241
440
  echo "PASS: no scope dropped"
441
+ if [[ "$PROFILE" == "default-token" ]]; then
442
+ # Assert mode green compares against the profile's OWN target-row count
443
+ # (parameterized, never a hardcoded 2 — addendum 3; aggregate-floor rule D11).
444
+ if [[ "$LB_EXPECT" == "1" && "$LB_TOTAL" -gt 0 && "$LB_OK" -eq "$LB_TOTAL" ]]; then
445
+ echo "PASS: LB scopes present — confirm the 403->present transition against your pre-widen baseline"
446
+ elif [[ "$LB_EXPECT" == "0" && "$LB_NOTED" == "1" ]]; then
447
+ echo "NOTE: LB scope not-yet-widened — expected BEFORE the #11181 widen; re-run with --expect-lb-scopes after it"
448
+ fi
449
+ fi
242
450
  # "present", not "added": a single run cannot observe the 403->authorized
243
451
  # transition — the operator confirms that against the pre-widen baseline.
244
452
  [[ -n "$TARGET" && "$TARGET_PRESENT" == "1" ]] && \
@@ -246,8 +454,16 @@ if [[ "$FAILED" -eq 0 ]]; then
246
454
  exit 0
247
455
  fi
248
456
 
249
- if [[ "$ZONE_CONTROL_OK" != "1" ]]; then
457
+ # The zone-control diagnostic names a probe the default-token profile never
458
+ # issues — gated to rulesets (addendum 9, pinned by the D-block lacks).
459
+ if [[ "$PROFILE" == "rulesets" && "$ZONE_CONTROL_OK" != "1" ]]; then
250
460
  echo "FAIL: zone control ($ZONE_CONTROL) is not authorized — the token is likely bad or missing its base scope, not a single dropped scope." >&2
251
461
  fi
462
+ # The assert-mode blocking verdict rides STDOUT — the documented data channel
463
+ # (#7797 rationale; addendum 1). Only minted for a real 403 (addendum 2): a
464
+ # degraded/wrong-shape target row says so on its own row and never here.
465
+ if [[ "$PROFILE" == "default-token" && "$LB_EXPECT" == "1" && "$LB_MISSING" -gt 0 ]]; then
466
+ echo "FAIL: LB scope still absent — the widen was not applied to CF_API_TOKEN"
467
+ fi
252
468
  echo "FAIL: retained-scope probe failed — inspect the denied/degraded entrypoints above." >&2
253
469
  exit 3
@@ -72,3 +72,9 @@ files); the cost came from three habits below, each of which multiplies.
72
72
 
73
73
  **Report cost honestly.** If a run was disproportionate, say so and name the cause — the
74
74
  operator paid for it and cannot see the breakdown.
75
+
76
+ **Depth-1 harness adaptation (OpenCode family).** When the harness forbids spawned children
77
+ from spawning further, a child skill that fans out runs its steps sequentially inline with
78
+ `Reviewed-Coverage: sequential-fallback` disclosed, while review-panel and fix-round seats
79
+ spawn from the pipeline session itself — gates change execution shape, never presence
80
+ (learning: `knowledge-base/project/learnings/2026-10-28-one-shot-on-opencode-depth-1-harness-adaptations.md`).