Commit a8eb86c
feat(daemon): loop body wires executeIntent end-to-end (claim → dispatch → heartbeat) (#107)
Stacked on #106. Replaces the injected-executor abstraction in daemon/loop.ts
with a direct call to meta/intent.ts::executeIntent, closing the
meta-orchestrator loop. Status transitions, audit-row writes, and the second
sovereignty gate are all owned by executeIntent → dispatch; the loop's
responsibility is leader lifecycle, intent claiming, heartbeats, and outcome
classification.
Four outcomes are handled distinctly:
- ok=true (executed) → bump processed counter, reset error backoff
- ok=true (replayed) → bump replayed counter, no backoff, no double-count
- ok=false (refused) → bump refused counter, no backoff (steady-state)
- ok=false (exec error) → bump errored counter, bounded exp backoff
Sovereignty refusals are identified by canonical error prefixes emitted by
meta/executors/dispatch.ts ("sovereignty re-reckon:" /
"sovereignty snapshot stale ..."). Refusals are NOT treated as transient
faults — they are valid outcomes and do not trigger backoff.
The loop honors options.signal via AbortController throughout, including
inside the sleep helper, so SIGTERM from daemon/runtime/entrypoint.ts (PR #105)
unwinds cleanly through releaseLeadership.
tests/daemon/loop.spec.ts — real Neon integration. Seeds two pending intents
against the update_obligation_status executor, runs runLeaderLoop with
maxIntents=2, asserts:
- both intents reach status='done'
- each produces exactly one cc_actions_log row (attempt=1, key set, status='completed')
- cc_obligations rows actually moved to 'deferred'
- cc_node_leases shows leadership released on clean exit
- log stream contains intent_heartbeat_before / intent_heartbeat_after pairs
Out of scope (not in this PR):
- new executors (mercury, etc.)
- production deploy
- multi-node coordination beyond single-node leader
- schema additions on cc_intents / cc_actions_log
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 5cc20f2 commit a8eb86c
2 files changed
Lines changed: 401 additions & 103 deletions
0 commit comments