12 Commits

Author SHA1 Message Date
Tanmoy Sarkar
84d69c46fd feat(companion): Promote companions from STARTING to RUNNING after startsecs
Add promote_running to CompanionManager: scans STARTING companions and moves
any that have stayed alive at least their startsecs window to RUNNING, logging
the pid and returning the promoted ones. Companions that die inside the window
are left to reaping.

Add tests for promotion after the window, too-early no-op, and non-STARTING.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 17:52:25 +05:30
Tanmoy Sarkar
bd8a91f656 feat(companion): Reap exited companion processes
Add reap_processes to CompanionManager: drains waitpid(WNOHANG), matches each
dead pid back to its companion, and records the exit via _record_exit (signal
number or exit code, exited_at, exit_count) while freeing the pid. Returns the
reaped companions; the restart decision stays with the run loop.

Add tests for exit-code, signal, and no-children cases.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 17:49:27 +05:30
Tanmoy Sarkar
2bf7e1b1fb feat(companion): Redirect companion stdout and stderr
Child calls _redirect_output after env setup: each configured log path is
opened append-mode and dup2'd onto fd 1/2. None/inherit keeps the inherited
fd; stderr stdout shares stdout's fd. Rotation stays external.

Add tests for inherit, append flags, file dup2, and stderr-to-stdout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 17:30:18 +05:30
Tanmoy Sarkar
ea2748a209 feat(companion): Apply cwd and env in spawned companion child
Child runs _apply_environment before the target: os.chdir(cwd) then
os.environ.update(env).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 17:06:42 +05:30
Tanmoy Sarkar
5639d467f3 feat(companion): Add CompanionManager skeleton and single-companion spawn
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 16:57:18 +05:30
Tanmoy Sarkar
78d67197b6 feat(companion): Add CompanionProcess runtime state and status helpers 2026-06-09 16:34:02 +05:30
Tanmoy Sarkar
2241dd4031 feat(companion): Add states and CompanionConfig with config hash 2026-06-09 15:35:00 +05:30
Tanmoy Sarkar
3f479157d7 feat(companion): Add companion process config settings 2026-06-09 15:17:43 +05:30
Tanmoy Sarkar
6fd0c2b236 feat: Add plan for companion process manager 2026-06-09 14:25:28 +05:30
Ankush Menat
7dc4d184be refactor: Simpler implementation
Just do multiple queues, nothing else.
2026-05-28 16:33:54 +05:30
Ankush Menat
ec6af68013 fix: Remove hardcoded paths for slow prediction 2026-05-28 16:01:02 +05:30
Ankush Menat
ee9bf1e950 feat: Adaptive queueing of slow/fast requests 2026-05-27 11:58:54 +05:30