feat: foundations — canonical types, Parse grammar, env DSNs, health, chains

Phase 1 of the majordomo build:
- llm/ canonical contract (messages, parts, tools, capabilities, streaming,
  Model/Provider, error classification)
- health/ clock-injected tracker (threshold bench, exponential capped
  cooldown, reset-on-success)
- root Registry + Parse (verbatim model ids, inline recursive alias
  expansion with cycle detection, chain dedup), LLM_* env-DSN providers
  (go-llm parity: lazy fallback + eager LoadEnv), health-aware chain
  executor behind the Model interface
- provider/fake scriptable test provider; hermetic test suite incl. the
  trailing-thinking chain and foreman:// env loading
- ADRs 0001-0008, CLAUDE.md, README (honest matrix), CI workflow,
  docs/phase-1-design.md

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 12:35:23 +02:00
parent 3025044817
commit dcd004289f
42 changed files with 3863 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
package llm
// StreamEvent is one increment of a streaming response.
//
// Exactly one field group is meaningful per event: a text delta, a completed
// tool call, or the final response. Tool-call arguments are buffered by the
// provider until complete — consumers never see partial JSON.
type StreamEvent struct {
// TextDelta is a fragment of assistant text.
TextDelta string
// ToolCall, when non-nil, is a fully-assembled tool call.
ToolCall *ToolCall
// Response, when non-nil, is the final accumulated response (content,
// tool calls, finish reason, usage). It is always the last event.
Response *Response
}
// Stream delivers a response incrementally.
//
// Next returns io.EOF after the final event (the one carrying Response).
// Close releases the underlying connection and is safe to call at any time,
// including after io.EOF or concurrently with Next returning.
type Stream interface {
Next() (StreamEvent, error)
Close() error
}