Repository navigation
Add tinyhivemind-host: neutral seat hosting and process supervision - #136
Merged
Merged
Conversation
…dules Introduce host-side configuration parsing and validation, model activation, journaling, and language package planning so the host can load settings, activate models, and plan tool execution. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
The host configuration types, along with the activation barrier, are now public so downstream crates can construct and inspect them directly. Visibility was widened across the config, activation, language, and tools modules, and the activation test module path attribute was dropped. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Validation no longer reaches into the core crate for schedule parsing and reserved agent ids; a HarnessRules trait now supplies those answers so the host stays independent of any particular harness. The config module also re-exports its error and rules types publicly, and the old language plan test is dropped. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
The plan lowering code moved from a single file into a plan module with its own tests, and the config test harness gained a shared fixture so validation can be exercised without a real adapter. The tools types were extended to carry the extra per-seat data the split module needs. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduce tests covering declarations, episodes, management, messaging, and sends, along with shared support helpers, to exercise the host tool implementations. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
The host crate now exposes activation, config, journal, language, policy, tools and turn modules alongside a shared error type, and gains a Linux-only process tree module for supervising child processes. Dependencies were added for policy wire forms, tool rules and, on Unix, rustix for signals and pidfds since the workspace forbids unsafe code. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduce a Belt that wraps a coordinator and exposes builder methods for send policy and management, plus a ToolCall type, so tool execution has a single entry point. The language test now returns anyhow::Result and reports a clearer error when a seat request is not a creation request. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduce a conformance test suite for the host crate backed by a fake harness binary, so host behaviour can be exercised end to end without a real harness. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a process tree that identifies members by pid and start time so a reused pid is never mistaken for the original process. Membership is proven by being the root, sharing its process group, carrying the instance marker, or descending from a member, and sampling remembers descendants after their parents exit. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
pidfd_open can return EINVAL when the pid has been reused as a thread of another process, so that case is now handled alongside ESRCH and the signal is skipped. The gone helper was inlined into the send path to keep the two error checks explicit. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduce a pipe submodule under the process supervisor and relocate the test-only alive helper from the tree module into its test file so it is no longer compiled into non-test builds. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a pipe module that drains child stdout and stdin as JSON lines with bounded queues, reporting overflow instead of silently dropping messages, and wire it into the host tool layer. The openhuman crate drops its duplicated config, journal, language plan, and error modules in favour of the shared host implementations. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
…nd-host The adapter now re-exports the harness-neutral tool belt, policies, package plans, turn scope and prompt from tinyhivemind-host instead of carrying its own copies, and the host bridge moves into the crate as a module. The process pipe queue was reworked so admission and push are separate steps, letting an overlong or overflowing line end the stream without allocating a closure per entry. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
The process module now re-exports its instance directory, error, and launch types so callers can name them directly, and the stopping tests were reworked to use shared fixture scripts instead of deeply nested shell quoting. This makes the supervision tests easier to read and adds coverage for descendants that clear their environment or ignore SIGTERM. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
The crate now surfaces ConfigError through its config module rather than the error module, keeping the type alongside the configuration API it belongs to. The seat_profile helper also gains a must_use annotation so callers cannot silently discard the generated profile id. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Once the host reaps the root process its pid can be reused, so matching members by process group against that pid could sweep in unrelated processes. The tree now tracks whether the root is still unreaped and only uses the group id while it is, with a test covering the reaped case. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Regenerated the example lockfile to pick up the jaq JSON query crates, a newer rustls and webpki-roots, and the tinyagents 3.0.0 bump. The openhuman example now depends on tinyflows instead of tinyagents-graph and tinytools-std. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Pinned ureq back to 3.5.0 and ureq-proto to 0.6.5, and moved getrandom to 0.3.4, to restore a dependency set that resolves consistently for the example. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Pinned webpki-roots back to 1.0.10 in the openhuman example lockfile, updating the checksum and all dependent entries accordingly. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
…ules The supervisor's child-reaping and containment logic now lives in dedicated instance and scope modules, leaving the supervisor to drive the stop sequence. This keeps the pid-reuse guarantees in one place as more containment modes are added. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduce `tinyhivemind-host`, which owns the hive tool belt, send and management policies, turn scope and prompt, package loading, the deployment plan, and supervised harness processes without linking any harness. Extend `assert-pure.sh` to forbid harness families in the host crate, and update the workspace docs and READMEs to describe the new seven-package layout. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a test asserting that stopping a process which has already exited returns promptly even when the cancel grace period is effectively unbounded, and register the new scope test module. The Cargo.toml comment now states that the purity script only checks the dependency graph for harness types. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Instance now tracks the abort handles of its stdout/stderr drain tasks and aborts them when dropped, so pipes held open by processes that escaped the tree no longer keep the pumps alive. Root gained a Drop impl that kills and reaps a child whose instance failed to start, and stop now returns early once the child has exited instead of waiting out the cancel timeout. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a test asserting that stopping a process group whose leader is already gone returns promptly instead of waiting out the terminate grace period, using a policy with an effectively infinite terminate timeout to prove the wait is skipped. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Termination now returns as soon as the child has exited when the scope cannot distinguish members from the child's own zombie, since waiting for an empty member list would never succeed. Deadline tracking also switched to elapsed time from a start instant to avoid overflow when adding large bounds. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add tests showing that dropping an instance kills its process group without going through the supervisor, and that a running instance's tree is sampled without being asked. The request sender is exposed to the process test module so the supervisor can be detached in the dropping test. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Wire a cfg(test) harness test module into the host crate and gate the process module behind cfg(unix) so the crate builds on non-Unix targets. The new tests cover payloads, seat handling, support helpers, and verification. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduce the Harness trait that starts a seat and returns the AgentRunner the coordinator drives, along with the neutral payloads every client shares. SeatRunner enforces one turn at a time and one session for life, Expected::verify rejects instances that do not match what was started, and TurnUsage::since converts a harness's running total into per-turn usage. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Turn setup and execution are now separate steps, with a Turn value that owns the seat and settles or cancels itself when dropped. This keeps the seat held through the whole turn and makes an abandoned future cancel the turn instead of leaving it in doubt. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Introduce a conformance test suite for the host crate along with fake implementations of the child, client, and subject traits. These fakes let the tests exercise host behaviour in isolation without depending on real processes or network peers. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Seats now serve only the tools named by a non-empty tools.allow list plus their executable tools, matching the linked path, and refuse argument schemas using keywords the server cannot check. Bearer secrets are zeroed on drop, and in-flight calls are bounded across and per seat rather than by connection count. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
…r order Update the crate READMEs and harness spec to match the server's current behaviour: per-seat and global in-flight call bounds, record limits, the argument schema check for executable tools, and the reordered ledger and access-gate steps. The new tools test module is also listed in the tools README. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Two packages declaring the same harness id are now only a conflict when they disagree on the kind or the resolved isolation, so identical declarations no longer fail. Seats of a package that names a harness also lower with unlisted tool groups off, closing the gap where the runtime's defaults left them callable through use_skill. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Moved the hook declaration and stop-hook rejection out of the seat validation loop into a dedicated `hooks` helper, and tidied the toolpack indexing so it is walked once. Behaviour is unchanged; the split keeps the seat walk readable as more capability checks are added. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a test asserting that the start check counts tools contributed by deferred tool search, the REPL handle tools, the orchestrator summary stage, extra_tools, and subagent delegation, matching what resolved_scope adds to an allowlist. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
…llowlist The visible-tool check now looks up the configured chat agent instead of a fixed id, and mirrors 0.64.15's resolved_scope by adding deferred, delegation, recovery and REPL tools under the conditions the binary uses. This keeps the live tests honest about what the model actually sees. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Add a conformance case asserting that when a seat's first turn fails, the next turn starts the thread afresh and completes rather than failing to resume. The fake surface now records a user message only once a turn ends, matching 0.64.15, and a shared helper builds turn requests for the test seat. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Renamed the internal Turn struct to Records since it holds a seat's records for its running turn rather than the turn itself, making the name match what the type actually represents. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
The call_message helper now takes its arguments by reference, and the two call sites pass a borrow of the identified payload. This avoids moving the value so it can be reused after building the request. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
A turn that fails before its thread has a transcript now returns a dedicated error instead of a session id, so the next turn is not asked to resume a thread that never existed. The transcript lookup is shared between the resume check and this new check. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Adds a test asserting that a tool call with no arguments is treated as an empty object and succeeds, while a non-object argument payload and an unknown argument are both rejected even for a read-only tool, with nothing logged when the call fails. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
The Debug implementations for the config input, written config, and RPC client now hide the bearer, prompt, and core token, since these values carry the seat's and instance's authority and were previously printed in full. Tests cover both the types directly and a running harness. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
This was referenced Nov 26, 2026
…d after close Seats are now inserted into the registry before their instance starts, so a concurrent start is refused and a stop can find the seat to stop, with the entry removed again if the start fails. A seat closed while its instance was starting now stops that instance instead of leaving it running, and approvals gained a configurable timeout. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
…ailures The keyring key is now rejected unless it is a regular file with mode 0600 holding 64 hex digits, and the config is chmodded to 0600 even when it already exists. Stop failures during launch are no longer swallowed but reported alongside the original error, and the harness fetch script rejects ambiguous lock entries and forbids non-HTTPS redirects. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
…l limits Update the harness, instance and turn READMEs and the harness spec to describe the behaviour settled on 0.64.15: seats are reserved by id so a second start is refused, the model-visible tool list is computed from the effective config since no RPC reports it, and approvals time out into denials while stale ones are denied before a turn starts. Also note that a failed start reports a failed stop alongside it, keyring key files must be 0600 with 64 hex digits, and a turn failing before its thread has a transcript reports no session. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
Renamed the local permission helper in the keyring test to chmod with a clearer parameter name, and removed an unused AGENT_ID import from the verify module. Auto-committed-on: cuttlefish Co-authored-by: Medulla <medulla@tinyhumans.ai>
11 tasks done
Choose a seat's harness in the hive language, default-deny
Brings in #137 (harness schema). The one conflict is the "Implemented so far" paragraph of docs/specs/harnesses.md, now covering steps 1, 2 and 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Serve hive tools over loopback MCP with per-turn call identity
Brings in #137 (harness schema) and #138 (hive tool server). Conflicts: - Cargo.toml: both new members, and both dependency blocks (hyper and its helpers for tinyhivemind-mcp, reqwest for this crate). - assert-pure.sh: host_crates now guards tinyhivemind-host, tinyhivemind-mcp and tinyhivemind-openhuman-process. - docs/specs/harnesses.md: "Implemented so far" covers steps 1, 2, 3 and 4b. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run OpenHuman seats as supervised processes
rustix 1.1.5 marks uninitialized bytes as initialized when an xattr call is given a zero-length buffer (unsound). Only the rustix entry and the references to it change, in the root and examples/openhuman lockfiles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only tree containment can list members. Under process-group containment, and on every platform but Linux, members() returns the child's pid while anything in the group is alive and nothing once it is gone, which the doc promised otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Step 1 of the process harness plan. Adds
tinyhivemind-host, the harness-neutral half of running a seat, which links no harness.Belt), send and management policy, turn scope and prompt rendering, activation, the journal, package loading and plans, and config validation behind aHarnessRulesport.tinyhivemind-openhumanre-exports them under its old paths and keeps everything that names OpenHuman.Harnessport (start,stop,kind), aSeatRunnerthat enforces one turn at a time and a stable session, start-up verification (pid, version, effective config, exact tool list), and Linux process supervision that stops the whole tree. There is also a conformance suite (featureconformance) that later client crates run against themselves.HarnessKindlives intinyhivemind-lang, so the schema step can use it.docs/specs/harnesses.mdis updated to match what supervision really guarantees. It also closes the two open threads from Specify process harnesses for OpenHuman, OpenClaw and Codex #135: sandbox and autonomy rules, and hooks counting as effects for retry.Supervision went through two independent reviews; every Critical and Important finding is fixed with a test. Stop proof under 16 forkers and 32 CPU burners (about 30k new pids/s): 200/200 proven, nothing left alive, p95 under 60 ms. What can still escape is listed in
crates/tinyhivemind-host/src/process/mod.rs. The main gap: a process that leaves the group, hides the marker and is orphaned within 100 ms. So the spec requires a cgroup or subreaper before any harness may run a shell.Related issue
None. Refs #135.
API or behavior changes
tinyhivemind-host, andtinyhivemind_lang::HarnessKind.From<tinyhivemind_host::Error> for Error. Every pathrsi-ralph-swarmuses was checked by reading, not by compiling it.Dependencies
rustix(process, no defaults) for pidfd signalling withoutunsafe.examples/openhuman/Cargo.lockwas stale and failed--lockedonmain. Refreshing it resyncs the vendored path crates (tinyagents 3.0, tinyflows 0.9). It also bumps ureq 3.5.0, ureq-proto 0.6.5, rustls 0.23.46 and webpki-roots 1.0.10, which the vendored tinybus requires.Validation
At
9a7b90b6:cargo fmt --all -- --check: passcargo clippy --all-targets --all-features -- -D warnings: passcargo build --all-targets --all-features: passcargo test --all-features: 1852 passed, 0 failed, 0 ignored;cargo test: 1818 passedassert-pure.sh(now also guardstinyhivemind-host),assert-openhuman-pin.sh, rustdoc-D warnings: passcheck-file-coverage.sh 90: fails on files this PR does not touch,deploy/packages.rs(66.3%) anddeploy/test/mcp.rs(85.2%).mainmeasures the same two at the same values, plus three more this PR brings over 90%. Everytinyhivemind-hostfile is at least 90.4%.cargo test --locked --manifest-path examples/openhuman/Cargo.toml: 11 failures, all already onmain. With this lockfile,mainfails the same 11 (9deepswe_hiveretry tests and 2prooftests). One retry test differs by name between runs, so one is timing dependent. Before this PR CI never got this far, because the stale lock failed first.Supply chainfails on RUSTSEC advisories already onmain, which this PR does not change.So CI will be red, for reasons all present on
main. They are left for a separate fix, to keep this change to one thing.Tests
The move kept every test, by name. The new code is tested first: each review finding has a test that failed on the old code, or recorded evidence where only a race shows it. Supervisor tests cover hidden and unreadable
/procentries, a hidden or dying ancestor, fast and unrelated forking, setsid grandchildren, pipe overflow and stops queued behind each other. Every test process stops by itself within two minutes, even if its test is killed.Deliberately untested: non-Linux builds (only process-group containment, and not compiled here).
Documentation
Crate and module READMEs, crate overview with doctests,
AGENTS.mdstructure,docs/crate-dependencies.md,docs/specs/harnesses.md, plan steps 2 to 4.Checklist
#[allow(...)],#[ignore], or relaxed lints.envcontents in the diff or the descriptionCo-authored-by: Medulla medulla@tinyhumans.ai