Skip to content

Test lead-only delegation across harnesses - #141

Merged
sanil-23 merged 11 commits into
tinyhumansai:mainfrom
sanil-23:lead-delegation-test
Nov 27, 2026
Merged

sanil-23 merged 11 commits into
tinyhumansai:mainfrom
sanil-23:lead-delegation-test

Conversation

@sanil-23

@sanil-23 sanil-23 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follows #140, now merged: this PR's diff is its one commit, Test lead-only delegation across harnesses.

A live test of the case where seats on other harnesses take part only because a lead asks them. One hive holds an OpenHuman, a Claude Code and a Codex seat, plus idle, a Claude Code seat nobody asks. The host starts the episode with the lead as its only starter. The test runs three times, each harness leading once:

  1. The lead calls hivemind_ask naming the seats on the other two harnesses, then ends its turn.
  2. Each seat asked takes a turn inside the conversation the ask opened, and answers by completing there.
  3. The lead gets a later turn showing both answers, completes, and the episode settles.

The checks:

  • Exactly the three harness seats ran, each through its own model API, and idle never ran.
  • The lead asked once, and its ask row is the conversation's root.
  • Each seat asked ran only inside that conversation and answered there once.
  • The lead's first turn showed no answer, and the turn that completed it showed both.

Related issue

None. Listed as a follow-up in #140.

API or behavior changes

None. Tests only.

What this found

  • The default round width fails an ask that names two seats. With round_width 1 (the default), the episode fails with "dm has 2 recipients but round width is 1". stage_action accepts the call, because it checks that the asked seats are members but not the width. The driver then fails the whole episode, rather than refusing the call so the model could narrow its ask. This is existing coordinator behaviour, separate from this test, which runs with round width 2. Raising it here as a possible follow-up.
  • The scripted model gave every response and tool call a fixed id. Claude Code joins a response's stored parts by id, and treats a tool call whose id it has already seen as already done. With fixed ids, a Claude Code seat's second turn looped until the episode's 60-turn wall. Ids are now fresh.
  • A lead that completes in the same turn it asks doesn't end the episode early. The asked seats still answer, and the lead completes again once it sees both answers.

Validation

Run on Linux (all-in), against the pinned agents:

  • cargo fmt --all -- --check: OK
  • cargo clippy -p tinyhivemind-acp --all-targets --all-features -- -D warnings: OK. Only the ACP crate's tests changed; the workspace-wide commands ran on Run hive seats on Claude Code and Codex over ACP, beside OpenHuman #140.
  • cargo test -p tinyhivemind-acp --all-features with every live agent set: all 7 live tests passed, 3 runs in a row.
  • The same with no live agents set: the live tests skip cleanly, as they will in CI.
  • Mutations, each run against the Claude Code lead:
    • the lead asks only one seat: fails (episode does not settle);
    • every member starts, not just the lead: fails (episode does not settle);
    • the lead never asks: fails ("the seats that ran: {claude}").

Tests

New: tests/hive/delegation.rs, with three live_* tests. tests/hive.rs now splits starting, settling and stopping a hive into helpers that both test files share. tests/hive/model.rs gains the delegation script.

Documentation

tests/README.md and tests/hive/README.md.

Checklist

  • The change is focused on one logical change
  • No new #[allow(...)], #[ignore], or relaxed lints
  • No secrets, tokens, or .env contents in the diff or the description

🤖 Generated with Claude Code

sanil-23 and others added 11 commits November 27, 2026 01:36
Two seats run the pinned openhuman-core through the process runner,
registered with a real coordinator and served hive tools by a real
tinyhivemind-mcp server, one bearer each. A loopback model reads each
rendered turn, posts, retries the same call, then completes. The test
checks each seat posts once under its own name, the retry returns the
first result, the episode settles, and no process is left after stop.

Opted into with THM_OPENHUMAN_CORE, like the crate's other live tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude Code speaks only Anthropic's Messages API, so the kind gets its own
model API and a new capability row: provider anthropic with an explicit
endpoint and no credential, which it alone accepts. An openai endpoint is
rejected for it by the spec; every other row matches codex's. ADR 0037
records the decision as proposed until a conformance run on the pinned
release backs it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One minimal ACP client drove Claude Code, Codex and OpenClaw against the
spike's scripted model and MCP stub. Each called the hive tool as the right
seat, cancelled, resumed after a restart and replayed nothing, once
Claude Code's built-in tools and Codex's auto review were turned off.
OpenClaw reports no per-turn usage over ACP and costs about 2 GB with its
Gateway; the adapters roughly double a Codex seat's memory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One harness client for every agent that speaks the Agent Client Protocol
over stdio, on the host's supervised JSON lines. What differs between
agents is an Agent descriptor of data: command, environment, files,
session metadata and mode. Claude Code and Codex have descriptors, with
the settings the ACP runs found each needs: Claude Code's built-in tools
and tool search off, Codex in read-only mode with a direct-tool catalog.

A permission request for a host tool is allowed by the client, since the
tool server judges hive tools; any other goes to the seat's approver.

Live tests on the pinned agents run a Claude Code seat, a Codex seat, and
a mixed hive of OpenHuman, Claude Code and Codex in one episode with a
real coordinator and tool server: each seat posts once as itself though
it retries, and the episode settles. ADR 0038 records the decision as
proposed until the conformance suite runs on each agent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An OpenHuman, a Claude Code and a Codex seat each write a file with the
host's write_file executable tool, which runs in the seat's own
workspace under the host's access gate. A read-only seat's write is
refused by the host and writes nothing. Agents' own tools stay off, as
the harness spec requires.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The edit test now has every editing seat retry its write, try a path
that climbs out of its workspace and an absolute one, and runs the
Claude Code and Codex seats supervised under a host approver that
records every request. It checks that a retried write runs once and
returns the first result, that both escapes are refused and nothing
lands outside a workspace, that the approver judges exactly the
supervised seats and is not asked again for a retry, and that a seat
the approver denies writes nothing. Editing seats post once, so an
OpenHuman seat's turn stays within its eight model calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From review of tinyhumansai#140:
- refuse an agent whose initialize lacks protocol version 1 or HTTP MCP,
  and resume a session only when the agent offers loadSession;
- keep a session as the seat's before setting its mode, so a failed
  session/set_mode is retried on it;
- keep a process until its stop succeeds, so a failed stop can be retried;
- close a turn's route before its last drain, and on drop answer what it
  still holds; answer a cancelled turn's permission requests `cancelled`;
- treat a prompt result without a stopReason as a broken protocol;
- hold a seat id from start to the end of stop, stopping what a dropped
  start began before freeing it;
- fill templates in one pass and TOML-escape values in .toml files;
- give write_codex_catalog a typed CatalogError;
- bound every wait in the connection tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From review of tinyhumansai#140: the replay row measured only a new agent starting,
not a loaded interrupted session, so it and ADR 0038 now say so; the
conclusion names Claude Code's CLI outliving its adapter; the spike
client decodes stdout as UTF-8 and fails its calls once the agent closes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test writes a script and runs it at once. When another test forks a
child in between, the child holds the script open for writing until it
execs, and running the script fails with ETXTBSY: about one run in
twenty of the crate's unit tests on a busy machine. The test now tries
again while the script is busy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
OpenHuman appends how long a tool call took (`[took 0.1s]`) to its
result, so a retry the host answers from its record can still read
differently from the first call when the first was slow. Under load the
edit test failed on exactly that. The scripted model now drops that
suffix, as it already drops Codex's timing prefix, before it compares.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A lead on each harness in turn is the only starter: it asks the seats on
the other two harnesses in one conversation, each answers there through
its own model API, the lead completes on a later turn showing both
answers, and a member nobody asked never runs. The round is two wide; at
the default width of one, an ask naming two seats fails the episode.

