Skip to content

fix(cli): succeed ensure for validated connected clients - #6427

Merged
lidge-jun merged 1 commit into
lidge-jun:devfrom
Ingwannu:fix/6420-connected-client-ensure
Oct 2, 2026
Merged

lidge-jun merged 1 commit into
lidge-jun:devfrom
Ingwannu:fix/6420-connected-client-ensure

Conversation

@Ingwannu

@Ingwannu Ingwannu commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Fixes [Bug]: ocx ensure exits 1 in connected client mode, so the Codex shim warns 'proxy autostart failed' on every launch #6420's connected-client ocx ensure exit-status defect on dev 8b23fe340a53799aac5ad7654582a75df7ade7c8. A validated connected client needs no local provider startup and now returns success after journal reconciliation, so the Codex shim does not print a false autostart failure.
  • Invalid/mismatched state still returns failure; disconnected local ensure and reconciliation failure behavior remain unchanged. This does not probe the remote hub, change credentials, or fix the separate GUI token observation.
  • Adds actual dispatch regressions and both test-layout registrations; documents the bounded contract in runtime structure and the CLI lifecycle reference. Thanks to @andrew05060414 for the report and proposed exit-status correction.

Verification

  • Red before the production change: the new dispatch regression reproduced connected state returning 1 instead of 0 (5 passed, 1 failed).
  • Green: bun test tests/cli/cli-ensure-client-state.test.ts tests/cli/cli-client-start-fence.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/file-size-ratchet.test.ts tests/ci-workflows/structure-ssot.test.ts — 92 passed, 0 failed, 781 assertions, exit 0, Bun 1.4.0. The test runner cleanup explicitly resets the injected process exit code; the first combined run had passing assertions but a nonzero runner exit and was not treated as successful.
  • git diff --cached --check passed.
  • Full local tsc --noEmit with Node 24.16.0 and a 768 MiB V8 heap did not complete: the capped systemd unit reached its runtime limit and was killed (memory peak 1.2 GiB, swap 0). This is not a passing local typecheck.
  • Hosted follow-up for head 250c791e18f3026ddd448c49243f17bb729680cc: Cross-platform CI 36974010724 completed successfully. Its merge checkout c246f70 explicitly includes this head and base 8b23fe340a53799aac5ad7654582a75df7ade7c8. The gates job completed bun x tsc --noEmit successfully; all four Linux test shards, docs build, structure gate and selected smoke jobs passed. Unselected Windows shard/macOS/native legs are not execution evidence. This addresses the validation hold using hosted evidence, not an increased local cap; now ready for maintainer review, not approved/merged/released.
  • Resource exception: local validation ran one workload at a time as ubuntu with fresh HOME/CODEX_HOME/OPENCODEX_HOME/TMPDIR; CPUQuota=75%, MemoryHigh=1280M, MemoryMax=1536M, MemorySwapMax=0, TasksMax=64, IOWeight=20 and nice=10. No limit increase or unbounded retry. Full suite and docs build are deferred to hosted CI, not claimed as locally verified.
  • No security scan, live client connection, account traffic, shared service restart, or live configuration mutation was performed.

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.

The client-state acceptance rules and credential handling are unchanged. No independent trust-boundary review is claimed; the user prohibited new security scans.

Summary by CodeRabbit

  • New Features
    • ocx ensure now succeeds without starting a local provider when the connected client’s state is valid. Disconnected clients continue through local startup; invalid or mismatched state still fails.
  • Documentation
    • Clarified how ocx ensure handles connected, disconnected, and invalid client states.

Preserve journal reconciliation and local startup refusal while avoiding a false Codex shim autostart error.

Co-authored-by: Andrew Wang <[email protected]>
@Ingwannu
Ingwannu requested a review from lidge-jun October 2, 2026 06:32
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (2)
src/AGENTS.md — auto-discovered
structure/AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 0d831798-8713-4741-86d4-623c966775bc

📥 Commits

Reviewing files that changed from the base of the PR and between 8b23fe3 and 250c791.

📒 Files selected for processing (6)
  • docs-site/src/content/docs/reference/cli/lifecycle.md
  • scripts/test-layout/layout.json
  • src/cli/dispatch.ts
  • structure/runtime.md
  • tests/cli/cli-ensure-client-state.test.ts
  • tests/fixtures/test-layout-expected.json

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


📝 Walkthrough

Walkthrough

ocx ensure now exits successfully for validated connected-client state after journal reconciliation. It does not start a local provider proxy or probe remote-hub availability in that state. Invalid or mismatched state still fails, and disconnected state retains local ensure.

Changes

Connected-client ensure behavior

