eval-preflight failures drop the real nix assertion — clan.Readiness carries no Tail, excerpt() cannot keep an assertion body line #629

Closed
opened 2026-08-21 02:22:47 +00:00 by matou-build-agent · 3 comments

What

The eval-preflight path (clan.Readiness / Adapter.evalReadiness in
internal/clan/adapter.go) drops the raw nix eval output entirely once it
classifies a failure. Unlike the deploy-apply path (clan.Failure.Tail,
internal/clan/adapter.go's classify()), the clan.Readiness struct
(internal/clan/clan.go:170) carries only Kind and Detail — no Tail
field — so the fuller raw log classify() computes internally
(f.Tail = tail(res.Output)) is computed and then discarded before it ever
reaches enrollment.go's preflight(), which builds s.Failure straight off
Readiness.Detail alone.

Detail itself is excerpt(res.Output) — an 8-line token grep
(internal/clan/adapter.go's excerpt()). Its token list ("error:",
"failed assertions", "attribute", "does not evaluate", …) reliably keeps
a Failed assertions: HEADER line, but a Nix assertion's own body line (e.g.
- services.kanidm.provision.systems.oauth2.gate-oidc.scopeMaps refers to unknown groups: idm_all_persons) carries none of those tokens unless the
assertion message text happens to include one by coincidence — so the actual
assertion, the one thing an operator or on-call agent needs to fix the
config, is silently dropped.

Evidence

Rehearsal drive 20260821T015833Z (#628) reds deploy-takeover on exactly
this path. founding-state.log's failure detail reads:

error:
… while evaluating the attribute 'value'
error:
Failed assertions:

— truncated with no assertion body at all. The real assertion was only
recoverable by re-running nix eval by hand against the drive's own captured
state/clan-config directory. No artifact the drive produces (legs.json,
founding-state.log, the operator-facing UI) carried the real cause.

Suggested shape

  • Add a Tail field to clan.Readiness (mirroring clan.Failure.Tail) and
    thread classify()'s already-computed tail through evalReadiness into it.
  • Carry Readiness.Tail into the clan.Failure enrollment.go's
    preflight() builds, the same way deploy.go already carries
    clan.Failure.Tail into DeployFailure.Tail for the apply path.
  • Consider widening excerpt()'s token match (or adding a dedicated
    "keep every line after a Failed assertions:/error: header, bounded")
    so a genuine assertion body survives the 8-line grep on its own, without
    needing the full Tail fallback.

Found and scoped by the #628 session-runner drive; not fixed there — a
different subsystem (observability/evidence-capture, not the config bug
itself).

## What The eval-preflight path (`clan.Readiness` / `Adapter.evalReadiness` in `internal/clan/adapter.go`) drops the raw `nix eval` output entirely once it classifies a failure. Unlike the deploy-apply path (`clan.Failure.Tail`, `internal/clan/adapter.go`'s `classify()`), the `clan.Readiness` struct (`internal/clan/clan.go:170`) carries only `Kind` and `Detail` — no `Tail` field — so the fuller raw log `classify()` computes internally (`f.Tail = tail(res.Output)`) is computed and then discarded before it ever reaches `enrollment.go`'s `preflight()`, which builds `s.Failure` straight off `Readiness.Detail` alone. `Detail` itself is `excerpt(res.Output)` — an 8-line token grep (`internal/clan/adapter.go`'s `excerpt()`). Its token list (`"error:"`, `"failed assertions"`, `"attribute"`, `"does not evaluate"`, …) reliably keeps a `Failed assertions:` HEADER line, but a Nix assertion's own body line (e.g. `- services.kanidm.provision.systems.oauth2.gate-oidc.scopeMaps refers to unknown groups: idm_all_persons`) carries none of those tokens unless the assertion message text happens to include one by coincidence — so the actual assertion, the one thing an operator or on-call agent needs to fix the config, is silently dropped. ## Evidence Rehearsal drive `20260821T015833Z` (#628) reds `deploy-takeover` on exactly this path. `founding-state.log`'s failure detail reads: ``` error: … while evaluating the attribute 'value' error: Failed assertions: ``` — truncated with no assertion body at all. The real assertion was only recoverable by re-running `nix eval` by hand against the drive's own captured `state/clan-config` directory. No artifact the drive produces (`legs.json`, `founding-state.log`, the operator-facing UI) carried the real cause. ## Suggested shape - Add a `Tail` field to `clan.Readiness` (mirroring `clan.Failure.Tail`) and thread `classify()`'s already-computed tail through `evalReadiness` into it. - Carry `Readiness.Tail` into the `clan.Failure` `enrollment.go`'s `preflight()` builds, the same way `deploy.go` already carries `clan.Failure.Tail` into `DeployFailure.Tail` for the apply path. - Consider widening `excerpt()`'s token match (or adding a dedicated "keep every line after a `Failed assertions:`/`error:` header, bounded") so a genuine assertion body survives the 8-line grep on its own, without needing the full `Tail` fallback. Found and scoped by the #628 session-runner drive; not fixed there — a different subsystem (observability/evidence-capture, not the config bug itself).
Author
Member

This was generated by AI during triage.

Triage: verified. internal/clan/adapter.go's classify() computes a bounded raw-output Tail (f.Tail = tail(res.Output)) and stores it on *Failure, but evalReadiness only reads f.Kind/f.Detail off that *Failure before discarding it and returning a Readiness — whose struct (internal/clan/clan.go) has no Tail field at all. enrollment.go's preflight() then builds s.Failure straight from Readiness.Kind/Readiness.Detail (no Tail), so the eval-preflight failure path is the one place *Failure.Tail — populated everywhere else — never makes it onto the wire. Confirms the issue's read of the code exactly; the suggested shape (add Tail to Readiness, thread it through) is the natural fix along the same seam the apply-path DeployFailure.Tail already uses.

Ruled by agent under ADR 0174 — veto anytime: classifying this bug / ready-for-agent rather than routing to a human. This is a two-way door — a typed-field addition and one extra assignment, revertible by a follow-up commit, and provable by the existing eval-preflight test coverage (extend it to assert Readiness.Tail/Failure.Tail is non-empty on a classified failure) plus a rehearsal drive reproducing #628's assertion-failure shape. No UX flow or wireframe is referenced (this is an internal observability/evidence-capture change), so the missing-design gate doesn't apply, and there's no task manifest with a needs_human_decision entry.

Agent Brief

Category: bug
Summary: Eval-preflight failures lose the raw Nix assertion body; only Readiness/Failure.Detail's 8-line token-grepped excerpt reaches disk/operator, never the fuller Tail the classify path already computes.

Current behavior:
When Adapter.evalReadiness classifies a failed nix eval during preflight, classify() internally computes a bounded raw-output tail and stores it as Failure.Tail, but evalReadiness discards that *Failure after reading only Kind and Detail, and returns a Readiness value whose type carries no tail field. enrollment.go's preflight() copies Readiness.Kind/Readiness.Detail into s.Failure, so the eval-preflight failure path's Failure.Tail is always empty — unlike the deploy-apply path, where Failure.Tail is populated and reaches DeployFailure.Tail. Detail's 8-line token grep (excerpt()) reliably keeps a Failed assertions: header line but drops the assertion's own body line unless it happens to contain one of the grep tokens, so a genuine Nix assertion message is silently absent from every artifact (legs.json, founding-state.log, the operator UI) a preflight failure produces.

