fleetstate: a failed enroll-ledger read fabricates provisioning refusals — "needs a public address, has 0 B" for a capable gateway #279

Closed
opened 2026-08-05 23:09:47 +00:00 by ben · 1 comment
Owner

internal/fleetstate/projection.go:145-148 — the projection's enroll-ledger List error path return nils. A nil map means device() (line ~204) merges no enrolment facts: every device gets zero Resources, and deriveNetwork(enroll.NetworkFacts{}) yields Network{Public: false, Description: "home connection, not publicly reachable"}.

This is not display-only — it gates provisioning at internal/provision/assess.go:270. A transient ledger read failure makes the assessment tell the operator "needs a public address — this device has none" and "needs 4 GB — this device has 0" for a perfectly capable public gateway. The reasons are specific and plausible; nothing hints the ledger was unreadable.

Acceptance

  • A ledger read failure never fabricates device facts: either fleetstate.Reader grows an error channel the assess path propagates, or the snapshot carries an explicit degraded marker that assess turns into an honest "fleet state unreadable — try again" refusal (never per-resource reasons derived from zeros).
  • Test: injected ledger error ⇒ assess reports the read failure, not resource/network refusals.

Filed from the 2026-08-05 fail-loud audit (three-agent pre-production sweep; findings verified against code).

`internal/fleetstate/projection.go:145-148` — the projection's enroll-ledger `List` error path `return nil`s. A nil map means `device()` (line ~204) merges no enrolment facts: every device gets zero `Resources`, and `deriveNetwork(enroll.NetworkFacts{})` yields `Network{Public: false, Description: "home connection, not publicly reachable"}`. This is not display-only — it gates provisioning at `internal/provision/assess.go:270`. A transient ledger read failure makes the assessment tell the operator "needs a public address — this device has none" and "needs 4 GB — this device has 0" for a perfectly capable public gateway. The reasons are specific and plausible; nothing hints the ledger was unreadable. **Acceptance** - A ledger read failure never fabricates device facts: either `fleetstate.Reader` grows an error channel the assess path propagates, or the snapshot carries an explicit degraded marker that assess turns into an honest "fleet state unreadable — try again" refusal (never per-resource reasons derived from zeros). - Test: injected ledger error ⇒ assess reports the read failure, not resource/network refusals. --- _Filed from the 2026-08-05 fail-loud audit (three-agent pre-production sweep; findings verified against code)._
Author
Owner

Fixed in commit 11487d8 (on origin/main).

The projection's enrolled() (internal/fleetstate/projection.go) swallowed enroll-ledger List errors into a nil map, so device() merged no enrolment facts and every placed node read back with zero Resources and Network{Public:false} — which assess.go then turned into confident "needs a public address — this device has none" / "needs 4 GB — this device has 0" refusals for a capable public gateway.

Fix (the acceptance's explicit-degraded-marker option): enrolled() now returns its read error; Devices/Device mark each derived device with a new fleetstate.Device.Degraded flag (zero resources because UNKNOWN, not small/private); and Assess/ForRole refuse a degraded device with an honest errFleetUnreadable ("fleet state ... is unreadable — try again") instead of deriving per-resource/network reasons from the zeros. ChangeSetup routes through both and is covered. The omitempty field is ignored by existing consumers, so no regression.

Tests (red-first): internal/provision/assess_test.go — injected ledger error ⇒ assess reports the read failure, never a resource/network refusal; internal/fleetstate/projection_test.go — an unreadable ledger marks every device Degraded with no fabricated resources. go build ./..., go vet, golangci-lint, and full go test ./... green.

Fixed in commit 11487d8 (on origin/main). The projection's `enrolled()` (`internal/fleetstate/projection.go`) swallowed enroll-ledger `List` errors into a nil map, so `device()` merged no enrolment facts and every placed node read back with zero `Resources` and `Network{Public:false}` — which `assess.go` then turned into confident "needs a public address — this device has none" / "needs 4 GB — this device has 0" refusals for a capable public gateway. Fix (the acceptance's explicit-degraded-marker option): `enrolled()` now returns its read error; `Devices`/`Device` mark each derived device with a new `fleetstate.Device.Degraded` flag (zero resources because UNKNOWN, not small/private); and `Assess`/`ForRole` refuse a degraded device with an honest `errFleetUnreadable` ("fleet state ... is unreadable — try again") instead of deriving per-resource/network reasons from the zeros. `ChangeSetup` routes through both and is covered. The `omitempty` field is ignored by existing consumers, so no regression. Tests (red-first): `internal/provision/assess_test.go` — injected ledger error ⇒ assess reports the read failure, never a resource/network refusal; `internal/fleetstate/projection_test.go` — an unreadable ledger marks every device `Degraded` with no fabricated resources. `go build ./...`, `go vet`, `golangci-lint`, and full `go test ./...` green.
ben closed this issue 2026-08-06 03:27:26 +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#279
No description provided.