Repository navigation
feat(deploy): make every Flagship routing flag from a policy in the repository, and check the live app against it - #229
Merged
Conversation
…epository, and check the live app against it Stage D of #195 (ADR-0111): the flags the edge reads are made only by CI, from definitions in this repository. - .github/deploy/flagship/policy.json: - routing's value (off); - the audiences, dev and rc, which must be exactly the edge's ACCESS_AUD_<AUDIENCE> variables; - the aliases, prod and staging; - per kind of target, which principal kinds and audiences reach it: - release and rc: human and ci, through dev or rc; - dev: human and ci, through dev. It names no person. - scripts/flagship.py, the only writer: - validate: the policy alone, offline; - check [--evaluate] [--retries n]: every difference from the policy, every foreign flag, every value the edge would refuse, and (with --evaluate) what Flagship actually serves to every principal kind and audience; - sync: rewrites what differs, creates routing, deletes foreign flags, then re-reads and checks again; - put / alias / delete: for the deploys and teardowns of targets (stages E and F); each reads back what it wrote. A target flag: default `denied` ({}), `allowed` = {url, deployment, release, kind, data, expires}, one rule per policy entry with `kind in [...]` and `audience in [...]`. Values are held to the edge's own grammar (crates/edge/src/route.rs, pin.rs). The token comes only from the environment; the base URL must be https (or http to 127.0.0.1, for the fake). - .github/workflows/flagship.yml: sync on a push to main that changes the policy, the script or the workflow, and by hand; check --evaluate --retries 12 after it and nightly. Off until the repository variable FLAGSHIP_APP_ID is set; environment `flagship` with app-scoped Read and Write tokens. lint-all-workflows.sh allows its two jobs that environment. - ci.yml: `flagship.py validate` in deps; test_flagship.py in ci-scripts. plan-ci.py routes the policy and the script to deps and ci-scripts (test_plan_ci.py's samples follow). - cicd.md "Routing flags", status.md G-43, and a dated update to ADR-0111. Deviation from the plan: no live check on pull requests. A pull request has no secrets, and a policy change is meant to differ from what is live; it gets validate and the fake-backed tests, and the live check runs after every sync and nightly. Tests: test_flagship.py, 463 checks against flagship_fake.py, a stand-in built from the published OpenAPI schema (the fields, cursor pagination, AND/OR condition groups, evaluation as documented). The expected flags come from a model in the test, not from the script. It covers: - every target kind with several names; - every applicable change to every flag of a good app (check finds it; sync restores exactly that app and writes only that flag); - foreign flags; - every broken value and policy; - page sizes 1, 2, 3 and 200; - a service that ORs conditions (caught only with --evaluate); - propagation lag (fails without retries, passes with them); - both response shapes of evaluate; - every missing or malformed variable, and a wrong token; - the token in no output. 21 hand mutants of the script each fail it. Also passing: every deps step (13), every ci-scripts test (28) individually with sh as dash, actionlint, and the workflow linter with a control (without the allowance it refuses flagship.yml's environment and secrets). Not verified: the real Flagship API beyond what the spike exercised (G-43). Nothing runs live until the app exists. Refs: #195 Co-Authored-By: Claude Opus 5.5 <[email protected]>
aRustyDev
added a commit
that referenced
this pull request
Nov 16, 2026
… (stage 0.2) (#236) research/0018-gate-spike.md records what the spike (draft #232, closed) measured: five designs against seven scenarios, and eleven facts, in two identical samples. The choice is A+: every called workflow ends with a `verdict` job, and gate requires the callee's result to be success and its `verdict` output to be pass. It was right on all seven scenarios; the control (the calling job's result only) was wrong on three, the same without the output on one, and re-actors/alls-green on two. The measurements corrected the plan, and PLAN.md and phases/0001-foundation.md say so: - A calling job is success when at least one job inside it succeeded, even if a planned sibling was skipped; with nothing inside run it is skipped. The plan had said success when every job inside was skipped. - A callee's workflow-level concurrency deadlocks the run and starts no job (the group is built from the caller's name), and a permission its caller did not grant stops the run from starting, so no gate would report. - An if that cannot be evaluated skips the job without failing it. - actionlint refuses a broken call contract, but only inside a git repository. Also recorded: flagship.yml (#229) on the inventory, and the test-suites plan (#234), whose pull requests edit commands inside jobs that Phase 1 moves. Docs only: plan-ci.py plans no job for this diff. Co-authored-by: Claude Sonnet 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 D of #195 (ADR-0111). The Flagship flags the edge reads are made only by CI, from a policy in this repository.
Nothing runs live until the Flagship app exists.
What it adds
.github/deploy/flagship/policy.json, which names no person:routing(off);dev,rc), which must be exactly the edge'sACCESS_AUD_<AUDIENCE>variables;prod,staging);release,rchuman,cidev,rcdevhuman,cidevThese defaults are mine. Change them if they're not what you want.
scripts/flagship.py, the only writer:validate: checks the policy alone, offline. It runs indeps.check [--evaluate] [--retries n]: reports:With
--evaluate, it also asks Flagship what each flag serves to every principal kind and audience.sync: rewrites what differs, createsrouting, deletes foreign flags, then re-reads everything and checks again.put,alias,delete: for the deploys and teardowns of targets (stages E and F). Each reads back what it wrote.A target flag defaults to
denied({}). Itsallowedvalue is{url, deployment, release, kind, data, expires},and it has one rule per policy entry:
kind in [...]andaudience in [...], both of which must match. Values followthe edge's own grammar (
route.rs,pin.rs).Secrets: the token is read only from the environment, never from an argument. The base URL must be https (http only
to 127.0.0.1, for the test fake).
.github/workflows/flagship.yml:sync: on a push tomainthat changes the policy, the script or the workflow, and by hand.check --evaluate --retries 12: after a sync, and nightly at 05:23 UTC. It writes nothing, so a dashboard edit isreported, not silently overwritten.
FLAGSHIP_APP_IDis set.flagship.lint-all-workflows.shallows only its two jobs to use it.Wiring:
ci.yml:flagship.py validateindeps;test_flagship.pyinci-scripts.plan-ci.py: routes the policy and the script todepsandci-scripts. Its tests' samples follow.Docs:
cicd.mdgets a "Routing flags" section;status.mdgets G-43;One deviation from the plan
There is no live check on pull requests. A pull request has no secrets, and a policy change is meant to differ from
what is live. Pull requests get
validateand the tests against the fake; the live check runs after every sync andevery night.
To turn it on (after the infrastructure issue makes the app)
flagship, with deployment branches limited tomain.FLAGSHIP_WRITE_TOKENandFLAGSHIP_READ_TOKEN: app-scoped Write and Read tokens.CLOUDFLARE_ACCOUNT_IDandPREVIEW_HOST_SUFFIX(the edge's).FLAGSHIP_APP_ID.Tests
test_flagship.py: 463 checks, about 20 s, againstflagship_fake.py. The fake is built from the published OpenAPIschema: its fields, cursor pagination, AND/OR condition groups, and evaluation as documented. The expected flags come
from a model in the test, not from the script. It covers:
checkfinds each one, andsyncrestores exactly that app,writing only that flag;
--evaluatecatches;--retries, passes with them;Hand mutants: 21 versions of the script with a planted bug; each one makes the tests fail.
Also passing:
depsstep (13);ci-scriptstest (28), each run on its own withshas dash;flagship.yml's environment and secrets.Not verified
It did not exercise the list endpoint, a two-condition rule or the evaluate endpoint. The first
flagship.ymlrun'scheck --evaluateis the check.mdbook-mermaidisn't installed here; thedocsjob builds it.Refs #195
🤖 Generated with Claude Code