Skip to content

refactor(core): one child-agent launch contract (#443) - #444

Merged
ajianaz merged 1 commit into
developfrom
refactor/child-launch-contract
Oct 27, 2026
Merged

ajianaz merged 1 commit into
developfrom
refactor/child-launch-contract

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

What

Adds tole_core::child_env, the one definition of the environment a parent's agent_start gives a child tole run, and moves both sides onto it. Closes #443.

Why

The parent (tole-core agents.rs) set seven TOLE_* variables as string literals, and the child read them back in tole-cli (handoff.rs, sibling.rs, tool_roster::agent_depth, main.rs), with the depth marker matched once more in the spawn-yourself guard. Producer and consumers shared no type: a renamed variable would compile on both sides and silently break children. #380 and #383 each had to touch four modules.

Changes

  • tole-core/src/child_env.rs (new, not behind shell-tools, so an embedder running as a child reads the same contract):
    • the names DEPTH, AGENT_ID, TOUCH_LOG, ROLE, HANDOFF, MEMORY, MEMORY_ROOM;
    • ChildLaunch { id, touch_log, mailbox_room, role } with vars(), which the parent sets on the child process;
    • read-back helpers depth (0 when absent or unparseable), sibling (agent-id charset validated, non-empty log) and role (role must parse; a role without a handoff path is no role). This is the validation the CLI applied before.
  • agents.rs: agent_start builds a ChildLaunch and sets cmd.envs(launch.vars()); the guard matches child_env::DEPTH.
  • sibling_watch.rs: ENV_AGENT_ID / ENV_TOUCH_LOG become aliases of the child_env names (public API kept).
  • tole-cli: sibling::tracking_from_env, handoff::tool_from_env, tool_roster::agent_depth and the memory room override read through child_env; ENV_ROLE / ENV_HANDOFF stay as aliases.
  • CHANGELOG.

No behaviour change: a child gets exactly the same variables (role and handoff only for a role child), and the mailbox room is still derived only from the validated agent id.

Testing

  • New child_env tests: the parent → child round trip (depth 1, sibling id and log, role and handoff file, memory backend and room; no role without a role launch); a parent process reads as no child; malformed values (non-numeric depth, a path-like agent id, an unknown role, a blank handoff path) are not trusted.
  • Existing child-agent tests pass unchanged: tole-core agents unit tests (env passed to a fake child, argv guard), tole-cli agents, child_handoff_e2e, sibling_notice_e2e.
  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo clippy -p tole-core --no-default-features --tests -- -D warnings, bare-profile clippy (none / shell-tools), cargo test --workspace: all green.
  • Cora agent-as-reviewer on the exact staged diff, judged from review_finalize: should_block: false, 0 issues (prepare listed four info qual-clone hits, ignored by .cora.yaml).

tole_core::child_env holds the environment agent_start gives a child: the variable names, ChildLaunch (id, shared touch log, mailbox room, optional role and handoff file) whose vars() the parent sets on the child process, and the child's read-back helpers depth, sibling and role with the existing validation. agent_start, the spawn-yourself guard, sibling tracking, the handoff tool, the depth cap and the memory room override use it; the public ENV_* constants remain as aliases. No behaviour change.
@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 5574dbe into develop Oct 27, 2026
16 checks passed
@ajianaz
ajianaz deleted the refactor/child-launch-contract branch October 27, 2026 01:59
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.

refactor(core): one child-agent launch contract

1 participant