Repository navigation
Thread scheduled runs and refuse classes whose tool approvals cannot be raised - #87
josephschorr wants to merge 9 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
A cron tick carries no message from a person, so a scheduled session's outbound thread was rooted by the agent's first output. A run that sent a single reply landed as a bare message in the channel with no thread under it, and its progress status had no thread to attach to. The bento kind now describes its trigger, so the thread opens with the schedule's name and interval and the agent's output lands beneath it.
A tool's permission check can name a resource type defined only in rawZed. Such a type composes and answers checks but has no standing, so the first denied call dead-ends in the approval flow with "declares no standing" while the class reports Valid=True. The AgentClass controller now sets Valid=False (ToolApprovalUnroutable) when a check names a type with no resolved standing and a denial of that check would ask a human: every check under enforcing mode, and under permissive mode only external tools and checks marked enforceMode always. Disabled mode is never refused.
2f136e9 to
f030fb6
Compare
samkim
left a comment
There was a problem hiding this comment.
This PR makes a bento schedule open its outbound thread with a "Scheduled run of ()" line, and makes an AgentClass go Valid=False (ToolApprovalUnroutable) when a tool check names a resource type with no resolved standing and a denial would ask a human. Both changes work for the cases their tests cover, and the targeted unit tests pass; the admission check is broader than the runner in one case (first issue below).
Verdict: changes requested. The admission check needs to respect allowSubcommands before this merges; the rest are nits.
Issues, highest first:
- The new admission check refuses a class over toolkit subcommands that the class's toolspec
allowSubcommandsexcludes and that can never be called, so a healthy existing class can flip invalid on upgrade for a subcommand it cannot dispatch (see inline,tool_approval_standing.go:114). - Becoming a
TriggerDescriberis kind-wide, so bento Channels without agenerateblock are also offeredupdate_opening_summaryalthough no opening line is ever posted (see inline,trigger_description.go:34, unconfirmed impact). - The
denialAskscomment claims it mirrors the hook "exactly"; pin-drift and runtimeEnforceOverrideasks are not covered (see inline, comment only). - Nits: the reconcile test table has two divergent cases and its permissive case asserts only a negative (
tool_approval_standing_reconcile_test.go:34); the error does not say when the offending check is a permission variant; the scheduled opening line has no bronzethread bundle, which the repo guidance asks for with new user-visible behavior.
Questions for the author:
- When a bento Channel has no
generateblock, should the runner still treat the session as having an opening (pinned message andupdate_opening_summary), or should that depend on the Channel rather than the kind? - Accepted upgrade behavior: are you comfortable that existing classes flip to
Valid=Falsewith running sessions unchanged? (Pre-existing behavior for other reasons; confirming it is intended here.)
This review was drafted by an automated pipeline and checked before submission.
The admission check walked every subcommand of every toolkit a class binds, so a class could be refused over a subcommand its toolspec excludes and that is never dispatched. It now walks only what each toolspec's allowSubcommands admits, taking the union across toolspecs that share a toolkit, and counts the toolkit-wide default only when an allowed subcommand inherits it. The reading of allowSubcommands is one predicate in the toolspec spec package, used by the validator that decides dispatch, the sandbox tool's permission surface, and both AgentClass walks. The surface and the fact-source walk previously read an empty list as "no narrowing" while the validator denied everything; they now agree with the validator. Whether a denied check asks a human, and whether permissive mode lets it through, are methods on authz.Permission shared by the tool-call hook and the admission check, so the check is the declared part of the hook rather than a description of it. The refusal message now says which toolspec allows the call and when the check is a permission variant.
update_opening_summary and the pinned-message projection were gated on the input kind being able to describe its triggers. A kind does not describe every one of them: a bento Channel with no schedule gets no opening line, and neither does a pull-request kind handed a key that names no pull request. Those sessions were offered a tool whose every call reported that there was no pinned opening message to update. Both now ask whether the session itself was given an opening line, which is recorded on it at creation. The kind-name lookup they used has no remaining callers and is removed.
|
Pushed c561a29 and 3e41dc8; the three inline threads have replies. The body-only items:
Questions:
|
Admission stopped holding an excluded toolkit subcommand against a class on the grounds that it is never dispatched. That is true, but the dispatch-time validator runs after the tool-call authorization hook, and the hook resolved the excluded subcommand's permission regardless of the toolspec. An agent that tried one anyway could still raise an approval for a call that cannot run, or, where the checked type has no standing, hit the unroutable approval the admission check exists to prevent. In permissive mode the call was let through to dispatch. A tool can now say that a call can never be dispatched, and the hook asks before it resolves a permission. The sandbox tool refuses a subcommand its toolspec does not allow and an argv that names no subcommand, reading the allow list through the predicate the validator uses. The hook denies such a call outright in enforcing and permissive mode alike, with no check and no approval ask, and records the refusal with the reason. The validator is unchanged and remains the backstop.
The previous change refused a call the toolspec excludes inside the tool-call authorization hook. The plan gate runs one position earlier, resolves a handle for every call from the tool's per-call permission without consulting the toolspec, and the executor publishes a hook's approval ask before the next hook runs. So an excluded subcommand was still recorded against the plan, and where its handle sat inside the phase ceiling, or the agent justified it, it raised a phase or amendment card before the refusal was reached. The refusal is now its own hook, ahead of the plan gate, trifecta and tool-call authorization and behind content inspection, so no gate sees a call that can never run. It is registered in every tool-call mode, since the plan gate activates on its own setting, and it still records one authz decision with the reason. Tool-call authorization no longer consults the tool itself.
samkim
left a comment
There was a problem hiding this comment.
Round 2 (commits since the last review: c561a29, 3e41dc8, 8dbde21, d4c8605). All 3 earlier issues are verified fixed, and the round 1 body items are addressed (the bronzethread bundle for the scheduled opening line is reasonably deferred).
Verdict: ready after the inline nits. The blocking item is gone. Admission now follows allowSubcommands through one shared predicate, the opening tool is offered only to a session that was given an opening line, and the admission check and the hook share their ask predicates.
New behavior in this round is the undispatchable_call hook, which refuses a call the toolspec excludes or that names no subcommand, before the plan gate and ToolCallAuthz. I found only nits:
- Unparseable args are skipped with no log, and the comment says something untrue for
toolCalls.mode: disabled(see inline,undispatchable.go:76). - The refusal message prints the bare command as
subcommand ""(see inline,subcommand_permission.go:172). - Builtin-parser toolkits skip the refusal that admission relies on. No builtin parser exists today, so no live impact (see inline,
subcommand_permission.go:158; relatedtool_approval_standing.go:194).
Questions for the author:
undispatchable_callruns aftertool_guard(15) andcontent_guard(18,order.go:44), so a call that can never run can still consume a tool-guard rate slot or, with an Approve inspector policy, raise a content_inspection card. You kept content inspection first on purpose. Do you also want tool_guard ahead of this hook, or is the rate/breaker accounting of such calls acceptable?- For the builtin-parser gap, do you prefer a parser-interface method that both the sandbox tool and admission consult, or documenting that builtin parsers are out of scope until one is registered?
This review was drafted by an automated pipeline and checked before submission.
| // credential. | ||
| func (s *SandboxTool) RefuseCall(args map[string]any) (string, bool) { | ||
| tk := s.opts.Toolkit | ||
| if tk == nil || s.opts.Spec == nil || tk.Parser.Kind == "builtin" { |
There was a problem hiding this comment.
[nit] Builtin-parser toolkits skip the undispatchable refusal, which admission relies on
Problem: RefuseCall returns false when tk.Parser.Kind == "builtin", so for such a toolkit an excluded subcommand still reaches ToolCallAuthz. permissionSources (pkg/controllers/agentclass/tool_approval_standing.go:194) skips excluded subcommands on the assumption that the call is refused first, so a class can be Valid=True while a call to an excluded subcommand with an undeclared check type is denied with a dead-end ask. Also a string branch on the parser kind in a consumer, against the "registered, not branched on" rule. No builtin parser is registered today, so there is no live impact.
Verify: confirm still no parser.kind: builtin toolkit is registered or shipped (grep -rn 'builtin' pkg/tools/toolspec/parser). If none, this can be a comment; otherwise add a method on the parser abstraction (for example whether it can identify a subcommand from an argv) and call it here instead of comparing the string, and have admission treat toolkits where it is false as not narrowed. Which of the two is a design choice for the author.
Test: a sandbox test with a builtin-kind toolkit asserting the documented behavior; go test ./pkg/agent/tool/sandbox/ -run RefuseCall.
Constraints: CLAUDE.md pluggability rule "New variants of an aspect get registered, not branched on".
There was a problem hiding this comment.
Took the documentation route in c916591: nothing registers a builtin parser outside a validator test, so RefuseCall and permissionSources now both say a builtin-parser toolkit is not narrowed by the refusal, and that registering one means giving parser.Parser a way to say which subcommand an argv selects, consulted by both sites in place of the kind comparison. An interface method with no implementer to shape it seemed premature; TestSandboxTool_RefuseCall_BuiltinParserToolkitIsNotNarrowed pins today's behaviour so that change has to be made on purpose.
There was a problem hiding this comment.
Deferred, acceptable. The doc comments state the builtin-parser gap and what the first builtin parser must change, and TestSandboxTool_RefuseCall_BuiltinParserToolkitIsNotNarrowed pins today's behaviour. It can wait because no builtin parser is registered, so such a toolkit fails at dispatch anyway.
…ents The hook passed on arguments that did not decode without a word, and its comment said tool-call authorization denies them, which is untrue under toolCalls.mode disabled where that hook is not registered. It now logs the tool, the mode and the decode error, and the comment says what actually stops such a call: the tool's own decoding at dispatch, and tool-call authorization when it is registered.
… toolkits A refusal for the bare binary read as subcommand ""; it now says (bare command), the wording the AgentClass controller already uses. A toolkit with a builtin parser is not narrowed by the refusal, while the admission walk skips excluded subcommands whatever the parser. No builtin parser is registered, so this is documented as out of scope at both sites, with what registering one has to change, and pinned by a test. A second test pins that the sandbox tool refuses arguments that do not decode on both execute paths, which the hook relies on when it stands aside for them.
|
Answers to the two questions from the round 2 review:
|
samkim
left a comment
There was a problem hiding this comment.
Round 3. Checked commits 82548fb and c916591 (plus a clean merge of main, 07b9acb) since the last review at d4c8605. The delta only touches the undispatchable-call hook, the sandbox tool's refusal message, and comments in tool_approval_standing.go.
Verdict: ready. All 6 earlier threads are verified or acceptably deferred (5 verified, 1 deferred). The targeted tests (pkg/agent/tool/sandbox, pkg/authz/hooks, pkg/controllers/agentclass) pass at the head.
What was checked:
- The hook now logs at INFO when it cannot read tool args, and the comment correctly says the sandbox tool's own decode refuses them (
sandbox_tool.go:325). - The refusal message names the bare command as
(bare command). - The builtin-parser gap is documented at both sites (
subcommand_permission.go:150-182,tool_approval_standing.go) and pinned by a test. No builtin parser is registered, so no live impact. The kind-string branch atsubcommand_permission.go:192has to go when the first builtin parser lands, as the doc comment says.
No new issues. Your answers to the two round-2 questions (tool_guard order, builtin-parser scope) are accepted.
One observation outside this round's delta, not a blocker: ActiveHooks (pkg/authz/hooks/activation.go:87), the table the runner and oap agent authz share, has no row for undispatchable_call, so the CLI's pipeline view omits the hook that refuses these calls. Worth a look in a follow-up.
This review was drafted by an automated pipeline and checked before submission.
| // credential. | ||
| func (s *SandboxTool) RefuseCall(args map[string]any) (string, bool) { | ||
| tk := s.opts.Toolkit | ||
| if tk == nil || s.opts.Spec == nil || tk.Parser.Kind == "builtin" { |
There was a problem hiding this comment.
Deferred, acceptable. The doc comments state the builtin-parser gap and what the first builtin parser must change, and TestSandboxTool_RefuseCall_BuiltinParserToolkitIsNotNarrowed pins today's behaviour. It can wait because no builtin parser is registered, so such a toolkit fails at dispatch anyway.
Summary
Two fixes for sessions that no person started, both found from one failing scheduled run.
Scheduled runs get their own thread
A session started by a schedule had no opening message, so its thread was rooted by whatever the agent posted first. A run that sent a single reply showed up as a bare message in the channel, with no thread and nowhere for progress updates to appear.
Scheduled sessions now open their thread with a line naming the schedule, the same way sessions started by a pull request already do, and the agent's output lands beneath it.
The tool that lets an agent update that opening message is now offered only to sessions that actually have one. Previously it was offered to every session of a kind that can post opening lines, including ones that never got a line.
An AgentClass is refused when a tool approval could never be raised
A tool's permission check can name a resource type that has no declared standing. Such a class looked healthy, but the first denied call failed outright because there was no way to decide who could approve it.
The AgentClass now reports
Valid=Falsewith reasonToolApprovalUnroutable, naming the tool and the resource type, whenever that failure is certain:Only tool calls the class can actually make are considered. A toolkit subcommand that the class's toolspecs do not allow is ignored, since it can never run: if an agent tries one anyway, the call is refused outright, before any permission is checked or approval requested.
Upgrade note
An existing class that has a tool check on a resource type with no standing, and runs in a mode where a denial asks for approval, will become
Valid=Falseafter upgrading. The condition message says which type needs a standing declared. Checks on tool calls the class cannot make do not count, so a class is never refused over a subcommand it does not allow.Testing
Unit tests cover both changes, including a check that every toolkit shipped in this repository passes the new rule in enforcing mode.