Skip to content

New detectors daemon for detection and quarantine#29

Open
dimitriosGX wants to merge 15 commits into
mainfrom
dk-quar
Open

New detectors daemon for detection and quarantine#29
dimitriosGX wants to merge 15 commits into
mainfrom
dk-quar

Conversation

@dimitriosGX

@dimitriosGX dimitriosGX commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary by cubic

Introduce a bundled detector daemon (edison-detectord) that takes over MCP discovery, quarantine, and onboarding with a batched approval dialog, automatic bootstrap/enroll on app start, and stdio support. This centralizes policy, improves resiliency (local-enrollment fallback, robust socket reconnect, safer IPC), and lets the client mirror daemon activity into logs while standing down its own pipeline in primary mode.

  • New Features

    • Daemon lifecycle: install as a LaunchAgent, connect via Unix socket, enroll with API/agents/secret, and mirror logs; toggle primary/shadow via EW_DETECTORD_PRIMARY.
    • Discovery prefers the daemon’s list_servers (includes stdio) and falls back to local scan if unreachable or not enrolled.
    • Quarantine approval window: batches prompts, bulk actions, conflict rename, correct “Keep Quarantined” handling, and role-aware labels (“Add to Edison” vs “Request Approval”).
    • Onboarding routes submit/resubmit through the daemon (handles stdio and conflicts); client-side removal is a no-op in primary mode.
    • IPC/preload: window.api.detectord.enroll, .setSecret (returns outcome), and .uninstall; renderer pushes credentials after sign-in; Org Key adoption flows to the daemon.
    • Reliability: enroll falls back to observing existing local enrollment during backend outages; socket reconnect clears partial buffers; try/catch guards keep IPC contracts; resubmit preserves optional agent; clearer template failure reporting; bootstrap race fixed.
    • Build/ops: add scripts/build-detectord.sh and npm run build:detectord; bundle daemon via electron-builder extraResources; mac builds target arm64 only; clear-data teardown purges the daemon.
  • Migration

    • Build the daemon before packaging/dev: npm run build:detectord (or cargo build --release --target aarch64-apple-darwin in detectord/ for mcp_detector_daemon).
    • Primary mode is on by default; set EW_DETECTORD_PRIMARY=0 to use the existing TypeScript hooks/quarantine pipeline.
    • Stdio onboarding is enabled via the daemon path; when disabled, stdio remains unsupported by the client’s HTTP submit path.
    • mac builds are arm64-only; no universal or x86_64 slice.

Written for commit ef813f7. Summary will update on new commits.

Review in cubic

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 22 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/main/index.ts
Comment thread src/main/detectord/bootstrap.ts Outdated
Comment thread src/main/detectord/bootstrap.ts
Comment thread src/main/detectord/submit.ts
Comment thread src/main/detectord/submit.ts
Comment thread package.json
Comment thread src/main/ipc/ipcHandlersMcpSubmit.ts Outdated
Comment thread scripts/build-detectord.sh Outdated
Comment thread src/main/detectord/socket.ts Outdated
Comment thread src/preload/index.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 21 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/main/detectord/socket.ts">

<violation number="1" location="src/main/detectord/socket.ts:54">
P2: A reconnect can lose a reply when the prior socket's delayed `close` fires after the new socket starts receiving data: this clears the shared buffer for the new stream. Associate close handling with its socket and ignore a stale socket's close event before clearing connection state/buffer.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

this.connecting = new Promise<void>((resolve, reject) => {
// A new byte stream must start clean; never inherit a partial frame left
// in the buffer by a previous (abruptly closed) connection.
this.buf = ''

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: A reconnect can lose a reply when the prior socket's delayed close fires after the new socket starts receiving data: this clears the shared buffer for the new stream. Associate close handling with its socket and ignore a stale socket's close event before clearing connection state/buffer.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/main/detectord/socket.ts, line 54:

<comment>A reconnect can lose a reply when the prior socket's delayed `close` fires after the new socket starts receiving data: this clears the shared buffer for the new stream. Associate close handling with its socket and ignore a stale socket's close event before clearing connection state/buffer.</comment>

<file context>
@@ -44,6 +49,9 @@ export class DetectordClient extends EventEmitter {
     this.connecting = new Promise<void>((resolve, reject) => {
+      // A new byte stream must start clean; never inherit a partial frame left
+      // in the buffer by a previous (abruptly closed) connection.
+      this.buf = ''
       const sock = createConnection(this.socketPath)
       sock.setEncoding('utf8')
</file context>

@dimitriosGX dimitriosGX requested a review from IliaMManolov July 13, 2026 10:38

@IliaMManolov IliaMManolov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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