You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(windows): check the stop deadline after reading the idle task state - #9058
The Windows Task Scheduler helper reads the registered task's state before it reports that no instances are running. On a slow host that final COM read can consume the remaining stop budget. The helper now reads the state once and checks the elapsed time before accepting a ready or disabled task as idle.
This follows up on the timing case found during #9027. #9026 also involves the installed service and desktop updater. That end-to-end check remains open.
Verification
On Windows x64 with Bun 1.4.4, the new test advances a synthetic clock to the exact deadline during the final state read. On the base commit the helper returned not-running. With this change it returns failed. Both cases made zero stop calls.
bun test tests/windows/windows-checked-stop.test.ts tests/windows/windows-checked-stop-live.test.ts passed all 82 cases with 327 assertions.
bun check --no-script --noEmit, bun scripts/structure-ssot.ts, bun scripts/privacy-scan.ts, and git diff HEAD^ HEAD --check passed.
Local validation covered the shared stop helper and its Windows callers. Concurrent Windows validation on the same host limited the local run to the affected suites. Broader coverage remains with CI.
Checklist
Scope stays focused on the final idle-state read.
The Windows checked-stop documentation describes the deadline.
Reviewed the deadline branch for unsafe defaults. It performs no stop operation.
Summary by CodeRabbit
Bug Fixes
Stop checks now recheck the deadline when no running task instances are found. If the deadline has elapsed, the result is reported as failed; otherwise, the task is reported as not running only when its state can be verified.
An empty instance list no longer proves a task is idle unless its final state is ready or disabled. Unverifiable states are reported as unreadable evidence, with guidance to verify the task and seek repair assistance.
Documentation
Clarified that stopping a running instance alone does not repair an unverifiable task registration.
A slow final Task Scheduler state read could outlast stop-before and report the task idle. Check the deadline after sampling the state. Cover the cutoff with a simulated getter and a zero-stop assertion.
Reviewing files that changed from the base of the PR and between 99944b2 and 921cfd8.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
When no task instances are captured, the stop path reads the task state and checks the deadline before returning a result. The helper documentation and live test describe and cover this idle-state deadline behavior.
The stop path returns failed if the deadline has elapsed after the task-state read. Before the deadline, states 1 or 3 return not-running; other states return unverified-registration. The documentation describes the final-state requirement, and the live test expects failed when the deadline elapses on the second state read.
lidge-jun/opencodex#8931: Introduced deadline checks in the Windows stop path that this change extends.
lidge-jun/opencodex#8564: Added the checked-stop primitives and contract documented and tested by files changed here.
lidge-jun/opencodex#9031: Reverts earlier deadline-handling changes in the Windows stop path modified by this change.
Merge Risk: Minimal · previous review cbbea
This change stops the Windows stop helper from reporting a task as idle when reading its state used up the remaining deadline. The change is small and covered by a targeted test, with no concrete merge-blocking risk identified. The installed-service and updater end-to-end check remains open.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the fix and its specific behavior: the Windows stop helper now checks the stop deadline after reading the idle task state. The raw summary and objectives both describe this change: a d…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the fix and its specific behavior: the Windows stop helper now checks the stop deadline after reading the idle task state. The raw summary and objectives both describe this change: a deadline re-check after the final idle-state read, which returns failed instead of not-running or unverified results when the deadline has elapsed. The title is concise, specific, and follows the conventional fix(scope) format. It does not mention the evidence-unreadable status or the test additions, which are secondary details.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 9e0e298 and cbbeac1.
Files selected for processing: 3
src/service/windows-task-instance-stop.ts
structure/ops/windows-checked-stop.md
tests/windows/windows-checked-stop-live.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Checked the interaction with #9027 at 470bd8278. The two changes previously inserted test cases at the same spot. cbbeac158 moves only the new deadline case within the test table. Both merge orders now produce tree 8f8525b4, with the two native ownership cases and the idle deadline case intact.
On Windows x64 with Bun 1.4.4, the affected PowerShell fixture passed all 58 assertions on that combined tree. It used a mock Scheduler and synthetic process identities. The runtime code in this PR is unchanged from the previously tested commit.
Maintainer integration (lane W, @lidge-jun) at exact head 921cfd849506852514cd68e5397cc161d45db812, which contains current dev9b5861c1a1 (0 commits behind).
PR CI on this head: all 19 checks pass, including gates, test changed and ci. The exact-head test changed job on a branch containing current dev is the test:changed evidence (coordinator ruling; local test:changed could not finish under host load).
Local, macOS: bun run typecheck clean; tests/windows/windows-checked-stop.test.ts + windows-checked-stop-live.test.ts 79 pass / 0 fail.
Real Windows x64 (Bun 1.4.4), PR head merged with dev: the same two files 82 pass / 0 fail, including the new idle-state-deadline case.
Independent gpt-6.1-terra review: PASS, no findings.
scripts/ci/assert-mergeable-review.sh --maintainer-integration 9058: OK.
This also closes the late idle-state read the #9027 review flagged as pre-existing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Windows Task Scheduler helper reads the registered task's state before it reports that no instances are running. On a slow host that final COM read can consume the remaining stop budget. The helper now reads the state once and checks the elapsed time before accepting a ready or disabled task as idle.
This follows up on the timing case found during #9027. #9026 also involves the installed service and desktop updater. That end-to-end check remains open.
Verification
not-running. With this change it returnsfailed. Both cases made zero stop calls.bun test tests/windows/windows-checked-stop.test.ts tests/windows/windows-checked-stop-live.test.tspassed all 82 cases with 327 assertions.bun check --no-script --noEmit,bun scripts/structure-ssot.ts,bun scripts/privacy-scan.ts, andgit diff HEAD^ HEAD --checkpassed.Checklist
Summary by CodeRabbit
Bug Fixes
Documentation