Repository navigation
fix: replace running Windows services safely on reinstall - #165261
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 11:40 PM ET / October 5, 2026, 03:40 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch stops existing Windows Scheduled Task processes before reinstalling their launchers, restores recoverable prior service state, and verifies runtime status against the registered command. Merge readiness✅ Ready for maintainer review This PR remains useful: current main lacks the replacement transition, and the latest fixture repairs introduce no identified correctness blocker. The native replacement and published-driver upgrade evidence support the change. Likely related people: steipete and fuller-stack-dev, both medium-confidence routing candidates from merged service and recovery work. Priority: P2 Review scores
Verification
How this fits togetherThe Windows service adapter translates Gateway installation, update, and status requests into Task Scheduler and process operations. Its observations also inform Doctor, update recovery, and safeguards against rebuilding artifacts used by a running Gateway. flowchart TD
A[Install or update request] --> B[Capture task and launcher]
B --> C[Verify ownership and prior state]
C --> D[Stop and settle old process]
D --> E[Publish and start replacement]
E --> F[Verify command and process]
E --> G[Restore recoverable prior state]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +217, Tests +871, Docs +13, Other +3. Total +1104 across 33 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep Windows replacement, settlement, and rollback under the existing service owner, with status attesting only a verified registered-command/process pair. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the trigger: reinstall a running IgnoreNew Scheduled Task with a changed command while main publishes and runs it without settling the old instance. The PR records native before/after observations; this review did not execute Windows code. Is this the best way to solve the issue? Yes, the patch repairs the existing service transition and recovery owner instead of adding another lifecycle path, and the latest fixture changes preserve meaningful ownership, rollback, and timeout assertions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 94f1e932eedc. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…65261) * fix: replace the running Windows Gateway on reinstall * fix: preserve concurrently replaced Windows node hosts * fix: retain native Windows task occupancy in build fences * test: model native process evidence in Windows service fixtures
What Problem This Solves
Fixes Windows Gateway reinstalls that report the replacement runtime or command while the previous process continues running.
User Impact
Reinstalling a managed Scheduled Task now stops and settles the old process before publishing and starting its replacement. This applies to Node-to-Node changes, arguments, and environment changes. Status verifies the running process against the captured registered command and reports uncertainty when it cannot establish that pair.
Update behavior: the existing updater retains stopped-state and recovery ownership. Ordinary install failures restore the previous definition and running policy when ownership is still verifiable; changed or inaccessible state is left for the existing owner to reconcile. Published-driver update proof: published 2026.9.8 → candidate passed, including a new serving PID/build identity, successful durable completion, Doctor, preserved operator content, and canonical cleanup (25m33s end to end). Managed-service reconciliation recorded the existing
Triggers.LogonTrigger.UserIdadmission warning and preserved that released task definition; package activation and restart still completed. The documented 2026.9.4 Windows schema-upgrade refusal remains unchanged; that legacy-driver cell refused schema 17→20 before activation and completed canonical cleanup.Why This Change Was Made
Task Scheduler's
IgnoreNewpolicy can accept a rewritten task and a start request while retaining its old instance. The existing Windows service owner now performs the transition under its native lock, expected-runtime-pin guard, and definition/file compare-and-swap checks. The captured guard also protects node-host cleanup after process discovery, so a replacement published during/Endis preserved. No new owner, configuration, or automatic runtime migration is introduced.Production and build-tool code grows by 223 net lines to retain pre-publication recovery, distinguish live/stopped/unknown process evidence, and bind environment-supplied ports to the existing scoped owner. Pure process matching moves into the existing snapshot module; obsolete fallback status behavior and an internal re-export are removed. The live-build fence retains native Running/Queued task evidence to protect known overlapping artifacts even when the current command cannot be verified; that evidence grants no service-control authority.
Evidence
826bdb88f86c; the subsequent node-host-only guard fix leaves those Gateway paths unchanged and passes 104 tests on Node and fork Bun. Current published-driver update: published 2026.9.8 → candidate passed, including Doctor and canonical cleanup.Measured test costs
Each changed suite was measured through the repository test wrapper with
--maxWorkers=1. Wall times include compiler/cache and worker startup.schtasks-install-rollback.test.tsschtasks-runtime-definition.test.tsschtasks-runtime.test.tsschtasks.install.test.tsschtasks.settlement.test.tsschtasks.startup-fallback.test.tsschtasks.test.tsThe final combined Node run, including inspection, stop/start, runtime-pin, and CLI-install siblings, took 75.49 s. Additional consumer-suite Node/Bun test execution time: maintenance 2.79/1.34s; status gathering 4.03/2.58s; service command inspection 0.21/0.15s; backup 12.52/5.09s; backup ordering 3.32/0.76s; policy preservation 1.56/0.18s; Scheduled Task audit 0.29/0.07s; systemd maintenance 3.26/1.11s. These exclude wrapper startup. Exact-head CI 37259972611 passed at
2ada701358842b8ecbe2bdf2b57065558586c94d. ClawSweeper completed that head at 03:40 UTC with no findings or security issues.