Skip to content

Gate enforces delegation depth 1 for native subagents - #7

Merged
tomastaker merged 2 commits into
mainfrom
fix/gate-depth
Sep 1, 2026
Merged

Gate enforces delegation depth 1 for native subagents#7
tomastaker merged 2 commits into
mainfrom
fix/gate-depth

Conversation

@tomastaker

Copy link
Copy Markdown
Owner

Stacked on #6.

Problem

Every dk-* role has Bash, and DELEGATE_KIT_DEPTH is set only for children of agent-run. A native implementer could run agent-run run itself and start a second-level worker; external.md stated "delegation depth is 1" without that caveat.

Change

  • hooks/gate.sh: when the hook input carries agent_type (Claude Code sets agent_id/agent_type on tool events fired inside a subagent, and settings hooks do fire there), agent-run run|resume and agent-wt lock are denied outright, before the confirmation-prefix bypass. status, list, wait, agent-wt diff and ordinary commands pass.
  • external.md, hosts.md: what the gate enforces for a native role, and that under a Codex parent the native roles hold the line by instruction only.
  • tests/gate.sh: 24 checks — the depth rule plus the existing dangerous-command patterns, which had no tests. CI step added.

Checks

gate.sh 24/24, route.sh 48/48, caps.sh 43/43, delivery.sh 25/25, shellcheck -S warning.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 381cac4f-6ec7-4ab0-bdbc-b1690848c40f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 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-09-01T22:11:05.445970Z 2450580 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: 2450580032

ℹ️ 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 skills/delegate-kit/hooks/gate.sh Outdated
# a worktree lock from there is denied outright — no confirmation prefix reopens it, so this
# check sits before the confirmation bypass below.
AGENT=$(printf '%s' "$INPUT" | jq -r '.agent_type // empty' 2>/dev/null || true)
if [ -n "$AGENT" ] && printf '%s' "$CMD" | grep -Eq '(^|[;&|(`[:space:]/])(agent-run[[:space:]]+(run|resume)|agent-wt[[:space:]]+lock)([[:space:]]|$)'; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Recognize quoted worker executables

When a native subagent quotes the executable, such as "agent-run" run ... or "/home/me/bin/agent-wt" lock task, Bash still executes the worker command but this pattern permits it because it requires whitespace immediately after the unquoted agent-run/agent-wt literal. This provides a straightforward, normal shell invocation that bypasses the newly claimed depth-one guarantee; extend the matcher to handle quoted executable names and add regression cases for both commands.

Useful? React with 👍 / 👎.

Все dk-роли имеют Bash, а DELEGATE_KIT_DEPTH получают только дети agent-run:
нативный implementer мог сам вызвать `agent-run run` и завести воркера
второго уровня. Хуки из settings.json срабатывают внутри субагентов и несут
agent_type во входе — gate.sh отклоняет `agent-run run|resume` и
`agent-wt lock`, когда это поле есть; префикс подтверждения этого не открывает.
Под Codex-родителем нативные роли держат правило инструкцией, сказано в
external.md. tests/gate.sh — 24 проверки, включая существующие паттерны gate,
которые до сих пор были без тестов; шаг в CI.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…глубины

По ревью PR #7 (Codex P1): "agent-run" run и '/path/agent-wt' lock проходили
мимо шаблона, требовавшего пробел сразу за словом. Три регрессионные проверки.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@tomastaker
tomastaker changed the base branch from fix/review-author to main September 1, 2026 22:29
@tomastaker
tomastaker merged commit f833914 into main Sep 1, 2026
5 checks passed
@tomastaker
tomastaker deleted the fix/gate-depth branch September 1, 2026 22:30
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.

1 participant