fix(harmonyos): clamp the open foreground probe's hdc read to the request deadline
Summary
Follow-up to #4860 (answered yes): the pre-dispatch already-foreground probe read the device on a fixed 15s hdc timeout, so a hung aa dump -l could hold the dispatch past the request deadline the #4293 poll already respects. readForegroundBundle now receives the request deadline beside the signal, and the probe clamps its read to the remaining budget (Math.min against 15s); a spent deadline skips the device. A deadline or cancel mid-read keeps the advisory outcome: the probe claims nothing, no new error code or CLI change. The post-open poll is untouched.
Before / after
open <bundle>, 2s of request budget left, hung foreground read (unit test, fake timers):
before: dispatch delayed ~15s — the probe held its fixed 15s timeout past the request deadline
after: probe gives up at the 2s clamp and stops holding the dispatch at the deadline
The clamp test pins the read timeout at 2000ms under a +2s deadline (15000 far); a spent deadline reads nothing.
Validation
- Targeted vitest: platform-harmonyos 141, contracts 807, daemon sessions 1272; integration node 153.
pnpm tsc -bandpnpm formatzero-diff; reason tables unchanged. check:affectedstops at the local layering gate; detach control at baseecb2089867gives byte-identical violation lists at the polish head — zero PR-introduced violations.- Live on the JDY-AL50 via
node bin/agent-device.mjsafterpnpm build+pnpm clean:daemon(docdocs/evidence/harmonyos-open-probe-clamp-2026-11-24.md): the already-foreground open warnedalreadyForegroundin 0.84 s; at the polish head9e23b8a13,replay --timeout 3000against an hdc wrapper hanging onaa dump -lcut the probe's read at +3.29 s (2.23 s lived, not 15 s), dispatched without waiting, settleddaemon_request_timeout/3000, noalreadyForegroundclaim (wall 3.68 s). An unlocked-screen re-record awaits the next device unlock.
Refs #4860
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.