Skip to content

Replace generic Error with DaemonConflictError in split-brain guard - #51

Merged
clduab11 merged 2 commits into
branch-3-devtestfrom
copilot/sub-pr-48-another-one
Feb 13, 2026
Merged

Replace generic Error with DaemonConflictError in split-brain guard#51
clduab11 merged 2 commits into
branch-3-devtestfrom
copilot/sub-pr-48-another-one

Conversation

Copilot AI commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

CodeFactor identified the split-brain guard throwing a generic Error instead of a typed exception, preventing callers and tests from distinguishing daemon conflicts from other failure modes.

Changes

  • Added DaemonConflictError class in src/core/errors.ts:

    • Extends CodexSynapticError with DAEMON_CONFLICT error code
    • Marked non-retryable (conflicts require operator intervention)
    • Captures structured context: daemonPid, alreadyRunning, allowLocalWithDaemon
  • Updated split-brain guard in src/cli/index.ts:

    • Replaced throw new Error(...) with throw new DaemonConflictError(...)
    • Added context object for debugging and telemetry

Example

// Before
throw new Error(`Background daemon already running (pid ${background.pid})...`);

// After
throw new DaemonConflictError(
  `Background daemon already running (pid ${background.pid})...`,
  {
    daemonPid: background.pid,
    alreadyRunning,
    allowLocalWithDaemon: process.env.CODEX_ALLOW_LOCAL_WITH_DAEMON
  }
);

// Now testable via instanceof
try {
  await useSystem('operation', async (sys) => { ... });
} catch (e) {
  if (e instanceof DaemonConflictError) {
    // Handle daemon conflict specifically
  }
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: clduab11 <185000089+clduab11@users.noreply.github.com>
Copilot AI changed the title [WIP] Add MCP workflows and growth automation docs Replace generic Error with DaemonConflictError in split-brain guard Feb 13, 2026
Copilot AI requested a review from clduab11 February 13, 2026 03:30
@clduab11
clduab11 marked this pull request as ready for review February 13, 2026 03:34
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@clduab11
clduab11 merged commit 100e422 into branch-3-devtest Feb 13, 2026
1 check passed
@github-actions

Copy link
Copy Markdown

Codex PR Review

Findings

  • P3: The split-brain guard now throws DaemonConflictError, but there is no automated coverage to lock this in. A future refactor could silently revert to a generic Error. Adding a targeted test would prevent that regression (src/cli/index.ts:601).

Suggested Fixes

  • Add a CLI/system test that stubs getBackgroundStatus() to report an active daemon and asserts useSystem() rejects with DaemonConflictError when CODEX_ALLOW_LOCAL_WITH_DAEMON is unset.

MCP Usage

  • deepwiki: Attempted resources/list; failed because DEEPWIKI_API_KEY is unset.
  • context7: Attempted resources/list; server responded “Method not found”.
  • brave: Attempted resources/list; MCP handshake failed (connection closed).
  • jina: Attempted resources/list; failed because JINA_API_KEY is unset.
  • firecrawl: Attempted resources/list; MCP handshake failed (connection closed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants