refactor(daemon): apply one dispatch-disclosure rule to returned and thrown failures
Summary
The request seam in src/daemon/request-dispatch-disclosure.ts applied the dispatch-disclosure rule twice. The returned-failure branch used disclosedDetails. The thrown-failure branch restated the same rule with discloseDispatchAfterSteps, discloseDispatch and discloseUnclassifiedDispatch. Now both branches use the same function.
src/daemon/request-dispatch-disclosure.ts:34-40: the catch branch calculatesdisclosedDetails(effect, failure.details, ledger)and writes it onto the normalized failure. When the details do not change, it rethrows the original value by identity.src/daemon/request-dispatch-disclosure.ts:43-55:disclosedDetailsis now the only owner of the request-seam rule. It delegates the after-steps part to the kernel'sdetailsAfterDispatchedSteps.- The two kernel imports that are no longer used were removed. No kernel export changes. The 13 producer call sites of
discloseDispatchAfterStepsand the 3 call sites ofdiscloseUnclassifiedDispatchare in other packages and do not change. src/daemon/__tests__/request-dispatch-disclosure.test.ts(end of file): a new test makes sure that a command without a declared recording effect (devices) rethrows a non-Error value by identity. This test was committed before the refactor, so it also passes with the base behavior.
The behavior is the same for each old branch:
dispatchedSteps > 0: same details (detailsAfterDispatchedStepsalways returns a new object), and the normalized failure is thrown.- No effect and no steps: the details do not change, so the raw error is rethrown, as before.
observes-app:dispatched: 'no', as before.mutates-app:dispatched: 'unknown'only when no producer classified the failure, as before.
contracts/fixtures/dispatch-disclosure.json does not change. No golden row value changes.
Mutation table
Mutations were made to src/daemon/request-dispatch-disclosure.ts. The driver ran request-dispatch-disclosure.test.ts, interaction-dispatch-disclosure.test.ts and scroll-movement.test.ts.
| id | mutation | result |
|---|---|---|
| M1 | delete if (details === failure.details) throw error; | killed by the new test ("rethrows its failure unnormalized") |
| M2 | delete failure.details = details; | 8 fail, incl. daemon.route.scroll-until-third-pass-refused, find-type-refused-after-focus, post-action-guard.android-press-left-app |
| M3 | observes-app returns details unchanged | 9 fail, incl. daemon.read-only-command, daemon.route.read-only-get, both read-only producer-verdict tests |
| M4 | delete the dispatchedSteps > 0 branch | 9 fail, incl. daemon.series.swipe-later-repetition-refused, daemon.route.batch-mutation-then-refused-step |
| M5 | mutates-app returns details unchanged | 6 fail, incl. daemon.unclassified, daemon.route.scroll-transport-failure |
Live evidence
None. This is a pure refactor of a daemon seam with no device-facing change. The router-driven golden rows cover it. #3096 (the cold-runner launch-confirmation read) is a separate item, and this PR does not address it.
Validation
pnpm typecheck: exit 0pnpm lint: exit 0pnpm check:layering: "Layering guard: OK"pnpm check:fallow: "No issues in 2 changed files"pnpm check:affected --rununder the host gate lock: an earlier run at this head exited 0 with 166/166 test files and 916/916 tests. A rerun at load average 450 to 680 failed only on 5 s timeouts. Those were the first test of each oftest/integration/provider-scenarios/{android-alert,interaction-direct-selector-fallback,ios-lifecycle}.test.ts, and each one pays the cold-import cost of its file.pnpm exec vitest run --testTimeout=60000on those three files: 3/3 files and 14/14 tests passed. The slowest test took 8.6 s, all of it cold-import time under host load.
Part of #3069.