refactor(host-kit): split atomic-file by concern

Merged
TH
8d ago
+713-682

Summary

atomic-file.ts (950 lines) mixed three concerns. This splits it by concern, move-only, in 19 files:

  • atomic-publish.ts: generic publication. process-lock.ts and owned-process-record.ts import only this.
  • script-destination.ts: the destination walk, exposure rules, level creation, publishScriptFileSync, Windows creation.
  • script-destination-refusal.ts: exposure wording, hints, typed reasons. The walk and the name rules both use it, so it is its own module to avoid an import cycle.
  • entry-name.ts: entry-name rules and resolveScriptDestination (moved from path-resolution.ts).

hostPathRules moves to path-resolution.ts, which now imports none of the script modules. The @agent-device/host-kit/file surface is unchanged. Tests move beside their owners: 116 cases before and after.

A parallel PR deletes judgeScriptDestination. Whichever lands second rebases; here it moved unchanged into script-destination.ts.

Validation

At a7f803d73f (rebased onto 83328f1d8a; only the two cross-package comment pointers #4742 moved conflicted):

  • Diff review: every function body is byte-identical (sorted-line diff of old vs new modules differs only in imports and export keywords), so checks and their order are unchanged.
  • Eager closure: eager-closure-budgets.test.ts green, no budget change. owned-process-record.ts 5 files / 96 KB → 4 files / 32 KB, process-lock.ts 220 KB → 188 KB.
  • host-kit, remote, capture-kit recording unit suites: 1203 passed. Daemon unit suite, typecheck, lint, check:layering (staged), check:production-exports, fallow audit --base origin/main: pass.
  • a7f803d73f only repoints the ADR 0016 path reference to entry-name.ts.
  • CI validates the pushed head.

šŸ¤– Generated with Claude Code