Skip to content

Phase 5c: core/loop #16

@cjimti

Description

@cjimti

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:
    1. Append user message to session.
    2. Optional Router.Narrow for the turn.
    3. Stream from Provider with narrowed tools.
    4. Forward TextDelta; on ToolCallRequestApprover.Approve → MCP dispatch → append result to session → re-stream.
    5. Forward Finish / Error and exit.
    6. 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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions