Skip to content

fix(restore): a community-harness seat the snapshot saw detached launches its harness, not a bare shell - #4050

Open
cavalcanticampos wants to merge 2 commits into
mvschwarz:mainfrom
cavalcanticampos:fix/4047-fix-restore-a-community-harness-seat-the
Open

cavalcanticampos wants to merge 2 commits into
mvschwarz:mainfrom
cavalcanticampos:fix/4047-fix-restore-a-community-harness-seat-the

Conversation

@cavalcanticampos

@cavalcanticampos cavalcanticampos commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What a user gets

Before: after a host reboot, rig launch <rig> <seat> on a launch-only community-harness seat printed Harness not started: no <preset> runtime adapter for <seat>. It also left a tmux session with only a bare shell, and a new session row with no harness selection (agent_app = NULL). That row then hid the seat's harness, so rig seat launch <seat> --fresh was refused with runtime_adapter_missing and the seat was stuck.

After: the seat starts fresh with its community harness, and the new session row keeps the harness selection.

Fixes #4047

Cause. An auto-periodic snapshot taken after the reboot sees the seat's session as detached, so it records the occupant as { kind: "absent" }. postLaunchRestore then has session = null. It used session?.communityHarness both to resolve the adapter (seatAdapter) and to carry the selection onto the new session. Both got undefined, so no adapter was found. The fail-closed branch then marked the harness not started and left the shell and its row behind.

Fix. When the snapshot records no occupant for the seat (and no history was explicitly selected), the harness selection is read from the seat's newest saved session row in that snapshot. The adapter lookups use it, and so does recordCommunityHarnessSelection for the new session. communityHarnessOf still requires the selection to match the node's current runtime, so a seat whose runtime changed, or a free-text runtime, still gets no community adapter. When an occupant is resolved, behaviour is unchanged.

How you verified it

On main at d958809:

  • New test in packages/daemon/test/launch-node-subset.test.ts. It uses a launch-only preset (first_input: true) and a snapshot whose occupant for the seat is absent while the seat's saved session carries communityHarness. It then launches the seat with the community resolver from withCommunityHarnessResolver. Without the fix the result is attention_required (the "Harness not started" path). With it the result is fresh-primed, the harness launch is called once, and the new session row has agent_app set to the preset.
  • These suites pass: launch-node-subset, restore-orchestrator, community-harness-runtime, community-harness-snapshot, community-harness-existing, qa-community-harness-snapshot-boundary.
  • npx tsc --noEmit -p packages/daemon/tsconfig.json is clean.
  • A wider vitest run (files matching restore/launch/rehydrate) passed apart from failures caused by my machine. My shell rc prints a banner that breaks the stdout parsing in seat-launch-environment and claude-interactive-launch, launch-exited-agent needs the CLI built, and seat-launch-environment-regression gets a /tmp readlink EINVAL. The last two fail the same way without this change.
  • Not run: the full npm test, npm run lint and npm run build, and a real Antigravity CLI seat. The harness's adapter methods are stubbed in the test.

Anything you were unsure about

  • This fixes defect A from the issue, which stops a seat getting stuck this way. It does not change the fail-closed branch itself (defect B). If the adapter is genuinely missing (for example the preset was removed), a "harness not started" provisional shell and row are still left in place, as before.
  • A seat already stuck from an earlier run still has a harness-less newest row, so this change won't recover it. The rig start --last / rig_not_stopped question for a partly running rig is also not addressed here.
  • The fallback picks the newest saved row by id. I didn't skip superseded rows, because the runtime match in communityHarnessOf already guards against a stale selection.

If this is security-related

Not security-related.

  • One concern per PR; no version bump; no CHANGELOG.md edit
  • Tests added or updated where the change is testable
  • I listed the checks I ran, their results, and any checks I could not run

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Restoring a detached seat now preserves the community-harness selection from its newest saved session when no session history is selected. That selection is used consistently for relaunching, guidance, resuming, and replaying startup activity.
    • Seats with an active occupant, or restored from explicitly selected history, continue to use that occupant’s harness selection. A detached seat starts only when its saved harness matches the seat’s runtime.
  • Documentation
    • Clarified fresh-start behavior for detached community-harness seats after a reboot.

