Skip to content

refactor(daemon): move the durable-capture admission family to capture-kit - #2651

Open
thymikee wants to merge 2 commits into
mainfrom
t3code/adversarial-review-2544-pr
Open

thymikee wants to merge 2 commits into
mainfrom
t3code/adversarial-review-2544-pr

Conversation

@thymikee

Copy link
Copy Markdown
Member

Summary

Extracts the daemon's durable-capture admission family — the perf-capture, audio-probe, and screen-recording admission ledgers, session resources, resource stores, recoveries, and the durable-capture factory — out of src/daemon into packages/capture-kit/src/capture-admission, exposed behind granular per-concern subpaths plus one barrel. The family binds to a package-local DurableCaptureSessionState slice instead of daemon-private SessionState, so nothing under packages/** imports SessionState/DaemonRequestInternal. safeSessionName moved to @agent-device/host-kit/session-paths. Behavior-preserving; cuts ~20 files / ~1,300 LOC from src/daemon. Closes #2544.

Measured SessionState field set the family touches: { perfCapture, audioProbe, screenRecording } — a non-spine slice, so shipping the family is the correct scope for #2544.

The maestro adapters move was evaluated and deferred: the runtime port reads internal.publicNetworkOnly and writes a daemon-internal endpoint-hold bag (ADR 0015), so a clean move needs a package-local compatibility bag, daemon-side invoke forwarding, and new provision-kit/undici deps, plus device/conformance verification that can't run here. It belongs in its own device-verified PR.

Validation

Tested at c5edae5e2f. pnpm check:affected --run passes: typecheck, lint, layering, fallow ("no issues in 87 changed files"), and affected unit suites. pnpm check:layering, check:production-exports, check:package, and eager-closure budgets are green; full unit suite 10,343 passed. No Apple/Android runtime path is changed, so no device run is required.

…e-kit

The 19-module durable-capture admission family (durable-*, perf-*,
audio-*, screen-*) reached src/** only through SessionState,
SessionStore, and safeSessionName. Its SessionState slice is exactly
the three durable-capture slots it reads/replaces (perfCapture,
audioProbe, screenRecording); its SessionStore use is exactly
capture-kit's structural DurableCaptureSessionStore (set +
resolveSessionDir) — not the session spine. capture-kit's
durable-capture machinery is already generic over S, so the residue
retypes onto that slice with no behavior change: sessionSlot.replace
spreads S and sessionStore.set writes the runtime record back, so the
session type stays opaque behind S.

- safeSessionName + session path helpers move to
  @agent-device/host-kit/session-paths (its only dep was host-kit/file).
- The family moves to @agent-device/capture-kit/capture-admission; the
  eager-closure-sensitive hub (session-teardown) reaches the same
  modules through narrow per-kind subpaths so its closure stays flat.
- app-log-* stay in the daemon and consume the relocated factory/ledger.

Closes #2544

Issue #2544
- session-resource-ownership (R68): extend scan roots to
  packages/capture-kit/src/capture-admission and repoint the audio/perf
  owner paths to the relocated owners, so the field guard follows the
  code; add a case proving a field planted there is still caught.
- package-boundaries (R11): add the new capture-kit and host-kit export
  subpaths to the exact export-surface enumeration.
- eager-closure budgets: one APPROVED_OVER_CEILING row (#2544) for the
  cohesive capture-admission barrel entry; the hub-reachable modules
  stay under the ceiling behind their narrow subpaths.

Issue #2544
@github-actions

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
Installed (including dependencies) 4.59 MB 4.59 MB -4.3 kB
Package (unpacked) 4.59 MB 4.59 MB -4.3 kB
Package (download) 1.36 MB 1.36 MB -992 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 26.8 ms 27.2 ms +0.5 ms
CLI --help 78.3 ms 78.8 ms +0.5 ms

@thymikee

Copy link
Copy Markdown
Member Author

Reviewed at c5edae5.

This PR breaks a test that landed on main after its merge base. session-close-cwd-scoped-resources.test.ts came in with #2648 (5b60f30) and imports audio-probe-resource-store.ts, perf-capture-resource-store.ts and screen-recording-resource-store.ts from src/daemon, which this PR moves. That is why Typecheck & Package, Repo Guards and Coverage fail on the merge ref with TS2307. No production file on main imports the moved modules. Please rebase, point those three imports at their new @agent-device/capture-kit specifier, and grep main for any other importer of the moved paths, including session-paths.ts.

Could this ship with only the per-kind subpaths that session-teardown needs, plus one recovery subpath, and without the capture-admission barrel? The barrel adds the first entry to APPROVED_OVER_CEILING in eager-closure-budgets.ts, and it gives screenRecordingDurableResource, audioProbeDurableResource and perfCaptureDurableResource two import paths each. The generic S on the resources looks like the right cut for the SessionState dependency. If the barrel stays, what makes the exemption fit the #2469 ceiling tolerance?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(daemon): extract the maestro adapter and durable-capture admission subtrees

1 participant