Skip to content

ci(pages): changing the live site's network needs a manual, confirmed run - #677

Merged
PastaPastaPasta merged 1 commit into
masterfrom
launch/pages-network-guard
Nov 24, 2026
Merged

PastaPastaPasta merged 1 commit into
masterfrom
launch/pages-network-guard

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

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, before pnpm install. The logic is in forge-contracts/scripts/pages-network-guard.mjs and has 8 offline tests in the contracts workflow:

  • It reads the live site's /forge-manifest.json network (from PAGES_SITE_URL, default https://forge.dashhq.org).
  • If this build's network differs from what the site serves, the run must be a workflow_dispatch with the new input confirm_network set 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).
  • A testnet or mainnet build fails while deployments/<network>.json is incomplete. This reuses check-release-network.mjs's notDeployedReason.
  • Ordinary pushes on the same network deploy exactly as before. I checked this locally against the live site: testnet, push, exit 0. A mainnet build with confirm=mainnet is refused today because there's no mainnet record yet.

Rollback is the same procedure in reverse: set PAGES_NETWORK=testnet, then dispatch with confirm_network: testnet.

Part of the mainnet launch prep (docs/launch/mainnet-runbook.md).

🤖 Generated with Claude Code

…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]>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d4d32f6a-e366-4667-97eb-93d9b92bd052
Commits

Reviewing files that changed from the base of the PR and between b5917e6 and f9098a1.

Files selected for processing: 4

  • .github/workflows/contracts.yml
  • .github/workflows/pages.yml
  • forge-contracts/scripts/pages-network-guard.mjs
  • forge-contracts/scripts/pages-network-guard.test.mjs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.mjs at f9098a1: 8/8 pass.
  • PAGES_BUILD_NETWORK=testnet PAGES_EVENT=push node forge-contracts/scripts/pages-network-guard.mjs against the live site printed live site network: testnet; this build: testnet; event: push and exited 0.
  • With mainnet, a push exits 1 with two errors (no record, and no confirmed dispatch). A workflow_dispatch with confirm_network=mainnet exits 1 on the record alone, because mainnet.json has no v2. An unreachable PAGES_SITE_URL exits 1.
  • YAML: the confirm_network input is optional and defaults to ''. On push, inputs.confirm_network is empty and becomes null in main(). The step sets working-directory: . to override the job default forge-web. It runs after setup-node and before pnpm 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.mjs has no side effects, because its main is guarded and check()'s default readFileSync only runs when called.
  • Rollback: testnet build, workflow_dispatch, confirm=testnet, live mainnet → 0 problems (testnet record is complete). A testnet push while live is mainnet → refused, as intended.
  • Devnet: the key devnet-<name> matches build-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 with confirm_network: devnet-<name>.

Findings

  1. Low: the cache-control: no-cache request 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 returned x-cache: HIT, age: 357 with Cache-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 testnet and the build is mainnet. 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_NETWORK until the live /forge-manifest.json reads the new network. After that, re-run any push run that failed the guard.

  2. 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 use curl --retry 5 --retry-all-errors. Fix: try 3 times with a short backoff before returning null.

  3. Low (docs): the runbook path is wrong, and the runbook doesn't describe the flip. pages.yml:22 and pages-network-guard.mjs:3 cite docs/launch/mainnet-runbook.md, which doesn't exist on master or on this branch; the file is docs/mainnet-runbook.md. That runbook never mentions PAGES_NETWORK, confirm_network or the rollback (set the variable back to testnet, then dispatch with confirm_network: testnet). Fix: correct the path and add a short "flip / roll back the hosted site" section, including the merge freeze from finding 1.

  4. Nit: the input description misleads for devnet. (pages.yml:53) It says "Type the network PAGES_NETWORK names", but a devnet needs devnet-<name>; typing devnet is refused. The error message does give the right value, so the operator can recover. Fix: "…e.g. mainnet, testnet or devnet-<name>".

  5. 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, live mainnet → []) and a devnet whose live network differs (push refused, dispatch with devnet-<name> allowed).
    • main()'s env mapping (empty PAGES_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.


🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

@PastaPastaPasta
PastaPastaPasta merged commit cf8693e into master Nov 24, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant