Skip to content

fix(update): release the Bun updater lease around service-manager starts (#5760) - #6407

Merged
lidge-jun merged 4 commits into
devfrom
devin/1790863745-bun-update-lease-release
Oct 1, 2026
Merged

lidge-jun merged 4 commits into
devfrom
devin/1790863745-bun-update-lease-release

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Release the Bun updater's ownership-mutation lease before service-manager starts in both failed-update recovery and the successful post-install refresh. A manager child starts outside the updater process tree and cannot inherit its delegated token; holding the lease through the repair health wait prevents that child from starting.
  • Reacquire before fallback ownership checks and direct startup. A new owner vetoes fallback, and a lease that remains busy fails closed. Direct recovery retains the lease through readiness.
  • This is the Bun CLI counterpart to the dashboard worker fix in fix(update): release the restart lease before the service refresh (#5760) #6404. No ownership, PID, or compatibility checks are relaxed.

Verification

  • Refreshed from dev at 06cc3815c06a10120d89ef986c46be95be37f28a without rewriting branch history, including the accepted upstream role-route and owner-registry ACL fixture corrections. Targeted verification: role routes 7 passed; owner-registry ACL 6 passed. Required CI passed at 70a8b6caff76c840ad37df4bc0e97e53b44f7ecd: zero failed and zero pending checks (platform/path-inapplicable checks remain skipped).

  • bun x tsc --noEmit, bun run privacy:scan, bun run structure:check: passed.

  • bun test tests/update/update-bun-ownership-lease.test.ts: 3 passed, 11 POSIX-only cases skipped on Windows. New subprocess checks verify release, reacquisition, and stale-token fallback; source-order checks cover both service refresh call sites.

  • bun test tests/update/update-desktop-owner.test.ts: passed.

  • POSIX integration assertions were updated for the intentionally released service-refresh boundary but were not executed locally; the latest POSIX CI passed.

  • A broad local test:changed run on the sibling branch reported 2274 passes and 428 failures, including EBUSY cleanup failures and worker panics. Without a base comparison these are not classified as unrelated. Focused checks and the latest required CI passed; the broad local Windows result remains inconclusive.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

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.

Link to Devin session: https://app.devin.ai/sessions/a8795b27d4114aa6be37a88565e404b2
Open in Devin Desktop: https://app.devin.ai/desktop/session/a8795b27d4114aa6be37a88565e404b2?variant=devin

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.

…rts (#5760)

withUpdateOwnershipLease held the mutation lease across 'ocx service
repair' in both the stopped-runtime recovery branch and the post-install
refresh. The manager's 'ocx start' child is not a process descendant and
carries no delegated token, so it died at the acquire deadline; recovery
then fell through to an unmanaged direct start beside a dead supervisor —
the same defect bin/ocx.mjs fixed in 4449334, left unfixed here.

The transaction now exposes release()/reacquire(): the lease is released
immediately before each service-manager-mediated start and re-acquired
before each fallback's ownership re-read, so a claim landing in the
unleased window is vetoed rather than killed unleased (bounded acquire
fails closed). Direct recovery keeps the lease as before.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: e8dca398-200d-480c-941d-58a76b728953

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
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

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

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

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

What to do

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

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/0 boxes ticked.

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

@github-actions
github-actions Bot marked this pull request as draft October 1, 2026 16:11
@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review October 1, 2026 17:54
@github-actions
github-actions Bot marked this pull request as draft October 1, 2026 17:54
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration record (MAINTAINERS.md, dev-only)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-01T23:56:26.339965Z dc10a26 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.

@lidge-jun
lidge-jun merged commit 17d6e84 into dev Oct 1, 2026
33 checks passed
@lidge-jun
lidge-jun deleted the devin/1790863745-bun-update-lease-release branch October 1, 2026 23:52

@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: dc10a2690b

ℹ️ 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/update/index.ts
// cannot join this lease, and holding it through the repair's health wait
// keeps that proxy from starting (#5760). Release it, then decide again —
// a claim could have landed while the repair ran unleased.
mutation.release();

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 Keep ownership fenced until service repair rechecks it

When a desktop takeover races with either newly unleased service-refresh path, it can commit immediately after repairService reads the CLI owner but before that function stops, rewrites, or restarts the manager, because service repair does not itself hold the ownership-mutation lease. The manager child’s later ownership gate can prevent a second listener, but it cannot undo the service-registration mutations performed after the takeover; the fallback-only reacquisition is also too late. Keep the lease through the repair’s final ownership validation and registration work, releasing it only at the manager-start boundary that needs an independently acquiring child.

Useful? React with 👍 / 👎.

Comment on lines +371 to +374
direct start stay serialized with a claim that landed in the unleased window. The dashboard
restart worker in `src/update/job.ts` releases the lease immediately before `ocx service
repair`, re-acquires it at the direct-start fallthrough — a still-claimed lease fails closed —
and re-runs the recorded-owner veto under it before mutating the port.

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 Remove the unsupported dashboard lease claim

At this commit, runUpdateRestartWithOwnershipLease still acquires the lease, installs its token in process.env, awaits the entire dashboard restart callback, and releases only in finally; src/update/job.ts invokes service repair inside that callback and has no release/reacquire handle. Therefore the new statement that the dashboard worker releases before repair and reacquires before fallback is false, and it hides that the dashboard path can still block the manager child and fall back to a directly started proxy. Update the implementation or limit this contract to behavior that actually exists.

AGENTS.md reference: structure/AGENTS.md:L9-L10

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.

1 participant