Skip to content

refactor(daemon): normalize lifecycle participation of platform resource owners #2333

Description

@thymikee

Purpose

Child of #2278 (audit area: runtime lifecycle participation). The daemon startup/shutdown code in src/daemon/server/daemon-runtime.ts explicitly names platform resource owners through three classified edges (R74 inventory):

  • src/platform-runtime-apple-runner-owner.tsconfigureAppleRunnerLeaseOwnerStateDir, configureAppleRunnerDeviceClaimAuthorityProbe (daemon-owned inputs pushed into the Apple runner host at startup, cleared on lock release)
  • src/platform-runtime-resource-cleanup.tsresetAndroidSnapshotHelperRuntime, cleanupManagedWebRuntimeOrphans (named platform owners invoked at startup; the platformResourceCleanup symbol on the same edge is the neutral PlatformResourceCleanup contract capability and is the model to follow)
  • src/platform-runtime-operation-host.ts — dynamic import() of recoverLegacyAppLogMarkersAfterDaemonLock at startup (app-log legacy marker recovery, a platform process-mechanic)

The daemon retains lifecycle sequencing, cancellation, failure policy, and budgets. Platform resource owners should participate through a typed owning interface; no generic hook bag, service locator, or dispatcher.

Required behavior

  • daemon-runtime.ts stops importing the named platform owners above. The daemon-owned values (lease-owner state dir, device-claim authority probe, cleanup inputs) are still supplied by the daemon — what changes is the hand-off: a typed lifecycle participation surface (startup/shutdown phases) that the root composition wires the platform owners into, or the existing PlatformResourceCleanup-style contract capability extended to cover snapshot-helper reset, Web orphan cleanup, and app-log legacy marker recovery.
  • The daemon keeps: ordering (runner-owner configuration after daemon lock acquisition; web-orphan cleanup and marker recovery before servers open; resets on the shutdown path), best-effort failure policy with diagnostics, and the existing teardown budgets.
  • One construction path for the participation surface; platform owners are registered by the root composition, not by daemon code naming platform modules.

Observable completion conditions

  • The three R74 inventory edges for daemon-runtime.ts (apple-runner-owner, resource-cleanup, operation-host dynamic import) are reclassified or removed.
  • No production importer of configureAppleRunnerLeaseOwnerStateDir, configureAppleRunnerDeviceClaimAuthorityProbe, resetAndroidSnapshotHelperRuntime, cleanupManagedWebRuntimeOrphans, or recoverLegacyAppLogMarkersAfterDaemonLock remains under src/daemon/**.
  • Daemon startup/shutdown behavior is identical (existing lifecycle tests; runner-owner state dir and claim-authority probe still configured; legacy markers still recovered).
  • Planted violation: a daemon import of any of the named owners is red.
  • pnpm check:layering and pnpm check:affected --run pass.

Dependencies

None hard. If the Apple runner owner seam intersects the #2332 observation port, sequence accordingly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions