founding: gateway deploy sends an empty Revision, tripping clan's own ADR-0102 exact-revision guard (#462 follow-on) #464

Closed
opened 2026-08-12 03:33:09 +00:00 by ben · 2 comments
Owner

Failure

Red leg control-plane (drive 20260812T032139Z, signature ed8f4af586c4):

founding: gateway deploy: founding: prepare gateway deploy: clan: deploy requires an exact committed revision (commit-then-apply, ADR 0102)

Evidence: test-results/drive-droplet/20260812T032139Z/logs/founding-state.log:188, .../artifacts/.../error-context.md:15.

Root cause

The prior healer commit 327b968 (#462) changed deployRevision() (internal/founding/deploy.go:689-691) to return "", reasoning in its own comment (deploy.go:679-681) that "the clan-config is a locally-assembled path tree ... NOT a git checkout at a committed rev." That premise is false: internal/clan/configrepo.go:54-104 (ConfigRepo.Mutate/.Head) shows the config repo IS a real git repo — every mutation (git add -A + git commit) lands a commit, and runDeploy already lands brand artifacts and the brand logo as commits (internal/founding/deploy.go:301-307, via landBrandArtifacts/landBrandLogo at deploy.go:525-573) immediately before calling applyControlPlane (deploy.go:311) — their returned clan.Commit values are just discarded.

So the empty "" revision from deployRevision() is threaded into clan.DeployRequest{Revision: deployRevision()} at deploy.go:403, and immediately trips Adapter.Deploy's own guard at internal/clan/adapter.go:201-203:

if req.Revision == "" {
    return nil, fmt.Errorf("clan: deploy requires an exact committed revision (commit-then-apply, ADR 0102)")
}

...which exists precisely because ADR 0102 (docs/adr/0102-...md:44-46) mandates "Commit-then-apply-exact-revision. A deploy applies a named revision (DeployRequest.Revision)" for every caller, founding included ("founding's stand-up all get their real backing from this one adapter", same ADR, Consequences). The founding path never reaches nix eval; it fails synchronously before dep.Run().

Note: this slipped past go test ./internal/founding/... in #462 because internal/clan/testing/fake.go's Fake.Deploy (used by founding's test doubles) never enforces the empty-revision guard the real Adapter.Deploy does — the guard only lives in the production adapter, so only a real rehearsal drive catches it.

Suspected layer

internal/founding (deploy orchestration) + internal/clan (the Config seam needs a way to hand founding a real committed revision).

What plugging it needs

  1. Give founding a real committed revision at deploy time instead of "". Two viable shapes:
    • (a) Thread the clan.Commit already returned by landBrandArtifacts/landBrandLogo (deploy.go:525-573, currently discarded) through runDeploy into applyControlPlane's DeployRequest.Revision.
    • (b) Add a Head(ctx) (clan.Commit, error) method to the clan.Config interface (internal/clan/clan.go), backed by configFace calling the existing *ConfigRepo.Head (internal/clan/config.go, internal/clan/adapter.go:407), and call it right before the deploy in runDeploy.
  2. Either way, remove deployRevision() (internal/founding/deploy.go:689-691) and its now-wrong-contract test internal/founding/deployrevision_internal_test.go (currently asserts the revision MUST be empty — exactly backwards).
  3. internal/clan/testing/fake.go's fakeConfig needs the corresponding method/wiring so founding's unit tests keep exercising the real contract (and would have caught this).
  4. internal/founding/privatepath.go:728,740 also calls landBrandArtifacts/landBrandLogo (for the private/VM path, which builds via Enroll, not Deploy — it doesn't need the revision, just needs to keep compiling against whatever signature change lands).

This spans the clan.Config interface plus its two implementations and 2-3 founding files — over the healer's self-fix bound (design/interface decision, >3 files) — so filing rather than patching directly. deployRevision() is currently called from exactly one site (deploy.go:403), so the blast radius of the actual fix is well-contained once the shape (a) vs (b) is picked.

drive 20260812T032139Z red at control-plane: journey leg "control-plane" went red: founding: gateway deploy: founding: prepare gateway deploy: clan: deploy requires an exact committed revision (commit-then-apply, ADR N)
evidence: test-results/…/20260812T032139Z/ on matou-workstation (legs.json, droplet-journal.txt, trace)

## Failure Red leg `control-plane` (drive `20260812T032139Z`, signature `ed8f4af586c4`): ``` founding: gateway deploy: founding: prepare gateway deploy: clan: deploy requires an exact committed revision (commit-then-apply, ADR 0102) ``` Evidence: `test-results/drive-droplet/20260812T032139Z/logs/founding-state.log:188`, `.../artifacts/.../error-context.md:15`. ## Root cause The prior healer commit `327b968` (#462) changed `deployRevision()` (`internal/founding/deploy.go:689-691`) to return `""`, reasoning in its own comment (`deploy.go:679-681`) that "the clan-config is a locally-assembled path tree ... NOT a git checkout at a committed rev." That premise is false: `internal/clan/configrepo.go:54-104` (`ConfigRepo.Mutate`/`.Head`) shows the config repo IS a real git repo — every mutation (`git add -A` + `git commit`) lands a commit, and `runDeploy` already lands brand artifacts and the brand logo as commits (`internal/founding/deploy.go:301-307`, via `landBrandArtifacts`/`landBrandLogo` at `deploy.go:525-573`) immediately before calling `applyControlPlane` (`deploy.go:311`) — their returned `clan.Commit` values are just discarded. So the empty `""` revision from `deployRevision()` is threaded into `clan.DeployRequest{Revision: deployRevision()}` at `deploy.go:403`, and immediately trips `Adapter.Deploy`'s own guard at `internal/clan/adapter.go:201-203`: ```go if req.Revision == "" { return nil, fmt.Errorf("clan: deploy requires an exact committed revision (commit-then-apply, ADR 0102)") } ``` ...which exists precisely because ADR 0102 (`docs/adr/0102-...md:44-46`) mandates "Commit-then-apply-exact-revision. A deploy applies a named revision (`DeployRequest.Revision`)" for every caller, founding included ("founding's stand-up all get their real backing from this one adapter", same ADR, Consequences). The founding path never reaches nix eval; it fails synchronously before `dep.Run()`. Note: this slipped past `go test ./internal/founding/...` in #462 because `internal/clan/testing/fake.go`'s `Fake.Deploy` (used by founding's test doubles) never enforces the empty-revision guard the real `Adapter.Deploy` does — the guard only lives in the production adapter, so only a real rehearsal drive catches it. ## Suspected layer `internal/founding` (deploy orchestration) + `internal/clan` (the `Config` seam needs a way to hand founding a real committed revision). ## What plugging it needs 1. Give founding a real committed revision at deploy time instead of `""`. Two viable shapes: - **(a)** Thread the `clan.Commit` already returned by `landBrandArtifacts`/`landBrandLogo` (`deploy.go:525-573`, currently discarded) through `runDeploy` into `applyControlPlane`'s `DeployRequest.Revision`. - **(b)** Add a `Head(ctx) (clan.Commit, error)` method to the `clan.Config` interface (`internal/clan/clan.go`), backed by `configFace` calling the existing `*ConfigRepo.Head` (`internal/clan/config.go`, `internal/clan/adapter.go:407`), and call it right before the deploy in `runDeploy`. 2. Either way, remove `deployRevision()` (`internal/founding/deploy.go:689-691`) and its now-wrong-contract test `internal/founding/deployrevision_internal_test.go` (currently asserts the revision MUST be empty — exactly backwards). 3. `internal/clan/testing/fake.go`'s `fakeConfig` needs the corresponding method/wiring so founding's unit tests keep exercising the real contract (and would have caught this). 4. `internal/founding/privatepath.go:728,740` also calls `landBrandArtifacts`/`landBrandLogo` (for the private/VM path, which builds via `Enroll`, not `Deploy` — it doesn't need the revision, just needs to keep compiling against whatever signature change lands). This spans the `clan.Config` interface plus its two implementations and 2-3 founding files — over the healer's self-fix bound (design/interface decision, >3 files) — so filing rather than patching directly. `deployRevision()` is currently called from exactly one site (`deploy.go:403`), so the blast radius of the actual fix is well-contained once the shape (a) vs (b) is picked. drive `20260812T032139Z` red at `control-plane`: `journey leg "control-plane" went red: founding: gateway deploy: founding: prepare gateway deploy: clan: deploy requires an exact committed revision (commit-then-apply, ADR N)` evidence: `test-results/…/20260812T032139Z/` on matou-workstation (legs.json, droplet-journal.txt, trace) <!-- rehearsal-sig: ed8f4af586c4 -->
Author
Owner

Verified fix: return the assembled clan-config repo's HEAD commit SHA

Confirmed against this run's captured config (test-results/drive-droplet/20260812T032139Z/state/clan-config), no droplet:

  • The assembled clan-config is a git repo with a clean commit — git rev-parse HEAD = c82402cc75cefd52df69c8e362037e669bb5358d, working tree clean.
  • Evaluating at that committed revision succeeds:
    nix eval --raw "git+file://<cfg>?rev=c82402cc…#nixosConfigurations.gateway.config.system.build.toplevel.drvPath"
    → /nix/store/4wwmnqwhbwh4nzngw9j53lm05hk599y3-nixos-system-gateway-….drv   EXIT=0
    
    (only benign kanidm-rename / network-online warnings)

So the fix is not the previous empty string (#462 — trips this ADR-0102 guard) and not the old "founding-gateway-"+node stub (parses as a bad hash). deployRevision must return the HEAD commit SHA of the assembled clan-config repo (o.clan/adapter repo dir = the same dir flakeRef uses). Resolve it with git -C <dir> rev-parse HEAD at deploy time; flakeRef then builds git+file://<dir>?rev=<SHA>, which satisfies commit-then-apply (ADR 0102) and evals cleanly.

The founding flow already commits the assembled config (that IS the "commit" in commit-then-apply); the bug is only that deployRevision never read the resulting HEAD. deployRevision currently takes no args and returns "" — it will need the config repo dir (thread it through from applyControlPlane, which has o), or resolve HEAD in applyControlPlane and pass it as DeployRequest.Revision.

Test

  • deployRevision/applyControlPlane yields a 40-hex SHA that rev-parse --verify confirms in the assembled repo — never "" and never a non-SHA.
  • Eval-seam (reuse #401 harness): readinessAt over the assembled config at the resolved rev returns OK for the gateway node.
  • Regression: the single-node deploy reaches clan machines update (reconcile runs) rather than the ADR-0102 guard or the preflight-skip.

Verified diagnosis; the next drive is the first real reconcile. Advances #378.

## Verified fix: return the assembled clan-config repo's HEAD commit SHA Confirmed against this run's captured config (`test-results/drive-droplet/20260812T032139Z/state/clan-config`), no droplet: - The assembled clan-config **is a git repo with a clean commit** — `git rev-parse HEAD` = `c82402cc75cefd52df69c8e362037e669bb5358d`, working tree clean. - Evaluating at that committed revision succeeds: ``` nix eval --raw "git+file://<cfg>?rev=c82402cc…#nixosConfigurations.gateway.config.system.build.toplevel.drvPath" → /nix/store/4wwmnqwhbwh4nzngw9j53lm05hk599y3-nixos-system-gateway-….drv EXIT=0 ``` (only benign kanidm-rename / network-online warnings) So the fix is **not** the previous empty string (#462 — trips this ADR-0102 guard) and **not** the old `"founding-gateway-"+node` stub (parses as a bad hash). `deployRevision` must return the **HEAD commit SHA of the assembled clan-config repo** (`o.clan`/adapter repo dir = the same dir `flakeRef` uses). Resolve it with `git -C <dir> rev-parse HEAD` at deploy time; `flakeRef` then builds `git+file://<dir>?rev=<SHA>`, which satisfies commit-then-apply (ADR 0102) and evals cleanly. The founding flow already commits the assembled config (that IS the "commit" in commit-then-apply); the bug is only that `deployRevision` never read the resulting HEAD. `deployRevision` currently takes no args and returns "" — it will need the config repo dir (thread it through from `applyControlPlane`, which has `o`), or resolve HEAD in `applyControlPlane` and pass it as `DeployRequest.Revision`. ### Test - `deployRevision`/`applyControlPlane` yields a 40-hex SHA that `rev-parse --verify` confirms in the assembled repo — never "" and never a non-SHA. - Eval-seam (reuse #401 harness): `readinessAt` over the assembled config at the resolved rev returns OK for the gateway node. - Regression: the single-node deploy reaches `clan machines update` (reconcile runs) rather than the ADR-0102 guard or the preflight-skip. Verified diagnosis; the next drive is the first real reconcile. Advances #378. <!-- rehearsal-sig: ed8f4af586c4 -->
Author
Owner

close-report for #464 — status success

✅ close-report gates passed — every claim verified against main; closing.

envelope
{
  "issue": 464,
  "status": "success",
  "commits": [
    "7b2b4b74de67ad18bc29799a885279569efbc4b7"
  ],
  "changed_files": [
    "STATUS.md",
    "control-plane/cmd/control-plane/resting_composition.go",
    "internal/clan/clan.go",
    "internal/clan/config.go",
    "internal/clan/testing/fake.go",
    "internal/founding/deploy.go",
    "internal/founding/deploy_test.go",
    "internal/founding/deployrevision_internal_test.go",
    "internal/founding/seed.go",
    "internal/rescue/deviceladder_test.go"
  ],
  "tests": [
    {
      "command": "go test ./internal/founding/... ./internal/clan/... ./internal/rescue/...",
      "exit_code": 0
    },
    {
      "command": "go test ./...",
      "exit_code": 0
    },
    {
      "command": "go vet ./...",
      "exit_code": 0
    },
    {
      "command": "go build ./...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Give founding a real committed revision instead of \"\"": "internal/founding/deploy.go: runDeploy reads o.clan.Config().Head(ctx) after landing the brand artifacts and threads it into applyControlPlane's DeployRequest.Revision (shape (b) from the issue, matching ben's verified ruling: the config repo's HEAD commit SHA)",
    "Add Head(ctx) (Commit,error) to clan.Config backed by ConfigRepo.Head": "internal/clan/clan.go (interface) + internal/clan/config.go (configFace.Head -> c.a.repo.Head, i.e. git rev-parse HEAD)",
    "Remove deployRevision() and its now-wrong-contract test": "internal/founding/deploy.go (deployRevision removed) + internal/founding/deployrevision_internal_test.go (deleted, 27 lines); replaced by TestDeploy_NamesRealCommittedRevision asserting a non-empty revision",
    "fakeConfig gains the corresponding method/wiring so founding unit tests exercise the real contract": "internal/clan/testing/fake.go: fakeConfig.Head + Fake.Deploy records requests exposed via Deploys(); TestDeploy_NamesRealCommittedRevision is red on empty revision, green on the real fix (proven by forcing Revision=\"\")",
    "privatepath.go landBrandArtifacts/landBrandLogo keep compiling": "no landBrand signature change, so internal/founding/privatepath.go compiles unchanged; go build ./... exit 0"
  },
  "summary": "Founding gateway deploy now names the config repo's real HEAD commit revision via clan.Config.Head, replacing #462's empty ref that tripped the ADR-0102 exact-revision guard.",
  "blockers": []
}
**close-report** for #464 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 464, "status": "success", "commits": [ "7b2b4b74de67ad18bc29799a885279569efbc4b7" ], "changed_files": [ "STATUS.md", "control-plane/cmd/control-plane/resting_composition.go", "internal/clan/clan.go", "internal/clan/config.go", "internal/clan/testing/fake.go", "internal/founding/deploy.go", "internal/founding/deploy_test.go", "internal/founding/deployrevision_internal_test.go", "internal/founding/seed.go", "internal/rescue/deviceladder_test.go" ], "tests": [ { "command": "go test ./internal/founding/... ./internal/clan/... ./internal/rescue/...", "exit_code": 0 }, { "command": "go test ./...", "exit_code": 0 }, { "command": "go vet ./...", "exit_code": 0 }, { "command": "go build ./...", "exit_code": 0 } ], "criteria": { "Give founding a real committed revision instead of \"\"": "internal/founding/deploy.go: runDeploy reads o.clan.Config().Head(ctx) after landing the brand artifacts and threads it into applyControlPlane's DeployRequest.Revision (shape (b) from the issue, matching ben's verified ruling: the config repo's HEAD commit SHA)", "Add Head(ctx) (Commit,error) to clan.Config backed by ConfigRepo.Head": "internal/clan/clan.go (interface) + internal/clan/config.go (configFace.Head -> c.a.repo.Head, i.e. git rev-parse HEAD)", "Remove deployRevision() and its now-wrong-contract test": "internal/founding/deploy.go (deployRevision removed) + internal/founding/deployrevision_internal_test.go (deleted, 27 lines); replaced by TestDeploy_NamesRealCommittedRevision asserting a non-empty revision", "fakeConfig gains the corresponding method/wiring so founding unit tests exercise the real contract": "internal/clan/testing/fake.go: fakeConfig.Head + Fake.Deploy records requests exposed via Deploys(); TestDeploy_NamesRealCommittedRevision is red on empty revision, green on the real fix (proven by forcing Revision=\"\")", "privatepath.go landBrandArtifacts/landBrandLogo keep compiling": "no landBrand signature change, so internal/founding/privatepath.go compiles unchanged; go build ./... exit 0" }, "summary": "Founding gateway deploy now names the config repo's real HEAD commit revision via clan.Config.Head, replacing #462's empty ref that tripped the ADR-0102 exact-revision guard.", "blockers": [] } ``` </details>
ben closed this issue 2026-08-12 03:55:28 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#464
No description provided.