Desired behavior:
An eval-preflight failure carries the same bounded raw-output tail that a deploy-apply failure already carries, so the real assertion body (or any other evidence outside excerpt()'s token list) survives into founding-state.log/legs.json and is visible to an operator or on-call agent without having to re-run nix eval by hand against a captured state/clan-config.

Key interfaces:

  • clan.Readiness (internal/clan/clan.go) — needs a Tail field, omitempty, mirroring Failure.Tail's shape and doc comment.
  • Adapter.evalReadiness (internal/clan/adapter.go) — thread the *Failure returned by classify() through into the new Readiness.Tail field, the same way Kind/Detail are threaded today.
  • enrollment.go's preflight() — carry Readiness.Tail into the Failure.Tail it builds for s.Failure, matching how deploy.go already carries Failure.Tail into DeployFailure.Tail for the apply path.
  • Optionally, widen excerpt()'s token match (or add a "keep every line after a Failed assertions:/error: header, bounded" rule) so a genuine assertion body survives the short grep on its own — the issue calls this out as a nice-to-have, not a substitute for the Tail fix.

Acceptance criteria:

  • Readiness carries a Tail field populated whenever evalReadiness classifies a failure, containing the same bounded tail classify() already computes.
  • preflight()'s s.Failure for an eval-preflight failure has a non-empty Tail whenever the underlying nix eval output is non-empty, matching the deploy-apply path's existing behavior.
  • A test reproducing #628's failure shape (a Nix assertion whose body line carries none of excerpt()'s grep tokens) shows the assertion body present in the resulting Failure.Tail, not just the Failed assertions: header in Detail.
  • Existing eval-preflight and deploy-apply failure-classification tests remain green — the change is additive to Readiness/Failure, not a reshaping of Detail's existing grep behavior.

Out of scope:

  • Rewriting or removing excerpt()'s token-grep Detail computation — Tail is a supplement, not a replacement, exactly as it already is for the deploy-apply path.
  • Any change to classify()'s classification order/tokens (connectivity before secrets, masked_exit handling) — untouched by this fix.
  • The rehearsal drive's own missing_var/sops.defaultGroups root cause (#628) — this ticket only fixes the evidence capture that #628's drive exposed, not the underlying config-eval failure itself.
> *This was generated by AI during triage.* **Triage:** verified. `internal/clan/adapter.go`'s `classify()` computes a bounded raw-output `Tail` (`f.Tail = tail(res.Output)`) and stores it on `*Failure`, but `evalReadiness` only reads `f.Kind`/`f.Detail` off that `*Failure` before discarding it and returning a `Readiness` — whose struct (`internal/clan/clan.go`) has no `Tail` field at all. `enrollment.go`'s `preflight()` then builds `s.Failure` straight from `Readiness.Kind`/`Readiness.Detail` (no `Tail`), so the eval-preflight failure path is the one place `*Failure.Tail` — populated everywhere else — never makes it onto the wire. Confirms the issue's read of the code exactly; the suggested shape (add `Tail` to `Readiness`, thread it through) is the natural fix along the same seam the apply-path `DeployFailure.Tail` already uses. Ruled by agent under ADR 0174 — veto anytime: classifying this `bug` / `ready-for-agent` rather than routing to a human. This is a two-way door — a typed-field addition and one extra assignment, revertible by a follow-up commit, and provable by the existing eval-preflight test coverage (extend it to assert `Readiness.Tail`/`Failure.Tail` is non-empty on a classified failure) plus a rehearsal drive reproducing #628's assertion-failure shape. No UX flow or wireframe is referenced (this is an internal observability/evidence-capture change), so the missing-design gate doesn't apply, and there's no task manifest with a `needs_human_decision` entry. ## Agent Brief **Category:** bug **Summary:** Eval-preflight failures lose the raw Nix assertion body; only `Readiness`/`Failure.Detail`'s 8-line token-grepped excerpt reaches disk/operator, never the fuller `Tail` the classify path already computes. **Current behavior:** When `Adapter.evalReadiness` classifies a failed `nix eval` during preflight, `classify()` internally computes a bounded raw-output tail and stores it as `Failure.Tail`, but `evalReadiness` discards that `*Failure` after reading only `Kind` and `Detail`, and returns a `Readiness` value whose type carries no tail field. `enrollment.go`'s `preflight()` copies `Readiness.Kind`/`Readiness.Detail` into `s.Failure`, so the eval-preflight failure path's `Failure.Tail` is always empty — unlike the deploy-apply path, where `Failure.Tail` is populated and reaches `DeployFailure.Tail`. `Detail`'s 8-line token grep (`excerpt()`) reliably keeps a `Failed assertions:` *header* line but drops the assertion's own body line unless it happens to contain one of the grep tokens, so a genuine Nix assertion message is silently absent from every artifact (`legs.json`, `founding-state.log`, the operator UI) a preflight failure produces. **Desired behavior:** An eval-preflight failure carries the same bounded raw-output tail that a deploy-apply failure already carries, so the real assertion body (or any other evidence outside `excerpt()`'s token list) survives into `founding-state.log`/`legs.json` and is visible to an operator or on-call agent without having to re-run `nix eval` by hand against a captured `state/clan-config`. **Key interfaces:** - `clan.Readiness` (`internal/clan/clan.go`) — needs a `Tail` field, `omitempty`, mirroring `Failure.Tail`'s shape and doc comment. - `Adapter.evalReadiness` (`internal/clan/adapter.go`) — thread the `*Failure` returned by `classify()` through into the new `Readiness.Tail` field, the same way `Kind`/`Detail` are threaded today. - `enrollment.go`'s `preflight()` — carry `Readiness.Tail` into the `Failure.Tail` it builds for `s.Failure`, matching how `deploy.go` already carries `Failure.Tail` into `DeployFailure.Tail` for the apply path. - Optionally, widen `excerpt()`'s token match (or add a "keep every line after a `Failed assertions:`/`error:` header, bounded" rule) so a genuine assertion body survives the short grep on its own — the issue calls this out as a nice-to-have, not a substitute for the `Tail` fix. **Acceptance criteria:** - [ ] `Readiness` carries a `Tail` field populated whenever `evalReadiness` classifies a failure, containing the same bounded tail `classify()` already computes. - [ ] `preflight()`'s `s.Failure` for an eval-preflight failure has a non-empty `Tail` whenever the underlying `nix eval` output is non-empty, matching the deploy-apply path's existing behavior. - [ ] A test reproducing #628's failure shape (a Nix assertion whose body line carries none of `excerpt()`'s grep tokens) shows the assertion body present in the resulting `Failure.Tail`, not just the `Failed assertions:` header in `Detail`. - [ ] Existing eval-preflight and deploy-apply failure-classification tests remain green — the change is additive to `Readiness`/`Failure`, not a reshaping of `Detail`'s existing grep behavior. **Out of scope:** - Rewriting or removing `excerpt()`'s token-grep `Detail` computation — `Tail` is a supplement, not a replacement, exactly as it already is for the deploy-apply path. - Any change to `classify()`'s classification order/tokens (connectivity before secrets, masked_exit handling) — untouched by this fix. - The rehearsal drive's own `missing_var`/`sops.defaultGroups` root cause (#628) — this ticket only fixes the *evidence capture* that #628's drive exposed, not the underlying config-eval failure itself.
Author
Member

swarm-claim host=matou-dev-server-01 run=8270
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=8270 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #629 — status success

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

envelope
{
  "issue": 629,
  "status": "success",
  "commits": [
    "6710a0b2"
  ],
  "changed_files": [
    "STATUS.md",
    "internal/clan/adapter.go",
    "internal/clan/clan.go",
    "internal/clan/enrollment.go",
    "internal/clan/readiness_tail_test.go"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci -c go test ./internal/clan/",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go vet ./...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go build ./...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Readiness carries a Tail field populated whenever evalReadiness classifies a failure, containing the same bounded tail classify() computes": "clan.go Readiness.Tail field added; adapter.go evalReadiness threads classify()'s tail into Readiness.Tail; proved by TestReadiness_TailCarriesAssertionBody (internal/clan/readiness_tail_test.go)",
    "preflight()'s s.Failure for an eval-preflight failure has a non-empty Tail whenever the underlying nix eval output is non-empty": "enrollment.go preflight() now builds s.Failure with Tail: r.Tail; proved by TestEnroll_PreflightEvalBlockCarriesTail",
    "A test reproducing #628's failure shape shows the assertion body present in the resulting Failure.Tail, not just the Failed assertions: header in Detail": "both new tests use assertionEvalLog (#628's exact shape) and assert the assertion body is absent from Detail but present in Tail",
    "Existing eval-preflight and deploy-apply failure-classification tests remain green — the change is additive": "full internal/clan go test green (15.2s); excerpt()/classify()/Detail grep untouched"
  },
  "summary": "Added Tail to clan.Readiness and threaded classify()'s raw nix-eval tail through evalReadiness into preflight()'s Failure.Tail, so a dropped assertion body reaches drive artifacts.",
  "blockers": []
}
**close-report** for #629 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 629, "status": "success", "commits": [ "6710a0b2" ], "changed_files": [ "STATUS.md", "internal/clan/adapter.go", "internal/clan/clan.go", "internal/clan/enrollment.go", "internal/clan/readiness_tail_test.go" ], "tests": [ { "command": "nix develop .#go-ci -c go test ./internal/clan/", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go vet ./...", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go build ./...", "exit_code": 0 } ], "criteria": { "Readiness carries a Tail field populated whenever evalReadiness classifies a failure, containing the same bounded tail classify() computes": "clan.go Readiness.Tail field added; adapter.go evalReadiness threads classify()'s tail into Readiness.Tail; proved by TestReadiness_TailCarriesAssertionBody (internal/clan/readiness_tail_test.go)", "preflight()'s s.Failure for an eval-preflight failure has a non-empty Tail whenever the underlying nix eval output is non-empty": "enrollment.go preflight() now builds s.Failure with Tail: r.Tail; proved by TestEnroll_PreflightEvalBlockCarriesTail", "A test reproducing #628's failure shape shows the assertion body present in the resulting Failure.Tail, not just the Failed assertions: header in Detail": "both new tests use assertionEvalLog (#628's exact shape) and assert the assertion body is absent from Detail but present in Tail", "Existing eval-preflight and deploy-apply failure-classification tests remain green — the change is additive": "full internal/clan go test green (15.2s); excerpt()/classify()/Detail grep untouched" }, "summary": "Added Tail to clan.Readiness and threaded classify()'s raw nix-eval tail through evalReadiness into preflight()'s Failure.Tail, so a dropped assertion body reaches drive artifacts.", "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#629
No description provided.