Skip to content

Daemon: client requests that wait keep no task or timer of their own - #434

Merged
lydakis merged 30 commits into
mainfrom
claude/project-thread-fwzozw
Oct 30, 2026
Merged

lydakis merged 30 commits into
mainfrom
claude/project-thread-fwzozw

Conversation

@lydakis

@lydakis lydakis commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Closes #406, which is left over from #393 (Codex finding #393 (comment)). This follows the plan George agreed to there.

AGENTS.md says the run loop owns the one wake-up schedule. Three kinds of wait still kept something live of their own:

  • A client wait with timeout_ms spawned a timer task in Handles::attach.
  • A parked turn whose wait has a deadline spawned a timer task too, through the same path.
  • An approve_step waiting for its step's decision spawned a task. It also kept a timer while a gate could lapse.

What changes

  • One schedule in the handles registry. Each deadline is an entry in Handles' schedule, a BTreeSet of (at, Due), where Due is a wait (by waiter and generation) or a step's lapse (by approval). The run loop has one arm, handles.due(), which sleeps until the first entry. A sooner entry, or a step that something touched, wakes it early. A waiter that leaves (answered, forgotten, its session closed, replaced) takes its entry with it.
  • Steps are answered from the run loop. The store no longer keeps a Notify per waiting step. Once a step's verdict, or its turn's or call's end, is committed, it is published as Publication::Stepped(approval). That happens after the group commits, as approver announcements already are. The publisher passes it to the handles, and the run loop then runs step_check and sends the waiting approve_step its reply. The Service keeps who to answer (stepping, by approval).
  • Closing a session abandons that session's steps on the run loop, through the same check_step path.
  • Nothing changes on the wire, and there is no protocol or schema bump. docs/RUST_PROTOTYPE.md and AGENTS.md now say how a waiting request is held.

Tests

  • New unit test, handles::tests::every_deadline_is_one_entry_on_the_schedule_and_none_outlives_its_waiter:
    • A forgotten waiter's deadline leaves the schedule.
    • A step's lapse moves rather than adds, and clears when it is set to none.
    • A touched step ends the sleep at once.
    • A due wait resumes its turn, and the schedule ends empty.
  • cargo test --workspace passes, and clippy with -D warnings is clean.
  • Runtime modules test_answered (the step tests: lapse, a client disconnecting, an answer to the call, the paused clock), test_approvals, test_daemon (waits with timeouts), test_lifecycle and test_paced_park pass against release builds.
  • The perf screen comes from this PR's Perf run and is recorded in docs/DAEMON_MEASUREMENTS.md once it lands.

claude added 24 commits October 29, 2026 23:27
…s installed

Links, files and pages opened through xdg-open alone, so a Linux machine
without it showed only the spawn error. The open crate tries the openers
a desktop may have (xdg-open, gio, wslview and the rest); when none is
there, the link goes on the clipboard and the notice says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDsJVnkrdmmdTXFLin
Sonny declared its tools on a bot only when the bot's window opened, so
an agent no one opened after an upgrade, such as a task out of sight,
kept the tools it was made with and never got exec. When the lookout
starts, it brings every agent Sonny declared on up to this build's tools,
as opening its window would: a lead stays a lead, a new gated tool is
gated as the bot's mode gates the rest, and a busy agent is tried again
each minute.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDsJVnkrdmmdTXFLin
A request signed before the machine slept and received minutes later is
refused as expired, and the turn failed for good. A 401 or 403 whose
x-amzn-ErrorType is one of the clock-skew codes the AWS SDK for Java
retries now retries at once as provider_signature_expired, and the retry
is signed with the time then, as every attempt already is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDsJVnkrdmmdTXFLin
An agent another client made could share a tool's name with one of
Sonny's (memory, plan), and the lookout would have taken it for Sonny's
and added tools to it, an ungated goal check among them. Ownership is now
a declared tool answered by Sonny's lookout, which no other client's tool
carries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDsJVnkrdmmdTXFLin
Any bot could already subscribe through the agent CLI and the lookout's
files, and the lookout knows no leads, but only a lead was given the
tool, so a monitor needed a hand-written subscription file to hear a
source. The tool now goes to every agent Sonny declares on, gated as
before; each subscribes for itself.

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

