real-rail: the set-release-channel --apply land-step hand-rolled a nix develop clan the gateway's own flake can never provide #1663

Closed
opened 2026-09-20 13:47:26 +00:00 by matou-build-agent · 1 comment

The failure

Drive 20260920T123207Z (artifacts/verdict.json: 8 green, 1 red, firstRedLeg: real-rail, commit 039b0c35) redded at the last leg. The guest refused the re-tune and named the reason itself — the verbatim refusal from artifacts/legs.json (leg real-rail):

time=2026-09-20T13:38:54.995Z level=ERROR msg="set-release-channel --apply: switching the gateway's own closure in place failed — the control plane was NOT restarted (the pin is committed but not live)" component=control-plane err="clan machines update gateway: exit status 1 — error: flake 'git+file:///srv/idss/config' does not provide attribute 'devShells.x86_64-linux.default', 'devShell.x86_64-linux', 'packages.x86_64-linux.default' or 'defaultPackage.x86_64-linux'" node=gateway

That is nix develop's error, not clan's: nix refused before the clan CLI ever ran, so the pin stayed committed-but-not-live and the Updates surface never reached applied.

The defect

control-plane/cmd/control-plane/channel_apply.go:105-119 (as of 039b0c35, #1661) hand-rolled its own invocation:

cmd := exec.CommandContext(ctx, "nix", "develop", "--command",
	"clan", "machines", "update", node,
	"--build-host", "localhost", "--target-host", "localhost", "--host-key-check", "none")
cmd.Dir = e.configDir

The comment above it says it mirrors "the standing re-supply (rehearsal-standing-lib.sh)" — a shape that only works from a DEV checkout. IDSS_CONFIG_REPO on a gateway is not one: this drive's captured community flake (state/clan-config/flake.nix:12) exports nixosConfigurations nixosModules clanInternals and nothing else, so nix develop there can only ever fail.

Three things were wrong with the hand-roll, all in one line:

  1. No dev shell exists in the community config repo (evidence above).
  2. No dev-shell clan exists on a gateway either — internal/clan/toolpin.go:16-19 states it outright: "On the control-plane deploy path no dev-shell clan is on PATH (vmguest.go omits it deliberately), so nix run <PinnedClanRef> runs on the critical path of every gateway deploy." The hand-roll bypassed that pinned-CLI resolution (resolveTool, ADR 0125) entirely.
  3. It named clan flags outside internal/clan — the DDR 0010 quarantine (internal/clan/cli.go:20: "Nothing OUTSIDE this package ever names a tool, a flag, or an exit code").

The layer, and what already worked on this same box

The product's own path was green on this guest an hour earlier. The gateway control plane wires its deploy runner over the same directory (logs/guest-control-plane.log:57: config repo wired: single-writer config store + clan deploy runner … dir=/srv/idss/config), and the update rollout's self-deploy (internal/update/rollout.go:526 → clan.Adapter.Deploy → internal/clan/adapter.go:632 updateNode) raised real switch units on the box: clan-switch-gateway-30a1376f at 13:12:25 and clan-switch-gateway-091be240 at 13:13:30 (logs/guest-system-journal.log:2967,3183), with the applied leg green in artifacts/legs.json. Only the new one-shot invented a second, broken way to do the same thing.

The fix

SwitchClosure now drives the SAME adapter the deploy runner drives (clan.New(clan.OpenConfigRepo(dir), clan.ExecCLI{}, log) — the shape set_release_channel.go:62 already uses for the pin): Deploy at an exact revision → eval preflight → headless clan machines update with the flags that work → layered failure classification, all inside internal/clan.

Deploy requires an exact commit (ADR 0102, commit-then-apply), which the land-step already has in hand: the pin's own commit now flows pin → SwitchClosure(node, revision), so the apply can never pick up a later writer's tip. Strict: true plus a reconciled-none guard keep a non-evaluating gateway a loud failure rather than a silent no-op the restart would then run over.

Banner text, the operator-facing command line (set-release-channel --apply gateway <url> <key>) and the five-step order are unchanged.

Box query

No artifacts/live-box.json was handed over — the guest was torn down (logs/qemu.log: exit 1 … ps -C qemu-system-x86_64 with no process). Diagnosis is from the harvested logs, quoted verbatim above; logs/guest-failed-units.log records 0 failed units and the control plane active/running, Result=success, NRestarts=2. This is not a roles-proof door leg, so no door re-prove applies.

Proposed ruling (Ruled by the healer under ADR 0174 — veto anytime)

Two-way door. The change is confined to how one on-box step shells out; reverting is git revert 043566a2 with nothing to undo on any box, in any config repo, or in any persisted state — SwitchClosure writes nothing of its own, and the pin it follows is unchanged. No operator-visible message, no route, no secrets shape, no security posture, and no default moved: the land-step's command line, its banners and its five-step order are byte-identical.

Mechanical, not a design decision. #1661 already decided WHAT this step does (switch the gateway's own closure in place after the pin, before the restart — DOOR 1, ruled under ADR 0174). It simply did it through an invocation that cannot resolve on the machine it runs on: nix develop against a flake whose outputs are nixosConfigurations nixosModules clanInternals. Routing it through clan.Adapter.Deploy makes the code do what it already meant to do, using the one sanctioned path (ADR 0125's pinned CLI, DDR 0010's flag quarantine) that the rollout drives green on this very box.

Proven by tests written here. TestExecChannelApply_SwitchClosureDrivesThePinnedClanAtThePinnedRevision injects a recording clan.CLI and asserts the switch runs machines update as clan.ToolClan in the config repo at git+file://<dir>?rev=<commit>, and that no invocation shells into a dev shell — it fails on the exact defect the drive hit. TestExecChannelApply_SwitchClosureRefusesWithoutAPinnedRevision and TestRunSetReleaseChannelApply_SwitchesTheClosureAtTheCommitThePinJustMade pin the commit-then-apply threading. All three were RED before the fix (build failure: no cli field, too many arguments in call to e.SwitchClosure) and green after.

Rules 1 and 2 hold. No assertion, expectation or test was edited, deleted or skipped — the only removed line in the test file is the fake's method signature (git diff deletions: exactly one line, func (f *fakeApply) SwitchClosure(_ context.Context, node string) error {); existing t.Fatalf values and the want := []string{"FleetIdle", "SwitchClosure:"+tNode, …} order assertion are untouched (the revision is recorded in a new field asserted by a new test). 3 files, 69 changed non-test lines, one commit. Built on the workstation (never the drive host) and closed through the close-report gate — the same gate a swarm worker passes.

drive 20260920T123207Z red at real-rail (sig 844ba04b38b5) — self-fixed on the fast lane, commit 2f368486cbe7343fd6982daa1a2685f994efabb7; checks: Targeted: go test ./control-plane/cmd/control-plane/ -run 'TestRunSetReleaseChannel|TestExecChannelApply' -v — RED first against the unfixed code, the absence proven by the compiler (set_release_channel_test.go:140:60: unknown field cli in struct literal of type execChannelApply; 176:54: too many arguments in call to e.SwitchClosure — have (context.Context, string, string), want (context.Context, string); build failed). GREEN after: 11 passed, including the recording-CLI case proving the invocation is the pinned clan at git+file://<dir>?rev=abc123 with no dev shell anywhere in it. Package tests: go test ./control-plane/cmd/control-plane/ ./internal/clan/ — both ok (26.239s / 20.275s). go build ./control-plane/... — clean. go vet ./control-plane/cmd/control-plane/ — clean. gofmt -l control-plane/cmd/control-plane/ — clean. golangci-lint is not on PATH on this workstation, so the errcheck gate (#1662) was not re-run here; the new code returns every error it produces and adds no writes to an io.Writer.. evidence: /home/swarm/swarm/Matou/idss/test-results/private-path/20260920T123207Z on matou-workstation.

## The failure Drive `20260920T123207Z` (`artifacts/verdict.json`: 8 green, 1 red, `firstRedLeg: real-rail`, commit `039b0c35`) redded at the last leg. The guest refused the re-tune and named the reason itself — the verbatim refusal from `artifacts/legs.json` (leg `real-rail`): ``` time=2026-09-20T13:38:54.995Z level=ERROR msg="set-release-channel --apply: switching the gateway's own closure in place failed — the control plane was NOT restarted (the pin is committed but not live)" component=control-plane err="clan machines update gateway: exit status 1 — error: flake 'git+file:///srv/idss/config' does not provide attribute 'devShells.x86_64-linux.default', 'devShell.x86_64-linux', 'packages.x86_64-linux.default' or 'defaultPackage.x86_64-linux'" node=gateway ``` That is `nix develop`'s error, not clan's: nix refused before the clan CLI ever ran, so the pin stayed committed-but-not-live and the Updates surface never reached `applied`. ## The defect `control-plane/cmd/control-plane/channel_apply.go:105-119` (as of `039b0c35`, #1661) hand-rolled its own invocation: ```go cmd := exec.CommandContext(ctx, "nix", "develop", "--command", "clan", "machines", "update", node, "--build-host", "localhost", "--target-host", "localhost", "--host-key-check", "none") cmd.Dir = e.configDir ``` The comment above it says it mirrors "the standing re-supply (rehearsal-standing-lib.sh)" — a shape that only works from a DEV checkout. `IDSS_CONFIG_REPO` on a gateway is not one: this drive's captured community flake (`state/clan-config/flake.nix:12`) exports `nixosConfigurations nixosModules clanInternals` and nothing else, so `nix develop` there can only ever fail. Three things were wrong with the hand-roll, all in one line: 1. **No dev shell exists** in the community config repo (evidence above). 2. **No dev-shell `clan` exists on a gateway either** — `internal/clan/toolpin.go:16-19` states it outright: "On the control-plane deploy path no dev-shell `clan` is on PATH (vmguest.go omits it deliberately), so `nix run <PinnedClanRef>` runs on the critical path of every gateway deploy." The hand-roll bypassed that pinned-CLI resolution (`resolveTool`, ADR 0125) entirely. 3. **It named clan flags outside `internal/clan`** — the DDR 0010 quarantine (`internal/clan/cli.go:20`: "Nothing OUTSIDE this package ever names a tool, a flag, or an exit code"). ## The layer, and what already worked on this same box The product's own path was green on this guest an hour earlier. The gateway control plane wires its deploy runner over the same directory (`logs/guest-control-plane.log:57`: `config repo wired: single-writer config store + clan deploy runner … dir=/srv/idss/config`), and the update rollout's self-deploy (`internal/update/rollout.go:526` → `clan.Adapter.Deploy` → `internal/clan/adapter.go:632` `updateNode`) raised real switch units on the box: `clan-switch-gateway-30a1376f` at 13:12:25 and `clan-switch-gateway-091be240` at 13:13:30 (`logs/guest-system-journal.log:2967,3183`), with the `applied` leg green in `artifacts/legs.json`. Only the new one-shot invented a second, broken way to do the same thing. ## The fix `SwitchClosure` now drives the SAME adapter the deploy runner drives (`clan.New(clan.OpenConfigRepo(dir), clan.ExecCLI{}, log)` — the shape `set_release_channel.go:62` already uses for the pin): `Deploy` at an exact revision → eval preflight → headless `clan machines update` with the flags that work → layered failure classification, all inside `internal/clan`. `Deploy` requires an exact commit (ADR 0102, commit-then-apply), which the land-step already has in hand: the pin's own commit now flows `pin → SwitchClosure(node, revision)`, so the apply can never pick up a later writer's tip. `Strict: true` plus a reconciled-none guard keep a non-evaluating gateway a loud failure rather than a silent no-op the restart would then run over. Banner text, the operator-facing command line (`set-release-channel --apply gateway <url> <key>`) and the five-step order are unchanged. ## Box query No `artifacts/live-box.json` was handed over — the guest was torn down (`logs/qemu.log`: `exit 1 … ps -C qemu-system-x86_64` with no process). Diagnosis is from the harvested logs, quoted verbatim above; `logs/guest-failed-units.log` records 0 failed units and the control plane `active/running`, `Result=success`, `NRestarts=2`. This is not a roles-proof door leg, so no door re-prove applies. ## Proposed ruling (Ruled by the healer under ADR 0174 — veto anytime) **Two-way door.** The change is confined to how one on-box step shells out; reverting is `git revert 043566a2` with nothing to undo on any box, in any config repo, or in any persisted state — `SwitchClosure` writes nothing of its own, and the pin it follows is unchanged. No operator-visible message, no route, no secrets shape, no security posture, and no default moved: the land-step's command line, its banners and its five-step order are byte-identical. **Mechanical, not a design decision.** #1661 already decided WHAT this step does (switch the gateway's own closure in place after the pin, before the restart — DOOR 1, ruled under ADR 0174). It simply did it through an invocation that cannot resolve on the machine it runs on: `nix develop` against a flake whose outputs are `nixosConfigurations nixosModules clanInternals`. Routing it through `clan.Adapter.Deploy` makes the code do what it already meant to do, using the one sanctioned path (ADR 0125's pinned CLI, DDR 0010's flag quarantine) that the rollout drives green on this very box. **Proven by tests written here.** `TestExecChannelApply_SwitchClosureDrivesThePinnedClanAtThePinnedRevision` injects a recording `clan.CLI` and asserts the switch runs `machines update` as `clan.ToolClan` in the config repo at `git+file://<dir>?rev=<commit>`, and that no invocation shells into a dev shell — it fails on the exact defect the drive hit. `TestExecChannelApply_SwitchClosureRefusesWithoutAPinnedRevision` and `TestRunSetReleaseChannelApply_SwitchesTheClosureAtTheCommitThePinJustMade` pin the commit-then-apply threading. All three were RED before the fix (build failure: no `cli` field, `too many arguments in call to e.SwitchClosure`) and green after. **Rules 1 and 2 hold.** No assertion, expectation or test was edited, deleted or skipped — the only removed line in the test file is the fake's method signature (`git diff` deletions: exactly one line, `func (f *fakeApply) SwitchClosure(_ context.Context, node string) error {`); existing `t.Fatalf` values and the `want := []string{"FleetIdle", "SwitchClosure:"+tNode, …}` order assertion are untouched (the revision is recorded in a new field asserted by a new test). 3 files, 69 changed non-test lines, one commit. Built on the workstation (never the drive host) and closed through the close-report gate — the same gate a swarm worker passes. drive `20260920T123207Z` red at `real-rail` (sig 844ba04b38b5) — self-fixed on the fast lane, commit `2f368486cbe7343fd6982daa1a2685f994efabb7`; checks: Targeted: `go test ./control-plane/cmd/control-plane/ -run 'TestRunSetReleaseChannel|TestExecChannelApply' -v` — RED first against the unfixed code, the absence proven by the compiler (`set_release_channel_test.go:140:60: unknown field cli in struct literal of type execChannelApply`; `176:54: too many arguments in call to e.SwitchClosure — have (context.Context, string, string), want (context.Context, string)`; build failed). GREEN after: 11 passed, including the recording-CLI case proving the invocation is the pinned clan at `git+file://<dir>?rev=abc123` with no dev shell anywhere in it. Package tests: `go test ./control-plane/cmd/control-plane/ ./internal/clan/` — both ok (26.239s / 20.275s). `go build ./control-plane/...` — clean. `go vet ./control-plane/cmd/control-plane/` — clean. `gofmt -l control-plane/cmd/control-plane/` — clean. golangci-lint is not on PATH on this workstation, so the errcheck gate (#1662) was not re-run here; the new code returns every error it produces and adds no writes to an io.Writer.. evidence: `/home/swarm/swarm/Matou/idss/test-results/private-path/20260920T123207Z` on matou-workstation. <!-- rehearsal-sig: 844ba04b38b5 -->
Author
Member

close-report for #1663 — status success

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

envelope
{
  "issue": 1663,
  "status": "success",
  "commits": [
    "2f368486cbe7343fd6982daa1a2685f994efabb7"
  ],
  "changed_files": [
    "control-plane/cmd/control-plane/channel_apply.go",
    "control-plane/cmd/control-plane/set_release_channel.go",
    "control-plane/cmd/control-plane/set_release_channel_test.go"
  ],
  "tests": [
    {
      "command": "Targeted: `go test ./control-plane/cmd/control-plane/ -run 'TestRunSetReleaseChannel|TestExecChannelApply' -v` — RED first against the unfixed code, the absence proven by the compiler (`set_release_channel_test.go:140:60: unknown field cli in struct literal of type execChannelApply`; `176:54: too many arguments in call to e.SwitchClosure — have (context.Context, string, string), want (context.Context, string)`; build failed). GREEN after: 11 passed, including the recording-CLI case proving the invocation is the pinned clan at `git+file://<dir>?rev=abc123` with no dev shell anywhere in it. Package tests: `go test ./control-plane/cmd/control-plane/ ./internal/clan/` — both ok (26.239s / 20.275s). `go build ./control-plane/...` — clean. `go vet ./control-plane/cmd/control-plane/` — clean. `gofmt -l control-plane/cmd/control-plane/` — clean. golangci-lint is not on PATH on this workstation, so the errcheck gate (#1662) was not re-run here; the new code returns every error it produces and adds no writes to an io.Writer.",
      "exit_code": 0
    }
  ],
  "criteria": {
    "the red leg is now green": "healed on the fast lane, commit 2f368486cbe7343fd6982daa1a2685f994efabb7"
  },
  "summary": "The #1661 --apply land-step hand-rolled `nix develop --command clan machines update` inside the gateway's community config repo, whose flake exports only nixosConfigurations/nixosModules/clanInternals — so nix refused before clan ran; the switch now goes through the same `clan.Adapter.Deploy` the control plane's own deploy runner drives, pinned to the commit the pin just made.",
  "blockers": []
}
**close-report** for #1663 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1663, "status": "success", "commits": [ "2f368486cbe7343fd6982daa1a2685f994efabb7" ], "changed_files": [ "control-plane/cmd/control-plane/channel_apply.go", "control-plane/cmd/control-plane/set_release_channel.go", "control-plane/cmd/control-plane/set_release_channel_test.go" ], "tests": [ { "command": "Targeted: `go test ./control-plane/cmd/control-plane/ -run 'TestRunSetReleaseChannel|TestExecChannelApply' -v` — RED first against the unfixed code, the absence proven by the compiler (`set_release_channel_test.go:140:60: unknown field cli in struct literal of type execChannelApply`; `176:54: too many arguments in call to e.SwitchClosure — have (context.Context, string, string), want (context.Context, string)`; build failed). GREEN after: 11 passed, including the recording-CLI case proving the invocation is the pinned clan at `git+file://<dir>?rev=abc123` with no dev shell anywhere in it. Package tests: `go test ./control-plane/cmd/control-plane/ ./internal/clan/` — both ok (26.239s / 20.275s). `go build ./control-plane/...` — clean. `go vet ./control-plane/cmd/control-plane/` — clean. `gofmt -l control-plane/cmd/control-plane/` — clean. golangci-lint is not on PATH on this workstation, so the errcheck gate (#1662) was not re-run here; the new code returns every error it produces and adds no writes to an io.Writer.", "exit_code": 0 } ], "criteria": { "the red leg is now green": "healed on the fast lane, commit 2f368486cbe7343fd6982daa1a2685f994efabb7" }, "summary": "The #1661 --apply land-step hand-rolled `nix develop --command clan machines update` inside the gateway's community config repo, whose flake exports only nixosConfigurations/nixosModules/clanInternals — so nix refused before clan ran; the switch now goes through the same `clan.Adapter.Deploy` the control plane's own deploy runner drives, pinned to the commit the pin just made.", "blockers": [] } ``` </details>
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.

Dependencies

No dependencies set.

Reference
Matou/idss#1663
No description provided.