Commit 64a70c5
feat(hcg): add surface-drift check script (standards#100 §1.5) (#228)
## Summary
Adds `scripts/hcg-surface-drift-check.sh`: a static, source-only audit
that asserts every wired `BojRest.Router` route is covered by at least
one rule in the HCG live Verb Governance Spec
(`config/gateway-policy-boj.yaml`).
The ADR's largest declared risk is **"policy lagging the surface"** —
a wired route landing without a matching policy rule would default-deny
in production (an outage on a route that should be live). The live
policy header carries a manual re-verification stamp
(`Re-verified 2026-05-28 against BojRest.Router`) which is the only
check today that catches this; the §1.5 prerequisite checklist relies
on the same manual procedure. This script makes the check
machine-checkable without changing any policy content, runbook
procedure, or gateway code.
### What the script does
1. Extracts `(verb, path-template)` tuples from
`elixir/lib/boj_rest/router.ex` (Plug.Router `get "/…"` / `post "/…"`
etc.).
2. Extracts `(verb, path-pattern)` tuples from
`config/gateway-policy-boj.yaml`.
3. For each wired route, concretises `:name`-style placeholders with a
known probe segment and asserts at least one policy rule matches
(literal equality for non-regex paths; ERE `grep -E` match against
the concrete URL for `^…` regex paths).
4. Exit 0 on no drift, 1 on drift detected, 64 on bad usage.
### Bracket-style relationship with `hcg-policy-smoke.sh`
- **Smoke script** (`hcg-policy-smoke.sh`) — runs against a *live
gateway* to confirm the policy enforces as declared (deny/allow
paths, stealth-status canaries, default-deny no-match canary).
- **Drift check** (this PR) — runs against the *source files* to
confirm the policy still covers the wired surface.
Together they cover both halves of the §1.5 pre-rollout verification:
surface→policy coverage (drift) and policy→gateway enforcement (smoke).
### What this PR does NOT do
- Does **not** modify the rollout runbook §1.5. Adoption as the §1.5
surface-drift check is a separate, owner-driven PR; this PR lands
the artefact only so the runbook update is a one-line wiring change.
- Does **not** wire the script into CI. Boj-server's CI discipline
(`docs/wikis/CI-and-Required-Checks.adoc` / `.claude/CLAUDE.md`)
requires path-filtered required checks to use the "always-trigger +
changes job" pattern; a CI wiring PR should follow that pattern.
Out of scope here.
- Does **not** modify any policy file. Today's surface and today's
policy are in agreement (the 2026-05-28 re-verification still holds;
the script run on this commit's working tree returns OK on the seven
wired routes: `/.well-known/boj-node-pubkey`, `/health`, `/menu`,
`/cartridges`, `/cartridge/:name`, `/cartridge/:name/invoke`,
`/cartridge/:name/sse`).
- Does **not** pre-empt the §6.4 Trustfile flip
(`tier_2_gateway.status` stays `PENDING`).
- Per single-lane HCG channel discipline (pattern set in
`http-capability-gateway` PRs #14, #22, #26, #30, #38 and `boj-server`
PRs #168, #173, #224, #226): joint-close is owner-only. **This PR
refs but does not close `standards#100`.**
### Channel state note
This session could not read `hyperpolymath/standards#91` / `#100` (the
session's repository scope is restricted to `http-capability-gateway`
and `boj-server`), so the brief's instructed status comment on
`standards#91` could not be posted. State was reconstructed from the
canonical sources in this repo (ADR-0004, the integration plan, the
audit, the rollout runbook, the live policy, and the merged-PR
commit history) plus the current `main` of both in-scope repos. The
analysis: Phase A/B/C/D are closed (artefacts merged, runbook §1.2 and
the Phase-D status note in the runbook header confirm); Phase E
(`standards#100`) is the only open phase; all remaining §1 checklist
items are owner-driven (`!OWNER:` placeholders, D-4 rebaseline
workflow_dispatch, cerro-torre `.ctp` signing, the §6.4 Trustfile flip).
This PR advances Phase E §1.5 ("Gateway-side prerequisites") by
converting one manual sub-check into an executable artefact, without
crossing into any owner-input territory.
## Test plan
- [ ] Run the script on this branch's working tree: `bash
scripts/hcg-surface-drift-check.sh` — expect exit 0, "OK: every wired
router route is covered by at least one policy rule." with the
wired-count = 7 and the policy-count matching the rule total in
`config/gateway-policy-boj.yaml`.
- [ ] Run `bash scripts/hcg-surface-drift-check.sh -v` — expect the
same exit 0 plus a `Matched:` block listing each of the seven wired
routes against its policy rule (literal `/health` → literal rule;
`/cartridge/:name/invoke` → `^/cartridge/[A-Za-z0-9_.-]+/invoke$`
regex; etc.).
- [ ] Synthetic drift test: temporarily add a wired route to the
router (e.g. `get "/__drift_test__" do …`) without a policy rule;
re-run and expect exit 1 with the route listed under `DRIFT:`.
Revert before merge.
- [ ] Confirm `shellcheck scripts/hcg-surface-drift-check.sh` is clean
(matches `scripts/hcg-policy-smoke.sh`'s shellcheck posture).
- [ ] Confirm SPDX header + Owner copyright match the canonical estate
format (matches `scripts/hcg-policy-smoke.sh`'s header shape).
- [ ] Verify no Hypatia / governance / spdx gates fire on the new
script file.
Refs hyperpolymath/standards#91
Refs hyperpolymath/standards#100
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JuztZ5kyDr3AqGtUsBipDL)_
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 8727662 commit 64a70c5
1 file changed
Lines changed: 259 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
0 commit comments