Repository navigation
Keep each conversation's gates and owed state in one record (S5, part 1) - #1336
Conversation
ConversationService kept five per-conversation lock tables (summary writes, deletions, mode changes, creations, creation decisions) and four per-conversation maps (model reconcile owed, unfinished marks, fork seeds, MCP Apps), each behind its own lock. They are now one ConversationRecords table: one record per conversation behind one std mutex, holding each gate as its own async lock and what this run still owes the conversation. Gates stay independent, so no work waits behind another kind of work. Records nobody holds or is owed are swept when the table doubles, so a sweep costs a constant share of the work that grew it. The stress handoff step now races three forks into one id and checks one fork is made with its copied turns recorded once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JcBpmTQfWyxdsN2yxEJM26
Review round 1: the failure-retry loop walked every record (one per conversation opened this run) under the table lock. The table now keeps the ids whose record holds an unfinished mark, maintained in settle after every change, and the loop walks those. Fix a nonminimal_bool lint, word the lock-forgetting test and doc for the sweep, and make the stress step fail when every raced fork is refused or a request opens another id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JcBpmTQfWyxdsN2yxEJM26
Add a_sweep_keeps_records_that_are_held_or_owed, check the table forgets let-go locks, clone an id only when its record is made, word the poison comment for a panicked change, and check every raced fork receipt's id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JcBpmTQfWyxdsN2yxEJM26
A seed holds the source's whole copied history. A seed that was not placed, or that its creation never took, is now dropped after the table lock is released, so freeing a long history never stalls every other conversation's gates. Index an id only when it is not indexed yet, and word the poison comment for what a panicked change can leave. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JcBpmTQfWyxdsN2yxEJM26
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 150b84e2e7
ℹ️ 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".
The raced fork was sent its next turn by the client while the window showed the other fork, so the step never checked a person can open it and send. It is now opened from its row, sent through the composer, and its carried reply checked in both the window and the gateway view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JcBpmTQfWyxdsN2yxEJM26
) (#1338) **Before:** Nothing a person sees changes. The conversation service, with its workspaces, MCP server use cases and timer, lived inside `nessa-server`, so every change there rebuilt and retested the whole gateway. **After:** Nothing a person sees changes. That code is now its own `nessa-conversation` crate. `nessa-server` depends on it and re-exports it under the old paths (`crate::conversation`, `crate::workspaces`, `crate::timer`, and so on), so the gateway's code reads as before. The gateway log again carries the lines of the crates split out of it, which the default log filter had been dropping since S4. Closes #1312 (S5 of #1307). Part 1 was #1336. ## Background #1307 moves the gateway toward a small core: domain crates that know nothing about sockets or the desktop, with `nessa-server` doing only composition. S5 takes the biggest piece, the conversation service, out of `nessa-server`. ## The problem `nessa-server` held about 200,000 lines. Most of them were the conversation service and what it alone uses. Any edit to a socket handler rebuilt all of it, and the server's library test binary ran all 3,600 tests together. Nothing kept the conversation code from reaching into server-only modules either. ```mermaid sequenceDiagram participant Edit as An edit anywhere in nessa-server participant Server as nessa-server (one crate) Edit->>Server: rebuild sockets, composition, conversation, workspaces, MCP Server->>Server: one library test binary runs every test ``` ## The solution `crates/nessa-conversation` now holds: - the conversation service (`application`, `domain`, `infrastructure`), which was `nessa-server/src/conversation`; - `workspaces` (application, domain, infrastructure), the timer, settings inheritance and the limit log; - the MCP server use cases and the conversation tools, which were in server `composition`; - the conversation's halves of desktop runtime, device pairing and attachments. The move keeps behaviour as it was: - Items that the server reaches went from `pub(crate)` to `pub`. Nothing else in their code changed. - Test hooks that server tests use are behind `#[cfg(any(test, feature = "test-support"))]`. The crate's `test-support` feature turns on the matching features of its dependencies. Private test helpers stay `cfg(test)`. - Tests moved with their code. Tests that drive the server's sockets or composition stayed in `nessa-server` and use small fixtures the crate exports (`owner_phone_test_support`, `service_with_command_hosts`). - Two tests that spanned both sides were split at the line. For example, the SSH login handoff test now checks the crate's lease in the crate and the server's log line in the server. - The lease protocol fingerprint covers the bytes of its listed source files, so it is re-pinned with a history comment, as in S3 and S4. The image id and the frames do not change. ```mermaid sequenceDiagram participant Edit as An edit to a socket handler participant Server as nessa-server (composition + product) participant Conv as nessa-conversation Edit->>Server: rebuild the server only Server->>Conv: uses the built crate as it is Note over Conv: its own test binary runs in the server-conversation CI partition ``` The default log filter now names every Nessa crate the gateway is built from. It named only `nessa_server`, `nessa_sdk` and `nessa_gateway_endpoint`, and a filter of named targets drops every target it does not name, errors included. So this split would have silenced the conversation service. The S4 feature crates already on main (attachments, peer gateways, device pairing, env serve, agent install, backup) have been silent since S4. They are named now too. A test reads this crate's manifest and fails if a Nessa dependency has no directive. Other Nessa libraries stay off, as before. CI and scripts follow the crate: - `-p nessa-conversation` was added to the local-auth workflow, `package.json`, and the CI plan's Rust package list. - `cargo-test-parallel.mjs` runs the crate's test binary in the `server-conversation` partition. - The CI plan's workspace graph treats a crate whose sources point at `../<other>/src` as depending on it. - The architecture check and dependency graphs know the new crate. Client core may not depend on it. - Docs, state pages and stress scripts point at the new paths. ## How we checked it - **Tests:** - `nessa-conversation` passed 1,882. - `nessa-server` lib passed 1,712 of 1,715, and its integration suites passed. The 3 failures are a Codex status-cleanup test and two native-hook tests. They fail on main in this sandbox too, because it runs as root. - **Lint:** clippy with `-D warnings` is clean for both crates on Linux, and on Windows through `x86_64-pc-windows-gnu`. - **Scripts:** the architecture check passed, and so did the node script tests (new tests cover the partition and the workspace graph). - **Stress and chaos:** the conversation stress check held 73/73 and the chaos check held 2/2. The `handoff` step was extended in #1336, which is the S5 stress addition; this half adds no new behaviour to cover. - **Logs:** the two new logging tests fail when `nessa_conversation=info` is taken out of the filter, and pass with it. - **Review:** three independent read-only review rounds. Every finding is fixed in the first commit, for example test hooks that were missing under the feature, CI filters that still named the old module paths, and state-doc paths split across YAML lines. - **Rebase:** rebased onto #1332, which changed workspace files that moved here. Its edits were reapplied to the moved files. ## Tradeoffs and follow-ups - Many items are now `pub` instead of `pub(crate)`, because the server is a separate crate. S6 can narrow what the gateway needs. - Server tests that need crate test hooks build the crate with `test-support`. - **Next:** S6 (#1313) moves the gateway's socket and product code into `nessa-gateway` and leaves `nessa-server` as composition only. ## Rollout Nothing special. Nothing stored or sent over the wire changes, so a plain merge or revert is enough. The gateway log gets the split crates' lines back, at the levels they had before S4. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JcBpmTQfWyxdsN2yxEJM26 --------- Co-authored-by: Claude <noreply@anthropic.com>
#1341) **Before:** Nothing a person sees changes. After S5, `nessa-server` still held the whole request path (sockets, product, HTTP routes, agents, devices, CLI, core) next to composition, so any edit to a socket handler rebuilt and retested composition too, and composition could reach into any module. **After:** Nothing a person sees changes. The request path is its own `nessa-gateway` crate. `nessa-server` is composition only: it wires the gateway to its stores and features and starts it, and re-exports the gateway's modules under the old paths (`crate::product`, `crate::core`, and so on). Closes #1313 (S6 of #1307). ## Background #1307 moves the gateway toward a small core: domain crates that know nothing about sockets or the desktop, with `nessa-server` doing only composition. S5 (#1336, #1338) took the conversation service out. S6 takes out the rest of the request path. ## The problem `nessa-server` mixed two jobs: serving requests and composing the process. Every change to either rebuilt both, the gateway's 1,100 library tests and composition's 600 ran in one binary, and nothing kept the request path from depending on composition. ```mermaid sequenceDiagram participant Edit as An edit to a socket handler participant Server as nessa-server (request path + composition) Edit->>Server: rebuild sockets, product, agents, CLI and composition Server->>Server: one library test binary runs both ``` ## The solution `crates/nessa-gateway` now holds everything that was in `nessa-server/src` except `composition/`, `bootstrap.rs`, `main.rs` and the backup binaries. `build.rs` moved with it. ```mermaid sequenceDiagram participant Main as nessa (nessa-server main) participant Boot as nessa_server::run (bootstrap) participant Comp as composition::CompositionRoot participant GW as nessa-gateway participant Conv as nessa-conversation Main->>Boot: start Boot->>GW: core::logging::init, log_file::bound Boot->>Comp: serve Comp->>GW: build product, sockets, routes GW->>Conv: conversation service Comp-->>Boot: Result<(), RunError> Boot->>GW: core::ending::report ``` The move keeps behaviour as it was: - Items that composition reaches went from `pub(crate)`/`pub(super)` to `pub`. Nothing else in their code changed. - Two items had to move to obey the orphan rule and the architecture check: the `CallerKindSource` impl for `LocalCredentialStore` (now `agents/infrastructure/caller_kinds.rs`) and `REVIEW_WAIT` (now in `limits.rs`, same 5 minutes). - Test hooks that composition tests use are behind `#[cfg(any(test, feature = "test-support"))]`. The product socket fixture the composition tests share is a `route_fixture` module, lifted verbatim from the socket tests. - Tests moved with their code. Tests that drive composition (backup restore, webhook product delivery, configuration, bootstrap) stay in `nessa-server`. - The lease protocol fingerprint covers the bytes of its listed sources, and one of them changed visibility, so it is re-pinned with a history comment, as in S3 to S5. The frames do not change. The guard that every lease source names the protocol now scans `nessa-gateway/src` too. - `nessa-server`'s manifest drops the dependencies only the gateway uses. The gateway declares them with the same versions and features, so the binary's merged features are unchanged. Logs: the default filter names `nessa_gateway`, so the moved code's lines (now `nessa_gateway::…` targets) keep reaching `gateway.log`. A new server test reads the binary's own manifest and fails if `nessa_server` or any Nessa dependency lacks a directive. CI and scripts follow the crate: - `-p nessa-gateway` was added to the local-auth workflow, `package.json`, the CI plan's Rust package list and the client-core dependency denylist. - `cargo-test-parallel.mjs` plans the server cases on the gateway library. Composition's library runs in `server-other`. - `check-changed.mjs` maps `crates/nessa-gateway/` and `crates/nessa-conversation/` to the server checks. - Docs, state pages, the architecture check and stress scripts point at the new paths. Recorded evidence keeps its original paths. ## How we checked it - **Tests:** `nessa-conversation`, `nessa-gateway` and `nessa-server` pass, apart from the 3 tests that fail on main in this sandbox because it runs as root (a Codex status-cleanup test and two native-hook tests). Server + gateway hold 1,909 `#[test]`/`#[tokio::test]` before and 1,910 after: the one new test is the server log test. - **Lint:** clippy with `-D warnings` is clean for the three crates on Linux, on Windows through `x86_64-pc-windows-gnu`, and for the gateway with only `test-support` on. - **Scripts:** the architecture check and the node script tests pass. - **Stress (gate 19):** the close step now also checks that the gateway log carries the conversation service's lines for the thread it closed. Its first full run failed: the VM background step swaps in a test-binary gateway that never set up logging, so every later step's lines were missing. That gateway now sets up logging like the binary, and VM background followed by close holds on 3 seeds. The full run held 73/73. The check fails with `RUST_LOG=nessa_server=info` and passes with the default filter. - **Chaos:** 2/2. One earlier run missed once on the known follower event-count race, then held on re-run. - **Logs:** the server log test fails when `nessa_server=info` is taken out of the filter. - **Review:** three independent read-only review rounds. Every actionable finding is fixed, for example the lease guard's scan, recorded evidence the path rewrite had touched, stale docs, and unused dependencies. ## Tradeoffs and follow-ups - Many gateway items are `pub` now that composition is a separate crate. A later pass can narrow them to what composition uses. - Server tests that need gateway test hooks build the gateway with `test-support`. - The partition script accepts zero composition test executables, as it does for nessa-conversation. A workflow that drops `-p nessa-server` would skip composition tests silently. ## Rollout Nothing special. Nothing stored or sent over the wire changes, so a plain merge or revert is enough. --- --- _Generated by [Claude Code](https://claude.ai/code/session_01JcBpmTQfWyxdsN2yxEJM26)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
<!-- 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>
Before: Nothing a person sees changes. Inside the gateway, the conversation service keeps each conversation's state in nine separate tables, each with its own lock.
After: Nothing a person sees changes. That state now lives in one record per conversation, in one table behind one lock.
Part of #1312 (S5 of #1307). Moving the service into a
nessa-conversationcrate, the second half of S5, comes in its own PR.Background
ConversationServiceruns every conversation on the gateway. Each conversation's live agent lives in aSlot. Besides that, the service keeps two kinds of state per conversation:The problem
All of that was spread across nine maps on
Inner, and each map had its own lock:retainpass on every lock call.Finding everything about one conversation meant visiting nine places, and nothing tied them together. For example, if nobody remembers to clear a map, it just keeps that conversation's entry.
sequenceDiagram participant Work as A send, delete or fork participant Svc as ConversationService participant Maps as Nine per-conversation maps Work->>Svc: act on conversation X Svc->>Maps: summary_writes / deletions / mode_changes / creations / creation Svc->>Maps: model_reconcile_owed / unfinished_marked / forks / apps Note over Maps: each map has its own lock and its own idea of what X hasThe solution
There is now one
ConversationRecordstable (service/records.rs). It keeps oneConversationRecordper conversation, behind one std mutex. The record holds the conversation's owed state and each of its gates. Every gate is still its own async lock, so one kind of work never waits behind another.retainon every lock call.Table::settleupdates it after every change, and the failure-retry loop walks only those conversations.sequenceDiagram participant Work as A send, delete or fork participant Svc as ConversationService participant Rec as ConversationRecords (one lock) Work->>Svc: act on conversation X Svc->>Rec: one lookup Rec-->>Svc: X's gate (its own async lock) or X's owed state Note over Rec: an empty record is swept when the table doublesThe commits:
6e733d49adds the records table, moves every call site and test onto it, and extends the stresshandoffstep.8494d491makes the retry loop walk only marked conversations, fixes a lint, and tightens the stress assertions.ceaf02abadds a test that a sweep keeps held and owed records, and tidies up after the second review round.How we checked it
recordsunit tests show that:cargo clippy -p nessa-server --all-targets -D warningsis clean.--inputFiles 0), held 73/73. The chaos check held 2/2.handoffstep now also forks the source into one id from three racing requests: one request sent twice at once, plus one other request. It checks that:cargo testfails in the cloud sandbox on onenessa-agent-installtest ("an unwritable use journal admitted a generation"). The sandbox runs as root, and root can write to the file the test makes unwritable. This PR does not touch that crate, and CI runs the test as a normal user.Tradeoffs and follow-ups
reconcile_retry_owed, keyed by the scheduler's row;submit_retry_owed, keyed by execution id;ownership_preparations, keyed by session.nessa-conversationcrate (the rest of One record per conversation, nessa-conversation crate (smaller core S5) #1312).Rollout
Nothing special. Nothing stored or sent over the wire changes, so a plain merge or revert is enough.
Generated by Claude Code