mirror of
https://github.com/garrytan/gbrain.git
synced 2026-07-31 04:07:52 +00:00
registerBuiltinHandlers now handlers every operation autopilot needs to
dispatch via Minions + the single autopilot-cycle handler the autopilot
loop actually submits each interval.
Existing handlers (sync, embed, lint) rewired to call library-level Core
functions directly instead of the CLI wrappers. CLI wrappers call
process.exit(1) on validation errors; if a worker claimed a badly-formed
job, the WORKER PROCESS would die — killing every in-flight job. Cores
throw, so one bad job fails one job.
New handlers:
- extract → runExtractCore (mode: links|timeline|all, dir)
- backlinks → runBacklinksCore (action: check|fix, dir)
- autopilot-cycle → THE killer handler. Runs sync → extract → embed →
backlinks inline. Each step wrapped in try/catch; returns
{ partial: true, failed_steps: [...] } when any step fails. Does NOT
throw on partial failure — that would trigger Minion retry, and an
intermittent extract bug would block every future cycle. Replaces
the 4-job parent-child DAG proposed in early plan drafts (Codex
H3/H4: parent/child is NOT a depends_on primitive in Minions).
import.ts handler still uses the CLI wrapper (runImport) — import's one
process.exit fires only on a missing dir arg and the handler always
passes a dir; Core extraction deferred to v0.12.0 when Tier 2 refactors
happen.
registerBuiltinHandlers promoted from private to exported for testability.
test/handlers.test.ts: 4 tests. Asserts every expected handler name
registers. Asserts autopilot-cycle against a nonexistent repo returns
{ partial: true, failed_steps: ['sync', 'extract', 'backlinks'] } — does
NOT throw. Asserts autopilot-cycle against an empty (but real) git repo
returns a result with a steps map, never throws.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>