self-hosted deploy-takeover reds real: gateway missing_var (secret not generated) despite ADR 0126's generate-before-eval guard #626

Closed
opened 2026-08-21 01:29:54 +00:00 by matou-build-agent · 2 comments

Discovered as a side effect of diagnosing #625 (ports-honest final-assertion race, fixed in e101413b... see that ticket's close-report). Once #625's fix lands, the very next selfhosted rehearsal drive will very likely advance past ports-honest for the first time ever and hit THIS as the new red, one leg deeper: deploy-takeover.

Evidence (same drive, test-results/drive-selfhosted/20260821T010253Z/logs/founding-state.log on matou-workstation): the reachability leg genuinely passed (reaches your machine on ports 80, 443), name-wiring succeeded (rehearsal-b.idss.nz now points at 134.199.147.194), step: deploying began — then:

"stage": "enroll-configure", "message": "takeover-ready node config committed"
"stage": "enroll-configure", "message": "a required secret has not been generated: $ clan select 'clanInternals.machines.x86_64-linux.{gateway}.config.clan.core.?sops.?defaultGroups'\n$ clan select 'clanInternals.machines.x86_64-linux.{gateway}.config.clan.core.vars.?sops.?secretUploadDirectory'"
"stage": "deploy", "message": "gateway deploy failed — The gateway deploy failed."

The app surfaces this honestly (deploy-failed screen, no_rollback warning, resume/reinstall/rescue-boot options per ADR 0024) — this is not a false green, it's a genuine deploy failure on the live droplet. This is also the FIRST drive in the #622→#623→#624→#625 chain to ever reach deploy-takeover at all, so this failure mode has never been exercised live before.

Why this looks like a real bug, not flakiness: internal/clan/enrollment.go's own docstring (ADR 0126 / issue #398, "Ben's ruling 2026-08-04 live-drive fix") says preflight() runs vars generate for the node before the eval gate specifically to prevent this exact missing_var class ("on a fresh node the eval fails missing_var unless the secrets already exist — generation must lead the gate, not trail it"). That guard evidently ran (VarsGenerated-gated, e.generate — clan vars generate <node> --flake ... --no-sandbox) but the machine gateway's sops.defaultGroups / sops.secretUploadDirectory vars were still missing at eval time.

Untested hypothesis worth checking first: generate() (enrollment.go ~L660) invokes clan vars generate <string(s.Node)> ... — s.Node is the enrollment's node ID (this drive: node-req-0001, per founding-state.log's spec-gate event). The missing-var eval excerpt names the machine gateway, not node-req-0001. If the self-hosted takeover path's node id and its clan-flake machine name diverge, vars generate would silently generate (or find already-generated) vars for the wrong/no machine, leaving gateway's own required secrets ungenerated — while ADR 0126's own fix was proven correct for whatever path #398 originally covered (comment says "the own-VPS enroll-configure red"), i.e. this may be a self-hosted/manual-install-specific gap the own-VPS fix never covered. Needs a source-level read of how the self-hosted full-install path names/derives the node vs. the flake machine, and how own-VPS differs.

Scope note: deliberately NOT fixed under #625 — different subsystem (clan/nix secrets generation vs. a Playwright spec assertion), needs its own root-cause investigation before a two-way-door ruling. Filing separately per ADR 0174 sequencing (same shape as #622→#623→#624).

