Skip to content

drive: # NEXT — single highest-priority work package - #4

Merged
khaliqgant merged 3 commits into
mainfrom
flow/drive-0ba6c88-08271225
Aug 27, 2026
Merged

drive: # NEXT — single highest-priority work package#4
khaliqgant merged 3 commits into
mainfrom
flow/drive-0ba6c88-08271225

Conversation

@khaliqgant

Copy link
Copy Markdown
Member

Automated drive tick. Work package: see ops/NEXT.md in diff. Verification and adversarial review passed in-run. A human merges.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 51 minutes.

View limit details

Limit details: You’ve used the included review currently available.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: 59879ca0-a6d7-48c6-8479-e2694dcd5a57

📥 Commits

Reviewing files that changed from the base of the PR and between aeb1c14 and fcce917.

📒 Files selected for processing (31)
  • kernel/relayflowd-core/src/lib.rs
  • kernel/relayflowd-core/src/machine.rs
  • kernel/relayflowd-core/tests/spec_parity.rs
  • kernel/relayflowd-journal/src/registry.rs
  • kernel/relayflowd/src/engine.rs
  • kernel/relayflowd/src/engine/model.rs
  • kernel/relayflowd/src/engine/remote.rs
  • kernel/relayflowd/src/lib.rs
  • kernel/relayflowd/src/main.rs
  • kernel/relayflowd/src/server.rs
  • kernel/relayflowd/src/server/reconcile.rs
  • kernel/relayflowd/src/server/session.rs
  • kernel/relayflowd/src/server/tests.rs
  • kernel/relayflowd/src/server/wire.rs
  • kernel/relayflowd/src/worker.rs
  • kernel/relayflowd/tests/crash_resume.rs
  • kernel/relayflowd/tests/crash_resume/concurrency.rs
  • kernel/relayflowd/tests/crash_resume/llm.rs
  • kernel/relayflowd/tests/crash_resume/llm_support.rs
  • kernel/relayflowd/tests/crash_resume/support.rs
  • ops/DRIVE-LOG.md
  • ops/NEXT.md
  • ops/reviews/20260827-1334-pr4-fixes.md
  • sdk/src/index.ts
  • sdk/src/journal-client.ts
  • sdk/src/protocol.ts
  • sdk/tests/journal-client.test.ts
  • sdk/tests/spec-parity.test.ts
  • testdata/hello-llm.flow.yaml
  • testdata/hello-llm.spec.canonical.json
  • testdata/hello-llm.spec.sha256

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/settings/billing.

Comment @coderabbitai help to get the list of available commands.

khaliqgant added a commit that referenced this pull request Aug 27, 2026
…rnel 42, sdk 54), process drift repeated

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c9b5f5e38

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

let data_dir = data_dir.to_path_buf();
let hub = hub.clone();
let connection_id = next_connection.fetch_add(1, Ordering::Relaxed);
thread::spawn(move || {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Serialize per-run mutations before dispatching work

Each connection now runs in its own thread, but there is no per-run lock around the engine's load-state → next_actions → append/execute sequence. If two clients issue run.resume for the same runnable run concurrently, both can observe the step as Runnable, append starts for the same attempt, and execute or dispatch it twice; SQLite only serializes individual appends, not this scheduling decision. Serialize mutating verbs per run or make the state transition atomic before enabling concurrent handlers.

AGENTS.md reference: AGENTS.md:L19-L21

Useful? React with 👍 / 👎.

Comment thread kernel/relayflowd/src/server.rs Outdated
Comment on lines +139 to +140
engine
.resume(&params.run_id, None)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve valid worker leases during live resume

When run.resume is called while an attached worker is still processing a valid lease, this invokes Engine::resume, which unconditionally applies recovery_actions; that function marks every running attempt crashed before its deadline rather than leaving it active. The server can consequently retry and redispatch work that is still executing, duplicating model calls or external effects. Live resume must distinguish active hub assignments from attempts recovered after a process crash.

AGENTS.md reference: AGENTS.md:L19-L21

Useful? React with 👍 / 👎.

Comment on lines +105 to +106
assignment.lease_deadline_ms = now_ms.saturating_add(LEASE_RENEWAL_MS);
Ok(assignment.lease_deadline_ms)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reconcile expired worker leases

If a worker hangs while keeping its socket open, a heartbeat only updates this in-memory field, and no code reads the deadline or sweeps expired assignments. detach therefore never runs, the journal never receives a lease_expired completion, and the run remains waiting_worker indefinitely instead of retrying; the original journaled deadline also remains unchanged. Add durable renewal and/or an expiry reconciler that abandons the attempt when heartbeats stop.

AGENTS.md reference: AGENTS.md:L11-L13

Useful? React with 👍 / 👎.

Comment thread kernel/relayflowd/src/server.rs Outdated
Comment on lines +150 to +153
let entries = engine
.journal_entries(&params.run_id, 1, usize::MAX)
.map_err(internal_error)?;
hub.watch(connection_id, params.run_id.clone(), writer.clone());

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 Badge Close the replay-to-watch subscription gap

If another connection appends an entry after journal_entries returns but before hub.watch registers this connection, that entry is in neither the replay snapshot nor subsequent notifications, so run.watch permanently misses it. Register the watcher with a sequence cursor atomically before replaying, then deduplicate or replay from that cursor.

Useful? React with 👍 / 👎.

Comment thread kernel/relayflowd/src/server.rs Outdated
Comment on lines +62 to +66
let _ = engine.abandon_out_of_band(
&lease.run_id,
&lease.step_id,
lease.attempt,
CompletionReason::Crashed,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Propagate journal failures during lease abandonment

When disconnect cleanup cannot append the crashed completion—for example because SQLite or the disk fails—let _ silently discards the error after the assignment has already been removed from the hub. The run is then left with an unexplained active attempt and no worker assignment, while the server reports nothing; journal-layer failures must be surfaced rather than swallowed during cleanup.

AGENTS.md reference: AGENTS.md:L16-L18

Useful? React with 👍 / 👎.

khaliqgant and others added 3 commits August 27, 2026 13:14
…rnel 42, sdk 54), process drift repeated

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…, expiry reconciler, watch cursor, fail-closed abandonment

Review fixes for PR #4 (gate-1 rung (b) llm server), each pinned by a test:

1. server.rs P1 — mutating verbs (run.resume, step.complete, event.emit,
   stream.append, disconnect cleanup, reconciler) hold a per-run lock so
   load-state -> next_actions -> append is atomic; two concurrent resumes
   can no longer double-dispatch one attempt.
   Test: concurrency::concurrent_resumes_lease_exactly_one_attempt.

2. server.rs P1 — live run.resume no longer applies recovery_actions
   unconditionally: Engine::resume_live + LeaseProbe leave attempts with a
   valid, heartbeating hub lease running; only detached or past-deadline
   attempts are abandoned (core: recovery_actions_filtered).
   Test: concurrency::live_resume_leaves_an_active_lease_running.

3. session.rs P1 — heartbeats persist the renewed deadline (registry,
   fail-closed) and a 250ms expiry reconciler sweeps assignments, journals
   lease_expired with completionReason, releases the assignment only after
   the durable write, and re-drives the run so the step is leasable again.
   Test: server::tests::stopped_heartbeats_past_the_deadline_journal_lease_expired_and_release_the_step.

4. server.rs P2 — run.watch registers the watcher with a sequence cursor
   BEFORE replaying; concurrent appends buffer and flush deduped against
   the replayed-through seq, closing the replay-then-watch gap.
   Test: server::tests::an_entry_appended_during_watch_registration_is_delivered_exactly_once.

5. server.rs P1 — disconnect cleanup no longer swallows journal failures:
   the error is logged and the abandonment is retained for reconciler
   retry until journaled; abandon_out_of_band returns Ok(None) only for an
   already-resolved lease, journal failures stay hard errors.
   Test: server::tests::a_failed_disconnect_journal_append_is_retained_and_retried_not_dropped.

Verification (hermetic wrapper): kernel 47 passed / 0 failed (was 42),
clippy -D warnings clean, fmt --check clean, sdk 54 passed. Each fix was
mutation-checked: reverting it makes its test fail. Full evidence in
ops/reviews/20260827-1334-pr4-fixes.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant