Skip to content

Fix: seed reliability — retry IPC failures, verify Rust worker ready - #610

Merged
joelteply merged 1 commit into
mainfrom
fix/seed-reliability
Mar 30, 2026
Merged

joelteply merged 1 commit into
mainfrom
fix/seed-reliability

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Problem

Seeding fails on fresh installs: All IPC connections to continuum-core failed. The Rust worker isn't ready when seeding starts.

Fix

  1. waitForJTAGReady() now verifies Rust IPC via data/list — won't proceed until Rust worker responds
  2. createUserViaCommand() retries 3x with backoff on IPC/timeout errors

Test

  • npm run build:ts passes
  • npm run data:seed succeeds — all 16 personas created
  • AIs responding in chat (4+ personas verified)

…ore seeding

Seed was failing on fresh installs because Rust IPC wasn't ready when seeding
started. Two fixes:
1. waitForJTAGReady() now verifies Rust IPC via data/list before proceeding
2. createUserViaCommand() retries 3x with backoff on IPC/timeout errors
Copilot AI review requested due to automatic review settings March 30, 2026 05:41
@joelteply
joelteply merged commit 6deee76 into main Mar 30, 2026
4 of 6 checks passed
@joelteply
joelteply deleted the fix/seed-reliability branch March 30, 2026 05:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Improves data:seed reliability on fresh installs by gating seeding on Rust IPC readiness and adding retries for transient IPC/timeout failures during user creation.

Changes:

  • Add retry-with-backoff to createUserViaCommand() when user creation fails due to transient IPC/timeout conditions.
  • Extend waitForJTAGReady() to additionally verify Rust IPC connectivity by running a data/list command before proceeding.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/scripts/seed/helpers.ts Adds retry/backoff logic (and exec timeout) around ./jtag user/create to reduce flakiness during early startup.
src/scripts/seed-continuum.ts Updates readiness gating to wait for Rust IPC by probing data/list after ping reports TS server readiness.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +346 to +351
// IPC/timeout errors — retry if attempts remain
const isTransient = err.message?.includes('IPC') || err.message?.includes('timeout') || err.message?.includes('TIMEOUT');
if (isTransient && attempt < MAX_RETRIES) {
console.log(` ⏳ Transient error, retrying in ${attempt * 3}s (attempt ${attempt}/${MAX_RETRIES})...`);
await new Promise(r => setTimeout(r, attempt * 3000));
continue;

Copilot AI Mar 30, 2026

Copy link

Choose a reason for hiding this comment

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

The retry logic treats timeouts as transient by checking substrings in err.message, but child_process.exec timeout errors often don't include "timeout"/"TIMEOUT" in the message (they may surface via killed, signal, or code like ETIMEDOUT). This can prevent retries from happening on actual timeouts. Consider detecting timeouts via the exec error fields (e.g., (err as any).killed, (err as any).signal, (err as any).code) and including that in isTransient.

Copilot uses AI. Check for mistakes.
Comment on lines +248 to +249
const { stdout: dbCheck } = await execAsync('./jtag data/list --collection=users --limit=1', { timeout: 10000 });
if (dbCheck.includes('"success":true') || dbCheck.includes('"success": true')) {

Copilot AI Mar 30, 2026

Copy link

Choose a reason for hiding this comment

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

The Rust IPC readiness check looks for string snippets in data/list output. Since ./jtag commands can emit extra log lines (you already robustly extract JSON for ping above), this can be brittle and can mis-detect readiness. Consider extracting/parsing the JSON from dbCheck and checking result.success === true (and optionally use DATA_COMMANDS.LIST instead of a hard-coded data/list string for consistency).

Suggested change
const { stdout: dbCheck } = await execAsync('./jtag data/list --collection=users --limit=1', { timeout: 10000 });
if (dbCheck.includes('"success":true') || dbCheck.includes('"success": true')) {
const { stdout: dbCheck } = await execAsync(`./jtag ${DATA_COMMANDS.LIST} --collection=users --limit=1`, { timeout: 10000 });
// Extract JSON from potentially polluted data/list output
const firstDbBrace = dbCheck.indexOf('{');
const lastDbBrace = dbCheck.lastIndexOf('}');
if (firstDbBrace === -1 || lastDbBrace === -1 || firstDbBrace > lastDbBrace) {
throw new Error('No valid JSON in data/list output');
}
const dbJsonStr = dbCheck.substring(firstDbBrace, lastDbBrace + 1);
const dbResponse = JSON.parse(dbJsonStr);
if (dbResponse?.result?.success === true) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants