This document identifies all required modules, APIs, and integration points that need to be implemented to build a complete drover-code system.
Status: ✅ IMPLEMENTED
Responsibilities:
- Discriminated union types using unexported marker methods
- ContentBlock interface with TextBlock, ToolUseBlock, ToolResultBlock
- StreamEvent and Delta discriminated unions
- Message constructors (UserMessage, AssistantMessage, ToolResultMessage)
- ToolDefinition structure for API schema delivery
Key Exports:
type ContentBlock interfacetype StreamEvent interfacetype Delta interfacefunc UserMessage(text string) Messagefunc AssistantMessage(blocks []ContentBlock) Messagefunc ToolResultMessage(results []ToolResultBlock) Message
Status: ✅ IMPLEMENTED
Responsibilities:
- Raw HTTP client (not using official SDK)
- Request construction with streaming headers
- Message serialisation (manual marshalling for correctness)
- Error handling and structured errors
- 10-minute timeout for long-running tasks
Key Exports:
type Client structfunc NewClient(apiKey, baseURL, model string) *Clientfunc (c *Client) StreamMessage(ctx context.Context, req StreamRequest) (*Stream, error)func (c *Client) StreamNonStreaming(ctx context.Context, req StreamRequest) (Message, error)
Dependencies:
- HTTP standard library
- JSON marshalling/unmarshalling
- Context for cancellation
Status: ✅ IMPLEMENTED
Responsibilities:
- Parse server-sent events from Anthropic API
- Iterator pattern:
Next(),Event(),Err(),Close() - Event type parsing and discrimination
- Backpressure support through iterator
- Wire-format to typed conversion
- Configurable scanner buffer for large inputs
Key Exports:
type Stream structfunc (s *Stream) Next() boolfunc (s *Stream) Event() StreamEventfunc (s *Stream) Err() errorfunc (s *Stream) Close() error
Status: ✅ IMPLEMENTED
Tool Interface:
type Tool interface {
Name() string
Description() string
InputSchema() json.RawMessage
NeedsPermission(input json.RawMessage) bool
Execute(ctx context.Context, input json.RawMessage) (string, error)
}Registry Responsibilities:
- Collect and index tools by name
- Generate ToolDefinition list for API
- Dispatch tool calls to implementations
- Goroutine-safe concurrent execution
Key Exports:
type Registry structfunc NewRegistry() *Registryfunc (r *Registry) Register(t Tool)func (r *Registry) Definitions() []api.ToolDefinitionfunc (r *Registry) Execute(ctx context.Context, name string, input json.RawMessage) (string, error)func RegisterAll(r *Registry, workDir string)
Status:
Responsibilities:
- JSON Schema builder for tool inputs
- Common parameter types
- Input validation helpers
- Error formatting utilities
Key Components:
Schemabuilder with fluent API- Property type helpers (string, number, boolean, object, array)
- Required/optional field handling
- Description injection
Status: ✅ IMPLEMENTED
| Tool | Type | File |
|---|---|---|
read_file |
Read-only | fs/read.go |
write_file |
Write | fs/write.go |
edit_file |
Write | fs/edit.go |
list_directory |
Read-only | fs/list.go |
file_info |
Read-only | fs/info.go |
Status: ✅ IMPLEMENTED
| Tool | Type | File |
|---|---|---|
bash |
System | shell/bash.go |
Status: ✅ IMPLEMENTED
| Tool | Type | File |
|---|---|---|
glob |
Read-only | search/glob.go |
grep |
Read-only | search/grep.go |
Status: ✅ IMPLEMENTED
| Tool | Type | File |
|---|---|---|
git_status |
Read-only | git/status.go |
git_diff |
Read-only | git/diff.go |
git_log |
Read-only | git/log.go |
git_add |
Write | git/add.go |
git_commit |
Write | git/commit.go |
git_push |
Write | git/push.go |
git_create_branch |
Write | git/branch.go |
Status: ✅ IMPLEMENTED
| Tool | Type | File |
|---|---|---|
web_fetch |
Read-only | web/fetch.go |
Status: ✅ IMPLEMENTED
| Tool | Type | File |
|---|---|---|
ukc_create |
System | ukc/tool_create.go |
ukc_exec |
System | ukc/tool_exec.go |
ukc_delete |
System | ukc/tool_delete.go |
ukc_delete_all |
System | ukc/tool_delete_all.go |
ukc_list |
Read-only | ukc/tool_list.go |
Status: ✅ IMPLEMENTED
Responsibilities:
- Maintain message history as immutable snapshots
- System prompt management
- Token budget estimation (heuristic-based)
- Thread-safe RWMutex for concurrent access
- Message appending with validation
Key Exports:
type Manager structfunc NewManager(systemPrompt string, estimator TokenEstimator) *Managerfunc (m *Manager) Messages() []api.Message(snapshot copy)func (m *Manager) Append(msg api.Message) errorfunc (m *Manager) EstimatedTokens() intfunc (m *Manager) EstimatedTokenUsage() TokenUsage
Key Features:
- Automatic context compaction when soft limit exceeded
- Snapshot copies prevent racing on concurrent access
- Atomic message additions
Status: ✅ IMPLEMENTED
Responsibilities:
- Plan → Act → Observe cycle
- Stream response and accumulate blocks
- Tool call execution and result injection
- Error handling and retry logic
- Event emission for UI/observer consumption
Agent State Machine:
- Send user message to API
- Stream and accumulate response blocks
- If
stop_reason == "tool_use":- Extract tool calls
- Execute each tool
- Inject results as user message
- Repeat from step 1
- If
stop_reason == "end_turn":- Emit final response event
- Return
Key Exports:
type Agent structfunc NewAgent(client *api.Client, convo *convo.Manager, tools *tools.Registry) *Agentfunc (a *Agent) Run(ctx context.Context, userInput string) errorfunc (a *Agent) Events() <-chan Event(event stream)
Event Types:
TokenUsageEvent— API token consumptionToolCallEvent— Tool invocation with name/inputToolResultEvent— Tool output and statusTextEvent— Streamed text from APIErrorEvent— Fatal errorsCompleteEvent— Turn finished
Status: ✅ IMPLEMENTED
Responsibilities:
- Define event types for UI/coordinator consumption
- Serializable event hierarchy
- Event metadata (timestamps, sequence numbers)
Key Types:
type Event interface {
Type() string // "text", "tool_call", "tool_result", "usage", "error", "complete"
Timestamp() time.Time
}
// Concrete types: TextEvent, ToolCallEvent, ToolResultEvent, UsageEvent, ErrorEvent, CompleteEventStatus: ✅ IMPLEMENTED
Responsibilities:
- Structured error types
- Error categorisation (retryable vs permanent)
- Error wrapping with context
Key Types:
UserError— Message parsing/validation failuresToolError— Tool execution failures (may be retryable)APIError— API communication failures (may be retryable)
Status: ✅ IMPLEMENTED
Responsibilities:
- Load settings from
~/.claude/settings.json→<workdir>/.claude/settings.json - Load local override from
.claude/settings.local.json - Merge cascade (system → project → local)
- Environment variable overrides
Key Exports:
func Load(workDir string) (Settings, error)type Settings structwith model, timeouts, permission presets, dream config
Status: ✅ IMPLEMENTED
Responsibilities:
- Apply settings to client (model, base URL)
- Apply settings to agent/convo (context limits, compaction heuristics)
- Environment variable precedence
Key Functions:
func ApplyClientSettings(c *api.Client, s Settings) errorfunc ApplyAgentSettings(a *Agent, s Settings) error
Status: ✅ IMPLEMENTED
Responsibilities:
- Recursively find CLAUDE.md files in working directory tree
- Walk upward from workDir to project root
- Concatenate markdown into system prompt fragment
- Inject into base system prompt
Key Functions:
func GlobMarkdownInstructions(workDir string) (string, error)
Status: ✅ IMPLEMENTED
Responsibilities:
- Identify oldest conversational "chunk" (user → assistant → tools → results)
- Select compaction candidate when context limit approaching
- Implement summarisation via API callback
Key Functions:
func (m *Manager) CompactionCandidate() ([]api.Message, error)func (m *Manager) ReplaceCompacted(old []api.Message, summary api.Message) error
Status: ✅ IMPLEMENTED
Responsibilities:
- Heuristic token estimation (characters ÷ 4 by default)
- Calibration against real API responses
- Per-model tuning (B2 heuristic)
Key Functions:
func EstimateTokens(text string) intfunc CalibrateFromResponse(estimatedBefore int, actualAfter int) float64
Status: ✅ IMPLEMENTED
Responsibilities:
- Define permission categories (read, write, system, git, web, dangerous)
- Tool-to-category mapping
- Check before tool execution
Key Functions:
func (e *Engine) IsAllowed(toolName string) boolfunc (e *Engine) NeedsApproval(toolName string, input json.RawMessage) bool
Status: ✅ IMPLEMENTED
Presets:
default— allow read + git read/write, require approval for system/webunikernel— minimal headless preset (read/write + safe shell)full— unrestricted (development only)readonly— only read operations
Status: ✅ IMPLEMENTED
Responsibilities:
- Non-blocking consolidation of sessions into memories
- Background goroutine for summarisation
- Safe buffered trigger channel (size 8, silent drop if full)
Key Types:
type Worker structfunc NewWorker(store Store, client API) *Workerfunc (w *Worker) Trigger(s Session)(non-blocking)func (w *Worker) Start(ctx context.Context)
Status: ✅ IMPLEMENTED
Features:
- Default backend
- Single
.claude/memory.jsonfile - Atomic writes via temp-file + rename
- O(n) loading for recent entries
Status: ✅ IMPLEMENTED
Features:
- Opt-in via
DROVER_CODE_DREAM_BACKEND=sqlite .claude/memory.db(modernc.org/sqlite, pure Go)- Indexed recency queries
- Auto-import from existing memory.json
Status: ✅ IMPLEMENTED
Features:
- Optional max entry count (settings or env)
- Optional max age in days
- Automatic pruning after consolidation save
- Startup pruning if limits are set
Status: ✅ IMPLEMENTED
Responsibilities:
- Decompose task into parallel subtasks
- Spawn worker agents with shared context
- Coordinate and merge results
- Handle partial failures
Key Functions:
func NewCoordinator(convo *convo.Manager, tools *tools.Registry) *Coordinatorfunc (c *Coordinator) Decompose(ctx context.Context, prompt string) ([]Task, error)func (c *Coordinator) RunWorkers(ctx context.Context, tasks []Task) ([]Result, error)
Decomposition Examples:
- "Write tests for all uncovered files" → one worker per file
- "Refactor auth module" → one worker per component
- "Update all dependencies" → one worker per dependency
Status: ✅ IMPLEMENTED
Protocol:
- LSP wire format (Content-Length + JSON-RPC 2.0)
- Bidirectional message handling
- Concurrent request handling on goroutines
- Response routing via pending map
Key Exports:
type Bridge structfunc NewBridge(r io.Reader, w io.Writer) *Bridgefunc (b *Bridge) Register(method string, h Handler)func (b *Bridge) Run(ctx context.Context) errorfunc (b *Bridge) Send(id int64, method string, params any) errorfunc (b *Bridge) SendError(id int64, code int, message string) error
Registered Methods (minimal):
drover/execute— execute agent with input promptdrover/cancel— cancel in-flight executionping— connection check
Status: ✅ IMPLEMENTED
Responsibilities:
- HTTP server listening for GitHub push/issue_comment events
- HMAC-SHA256 signature verification
- Thread-safe event routing
Key Functions:
func NewServer(port int, secret string, handler EventHandler) *Serverfunc (s *Server) Start() errorfunc (s *Server) Close() error
Status: ✅ IMPLEMENTED
Responsibilities:
- Parse GitHub webhook payloads
- Extract
@drover-codementions from comments - Build execution context (repo, file, branch)
Key Functions:
func ParseIssueCommentEvent(payload []byte) (Event, error)func ExtractDroverMentions(comment string) ([]Mention, error)
Status: ✅ IMPLEMENTED
Responsibilities:
- Clone/fetch repo
- Create agent session with GitHub context
- Post results back as comment
- Handle authentication and permissions
Key Functions:
func NewRunner(client *github.Client, token string, workDir string) *Runnerfunc (r *Runner) Run(ctx context.Context, ev Event) errorfunc (r *Runner) PostComment(ctx context.Context, repoURL, number string, body string) error
Status: ✅ IMPLEMENTED
Responsibilities:
- Thin wrapper around GitHub API
- Post/update comments
- Clone repo via git
- Fetch branch updates
Status: ✅ IMPLEMENTED
Responsibilities:
- Bubble Tea model implementation
- Message routing (from stdin, agent events)
- State management (input buffer, conversation history, view mode)
Key Types:
type Model struct(implements tea.Model)func NewModel(convo *convo.Manager, agent *agent.Agent) *Modelfunc (m *Model) Init() tea.Cmdfunc (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)func (m *Model) View() string
Status: ✅ IMPLEMENTED
Responsibilities:
- Render conversation history
- Render input prompt area
- Render status bar (mode, tokens, model)
- Render help text
Key Functions:
func (m *Model) renderHistory() stringfunc (m *Model) renderInput() stringfunc (m *Model) renderStatus() string
Status: ✅ IMPLEMENTED
Responsibilities:
- Interactive permission approval for sensitive tools
- Tool description display
- Input/output preview
- Approval/denial UI
Key Functions:
func (m *Model) promptPermission(tool string, input json.RawMessage) bool
Status: ✅ IMPLEMENTED
Provides:
- Lipgloss style definitions
- Color palette
- Component styling (input, status, history, etc.)
Status: ✅ IMPLEMENTED
Responsibilities:
- Initialize and run Bubble Tea program
- Handle terminal setup/teardown
- Signal handling (Ctrl+C)
Key Functions:
func Run(ctx context.Context, m *Model) error
Status: ✅ IMPLEMENTED
Formats:
- Plain text (default)
- JSON Lines (DROVER_CODE_JSONL=1)
- Structured result JSON (--result-json PATH)
Key Features:
- Line-based output for piping
- Machine-readable event serialisation
- Final artifact output
Status: ✅ IMPLEMENTED
Responsibilities:
- Parse webhook flags
- Start GitHub webhook server
- Route events to runner
- Keep process alive
Flags:
--port(default: 8080)--secret(GitHub webhook secret)--work-dir(default: current dir)
Status: ✅ IMPLEMENTED
Responsibilities:
- Load command definitions from Markdown (frontmatter) and JSON configuration
- Expand variables (
$1,$ARGUMENTS), placeholders ({var}), file contents (@file.txt), and inline shell execution (!`cmd`) - Evaluate operations through
guardclientfor risk and policy governance - Provide an
Executorfor TUI and Headless environments to evaluate custom inputs
Key Modules:
types.go:CommandDefinitionandCommandRegistryparser.go: Frontmatter and JSON parsingloader.go: Directory traversal and configuration injectionexpander.go: Regex-based prompt expansionexecutor.go: Integration of template expansion and Drover Guard evaluation
Status:
Responsibilities:
- Accept uploaded workspace tar/zip
- Extract to worker filesystem
- Prepare for drover-code execution
- Upload results back to coordinator
Endpoints:
POST /workspace/upload— receive and extractGET /workspace/download— stream results back
Status:
Responsibilities:
- Execute drover-code subprocess
- Stream tool execution logs via SSE
- Report completion/failure
Endpoints:
POST /exec— start execution with configGET /exec/:id— stream output
Status: ✅ IMPLEMENTED
Features:
- Request ID tracing
- User ID tracking
- Structured logging
Status:
Responsibilities:
- Optional Langfuse trace export
- Trace parent/child relationships
- Token usage reporting
Status: ✅ IMPLEMENTED
Responsibilities:
- Detect API keys, tokens, passwords in output
- Redact before display
- Warning system
Key Functions:
func Detect(text string) []Findingfunc (f Finding) Redact(text string) string
Status: ✅ IMPLEMENTED
Responsibilities:
- Flag parsing
- Mode detection (TUI, headless, webhook, bridge)
- Context setup (config, API client, agent)
- Mode-specific execution
Flags/Modes:
- TUI: default (no flags)
- Headless: non-TTY stdin or
DROVER_CODE_HEADLESS=1 - Webhook:
./drover-code webhook - IDE Bridge:
CLAUDE_CODE_IDE_BRIDGE=1 - Coordinator:
CLAUDE_CODE_COORDINATOR_MODE=1
| Component | Depends On | Depended On By |
|---|---|---|
api (types, client, stream) |
(none - foundation) | All |
tools (registry, toolutil) |
api |
agent, coordinator |
agent (loop, events) |
api, tools, convo |
tui, coordinator, bridge, github, cmd |
convo (manager, compaction) |
api |
agent, coordinator, dream |
config (loader, apply, markdown) |
(stdlib) | cmd |
permissions (engine, presets) |
(stdlib) | tui, agent |
dream (worker, stores, retention) |
api, convo |
cmd |
coordinator |
api, agent, convo, tools |
cmd |
bridge (JSON-RPC) |
agent, api, tools |
cmd |
github (server, parser, runner) |
api, agent, tools, config |
cmd |
tui (Bubble Tea) |
agent, convo, permissions, config |
cmd |
telemetry (context, langfuse) |
(stdlib) | cmd, optional in various packages |
undercover (detection, redaction) |
(stdlib) | tui, bridge |
ukc-agent |
api, REST framework |
standalone server |
- Manual JSON marshalling (not struct tags) to handle discriminated unions
json.RawMessagefor tool input round-trip fidelity- Type field injection at serialisation time
- Five methods:
Name(),Description(),InputSchema(),NeedsPermission(),Execute() - Goroutine-safe (coordinator calls tools concurrently)
json.RawMessagefor deferred parsing
- Strict plan → act → observe cycle
- Accumulator for tool input fragments (strings.Builder for efficiency)
- Per-index maps for concurrent block assembly
- Error differentiation (retryable vs permanent)
- RWMutex for thread-safe snapshots
- Snapshot copies prevent racing
- Token estimation + automatic compaction
- Non-blocking trigger channel (8-size buffer)
- Background consolidation goroutine
- Two backend implementations (JSON, SQLite)
- Retention caps with pruning
- Task decomposition via API
- Worker isolation with snapshot contexts
- Result merging and failure handling
- Content-Length framing
- Bidirectional message routing
- Goroutine-per-request handlers
- Pending map for response correlation
- HMAC-SHA256 signature verification
@drover-codemention extraction- Inline comment posting
- Full repo interaction via git + agent
-
UKC Agent (
cmd/ukc-agent)- Workspace upload/download endpoints need full implementation
- Execution streaming needs SSE integration
-
Langfuse Telemetry
- Optional integration needs completion
- Trace export and parent/child relationships
-
Bridge IDE Extensions
- VS Code extension stub exists but needs full implementation
- JetBrains plugin not yet started
-
Batch API Integration
- Future optimization for non-streaming calls (dream consolidation)
- Not yet implemented but documented
-
Retry/Backoff Logic
- Currently relies on caller retries
- Could benefit from RetryingClient wrapper for 429/529 responses
-
Real Token Counting
- Currently uses character heuristic (÷4)
- Proper tokenizer integration could be added
# Main binary (single static binary)
CGO_ENABLED=0 go build -o drover-code ./cmd/drover-code
# UKC agent (optional deployment)
CGO_ENABLED=0 go build -o ukc-agent ./cmd/ukc-agent
# Tests (all packages)
CGO_ENABLED=0 go test ./...
# Fuzz targets (see .github/workflows/ci.yml)
go test -fuzz=. -fuzztime=10s ./...ANTHROPIC_API_KEY— requiredANTHROPIC_AUTH_TOKEN— alternative key formatANTHROPIC_BASE_URL— optional gateway overrideANTHROPIC_MODEL— override default model
DROVER_CODE_HEADLESS=1— force headless modeCLAUDE_CODE_IDE_BRIDGE=1— enable IDE bridgeCLAUDE_CODE_COORDINATOR_MODE=1— enable coordinator modeGITHUB_TOKEN— for webhook mode
DROVER_CODE_PERMISSION_PRESET=— permission set (default, unikernel, full, readonly)
DROVER_CODE_DREAM_BACKEND=sqlite— use SQLite instead of JSONDROVER_CODE_DREAM_SKIP_JSON_IMPORT=1— skip JSON→SQLite migrationDROVER_CODE_DREAM_MAX_ENTRIES=— max memory entries (0 = unlimited)DROVER_CODE_DREAM_MAX_AGE_DAYS=— max memory age (0 = unlimited)
DROVER_CODE_JSONL=1— force JSON Lines outputDROVER_CODE_HEADLESS_PLAIN=1— force plain text in headless modeDROVER_CODE_RESULT_PATH=— write final result JSON to file
RUN_AGENT_EVALS=1— run integration eval tests (requires API key)
types_test.go— message construction, marshalling round-tripsstream_test.go— SSE parsing, event accumulationclient_test.go— request construction, error handling- Each tool has
_test.gofor schema validation and execution
- Agent loop with fake streams
- Full conversation flow with mock tools
- Coordinator task decomposition
- Bridge JSON-RPC message routing
- Stream parsing (
stream_fuzz_test.go) - Config merge (
merge_fuzz_test.go) - GitHub parser (
parser_fuzz_test.go) - Undercover detection (
undercover_fuzz_test.go) - Registry (
registry_fuzz_test.go) - Permissions (
permission_fuzz_test.go) - Convo compaction (
convo_fuzz_test.go)
- Conversation compaction invariants (
convo_property_test.go) - Registry completeness (
registry_property_test.go) - Permissions engine consistency (
engine_property_test.go) - Undercover redaction coverage (
undercover_property_test.go)
- Live agent tasks against real API (see
evals/) - Token counting calibration
- Tool integration validation
Last updated: [Current Date] This is a reference document; specific implementation status may change.