deploy: continuous deployment for the forge, HQ and apps (KSE-0221) #509

Merged
merge-queue merged 1 commit from continuous-deployment into main 2026-11-16 18:42:28 +00:00
Owner

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

  • Deploy: Forge Host now also runs on every main push and on an hourly tick (minute 23). The automatic runs are skipped unless the repo variable KEYSTORE_CD_FORGE is plan or switch. It defaults to off, so merging this changes nothing. Manual dispatch keeps its founder gate. It also gets a new hq input (skip, plan or switch), so the founder can deploy HQ after the forge from the same dispatch.
  • Scripts/deploy/continuous-deploy.sh runs on the forge in the transient deploy unit. It uses the same /run/key-store-forge-host-deploy.lock as the manual path, and a persistent clone instead of a 200 MB clone per run.
    • Coalescing: it deploys the newest main at the time it gets the lock. Merges that land during a deploy collapse into one switch.
    • Skips: it skips when the running and boot closures already equal the candidate. It also skips when every changed path is prose (docs/, evolution/, top-level *.md). prompts/, org/, records/ and notes/ are deliberately not treated as prose.
    • Guards: it refuses while someone else's guarded-maintenance barrier is up, when the root disk is at or above the limit (forge 90%, the Loki WAL threshold; HQ 93%), when the candidate fails to evaluate, or when a newly declared OpenBao secret has no value. The secret check runs on the target host with the host's jwt login and prints names only. Automatic switches are spaced at least 30 minutes apart by default.
    • Activation: it builds first, so a failed build never touches the host and is retried on the next run. It records the dry-activate plan, then sets the profile to the built closure and runs switch-to-configuration on it, which is what nixos-rebuild switch does. Then it verifies the dispatcher.
    • Failure: a failed activation (rc=4 included), a failed dispatcher check, or a failed Zulip/inbox check sets a halt latch. That pages through the new forge-meta rule 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 as rollback_closure.
  • HQ follows a forge that ended deployed or unchanged (job deploy-hq, behind KEYSTORE_CD_HQ). It runs in its own forge-side unit under /run/key-store-hq-deploy.lock and deploys with Scripts/hq-deploy.sh --switch.
  • Apps already reach the internal tracks continuously (release-if-needed → build-release → Play internal, TestFlight internal, Developer ID/Sparkle, F-Droid, Flatpak beta, App Installer, Chrome Web Store, AMO). New: KEYSTORE_CD_APPS=off pauses the automatic runs without editing a workflow. Promotion to production stays a human decision.

Findings (details in KSE-0221 §2)

  • Every forge switch restarts services even when the commit changes nothing for them. A no-op commit restarts 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.
  • Evaluation depends on HOME. Through the Apple/External gitlink, 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.
  • HQ's root disk is at 91%. build-release succeeded 9 of 23 times in the last 14 days. Sparkle main, the F-Droid repo, CWS DEFAULT_PUBLISH and AMO listed already 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_test passes 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.sh is clean. actionlint shows only the known Forgejo-only enable-openid-connect notice. Every shell script embedded in the workflows passes bash -n.
  • nix eval succeeds for the keystore-forge and keystore-hq toplevels. The generated forge-meta alerting YAML builds and parses (13 rules).
  • Read-only live plan run inside a systemd unit, using scratch lock and state directories: it coalesced to the newest main, and the forge and HQ both came out unchanged (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=plan and KEYSTORE_CD_HQ=plan for a day, then KEYSTORE_CD_FORGE=switch. Set KEYSTORE_CD_HQ=switch once HQ's disk is below 93%. To turn it off, set the flag back to off. To pause a host, run continuous-deploy.sh pause forge|hq "<why>".

🤖 Generated with Claude Code

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 - **Deploy: Forge Host** now also runs on every main push and on an hourly tick (minute 23). The automatic runs are skipped unless the repo variable `KEYSTORE_CD_FORGE` is `plan` or `switch`. It defaults to `off`, so merging this changes nothing. Manual dispatch keeps its founder gate. It also gets a new `hq` input (skip, plan or switch), so the founder can deploy HQ after the forge from the same dispatch. - **`Scripts/deploy/continuous-deploy.sh`** runs on the forge in the transient deploy unit. It uses the same `/run/key-store-forge-host-deploy.lock` as the manual path, and a persistent clone instead of a 200 MB clone per run. - **Coalescing:** it deploys the newest main at the time it gets the lock. Merges that land during a deploy collapse into one switch. - **Skips:** it skips when the running and boot closures already equal the candidate. It also skips when every changed path is prose (`docs/`, `evolution/`, top-level `*.md`). `prompts/`, `org/`, `records/` and `notes/` are deliberately not treated as prose. - **Guards:** it refuses while someone else's guarded-maintenance barrier is up, when the root disk is at or above the limit (forge 90%, the Loki WAL threshold; HQ 93%), when the candidate fails to evaluate, or when a newly declared OpenBao secret has no value. The secret check runs on the target host with the host's jwt login and prints names only. Automatic switches are spaced at least 30 minutes apart by default. - **Activation:** it builds first, so a failed build never touches the host and is retried on the next run. It records the dry-activate plan, then sets the profile to the built closure and runs `switch-to-configuration` on it, which is what `nixos-rebuild switch` does. Then it verifies the dispatcher. - **Failure:** a failed activation (rc=4 included), a failed dispatcher check, or a failed Zulip/inbox check sets a halt latch. That pages through the new forge-meta rule `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 as `rollback_closure`. - **HQ** follows a forge that ended deployed or unchanged (job `deploy-hq`, behind `KEYSTORE_CD_HQ`). It runs in its own forge-side unit under `/run/key-store-hq-deploy.lock` and deploys with `Scripts/hq-deploy.sh --switch`. - **Apps** already reach the internal tracks continuously (release-if-needed → build-release → Play internal, TestFlight internal, Developer ID/Sparkle, F-Droid, Flatpak beta, App Installer, Chrome Web Store, AMO). New: `KEYSTORE_CD_APPS=off` pauses the automatic runs without editing a workflow. Promotion to production stays a human decision. ## Findings (details in KSE-0221 §2) - **Every forge switch restarts services even when the commit changes nothing for them.** A no-op commit restarts `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. - **Evaluation depends on `HOME`.** Through the `Apple/External` gitlink, 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. - HQ's root disk is at 91%. `build-release` succeeded 9 of 23 times in the last 14 days. Sparkle main, the F-Droid repo, CWS `DEFAULT_PUBLISH` and AMO `listed` already 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_test` passes 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.sh` is clean. actionlint shows only the known Forgejo-only `enable-openid-connect` notice. Every shell script embedded in the workflows passes `bash -n`. - `nix eval` succeeds for the keystore-forge and keystore-hq toplevels. The generated forge-meta alerting YAML builds and parses (13 rules). - Read-only live `plan` run inside a systemd unit, using scratch lock and state directories: it coalesced to the newest main, and the forge and HQ both came out `unchanged (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=plan` and `KEYSTORE_CD_HQ=plan` for a day, then `KEYSTORE_CD_FORGE=switch`. Set `KEYSTORE_CD_HQ=switch` once HQ's disk is below 93%. To turn it off, set the flag back to `off`. To pause a host, run `continuous-deploy.sh pause forge|hq "<why>"`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
deploy: continuous deployment for the forge, HQ and apps (KSE-0221)
Some checks failed
key.store/merge-queue merged by the key.store merge queue
Deploy: Forge Host / Deploy (Forge Host) (push) Has been skipped
Deploy: Forge Host / Deploy (HQ Host) (push) Has been skipped
Namespace: Build Images / Refresh macOS runner lane (push) Successful in 4s
Deploy: Web / Evaluate deploy impact (push) Successful in 6s
Deploy: API / Evaluate deploy impact (push) Successful in 6s
Release: If Needed / Check (Release Needed) (push) Successful in 9s
Check: MCP Hub / Check (MCP Hub bun suite) (push) Successful in 23s
Check: Workflows / Check (CI performance contracts) (push) Successful in 1m32s
Build: Apple / Classify (Apple inputs) (push) Successful in 35s
Check: Redmine / Check (Redmine conditional writes) (push) Successful in 20s
Check: GoAlert / Check (GoAlert effective configuration and native fixture) (push) Successful in 41s
Build: Snap / Build (Snap arm64) (push) Successful in 3m32s
Build: Windows / Build (Windows) (push) Successful in 3m15s
Build: Apple / Build (visionOS) (push) Successful in 3m54s
Namespace: Build Images / Refresh macOS Nix snapshot application (push) Failing after 11m59s
Build: Apple / Build (iOS) (push) Successful in 3m34s
Namespace: Build Images / Refresh Flatpak image (arm64) (push) Successful in 6m42s
Namespace: Build Images / Refresh Flatpak image (amd64) (push) Successful in 6m41s
Build: sqlite3mc / sqlite3mc smoke (macOS) (push) Successful in 42s
Check: Workflows / Check (deploy-impact classifier) (push) Successful in 27s
Namespace: Build Images / Refresh Linux runner image (push) Successful in 2m25s
Check: Workflows / Check (Workflow YAML) (push) Successful in 35s
Check: Agent Dispatcher / Check (Dispatcher Bazel integration) (push) Successful in 2m29s
Build: Apple / Check (SwiftLint) (push) Successful in 13s
Build: sqlite3mc / sqlite3mc smoke (Linux x86_64) (push) Successful in 1m25s
Deploy: API / Deploy (API) (push) Successful in 2m32s
Deploy: Web / Deploy (Web) (push) Successful in 2m34s
Build: Apple / Build (macOS) (push) Successful in 1m51s
Build: Snap / Build (Snap amd64) (push) Successful in 2m36s
a6b9376658
The merge queue merged #506 at 07:13 UTC and nothing deployed the forge or
HQ until 17:17. Deploy: Forge Host now also runs on every main push and an
hourly tick, behind KEYSTORE_CD_FORGE (off|plan|switch, default off), and HQ
follows a good forge behind KEYSTORE_CD_HQ.

Scripts/deploy/continuous-deploy.sh runs on the forge in the transient deploy
unit under the existing forge deploy lock and a persistent clone:
- coalesces: deploys the newest main at lock time, so merges that land during
  a deploy collapse into one switch;
- skips when the candidate is the running and boot closure, or when every path
  since the deployed revision is prose (docs/, evolution/, top-level *.md);
- blocks on a foreign guarded-maintenance barrier, a root disk at the limit,
  a failed eval, or a newly declared OpenBao secret without a value (names
  only, host jwt login), and spaces automatic switches (30 min default);
- builds first (a failed build never touches the host), records the
  dry-activate plan, activates exactly the built closure, verifies the
  dispatcher; a failed activation or verification sets a halt latch that
  pages via the new forge-meta rules key-store-meta-cd-halted/-stuck.
  It never writes a barrier and never auto-rolls back.

Decisions live in Scripts/deploy/cd_plan.py with a decision-table test and an
offline dry-run of the orchestrator (//bazel/deploy). Apps were already
continuous to internal tracks via release-if-needed; KEYSTORE_CD_APPS=off now
pauses that without a workflow edit.

Findings recorded in the KSE: every forge switch restarts Forgejo, Authentik
and Redmine even for a no-op commit (units embed the whole flake source), and
flake evaluation depends on HOME (the Apple/External gitlink), so closures
are compared in the deploy unit environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
manager approved these changes 2026-11-16 18:26:57 +00:00
manager left a comment

Manager-seat technical review of #509 at exact head a6b9376658 (base a897390718, 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:

  • Default-off: KEYSTORE_CD_FORGE/HQ default off, KEYSTORE_CD_APPS defaults on (current behavior preserved). Merging changes nothing until flags are set. Manual dispatch path keeps the founder-switch gate (CD_MODE bypass only for non-dispatch events; Gate Continuous Deploy enforces main-only).
  • Fail-safe directions: prose-only regexes fail toward deploy on unknown paths; prompts/org/records/notes deliberately excluded. Secrets check (openbao_declared_secrets_check.py) runs on the target host with the host jwt, prints names only, revokes the token, and any login/read error maps to blocked, never to deploy. Coalescing deploys newest main, which itself passed queue CI. Lock contention exits 0. Build-first: failed build records failed with no latch; failed activation/verification latches (halt) and pages via key-store-meta-cd-halted, with no barrier writes and no auto-rollback (rollback_closure recorded).
  • HQ ordering: deploy-hq requires forge deployed/unchanged (planned forge lets HQ only plan); manual path without hq input cannot reach the run block (job-level if). Empty forge_state falls through to forge-not-deployed block. Safe.
  • Alert rules inherit key_store_escalation=human from the rule-template default (escalate ? true), matching KSE-0221 §3.4; for=1m/2h as documented.
  • Tests: 26-case planner table (bazel/deploy/cd_plan_test.py) and 23-scenario fixture dry-run (continuous_deploy_test.sh) both wired into Check: Workflows path filters.

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.

Manager-seat technical review of #509 at exact head a6b93766583c0946d744b36ceabe97fa7a86c589 (base a897390718a6f7ffc46cfd750aa1e3c983459bd6, 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: - Default-off: KEYSTORE_CD_FORGE/HQ default off, KEYSTORE_CD_APPS defaults on (current behavior preserved). Merging changes nothing until flags are set. Manual dispatch path keeps the founder-switch gate (CD_MODE bypass only for non-dispatch events; Gate Continuous Deploy enforces main-only). - Fail-safe directions: prose-only regexes fail toward deploy on unknown paths; prompts/org/records/notes deliberately excluded. Secrets check (openbao_declared_secrets_check.py) runs on the target host with the host jwt, prints names only, revokes the token, and any login/read error maps to blocked, never to deploy. Coalescing deploys newest main, which itself passed queue CI. Lock contention exits 0. Build-first: failed build records failed with no latch; failed activation/verification latches (halt) and pages via key-store-meta-cd-halted, with no barrier writes and no auto-rollback (rollback_closure recorded). - HQ ordering: deploy-hq requires forge deployed/unchanged (planned forge lets HQ only plan); manual path without hq input cannot reach the run block (job-level if). Empty forge_state falls through to forge-not-deployed block. Safe. - Alert rules inherit key_store_escalation=human from the rule-template default (escalate ? true), matching KSE-0221 §3.4; for=1m/2h as documented. - Tests: 26-case planner table (bazel/deploy/cd_plan_test.py) and 23-scenario fixture dry-run (continuous_deploy_test.sh) both wired into Check: Workflows path filters. 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 approved these changes 2026-11-16 18:28:15 +00:00
devex left a comment

DevEx-seat technical review of #509 at exact head a6b9376658 (base a897390718, 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):

  • Provenance: git verify-commit reports Good git signature for forge@key.store with the tracked ED25519 key (SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ).
  • bash -n clean 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.
  • Planner decision table: python3 -B bazel/deploy/cd_plan_test.py → 26 tests, OK.
  • Orchestrator dry-run: 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.sh on the three changed workflow files → clean, no duplicate mapping keys.
  • concurrency: cancel-in-progress: false on 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.
  • Manual dispatch path is untouched when CD_MODE is empty; automatic runs fail closed (Gate Continuous Deploy exits 1 unless flag is plan|switch and ref is main); merge changes nothing (KEYSTORE_CD_FORGE/HQ default off, KEYSTORE_CD_APPS defaults on = current behavior).

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:

  1. Enablement is gated on #263: continuous deploys reuse the same transient-unit host path whose Queue Host Deploy step failed on 19th main (run 33051). Rollout step 2 (founder manual switch installing the alert rules) cannot succeed until the infra-owned host cause is fixed.
  2. Infra should confirm the feature's core signal: that merge-queue fast-forward pushes to main fire push triggers, and that schedule: cron "23 * * * *" is honored by this Forgejo instance (hourly tick is the backstop).
  3. Minor: the HQ bootstrap lacks the git clean -ffdx the forge bootstrap has; harmless with the persistent CD-only clone, suggested for symmetry.
  4. HQ root disk was 91% vs the 93% default limit — thin margin; the rollout already gates HQ switch on dropping below 93%.
DevEx-seat technical review of #509 at exact head a6b93766583c0946d744b36ceabe97fa7a86c589 (base a897390718a6f7ffc46cfd750aa1e3c983459bd6, 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): - Provenance: `git verify-commit` reports Good git signature for forge@key.store with the tracked ED25519 key (SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ). - `bash -n` clean 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. - Planner decision table: `python3 -B bazel/deploy/cd_plan_test.py` → 26 tests, OK. - Orchestrator dry-run: `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.sh` on the three changed workflow files → clean, no duplicate mapping keys. - `concurrency: cancel-in-progress: false` on 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. - Manual dispatch path is untouched when CD_MODE is empty; automatic runs fail closed (Gate Continuous Deploy exits 1 unless flag is plan|switch and ref is main); merge changes nothing (KEYSTORE_CD_FORGE/HQ default off, KEYSTORE_CD_APPS defaults on = current behavior). 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: 1. Enablement is gated on #263: continuous deploys reuse the same transient-unit host path whose Queue Host Deploy step failed on 19th main (run 33051). Rollout step 2 (founder manual switch installing the alert rules) cannot succeed until the infra-owned host cause is fixed. 2. Infra should confirm the feature's core signal: that merge-queue fast-forward pushes to main fire `push` triggers, and that `schedule: cron "23 * * * *"` is honored by this Forgejo instance (hourly tick is the backstop). 3. Minor: the HQ bootstrap lacks the `git clean -ffdx` the forge bootstrap has; harmless with the persistent CD-only clone, suggested for symmetry. 4. HQ root disk was 91% vs the 93% default limit — thin margin; the rollout already gates HQ switch on dropping below 93%.
security-agent left a comment

Security-seat technical review of #509 at exact head a6b9376658 (base a897390718, 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:

  • Provenance: git verify-commit a6b93766 → Good "git" signature for forge@key.store, ED25519 SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ (tracked signer, KSE-0001).
  • Secrets check (openbao_declared_secrets_check.py, 104 lines, all read): runs on the target host with the host's own subject-token jwt login — same trust as the materializer, no new credential. Only secrets whose materialised file does not exist are read; existing secrets are untouched. Output is names-only; the value body is tested for non-empty value_base64 and dropped (del). The login token is revoked in a finally. Login/read failures map to error → planner blocked (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.
  • Auth boundary: automatic runs are authorised by the admin-set repository variable plus the main-only gate (Gate Continuous Deploy exits 1 otherwise); the founder-switch gate is preserved for manual dispatch (CD_MODE empty for dispatch events). Merging changes nothing (KEYSTORE_CD_FORGE/HQ default off; KEYSTORE_CD_APPS defaults on = current behavior).
  • Injection: HQ-path sha is regex-validated ^[0-9a-f]{40} before use; `forge_state` is regex-validated ^[a-z-]* else unknown; hq_mode is case-validated; run_key is ${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 into bash -s -- and quoted at use.
  • Serialization/safety: shared per-host lock with the manual path, KEYSTORE_CD_LOCK_HELD anti-deadlock, 90-min lock-wait exit-0, coalescing deploys the newest main — which only the merge queue can move, after green CI. Build-first (failed build → 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 a deployed/unchanged forge.
  • Alert rules: expressions reference the exact metric names the planner writer emits; severity/page path inherits the template default (manager-verified), matching KSE-0221 §3.4.
  • Tests inspected (not re-run): devex firsthand ran the 26-case planner table (OK) and all 23 fixture dry-run scenarios (pass) at this head, plus bash -n and the workflow YAML guard.

No blocking findings. Non-blocking notes: (1) revoke-self failure 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 missing git clean -ffdx is 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.

Security-seat technical review of #509 at exact head a6b93766583c0946d744b36ceabe97fa7a86c589 (base a897390718a6f7ffc46cfd750aa1e3c983459bd6, 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: - Provenance: `git verify-commit a6b93766` → Good "git" signature for forge@key.store, ED25519 SHA256:gNOsvO0KOu7TaSWOBDwGBwsiExR7kauwDr9O2+IswJQ (tracked signer, KSE-0001). - Secrets check (openbao_declared_secrets_check.py, 104 lines, all read): runs on the target host with the host's own subject-token jwt login — same trust as the materializer, no new credential. Only secrets whose materialised file does not exist are read; existing secrets are untouched. Output is names-only; the value body is tested for non-empty value_base64 and dropped (`del`). The login token is revoked in a finally. Login/read failures map to `error` → planner `blocked` (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. - Auth boundary: automatic runs are authorised by the admin-set repository variable plus the main-only gate (Gate Continuous Deploy exits 1 otherwise); the founder-switch gate is preserved for manual dispatch (CD_MODE empty for dispatch events). Merging changes nothing (KEYSTORE_CD_FORGE/HQ default off; KEYSTORE_CD_APPS defaults on = current behavior). - Injection: HQ-path `sha` is regex-validated ^[0-9a-f]{40}$ before use; `forge_state` is regex-validated ^[a-z-]*$ else `unknown`; `hq_mode` is case-validated; `run_key` is `${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 into `bash -s --` and quoted at use. - Serialization/safety: shared per-host lock with the manual path, KEYSTORE_CD_LOCK_HELD anti-deadlock, 90-min lock-wait exit-0, coalescing deploys the newest main — which only the merge queue can move, after green CI. Build-first (failed build → `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 a `deployed`/`unchanged` forge. - Alert rules: expressions reference the exact metric names the planner writer emits; severity/page path inherits the template default (manager-verified), matching KSE-0221 §3.4. - Tests inspected (not re-run): devex firsthand ran the 26-case planner table (OK) and all 23 fixture dry-run scenarios (pass) at this head, plus `bash -n` and the workflow YAML guard. No blocking findings. Non-blocking notes: (1) `revoke-self` failure 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 missing `git clean -ffdx` is 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 approved these changes 2026-11-16 18:30:04 +00:00
infra left a comment

Infra-seat technical review of #509 at exact head a6b93766 (base a8973907, merge-base == base, mergeable true, single commit a6b93766 on 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, grafana default.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:

  • Default-off: KEYSTORE_CD_FORGE/HQ default off with a job-level if gate and a main-only gate for auto triggers; merging changes nothing until flags are set. KEYSTORE_CD_APPS defaults on = current behavior preserved; off only pauses ticks. Manual founder dispatch path unchanged (founder-switch gate intact).
  • Today's #263 failure mode is handled by design: cmd_forge builds first (failed build = failed, no latch, retried), records dry-activate.txt, sets the profile then switches exactly the built closure, restores the boot profile when nothing activated, and latches halt on any non-zero activation rc — with a dedicated switch-rc4 dry-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_closure recorded in state.
  • Locking/coalescing: same /run/key-store-forge-host-deploy.lock as the manual path (no split-brain), flock -w 5400 with exit-0 handoff, persistent shared clone checked out under the lock, newest-main coalescing with per-run run_sha recorded. HOME is unset for eval parity (the Apple/External closure-skew mechanism from KSE-0221 §3.3).
  • Decision order in 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 as unchanged (candidate != current+boot after a refused switch retries as deploy). Disk defaults 90/93 sane vs HQ at 91%.
  • Secrets check reads only not-yet-materialised secrets with the host's own jwt, prints names only, revokes its token in finally. Values never logged.
  • Metrics: textfile key-store-continuous-deploy.prom with halted gauge per target backing the two new Grafana rules. New rule uids key-store-meta-cd-halted / key-store-meta-cd-stuck are fresh identifiers (list elements in Nix, no YAML-key collision class as in #126); halted is critical with key_store_escalation=human, stuck warning 2h.
  • Tests: cd_plan_test.py covers the decision table (latch precedence, prose/ancestor rules, disk, secrets, HQ gating); continuous_deploy_test.sh covers 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 plan first per §5, and note the first plan run reports deploy once for a head deployed by hand from a login shell (HOME skew). Today's #263 rc=4 root cause is still open on #263 — enabling switch should wait for that diagnosis plus one green manual deploy at the then-current main.

APPROVED (infra seat) at exact head a6b93766.

Infra-seat technical review of #509 at exact head `a6b93766` (base `a8973907`, merge-base == base, mergeable true, single commit `a6b93766` on 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, grafana `default.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: - Default-off: `KEYSTORE_CD_FORGE`/`HQ` default `off` with a job-level `if` gate and a main-only gate for auto triggers; merging changes nothing until flags are set. `KEYSTORE_CD_APPS` defaults `on` = current behavior preserved; `off` only pauses ticks. Manual founder dispatch path unchanged (founder-switch gate intact). - Today's #263 failure mode is handled by design: `cmd_forge` builds first (failed build = `failed`, no latch, retried), records `dry-activate.txt`, sets the profile then switches exactly the built closure, restores the boot profile when nothing activated, and latches `halt` on any non-zero activation rc — with a dedicated `switch-rc4` dry-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_closure` recorded in state. - Locking/coalescing: same `/run/key-store-forge-host-deploy.lock` as the manual path (no split-brain), `flock -w 5400` with exit-0 handoff, persistent shared clone checked out under the lock, newest-main coalescing with per-run `run_sha` recorded. `HOME` is unset for eval parity (the `Apple/External` closure-skew mechanism from KSE-0221 §3.3). - Decision order in `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 as `unchanged` (candidate != current+boot after a refused switch retries as `deploy`). Disk defaults 90/93 sane vs HQ at 91%. - Secrets check reads only not-yet-materialised secrets with the host's own jwt, prints names only, revokes its token in `finally`. Values never logged. - Metrics: textfile `key-store-continuous-deploy.prom` with `halted` gauge per target backing the two new Grafana rules. New rule uids `key-store-meta-cd-halted` / `key-store-meta-cd-stuck` are fresh identifiers (list elements in Nix, no YAML-key collision class as in #126); `halted` is critical with `key_store_escalation=human`, `stuck` warning 2h. - Tests: `cd_plan_test.py` covers the decision table (latch precedence, prose/ancestor rules, disk, secrets, HQ gating); `continuous_deploy_test.sh` covers 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 `plan` first per §5, and note the first `plan` run reports `deploy` once for a head deployed by hand from a login shell (HOME skew). Today's #263 rc=4 root cause is still open on #263 — enabling `switch` should wait for that diagnosis plus one green manual deploy at the then-current main. APPROVED (infra seat) at exact head `a6b93766`.
merge-queue deleted branch continuous-deployment 2026-11-16 18:42:28 +00:00
Sign in to join this conversation.
No labels
No milestone
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
key-store/key.store!509
No description provided.