A declared tool with "steps": true is never gated as a whole. The client
answering its call asks the bot's gates about one step at a time, the way
Codex approves each nested call of a code-mode script instead of the
script. A step is an ordinary approvals row (call id CALL/STEP, step_of
naming the call), announced, listed, served and answered like a gated
call, and its decision is recorded in a step_decided event. The turn
never waits on a step. While a step waits, its call's answer clock stops.

A step lives only as long as the request waiting on it. A closed
session, an answer to the call, the turn's end and a restart each drop
it. Protocol 24, schema 63.

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

exec is declared with "steps": true, so the script is not gated as a
whole. Each tools.mcp__S__T call is checked by its server's
default_tools_approval_mode or tools.TOOL.approval_mode, under Codex's
names and rule:
- auto (the default) asks for a tool marked destructiveHint unless it
  is also marked readOnlyHint, which wins.
- writes asks unless the tool is read-only.
- prompt always asks.
- approve never asks.

Asking goes through approve_step to the agent's own gate: full runs at
once, auto is judged and ask goes to the person. The script's clock stops
while a call waits, as the call's clock does in the daemon. A denial
rejects the call with its reason. Sonny's approval prompt marks a
script's call, and step_decided refreshes it.

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

- A script whose call waits for the gate gives up its place among the
  four running scripts and takes one back once the verdict comes (Codex
  review). Four scripts waiting on a person would otherwise hold back
  every other agent's.
- approve_step takes a step's tool name of up to 512 bytes. A script's
  identifier for a 64-byte server and tool is longer than 128.
- The schema 62 test drops the new partial indexes before their columns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDsJVnkrdmmdTXFLin
…time, refused steps for the judge

A script waiting for a verdict gives up its running place but keeps its
heap, so the scripts alive are bounded on their own (16, at most 4 GB at
the memory cap). While a call waits, the interrupt checks measure the
JavaScript still running beside it, which spends the script's time, so a
spinning branch cannot outlive its timeout. A step its gates refused is
recorded with its arguments and denied, and a judge of a later call sees
it among the turn's refused calls unless it was then allowed as it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDsJVnkrdmmdTXFLin
On a busy lookout, retaking a place could spend a short script's whole
time after its verdict came; now it waits the way a new script does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDsJVnkrdmmdTXFLin
A step its gates allowed now joins the turn's calls a judge of a later call
reads, as running until the client says how it ended with the new
step_result request, which records step_completed. Sonny reports each
allowed nested call once it has run, so a one-time effect a script already
did counts as used up when it asks for another.

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

A call that takes steps skips the gates of the call as a whole, so a
sandboxed bot redeclaring an inherited tool with steps could run it
ungated through a client that never asks for steps.

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

# Conflicts:
#	docs/DAEMON_MEASUREMENTS.md
…-fwzozw

# Conflicts:
#	docs/RUST_PROTOTYPE.md
A lookout that restarts and answers a pending exec call again started its
step ids over at 1, so the agent's judge took the first gated call as one
it had reviewed already and gave no verdict. Each answering now prefixes
its step ids with its own id: the time, the process and a count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDsJVnkrdmmdTXFLin
A client's wait with a deadline held a timer task, and so did a parked
turn's; an approve_step waiting for its step's decision held a task, and a
timer while a gate could lapse. Now every such deadline is one entry in the
handles' schedule, which the run loop sleeps on. A step's answer, or its
turn's or call's end, is published after its commit, and the run loop
checks the step and answers its approve_step. A session that closes drops
its steps from the run loop as well.

Closes #406.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGDsJVnkrdmmdTXFLin
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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-10-30T05:55:36.499601Z 7741fc3 New commits
🔒 Security Review ✅ Completed 2026-10-30T05:58:23.628171Z 7741fc3 New commits
ℹ️ 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: c3035ac1d1

ℹ️ 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/mod.rs Resolved
Comment thread src/store/db.rs Resolved
Steps that come due together are checked in one storage job, so they
commit together, and the run loop goes on while it runs: its result comes
back through a JoinSet arm. A step already being checked is checked again
once that check is back.

A group that removes a waiting step's registration and then fails to
commit now puts it back, as SQLite does its row, so a later answer or turn
end still tells of the step.

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

@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: 93b93e1407

ℹ️ 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/mod.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: 53bb9a8057

ℹ️ 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/mod.rs Resolved
@lydakis
lydakis merged commit faaa92b into main Oct 30, 2026
5 checks passed
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.

Daemon: client request waits (approve_step, wait) join the run loop's wake-up schedule

2 participants