Skip to content

fix: release startup migration lease before exit - #103157

Merged
steipete merged 1 commit into
mainfrom
codex/fix-startup-migration-lease
Jul 9, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-startup-migration-lease

Conversation

@steipete

@steipete steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Closes #103145

What Problem This Solves

Gateway startup config drift can request a controlled process exit while doctor preflight still owns the shared startup-migration lease. A hard runtime exit bypasses the lease cleanup finally, so immediate retries wait for the five-minute lease expiry.

Why This Change Was Made

Defer guarded exits with the existing typed ExitError, let doctor preflight unwind its heartbeat and lease, then hand the original exit code back to the CLI runtime. Pin lease and checkpoint operations to the accepted environment so a later config reload cannot redirect cleanup to another state database.

The preflight also treats a rejected second config guard as a startup failure instead of recording a successful migration checkpoint.

User Impact

When the selected config changes during startup, the gateway exits with the existing status and can be retried immediately. Service-mode future-config rejection keeps exit code 78 and revokes the destructive override as before.

Evidence

  • Before-fix exact-base focused run: new regression tests failed at the hard exit paths in pre-bootstrap.ts and future-config-guard.ts.
  • Blacksmith Testbox tbx_01kx4hyn6qdjpyfpvakgyepk6h: 211 focused tests passed across runtime, config guard, gateway startup, and migration preflight.
  • Same Testbox: pnpm check:changed passed for core, core tests, and docs lanes.
  • Same Testbox: pnpm build passed, including tsdown, CLI bootstrap import guard, runtime postbuild, and Control UI build.
  • Targeted pnpm format:check passed for all 8 changed files.
  • Fresh autoreview: clean, no accepted or actionable findings.

AI-assisted implementation and review.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: M maintainer Maintainer-authored PR labels Jul 9, 2026

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

Copy link
Copy Markdown
Contributor

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: 11e325026c

ℹ️ 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 CHANGELOG.md

### Fixes

- **Gateway startup migrations:** release the shared migration lease before exiting when the selected config changes during startup, allowing immediate retries instead of blocking readiness until the five-minute lease expires. (#103145)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Remove the manual changelog entry

For normal fixes or direct-main commits, root AGENTS.md makes CHANGELOG.md release-only and says release generation owns these entries; adding this Unreleased line manually can leave stale or duplicated release notes when the generator derives the release from merged PRs and direct commits. The commit message already carries the release-note context, so this line should be removed and left to the release-generation flow.

Useful? React with 👍 / 👎.

@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 11e325026ced1f25c19698c7762fcccaa5d8e508:

  • Before fix, the new focused regressions failed on the exact base because runtime.exit(1) escaped from pre-bootstrap.ts / future-config-guard.ts before doctor preflight could release its lease.
  • Blacksmith Testbox tbx_01kx4hyn6qdjpyfpvakgyepk6h: corepack pnpm test src/commands/doctor-config-preflight.state-migration.test.ts src/cli/program/config-guard.test.ts src/cli/run-main.exit.test.ts src/runtime.test.ts — 211/211 passed.
  • Same Testbox: env OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 corepack pnpm check:changed — passed for core, core tests, and docs lanes.
  • Same Testbox: corepack pnpm build — passed, including tsdown, CLI bootstrap import guard, runtime postbuild, and Control UI build.
  • Same Testbox: targeted corepack pnpm format:check — all 8 changed files matched.
  • Fresh autoreview — clean; no accepted or actionable findings.
  • Authoritative exact-head CI — success: https://github.com/openclaw/openclaw/actions/runs/29058141491
  • Repo-native review-validate-artifacts — READY FOR /prepare-pr, 0 findings.
  • Repo-native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 103157 — hosted exact-head gates passed; prepared and verified the same head SHA.

Known proof gaps: none for the touched gateway startup/config-migration surface.

@steipete
steipete merged commit 5337845 into main Jul 9, 2026
129 of 135 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the codex/fix-startup-migration-lease branch July 9, 2026 23:53
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
steipete added a commit that referenced this pull request Jul 11, 2026
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway config-drift exit strands startup migration lease

1 participant