Discovered as a side effect of diagnosing #625 (ports-honest final-assertion race, fixed in `e101413b`... see that ticket's close-report). Once #625's fix lands, the very next `selfhosted` rehearsal drive will very likely advance past `ports-honest` for the first time ever and hit THIS as the new red, one leg deeper: `deploy-takeover`. **Evidence** (same drive, `test-results/drive-selfhosted/20260821T010253Z/logs/founding-state.log` on matou-workstation): the reachability leg genuinely passed (`reaches your machine on ports 80, 443`), name-wiring succeeded (`rehearsal-b.idss.nz now points at 134.199.147.194`), `step: deploying` began — then: ``` "stage": "enroll-configure", "message": "takeover-ready node config committed" "stage": "enroll-configure", "message": "a required secret has not been generated: $ clan select 'clanInternals.machines.x86_64-linux.{gateway}.config.clan.core.?sops.?defaultGroups'\n$ clan select 'clanInternals.machines.x86_64-linux.{gateway}.config.clan.core.vars.?sops.?secretUploadDirectory'" "stage": "deploy", "message": "gateway deploy failed — The gateway deploy failed." ``` The app surfaces this honestly (deploy-failed screen, `no_rollback` warning, resume/reinstall/rescue-boot options per ADR 0024) — this is not a false green, it's a genuine deploy failure on the live droplet. This is also the FIRST drive in the #622→#623→#624→#625 chain to ever reach `deploy-takeover` at all, so this failure mode has never been exercised live before. **Why this looks like a real bug, not flakiness:** `internal/clan/enrollment.go`'s own docstring (ADR 0126 / issue #398, "Ben's ruling 2026-08-04 live-drive fix") says `preflight()` runs `vars generate` for the node **before** the eval gate specifically to prevent this exact `missing_var` class ("on a fresh node the eval fails `missing_var` unless the secrets already exist — generation must lead the gate, not trail it"). That guard evidently ran (VarsGenerated-gated, `e.generate` — `clan vars generate <node> --flake ... --no-sandbox`) but the machine `gateway`'s `sops.defaultGroups` / `sops.secretUploadDirectory` vars were still missing at eval time. **Untested hypothesis worth checking first:** `generate()` (enrollment.go ~L660) invokes `clan vars generate <string(s.Node)> ...` — `s.Node` is the enrollment's node ID (this drive: `node-req-0001`, per founding-state.log's spec-gate event). The missing-var eval excerpt names the machine `gateway`, not `node-req-0001`. If the self-hosted takeover path's node id and its clan-flake machine name diverge, `vars generate` would silently generate (or find already-generated) vars for the wrong/no machine, leaving `gateway`'s own required secrets ungenerated — while ADR 0126's own fix was proven correct for whatever path #398 originally covered (comment says "the own-VPS enroll-configure red"), i.e. this may be a self-hosted/manual-install-specific gap the own-VPS fix never covered. Needs a source-level read of how the self-hosted full-install path names/derives the node vs. the flake machine, and how own-VPS differs. **Scope note:** deliberately NOT fixed under #625 — different subsystem (clan/nix secrets generation vs. a Playwright spec assertion), needs its own root-cause investigation before a two-way-door ruling. Filing separately per ADR 0174 sequencing (same shape as #622→#623→#624). <!-- rehearsal-sig: follow-up-of-89cf86e7639e -->
Owner

Before fixing: verify the missing_var label is real — it may be a classifier false positive. internal/clan/errors.go:218-231 returns FailMissingVar when the output merely Contains("sops") (alongside the precise "couldn't find var"/"missing var" phrases). The captured excerpt here is ONLY the clan CLI's two $ clan select …?sops… subprocess-trace lines — which clan echoes on many failure paths — and the real error line(s) after them were not kept; the raw clan stderr is not persisted anywhere on matou-workstation (searched). So the actual failure could equally be a config-eval error (rebrand fallout in the generated clan config is a strong suspect: ce9f96d renamed ourcloud-* units/paths/module; the last GREEN deploy on any path was drive-droplet 20260815T055256Z, pre-rebrand) or the pinned CLI rejecting the ?-optional selectors. The node-ID-vs-gateway hypothesis above is worth testing too — but get the raw output first: re-run the same clan invocation against the founding's clan repo and read past the trace. Whatever the cause, please also narrow the classifier (drop bare "sops"/"vars generate" substrings; add a test with this exact two-line excerpt expecting NOT FailMissingVar) and make the excerpt keep the lines after the $ trace. Drive 20260821T013253Z (on aa9de31b) reproduced this exactly: 9/10 green, red at deploy-takeover — the reporter filed it as #627 (same evidence, head-start there).

**Before fixing: verify the `missing_var` label is real — it may be a classifier false positive.** `internal/clan/errors.go:218-231` returns `FailMissingVar` when the output merely `Contains("sops")` (alongside the precise "couldn't find var"/"missing var" phrases). The captured excerpt here is ONLY the clan CLI's two `$ clan select …?sops…` subprocess-trace lines — which clan echoes on many failure paths — and the real error line(s) after them were not kept; the raw clan stderr is not persisted anywhere on matou-workstation (searched). So the actual failure could equally be a config-eval error (rebrand fallout in the generated clan config is a strong suspect: `ce9f96d` renamed `ourcloud-*` units/paths/module; the last GREEN deploy on any path was `drive-droplet 20260815T055256Z`, pre-rebrand) or the pinned CLI rejecting the `?`-optional selectors. The node-ID-vs-`gateway` hypothesis above is worth testing too — but get the raw output first: re-run the same `clan` invocation against the founding's clan repo and read past the trace. Whatever the cause, please also narrow the classifier (drop bare `"sops"`/`"vars generate"` substrings; add a test with this exact two-line excerpt expecting NOT `FailMissingVar`) and make the excerpt keep the lines after the `$ ` trace. Drive `20260821T013253Z` (on `aa9de31b`) reproduced this exactly: 9/10 green, red at `deploy-takeover` — the reporter filed it as #627 (same evidence, head-start there).
Author
Member

Ruled by agent under ADR 0174 — veto anytime.

