Skip to content

Phase 0.4: Decision logging for edge evaluation, provider selection, retries#76

Merged
mattleaverton merged 6 commits intodanshapiro:mainfrom
mattleaverton:impl/decision-logging
Apr 1, 2026
Merged

Phase 0.4: Decision logging for edge evaluation, provider selection, retries#76
mattleaverton merged 6 commits intodanshapiro:mainfrom
mattleaverton:impl/decision-logging

Conversation

@mattleaverton
Copy link
Copy Markdown
Collaborator

Summary

  • Edge condition evaluation events — every condition on every outgoing edge is logged with whether it matched, so you can trace exactly why routing went one way vs another
  • Enhanced edge_selected event — now includes selection_method (condition_match, preferred_label, weight, lexical_tiebreak, etc.), candidates_evaluated, and conditions_matched
  • Provider/model selection events — logs which provider, model, and backend were chosen for each agent node
  • Retry decision events — logs each retry decision with attempt number, max retries, whether it will retry, and why

All events go to progress.ndjson as structured JSON. Best-effort, non-blocking — never impacts run performance or correctness.

Files changed

  • next_hop.go — Added ProgressFunc callback, emit edge_condition_evaluated events
  • engine.go — Enhanced edge_selected, added retry_decision events, selection metadata tracking
  • codergen_router.go — Added provider_selected event
  • decision_logging_test.go — Two integration tests (conditional routing + hill-climber loop)
  • next_hop_test.go, resume.go, subgraph.go — Signature updates for new callback parameter

Test plan

  • go test ./internal/attractor/engine/... -run TestDecisionLogging — 2 new tests pass
  • go test ./internal/attractor/engine/... -run TestToolGraph — all existing Phase 0 tests pass
  • Run a conditional graph, read progress.ndjson, verify edge evaluation trail explains routing

🤖 Generated with Claude Code

mattleaverton and others added 6 commits April 1, 2026 12:41
Thread a ProgressFunc callback through resolveNextHop and
selectMatchingConditionalEdge so routing functions can emit
structured progress events without depending on the engine.

Emit edge_condition_evaluated events for each condition
evaluated during fan-in failure routing, showing the node,
target, condition expression, and whether it matched.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Thread ProgressFunc through selectAllEligibleEdges and selectNextEdge
using variadic parameter for backward compatibility with tests.
Emit edge_condition_evaluated for each conditional edge evaluated
in selectAllEligibleEdges, matching the fan-in path events.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add edgeSelectionMeta struct to track how edges were selected:
condition_match, preferred_label, suggested_next_ids, weight,
lexical_tiebreak, only_edge, or fallback. Thread this through
selectAllEligibleEdgesWithMeta, selectNextEdgeWithMeta, and
resolvedNextHop so the edge_selected progress event includes
selection_method, candidates_evaluated, and conditions_matched.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Log a structured progress event when a provider, model, and backend
are resolved for a node. The source field indicates how the selection
was made: graph_attrs, force_model, or cli_only_override.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Log a structured event after each failed attempt capturing whether
the engine will retry, the attempt number, max retries, and a
human-readable reason explaining why or why not.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
TestDecisionLogging_ConditionalRoute verifies that edge_condition_evaluated
events appear with correct matched/unmatched values and that edge_selected
shows selection_method=condition_match.

TestDecisionLogging_HillClimber verifies the retry loop produces edge
evaluation events for each iteration, fail->implement edges on failures,
success->done on final iteration, and retry_decision events.

Also fix: remove progress callback from fan-out probe call to avoid
duplicate edge_condition_evaluated events.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@mattleaverton mattleaverton merged commit 7e27a56 into danshapiro:main Apr 1, 2026
1 check failed
leegonzales added a commit to leegonzales/kilroy that referenced this pull request Apr 3, 2026
engine.go — struct literal alignment drift from PR danshapiro#76 (decision logging)
worktree_hint_test.go — comment alignment drift from PR danshapiro#78 (error UX)

No logic changes. Pure whitespace.

gofmt -l . → clean
go vet ./... → clean
go build ./... → clean

🤖 Servitor heartbeat fix — unblocks main CI
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant