Skip to content

Daemon: bots filters by maker; the perf screen sees Sonny - #573

Merged
lydakis merged 68 commits into
mainfrom
claude/project-thread-je4o8y
Nov 1, 2026
Merged

lydakis merged 68 commits into
mainfrom
claude/project-thread-je4o8y

Conversation

@lydakis

@lydakis lydakis commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Item 6 of the fleet performance proposals, last two parts: a created_by filter on bots, and a perf gate that runs on Sonny changes.

A created_by filter on bots (protocol 40)

Without a fleet view, every Sonny paged all running bots every three seconds and kept its own tasks locally. Now bots filters at the source.

  • bots takes created_by_id and keeps only the bots that the bot with that id made.
  • It reads from a new partial index on (created_by_id, name), bots_maker. The index is created with CREATE INDEX IF NOT EXISTS, like the store's other indexes, so there is no schema change.
  • It combines with name and active, and pages like any other bots page.
  • The filter takes an id, not a name, so a maker that reuses an earlier bot's name sees none of that bot's children.
  • agent ls --created-by BOT resolves BOT to its id and lists what it made.
  • Sonny's read_running_tasks asks for {"active": true, "created_by_id": <its own id>}.
  • Tests:
    • bot_pages_filter_by_maker_from_its_own_index covers the filter and its combinations, paging, name reuse, and the query plan, which uses bots_maker with and without active.
    • merged_schema_preserves_stores_from_both_published_branches now drops the new index before it drops the column.
    • The footer's agents-at-work test asks by the agent's id.
  • Protocol 40: Command rules: Codex-style allow, prompt and forbidden rules replace a bot's unsandboxed list #572 (command rules) merged first with 39.

The perf screen sees Sonny

  • perf.yml now also runs on sonny/**, client/** and its own bench files. It builds Sonny for both sides.
  • It runs bench.sonny_screen alongside the daemon benches, alternating base and head as they do. The bench covers:
    • lookout: sonny lookout over 10 leads with 10, 100 and 1,000 subscribed tasks. It records the time until every lead is seated, the CPU per thousand streamed deltas, and how late a lead hears that a task's turn ended.
    • quiet window: one quiet lead's Sonny in an 80x24 pseudo-terminal while the 1,000 tasks run turns elsewhere. A pass-through socket in front of the daemon's counts what the window asks for and reads back, by op and in bytes.
    • sky: sonny sky --replay 1h at its fastest speed (512x), sampled from launch until its footer says it has caught up with now (read with pyte, a measurement-only dependency). Its CPU is compared per thousand lines the daemon sent, since each side's fleet writes a different amount of history.
  • A run is refused if a window or the lookout exits, or a replay never finishes.
  • perf_gate adds a sonny group of rows. Like the daemon's timings, these warn and never fail.

Locally, with release builds and 1,000 busy tasks elsewhere, the quiet window reads 0.02 KiB/s from the daemon, down from 34.41 KiB/s before this change. Its CPU went from 7.49 to 5.03 ms/s. The CI's matched screen agrees: quiet window reads fell 97.9% (29.7 to 0.6 KiB/s) and its CPU 10.1%, and the daemon's own timings did not move. Both are in docs/DAEMON_MEASUREMENTS.md.

The same bench also shows the next limit, recorded there too. At 1,000 subscribers, a lead's notes named only 660 of 5,000 task turns that had ended within ten seconds, at a p95 of 20 s. A lead takes notes one turn at a time. That is the lookout's batching question, not this PR's.

Docs

  • docs/RUST_PROTOTYPE.md: protocol 40, under the bots filters.
  • docs/CLI.md: ls --created-by.
  • sonny/FEATURES.md: the footer's agents-at-work row.
  • docs/DAEMON_MEASUREMENTS.md: the window's numbers and the matched screen.

🤖 Generated with Claude Code

claude added 30 commits October 31, 2026 18:55
…eader 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
… 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
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
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
…#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
…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
# Conflicts:
#	docs/DAEMON_MEASUREMENTS.md
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
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
…n 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
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
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
# Conflicts:
#	src/server/mod.rs
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
…er 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
…aken

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
# Conflicts:
#	docs/DAEMON_MEASUREMENTS.md
claude added 12 commits November 1, 2026 01:15
# Conflicts:
#	docs/DAEMON_MEASUREMENTS.md
…ials 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
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
…cenarios

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
# Conflicts:
#	docs/DAEMON_MEASUREMENTS.md
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-01T03:47:07.538591Z fc966b7 New commits
🔒 Security Review ✅ Completed 2026-11-01T02:18:35.035779Z 669b6b6 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: 669b6b66dd

ℹ️ 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 bench/sonny_screen.py Resolved
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

@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: 5bfb8cfe2a

ℹ️ 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 bench/sonny_screen.py Resolved
Comment thread bench/sonny_screen.py Resolved
…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

@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: 78f68e4717

ℹ️ 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 bench/sonny_screen.py Resolved
…layed

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

@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: 49e18a48a3

ℹ️ 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 bench/sonny_screen.py Resolved
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
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
@lydakis
lydakis merged commit 6bba79d into main Nov 1, 2026
10 checks passed
lydakis pushed a commit that referenced this pull request Nov 1, 2026
# Conflicts:
#	client/src/lib.rs
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.

2 participants