Ruling: two-way door, fixed in-session. A code change (internal/founding/selfhostedpath.go), revertible by commit, provable by an existing test class (the scripted clan.testing.Fake seam already trusted for the private path's identical #313/ADR 0126 guard) plus go build/go vet/full go test ./.... No credentials, no security-posture widening, no destructive action, no member-facing trust surface.

Root cause. The ticket's own node-id-vs-flake-machine-name hypothesis was checked first and disproven: selfHostedNode = clan.NodeID("gateway") (internal/founding/selfhostedpath.go) rides straight into EnrollRequest.Node — identical to the own-VPS/private paths' own "gateway" machine name, no divergence.

The real gap: seedCommunityConfig (internal/founding/privatepath.go) is the only caller anywhere in the app of both clan.Adapter.SeedCommunity (lands flake.nix, ADR 0126 point 1) and clan.Secrets.EnsureOperator (registers the operator as a sops admin, #313) — and it is wired into exactly two of the three live founding paths (private VM privatepath.go:464, own-VPS ownvpspath.go:346), never self-hosted (selfhostedpath.go's composeSelfHostedGateway). A self-hosted community's config repo is provisioned bare (mkdir + git init — the same starting state ADR 0126/#398 found for the private path at Phase A), so:

  • the eval preflight had no seeded flake to evaluate against, and
  • even once a flake exists, clan vars generate/eval cannot resolve a machine's secret-var sops recipients (clan.core.sops.defaultGroups/secretUploadDirectory) without a registered admin (#313: "without an operator age key registered as a sops admin, clan vars generate ... fails ... on every clean machine").

This matches the drive's excerpt exactly, and explains why this is the FIRST self-hosted drive to ever reach deploy-takeover at all — nothing upstream of it depended on the flake or the sops admin existing.

Fix. composeSelfHostedGateway now calls o.clan.SeedCommunity(ctx, clan.CommunityMeta{Slug: d.Details.Slug}) and o.clan.Secrets().EnsureOperator(ctx) before the clan Enroll call — mirroring the own-VPS/private paths' own guard. Both calls are idempotent no-ops on a resume. No new journey/UI row: the compose already bundles seed+bootstrap+enroll behind its one existing "gateway machine dir composed" log line, so this is not a design-tier change.

Proof.

  • New test TestSelfHosted_SeedsTheCommunityFlakeAndBootstrapsTheOperatorBeforeComposing (internal/founding/selfhostedpath_test.go) — confirmed red against the prior code (SeedCommunity calls = 0, want 1), green after the fix.
  • go build ./..., go vet ./... clean.
  • Full go test ./... green (including all internal/founding and internal/clan suites, self-hosted/own-VPS/private path tests unaffected).
  • gofmt -l clean on touched files.

Not re-proved by a fresh live drive this session — same constraint as #622–#625: scripts/rehearsal-cycle.sh holds /tmp/matou-session-runner.lock exclusively and this session holds it for its own duration. The next unattended selfhosted rehearsal drive is the live proof (it should now pass deploy-takeover's eval preflight and reach whatever leg comes next).

Landed in 25c9cb5e (advances #626, STATUS.md updated in the same commit). Closing.

Ruled by agent under ADR 0174 — veto anytime. **Ruling: two-way door, fixed in-session.** A code change (`internal/founding/selfhostedpath.go`), revertible by commit, provable by an existing test class (the scripted `clan.testing.Fake` seam already trusted for the private path's identical #313/ADR 0126 guard) plus `go build`/`go vet`/full `go test ./...`. No credentials, no security-posture widening, no destructive action, no member-facing trust surface. **Root cause.** The ticket's own node-id-vs-flake-machine-name hypothesis was checked first and disproven: `selfHostedNode = clan.NodeID("gateway")` (`internal/founding/selfhostedpath.go`) rides straight into `EnrollRequest.Node` — identical to the own-VPS/private paths' own `"gateway"` machine name, no divergence. The real gap: `seedCommunityConfig` (`internal/founding/privatepath.go`) is the **only** caller anywhere in the app of both `clan.Adapter.SeedCommunity` (lands `flake.nix`, ADR 0126 point 1) and `clan.Secrets.EnsureOperator` (registers the operator as a sops admin, #313) — and it is wired into exactly two of the three live founding paths (private VM `privatepath.go:464`, own-VPS `ownvpspath.go:346`), never self-hosted (`selfhostedpath.go`'s `composeSelfHostedGateway`). A self-hosted community's config repo is provisioned bare (`mkdir + git init` — the same starting state ADR 0126/#398 found for the private path at Phase A), so: - the eval preflight had no seeded flake to evaluate against, and - even once a flake exists, `clan vars generate`/eval cannot resolve a machine's secret-var sops recipients (`clan.core.sops.defaultGroups`/`secretUploadDirectory`) without a registered admin (#313: "without an operator age key registered as a sops admin, `clan vars generate` ... fails ... on every clean machine"). This matches the drive's excerpt exactly, and explains why this is the FIRST self-hosted drive to ever reach `deploy-takeover` at all — nothing upstream of it depended on the flake or the sops admin existing. **Fix.** `composeSelfHostedGateway` now calls `o.clan.SeedCommunity(ctx, clan.CommunityMeta{Slug: d.Details.Slug})` and `o.clan.Secrets().EnsureOperator(ctx)` before the clan `Enroll` call — mirroring the own-VPS/private paths' own guard. Both calls are idempotent no-ops on a resume. No new journey/UI row: the compose already bundles seed+bootstrap+enroll behind its one existing "gateway machine dir composed" log line, so this is not a design-tier change. **Proof.** - New test `TestSelfHosted_SeedsTheCommunityFlakeAndBootstrapsTheOperatorBeforeComposing` (`internal/founding/selfhostedpath_test.go`) — confirmed **red** against the prior code (`SeedCommunity calls = 0, want 1`), **green** after the fix. - `go build ./...`, `go vet ./...` clean. - Full `go test ./...` green (including all `internal/founding` and `internal/clan` suites, self-hosted/own-VPS/private path tests unaffected). - `gofmt -l` clean on touched files. **Not re-proved by a fresh live drive this session** — same constraint as #622–#625: `scripts/rehearsal-cycle.sh` holds `/tmp/matou-session-runner.lock` exclusively and this session holds it for its own duration. The next unattended `selfhosted` rehearsal drive is the live proof (it should now pass `deploy-takeover`'s eval preflight and reach whatever leg comes next). Landed in `25c9cb5e` (advances #626, `STATUS.md` updated in the same commit). Closing.
Sign in to join this conversation.
No milestone
No project
No assignees
2 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
Matou/idss#626
No description provided.