refactor(host-kit): move settleWithin to a dependency-free leaf module

Merged
TH
7d ago
+241-201

Summary

settleWithin sat in retry.ts, so a caller wanting only the deadline race also evaluated the retry policy, the Deadline class, the diagnostics edge and the kernel error vocabulary. That is why #4788 reverted two migrations: the eager-closure budget went up.

settleWithin and SettleWithinOutcome now live in packages/host-kit/src/settle-within.ts, which imports nothing, published as @agent-device/host-kit/settle-within. Every production importer uses that subpath; host-kit/retry no longer exports them.

Newly migrated sites:

  • capture-kit/capture-fact-grace.ts, through a function-scoped await import. A static import fails the eager-closure budget (2 modules against 1 at the merge-base).
  • Both platform-apple/core/perf-xctrace.ts exit waits. They no longer leave the 45 s grace timer armed after xctrace exits; a fake-timer test proves it and fails when the migration is reverted.
  • waitForValidatorCompile in capture-kit/recording/video.ts, same timeout error as before.

provider-limrun has one such race but does not depend on host-kit, so it is untouched. No budget raised, no allowlist, no baseline regenerated. 23 files changed, 241 insertions(+), 201 deletions(-).

Validation

Tested at 79513fc064.

  • R88 Promise.race( total: 34 → 30.
  • pnpm build, check:quick, check:layering, check:fallow, check:package, check:production-exports: pass.
  • eager-closure-budgets.test.ts and the host-kit, capture-kit, platform-apple core, daemon, daemon-client and CLI tests: pass.
  • CI owns the full unit and device lanes.

šŸ¤– Generated with Claude Code


Autofix with [code]smith
Open in [code]smith Ā· Need help on this PR? Tag @codesmith-bot with what you need.