Skip to content

feat(subagent): phase1 - persistent subagent instance types and registry - #2192

Closed
ArrogHie wants to merge 3 commits into
GCWing:mainfrom
ArrogHie:feat/subagent-persistent-phase1
Closed

feat(subagent): phase1 - persistent subagent instance types and registry#2192
ArrogHie wants to merge 3 commits into
GCWing:mainfrom
ArrogHie:feat/subagent-persistent-phase1

Conversation

@ArrogHie

Copy link
Copy Markdown
Contributor

Summary

Phase 1 of Persistent Subagent + Structured Output: define the orchestrator-level SubagentInstance data model and an in-memory instance registry. No existing call paths are modified.

Changes

  • subagent_instance.rs (new): SubagentInstance type mapping a resumable instance_id to a child Runtime Session, SubagentInstanceStatus lifecycle enum (Running / Idle / Destroyed), and a DashMap-backed SubagentInstanceRegistry.
  • Registry operations: register / get / set_running / set_idle / destroy / destroy_all_for_parent / list_for_parent / active_count, with English logs and validated state transitions (invalid transitions return Err with a warn! log).
  • coordination/mod.rs: crate-wide export of the new types (pub(crate)), following the internal-helper-module convention (mod + pub(crate) use).
  • Unit tests: 16 tests covering storage, all state-transition paths (valid and invalid), destroy semantics, per-parent listing/cleanup, can_resume, instance ID uniqueness, and active_count.

Verification

  • pnpm run fmt:rs - formatted
  • cargo check -p bitfun-core - passes, no new warnings
  • cargo test -p bitfun-core subagent_instance - 16 passed
  • cargo test -p bitfun-core coordination - 160 passed (no regressions)

Notes

  • Phase 2 will wire the registry into the Coordinator and add create/resume APIs; TaskTool changes are deferred to Phase 5.
  • The types are currently unreferenced in production call paths by design (#[expect(unused_imports)] / #[allow(dead_code)] on the module, with comments), which the compiler will flag for removal once Phase 2 lands.

- SubagentInstance maps a resumable instance_id to a child Runtime Session
- SubagentInstanceRegistry (DashMap-backed) with register/get/state
  transitions/destroy/list operations and English logs
- State transitions validated (Idle->Running, Running->Idle); invalid
  transitions return Err with warn log
- Types exported crate-wide via coordination::mod; unused until Phase 2
- 16 tests covering register/get, Idle<->Running transitions, invalid
  transition errors (Err + warn), destroy and destroy_all_for_parent,
  list_for_parent, can_resume, instance id uniqueness, and active_count
- register warns when overwriting an existing entry (M2)
- transition and destroy logs include parent_session_id (m1, m2)
- destroy captures the removed instance via DashMap remove() for logging
- document Destroyed as terminal state reserved for soft-delete/history (M1)
- module allow(dead_code) -> expect(dead_code) with reason (m3)
- add tests: transitions after destroy fail, register overwrite keeps newest (m4, m5)
@ArrogHie ArrogHie closed this Aug 10, 2026
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