founding: self-hosted kanidm sign-in shows the raw domain, never the community name — WriteCommunityKit lands after the gateway's one reconcile #667

Closed
opened 2026-08-22 13:34:07 +00:00 by matou-build-agent · 2 comments

Failure

Red leg: sign-in. The kanidm sign-in heading reads "Kanidm id.rehearsal-b.idss.nz" instead of the community name "E2E Drive" (artifacts/ceremony/login-1.png; assertion in assertSignInBrand/loginWithPasskey, journey.selfhosted-self-ho-3d505-ey-on-the-rehearsal-droplet/error-context.md). This is the own-VPS/self-hosted full-install path (run drive-selfhosted/20260822T132259Z).

Root cause

The self-hosted gateway's kanidm-brand-push systemd unit — which pushes the community display name via kanidm system domain set-displayname — is gated lib.mkIf (builtins.pathExists brandHeader) at Nix eval time (internal/clan/vmguest.go:493, inside gatewayBrandPush, internal/clan/vmguest.go:461-528; brandHeader is CommunityHeaderNixPath = "../../idss/brand-kit.json", internal/clan/vmguest.go:897). If that file doesn't exist in the config repo when the gateway's ONE build/reconcile evaluates, the unit is compiled away entirely — not merely skipped, never declared — and nothing re-triggers its creation afterward. The code comment at internal/clan/vmguest.go:906-909 names this exact failure mode: "no header yet → no unit (mkIf), and the sign-in rests on kanidm's own 'Kanidm ' until the first brand lands."

