clan: ReadPlacement collapses a corrupt or unreadable inventory into "no machines placed" #292

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

internal/clan/inventory.go:177-181 (read via control-plane/cmd/control-plane/whole_composition.go:361) — corrupt JSON, EACCES and a half-written file all read as an empty placement, indistinguishable from a freshly-founded community. The repo's own posture for the same hazard on the enrollment document is a deliberate boot panic (whole_composition.go:334): better down than a vanished fleet.

Acceptance

  • A present-but-unreadable/corrupt inventory is an error, not an empty placement; only genuinely-absent reads as empty.
  • Callers surface it (boot refusal or explicit degraded state — match the enrollment-document posture).
  • Tests: absent ⇒ empty; corrupt ⇒ error.

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

`internal/clan/inventory.go:177-181` (read via `control-plane/cmd/control-plane/whole_composition.go:361`) — corrupt JSON, EACCES and a half-written file all read as an empty placement, indistinguishable from a freshly-founded community. The repo's own posture for the same hazard on the enrollment document is a deliberate boot panic (`whole_composition.go:334`): better down than a vanished fleet. **Acceptance** - A present-but-unreadable/corrupt inventory is an error, not an empty placement; only genuinely-absent reads as empty. - Callers surface it (boot refusal or explicit degraded state — match the enrollment-document posture). - Tests: absent ⇒ empty; corrupt ⇒ error. --- _Filed from the 2026-08-05 fail-loud audit (three-agent pre-production sweep; findings verified against code)._
Author
Owner

Fixed in e822bbf (on origin/main).

clan.ReadPlacement now returns ([]PlacedMachine, error) — only a genuinely-absent inventory reads empty (loadInventory already draws that line at os.ErrNotExist); corrupt JSON, EACCES and a half-written inventory.json surface as errors instead of collapsing to "no machines placed". The sole caller, configRepoInventory.Placement in whole_composition.go, refuses loudly on the error, matching the enroll-document posture (openEnrollLedger panics at boot rather than project a fleet it cannot read).

Red-first tests in internal/clan/readplacement_test.go: absent ⇒ empty, corrupt ⇒ error, EACCES ⇒ error, well-formed ⇒ its machines. go test/golangci-lint green (clan, control-plane).

Fixed in e822bbf (on origin/main). `clan.ReadPlacement` now returns `([]PlacedMachine, error)` — only a genuinely-absent inventory reads empty (`loadInventory` already draws that line at `os.ErrNotExist`); corrupt JSON, EACCES and a half-written `inventory.json` surface as errors instead of collapsing to "no machines placed". The sole caller, `configRepoInventory.Placement` in `whole_composition.go`, refuses loudly on the error, matching the enroll-document posture (`openEnrollLedger` panics at boot rather than project a fleet it cannot read). Red-first tests in `internal/clan/readplacement_test.go`: absent ⇒ empty, corrupt ⇒ error, EACCES ⇒ error, well-formed ⇒ its machines. `go test`/`golangci-lint` green (clan, control-plane).
ben closed this issue 2026-08-06 01:39:49 +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#292
No description provided.