Repository navigation
ci(pages): changing the live site's network needs a manual, confirmed run - #677
Conversation
…al, confirmed run The hosted site flips from testnet to mainnet at launch. Until now a single repository variable change (or any push after it) would rebuild forge.dashhq.org on another network, including one with no deployment record. The network guard reads the live site's manifest network: a push that would change it fails, a workflow_dispatch must name the new network in confirm_network, and a testnet or mainnet build needs that network's record complete. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 40 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
PastaPastaPasta
left a comment
There was a problem hiding this comment.
Verdict: approve
I checked the workflow wiring, the guard logic, the tests and the live behavior. Nothing here blocks the launch. The low findings are availability and docs items worth fixing in this PR or as a quick follow-up.
What I checked
node --test forge-contracts/scripts/pages-network-guard.test.mjsat f9098a1: 8/8 pass.PAGES_BUILD_NETWORK=testnet PAGES_EVENT=push node forge-contracts/scripts/pages-network-guard.mjsagainst the live site printedlive site network: testnet; this build: testnet; event: pushand exited 0.- With
mainnet, apushexits 1 with two errors (no record, and no confirmed dispatch). Aworkflow_dispatchwithconfirm_network=mainnetexits 1 on the record alone, becausemainnet.jsonhas no v2. An unreachablePAGES_SITE_URLexits 1. - YAML: the
confirm_networkinput is optional and defaults to''. Onpush,inputs.confirm_networkis empty and becomesnullinmain(). The step setsworking-directory: .to override the job defaultforge-web. It runs after setup-node and beforepnpm install, so it runs no npm code and needs no token. The build, attest and deploy steps are byte-for-byte unchanged. - Importing
check-release-network.mjshas no side effects, because itsmainis guarded andcheck()'s defaultreadFileSynconly runs when called. - Rollback: testnet build,
workflow_dispatch,confirm=testnet, livemainnet→ 0 problems (testnet record is complete). A testnetpushwhile live ismainnet→ refused, as intended. - Devnet: the key
devnet-<name>matchesbuild-manifest.mjs:66, and no record check runs (so a retired devnet with the "moving" notice still builds). The same-devnet push path is unchanged. Moving to a devnet from testnet needs a dispatch withconfirm_network: devnet-<name>.
Findings
-
Low: the
cache-control: no-cacherequest header does nothing, so the guard can read a manifest up to ~10 minutes old. (forge-contracts/scripts/pages-network-guard.mjs:53) I tested it. GitHub Pages' Fastly returnedx-cache: HIT,age: 357withCache-Control: no-cache, and the same with a?t=query string. Stale reads only fail closed in the direction that matters, but they have operational effects at the flip:- For about 10 minutes after the confirmed mainnet deploy, every push to master fails the guard: the live manifest still reads
testnetand the build ismainnet. Re-running the failed run after the max-age clears it. concurrency: pages/cancel-in-progress: true(unchanged) means a merge to master during the manual flip run cancels it. The push run that replaces it then fails the guard, so the site stays on testnet and the only signal is a red run.- A false pass needs the variable flipped back within 10 minutes of a flip (A→B→A by variable, then a push). That's low risk, since that is a rollback the operator meant to do.
Fix: drop the header, or keep it with a comment saying it isn't honored. Add to the runbook: freeze merges to master from setting
PAGES_NETWORKuntil the live/forge-manifest.jsonreads the new network. After that, re-run any push run that failed the guard. - For about 10 minutes after the confirmed mainnet deploy, every push to master fails the guard: the live manifest still reads
-
Low: the live fetch is tried once, with no retry. (
pages-network-guard.mjs:51-61) One 5xx or a 20 s timeout makes an ordinary same-network push fail with "could not be read … needs a manual run". The deploy job's own checks usecurl --retry 5 --retry-all-errors. Fix: try 3 times with a short backoff before returningnull. -
Low (docs): the runbook path is wrong, and the runbook doesn't describe the flip.
pages.yml:22andpages-network-guard.mjs:3citedocs/launch/mainnet-runbook.md, which doesn't exist on master or on this branch; the file isdocs/mainnet-runbook.md. That runbook never mentionsPAGES_NETWORK,confirm_networkor the rollback (set the variable back totestnet, then dispatch withconfirm_network: testnet). Fix: correct the path and add a short "flip / roll back the hosted site" section, including the merge freeze from finding 1. -
Nit: the input description misleads for devnet. (
pages.yml:53) It says "Type the network PAGES_NETWORK names", but a devnet needsdevnet-<name>; typingdevnetis refused. The error message does give the right value, so the operator can recover. Fix: "…e.g.mainnet,testnetordevnet-<name>". -
Nit: tests. (
pages-network-guard.test.mjs)- The temp dir is shared and mutable: test 4 rewrites
mainnet.json, so tests 3 and 4 depend on their order, and the dir is never removed. - Cases not covered: a confirmed rollback (
testnet, dispatch,confirm=testnet, livemainnet→[]) and a devnet whose live network differs (push refused, dispatch withdevnet-<name>allowed). main()'s env mapping (emptyPAGES_CONFIRM→null,PAGES_DEVNET_NAME→ key) isn't tested.
The tests that exist do cover the core decision table and the null-on-failure fetch, so they're meaningful. These gaps are coverage, not correctness.
- The temp dir is shared and mutable: test 4 rewrites
🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
At launch, forge.dashhq.org moves from testnet to mainnet by changing
PAGES_NETWORK. Today that one variable change, or any push to master after someone changes it, rebuilds and deploys the site on the other network with no gate. The network may also have no deployment record yet, in which case every page says "not deployed".This adds a network guard step to
pages.yml, beforepnpm install. The logic is inforge-contracts/scripts/pages-network-guard.mjsand has 8 offline tests in the contracts workflow:/forge-manifest.jsonnetwork(fromPAGES_SITE_URL, defaulthttps://forge.dashhq.org).workflow_dispatchwith the new inputconfirm_networkset to that network. A push that would flip the network fails, and so does a dispatch with the wrong confirmation. If the live site can't be read, that counts as a change (fail closed).deployments/<network>.jsonis incomplete. This reusescheck-release-network.mjs'snotDeployedReason.Rollback is the same procedure in reverse: set
PAGES_NETWORK=testnet, then dispatch withconfirm_network: testnet.Part of the mainnet launch prep (docs/launch/mainnet-runbook.md).
🤖 Generated with Claude Code