deploy-surveys: the surveys-brand oneshot hand-copies limesurvey-init's PATH beside the one systemd-lib generates from its own path — two normal-priority definitions, eval preflight excludes the gateway, nothing deployed #1329

Closed
opened 2026-09-08 17:59:37 +00:00 by matou-build-agent · 1 comment

The failure

Drive 20260908T164009Z (artifacts/verdict.json: 21 legs, 20 green) red at deploy-surveys after 50.6s. The clean-retry deploy never reached the box — the node was excluded at the eval preflight:

error: The option `systemd.services.surveys-brand.environment.PATH' has conflicting definition values:
- In `…/nixos/modules/system/boot/systemd.nix': "…coreutils/bin:…gnused/bin:…gnugrep/bin:…coreutils/bin:…findutils/bin:…gnugrep/bin:…gnused/bin:…systemd/bin:…" (8 packages)
- In `…/machines/gateway/surveys.nix':        "…coreutils/bin:…findutils/bin:…gnugrep/bin:…gnused/bin:…systemd/bin:…"     (5 packages)

The defect

environment.PATH is not a key a service author owns.

  • nixos/lib/systemd-lib.nix:660 (serviceConfig submodule) defines it for every unit from that unit's own path, at NORMAL priority: environment.PATH = mkIf (config.path != []) "${makeBinPath config.path}:${makeSearchPathOutput "bin" "sbin" config.path}".
  • nixos/lib/systemd-lib.nix:708-720 (stage2ServiceConfig) mkAfter-appends coreutils/findutils/gnugrep/gnused/systemd to every stage-2 service's path, so config.path is never empty and that definition always exists.

internal/clan/surveys.go:479 gave the oneshot path = [ pkgs.coreutils pkgs.gnused pkgs.gnugrep ], and internal/clan/surveys.go:481 also copied the sibling's already-evaluated, already-PATH-bearing environment attrset whole:

environment = config.systemd.services.limesurvey-init.environment // { YII_CONSOLE_COMMANDS = themeCommands; };

attrsOf then held two equal-priority values for environment.PATH — the unit's own 3+5 packages vs the sibling's 5 — and types.str refuses to merge unequal definitions. Both lines were introduced by HEAD commit 902a65f0 (#1326).

limesurvey-admin (internal/clan/surveys.go:650, #1319) carried the same copy. It evaluated green only because it adds no package of its own, so its generated PATH and the copied one are byte-equal and the merge is quiet — quiet by coincidence, one package away from the identical red.

Why the workstation missed it

TestSurveysCohost_EvalSmoke (internal/clan/surveys_eval_test.go) never landed a brand kit, so haveBrand (surveys.go:224) was false and the entire lib.mkIf haveBrand branch — the oneshot, its environment, its path, config.php's brand keys — was dead text no eval ever type-checked. The brand-bearing half of the render had only ever been evaluated on a paid droplet.

The fix

Both units strip PATH on the way in (removeAttrs … [ "PATH" ]) and let path be the single definition. The inherited LIMESURVEY_CONFIG (#1319) and the YII_CONSOLE_COMMANDS dir (#1326) are unchanged; limesurvey-admin's resulting PATH is byte-identical to what it had.

The eval smoke now lands the compiled svc:surveys artifact plus its logo object and type sidecar (the exact bytes this drive's brand apply committed, read from state/clan-config/idss/brand/svc-surveys/) before the eval, so the brand branch is evaluated against real nixpkgs here, and asserts both oneshots' evaluated environments. The render seam gains two negative guards: no environment.PATH anywhere in the output, and no un-stripped inheritance of the sibling's environment.

Suspected layer

The clan render (internal/clan/surveys.go) vs. the NixOS module system's per-key merge priority — the same class as #1322 (config.config at normal priority wiping nixpkgs' subtree), one level down: not which option, but who owns the key.

Follow-up not landed here

A docs/GOTCHAS.md entry ("never hand-write or copy a systemd unit's environment.PATH; it is generated from path at normal priority for every unit") — the 3-file heal cap was spent on the fix plus the two test files that prove it.

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

Two-way door. Revertible: git revert 7153771b restores the previous render byte-for-byte; the change is three rendered Nix lines plus comments in one file, no state, no migration, no secret, no route, no message a community reads. Proven by: TestSurveysCohost_EvalSmoke — a real-nixpkgs eval of the co-hosted gateway, extended here to land a brand kit so the branch is live; it FAILED before the fix with the drive's exact conflict sentence and PASSES after, and additionally decodes both units' evaluated environment attrsets to prove LIMESURVEY_CONFIG is inherited (identical across the two) and PATH is the generated one. Plus two negative render-seam guards in TestRenderSurveys_BrandThemeLandsInWritableUploadAndSetDefault and the existing TestRenderSurveys_AdminConsoleCarriesLimeSurveyConfigEnv. Mechanical, not a design decision: nothing about what the port means to do changed — the oneshot still lands and registers the brand theme, still reads the same config.php, still runs with the same tools on PATH. The render simply stopped defining a key the module system already defines for it. There is no product-visible difference: limesurvey-admin's PATH is byte-identical before and after, and surveys-brand previously produced no configuration at all (eval refused). Rules 1 and 2 self-checked against the rails' own regexes in .sandcastle/rehearsal-heal-lib.sh: no removed or edited assertion/expectation line (I reverted one reworded t.Fatalf message to keep it byte-identical), no removed test or leg declaration, no added skip; 3 files, 25 changed non-test lines, exactly one commit, no .sandcastle/rehearsal-* or .forgejo/workflows/ touched. Not pushed. Built on the workstation (never the drive host) and closed through the close-report gate — the same gate a swarm worker passes.

drive 20260908T164009Z red at deploy-surveys (sig 119db33993c0) — self-fixed on the fast lane, commit f99c325ee195462891408c0bc561d9673636512b; checks: targeted (red-first): IDSS_EVAL_SMOKE=1 go test ./internal/clan/ -run TestSurveysCohost_EvalSmoke -v → FAIL before the fix (97.65s), reproducing the drive's exact sentence: "The option systemd.services.surveys-brand.environment.PATH' has conflicting definition values" — same 8-package vs 5-package values, at … while evaluating the option systemd.units."surveys-brand.service".text. PASS after (34.88s): toplevel evaluated to /nix/store/8ijby2gkggdy94l6jmcrlshdv1102cy3-nixos-system-gateway-26.11.20260612.173d0ad.drv; "surveys environment guard passed: LIMESURVEY_CONFIG inherited by both oneshots, PATH generated from pathalone"; the #1322 config.config merge guard still passes; the teeth half still fails on the phantomuploadsDiras it should. package:go test ./internal/clan/→ ok (18.4s), all 11TestRenderSurveys_PASS. trees:go test ./internal/... ./control-plane/... → no failures. root cause verified against the pinned nixpkgs source (/nix/store/lr5ld8f0qbyhjx3nr9mxfvg4cndvpggp-source): nixos/lib/systemd-lib.nix:660definesenvironment.PATH = mkIf (config.path != []) …at normal priority,:708-720 stage2ServiceConfigmkAfter-appends the 5 default packages to every service'spath; nixos/modules/services/web-apps/limesurvey.nix:327-333shows limesurvey-init declares only DBENGINE + LIMESURVEY_CONFIG and nopath, which is why its evaluated environment carries the default-5 PATH the render was copying. go build ./...→ clean;go vet ./internal/clan/→ clean;gofmt -l internal/clan/ → clean. commit shape: 3 files, 25 changed non-test lines (internal/clan/surveys.go20/5;surveys_eval_test.go128/0;surveys_test.go27/2), one commit, not pushed. rails self-check with the lib's own regexes → rule 1 NONE on all three patterns (removed assertion/expectation, removed test/leg declaration, added skip); no.sandcastle/rehearsal-or.forgejo/workflows/path in the diff.. evidence:/home/swarm/swarm/Matou/idss/test-results/private-path/20260908T164009Z` on matou-workstation.

