Skip to content

Fix checked stop on localized Windows Task Scheduler states - #9041

Merged
lidge-jun merged 5 commits into
lidge-jun:devfrom
stanthewizzard:fix/windows-scheduler-state-com
Nov 25, 2026
Merged

lidge-jun merged 5 commits into
lidge-jun:devfrom
stanthewizzard:fix/windows-scheduler-state-com

Conversation

@stanthewizzard

@stanthewizzard stanthewizzard commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On French Windows, schtasks reports Prêt for a ready task. The existing PowerShell fallback took about 1.5 seconds on the affected machine, beyond the one-second state budget, and service installation rolled back. Read the numeric TASK_STATE through Schedule.Service when the CSV fast path cannot classify the result. Queued and running remain active. Failed, timed-out and unknown reads remain inconclusive.

Verification

  • Ran bun test tests/windows/windows-checked-stop-live.test.ts on Windows. All 42 tests passed.
  • Measured the COM read at 299–337 ms including PowerShell startup on the affected French host.
  • With the patch applied to 2.100.8, the scheduler installer completed instead of rolling back. End-to-end tray behavior is still being checked.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes
    • Windows scheduled-task status is now detected consistently when localized status labels are unfamiliar, using the scheduler’s numeric state.
    • Active and stopped states are reported correctly across supported numeric values. If status cannot be determined because of a timeout, command failure, or unrecognized state, it is reported as unknown.
  • Documentation
    • Updated Windows task-status guidance to describe localized labels, numeric states, and unknown results.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Windows task-state fallback now reads numeric Task Scheduler state through COM when localized CSV labels are not recognized. States 2 and 4 map to running; states 1 and 3 map to not-running. Other states, failed commands, timeouts, and exhausted time budgets return unknown.

Changes: Windows task-state classification

Layer / File(s) Summary
Numeric state fallback and validation
src/service/windows-checked-stop-live.ts:182-183, 417-425, tests/windows/windows-checked-stop-live.test.ts:105-138, structure/ops/windows-checked-stop.md:186
taskState uses the numeric State value from the Schedule.Service COM API when the CSV label is unrecognized. Tests and documentation cover state mappings, failed queries, timeouts, and remaining-time limits.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

Possibly related PRs

  • lidge-jun/opencodex#8959: Adds Japanese Task Scheduler state labels to the CSV classification path supplemented by this numeric fallback.
  • lidge-jun/opencodex#8976: Adds Korean Task Scheduler state labels to the CSV classification path supplemented by this numeric fallback.

Suggested reviewers: ingwannu

Merge Risk: Minimal · up to de145

Localized Windows Task Scheduler states now fall back to a fast numeric COM read instead of a slower name-based query. No concrete merge-blocking risk was identified. End-to-end tray behavior is still being checked by the author.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: checked stop now handles localized Windows Task Scheduler states. The raw summary confirms the change adds a numeric TASK_STATE fallback via COM for localized CSV labe…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: checked stop now handles localized Windows Task Scheduler states. The raw summary confirms the change adds a numeric TASK_STATE fallback via COM for localized CSV labels such as the French 'Prêt', with tests for numeric states and timeout handling. The title is specific and matches the changeset, so it passes.

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 584f6e9 and de14582.

Files selected for processing: 2

  • src/service/windows-checked-stop-live.ts
  • 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; 8 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 21, 2026
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

Automatic draft conversion failed. Please convert this pull request to a draft manually until every box above is ticked.

Hygiene

✅ Deterministic PR hygiene checks passed.

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The French-host timing and successful install are useful evidence for the numeric TASK_STATE fallback. This head also changes src/service/windows-process-evidence.ts and src/service/windows-process-native.ts to supply process ownership evidence. That is a different contract, overlaps the work already under review in #9027, and is outside the verification in this PR description. Could you keep #9041 focused on the task-state fallback and move any remaining ownership differences to the #9027 discussion? Please keep the failed or timed-out lookup cases inconclusive and update the old Get-ScheduledTask fallback description in windows-checked-stop-live.ts alongside the change.

# Conflicts:
#	src/service/windows-process-evidence.ts
#	src/service/windows-process-native.ts
Revert the snapshot-owner fallback in windows-process-evidence.ts and
windows-process-native.ts to dev: lidge-jun#9027 carries the native ownership proof for a
missing CIM owner sample, and two fallbacks for the same evidence would disagree.
Document the Schedule.Service TASK_STATE fallback for unrecognized locales.
@lidge-jun
lidge-jun marked this pull request as ready for review November 25, 2026 05:55
@lidge-jun
lidge-jun self-requested a review as a code owner November 25, 2026 05:55
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T06:44:46.451364Z de14582 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions
github-actions Bot marked this pull request as draft November 25, 2026 06:17
@lidge-jun
lidge-jun marked this pull request as ready for review November 25, 2026 06:37
@github-actions
github-actions Bot marked this pull request as draft November 25, 2026 06:40
@lidge-jun
lidge-jun marked this pull request as ready for review November 25, 2026 06:41
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration (lane W, @lidge-jun) at exact head de14582be0868b7c432ea2e5ddd78edf52c927cc. Part of #9038: on a host whose schtasks CSV status word is not recognized (French Prêt, for example), the manager-state probe now reads the numeric TASK_STATE through the Schedule.Service COM object instead of importing ScheduledTasks for Get-ScheduledTask. 2 and 4 count as active, 1 and 3 as stopped, and anything else, a timeout or a nonzero exit stays unknown.

Changes I added after the author's head ce0a3f640:

  • 584f6e9d2e keeps this PR to the state read. It drops the second snapshot-owner fallback in windows-process-evidence.ts / windows-process-native.ts, because fix(windows): verify service owners when WMI evidence is missing #9027 (merged as 93a4572f8f) owns that evidence, as @Ingwannu asked. It also documents the fallback in structure/ops/windows-checked-stop.md.
  • de14582be0 adds a test that the PowerShell read gets only the time the CSV query left, and none once that time is spent. A mutation check confirmed the test catches the full-budget bug. It also fixes a stale comment.

Relaxed merge gate, checked against dev a3e2c70b36:

Evidence:

  • PR CI on this head: all checks pass. A hygiene job that was cancelled while the PR was a draft was rerun and passed. The exact-head test changed job is the test:changed evidence (coordinator ruling).
  • Real Windows x64, ko-KR (Bun 1.4.4), at de14582be: windows-checked-stop-live, windows-checked-stop, windows-process-evidence and windows-stop-callers give 144 pass / 0 fail. A live read-only measurement on the same host: the COM state read takes 332 ms (state 4 for the running task), against 4,310 ms for Get-ScheduledTask. A missing task exits 1, which maps to unknown.
  • Independent gpt-6.1-terra review, two rounds: PASS, no open findings.
  • assert-mergeable-review.sh --maintainer-integration 9041: checked by the merge helper (it must print OK).

@lidge-jun
lidge-jun merged commit 3c0ed3b into lidge-jun:dev Nov 25, 2026
44 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants