singularity-forge/src
deseltrus 7c449b8b73 feat: worker NDJSON monitoring + budget enforcement for parallel orchestration (#814)
* feat: worker NDJSON monitoring, budget enforcement, PID-based stop fallback

Closes three gaps in parallel orchestration:

1. **Worker stdout monitoring** — Workers now run with `--mode json` so
   they emit NDJSON events. The coordinator parses stdout line-by-line,
   extracting cost/token data from `message_end` events. This keeps
   per-worker cost tracking in sync with actual API spend and updates
   session status files for live dashboard visibility.

2. **Budget enforcement before spawn** — `startParallel()` now checks
   `isBudgetExceeded()` before each worker spawn. When the aggregate
   cost across all workers reaches the configured ceiling, no new
   workers are started.

3. **PID-based stop fallback** — `stopParallel()` now falls back to
   `process.kill(pid, "SIGTERM")` when the ChildProcess handle is null
   (e.g., after coordinator restart when handles aren't available).
   Previously, orphaned workers could not be stopped.

Includes 11 new tests covering NDJSON format validation, cost
aggregation, budget ceiling comparison, and PID-based kill patterns.
All 54 existing parallel-orchestration tests still pass.

Relates to #672

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: currentUnit type must match SessionStatus interface (object | null, not string)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 07:46:52 -06:00
..
resources feat: worker NDJSON monitoring + budget enforcement for parallel orchestration (#814) 2026-03-17 07:46:52 -06:00
tests test: expand E2E smoke tests with 14 new CLI verification tests 2026-03-17 00:02:26 -05:00
app-paths.ts Initial commit 2026-03-10 22:28:37 -06:00
bundled-extension-paths.ts Fix packaging verification and path portability (#378) 2026-03-14 12:28:14 -06:00
cli.ts feat: interactive update prompt on startup (#770) (#775) 2026-03-16 21:09:33 -06:00
headless.ts feat: add headless new-milestone command for programmatic milestone creation (#781) 2026-03-16 21:28:56 -06:00
help-text.ts feat: add headless new-milestone command for programmatic milestone creation (#781) 2026-03-16 21:28:56 -06:00
loader.ts refactor: deduplicate help text, cross-platform validate-pack, fix dev.js 2026-03-16 13:29:31 -05:00
logo.ts fix: abort squash-merge on conflict and stop auto-mode instead of looping (#merge-bug-fix) 2026-03-12 15:32:39 -06:00
mcp-server.ts feat: add VS Code extension scaffold and MCP server compiled module 2026-03-16 16:46:20 -05:00
models-resolver.ts refactor: remove unnecessary 'as any' casts, dead exports, and duplicate code (#786) 2026-03-16 21:47:04 -06:00
onboarding.ts fix: Phase 1 quick wins — bug fixes, security hardening, and performance 2026-03-16 13:18:02 -05:00
pi-migration.ts Merge pull request #151 from dbachelder/fix/pi-provider-reuse-and-extension-loading 2026-03-12 22:25:15 -06:00
remote-questions-config.ts feat: add Telegram as remote questions channel (#645) (#655) 2026-03-16 11:09:39 -06:00
resource-loader.ts refactor: remove unnecessary 'as any' casts, dead exports, and duplicate code (#786) 2026-03-16 21:47:04 -06:00
tool-bootstrap.ts fix: Phase 1 quick wins — bug fixes, security hardening, and performance 2026-03-16 13:18:02 -05:00
update-check.ts feat: interactive update prompt on startup (#770) (#775) 2026-03-16 21:09:33 -06:00
update-cmd.ts feat: add gsd update subcommand for self-update 2026-03-13 18:47:33 -03:00
wizard.ts fix: Phase 1 quick wins — bug fixes, security hardening, and performance 2026-03-16 13:18:02 -05:00