refactor(daemon): route daemon-level diagnostics through one scope helper - #3242
Conversation
…elper withDaemonDiagnosticsScope owns the daemon session scope fields, runs the body, and forces the flush. All seven daemon-runtime call sites use it with their original command, debug flag, and flush timing.
…lper withDaemonDiagnosticsScope owns the daemon session scope and the forced flush, which now also runs when the body throws, so a failing body keeps its record. It lives at the src root so both daemon-runtime and daemon-registration-owner use it; the eight hand-written copies and the call-site comments that repeated its contract are gone.
|
This PR is ready at 7262f17. The daemon diagnostics refactor reads clean, and no conflicts are known. CI has not shown a result on this head, because all 9 non-passing jobs were cancelled and left no logs. The diff touches daemon startup and shutdown paths that Typecheck & Package, Lint & Format, Coverage and the Smoke Tests exercise, so please re-run CI on this head before merge. I did not run the typecheck, the new test, or the layering and fallow gates, so whether the src/daemon/server import from the src/ root is allowed is still unchecked. No live daemon run is needed for this internal change. Not blocking: the new test sits beside its source in src/, while the registration-owner test lives in src/tests/, and no test goes through the daemon-runtime call sites, including the flush-on-throw path of the sweep's |
|
|
At I'm leaving the two optional notes as they are:
|
Size Report
Startup median (7 runs, lower is better):
|
* origin/main: (77 commits) fix(apple-runner): fence prep spawns behind a start-owned admission (callstack#3239) 0.21.22 test(apple): own the simctl settings plan tests in simctl-settings.test.ts (callstack#3244) fix(limrun): report the session device id in iOS settings refusals (callstack#3243) 0.21.21 feat(remote): add a host-allocated macos-app lease backend (callstack#3236) test(android): bound the screenshot write wait by wall time, not event-loop turns (callstack#3250) feat(recording): cap the touch overlay frame rate at the caller's --fps (callstack#3241) fix(ad-script): let .ad scripts carry scroll --until and wait capture flags (callstack#3197) (callstack#3234) feat(provider-webdriver): keyboard enter, dismiss, and status over WebDriver (callstack#3233) feat(selectors): match role= against snapshot kind with a node-scoped alias window (callstack#3232) fix(provider-webdriver): read field values, placeholders, secure fields, and checked state from page source (callstack#3231) feat(replay): accept --test-ime on test and replay so flow-owned Android opens opt into the test IME (callstack#3235) refactor(daemon): route daemon-level diagnostics through one scope helper (callstack#3242) docs(adr): correct ADR 0031 pointer event delivery evidence (callstack#3245) fix(ios): stop a tap's post-gesture lookup from recording an XCTest failure (callstack#3060) (callstack#3237) fix(recording): render the touch overlay at most 30 fps and inside the record request (callstack#3219) fix(daemon): keep an idle daemon alive only for retained leases (callstack#3227) fix(provider-webdriver): send an empty JSON object on bodyless POSTs (callstack#3230) Feat/maestro repeat while (callstack#3214) ...
Summary
Daemon-level work that runs outside a request needs its own diagnostics scope, or
emitDiagnosticdrops its events. That wrapper (withDiagnosticsScope({ session: 'daemon', logPath, … })plus a forced flush) was written out eight times: seven indaemon-runtime.tsand one indaemon-registration-owner.ts.withDaemonDiagnosticsScopenow owns it, and every site uses it.src/daemon-diagnostics-scope.ts.daemon-runtime.tsalready imports the registration module, so a root module avoids reversing that dependency.daemon-runtime.tsshrinks by about 50 lines.4 files, 242 gross lines.
Validation
At
7262f17b67:pnpm check:affected --runpasses. The helper test covers the scope fields, the default and startup command names, and a throwing body that keeps its events and rethrows. Log output is otherwise unchanged: in a debug scope with a log path every event is written as it is emitted, so the extra flushes write nothing.