Repository navigation
test(claude): isolate the Desktop lifecycle lock in first-party fixtures - #7868
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ READY
Hygiene✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Lifecycle-lock isolation helper tests/helpers/client-lifecycle-lock.ts |
Adds a helper that wraps synchronous and asynchronous lifecycle-lock calls, uses a root-scoped default path when no path is supplied, records acquisition kinds and resolved paths, and restores both spies. |
Fixture isolation and management API verification tests/claude-integration/claude-config-root-late-admission.test.ts, tests/claude-integration/claude-config-root-writer-barrier.test.ts, tests/claude-integration/claude-desktop-first-party-guards.test.ts, tests/claude-integration/claude-desktop-first-party.test.ts, tests/claude-integration/claude-desktop-picker-routes.test.ts, tests/claude-integration/claude-first-party-agent-sync.test.ts, tests/claude-integration/claude-intercept-acl-barrier.test.ts, tests/claude-integration/claude-messages-endpoint.test.ts |
The fixtures isolate lifecycle locks using their temporary roots and restore the spies during teardown. The management API test checks lock-path containment and confirms that production runtime-root resolution is not called. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Other
Merge Risk: 
Minimal · up to 738b5
-
The fixtures use isolated lock paths. No merge-blocking issue was identified.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 9 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 2
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- 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.
Comment @coderabbitai help to get the list of available commands.
|
Maintainer integration into dev: all 26 checks passed on exact head 738b595, which merges into current origin/dev without conflict. Test-only change. Independent review (GPT-6.1 Sol, high) confirmed the isolation intercepts named imports for both sync and async lifecycle entry points, restores after failure, and that the namespace regression is non-vacuous; it also found two more files (claude-picker-runtime, claude-picker-relay-intent) that still reach the account-wide lock. That finding is accepted and will land as a follow-up PR from a full sentinel sweep, so this fix is not held for it. |
Summary
tests/claude-integration/claude-desktop-first-party.test.ts>POST /api/claude-desktop/apply defaults to gateway; first-party is explicit and carries the account-risk noticefailed in #7760'stest changedjob (run 40626448565, job 122613979078, ubuntu) with HTTP 500 and{"error":"desktop_lifecycle_busy_or_unsafe","saved":true}. #7760 does not touch that path.Cause: Claude Desktop writes run under the client lifecycle lock (
src/client/lifecycle-lock.ts). Unless a caller passeslockPath, that lock lives in the effective OS user's runtime directory, independent ofOPENCODEX_HOME, and it is taken withbusy_timeout = 0. CI runs test files in parallel processes as one user. Whenever another file held that lock, this file's gateway apply gotclient_lifecycle_busy, whichwriteDesktop3pConfig(src/claude/desktop-3p.ts) reports asdesktop_lifecycle_busy_or_unsafe. The product refusal is correct; the fixture was not isolated. Other files already isolate it, for exampleclaude-desktop-picker-profile.test.tsandclaude-desktop-cli.test.ts.Changes (tests only):
tests/helpers/client-lifecycle-lock.tswraps the sync and async lifecycle entry points withlockPath: deps?.lockPath ?? <fixture>/locks/lifecycle.sqliteand forwards to the real implementations, so SQLite exclusion and lease checks stay real. Explicit lock paths are preserved.beforeEachand restored inafterEachin this file and in the seven sibling files that reach the same writers in process:claude-desktop-first-party-guards,claude-desktop-picker-routes,claude-first-party-agent-sync,claude-config-root-writer-barrier,claude-config-root-late-admission,claude-intercept-acl-barrierandclaude-messages-endpoint.No production code, timeouts, retries, skips or assertion changes.
Verification
Windows 11, Bun 1.4.4:
claude-desktop-first-party.test.ts: 15 pass / 23 fail on cleanorigin/devon this host (Windows host baseline), 39 pass / 0 fail with this change.lockPathremoved, passes with it.BEGIN IMMEDIATE, the unisolated gateway apply returned 500desktop_lifecycle_busy_or_unsafe(underlyingclient_lifecycle_busy). The isolated gateway and first-party applies returned 200 while that transaction was still held.an explicit picker off is remembered...timeout,present invalid compatibility modes return one fixed 503...) also fail on cleanorigin/devon this host. The third (native passthrough precedes even invalid compatibility mode,SPEND_LEDGER_OWNER_HOME_CONFLICT) followed the preceding timed-out cleanup and was not separately reproduced on the baseline.bun run typecheck: exit 0.NOT RUN: full
bun run test, localtest:changed, hosted macOS/Windows CI. Ubuntu PR CI covers the hosted Linux job where this failed.Checklist
devSummary by CodeRabbit