Skip to content

test: lock the proactive backend-id guarantee (never-again) - #104

Merged
TraderSamwise merged 1 commit into
masterfrom
test/lock-proactive-backend-id-capture
Jun 7, 2026
Merged

test: lock the proactive backend-id guarantee (never-again)#104
TraderSamwise merged 1 commit into
masterfrom
test/lock-proactive-backend-id-capture

Conversation

@TraderSamwise

@TraderSamwise TraderSamwise commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Goal: never again

The durable answer to "an agent loses its backend id and can't be restored" is proactive assignment: aimux launches claude with its own --session-id (config.ts:148) and persists it the instant the session spawns (session-launch.ts:530:545 saveState → topology, fsync-durable via W1). The id is never discovered after the fact — it's known from the start.

That already works (empirically, almost every project shows 1/1 claude sessions with a backend id). The stranded tealstreet-next sessions were legacy, spawned before the --session-id flag existed.

The gap was not behavior — it was the lack of a lock. The reactive hook path silently rotted in 298d5a1 precisely because no test guarded it. This PR guards the proactive path the same way, at the two points it could regress:

  • config — the default claude tool ships sessionIdFlag: ["--session-id", "{sessionId}"] with backend-resume enabled. Drop it and the failure mode returns.
  • session-launch — a fresh claude launch (given that flag, as the real spawn path passes it) generates a uuid backend id, passes it as --session-id <uuid>, and persists via saveState.

Together with the W0 reactive-capture test, both capture paths are now test-locked. If either regresses, CI fails instead of an agent silently becoming unrecoverable after the next crash.

Verification

Tests-only — no runtime change. yarn verify green: typecheck + lint clean, 1029/1029 tests.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Improved test coverage for backend session management and persistence verification
    • Enhanced configuration testing to verify session id assignment and state handling

…gress

The durable fix for "an agent loses its backend id and becomes
unresumable" is that aimux assigns the id at spawn: it launches claude
with its own --session-id and persists it immediately (saveState ->
topology), rather than discovering it later. That already works, but like
the reactive hook path that 298d5a1 silently broke, nothing locked it.

Lock the two points it could regress:
- config: the default claude tool ships sessionIdFlag ["--session-id",
  "{sessionId}"] with backend-resume enabled. Dropping it recreates the
  failure mode.
- session-launch: a fresh claude launch (given that flag, as the spawn
  path passes it) generates a uuid backend id, passes it as --session-id,
  and persists via saveState.

Together with the W0 reactive-capture test, both capture paths are now
guarded.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jun 7, 2026 3:57am

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7f11ace3-ee5d-4f8b-8280-741091ea59dc

📥 Commits

Reviewing files that changed from the base of the PR and between 45babda and c4408f5.

📒 Files selected for processing (2)
  • src/config.test.ts
  • src/multiplexer/session-launch.test.ts

📝 Walkthrough

Walkthrough

This PR adds test coverage for backend session ID handling across two test suites. The first test verifies that the default Claude configuration properly initializes a session ID flag and resume arguments. The second test confirms that session creation generates a unique ID, binds it into the command, and persists the state.

Changes

Backend Session ID Test Coverage

Layer / File(s) Summary
Config session ID initialization test
src/config.test.ts
Verifies that the default Claude config includes a --session-id flag with {sessionId} placeholder, resume arguments reference the session ID, and resumeByBackendSessionId is enabled.
Session launch and persistence test
src/multiplexer/session-launch.test.ts
Confirms that createSession generates a UUID-pattern backend session ID, injects it into the spawned command as a --session-id argument, and persists state through host.saveState.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A session blooms with IDs bright,
Each test a checkpoint, burning light,
Config and launch dance hand-in-hand,
State saved safe across the land!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main objective: adding tests to lock the proactive backend session ID guarantee to prevent regressions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/lock-proactive-backend-id-capture

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

@TraderSamwise
TraderSamwise merged commit cd8d6ac into master Jun 7, 2026
3 checks passed
@TraderSamwise
TraderSamwise deleted the test/lock-proactive-backend-id-capture branch June 7, 2026 04:01
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