The scripted model now gives every response and tool call a fresh id.
Claude Code joins a response's stored parts by id and interrupts a tool
call whose id its session has seen, so with fixed ids a seat's second
turn looped until the episode's turn wall.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 52 billable files and costs up to $13.00.

Or wait 59 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 427f5f31-1884-4bd9-9938-35cae2402f95
Commits

Reviewing files that changed from the base of the PR and between a01e4cf and 7af923b.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 52

  • .github/scripts/assert-pure.sh
  • AGENTS.md
  • Cargo.toml
  • crates/tinyhivemind-acp/Cargo.toml
  • crates/tinyhivemind-acp/README.md
  • crates/tinyhivemind-acp/src/README.md
  • crates/tinyhivemind-acp/src/agent/README.md
  • crates/tinyhivemind-acp/src/agent/mod.rs
  • crates/tinyhivemind-acp/src/agent/test.rs
  • crates/tinyhivemind-acp/src/capability/README.md
  • crates/tinyhivemind-acp/src/capability/mod.rs
  • crates/tinyhivemind-acp/src/capability/test.rs
  • crates/tinyhivemind-acp/src/connection/README.md
  • crates/tinyhivemind-acp/src/connection/mod.rs
  • crates/tinyhivemind-acp/src/connection/test.rs
  • crates/tinyhivemind-acp/src/error/README.md
  • crates/tinyhivemind-acp/src/error/mod.rs
  • crates/tinyhivemind-acp/src/error/test.rs
  • crates/tinyhivemind-acp/src/harness/README.md
  • crates/tinyhivemind-acp/src/harness/mod.rs
  • crates/tinyhivemind-acp/src/lib.rs
  • crates/tinyhivemind-acp/src/protocol/README.md
  • crates/tinyhivemind-acp/src/protocol/mod.rs
  • crates/tinyhivemind-acp/src/protocol/test.rs
  • crates/tinyhivemind-acp/src/seat/README.md
  • crates/tinyhivemind-acp/src/seat/mod.rs
  • crates/tinyhivemind-acp/src/seat/turn.rs
  • crates/tinyhivemind-acp/tests/README.md
  • crates/tinyhivemind-acp/tests/hive.rs
  • crates/tinyhivemind-acp/tests/hive/README.md
  • crates/tinyhivemind-acp/tests/hive/delegation.rs
  • crates/tinyhivemind-acp/tests/hive/model.rs
  • crates/tinyhivemind-lang/src/harness/capability.rs
  • crates/tinyhivemind-lang/src/harness/mod.rs
  • crates/tinyhivemind-lang/src/harness/test.rs
  • crates/tinyhivemind-lang/src/validation/capability/mod.rs
  • crates/tinyhivemind-lang/src/validation/test/harness.rs
  • crates/tinyhivemind-openhuman-process/Cargo.toml
  • crates/tinyhivemind-openhuman-process/tests/README.md
  • crates/tinyhivemind-openhuman-process/tests/hive.rs
  • crates/tinyhivemind-openhuman-process/tests/hive/README.md
  • crates/tinyhivemind-openhuman-process/tests/hive/model.rs
  • docs/adr/0037-claude-code-is-a-fourth-harness-kind.md
  • docs/adr/0038-acp-agents-share-one-client.md
  • docs/adr/README.md
  • docs/experiments/2026-11-26-acp-harnesses.md
  • docs/experiments/2026-11-26-acp-harnesses/README.md
  • docs/experiments/2026-11-26-acp-harnesses/acp.mjs
  • docs/experiments/2026-11-26-acp-harnesses/fixture.mjs
  • docs/experiments/2026-11-26-acp-harnesses/measure.mjs
  • docs/experiments/README.md
  • docs/specs/harnesses.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@sanil-23 sanil-23 changed the title Test lead-only delegation across harnesses (stacked on #140) Test lead-only delegation across harnesses Nov 27, 2026
@sanil-23
sanil-23 merged commit 4ae2114 into tinyhumansai:main Nov 27, 2026
3 of 5 checks passed
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