Repository navigation
feat(edge): route the shared hostname to production or to an opted-in target, decided by Flagship - #211
Merged
Conversation
… target, decided by Flagship Stage PR C of #195 (ADR-0111): `crates/thrust-edge`, the Worker that will own thrust.sow.foo. - A request without a valid pin goes to production through the service binding THRUST, without asking Flagship, so production never depends on the routing. - A pinned request reaches a Worker Preview of thrust only when three things hold: Flagship's `routing` is on, the alias (if any) resolves, and the target's flag serves the pin's kind and audience. - Even then the URL must be `https://<label>-<worker>.<sub>.workers.dev`. A flag can never send traffic to another host. - Any error at any step means production. The decisions are plain modules, built and tested natively: - pin: the opt-in cookie `__Host-thrust_edge`, v1.<payload>.<HMAC-SHA256>. The shape is checked first, then the MAC (constant time) before any JSON is parsed, then the strict fields (no unknown field, each in its grammar) and expiry. Time is injected. - access: the Access token on an opt-in path. RS256 only (none, HS256 keyed with the public key, RS512 and `crit` are refused before any key is used), the key by kid, then iss, aud (the path's own Access app), exp and nbf. An `email` claim is a person; otherwise `common_name` is CI. JWKS parsing keeps only RSA-2048..4096 signing keys. - route: the rule above; flag keys `alias-<name>` and `target-<name>` (Flagship allows no `.`, so `.` becomes `_`, one to one). Request scrubbing drops a client's cf-access-* headers, Cloudflare-Workers-Version-* overrides and X-Forwarded-*, and its CF_Authorization and pin cookies. - forward: the upstream URL is the target's base plus the request's path and query, never the client's host. The response loses every `Set-Cookie: CF_Authorization` (Access sets it on the Preview's answer; passed on it would be stored for the shared host), a Location naming the Preview host is rewritten to the shared origin, and x-thrust-route says where the request went. - runtime (wasm32 only): the glue research/0016 proved live, plus two things: - the opt-in endpoints `/_edge/opt-in/<audience>` (a pin is issued only for a target the rules route this principal to now), `/_edge/opt-out` and `/_edge/whoami`; - production stays reachable when the edge's own vars or secrets are missing; only `/_edge/*` then answers 503. The proven glue is Flagship through extern method imports, `redirect: manual`, a fetched 101 handed back with its WebSocket, and the JWKS fetched and cached per isolate. Tests, all generated except named spec examples and pinned shapes: - the plan's exhaustive matrix: cookie absent/valid/forged/expired x routing on/off x target allowed/denied/missing x client headers clean/spoofed. Only valid+on+allowed reaches a target, and nothing spoofed reaches an upstream; - alias, flag-error and kind matrices; - properties: pin round trip, tampering and forgery, the Access validity window with its boundaries weighted in, any changed token byte, arbitrary text never accepted, grammars against an independent spec, flag keys against a reference, scrubbing, response headers, upstream host; - two fuzz harnesses (`pin_open`, `access_verify`), with committed seeds replayed by `fuzz_replay_` tests, a must-fail control, and a manual control that removing the seeds turns the replay red. cargo-mutants 27.1.0 on pin, access, route and forward: 192 mutants, 184 caught, 0 missed, 8 unviable. The first run missed 15. Each was fixed through behaviour, not aimed at the mutant: inclusive size limits, exact refusal reasons for signed values in the wrong shape, an invalid common_name, the spec flag keys, the Preview host, misconfigured suffixes, and an invalid alias that has a live flag. `Jwks::is_empty` was removed (a Jwks is never empty), and `parse_target` no longer re-checks a name `decide` already validated. Also: - `crates/thrust-edge/wrangler.deploy.toml`, rendered by scripts/render-wrangler.sh: six new variables and the kinds uuid, hex64 and accessteam; the relations AUD_RC != AUD_DEV and edge name != worker name apply only where their markers are. Self-test 91/91, also with every shell being dash. - `scripts/check-edge-config.sh`, a new guard in CI's deps job: an allowlist of tables and top-level keys, workers_dev and preview_urls false, exactly one service and one Flagship binding. Its self-test has 17 fixtures. - A wasm32 clippy step for the edge in the lint job; plan-ci.py classifies the new guard. - release-plz lists the crate. - deny.toml names the edge in the RUSTSEC-2023-0071 note. It only verifies with public keys. - `cfg(fuzzing)` is declared, as cargo-fuzz sets it. - Docs: testing gap G-41 (the wasm-only runtime has no automated test; no fuzz campaign has run), and the fuzz page names the first targets. Not verified here: - the runtime against Workers, beyond the spike's live proof of its plumbing; - the Access JWT from a human login; - fuzz campaigns (cargo-fuzz and nightly are not installed). A `wrangler deploy --dry-run` of the rendered template validated both bindings and every variable (683 KiB, 236 KiB gzip). Refs: #195 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two additive conflicts with #201: .github/scripts/plan-ci.py now classifies both check-migration-lint.sh and check-edge-config.sh as deps guards, and docs/src/testing/status.md keeps G-40 (the migration ledger) before G-41 (the edge Worker). Refs: #195 Co-Authored-By: Claude Opus 5.5 <[email protected]>
One conflict in .github/scripts/plan-ci.py: main added the docs job's check-book.sh rule beside the deps guards. Both kept; check-edge-config.sh stays a deps guard. #212's crate-path rules need nothing here: the edge reads no file outside its crate, and its fuzz crate is not a workspace member. Refs: #195 Co-Authored-By: Claude Opus 5.5 <[email protected]>
aRustyDev
added a commit
that referenced
this pull request
Nov 16, 2026
… 3) (#221) * chore: move every crate into its ADR-0009 directory, renames only Each of the 19 workspace members moves with git mv, and nothing else changes in this commit, so review and git log --follow see 359 renames at 100 % similarity. Package names do not change. adapters/{cloudflare,memory,oidc,postgres,selfhosted} api/core (thrust-api), api/v1, api/compat-plane, api/plane-types core/ports, core/types (thrust-contracts), core/usecases (thrust-core) editor/doc, spikes/editor-worker testing/suites/api (thrust-contract-tests), testing/fixtures/oracle (thrust-oracle-fixture) edge, server, worker thrust-edge (#211) arrived after the plan was written. ADR-0009 had already reserved crates/edge/ for it. The workspace does not build at this commit: the next one edits the paths that name these directories. Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore: point every path at the crates' ADR-0009 directories The previous commit moved the crates; this one edits what names their directories, so the workspace builds again. - Root Cargo.toml: members and [workspace.dependencies]. Since PR 2 (#212) it is the only manifest that names a crate's directory. - crates/spikes/editor-worker/wrangler.toml calls ../../../scripts/rs: it is the one crate now three levels down that climbs out with a relative path. The worker's and the edge's configs stay at ../../ (depth 2). - Every other file that wrote crates/thrust-<x>: CI actions and workflows, the deploy and check scripts, the probes, tools/compat-record, tools/spike-0006, the docs. Matched on a whole name, so thrust-api never matched inside thrust-api-v1. Also the comments and docs that wrote a crate path without crates/ (thrust-core/tests/operator.rs): they now name the real path. - The ones that fail silently when missed: deploy.yml's paths filter (crates/worker/wrangler.deploy.toml), .cargo/mutants.toml's exclude globs (the contract suite, the edge's runtime.rs) and .gitignore. - check-deps.sh: the proof-minting guard's literal paths, including the regex alternation that exempts the composition roots. - tools/measure-zxcvbn/patches: regenerated (applied to the moved tree, diffed, reverted). Their hunks are unchanged; their headers name crates/core/usecases, at today's line numbers. - test_plan_ci.py: ADR-0009's layout is now the default for the real graph and the flat one only the "before" of the check that moving a crate changes no plan. It also checks that this repository keeps REAL_GRAPH's crates where ADR_0009 says. - docs/src/contributing/crates.md: "Adding a crate" starts by choosing the group (or the top level, for a program); "Not part of the product graph" puts the editor Worker in spikes/ and says thrust-editor-doc is product code now, and adds crates/testing/. - ARCHITECTURE §2a redrawn from ADR-0009, with all 19 crates and the two planned ones (the M4 core API, the collab root). - The plan: thrust-edge's row in the mapping, the recount, the status. Not edited: .agents/plans/** other than the two above (dated records) and CHANGELOG.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(crates): a README for crates/ and for each group ADR-0009 rule 1: a directory under crates/ is a crate or a group, and a group has a README.md that names its members and says what belongs in it. One for crates/ (the groups, the programs and the names reserved for programs), and one each for adapters/, api/, core/, editor/, spikes/ (when a spike goes here and when in probes/) and testing/ (what goes there, and where each kind of test that is not a crate lives). The two groups inside testing/, suites/ and fixtures/, get short ones too, so the rule holds for every group and PR 4's guard can check it without an exception. plan-ci.py gives a group's README.md, inside no crate, no job. Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(editor-doc): describe the crate as what it is now, not as a spike Its description began "Spike 0006". The crate is product code now: thrust-api-v1 and thrust-compat-plane use its sanitiser, which is why ADR-0009 puts it in editor/ and only the spike's measurement Worker in spikes/. The description says that, and that it began as spike 0006. This is the only change to package metadata in PR 3; the cargo metadata comparison of the move ran before it. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
aRustyDev
added a commit
that referenced
this pull request
Nov 16, 2026
…se tag pattern, and check both ends (#222) release-pr has failed on main since #211: `cannot find package "thrust-edge" in workspace`. Every crate finds its previous version from the one tag v<version>; release-plz 0.4.3 then rebuilds that tag's workspace and looks the crate up in it (next_ver.rs, process_git_only_package), and thrust-edge is not in v0.2.0. A crate is treated as a first release only when no tag matches its pattern. - release-plz.toml: thrust-edge gets git_tag_name = "thrust-edge-v{{ version }}", which matches no tag. The header says why, and that the pattern goes once a release contains the crate. - check-release-plz.py: a git_tag_name may only be the entry's own first-release pattern, and never on the tagger. New --first-release, against the highest v<major>.<minor>.<patch> tag, comparing package names (a moved crate is not new): - `required`: every crate the tag lacks has its pattern. Run by ci.yml's deps job, whose checkout now fetches the tags. - `exact`: and no crate the tag has keeps one. Run by release-plz.yml's release-pr job before release-plz. It is not run in deps, where from the tag of a release to the pattern's removal it would fail every pull request, and main's run of the release commit. - cicd.md: "A new crate", and how it was verified. Verified with release-plz 0.4.3 on clones of main: - at #218: release-plz update exits 1 with the CI error on main's config; with this one it exits 0 and proposes 0.2.1 with #211's feature in the changelog. The candidate's Cargo.lock passes cargo metadata --locked. A first release's own commits do not set the bump (a feature alone proposed the patch). - at #221 (every crate moved, ADR-0009): the same error on main's config. With this one, exit 0 and nothing to propose: release-plz counts a crate's commits by its current directory, so #211's feature (made under crates/thrust-edge) no longer counts and the move is a chore. #211's feature reaches a changelog only through a release made by hand. - then a fix(edge) commit proposes 0.2.1. With v0.2.1 tagged and a second fix: with the pattern kept, 0.2.2's section lists the first fix (and the move) again, and --first-release exact refuses it; with it removed, only the second fix, and exact passes. - on this repository: --first-release required refuses main's release-plz.toml (thrust-edge only: the moved crates are found in v0.2.0 by name) and passes with this one; exact passes. - test_check_release_plz.py: 151 passed, over generated git histories for every crate. Nine hand mutants of the checker (name-order or pre-release tags as the last release, exact never or always refusing, any pattern value accepted, the tagger's pattern allowed, no tag passing, crates compared by directory, a patterned crate still required) each fail it. - lint-all-workflows.sh, actionlint, test-lint-all-workflows.sh, test-lint-workflow.sh, test-required-contexts.sh and test_plan_ci.py (5013) pass. Not verified: actions/checkout with fetch-tags at depth 1 on the runner. Its source at the pinned commit adds +refs/tags/*:refs/tags/* to the fetch; this pull request's deps job is the check. Refs: #195 Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage PR C of #195 (ADR-0111):
crates/thrust-edge, the Worker that will ownthrust.sow.foo. Nothing is deployedby this PR; the pipeline that deploys it is a later stage.
What it does
Production is the default.
THRUSTservice binding, and Flagship is notcalled.
/_edge/*then answers 503.A pinned request reaches a Preview only when all of these hold:
routingflag is on;What the edge does to every request:
cf-access-*andCloudflare-Workers-Version-*headers, itsX-Forwarded-Host/-Proto, theCF_Authorizationcookie and the pin cookie itself.redirect: manualand the Access service token, rewrites aLocationthatnames the Preview host, drops Access's
Set-Cookie: CF_Authorization, passes WebSocket upgrades through, and addsx-thrust-route. These are the spike's findings (research/0016).Opt-in endpoints:
/_edge/opt-in/<audience>?target=…verifies the Access token: RS256 against the team's keys, withaudperaudience,
iss, andexp/nbf. It then sets an HMAC-SHA256 pin (12 h for a person, 1 h for CI), but only for atarget that would route this principal now; otherwise 403.
/_edge/opt-outand/_edge/whoami(which shows only the caller's own pin).Flagship is called through
#[wasm_bindgen] externmethod imports, the only form that works from workers-rs.Layout
src/pin.rs,src/access.rs,src/route.rs,src/forward.rs.src/runtime.rs, excluded from native mutation testing.crates/thrust-edge/wrangler.deploy.toml, rendered byscripts/render-wrangler.sh, whichnow takes a template path. It has no data binding,
workers_dev = false,preview_urls = false, no route (theinfrastructure repository attaches the domain), and one AUD variable per audience (
rc,dev).scripts/check-edge-config.shruns in the deps job, with a must-fail self-test of 17 fixtures.check-topology.shstill checks only thrust-worker's configurations.plan-ci.pyclassifies the new files.fuzz/has two targets (the cookie and the token) and committed seeds.deny.tomlnotes RUSTSEC-2023-0071 for the edge, which only verifies with public keys.docs/src/testing/status.mdgets G-41.Tests (local)
cargo nextest run -p thrust-edgecargo nextest run --profile ci --workspacecargo fmt --all --check,cargo deny --locked checkrender-wrangler.sh --self-testtest_plan_ci.py(4890), the touched ci-scripts tests under dashExhaustive matrix: pin cookie absent/valid/forged/expired ×
routingon/off × target allowed/denied/missing ×client headers clean/spoofed. Only a valid pin with
routingon and the target allowed reaches a target, and spoofedheaders never reach it.
prop_tests: the pin round-trips and every tampering is refused. The Access verifier refuses a wrongaud, awrong
iss, an expired token, one not yet valid, a wrong key,alg: noneand HS256.Mutation testing on pin, access, route and forward: 192 mutants, 184 caught, 0 missed, 8 unviable. The first run
missed 15; each was killed through observable behaviour. Two pieces of code no test could reach were removed.
Fuzz seeds: they replay. Removing a seed directory turns the replay red.
Bundle:
worker-build --releasegives 658 KB of wasm (233 KB gzipped). Awrangler deploy --dry-runof therendered template validated its bindings.
Not verified
The live spike exercised these paths with its own edge; this code first runs with the deploy stage.
Refs #195
🤖 Generated with Claude Code