Repository navigation
test(daemon): make managerless port fixture hermetic - #137692
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
010004e to
610de93
Compare
|
@clawsweeper review Please run the durable correctness review for exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: blocked before merge. Reviewed September 3, 2026, 8:32 PM ET / September 4, 2026, 00:32 UTC. ClawSweeper reviewWhat this changesThe PR replaces real TCP listener setup in the managerless daemon-update test with deterministic mocked free, busy, and unknown port-usage results. Merge readiness⛔ Blocked before merge - 1 item remains Keep this maintainer-authored PR open for normal handling. The exact-head diff removes a real-socket rebind race from the managerless preflight fixture while retaining and extending the fail-closed port-result coverage; no blocking correctness or security defect was found. Priority: P3 Review scores
Verification
How this fits togetherBefore updating code, the daemon updater determines whether a Gateway service or listener is active and blocks unsafe mutations when inspection is uncertain. This test covers the managerless Linux path that turns service and port observations into an update-safety verdict. flowchart LR
A[Daemon update request] --> B[Managerless preflight]
B --> C[Inspect service state]
C --> D[Probe configured Gateway port]
D --> E[Safety verdict]
E --> F[Allow or block code mutation]
G[Deterministic test fixture] --> D
Before merge
Agent review detailsSecurityNone. PR surfaceTests +25. Total +25 across 1 file. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the port outcome controlled at the imported probe boundary, preserving the production fail-closed behavior while making the fixture independent of host socket allocation timing. Do we have a high-confidence way to reproduce the issue? Yes, from source: the old fixture allocated then released an ephemeral port before the production four-interface probe, creating a rebind window. No local test execution was performed because this review must keep the checkout byte-for-byte clean. Is this the best way to solve the issue? Yes. Mocking the imported port-probe owner preserves the tested update-policy branch while removing the unrelated host socket-timing dependency; the unexpected-call default also detects accidental probe-path drift. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cd8c74889d21. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
610de93 to
db2301c
Compare
|
Maintainer disposition for the sole ClawSweeper before-merge item: Exact-head native Vitest proof passed |
|
Merged via squash.
|
* origin/main: fix(git-hooks): keep unstaged bytes out of pre-commit formatting (#137723) test(gateway): drain session tool fixture cleanup (#137743) fix: avoid duplicate errors when a desktop disconnects (#137724) refactor: streamline temporary mention retention (#137714) fix(gateway): prevent hosted lifecycle crashes and self-waits (#137456) test(daemon): make managerless port fixture hermetic (#137692)
Related: #137634
What Problem This Solves
Resolves a nondeterministic daemon update fixture where the managerless Linux preflight test released an ephemeral TCP port and then assumed the same port remained free. On busy hosted runners, another socket could claim the port before production inspected all four local interfaces, causing the test to observe the correct fail-closed "inspection unavailable" result instead of the expected absent-service result.
This exact failure occurred in CI jobs
100855049862and100857628036atsrc/daemon/service.test.ts:250. The unchanged fixture also passed locally 65/65, which is consistent with a port-rebind race rather than evidence that the fixture was deterministic. The same rebind hazard is documented insrc/infra/ports-probe.test.ts.Why This Change Was Made
The existing table now controls
probePortUsagethrough a typed partial module mock that preserves every other export. Each planned case declares an exact synthetic port andfree,busy, orunknownresult; every unplanned probe rejects. Installed-definition and service-manager cases also prove that no port probe occurs.Busy and unknown cases assert the semantic fail-closed contract without coupling the fixture to production diagnostic prose. Production port probing and its strict fail-closed update policy are unchanged. No real sockets, retries, timeout changes, production seams, or relaxed assertions were added.
User Impact
No runtime behavior changes. The daemon update contract test no longer depends on host port allocation timing, so unrelated PR CI can distinguish real updater regressions from runner-local socket races.
Evidence
node scripts/run-vitest.mjs src/daemon/service.test.ts --reporter=dot- 66 passednode scripts/run-vitest.mjs src/infra/ports-probe.test.ts src/cli/update-cli/update-command-service-maintenance.test.ts --reporter=dot- 5 passed and 13 passednode_modules/.bin/oxfmt --check src/daemon/service.test.ts- passednode scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/daemon/service.test.ts- passednode scripts/check-changed.mjs --dry-run -- src/daemon/service.test.ts- classifiedcoreTestsgit diff --check- passedTest audit: this extends the existing owner-boundary table, adds the missing
unknownfail-closed case, removes socket lifecycle cleanup, and does not duplicate coverage or weaken production policy.