Skip to content

refactor: remove process module dependency on agents module (#326)#348

Merged
Wirasm merged 2 commits into
mainfrom
kild/326-process-agents-dep
Feb 11, 2026
Merged

refactor: remove process module dependency on agents module (#326)#348
Wirasm merged 2 commits into
mainfrom
kild/326-process-agents-dep

Conversation

@Wirasm

@Wirasm Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Removed upward dependency from process module to agents module by making find_process_by_name() accept caller-provided search patterns via additional_patterns parameter
  • Moved agent pattern resolution to terminal/handler.rs (the only caller) where domain awareness belongs
  • Added get_all_process_patterns() helper to agents module for bidirectional pattern resolution

Root Cause

process/operations.rs imported crate::agents to look up agent-specific process name patterns in generate_search_patterns(). This created an upward dependency from a low-level utility layer to a domain-specific layer, violating the existing pattern where callers pass metadata to process functions (like kill_process() already does).

Changes

File Change
crates/kild-core/src/process/operations.rs Added additional_patterns param to find_process_by_name() and generate_search_patterns(), removed use crate::agents import
crates/kild-core/src/terminal/handler.rs Resolves agent patterns once before retry loop, passes them to find_process_by_name()
crates/kild-core/src/agents/registry.rs Added get_all_process_patterns() for bidirectional agent pattern resolution
crates/kild-core/src/agents/mod.rs Re-exports get_all_process_patterns

Testing

  • cargo fmt --check passes
  • cargo clippy --all -- -D warnings passes
  • cargo test -p kild-core passes (all 5 directly affected tests pass)
  • cargo build --all succeeds

Validation

cargo fmt --check && cargo clippy --all -- -D warnings && cargo test -p kild-core && cargo build --all

Issue

Fixes #326

Analyze the upward dependency from process to agents module and
document implementation plan to decouple via caller-passed patterns.
The process module imported the agents module to look up agent-specific
process name patterns during process detection, creating an upward
dependency from a low-level utility to a domain-specific layer.

Move agent pattern resolution to the caller (terminal/handler.rs) by
adding an `additional_patterns` parameter to `find_process_by_name()`
and `generate_search_patterns()`. Add `get_all_process_patterns()` to
the agents module for bidirectional pattern resolution.

Fixes #326
@Wirasm

Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner Author

Self Code Review

Summary

The refactor correctly addresses the architectural concern. No issues found.

Findings

Strengths

  • Dependency cleanly eliminated - use crate::agents removed from process/operations.rs
  • Follows the existing kill_process() pattern where callers pass domain-specific metadata
  • Bidirectional agent pattern resolution logic correctly preserved in get_all_process_patterns()
  • Agent patterns resolved once before retry loop (performance improvement over old per-attempt resolution)
  • All tests pass, clippy clean

Security

  • No security concerns identified

Checklist

  • Fix addresses root cause from investigation
  • Code follows codebase patterns
  • Tests cover the change
  • No obvious bugs introduced

@Wirasm Wirasm merged commit 48b126f into main Feb 11, 2026
6 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.

refactor: remove process module dependency on agents module

1 participant