## The failure Drive `20260908T164009Z` (`artifacts/verdict.json`: 21 legs, 20 green) red at `deploy-surveys` after 50.6s. The clean-retry deploy never reached the box — the node was excluded at the eval preflight: ``` error: The option `systemd.services.surveys-brand.environment.PATH' has conflicting definition values: - In `…/nixos/modules/system/boot/systemd.nix': "…coreutils/bin:…gnused/bin:…gnugrep/bin:…coreutils/bin:…findutils/bin:…gnugrep/bin:…gnused/bin:…systemd/bin:…" (8 packages) - In `…/machines/gateway/surveys.nix': "…coreutils/bin:…findutils/bin:…gnugrep/bin:…gnused/bin:…systemd/bin:…" (5 packages) ``` ## The defect `environment.PATH` is not a key a service author owns. - `nixos/lib/systemd-lib.nix:660` (`serviceConfig` submodule) defines it for **every** unit from that unit's own `path`, at NORMAL priority: `environment.PATH = mkIf (config.path != []) "${makeBinPath config.path}:${makeSearchPathOutput "bin" "sbin" config.path}"`. - `nixos/lib/systemd-lib.nix:708-720` (`stage2ServiceConfig`) `mkAfter`-appends coreutils/findutils/gnugrep/gnused/systemd to every stage-2 service's `path`, so `config.path` is **never** empty and that definition always exists. `internal/clan/surveys.go:479` gave the oneshot `path = [ pkgs.coreutils pkgs.gnused pkgs.gnugrep ]`, and `internal/clan/surveys.go:481` **also** copied the sibling's already-evaluated, already-PATH-bearing environment attrset whole: ```nix environment = config.systemd.services.limesurvey-init.environment // { YII_CONSOLE_COMMANDS = themeCommands; }; ``` `attrsOf` then held two equal-priority values for `environment.PATH` — the unit's own 3+5 packages vs the sibling's 5 — and `types.str` refuses to merge unequal definitions. Both lines were introduced by HEAD commit `902a65f0` (#1326). `limesurvey-admin` (`internal/clan/surveys.go:650`, #1319) carried the same copy. It evaluated green only because it adds no package of its own, so its generated PATH and the copied one are byte-equal and the merge is quiet — quiet by **coincidence**, one package away from the identical red. ## Why the workstation missed it `TestSurveysCohost_EvalSmoke` (`internal/clan/surveys_eval_test.go`) never landed a brand kit, so `haveBrand` (`surveys.go:224`) was false and the entire `lib.mkIf haveBrand` branch — the oneshot, its `environment`, its `path`, config.php's brand keys — was dead text no eval ever type-checked. The brand-bearing half of the render had only ever been evaluated on a paid droplet. ## The fix Both units strip PATH on the way in (`removeAttrs … [ "PATH" ]`) and let `path` be the single definition. The inherited `LIMESURVEY_CONFIG` (#1319) and the `YII_CONSOLE_COMMANDS` dir (#1326) are unchanged; `limesurvey-admin`'s resulting PATH is byte-identical to what it had. The eval smoke now lands the compiled `svc:surveys` artifact plus its logo object and type sidecar (the exact bytes this drive's brand apply committed, read from `state/clan-config/idss/brand/svc-surveys/`) **before** the eval, so the brand branch is evaluated against real nixpkgs here, and asserts both oneshots' evaluated environments. The render seam gains two negative guards: no `environment.PATH` anywhere in the output, and no un-stripped inheritance of the sibling's environment. ## Suspected layer The clan render (`internal/clan/surveys.go`) vs. the NixOS module system's per-key merge priority — the same class as #1322 (`config.config` at normal priority wiping nixpkgs' subtree), one level down: not *which* option, but *who owns* the key. ## Follow-up not landed here A `docs/GOTCHAS.md` entry ("never hand-write or copy a systemd unit's `environment.PATH`; it is generated from `path` at normal priority for every unit") — the 3-file heal cap was spent on the fix plus the two test files that prove it. ## Proposed ruling (Ruled by the healer under ADR 0174 — veto anytime) Two-way door. **Revertible**: `git revert 7153771b` restores the previous render byte-for-byte; the change is three rendered Nix lines plus comments in one file, no state, no migration, no secret, no route, no message a community reads. **Proven by**: `TestSurveysCohost_EvalSmoke` — a real-nixpkgs eval of the co-hosted gateway, extended here to land a brand kit so the branch is live; it FAILED before the fix with the drive's exact conflict sentence and PASSES after, and additionally decodes both units' evaluated `environment` attrsets to prove LIMESURVEY_CONFIG is inherited (identical across the two) and PATH is the generated one. Plus two negative render-seam guards in `TestRenderSurveys_BrandThemeLandsInWritableUploadAndSetDefault` and the existing `TestRenderSurveys_AdminConsoleCarriesLimeSurveyConfigEnv`. **Mechanical, not a design decision**: nothing about what the port *means* to do changed — the oneshot still lands and registers the brand theme, still reads the same config.php, still runs with the same tools on PATH. The render simply stopped defining a key the module system already defines for it. There is no product-visible difference: `limesurvey-admin`'s PATH is byte-identical before and after, and `surveys-brand` previously produced no configuration at all (eval refused). Rules 1 and 2 self-checked against the rails' own regexes in `.sandcastle/rehearsal-heal-lib.sh`: no removed or edited assertion/expectation line (I reverted one reworded `t.Fatalf` message to keep it byte-identical), no removed test or leg declaration, no added skip; 3 files, 25 changed non-test lines, exactly one commit, no `.sandcastle/rehearsal-*` or `.forgejo/workflows/` touched. Not pushed. Built on the workstation (never the drive host) and closed through the close-report gate — the same gate a swarm worker passes. drive `20260908T164009Z` red at `deploy-surveys` (sig 119db33993c0) — self-fixed on the fast lane, commit `f99c325ee195462891408c0bc561d9673636512b`; checks: targeted (red-first): `IDSS_EVAL_SMOKE=1 go test ./internal/clan/ -run TestSurveysCohost_EvalSmoke -v` → FAIL before the fix (97.65s), reproducing the drive's exact sentence: "The option `systemd.services.surveys-brand.environment.PATH' has conflicting definition values" — same 8-package vs 5-package values, at `… while evaluating the option systemd.units."surveys-brand.service".text`. PASS after (34.88s): toplevel evaluated to `/nix/store/8ijby2gkggdy94l6jmcrlshdv1102cy3-nixos-system-gateway-26.11.20260612.173d0ad.drv`; "surveys environment guard passed: LIMESURVEY_CONFIG inherited by both oneshots, PATH generated from `path` alone"; the #1322 config.config merge guard still passes; the teeth half still fails on the phantom `uploadsDir` as it should. package: `go test ./internal/clan/` → ok (18.4s), all 11 `TestRenderSurveys_*` PASS. trees: `go test ./internal/... ./control-plane/...` → no failures. root cause verified against the pinned nixpkgs source (`/nix/store/lr5ld8f0qbyhjx3nr9mxfvg4cndvpggp-source`): `nixos/lib/systemd-lib.nix:660` defines `environment.PATH = mkIf (config.path != []) …` at normal priority, `:708-720` `stage2ServiceConfig` mkAfter-appends the 5 default packages to every service's `path`; `nixos/modules/services/web-apps/limesurvey.nix:327-333` shows limesurvey-init declares only DBENGINE + LIMESURVEY_CONFIG and no `path`, which is why its evaluated environment carries the default-5 PATH the render was copying. `go build ./...` → clean; `go vet ./internal/clan/` → clean; `gofmt -l internal/clan/` → clean. commit shape: 3 files, 25 changed non-test lines (`internal/clan/surveys.go` 20/5; `surveys_eval_test.go` 128/0; `surveys_test.go` 27/2), one commit, not pushed. rails self-check with the lib's own regexes → rule 1 NONE on all three patterns (removed assertion/expectation, removed test/leg declaration, added skip); no `.sandcastle/rehearsal-*` or `.forgejo/workflows/` path in the diff.. evidence: `/home/swarm/swarm/Matou/idss/test-results/private-path/20260908T164009Z` on matou-workstation. <!-- rehearsal-sig: 119db33993c0 -->
Author
Member

