Skip to content

Daemon: a planned stop parks running turns, and the next start continues them - #565

Merged
lydakis merged 11 commits into
mainfrom
claude/project-thread-v09u6p
Nov 1, 2026
Merged

lydakis merged 11 commits into
mainfrom
claude/project-thread-v09u6p

Conversation

@lydakis

@lydakis lydakis commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

What

Until now a planned stop ended every running turn. That covers agent shutdown, the upgrade path (replace_older, 120 s grace), SIGTERM and SIGINT, so a long turn died on every upgrade and on every restart after a protocol bump. Now a stop parks those turns the same way the pull cord (#534) parks them, and the next start continues them.

  • Drain (grace). Nothing starts, and a running turn sends no new request and starts no new call. A model call that is already streaming runs to its end. If that answer ends the turn, the turn finishes. Otherwise the turn parks at its next boundary, after the answer and every call already running have committed. Calls the answer made that had not started get {error: "daemon_shutdown", detail: "...did not run"}.
    • What the drain covers:
      • every model request, first attempt or retry, summaries included
      • each call a round runs in order
      • each call of a wide parallel batch as it starts
      • a gated call allowed during the drain
      • prompt-cache refreshes
    • A summary running beside the turn's call is skipped, not parked on.
    • How it's checked: each check is one relaxed AtomicBool load. Turn.stopping is the service's draining, which is now an Arc<AtomicBool>.
  • Cut (grace over, no grace, or a signal). Whatever still runs parks as a pull parks it. The reply being written is dropped and asked for again. Each open call gets daemon_shutdown: one cut off while running says "may have had effects. It is not run again", and its tool_completed says outcome_unknown. One that never started is cancelled. Nothing is rerun. A pause now reports the same flags.
  • Next start. It continues those turns as capacity allows, with no resume needed. turn_paced and the turn view's waiting_on say {resume_at_ms: null, stopped: true}. Downtime is not counted in paced_ms, as with a pause. A model call's retry count starts over.
  • Open waits. A client's open wait is answered the way its deadline would answer it: the parked turn is reported pending, as it stands. Before, the turn ending answered the wait. A parked turn never ends, so without this the wait would go silent.
  • Fatal errors. Only a planned stop parks. A daemon that exits on a fatal error ends its running turns process_interrupted, as a crash would, and leaves its waits unanswered. Crash continuation (step 2 of the design) is not part of this.
  • One park for both halts. suspend_pulled becomes suspend_halted(turn, Halt::{Pause, Shutdown}, ...), and the waiting record's pulled flag becomes halt: "pause" | "shutdown". Schema 74 migrates held pull parks. Protocol 36.
  • Sonny says "Stopped" for such a turn, and sonny/FEATURES.md has a new row for it.
  • No flag. A caller that wants turns ended instead of parked interrupts them before stopping.

The grace-end park comes from the day-five review thread's commit: Halt, the daemon_shutdown results and the updated shutdown tests. That thread handed it over so it isn't built twice.

Keeping the daemon fast and light

  • Nothing new blocks the runtime thread. The park is the pull cord's one store job.
  • A parked turn holds no task, slot or timer. On restart it is one wake entry due now, as a pool park is.
  • The hot path gains one relaxed atomic load per round boundary, model request and tool call. A turn that isn't stopping gets no new store jobs.
  • docs/DAEMON_MEASUREMENTS.md records a matched screen against the base, run the way the Perf workflow runs it. Store work per turn is unchanged, and no timing reaches the warning threshold.

Upgrade note

The first upgrade onto this release still runs the old daemon's code, so turns running then still end. From the next upgrade on, they park.

Tests

  • New runtime tests. A drain:

    • starts none of the calls the model returned
    • lets a running command commit its result, then parks
    • starts no more of a wide parallel batch
    • doesn't start a call allowed during it
    • sends no retry of a failed model call
    • sends no cache refresh while a command finishes

    In each case the next start continues the turn.

  • Updated runtime and CLI tests:

    • A stdio or socket shutdown, or a grace expiry, parks the turn, and the open wait is answered pending.
    • A fatal storage failure still ends turns interrupted.
  • Rust:

    • A turn with stopping set parks before any call.
    • The store contract covers the schema 73→74 migration, plus the outcome_unknown / cancelled flags for both halts.
  • Results: CI (Test, Perf) is green.

…ues them

`shutdown` with a grace, and the upgrade path that uses one, now drain:
nothing starts, and each running turn starts no further model call or
tool call and parks at its next boundary, once its model's answer and the
calls already running have committed. Calls that answer made and had not
started are answered `daemon_shutdown`, saying they did not run. What
still runs when the daemon exits (the grace passed, no grace, SIGTERM or
SIGINT) parks as the pull cord parks it: the reply it was writing is asked
for again, each open call is answered `daemon_shutdown` (it may have had
effects), and none is run again. The next start continues those turns as
capacity allows, with no `resume`; `turn_paced` and the turn view's
`waiting_on` say `{resume_at_ms: null, stopped: true}`, and the time down
is not counted as pacing. A client's open `wait` is answered as its
deadline would answer it. Before, every running turn ended interrupted.

Only a planned stop parks: a daemon that exits on a fatal error ends its
running turns `process_interrupted`, as a crash would.

One park serves both halts: `suspend_halted` with `Halt::{Pause,
Shutdown}`, and the waiting record's `pulled` flag becomes
`halt: "pause" | "shutdown"` (schema 74 migrates held parks). Protocol 36.
Sonny says "Stopped" for such a turn.

The grace-end park is from the day-five review thread's commit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGGvnSZrwvDfwKJ5KBN
@lydakis lydakis self-assigned this Oct 31, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T00:41:43.492350Z dab94d1 New commits
🔒 Security Review ✅ Completed 2026-10-31T23:04:46.724907Z d77a9e4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d77a9e4246

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/server/turn.rs Resolved
Comment thread src/server/turn.rs Resolved
Comment thread src/server/turn.rs Resolved
…e rest of a wide batch

A summary that ran as the stop began no longer leads into the call it was
for, and a batch of commands wider than its width starts none of its later
calls once the daemon is stopping; those are answered as not run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGGvnSZrwvDfwKJ5KBN

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fdac81989f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/server/turn.rs Resolved
Comment thread src/store/db.rs Resolved
…lt cut off says its outcome is unknown

The verdict wait checks the stopping flag before it starts the call, so an
answer that lands during the grace leaves the call for the park to close as
not run. A pause or stop that cuts off a running call now marks its
tool_completed outcome_unknown, as its result already says it may have had
effects; a call it never started stays cancelled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGGvnSZrwvDfwKJ5KBN

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 06c7dde53f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/server/turn.rs Resolved
A transient failure, a resend without thinking, or a fallback request no
longer goes out once the daemon is stopping: the call returns
daemon_shutdown, which the turn takes as a drain and parks on. A summary's
call that stops this way parks the turn too, rather than failing the
summary.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGGvnSZrwvDfwKJ5KBN

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 439fa1887c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/server/turn.rs Resolved
A reply or a command still running through the grace no longer refreshes
the last call's cache: no call after it would read the cache before the
next start. A refresh already sent is still billed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGGvnSZrwvDfwKJ5KBN
Comment thread src/store/db.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec73b9ce60

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/server/turn.rs Resolved
Comment thread src/store/db.rs Resolved
lydakis pushed a commit that referenced this pull request Nov 1, 2026
36 is claimed by the open planned-stop PR (#565); whichever merges
second takes the next number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA
lydakis pushed a commit that referenced this pull request Nov 1, 2026
36 is the planned-stop PR's (#565) and 37 the day-five command rules';
whichever merges later takes the next free number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA
…he call stops quietly

call_with checks the stopping flag before every request, the first
included, so a summary that loops to a standalone request after its copy
failed sends none either. A summary at the boundary parks the turn; one
running beside the turn's call is skipped, left for a later boundary,
rather than parking a turn whose call already answered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGGvnSZrwvDfwKJ5KBN
@lydakis
lydakis merged commit 3f59bfb into main Nov 1, 2026
10 checks passed
lydakis added a commit that referenced this pull request Nov 1, 2026
… lookout (#570)

* Daemon: reads that decide nothing run beside the service loop, on a reader pool

Observation reads (history_nodes, history_items, history_search, turns,
bots, events, usage, prompts) used to run inside the service loop, on one
reader connection. A deep history read or a search across every bot held
every other session's submit, interrupt or pause behind it, and every
read waited behind every other read.

They now run in an observation lane beside the loop, as Kubernetes' API
Priority and Fairness gives a priority level its own seats. The store
has a pool of WAL reader connections (--max-readers, one per logical
CPU by default). Observation reads take all but one of them, waiting in
the order they came, so a turn's own reads always find one free. A
session waits for its read before its next request is taken (the input
queue parks it), so a session's own requests keep their order.

events moves from the writer to a reader. usage and history_search,
which spawned a task each, now go through the lane and are bounded by it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: parked sessions hold back their readers; each reads at most 8 ahead

Measured: sessions parked on reads kept the input queue full, so another
session's next request waited for room. A session now reads at most an
eighth of the queue ahead, and no further than its next request while it
waits on a read. A read's answer is written in its own task, not in the
service loop. Observation reads leave one reader for turns' own reads.
bench/fair_queuing.py floods history and searches from several sessions
over deep histories; the Perf screen is in docs/DAEMON_MEASUREMENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Give a parked session's read-ahead back to the shared input queue

A session parked behind an observation read kept the room its queued
requests held, so enough parked sessions could fill the queue and hold
new connections and other clients' requests until a read finished.
Parking now hands those slots back, and a parked session reads nothing
more until it is answered; what it read ahead is taken uncharged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Let a parked session read on to its share, uncharged

A parked session's reader stopped at its next request, so lease
renewals behind it went unread until the observation was answered.
It now reads on to its share while parked, and what it queues then
takes no room, so renewals stay readable and the shared queue stays
free. The fair-queuing bench gives each flooder its own bots to create
and delete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Bound history traversal with skip pointers and history pages by bytes (#472)

Each node gets a narrow lineage row (parent, depth, a skip pointer
chosen as Bitcoin Core's block index chooses pskip, and its turn's
start), written with the node. Checking that a node is in a bot's
lineage, finding where an oldest-first page starts, validating a
history_items batch, and naming a page's turn now take O(log n) point
lookups rather than a walk over the history. A history_nodes page
stops at 256 KiB sent and continues from next_from, or next_newer
oldest first. Schema 72 places every existing node when a store opens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the hot-path screens for skip pointers

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: replay pages come from the reader pool, with no subscription lock held

A follow catching up from an early cursor used to read every page as a job
on the storage worker while holding its subscription's lock, so one client
replaying a long history put hundreds of reads ahead of every write. Pages
now come from the reader pool behind the observation seats (all but one
reader across every replay). Only the switch to live stays on the worker,
as one job that reads at most one event and either marks the follow live or
sends the replay back for another page, so nothing committed between the
modes is lost.

bench/fair_queuing.py gains a follow flood: 16 whole-store replays move the
probe's p95 from about 40 ms to about 15 ms and finish about 20% sooner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: terminals and detached commands share one lasting-process cap

A terminal spawned its PTY and shell with no slot at all, bounded only by
16 per bot, and terminals outlive turns, so nothing bounded them
daemon-wide. Terminals and detached commands now share --max-lasting (4
per logical CPU, replacing --max-detached), as a systemd slice holds a
service's processes. A terminal takes its permit before it spawns and keeps
it until its whole session is gone; a full cap answers lasting_limit,
naming how many terminals and detached commands hold it. A bot at its 16
terminals ends its least recently used before the next starts, so that
permit is free for it.

From #328: a kill now ends every process group in the terminal's session
(the foreground job via tcgetpgrp, the rest from /proc on Linux and the
process list on macOS), so a job that a shell with job control started and
that ignores SIGHUP no longer outlives its terminal. A secret field's name
cut off at the end of a read now waits with its value for the next one, so
the value is redacted whole.

Protocol 35: ready's limits report lasting in place of detached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: a sandboxed bot's socket listens while its turns or commands do

Each sandboxed bot's own socket was bound on its first command and kept,
with its accept task, until the bot was deleted, so every bot that ever ran
a sandboxed command held a listening descriptor forever: past macOS's
default 256-descriptor limit long before 10,000 bots. Opening it now hands
out a share, held by the turn's policy and by every running command's
sandbox hold (foreground, background, detached, terminal), as a refcounted
handle or systemd's socket activation keeps a unit's socket. Thirty seconds
after the last share goes it closes; a share taken again in that time
keeps the same listener, and accepted connections keep their sessions.
Deleting the bot still closes it at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Replay pages share the lane's reader seats; the switch reports its own pruning

Codex review: replay pages and observation reads each took all but one
reader, so together they could fill every reader ahead of turns' own reads.
They now share the lane's seats. The switch to live reads at a later point
than the empty page did, so a deletion in between could prune events past
the cursor: its own retention notice is the one reported. The bench raises
when a flood fails instead of writing a clean result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A replay page's seat goes with its read, so a cancelled replay keeps it until the read is done

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal polls past the bot's hold park their turn, as wait does

An empty write_stdin waits live for the bot's approval_hold_ms, then
parks its turn on the terminal's handle until the command ends or the
poll's time runs out, holding no task and no active slot. The resumed
turn reads what the terminal wrote meanwhile. A steer waiting for the
boundary keeps the poll live.

Closes #324

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: request lines are read on credit from one byte budget

Every session's reader takes credit before it reads: a line's first 4 KiB
from the budget or a reserve kept for short lines, and a line that goes on
waits for credit for the longest line at once, so readers never each hold
part of what they need. The request gives it back once the service takes
it up. --max-input-bytes, a sixteenth of physical memory by default (at
least 64 MiB), 0 unbounded; ready reports limits.input_bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: tool_processes is one total, three quarters for the tool host and a quarter for the lookout

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminals show a secret field's name at once and redact its value after it

A prompt such as `Password: ` was held back with the value it waits
for, so a program asking for one never showed its prompt. Only the
value is held now; the name and separator are shown, and kept so the
next read is redacted as read after them, at a command's end too.
A field's name is matched by bytes, so one in any script no longer
panics the read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal start waits on the one it pruned only when every slot is taken

Pruning a bot's least recently used terminal waited up to 2 s for it to
go on every start past the bot's share, inside the active turn. A start
now takes a free lasting slot at once; only when none is free does it
wait, bounded, for the pruned terminal's, a moment after its kill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the lasting-process cap's perf screen and a terminal read timing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sandbox sockets close from one daemon-wide schedule, off the runtime thread

A last share's drop spawned a task and a 30 s timer per bot, and the
expiry unlinked the socket on the runtime thread. Drops now queue their
deadline in one schedule, in order since every grace is the same; one
task sleeps until the first, and checks and unlinks the ended ones off
the runtime thread under the lock an open takes. A detached command's
share is kept until its whole process group is gone, not only its
launcher.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the socket shares' perf screen; a test's process may go between open and read

test_served's running() caught a stat file that vanished before its open
but not a process that went between the open and the read, which reads
as ESRCH: the turn-interrupt test failed on a setup process that had
just been reaped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal stays readable with its end until its result is recorded

A terminal used to leave the registry as it ended, before its handle's
result reached the store. A parked poll that woke on its deadline in
between found neither, and failed terminal_not_running. The terminal
now stays, its end held, until the result is recorded; a poll or a
write in between reads the end. An ended terminal no longer counts
toward its bot's share, and a write to one types nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal contract tests let an ended terminal go as its result is recorded

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the terminal polls' perf screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 37: ready reports limits.input_bytes

36 is claimed by the open planned-stop PR (#565); whichever merges
second takes the next number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 38: 37 is claimed by the day-five command rules

36 is the planned-stop PR's (#565) and 37 the day-five command rules';
whichever merges later takes the next free number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the ingress credits' perf screen on the ordinary request path

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

---------

Co-authored-by: Claude <[email protected]>
lydakis added a commit that referenced this pull request Nov 1, 2026
* Daemon: reads that decide nothing run beside the service loop, on a reader pool

Observation reads (history_nodes, history_items, history_search, turns,
bots, events, usage, prompts) used to run inside the service loop, on one
reader connection. A deep history read or a search across every bot held
every other session's submit, interrupt or pause behind it, and every
read waited behind every other read.

They now run in an observation lane beside the loop, as Kubernetes' API
Priority and Fairness gives a priority level its own seats. The store
has a pool of WAL reader connections (--max-readers, one per logical
CPU by default). Observation reads take all but one of them, waiting in
the order they came, so a turn's own reads always find one free. A
session waits for its read before its next request is taken (the input
queue parks it), so a session's own requests keep their order.

events moves from the writer to a reader. usage and history_search,
which spawned a task each, now go through the lane and are bounded by it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: parked sessions hold back their readers; each reads at most 8 ahead

Measured: sessions parked on reads kept the input queue full, so another
session's next request waited for room. A session now reads at most an
eighth of the queue ahead, and no further than its next request while it
waits on a read. A read's answer is written in its own task, not in the
service loop. Observation reads leave one reader for turns' own reads.
bench/fair_queuing.py floods history and searches from several sessions
over deep histories; the Perf screen is in docs/DAEMON_MEASUREMENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Give a parked session's read-ahead back to the shared input queue

A session parked behind an observation read kept the room its queued
requests held, so enough parked sessions could fill the queue and hold
new connections and other clients' requests until a read finished.
Parking now hands those slots back, and a parked session reads nothing
more until it is answered; what it read ahead is taken uncharged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Let a parked session read on to its share, uncharged

A parked session's reader stopped at its next request, so lease
renewals behind it went unread until the observation was answered.
It now reads on to its share while parked, and what it queues then
takes no room, so renewals stay readable and the shared queue stays
free. The fair-queuing bench gives each flooder its own bots to create
and delete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Bound history traversal with skip pointers and history pages by bytes (#472)

Each node gets a narrow lineage row (parent, depth, a skip pointer
chosen as Bitcoin Core's block index chooses pskip, and its turn's
start), written with the node. Checking that a node is in a bot's
lineage, finding where an oldest-first page starts, validating a
history_items batch, and naming a page's turn now take O(log n) point
lookups rather than a walk over the history. A history_nodes page
stops at 256 KiB sent and continues from next_from, or next_newer
oldest first. Schema 72 places every existing node when a store opens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the hot-path screens for skip pointers

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: replay pages come from the reader pool, with no subscription lock held

A follow catching up from an early cursor used to read every page as a job
on the storage worker while holding its subscription's lock, so one client
replaying a long history put hundreds of reads ahead of every write. Pages
now come from the reader pool behind the observation seats (all but one
reader across every replay). Only the switch to live stays on the worker,
as one job that reads at most one event and either marks the follow live or
sends the replay back for another page, so nothing committed between the
modes is lost.

bench/fair_queuing.py gains a follow flood: 16 whole-store replays move the
probe's p95 from about 40 ms to about 15 ms and finish about 20% sooner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: terminals and detached commands share one lasting-process cap

A terminal spawned its PTY and shell with no slot at all, bounded only by
16 per bot, and terminals outlive turns, so nothing bounded them
daemon-wide. Terminals and detached commands now share --max-lasting (4
per logical CPU, replacing --max-detached), as a systemd slice holds a
service's processes. A terminal takes its permit before it spawns and keeps
it until its whole session is gone; a full cap answers lasting_limit,
naming how many terminals and detached commands hold it. A bot at its 16
terminals ends its least recently used before the next starts, so that
permit is free for it.

From #328: a kill now ends every process group in the terminal's session
(the foreground job via tcgetpgrp, the rest from /proc on Linux and the
process list on macOS), so a job that a shell with job control started and
that ignores SIGHUP no longer outlives its terminal. A secret field's name
cut off at the end of a read now waits with its value for the next one, so
the value is redacted whole.

Protocol 35: ready's limits report lasting in place of detached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: a sandboxed bot's socket listens while its turns or commands do

Each sandboxed bot's own socket was bound on its first command and kept,
with its accept task, until the bot was deleted, so every bot that ever ran
a sandboxed command held a listening descriptor forever: past macOS's
default 256-descriptor limit long before 10,000 bots. Opening it now hands
out a share, held by the turn's policy and by every running command's
sandbox hold (foreground, background, detached, terminal), as a refcounted
handle or systemd's socket activation keeps a unit's socket. Thirty seconds
after the last share goes it closes; a share taken again in that time
keeps the same listener, and accepted connections keep their sessions.
Deleting the bot still closes it at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Replay pages share the lane's reader seats; the switch reports its own pruning

Codex review: replay pages and observation reads each took all but one
reader, so together they could fill every reader ahead of turns' own reads.
They now share the lane's seats. The switch to live reads at a later point
than the empty page did, so a deletion in between could prune events past
the cursor: its own retention notice is the one reported. The bench raises
when a flood fails instead of writing a clean result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A replay page's seat goes with its read, so a cancelled replay keeps it until the read is done

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal polls past the bot's hold park their turn, as wait does

An empty write_stdin waits live for the bot's approval_hold_ms, then
parks its turn on the terminal's handle until the command ends or the
poll's time runs out, holding no task and no active slot. The resumed
turn reads what the terminal wrote meanwhile. A steer waiting for the
boundary keeps the poll live.

Closes #324

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: request lines are read on credit from one byte budget

Every session's reader takes credit before it reads: a line's first 4 KiB
from the budget or a reserve kept for short lines, and a line that goes on
waits for credit for the longest line at once, so readers never each hold
part of what they need. The request gives it back once the service takes
it up. --max-input-bytes, a sixteenth of physical memory by default (at
least 64 MiB), 0 unbounded; ready reports limits.input_bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: tool_processes is one total, three quarters for the tool host and a quarter for the lookout

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: large tool output is redacted on a blocking thread

A command's or a fetched page's output over 64 KiB is redacted with
spawn_blocking, under a byte budget of two of the largest results per
logical CPU, instead of on the runtime's thread (8 ms a MiB measured).

Closes #316

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminals show a secret field's name at once and redact its value after it

A prompt such as `Password: ` was held back with the value it waits
for, so a program asking for one never showed its prompt. Only the
value is held now; the name and separator are shown, and kept so the
next read is redacted as read after them, at a command's end too.
A field's name is matched by bytes, so one in any script no longer
panics the read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal start waits on the one it pruned only when every slot is taken

Pruning a bot's least recently used terminal waited up to 2 s for it to
go on every start past the bot's share, inside the active turn. A start
now takes a free lasting slot at once; only when none is free does it
wait, bounded, for the pruned terminal's, a moment after its kill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the lasting-process cap's perf screen and a terminal read timing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sandbox sockets close from one daemon-wide schedule, off the runtime thread

A last share's drop spawned a task and a 30 s timer per bot, and the
expiry unlinked the socket on the runtime thread. Drops now queue their
deadline in one schedule, in order since every grace is the same; one
task sleeps until the first, and checks and unlinks the ended ones off
the runtime thread under the lock an open takes. A detached command's
share is kept until its whole process group is gone, not only its
launcher.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the socket shares' perf screen; a test's process may go between open and read

test_served's running() caught a stat file that vanished before its open
but not a process that went between the open and the read, which reads
as ESRCH: the turn-interrupt test failed on a setup process that had
just been reaped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal stays readable with its end until its result is recorded

A terminal used to leave the registry as it ended, before its handle's
result reached the store. A parked poll that woke on its deadline in
between found neither, and failed terminal_not_running. The terminal
now stays, its end held, until the result is recorded; a poll or a
write in between reads the end. An ended terminal no longer counts
toward its bot's share, and a write to one types nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal contract tests let an ended terminal go as its result is recorded

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the terminal polls' perf screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 37: ready reports limits.input_bytes

36 is claimed by the open planned-stop PR (#565); whichever merges
second takes the next number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 38: 37 is claimed by the day-five command rules

36 is the planned-stop PR's (#565) and 37 the day-five command rules';
whichever merges later takes the next free number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the ingress credits' perf screen on the ordinary request path

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: redaction waits without the process budget, and reads credentials without the lock

A finished command lets its process slot and sandbox hold go before its output waits for redaction, so a burst of large results never keeps small commands from starting. Credentials are an Arc set behind the lock: a scan takes the current set and lets go, and a refresh copies the set if a scan still reads it, so a long scan on a blocking thread never holds up a refresh on the runtime's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: bots filters by maker, and Sonny's task count reads only its own

bots takes created_by_id, kept by a partial index on (created_by_id, name), so a page costs the maker's own children however many bots the store holds; it combines with name and active. An id, not a name, so a maker that reuses a name sees none of an earlier one's. agent ls --created-by BOT. Sonny without a fleet view asks for its own running tasks instead of every running bot every three seconds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Measurements: the matched screen for redaction off the runtime

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Perf: the screen runs on Sonny and client changes, with Sonny's own scenarios

bench.sonny_screen: the lookout at 10, 100 and 1,000 subscribers; one quiet lead's window in a pseudo-terminal while 1,000 tasks elsewhere run turns, with what it asks the daemon counted on a socket in front of the daemon's; and a sky replay of the hour at its fastest speed. perf.yml builds Sonny for both sides and runs it on sonny/** and client/**; perf_gate compares it, warning only, as for the daemon's timings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Measurements: a blank line before the window's section

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: refuse a run whose window exited or drew nothing

An exited Sonny costs no CPU and no memory, so a window that crashed
as it opened or under load would read as a fast one. The screen now
checks the program is up and has drawn before and after each sampled
stretch, and fails the run with the last of its screen otherwise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: absolute output, refuse a dead lookout, footer test by maker

The perf job passes a relative --out, which the bots' workspaces
refuse; it is resolved first. A lookout that exited as it started or
under load now fails the run instead of reading as a cheap one. The
footer test asks the daemon for this agent's tasks by its id, as the
footer now does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Perf gate: a side that told no note shows none, not a delay of zero

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: the sky's cost runs from its start until the hour has played

A fixed sleep could end before a slow replay had read its history in,
so a slower revision would replay less and read as cheaper. The screen
now keeps what the terminal shows (pyte, a measurement dependency) and
waits for the replay's footer: ready once it stops reading, done once
512x has caught up with now, refusing the run past a limit. The
result says how long each took.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: the sky's CPU per thousand lines the daemon sent

The fleet's hour holds as many turns as the daemon ran in the time
given, so two revisions replay different histories. The replay now
goes through a counting socket too, and the gate compares its CPU per
thousand lines read rather than in total; a replay that read nothing
is refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 40: 39 went to the command rules; record the matched screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Store: the maker filter takes a fixed number, so the plan audit sees it

bench.query_plans plans every variant of a listing from its named
clauses; numbering the parameters as they were bound left braces it
could not fill. The filters now take ?3 and ?4, a maker without a name
binding ?3 as NULL, and the audit plans all eight variants of `bots`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

---------

Co-authored-by: Claude <[email protected]>
lydakis added a commit that referenced this pull request Nov 1, 2026
…ds (#575)

* Daemon: reads that decide nothing run beside the service loop, on a reader pool

Observation reads (history_nodes, history_items, history_search, turns,
bots, events, usage, prompts) used to run inside the service loop, on one
reader connection. A deep history read or a search across every bot held
every other session's submit, interrupt or pause behind it, and every
read waited behind every other read.

They now run in an observation lane beside the loop, as Kubernetes' API
Priority and Fairness gives a priority level its own seats. The store
has a pool of WAL reader connections (--max-readers, one per logical
CPU by default). Observation reads take all but one of them, waiting in
the order they came, so a turn's own reads always find one free. A
session waits for its read before its next request is taken (the input
queue parks it), so a session's own requests keep their order.

events moves from the writer to a reader. usage and history_search,
which spawned a task each, now go through the lane and are bounded by it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: parked sessions hold back their readers; each reads at most 8 ahead

Measured: sessions parked on reads kept the input queue full, so another
session's next request waited for room. A session now reads at most an
eighth of the queue ahead, and no further than its next request while it
waits on a read. A read's answer is written in its own task, not in the
service loop. Observation reads leave one reader for turns' own reads.
bench/fair_queuing.py floods history and searches from several sessions
over deep histories; the Perf screen is in docs/DAEMON_MEASUREMENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Give a parked session's read-ahead back to the shared input queue

A session parked behind an observation read kept the room its queued
requests held, so enough parked sessions could fill the queue and hold
new connections and other clients' requests until a read finished.
Parking now hands those slots back, and a parked session reads nothing
more until it is answered; what it read ahead is taken uncharged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Let a parked session read on to its share, uncharged

A parked session's reader stopped at its next request, so lease
renewals behind it went unread until the observation was answered.
It now reads on to its share while parked, and what it queues then
takes no room, so renewals stay readable and the shared queue stays
free. The fair-queuing bench gives each flooder its own bots to create
and delete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Bound history traversal with skip pointers and history pages by bytes (#472)

Each node gets a narrow lineage row (parent, depth, a skip pointer
chosen as Bitcoin Core's block index chooses pskip, and its turn's
start), written with the node. Checking that a node is in a bot's
lineage, finding where an oldest-first page starts, validating a
history_items batch, and naming a page's turn now take O(log n) point
lookups rather than a walk over the history. A history_nodes page
stops at 256 KiB sent and continues from next_from, or next_newer
oldest first. Schema 72 places every existing node when a store opens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the hot-path screens for skip pointers

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: replay pages come from the reader pool, with no subscription lock held

A follow catching up from an early cursor used to read every page as a job
on the storage worker while holding its subscription's lock, so one client
replaying a long history put hundreds of reads ahead of every write. Pages
now come from the reader pool behind the observation seats (all but one
reader across every replay). Only the switch to live stays on the worker,
as one job that reads at most one event and either marks the follow live or
sends the replay back for another page, so nothing committed between the
modes is lost.

bench/fair_queuing.py gains a follow flood: 16 whole-store replays move the
probe's p95 from about 40 ms to about 15 ms and finish about 20% sooner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: terminals and detached commands share one lasting-process cap

A terminal spawned its PTY and shell with no slot at all, bounded only by
16 per bot, and terminals outlive turns, so nothing bounded them
daemon-wide. Terminals and detached commands now share --max-lasting (4
per logical CPU, replacing --max-detached), as a systemd slice holds a
service's processes. A terminal takes its permit before it spawns and keeps
it until its whole session is gone; a full cap answers lasting_limit,
naming how many terminals and detached commands hold it. A bot at its 16
terminals ends its least recently used before the next starts, so that
permit is free for it.

From #328: a kill now ends every process group in the terminal's session
(the foreground job via tcgetpgrp, the rest from /proc on Linux and the
process list on macOS), so a job that a shell with job control started and
that ignores SIGHUP no longer outlives its terminal. A secret field's name
cut off at the end of a read now waits with its value for the next one, so
the value is redacted whole.

Protocol 35: ready's limits report lasting in place of detached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: a sandboxed bot's socket listens while its turns or commands do

Each sandboxed bot's own socket was bound on its first command and kept,
with its accept task, until the bot was deleted, so every bot that ever ran
a sandboxed command held a listening descriptor forever: past macOS's
default 256-descriptor limit long before 10,000 bots. Opening it now hands
out a share, held by the turn's policy and by every running command's
sandbox hold (foreground, background, detached, terminal), as a refcounted
handle or systemd's socket activation keeps a unit's socket. Thirty seconds
after the last share goes it closes; a share taken again in that time
keeps the same listener, and accepted connections keep their sessions.
Deleting the bot still closes it at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Replay pages share the lane's reader seats; the switch reports its own pruning

Codex review: replay pages and observation reads each took all but one
reader, so together they could fill every reader ahead of turns' own reads.
They now share the lane's seats. The switch to live reads at a later point
than the empty page did, so a deletion in between could prune events past
the cursor: its own retention notice is the one reported. The bench raises
when a flood fails instead of writing a clean result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A replay page's seat goes with its read, so a cancelled replay keeps it until the read is done

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal polls past the bot's hold park their turn, as wait does

An empty write_stdin waits live for the bot's approval_hold_ms, then
parks its turn on the terminal's handle until the command ends or the
poll's time runs out, holding no task and no active slot. The resumed
turn reads what the terminal wrote meanwhile. A steer waiting for the
boundary keeps the poll live.

Closes #324

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: request lines are read on credit from one byte budget

Every session's reader takes credit before it reads: a line's first 4 KiB
from the budget or a reserve kept for short lines, and a line that goes on
waits for credit for the longest line at once, so readers never each hold
part of what they need. The request gives it back once the service takes
it up. --max-input-bytes, a sixteenth of physical memory by default (at
least 64 MiB), 0 unbounded; ready reports limits.input_bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: tool_processes is one total, three quarters for the tool host and a quarter for the lookout

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: large tool output is redacted on a blocking thread

A command's or a fetched page's output over 64 KiB is redacted with
spawn_blocking, under a byte budget of two of the largest results per
logical CPU, instead of on the runtime's thread (8 ms a MiB measured).

Closes #316

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminals show a secret field's name at once and redact its value after it

A prompt such as `Password: ` was held back with the value it waits
for, so a program asking for one never showed its prompt. Only the
value is held now; the name and separator are shown, and kept so the
next read is redacted as read after them, at a command's end too.
A field's name is matched by bytes, so one in any script no longer
panics the read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal start waits on the one it pruned only when every slot is taken

Pruning a bot's least recently used terminal waited up to 2 s for it to
go on every start past the bot's share, inside the active turn. A start
now takes a free lasting slot at once; only when none is free does it
wait, bounded, for the pruned terminal's, a moment after its kill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the lasting-process cap's perf screen and a terminal read timing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sandbox sockets close from one daemon-wide schedule, off the runtime thread

A last share's drop spawned a task and a 30 s timer per bot, and the
expiry unlinked the socket on the runtime thread. Drops now queue their
deadline in one schedule, in order since every grace is the same; one
task sleeps until the first, and checks and unlinks the ended ones off
the runtime thread under the lock an open takes. A detached command's
share is kept until its whole process group is gone, not only its
launcher.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the socket shares' perf screen; a test's process may go between open and read

test_served's running() caught a stat file that vanished before its open
but not a process that went between the open and the read, which reads
as ESRCH: the turn-interrupt test failed on a setup process that had
just been reaped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal stays readable with its end until its result is recorded

A terminal used to leave the registry as it ended, before its handle's
result reached the store. A parked poll that woke on its deadline in
between found neither, and failed terminal_not_running. The terminal
now stays, its end held, until the result is recorded; a poll or a
write in between reads the end. An ended terminal no longer counts
toward its bot's share, and a write to one types nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal contract tests let an ended terminal go as its result is recorded

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the terminal polls' perf screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 37: ready reports limits.input_bytes

36 is claimed by the open planned-stop PR (#565); whichever merges
second takes the next number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 38: 37 is claimed by the day-five command rules

36 is the planned-stop PR's (#565) and 37 the day-five command rules';
whichever merges later takes the next free number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the ingress credits' perf screen on the ordinary request path

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: redaction waits without the process budget, and reads credentials without the lock

A finished command lets its process slot and sandbox hold go before its output waits for redaction, so a burst of large results never keeps small commands from starting. Credentials are an Arc set behind the lock: a scan takes the current set and lets go, and a refresh copies the set if a scan still reads it, so a long scan on a blocking thread never holds up a refresh on the runtime's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: bots filters by maker, and Sonny's task count reads only its own

bots takes created_by_id, kept by a partial index on (created_by_id, name), so a page costs the maker's own children however many bots the store holds; it combines with name and active. An id, not a name, so a maker that reuses a name sees none of an earlier one's. agent ls --created-by BOT. Sonny without a fleet view asks for its own running tasks instead of every running bot every three seconds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Measurements: the matched screen for redaction off the runtime

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Perf: the screen runs on Sonny and client changes, with Sonny's own scenarios

bench.sonny_screen: the lookout at 10, 100 and 1,000 subscribers; one quiet lead's window in a pseudo-terminal while 1,000 tasks elsewhere run turns, with what it asks the daemon counted on a socket in front of the daemon's; and a sky replay of the hour at its fastest speed. perf.yml builds Sonny for both sides and runs it on sonny/** and client/**; perf_gate compares it, warning only, as for the daemon's timings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Measurements: a blank line before the window's section

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: limits from [daemon] formulas, and a load gate for new commands

wip

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: refuse a run whose window exited or drew nothing

An exited Sonny costs no CPU and no memory, so a window that crashed
as it opened or under load would read as a fast one. The screen now
checks the program is up and has drawn before and after each sampled
stretch, and fails the run with the last of its screen otherwise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: absolute output, refuse a dead lookout, footer test by maker

The perf job passes a relative --out, which the bots' workspaces
refuse; it is resolved first. A lookout that exited as it started or
under load now fails the run instead of reading as a cheap one. The
footer test asks the daemon for this agent's tasks by its id, as the
footer now does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Perf gate: a side that told no note shows none, not a delay of zero

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: the sky's cost runs from its start until the hour has played

A fixed sleep could end before a slow replay had read its history in,
so a slower revision would replay less and read as cheaper. The screen
now keeps what the terminal shows (pyte, a measurement dependency) and
waits for the replay's footer: ready once it stops reading, done once
512x has caught up with now, refusing the run past a limit. The
result says how long each took.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: the sky's CPU per thousand lines the daemon sent

The fleet's hour holds as many turns as the daemon ran in the time
given, so two revisions replay different histories. The replay now
goes through a counting socket too, and the gate compares its CPU per
thousand lines read rather than in total; a replay that read nothing
is refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 40: 39 went to the command rules; record the matched screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Store: the maker filter takes a fixed number, so the plan audit sees it

bench.query_plans plans every variant of a listing from its named
clauses; numbering the parameters as they were bound left braces it
could not fill. The filters now take ?3 and ?4, a maker without a name
binding ?3 as NULL, and the audit plans all eight variants of `bots`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* CLI docs: the daemon's limits from [daemon], and the load gate

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Park turns the load gate holds, recheck the gate for a freed slot, check formulas for this machine

A foreground command the load gate holds past 1.5 s now parks its turn
before the call starts, as a verdict park does: one commit, no task, no
active slot, and it survives restart. The turn view's waiting_on carries
load: true. A server task wakes every parked turn when the gate opens, or
the oldest alone on a loaded machine where none of the daemon's commands
runs, and reads the store only after a turn parks.

A background command waiting at the gate takes a freed slot only if the
gate still admits it, so a burst cannot pass the gate together.

[daemon] formulas are worked out for this machine when the file is read,
so one below 0 here is config_invalid then rather than at a daemon start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: a parallel batch is let in or held whole

A round's calls that run together were checked against the load gate by
their first alone, so a read ahead of shell calls let the commands start
on a loaded machine. The batch is now formed first and parked whole,
none of it started, when the gate holds any command in it; the park
names the command it holds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 42: 41 went to configure's settings (#574)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: waiters go in order, forbidden commands are refused at once, and the matched screen

Background commands waiting at a shut gate now hold a fair line, and the
queue's fast path takes a free slot only while nobody waits in it, so a
newcomer between two readings cannot take the slot ahead of an older
waiter. A command its rules forbid is refused rather than held, since it
starts nothing. DAEMON_MEASUREMENTS records the Perf workflow's matched
screen of the branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: only a command that would start now is held; a small load limit stays one

The gate held every foreground shell call before the turn looked at its
verdict or its rules, so a denial, a forbidden command, one a rule asks
about with no gate, or an escape no gate allows sat parked until the
load fell. Now only a call that would start at once is held; a gated
call waits for its verdict instead and starts once allowed. A `[daemon]
load` below 0.005 was rounded to 0, which is no gate; it is passed whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

---------

Co-authored-by: Claude <[email protected]>
lydakis added a commit that referenced this pull request Nov 1, 2026
…ntly used (#591)

* Daemon: reads that decide nothing run beside the service loop, on a reader pool

Observation reads (history_nodes, history_items, history_search, turns,
bots, events, usage, prompts) used to run inside the service loop, on one
reader connection. A deep history read or a search across every bot held
every other session's submit, interrupt or pause behind it, and every
read waited behind every other read.

They now run in an observation lane beside the loop, as Kubernetes' API
Priority and Fairness gives a priority level its own seats. The store
has a pool of WAL reader connections (--max-readers, one per logical
CPU by default). Observation reads take all but one of them, waiting in
the order they came, so a turn's own reads always find one free. A
session waits for its read before its next request is taken (the input
queue parks it), so a session's own requests keep their order.

events moves from the writer to a reader. usage and history_search,
which spawned a task each, now go through the lane and are bounded by it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: parked sessions hold back their readers; each reads at most 8 ahead

Measured: sessions parked on reads kept the input queue full, so another
session's next request waited for room. A session now reads at most an
eighth of the queue ahead, and no further than its next request while it
waits on a read. A read's answer is written in its own task, not in the
service loop. Observation reads leave one reader for turns' own reads.
bench/fair_queuing.py floods history and searches from several sessions
over deep histories; the Perf screen is in docs/DAEMON_MEASUREMENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Give a parked session's read-ahead back to the shared input queue

A session parked behind an observation read kept the room its queued
requests held, so enough parked sessions could fill the queue and hold
new connections and other clients' requests until a read finished.
Parking now hands those slots back, and a parked session reads nothing
more until it is answered; what it read ahead is taken uncharged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Let a parked session read on to its share, uncharged

A parked session's reader stopped at its next request, so lease
renewals behind it went unread until the observation was answered.
It now reads on to its share while parked, and what it queues then
takes no room, so renewals stay readable and the shared queue stays
free. The fair-queuing bench gives each flooder its own bots to create
and delete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Bound history traversal with skip pointers and history pages by bytes (#472)

Each node gets a narrow lineage row (parent, depth, a skip pointer
chosen as Bitcoin Core's block index chooses pskip, and its turn's
start), written with the node. Checking that a node is in a bot's
lineage, finding where an oldest-first page starts, validating a
history_items batch, and naming a page's turn now take O(log n) point
lookups rather than a walk over the history. A history_nodes page
stops at 256 KiB sent and continues from next_from, or next_newer
oldest first. Schema 72 places every existing node when a store opens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the hot-path screens for skip pointers

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: replay pages come from the reader pool, with no subscription lock held

A follow catching up from an early cursor used to read every page as a job
on the storage worker while holding its subscription's lock, so one client
replaying a long history put hundreds of reads ahead of every write. Pages
now come from the reader pool behind the observation seats (all but one
reader across every replay). Only the switch to live stays on the worker,
as one job that reads at most one event and either marks the follow live or
sends the replay back for another page, so nothing committed between the
modes is lost.

bench/fair_queuing.py gains a follow flood: 16 whole-store replays move the
probe's p95 from about 40 ms to about 15 ms and finish about 20% sooner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: terminals and detached commands share one lasting-process cap

A terminal spawned its PTY and shell with no slot at all, bounded only by
16 per bot, and terminals outlive turns, so nothing bounded them
daemon-wide. Terminals and detached commands now share --max-lasting (4
per logical CPU, replacing --max-detached), as a systemd slice holds a
service's processes. A terminal takes its permit before it spawns and keeps
it until its whole session is gone; a full cap answers lasting_limit,
naming how many terminals and detached commands hold it. A bot at its 16
terminals ends its least recently used before the next starts, so that
permit is free for it.

From #328: a kill now ends every process group in the terminal's session
(the foreground job via tcgetpgrp, the rest from /proc on Linux and the
process list on macOS), so a job that a shell with job control started and
that ignores SIGHUP no longer outlives its terminal. A secret field's name
cut off at the end of a read now waits with its value for the next one, so
the value is redacted whole.

Protocol 35: ready's limits report lasting in place of detached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: a sandboxed bot's socket listens while its turns or commands do

Each sandboxed bot's own socket was bound on its first command and kept,
with its accept task, until the bot was deleted, so every bot that ever ran
a sandboxed command held a listening descriptor forever: past macOS's
default 256-descriptor limit long before 10,000 bots. Opening it now hands
out a share, held by the turn's policy and by every running command's
sandbox hold (foreground, background, detached, terminal), as a refcounted
handle or systemd's socket activation keeps a unit's socket. Thirty seconds
after the last share goes it closes; a share taken again in that time
keeps the same listener, and accepted connections keep their sessions.
Deleting the bot still closes it at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Replay pages share the lane's reader seats; the switch reports its own pruning

Codex review: replay pages and observation reads each took all but one
reader, so together they could fill every reader ahead of turns' own reads.
They now share the lane's seats. The switch to live reads at a later point
than the empty page did, so a deletion in between could prune events past
the cursor: its own retention notice is the one reported. The bench raises
when a flood fails instead of writing a clean result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A replay page's seat goes with its read, so a cancelled replay keeps it until the read is done

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal polls past the bot's hold park their turn, as wait does

An empty write_stdin waits live for the bot's approval_hold_ms, then
parks its turn on the terminal's handle until the command ends or the
poll's time runs out, holding no task and no active slot. The resumed
turn reads what the terminal wrote meanwhile. A steer waiting for the
boundary keeps the poll live.

Closes #324

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: request lines are read on credit from one byte budget

Every session's reader takes credit before it reads: a line's first 4 KiB
from the budget or a reserve kept for short lines, and a line that goes on
waits for credit for the longest line at once, so readers never each hold
part of what they need. The request gives it back once the service takes
it up. --max-input-bytes, a sixteenth of physical memory by default (at
least 64 MiB), 0 unbounded; ready reports limits.input_bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: tool_processes is one total, three quarters for the tool host and a quarter for the lookout

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: large tool output is redacted on a blocking thread

A command's or a fetched page's output over 64 KiB is redacted with
spawn_blocking, under a byte budget of two of the largest results per
logical CPU, instead of on the runtime's thread (8 ms a MiB measured).

Closes #316

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminals show a secret field's name at once and redact its value after it

A prompt such as `Password: ` was held back with the value it waits
for, so a program asking for one never showed its prompt. Only the
value is held now; the name and separator are shown, and kept so the
next read is redacted as read after them, at a command's end too.
A field's name is matched by bytes, so one in any script no longer
panics the read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal start waits on the one it pruned only when every slot is taken

Pruning a bot's least recently used terminal waited up to 2 s for it to
go on every start past the bot's share, inside the active turn. A start
now takes a free lasting slot at once; only when none is free does it
wait, bounded, for the pruned terminal's, a moment after its kill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the lasting-process cap's perf screen and a terminal read timing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sandbox sockets close from one daemon-wide schedule, off the runtime thread

A last share's drop spawned a task and a 30 s timer per bot, and the
expiry unlinked the socket on the runtime thread. Drops now queue their
deadline in one schedule, in order since every grace is the same; one
task sleeps until the first, and checks and unlinks the ended ones off
the runtime thread under the lock an open takes. A detached command's
share is kept until its whole process group is gone, not only its
launcher.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the socket shares' perf screen; a test's process may go between open and read

test_served's running() caught a stat file that vanished before its open
but not a process that went between the open and the read, which reads
as ESRCH: the turn-interrupt test failed on a setup process that had
just been reaped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal stays readable with its end until its result is recorded

A terminal used to leave the registry as it ended, before its handle's
result reached the store. A parked poll that woke on its deadline in
between found neither, and failed terminal_not_running. The terminal
now stays, its end held, until the result is recorded; a poll or a
write in between reads the end. An ended terminal no longer counts
toward its bot's share, and a write to one types nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal contract tests let an ended terminal go as its result is recorded

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the terminal polls' perf screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 37: ready reports limits.input_bytes

36 is claimed by the open planned-stop PR (#565); whichever merges
second takes the next number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 38: 37 is claimed by the day-five command rules

36 is the planned-stop PR's (#565) and 37 the day-five command rules';
whichever merges later takes the next free number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the ingress credits' perf screen on the ordinary request path

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: redaction waits without the process budget, and reads credentials without the lock

A finished command lets its process slot and sandbox hold go before its output waits for redaction, so a burst of large results never keeps small commands from starting. Credentials are an Arc set behind the lock: a scan takes the current set and lets go, and a refresh copies the set if a scan still reads it, so a long scan on a blocking thread never holds up a refresh on the runtime's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: bots filters by maker, and Sonny's task count reads only its own

bots takes created_by_id, kept by a partial index on (created_by_id, name), so a page costs the maker's own children however many bots the store holds; it combines with name and active. An id, not a name, so a maker that reuses a name sees none of an earlier one's. agent ls --created-by BOT. Sonny without a fleet view asks for its own running tasks instead of every running bot every three seconds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Measurements: the matched screen for redaction off the runtime

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Perf: the screen runs on Sonny and client changes, with Sonny's own scenarios

bench.sonny_screen: the lookout at 10, 100 and 1,000 subscribers; one quiet lead's window in a pseudo-terminal while 1,000 tasks elsewhere run turns, with what it asks the daemon counted on a socket in front of the daemon's; and a sky replay of the hour at its fastest speed. perf.yml builds Sonny for both sides and runs it on sonny/** and client/**; perf_gate compares it, warning only, as for the daemon's timings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Measurements: a blank line before the window's section

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: limits from [daemon] formulas, and a load gate for new commands

wip

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: refuse a run whose window exited or drew nothing

An exited Sonny costs no CPU and no memory, so a window that crashed
as it opened or under load would read as a fast one. The screen now
checks the program is up and has drawn before and after each sampled
stretch, and fails the run with the last of its screen otherwise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: absolute output, refuse a dead lookout, footer test by maker

The perf job passes a relative --out, which the bots' workspaces
refuse; it is resolved first. A lookout that exited as it started or
under load now fails the run instead of reading as a cheap one. The
footer test asks the daemon for this agent's tasks by its id, as the
footer now does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Perf gate: a side that told no note shows none, not a delay of zero

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: the sky's cost runs from its start until the hour has played

A fixed sleep could end before a slow replay had read its history in,
so a slower revision would replay less and read as cheaper. The screen
now keeps what the terminal shows (pyte, a measurement dependency) and
waits for the replay's footer: ready once it stops reading, done once
512x has caught up with now, refusing the run past a limit. The
result says how long each took.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: the sky's CPU per thousand lines the daemon sent

The fleet's hour holds as many turns as the daemon ran in the time
given, so two revisions replay different histories. The replay now
goes through a counting socket too, and the gate compares its CPU per
thousand lines read rather than in total; a replay that read nothing
is refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 40: 39 went to the command rules; record the matched screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Store: the maker filter takes a fixed number, so the plan audit sees it

bench.query_plans plans every variant of a listing from its named
clauses; numbering the parameters as they were bound left braces it
could not fill. The filters now take ?3 and ?4, a maker without a name
binding ?3 as NULL, and the audit plans all eight variants of `bots`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* CLI docs: the daemon's limits from [daemon], and the load gate

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Park turns the load gate holds, recheck the gate for a freed slot, check formulas for this machine

A foreground command the load gate holds past 1.5 s now parks its turn
before the call starts, as a verdict park does: one commit, no task, no
active slot, and it survives restart. The turn view's waiting_on carries
load: true. A server task wakes every parked turn when the gate opens, or
the oldest alone on a loaded machine where none of the daemon's commands
runs, and reads the store only after a turn parks.

A background command waiting at the gate takes a freed slot only if the
gate still admits it, so a burst cannot pass the gate together.

[daemon] formulas are worked out for this machine when the file is read,
so one below 0 here is config_invalid then rather than at a daemon start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: a parallel batch is let in or held whole

A round's calls that run together were checked against the load gate by
their first alone, so a read ahead of shell calls let the commands start
on a loaded machine. The batch is now formed first and parked whole,
none of it started, when the gate holds any command in it; the park
names the command it holds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 42: 41 went to configure's settings (#574)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: waiters go in order, forbidden commands are refused at once, and the matched screen

Background commands waiting at a shut gate now hold a fair line, and the
queue's fast path takes a free slot only while nobody waits in it, so a
newcomer between two readings cannot take the slot ahead of an older
waiter. A command its rules forbid is refused rather than held, since it
starts nothing. DAEMON_MEASUREMENTS records the Perf workflow's matched
screen of the branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: only a command that would start now is held; a small load limit stays one

The gate held every foreground shell call before the turn looked at its
verdict or its rules, so a denial, a forbidden command, one a rule asks
about with no gate, or an escape no gate allows sat parked until the
load fell. Now only a call that would start at once is held; a gated
call waits for its verdict instead and starts once allowed. A `[daemon]
load` below 0.005 was rounded to 0, which is no gate; it is passed whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: a lead keeps so many task windows open, closing the least recently used

Past `[sonny] task_windows` (32 by default, 0 for no limit, in /config),
a new task window closes the one the person used least recently, as VS
Code's editor limit does. Each window's own Sonny marks its agent's file
in ~/.agent/sonny/used/ when the person focuses, types or clicks there,
at most once every 10 s; the lead reads those times only when it needs
room. A window whose task needs the person, failed, or holds a block it
asked for is never closed for room. A window closed for room stays
closed while its task works on, and /status opens it again. The limit
is read again on the layout's worker whenever the config file changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: close only the lead's own task windows for room, and keep those their windows say need the person

Two leads of a folder share its multiplexer home, so a lead now counts
and closes only its own tasks' windows. What holds a window is no longer
only what this lead heard since it started: each window's Sonny keeps a
file in ~/.agent/sonny/held/ while its agent failed, waits on an
approval, or has a question open in it, and leaves it for the next
window until its status says otherwise. So a lead started again, which
hears neither old failures nor open questions, still keeps those
windows. The protected set is built in one place (room_for), tested
from a lead's state through to the window it closes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: rustfmt the task window protection

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: a window's held file always ends saying the latest, and a window opened again on a failed agent keeps it

Writes asked one after another run one at a time and each writes what
the window wants now, so an earlier write finishing late cannot undo a
later one. At start, a window with no turn running reports its last
turn's end as live: a failure (not a model that said nothing) is
"error", so its held file stands across a restart of both the window
and its lead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: task windows count by window, and a lead started again still reopens one it closed for room

Tasks shown together (a split beside another task) are one window: they
count once against task_windows, and close together, held whole when any
of them is. A window holding a lead's or another lead's blocks is not a
task window. Which windows a lead closed for room is kept in
~/.agent/sonny/aside/, so /status opens one again after the lead
restarts, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: a cmux task tab counts as its own window against task_windows

Backend::tab says what a window placement opened a block in: the window
for Rex, the tab for Herdr, and the tab itself for cmux, whose task tabs
share the lead's pane.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

---------

Co-authored-by: Claude <[email protected]>
lydakis added a commit that referenced this pull request Nov 1, 2026
…reach their leads in seconds (#616)

* Daemon: reads that decide nothing run beside the service loop, on a reader pool

Observation reads (history_nodes, history_items, history_search, turns,
bots, events, usage, prompts) used to run inside the service loop, on one
reader connection. A deep history read or a search across every bot held
every other session's submit, interrupt or pause behind it, and every
read waited behind every other read.

They now run in an observation lane beside the loop, as Kubernetes' API
Priority and Fairness gives a priority level its own seats. The store
has a pool of WAL reader connections (--max-readers, one per logical
CPU by default). Observation reads take all but one of them, waiting in
the order they came, so a turn's own reads always find one free. A
session waits for its read before its next request is taken (the input
queue parks it), so a session's own requests keep their order.

events moves from the writer to a reader. usage and history_search,
which spawned a task each, now go through the lane and are bounded by it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: parked sessions hold back their readers; each reads at most 8 ahead

Measured: sessions parked on reads kept the input queue full, so another
session's next request waited for room. A session now reads at most an
eighth of the queue ahead, and no further than its next request while it
waits on a read. A read's answer is written in its own task, not in the
service loop. Observation reads leave one reader for turns' own reads.
bench/fair_queuing.py floods history and searches from several sessions
over deep histories; the Perf screen is in docs/DAEMON_MEASUREMENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Give a parked session's read-ahead back to the shared input queue

A session parked behind an observation read kept the room its queued
requests held, so enough parked sessions could fill the queue and hold
new connections and other clients' requests until a read finished.
Parking now hands those slots back, and a parked session reads nothing
more until it is answered; what it read ahead is taken uncharged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Let a parked session read on to its share, uncharged

A parked session's reader stopped at its next request, so lease
renewals behind it went unread until the observation was answered.
It now reads on to its share while parked, and what it queues then
takes no room, so renewals stay readable and the shared queue stays
free. The fair-queuing bench gives each flooder its own bots to create
and delete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Bound history traversal with skip pointers and history pages by bytes (#472)

Each node gets a narrow lineage row (parent, depth, a skip pointer
chosen as Bitcoin Core's block index chooses pskip, and its turn's
start), written with the node. Checking that a node is in a bot's
lineage, finding where an oldest-first page starts, validating a
history_items batch, and naming a page's turn now take O(log n) point
lookups rather than a walk over the history. A history_nodes page
stops at 256 KiB sent and continues from next_from, or next_newer
oldest first. Schema 72 places every existing node when a store opens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the hot-path screens for skip pointers

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: replay pages come from the reader pool, with no subscription lock held

A follow catching up from an early cursor used to read every page as a job
on the storage worker while holding its subscription's lock, so one client
replaying a long history put hundreds of reads ahead of every write. Pages
now come from the reader pool behind the observation seats (all but one
reader across every replay). Only the switch to live stays on the worker,
as one job that reads at most one event and either marks the follow live or
sends the replay back for another page, so nothing committed between the
modes is lost.

bench/fair_queuing.py gains a follow flood: 16 whole-store replays move the
probe's p95 from about 40 ms to about 15 ms and finish about 20% sooner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: terminals and detached commands share one lasting-process cap

A terminal spawned its PTY and shell with no slot at all, bounded only by
16 per bot, and terminals outlive turns, so nothing bounded them
daemon-wide. Terminals and detached commands now share --max-lasting (4
per logical CPU, replacing --max-detached), as a systemd slice holds a
service's processes. A terminal takes its permit before it spawns and keeps
it until its whole session is gone; a full cap answers lasting_limit,
naming how many terminals and detached commands hold it. A bot at its 16
terminals ends its least recently used before the next starts, so that
permit is free for it.

From #328: a kill now ends every process group in the terminal's session
(the foreground job via tcgetpgrp, the rest from /proc on Linux and the
process list on macOS), so a job that a shell with job control started and
that ignores SIGHUP no longer outlives its terminal. A secret field's name
cut off at the end of a read now waits with its value for the next one, so
the value is redacted whole.

Protocol 35: ready's limits report lasting in place of detached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: a sandboxed bot's socket listens while its turns or commands do

Each sandboxed bot's own socket was bound on its first command and kept,
with its accept task, until the bot was deleted, so every bot that ever ran
a sandboxed command held a listening descriptor forever: past macOS's
default 256-descriptor limit long before 10,000 bots. Opening it now hands
out a share, held by the turn's policy and by every running command's
sandbox hold (foreground, background, detached, terminal), as a refcounted
handle or systemd's socket activation keeps a unit's socket. Thirty seconds
after the last share goes it closes; a share taken again in that time
keeps the same listener, and accepted connections keep their sessions.
Deleting the bot still closes it at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Replay pages share the lane's reader seats; the switch reports its own pruning

Codex review: replay pages and observation reads each took all but one
reader, so together they could fill every reader ahead of turns' own reads.
They now share the lane's seats. The switch to live reads at a later point
than the empty page did, so a deletion in between could prune events past
the cursor: its own retention notice is the one reported. The bench raises
when a flood fails instead of writing a clean result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A replay page's seat goes with its read, so a cancelled replay keeps it until the read is done

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal polls past the bot's hold park their turn, as wait does

An empty write_stdin waits live for the bot's approval_hold_ms, then
parks its turn on the terminal's handle until the command ends or the
poll's time runs out, holding no task and no active slot. The resumed
turn reads what the terminal wrote meanwhile. A steer waiting for the
boundary keeps the poll live.

Closes #324

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: request lines are read on credit from one byte budget

Every session's reader takes credit before it reads: a line's first 4 KiB
from the budget or a reserve kept for short lines, and a line that goes on
waits for credit for the longest line at once, so readers never each hold
part of what they need. The request gives it back once the service takes
it up. --max-input-bytes, a sixteenth of physical memory by default (at
least 64 MiB), 0 unbounded; ready reports limits.input_bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: tool_processes is one total, three quarters for the tool host and a quarter for the lookout

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: large tool output is redacted on a blocking thread

A command's or a fetched page's output over 64 KiB is redacted with
spawn_blocking, under a byte budget of two of the largest results per
logical CPU, instead of on the runtime's thread (8 ms a MiB measured).

Closes #316

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminals show a secret field's name at once and redact its value after it

A prompt such as `Password: ` was held back with the value it waits
for, so a program asking for one never showed its prompt. Only the
value is held now; the name and separator are shown, and kept so the
next read is redacted as read after them, at a command's end too.
A field's name is matched by bytes, so one in any script no longer
panics the read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal start waits on the one it pruned only when every slot is taken

Pruning a bot's least recently used terminal waited up to 2 s for it to
go on every start past the bot's share, inside the active turn. A start
now takes a free lasting slot at once; only when none is free does it
wait, bounded, for the pruned terminal's, a moment after its kill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the lasting-process cap's perf screen and a terminal read timing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sandbox sockets close from one daemon-wide schedule, off the runtime thread

A last share's drop spawned a task and a 30 s timer per bot, and the
expiry unlinked the socket on the runtime thread. Drops now queue their
deadline in one schedule, in order since every grace is the same; one
task sleeps until the first, and checks and unlinks the ended ones off
the runtime thread under the lock an open takes. A detached command's
share is kept until its whole process group is gone, not only its
launcher.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the socket shares' perf screen; a test's process may go between open and read

test_served's running() caught a stat file that vanished before its open
but not a process that went between the open and the read, which reads
as ESRCH: the turn-interrupt test failed on a setup process that had
just been reaped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal stays readable with its end until its result is recorded

A terminal used to leave the registry as it ended, before its handle's
result reached the store. A parked poll that woke on its deadline in
between found neither, and failed terminal_not_running. The terminal
now stays, its end held, until the result is recorded; a poll or a
write in between reads the end. An ended terminal no longer counts
toward its bot's share, and a write to one types nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal contract tests let an ended terminal go as its result is recorded

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the terminal polls' perf screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 37: ready reports limits.input_bytes

36 is claimed by the open planned-stop PR (#565); whichever merges
second takes the next number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 38: 37 is claimed by the day-five command rules

36 is the planned-stop PR's (#565) and 37 the day-five command rules';
whichever merges later takes the next free number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the ingress credits' perf screen on the ordinary request path

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: redaction waits without the process budget, and reads credentials without the lock

A finished command lets its process slot and sandbox hold go before its output waits for redaction, so a burst of large results never keeps small commands from starting. Credentials are an Arc set behind the lock: a scan takes the current set and lets go, and a refresh copies the set if a scan still reads it, so a long scan on a blocking thread never holds up a refresh on the runtime's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: bots filters by maker, and Sonny's task count reads only its own

bots takes created_by_id, kept by a partial index on (created_by_id, name), so a page costs the maker's own children however many bots the store holds; it combines with name and active. An id, not a name, so a maker that reuses a name sees none of an earlier one's. agent ls --created-by BOT. Sonny without a fleet view asks for its own running tasks instead of every running bot every three seconds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Measurements: the matched screen for redaction off the runtime

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Perf: the screen runs on Sonny and client changes, with Sonny's own scenarios

bench.sonny_screen: the lookout at 10, 100 and 1,000 subscribers; one quiet lead's window in a pseudo-terminal while 1,000 tasks elsewhere run turns, with what it asks the daemon counted on a socket in front of the daemon's; and a sky replay of the hour at its fastest speed. perf.yml builds Sonny for both sides and runs it on sonny/** and client/**; perf_gate compares it, warning only, as for the daemon's timings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Measurements: a blank line before the window's section

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: limits from [daemon] formulas, and a load gate for new commands

wip

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: refuse a run whose window exited or drew nothing

An exited Sonny costs no CPU and no memory, so a window that crashed
as it opened or under load would read as a fast one. The screen now
checks the program is up and has drawn before and after each sampled
stretch, and fails the run with the last of its screen otherwise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: absolute output, refuse a dead lookout, footer test by maker

The perf job passes a relative --out, which the bots' workspaces
refuse; it is resolved first. A lookout that exited as it started or
under load now fails the run instead of reading as a cheap one. The
footer test asks the daemon for this agent's tasks by its id, as the
footer now does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Perf gate: a side that told no note shows none, not a delay of zero

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: the sky's cost runs from its start until the hour has played

A fixed sleep could end before a slow replay had read its history in,
so a slower revision would replay less and read as cheaper. The screen
now keeps what the terminal shows (pyte, a measurement dependency) and
waits for the replay's footer: ready once it stops reading, done once
512x has caught up with now, refusing the run past a limit. The
result says how long each took.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: the sky's CPU per thousand lines the daemon sent

The fleet's hour holds as many turns as the daemon ran in the time
given, so two revisions replay different histories. The replay now
goes through a counting socket too, and the gate compares its CPU per
thousand lines read rather than in total; a replay that read nothing
is refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 40: 39 went to the command rules; record the matched screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Store: the maker filter takes a fixed number, so the plan audit sees it

bench.query_plans plans every variant of a listing from its named
clauses; numbering the parameters as they were bound left braces it
could not fill. The filters now take ?3 and ?4, a maker without a name
binding ?3 as NULL, and the audit plans all eight variants of `bots`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* CLI docs: the daemon's limits from [daemon], and the load gate

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Park turns the load gate holds, recheck the gate for a freed slot, check formulas for this machine

A foreground command the load gate holds past 1.5 s now parks its turn
before the call starts, as a verdict park does: one commit, no task, no
active slot, and it survives restart. The turn view's waiting_on carries
load: true. A server task wakes every parked turn when the gate opens, or
the oldest alone on a loaded machine where none of the daemon's commands
runs, and reads the store only after a turn parks.

A background command waiting at the gate takes a freed slot only if the
gate still admits it, so a burst cannot pass the gate together.

[daemon] formulas are worked out for this machine when the file is read,
so one below 0 here is config_invalid then rather than at a daemon start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: a parallel batch is let in or held whole

A round's calls that run together were checked against the load gate by
their first alone, so a read ahead of shell calls let the commands start
on a loaded machine. The batch is now formed first and parked whole,
none of it started, when the gate holds any command in it; the park
names the command it holds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 42: 41 went to configure's settings (#574)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: waiters go in order, forbidden commands are refused at once, and the matched screen

Background commands waiting at a shut gate now hold a fair line, and the
queue's fast path takes a free slot only while nobody waits in it, so a
newcomer between two readings cannot take the slot ahead of an older
waiter. A command its rules forbid is refused rather than held, since it
starts nothing. DAEMON_MEASUREMENTS records the Perf workflow's matched
screen of the branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: only a command that would start now is held; a small load limit stays one

The gate held every foreground shell call before the turn looked at its
verdict or its rules, so a denial, a forbidden command, one a rule asks
about with no gate, or an escape no gate allows sat parked until the
load fell. Now only a call that would start at once is held; a gated
call waits for its verdict instead and starts once allowed. A `[daemon]
load` below 0.005 was rounded to 0, which is no gate; it is passed whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: a lead keeps so many task windows open, closing the least recently used

Past `[sonny] task_windows` (32 by default, 0 for no limit, in /config),
a new task window closes the one the person used least recently, as VS
Code's editor limit does. Each window's own Sonny marks its agent's file
in ~/.agent/sonny/used/ when the person focuses, types or clicks there,
at most once every 10 s; the lead reads those times only when it needs
room. A window whose task needs the person, failed, or holds a block it
asked for is never closed for room. A window closed for room stays
closed while its task works on, and /status opens it again. The limit
is read again on the layout's worker whenever the config file changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: close only the lead's own task windows for room, and keep those their windows say need the person

Two leads of a folder share its multiplexer home, so a lead now counts
and closes only its own tasks' windows. What holds a window is no longer
only what this lead heard since it started: each window's Sonny keeps a
file in ~/.agent/sonny/held/ while its agent failed, waits on an
approval, or has a question open in it, and leaves it for the next
window until its status says otherwise. So a lead started again, which
hears neither old failures nor open questions, still keeps those
windows. The protected set is built in one place (room_for), tested
from a lead's state through to the window it closes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: rustfmt the task window protection

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: a window's held file always ends saying the latest, and a window opened again on a failed agent keeps it

Writes asked one after another run one at a time and each writes what
the window wants now, so an earlier write finishing late cannot undo a
later one. At start, a window with no turn running reports its last
turn's end as live: a failure (not a model that said nothing) is
"error", so its held file stands across a restart of both the window
and its lead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: task windows count by window, and a lead started again still reopens one it closed for room

Tasks shown together (a split beside another task) are one window: they
count once against task_windows, and close together, held whole when any
of them is. A window holding a lead's or another lead's blocks is not a
task window. Which windows a lead closed for room is kept in
~/.agent/sonny/aside/, so /status opens one again after the lead
restarts, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: a cmux task tab counts as its own window against task_windows

Backend::tab says what a window placement opened a block in: the window
for Rex, the tab for Herdr, and the tab itself for cmux, whose task tabs
share the lead's pane.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: a detached command keeps its lasting slot while what it left in its group runs

A launcher that starts a service with `cmd &` and exits gave its
--max-lasting slot back while the service ran on, so launchers repeated
could keep any number of services past the bound. The waiter already
looks for the command's group each second until it is empty, keeping the
bot's socket listening; the slot and the sandbox's hold now go with the
listener, once the group is gone or the pull cord ends it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Bench: the load gate on a busy machine, against none

bench/load_gate.py runs CPU-bound commands from many workers with the
gate off, at the CPU count and at the default, and probes a plain turn,
a short command and a control request meanwhile. Recorded under #575's
measurements, which ran with the gate off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: an exited, unreaped member of a detached group holds no slot

kill(-pgid, 0) also answers for a zombie, and an init that does not reap
orphans, as some containers run, leaves one for good: the slot would stay
taken until a pull. On Linux the group now counts only members that are
not zombies, read from /proc off the runtime thread. A test in its own
binary makes itself a subreaper that never reaps and checks the slot frees.

The load-gate screen now gives work commands the shell's longest timeout
and counts a run only if every one finished its work, and samples its
three probes on their own connections, so a held `true` does not stop the
other two. Rerun: same shape, gate at the CPU count 1.75x the wall time,
short commands p95 10 s; every work command finished in every run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: a detached service whose main thread exited still holds its slot

/proc shows a process whose main thread called pthread_exit as a zombie
while its other threads run. A zombie member now counts as running while
any of its tasks is not a zombie. A second test in the reaping binary
builds such a service with cc and checks it keeps its place, then frees it.

The gate screen's probes wait for their own turns however long the gate
holds them, so the slowest samples are kept, and a probe that never ends
fails the run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: read a group member's /proc stat as bytes

A process's name in /proc/<pid>/stat is any bytes, and the kernel's cut to
15 can split a UTF-8 character, so reading it as a string dropped a live
service and freed its slot. Stat files are now read as bytes and only the
ASCII fields after the last ')' parsed, for the process and its threads.
A third reaping test runs sleep under a 16-byte name ending in é.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: three agreeing /proc walks before an exited-only group frees its slot

A walk of /proc is no one moment: it can list a parent before it forks a
replacement and read its stat after it exits, never seeing the child, so a
fork-and-exit chain could read as empty and lose its slot and pull cord.
kill(-pgid, 0) still frees a group at once when nothing answers; where only
exited members are seen, three walks a second apart must agree. The
reaping tests wait for that, and docs/RUST_PROTOTYPE.md says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: free an exited-only group's slot at the third agreeing walk

The waiter slept a second after the third walk before letting go; it now
lets go at once. The contract test waits up to 6 s for the slot, as the
reaping tests do, so it holds where nobody reaps the killed service.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Lookout: replies read on a pool of connections, so 1,000 tasks' ends reach their leads in seconds

The daemon answers one read at a time from each session, so the lookout's
one connection read a busy fleet's replies one by one, 8 to 10 s behind.
It now reads on a pool, one connection per logical CPU; a completed turn's
reply is its checkpoint, read in one request; a note waits only for reads
that started before its news settled, and holds as many tasks as its bytes
allow. The screen measures leads x tasks per lead over fixed rounds, and
counts every ended turn as told or untold from the lookout's own log.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Bench: a lookout note counts as delivered when a busy lead absorbs it too

A note a busy lead takes into its running turn, as a steer or an attach,
finishes as `steered` with no start of its own; the screen now takes its
absorption as its delivery, and reports how many notes reached their lead
each way and how many never did. Rerun on main: 4,000 of 4,000 told in
each shape, every note delivered, p95 2.9 s (10x100) and 4.2 s (100x10).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Lookout: budget a note's message lines as written; a turn is told once its note reaches the lead

A message counted as LINE_BYTES however long its task's and writer's
names were, so with the 32-task cap gone a note of 1,000 tasks with long
names wrote about 400 KB of lines on a 192 KB budget, past the daemon's
prompt limit. Each message now counts as the longest line `said` can
write for it.

The screen counted a turn as told when a note naming it was sent, even
if that note never reached its lead. It now needs the note delivered;
the submit time still counts every note sent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

---------

Co-authored-by: Claude <[email protected]>
lydakis added a commit that referenced this pull request Nov 1, 2026
…on every use (#617)

* Daemon: reads that decide nothing run beside the service loop, on a reader pool

Observation reads (history_nodes, history_items, history_search, turns,
bots, events, usage, prompts) used to run inside the service loop, on one
reader connection. A deep history read or a search across every bot held
every other session's submit, interrupt or pause behind it, and every
read waited behind every other read.

They now run in an observation lane beside the loop, as Kubernetes' API
Priority and Fairness gives a priority level its own seats. The store
has a pool of WAL reader connections (--max-readers, one per logical
CPU by default). Observation reads take all but one of them, waiting in
the order they came, so a turn's own reads always find one free. A
session waits for its read before its next request is taken (the input
queue parks it), so a session's own requests keep their order.

events moves from the writer to a reader. usage and history_search,
which spawned a task each, now go through the lane and are bounded by it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: parked sessions hold back their readers; each reads at most 8 ahead

Measured: sessions parked on reads kept the input queue full, so another
session's next request waited for room. A session now reads at most an
eighth of the queue ahead, and no further than its next request while it
waits on a read. A read's answer is written in its own task, not in the
service loop. Observation reads leave one reader for turns' own reads.
bench/fair_queuing.py floods history and searches from several sessions
over deep histories; the Perf screen is in docs/DAEMON_MEASUREMENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Give a parked session's read-ahead back to the shared input queue

A session parked behind an observation read kept the room its queued
requests held, so enough parked sessions could fill the queue and hold
new connections and other clients' requests until a read finished.
Parking now hands those slots back, and a parked session reads nothing
more until it is answered; what it read ahead is taken uncharged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Let a parked session read on to its share, uncharged

A parked session's reader stopped at its next request, so lease
renewals behind it went unread until the observation was answered.
It now reads on to its share while parked, and what it queues then
takes no room, so renewals stay readable and the shared queue stays
free. The fair-queuing bench gives each flooder its own bots to create
and delete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Bound history traversal with skip pointers and history pages by bytes (#472)

Each node gets a narrow lineage row (parent, depth, a skip pointer
chosen as Bitcoin Core's block index chooses pskip, and its turn's
start), written with the node. Checking that a node is in a bot's
lineage, finding where an oldest-first page starts, validating a
history_items batch, and naming a page's turn now take O(log n) point
lookups rather than a walk over the history. A history_nodes page
stops at 256 KiB sent and continues from next_from, or next_newer
oldest first. Schema 72 places every existing node when a store opens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the hot-path screens for skip pointers

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: replay pages come from the reader pool, with no subscription lock held

A follow catching up from an early cursor used to read every page as a job
on the storage worker while holding its subscription's lock, so one client
replaying a long history put hundreds of reads ahead of every write. Pages
now come from the reader pool behind the observation seats (all but one
reader across every replay). Only the switch to live stays on the worker,
as one job that reads at most one event and either marks the follow live or
sends the replay back for another page, so nothing committed between the
modes is lost.

bench/fair_queuing.py gains a follow flood: 16 whole-store replays move the
probe's p95 from about 40 ms to about 15 ms and finish about 20% sooner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: terminals and detached commands share one lasting-process cap

A terminal spawned its PTY and shell with no slot at all, bounded only by
16 per bot, and terminals outlive turns, so nothing bounded them
daemon-wide. Terminals and detached commands now share --max-lasting (4
per logical CPU, replacing --max-detached), as a systemd slice holds a
service's processes. A terminal takes its permit before it spawns and keeps
it until its whole session is gone; a full cap answers lasting_limit,
naming how many terminals and detached commands hold it. A bot at its 16
terminals ends its least recently used before the next starts, so that
permit is free for it.

From #328: a kill now ends every process group in the terminal's session
(the foreground job via tcgetpgrp, the rest from /proc on Linux and the
process list on macOS), so a job that a shell with job control started and
that ignores SIGHUP no longer outlives its terminal. A secret field's name
cut off at the end of a read now waits with its value for the next one, so
the value is redacted whole.

Protocol 35: ready's limits report lasting in place of detached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: a sandboxed bot's socket listens while its turns or commands do

Each sandboxed bot's own socket was bound on its first command and kept,
with its accept task, until the bot was deleted, so every bot that ever ran
a sandboxed command held a listening descriptor forever: past macOS's
default 256-descriptor limit long before 10,000 bots. Opening it now hands
out a share, held by the turn's policy and by every running command's
sandbox hold (foreground, background, detached, terminal), as a refcounted
handle or systemd's socket activation keeps a unit's socket. Thirty seconds
after the last share goes it closes; a share taken again in that time
keeps the same listener, and accepted connections keep their sessions.
Deleting the bot still closes it at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Replay pages share the lane's reader seats; the switch reports its own pruning

Codex review: replay pages and observation reads each took all but one
reader, so together they could fill every reader ahead of turns' own reads.
They now share the lane's seats. The switch to live reads at a later point
than the empty page did, so a deletion in between could prune events past
the cursor: its own retention notice is the one reported. The bench raises
when a flood fails instead of writing a clean result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A replay page's seat goes with its read, so a cancelled replay keeps it until the read is done

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal polls past the bot's hold park their turn, as wait does

An empty write_stdin waits live for the bot's approval_hold_ms, then
parks its turn on the terminal's handle until the command ends or the
poll's time runs out, holding no task and no active slot. The resumed
turn reads what the terminal wrote meanwhile. A steer waiting for the
boundary keeps the poll live.

Closes #324

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: request lines are read on credit from one byte budget

Every session's reader takes credit before it reads: a line's first 4 KiB
from the budget or a reserve kept for short lines, and a line that goes on
waits for credit for the longest line at once, so readers never each hold
part of what they need. The request gives it back once the service takes
it up. --max-input-bytes, a sixteenth of physical memory by default (at
least 64 MiB), 0 unbounded; ready reports limits.input_bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: tool_processes is one total, three quarters for the tool host and a quarter for the lookout

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: large tool output is redacted on a blocking thread

A command's or a fetched page's output over 64 KiB is redacted with
spawn_blocking, under a byte budget of two of the largest results per
logical CPU, instead of on the runtime's thread (8 ms a MiB measured).

Closes #316

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminals show a secret field's name at once and redact its value after it

A prompt such as `Password: ` was held back with the value it waits
for, so a program asking for one never showed its prompt. Only the
value is held now; the name and separator are shown, and kept so the
next read is redacted as read after them, at a command's end too.
A field's name is matched by bytes, so one in any script no longer
panics the read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal start waits on the one it pruned only when every slot is taken

Pruning a bot's least recently used terminal waited up to 2 s for it to
go on every start past the bot's share, inside the active turn. A start
now takes a free lasting slot at once; only when none is free does it
wait, bounded, for the pruned terminal's, a moment after its kill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the lasting-process cap's perf screen and a terminal read timing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sandbox sockets close from one daemon-wide schedule, off the runtime thread

A last share's drop spawned a task and a 30 s timer per bot, and the
expiry unlinked the socket on the runtime thread. Drops now queue their
deadline in one schedule, in order since every grace is the same; one
task sleeps until the first, and checks and unlinks the ended ones off
the runtime thread under the lock an open takes. A detached command's
share is kept until its whole process group is gone, not only its
launcher.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the socket shares' perf screen; a test's process may go between open and read

test_served's running() caught a stat file that vanished before its open
but not a process that went between the open and the read, which reads
as ESRCH: the turn-interrupt test failed on a setup process that had
just been reaped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal stays readable with its end until its result is recorded

A terminal used to leave the registry as it ended, before its handle's
result reached the store. A parked poll that woke on its deadline in
between found neither, and failed terminal_not_running. The terminal
now stays, its end held, until the result is recorded; a poll or a
write in between reads the end. An ended terminal no longer counts
toward its bot's share, and a write to one types nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal contract tests let an ended terminal go as its result is recorded

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the terminal polls' perf screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 37: ready reports limits.input_bytes

36 is claimed by the open planned-stop PR (#565); whichever merges
second takes the next number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 38: 37 is claimed by the day-five command rules

36 is the planned-stop PR's (#565) and 37 the day-five command rules';
whichever merges later takes the next free number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the ingress credits' perf screen on the ordinary request path

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: redaction waits without the process budget, and reads credentials without the lock

A finished command lets its process slot and sandbox hold go before its output waits for redaction, so a burst of large results never keeps small commands from starting. Credentials are an Arc set behind the lock: a scan takes the current set and lets go, and a refresh copies the set if a scan still reads it, so a long scan on a blocking thread never holds up a refresh on the runtime's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: bots filters by maker, and Sonny's task count reads only its own

bots takes created_by_id, kept by a partial index on (created_by_id, name), so a page costs the maker's own children however many bots the store holds; it combines with name and active. An id, not a name, so a maker that reuses a name sees none of an earlier one's. agent ls --created-by BOT. Sonny without a fleet view asks for its own running tasks instead of every running bot every three seconds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Measurements: the matched screen for redaction off the runtime

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Perf: the screen runs on Sonny and client changes, with Sonny's own scenarios

bench.sonny_screen: the lookout at 10, 100 and 1,000 subscribers; one quiet lead's window in a pseudo-terminal while 1,000 tasks elsewhere run turns, with what it asks the daemon counted on a socket in front of the daemon's; and a sky replay of the hour at its fastest speed. perf.yml builds Sonny for both sides and runs it on sonny/** and client/**; perf_gate compares it, warning only, as for the daemon's timings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Measurements: a blank line before the window's section

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: limits from [daemon] formulas, and a load gate for new commands

wip

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: refuse a run whose window exited or drew nothing

An exited Sonny costs no CPU and no memory, so a window that crashed
as it opened or under load would read as a fast one. The screen now
checks the program is up and has drawn before and after each sampled
stretch, and fails the run with the last of its screen otherwise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: absolute output, refuse a dead lookout, footer test by maker

The perf job passes a relative --out, which the bots' workspaces
refuse; it is resolved first. A lookout that exited as it started or
under load now fails the run instead of reading as a cheap one. The
footer test asks the daemon for this agent's tasks by its id, as the
footer now does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Perf gate: a side that told no note shows none, not a delay of zero

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: the sky's cost runs from its start until the hour has played

A fixed sleep could end before a slow replay had read its history in,
so a slower revision would replay less and read as cheaper. The screen
now keeps what the terminal shows (pyte, a measurement dependency) and
waits for the replay's footer: ready once it stops reading, done once
512x has caught up with now, refusing the run past a limit. The
result says how long each took.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: the sky's CPU per thousand lines the daemon sent

The fleet's hour holds as many turns as the daemon ran in the time
given, so two revisions replay different histories. The replay now
goes through a counting socket too, and the gate compares its CPU per
thousand lines read rather than in total; a replay that read nothing
is refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 40: 39 went to the command rules; record the matched screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Store: the maker filter takes a fixed number, so the plan audit sees it

bench.query_plans plans every variant of a listing from its named
clauses; numbering the parameters as they were bound left braces it
could not fill. The filters now take ?3 and ?4, a maker without a name
binding ?3 as NULL, and the audit plans all eight variants of `bots`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* CLI docs: the daemon's limits from [daemon], and the load gate

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Park turns the load gate holds, recheck the gate for a freed slot, check formulas for this machine

A foreground command the load gate holds past 1.5 s now parks its turn
before the call starts, as a verdict park does: one commit, no task, no
active slot, and it survives restart. The turn view's waiting_on carries
load: true. A server task wakes every parked turn when the gate opens, or
the oldest alone on a loaded machine where none of the daemon's commands
runs, and reads the store only after a turn parks.

A background command waiting at the gate takes a freed slot only if the
gate still admits it, so a burst cannot pass the gate together.

[daemon] formulas are worked out for this machine when the file is read,
so one below 0 here is config_invalid then rather than at a daemon start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: a parallel batch is let in or held whole

A round's calls that run together were checked against the load gate by
their first alone, so a read ahead of shell calls let the commands start
on a loaded machine. The batch is now formed first and parked whole,
none of it started, when the gate holds any command in it; the park
names the command it holds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 42: 41 went to configure's settings (#574)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: waiters go in order, forbidden commands are refused at once, and the matched screen

Background commands waiting at a shut gate now hold a fair line, and the
queue's fast path takes a free slot only while nobody waits in it, so a
newcomer between two readings cannot take the slot ahead of an older
waiter. A command its rules forbid is refused rather than held, since it
starts nothing. DAEMON_MEASUREMENTS records the Perf workflow's matched
screen of the branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: only a command that would start now is held; a small load limit stays one

The gate held every foreground shell call before the turn looked at its
verdict or its rules, so a denial, a forbidden command, one a rule asks
about with no gate, or an escape no gate allows sat parked until the
load fell. Now only a call that would start at once is held; a gated
call waits for its verdict instead and starts once allowed. A `[daemon]
load` below 0.005 was rounded to 0, which is no gate; it is passed whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: a lead keeps so many task windows open, closing the least recently used

Past `[sonny] task_windows` (32 by default, 0 for no limit, in /config),
a new task window closes the one the person used least recently, as VS
Code's editor limit does. Each window's own Sonny marks its agent's file
in ~/.agent/sonny/used/ when the person focuses, types or clicks there,
at most once every 10 s; the lead reads those times only when it needs
room. A window whose task needs the person, failed, or holds a block it
asked for is never closed for room. A window closed for room stays
closed while its task works on, and /status opens it again. The limit
is read again on the layout's worker whenever the config file changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: close only the lead's own task windows for room, and keep those their windows say need the person

Two leads of a folder share its multiplexer home, so a lead now counts
and closes only its own tasks' windows. What holds a window is no longer
only what this lead heard since it started: each window's Sonny keeps a
file in ~/.agent/sonny/held/ while its agent failed, waits on an
approval, or has a question open in it, and leaves it for the next
window until its status says otherwise. So a lead started again, which
hears neither old failures nor open questions, still keeps those
windows. The protected set is built in one place (room_for), tested
from a lead's state through to the window it closes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: rustfmt the task window protection

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: a window's held file always ends saying the latest, and a window opened again on a failed agent keeps it

Writes asked one after another run one at a time and each writes what
the window wants now, so an earlier write finishing late cannot undo a
later one. At start, a window with no turn running reports its last
turn's end as live: a failure (not a model that said nothing) is
"error", so its held file stands across a restart of both the window
and its lead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: task windows count by window, and a lead started again still reopens one it closed for room

Tasks shown together (a split beside another task) are one window: they
count once against task_windows, and close together, held whole when any
of them is. A window holding a lead's or another lead's blocks is not a
task window. Which windows a lead closed for room is kept in
~/.agent/sonny/aside/, so /status opens one again after the lead
restarts, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: a cmux task tab counts as its own window against task_windows

Backend::tab says what a window placement opened a block in: the window
for Rex, the tab for Herdr, and the tab itself for cmux, whose task tabs
share the lead's pane.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: a detached command keeps its lasting slot while what it left in its group runs

A launcher that starts a service with `cmd &` and exits gave its
--max-lasting slot back while the service ran on, so launchers repeated
could keep any number of services past the bound. The waiter already
looks for the command's group each second until it is empty, keeping the
bot's socket listening; the slot and the sandbox's hold now go with the
listener, once the group is gone or the pull cord ends it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Bench: the load gate on a busy machine, against none

bench/load_gate.py runs CPU-bound commands from many workers with the
gate off, at the CPU count and at the default, and probes a plain turn,
a short command and a control request meanwhile. Recorded under #575's
measurements, which ran with the gate off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: an exited, unreaped member of a detached group holds no slot

kill(-pgid, 0) also answers for a zombie, and an init that does not reap
orphans, as some containers run, leaves one for good: the slot would stay
taken until a pull. On Linux the group now counts only members that are
not zombies, read from /proc off the runtime thread. A test in its own
binary makes itself a subreaper that never reaps and checks the slot frees.

The load-gate screen now gives work commands the shell's longest timeout
and counts a run only if every one finished its work, and samples its
three probes on their own connections, so a held `true` does not stop the
other two. Rerun: same shape, gate at the CPU count 1.75x the wall time,
short commands p95 10 s; every work command finished in every run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: a detached service whose main thread exited still holds its slot

/proc shows a process whose main thread called pthread_exit as a zombie
while its other threads run. A zombie member now counts as running while
any of its tasks is not a zombie. A second test in the reaping binary
builds such a service with cc and checks it keeps its place, then frees it.

The gate screen's probes wait for their own turns however long the gate
holds them, so the slowest samples are kept, and a probe that never ends
fails the run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: read a group member's /proc stat as bytes

A process's name in /proc/<pid>/stat is any bytes, and the kernel's cut to
15 can split a UTF-8 character, so reading it as a string dropped a live
service and freed its slot. Stat files are now read as bytes and only the
ASCII fields after the last ')' parsed, for the process and its threads.
A third reaping test runs sleep under a 16-byte name ending in é.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: three agreeing /proc walks before an exited-only group frees its slot

A walk of /proc is no one moment: it can list a parent before it forks a
replacement and read its stat after it exits, never seeing the child, so a
fork-and-exit chain could read as empty and lose its slot and pull cord.
kill(-pgid, 0) still frees a group at once when nothing answers; where only
exited members are seen, three walks a second apart must agree. The
reaping tests wait for that, and docs/RUST_PROTOTYPE.md says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: free an exited-only group's slot at the third agreeing walk

The waiter slept a second after the third walk before letting go; it now
lets go at once. The contract test waits up to 6 s for the slot, as the
reaping tests do, so it holds where nobody reaps the killed service.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Lookout: replies read on a pool of connections, so 1,000 tasks' ends reach their leads in seconds

The daemon answers one read at a time from each session, so the lookout's
one connection read a busy fleet's replies one by one, 8 to 10 s behind.
It now reads on a pool, one connection per logical CPU; a completed turn's
reply is its checkpoint, read in one request; a note waits only for reads
that started before its news settled, and holds as many tasks as its bytes
allow. The screen measures leads x tasks per lead over fixed rounds, and
counts every ended turn as told or untold from the lookout's own log.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Bench: a lookout note counts as delivered when a busy lead absorbs it too

A note a busy lead takes into its running turn, as a steer or an attach,
finishes as `steered` with no start of its own; the screen now takes its
absorption as its delivery, and reports how many notes reached their lead
each way and how many never did. Rerun on main: 4,000 of 4,000 told in
each shape, every note delivered, p95 2.9 s (10x100) and 4.2 s (100x10).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Lookout: budget a note's message lines as written; a turn is told once its note reaches the lead

A message counted as LINE_BYTES however long its task's and writer's
names were, so with the 32-task cap gone a note of 1,000 tasks with long
names wrote about 400 KB of lines on a 192 KB budget, past the daemon's
prompt limit. Each message now counts as the longest line `said` can
write for it.

The screen counted a turn as told when a note naming it was sent, even
if that note never reached its lead. It now needs the note delivered;
the submit time still counts every note sent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Store: plan statements once, so cached joins stop being parsed again on every use

SQLite 3.54.1 (from #544) marks a join that binds an `x = ?` value to be
planned again when that value changes, and counts the statement cache
clearing its bindings as a change. Every reuse of such a statement was
parsed and planned again: history_items did it on all of its calls, about
half a millisecond each, which doubled its time. Both store connections
now turn on SQLite's query planner stability guarantee; the store runs no
ANALYZE, so a bound value could never improve a plan.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Store: write out a GLOB pattern's prefix bound, which stable plans no longer derive

With plans that ignore bound values, SQLite no longer narrowed a GLOB
match on a name to its literal prefix's index range, so `list` with a
name pattern, history search and `usage` could read every bot. Each now
bounds the index itself (name >= prefix AND name < prefix || x'ff'); the
page cursor and the prefix make one lower bound, so the range is the
same whichever term the planner reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

---------

Co-authored-by: Claude <[email protected]>
lydakis added a commit that referenced this pull request Nov 1, 2026
…tions do (#624)

* Daemon: reads that decide nothing run beside the service loop, on a reader pool

Observation reads (history_nodes, history_items, history_search, turns,
bots, events, usage, prompts) used to run inside the service loop, on one
reader connection. A deep history read or a search across every bot held
every other session's submit, interrupt or pause behind it, and every
read waited behind every other read.

They now run in an observation lane beside the loop, as Kubernetes' API
Priority and Fairness gives a priority level its own seats. The store
has a pool of WAL reader connections (--max-readers, one per logical
CPU by default). Observation reads take all but one of them, waiting in
the order they came, so a turn's own reads always find one free. A
session waits for its read before its next request is taken (the input
queue parks it), so a session's own requests keep their order.

events moves from the writer to a reader. usage and history_search,
which spawned a task each, now go through the lane and are bounded by it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: parked sessions hold back their readers; each reads at most 8 ahead

Measured: sessions parked on reads kept the input queue full, so another
session's next request waited for room. A session now reads at most an
eighth of the queue ahead, and no further than its next request while it
waits on a read. A read's answer is written in its own task, not in the
service loop. Observation reads leave one reader for turns' own reads.
bench/fair_queuing.py floods history and searches from several sessions
over deep histories; the Perf screen is in docs/DAEMON_MEASUREMENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Give a parked session's read-ahead back to the shared input queue

A session parked behind an observation read kept the room its queued
requests held, so enough parked sessions could fill the queue and hold
new connections and other clients' requests until a read finished.
Parking now hands those slots back, and a parked session reads nothing
more until it is answered; what it read ahead is taken uncharged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Let a parked session read on to its share, uncharged

A parked session's reader stopped at its next request, so lease
renewals behind it went unread until the observation was answered.
It now reads on to its share while parked, and what it queues then
takes no room, so renewals stay readable and the shared queue stays
free. The fair-queuing bench gives each flooder its own bots to create
and delete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Bound history traversal with skip pointers and history pages by bytes (#472)

Each node gets a narrow lineage row (parent, depth, a skip pointer
chosen as Bitcoin Core's block index chooses pskip, and its turn's
start), written with the node. Checking that a node is in a bot's
lineage, finding where an oldest-first page starts, validating a
history_items batch, and naming a page's turn now take O(log n) point
lookups rather than a walk over the history. A history_nodes page
stops at 256 KiB sent and continues from next_from, or next_newer
oldest first. Schema 72 places every existing node when a store opens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the hot-path screens for skip pointers

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: replay pages come from the reader pool, with no subscription lock held

A follow catching up from an early cursor used to read every page as a job
on the storage worker while holding its subscription's lock, so one client
replaying a long history put hundreds of reads ahead of every write. Pages
now come from the reader pool behind the observation seats (all but one
reader across every replay). Only the switch to live stays on the worker,
as one job that reads at most one event and either marks the follow live or
sends the replay back for another page, so nothing committed between the
modes is lost.

bench/fair_queuing.py gains a follow flood: 16 whole-store replays move the
probe's p95 from about 40 ms to about 15 ms and finish about 20% sooner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: terminals and detached commands share one lasting-process cap

A terminal spawned its PTY and shell with no slot at all, bounded only by
16 per bot, and terminals outlive turns, so nothing bounded them
daemon-wide. Terminals and detached commands now share --max-lasting (4
per logical CPU, replacing --max-detached), as a systemd slice holds a
service's processes. A terminal takes its permit before it spawns and keeps
it until its whole session is gone; a full cap answers lasting_limit,
naming how many terminals and detached commands hold it. A bot at its 16
terminals ends its least recently used before the next starts, so that
permit is free for it.

From #328: a kill now ends every process group in the terminal's session
(the foreground job via tcgetpgrp, the rest from /proc on Linux and the
process list on macOS), so a job that a shell with job control started and
that ignores SIGHUP no longer outlives its terminal. A secret field's name
cut off at the end of a read now waits with its value for the next one, so
the value is redacted whole.

Protocol 35: ready's limits report lasting in place of detached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: a sandboxed bot's socket listens while its turns or commands do

Each sandboxed bot's own socket was bound on its first command and kept,
with its accept task, until the bot was deleted, so every bot that ever ran
a sandboxed command held a listening descriptor forever: past macOS's
default 256-descriptor limit long before 10,000 bots. Opening it now hands
out a share, held by the turn's policy and by every running command's
sandbox hold (foreground, background, detached, terminal), as a refcounted
handle or systemd's socket activation keeps a unit's socket. Thirty seconds
after the last share goes it closes; a share taken again in that time
keeps the same listener, and accepted connections keep their sessions.
Deleting the bot still closes it at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Replay pages share the lane's reader seats; the switch reports its own pruning

Codex review: replay pages and observation reads each took all but one
reader, so together they could fill every reader ahead of turns' own reads.
They now share the lane's seats. The switch to live reads at a later point
than the empty page did, so a deletion in between could prune events past
the cursor: its own retention notice is the one reported. The bench raises
when a flood fails instead of writing a clean result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A replay page's seat goes with its read, so a cancelled replay keeps it until the read is done

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal polls past the bot's hold park their turn, as wait does

An empty write_stdin waits live for the bot's approval_hold_ms, then
parks its turn on the terminal's handle until the command ends or the
poll's time runs out, holding no task and no active slot. The resumed
turn reads what the terminal wrote meanwhile. A steer waiting for the
boundary keeps the poll live.

Closes #324

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: request lines are read on credit from one byte budget

Every session's reader takes credit before it reads: a line's first 4 KiB
from the budget or a reserve kept for short lines, and a line that goes on
waits for credit for the longest line at once, so readers never each hold
part of what they need. The request gives it back once the service takes
it up. --max-input-bytes, a sixteenth of physical memory by default (at
least 64 MiB), 0 unbounded; ready reports limits.input_bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: tool_processes is one total, three quarters for the tool host and a quarter for the lookout

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: large tool output is redacted on a blocking thread

A command's or a fetched page's output over 64 KiB is redacted with
spawn_blocking, under a byte budget of two of the largest results per
logical CPU, instead of on the runtime's thread (8 ms a MiB measured).

Closes #316

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminals show a secret field's name at once and redact its value after it

A prompt such as `Password: ` was held back with the value it waits
for, so a program asking for one never showed its prompt. Only the
value is held now; the name and separator are shown, and kept so the
next read is redacted as read after them, at a command's end too.
A field's name is matched by bytes, so one in any script no longer
panics the read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal start waits on the one it pruned only when every slot is taken

Pruning a bot's least recently used terminal waited up to 2 s for it to
go on every start past the bot's share, inside the active turn. A start
now takes a free lasting slot at once; only when none is free does it
wait, bounded, for the pruned terminal's, a moment after its kill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the lasting-process cap's perf screen and a terminal read timing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sandbox sockets close from one daemon-wide schedule, off the runtime thread

A last share's drop spawned a task and a 30 s timer per bot, and the
expiry unlinked the socket on the runtime thread. Drops now queue their
deadline in one schedule, in order since every grace is the same; one
task sleeps until the first, and checks and unlinks the ended ones off
the runtime thread under the lock an open takes. A detached command's
share is kept until its whole process group is gone, not only its
launcher.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the socket shares' perf screen; a test's process may go between open and read

test_served's running() caught a stat file that vanished before its open
but not a process that went between the open and the read, which reads
as ESRCH: the turn-interrupt test failed on a setup process that had
just been reaped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* A terminal stays readable with its end until its result is recorded

A terminal used to leave the registry as it ended, before its handle's
result reached the store. A parked poll that woke on its deadline in
between found neither, and failed terminal_not_running. The terminal
now stays, its end held, until the result is recorded; a poll or a
write in between reads the end. An ended terminal no longer counts
toward its bot's share, and a write to one types nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Terminal contract tests let an ended terminal go as its result is recorded

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the terminal polls' perf screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 37: ready reports limits.input_bytes

36 is claimed by the open planned-stop PR (#565); whichever merges
second takes the next number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 38: 37 is claimed by the day-five command rules

36 is the planned-stop PR's (#565) and 37 the day-five command rules';
whichever merges later takes the next free number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Record the ingress credits' perf screen on the ordinary request path

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: redaction waits without the process budget, and reads credentials without the lock

A finished command lets its process slot and sandbox hold go before its output waits for redaction, so a burst of large results never keeps small commands from starting. Credentials are an Arc set behind the lock: a scan takes the current set and lets go, and a refresh copies the set if a scan still reads it, so a long scan on a blocking thread never holds up a refresh on the runtime's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: bots filters by maker, and Sonny's task count reads only its own

bots takes created_by_id, kept by a partial index on (created_by_id, name), so a page costs the maker's own children however many bots the store holds; it combines with name and active. An id, not a name, so a maker that reuses a name sees none of an earlier one's. agent ls --created-by BOT. Sonny without a fleet view asks for its own running tasks instead of every running bot every three seconds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Measurements: the matched screen for redaction off the runtime

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Perf: the screen runs on Sonny and client changes, with Sonny's own scenarios

bench.sonny_screen: the lookout at 10, 100 and 1,000 subscribers; one quiet lead's window in a pseudo-terminal while 1,000 tasks elsewhere run turns, with what it asks the daemon counted on a socket in front of the daemon's; and a sky replay of the hour at its fastest speed. perf.yml builds Sonny for both sides and runs it on sonny/** and client/**; perf_gate compares it, warning only, as for the daemon's timings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Measurements: a blank line before the window's section

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: limits from [daemon] formulas, and a load gate for new commands

wip

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: refuse a run whose window exited or drew nothing

An exited Sonny costs no CPU and no memory, so a window that crashed
as it opened or under load would read as a fast one. The screen now
checks the program is up and has drawn before and after each sampled
stretch, and fails the run with the last of its screen otherwise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: absolute output, refuse a dead lookout, footer test by maker

The perf job passes a relative --out, which the bots' workspaces
refuse; it is resolved first. A lookout that exited as it started or
under load now fails the run instead of reading as a cheap one. The
footer test asks the daemon for this agent's tasks by its id, as the
footer now does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Perf gate: a side that told no note shows none, not a delay of zero

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: the sky's cost runs from its start until the hour has played

A fixed sleep could end before a slow replay had read its history in,
so a slower revision would replay less and read as cheaper. The screen
now keeps what the terminal shows (pyte, a measurement dependency) and
waits for the replay's footer: ready once it stops reading, done once
512x has caught up with now, refusing the run past a limit. The
result says how long each took.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny screen: the sky's CPU per thousand lines the daemon sent

The fleet's hour holds as many turns as the daemon ran in the time
given, so two revisions replay different histories. The replay now
goes through a counting socket too, and the gate compares its CPU per
thousand lines read rather than in total; a replay that read nothing
is refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 40: 39 went to the command rules; record the matched screen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Store: the maker filter takes a fixed number, so the plan audit sees it

bench.query_plans plans every variant of a listing from its named
clauses; numbering the parameters as they were bound left braces it
could not fill. The filters now take ?3 and ?4, a maker without a name
binding ?3 as NULL, and the audit plans all eight variants of `bots`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* CLI docs: the daemon's limits from [daemon], and the load gate

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Park turns the load gate holds, recheck the gate for a freed slot, check formulas for this machine

A foreground command the load gate holds past 1.5 s now parks its turn
before the call starts, as a verdict park does: one commit, no task, no
active slot, and it survives restart. The turn view's waiting_on carries
load: true. A server task wakes every parked turn when the gate opens, or
the oldest alone on a loaded machine where none of the daemon's commands
runs, and reads the store only after a turn parks.

A background command waiting at the gate takes a freed slot only if the
gate still admits it, so a burst cannot pass the gate together.

[daemon] formulas are worked out for this machine when the file is read,
so one below 0 here is config_invalid then rather than at a daemon start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: a parallel batch is let in or held whole

A round's calls that run together were checked against the load gate by
their first alone, so a read ahead of shell calls let the commands start
on a loaded machine. The batch is now formed first and parked whole,
none of it started, when the gate holds any command in it; the park
names the command it holds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Protocol 42: 41 went to configure's settings (#574)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: waiters go in order, forbidden commands are refused at once, and the matched screen

Background commands waiting at a shut gate now hold a fair line, and the
queue's fast path takes a free slot only while nobody waits in it, so a
newcomer between two readings cannot take the slot ahead of an older
waiter. A command its rules forbid is refused rather than held, since it
starts nothing. DAEMON_MEASUREMENTS records the Perf workflow's matched
screen of the branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Load gate: only a command that would start now is held; a small load limit stays one

The gate held every foreground shell call before the turn looked at its
verdict or its rules, so a denial, a forbidden command, one a rule asks
about with no gate, or an escape no gate allows sat parked until the
load fell. Now only a call that would start at once is held; a gated
call waits for its verdict instead and starts once allowed. A `[daemon]
load` below 0.005 was rounded to 0, which is no gate; it is passed whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: a lead keeps so many task windows open, closing the least recently used

Past `[sonny] task_windows` (32 by default, 0 for no limit, in /config),
a new task window closes the one the person used least recently, as VS
Code's editor limit does. Each window's own Sonny marks its agent's file
in ~/.agent/sonny/used/ when the person focuses, types or clicks there,
at most once every 10 s; the lead reads those times only when it needs
room. A window whose task needs the person, failed, or holds a block it
asked for is never closed for room. A window closed for room stays
closed while its task works on, and /status opens it again. The limit
is read again on the layout's worker whenever the config file changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: close only the lead's own task windows for room, and keep those their windows say need the person

Two leads of a folder share its multiplexer home, so a lead now counts
and closes only its own tasks' windows. What holds a window is no longer
only what this lead heard since it started: each window's Sonny keeps a
file in ~/.agent/sonny/held/ while its agent failed, waits on an
approval, or has a question open in it, and leaves it for the next
window until its status says otherwise. So a lead started again, which
hears neither old failures nor open questions, still keeps those
windows. The protected set is built in one place (room_for), tested
from a lead's state through to the window it closes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: rustfmt the task window protection

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: a window's held file always ends saying the latest, and a window opened again on a failed agent keeps it

Writes asked one after another run one at a time and each writes what
the window wants now, so an earlier write finishing late cannot undo a
later one. At start, a window with no turn running reports its last
turn's end as live: a failure (not a model that said nothing) is
"error", so its held file stands across a restart of both the window
and its lead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: task windows count by window, and a lead started again still reopens one it closed for room

Tasks shown together (a split beside another task) are one window: they
count once against task_windows, and close together, held whole when any
of them is. A window holding a lead's or another lead's blocks is not a
task window. Which windows a lead closed for room is kept in
~/.agent/sonny/aside/, so /status opens one again after the lead
restarts, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Sonny: a cmux task tab counts as its own window against task_windows

Backend::tab says what a window placement opened a block in: the window
for Rex, the tab for Herdr, and the tab itself for cmux, whose task tabs
share the lead's pane.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: a detached command keeps its lasting slot while what it left in its group runs

A launcher that starts a service with `cmd &` and exits gave its
--max-lasting slot back while the service ran on, so launchers repeated
could keep any number of services past the bound. The waiter already
looks for the command's group each second until it is empty, keeping the
bot's socket listening; the slot and the sandbox's hold now go with the
listener, once the group is gone or the pull cord ends it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Bench: the load gate on a busy machine, against none

bench/load_gate.py runs CPU-bound commands from many workers with the
gate off, at the CPU count and at the default, and probes a plain turn,
a short command and a control request meanwhile. Recorded under #575's
measurements, which ran with the gate off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: an exited, unreaped member of a detached group holds no slot

kill(-pgid, 0) also answers for a zombie, and an init that does not reap
orphans, as some containers run, leaves one for good: the slot would stay
taken until a pull. On Linux the group now counts only members that are
not zombies, read from /proc off the runtime thread. A test in its own
binary makes itself a subreaper that never reaps and checks the slot frees.

The load-gate screen now gives work commands the shell's longest timeout
and counts a run only if every one finished its work, and samples its
three probes on their own connections, so a held `true` does not stop the
other two. Rerun: same shape, gate at the CPU count 1.75x the wall time,
short commands p95 10 s; every work command finished in every run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: a detached service whose main thread exited still holds its slot

/proc shows a process whose main thread called pthread_exit as a zombie
while its other threads run. A zombie member now counts as running while
any of its tasks is not a zombie. A second test in the reaping binary
builds such a service with cc and checks it keeps its place, then frees it.

The gate screen's probes wait for their own turns however long the gate
holds them, so the slowest samples are kept, and a probe that never ends
fails the run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: read a group member's /proc stat as bytes

A process's name in /proc/<pid>/stat is any bytes, and the kernel's cut to
15 can split a UTF-8 character, so reading it as a string dropped a live
service and freed its slot. Stat files are now read as bytes and only the
ASCII fields after the last ')' parsed, for the process and its threads.
A third reaping test runs sleep under a 16-byte name ending in é.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: three agreeing /proc walks before an exited-only group frees its slot

A walk of /proc is no one moment: it can list a parent before it forks a
replacement and read its stat after it exits, never seeing the child, so a
fork-and-exit chain could read as empty and lose its slot and pull cord.
kill(-pgid, 0) still frees a group at once when nothing answers; where only
exited members are seen, three walks a second apart must agree. The
reaping tests wait for that, and docs/RUST_PROTOTYPE.md says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Daemon: free an exited-only group's slot at the third agreeing walk

The waiter slept a second after the third walk before letting go; it now
lets go at once. The contract test waits up to 6 s for the slot, as the
reaping tests do, so it holds where nobody reaps the killed service.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Lookout: replies read on a pool of connections, so 1,000 tasks' ends reach their leads in seconds

The daemon answers one read at a time from each session, so the lookout's
one connection read a busy fleet's replies one by one, 8 to 10 s behind.
It now reads on a pool, one connection per logical CPU; a completed turn's
reply is its checkpoint, read in one request; a note waits only for reads
that started before its news settled, and holds as many tasks as its bytes
allow. The screen measures leads x tasks per lead over fixed rounds, and
counts every ended turn as told or untold from the lookout's own log.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Bench: a lookout note counts as delivered when a busy lead absorbs it too

A note a busy lead takes into its running turn, as a steer or an attach,
finishes as `steered` with no start of its own; the screen now takes its
absorption as its delivery, and reports how many notes reached their lead
each way and how many never did. Rerun on main: 4,000 of 4,000 told in
each shape, every note delivered, p95 2.9 s (10x100) and 4.2 s (100x10).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Lookout: budget a note's message lines as written; a turn is told once its note reaches the lead

A message counted as LINE_BYTES however long its task's and writer's
names were, so with the 32-task cap gone a note of 1,000 tasks with long
names wrote about 400 KB of lines on a 192 KB budget, past the daemon's
prompt limit. Each message now counts as the longest line `said` can
write for it.

The screen counted a turn as told when a note naming it was sent, even
if that note never reached its lead. It now needs the note delivered;
the submit time still counts every note sent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Store: plan statements once, so cached joins stop being parsed again on every use

SQLite 3.54.1 (from #544) marks a join that binds an `x = ?` value to be
planned again when that value changes, and counts the statement cache
clearing its bindings as a change. Every reuse of such a statement was
parsed and planned again: history_items did it on all of its calls, about
half a millisecond each, which doubled its time. Both store connections
now turn on SQLite's query planner stability guarantee; the store runs no
ANALYZE, so a bound value could never improve a plan.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Store: write out a GLOB pattern's prefix bound, which stable plans no longer derive

With plans that ignore bound values, SQLite no longer narrowed a GLOB
match on a name to its literal prefix's index range, so `list` with a
name pattern, history search and `usage` could read every bot. Each now
bounds the index itself (name >= prefix AND name < prefix || x'ff'); the
page cursor and the prefix make one lower bound, so the range is the
same whichever term the planner reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

* Plan audit: plan with the stability guarantee, as the daemon's connections do

Since #617 the store's connections plan without reading bound values, but
bench.query_plans still planned with them: binding its sample values let
SQLite derive a GLOB prefix range the daemon never gets, so a query that
lost its index range would pass the audit. The audit now connects the way
the store does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGF9fn2EXiBvzYrQtaA

---------

Co-authored-by: Claude <[email protected]>
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.

3 participants