feat(daemon): add managed allocation operation journal

Merged
TH
1mo ago
+4430-63

Summary

Share one host-kit durable file publication seam between durable capture envelopes and managed-allocation records. It owns same-directory exclusive temp creation, configurable mode (default 0600), complete UTF-8 write, file fsync, final-path regular-file/symlink checks, replace or link-exclusive publication, directory sync, descriptor/temp cleanup, and primary-error preservation. Allocation reads use host-kit identity-verified descriptors and preserve missing versus corrupt/unreadable outcomes.

The allocation journal is localized under src/daemon/managed-device-allocation/ with journal.ts, record.ts, transitions.ts, decision.ts, and store.ts as caller-facing seams; no barrel was added. The two duplicated durable writers are gone. Simlock allocation/capacity/provisioning/health/lifecycle ownership remains untouched; directory enumeration, record validation, fenced state transitions, and external binding recovery remain domain-specific because they cannot safely use a generic file primitive.

Production allocation journal: 3,075 -> 2,973 lines; durable callers: 326 -> 263 lines. The shared publisher is implemented in the existing host-kit atomic-file owner to preserve import-closure budgets. PR diff: 44 files, +4,430/-63.

Validation

  • Exact head: d7b7ebc71f3b637ab7599fa1fe1994f5a2d1160a
  • pnpm depgraph affected packages/host-kit/src/file.ts --json ran before host-kit edits.
  • Focused suite: 8 files, 56 tests passed.
  • Eager-closure budgets: 418 tests passed.
  • pnpm check:affected --run: 612 test files and 4,663 tests passed; all runnable checks passed.
  • git diff --check is clean; final strict review found no actionable findings.
  • No live/device evidence is owed: no production allocation caller changed.