Layer / File(s) Summary
Dispatch behavior and regression coverage
src/cli/dispatch.ts, tests/cli/cli-ensure-client-state.test.ts
Connected state now returns exit code 0 after journal reconciliation. Invalid and mismatched states return failure, while disconnected state uses the local ensure handler. Tests cover these paths and journal reconciliation errors.
Behavior documentation and test registration
docs-site/src/content/docs/reference/cli/lifecycle.md, structure/runtime.md, scripts/test-layout/layout.json, tests/fixtures/test-layout-expected.json
The documentation describes connected, invalid, mismatched, and disconnected behavior. The new CLI test is registered in the test layout and its expected fixture.

Priority: ⬇️ Low

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

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 250c7

Connected-client ocx ensure succeeds after journal reconciliation, and the informational message does not change the inspected caller’s success result.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 250c7

The fix preserves existing startup and credential boundaries, but successful exit status can now hide unresolved client-routing recovery from the Codex launcher.

Retained concerns

  • Low · reliability · inferred: A connected configuration now yields success even when journal recovery preserves unverified files or completes only part of the configuration/profile restoration. Because the Codex wrappers discard reconciliation output and show their failure diagnostic only for unsuccessful ensure, unresolved routing recovery can become less visible. The recovery limitations predate this PR; the newly successful status worsens their observability, without newly authorizing Codex execution.
Security review details

Security Blast Radius

  • inferred — The demonstrated impact is limited to lifecycle reporting and recovery visibility for the local Codex configuration/profile pair. The inspected change does not add a remote request, listener, credential mutation, or additional execution privilege.

Security Findings and Attack Paths

  • inferred — A connected client with a recoverable mismatched-owner or stale-process journal can encounter unverified or incomplete recovery yet exit successfully. The wrappers then omit their failure diagnostic. This supports reduced visibility into unresolved routing state, but does not establish attacker-directed routing or credential disclosure.

Trust Boundaries and Controls

  • observed — Existing controls remain: invalid or mismatched client configuration fails, matching active-client journal ownership skips restoration, live or permission-protected process ownership skips restoration, and unverified restoration preserves existing files.
  • observed — The Unix, CMD, and PowerShell wrappers launch Codex regardless of ensure's success. The changed status affects their diagnostic, not permission to execute Codex.

Resilience and Maintainability Implications

  • observed — The reconciliation boolean mixes benign no-op outcomes with unsuccessful recovery, and can also report true after only one restoration succeeds. It is therefore not a complete-recovery indicator, independently of this PR.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (4 skipped: 4 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: ocx ensure now succeeds for validated connected clients.
Linked Issues check ✅ Passed The PR meets the coding requirements in #6420. In src/cli/dispatch.ts, the ensure runner reconciles the client journal, returns success for connected, keeps invalid and mismatched as failure…
Out of Scope Changes check ✅ Passed The changed files stay within #6420. The dispatch change implements the connected-client exit-status fix. The new test provides regression coverage for the required state and reconciliation behavior. …
Full 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. Analyzed 1 functions across 2 files. (4 skipped: 4 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • 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 2, 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 2, 2026
@Ingwannu
Ingwannu marked this pull request as ready for review October 2, 2026 06:44
@Ingwannu

Ingwannu commented Oct 2, 2026

Copy link
Copy Markdown
Owner Author

@lidge-jun Ready for your review at 250c791. The local capped typecheck timed out and remains documented as such; current-head hosted CI 36974010724 now completed successfully, including actual typecheck, four Linux shards, docs and structure gates. The local red/green dispatch proof and 92 passing focused/gate tests are in Verification. No self-approval, merge, release or live configuration change. This only corrects connected-client ensure success after reconciliation; invalid/mismatched state remains refused and remote availability is not certified.

@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration decision (dev, admin bypass per MAINTAINERS.md): merging at exact head 250c791.

  • Exact-head CI: Cross-platform CI passed; the latest Enforce PR target branch, PR hygiene, React Doctor and Labeler runs passed. The one cancelled enforce-target run was superseded by a later successful run on the same head.
  • No unresolved review threads. The branch is 4 commits behind dev; merge-tree is clean, and the only overlapping file (src/cli/dispatch.ts) changes in an unrelated command block.
  • Behaviour: ocx ensure returns 0 for a validated connected client, so the Codex shim stops warning on every launch. Fixes [Bug]: ocx ensure exits 1 in connected client mode, so the Codex shim warns 'proxy autostart failed' on every launch #6420.

@lidge-jun
lidge-jun merged commit af35814 into lidge-jun:dev Oct 2, 2026
41 of 42 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.

2 participants