Part of #1 and #6 (project bootstrap, v0.1, phase 5 split). Blocked by 5a and 5b.
Deliverables
core/loop/
Config struct (Provider, MCP, Router, Approver, Logger, MaxSteps).
Run(ctx, cfg, sess, userMessage) (<-chan event.Event, error).
- Behavior:
- Append user message to session.
- Optional
Router.Narrow for the turn.
- Stream from Provider with narrowed tools.
- Forward
TextDelta; on ToolCallRequest → Approver.Approve → MCP dispatch → append result to session → re-stream.
- Forward
Finish / Error and exit.
- Enforce
MaxSteps cap.
- Recover from panics in tool handlers →
event.Error; do not recover panics from Provider/core.
- Structured logging via
slog (helper at core/log/ if needed).
Tests
- Loop tests using
provider.FakeProvider — no live model, no live MCP.
- Cover: text-only turn; tool-call turn; multi-step tool chain; MaxSteps enforcement; approval denied; approval allow-all-for-session; provider error mid-stream; mcp error during dispatch; context cancellation.
-race clean, -shuffle=on clean.
- Coverage contributes to the >80%
core/... gate.
Out of scope
- SQL safety middleware (v0.2)
- OpenTelemetry tracing (v0.3)
Branch
feat/bootstrap-loop (off main after 5b merges)
Spec: §6.5, §11, §12 of the bootstrap spec in #1.
Part of #1 and #6 (project bootstrap, v0.1, phase 5 split). Blocked by 5a and 5b.
Deliverables
core/loop/Configstruct (Provider,MCP,Router,Approver,Logger,MaxSteps).Run(ctx, cfg, sess, userMessage) (<-chan event.Event, error).Router.Narrowfor the turn.TextDelta; onToolCallRequest→Approver.Approve→ MCP dispatch → append result to session → re-stream.Finish/Errorand exit.MaxStepscap.event.Error; do not recover panics from Provider/core.slog(helper atcore/log/if needed).Tests
provider.FakeProvider— no live model, no live MCP.-raceclean,-shuffle=onclean.core/...gate.Out of scope
Branch
feat/bootstrap-loop(offmainafter 5b merges)Spec: §6.5, §11, §12 of the bootstrap spec in #1.