Skip to content

Keep where each conversation runs in one place record - #1334

Merged
Varuas37 merged 4 commits into
mainfrom
claude/project-thread-xquerh
Nov 14, 2026
Merged

Varuas37 merged 4 commits into
mainfrom
claude/project-thread-xquerh

Conversation

@Varuas37

Copy link
Copy Markdown
Contributor

Closes #1333. Slice P4 of the "where agents run" plan; lands after C1 (#1304).

Before / After

Before: a conversation's place was two facts in two files. conversations/placements/<id>.json said where it was placed (absent for here). For a peer:any conversation, conversations/bindings/<id>.json said which worker held it and which provider context it had opened there. runs_on, in_workspace, of and the cloud-VM look-ups in environment_tools.rs each read one or both separately, so one command could read the placement and the binding at different moments.

After: one file, conversations/places/<id>.json:

{"schemaVersion":1,"placed":"peer:any","worker":"peer:…","context":"…"}

Here is written too ({"schemaVersion":1,"placed":"here"}). Every look-up reads the record once (Environments::record), and environment_for(id, &record) answers from that same read.

Background

The plan asked for one place record per conversation, so that S5 (#1312) and the "keep the main conversation on a move" work can change where a conversation runs in one place.

The problem

Two stores (ConversationPlacements, ConversationBindings) held parts of one fact. Callers combined them by hand, and nothing kept a placement and its binding in step on disk.

The solution

sequenceDiagram
    participant S as ConversationService
    participant E as Environments
    participant P as FilePlaces
    participant D as conversations/
    S->>E: place(id, placed)
    E->>P: write(PlaceRecord::placed)
    P->>D: placements/<id>.json (not for here), then places/<id>.json
    S->>E: for_lease(id) / runs_on(id) / of(id)
    E->>P: read(id)
    P->>D: places/<id>.json
    alt no record yet (earlier build)
        P->>D: placements/<id>.json, then bindings/<id>.json for peer:any
    end
    P-->>E: PlaceRecord {placed, worker}
    Note over E: now() = Peer(worker) when bound, else placed
    E->>P: write(PlaceRecord::in_pool(binding)) on a rebind or a new context
    P->>D: bindings/<id>.json, then places/<id>.json
Loading
  • PlaceRecord { placed, worker: Option<WorkerBinding> }. A worker is only valid with placed == Pool, and a context only comes with a worker. A file that breaks either rule is refused as unreadable, never read as here.
  • One trait, ConversationPlaces { write, read, erase }, replaces the two stores. FilePlaces::new(conversations_dir) owns all three directories.
  • Earlier files. They are read, exactly as earlier builds read them, until the record exists, and the record wins wherever both exist. For this release they are also written before the record, and removed when they have nothing to say (no placement for here, no binding before a worker holds it). That way a build put back finds every conversation where it runs, never here in place of its host. Erasing removes the earlier files first, so a failed erase never leaves them as the only answer.
  • Deviation from the plan text. The record holds placed plus the current worker, not "asked" and "now". "Now" is derived (PlaceRecord::now), and nothing reads "asked" apart from placed. The cloud-VM receipt stays in boat-workspaces, because C1 did not move it into the SDK. Moving it is for when the SDK holds it.

How we checked it

  • cargo test -p nessa-server --lib conversation:: runs 1,657 tests and all pass. tests/conversation/placements.rs is rewritten to cover:
    • each place round trip, here included;
    • a worker being replaced whole;
    • the table of earlier-build reads;
    • the first change writing the record and the earlier files;
    • writing here removing a failed creation's placement;
    • unreadable records and earlier files;
    • a concurrent replace.
  • Stress (pnpm test:e2e:stress), each knob run alone in the cloud box:
    • pools, 5/5 held. After the first turn, the step turns the conversation back into an older build's placement and binding, then sends a message from the window. The conversation stays on its worker and no record is written. The worker then drains, the conversation moves, and the move writes the record and the older binding naming the new worker.
    • upgrades, 5/5 held. Every place record is turned back into older files during the restart (upgrade: restarted on a version 6 file and 1 older place files), and the main conversation opens and answers.
  • stress-upgrade.test.mjs passes 6/6, including stale older files being removed by the conversion.
  • An independent review found one major issue, five minors and two nits. All are fixed or answered below.

Tradeoffs and follow-ups

  • Writing the older files for one release keeps a build that is put back correct. The cost is up to two extra small synced writes per placement change. The next release stops writing them. The release after that stops reading them, but only after every conversation has a record: a host or cloud-VM conversation from before this change is only rewritten if something writes its record. That release needs a one-time pass that writes a record for every conversation first.
  • Each conversation's place is now one file. A bad worker in it therefore refuses the conversation's placement read too, where before only its binding read failed. This is the record-scope rule (ADR 202): a file this build cannot read refuses that conversation alone.
  • A provider context opened after its conversation was erased can leave a stray record. Before, the same race left a stray binding. Conversation ids are never reused, so nothing reads it.
  • Decision 2 (moving a channel's main agent keeps the conversation) can now be built on this, but this PR doesn't do it.
  • No docs/state page covers place files. worker-pool-preferences.md, auth/peer-gateways.md and runtime-architecture.md are updated.

Rollout

No migration step. The gateway reads earlier files as before and writes the record on the next change.


Generated by Claude Code

Each conversation now has one file, conversations/places/<id>.json,
holding where it was placed (here included) and, for a peer:any
conversation, the worker that holds it and the provider context opened
there. ConversationPlacements and ConversationBindings become one
ConversationPlaces store; runs_on, in_workspace and the cloud-VM
look-ups in environment_tools.rs read the record once.

An earlier build's placements/ and bindings/ files are read until the
record is first written, and for one release are still written beside
it so a build put back finds every conversation where it runs. Erasing
removes all three, the earlier files first.

The stress pool step turns its conversation back into the older files
and checks it stays put and then moves; the upgrade step restarts the
gateway on older files for every conversation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcBpmUavSQzUs5aJwmDfpv
@Varuas37
Varuas37 marked this pull request as ready for review November 14, 2026 10:53
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

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: b9b374c1-cbfb-43f4-b824-f1e0eff7ef4c
  • 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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T11:06:34.592362Z e119c8c Manual request
ℹ️ 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.

@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: 1c64e443a3

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

This build writes the earlier binding before the place record, so the
binding is never older than the record. A build put back moves a pool
conversation in its binding alone, so on return the binding wins for a
pool record; a record placed anywhere else still ignores it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcBpmUavSQzUs5aJwmDfpv

Copy link
Copy Markdown
Contributor Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: e119c8c066

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

Two record helpers are used only by the Unix gateway's file store, and
leases.rs uses Place only in Unix tests. The placement tests now write
their files as private files the way a build does, so Windows reads the
content rather than refusing a file it cannot trust.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcBpmUavSQzUs5aJwmDfpv

Copy link
Copy Markdown
Contributor Author

local-auth (ubuntu-22.04) failed at 6d99e12 on background_transport::ssh_eof_cleans_the_shepherd_scope_before_reporting. The assertion is at tests/conversation/background_transport.rs:54: the shepherd's child process had not yet exited or turned into a zombie by the time the test looked at /proc. This PR doesn't touch the SSH background transport or its tests. The same test passes 3 of 3 times locally at this head. I'll re-run the failed job once when the workflow finishes.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Conversation stress check failed at 6d99e12 on the WebKit devices step only. The step could not start: "the desktop page never settled ... waitForFunction: Timeout 30000ms exceeded". This PR doesn't change the desktop page or the devices step. The same job's full Chromium run held 73/73, including pool and upgrade. I'll re-run the failed jobs once the workflow finishes, together with the ubuntu job.


Generated by Claude Code

@Varuas37
Varuas37 merged commit c838fbd into main Nov 14, 2026
24 of 27 checks passed
@Varuas37
Varuas37 deleted the claude/project-thread-xquerh branch November 14, 2026 13:45
Varuas37 added a commit that referenced this pull request Nov 18, 2026
<!-- claude-projects-attribution: {"github_login":"Varuas37"} -->
_Requested by **Saurav** · [project
thread](https://claude.ai/code/project/chan_01UZaufydjNk2K88KGgoAfmr?thread=cmsg_01UZaufydjNk2K88KGgoAfmrX5YyyUXBGeQoMRRr3igVbS)_

**Before:** Of the 11 changes merged to main in the last day, two fixes
had no check in CI. A sidebar row losing its hover fill under its
actions (#1337), or onboarding asking for the vault passphrase (#1340),
could come back unnoticed.

**After:** The conversation stress suite (run by every PR's CI) fails if
either comes back. 2 gaps closed, no issues opened.

## Background

The daily test-gap run reviews what merged to main in the last 26 hours.
For each fix it puts the bug back and checks that a test CI runs fails.
A fix only a local script checks counts as a gap.

## The problem

- **#1337 (row hover).** When the pointer moved from a sidebar row onto
its trailing action (a channel's settings), the row lost its highlight.
Only `shared-controls.mjs --only rows` checked this, and no CI job runs
that script.
- **#1340 (onboarding vault).** The setup window opened the vault's
unlock dialog on its own. The stress `onboarding` step already refused a
vault dialog, but it ran over an unlocked vault. There the old code drew
no dialog either, so the step passed with the bug put back.

## The solution

All in `verification/desktop/scripts/conversation-stress.mjs`:

1. **`channel` step.** Once two channels exist, it finds the channel row
that is not selected (its rest and hover fills differ). It points at the
row, then at its settings beside it, and requires the same hover fill
both times.
2. **`onboarding` step.** It locks the vault through its native session,
as after a restart. Then it opens the setup window, which already
refuses any vault dialog. It unlocks the vault again afterwards.

## How we checked it

| Entry | Bug | What holds it now |
| --- | --- | --- |
| #1353 | A VM creation whose answer was lost never finished | Existing:
2 allocation tests fail with it put back |
| #1351 | A voice call ended when its chat left the panes | Existing: 2
VoiceController V16 tests fail with it put back |
| #1337 | Row hover dropped under its trailing actions | **New**
channel-step check: fails with the CSS put back (`rgba(0, 0, 0, 0), not
oklab(0.985 0 0 / 0.05)`), holds on main |
| #1340 | Onboarding asked for the passphrase | **New** locked vault in
the onboarding step: fails with the fix put back ("the setup window
opened a vault dialog on its own"), holds on main |
| #1350 #1346 #1339 #1332 | Features, copy, and SDK guard naming | Not
fixes |
| #1341 #1338 #1336 #1334 | Crate moves and refactors | Not fixes |

- Stress `--only onboarding,passphrase,channel,stop` in Chromium held
9/9 on this branch. `verification/desktop/scripts/lib/*.test.mjs` passed
698 tests. eslint and prettier are clean.
- Not run: WebKit (it cannot be downloaded in the cloud sandbox).

## Tradeoffs and follow-ups

- The hover check needs an unselected channel row. In the `stop` step
only one channel exists, and it is selected, so the check runs in the
`channel` step.
- The onboarding step briefly locks the shared vault. It unlocks it
again in a `finally`, so later steps see it unlocked.

## Rollout

Nothing special. Test-only change.

---
_Generated by [Claude
Code](https://claude.ai/code/session_018rccRX3nxAcKBWu6gcEXWB)_

---------

Co-authored-by: Claude <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.

Keep where each conversation runs in one place record (P4)

2 participants