GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(cli): check live proxy before journal recovery by Ingwannu · Pull Request #1269 · lidge-jun/opencodex Conversation
|
📝 WalkthroughWalkthrough
ChangesStartup lifecycle
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
✅ Deterministic PR hygiene checks passed. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Adopting this — the One gap: Could you extend the fix to On the test: the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
✅ READY
UI screenshot waived by a maintainer comment. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/cli/index.ts`:
- Around line 234-237: Move the ownership gate currently guarding
reconcileJournal near the startup path into a shared helper, including PID
existence, live-proxy detection, and stale-PID cleanup. Invoke this helper
before reconcileJournal in both the startup flow and handleEnsure, so a healthy
active proxy prevents journal merging while stale ownership is cleaned up first;
add an ensure regression case covering this behavior.
In `@tests/cli-start-journal-order.test.ts`:
- Around line 15-30: Replace the source-offset assertions in the journal
ownership ordering test with Bun behavioral regression tests that invoke the
actual CLI lifecycle. In the healthy-owner case, isolate OPENCODEX_HOME and
CODEX_HOME, seed a dead journal PID, run a healthy proxy, execute ocx start, and
verify managed Codex configuration, catalog, journal, profile, and history
remain unchanged; in the dead-owner/no-listener case, use the isolated state
without a proxy and verify reconciliation restores the expected state. Add
equivalent ocx ensure coverage when it uses the shared startup gate, using
existing test helpers and symbols rather than asserting source layout.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 28e246d3-22ea-4c78-8117-76a364e9b03c
src/cli/index.tstests/cli-start-journal-order.test.ts
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // A losing concurrent start must not restore the active proxy's Codex config. | ||
| // Establish that the PID-file owner is stale before reconciling a dead journal; | ||
| // a healthy owner exits above without changing integration state (#1230). | ||
| if (!currentExternalCodexModelProvider()) reconcileJournal(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🏁 Script executed:
#!/bin/bash set -euo pipefail ast-grep outline src/cli/index.ts --items all --type function rg -n -C 30 'async function handleEnsure|reconcileJournal|findLiveProxy|readPid|removePid' src/cli/index.ts
Repository: lidge-jun/opencodex
Length of output: 41991
Apply the ownership gate to handleEnsure before merging.
src/cli/index.ts:444 calls reconcileJournal() before handleEnsure checks for a live proxy at line 450. When another healthy proxy already owns the lifecycle, ocx ensure can restore the stale journal and overwrite the active proxy's Codex configuration/profile. Apply the same PID existence/live-proxy/stale-PID cleanup sequence used in src/cli/index.ts:225-237, share it for both startup paths, and add an ensure regression case.
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/cli/index.ts` around lines 234 - 237, Move the ownership gate currently
guarding reconcileJournal near the startup path into a shared helper, including
PID existence, live-proxy detection, and stale-PID cleanup. Invoke this helper
before reconcileJournal in both the startup flow and handleEnsure, so a healthy
active proxy prevents journal merging while stale ownership is cleaned up first;
add an ensure regression case covering this behavior.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| describe("handleStart journal ownership ordering (#1230)", () => { | ||
| test("a healthy PID-file proxy is detected before journal reconciliation", () => { | ||
| const handleStart = handleStartSource(); | ||
| const readPid = handleStart.indexOf("const existingPid = readPid();"); | ||
| const findLive = handleStart.indexOf("const live = await findLiveProxy();", readPid); | ||
| const healthyExit = handleStart.indexOf("process.exit(1);", findLive); | ||
| const removeStalePid = handleStart.indexOf("removePid(existingPid);", healthyExit); | ||
| const reconcile = handleStart.indexOf("reconcileJournal();", removeStalePid); | ||
| const updatePrompt = handleStart.indexOf("await maybeShowUpdatePrompt();", reconcile); | ||
|
|
||
| expect(readPid).toBeGreaterThanOrEqual(0); | ||
| expect(findLive).toBeGreaterThan(readPid); | ||
| expect(healthyExit).toBeGreaterThan(findLive); | ||
| expect(removeStalePid).toBeGreaterThan(healthyExit); | ||
| expect(reconcile).toBeGreaterThan(removeStalePid); | ||
| expect(updatePrompt).toBeGreaterThan(reconcile); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Replace the source-order assertion with behavioral coverage.
This test compares string offsets only. It never runs handleStart, writes a PID or journal, starts a healthy proxy, or verifies Codex state. A broken implementation can still satisfy Lines [18-30]. Moving reconcileJournal() into a helper also makes the test enforce source layout instead of behavior. The test cannot detect the handleEnsure gap.
Add two Bun regression tests:
OPENCODEX_HOME and CODEX_HOME, seed a dead journal PID, run a separate healthy proxy, invoke ocx start, and assert that managed Codex configuration, catalog, journal, profile, and history remain unchanged.Also cover ocx ensure if it uses the shared startup lifecycle gate.
As per path instructions, runtime behavior changes require focused regression coverage in tests/**. The PR objective also requires healthy-owner and dead-owner/no-listener cases.
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests/cli-start-journal-order.test.ts` around lines 15 - 30, Replace the
source-offset assertions in the journal ownership ordering test with Bun
behavioral regression tests that invoke the actual CLI lifecycle. In the
healthy-owner case, isolate OPENCODEX_HOME and CODEX_HOME, seed a dead journal
PID, run a healthy proxy, execute ocx start, and verify managed Codex
configuration, catalog, journal, profile, and history remain unchanged; in the
dead-owner/no-listener case, use the isolated state without a proxy and verify
reconciliation restores the expected state. Add equivalent ocx ensure coverage
when it uses the shared startup gate, using existing test helpers and symbols
rather than asserting source layout.
Source: Path instructions
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
no gui |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Landed on The defect was real — The correction shares one ownership/liveness preflight across both paths: a healthy owner returns before reconciliation, and a dead owner has only its own matching stale PID removed before recovery. The source-offset assertions were replaced with subprocess behavioral tests, since comparing line positions cannot show that state is actually preserved. Red ablation against your head: 0 passed / 2 failed — healthy Thanks — the ordering insight was the hard part; extending it to the second call site was mechanical once you had named it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.