Skip to content

feat(cli): delegation limits and the delegated-child launch contract (#585) - #621

Merged
ajianaz merged 1 commit into
developfrom
feat/delegation-config
Nov 11, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/delegation-config

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What

Part 2 of #585 (epic #583): the configuration, launch contract and authority rule that the delegate tool will build on. Nothing new runs yet: no tool uses these pieces until the next PR (part 3).

Part (a) of the plan came to about 1350 lines, past the ~1100 limit, so I split it in two:

  • This PR (about 270 lines): the foundation.
  • Next PR (about 1050 lines): the delegate tool. It opens after this one merges.

Why

Design docs/profiles-collaboration-secrets.md A8, with the owner rules in force:

Changes

  • [delegation] config table (config.rs):
    • Keys: max_depth, max_live_processes, goal_budget, goal_steps and goal_minutes. No key name contains token or secret.
    • User layer only, like [cron]: layered drops a project's [delegation], and config check marks it IGNORED.
    • Validation: max_depth outside 1–3, or any value of 0, is a config error. Unknown keys are refused.
  • Delegated child takes allow and trust only from its flags (config_apply.rs):
    • A child launched with TOLE_DELEGATION_LOG and TOLE_DELEGATION_NODE takes its allow patterns and trust presets only from the --allow / --trust flags its parent passed.
    • Its profile's allow, the config's allow / trust and TOLE_TRUST are ignored, since any of them could be wider than parent ∩ profile.
    • A session that is not delegated behaves as before.
  • Launch contract (tole-core/src/child_env.rs):
    • ChildLaunch now carries the child's real depth and, for a delegated child, its log and node id.
    • child_env::delegation(env) reads them back. It trusts only an absolute log path and a node id in the delegation charset.
  • agent_start launch options (tole-core/src/agents.rs):
    • A new ChildOpts holds the child subcommand and its flags (e.g. mission --max-steps …), its depth, the delegation pair, extra secret names to keep, and a delegated flag. The tree's checks replace the depth-1 refusal only when that flag is set.
    • The default is exactly today's tole run child at depth 1.
    • New helpers: agents_dir(root) and agent_dir(root, id).
  • Ledger file store (ledger_file.rs): moved from cron/store.rs, so the delegate tool can use it without the cron module. It is still reachable as crate::cron::store, and nothing else changed in it.
  • Docs: a CHANGELOG.md entry, the README.md config table, a docs/threat-model.md launch-contract note under "Delegation tree (feat(core): delegation — budget carve, depth 2 (max 3), write lease and mandatory report #585)", and docs/epics.md E2.

Testing

  • New tests:

    • config::tests::delegation_table_is_bounded_and_user_layer_only
    • config_apply::tests::a_delegated_child_takes_allow_and_trust_only_from_its_flags
    • an extended child_env::tests::a_child_reads_back_what_its_parent_launched (depth 2, the delegation pair, a relative log refused)
  • Each rule was broken on purpose; the matching test went red, and green again once restored:

    Behavior broken Test that failed
    max_depth bound off delegation_table_is_bounded_and_user_layer_only
    zero values accepted delegation_table_is_bounded_and_user_layer_only
    a project's [delegation] kept by layered delegation_table_is_bounded_and_user_layer_only
    a relative delegation log trusted a_child_reads_back_what_its_parent_launched
    child depth fixed at 1 a_child_reads_back_what_its_parent_launched
    a delegated child takes the config/profile allow a_delegated_child_takes_allow_and_trust_only_from_its_flags
  • Commands (private CARGO_TARGET_DIR, CARGO_INCREMENTAL=0, debuginfo off):

    • cargo fmt --all: clean
    • cargo clippy --workspace --all-targets -- -D warnings: clean
    • cargo test --workspace: 1489 passed, 0 failed
    • cargo test -p tole-core --no-default-features: 507 passed, 0 failed
    • cargo build -p tole-cli --no-default-features: ok
    • cora review --no-llm --staged: no issues found

Next PR (opens after this merges)

  • The delegate tool:
    • delegate / delegate_poll, with agent_start / agent_poll as deprecated aliases for one release.
    • Each child runs as tole mission with the carve as --max-steps / --max-minutes / --max-tokens, optionally --profile, and --allow = parent ∩ profile.
    • Child secrets = parent grant ∩ Profile::granted.
    • An execute child takes a write lease on the canonicalized workspace or worktree, checked before it spawns.
  • Usage: the measured usage comes from the child's session usage records, falling back to the whole carve when they cannot be read.
  • Machine guard: a queued spawn starts on a later delegate or poll.
  • Faces: tole serve keeps the classic depth-1 tools for now, and cron registers no agent tools.
  • Readiness: that branch is built and its tests pass. Once this PR lands, it will be brought up to date by merging develop into it.

…585)

New user-config table [delegation]: max_depth (1-3, default 2),
max_live_processes, goal_budget, goal_steps and goal_minutes, user layer
only, with out-of-range values refused. The child launch contract carries
a delegated child's real depth and its log and node id
(TOLE_DELEGATION_LOG, TOLE_DELEGATION_NODE), and agent_start takes launch
options (subcommand, depth, secret names to keep) for a delegating host.

A delegated child takes its allow patterns and trust presets only from
the flags its parent passed (parent intersect profile): its profile's
allow, the config's allow and trust and TOLE_TRUST are ignored, since
any of them could be wider.

The ledger file store moves from cron::store to ledger_file (still
reachable as cron::store) so the delegate tool can use it without the
cron module.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 5550c57 into develop Nov 11, 2026
19 of 20 checks passed
@ajianaz
ajianaz deleted the feat/delegation-config branch November 20, 2026 08:36
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