Rendered machine modules assert their own invariants, with remedies in domain vocabulary #419

Closed
opened 2026-08-10 21:14:50 +00:00 by ben · 1 comment
Owner

The rendered Nix carries no assertions at all — the only render-time guard is a Go-side panic() in renderGatewayGuest. Meanwhile every deploy and enrollment already runs a per-node nix eval (the Readiness gate, internal/clan/adapter.go — the thing docs/architecture/10-change-flow.md credits with inverting clan's worst property). Assertions emitted into the rendered modules would ride that existing gate for free and fail with an operator-legible message instead of a missing-var stack.

The reference pattern is the mauke library's modules/topology.nix / mesh.nix: derive membership from one source, then defend it with build-time assertions whose messages name the fix.

Acceptance criteria

  • The renders emit assertions for invariants OurCloud already holds in Go — starting set: the gateway node's required generators/files are declared; a service render's front-door route and mesh port agree; ADR 0112's "no declared check, no activation" gets a build-time echo of the Go enforcement in internal/provision/health.go.
  • Every assertion message names the remedy in CONTEXT.md vocabulary (what the operator or agent should do, not just what's wrong).
  • Eval-affecting: prove via the existing eval smoke (OURCLOUD_EVAL_SMOKE=1, seedcommunity_eval_test.go) that a fixture violating an invariant fails eval with the message, and the healthy fixture still evaluates.

Source: the clan-community (mauke reference fleet) lessons review, docs/research/2026-08-10-clan-community-lessons.md (lands on main this sitting), lesson 11.

The rendered Nix carries **no `assertions` at all** — the only render-time guard is a Go-side `panic()` in `renderGatewayGuest`. Meanwhile every deploy and enrollment already runs a per-node `nix eval` (the Readiness gate, `internal/clan/adapter.go` — the thing `docs/architecture/10-change-flow.md` credits with inverting clan's worst property). Assertions emitted into the rendered modules would ride that existing gate for free and fail with an operator-legible message instead of a missing-var stack. The reference pattern is the mauke library's `modules/topology.nix` / `mesh.nix`: derive membership from one source, then defend it with build-time `assertions` whose messages name the fix. **Acceptance criteria** - The renders emit `assertions` for invariants OurCloud already holds in Go — starting set: the gateway node's required generators/files are declared; a service render's front-door route and mesh port agree; ADR 0112's "no declared check, no activation" gets a build-time echo of the Go enforcement in `internal/provision/health.go`. - Every assertion message names the remedy in CONTEXT.md vocabulary (what the operator or agent should do, not just what's wrong). - Eval-affecting: prove via the existing eval smoke (`OURCLOUD_EVAL_SMOKE=1`, `seedcommunity_eval_test.go`) that a fixture violating an invariant fails eval with the message, and the healthy fixture still evaluates. _Source: the clan-community (mauke reference fleet) lessons review, `docs/research/2026-08-10-clan-community-lessons.md` (lands on main this sitting), lesson 11._
Author
Owner

Landed on main in a41ba50.

renderGatewayGuest now emits a build-time assertions block that rides the existing per-node eval gate (Adapter.readinessAts nix eval …toplevel, run as the enrollment preflight and Deploys per-node gate) — no new machinery. The mauke pattern (modules/topology.nix): derive from one source, defend it with assertions whose messages name the fix in CONTEXT.md vocabulary.

The starting set, all homed in the gateway baseline (the richest render the VM eval smoke exercises):

  • generators/files declared — the kanidm-tls {cert,key,ca} and kanidm-admins {admin,idm_admin} generators this module dereferences (the /etc secret/CA pointers, services.kanidm, the brand push);
  • front-door route ↔ mesh port agree — kanidm binds the loopback port the front door`s id. sign-in route proxies to (privateKanidmLoopbackPort, frontdoor.go); the assertion is built FROM that const so the two cannot drift silently;
  • ADR 0112 echo — no declared check, no activation (internal/provision/health.go): the routed IdP must be enabled AND provisioned, never activated on hope.

Proven via the eval smoke:

  • healthy fixture still evaluates (TestSeedCommunity_EvalSmoke), and the #421 drvPath baseline is BIT-IDENTICAL — passing assertions are pure eval-time guards, so the closure is unchanged (no baseline re-record);
  • a violating fixture (kanidm bound to :9999) fails nix eval with the assertion`s remedy message — new TestGatewayAssertions_EvalCatchesViolation, which asserts the failure carries the operator-legible remedy.

Files: internal/clan/vmguest.go (gatewayAssertions + render seam tests in vmguest_test.go), seedcommunity_eval_test.go (negative eval), STATUS.md.

Landed on main in a41ba50. `renderGatewayGuest` now emits a build-time `assertions` block that rides the existing per-node eval gate (Adapter.readinessAt`s `nix eval …toplevel`, run as the enrollment preflight and Deploy`s per-node gate) — no new machinery. The mauke pattern (modules/topology.nix): derive from one source, defend it with assertions whose messages name the fix in CONTEXT.md vocabulary. The starting set, all homed in the gateway baseline (the richest render the VM eval smoke exercises): - **generators/files declared** — the kanidm-tls {cert,key,ca} and kanidm-admins {admin,idm_admin} generators this module dereferences (the /etc secret/CA pointers, services.kanidm, the brand push); - **front-door route ↔ mesh port agree** — kanidm binds the loopback port the front door`s id.<apex> sign-in route proxies to (privateKanidmLoopbackPort, frontdoor.go); the assertion is built FROM that const so the two cannot drift silently; - **ADR 0112 echo** — `no declared check, no activation` (internal/provision/health.go): the routed IdP must be enabled AND provisioned, never activated on hope. **Proven via the eval smoke:** - healthy fixture still evaluates (TestSeedCommunity_EvalSmoke), and the #421 drvPath baseline is BIT-IDENTICAL — passing assertions are pure eval-time guards, so the closure is unchanged (no baseline re-record); - a violating fixture (kanidm bound to :9999) fails `nix eval` with the assertion`s remedy message — new TestGatewayAssertions_EvalCatchesViolation, which asserts the failure carries the operator-legible remedy. Files: internal/clan/vmguest.go (gatewayAssertions + render seam tests in vmguest_test.go), seedcommunity_eval_test.go (negative eval), STATUS.md.
ben closed this issue 2026-08-10 22:29:02 +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.

Dependencies

No dependencies set.

Reference
Matou/idss#419
No description provided.