deploy-surveys: the surveys port's own two units break the switch — limesurvey-admin runs nixpkgs' console.php with no LIMESURVEY_CONFIG, and surveys-brand cannot write under the root-owned Nix-store copy nixpkgs seeds upload/ from #1319

Closed
opened 2026-09-08 10:49:35 +00:00 by matou-build-agent · 1 comment

The failure

Drive 20260908T092408Z (drive 8, #1277, on d2830225): 20 legs green, red at deploy-surveys — clan: masked_exit on gateway, the remote switch dead at exit 4 (artifacts/legs.json, leg 21; artifacts/verdict.json firstRedLeg: deploy-surveys, 20 green / 1 red).

#1318's eval repair held: the gateway co-hosting surveys.nix evaluated and the LimeSurvey daemon deployed. What failed were the only two units the surveys port adds itself — each dying twice inside the switch, and each outside every assertion nixpkgs wrote:

limesurvey-admin-start[20611]: Fatal error: Uncaught ValueError: Path must not be empty in
  /nix/store/inj1nizfn0jwpnlid0sfz3r360bp2khh-limesurvey-6.15.14+250924/share/limesurvey/application/config/config.php:2
systemd[1]: Failed to start Bootstrap the LimeSurvey admin service identity from a clan var (surveys port, ADR 0062).
surveys-brand-start[20613]: install: cannot create directory '/var/lib/limesurvey/upload/themes/survey/idss_brand': Permission denied   (x3)
systemd[1]: Failed to start Land the community brand survey theme into LimeSurvey's writable upload dir (surveys port, DDR 0225).

Evidence and cause

(1) limesurvey-admin ran with an empty environment. nixpkgs' limesurvey package replaces application/config/config.php with a two-line require(getenv("LIMESURVEY_CONFIG")), and the module hands that env to every consumer it owns — systemd.services.limesurvey-init.environment.LIMESURVEY_CONFIG (nixos/modules/services/web-apps/limesurvey.nix:332) and services.phpfpm.pools.limesurvey.phpEnv.LIMESURVEY_CONFIG (:420). renderLimeSurveyAdmin (internal/clan/surveys.go:407-432 pre-fix) ran the same console.php with no environment at all, so getenv returned false, require("") raised the ValueError, and php aborted before resetpassword was ever dispatched. The three x3 messages in (2) confirm the parent dirs existed — one message per install -d argument.

(2) surveys-brand could not create its theme dir. The module seeds the writable upload dir with a tmpfiles copy of the package's own tree — "C ${stateDir}/upload 0750 ${user} ${group} - ${cfg.package}/share/limesurvey/upload" (limesurvey.nix:438) — and systemd's copy preserves the source's mode and owner on everything below the copied root: Nix store dirs are root:root dr-xr-xr-x. Only upload/ itself received the rule's 0750 limesurvey:wwwrun; upload/themes/survey stayed root-owned and unwritable, so the oneshot's User = limesurvey (internal/clan/surveys.go:331) could not install -d beneath it.

Verified locally against systemd 259: a C copy from a read-only source reproduces the mode preservation, and systemd-tmpfiles processes a path's parent item before the path's own (with z lines listed ahead of the C line, the copy still landed first and the z rules then adjusted).

Suspected layer

The surveys port's declarative render, internal/clan/surveys.go — specifically the two units the port adds beside services.limesurvey. This is the sibling of GOTCHAS #191 one layer down: an eval smoke proves the options are real, not that the units run.

The repair (landed)

  • limesurvey-admin takes environment = config.systemd.services.limesurvey-init.environment; verbatim (one home for the config store path), runs under config.services.phpfpm.pools.limesurvey.phpPackage (nixpkgs pins LimeSurvey to php83; pkgs.php is a floating alias), and is handed CREDENTIALS_DIRECTORY=/var/lib/limesurvey/credentials on the command line — systemd points the unit's own $CREDENTIALS_DIRECTORY at its LoadCredential dir, which holds only the admin password, while config.php reads the encryption key/nonce from the daemon's dir.
  • Two z tmpfiles rules re-own upload/themes and upload/themes/survey to the same limesurvey wwwrun 0750 nixpkgs gives upload/ itself. z adjusts an existing path and never creates one: a creating d rule could make upload/ non-empty before the C runs, and C skips a non-empty target — every stock theme silently lost.
  • GOTCHAS #192 records the class.

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

Two-way and mechanical, not a design decision. Revertible how: git revert 7bd371dc restores the previous render byte-for-byte — the change adds a Environment= line and two z tmpfiles rules to a generated NixOS module, touches no route, no secrets shape, no message a community sees, no security posture (the oneshot keeps User = limesurvey; nothing gains privilege, and the re-owned dirs get exactly the limesurvey:wwwrun 0750 nixpkgs already gives their parent). Proven by which test: TestRenderSurveys_AdminConsoleCarriesLimeSurveyConfigEnv and TestRenderSurveys_BrandThemeParentsAreWritableByLimeSurvey (both written first, both watched fail on the pre-fix render), plus the existing real-nixpkgs TestSurveysCohost_EvalSmoke, which now evaluates the co-hosted gateway to a drvPath — proving the three new config reads (systemd.services.limesurvey-init.environment, services.phpfpm.pools.limesurvey.phpPackage, users.users.limesurvey.group) resolve without recursion. Beyond the tests I read the built artifacts of that eval: the rendered unit carries Environment="LIMESURVEY_CONFIG=/nix/store/in36sfliyb3zc7fgcfd457zsqiplynqy-config.php", and the built tmpfiles.d carries z /var/lib/limesurvey/upload/themes 0750 limesurvey wwwrun - - beside nixpkgs' own C /var/lib/limesurvey/upload … /nix/store/inj1nizfn0jwpnlid0sfz3r360bp2khh-limesurvey-6.15.14+250924/share/limesurvey/upload — the identical package store path the failing drive's journal names. Why mechanical: the module already meant to bootstrap the admin identity and land the brand theme; it simply never gave php the env nixpkgs' own consumers get, and never accounted for the store's read-only ownership surviving nixpkgs' seed copy. The code is made to do what it already meant to do — no new default, no changed trust moment, no one-way door. Built on the workstation (never the drive host) and closed through the close-report gate — the same gate a swarm worker passes.

drive 20260908T092408Z red at deploy-surveys (sig 119db33993c0) — self-fixed on the fast lane, commit 409b233ef50695a605b34a57ef5f1d65a9c638c5; checks: targeted (red-first): go test ./internal/clan/ -run 'TestRenderSurveys_AdminConsoleCarriesLimeSurveyConfigEnv|TestRenderSurveys_BrandThemeParentsAreWritableByLimeSurvey' -v → FAIL before the fix (surveys_test.go:136: the admin console must inherit limesurvey-init's environment (LIMESURVEY_CONFIG, #1319) and surveys_test.go:167: the brand theme's parent dirs must be re-owned writable by limesurvey ("z /var/lib/limesurvey/upload/themes 0750 limesurvey ${config.users.users.limesurvey.group} - -")), PASS after. package: go test ./internal/clan/ → ok (17.986s), all 10 TestRenderSurveys_* PASS. tree: go test ./internal/... → no failures. real-nixpkgs eval: IDSS_EVAL_SMOKE=1 go test ./internal/clan/ -run TestSurveysCohost_EvalSmoke -v → PASS (44.33s) — positive half evaluated the co-hosted gateway to /nix/store/gs0378ih7cv44z69shxfiqvs5v06c3iw-nixos-system-gateway-26.11.20260612.173d0ad.drv, teeth half still fails on the phantom uploadsDir. built-artifact check on that drv: unit-limesurvey-admin.service.drv carries LIMESURVEY_CONFIG=/nix/store/in36sfliyb3zc7fgcfd457zsqiplynqy-config.php; nixos-tmpfiles.d.drv carries both z /var/lib/limesurvey/upload/themes{,/survey} 0750 limesurvey wwwrun - -. go build ./... → clean; go vet ./internal/clan/ → clean; gofmt -l internal/clan/ → clean. Commit shape: 3 files, 68 changed non-test lines (internal/clan/surveys.go 57/3, docs/GOTCHAS.md 8/0), one commit, not pushed; rails self-check → no removed or edited assertion/expectation line (the test file is additions only, 50/0), no removed test or leg declaration, no added skip.. evidence: /home/swarm/swarm/Matou/idss/test-results/private-path/20260908T092408Z on matou-workstation.

## The failure Drive `20260908T092408Z` (drive 8, #1277, on `d2830225`): 20 legs green, red at `deploy-surveys` — `clan: masked_exit on gateway`, the remote switch dead at **exit 4** (`artifacts/legs.json`, leg 21; `artifacts/verdict.json` `firstRedLeg: deploy-surveys`, 20 green / 1 red). #1318's eval repair **held**: the gateway co-hosting `surveys.nix` evaluated and the LimeSurvey daemon deployed. What failed were the only two units the surveys port adds *itself* — each dying twice inside the switch, and each outside every assertion nixpkgs wrote: ``` limesurvey-admin-start[20611]: Fatal error: Uncaught ValueError: Path must not be empty in /nix/store/inj1nizfn0jwpnlid0sfz3r360bp2khh-limesurvey-6.15.14+250924/share/limesurvey/application/config/config.php:2 systemd[1]: Failed to start Bootstrap the LimeSurvey admin service identity from a clan var (surveys port, ADR 0062). surveys-brand-start[20613]: install: cannot create directory '/var/lib/limesurvey/upload/themes/survey/idss_brand': Permission denied (x3) systemd[1]: Failed to start Land the community brand survey theme into LimeSurvey's writable upload dir (surveys port, DDR 0225). ``` ## Evidence and cause **(1) `limesurvey-admin` ran with an empty environment.** nixpkgs' limesurvey *package* replaces `application/config/config.php` with a two-line `require(getenv("LIMESURVEY_CONFIG"))`, and the module hands that env to every consumer it owns — `systemd.services.limesurvey-init.environment.LIMESURVEY_CONFIG` (`nixos/modules/services/web-apps/limesurvey.nix:332`) and `services.phpfpm.pools.limesurvey.phpEnv.LIMESURVEY_CONFIG` (`:420`). `renderLimeSurveyAdmin` (`internal/clan/surveys.go:407-432` pre-fix) ran the **same** `console.php` with no `environment` at all, so `getenv` returned `false`, `require("")` raised the ValueError, and php aborted before `resetpassword` was ever dispatched. The three `x3` messages in (2) confirm the parent dirs existed — one message per `install -d` argument. **(2) `surveys-brand` could not create its theme dir.** The module seeds the writable upload dir with a tmpfiles **copy** of the package's own tree — `"C ${stateDir}/upload 0750 ${user} ${group} - ${cfg.package}/share/limesurvey/upload"` (`limesurvey.nix:438`) — and systemd's copy preserves the **source's** mode and owner on everything below the copied root: Nix store dirs are `root:root dr-xr-xr-x`. Only `upload/` itself received the rule's `0750 limesurvey:wwwrun`; `upload/themes/survey` stayed root-owned and unwritable, so the oneshot's `User = limesurvey` (`internal/clan/surveys.go:331`) could not `install -d` beneath it. Verified locally against systemd 259: a `C` copy from a read-only source reproduces the mode preservation, and systemd-tmpfiles processes a path's **parent** item before the path's own (with `z` lines listed *ahead* of the `C` line, the copy still landed first and the `z` rules then adjusted). ## Suspected layer The surveys port's declarative render, `internal/clan/surveys.go` — specifically the two units the port adds beside `services.limesurvey`. This is the sibling of GOTCHAS #191 one layer down: an eval smoke proves the *options* are real, not that the *units run*. ## The repair (landed) - `limesurvey-admin` takes `environment = config.systemd.services.limesurvey-init.environment;` verbatim (one home for the config store path), runs under `config.services.phpfpm.pools.limesurvey.phpPackage` (nixpkgs pins LimeSurvey to php83; `pkgs.php` is a floating alias), and is handed `CREDENTIALS_DIRECTORY=/var/lib/limesurvey/credentials` on the command line — systemd points the unit's own `$CREDENTIALS_DIRECTORY` at its `LoadCredential` dir, which holds only the admin password, while `config.php` reads the encryption key/nonce from the daemon's dir. - Two `z` tmpfiles rules re-own `upload/themes` and `upload/themes/survey` to the same `limesurvey wwwrun` `0750` nixpkgs gives `upload/` itself. `z` **adjusts** an existing path and never creates one: a creating `d` rule could make `upload/` non-empty before the `C` runs, and `C` skips a non-empty target — every stock theme silently lost. - GOTCHAS #192 records the class. ## Proposed ruling (Ruled by the healer under ADR 0174 — veto anytime) Two-way and mechanical, not a design decision. **Revertible how:** `git revert 7bd371dc` restores the previous render byte-for-byte — the change adds a `Environment=` line and two `z` tmpfiles rules to a generated NixOS module, touches no route, no secrets shape, no message a community sees, no security posture (the oneshot keeps `User = limesurvey`; nothing gains privilege, and the re-owned dirs get exactly the `limesurvey:wwwrun 0750` nixpkgs already gives their parent). **Proven by which test:** `TestRenderSurveys_AdminConsoleCarriesLimeSurveyConfigEnv` and `TestRenderSurveys_BrandThemeParentsAreWritableByLimeSurvey` (both written first, both watched fail on the pre-fix render), plus the existing real-nixpkgs `TestSurveysCohost_EvalSmoke`, which now evaluates the co-hosted gateway to a drvPath — proving the three new config reads (`systemd.services.limesurvey-init.environment`, `services.phpfpm.pools.limesurvey.phpPackage`, `users.users.limesurvey.group`) resolve without recursion. Beyond the tests I read the built artifacts of that eval: the rendered unit carries `Environment="LIMESURVEY_CONFIG=/nix/store/in36sfliyb3zc7fgcfd457zsqiplynqy-config.php"`, and the built tmpfiles.d carries `z /var/lib/limesurvey/upload/themes 0750 limesurvey wwwrun - -` beside nixpkgs' own `C /var/lib/limesurvey/upload … /nix/store/inj1nizfn0jwpnlid0sfz3r360bp2khh-limesurvey-6.15.14+250924/share/limesurvey/upload` — the identical package store path the failing drive's journal names. **Why mechanical:** the module already meant to bootstrap the admin identity and land the brand theme; it simply never gave php the env nixpkgs' own consumers get, and never accounted for the store's read-only ownership surviving nixpkgs' seed copy. The code is made to do what it already meant to do — no new default, no changed trust moment, no one-way door. Built on the workstation (never the drive host) and closed through the close-report gate — the same gate a swarm worker passes. drive `20260908T092408Z` red at `deploy-surveys` (sig 119db33993c0) — self-fixed on the fast lane, commit `409b233ef50695a605b34a57ef5f1d65a9c638c5`; checks: targeted (red-first): `go test ./internal/clan/ -run 'TestRenderSurveys_AdminConsoleCarriesLimeSurveyConfigEnv|TestRenderSurveys_BrandThemeParentsAreWritableByLimeSurvey' -v` → FAIL before the fix (`surveys_test.go:136: the admin console must inherit limesurvey-init's environment (LIMESURVEY_CONFIG, #1319)` and `surveys_test.go:167: the brand theme's parent dirs must be re-owned writable by limesurvey ("z /var/lib/limesurvey/upload/themes 0750 limesurvey ${config.users.users.limesurvey.group} - -")`), PASS after. package: `go test ./internal/clan/` → ok (17.986s), all 10 `TestRenderSurveys_*` PASS. tree: `go test ./internal/...` → no failures. real-nixpkgs eval: `IDSS_EVAL_SMOKE=1 go test ./internal/clan/ -run TestSurveysCohost_EvalSmoke -v` → PASS (44.33s) — positive half evaluated the co-hosted gateway to `/nix/store/gs0378ih7cv44z69shxfiqvs5v06c3iw-nixos-system-gateway-26.11.20260612.173d0ad.drv`, teeth half still fails on the phantom `uploadsDir`. built-artifact check on that drv: `unit-limesurvey-admin.service.drv` carries `LIMESURVEY_CONFIG=/nix/store/in36sfliyb3zc7fgcfd457zsqiplynqy-config.php`; `nixos-tmpfiles.d.drv` carries both `z /var/lib/limesurvey/upload/themes{,/survey} 0750 limesurvey wwwrun - -`. `go build ./...` → clean; `go vet ./internal/clan/` → clean; `gofmt -l internal/clan/` → clean. Commit shape: 3 files, 68 changed non-test lines (`internal/clan/surveys.go` 57/3, `docs/GOTCHAS.md` 8/0), one commit, not pushed; rails self-check → no removed or edited assertion/expectation line (the test file is additions only, 50/0), no removed test or leg declaration, no added skip.. evidence: `/home/swarm/swarm/Matou/idss/test-results/private-path/20260908T092408Z` on matou-workstation. <!-- rehearsal-sig: 119db33993c0 -->
Author
Member

close-report for #1319 — status success

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

envelope
{
  "issue": 1319,
  "status": "success",
  "commits": [
    "409b233ef50695a605b34a57ef5f1d65a9c638c5"
  ],
  "changed_files": [
    "docs/GOTCHAS.md",
    "internal/clan/surveys.go",
    "internal/clan/surveys_test.go"
  ],
  "tests": [
    {
      "command": "targeted (red-first): `go test ./internal/clan/ -run 'TestRenderSurveys_AdminConsoleCarriesLimeSurveyConfigEnv|TestRenderSurveys_BrandThemeParentsAreWritableByLimeSurvey' -v` → FAIL before the fix (`surveys_test.go:136: the admin console must inherit limesurvey-init's environment (LIMESURVEY_CONFIG, #1319)` and `surveys_test.go:167: the brand theme's parent dirs must be re-owned writable by limesurvey (\"z /var/lib/limesurvey/upload/themes 0750 limesurvey ${config.users.users.limesurvey.group} - -\")`), PASS after. package: `go test ./internal/clan/` → ok (17.986s), all 10 `TestRenderSurveys_*` PASS. tree: `go test ./internal/...` → no failures. real-nixpkgs eval: `IDSS_EVAL_SMOKE=1 go test ./internal/clan/ -run TestSurveysCohost_EvalSmoke -v` → PASS (44.33s) — positive half evaluated the co-hosted gateway to `/nix/store/gs0378ih7cv44z69shxfiqvs5v06c3iw-nixos-system-gateway-26.11.20260612.173d0ad.drv`, teeth half still fails on the phantom `uploadsDir`. built-artifact check on that drv: `unit-limesurvey-admin.service.drv` carries `LIMESURVEY_CONFIG=/nix/store/in36sfliyb3zc7fgcfd457zsqiplynqy-config.php`; `nixos-tmpfiles.d.drv` carries both `z /var/lib/limesurvey/upload/themes{,/survey} 0750 limesurvey wwwrun - -`. `go build ./...` → clean; `go vet ./internal/clan/` → clean; `gofmt -l internal/clan/` → clean. Commit shape: 3 files, 68 changed non-test lines (`internal/clan/surveys.go` 57/3, `docs/GOTCHAS.md` 8/0), one commit, not pushed; rails self-check → no removed or edited assertion/expectation line (the test file is additions only, 50/0), no removed test or leg declaration, no added skip.",
      "exit_code": 0
    }
  ],
  "criteria": {
    "the red leg is now green": "healed on the fast lane, commit 409b233ef50695a605b34a57ef5f1d65a9c638c5"
  },
  "summary": "The surveys port's two own units were switch-fatal: `limesurvey-admin` invoked nixpkgs' `console.php` with no `LIMESURVEY_CONFIG` (its `config.php` is `require(getenv …)`, so php died at `config.php:2` with \"Path must not be empty\"), and `surveys-brand` could not create its theme dir because nixpkgs seeds `upload/` by copying the read-only Nix store, leaving `upload/themes/survey` root-owned — the unit now inherits `limesurvey-init`'s environment, runs the phpfpm pool's php with the daemon's credentials dir, and two `z` tmpfiles rules re-own the two theme parents to `limesurvey wwwrun 0750`.",
  "blockers": []
}
**close-report** for #1319 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1319, "status": "success", "commits": [ "409b233ef50695a605b34a57ef5f1d65a9c638c5" ], "changed_files": [ "docs/GOTCHAS.md", "internal/clan/surveys.go", "internal/clan/surveys_test.go" ], "tests": [ { "command": "targeted (red-first): `go test ./internal/clan/ -run 'TestRenderSurveys_AdminConsoleCarriesLimeSurveyConfigEnv|TestRenderSurveys_BrandThemeParentsAreWritableByLimeSurvey' -v` → FAIL before the fix (`surveys_test.go:136: the admin console must inherit limesurvey-init's environment (LIMESURVEY_CONFIG, #1319)` and `surveys_test.go:167: the brand theme's parent dirs must be re-owned writable by limesurvey (\"z /var/lib/limesurvey/upload/themes 0750 limesurvey ${config.users.users.limesurvey.group} - -\")`), PASS after. package: `go test ./internal/clan/` → ok (17.986s), all 10 `TestRenderSurveys_*` PASS. tree: `go test ./internal/...` → no failures. real-nixpkgs eval: `IDSS_EVAL_SMOKE=1 go test ./internal/clan/ -run TestSurveysCohost_EvalSmoke -v` → PASS (44.33s) — positive half evaluated the co-hosted gateway to `/nix/store/gs0378ih7cv44z69shxfiqvs5v06c3iw-nixos-system-gateway-26.11.20260612.173d0ad.drv`, teeth half still fails on the phantom `uploadsDir`. built-artifact check on that drv: `unit-limesurvey-admin.service.drv` carries `LIMESURVEY_CONFIG=/nix/store/in36sfliyb3zc7fgcfd457zsqiplynqy-config.php`; `nixos-tmpfiles.d.drv` carries both `z /var/lib/limesurvey/upload/themes{,/survey} 0750 limesurvey wwwrun - -`. `go build ./...` → clean; `go vet ./internal/clan/` → clean; `gofmt -l internal/clan/` → clean. Commit shape: 3 files, 68 changed non-test lines (`internal/clan/surveys.go` 57/3, `docs/GOTCHAS.md` 8/0), one commit, not pushed; rails self-check → no removed or edited assertion/expectation line (the test file is additions only, 50/0), no removed test or leg declaration, no added skip.", "exit_code": 0 } ], "criteria": { "the red leg is now green": "healed on the fast lane, commit 409b233ef50695a605b34a57ef5f1d65a9c638c5" }, "summary": "The surveys port's two own units were switch-fatal: `limesurvey-admin` invoked nixpkgs' `console.php` with no `LIMESURVEY_CONFIG` (its `config.php` is `require(getenv …)`, so php died at `config.php:2` with \"Path must not be empty\"), and `surveys-brand` could not create its theme dir because nixpkgs seeds `upload/` by copying the read-only Nix store, leaving `upload/themes/survey` root-owned — the unit now inherits `limesurvey-init`'s environment, runs the phpfpm pool's php with the daemon's credentials dir, and two `z` tmpfiles rules re-own the two theme parents to `limesurvey wwwrun 0750`.", "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#1319
No description provided.