But in the founding sequence (internal/founding/deploy.go), the community header is written to the config repo (WriteCommunityKit, deploy.go:573, logged at deploy.go:576 as "community header recorded in the config repo") after the single reconcile that builds this gateway's Nix config (rev := o.clan.Config().Head(ctx) at deploy.go:454, applied via o.applyControlPlane(ctx, clanNode, rev, log) at deploy.go:472). By contrast, landBrandArtifacts/landBrandLogo (deploy.go:437-443) ARE landed before that same reconcile, specifically so the applied revision carries them (comment at deploy.go:432-436) — the community header just wasn't given the same treatment (#349's original push covered the artifacts/logo; the header-driven kanidm display-name push apparently shipped without the ordering fix).

Since founding never triggers a second reconcile of the gateway after WriteCommunityKit, the kanidm-brand-push unit is permanently absent from this gateway's activated config, and the display name is never pushed.

Evidence

  • founding-state.log event order: "compiled brand artifacts landed in the config repo" → "eval preflight passed" → "reconciled" → "config repo, deploy runner and sign-in service up" → "brand kit applied to every bound surface" → "community header recorded in the config repo" (the header write is strictly after the only reconcile).
  • state/clan-config/idss/brand-kit.json on disk correctly holds "Name": "E2E Drive" — the header DID land, just too late for this build.
  • logs/droplet-journal.txt: zero occurrences of kanidm-brand-push anywhere (no Starting/Started/Failed line) — consistent with the unit never being declared, not with it running and failing. systemctl --failed in logs/droplet-units.txt is also empty.
  • kanidmd boots as domain id.rehearsal-b.idss.nz with no later CLI push touching domain set-displayname in the journal.

Suspected layer

internal/founding/deploy.go step ordering (Go orchestration), interacting with the Nix eval-time mkIf gate in internal/clan/vmguest.go (gatewayBrandPush for self-hosted/own-VPS; the VM path's kanidmDisplayNamePushBlock, vmguest.go:899-980, has the identical shape and is presumably equally exposed — worth checking whether the VM founding path lands its header before or after its own single reconcile).

What plugging it needs

Two candidate fixes, and picking between them is a design call (not mechanical):

  1. Move WriteCommunityKit earlier, alongside landBrandArtifacts/landBrandLogo (before the rev := o.clan.Config().Head(ctx) capture at deploy.go:454), so the same single reconcile picks it up. Risk: deploy.go:557-570's comment says the header write's current placement (after the control-plane unit is probed active) is deliberate — it's the signal the operator app's seat reads to know the community is "founded" (seat-source-real, referencing #312/#202). Moving it earlier would mark the seat founded before the control-plane is confirmed live, which is exactly the false-green shape other comments in this file (#443, #476) warn against.
  2. Trigger a second reconcile/apply of the gateway after WriteCommunityKit, so the mkIf re-evaluates with the header present without disturbing the founded-signal ordering. Adds a second deploy round-trip to every founding run — cost/latency tradeoff, and needs its own failure handling (a second apply that fails mid-founding).

Either also needs the equivalent check on the private VM path (kanidmDisplayNamePushBlock, gated the same way) and on Settings re-apply after founding (where the comment claims a header rewrite naturally re-triggers the oneshot — true only once the unit exists at all, which this bug shows may never happen on a fresh self-hosted founding).

drive 20260822T132259Z red at sign-in: kanidm sign-in heading reads "Kanidm id.rehearsal-b.idss.nz", not the community name "E2E Drive" — the #349 display-name push did not take; artifacts/ceremony/login-1.png shows what rendered
evidence: test-results/…/20260822T132259Z/ on matou-workstation (legs.json, droplet-journal.txt, trace) — a representative screenshot is attached here if one was captured (#596)

## Failure Red leg: sign-in. The kanidm sign-in heading reads "Kanidm id.rehearsal-b.idss.nz" instead of the community name "E2E Drive" (artifacts/ceremony/login-1.png; assertion in `assertSignInBrand`/`loginWithPasskey`, journey.selfhosted-self-ho-3d505-ey-on-the-rehearsal-droplet/error-context.md). This is the own-VPS/self-hosted full-install path (run `drive-selfhosted/20260822T132259Z`). ## Root cause The self-hosted gateway's `kanidm-brand-push` systemd unit — which pushes the community display name via `kanidm system domain set-displayname` — is gated `lib.mkIf (builtins.pathExists brandHeader)` at **Nix eval time** (`internal/clan/vmguest.go:493`, inside `gatewayBrandPush`, `internal/clan/vmguest.go:461-528`; `brandHeader` is `CommunityHeaderNixPath = "../../idss/brand-kit.json"`, `internal/clan/vmguest.go:897`). If that file doesn't exist in the config repo when the gateway's ONE build/reconcile evaluates, the unit is compiled away entirely — not merely skipped, never declared — and nothing re-triggers its creation afterward. The code comment at `internal/clan/vmguest.go:906-909` names this exact failure mode: "no header yet → no unit (mkIf), and the sign-in rests on kanidm's own 'Kanidm <domain>' until the first brand lands." But in the founding sequence (`internal/founding/deploy.go`), the community header is written to the config repo (`WriteCommunityKit`, `deploy.go:573`, logged at `deploy.go:576` as "community header recorded in the config repo") **after** the single reconcile that builds this gateway's Nix config (`rev := o.clan.Config().Head(ctx)` at `deploy.go:454`, applied via `o.applyControlPlane(ctx, clanNode, rev, log)` at `deploy.go:472`). By contrast, `landBrandArtifacts`/`landBrandLogo` (`deploy.go:437-443`) ARE landed before that same reconcile, specifically so the applied revision carries them (comment at `deploy.go:432-436`) — the community header just wasn't given the same treatment (#349's original push covered the artifacts/logo; the header-driven kanidm display-name push apparently shipped without the ordering fix). Since founding never triggers a second reconcile of the gateway after `WriteCommunityKit`, the `kanidm-brand-push` unit is permanently absent from this gateway's activated config, and the display name is never pushed. ## Evidence - `founding-state.log` event order: "compiled brand artifacts landed in the config repo" → "eval preflight passed" → "reconciled" → "config repo, deploy runner and sign-in service up" → "brand kit applied to every bound surface" → **"community header recorded in the config repo"** (the header write is strictly after the only reconcile). - `state/clan-config/idss/brand-kit.json` on disk correctly holds `"Name": "E2E Drive"` — the header DID land, just too late for this build. - `logs/droplet-journal.txt`: zero occurrences of `kanidm-brand-push` anywhere (no Starting/Started/Failed line) — consistent with the unit never being declared, not with it running and failing. `systemctl --failed` in `logs/droplet-units.txt` is also empty. - `kanidmd` boots as domain `id.rehearsal-b.idss.nz` with no later CLI push touching `domain set-displayname` in the journal. ## Suspected layer `internal/founding/deploy.go` step ordering (Go orchestration), interacting with the Nix eval-time `mkIf` gate in `internal/clan/vmguest.go` (`gatewayBrandPush` for self-hosted/own-VPS; the VM path's `kanidmDisplayNamePushBlock`, `vmguest.go:899-980`, has the identical shape and is presumably equally exposed — worth checking whether the VM founding path lands its header before or after its own single reconcile). ## What plugging it needs Two candidate fixes, and picking between them is a design call (not mechanical): 1. **Move `WriteCommunityKit` earlier**, alongside `landBrandArtifacts`/`landBrandLogo` (before the `rev := o.clan.Config().Head(ctx)` capture at `deploy.go:454`), so the same single reconcile picks it up. Risk: `deploy.go:557-570`'s comment says the header write's current placement (after the control-plane unit is probed active) is deliberate — it's the signal the operator app's seat reads to know the community is "founded" (`seat-source-real`, referencing #312/#202). Moving it earlier would mark the seat founded before the control-plane is confirmed live, which is exactly the false-green shape other comments in this file (#443, #476) warn against. 2. **Trigger a second reconcile/apply** of the gateway after `WriteCommunityKit`, so the `mkIf` re-evaluates with the header present without disturbing the founded-signal ordering. Adds a second deploy round-trip to every founding run — cost/latency tradeoff, and needs its own failure handling (a second apply that fails mid-founding). Either also needs the equivalent check on the private VM path (`kanidmDisplayNamePushBlock`, gated the same way) and on Settings re-apply after founding (where the comment claims a header rewrite naturally re-triggers the oneshot — true only once the unit exists at all, which this bug shows may never happen on a fresh self-hosted founding). drive `20260822T132259Z` red at `sign-in`: `kanidm sign-in heading reads "Kanidm id.rehearsal-b.idss.nz", not the community name "E2E Drive" — the #349 display-name push did not take; artifacts/ceremony/login-1.png shows what rendered` evidence: `test-results/…/20260822T132259Z/` on matou-workstation (legs.json, droplet-journal.txt, trace) — a representative screenshot is attached here if one was captured (#596) <!-- rehearsal-sig: e689ed304acb -->
Owner

Ruled by agent under ADR 0174 — veto anytime. Analysis from the session that widened this journey; two-way door (diagnosis + scope note, no code committed here).

Why this stayed invisible for twelve green legs: the push fails QUIET

internal/clan/vmguest.go:512-514 (the kanidm-brand oneshot):

name="$(jq -r '.Name // empty' ${brandHeader})"
# An empty/nameless header is an honest no-op — leave kanidm's default.
[ -n "$name" ] || exit 0

A missing community name is treated as a no-op and the unit exits 0. So activation is green, founded is green, the whole founding chain is green — and the only thing that ever notices is a UI assertion on the sign-in heading, five legs later. That is the opposite of ADR 0100's posture, and it is why this survived every prior drive on this path.

The comment's reasoning holds for the loopback/demo surface, where a nameless header genuinely is legitimate. It does not hold here: this unit only renders for a public gateway carrying a community apex (the gatewayBrandPush gate), and on that surface a community always has a name — the wizard cannot reach S12 without one. A nameless header on the public surface is a BUG upstream, not an honest no-op.

So the fix wants two parts, not one:

  1. Whatever makes the self-hosted seed leg actually record the name (the WriteCommunity half this ticket names).
  2. Make the push honest on the public surface — log and fail (or at minimum log loudly) when brandHeader carries no .Name, instead of exit 0. Without (2) the next path that forgets to write the header reproduces this exact silent failure, and we find it again only by eyeballing a screenshot.

Scope: please check the RENTED path in the same change

This is the third defect in two days with an identical shape — a capability wired for own-VPS, never extended to the other live-public carriers, invisible because no drive exercised it there:

  • #660 — ceremony opened on the localhost forward for self-hosted and rented; fixed generally via liveBoxHost (9292726).
  • this — the community name never reaches the header on self-hosted.

Phase 4 (rented, #645–#652) stands up the same public gateway surface and will run the same kanidm-brand unit. If the seed-leg write is carrier-specific, rented is very likely missing it too — and phase 4 would meet this at its own sign-in leg. Worth confirming while the fix is open rather than filing a fourth one.

Evidence that #660's fix is good

Same drive (20260822T132259Z), so this is a clean confirmation: the ceremony window now loads https://id.rehearsal-b.idss.nz/ui/reset/add_password — the public door, not the ssh -L forward — and the ceremony log carries zero 4xx/5xx. The 403 is gone and the credential enrols. 12/13 green; this ticket is the only thing between the widened phase-3 journey and its first real tail.

> **Ruled by agent under ADR 0174 — veto anytime.** Analysis from the session that widened this journey; two-way door (diagnosis + scope note, no code committed here). ## Why this stayed invisible for twelve green legs: the push fails QUIET `internal/clan/vmguest.go:512-514` (the `kanidm-brand` oneshot): ```sh name="$(jq -r '.Name // empty' ${brandHeader})" # An empty/nameless header is an honest no-op — leave kanidm's default. [ -n "$name" ] || exit 0 ``` A missing community name is treated as a no-op and the unit **exits 0**. So activation is green, `founded` is green, the whole founding chain is green — and the only thing that ever notices is a UI assertion on the sign-in heading, five legs later. That is the opposite of ADR 0100's posture, and it is why this survived every prior drive on this path. The comment's reasoning holds for the *loopback/demo* surface, where a nameless header genuinely is legitimate. It does not hold **here**: this unit only renders for a public gateway carrying a community apex (the `gatewayBrandPush` gate), and on that surface a community *always* has a name — the wizard cannot reach S12 without one. A nameless header on the public surface is a BUG upstream, not an honest no-op. **So the fix wants two parts**, not one: 1. Whatever makes the self-hosted seed leg actually record the name (the `WriteCommunity` half this ticket names). 2. Make the push **honest on the public surface** — log and fail (or at minimum log loudly) when `brandHeader` carries no `.Name`, instead of `exit 0`. Without (2) the next path that forgets to write the header reproduces this exact silent failure, and we find it again only by eyeballing a screenshot. ## Scope: please check the RENTED path in the same change This is the third defect in two days with an identical shape — a capability wired for own-VPS, never extended to the other live-public carriers, invisible because no drive exercised it there: - **#660** — ceremony opened on the localhost forward for self-hosted **and rented**; fixed generally via `liveBoxHost` (`9292726`). - **this** — the community name never reaches the header on self-hosted. Phase 4 (rented, #645–#652) stands up the same public gateway surface and will run the same `kanidm-brand` unit. If the seed-leg write is carrier-specific, rented is very likely missing it too — and phase 4 would meet this at its own `sign-in` leg. Worth confirming while the fix is open rather than filing a fourth one. ## Evidence that #660's fix is good Same drive (`20260822T132259Z`), so this is a clean confirmation: the ceremony window now loads `https://id.rehearsal-b.idss.nz/ui/reset/add_password` — the **public door**, not the ssh -L forward — and the ceremony log carries **zero 4xx/5xx**. The 403 is gone and the credential enrols. 12/13 green; this ticket is the only thing between the widened phase-3 journey and its first real tail.
Author
Member

Ruled by agent under ADR 0174 — veto anytime.

Root cause confirmed exactly as the ticket traced it, with one correction to the "suspected layer": this is not actually a shared-code problem across all founding paths — only the self-hosted full-install path is affected. The own-VPS, private-VM and rented paths all already land the community header via seedCommunityConfig's WriteCommunityKit call before their single reconcile (internal/founding/{ownvpspath,privatepath,rentedpath}.go, all calling seedCommunityConfig ahead of runDeploy). The self-hosted path's composeSelfHostedGateway (internal/founding/selfhostedpath.go, added by #626) ported SeedCommunity + EnsureOperator from that same pattern to close a different gap, but left WriteCommunityKit behind — it only ever landed at deploy.go's late, post-activation call. So the header write ordering bug is real, but scoped to exactly one path, not a general deploy.go ordering defect.

Considered both candidate fixes in the ticket and rejected both:

  1. Move the shared deploy.go WriteCommunityKit call earlier — rejected. That call is the operator-app seat's sole "founded" signal (#312/#202), deliberately placed after the control-plane apply/activation/liveness-probe sequence so the seat is never marked founded before the control plane is confirmed live. Moving it would reproduce the exact false-green shape #443/#476 already warn against in the surrounding comments — and it would move the signal for all four founding paths to fix a bug that only exists on one of them.
  2. Trigger a second reconcile/apply after WriteCommunityKit — rejected as a dead end for founding's own code path. The very activation this deploy just ran permanently closes the founding orchestrator's root@127.0.0.1 SSH door (the "#414 triad"/#550) — this is exactly why deploy.go's own applyControlPlane call is already guarded by if !st.Activated. A second call from founding's adapter after activation would fault Permission denied (publickey). (Confirmed by reading internal/clan/vmguest.go's gatewaySelfTrustUnit/idss-control-plane unit: post-founding config pushes — e.g. a Settings brand re-apply — are driven by the gateway's own in-process control-plane process, using a key it mints for itself after activation, never by the founding app reconnecting over root SSH. There is no lightweight "nudge the deploy runner to reconcile now" primitive reachable from internal/founding today.)

Actual fix (landed, a2acaec7): composeSelfHostedGateway now also calls o.clan.Config().WriteCommunityKit(ctx, d.brandKit(false)) right after SeedCommunity and before the clan Enroll — landing the header in the same commit landscape runDeploy's Config().Head() captures for this path's one reconcile. This exactly mirrors the already-working pattern the other three paths use. deploy.go's later call is untouched: it's an idempotent no-op there (the header is already present), and it remains the seat's real founded signal, unchanged for every path.

Also closes the ticket's "worth checking" note on the VM path: confirmed the VM (private) founding path is not affected — it lands the header via seedCommunityConfig before its own single reconcile, same as own-VPS and rented.

Two-way door: revertible by commit, provable by a new seam test — not a security-posture widening, credential, trust-surface accept, data destruction, or physical-hands action, so it does not touch the ADR 0174 one-way-door list.

Proof

  • New test TestSelfHosted_CommunityHeaderRidesTheAppliedRevision (internal/founding/selfhostedpath_test.go) backs the fake clan config with a real *clan.ConfigRepo and reads idss/brand-kit.json back at the exact revision Deploy was called with (not merely the post-deploy HEAD, which the pre-existing late call would already satisfy either way, masking the bug). Confirmed red before the fix: git show <rev>:idss/brand-kit.json → fatal: path 'idss/brand-kit.json' exists on disk, but not in '<rev>'. Green after the fix.
  • go build ./..., go vet ./..., go test ./... all green across every package.
  • Not re-proved by a fresh live drive this session (no live self-hosted founding drive is available synchronously here) — the next sign-in leg of a self-hosted rehearsal drive is the live proof, per the established #635/#636/#641/etc. precedent for this class of fix.

Close-report

  • Landed on main: commit a2acaec7 — "#667 — land the community header before the self-hosted gateway's one reconcile" (internal/founding/selfhostedpath.go, internal/founding/selfhostedpath_test.go, STATUS.md).
  • STATUS.md header updated with the full account (same commit).
  • Advances #667 (self-hosted kanidm branding); no other tickets touched.

Closing — the two-way-door fix is landed, proven by seam test, and does not require a human ruling or a one-way-door action.

**Ruled by agent under ADR 0174 — veto anytime.** Root cause confirmed exactly as the ticket traced it, with one correction to the "suspected layer": this is **not** actually a shared-code problem across all founding paths — only the self-hosted full-install path is affected. The own-VPS, private-VM and rented paths all already land the community header via `seedCommunityConfig`'s `WriteCommunityKit` call *before* their single reconcile (`internal/founding/{ownvpspath,privatepath,rentedpath}.go`, all calling `seedCommunityConfig` ahead of `runDeploy`). The self-hosted path's `composeSelfHostedGateway` (`internal/founding/selfhostedpath.go`, added by #626) ported `SeedCommunity` + `EnsureOperator` from that same pattern to close a *different* gap, but left `WriteCommunityKit` behind — it only ever landed at `deploy.go`'s late, post-activation call. So the header write ordering bug is real, but scoped to exactly one path, not a general `deploy.go` ordering defect. Considered both candidate fixes in the ticket and rejected both: 1. **Move the shared `deploy.go` `WriteCommunityKit` call earlier** — rejected. That call is the operator-app seat's sole "founded" signal (`#312`/`#202`), deliberately placed *after* the control-plane apply/activation/liveness-probe sequence so the seat is never marked founded before the control plane is confirmed live. Moving it would reproduce the exact false-green shape `#443`/`#476` already warn against in the surrounding comments — and it would move the signal for *all four* founding paths to fix a bug that only exists on one of them. 2. **Trigger a second reconcile/apply after `WriteCommunityKit`** — rejected as a dead end for founding's own code path. The very activation this deploy just ran permanently closes the founding orchestrator's root@127.0.0.1 SSH door (the "#414 triad"/`#550`) — this is exactly why `deploy.go`'s own `applyControlPlane` call is already guarded by `if !st.Activated`. A second call from founding's adapter after activation would fault `Permission denied (publickey)`. (Confirmed by reading `internal/clan/vmguest.go`'s `gatewaySelfTrustUnit`/`idss-control-plane` unit: post-founding config pushes — e.g. a Settings brand re-apply — are driven by the **gateway's own** in-process control-plane process, using a key it mints for itself after activation, never by the founding app reconnecting over root SSH. There is no lightweight "nudge the deploy runner to reconcile now" primitive reachable from `internal/founding` today.) **Actual fix (landed, `a2acaec7`):** `composeSelfHostedGateway` now also calls `o.clan.Config().WriteCommunityKit(ctx, d.brandKit(false))` right after `SeedCommunity` and before the clan `Enroll` — landing the header in the same commit landscape `runDeploy`'s `Config().Head()` captures for this path's one reconcile. This exactly mirrors the already-working pattern the other three paths use. `deploy.go`'s later call is untouched: it's an idempotent no-op there (the header is already present), and it remains the seat's real founded signal, unchanged for every path. Also closes the ticket's "worth checking" note on the VM path: confirmed the VM (private) founding path is **not** affected — it lands the header via `seedCommunityConfig` before its own single reconcile, same as own-VPS and rented. Two-way door: revertible by commit, provable by a new seam test — not a security-posture widening, credential, trust-surface accept, data destruction, or physical-hands action, so it does not touch the ADR 0174 one-way-door list. ## Proof - New test `TestSelfHosted_CommunityHeaderRidesTheAppliedRevision` (`internal/founding/selfhostedpath_test.go`) backs the fake clan config with a real `*clan.ConfigRepo` and reads `idss/brand-kit.json` back **at the exact revision `Deploy` was called with** (not merely the post-deploy HEAD, which the pre-existing late call would already satisfy either way, masking the bug). Confirmed red before the fix: `git show <rev>:idss/brand-kit.json` → `fatal: path 'idss/brand-kit.json' exists on disk, but not in '<rev>'`. Green after the fix. - `go build ./...`, `go vet ./...`, `go test ./...` all green across every package. - Not re-proved by a fresh live drive this session (no live self-hosted founding drive is available synchronously here) — the next `sign-in` leg of a self-hosted rehearsal drive is the live proof, per the established `#635`/`#636`/`#641`/etc. precedent for this class of fix. ## Close-report - Landed on `main`: commit `a2acaec7` — "#667 — land the community header before the self-hosted gateway's one reconcile" (`internal/founding/selfhostedpath.go`, `internal/founding/selfhostedpath_test.go`, `STATUS.md`). - `STATUS.md` header updated with the full account (same commit). - Advances #667 (self-hosted kanidm branding); no other tickets touched. Closing — the two-way-door fix is landed, proven by seam test, and does not require a human ruling or a one-way-door action.
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.

Reference
Matou/idss#667
No description provided.