Repository navigation
ci(pages): deploy the testnet build to its own site, testnet-forge.dashhq.org - #678
Conversation
…shhq.org When forge.dashhq.org moves to mainnet, testnet needs a home. GitHub Pages serves one custom domain per repository, so pages-testnet.yml builds forge-web for testnet and pushes it to a site repository's gh-pages branch (keeping old _next/static chunks for open tabs), attesting the manifest like pages.yml. It deploys nothing until TESTNET_SITE_DEPLOY_KEY is set. The passkey vault accepts testnet-forge.dashhq.org as its own relying party. The host is a sibling of forge.dashhq.org on purpose: a child host could ask the browser for forge.dashhq.org's passkeys. 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 17 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: changes requested
Two medium items should land before TESTNET_SITE_DEPLOY_KEY is set. Neither one breaks the build or the skip path. Everything else below is low or a nit.
What I checked and found correct
- Skip path: with the secret unset,
buildruns only theenabledstep, prints a notice and passes.attestanddeployare skipped because theirif:is false, andsuccess()is still implied. Nothing fails. - Non-master refs:
attestanddeployboth checkgithub.ref == 'refs/heads/master', anddeployneedsattest. A dispatch from a branch or a tag builds and deploys nothing. This only holds while the workflow file itself is the one on master; see M2. - Dotfiles:
upload-artifactv7 withinclude-hidden-files: truekeepsout/.well-known/.download-artifactv8 extracts the tree as it was,cp -R site/. dest/copies dotfiles, and.nojekyllstops Jekyll dropping_next/and.well-known/. The build checkstest -s out/.well-known/security.txtbefore the upload. The manifest grep matches too:build-manifest.mjswritesJSON.stringify(m, null, 1), which gives"network": "testnet". - Deploy skew: the logic is right. It removes everything at the top level except
.gitand_next, removes everything in_next/exceptstatic/, then copies the new build over it. Names are hashed, so nothing of the new build is shadowed. Growth is a separate problem; see M3. - Secret handling: the key only ever goes into an env var and a 0600 file and is never echoed. The
enabledstep reads it before checkout, so no npm code ever sees it in its environment. Thedeployjob inherits onlycontents: read, and it needs no write access throughGITHUB_TOKEN. - Missing build env: compared with pages.yml, the only gap is
NEXT_PUBLIC_CF_BEACON_TOKEN, and leaving it out is fine as long as Cloudflare doesn't inject a beacon on this host (N2). TheDEVNET_*variables don't apply to a testnet build. - Passkey RP: accepting
testnet-forge.dashhq.orgis safe. It andforge.dashhq.orgare siblings, and neither is a registrable suffix of the other, so neither can claim the other's RP id. The parentdashhq.orgis still refused, and the new "child of forge.dashhq.org" test pins the dangerous shape. SITE_URLimport: fine.lib/site.tsimports nothing, so there is no import cycle, andSITE_URLis a pure constant built from build-time env, so it is safe under SSR.- Tests:
pnpm install --frozen-lockfile && pnpm vitest run lib/auth/passkey-vaultin a clean worktree gave 72 passed and 1 skipped (the live test). - actionlint: clean except SC2034 (
iunused) at.github/workflows/pages-testnet.yml:177. Usefor _ in ….
Findings
M1 (medium): dg verify-app fails on the new site by default.
.github/workflows/pages-testnet.yml:124 signs the attestation with the workflow .github/workflows/pages-testnet.yml. But dg verify-app's default expected signer is PastaPastaPasta/dash-forge/.github/workflows/pages.yml (crates/dg/src/attestation_signer.rs:18, crates/dg/src/verify_app.rs:93). The docs give the same default (docs/guides/verify-the-app.md:136), including the gh attestation verify … --signer-workflow …/pages.yml command.
So dg verify-app https://testnet-forge.dashhq.org exits with E504 ("signed by …/pages-testnet.yml"). Only --signer-workflow PastaPastaPasta/dash-forge/.github/workflows/pages-testnet.yml makes it pass.
The in-app check (forge-web/lib/build-check.ts) does pass. It accepts any attestation in this repo, so it doesn't catch the mismatch.
Fix, either way:
- (a) Make dg accept both official deploy workflows by default (
pages.ymlandpages-testnet.ymlonrefs/heads/master), or choose the default by host. - (b) At least document
--signer-workflow …/pages-testnet.ymland the matchinggh attestation verifycommand for testnet-forge.dashhq.org in verify-the-app.md.
M2 (medium, security): the deploy key isn't limited to master the way the Pages deploy is.
pages.yml deploys through the github-pages environment, whose branch policy is what restricts deploys to master. Here, TESTNET_SITE_DEPLOY_KEY is a plain repository secret (.github/workflows/pages-testnet.yml:53, :139). The github.ref checks only bind the copy of the workflow file on master.
Anyone with write access can push a branch whose copy of the workflow drops those checks (or just prints the key) and run it with workflow_dispatch or on: push. That puts arbitrary code on testnet-forge.dashhq.org. That origin now holds a passkey-vault RP and signing keys, and the bypass gets around master's branch protection.
Fix:
- Create an environment (say
testnet-site) whose deployment branches are master only, and store the key there. - Add
environment: testnet-siteto thedeployjob. - The
buildjob runs npm code, so keep it outside that environment. Drive the skip from a repository variable such asTESTNET_SITE_ENABLED, or from a cheap gate job that uses the environment and only checks whether the secret is set.
M3 (medium, not urgent): _next/static on gh-pages grows without bound.
.github/workflows/pages-testnet.yml:157-158 never deletes anything under _next/static. Each deploy whose chunks change adds files (the wasm SDK alone is tens of MB whenever it changes), and they stay forever. GitHub Pages refuses to publish a site over 1 GB, and the repo keeps growing too.
pages.yml bounds this: it keeps two older generations and stops at MAX_SITE_MB=700.
Fix: clone with --depth 3. Read git show HEAD:forge-manifest.json and HEAD~1:forge-manifest.json; the manifest lists every _next/static/… file of its build. Then delete any file under dest/_next/static that neither manifest nor the new build lists. That keeps the same two-generation skew window as pages.yml.
L1 (low): an unauthenticated ssh-keyscan decides which github.com host key the deploy trusts.
At .github/workflows/pages-testnet.yml:147, whatever host key answers the scan is trusted on first use. Hosted runners already ship GitHub's keys in /etc/ssh/ssh_known_hosts. Pin them instead: either -o UserKnownHostsFile=/etc/ssh/ssh_known_hosts, or write GitHub's published ed25519 line (github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl).
L2 (low): on a self-hosted build, the passkey message sends users to the page they are already on.
forge-web/lib/auth/passkey-vault/policy.ts:48 now says "open ${SITE_URL}". Take a self-hosted build with NEXT_PUBLIC_SITE_URL=https://example.org (docs/hosting.md asks self-hosters to set it). There passkeyVaultRpId is null, so the message says "open https://example.org" to a user who is already on example.org.
Fix: name SITE_URL only when SITE_HOST is in PASSKEY_VAULT_RP_IDS. Otherwise name the official host for the build's network: testnet → testnet-forge, mainnet → forge.
L3 (low): fewer export and live checks than pages.yml.
The testnet workflow leaves out several checks pages.yml has:
- the
Contact:andExpires:checks on security.txt, and the check that the manifest lists it - the license-notice checks (
third-party-licenses.txt,licenses/*) - the live security.txt check after the deploy
Also, nothing checks site/.well-known/security.txt after download-artifact. Copy those steps over and add test -s site/.well-known/security.txt before the push.
Nits (none block):
- N1:
NEXT_PUBLIC_MAINNET_SITE_URLandNEXT_PUBLIC_TESTNET_SITE_URL(.github/workflows/pages-testnet.yml:86-87) aren't read anywhere in forge-web. The header says they're shared with pages.yml, which doesn't set them. Drop them, or land the code that reads them. They don't change the bytes, since Next inlines only the variables it references. - N2: the build carries no CF beacon. If testnet-forge.dashhq.org is proxied by Cloudflare and Web Analytics automatic setup is ever enabled for it,
dg verify-appwill fail, because it removes an injected tag only next to the build's own beacon. Keep automatic injection off for this host, or add aTESTNET_SITE_CF_BEACON_TOKENvariable. - N3:
docs/launch/mainnet-runbook.mdis referenced at lines 4 and 58 but doesn't exist on master or in this PR. - N4: some text still names only forge.dashhq.org:
public/.well-known/security.txthasCanonical: https://forge.dashhq.org/…components/ui/trust-panel.tsx:179calls only forge.dashhq.org "GitHub Pages, behind Cloudflare"components/username-hint.tsx:31hardcodes forge.dashhq.org
- N5 (migration, not this PR's code): existing testnet passkey-vault users made their passkeys with RP
forge.dashhq.org, and their IndexedDB is on that origin. On testnet-forge they need another way to sign in, and they have to enroll again. Worth a line in the launch notes.
🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
…; prune old chunks The deploy key moves to the testnet-site environment (deployments from master only), entered only by the deploy job, so a workflow edited on a branch never sees it; TESTNET_SITE_ENABLED turns the workflow on. The site keeps the static chunks of the last three deploys and prunes the rest (Pages' 1 GB limit), pins GitHub's SSH host key, and runs pages.yml's export checks. verify-the-app names the --signer-workflow for the testnet site. The passkey hint names the build's own host only when it is a passkey host. Co-Authored-By: Claude Opus 5.5 <[email protected]>
PastaPastaPasta
left a comment
There was a problem hiding this comment.
Verdict: approve
Re-review at 576707e. M1–M3 and L1–L3 from the previous review are fixed. Nothing below blocks the merge.
What I checked
- Environment:
testnet-sitehas a singlebranch_policyrule, with custom branch policies set to exactly one:master(typebranch).TESTNET_SITE_DEPLOY_KEYexists only as an environment secret; there is no repo-level copy. Only thedeployjob enters the environment, and it is also gated ongithub.ref == 'refs/heads/master'. A workflow edited on a branch or in a PR can't get the key.TESTNET_SITE_ENABLED=trueis set at repo level. - Host key: the pinned key matches
gh api metassh_keysand has fingerprintSHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU, GitHub's published ed25519 key.StrictHostKeyChecking=yesandIdentitiesOnly=yesare set. - Manifest format: in the live https://forge.dashhq.org/forge-manifest.json,
filesis an object keyed by relative paths with no leading/, for example_next/static/chunks/103-….js.scripts/build-manifest.mjslists every file inout/except the manifest itself, so the current build's_next/staticfiles are always in the keep set. The"network": "testnet"grep matchesJSON.stringify(…, null, 1)output. - Prune logic (
pages-testnet.yml:155-170): I replayed it in /work/scratch with jq-built manifests over deploys A→B→C→D→D2.- After D it keeps exactly B, C and D, and the shared chunks survive.
sort,sort -uandcommall run underLC_ALL=C, so their orders agree. Mixed-case names prune correctly.- No
set -etraps: every conditional is anif, nothing uses a bare&&,commexits 0 underpipefail, andfind -deleteimplies-depth, so nested empty directories go. - A wrong key or network failure in
ls-remotefalls through togit init. The push is then a non-fast-forward without force, so it can't clobber the site.
- dg:
ExpectedSigner::parseacceptsPastaPastaPasta/dash-forge/.github/workflows/pages-testnet.yml. Thename_okcheck allows-, and the default signer stayspages.yml, so a testnet manifest served on forge.dashhq.org still fails the default check.lib/build-check.tsonly checks that some attestation exists in the repo, so the in-app check also works for testnet. - Passkey policy: the
PASSKEY_VAULT_RP_IDSchange is sound.testnet-forge.dashhq.orgis a sibling host, the test pins thattestnet.forge.dashhq.orgis refused, andofficialSite()falls back to forge.dashhq.org for self-hosted builds.new URL(SITE_URL)adds no new way to fail, becausesite.tsalready parses it at import. - actionlint 1.7.7 is clean on
pages-testnet.yml.
Findings
-
Low: the runbook reference is wrong, and the owner steps for the testnet site aren't written down anywhere.
- Where:
.github/workflows/pages-testnet.yml:3and the PR body. - Problem: both cite
docs/launch/mainnet-runbook.md, which doesn't exist; the runbook isdocs/mainnet-runbook.md, and it doesn't mention the testnet site at all. Pages isn't set up onPastaPastaPasta/dash-forge-testnet-siteyet (GET /pagesreturns 404, and the repo is empty). - Fix: correct the path, and add the remaining owner steps to the runbook:
- set the Pages source to
gh-pageswith custom domaintestnet-forge.dashhq.organd enforce HTTPS; - add the DNS CNAME
testnet-forge→pastapastapasta.github.io; - record the deploy key and the
testnet-siteenvironment as done.
- set the Pages source to
- Where:
-
Low: the PR description is out of date about what a merge does.
- Problem: it says that until the secret exists the workflow "deploys nothing, so merging this changes nothing yet". The key and
TESTNET_SITE_ENABLED=trueboth exist now, and the workflow file is inpaths. Merging will push to the site repo straight away. That push is harmless, but the "Check the live site" step will warn until Pages and DNS are set up. - Fix: update the description. It should also mention
TESTNET_SITE_ENABLED, the environment and theofficialSite()hint.
- Problem: it says that until the secret exists the workflow "deploys nothing, so merging this changes nothing yet". The key and
-
Low: the shared-origin hint still sends testnet users to mainnet. This is the same kind of problem as the previous L2.
- Where:
forge-web/lib/auth/vault.ts:83. - Problem:
sharedOriginProblemstill hardcodes "use https://forge.dashhq.org". After launch, a testnet build opened on a path gateway or github.io tells the user to go to the mainnet site. - Fix: move
officialSite()intolib/site.tsand use it in both messages.
- Where:
Nits
- Re-running a deploy shortens the skew window (
pages-testnet.yml:157-158). Re-running the same build, or redeploying the same manifest, still rotates.deploys. Replayed: re-running D2 dropped C and kept only D and D2. It also makes a commit, so the "no change" path is never reached. Fix: skip the rotation whencmp -s site/forge-manifest.json dest/forge-manifest.json. - The gh-pages history grows without limit. The tree is now bounded, but every deploy commits its new chunks on top of a shallow clone. Each SDK bump adds a new
wasm_sdk_bg.*.wasmof about 26.5 MB, and GitHub recommends keeping a Pages source repository under 1 GB. Fix: publish each deploy as a single orphan commit and force-push, since the history has no use. - Concurrency isn't per ref (
concurrency.group: pages-testnet). A build-onlyworkflow_dispatchon a feature branch cancels a master deploy that is in progress. No harm is done, because the push is atomic and the next master push redeploys. A${{ github.ref }}suffix avoids it. - No unit test covers the
officialSite()hint text inpasskeyVaultProblem.
🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
When forge.dashhq.org moves to mainnet at launch, testnet users need a site. GitHub Pages serves only one custom domain per repository, so the testnet build can't share this repo's Pages site.
.github/workflows/pages-testnet.ymlbuilds forge-web for testnet withNEXT_PUBLIC_SITE_URL=https://testnet-forge.dashhq.org.pages.ymldoes, so the app's verify check anddg verify-appwork there.gh-pagesbranch of a site repo (TESTNET_SITE_REPO, defaultPastaPastaPasta/dash-forge-testnet-site) with a deploy key, writingCNAMEand.nojekyll._next/staticchunks are kept so tabs that are already open don't break.pages.yml's export checks.TESTNET_SITE_*).TESTNET_SITE_ENABLED=true(set). The deploy key is a secret of thetestnet-siteenvironment, which allows master only, and only the deploy job enters it. Merging pushes the first build to the site repo. The site goes live once its Pages source/custom domain and thetestnet-forgeDNS CNAME exist (runbook step 1 / P1).testnet-forge.dashhq.orgis accepted as its own relying party. The "open Forge's address" hint now names the build's ownSITE_URL. A test pins thattestnet.forge.dashhq.orgis refused.rpId: forge.dashhq.org, so a compromised testnet site could ask for mainnet passkey PRF outputs.git-forge.dashhq.orgconvention.Verified:
pnpm vitest run lib/auth/passkey-vaultgives 72 passed, and the YAML parses. The end-to-end deploy runs after the site repo, deploy key and DNS exist; those steps are in docs/launch/mainnet-runbook.md.🤖 Generated with Claude Code