close-report for #1329 — status success

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

envelope
{
  "issue": 1329,
  "status": "success",
  "commits": [
    "f99c325ee195462891408c0bc561d9673636512b"
  ],
  "changed_files": [
    "internal/clan/surveys.go",
    "internal/clan/surveys_eval_test.go",
    "internal/clan/surveys_test.go"
  ],
  "tests": [
    {
      "command": "targeted (red-first): `IDSS_EVAL_SMOKE=1 go test ./internal/clan/ -run TestSurveysCohost_EvalSmoke -v` → FAIL before the fix (97.65s), reproducing the drive's exact sentence: \"The option `systemd.services.surveys-brand.environment.PATH' has conflicting definition values\" — same 8-package vs 5-package values, at `… while evaluating the option systemd.units.\"surveys-brand.service\".text`. PASS after (34.88s): toplevel evaluated to `/nix/store/8ijby2gkggdy94l6jmcrlshdv1102cy3-nixos-system-gateway-26.11.20260612.173d0ad.drv`; \"surveys environment guard passed: LIMESURVEY_CONFIG inherited by both oneshots, PATH generated from `path` alone\"; the #1322 config.config merge guard still passes; the teeth half still fails on the phantom `uploadsDir` as it should. package: `go test ./internal/clan/` → ok (18.4s), all 11 `TestRenderSurveys_*` PASS. trees: `go test ./internal/... ./control-plane/...` → no failures. root cause verified against the pinned nixpkgs source (`/nix/store/lr5ld8f0qbyhjx3nr9mxfvg4cndvpggp-source`): `nixos/lib/systemd-lib.nix:660` defines `environment.PATH = mkIf (config.path != []) …` at normal priority, `:708-720` `stage2ServiceConfig` mkAfter-appends the 5 default packages to every service's `path`; `nixos/modules/services/web-apps/limesurvey.nix:327-333` shows limesurvey-init declares only DBENGINE + LIMESURVEY_CONFIG and no `path`, which is why its evaluated environment carries the default-5 PATH the render was copying. `go build ./...` → clean; `go vet ./internal/clan/` → clean; `gofmt -l internal/clan/` → clean. commit shape: 3 files, 25 changed non-test lines (`internal/clan/surveys.go` 20/5; `surveys_eval_test.go` 128/0; `surveys_test.go` 27/2), one commit, not pushed. rails self-check with the lib's own regexes → rule 1 NONE on all three patterns (removed assertion/expectation, removed test/leg declaration, added skip); no `.sandcastle/rehearsal-*` or `.forgejo/workflows/` path in the diff.",
      "exit_code": 0
    }
  ],
  "criteria": {
    "the red leg is now green": "healed on the fast lane, commit f99c325ee195462891408c0bc561d9673636512b"
  },
  "summary": "The #1326 surveys-brand oneshot set `path` AND copied limesurvey-init's already-PATH-bearing environment, giving `environment.PATH` two unequal normal-priority definitions so the gateway was excluded at the eval preflight; both it and limesurvey-admin now strip PATH from the inherited env and let `path` be the single definition, and the eval smoke now lands a brand kit so the previously-dead `mkIf haveBrand` branch is actually evaluated.",
  "blockers": []
}
**close-report** for #1329 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1329, "status": "success", "commits": [ "f99c325ee195462891408c0bc561d9673636512b" ], "changed_files": [ "internal/clan/surveys.go", "internal/clan/surveys_eval_test.go", "internal/clan/surveys_test.go" ], "tests": [ { "command": "targeted (red-first): `IDSS_EVAL_SMOKE=1 go test ./internal/clan/ -run TestSurveysCohost_EvalSmoke -v` → FAIL before the fix (97.65s), reproducing the drive's exact sentence: \"The option `systemd.services.surveys-brand.environment.PATH' has conflicting definition values\" — same 8-package vs 5-package values, at `… while evaluating the option systemd.units.\"surveys-brand.service\".text`. PASS after (34.88s): toplevel evaluated to `/nix/store/8ijby2gkggdy94l6jmcrlshdv1102cy3-nixos-system-gateway-26.11.20260612.173d0ad.drv`; \"surveys environment guard passed: LIMESURVEY_CONFIG inherited by both oneshots, PATH generated from `path` alone\"; the #1322 config.config merge guard still passes; the teeth half still fails on the phantom `uploadsDir` as it should. package: `go test ./internal/clan/` → ok (18.4s), all 11 `TestRenderSurveys_*` PASS. trees: `go test ./internal/... ./control-plane/...` → no failures. root cause verified against the pinned nixpkgs source (`/nix/store/lr5ld8f0qbyhjx3nr9mxfvg4cndvpggp-source`): `nixos/lib/systemd-lib.nix:660` defines `environment.PATH = mkIf (config.path != []) …` at normal priority, `:708-720` `stage2ServiceConfig` mkAfter-appends the 5 default packages to every service's `path`; `nixos/modules/services/web-apps/limesurvey.nix:327-333` shows limesurvey-init declares only DBENGINE + LIMESURVEY_CONFIG and no `path`, which is why its evaluated environment carries the default-5 PATH the render was copying. `go build ./...` → clean; `go vet ./internal/clan/` → clean; `gofmt -l internal/clan/` → clean. commit shape: 3 files, 25 changed non-test lines (`internal/clan/surveys.go` 20/5; `surveys_eval_test.go` 128/0; `surveys_test.go` 27/2), one commit, not pushed. rails self-check with the lib's own regexes → rule 1 NONE on all three patterns (removed assertion/expectation, removed test/leg declaration, added skip); no `.sandcastle/rehearsal-*` or `.forgejo/workflows/` path in the diff.", "exit_code": 0 } ], "criteria": { "the red leg is now green": "healed on the fast lane, commit f99c325ee195462891408c0bc561d9673636512b" }, "summary": "The #1326 surveys-brand oneshot set `path` AND copied limesurvey-init's already-PATH-bearing environment, giving `environment.PATH` two unequal normal-priority definitions so the gateway was excluded at the eval preflight; both it and limesurvey-admin now strip PATH from the inherited env and let `path` be the single definition, and the eval smoke now lands a brand kit so the previously-dead `mkIf haveBrand` branch is actually evaluated.", "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#1329
No description provided.