…rness

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When no history was selected and the snapshot has no active occupant, the restore path now uses the seat’s newest saved session to select the community harness. The selection is used for adapter lookups and the relaunched session record. Tests and reference documentation cover this behavior.

Changes: Detached-seat harness restoration

Layer / File(s) Summary
Harness selection and subset-launch coverage
packages/daemon/src/domain/restore-orchestrator.ts, packages/daemon/test/launch-node-subset.test.ts, docs/reference/community-harness-presets.md
When no history was selected and the snapshot has no active occupant, the restore path derives the harness selection from the seat’s newest saved session. It uses that selection for adapter lookups and the relaunched session’s agent_app. Tests check matching and nonmatching runtime selections. The reference documents fresh-start behavior for detached seats.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: mvschwarz

Merge Risk: Minimal · up to 8190f

A detached community-harness seat with no recorded occupant now restarts fresh with the harness named by its newest saved session. If the newest session names a different harness or none, launch still stops and asks. Nothing blocking was found. The change is small, covered by new tests, and easy to revert.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the fix's main subject: a community-harness seat that the snapshot saw as detached now launches with its harness instead of a bare shell. The raw summary and objectives both describe t…
Linked Issues check Passed [#4047] Primary objective: a launch-only community-harness seat must start fresh with its harness, or refuse cleanly without state changes, and a fresh launch must stay available. The PR scopes its wo…
Out of Scope Changes check Passed Three files changed since the merge base, per the summary: packages/daemon/src/domain/restore-orchestrator.ts (about +11/-5) changes only the harness-selection source for the absent-occupant case, and…
Full details: Title check

Explanation

The title names the fix's main subject: a community-harness seat that the snapshot saw as detached now launches with its harness instead of a bare shell. The raw summary and objectives both describe this change: the restore path now takes the harness selection from the seat's newest saved session when no occupant is recorded, and the launch-node-subset tests cover this case. The title is specific and matches the primary change. It is long (103 characters) and uses somewhat dense phrasing, but it is not misleading or off-topic.

Full details: Linked Issues check

Explanation

[#4047] Primary objective: a launch-only community-harness seat must start fresh with its harness, or refuse cleanly without state changes, and a fresh launch must stay available. The PR scopes its work to defect A: the absent-occupant restore path. Per the PR description and the restore-orchestrator summary, when the snapshot records no occupant and no history was selected, restoreNodeCore reads the harness selection from the seat's newest saved session row. It uses that selection for adapter lookup and for recordCommunityHarnessSelection on the new row. communityHarnessOf still requires a runtime match. The added test in launch-node-subset.test.ts covers this case. The author reports attention_required before the fix and fresh-primed with agent_app set after it. The docs change and the extra cases (newest row naming another harness or none) are consistent with this behaviour. This meets the reboot-recovery expectation for the reported seat. Defect B is addressed on this path because the new row keeps the harness selection, which #4047 lists as an acceptable option. Not addressed, and excluded by the PR: rollback of the provisional shell and row when the adapter is genuinely missing; recovery of seats already stuck with a harness-less newest row; partial-rig recovery via rig start --last (issue questions 2 and 3). Those items are outside the PR's stated objectives. The PR description still says 'Fixes #4047'; the author agreed in comments to change it to 'Refs #4047'. Evidence limit: the text diff could not be read (changed blobs missing from checkout), so this verdict relies on the PR summary and the author's reported test results.

Full details: Out of Scope Changes check

Explanation

Three files changed since the merge base, per the summary: packages/daemon/src/domain/restore-orchestrator.ts (about +11/-5) changes only the harness-selection source for the absent-occupant case, and the adapter lookups and new-row recording use that selection. packages/daemon/test/launch-node-subset.test.ts (+57/-0) adds regression cases for the detached-seat launch. docs/reference/community-harness-presets.md (+1/-1) documents the new Resume behaviour. All three connect directly to the #4047 objective. The summary states that the fail-closed branch, the rig start path, and unrelated modules are not changed. Evidence limit: the text diff could not be read, so this verdict relies on the summary's description of the changes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fead4f9c-37ae-415a-ae3c-7f21584a422c
Commits

Reviewing files that changed from the base of the PR and between c45aca6 and 8190fa2.

Files selected for processing: 2

  • docs/reference/community-harness-presets.md
  • packages/daemon/test/launch-node-subset.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@mvschwarz

Copy link
Copy Markdown
Owner

Thanks again, @cavalcanticampos, for the quick fix. I read the source at c45aca6c, and the cause is right: with no occupant recorded, the harness selection was undefined, so no adapter was found. The fix is the smallest one, in the shared step after launch. It borrows only the harness selection from the agent's newest saved session in the snapshot, never the occupant or its resume token, the runtime match still applies, and nothing changes when an occupant resolves. The new test covers the case where the snapshot records no occupant.

One change, in the PR description only (no push): please change "Fixes #4047" to "Refs #4047". As your notes say, this fixes reading A, and #4047 also covers the bare shell left when the harness really is missing, recovering an agent that's already stuck, and bringing back part of a running rig, so merging this shouldn't close it.

Optional, your call:

  • One more test where the newest saved session names another harness, or none, expecting today's "harness not started" result. A few sessions in newest-first order would pin which one is picked.
  • docs/reference/community-harness-presets.md:21 says a launch-only preset's restore "stops and asks". With this change, an agent that had no occupant when the snapshot was taken starts fresh instead, and one clause there could say so.

This is from reading the source; I haven't run it locally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cavalcanticampos

Copy link
Copy Markdown
Contributor Author

Thanks for the careful read, @mvschwarz.

Ran: launch-node-subset.test.ts (88/88 pass) and npx tsc --noEmit -p packages/daemon/tsconfig.json (clean). Not run: the full npm test, lint and build.

🤖 Generated with Claude Code

@openrig-review openrig-review 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.

Approved at 8190fa2. A launch-only community-harness seat that the snapshot recorded with no occupant (detached when it was taken, as after a reboot) now starts fresh with the harness its newest saved session names, instead of leaving a bare shell. The selection must still match the seat's runtime, so a newest session naming another harness, or none, keeps today's result. Reviewed independently.

@mvschwarz

Copy link
Copy Markdown
Owner

Thanks again, @cavalcanticampos, for the quick push. I read 8190fa25: the #4047 test now runs your four cases, picked by id, and the Resume entry in docs/reference/community-harness-presets.md now says what happens when the snapshot recorded no occupant. Both look right.

The one thing left is the description: it still says "Fixes #4047". Please change it to "Refs #4047", as you said you would, since this covers one part of the issue. The rest of the checks are still running at 8190fa25.

@mvschwarz mvschwarz moved this to In Progress in OpenRig roadmap Nov 27, 2026
@mvschwarz mvschwarz added this to the v0.7.25 milestone Nov 27, 2026
mvschwarz added a commit that referenced this pull request Nov 27, 2026
… newer session that lost it (#4053)

A community-harness seat left stuck by a failed restore launch now recovers with `rig seat launch <seat> --fresh`. The fresh launch, its folder move and the runtime switch read the seat's harness from its newest session row that recorded one, so a newer row with no harness (left by the failed launch) no longer hides it, whether the bare shell still runs or the seat is detached after a reboot. The harness starts with its startup context and first input. The selection must still match the seat's runtime, and a newer different selection stops the search, so a seat never launched for the harness still gets no adapter. Reported by kwang281 in #4047; #4050 covers the restore side.
@mvschwarz mvschwarz modified the milestones: v0.7.25, v0.7.26, v0.7.27 Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

rig launch <rig> <seat> leaves a bare shell for a community-harness seat, then fresh launch is refused (runtime_adapter_missing)

3 participants