Skip to content

Composer: never block a send that only has to wait (#1499) - #1503

Open
scuttletoby wants to merge 870 commits into
mainfrom
composer-never-block-send
Open

scuttletoby wants to merge 870 commits into
mainfrom
composer-never-block-send

Conversation

@scuttletoby

@scuttletoby scuttletoby commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Merge #1502 first. It announces this PR's seam lines. Until then this PR's seam check is red by design. This branch has #1502's head merged in.

Problem

Several composer blocks refuse a message even though the block clears on its own. The person has to wait and send again, and on a phone the send button simply stays off:

  • the machine is reconnecting: the button is off, and Enter shows "Not connected: message not sent";
  • the previous message is still being sent: "Still sending your previous message";
  • "Messages loading" (or a thread still syncing), "Preparing machine", "Preparing worktree", "Rewinding conversation" or "Sending feedback": the button is off and Enter does nothing.

All of these are upstream code. The full inventory, including the server's paths, is in the Part 1 comment on #1499.

Fix

A send hit by one of those blocks is now held, then sent once the block ends.

When it is released: only when nothing waits and upstream does not own the send. "Nothing waits" includes the thread being live. After a reconnect, the machine shows as connected while the cached thread is still catching up (sync phase syncing), so the client may not yet know of an approval, a question or a turn change that came while it was away. The message waits ("Sends once the thread catches up") until the sync is done. A sync that fails keeps it held. While an approval or a question is open, the message stays held and the chip says "Waiting: answer the approval first" (or the question). A held message never answers or declines an approval, never answers a question, and never redirects a turn. The same applies while the connection cannot operate, the project is not ready, a queued message is being edited, or a resume or setup-queued send is running. In all those cases upstream's own composer, with its reasons, is shown.

Its mode: picked at release, exactly as upstream's send would pick it for the same press at that moment. A Ctrl/Cmd+Enter press (intent alternate, the other follow-up action) keeps that pick. It depends on the follow-up setting and the turn state then: auto when nothing runs; when a turn runs, the follow-up setting, whose upstream default is steer; and queue when the turn takes no steer. A held message never restarts a turn: a restart press that hits a block is not held, the text stays a draft, and a notice names the block. If the follow-up setting is restart at release, the message is queued instead.

What you see:

  • While a block lasts and the draft has text, the send button stays on.
  • While the machine is away, a chip says "Laptop is not connected": "A message you send now waits, then sends when it reconnects". With an empty draft, upstream's own disconnected composer shows, and Resume stays guarded.
  • Once a message is held, the button names the wait (for example "Sends when Laptop reconnects"), and a chip above the composer shows "Message waiting to send" with the reason and a Cancel button.

How a hold ends without sending: an edit, Esc, Cancel, or leaving the thread drops the hold and keeps the text as a draft. So does a draft whose key changes when it gets its server thread, so a hold never fires into another thread.

A refused release: a release counts as refused when the draft's content is untouched after the send. This is judged by content, not by object identity, so a refusal that rewrites the draft object is still seen. Most often the cause is a send already under way that got past its busy state (upstream shows its own "Still sending your previous message" toast for that). The message is then held once more ("Sends after the send under way goes through"), and it goes once that send has shown busy and finished. If the second release is refused too, a notice says "Message not sent: it is still in the composer". It is never silent.

Two tabs (accepted risk): a hold lives in one tab, because the draft store is per tab. If the same text is sent again from a second tab, the first tab still sends its own copy when its wait ends. The owner accepts this risk.

This is a fork add-on in apps/web/src/components/fork/sendWhenReady/: logic, a hook and the chip. Its wiring is one hook call in ChatView.tsx, 24 lines announced by #1502 (one of them passes threadSyncPhase); the hook returns composer props that are spread last into <ChatComposer>. ChatComposer.tsx, useComposerSend.ts and the server are not touched.

State questions

  • What happens when the send is retried? While a message is held, its button is off and Enter is refused by upstream's own sendDisabledReason check. A second hold call keeps the first. The release clears the hold before it sends, so the message goes out once. A retry after a refused release is a new press made by hand.
  • What happens when the server restarts with a message queued?
  • What happens with the syncing hold?
    • A reconnect during a hold: the disconnected wait ends, the syncing wait starts, and the message goes once the thread is live. If an approval or a question shows up during the sync, upstream owns the send and the hold stays until it is answered. The mode is worked out then, from the live turn state.
    • A sync that never finishes or fails: the hold stays, with the chip "Sends once the thread catches up" and Cancel. The text stays in the draft, and Esc, Cancel, an edit, leaving the thread or a reload give it back as a draft.
    • A thread deleted while syncing: its sync phase becomes null, and upstream has no active thread. If the person is still on it, the release is refused untouched: it is held once more (visible), and then the notice shows. Leaving the thread drops the hold. The text is never sent into the deleted thread, and never lost.
  • What happens when a thread has old or empty queue state? There is no stored state and no migration. The hold store lives in memory and is empty on load, and a thread with no hold behaves exactly as upstream. A reload, a closed tab, or a thread that never comes back leaves the text as a draft. Nothing is sent silently and nothing is lost.

Tests

  • fork/sendWhenReady/sendWhenReady.logic.test.ts, 24 cases:
    • one table of the block cases: each is held, its button names the wait and takes no second press, and it is sent once when the block ends. The messagesLoading and syncing rows are driven by the real resolveThreadSyncPhase (cached thread synchronizing after a reconnect → held; live → sent);
    • one table of the upstream owners (approval, question, no operate permission, project not ready, queued edit, busy): a held message is not sent while one is on;
    • one table of the mode at release (idle, follow-up queue, steer, restart → queue, no steer → queue, and alternate presses: steer → queue, queue → steer);
    • the restart press that is not held;
    • a refused release held once more behind a send under way, then sent; a second refusal is not held;
    • an empty draft keeps upstream's composer.
  • fork/sendWhenReady/useForkSendWhenReady.browser.test.tsx, a new browser test of the hook:
    • an approval appearing keeps the hold, and the message is sent once it is answered;
    • after a reconnect, with the real sync phase: not sent while the thread is synchronizing, sent once when it is live; the "not connected" chip shows before the press;
    • an edit, Esc, Cancel, or leaving for another thread drops the hold, keeps the text, and sends nothing;
    • a refused release waits behind the send under way, then a second refusal shows the notice and keeps the text.
  • Run locally:
    • the logic file passes 24/24;
    • vp run check:changed: format, lint, both knip parts, typecheck and the React compiler pass;
    • the web typecheck, run again on the merged tree, passes.
  • Not run locally: the browser test files (Chromium cannot start on this machine because local sockets are blocked). CI runs them.
  • Fork checks: the schema and upstream-files checks pass; the seam check passes against fork seams: announce the composer's send-when-ready lines in ChatView.tsx (#1499) #1502's list.

Left for later parts of #1499

  • The approval panel replaces the composer, so no message can be typed while an approval waits.
  • Server side: queues held after an error, a Stop or a restart; a queued start that throws fails its message; a steer re-sent to a disabled provider is only logged.
  • A hold lives in memory only: after a reload the message is a draft, not a hold.

Part of #1499.

🤖 Generated with Claude Code

scuttletoby and others added 30 commits November 28, 2026 22:29
* Lanes, part 1: the lanes settings and the lane contracts (#1156)

Adds the person-only server setting `lanes` (off): lanes under a
project's orchestrator, defined in settings by name (built-in `pr-queue`
and `issues`, each with a description, the item kinds it owns and its
driver `agent`). The orchestrator will only switch defined lanes on and
off. Nothing reads the setting yet.

- Lenient read: not an object reads as off with the built-in lanes; a
  `definitions` that is not an object defines none; a bad lane name or
  definition (another driver, an unknown item kind) drops alone.
- Save: `enabled` and each definition on their own (`null` removes a
  lane), strict: a bad name is refused rather than dropped.
- Contracts for later phases: item refs (`pr:owner/repo#n`,
  `issue:owner/repo#n`), lane generation, claim, note, escalation.
- Run records: an optional `lane` field (not written yet) and
  runRecordLane, which reads an older record without it as no lane.
- Docs row and section, FORK_CHANGES row, fork report and managed
  settings lists.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Lanes, part 1: keep forkLanes' module-only constants unexported (knip) (#1156)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Lanes, part 1, round 1: built-in lanes survive the sparse settings write (#1156)

The settings writer leaves out values equal to the default, and the
default `definitions` held the two built-in lanes, so a lane added was
saved without them, a removed built-in came back and an edited one
failed the save. The stored `definitions` is now empty by default; the
built-in lanes live in BUILT_IN_LANE_DEFINITIONS and laneDefinitions()
lays the stored entries over them. `false` removes a built-in lane
(refused for any other name); `null` drops a stored entry.

- New apps/server/src/fork/lanes/lanesSettingsFile.test.ts: add, remove
  and edit through updateSettings, the file on disk and the next load.
- Item refs: owner and repository lower case (one ref per item), `.`
  and `..` refused; formatLaneItemRef returns null for a bad item.
- `owns`: at least one kind, each once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
) (#1206)

* dynamic slots D5: agent costs learned from their last runs' memory

The slot gate keeps the highest memory demand it reads of each child it
started while that child runs; when the run ends, the peak goes into its
kind's last 20 runs. A kind's cost is the highest of those x 1.15, rounded
up to 128 MB, never below the rule's start cost (as heavy learns job costs);
OOM raises multiply it and the rule still clamps it at learnedBounds.
Memory only: a restart starts again from the start costs.

Part of #882

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork changes: agent slots learn agent costs from their runs (#1206)

Part of #882

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
- backlog/ next to the queue: standing items (queue format, optional
  repeat/expires) fill slots no ready queue item fits; queue items always
  go first. A one-off moves to started/; a repeating item runs as
  <id>.r<n> once its last run is no longer live in T3 and its gap passed.
- Idle alarm: a machine with free slots, an account with usage and
  nothing ready for it on 3 runs in a row gets one message to the parent,
  at most every 15 minutes, every alarm logged.
- `slot-filler status`: live counts from T3, queue/backlog, idle lines.
- Server: POST /api/fork/delegate/notify sends the parent one message
  the way the wake is sent (once per request id, slot gate).

Co-authored-by: Claude Opus 5.5 <[email protected]>
… (#1172)

* Lanes, part 2: the lane store (registry, claims, outbox, notes) (#1156)

One file per project under <stateDir>/lanes/ holds the lane registry
(running or stopped, the acting thread and its generation), one claim
per item, the outbox of escalations and the notes. Each step reads,
changes and atomically rewrites the file under one lock. Off unless
server.lanes.enabled: every step is refused and no file is touched.
An unreadable file is unknown, not empty: steps are refused and the
file is kept. A replaced lane thread can no longer act; its claims
move to the new generation. Run records name a lane run's lane.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Lanes, part 2: keep the lane store's module-only constants unexported (knip) (#1156)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Lanes, part 2: read the lanes through laneDefinitions (built-in lanes plus stored ones) (#1156)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Lanes, part 2, round 1: own-key lookups, one spelling per item and escalation key (#1156)

- Look lanes and claims up by own key only, so a name like `constructor`
  finds nothing, and check every new state decodes before writing it.
- Claim keys, ownerOf, release and note/escalation items use the
  normalised (lower-case owner/repo) item ref.
- Escalations are keyed by lane and trimmed id; ack takes those keys.
- A failed write is `store-unwritable`, not `store-unreadable`.
- A claim goes stale when its lane no longer owns the item's kind.
- A stopped lane's thread counts as a lane run only up to the stop.
- A file whose claim key or record project does not match is unreadable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
#1153)

* Replay #1153 onto the caught-up main

One commit with this pull request's whole change, so the replay keeps what its merge commits held (old head ba82163).

* seams: list the fleet usage element in UsageLimitsPooled.tsx after the restack

The restack's merge left the ForkFleetUsage element announced; this pull request adds it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fleet usage: a login reported without its workspace is the same account (#1146)

Codex reports its workspace only after it reads its limits, so one login on two
machines (one read, one not) was two rows and the work panel counted it twice.
Each reading now also carries the hash of the id without the workspace, and the
merge (and one machine's own snapshot) follows upstream's Limits rule
(accountKeyResolver): a report with no workspace joins the one account of that
login with a workspace; with two it is shown for its machine only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fleet usage: a kept answer ages on the client and goes unknown past 30 min (#1146)

The client kept the last answer on a failed refresh and showed the server's age
as it was then, so a server that stopped answering left "Read 1 min ago" for
hours. The atom now keeps when this client received the answer, and the view
(and the work panel's accounts) add the time since to each reading's age; past
the 30-minute limit an account is unknown with why, as on the server.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fleet usage: agedFleetUsage is the logic file's own helper, not an export (#1146)

Only fleetUsage.logic.ts calls it (through fleetUsageView and asLimitAccounts), so
knip flagged the export as unused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fleet usage: the section ages a kept answer on its own minute clock (#1146)

The Usage tab's `now` moves only on a limits refresh, so a kept answer never
aged there. ForkFleetUsage now reads useFleetUsageNow (a minute ticker, at
least the page's `now`), which the work panel's asLimitAccounts reader uses
too. A kept answer (a refresh missed) also says on its machine lines how long
it has not been refreshed, and dates its unknown accounts' reasons.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fleet usage: an older machine's reading without a workspace still joins (#1146)

A machine on a version before `base` sends none; a reading whose key is some
login's `base` is that login's reading without a workspace, so it joins as a
newer machine's does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…earer refusals (out-of-time skim dropped) (#1180)

* fix(agent-guards): actions-disable-guard skims what it cannot parse in time

Out of time, the guard no longer refuses every command it did not finish:
it skims the command and the files it names (two deep, folders it cds to,
NAME=value paths, PATH scripts under $HOME) for a guard word (a guarded
token, gh, an HTTP client, workflow/disable, claude/codex, a refuseScripts
line) and refuses only when it finds one or the skim runs out of its 2 s
too. Shell text past 10,000 commands in one call is skimmed the same way
instead of parsed (a 2 MB script took 4 s of the 5 s budget idle; now
0.85 s). head() keeps its answers (1 M calls on a 400 KB script).

Refusals now say where the text that names a token goes (the file, the
pipe, $(..)), which tool the guard cannot read, and what to do instead
("What to do instead:" separate Bash calls, or a file argument).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(agent-guards): the skim fails closed (PR #1180 lens round 1)

The actions-disable-guard skim passed switch-off scripts that the full reading
and main refuse. Now, wherever it cannot be sure what a command runs, it refuses.

- What it runs (skim_runs): the text is split by the guard's own Lex and
  readings, with no second word splitter. Every script a shell, source, an
  interpreter or a path runs is read in turn, and so is every text that
  bash -c, eval, an alias, a git alias, find -exec, trap/ssh/su or a heredoc
  into a shell runs. Refused: a name it cannot spell out ({a,b}, glob,
  unknown $X, $(..)), a script that is not there, cd to $X, input a shell
  reads that it cannot spell out, xargs bash, and a file MAX_DEPTH deep
  that still runs something.
- The 10,000-command limit counts per text, not per call, so a big
  harmless script no longer switches later texts to the skim.
- File names are also read whole (x:y.sh, a,b.sh).
- The skim parses past 400 $(..) on its own clock; arithmetic pieces with
  no command word are skipped.

Tests: Lens1180SkimBypassTest (the lens test, plus 16 more shapes padded,
out of time and one file down, and big harmless input still passing).
The late-start test now expects a script that is not there to be refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(agent-guards): drop the out-of-time skim; out of time refuses again, as main

Both round-2 reviews of PR #1180 found switch-offs that the skim passed and
main refuses. Neon security+state found 6 blocker classes (overwriting a
harmless script, text piped into a shell, flags with values and env -S,
tools that run code, cd/alias inside groups and keywords, ANSI-C names and
agent links). The code lens found 2 (a script behind a command word the skim
did not follow, a cd that is not the first word).

A strict allowlist skim (plain literal words, known data commands only)
was tried first. It would pass 2 of the 9,840 real Bash calls on this
machine that miss the fast exit, and no real call goes past 10,000
commands. So the skim is dropped, and MAX_COMMANDS with it. Out of time the
guard refuses as on main, and a big text is read in full again.

Kept from round 1: head() keeps its answers and the regexes are compiled
once (a 1.55 MB script: 5.07 s on main, 3.95 s now), and the clearer
refusal messages.

Tests: Pr1180SkimBypassTest (one test per lens r1 and Neon r2 blocker
class) and Lens1180R2SkimTest (the code lens r2 test as given): 59 failures
on b079381, OK now. OutOfTimeTest replaces OutOfTimeSkimTest (out of
time refuses, a big text is read in full, head() answers cannot be
changed). The round-1 edits to older tests are reverted to main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…1211)

* fork(ci): a failed typecheck names its failed tasks and their errors

vp stops the other tasks at the first failed one and can drop the end of
that task's output, so the Build and Typecheck job on #1149 failed with
"26/30 successful" and no error. When `vpr typecheck` fails,
fork-typecheck-failures.py reads `vp run --last-details` (before the build's
own `vp run`), prints each failed task with its exit code, and reruns each
task that failed on its own (not those vp stopped, exit 137) so its errors
show. The typecheck's exit status is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork(ci): the typecheck failures script is not fork-owned

Build and Typecheck, an app job, runs .github/scripts/fork-typecheck-failures.py,
so a pull request changing only that script must still run the job. List it
with `!` beside the other scripts app jobs read (fork-owned-paths.test.py).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…ore.ts (#1212)

A new worktree's background index refresh writes into the worktree's Git
folder while `git worktree remove` deletes it, so a cancelled launch could
keep its task folder. The fix (#1210) keeps its logic in
apps/server/src/fork/worktreeIndexRefreshes.ts and needs five one-line seams
in the upstream driver; this list-only change announces them.

Co-authored-by: Claude Opus 5.5 <[email protected]>
… (eval) (#1216)

The kit's default lens runner is now Opus 5.5 medium, and a new settings
key weight_runners gives every lens of a change of one tier its own
runner; its default keeps every lens of a critical change (its code lens
too) on Opus 5.5 high. A lens's own lens_runners entry still wins.

From a 48-review eval (6 fork cases, high vs medium, 4 runs each, blind
judge): on normal code medium found each confirmed bug at least as often
as high (13 of 16 hits vs 12 of 16) at about 0.68x the cost; on critical
code it missed two bugs once more each, so critical stays high. Results
in fork-kit/review/eval/README.md.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…tep 1) (#1213)

Announces one line for apps/web/src/components/CommandPaletteContent.tsx:
after upstream's input.focus() in claimFocusInOpenDialog, a disabled
search input hands focus to the dialog popup. Without it, focus stays on
the body and Base UI's dialog refocuses its popup a frame later, which
steals focus from the root search after a quick step back from file
search (the flaky "ignores repeated Escape keydowns after stepping back
from file search" browser test). The line itself follows in step 2.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…ges weight_runners per weight (#1225)

server.reviewRules gains an optional `weightRunners` ({critical, normal, light}: a runner each),
the fork's mirror of the review kit's `weight_runners`. lens_start gives a lens its own
lensRunners entry, else (the approach lens) the approach role runner, else its change's weight
runner, else `runner`. The preset sets none, so a value without the field runs as before. An
unknown weight or a bad entry is refused on save and reads as off in the file. The settings panel
shows the weight runners and asks before the preset button drops them.

Review kit: a settings file's `weight_runners` merges per weight over the default, so a file that
names only `light` keeps critical lenses on high. Eval README and the DEFAULTS comment say medium
is not shown to be at parity on critical code; the README names `weight_runners`.

Co-authored-by: Claude Opus 5.5 <[email protected]>
* Dynamic slots D5: learned agent costs survive a restart (#882)

The slot gate keeps each agent kind's last 20 run peaks in the state
folder's agent-peaks.json (AgentPeaksFile), reads them when it starts
and writes them after every run that adds a peak. A missing or
undecodable file holds no runs (the start costs). learnedAgentMb now
clamps at the rule's upper bound, so the "cost learned" log line shows
the cost the gate counts (#1206 review).

Part of #882

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(shared): keep AGENT_PEAKS_FILE_VERSION module-local (knip unused export)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…#808 row 3, web) (#1228)

The parent thread's composer shows read-only banners for each prompt its open
delegated tasks wait on (question, approval, secret, pairing card), here and on
linked machines, read from GET /api/fork/prompt-mirror. At most three cards,
then a count. A task whose prompts are not known shows a card with the reason.
Read on each thread change, every 10 s while a card shows, 30 s otherwise; a
failed read shows nothing and is tried again later.

The card shape moves to packages/contracts/src/forkPromptMirror.ts so the web
reads the server's type. The four ChatView.tsx lines announced in #1097 move to
"added" in .github/fork-seams.json.

Co-authored-by: scuttletoby <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
…(step 2) (#1214)

* fork seams: announce the Command Palette disabled-input focus line (step 1)

Announces one line for apps/web/src/components/CommandPaletteContent.tsx:
after upstream's input.focus() in claimFocusInOpenDialog, a disabled
search input hands focus to the dialog popup. Without it, focus stays on
the body and Base UI's dialog refocuses its popup a frame later, which
steals focus from the root search after a quick step back from file
search (the flaky "ignores repeated Escape keydowns after stepping back
from file search" browser test). The line itself follows in step 2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(web): a disabled Command Palette input hands focus to the dialog (step 2)

claimFocusInOpenDialog claims focus for a view that replaces another in
the open Command Palette, but input.focus() does nothing on a disabled
input (file search with no project open). Focus then stayed on the body,
so Base UI's dialog refocused its popup on the next animation frame; a
step back to the root search before that frame lost its focus to the
popup. That is the flaky CommandPalette.browser.test.tsx test "ignores
repeated Escape keydowns after stepping back from file search" on slow
runners.

A disabled input now gives focus to the dialog popup itself, so Base UI
has nothing to restore and schedules no late frame. The seam line moves
from announced to added. The fork test holds frames with fake timers
and fails without the line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…tVcsDriver.ts) (#1224)

* fork seams: announce the worktree index refresh stop in GitVcsDriverCore.ts

A new worktree's background index refresh writes into the worktree's Git
folder while `git worktree remove` deletes it, so a cancelled launch could
keep its task folder. The fix (#1210) keeps its logic in
apps/server/src/fork/worktreeIndexRefreshes.ts and needs five one-line seams
in the upstream driver; this list-only change announces them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork seams: announce the index refresh stop in checkpoint restore (GitVcsDriver.ts)

A rewind right after its task folder was recreated failed with "Git's
index is locked": the restore met the new worktree's background index
refresh swapping its copy in through index.lock. restoreCheckpoint will
stop that refresh and wait for it first. This list-only change announces
the two seam lines; the fix PR adds them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
… D5) (#1230)

* feat(server): slot gate learned costs may go below the start cost (#882 D5)

After 10 finished runs of a kind (AGENT_RUNS_TO_LOWER), its learned cost
follows the measured peaks down as well as up: highest of the last 20
runs x 1.15, up to 128 MB, never under the rule's learnedBounds.minPercent
of the start cost. Fewer runs keep the start cost as the floor; one big run
raises the cost at once. Zero peaks are no runs, like NaN, negatives and
infinities.

The agent peaks file is written by a fiber of its own, so a slow or hung
disk never delays an admission; a stop writes the newest peaks within 2 s.
A newer server's peaks file is read as no runs and never written over.
Run ends are also seen by the 30 s sample, not only at decisions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(fork): link the D5 part 3 PR in the agent slots change doc

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…arts (Text file busy flake) (#1223)

* test(fork): write every fake curl before any release-download step starts

test_passing_errors_retried ran the four download steps in a thread pool, and
each thread wrote its own fake curl and then forked bash. A fork made while
another thread still had its fake curl open for writing kept that descriptor
until it exec'd. If that thread's curl ran in that moment, it failed with
"bad interpreter: Text file busy" (exit 126, ETXTBSY), as on #1194 and #1213.

Each step is now made (server, temp dir, fake curl written, closed and made
executable) before the pool starts any of them, so no fake curl is open for
writing once any process can start. A new test checks this with an audit
hook: every fake curl is written before the first process starts, and no
process starts while this process holds a fake curl open for writing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(fork): fork-release-downloads.test.py weighs ~10s with its new test

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…k's gate (#1219)

* fix(fork-ci): cap review rounds at 2 in the fork's gate config

The owner's rule since 2026-11-16 is at most two lens rounds per PR, but
review.rounds in .github/fork-pr-queue.json still said max 4 with the
approach lens from round 3. Set approach_at 2 and max 2 so the gate says
the same, and update the two tests that pin the fork's own numbers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(fork-ci): rounds.approach_at null means no approach lens, and the fork's gate asks for none

The owner's rule is at most two lens rounds and no approach lens (a PR stuck after round 2 gets an audit outside the
gate). The config could not say "never": approach_at had to be 1-20 and max not below it, in both readers.

- review_config.py: approach_at may be null; approach_lens is then optional (still a declared lens when given).
  A missing approach_at is still refused, and a number reads as before.
- review_judge.py, review_kit.py: no round requires the approach lens under null; the plan says so.
- lensStartRun.ts, plan.ts, rounds.ts, lensStart.ts: the same on the server side.
- review.vectors.json: a no-approach config and two rounds vectors both sides run.
- .github/fork-pr-queue.json: rounds approach_at null, max 2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(fork-ci): T3's config reader takes review.rounds exactly when the gate does

parseQueueConfig took rounds the gate refuses: approach_at 0, -1, 1.5 or 21, max 0 or 21, max below approach_at,
and an approach_lens that is empty or names no declared lens (also under approach_at null). It now ports
review_config._rounds: approach_at a round 1-20 or null (a missing one refused), max a round 1-20 not below it,
approach_lens a declared lens written the way the gate reads it, left out only under null, and no unknown key.

The new shared section `round_configs` in review.vectors.json (39 values, 7 read and 32 refused) is run by
review_judge.test.py against review_config and by lensStartRun.test.ts against parseQueueConfig, so the two
readers cannot drift again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(fork-ci): a round that requires the approach lens but names none is refused in T3

ReviewBlock.rounds had an optional approach_lens, so a numeric approach_at with no lens compiled, and
requiredLenses and planLensStart dropped the required approach lens while roundsText printed "undefined".
The type is now a union (a number has its lens; only null may leave it out). At run time a block that still
lacks it fails closed: approachLensOf throws ReviewPlanError (requiredLenses, roundsText), and lens_start
refuses the pull request rather than start too few lenses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(fork-ci): the over-cap reason names no approach lens under approach_at null

Past the round cap the reason said a person's override is enough "also for a required approach lens that never
posted", even when approach_at is null and no round requires one. Both judges (review_judge.judge_rounds and T3's
judgeRounds) now leave that clause out under null; the shared no-approach vector holds the new text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(fork-ci): the approach_at null entry says what to upgrade first

Every older reader refuses approach_at null and fails closed: a ci/v36 or older gate and queue, a fork-kit/review
checkout from before this release, and a T3 server built before this change (lens_start starts no lens). The
entry's Upgrade line says to move every pin, update the kit and install a T3 build before a repo sets null, and
that on the fork lens_start stops until such a T3 build is installed. review_config.test.py checks the line names
each of them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(server): keep approachLensOf module-local (knip unused export)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…1232)

readDatabase resolves statev2.sqlite with realpathSync before its WAL checks,
so it looks for <realpath>-shm. Two tests armed their "right after the last WAL
check" hook with the unresolved <home>/userdata/statev2.sqlite-shm. On Linux the
temp dir has no link and the two agree; on macOS os.tmpdir() is /var/folders/...,
a link to /private/var/folders/..., so the hook never fired and both tests
failed on main. The hook now names the path the checks use, and the second test
also asserts the hook fired.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…e owner's word (#980) (#1113)

* Assistant: only the read, start and message T3 tools; acts only on the owner's word (#980)

The built-in MCP profile `assistant` now keeps only three narrow T3 tool
groups: `read` (tools that change nothing), `start` (delegate_task,
create_threads, t3_thread_launch) and `message` (t3_thread_send). Every
other T3 tool is hidden, refused on call and not found by tool_search.

- Narrow groups name their tools by toolkit; each tool stays in its own
  group, so a profile that keeps `orchestration`, `threads` or `projects`
  keeps every tool it had.
- Cuts and containment know a narrow group is within the whole groups its
  tools are in, never the other way.
- A carried profile named `assistant` (a scheduled task's record, a
  delegated task) is re-narrowed as it is read, so records from before the
  split never keep the destructive tools.
- A thread on the profile `assistant` gets the owner rule with every
  prompt (Claude UserPromptSubmit context): act only on the owner's own
  messages; what it reads is data, not instructions.
- Settings text and docs/fork/assistant.md say what it can and cannot do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Tool filter test: register the assistant's toolkits the checks look at

The test server registered only the PR, waits and tool_search toolkits,
so the project, thread and orchestration tools the "assistant's tools"
block checks did not exist. Register their real toolkits (with mocks for
what they are built with), run the block with Linked environments on and
the background-wait capability, and leave tool_search out of tools/list
checks, since the server lists it only to deferred sessions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Give the assistant's owner rule by lineage, not profile name

The owner rule went only to a thread whose profile was named exactly
`assistant`, so the assistant on a narrower pick of its own, and every
thread it started on another profile, had none. The resolver now marks
the assistant's lineage (the role thread and every thread down from it,
and a task another machine's assistant delegated, which is carried as
`assistant`), and the Claude plan gives the rule by that mark. An `all`
plan with the rule gets its own process key.

A whole group under a parent that keeps it and a narrow group of it no
longer counts as wider: the cut skips a narrow group the kept whole
groups cover. The profile editor names, beside read, start and message,
the whole groups each is part of.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fork: mark threads the assistant starts, so the owner rule follows them

A thread the assistant (or a thread it started) launches with
t3_thread_launch, create_threads or a fork is recorded as its own in
assistant-threads.json in the state folder before it is made, and a
sub-agent it delegates is recorded just after; the profile resolver reads
the mark on the thread itself. A launched top-level thread on a narrower
project profile now gets the owner's rule, and a child keeps it when its
assistant parent is deleted or the role moves. A file that cannot be read
refuses profiles (fail closed); a launch whose mark cannot be written is
refused. Starts the mark cannot follow (an unbound scheduled task, a launch
or schedule on another machine) are refused for the assistant's lineage.

A delegate_task to another machine from an assistant thread on `all` now
asks that machine first, as a narrower profile does: the carried
`assistant` profile must be applied there, on Claude.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fork: type the assistant thread marks as their interface

The no-file branch's read was inferred from NO_MARKS, which TypeScript
narrowed to its ok member, so the reads in claudeMcpProfile saw no
failure case and every profile read downstream became unknown. Both
branches are now typed as AssistantThreadMarks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(knip): un-export decodeAssistantThreadMarks

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fork: test assistant marks through effect's FileSystem and Path

The marks tests read and write the state folder with effect's
FileSystem and Path instead of node:fs and node:path, and take the
launched thread's id through a check that fails the test when there is
none, instead of passing ThreadId | undefined on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
* Review rules T5 part 1: lens_arm's decision as pure logic (#888)

lens_arm arms a head only if the gate would pass it after the override
lens_arm itself would post: every required lens reads the head, and no
round, finding or approach lens is left open (a TS port of
head_check.review_rounds, replayed on the shared reads vectors). T3's
override counts as no person's, so it never clears a finding. A why that
cites a quick check is refused unless that comment is the newest of its
lens, reads this head, says nit-only: yes and reports no blocker or major.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm: a nit-only line other than yes on any report of this head refuses, cited or not

Round 1 (both reviews): a quick check of the head that said nit-only: no
was only read when the why cited its URL, so a why without the anchor
armed past it. Now the newest report of every lens that reads this head
is read: a nit-only value other than yes, or a quick check with no
nit-only line, refuses.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm: only a bare nit-only: yes passes, read folded as the gate reads lines

Round 1 (both reviews): /^yes\b/ let yes|no, yes/no and yes, but through,
and the line was read without review_judge.fold or the narrow markdown
reading, so nit-only\: no, nit-only&#58; no, a zero-width character or
a look-alike letter was missed. Now each line is folded and read both
ways (as has_state_line reads one), nit only / nit_only count too, and
only a bare yes lets the head through.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* review rules: a blank override_authors entry never matches an override with no author

Round 1 (Neon): people.has((post.author ?? "").toLowerCase()) matched an
override with no author (T3's planned one) when override_authors held "",
so T3's override cleared findings, the cap and the approach lens. One
helper, isPersonsOverride, now needs a non-empty author and skips blank
entries, for lens_arm and lens_start's postAgainKeys alike; lens_arm
also refuses an override_authors list the gate's parser refuses
(review_config._override_authors: logins, each once, at most 20).

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* review rules: an edited, hidden or unread override covers no read and clears nothing

Round 1 (Neon): gateRounds and lens_start's gateReads trusted
post.override without the gate's own checks (lens.Review.override_sha:
never edited, not hidden), and lensPosts could set it on a post whose
hidden flag was not read. One check, trustedOverride (a full sha, not
edited, not hidden, flags read), now gates every override in
newestOverride and gateRounds, and lensPosts keeps an override only when
GitHub recorded it as not hidden.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* review rules: an override is scanned as a lens post as the gate scans it (shared vector)

Round 1 (Neon): lens.Review.scan_posts reads every post of a lens author,
overrides too, so an override prefix that reads as a lens header
(lens: override, which config.py accepts) makes the override a lens
entry with no sha and the gate fails the head. The TS port skipped every
override post and armed it. Now only an override whose author has no
lens association (overrideOnly, set by lensPosts) is skipped, as the
gate skips it. A new shared reads vector with its own override_prefix
runs in review_judge.test.py, lensStart.test.ts and lensArm.test.ts.
lens_arm also refuses an override prefix config._text refuses (blanks
around it, a line break, empty).

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm: T3's own override is never a person's, whatever login it posts as

Round 1 (Opus): the gate counts an override only from the override
association's account, which until #916 is the owner's own login, often
listed in review.override_authors. So T3's posted override would read as
a person's on the next call and clear findings, the cap and the
approach lens. lens_arm now takes the login T3 posts as (poster, a
typed input; unknown or not a login: refused), drops the author of
every override by that login before judging, and says in its notes
when the gate will count T3's override as a person's.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm: refuse a pull request read that is not the number asked for

Round 1 (Neon, minor): planLensArm never compared pull.number with
pr.number, so a mismatched read armed one number with another pull
request's reviews and head.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm: name both reads when the lenses read two commits of one change

Round 1 (Neon, minor): when every lens read the head's change but not
one commit, the gate fails the head, yet no lens counted as unread, so
the refusal said "lens  does not read this head". It now names each
lens and the commit it read.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm: a quick check whose flags were not read is not called edited

Round 1 (Neon, minor): the refusal said "is edited" for a post with
unread flags (a review whose edit and hidden flags were not read). It now
says so.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm: gateRounds reads the head lower-case, as the gate does

Round 1 (Neon, minor): the exported gateRounds compared a person's
override sha with the head as given, so a caller passing an upper-case
head missed that override (head_check.review_rounds lower-cases it).

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm: the module comment says the round-1 rules

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* review rules: types for the round-1 fixes (exactOptionalPropertyTypes)

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm: refuse exactly the review blocks the gate's parser refuses (shared vectors)

Round 2 (Neon): planLensArm read the review block as given, so blocks
review_config.parse_review refuses were armed under or crashed it:
override_authors as a string (TypeError), findings missing (no finding
judged), bad rounds, a normal rule with no lenses (armed with 0 posts).
reviewConfig.ts ports parse_review's refusals (keys, types, lenses,
min_lenses, rules, catch-all, rounds, override_authors and the rule
order check with glob_witness). A new shared review_configs section (45
blocks, each refused or not as parse_review decides) runs in
review_judge.test.py and reviewConfig.test.ts, and every valid configs
block parses in both. lens_arm refuses any block with a problem.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm: a quick check of this head that is not a bare yes holds it, in any shape

Round 2 (Neon majors 1 and 2, Opus major and minors): the uncited
nit-only check read only well-formed newest entries, so it deadlocked a
head that a clean next round or a person had passed, and it missed a
quick check the gate cannot read as a report (a title line above the
header, a fence, a quote, no lens marker, edited, hidden, a short sha),
which T3's planned override then turned into a pass. It also read only
each lens's newest comment, so a later quick check of an older head hid
this head's no, and it matched only the literal name quick-check.

Now quickCheckHolds reads every comment, every line folded: per lens
and per head, the newest one of this head whose nit-only value is not a
bare yes, or a quick check (quick-check, quick check, quickcheck, as
lens_key folds it) with none, holds the head. A comment naming no sha
counts as one of this head. Only a person's override newer than the
hold, or a clean read that passes without the hold and without any
override, releases it; T3's own override, posted or planned, never does.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm: T3's own override never covers a comment the gate cannot read

Round 2 (Opus major, root fix): a lens report the gate reads as
NO_HEADER (inside a fence, under a title line, in a quote or table)
fails the head, and any override newer than it covers it and reads its
findings loosely, so T3's planned override alone passed the head (new
shared reads vectors show both, through the gate's own replay and the
TS ports). lens_arm now refuses (posts) while such a comment is newer
than every trusted override that is not T3's own, posted or planned:
that lens posts a report the gate reads, or a person overrides.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* review rules: one login compare (sameLogin) for T3's posts and a person's override

Round 2 (Neon, minor): lens_arm matched T3's own posts by lower-case only,
while isPersonsOverride trimmed the author first, so a padded author
was not T3's but was a person's. sameLogin compares as the gate does
(lower-case, nothing trimmed; a missing or blank login matches nothing)
and both use it.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm: a cited quick check is skipped only when it is a trusted override

Round 2 (Neon, minor): the cited loop skipped any post with an override
field, also one that is edited, hidden or holds no full sha, which the
gate reads as an ordinary comment. It now skips only trustedOverride.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_start: test lensPosts' override reading (hidden: null, overrideOnly)

Round 2 (Neon, minor): round 1 changed lensPosts (an override needs
hidden false; overrideOnly for an author with no lens association) with
no test of its own. lensPosts is exported and tested: an override whose
hidden flag was not read is no override, overrideOnly is set only for
an author with no lens association, and a lens: prefix override by a
lens author is scanned as a lens post.

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm tests: post times without Date (effect globalDate)

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(knip): un-export isQuickCheckName and quickCheckHolds

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* lens_arm: un-export the QuickCheckHold type (used only here)

Part of #888

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
* Account order: a project may set its own order (#881)

A project's `accountOrder` override replaces the server's for the tasks
delegated from that project's threads; an empty one moves nothing there.
Left out or null: the server's order. Read leniently and saved strictly,
as the server's; an older client's save keeps it, only null clears it.

- contracts: the project-scoped key, its file and patch fields, its
  default row, and the feature count reads each project's override.
- delegate_task: the order check reads the parent's project order.
- Settings: a project screen shows the Account order row; its reset gives
  the project the server's order again.
- docs: README row and section, change file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Account order: project tests in a fork-named file (seam check)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Account order: the change file names #1231 and the project's own order

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Account order: say the pacing gate can still move a task; no order on remote handoffs or create_threads

The project note said an empty order moves nothing, which is wrong with
usagePacingGate on: the gate runs after the order and reads none. The
README now says so, and that remote handoffs and create_threads read no
account order yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
)

* Git: removing a worktree first stops its background index refresh

A new worktree whose first index refresh ends inside the checkout's second gets a second refresh about a second later, in the background. It writes index.t3-refresh and index.lock beside the index in .git/worktrees/<id>. A removal in that window (a launch cancelled right after checkout) made `git worktree remove` fail with "failed to delete '.git/worktrees/<id>': Directory not empty", so the cancel kept the worktree and the thread's binding to it. Seen as a flake of "cancels task folder setup with side chat".

removeWorktree now interrupts that worktree's refresh and waits for it, its git process and its copy cleanup included, before Git runs. A refresh for a folder made again at the same path stops the older one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork seams: announce the worktree index refresh stop in GitVcsDriverCore.ts

A new worktree's background index refresh writes into the worktree's Git
folder while `git worktree remove` deletes it, so a cancelled launch could
keep its task folder. The fix (#1210) keeps its logic in
apps/server/src/fork/worktreeIndexRefreshes.ts and needs five one-line seams
in the upstream driver; this list-only change announces them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* vcs: keep the index refresh code in a fork file, with five seam lines

The seam check refuses fork lines in GitVcsDriverCore.ts that its list does
not name. The tracking and stopping of a new worktree's background index
refresh moves to apps/server/src/fork/worktreeIndexRefreshes.ts; the driver
keeps only the five one-line calls announced in .github/fork-seams.json.
The regression test moves to fork/worktreeIndexRefreshes.test.ts, with a
second test that removes a worktree twice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork seams: move the index refresh stop lines from announced to added

Step 2 of 2 after the announcement (#1212): the five lines are now in
GitVcsDriverCore.ts, so they move to the entry's "added".

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fork seams: announce the index refresh stop in checkpoint restore (GitVcsDriver.ts)

A rewind right after its task folder was recreated failed with "Git's
index is locked": the restore met the new worktree's background index
refresh swapping its copy in through index.lock. restoreCheckpoint will
stop that refresh and wait for it first. This list-only change announces
the two seam lines; the fix PR adds them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(server): a checkpoint restore stops a new worktree's index refresh first

A rewind right after its task folder was recreated failed with "Git's
index is locked" (flaky CheckpointRollbackService.taskFolder test
"restores a task folder storage cleanup removed before rewinding it"):
the recreate's background index refresh swaps its refreshed copy in
through index.lock about a second after the checkout, and a restore that
writes the index meanwhile fails.

The refresh registry is now one per process, so the checkpoint driver
(a service of its own) sees the refreshes the driver core forks.
restoreCheckpoint stops the refresh of the worktree its cwd is in and
waits for it before any Git command; the swap is uninterruptible, so it
has either finished or never started. Moves #1224's two GitVcsDriver.ts
seam lines from "announced" to "added".

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(server): the index refresh registry resolves with Effect's Path, not node:path

Each tracked refresh keeps the Path of the driver that tracked it, and
stopWithin resolves the cwd with it (effect(nodeBuiltinImport)).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…#875) (#1215)

* fork seams: announce the fork budget lines in AgentContextBudget.test.ts (#875 PR 6)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profiles PR 6: delegate_task gives a sub-agent a narrower profile

delegate_task takes an optional mcpProfile. Seat 2 checks it within what
the sub-agent would get without it (its role default cut to the caller's)
and records it for the child's thread before the dispatch. Every read of a
delegated child's profile cuts the pick to that again, for the whole
lineage; a task for another machine carries the pick instead of the
parent's. A retry keeps the first pick; an unreadable record refuses.

Part of #875

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* starterMcpProfiles: decodeStarterPicks is used only in this file

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* delegate_task: the sub-agent's pick is narrowMcpProfile, a narrowing-only field

The tool field shared the person-only mcpProfile setting's name. It is
now narrowMcpProfile, and the person-only guard also finds a field whose
name only contains a setting's, passing only reviewed narrowing picks by
tool and field. The tool list grows by the one field (budget updated).

Part of #875

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Put agentContextBudget.json back as main has it

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profiles PR 6: one pick per child id, no leftovers; fork bytes in the fork budget

The pick is checked before the slot gate and bound to the child's id after
it, under the record's lock: a call in flight on the same id must name the
same pick, an accepted child keeps its first pick, a refusal or a stop
before the child is made removes the record, and a retry without a pick
drops one a stopped server left. A remote retry of an accepted task with a
different pick is refused. Recorded names are trimmed.

agentContextBudget.json is back as main has it: upstream's budget test
measures each tool without the fork's input fields (the lines announced
in the base PR), and ForkAgentContextBudget.test.ts counts them in
forkAgentContextBudget.json.

Part of #875

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* delegateMcpProfile: the retry refusal and the release are used only in this file

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* starterMcpProfiles, delegateMcpProfile: the claim and hold types stay in their files

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* MCP profiles PR 6: a pick is never dropped on a read that fails

A child counts as made when the thread store has it or its command has a
receipt, read from the receipt store with its errors kept: a failed read
refuses the call and never means "not made", and release keeps a record
unless it is known that nothing was made. Profile reads with no state
folder refuse delegated-child lineages, and the plan read reads the
picks. A task for another machine binds the first pick sent per
clientRequestId, recorded after the checks there (no leftover on a
refusal, a retry after a half-way stop is matched). A retry while the
child is still being prepared is told so.

Part of #875

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…sh-session row (#877) (#1235)

The 11-21 design wrapped upstream's fresh-session line in a scope, which the
formatter re-indents, so the seam check refused it. The new design keeps
upstream's lines in place: one fork element before that line renders
"Handoff N" for a handoff's first message and hides its next sibling,
upstream's "New session" divider. The unused 11-21 announcements (the scope
tags and the V2LifecycleRow.tsx lines) are dropped.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…thon (#1233)

The gate's reasons quote comment text with Python's own repr, which escapes
by the runner's Unicode. On a Python with Unicode 16 a symbol new there
(U+1FAE9) printed as itself, where the gate's Unicode 15.0 and T3's port
write \U0001fae9: the same head got another reason text depending on the
runner. lens.py_repr pins it to PY_UNICODE's table (escapes what that
Unicode leaves unassigned; refuses, as UnicodeDrift, a code point only that
Unicode assigns), and the four quoting sites use it.

The table test now checks the table as far as the runner's Python can tell
(the full table on the pinned Unicode, monotonic on a newer or older one)
and expects the unicode vectors' refusal where this Python assigns a code
point a rule reads otherwise, instead of asserting the runner's version.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…5) (#1236)

One fork element just before upstream's fresh-session line in UserMessageRow
renders "Handoff N" for a handoff's first message (a fresh-session user
message with the server's handoff id for its thread and a [T3 handoff N]
header) and hides its next sibling, upstream's "New session" divider, with
CSS. Any other message renders nothing and hides nothing; old or partial
rows give nothing too. Spends the three lines announced in #1235.

Co-authored-by: Claude Opus 5.5 <[email protected]>
… like OpenCode

Upstream pingdotgg#41726 made recovering a failed usage probe on the interval opt-in
(recoverUsageOnInterval). The fork's test of the interval loop's own answer
still assumed every driver recovers; it now opts in the way the OpenCode
driver does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ressure too

Upstream's t3_environment_read now adds a machine field that samples
HostResources.readPressure. The fork's linked-machine test mocked only read,
so the box's handler died and the read came back as an error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
scuttletoby and others added 4 commits November 30, 2026 05:14
…k its rebase (#1472)

A minors item queued with readyWhen pr-merged of PR N names N in its id, title and
pr field, so writers() counted it as "a writer works on it". It cannot start while
N is open, so a conflicting N never got its rebase (seen on #1373).

Co-authored-by: Claude Opus 5.5 <[email protected]>
…and MessagesTimeline.tsx (#879) (#1473)

List only. In the assistant thread's texting look, a closing replies fence in an
assistant reply becomes buttons that send through the composer. ChatView.tsx gets
an import, one hook call and a fork context around ThreadTimeline; MessagesTimeline.tsx
gets an import and one element at the end of TimelineRowContent. Step 2 adds them.

Part of #879

Co-authored-by: Claude Opus 5.5 <[email protected]>
…issues (#1480)

- Read only enabled, supported machines (enabledEnvironmentIds), so a
  machine the owner turned off is not named as "Not connected now".
- When issues are unsupported, the first line gives only the sign-ins.
- Change file notes that cached statuses can show briefly on reconnect.

Part of #808

Co-authored-by: Claude Opus 5.5 <[email protected]>
@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: code · reviewer: Claude Opus 5.5 (code + state, high) · read at: 2448161

blocker: a held message is sent as soon as upstream takes the send back, and if an approval is now showing, that send declines the approval. sendWaitOn returns null both when nothing waits and when upstreamOwnsSend is true, and the hook's effect releases on wait === null. Case: a message is held while the machine reconnects, and the agent asked for an approval in the meantime. On reconnect, answering turns true, the wait becomes null, and the effect calls upstream's onSend(undefined, mode, intent). useComposerSend then declines every approval in shownPendingApprovalIds and sends the text as a redirect (useComposerSend.ts ~1255). The typing guard does not hold the approval, because nobody is typing. So an approval the owner never saw is declined and the running turn is redirected. That is the "never interrupts a running turn" promise broken. With an open question, the same release goes into onAdvanceActivePendingUserInput (it can submit resolved answers) instead of sending the message. !canOperate and cloneBlocked release too, even while still disconnected; upstream then refuses, so there the hold is only dropped. Traced in code (deterministic: sendWaitOn → null whenever upstreamOwnsSend, then the effect's releaseForkHeldSend(targetKey, null, send) sends). The lens test below was written but not run: the machine's capacity gate refused it for 25 minutes. Fix: release only when nothing waits AND upstream does not own the send. When upstream takes over while a message is held, keep the hold (chip still shown) or cancel it, leaving the text as a draft, but never call send.
major: the table test encodes the blocker instead of guarding against it. Its "keeps upstream's composer" row checks {disconnected: true} + upstreamOwnsSend → wait === null and stops there, while wait === null is exactly what makes the hook release. No test drives the hook (useForkSendWhenReady): nothing checks that editing the draft cancels the hold, that Cancel keeps the text, or that a hold made on another thread is not sent. The PR body mentions "Its browser test file", but the diff has no browser test. One hook-level test (or a pure shouldRelease(held, waits, upstreamOwnsSend) with the release rule in the table) would cover all of this.
major: the send mode is chosen when the button is pressed, not when the message is sent. ChatComposer turns the press into a mode (resolveComposerDispatchMode) before the fork's onSend sees it. A press made while nothing runs stores "auto"; a press made while a turn runs stores the person's follow-up setting (steer, queue or restart). Minutes later, on release, the turn may be a different one or none at all. A stored "auto" that lands on a running turn becomes steer_active on the server (CommandPolicy resolveDeliveryIntent), even when the person's follow-up setting is Queue. A stored "restart" restarts whatever turn runs at release. The PR says "a send made while the agent works is queued"; upstream's default when a turn runs is actually steer. Suggest: hold only the intent plus whether the person picked the mode explicitly, and work out the mode again at release with the phase at that moment.
minor: while any wait is on, the override replaces upstream's whole isSendBusy / sendDisabledReason, so other reasons are hidden too: "Rewinding conversation", "Sending feedback", isResuming, and a setup-queue send. A press is held, and on release upstream refuses it silently (isRevertingCheckpoint) or with "Still sending" (sendInFlightRef). The hold is gone and the text is still a draft. Nothing is lost, but the promise "sends on its own" is broken without notice.
minor: a hold made on thread A stays in memory after the person leaves A. If they come back hours later, it sends as soon as A loads, with the mode chosen back then. A hold made on a new draft thread keys on the DraftId; once the thread gets its server id the key changes, so the hold is probably never released (not reproduced). Consider dropping holds for targets that are no longer shown, with the text left as a draft.
minor: two tabs keep separate holds. If the person sends the same text again in tab B, tab A still sends its copy when its wait ends. That is low risk.
minor: Esc does not cancel the hold (upstream's image hold cancels on Esc). The chip text says "Edit it to keep it as a draft", but Cancel does the same, so the chip could say so.

Checked and fine: one release per hold, because the store is read and cleared before send, so StrictMode and two mounted ChatViews still send once. A second press is blocked (sendDisabledReason → submissionBlocked, and upstream's own closure refuses anyway). An edit cancels the hold right away: the zustand subscription runs before the next render. Editing a queued message switches composerDraftTarget, so the hold is not touched. Only the 17 announced seam lines are in ChatView.tsx, and the change builds on upstream's onSend and queue/steer with no parallel dispatch path. The red "Fork lines in upstream files" check is the #1502 seam check, which is expected.

State question:

  • Runs again: a second hold call keeps the first, and the release clears the hold before it sends, so there is no double send from the hold itself. A retry after a refused release has to be made by hand.
  • Stops half-way: if the page reloads or the tab closes, the hold is dropped and the text stays as a persisted draft. If the server restarts, the client shows disconnected and sends after reconnect; that is the case where the blocker bites when an approval is waiting.
  • Old or empty state: nothing is stored and there is no migration; an empty store behaves exactly as upstream. If the machine never comes back or the thread is deleted, the hold sits in memory with its chip and Cancel until a reload, and the text is never lost.

Repro test (lens-only, not pushed, not run for capacity; by reading it fails on this head):

it("a held send is not released when an approval or question appears", () => {
  const key = "thread-a";
  forkSendWhenReadyProps({ targetKey: key, wait: "disconnected", held: false, waitText: "x" })
    .onSend?.(undefined, "queue", "foreground");
  const wait = sendWaitOn({ waits: CLEAR, upstreamOwnsSend: true }); // answering = true
  const send = vi.fn();
  expect(releaseForkHeldSend(key, wait, send)).toBe(false); // this head: true, send called once
  expect(send).not.toHaveBeenCalled();
});

Verdict: NOT SAFE. Fix the blocker and the test that hides it; the mode major should be fixed in this PR too, because it is the "wrong mode" case #1499 asks about.

🤖 Generated with Claude Code

scuttletoby and others added 12 commits November 30, 2026 05:28
…ccount (#881) (#1329)

* Account order: t3_thread_launch moves an agent's launch off a spent account (#881)

An agent's t3_thread_launch that names no model, on a spent account, now
starts on the first account in the order that applies (the project's own,
else the server's) with room that lists the same model, takes the same
options unchanged, is not turned off for the project and offers the started
runtime mode. The slot is counted on that account.

- handlers.ts: the two lines #1312 announced (forkLaunch, and launchGate
  taking it), moved from announced to added in fork-seams.json.
- usage/accountOrder.ts: moveByOrder, the order loop delegate_task and
  create_threads ran inside delegateChecks.ts, now shared by every route;
  orderThatApplies moves here too (delegateChecks re-exports it).
- fork/launchAccountOrder.ts: the launch's candidate check and log line.
- launchGate runs the order first, before the no-message return, then
  linked pacing and the slot on the final account.
- Docs: under modelPolicy enforce a launch naming no model is refused
  before the order, so only off/advise launches move; not asked again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Account order change file: link #1329 (#881)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
systemd 255 kept hundreds of tmux-spawn-*.scope folders active below one
agent slice after their panes ended (cgroup.events populated 0, no
process, 0 MB). scope_demand only treated a missing cgroup as gone, so
each owed a whole agent: reserved 67916 MB, free -61514 MB, and every
start on the machine was refused for 30+ minutes.

A listed scope (this user's agents and plain heavy jobs, other users'
agents and jobs) whose cgroup.events says populated 0 now counts
nothing, with one note giving the number. A missing, unreadable or
garbled cgroup.events still counts it (fail closed); a live ticket owes
its cost however its scope reads.

claude-login's RealTmux tests already give tmux no user bus, so their
panes never get a scope of their own; a new test pins that (the pane is
in the test's own cgroup).

Co-authored-by: Claude Opus 5.5 <[email protected]>
…1481)

The transient filter was the glob run-u[0-9]*.*, which also skipped real
units such as run-u9backup.service. It is now the regex
run-u[0-9]+\.[a-z]+. timeoutSeconds is now one deadline across every
systemctl call of a run, so the check's own one-line timeout message
shows before the runner's generic one. The docs say which systemd-run
names are skipped and that run-r<hex> ones still count.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…PRs, partial on unfinished runs (#1482)

Follow-up to #1419 (the three minors of its code lens):
- read_cache checks every cached time with stamp() (and stamp() no longer raises on a right-shaped non-time),
  so a bad mergedAt/created reads the cache as empty and it is rewritten, instead of crashing the clean-up daily.
- a cached merged pull request merged in the last RELIST_DAYS (2) days has its branch's runs listed again; a run
  whose attempt rose or whose updated_at changed since its read is read again. Cache version 2 (runs keep
  "updated"); an older cache is read as empty once.
- a run still going makes the report ci-cost.partial (warn), not only a stderr note.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…r full run (#1090) (#1483)

* Fork tests: Rust and Release Smoke run as Lint steps, 2 fewer jobs per full run

Each was about 40-60 s, most of it runner start, checkout and setup (Rust about
22 s of work, Release Smoke about 11 s), so a full run started two runners for
about half a minute of checks. Both now run as gated steps of Lint: each keeps
its gate, its steps run in order, and they still run after an earlier Lint step
failed. fork-fleet.json, fork-ci-result's needs and the tests that named the two
jobs follow.

Part of #1090.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fork tests: the Cargo cache save in Lint runs only when every Lint step before it passed

The save had !cancelled() like the merged Rust steps, so a push whose Lint
failed elsewhere could still save; fork-ci-cache-keys.cjs refuses that. The
cache-keys test now looks for the Cargo restore and save in Lint, their new job.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…5) (#1486)

* heavy: learn the memory peak per light step, not one per kind (#882 D5)

Every light CI step ran under one kind, so each one reserved the kind's
shared start value (1536 MB) and a 25 s step waited for room it never
uses. Each queued job now also has a step (--step KEY, else its command
line). A step keeps its own last 20 peaks in peaks.json; once one of
them exited 0 by itself, it reserves its own highest x 1.15 (below the
start value too, same 4x and budget caps). A new step, or one with only
failed or stopped runs, gets the kind's value as its first-run default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* heavy: a step learns from memory.peak, and peaks.json gets its own lock (#882 D5, r1)

- The Measurer hands the queue's sampler its memory.peak-based need, so a spike
  between two samples counts; only a run with that figure may lower its step.
- record_peak also takes peaks.lock next to peaks.json (one file per user,
  one queue lock per slice), so two slices ending together keep both records.
- README: derived step keys, the 20-run window, a raised --mb, how to start a
  step over; the sampling-limits sentence now covers steps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
…ry copy agrees (#987) (#1500)

The Skill check read the first copy T3's skill list keeps. The list passes
over a copy it cannot parse and takes the next one of that name, and
Claude Code's own order is not checked against T3's, so Claude Code could
run a copy the check never read.

Now a name found in more than one of the managed, config and project skill
folders is refused (enforce) or noted (advise) unless every copy reads and
runs the same model and effort. The refusal names each copy and what it
runs. Plugin skills (prefixed names) and launch-arg folders are not
scanned.

Co-authored-by: Claude Opus 5.5 <[email protected]>
…ecks (CI flake) (#1501)

Upstream's "bolds $word after '$prefix' with Mod+B over a selection"
read the editor right after pressing End. ProseMirror reads End's caret
move from Chrome's selectionchange, which can arrive after the key press
resolves on a loaded runner, so the markers shown around the selection
were still there and the bold check read nothing. Wait until the
selection has collapsed (the caret left the markers) first.

Step 2 of 2: adds the lines announced in step 1 and moves them to
"added".

Co-authored-by: Claude Opus 5.5 <[email protected]>
…d follow-up inputs (#1499)

The fix round on the send-when-ready PR keeps a held message held while an
approval or question is open and picks its mode at release, so the hook
call in ChatView.tsx reads those states and the follow-up setting too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A send the composer refused for a reason that passes on its own (the
machine reconnecting, the previous message still sending, the messages
loading, the machine or worktree being prepared) is now held and sent
once that reason ends, in the mode it was sent with. The send button
stays on while it waits; once held it names the wait, and a chip above
the composer shows the message waiting with Cancel. Editing the draft
or Cancel keeps it as a draft. The text never leaves the draft, so a
reload keeps it.

Fork add-on in fork/sendWhenReady/, wired by one hook call in
ChatView.tsx whose props spread last into ChatComposer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve .github/fork-seams.json: main and this branch each announced new
ChatView.tsx seam lines (quick replies, send when ready). Keep both: both
announced lists and both sentences in the why.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…se (#1499)

Fix round r1. A held message is sent only when nothing waits and no
approval, question or other upstream state owns the send, so it never
answers, declines or redirects. The mode is the one a press would get at
release (follow-up setting, turn state); a restart is never held. A hold is
dropped, text kept as a draft, on leaving the thread, Esc, an edit or
Cancel, and a release upstream still refuses says so. Rewind and feedback
uploads are waits too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby
scuttletoby force-pushed the composer-never-block-send branch from 2448161 to 2084523 Compare November 30, 2026 04:36
… fork-seams-send-when-ready

# Conflicts:
#	.github/fork-seams.json
…-never-block-send

# Conflicts:
#	.github/fork-seams.json
@scuttletoby

Copy link
Copy Markdown
Owner Author

Fix round r1

This answers the code lens review (NOT SAFE). The fix is commit 2084523. The head is bc31b79, which merges #1502's head, because #1502 now carries main's quick-reply announcement too.

Finding Done
Blocker: a held send fired into an approval or question The release rule is now "nothing waits and upstream does not own the send" (releaseForkHeldSend takes wait and owner separately). While an approval or a question is open, the hold stays and the chip says "Waiting: answer the approval first" (or the question). The other owners behave the same: no operate permission, project not ready, queued edit, resume or setup-queued send. A held message never answers, declines or redirects.
Major: the mode was fixed at press The hold keeps only the submission intent. At release the mode is resolveComposerDispatchMode with the follow-up setting, running and canSteer at that moment, as a press then would get. A restart press is not held: the text stays a draft and a notice names the block. A restart that resolves at release is sent as queue. The PR body now says upstream's default is steer.
Major: the test hid the bug, and nothing covered the hook The row that asserted the bad null is gone. A table of upstream owners now checks that a held message is not sent while one is on, and a table of release modes is added. The new useForkSendWhenReady.browser.test.tsx checks: an approval keeps the hold, then the message is sent once it is answered; an edit, Esc, Cancel, or leaving for another thread drops the hold, keeps the text and sends nothing; a refused release shows a notice. The PR body now matches the diff.
Minor: other reasons were hidden While upstream owns the send, the fork overrides nothing, so upstream's reasons show. Rewind and feedback uploads are now waits with their own text.
Minor: a refused release was silent If upstream leaves the draft untouched at release, a warning says "Message not sent: it is still in the composer".
Minor: a hold outlived its thread Leaving the thread drops the hold, and so does a draft whose key changes when it gets its thread. The text stays a draft; nothing fires into another thread.
Minor: Esc did not cancel Esc now cancels, and the chip text says so.
Minor: two tabs One line in the code comment and in the PR body; accepted as is.

The seam lines in ChatView.tsx went from 17 to 24 (approval and question split, rewind, feedback, busy, running, canSteer, follow-up setting). #1502's announcement is updated to match, merged over its main merge, and keeps main's quick-reply lines.

Checks:

🤖 Generated with Claude Code

@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: code · reviewer: Claude Opus 5.5 (code, high) · read at: bc31b79

blocker: none
major: a held "alternate" press loses its explicit mode at release. While a turn runs, Ctrl/Cmd+Enter (or Ctrl-click) is the person's explicit choice of the other follow-up action: with the default follow-up steer it resolves to queue, with intent "alternate". The hold keeps only the intent, and releaseDispatchMode calls resolveComposerDispatchMode with alternateModifier: false, so at release the message goes out as steer into the running turn. That is the opposite of what the person picked, and it is not what a press then would get (the same keys at release give queue). This case is realistic: the turn runs, message 1 is still sending (previousSend wait), and the person queues message 2 with Ctrl+Enter, which then steers. Fix (one line, in releaseDispatchMode/releaseForkHeldSend): alternateModifier: held.submissionIntent === "alternate". It still never resolves to restart (alternate of restart is queue, and restart maps to queue anyway). Add one row for this to the release-mode table. Traced in code; the lens test below was written but not run, because the machine's capacity gate refused it for about 12 minutes.
minor: a reconnect can release before the thread has caught up. After reconnect, a cached thread is synchronizing, so threadSyncPhase is "syncing" (not "loading") and is not a wait. If an approval or a question arrived while the client was disconnected, the first render after connected may not have it yet: no owner is set, and the hold releases into a run that waits on that approval. This is not the round-1 blocker. Nothing is declined: the client's shownPendingApprovalIds is empty, and the server's steer path (dispatchSteerIntoRun) does not touch approvals. But the message lands in a turn whose approval the person has not seen yet. Consider treating "syncing" right after a reconnect as a wait (one more seam line).
minor: while any wait is on, the override also sets environmentUnavailable: null. That reopens two upstream paths while still disconnected: Enter on an empty draft with Resume shown calls onResume() (upstream returns false while environmentUnavailable !== null), and a press during voice dictation reaches submitAfterDictation, whose detached send (used when the composer is gone before the transcript lands) calls upstream's onSend directly, not held. Both are narrow, and upstream then refuses or errors visibly. Consider passing environmentUnavailable through when the draft is empty or voice input is active.
minor: a release that upstream refuses through sendInFlightRef (an earlier send that got past isSendBusy, for example the mobile dock transition after the worktree-layout approval) shows upstream's "Still sending your previous message" toast while the first send goes through. There is no double send (the guard refuses, and the first send clears the draft), so this is cosmetic only.

Round 1, fixed: the blocker. releaseForkHeldSend returns early unless wait === null && owner === null, and forkSendWhenReadyProps returns {} whenever an owner is set. So with an approval or a question open, the fork never calls send, and upstream's own onSend (which declines shownPendingApprovalIds or advances the question) runs only on a press the person makes. approvalPending is ChatView's pendingApprovals[0], which also counts approvals the typing guard holds, so it is stricter than the composer. Round 1, fixed: the test that hid it (owner table plus hook browser test). Round 1, mostly fixed: mode at press (now worked out at release; the alternate case above is left). Round 1, fixed: the minors (reasons shown, notice on a refused release, a hold dropped on key change, Esc).

Checked and fine:

  • Double send: the store is read and cleared before send, so a second ChatView or a StrictMode re-run gets null. While held, the button names the wait, and Enter is refused by upstream's submissionBlocked. A hold made on text that an in-flight send is still sending is dropped by the draft subscription when clearComposerDraftContent runs, or refused by sendInFlightRef. No path re-sends the same text.
  • Wrong thread: the [targetKey] cleanup cancels the old key before the new render's release effect runs. A draft that gets its server thread, a queued edit that switches draftTarget, and a thread switch all drop the hold, and the text stays.
  • Edit, Esc and Cancel drop the hold and keep the text (composerDraftContentChanged subscription, window Escape with an IME guard, the chip button).
  • Interrupt: a restart press is refused with a notice, and a restart resolved at release becomes queue. canSteer false gives queue. settings.followUpBehavior is the same input the composer uses, apart from its approval override, which cannot apply here because approvals are owners.
  • Seam: ChatView.tsx adds exactly the 24 lines announced in fork seams: announce the composer's send-when-ready lines in ChatView.tsx (#1499) #1502 (b93b9f0): the import, the hook call (22 lines), and {...forkSendProps} as the last prop of <ChatComposer>.

State question:

  • Runs again: a second press keeps the first hold, and the release clears it before sending, so there is one send. A retry after a refused release is a new press made by hand.
  • Stops half-way: if the page reloads or the tab closes, the hold (memory only) is gone and the text stays a persisted draft. If the connection drops during the send itself, upstream handles it as for any press. A server restart shows as disconnected and releases after reconnect, but see the "syncing" minor above.
  • Old or empty state: nothing is stored and there is no migration. An empty store behaves like upstream. A thread that never comes back keeps its hold with its chip and Cancel until the person leaves the thread or reloads, and the text is never lost.

Lens test (lens-only, not pushed; not run, capacity gate refused):

it("an explicit alternate (queue) press made during a wait is not steered at release", () => {
  forkSendWhenReadyProps({ targetKey: "t", wait: "disconnected", owner: null, held: false, waitText: "x", onRefused: vi.fn() })
    .onSend?.(undefined, "queue", "alternate");
  const send = vi.fn();
  releaseForkHeldSend({ targetKey: "t", wait: null, owner: null,
    turn: { running: true, canSteer: true, followUpBehavior: "steer" }, send });
  expect(send).toHaveBeenCalledWith(undefined, "queue", "alternate"); // this head: "steer"
});

Verdict: NOT SAFE, for the one major only. No blocker: nothing is lost, sent twice, sent to the wrong thread, or sent into an approval or question the client knows about. With the one-line alternateModifier fix and its table row, I would call it safe.

🤖 Generated with Claude Code

@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: state · reviewer: Claude Opus 5.5 (state, high) · read at: bc31b79

blocker: a held message is released while the thread is still catching up after a reconnect. At that point the client has not yet learnt of an approval (or question, or turn change) that arrived while it was away, so the message goes out into the approval. The PR's rule says this cannot happen ("if an approval or a question is open by then, it stays held"). This is the "server restart or network drop, then reconnect with an approval waiting" case. The cause is the wiring messagesLoading: threadDetailLoading, which is only threadSyncPhase === "loading", and that is true only when no detail is cached. On reconnect, threads.ts sets the thread status to synchronizing (the setConnecting / setReady path), and resolveThreadSyncPhase then returns "syncing" (detail exists), not "loading". connection.phase is already "connected" by then, so disconnected is false. In the first render after reconnect, wait and owner are both null, and the effect calls send(undefined, mode, intent), with the mode taken from the stale cached turn (default follow-up: steer). On the server, resolveDeliveryIntent sends that steer to the active run. For a provider that steers only by interrupt-and-restart, it interrupts the turn that is waiting on the approval: the held message has redirected a turn, which the PR says it never does. Reproduced with a throwaway test (not pushed, run on this head, it passes, which means the release fires):

const phase = resolveThreadSyncPhase({ detailExists: true, shellExists: true, status: "synchronizing", hasError: false });
expect(phase).toBe("syncing");                       // so messagesLoading (=== "loading") is false
const r = releaseForkHeldSend({ targetKey: key, wait: sendWaitOn({ ...clear, messagesLoading: phase === "loading" }),
  owner: null, turn: { running: true, canSteer: true, followUpBehavior: "steer" }, send });
expect(r).not.toBeNull(); expect(send).toHaveBeenCalledWith(undefined, "steer", "foreground");

Fix (small): hold while the thread is not live after a reconnect, for example a new wait syncing: threadSyncPhase !== null (text "Sends once the thread catches up"). A thread whose sync has "failed" then stays held, which is safe: the text is still a draft. Add one row to the block table, and one browser case: hold while disconnected, rerender with connected but syncing, assert not sent, then rerender live and assert sent once.

major: none

minor: two tabs. The draft store is per tab (zustand persist with no storage listener), so a hold in tab A and a send of the same text from tab B gives two copies. The PR states and accepts this. It is recorded here only so it is a known choice.
minor: the refused-release notice relies on the draft object's identity (getComposerDraft(target) !== before). An upstream refusal that still rewrites the draft object (for example a held-for-images path that stores something) would show no notice. The text still stays, so this is not a loss, just a silent case.

Round 1, fixed: a held send fired into an approval or a question that the client already knows about. releaseForkHeldSend now takes wait and owner separately, and the owner table (6 rows) and the browser "waits for an approval" case prove it.

State question:

  • Runs again: a second press while held is refused by upstream's own sendDisabledReason, and holdForkSend keeps the first hold. The release clears the hold before it calls send, so a re-render, a StrictMode double effect or a second effect run finds nothing to send. The message goes out once (logic table: release(null) twice gives one call).
  • Stops half-way: on a reload, a closed tab or a crash, the hold is in memory only and is gone, and the text stays in the persisted draft, so nothing is sent silently. If the release starts and upstream refuses it, the notice shows and the text stays (browser case). If the release starts and upstream's send fails later, upstream's own restore puts the text back.
  • Old or empty state: the store is empty on load and nothing is migrated. A thread with no hold gets {} props, the same as upstream (keeps upstream's composer when nothing waits). Thread deleted, or leaving it: the targetKey cleanup drops the hold, the text stays, and with no activeThread upstream refuses and the notice shows. Machine never returns: the hold and the chip stay up, and Cancel, Esc or an edit gives the text back as a draft. Stale state just after a reconnect: see the blocker.

Tests: the 20-row logic file passes in CI (Test Web 1). useForkSendWhenReady.browser.test.tsx ran in CI (Test Web 3, chromium, 6 tests, passed). Together they prove the block, owner and mode rules, and drop-to-draft for edit, Esc, Cancel and leaving the thread. They do not cover the reconnect re-sync window above, because the hook's inputs come from ChatView and the tests feed messagesLoading directly. The only red checks are the seam check, red by design until #1502 merges.

Verdict: NOT SAFE until the blocker is fixed. Everything else holds.

🤖 Generated with Claude Code

scuttletoby and others added 3 commits November 30, 2026 06:12
…1499)

A held message must also wait while the thread catches up after a
reconnect, so the hook reads threadSyncPhase instead of only its
loading flag.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…alternate pick (#1499)

Fix round 2. A held message also waits while the thread is syncing after
a reconnect (the client may not know yet of an approval that came while
away); a failed sync keeps it held. A Ctrl/Cmd+Enter press keeps its
alternate follow-up action at release. While the machine is away and the
draft can be held, a chip says it is not connected; an empty draft keeps
upstream's disconnected composer. A release upstream refuses untouched is
held once more behind the send under way, and a second refusal says so;
refusal is judged by the draft's content, not its object.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-never-block-send

# Conflicts:
#	.github/fork-seams.json
@scuttletoby

Copy link
Copy Markdown
Owner Author

Fix round 2

This answers the state lens (7269371999) and the code lens on bc31b79. The fix is commit b4e858f. The head is 00f4bc0, which merges #1502's head b8ac64e.

Finding Done
Blocker (state): a release after a reconnect went out while the thread was still syncing ChatView now passes threadSyncPhase (one seam line changed, re-announced in #1502), not just === "loading". syncWaits turns loading into the "messages load" wait, and syncing/failed into a new syncing wait ("Sends once the thread catches up"). A failed sync keeps the message held, with its text as a draft. The block table's messagesLoading and syncing rows are driven by the real resolveThreadSyncPhase (synchronizing + detail → held; live → sent). A browser case holds while disconnected, rerenders connected but synchronizing (not sent, chip shows the wait), then live (sent once).
Major (code): an alternate press lost its pick at release releaseDispatchMode passes alternateModifier: submissionIntent === "alternate". Rows added to the mode table: follow-up steer + alternate → queue, and follow-up queue + alternate → steer.
Minor: the machine-unavailable state was hidden While the machine is away and the draft has text (so the override is on), a warning chip says "Laptop is not connected": a message sent now waits, then goes on reconnect. With an empty draft the fork overrides nothing, so upstream's disconnected composer shows and its Resume guard stays. The browser reconnect case checks the chip.
Minor: the "Still sending" case A release upstream refuses untouched, most often a send under way past its busy state, is no longer dropped with a misleading notice. It is held once more ("Sends after the send under way goes through"), armed until that send shows busy, and sent once it is through. Upstream's own "Still sending" toast still shows once; it comes from upstream code. A second refusal shows the notice. Covered by a logic case and the browser refused case.
Minor: the refusal notice depended on the draft object staying the same Refusal is now judged by the draft's content (composerDraftContentChanged(before, after)), not by object identity, so the notice always shows on a refusal.
Two tabs Stated in the PR body as an accepted risk.

The PR body's state questions now cover the syncing hold: a reconnect during a hold, a sync that never finishes or fails (held and visible, text as a draft), and a thread deleted while syncing.

Checks:

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant