Repository navigation
feat: web origin and top-up link follow the network - #691
Conversation
Mainnet's web app is https://forge.dashhq.org; testnet's moves to the sibling host https://testnet-forge.dashhq.org. The clients hard-coded one origin and a bare bridge URL, which opens on testnet. - Network::web_origin() and Network::top_up_url() (bridge ?network=mainnet or ?network=testnet; devnets keep forge.dashhq.org and the bare bridge). - Repo, commit and done-line links, the storage CORS probe and the CORS document dg prints use the web origin of the network in use. - E401's fix opens the bridge on the command's network: ErrorContext carries it, with a process-wide fallback set once dg, git-remote-dash and forge-import resolve their network. The testnet faucet hint names the testnet web app. - forge-relay links to its network's web app unless --web-base-url is set. - Live e2e scenarios expect the origin of the network they run on. - Storage/CORS guides and docs/errors.md say which origin to allow. 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 1 minute. 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 read the full diff against master at 8c437c6 and traced every caller. Nothing blocks the merge.
Threading. No call site still uses the old constants. In Rust code outside tests, forge.dashhq.org now appears only in MAINNET_WEB_ORIGIN and in dg ipfs's DEFAULT_ORIGIN, which the PR body lists as out of scope. bridge.thepasta.org now appears only in TOP_UP_BRIDGE.
- Every caller of
repo_link,web_url,web_page_url,short_repo_baseandcommit_web_url(dg ci report/status,dg init/repo create, the helper's done-line) gets its network fromctx.network()orHelper::network(). dgresolves its network once, inCtx::resolve(flags, then the repo's git config, then the environment, then the key). Nothing resolves it later.Network::kind()returnsmainnetortestnet. The bridge reads?network=inmainnet-bridgesrc/main.tsstateFromUrl()(defaulttestnet), so the deep link is a real bridge feature. A devnet still gets the bare bridge URL, as before.
Process-wide fallback. It is a OnceLock: the first set_network wins, later calls are ignored, and there is no data race. Each binary calls it once, right after it resolves its network: dg main.rs:2827, git-remote-dash main.rs:204, and forge-import main.rs:242 (only the import path writes). An explicit ErrorContext::network takes precedence (ctx.network.or_else(|| PROCESS_NETWORK.get())). No test calls set_network, so top_up(None) is not polluted today.
forge-relay. The precedence is still --web-base-url, then the config file, then target.network.web_origin(). target is resolved before that line, and the new asserts cover the explicit value, testnet and mainnet.
CORS check. The probe origin can't be empty in practice: web_origin() always returns a non-empty &'static str. The !origin.is_empty() guard only blocks the case where an empty origin would equal a missing header. Behaviour is otherwise unchanged.
e2e. config.sh allows only DASH_FORGE_NETWORK = devnet or testnet. web_origin() in e2e/cli/lib.sh covers both. The dot escaping in scenario 13's grep -E is correct. The json-fixtures check shapes, not values, so the old URLs there don't matter.
Merging before the testnet site is live. This is safe, since no release ships until v0.3.0 and the flip is today. Only source builds, the Action with install: 'source', and the nightly are affected:
- Their testnet links would point at a host that doesn't resolve yet.
dg storage testanddg doctorwould probe with the testnet origin. A bucket whose read rule is*passes either way, and the e2e/infra bucket uses*. Only a read rule restricted tohttps://forge.dashhq.orgwould fail by mistake.- The CORS document printed on testnet names
testnet-forgein its write rule. Applied before the flip, it would stop browser pushes from today's testnet site. - The nightly only compares strings.
verify-appstill targets forge.dashhq.org.
CI and the 3 git-version tests. On master, rust build + test (run 45329408553, git 2.56.1) runs and passes all three: history_no_clone_takes_is_refused_before_it_is_stored, git::tests::real_histories_with_malformed_idents_index and git::tests::many_malformed_idents_index_without_hanging. This PR doesn't touch that code, so the sandbox failures come from its git 2.43. This PR's own rust build + test was still pending when I posted this; it needs to go green before merge. no-devnet-copy.sh passes locally on the PR head.
Findings (all nits, none blocking)
- nit,
crates/forge-core/src/user_error.rs:686: no production code ever setsErrorContext::networktoSome. Every E401 goes through the process fallback, so the field only serves tests. Either keep it as the documented override, or drop it and testinsufficientthrough a small helper that takes the fallback as an argument. - nit,
crates/forge-core/src/user_error.rs:3677:top_up(None)expects the bare bridge, which holds only while no test in the forge-core lib binary callsset_network. A future test that does would make it order-dependent. A one-line comment next toPROCESS_NETWORKwould prevent that. - nit,
docs/guides/bring-your-own-storage.md(new "CORS origins" section): "check from the origin of the network they run on (--network)". The network can also come from the repo'sdash.network, the environment or the key. Suggest "the networkdgresolves (--network, the repo'sdash.network, …)". - nit,
crates/dg/src/ipfs/mod.rs:278-283:verifynow takes the origin, but the managed-node profile haspublic_gateway: None, socheck_public_read/probe_corsnever runs there. The argument has no effect on that path. Harmless, and correct if the profile ever gains a public gateway. - Follow-up, outside this PR's Rust scope but visible at the flip:
action/summary.sh:81hard-codes "Renew at forge.dashhq.org/…", and the Action's default network is testnet. After the flip, testnet mirror users get a renew link to the mainnet app.action/README.mdandaction.ymlalso still say forge.dashhq.org serves testnet. This belongs in the launch docs pass, together with the forge-relay README default row anddg ipfs'sDEFAULT_ORIGIN, which the PR body already lists.
🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
The Rust clients hard-code one web origin (
https://forge.dashhq.org) and a bare top-up URL (https://bridge.thepasta.org, which opens on testnet). At launch, mainnet's web app ishttps://forge.dashhq.organd testnet's moves tohttps://testnet-forge.dashhq.org. That host is a sibling, not a child, so it can't claim mainnet's WebAuthn rpId. Without this change, testnet links, the storage CORS probe and the CORS documentdgprints would all name the mainnet app, and a mainnet E401 would send users to the bridge's testnet mode.Change
Network::web_origin(): testnet giveshttps://testnet-forge.dashhq.org. Mainnet and devnets givehttps://forge.dashhq.org, since a devnet has no web app of its own.Network::top_up_url():https://bridge.thepasta.org/?network=mainnet|testnet; a devnet gets the bare URL.web_url,repo_link,commit_web_url, the push done-line) take the network.storage::corsdropsPROBE_ORIGIN.dg storage test, the storage wizard anddg doctorprobe from the web origin of the network in use, and the CORS document they print names that origin.ErrorContextgains an optionalnetwork, with a fallback thatdg,git-remote-dashandforge-importset for the whole process once they resolve their network. This also covers error paths that classify with a default context.check_fundsandcheck_affordabletake the network instead oftestnet: bool, and the testnet faucet hint names the testnet web app.web_base_urlis the target network's web origin.--web-base-urland the config-file key still win.web_originhelper ine2e/cli/lib.sh).docs/errors.md.Not in this PR
dg ipfs up) still allows onlyhttps://forge.dashhq.orgby default, and its pairing link opens there. The guide tells testnet users to rundg ipfs up --origin https://testnet-forge.dashhq.org.--web-base-urldefault row in the forge-relay README, and other docs that say forge.dashhq.org serves testnet (quick start, networks.md, the Action): left for the launch docs pass.testnet-forge.dashhq.orgmust be live before adgrelease that includes this change ships.Tests
Run on a boat.dev sandbox with toolchain 1.98.0:
cargo fmt --checkandcargo clippy --all-targets -D warningspassed for forge-core, dg, git-remote-dash, forge-relay and forge-import. Incargo test --no-fail-fastfor those crates, everything passed except three tests that depend on git's fsck behaviour:build_pack_fsck::history_no_clone_takes_is_refused_before_it_is_storedand twogit::tests::*malformed_idents*. The sandbox has git 2.43, and this PR doesn't touch that code.🤖 Generated with Claude Code