Skip to content

fix: spawn lineage, extract tests, remove kill instructions - #16

Merged
araa47 merged 8 commits into
mainfrom
refactor/extract-unit-tests
Mar 21, 2026
Merged

fix: spawn lineage, extract tests, remove kill instructions#16
araa47 merged 8 commits into
mainfrom
refactor/extract-unit-tests

Conversation

@araa47

@araa47 araa47 commented Mar 20, 2026

Copy link
Copy Markdown
Owner

Summary

Spawn lineage (v0.0.7)

  • Require --spawned-by on every orca spawn call; fail closed when lineage is missing
  • Auto-register L0 orchestrator entries (openclaw, cc/cx/cu with --spawned-by self)
  • Workers spawned by L0 now correctly get depth=1 via parent lookup
  • orca list shows L0 orchestrator headers with backend info
  • Protect L0 entries from kill/killall/gc

Extract unit tests

  • Move inline #[cfg(test)] mod tests blocks from all 11 source modules into dedicated tests.rs companion files (src/foo.rs -> src/foo/mod.rs + src/foo/tests.rs)
  • Reduces production source file sizes by ~60% (from 11,060 to 4,561 lines)

Remove kill instructions from agent notifications

  • Remove "orca kill" from wake/stuck/warn messages sent to orchestrator panes
  • Remove "orca killall --mine" from the REPORT_INSTRUCTIONS prompt injected into workers
  • Update SKILL.md to forbid agents from killing/gc-ing workers without human approval

Test plan

  • cargo fmt --check passes
  • cargo clippy -- -D warnings passes
  • cargo nextest run -- 617 tests pass, 0 failures
  • Pre-commit hooks pass
  • CI checks green

araa47 and others added 5 commits March 21, 2026 00:27
Fail closed when a spawn omits parent lineage so delegated workers cannot silently become root L1 workers. This keeps depth labels, wake routing, and completion deferral aligned with the real worker tree while documenting the new v0.0.7 contract.

Made-with: Cursor
- Stop normalizing `openclaw` to empty string; preserve in spawned_by
- Root spawns (L0→L1) now correctly produce depth=1 instead of depth=0
- resolve_spawn_lineage returns parent.depth+1 for known parents,
  depth=1 for L0 markers (openclaw, self, legacy root)
- Add `--spawned-by self` for L0 cc/cx/cu orchestrators: auto-detects
  or generates L0 pane name from tmux window title
- orca list now shows L0 orchestrator headers (e.g. |-🐋 | L0 openclaw)
- Update validate_spawn_context to allow L0 markers as spawned_by
- Update SKILL.md with L0 cc/cx/cu instructions (self marker)
- Fix 5 broken tests, add 13 new tests (606 total, all passing)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace normalize_spawned_by/resolve_self_l0_name with ensure_l0_orchestrator
  that auto-registers L0 entries (openclaw or cc/cx/cu) in state at depth=0
- Workers spawned by L0 now correctly get depth=1 (🐳 L1) via parent lookup
- print_tree shows L0 orchestrator entries as group headers with backend info
- cmd_kill protects virtual openclaw L0 entries from being killed
- cmd_killall/cmd_gc skip L0 orchestrator entries (bookkeeping, not workers)
- Validate spawn context before L0 registration to avoid side effects on error
- Remove L0 window rename from spawn.rs (now handled by ensure_l0_orchestrator)
- Update integration tests to use depth=1/spawned_by=openclaw for seeded workers

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move inline `#[cfg(test)] mod tests` blocks from all 11 source modules
into dedicated `tests.rs` companion files using the directory module
pattern (e.g. `src/cli.rs` -> `src/cli/mod.rs` + `src/cli/tests.rs`).

This reduces production source file sizes by ~60% (from 11,060 to 4,561
lines across src/) while keeping all 617 tests passing with full access
to private items via `use super::*`.

Also updates `include_str!` paths in cli/mod.rs to account for the
extra directory nesting.

Made-with: Cursor
@github-actions

github-actions Bot commented Mar 20, 2026

Copy link
Copy Markdown

🧪 Coverage Report

Metric Coverage
Lines 88.22% (12157 lines, 1432 missed)
Functions 96.32%
Regions 88.41%
📄 Coverage by file
File Lines Functions Regions
cli.rs 89.52% 98.05% 90.87%
cli/mod.rs 77.00% 85.71% 76.21%
config.rs 94.94% 95.71% 94.35%
config/mod.rs 90.57% 90.00% 87.10%
daemon.rs 80.05% 92.47% 81.36%
daemon/mod.rs 42.28% 78.05% 40.19%
events.rs 99.44% 100.00% 97.63%
events/mod.rs 98.72% 100.00% 92.86%
main.rs 100.00% 100.00% 100.00%
names.rs 100.00% 100.00% 100.00%
names/mod.rs 100.00% 100.00% 100.00%
prompts.rs 100.00% 100.00% 100.00%
prompts/mod.rs 100.00% 100.00% 100.00%
spawn.rs 93.08% 96.43% 92.57%
spawn/mod.rs 89.89% 92.86% 87.77%
state.rs 98.09% 93.33% 96.13%
state/mod.rs 95.36% 87.50% 87.88%
tmux.rs 97.53% 100.00% 96.69%
tmux/mod.rs 93.59% 100.00% 91.99%
wake.rs 98.60% 100.00% 98.93%
wake/mod.rs 95.08% 100.00% 95.67%
worktree.rs 95.25% 100.00% 95.61%
worktree/mod.rs 84.76% 100.00% 83.91%

Coverage must not decrease. See CONTRIBUTING.md for policy.

Agents receiving wake/stuck/warn notifications were seeing "orca kill
<name>" as a suggested action, which led to agents killing workers
(including orchestrators) without human approval. This caused the ivy
orchestrator to get killed during testing.

- Remove "orca kill" lines from wake_message, stuck_message,
  warn_message, and routing_block in wake/mod.rs
- Remove "orca killall --mine" cleanup instructions from the
  REPORT_INSTRUCTIONS prompt injected into spawned workers
- Update SKILL.md to explicitly forbid agents from killing/gc-ing
  workers without human approval
- Update wake tests to assert kill instructions are absent

Made-with: Cursor
@araa47 araa47 changed the title refactor: extract unit tests into companion files fix: spawn lineage, extract tests, remove kill instructions Mar 20, 2026
@araa47
araa47 merged commit 735f1fa into main Mar 21, 2026
3 checks passed
@araa47
araa47 deleted the refactor/extract-unit-tests branch March 21, 2026 07:27
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