deploy: continuous deployment for the forge, HQ and apps (KSE-0221) #509
Loading…
Reference in a new issue
No description provided.
Delete branch "continuous-deployment"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Founder direction (2026-11-16): "work on auto deploying: builds for app, forge builds, etc. all need continuous deployment". The trigger was #506: the queue merged it at 07:13 UTC and nothing deployed the forge or HQ until 17:17. Design of record:
evolution/proposals/KSE-0221-continuous-deployment.md, which has the full inventory, decision table, flags, rollout and rollback.What changes
KEYSTORE_CD_FORGEisplanorswitch. It defaults tooff, so merging this changes nothing. Manual dispatch keeps its founder gate. It also gets a newhqinput (skip, plan or switch), so the founder can deploy HQ after the forge from the same dispatch.Scripts/deploy/continuous-deploy.shruns on the forge in the transient deploy unit. It uses the same/run/key-store-forge-host-deploy.lockas the manual path, and a persistent clone instead of a 200 MB clone per run.docs/,evolution/, top-level*.md).prompts/,org/,records/andnotes/are deliberately not treated as prose.switch-to-configurationon it, which is whatnixos-rebuild switchdoes. Then it verifies the dispatcher.key-store-meta-cd-halted. A second rule,key-store-meta-cd-stuck, fires when a host stays blocked or failed for 2 hours. The script never writes a barrier and never rolls back on its own; the previous closure is recorded asrollback_closure.deploy-hq, behindKEYSTORE_CD_HQ). It runs in its own forge-side unit under/run/key-store-hq-deploy.lockand deploys withScripts/hq-deploy.sh --switch.KEYSTORE_CD_APPS=offpauses the automatic runs without editing a workflow. Promotion to production stays a human decision.Findings (details in KSE-0221 §2)
forgejo, both Authentik containers and its provisioners,redmine, the office gateway, and more, because these units embed paths built from the whole flake source. This is the mechanism behind "Authentik bounces on every switch". The 30-minute minimum interval and the prose skip limit the churn; the real fix is a follow-up.HOME. Through theApple/Externalgitlink, the same commit evaluates to a different closure from a login shell than inside a systemd unit. Closures are therefore compared inside the deploy unit.build-releasesucceeded 9 of 23 times in the last 14 days. Sparkle main, the F-Droid repo, CWSDEFAULT_PUBLISHand AMOlistedalready go past internal tracks today; that existing policy is left unchanged and flagged for the founder.Tests
bazel test //bazel/deploy:cd_plan_test //bazel/deploy:continuous_deploy_testpasses on the forge in the ci-classifier shell. The first covers the planner's decision table (26 cases). The second is an offline dry run of the orchestrator (23 scenarios) covering coalescing, every skip and block, the halt latch, profile restore when activation is refused, HQ ordering, and halt/resume plus metrics. Both are added to Check: Workflows.Scripts/ci/workflow-yaml-guard.shis clean. actionlint shows only the known Forgejo-onlyenable-openid-connectnotice. Every shell script embedded in the workflows passesbash -n.nix evalsucceeds for the keystore-forge and keystore-hq toplevels. The generated forge-meta alerting YAML builds and parses (13 rules).planrun inside a systemd unit, using scratch lock and state directories: it coalesced to the newest main, and the forge and HQ both came outunchanged (closure-identical)against what had just been deployed.Rollout
Merge, then a founder forge switch to install the alert rules. Then set
KEYSTORE_CD_FORGE=planandKEYSTORE_CD_HQ=planfor a day, thenKEYSTORE_CD_FORGE=switch. SetKEYSTORE_CD_HQ=switchonce HQ's disk is below 93%. To turn it off, set the flag back tooff. To pause a host, runcontinuous-deploy.sh pause forge|hq "<why>".🤖 Generated with Claude Code
Manager-seat technical review of #509 at exact head
a6b9376658(basea897390718, merge-base == base, mergeable true). I read the full unified diff (1895 lines, 5 pages) plus the grafana rule-template default (escalate ? true) at this head. CI at review time: 17 contexts, 15 pending / 1 success / 1 skipped — verdict published without waiting for CI per no-deferral; the merge queue still gates on green CI.Scope is Tier 2 (deploy-forge-host.yml push/schedule triggers, nixos grafana forge-meta module, OpenBao-adjacent check). Required seats per policy: manager (this verdict), infra, devex, security-agent (OpenBao secrets path). The queue has already requested infra and security-agent; devex seat still needed for the workflow/test changes.
What I verified firsthand:
No blocking findings. Non-blocking notes for the author: (1) the hourly schedule tick costs one runner + SSH session per hour even with no merges — accepted in design, just naming it; (2) take_lock waits up to 90 min against a 120-min job timeout — bounded, fine.
APPROVED for the manager seat at this exact head. Still required before merge: infra, devex, security-agent verdicts + green CI at the current head, then queue merge. Checks I did not run: the two new Bazel tests and nix eval were inspected as CI-covered (author reports forge-local green); I did not re-execute them here.
DevEx-seat technical review of #509 at exact head
a6b9376658(basea897390718, merge-base == base, mergeable true). Tier 2; my scope is the CI-workflow changes, pipeline safety, shared-CI hygiene and automation entrypoints. I read the full unified diff (1895 lines, 5 pages). CI at review time: 16 pending / 1 success / 1 skipped — this verdict is published without waiting for CI per the no-deferral rule; the merge queue still gates on green exact-head CI.What I verified firsthand (worktree at
a6b93766, FETCH_HEAD == head):git verify-commitreports Good git signature for forge@key.store with the tracked ED25519 key (SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ).bash -nclean on Scripts/deploy/continuous-deploy.sh, bazel/deploy/continuous_deploy_test.sh, bazel/deploy/cd_plan_test.sh; all three added/changed Python files parse.python3 -B bazel/deploy/cd_plan_test.py→ 26 tests, OK.bash bazel/deploy/continuous_deploy_test.sh→ all 23 fixture scenarios pass (coalescing, every skip/block, halt latch, profile restore on refused activation, HQ ordering, halt/resume + metrics).bash Scripts/ci/workflow-yaml-guard.shon the three changed workflow files → clean, no duplicate mapping keys.concurrency: cancel-in-progress: falseon deploy-forge-host (queued runs wait; no tick cancels a running deploy), and both new tests are added to the Check: Workflows Bazel invocation with Scripts/deploy/** + bazel/deploy/** path filters — shared-CI hygiene is correct.DevEx verdict: APPROVED. Fail-safe directions are right (prose skip needs ancestor + non-empty diff; unknown disk does not block; eval/secrets failures block; failed build latches nothing and retries; failed activation/verification latches and pages; never a barrier, never auto-rollback), and the serialization (Forgejo queue + shared host lock + KEYSTORE_CD_LOCK_HELD anti-deadlock + 90-min lock-wait exit-0) is sound.
Noted dependencies, not merge blockers:
pushtriggers, and thatschedule: cron "23 * * * *"is honored by this Forgejo instance (hourly tick is the backstop).git clean -ffdxthe forge bootstrap has; harmless with the persistent CD-only clone, suggested for symmetry.Security-seat technical review of #509 at exact head
a6b9376658(basea897390718, merge-base == base, mergeable true). I read the full unified diff (1895 lines, 5 pages) plus the KSE-0221 proposal, the commit_status snapshot, and the manager (8837) and devex (8838) exact-head APPROVED bodies. CI at review time: complete:true, 13 success / 1 skipped / 4 pending (Apple macOS/iOS/visionOS + review-policy Tier 2 awaiting infra, security-agent — devex APPROVED after that snapshot). Published without waiting for CI per no-deferral; the queue still gates on green exact-head CI. Scope: the OpenBao secrets path, auth boundaries, injection surfaces, and fail-safe directions of the new CD pipeline.What I verified firsthand:
git verify-commit a6b93766→ Good "git" signature for forge@key.store, ED25519 SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ (tracked signer, KSE-0001).del). The login token is revoked in a finally. Login/read failures map toerror→ plannerblocked(openbao-secrets-unverifiable / openbao-secrets-missing), never to deploy. Fail-closed. The base64 spec in argv carries address/mount/paths only — no secret material — and the process runs as root on the host anyway.shais regex-validated ^[0-9a-f]{40}before use; `forge_state` is regex-validated ^[a-z-]*elseunknown;hq_modeis case-validated;run_keyis${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-${short_sha}(numeric + 12-hex, workflow line 174) — safe in the systemd unit name. Remote args are single-quoted intobash -s --and quoted at use.failed, no latch, retried); failed/refused activation or failed verification → halt latch + page, boot profile restored when nothing activated; never a barrier write, never auto-rollback, rollback_closure recorded. HQ only follows adeployed/unchangedforge.bash -nand the workflow YAML guard.No blocking findings. Non-blocking notes: (1)
revoke-selffailure is swallowed — acceptable for a short-lived jwt token, named only; (2) the beyond-internal publish policy (Sparkle main, F-Droid repo, CWS DEFAULT_PUBLISH, AMO listed) is pre-existing and unchanged here, already flagged for the founder in §3.6; (3) StrictHostKeyChecking=accept-new toward git.key.store continues the manual path's existing TOFU pattern; (4) agree with devex that the HQ clone's missinggit clean -ffdxis harmless (CD-dedicated clone).APPROVED for the security-agent seat at this exact head. Still required before merge: infra verdict + green CI at the current head + COO-final, then queue merge. Head/base move voids this verdict.
Infra-seat technical review of #509 at exact head
a6b93766(basea8973907, merge-base == base, mergeable true, single commita6b93766on top of main —git verify-commit: Good, forge@key.store ED25519 SHA256:gNOsvO0KOu7TaSWOBwDwGBwsiExR7kauwDr9O2+IswJQ).I read the full unified diff firsthand (1895 lines, 4 pages: both workflow files, BUILD files,
cd_plan.py,continuous-deploy.sh,openbao_declared_secrets_check.py, both Bazel tests, KSE-0221 proposal, grafanadefault.nix) plus the file list (13 files, +1641/-9). CI is still running at this head (manager observed 15 pending / 1 success / 1 skipped); per no-deferral this verdict publishes without waiting — the merge queue still gates on green exact-head CI.Tier-2 (deploy-forge-host.yml push/schedule triggers, NixOS grafana forge-meta module, OpenBao-adjacent secret check, CI workflows). Required seats: manager (APPROVED, observed), infra (this verdict), devex, security-agent (secret-check path).
What I verified firsthand:
KEYSTORE_CD_FORGE/HQdefaultoffwith a job-levelifgate and a main-only gate for auto triggers; merging changes nothing until flags are set.KEYSTORE_CD_APPSdefaultson= current behavior preserved;offonly pauses ticks. Manual founder dispatch path unchanged (founder-switch gate intact).cmd_forgebuilds first (failed build =failed, no latch, retried), recordsdry-activate.txt, sets the profile then switches exactly the built closure, restores the boot profile when nothing activated, and latcheshalton any non-zero activation rc — with a dedicatedswitch-rc4dry-run scenario asserting the latch. Post-switch Zulip/inbox surface failure also latches (workflow step). Never a writer barrier, never a runtime drop-in, never auto-rollback;rollback_closurerecorded in state./run/key-store-forge-host-deploy.lockas the manual path (no split-brain),flock -w 5400with exit-0 handoff, persistent shared clone checked out under the lock, newest-main coalescing with per-runrun_sharecorded.HOMEis unset for eval parity (theApple/Externalclosure-skew mechanism from KSE-0221 §3.3).cd_plan.py(disabled → busy → halted → barriers → eval → unchanged/prose → disk → secrets → interval → plan → deploy) matches the proposal table;prompts//org//records//notes/deliberately not prose; failed-activation retry is not skipped asunchanged(candidate != current+boot after a refused switch retries asdeploy). Disk defaults 90/93 sane vs HQ at 91%.finally. Values never logged.key-store-continuous-deploy.promwithhaltedgauge per target backing the two new Grafana rules. New rule uidskey-store-meta-cd-halted/key-store-meta-cd-stuckare fresh identifiers (list elements in Nix, no YAML-key collision class as in #126);haltedis critical withkey_store_escalation=human,stuckwarning 2h.cd_plan_test.pycovers the decision table (latch precedence, prose/ancestor rules, disk, secrets, HQ gating);continuous_deploy_test.shcovers deploy/coalesce/plan/off/busy/unchanged/prose/barrier/deferred/disk/secrets/rc4-latch/profile-restore/verify-fail/HQ paths plus halt/resume metric flips.Residuum for other seats / rollout (not blockers for merge): devex owns the workflow/test verdict; security-agent owns the OpenBao-adjacent check verdict. At enablement time (separate founder action, not this PR): start
planfirst per §5, and note the firstplanrun reportsdeployonce for a head deployed by hand from a login shell (HOME skew). Today's #263 rc=4 root cause is still open on #263 — enablingswitchshould wait for that diagnosis plus one green manual deploy at the then-current main.APPROVED (infra seat) at exact head
a6b93766.