Skip to content

Approve each call an exec script makes, as Codex does, instead of the script - #393

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

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

Conversation

@lydakis

@lydakis lydakis commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Before this PR, an exec script was gated as a whole: one verdict covered every MCP call inside it, reads and sends alike. Codex's code mode approves each nested call instead, and decides which calls ask first from the tool's MCP annotations. This PR adopts that pattern, with auto as the default mode.

There are two commits. The daemon change was discussed in the project thread first.

1. Daemon: approve_step

  • A declared tool can now carry "steps": true, but only together with answered_by. Such a tool is never gated as a whole. Its call starts at once, and the gates that name the tool judge its steps instead.
  • The client answering the call sends {"op":"approve_step","bot","turn","call_id","step","name","arguments"}.
    • Under no gate, the reply is an allow at once.
    • Otherwise the step becomes an ordinary approvals row with call id CALL/STEP and step_of. It is announced, listed, served and answered exactly like a gated call. The approver, a person, or any client holding the tag can answer it.
    • The reply waits for the decision. It waits off the service loop, the same way wait defers its reply.
  • Each decision is recorded in a step_decided event. Denials count toward the bot's denial counts, as a gated call's do.
  • A gate that lapses denies the step and nothing more. The turn never waits on a step: next_lapse, lapses and reannounce skip step rows.
  • While a step waits, its call's answer clock stops. The call cannot run out, and its parked turn has no deadline. Once the last step is decided, the call gets back the time it had left, and the turn is told: a notify if it is running, a wake-up if it is parked.
  • A step lives only as long as the request waiting on it:
    • Asking again for a step that is still waiting is refused with step_waiting.
    • A closed session takes its waiting steps with it.
    • An answer to the call ends its steps.
    • The turn's end ends them too.
    • A restart drops them all.
  • Protocol 24 and schema 63, which adds approvals.step_of and answers.paused_ms, each with a partial index so the query-plan audit stays scan-free. Everything is documented in docs/RUST_PROTOTYPE.md.

2. Sonny: per-call approval by Codex's approval_mode

  • exec is declared with steps: true. The lookout's start-up tool refresh (Open links without xdg-open, give agents Sonny's current tools and subscriptions, retry Bedrock clock-skew refusals #382) brings existing agents over to it.
  • Each tools.mcp__S__T call is checked against its server's default_tools_approval_mode or tools.TOOL.approval_mode, using Codex's names and rule:
    • auto (the default) asks for a tool marked destructiveHint, unless it is also marked readOnlyHint, which wins.
    • writes asks for every call except a read-only tool's.
    • prompt always asks.
    • approve never asks.
  • Asking means approve_step to the agent's own gate:
    • In full mode, nothing waits.
    • In auto mode, the judge decides.
    • In ask mode, the person decides. Sonny's prompt marks the call as a call in a running script.
  • The script's 10-minute clock stops while a call waits, matching the daemon's clock. A denied call rejects with the reason, and the script can catch it.
  • The new keys are documented in docs/SONNY.md and the README.

Tests

  • New runtime tests, tests/test_answered.py::StepTests (7 tests):
    • An ungated step is allowed at once.
    • Gated steps get an allow and a deny, are listed with step_of, and a second ask for a waiting step is refused.
    • The paused clock: once a step is allowed, the call is answered, and an unanswered call runs out of what was left.
    • A lapse denies only the step.
    • An answer to the call ends its steps.
    • A client that disconnects takes its step with it.
    • Validation refusals.
  • New Rust tests:
    • Schema 62 migrates.
    • Config parsing and Codex's rule table.
    • A Sonny exec test against a stand-in gate. It checks that a read-only tool doesn't ask, that a denied call rejects with its reason, that approve skips asking, and that a 300 ms script survives a 600 ms wait for its verdict.
  • Local results:
    • cargo test --workspace passes, and cargo clippy --workspace --all-targets -D warnings is clean.
    • Every runtime module passes. test_served and test_acp needed bubblewrap installed on this machine, and three bench modules needed psutil.

…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
@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-30T04:18:26.110567Z 4f6478d New commits
🔒 Security Review ✅ Completed 2026-10-30T04:22:35.297806Z 4f6478d New commits

Security findings

Advisory findings (1)

ℹ️ 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: 613954b794

ℹ️ 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/server/mod.rs Resolved
Comment thread sonny/src/exec.rs Resolved
…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

@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: ce64b892d7

ℹ️ 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 sonny/src/exec.rs Resolved
Comment thread sonny/src/exec.rs Resolved
Comment thread src/store/db.rs Resolved
…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

@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: 4b4b299027

ℹ️ 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/store/db.rs Resolved
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 Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 4b4b299027

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread src/store/db.rs Resolved
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

@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: a74a9c3d81

ℹ️ 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/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: 21a7b72ac6

ℹ️ 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 sonny/src/exec.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: eee140d2e7

ℹ️ 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 sonny/src/exec.rs Resolved
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
@lydakis
lydakis merged commit 5d6fb9e into main Oct 30, 2026
5 checks passed
lydakis pushed a commit that referenced this pull request Oct 30, 2026
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