Skip to content

fix(session): treat an unprovable connectionId as no host, not as ssh - #5

Merged
kiwidream merged 4 commits into
swaplabs/mainfrom
swaplabs/resume-origin-host
Sep 23, 2026
Merged

kiwidream merged 4 commits into
swaplabs/mainfrom
swaplabs/resume-origin-host

Conversation

@kiwidream

@kiwidream kiwidream commented Sep 23, 2026 •

Copy link
Copy Markdown

ELI5

When a terminal running an agent goes to sleep, Orca writes down which machine that conversation lives on so it can find it again. If it cannot actually tell which machine the note refers to, it used to guess "some SSH box" — and filed the note in a drawer nothing ever opens. The conversation was then unreachable even though nothing was wrong with it.

What changed

sleepingRecordOriginHostId gated its SSH classification on whether the SSH target list had loaded, but had no equivalent guard on the runtime side. When runtimeEnvironmentIds was empty, or simply did not contain the id, control fell through to toSshExecutionHostId(targetId). A record stamped with a perfectly valid runtime environment id during a catalog gap — or one whose environment had since been removed — was written to the ssh:<environmentId> partition, which no runtime reader ever opens. That is the exact failure the module's own doc comment warns about.

Neither id set is a complete census. sshTargetIds is null until the client loads the target set, and runtimeEnvironmentIds is a best-effort union of whatever catalogs this boot happens to hold. So membership proves an id's kind; absence proves nothing. The classifier now says so: an id it cannot place in either space returns no host rather than being assumed to be an SSH target.

Why this shape

The alternative was to widen the id sets until absence became meaningful. That cannot be done honestly — a client genuinely may not have loaded a catalog yet, and a removed environment is gone from every set by definition, which is precisely the case this code exists to survive.

Where this belongs

This is a fix to the change that merged as PR #1, which is on swaplabs/main but has not yet reached stablyai/orca. It targets the integration branch so fork builds carry the corrected version. When PR #1's content is upstreamed, this commit goes with it in the same changeset rather than following as a separate patch.

Verification

pnpm tc clean, npx oxlint clean, and the two directly affected suites pass — workspace-session-sleeping-record-origin-host.test.ts and workspace-session-host-split.test.ts, 38 tests.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

A sleeping record's `connectionId` is a host STAMP, not a host kind. Round four
gated the ssh answer on `sshTargetIds` hydration but left the runtime side
unguarded, so an id neither list claimed still fell through to
`ssh:<targetId>` — filing a runtime-stamped record captured during a catalog
gap, or one whose environment was later removed, into a partition no runtime
reader ever opens.

Neither id space can disprove an id: the ssh list may not have loaded, and the
runtime set is a best-effort union of whatever catalogs this boot holds. So
only positive membership answers now, for both spaces. "Cannot prove" is null,
which leaves the row local — the partition every reader loads, and the one
`adoptStrandedHostPartitionSession` returns to its owner once some list can
name it. A guessed `ssh:<id>` has no way back.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@luxor-code-review

luxor-code-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


Tightens sleeping-record origin-host resolution to require proven SSH-target membership instead of guessing an SSH host id when the catalog is unhydrated.

Reviewed commit: 4bae366

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T19:07:09.273086Z adeaa9b New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

luxor-code-review[bot]
luxor-code-review Bot previously approved these changes Sep 23, 2026

@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: 4bae3662cc

ℹ️ 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".

Review follow-up. The six-line block restated the type doc and the function
body; what it had to carry is that catalog absence is not authoritative, so an
unplaceable id stays local and stays recoverable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@luxor-code-review

luxor-code-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


Inverts sleepingRecordOriginHostId so catalog gaps resolve to the local host instead of guessing the SSH partition, with tests and comment updates covering the new semantics.

Reviewed commit: 8317188

@kiwidream

Copy link
Copy Markdown
Author

Fixed in 8317188 — the six-line block is now three, keeping only what the code does not already say: catalog absence is not authoritative, so an unplaceable id stays local and stays recoverable, where a guessed ssh:<id> would not be. Also trimmed the same restatement out of the type doc above it. pnpm tc and oxlint clean, origin-host suite 9 tests passing.

luxor-code-review[bot]
luxor-code-review Bot previously approved these changes Sep 23, 2026
@luxor-code-review
luxor-code-review Bot dismissed their stale review September 23, 2026 18:19

Superseded by a newer Tenki approval on this pull request.

This test asserted the old contract — a nonempty connectionId reaching the ssh
partition — and the routing fix changes that answer, so it failed rather than
caught anything. Its setup is still the scenario worth pinning: a catalog with
no row for the worktree, so only the record's own stamp names a host.

What makes local the right answer is asymmetry, not preference.
`fetchWorkspaceSessionWithRuntimeHostOwners` enumerates the local partition and
one per KNOWN runtime and ssh host. A phantom `ssh:<id>` is not a known target,
so it is never enumerated, never fetched, never merged — a wrong guess loses
the pane's only resume handle permanently and silently. `local` is fetched
unconditionally, and the next write re-routes the record once the target list
can name it, so a mis-park corrects itself.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@luxor-code-review

luxor-code-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review complete. No blocking issues — approved ✅; 2 nitpicks below.

🧹 Nitpicks (2) — 🟢 2 low
  • 🟢 Docstring names adoptStrandedHostPartitionSession as a recovery it never performs (sleeping-record-origin-host.ts:29) — The sleepingRecordOriginHostId docstring says a record parked in local "can still be handed back by adoptStrandedHostPartitionSession once some list names it" (src/renderer/src/lib/sleeping-record-origin-host.ts:29-31), but that function only adopts rows OUT of non-local partitions into the merged session (src/shared/workspace-session-stranded-partition-adoption.ts:273-287, called from src/renderer/src/lib/workspace-session-host-hydration.ts:223 on ssh partitions only) — it never re-routes a row already parked in local.
  • 🟢 New comment wrongly claims mis-guessed ssh partitions are never fetched (workspace-session-partition-stale-row-leak.test.ts:71) — The new rationale in workspace-session-partition-stale-row-leak.test.ts states that fetchWorkspaceSessionWithRuntimeHostOwners enumerates only known ssh hosts, so a wrong ssh:<id> guess is never fetched again (src/renderer/src/lib/workspace-session-partition-stale-row-leak.test.ts:71-74).

Reworks sleeping-session origin-host routing so records with unhydrated or unknown SSH target ids park locally instead of guessing an ssh:<id> partition, with tests updated to the new recoverability contract.

Reviewed commit: 5868a00

luxor-code-review[bot]
luxor-code-review Bot previously approved these changes Sep 23, 2026
@luxor-code-review
luxor-code-review Bot dismissed their stale review September 23, 2026 18:52

Superseded by a newer Tenki approval on this pull request.

@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: 5868a002c9

ℹ️ 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".

Review follow-up on the previous commit. The clear assertion compared the patch
argument by reference, but `splitWorkspaceSessionForWrite` builds a new slice,
so it could never match and the check passed without testing anything.

It now asserts the record reached the local partition — verified to fail if the
classifier goes back to guessing ssh — and the rationale is one line instead of
a five-line walkthrough of what the assertions already show.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@luxor-code-review

luxor-code-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review complete. No blocking issues — approved ✅; 1 nitpick below.

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 Never-hydrating clients strand ssh-stamped records in local partition (sleeping-record-origin-host.ts:47) — The new return null fallback files an unprovable ssh stamp under local, but the recoverability the doc comment promises only exists for clients that eventually hydrate sshTargetIds.

This PR flips the sleeping-record origin-host fallback so unprovable connectionId stamps stay local instead of being guessed onto an ssh:<id> partition, with tests updated to the new contract.

Reviewed commit: adeaa9b

@luxor-code-review
luxor-code-review Bot dismissed their stale review September 23, 2026 19:07

Superseded by a newer Tenki approval on this pull request.

@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: adeaa9b33e

ℹ️ 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".

@kiwidream

Copy link
Copy Markdown
Author

Two open findings, one already done and one I am declining with reasons.

"Condense the routing walkthrough" — already addressed in adeaa9b33e, which landed before this review ran. The block is now the two lines the finding asked for: "Local is always fetched; an unproven ssh:<id> partition never is, so guessing it loses the handle for good while parking locally corrects itself on the next write." Resolved.

"Preserve unhydrated SSH records in durable host storage" — not implementing, because the remedy is the failure mode this PR removes.

Writing a durable copy to ssh:<id> when nothing proves that id names an SSH target is the guess itself. fetchWorkspaceSessionWithRuntimeHostOwners enumerates the local partition and one per known runtime and SSH host. A partition named from an unproven id is not a known target, so it is never enumerated, never fetched, never merged — the copy is not durable, it is unreachable. The two outcomes are asymmetric: a wrong ssh: guess loses the handle permanently and silently, while a local park is always read and re-routes itself on the next write once the target list can name it.

The finding is right that the local map is clearable, and that is a real cost — but a recoverable one, against an unrecoverable alternative.

Where it is right, and what I did about it: the test's mock records patches without applying them, so it cannot observe what survives across the two writes. That was a fair criticism of the test's fidelity, and a separate finding on the same file — that its clear assertion compared by reference and so could never fail — was correct and is fixed in adeaa9b33e. The assertion now checks that the record reached the local partition, and I verified it fails when the classifier goes back to guessing SSH.

A test that observes the merged result across writes would be better than one that inspects patch calls. I have not written it here; it belongs with the persistence layer rather than in a routing fix.

@kiwidream
kiwidream merged commit 4cff4d9 into swaplabs/main Sep 23, 2026
2 checks passed
@kiwidream
kiwidream deleted the swaplabs/resume-origin-host branch September 24, 2026 13:58
kiwidream pushed a commit that referenced this pull request Oct 24, 2026
…anel (stablyai#7655)

The workspace space-manager rendered every hosted review as "PR #N", so a
GitLab merge request showed as "PR #5" instead of "MR !5". The cached review
already carries its provider (HostedReviewInfo.provider) — the panel's local
input type just narrowed it away. Thread provider through and format via the
same localizedHostedReviewCopy / '!' vs '#' helpers the rest of the app uses.

Extract the label formatting into hosted-review-label.ts (a pure module, away
from the panel's heavy React/store imports) so it can be unit-tested directly,
and add hosted-review-label.test.ts covering github / gitlab / azure-devops /
gitea and the status suffix.

linkedPR stays "PR #N" — it is the GitHub-specific workspace field, distinct
from linkedGitLabMR.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
Co-authored-by: Neil <neil@stably.ai>
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