Skip to content

feat: Phase 5 — Agent Composition & Subordinate Spawning - #107

Merged
rysweet merged 1 commit into
mainfrom
feat/phase-5-agent-composition
Mar 31, 2026
Merged

feat: Phase 5 — Agent Composition & Subordinate Spawning#107
rysweet merged 1 commit into
mainfrom
feat/phase-5-agent-composition

Conversation

@rysweet

@rysweet rysweet commented Mar 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • agent_supervisor.rs (389 LOC): Subordinate lifecycle management — spawn, heartbeat tracking via hive, kill, retry policy (max 2 per goal)
  • agent_goal_assignment.rs (241 LOC): Goal assignment and progress reporting through semantic facts in the cognitive memory bridge (no raw IPC)
  • identity_composition.rs (243 LOC): Composite identity with name-collision validation and depth-limited nesting (SIMARD_MAX_SUBORDINATE_DEPTH, default 3)
  • agent_roles.rs (245 LOC): Role catalog (Engineer, Reviewer, GymRunner, Facilitator) with objective heuristic matching and manifest generation
  • tests/composition.rs (323 LOC): 20 integration tests covering spawn/heartbeat lifecycle, goal round-trips, progress polling, composite identity, and feral edge cases (stale heartbeats, dead subordinates, depth limits, isolation)
  • Wired into lib.rs with public re-exports

Architecture alignment

  • Pillar 8: Identity != Runtime — subordinates get distinct agent_name for memory isolation
  • Pillar 9: Composition Outlives Topology — communication through hive facts, not IPC
  • Pillar 11: Honest error surfacing — no silent failures, explicit depth/retry/kill errors

Closes #94

Test plan

  • All 148 unit tests pass (cargo test)
  • All 20 new composition integration tests pass
  • All 70 existing CLI integration tests pass
  • cargo clippy --all-targets — zero warnings
  • cargo fmt -- --check — clean
  • All modules within LOC limits (400/300/400/300/400)
  • Review: verify hive-based goal/progress protocol matches agent-composition.md design

🤖 Generated with Claude Code

Add four new modules for multi-agent composition following Pillars 8
(Identity != Runtime) and 9 (Composition Outlives Topology):

- agent_supervisor: subordinate lifecycle management with heartbeat
  tracking via hive, retry policy (max 2), and kill semantics
- agent_goal_assignment: goal communication and progress reporting
  through semantic facts in cognitive memory bridge
- identity_composition: composite identity with depth-limited
  subordinate nesting (SIMARD_MAX_SUBORDINATE_DEPTH env, default 3)
- agent_roles: role catalog (Engineer, Reviewer, GymRunner, Facilitator)
  with objective-based role selection and manifest generation

Integration tests cover spawn/heartbeat lifecycle, goal assignment
round-trips, progress polling, composite identity validation, and
feral cases (stale heartbeats, dead subordinates, depth limits).

Closes #94

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rysweet
rysweet merged commit 3768735 into main Mar 31, 2026
3 checks passed
rysweet pushed a commit that referenced this pull request Jun 24, 2026
…108 fix

Resolves the Cargo.toml/Cargo.lock conflict with the reverted main (4e01fbb):
- amplihack-memory re-pinned to the squash-merge SHA of amplihack-memory-lib
  PR #108 (26d49bf — the #107 _deleted read-path fix + empty-read safety gate).
- lbug = =0.17.1 (prebuilt crates.io engine; NO [patch.crates-io]). The CSR
  SIGSEGV defense is the lib's tombstone soft-delete, so the from-source C++
  patch is intentionally dropped (faster builds; prebuilt 0.17.1 reads v40 fine).
- Single lbug 0.17.1 in the graph; 0 lbug-patched refs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
rysweet added a commit that referenced this pull request Jun 24, 2026
…mory) + safe-update item-count parity gate (#2400)

* feat(safe-update): re-pin lbug 0.15.3 -> 0.17.1 (#107-fixed amplihack-memory) + item-count parity gate

Re-enables the lbug 0.15.4 -> 0.17.1 engine migration, now that the
amplihack-memory-lib #107 "silent empty-read" data-loss bug is fixed.

Re-pin (Cargo.toml / Cargo.lock):
- Bump the direct `lbug` dep (used by simard-tui's read-only goal-board view)
  from "=0.15.3" to "=0.17.1", in lockstep with the amplihack-memory pin so the
  final binary links exactly ONE engine and ONE storage format (v41). Verified
  with `cargo tree -i lbug` => a single `lbug v0.17.1` (direct + transitive).
- Re-pin the `amplihack-memory` git dependency to the commit carrying the
  0.15.4->0.17.1 engine migration AND the #107 fix (the `_deleted` tombstone
  read-path fix + the empty-read safety gate). Repoint to the squash-merge
  commit on amplihack-memory-lib `main` once PR #108 merges.

Safe-update item-count parity gate (defense-in-depth, the doc's "second,
independent defense layer"):
- The validate phase previously declared an upgrade `validated` after N clean
  OODA cycles ONLY. A silently-empty store passes clean cycles, so that alone is
  not evidence of a healthy upgrade. Now `record_cycle_with_parity` compares the
  incoming binary's cognitive item count against a pre-upgrade baseline recorded
  in `upgrade-status.json`; on a shortfall (the #107 signature: pre > 0, post
  read back smaller / empty) it forces `validate_timeout` instead of `validated`,
  so the watchdog rolls the upgrade back. `record_cycle` delegates with no
  baseline, preserving existing behaviour.
- `UpgradeStatus.pre_upgrade_item_count` (serde default) carries the baseline;
  `UpdateConfig.pre_upgrade_item_count` threads it through the orchestrator ->
  `do_swap` -> `exec_handover`. The operator CLI leaves it `None` (it must NOT
  open the live store); the brain sets it in-process from its already-open store.
- Pure `memory_parity_verdict(pre, current) -> ParityVerdict` + unit tests.

The hard, always-on guarantee is the amplihack-memory store-open gate (which the
re-pinned daemon now links); this Simard gate is the second layer. Brain-loop
wiring of the actual counts (record pre-upgrade count at update initiation; pass
the current count to `record_cycle_with_parity` at validate) requires the live
daemon's open store and is the remaining live-deploy step.

Does NOT deploy 0.17.1 to the live daemon. All 55 safe_update + 60
cognitive_memory tests pass; clippy + fmt clean.

Refs amplihack-memory-lib#107
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore(deps): bump quinn-proto 0.11.14 -> 0.11.15 (RUSTSEC-2026-0185 memory exhaustion)

cargo-audit flagged RUSTSEC-2026-0185 (high; remote memory exhaustion in
quinn-proto's out-of-order stream reassembly) — a newly-published advisory whose
fix is >=0.11.15. A transitive dep; the precise bump resolves it with no other
lockfile churn.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix(logging): route tracing logs to stderr so --json command stdout stays clean

The lbug 0.17.1 / newer amplihack-memory rev emits an INFO log on store-open;
with the tracing fmt layer writing to STDOUT, that log interleaved with the JSON
emitted by `simard memory stats|dump --json`, breaking the 3
bin_simard_memory_cli integration tests (stdout no longer parseable as JSON).

Route the fmt layer to stderr (standard CLI hygiene: logs -> stderr, results ->
stdout). Fixes the pollution for every --json command, not just memory stats.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Simard Engineer <engineer@simard.local>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

feat: Phase 5 — Agent composition & subordinate spawning

1 participant