-
Notifications
You must be signed in to change notification settings - Fork 1
Pipeline Plan 46
The plan file is being blocked by the sandbox. The plan content has been fully prepared. Let me present it directly to you instead.
Add mid-pipeline team scaling to Shipwright — spawn additional agents when a pipeline stage is struggling, dismiss idle agents when work is done. This builds on the existing daemon_auto_scale() infrastructure (which scales pipelines) to now scale agents within a pipeline.
Key distinction: daemon_auto_scale() controls how many concurrent pipelines run. This feature controls how many agents work within a single pipeline's build stage.
The 12 prior loop iterations on this branch made no progress on the actual feature and introduced regressions by removing safety code:
- Removed
unset CLAUDECODE(needed for spawning Claude CLI from within a session) - Removed
trap '' HUP(prevents tmux detach from killing pipelines) - Reverted
printf-based state writes to heredoc (vulnerable to delimiter injection) - Changed
daemon_logfrom stderr to stdout (corrupts$()captures) - Removed CPU-based agent health detection (premature killing of thinking agents)
- Removed nudge system, deterministic log rotation, overflow-safe backoff
These must be reverted first before adding new code.
-
scripts/sw-scaling.sh(~400 lines) — Team scaling engine: trigger evaluation, spawn/dismiss orchestration, agent registry, cooldown, budget checks -
scripts/sw-scaling-test.sh(~600 lines) — Test suite
-
scripts/sw-daemon.sh— Source scaling engine, addscaling_evaluate()call in health check loop, add scaling config toload_config() -
scripts/sw-loop.sh— Writescaling-signals.jsonafter each iteration with structured progress data -
scripts/sw-pipeline.sh— Export scaling-relevant state fromstage_build() -
templates/pipelines/autonomous.json— Addscalingconfig section -
templates/pipelines/full.json— Addscalingconfig section -
templates/pipelines/enterprise.json— Addscalingconfig section -
dashboard/server.ts— Handlepipeline.agent_spawned/pipeline.agent_dismissedevents -
package.json— Registersw-scaling-test.sh -
.claude/CLAUDE.md— Document the scaling system
Restore: unset CLAUDECODE, trap '' HUP, printf-based state writes, daemon_log stderr routing, CPU health detection, nudge system, DAEMON_LOG_WRITE_COUNT, overflow-safe backoff, exec in daemon_spawn_pipeline.
Functions: scaling_load_config(), scaling_evaluate(), scaling_check_triggers(), scaling_cooldown_ok(), scaling_budget_check(), scaling_get_active_agents()
Agent registry at ~/.shipwright/scaling/<issue>/agents.json. Triggers:
| Trigger | Condition | Action |
|---|---|---|
iteration_threshold |
Build iter > 5, no test pass | Spawn debugger |
repeated_errors |
Same error 3+ times | Spawn specialist |
multi_module |
5+ directories touched | Spawn builder |
idle_dismiss |
No output for 5+ min | Dismiss agent |
stage_complete |
Stage finished | Dismiss extras |
Uses tmux split-window, sets pane title, writes context file, launches Claude, registers in agent registry, emits pipeline.agent_spawned event.
Sends C-c to pane, waits 30s, force-kills if needed, removes from registry, emits pipeline.agent_dismissed, re-tiles.
Assembles: pipeline state, recent errors, memory patterns, file assignments (non-overlapping), team task list.
Add scaling_evaluate() call after existing health check logic. Add config vars to load_config().
Write scaling-signals.json after each iteration with iteration count, consecutive failures, error signature, modules touched, test pass/fail.
autonomous.json, full.json, enterprise.json get "scaling": { "enabled": true, "agents_max": 3, "cooldown_s": 120 }.
Add pipeline.agent_spawned, pipeline.agent_dismissed, pipeline.team_scaled to event processing in dashboard/server.ts.
15 tests following project harness pattern with mock tmux/claude/sw-cost.sh binaries.
- Task 1: Revert regressions from previous iterations
- Task 2: Create
sw-scaling.shwith core scaling functions - Task 3: Implement
scaling_spawn_agent()with tmux + context + registry - Task 4: Implement
scaling_dismiss_agent()with graceful shutdown - Task 5: Implement
scaling_build_context()for new agent context transfer - Task 6: Integrate scaling into daemon health check loop
- Task 7: Add
scaling-signals.jsonoutput tosw-loop.sh - Task 8: Add scaling config to pipeline templates
- Task 9: Add dashboard event handling for scaling events
- Task 10: Create
sw-scaling-test.shwith 15 unit tests - Task 11: Register test suite in package.json, update CLAUDE.md
- Task 12: Run full test suite — all 23 suites pass
Unit tests: Mock tmux/claude/cost binaries; test each trigger, cooldown, budget, registry CRUD, context generation.
Integration: Run existing daemon + pipeline test suites to verify no regressions.
Manual: Start daemon with scaling.enabled: true, run pipeline with failing tests, verify agent spawns/dismisses, check events.jsonl + dashboard.
-
sw-scaling.shfollows project conventions (pipefail, Bash 3.2, VERSION, emit_event) - Pipeline can add/dismiss agents mid-stage
- New agents receive full context
- Budget limits constrain scaling
- 120s cooldown prevents thrashing
- Scale events in
events.jsonland dashboard - All regressions reverted
- 15+ scaling tests pass
- Full
npm test(23 suites) passes