Skip to content

refactor(epic-1973): Extract zeph-subagent crate from zeph-core (Phase 1f)#2010

Merged
bug-ops merged 1 commit intomainfrom
1973-phase-1f
Mar 19, 2026
Merged

refactor(epic-1973): Extract zeph-subagent crate from zeph-core (Phase 1f)#2010
bug-ops merged 1 commit intomainfrom
1973-phase-1f

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 19, 2026

Summary

  • Extract 9,036 LOC subagent management module from zeph-core into standalone zeph-subagent crate
  • zeph-core reduced from 64,851 to 55,860 LOC (-13.9%)
  • No circular dependencies: zeph-subagent has zero imports from zeph-core

New crate: crates/zeph-subagent

11 modules: command, def, error, filter, grants, hooks, manager, memory, resolve, state, transcript

Key design decisions

spawn_for_task() callback refactor — instead of taking TaskId + mpsc::Sender<TaskEvent> (which would require zeph-subagent → zeph-core), the method now accepts a generic completion callback:

pub fn spawn_for_task<F>(&mut self, ..., on_done: F) -> Result<String, SubAgentError>
where F: FnOnce(String, Result<String, SubAgentError>) + Send + 'static

The caller (agent/mod.rs) constructs the closure that sends TaskEvent to the scheduler. This breaks the orchestration dependency at the API boundary.

Re-export shimzeph-core/src/lib.rs replaces pub mod subagent; with:

pub mod subagent {
    pub use zeph_subagent::*;
    pub use zeph_subagent::{command, def, error, filter, grants, hooks, manager, memory, resolve, state, transcript};
}

All crate::subagent::* paths in orchestration, agent, and tests work unchanged.

SubAgentHandle fields — widened from pub(crate) to pub to allow test harnesses in zeph-core to construct handles via struct literals.

Test results

  • 5,917 tests passing (299 new in zeph-subagent), 0 failures
  • cargo +nightly fmt --check: clean
  • cargo clippy --workspace --features full -- -D warnings: clean

Breaking changes

None. All re-exports in zeph-core maintain backward compatibility.

Next phase

Phase 1g will extract zeph-orchestration. spawn_for_task no longer depends on orchestration types, so the circular dependency between orchestration and subagent is resolved.

Spec: .local/specs/003-epic-1973-phase-1f/spec.md
Epic: #1973

…e 1f)

Extract 9,028 LOC subagent management module from zeph-core into standalone
zeph-subagent crate. zeph-core reduces from 64,851 to 55,860 LOC (-13.9%).

New crate zeph-subagent contains 11 modules:
  command, def, error, filter, grants, hooks, manager,
  memory, resolve, state, transcript

Key changes:
- spawn_for_task() refactored to accept generic completion callback
  (F: FnOnce(String, Result<String, SubAgentError>)) eliminating the
  direct orchestration dependency from zeph-subagent
- zeph-core re-exports pub mod subagent { pub use zeph_subagent::*; }
  preserving all crate::subagent::* import paths in orchestration,
  agent, and test code without modification
- SubAgentHandle fields widened from pub(crate) to pub to allow test
  harnesses in downstream crates to construct handles directly

Test results: 5,917 tests passing (299 new in zeph-subagent)
Phase 1g will extract zeph-orchestration.

Closes: epic #1973 Phase 1f
@github-actions github-actions bot added refactor Code refactoring without functional changes size/L Large PR (201-500 lines) documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate dependencies Dependency updates and removed size/L Large PR (201-500 lines) refactor Code refactoring without functional changes labels Mar 19, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 19, 2026 09:19
@bug-ops bug-ops merged commit c93d55f into main Mar 19, 2026
24 checks passed
@bug-ops bug-ops deleted the 1973-phase-1f branch March 19, 2026 09:20
@bug-ops bug-ops linked an issue Mar 19, 2026 that may be closed by this pull request
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate dependencies Dependency updates documentation Improvements or additions to documentation rust Rust code changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: extract zeph-subagent crate from zeph-core

1 participant