Skip to content

fix(service): stop an update wedging on its own teardown receipts (#8960) - #9062

Merged
lidge-jun merged 5 commits into
lidge-jun:devfrom
bokjk:fix/8960-stop-budget-receipts
Nov 25, 2026
Merged

lidge-jun merged 5 commits into
lidge-jun:devfrom
bokjk:fix/8960-stop-budget-receipts

Conversation

@bokjk

@bokjk bokjk commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the self-perpetuating ocx update failure on Windows described in #8960. That issue was auto-closed for a missing version field, not fixed. I hit it on 2.100.5 → 2.100.7/2.100.8 (Task Scheduler service, ko-KR Windows 11). The failing update printed:

❌ The installed service manager did not stop; it may respawn the proxy.
   The remaining time cannot hold a verified Windows service stop, so nothing was changed; retry from a terminal.

and left one more pending-teardown-*.json on every attempt.

Two independent causes, both addressed:

  1. A refused admission kept this run's own receipt. An update's handover claims its receipt before Part A admission (claimHandoverBeforeManager). When Part A refused unverified-budget, it had changed nothing, but the receipt stayed on disk. Now a held snapshotless Part A that changed nothing (windowsPartAHeldUnchanged: no manager stop, no terminate, and therefore no POST) removes the receipt this run claimed. A Part A that changed something keeps it, as before.
  2. Admission budgeted one 3 s probe per inherited receipt. It now budgets one probe per distinct exact endpoint (inheritedTeardownProbeCount). The recovery pass asks each endpoint once (abandonedTeardownProbeOncePerEndpoint), so the budget matches the probes that actually run. Invalid, unscannable and guessed-endpoint receipts block without probing, so they no longer count. Previously, two leftover receipts for the same 127.0.0.1:10100 pushed the scheduler-only worst case from 53.5 s to 59.5 s against the 60 s deadline.

structure/ops/windows-checked-stop.md is updated to match.

Verification

All commands were run on Windows 11 with Bun 1.4.4:

  • bun run typecheck: no type errors in 2,691 files.
  • bun run structure:check: structure/ SSOT checks passed.
  • bun test tests/windows/windows-stop-ocx-stop.test.ts: 20 pass, 0 fail, including 4 new tests:
    • an update handover refused by Part A (#8960):
      • unverified-budget with handover: true claims a nonce, and the receipt no longer exists afterwards.
      • survived (changed) keeps the receipt.
    • inherited receipts are budgeted and probed per endpoint (#8960): covers the endpoint dedupe counts and one probe per endpoint.
  • Red check: with the src/cli/index.ts change reverted, unverified-budget changed nothing: the receipt this run claimed is removed fails (receiptExists true).
  • bun test tests/service/connected-stop-capability-auth.test.ts tests/service/stop-deferred-teardown.test.ts tests/windows/windows-stop-callers.test.ts: 199 pass, 9 skip, 0 fail on this branch. The same command gives the same result on dev at 9e0e298.
  • bun run test:changed on this Windows machine had 4–5 failures that varied between runs. All were 5 s test timeouts in the three files above under the parallel runner. Each file passes when run directly, both here and on dev.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed (structure/ops/windows-checked-stop.md).
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. A receipt is removed only when Part A reports that nothing changed and the hold already skipped the POST.

🤖 Generated with Claude Code

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
    • Improved Windows stop handling when a service cannot be verified as stopped: the service and shared teardown remain held.
    • Stops that make no changes now clear the current run’s temporary teardown record, while preserving records from an earlier update handover.
    • Teardown recovery checks each known endpoint only once per stop attempt. Valid inherited records count once per distinct endpoint for admission checks; guessed or unreadable endpoint records do not count.

…dge-jun#8960)

A Windows `ocx update` claims its handover receipt before the checked stop's
Part A admission. When admission refused `unverified-budget` (nothing changed),
the receipt stayed on disk. The next stop inherited it and budgeted another
3 s probe on a ~53.5 s baseline against a 60 s deadline, so each refused retry
needed more time than the last and the update wedged permanently.

- A held snapshotless Part A that changed nothing removes the receipt this run
  claimed (`windowsPartAHeldUnchanged`): it describes a stop that never happened.
- Admission budgets one probe per distinct exact endpoint among inherited
  receipts (`inheritedTeardownProbeCount`), and the recovery pass asks each
  endpoint once (`abandonedTeardownProbeOncePerEndpoint`). Invalid, unscannable
  and guessed-endpoint receipts block without probing, so they cost nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 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-25T04:02:55.643041Z 01a61da 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

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

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

github-actions Bot commented Nov 23, 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.

@github-actions
github-actions Bot marked this pull request as draft November 23, 2026 01:11
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

No actionable comments were generated in the recent review.

Walkthrough

The stop path counts inherited teardown receipts once per eligible endpoint and reuses endpoint probes during recovery. When Windows Part A is held without changes, the stop attempts to clear its newly claimed receipt while preserving one claimed by an update handover.

Changes: Windows stop teardown

Layer / File(s) Summary
Inherited teardown probe deduplication
src/cli/stop-restore.ts, src/cli/index.ts, tests/windows/windows-stop-ocx-stop.test.ts
The inherited receipt count uses distinct exact endpoints and excludes guessed or invalid receipts. Recovery reuses a probe promise for repeated calls to the same endpoint. Tests cover endpoint deduplication and probe reuse.
Unchanged Part A receipt cleanup
src/cli/stop-windows-checked.ts, src/cli/index.ts, structure/ops/windows-checked-stop.md, tests/windows/windows-stop-ocx-stop.test.ts
A helper identifies unchanged, held Windows snapshotless Part A results. When that condition holds, the stop attempts to clear its newly claimed receipt; tests cover receipt removal for unverified-budget and retention for survived.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • lidge-jun/opencodex#8573: Introduces the teardown receipts and Windows Part A outcome handling that this change updates.
  • lidge-jun/opencodex#7747: Adds the update-teardown handover receipt contract used by the receipt-preservation behavior tested here.
Merge Risk: Minimal · previous review f2974

This change stops Windows updates from getting stuck on their own teardown receipts. Tests cover the new behavior and no concrete risk was found, so it looks ready to merge.

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 fix and the affected area: an update that wedges on its own teardown receipts. The changeset matches this. It removes the update's claimed receipt when Part A holds unchanged, and …
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 fix and the affected area: an update that wedges on its own teardown receipts. The changeset matches this. It removes the update's claimed receipt when Part A holds unchanged, and it budgets admission probes once per distinct exact endpoint for inherited receipts. The title is specific and does not cover every detail, which is acceptable. The title's scope word 'service' is a minor mismatch with files under src/cli and tests/windows, but the referenced fix is still the main change. The issue number in the title (#8960) matches the linked report.

  • 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 109dde0 and f2974dc.

Files selected for processing: 1

  • tests/windows/windows-stop-ocx-stop.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@github-actions
github-actions Bot marked this pull request as ready for review November 23, 2026 01:49
@github-actions
github-actions Bot marked this pull request as draft November 25, 2026 02:10
@lidge-jun
lidge-jun marked this pull request as ready for review November 25, 2026 03:54
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration (lane W, @lidge-jun) at exact head 01a61da8548f6a14f1b7d11203bb9085c3972c30. Fixes the self-perpetuating Windows ocx update failure reported in #8960.

Changes I added since the author's head 109dde00e:

  • f2974dcd14 adds a test that seeds another run's receipt and refuses an update handover in Part A. It asserts this run's own claim is removed and the inherited receipt stays byte-identical, with no POST and the shared teardown skipped. This answers the review's SHOULD.
  • Two merges from dev (the latest is 01a61da854).

Relaxed merge gate, checked against dev 89614765bd:

Evidence:

  • PR CI on this head: all checks pass, including gates, test changed and ci. That exact-head test changed job is the test:changed evidence (coordinator ruling).
  • Real Windows x64 (Bun 1.4.4), at f2974dcd14 merged with dev: the same three files give 99 pass / 0 fail.
  • Independent gpt-6.1-terra review, two rounds: PASS, no open findings. After that, only dev was merged in; no contributor push.
  • assert-mergeable-review.sh --maintainer-integration 9062: OK.

@lidge-jun
lidge-jun merged commit 8d43c92 into lidge-jun:dev Nov 25, 2026
35 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 01a61da854

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/index.ts
// #8960: a held Part A that changed nothing owes no teardown, so the receipt this run claimed
// before it goes too. Kept, the next stop inherits it and budgets one more probe, so each
// refused retry needed more time than the last and an update could wedge for good.
if (teardownNonce && windowsPartAHeldUnchanged() && clearPendingTeardown(teardownNonce)) teardownNonce = undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve Link claims whose deferral may already be accepted

For a foreground Windows Link Child with native routing, Ctrl+C during Part A's pre-mutation probes can already hand teardown to this receipt: linkNativeTeardownDecision() recognizes the active clientStopOwner and matching claim and returns defer (src/client/stop-native-handoff.ts:98-105), allowing the signal handler to exit without restoring Codex/Grok. If Part A then returns an unchanged refusal, this line deletes the receipt even though teardown is now owed, while ownershipBlocked also skips the parent's restore. When this was the only claim, native routing remains pointed at the dead Child with no pending recovery receipt. Exclude Link claims from this shortcut unless their deferral is proved unaccepted; Part A's mutation flag alone cannot establish that.

Useful? React with 👍 / 👎.

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.

2 participants