-
Notifications
You must be signed in to change notification settings - Fork 670
fix(cli): check live proxy before journal recovery #1269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { describe, expect, test } from "bun:test"; | ||
| import { readFileSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
|
|
||
| const source = readFileSync(join(import.meta.dir, "..", "src", "cli", "index.ts"), "utf8"); | ||
|
|
||
| function handleStartSource(): string { | ||
| const start = source.indexOf("async function handleStart("); | ||
| const end = source.indexOf("async function handleEnsure(", start); | ||
| expect(start).toBeGreaterThanOrEqual(0); | ||
| expect(end).toBeGreaterThan(start); | ||
| return source.slice(start, end); | ||
| } | ||
|
|
||
| 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); | ||
|
Comment on lines
+15
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Add two Bun regression tests:
Also cover As per path instructions, runtime behavior changes require focused regression coverage in 🤖 Prompt for AI AgentsSource: Path instructions |
||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 41991
Apply the ownership gate to
handleEnsurebefore merging.src/cli/index.ts:444callsreconcileJournal()beforehandleEnsurechecks for a live proxy at line 450. When another healthy proxy already owns the lifecycle,ocx ensurecan 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 insrc/cli/index.ts:225-237, share it for both startup paths, and add anensureregression case.🤖 Prompt for AI Agents