Commit Graph
24 Commits
Author SHA1 Message Date
Brennan Benson 980352d897 Reduce native chat memory by replacing per-chat Electron supervisors (#42760)
* Launch provider CLIs without a per-chat runtime supervisor

* Initialize process-owner fixtures with an isolated app environment

* Retire provider output transports and failed ownership drafts

* Finish provider stops when the session group empties

* Complete native cleanup from verified watcher exit and cancel held launches

* Let native watcher finish one-shot provider exits

* Retire late ownership records after canceled provider launches settle

* Reap each provider subtree in an isolated native parent

* Preserve provider outcomes and compatibility with native parents

* Publish actual provider identities and retire native parent observers

* Retire numeric writer PIDs when their group is proven absent

* Retire provider transports and accept proven group absence

* Fence retired process identities across asynchronous cleanup

* Use native timer types and readonly process fixtures

* Reuse bounded timeout for compatibility output drain

* Release launch scopes held by late transport error handlers

* Keep processless launch failures out of watcher waits

* Align lifecycle validation with final ownership contracts

* Remove duplicate helper preparation from the dev launcher

* Keep legacy fallback in place and simplify native ownership handoff

* Defer background provider maintenance until the first window

* Release startup hook maintenance for terminal launches

* Use relocated artifact module in native prebuild scripts

* Preserve agent failure outcomes and clean tools before ownership is lost

* Budget ownership capture for its bounded identity reads

* Keep lifecycle regressions at their behavior-owning seam

* Explain the fake-clock process-read fixture

* Capture tool ownership before restart recovery removes the CLI

* Skip descendant inventories for absent provider roots

* Make final output drain regression test deterministic

* Keep output drain fixture assertions type-safe with IPC

* Use existing provider fixtures across Node and Bun

* Prepare native provider helper for Codex contract CI

* Verify provider ownership using its recorded start precision

* Preserve exact provider ownership through reader failures

* Retire exhausted recovery records without blocking watcher cleanup

* Distinguish exited descendants from unreaped zombies

* Preserve group retirement without trusting an exited root

* Keep CLI input owned through native parent loss

* Keep watcher cleanup proof through lost-parent retirement

* Guard retirement against late watcher cleanup proof

* Contain provider launches that fail before stdio setup

* fix(claude): preserve startup diagnostics after input pipe failures

* fix(provider): capture lost outcomes before native completion cleanup

* fix(provider): retire speculative captures after a valid outcome

* fix(provider): share spawn absence classification through its existing boundary
2026-11-16 01:01:24 -08:00
Neil b98c4d006a chore(test): silence Vitest filter-miss path dump and typeless-package warnings (#42911) 2026-11-15 19:38:47 -08:00
Neil c3a681f5b1 refactor: group process and platform modules by ownership (#42742)
* refactor: group process and platform modules by ownership

* refactor: preserve moved module workflow routing

* refactor: preserve native loader and embedded bundle origins
2026-11-15 07:23:28 -08:00
506d116ee3 Move saved server reads and writes off the main thread (#42253)
* Move environment store operations off the main thread

* Preserve CLI startup speed with the serialized environment owner

* Handle absent paired host labels in the producer regression fixture

* Preserve publication ownership and copy selected environment results

* Correct publication and WSL readiness regression fixtures

* Include environment store worker in deployed server artifacts

* Check fresh listing publication across an intervening store update

* Await store-backed results in new recovery coverage

* Retire failed page publications and retain CLI worker support entries

* Unpack environment store support modules for the installed CLI

* Align async store callers with their return contracts

* Avoid hardening work for absent environment store files

* Keep permission repair bounded to one hardening attempt

* Align store test fixtures and await pairing replacement

* Use the semantic store operation for external pairing fixtures

* Provide the live sender frame in the timed subscription fixture

* Share pending server lookups and settle retired phone requests

* Keep the relay error type import

* Keep status ownership and transport imports acyclic

* Await replacement pairing in status retirement cases

* Keep asynchronous server rows bound to their admitted pairing

* Keep inventory snapshots and queued delivery at one publication boundary

* Await saved-host and graph test setup through publication completion

* Finish async fixture types and remove foreground timing probe

* Await renderer surface transitions in process identity coverage

* Await nested graph publication fixtures through their callers

* Await restored pane graph publication before hook assertions

* Include imported store worker and sidebar files in web typecheck

* Prepare saved host storage in source-based WSL test rigs

* Await saved server lookups in the source retirement diagnostic

* Preserve newer WSL status across async saved-host reads

* Fence stopped probes when a newer WSL Ready arrives

* Keep saved WSL host selection covered when admission is off

* Check WSL probe ownership after async admission

* Preserve WSL stop authority without cancelling Ready persistence

* Prune removed WSL E2E real-time wait from flaky-test baseline

* Limit WSL callback invalidation to confirmed stops

* Retire pending WSL notices on every confirmed stop

* Close the WSL picker dialog explicitly between scenarios

* perf(layout): skip unused normalization reports in pane commands (#42615)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Clarify cleanup pinning and ignored-file protection (#42616)

* test: remove 55 low-value suites and assertion driver (#42605)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>

* fix(skills): skip Claude sync scratch folders during skill discovery (#42610)

Claude Code parks replaced skill copies in `.trash` and in-progress syncs
in `.staging` under its skills roots. Discovery walked into both, so each
synced skill showed up as duplicates. Prune those directory names in the
native file walk and in the generated WSL `find` command.

Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>

* test: remove 78 low-value suites and trim redundant cases (#42621)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>

* Keep quit teardown within the source line budget

---------

Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: OrcaWin <alpha-eng@stably.ai>
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
Co-authored-by: BingZ <zzb@gxsmjx.com>
Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
2026-11-15 02:45:45 -08:00
Neil d5a90c0da0 refactor(shared): group host and runtime owners by domain (#42528) 2026-11-14 21:10:34 -08:00
Brennan Benson 88a266e003 Make SQLite the source of truth for native chats (#39256)
* Retire projection adapter tests and use real SQL journal fixtures

* Persist bounded history detail and conversation outline projections

* Select rewind cuts by provider indexes and delete uniform rows as a set

* Cache bounded conversation outlines after reader projection

* Remove retired journal fold and message adapters

* Add the 4a main-vs-candidate native chat comparison harness

One entry (native-chat-4a-comparison.ts) seeds the 55k-history/310-chat
profile once through the seed arm, clones it per arm at a fixed path,
launches each built checkout in the background with an isolated home,
and drives the same stub provider events through the host RPC surface
both builds serve. Envelopes come from each arm's own source bundle.
Rows cover send/queue, 1/8/16 MiB streams with a competing send,
maintenance windows, open/reopen, history/detail, outline/fork,
rewind, record operations, R3 retained-history admission and, reported
separately, first-launch conversion (optional 20 GiB source). Output is
one JSON and one markdown table keyed by both head SHAs.

* Fail the 4a harness launch fast on a non-e2e build and stop the app it launched

* Shim tsx's __name in 4a harness pages and install the probe inside the guarded launch

* Read the native chat working flag from the 4a harness's visible root itself

* Retry transient main-process evaluates in the 4a harness host-work probe

* Use the history page's itemId in the 4a harness and name what a visible-state wait timed out on

* Activate 4a harness chat tabs through their tab group and seed enough smoke filler chats for the unopened-chat row

* WIP: migrate native chat tests to SQL journal readers

* Treat refusals carried inside a successful 4a harness RPC result as refusals

* Give the 4a stub's user echo the uuid its transcript row records

* Remove retired journal writer test machinery

* Chain the 4a stub's resumed transcript to the last message, past a fork copy's title row

* Fork the 4a harness's large chat through its latest response, not its latest prompt

* Port persisted chat tests to SQL fixtures (red WIP)

* Add the 4a main-vs-candidate native chat comparison harness

One entry (native-chat-4a-comparison.ts) seeds the 55k-history/310-chat
profile once through the seed arm, clones it per arm at a fixed path,
launches each built checkout in the background with an isolated home,
and drives the same stub provider events through the host RPC surface
both builds serve. Envelopes come from each arm's own source bundle.
Rows cover send/queue, 1/8/16 MiB streams with a competing send,
maintenance windows, open/reopen, history/detail, outline/fork,
rewind, record operations, R3 retained-history admission and, reported
separately, first-launch conversion (optional 20 GiB source). Output is
one JSON and one markdown table keyed by both head SHAs.

* Fail the 4a harness launch fast on a non-e2e build and stop the app it launched

* Shim tsx's __name in 4a harness pages and install the probe inside the guarded launch

* Read the native chat working flag from the 4a harness's visible root itself

* Retry transient main-process evaluates in the 4a harness host-work probe

* Use the history page's itemId in the 4a harness and name what a visible-state wait timed out on

* Activate 4a harness chat tabs through their tab group and seed enough smoke filler chats for the unopened-chat row

* Treat refusals carried inside a successful 4a harness RPC result as refusals

* Give the 4a stub's user echo the uuid its transcript row records

* Chain the 4a stub's resumed transcript to the last message, past a fork copy's title row

* Fork the 4a harness's large chat through its latest response, not its latest prompt

* Port ACP tests to SQL journal named reads

* Port Claude tests to SQL journal named reads

* Port Codex tests to SQL journals and drop the legacy row rollback test

* Port failure and persisted-read fixtures to the active chat database

* Remove obsolete internal-work counting from chat inventory tests

* test(native-chat): repair SQL epoch fixtures and sender closure case

* fix(native-chat): own async option preparation and port SQL runtime fixtures

* test(native-chat): encode the full founding identity

* fix(native-chat): recover saved live work on SQL open

* fix(native-chat): select retained image sources before history paging

* fix(native-chat): preserve catch-up authority and scoped journal teardown

* Cover the 4a conversion, history-shape and maintenance-debt cases through outside observation

Conversion: seed a medium chat (310 chats on the full profile) and refuse a
cached seed from another recipe. Observe the candidate's existing
epoch-installed ready boundary with a read-only poll of journal_chat_state.
An idle seed copy yields launch to every chat ready and the per-size
ready-mark intervals; the families copy verifies an unconverted first open and
waits for every chat ready before any steady-state family.

History/detail: the stub emits ordinary Claude subagent frames (interleaved
and sparse-root corpora) and a shapes turn (huge completed tool originals, one
above the detail reply cap, an oversized ordinary message). Each named shape is
verified through the real history/detail route before its samples count; diff
items stay explicit missing evidence because the Claude adapter writes none.

Maintenance: write and rewind large completed rows on a disposable seeded chat
under a held outside reader, then measure other-chat sends during the hold,
after release and while freed pages are reclaimed, from read-only page/WAL
state. Retired-epoch pruning is skipped unless such rows are observed.

* fix(native-chat): preserve stopped result disclosure and async fixture ownership

* Resolve lost-session warning identity at the journal writer

* Cover the 4a conversion, history-shape and maintenance-debt cases through outside observation

Conversion: seed a medium chat (310 chats on the full profile) and refuse a
cached seed from another recipe. Observe the candidate's existing
epoch-installed ready boundary with a read-only poll of journal_chat_state.
An idle seed copy yields launch to every chat ready and the per-size
ready-mark intervals; the families copy verifies an unconverted first open and
waits for every chat ready before any steady-state family.

History/detail: the stub emits ordinary Claude subagent frames (interleaved
and sparse-root corpora) and a shapes turn (huge completed tool originals, one
above the detail reply cap, an oversized ordinary message). Each named shape is
verified through the real history/detail route before its samples count; diff
items stay explicit missing evidence because the Claude adapter writes none.

Maintenance: write and rewind large completed rows on a disposable seeded chat
under a held outside reader, then measure other-chat sends during the hold,
after release and while freed pages are reclaimed, from read-only page/WAL
state. Retired-epoch pruning is skipped unless such rows are observed.

* Remove the retired ACP warning-reader fixture field

* Validate warning writer authority before duplicate selection

* Wake queued delivery when pending requests change

* Validate authority before all resolved item selection

* Use current chat test fixtures and name the handover journal owner

* Keep warning authority validation on the semantic selection branch

* test: lose unsaved ACP creations before a successful resume

* refactor: tighten SQL journal types and publication reads

* test: use SQL chat writers and async journal observations

* Replace casts and empty type imports in the 4a harness scripts with annotations and guards

Renderer times and tab ids from waitForFunction handles go through typeof
guards, the visibility probe is a declared Window global, the runtime call
keeps its own typed response, and cached manifests, Electron paths, profiles
and families are narrowed by guards. The empty `import type {}` blocks name
AppStore and use it. Three casts remain, each with a line-specific SAFETY:
the generic RPC result and Node's performance inside main-process callbacks.

* refactor: type handover owners and finite recovery snapshots

* Name the 4a arm's bundled envelope builders by their tracked source files

The protocol bundle imported from './src/shared/agent-session/...', a folder
the path-literal ratchet reads as an unresolved import. Each module is now a
tracked-file constant joined onto the arm's own checkout, the same form
runtime-file-watcher-resource-probe.mjs uses; the bundle and its exports are
unchanged.

* Replace casts and empty type imports in the 4a harness scripts with annotations and guards

Renderer times and tab ids from waitForFunction handles go through typeof
guards, the visibility probe is a declared Window global, the runtime call
keeps its own typed response, and cached manifests, Electron paths, profiles
and families are narrowed by guards. The empty `import type {}` blocks name
AppStore and use it. Three casts remain, each with a line-specific SAFETY:
the generic RPC result and Node's performance inside main-process callbacks.

* Name the 4a arm's bundled envelope builders by their tracked source files

The protocol bundle imported from './src/shared/agent-session/...', a folder
the path-literal ratchet reads as an unresolved import. Each module is now a
tracked-file constant joined onto the arm's own checkout, the same form
runtime-file-watcher-resource-probe.mjs uses; the bundle and its exports are
unchanged.

* Port cross-version wire tests to SQL journal reads

Hosts take the shared domain database, reads go through named async
journal reads and catch-up history pages, and released-build fixtures
type the release's own synchronous journal API.

* Align cross-version downgrade tests with one-way conversion

A downgraded build sees the chat and records as converted and its
later writes are not carried forward. Drop tests whose subject was
this build's legacy row and outcome writes; seed newer legacy rows
before the first conversion.

* Port cross-version wire tests to SQL journal reads

Hosts take the shared domain database, reads go through named async
journal reads and catch-up history pages, and released-build fixtures
type the release's own synchronous journal API.

* Align cross-version downgrade tests with one-way conversion

A downgraded build sees the chat and records as converted and its
later writes are not carried forward. Drop tests whose subject was
this build's legacy row and outcome writes; seed newer legacy rows
before the first conversion.

* test: open runtime fixtures with SQL journal workers

* test: combine runtime fixture imports

* test: prune resolved compatibility timeout finding

* test: use bundled SQL workers for runtime admission fixtures

* test: await SQL reader delivery and complete real rewind cuts

* test: include the medium chat in comparison profile metadata

* test: cover snapshot holds after replacement rollback and read failure

* test: keep clear history assertions on saved and rendered results

* Inject the deletion scenarios' record removal at the SQL record store's reads

The SQL record store has no transact or record-deletion command, so the
authoritative-deletion cases make the store's public record reads answer as
for a missing record and restore them before teardown. Assertions unchanged.

* Align cross-version fixtures with async SQL publication

Wait for frames that follow committed reads, await the async
completion feed, route the outline and item calls to their current
host methods, and expect the restart unreconciled latch on loaded
records.

* test: delete automation records with their command receipts

* Seed completed diff originals through the baseline writer and measure them

The 4a stub speaks Claude stream-json, whose adapter writes no diff items, so
completed diff originals were a skipped row. The seed now appends known
diffs once into its last filler chat through the seed arm's own original
journal writer, after that arm stops and before the seed is renamed or
copied, so every arm starts from the same rows and item IDs. Both arms verify
kind, original length, a short page head and the exact patch from detail
before timing the tail page and the detail read, and the conversion sweep
reports the diff chat apart from the small chats.

* Pin each 4a arm to a full SHA and prove its build came from it

Each --arm now names name=<checkout>@<full sha>. The harness refuses an arm whose HEAD
differs, whose product sources are dirty, whose renderer build-commit stamp is not that
HEAD, or whose sources changed after the build, and records that provenance in every
result. A cached seed from another seed-arm commit is refused, and report-only refuses to
mix results from different pins, seeds or recipes. Tables name full SHAs and disclose that
writer BEGIN-to-COMMIT spans are not observed.

* Establish restart recovery debt in the record writer

* Add active-chat resident memory comparison to 4a harness

* Commit complete provider dispatches and preserve Stop sources

* Coalesce pending publications across provider dispatches

* Capture CI watch actions at SQL writer publication

* Restore Claude task linkage in SQL acquisition facts

* Lift restarted queue holds through SQL admission

* Forward brief clear through Claude close

* Isolate SQL test worker lifetimes and prove fork durability

* Preserve saved queue order and recover restart custody on SQL open

* Keep saved queue contracts explicit and type fixtures accurately

* Run startup chat workspace conversion through its SQL owner

* Make journal command classifications exhaustive and remove unchecked casts

* Temporarily reverse quality cleanup to isolate translation regression

* Restore verified behavior-neutral journal quality cleanup

* Initialize real saved snapshot routes in Claude translation tests

* Repair native chat campaign readiness and contention measurements

* Measure fork contention under isolated retired history pressure

* Verify contention still targets a live stream at dispatch

* Run chat maintenance within the record-store lifetime

* Bound chat activity reads to work transitions

* test: adopt saved snapshots in direct Claude sinks

* Cover maintenance activity during registered starts

* test: initialize saved facts for Claude permission and resume fixtures

* test: await durable Claude resume and chain publications

* Complete provider dispatch identities in maintenance fixtures

* Preserve journal body admission and text close finality

* Scope optional permission backfill failure to its record change

* test: seed SQL reader fixtures through their owning contract

* test: assert saved Codex outcomes through SQL readers

* test: seed replay-budget withdrawals through command turns

* fix: refuse chat access on newer journal schemas

* test: migrate Claude echo wait; fails on known product finding

The retained Working assertion still fails after awaiting initial publication and accepted echo. The product finding is handed to the author.

* test: await SQL transcript and command publications

* test: migrate public rewind cursors and teardown warning scopes

* test: await child-work and status re-entry publications

* test: bind operation fixtures to SQL current-work reads

* test: establish recovery fixtures through owner restart reconciliation

* Keep child work owned across null status publications

* test: await subscriber and late-proof SQL observations

* test: resolve the profile transfer fixture from the repository root

* test: assert restart recovery capsules instead of internal call counts

* test: migrate Claude echo wait; fails on known product finding

The retained Working assertion still fails after awaiting initial publication and accepted echo. The product finding is handed to the author.

* test: await runtime session publications and final writer acknowledgement

* test: migrate coordinator mail SQL APIs; known product failures remain

* test: persist fork sources and use SQL RPC fixture contracts

* test: observe conversation publications in worker abandonment

* test: admit downgrade fixture owners through the SQL store

* test: await ordered attention prompt relay observations

* Keep status observer failures outside provider ingress

* Order provider facts before late delivery receipts

* test: submit replay fixture turns through the general writer command

* test: await durable worker delivery and lifecycle outcomes

* test: follow current provider ownership in coordinator mail

* fix(chat): settle mail custody from writer outcomes

* fix(perf): format retired fixture row count explicitly

* fix(chat): admit automatic worker close from current work

* Require live tool contention witness at send dispatch

* Await attention fixture updates and prune the fixed echo wait baseline

* Preserve the Pi startup exit verdict after recording process identity

* Check restored image deletion through the transcript view

* Adapt history pressure fixture and probes to current item storage

* Repair CI import paths and asynchronous lint findings

* Keep journal storage and projections acyclic

* Preserve proven startup facts across acquisition settlement

* Wait for the owning chat boundary in recovery and delivery tests

* Observe admitted delivery work in native chat fixtures

* Make native chat comparison measurements fail closed

* Isolate SQL worker fixtures across test files

* fix(sqlite): avoid retaining large bindings in cached statements

* perf(native-chat): reuse the captured queue publication

* test(orchestration): await refused mail settlement before recovery

* fix(orchestration): reconcile owned mail before consuming checks

* fix(orchestration): preserve each mail check response

* test(orchestration): diagnose surviving timers through public SQL reads

* perf(native-chat): place item metadata before large forms

* test(native-chat): require the octet-length column flag

* fix(native-chat): version persisted item presentations

* fix(native-chat): bound queued-image history admission

* test(orchestration): update shared mail source support

* fix(native-chat): preserve Stop transitions and admitted forms

* perf(native-chat): select the existing latest-turn index

* perf(native-chat): reuse history admission facts

* perf(native-chat): reuse shortened history wire forms

* perf(native-chat): batch bounded fork metadata reads

* fix(native-chat): synchronize CI fixtures and type mailbox receipts

* perf(native-chat): bound fork scratch presentation work

* test(native-chat): await subscriber catch-up completion

* fix(native-chat): retire readers after fork setup failure

* perf(native-chat): batch bounded fork metadata and output reads

* Reuse validated journal publication inputs on demand

* fix(chat): cancel reader requests on requested shutdown

* perf(native-chat): reuse narrow SQLite work reads

Read canonical current work and queue eligibility in one snapshot, and reuse validated work through the existing journal observation entry. Preserve full status publication, live authority validation, optional queue failures and final writer claims.

Frozen700 matches the reviewed 27-file source manifest and measured tree 6423b1cfbb. Cold and changed-head reads meet the one-point budget; unchanged publication frames improve.

Disclose report698 strict-rule misses accepted by the coordinator as noise: the approximately 4us warm in-memory hit has paired p50 ratio 1.047; one writer-ack cell (empty / 2 subscribers / changed) is +5.5% at p50, 0.259 to 0.274 ms, while completion is approximately twice as fast.

* test(native-chat): synchronize Stop with interrupt entry

The request note is written before the separate dispatch read and native cancel call, so observing the note cannot prove cancelTurn has started. Await the mock interrupt entry, then inspect the request note while its response stays unanswered.

Remove eventual polling and verify the single status note before and after the response without asserting its wording. No production ordering change, sleep, retry or timeout increase.

* fix(native-chat): refresh invalid full work projections

Use the existing SQL authority and context validation before preserving a
full projection, so refreshed narrow work can be reused after row-free
invalidation. Preserve a valid full projection arriving during a narrow
read and extend the existing owner scenario for both transitions.

Correct the description in b98a2544bf: the report698 strict misses are
small measured overhead, not proven noise. Empty warm currentWork p50 is
3.542 to 3.709 us (+0.167 us, 60/80 pairs slower, ratio 1.04715, 95% CI
1.02291-1.07259). Empty/2-subscriber/changed writer ack p50 rises 5.5%,
0.259459 to 0.273833 ms, with its CI excluding parity, on an unchanged
writer path; completion falls 1.546834 to 0.657125 ms. The coordinator
accepts these marginal costs; the strict FAILs remain disclosed.

Frozen714 patch 6a4ded1ee72e8c0134a9a2121fb39bde618213e3f740b4888fd13c8900274620.
Owning 53 tests pass on both configured entries; static gates pass. Private
point attribution verifies repeated narrow reuse and all 92 serving/frame
outputs match. Focused714 against pre-P7 base still measures a small warm
currentWork median overhead; report716 preserves raw samples and CIs.

* fix(native-chat): retain full work projections with saved Stop

Reuse the existing work-answer validity lookup when a narrow read returns.
A full status projection includes the saved Stop, while narrow work leaves
that overlay unrequested. Comparing only the authority work actually read
preserves a valid arriving full projection and retires stale authority or
context without a second cache or comparator.

Extend the held-read owner scenario with a real saved Stop. Private point
attribution shows unchanged full demand going from one reader point to
zero, with full and work outputs equal; invalidation reuse remains one
read followed by three cache hits. Owning 53 tests pass on both entries and
static gates pass. Frozen721 is parent plus two W3 files only; paused SQL
diagnostics work is excluded. Historical P7 benchmark costs remain small
measured overhead as corrected in 12d479e640 and report716.

* refactor(native-chat): remove obsolete work-state read plumbing

Remove the test-only combined work/queue wrapper and its queue callback after the work-state RPC removal. Delete unused projection and queue-list wrappers, keep internal functions private, and point the hydration overlap assertion at surviving current-work and queue owners.

Retain the narrow SQL work path, work-only projection entry and invalidation/Stop reuse guards: subscriber frames, history/current requests and background-task publication still demand them. Combined work and queue eligibility plus resolved-work reuse remain in production.

Validation: 7 owning files, 26 cases on direct Node and configured Bun entry; full configured Node typecheck and static gates pass. Focused parent-versus-change micro preserves exact output equality and point shape across 36 live queue/frame cells and 80 pairs; no paired interval excludes parity. Removed RPC work-state measurements are historical only.

Prior P7 strict misses remain disclosed small measured overhead: warm current-work median 3.542 to 3.709 us (+0.167 us, ratio 1.047; 60/80 pairs slower), and empty / 2 subscribers / changed writer acknowledgment 0.259459 to 0.273833 ms (+5.5%, CI excludes 1) on an unchanged writer path; completion 1.546834 to 0.657125 ms. Neither cost is established as noise.

* test(native-chat): preserve released chat queue publication coverage

Use the surviving queue publication owner after rewind and reopen,
preserving visible card persistence checks across both providers and all
three release cohorts without a production wrapper used only by tests.

Validation: all 49 cross-version and owning files pass on Node and the
configured Bun entry (148 passed, 1 skipped each); the e2e typecheck
ratchet has zero test errors and the owning static gates pass.

* Register native chat SQL workers with the main-blocking ratchet

The journal SQL writer and reader entries run on worker threads. Their
dependencies are grandfathered in the SQLite baseline as worker-only, the
same way existing worker dependencies are; none run SQL on Electron main.
Prune baseline rows the branch no longer needs.

* test(orchestration): hold native admission in mail reconciliation busy chats

The file-local busyChat answered turn/start, so main's automatic mail
steering (#41476) handed each queued mail card to the accepted turn about
80 ms after send. Cases that wait for a visible card then timed out (or
found it gone), and teardown logged the closed SQL reader. Reuse the
custody fixture's busyChat and settleTurn, which keep admission
unanswered until the scenario settles the turn.

Bun: 4/7 failed before; 35/35 passed across 5 runs after. Node: passes
with the custody file (18/18).

* test(agent-session): wait for the at-rest opening snapshot on the open stream

Subscribers queue the opening snapshot behind an asynchronous SQL work
read, so agentSession.subscribe can reply before the snapshot frame; the
queued-image wire contract depends on that ordering. The at-rest case
read frames only up to the reply and lost the race under CI load.

With a 50 ms opening delay injected locally: old assertion 3/3 failed
(expected undefined), new assertion 3/3 passed.

* Correct subscribe comment: the opening snapshot follows the reply

* test(agent-session): assert no agent start after the at-rest opening snapshot

* test(agent-session): wait for the status summary's own publication in the child-records switch

The session-list summary publishes after an async journal projection read that
neither flushStreamedEvents nor the strip's batch covers, so asserting it right
after either raced the SQL worker.

* fix(explorer): resync a recovered remote watch only after the host watcher is installed

The contact-regained resync fired when the files.watch subscription was accepted, before the
restarted host reported its watcher ready, so a file created in that gap was neither in the
re-read listing nor reported by the watcher. The managed-orcad explorer recovery spec now waits
for that resync before writing its probe file.

* fix(explorer): re-read a recovered remote explorer once when its host watcher fails to install

* test(explorer): the recovered watch resyncs after its ready signal

* test(agent-session): await the queued-operation results instead of polling a settled flag

The operation-order cases polled a settled flag and the compact spy with
vi.waitFor's 1 s default. Under SQL worker contention the goal or rewind
answers after more than a second, so the poll gave up while the operation
was still on its way (CI: "expected false to be true", then "closed by
quit" from the unhandled result). Await the result itself and a promise the
compact stub resolves.

With a 30 ms SQL reply delay injected locally plus CPU load, 3 repeats: the
old file failed "releases a startup goal" (expected false to be true) and
"answers a goal" (compact called 0 times); the awaited version passed all.

* fix(agent-session): reserve queued sends before a waiting operation's own place

DeliveryOrder.reconcile became async when the first-queued read moved to the
SQL readers, but the ready-operation path still called it without awaiting
and reserved the operation's place right after. The operation then took its
place before the queued send it was meant to follow, so a goal, rewind or
other operation requested while the agent starts could run ahead of a
message sent earlier; a failed read also became an unhandled rejection.
Await it, restoring main's order (reconcile, then reserve).

Found by typescript/no-floating-promises over src/main/native-chat.

* test(agent-session): let delivery park before the attention case's idle sweep

The single idle-sweep tick keeps a chat whose delivery loop is still
running, and the loop parks only after SQL reads that follow the second
send's completion event. When the tick ran first it touched the session
instead of retiring it, and the 1 s hasSession poll failed. Wait for the
loop to park (wake resolves when it does), as goal-steering does.

With an 8 ms SQL reply delay injected locally plus CPU load: old 2/5
failed (expected true to be false), new 5/5 passed.

* test(agent-session): await the fake Codex child's requests in compact-exit

Restarting after a mid-command exit runs the exit settlement, a fresh
acquire and the queued send's handover through the SQL workers before
turn/start, which outran vi.waitFor's 1 s poll under load. The shared fake
Codex now resolves nextRequest(method) when a child receives that request;
compact-exit awaits it instead of polling the calls list.

Seen once in a contended local sweep (8 ms SQL reply delay plus CPU load):
"expected [] to have a length of 1" at the turn/start poll. The new
version passed 5/5 under the same delay.

* fix(agent-session): keep a settled send's frame over an older work restatement

Subscriber delivery reads current work before the history page, then lets
that work restate unanswered sends over the page's rows. When a send's
settlement committed between the two reads, the page carried it accepted
but the earlier work restated it pending, so the frame at the new cursor
published the stale state. Later caught-up frames restate only still
unanswered sends, so the client never learned of the acceptance: the
Claude echo case kept a "pending" bubble although the journal held it
accepted. A restatement only describes sends its read saw unanswered, so
an accepted or rejected page row is newer and now wins.

structured-agent-session-claude-echo-working (failed once in CI, never
reproduced) with an 8 ms SQL reply delay injected locally plus CPU load:
before, most repeats stayed pending for 15 s while the stored row was
accepted at the subscriber's own cursor; after, 7/7 passed in ~100 ms.

* fix(native-chat): record the original journal copy identity

* chore(native-chat): grandfather the writer worker's one-shot source receipt

The receipt is captured once inside domain initialization, which runs only in
the SQL writer worker, so its synchronous stat and SQLite write never run on
Electron main or the orcad loop.

* test(native-chat): await current-request reads instead of polling for one second

The child-request case waited 1 s for the SQL reader's current-request
answer and failed on a loaded CI shard. Wake on each real state change
from the subscription and the request reader instead.

* fix(native-chat): re-answer current work when a catch-up page passes its cursor

A subscriber catch-up answered current work at one journal cursor, then read
the history page in a later reader transaction. The restated copy of a send
still pending at the work cursor replaced the page's accepted row, so the
renderer kept showing the send as sending.

Re-answer work when the page cursor has passed the work answer, refresh the
fan-out's shared work answer once the journal adopts a newer commit, and keep
the page's own rows when the page holds a commit not yet adopted.

* fix(native-chat): read subscriber page rows and current work in one reader snapshot

The catch-up overlaid a work answer from one journal cursor on a history page
read at another. Re-answering work afterwards still left a page that ran ahead
of the adopted cursor without its work, so a send shown as unknown could
revert to pending under an unchanged work fingerprint.

The history read now answers current work in its own transaction. The main
thread validates that answer against live owners and handover with the
existing currentness check, and reads the frame again until it has adopted
the frame's cursor. A cached answer is reused only when the page head is that
same cursor. The fan-out's queue now follows the work answer it was read
with.

* fix(native-chat): capture each subscriber frame at one held command-lane position

A subscriber frame paired rows, current work and the queue from different
positions, and waiting for the main thread to adopt a newer head re-read the
page until it did.

Each frame now captures its page and work (one reader transaction) and its
queue inside a single readInOrder on the chat's command lane, then releases
the lane before emitting. The queue reaches the frame through the explicit
queuePublication option, so emission never reads a newer one. A capture
whose live authority changed mid-read is discarded without advancing the
subscriber; the change's own publication delivers its replacement. Inactive
subscribers, closed journals and replaced session handles abandon the frame.
The resume path no longer decorates stop notes with work read before catch-up;
they restate the work of the frame the subscriber caught up to.

* fix(native-chat): validate whole captured frames and capture every work overlay

The queue gate inside a frame capture re-read work until it matched live
authority, holding the command lane, and the capture stopped validating
before its queue read. Stop-note pages, history replies, attach hydration
and queued-image decoration still paired rows and work from different
positions.

The queue gate now reads once at the frame's own authority, and outside a
capture once at the live one; a moved authority abandons the frame for the
change's own redelivery. The capture re-validates authority, handle and
cursor after its queue read. Stop-note pages are read on the lane only
while the journal is still at the delivered frame, otherwise the resume
catches up first. History replies and attach hydration use the same held
capture, and image decoration that finds the journal past its frame is
abandoned in favour of the newer commit's delivery. With every overlay
coherent, a settled page row can no longer meet an older restatement, so
the settled-send guard is removed.

* fix(native-chat): owe restatements after an emitted replacement and refuse exhausted captures as unavailable history

* test(native-chat): follow captured history frames in cross-version and queued-image wire tests

* Remove the converted legacy chat journal after its grace period (#42024)

* fix(native-chat): retire certified legacy journals after the grace period

* perf(native-chat): pace source proof through existing maintenance

* test(native-chat): exercise retirement with the native source lock

* fix(native-chat): account for queued card epochs during source proof

* fix(native-chat): settle retained journals and cancel stalled source leases

* fix(native-chat): keep the prepared retirement state narrowed

* fix(native-chat): apply retirement backoff before writer admission

* fix(native-chat): retry restored legacy retirement eligibility

* fix(native-chat): retain pending legacy eligibility helpers

* chore(native-chat): grandfather the writer worker's one-shot source receipt

The receipt is captured once inside domain initialization, which runs only in
the SQL writer worker, so its synchronous stat and SQLite write never run on
Electron main or the orcad loop.

* fix(native-chat): make retirement filesystem checks asynchronous

The four maintenance SQLite uses run only in the SQL writer worker and the 28 proof-page SQLite uses run only in the SQL reader worker; main-side proof coordination dispatches worker requests.

* fix(native-chat): build lock helper at the server glibc floor

Build Linux server helpers with the existing pinned glibc 2.28 slot images when the host is newer. Keep native floor and musl builds, and select the separate desktop toolchain explicitly. This prevents fast Ubuntu prebuilds from linking GLIBC_2.33/2.34 into a 2.28 payload.

Bound the helper PR workflow to 20 minutes and cover compiler selection without compiling native code locally.

* fix(native-chat): honor read-only retirement ownership

Do not acquire a writable retirement lifecycle for a newer-schema database, so shutdown never sends its read-only writer a retirement-credit command. Keep the existing preservation and empty-diagnostics regression unchanged.

Select the native exclusion test with the dedicated workflow flag instead of generic CI, and merge duplicate database imports in the retirement test.

* fix(native-chat): remove source proof table assertion

Annotate the content table inventory as readonly strings so membership checks accept schema table names without a type assertion.

* fix(native-chat): bound legacy retirement proof work

Persist source-intrinsic refusals for the exact copy, source and destination descriptor. Resume completed proof work after transient failures, and let the existing conversion owner finish pending imports.

Use covering-index key pages for history membership and exit terminal retirement states before writer admission. Preserve originals and prepared unlink manifests.

* fix(native-chat): recover legacy proof without repeating source work

Use the fixed profile-copy columns for source certification and keep damaged destination inventory retryable. Advance the shared refusal policy so earlier false inventory results are re-proved.

Complete verified empty heads after transient conversion failure, and carry proven original-source diagnoses through SQL errors without changing their ordinary identity. Persist only source-intrinsic refusals.

Validate in-place schema recovery, bounded empty completion, and malformed/newer histories at 128/1280 rows with zero retirement proof, conversion, restore or helper work across subsequent owners. Focused tests, tc:node, scoped checks and all 27 ratchets pass.

* test(native-chat): trace cursor resume frames on failure

Capture synthetic subscriber frame payloads and emission stacks when the existing restart assertion fails in CI. Keep the two-frame expectation and production behavior unchanged.

* test(native-chat): allow held-cursor roster frames on resume

A restarted host can publish an empty task and command roster before catch-up when its initial coherent capture is superseded. Validate that optional metadata frame, preserve the two history/work frames and no-replay checks, and await the work restatement instead of polling packet counts.

Remove temporary per-frame stack tracing now that CI identified the publisher. Production wire behavior is unchanged.

* test(native-chat): assert empty resume batches independently

Use literal empty arrays in the resume contract so a defect in the host's batch constructor cannot also change the expected value. Keep the optional held-cursor roster prefix and the two required catch-up/work frames.

* test(native-chat): expect the current conversation fence on resume

The roster publisher reads the conversation fence after restart and send, which can advance beyond the earlier runtime lease fence. Derive the expected fence from that current record and preserve every other resume assertion.

* test(native-chat): hold the domain database lock while a revoked history step is dispatched

* test(native-chat): accept held-cursor state frames before a resumed catch-up and fold them in a released client

* Start the chat journal writer earlier and defer maintenance until serving (#42045)

* Boot the chat journal writer during startup waits

Start the existing record-store slot after login env and before the daemon
wait in orcad, and right after runtime construction on Electron, through one
shared location builder that probes for saved chats once. Startup restoration
consumes that same attempt, so a refused journal is not reopened before RPC.
orcad's push-service start moves to its own module to keep the entry small.

* Start journal maintenance after startup restoration

The CPU profile showed the background sweep's reader spawn and writer
work competing with pre-RPC startup for the disk and CPU. A startup
open now holds maintenance until its restoration settles; other openers
start it on open as before. Reads still convert saved chats on demand.

* Move the headless-serve browser check to its own module

Behavior-neutral; keeps main-process-runtime-launch.ts within the line limit.

* Collect saved chat ids once and start journal maintenance after serving

orcad passes the ids it collected for the early open into runtime
construction instead of collecting them again. Background journal
maintenance now waits for the host's serving milestone (orcad readiness
published, Electron serve ready, desktop RPC start) rather than
restoration settling, so a stalled renderer cannot hold it. The desktop
early open starts after the first-window services fence. The refusal
test now observes that the journal is opened once.

* Keep the deferred desktop chat open inside shutdown, and start CI-line watches after serving

A first-window fence that settles after quit or a failed startup has
committed no longer opens the chat journal past its teardown; the
Electron startup-failure path now commits host shutdown as orcad's does.
Host installation re-arms CI-line watches only after a teardown stopped
them, so the first run starts at each host's serving milestone (orcad
after readiness, Electron after startup settles) instead of during
restoration.

* Admit CI-line watches at each host's serving milestone and let installs retry them

The first watch start no longer depends on renderer load: orcad admits it
after readiness, Electron serve after the serve-ready line, desktop once
the window and RPC start settle. Before admission, chat installation
leaves watches to that milestone; after it, installation's idempotent
start covers a failed first start as well as a teardown. Starts are
skipped once host shutdown has committed.

* Fence desktop watch admission, make warmup retry-only, and release failed watch starts

Desktop admits CI-line watches after the bounded first-window fence, so
automatic journal work never precedes it. The startup warmup timer only
retries a failed start; admission stays with each host's serving
milestone. A watch service whose start rejects after registering its
outcome observer and job hooks is stopped before a retry replaces it.

* Retry a failed CI-line watch start on the journal's maintenance pass

After admission, a saved-chat host whose first watch start failed had no
automatic retry. The journal's existing periodic maintenance pass now
calls the idempotent start when watches are admitted but neither running
nor starting; it does nothing after committed shutdown or while a service
runs. No new timer or loop, and nothing moves before readiness.

* Wire PR-watch recovery into every record-store opener

The chat host's install could open the once-slot first, without the
maintenance-tick hook, leaving a failed first watch start with no automatic
retry. The hook is now a required location field, set through one shared
builder by every production opener.

* Keep runtime identity state within the file-length limit

The saved-chat startup open's import now uses one namespace line, so the
file stays at the 300-line cap after the early-open field and method.

* Load the real chat host once before the PR-watch tests

The host-install-first regression loaded the real chat host module inside
the test, which CI's in-test vi.importActual gate refuses. It now loads in
beforeAll; the test body and its assertions are unchanged.

* Mark the desktop serving test's runtime stand-in as a reasoned cast

CI's changed-code gate requires the lint suppression form for a test cast;
the stand-in and its SAFETY reason are unchanged.

* Share journal database open options so the file stays within its line limit

* test(chat): restore released-client resume projection coverage

* test(chat): type the released-client fold accumulator

* test: fail the first opening subscription data frame

* test: update benchmark module paths after main sync

* test: resolve benchmark modules within each checkout

* test(native-chat): inject late receipts without a history read
2026-11-14 05:51:16 -08:00
OrcaWinandOrcaWin 6a6b23c910 test: remove low-value packaging and release test cases (#42078)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-11-13 09:12:30 -08:00
Brennan Benson 912a723f6c Give terminal agents a lasting Agent ID with Copy Agent ID (#41286)
* Give terminal agents a lasting Orca Agent ID

Terminal agents now get an Orca ID (orca_session_id:<agent>_<uuid>) derived
from their own conversation id on the host that runs them, so it stays the
same across worktree sleep/wake, app restart and a hand-run resume in any
pane. The terminal pane menu gets Copy Agent ID beside Copy Session ID, and
worktree ps --json agent rows carry orcaSessionId. Messaging a terminal
agent by that ID is refused with a message naming its pane until terminal
delivery lands.

* Name terminal agents at row admission and fix review round 1

- Perf: a row's Agent ID is resolved once, when its provider key changes at
  admission (legacy rows via the status adapter's prepareRow hook, tmux rows at
  canonical commit) and carried on the row as runtime-only agentIdentity.
  Snapshots, publications and internal notifications only copy it; no key
  serialization, cache lookup or database access per walk. Drops the pane FIFO
  cache.
- Refusal: the identity service keeps a reverse index id -> rows, kept exact by
  the adapter's rowChanged hook; a terminal refusal reads only matching panes
  and names only confirmed running ones (no resume seeds, exited or
  unconfirmed restored rows).
- Retry: a read-only identity file is lookup-only and never mints; any store
  failure backs off all SQLite work for 30 s; a Copy click retries once.
- Menu: Copy Agent ID shows for a live pane only when its host stamped an ID,
  and for a sleeping pane only when this app owns it on macOS/Linux.
- SSH: a sleeping record keeps its connection; a foreign (non-WSL) one resolves
  no ID.
- Renderer keeps an existing ID only for the same agent, owner and provider key
  including the Pi transcript locator.
- tmux-selected terminal rows carry their ID at every snapshot seam and in Copy
  resolution; structured chat rows stay excluded.

* Keep Agent ID work out of notifications and reach Copy wherever a host can answer

- Internal status/provider notifications walk rows without Agent ID work:
  canonical (tmux-selected) rows are decorated only for outputs that carry
  the id (snapshots, live emit, ps, Copy). The tmux publish body is now
  publishTmuxSelectedStatus so tests drive the production path.
- A row this host can name but has not yet (failed or pending link) is
  published with orcaSessionId: null; older hosts omit the field. The
  renderer offers Copy Agent ID on a live row whenever the field is present,
  and the click retries through terminal.agentId.
- Hosts advertise terminal.agent-id.v1. A sleeping pane offers Copy Agent ID
  when its owner is this app on macOS/Linux, or a remote owner that advertises
  the capability on a known non-Windows platform, and its record names no
  foreign connection.
- "Running in pane" places require that this runtime observed the row; a
  saved status, Done included, is history.

* Guard the pane menu subscription and stop offering Copy where it can never succeed

- A settled read-only miss (no link in a newer build's identity file) no
  longer publishes orcaSessionId; only a resolved id or a pending failed link
  does, so Copy Agent ID is offered only where a click can succeed.
- Render contract for the per-pane menu selection: another pane's or host's
  status change re-renders no unaffected pane; a pane's own stamp flips its
  availability.

* Move terminal agent identity SQL into a worker thread

Main's blocking-SQLite ratchet forbids the synchronous identity store, so
(per the decider ruling) agent-identities.db is now owned by one lazy
worker-thread entry per hook-server owner, desktop and orcad alike.

- The schema, open/version handling, mint/link transaction and read-only
  behaviour move unchanged into agent-identity-worker-entry.ts; main keeps
  only the key type, path and an async client over WorkerThreadRequestQueue.
- Admission stays synchronous: a new key is published pending (null), one
  request per exact key is shared by every row and click, and the committed
  answer re-stamps the current rows still pending on that key (legacy and
  tmux-selected) as identity-only replays. Replies are fenced by store
  generation, key and current subscription; failures back off 30 s and a
  Copy click retries once.
- terminal.agentId and the terminal-ID refusal are async: Copy waits for the
  pending lookup and revalidates the pane; send/task routing resolves the
  terminal recipient (awaiting the store's has() on an index miss) before
  any synchronous routing or effects.
- The renderer treats the host's row naming a conversation as authoritative
  for its id, so a settled miss clears a pending null, while ID-less local
  updates keep it.
- Packaged for desktop and orcad; registered as a worker entry, no baseline
  growth.

* Own identity demand per key, publish settled ids as projections, recheck authority

Implements the second decider ruling for the identity worker:

- One owner-level demand table replaces the per-key promise backlog and the
  settled-row scan: each exact key a current row or caller needs has one
  record (identity, places, waiters); the pump sends the worker one operation
  at a time, only for keys still needed, so a healthy burst completes and
  detached keys are never sent. Operation deadlines start at dispatch; a
  caller's wait expiring never drops a row's demand.
- One failure gate for lookups and membership: after a failure nothing is
  sent for 30 s except one coalesced Copy attempt; a single owner wake
  retries while rows still wait, and cancels with the last demand or close.
- The retirement barrier outlives a client: a replaced worker must exit
  before another starts; a different store path is a different authority.
- Settlement re-stamps the stored row and publishes a projection only: window
  readers get the row without its hook event (no agent-state record) and
  session.tabs is woken by a row touch; no enriched subscriber, plugin event
  or freshness heartbeat runs again.
- Copy and terminal membership check the owner generation after their waits.
  A known chat is decided by the chat store alone; send, peer mail, reply and
  assignee admission resolve the terminal recipient before reading the facts
  they act on, recheck the sender after the wait, and group send reselects
  its audience and mailboxes after each wait before writing.

* Scope identity answers to their store authority, expire Copy grants with callers, index provider aliases

- One synchronized authority token before Copy/reverse fast paths, compared after their awaits;
  answers carry their authority and an ended store turns rows, tmux subjects and the reverse
  index pending together. Status path changes sync the authority outside admission.
- A failed operation reschedules the pump so a queued click gets its attempt; grants belong to
  live waiters and a click joining a running attempt earns none.
- Provider-native ids resolve through a commit-maintained alias index at the record store.
- Group fan-out no longer classifies authoritative candidates; @idle rereads statuses with
  current candidates before the final synchronous selection.
- Hook-server unit fixtures use an in-memory identity client; a real worker load/stop failure
  check covers the worker boundary.

* Pick a shared provider alias's owner among its owners only

The alias index keeps the store's listing order (readable, then unreadable) as derived ranks, updated from the draft's appended keys on commit, so a duplicate alias no longer walks the history per lookup.

* Ask a remote pane's host for its Agent ID by the host's own pane key

Copy Agent ID on a web-terminal surface sent the client's mirrored pane key, which the execution host does not know, so it answered null.

* Keep focus where the user moved, recover a missed identity re-stamp, ack peer-mail replays first

Copy Agent ID refocuses its pane only when focus is unclaimed or still in the pane; a carried pending row takes its key's settled answer; an already-delivered peer-mail retry is acknowledged before recipient preparation.
2026-11-12 16:18:16 -08:00
Neil fb58871bdb refactor(claude): group root modules by defining owners (#41437) 2026-11-12 00:20:10 -08:00
OrcaWinandOrcaWin 1cc94fdfd6 test: remove low-value workspace and launch suites (#41336)
* test: remove low-value workspace and launch coverage

* test: prune removed orphan cleanup timer baseline

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-11-11 19:03:54 -08:00
Neil 1708f1caee refactor(claude-accounts): organize sign-in and profile owners (#41222) 2026-11-11 13:47:58 -08:00
OrcaWinandOrcaWin 5796c30c97 test: remove 161 low-value cases and 12 suites (#41151)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-11-11 05:16:06 -08:00
Neil 386afed0ca refactor(persistence): organize profile state and Store domains (#41106)
* refactor(persistence): organize profile state and Store domains

* fix(test): locate relocated profile state worker fixtures
2026-11-11 02:44:06 -08:00
Neil 2195eae589 refactor(main): group search and profile implementation owners (#41082)
* refactor(main): group search and profile implementation owners

* test(browser): isolate retained preview grant callbacks
2026-11-11 01:02:18 -08:00
Kelvin Amoaba 64a2a6f779 perf(mobile): let newer phones fetch their language catalog from the desktop instead of downloading all of them (#40519)
* perf(mobile): let newer phone shells fetch the language catalog from the desktop instead of downloading all of them

* fix(mobile): hash only the buildId fields so phone readers can recompute it

* fix(mobile): use the catalog chunk when the generation still has it

* fix(desktop): give catalog reads their own read-slot budget
2026-11-10 03:52:19 +00:00
OrcaWinandOrcaWin a163b9fc5b test: remove low-value copy, inventory, and runner assertions (#40282)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-11-09 10:25:23 +00:00
Neil 76b17ad670 fix(orcad): ship session search worker entry to remote hosts (#40133)
ORCAD_CHILD_ENTRY_POINTS builds session-search-worker-entry.js, but
ORCAD_ARTIFACTS never listed it, so templates, the materializer, and the
remote installer dropped it and SSH-hosted session search failed with
'Session search worker entry not found'. Add the artifact and a test that
every built child entry is listed.
2026-11-08 20:56:01 -08:00
Brennan Benson bf7dfff664 Keep Session History responsive on large histories: move session search SQLite to worker threads (#38945)
* Move session search SQLite into dedicated workers

* test: spawn the session search test worker with the shared worker helper

* fix: pass only drain promises to the channel's drain wait

* Repair session search failure and lifecycle boundaries

* Stop indexing tool output and reclaim existing rows

* test: say why the session search worker tests need a longer timeout

* Bound search cleanup and preserve failure and digest semantics

* Use the database row type for tool purge batches

* test: drop the same-connection mid-page write case now that each page reads one snapshot

* test: prove a mid-page delete from the writer can't change that page's hits

* Repair transcript cancellation cleanup and search test runtime admission

* fix: cancel active transcript finalization and enrichment waits

* fix: close transcript handles when cancellation wins delivery

* fix: preserve scan cancellation errors across parser waits

* test: prove cold session search bypasses an active writer batch

* fix: preserve search continuation through background tool cleanup

* fix: preserve search pages during orphan reclamation

* fix: bound typo repair posting visibility probes

* fix: preserve exact search terms when visibility is inconclusive

* test: drop orphan-reclaim cursor staleness case superseded by frozen continuation

* Bound session search work before ranking candidates

* Preserve the limit notice for empty search windows

* Bound session eligibility lookups and reuse FTS scoring statistics

* Index session scopes for population and candidate searches

* Derive search status from the live index after clear

* Preserve disabled search status during settings transitions

* Share planned expressions between spelling probes and search

* Keep identifier fragments out of spelling presence checks

* Report search initialization through its pending transition

* Bound spelling vocabulary work with the search posting budget

* Preserve search fallback while bounding distinct vocabulary seeks

* fix(session-search): drain removals before the worker queue fills; keep aborted close waits from failing teardown

* fix(session-search): hold writer commands when the worker queue is full instead of stopping the writer

* chore(ratchets): baseline the session search worker's one-shot entry check
2026-11-08 17:08:24 -08:00
OrcaWinandOrcaWin ff416c2f6c test: remove 181 low-value mobile, CI and runtime tests (#39351)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-11-06 23:39:35 -08:00
Brennan BensonandClaude Opus 5.5 2648941358 Fork a Chat UI chat from any finished response (#38326)
* feat(chat): shared contract for forking a chat from a response

Adds the create-time fork source, the host fork capability, the agent fork
level, the forked-from record relationship and the forked-from divider row.

* feat(chat): advertise each agent's fork level and a chat's fork support

* feat(chat): carry a fork source through chat launch, reload and retry

A launch with forkFrom {sessionId, throughItemId} keeps it on the create call,
the saved launch record, reload, retry and its holders, sends no new-chat
options, and is refused before create on a host that does not advertise forks.

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

* feat(chat): fork a native chat from a finished response on desktop

Finished root responses offer "Fork from this response" where the host and
agent can fork: disabled while support is unknown or a fork is opening, opened
in a new tab right after the source, with one toast naming the agent on
failure. The forked-from row draws as a divider linking to its source.

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

* feat(mobile): fork a chat from a response in the message actions sheet

The sheet offers "Fork from this response" with the desktop's eligibility and
host capability, creates the fork through the phone's chat create, and draws
the forked-from divider with a link to the source chat.

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

* feat(chat): a fork create replays only as the same fork

* Add native conversation copy adapters

* Create native chat forks with derived source markers

* fix(chat): offer a fork only on rows that show the agent's own message

A displayed row can be a tool call or a status projected as a plan while
reading as a response; both clients now check the journal row's own kind.

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

* fix(chat): open phone and paired-desktop forks right after their source

The phone names its source tab as the create's placement and the host takes
that tab's group; a paired desktop sends the address captured at the click
when the fork has no tab of its own yet.

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

* fix(chat): float a mid-turn response's fork action instead of adding a line

The action on a response the turn continues past hangs from a line of no
height, as the reply controls hang into the gap, so tool-heavy turns keep
their spacing.

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

* fix(chat): follow the chat's own fork verdict on both clients

The options read already says whether the installed agent forks; an observed
no hides the action, an unanswered read keeps it disabled, and yes enables it.

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

* Preserve native copy boundaries and rewind behavior

* Preserve imported fork tips and serialize create replays

* fix(mobile): open a fork's source through the session's own chat opener

The forked-from link now asks the controller's existing opener for the source
by history id, so it follows that opener's host, selection and reveal rules
instead of navigating on its own.

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

* Project fork markers from touched journal groups

* Retain fork group restoration for delayed readers

* fix(chat): keep a mid-turn response's fork in its own right gutter

The floated action covered the start of the next row. It now sits beside the
response's last line, in a gutter as tall as the prose, so it adds no line and
never reaches the following row.

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

* Preserve native fork chain boundaries and durable streamed copies

* Place phone forks beside their source in window publications

* fix(tabs): adopt a host's new tab where the host placed it

First adoption put every unseen tab at the end of its group, so a fork the host
published after its source landed last. A new tab now follows its nearest host
predecessor when that tab is here; tabs already adopted keep the user's order.

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

* fix(chat): reserve the fork gutter on every root response from the first frame

The gutter came and went with the fork offer, so prose reflowed when a turn
finished or support resolved. A pane that draws forks now keeps it on all root
responses, and the fork sits only there, not also beside Copy.

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

* Return Codex copies without automatic provider renaming

* Resolve chat placement once at the current layout owner

* Preserve chat publication when saved opens are skipped

* Retry chat opens when queued placement changes

* Bound stale chat placement retries

* test: expect the OpenCode reader's imported fork tip

* perf(chat): keep the fork offer stable while a chat streams

Every stream commit made a new forkable-id set, so the fork context changed and
every offered response re-rendered. The set is reused while its members hold,
and rows get an action object that changes only with support or pending.

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

* fix: keep the fork params and Claude fork worker inside main's new lint limits

* Test fork copy and source refresh scaling

* fix: merge duplicate imports and stringify the OpenCode fork tip id for main's lint rules

* Keep fork placement behind session tab projection boundaries

* test: annotate the Claude copy test's hoisted account homes instead of asserting

* fix: add the fork action and forked-from strings to the English catalogs

* test: give fixtures the fork copy their agents declare; add the forked-from string to the boot catalog

* test: keep registry fixtures consistent with the fork copy their agents declare

* fix(orcad): ship the Claude fork worker with the server; update tests for fork fields

* Test saved fork selections through import and first send

* Preserve ordinary chat publication while saving placement

* Show fork beside the copy button on phone chat responses

Long-press opens text selection on every current phone, so the actions sheet that held fork never opened. The fork button now sits next to each response's copy button.

* Keep the phone fork slot fixed and offer it on every forkable response

The fork slot is now held by the row's own kind, as desktop's gutter is, so finishing a turn or learning the host's support never moves the timestamp. Responses with no copyable text (a visual only) still get fork, and each button re-renders only when its own offer changes.

* Follow main's moved runtime modules in fork code and tests

* test: build the phone response-actions fixture without type casts

* Let the phone read the host's agents so its fork action can turn on

Phone QA found the fork button always disabled: the phone asks the host which agents can fork, and the host refused that read from paired phones.

* Retry the phone's agent-list read, and read again after a reconnect

A read lost to a dropped connection or a timeout left Fork disabled until the chat was reopened.

* Own the phone's agent-list retry timer in its own effect

CI's effect-cleanup check could not see a timer set inside the read's callback; each retry is now a state change with an effect that sets and clears one timer.

* Give each phone connection its own agent-list retries

A count left over from an earlier connection could leave a new one with no retries, so one failed read kept Fork disabled after the transport moved.

* Scope the phone's agent-list retries to each spell of discovery

When the host's fork support dropped and came back on the same connection, the earlier failures carried over, so one more failure got no retry. Each stretch of discovery now owns its reads, failures and retry timer.

* Keep the forked-from source link reachable by screen readers

The divider's separator role and row label hid the source chat button inside it; the rules are now decorative and the text and button read normally.

* Keep fork names owned by adopted chat records

* Use the fork icon for Fork from this response

* Show the phone meta actions only when a row has one

An empty actions group still shifted the time by the icons' edge margin on rows with no copy, fork or rewind.

* fix(chat): put Fork beside Copy in the response's hover row

The fork button sat alone in a right gutter far from the other row actions.
It now joins the response's existing hover controls next to Copy, where those
controls show, and the gutter is gone.

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

* fix(chat): keep a finished turn's actions on its last words and hold the Fork slot

A turn whose last prose was followed by tool or thought rows showed no Copy
and no Fork anywhere until it was collapsed. The actions now belong to the
turn's last prose row, decided when the transcript's rows are built, and keep
the gap below it whole so they never cover the next row. Root responses also
keep an empty Fork slot when not offered, so resolving support never moves
the row's other actions.

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

* fix(chat): give a turn's actions only to a reply with words

An image-only reply after the turn's text took the response actions but could
not draw them, so the text lost Copy and Fork. Slot construction now picks the
turn's last reply by the same words the row draws and copies.

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

* fix(chat): let an image-only response hold a turn's actions when its text is folded

A collapsed turn that ends in an image hides its earlier text, so no drawn row
could show the response actions and Fork vanished. Each turn's actions now go
to its last drawn response with words, else its last with images. Copy and its
context-menu target appear only where there are words to copy.

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

* Fix Claude fork cuts after local commands

* Extract the conversation copy input contract

* Preserve caller results at Claude fork boundaries

* test: check the copied fork for the wake answer without a type assertion

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-06 02:08:24 -08:00
OrcaWinandOrcaWin b47835025b test: remove 166 low-value prebuild and release tests (#38712)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-11-05 15:27:06 -08:00
OrcaWinandOrcaWin f865fb26a8 test: remove 141 low-value tests and 13 entire suites (#38613)
* test: remove server qualification inventories and mocked build tests

* test: remove packaging inventories and synthetic native tests

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-11-05 10:22:08 -08:00
Neil 2f217b4d0d refactor(daemon): group endpoint, provider, session and transport owners (#38462)
* refactor(daemon): group transport, provider, endpoint, and terminal owners

* refactor(daemon): consolidate owner imports and preserve pinned baseline sources

* refactor(daemon): import termination budgets from their defining owner

* fix(ci): retain serve mode coverage for extracted orcad startup

* fix daemon build smoke to load concrete argument owner

* read daemon protocol facts from historical defining paths

* route protocol revision owners through compatibility checks
2026-11-05 01:54:51 -08:00
Neil 9bd6272fdf refactor(tooling): organize build, CI, and test owners (#38130)
* refactor(tooling): organize test runtime and maintenance owners

* test(tooling): preserve relocated runtime fixture dependency edges

* refactor(tooling): preserve xterm routing owner checks

* ci(tooling): include routing owner in sparse checkout

* test(tooling): preserve copied workflow dependency closures

* fix(tooling): normalize hashed JSON assets in release parity

* fix(tooling): distinguish asset aliases from literal references

* fix(tooling): frame normalized asset reference payloads

* fix(tooling): normalize decoded JSON asset references

* refactor(tooling): organize build, CI and release owners

* fix(tooling): align moved generator and workflow path contracts

* fix(tooling): update generated plugin bundle owner banners

* test(tooling): create relocated mobile verifier fixture directories

* test(tooling): copy headless detector dependency closure

* test(tooling): align native batch policy fixtures with owner path

* fix(tooling): link moved reliability command to historical evidence

* fix(tooling): preserve nested sandbox owners and canonical guide source

* fix(tooling): target release version owners in checkout fixture
2026-11-04 21:08:19 -08:00