Home

mweinbach / agent-coworker

publicmweinbach/agent-coworker
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

feat(platform): proc + fs lifecycle modules

2 months ago

564e14c
Authored
Max Weinbach7/7/2026, 2:08:38 PM
proc.ts: the process-lifecycle engine (spec §1.7, amendment 4). run() ports
the full execFileCompat errorCode contract (TIMEOUT/124, ABORT_ERR/130,
ENOENT, MAXBUFFER) but spawns POSIX children detached so timeout/abort/
overflow kill the whole process TREE via kill(-pgid) + SIGKILL escalation;
win32 uses taskkill /T /F (no Job Object API in pure Bun — PID-reuse raciness
documented). Output decodes via text.decodeChildOutput (the mid-code-point
maxBuffer-truncation bug is fixed). spawnStreaming/ChildHandle absorb
subprocess.ts. terminateGracefully takes requestShutdown (the JSON-RPC
shutdown hook) and falls back to stdin-EOF then killTree. isAlive with the
one conservative liveness policy. registerShutdownSignals with opt-in
stdin-EOF (headless servers must not exit at boot). 42 tests incl. a live
grandchild-heartbeat tree-kill proof.

fs.ts: atomic filesystem primitives (spec §1.9, trimmed per critique).
writeFileAtomic/replaceFileAtomic/replaceExecutableAtomic (never delete-first,
win32 lock-code retry, EXDEV copy+fsync+rename), moveWithFallback (typed
FileLockedError), removeWithRetry, acquireLockDir (mkdir-based, dead-owner
stale break), symlink (win32 junction fallback + typed SymlinkPrivilegeError),
hardenPrivate* (posix mode bits, documented win32 no-op). 56 tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Parentde67a62

5 files changed
  • src/platform/fs.ts+776−0
  • src/platform/index.ts+2−0
  • src/platform/proc.ts+708−0
  • test/platform/fs.test.ts+1006−0
  • test/platform/proc.test.ts+732−0