feat: outcome tracking + semantic search + read-before-write#4
Conversation
Three additive expansions driven by deep research into the broader DR/ADR ecosystem (see docs/explanation/research-notes.md): 1. Outcome tracking — close the feedback loop between an accepted decision and what was actually observed in practice. Outcomes are first-class entities at dr/outcomes/, with status pending|validated|invalidated| inconclusive, optional metric and evidence. Five new MCP tools (dr_record_outcome / set_outcome_status / update_outcome / list / get) gated to post-handoff only. 2. Semantic search — embeddings cache at .dr/cache/embeddings.json, populated on every dr_accept_decision (and on dr_update_decision when the result is accepted). dr_search_decisions returns semantic results when the cache is populated, substring fallback when not, "empty" when no decisions match the status filter. dr_reindex_embeddings backfills or rebuilds. OPENAI_EMBEDDING_MODEL env var; "none" disables. 3. Read-before-write — the deciding agent now retrieves prior accepted decisions before proposing a new one. The prompt mandates a dr_search_decisions call per prospective topic; hits ≥ 0.85 either suppress the new DR or get cited via related_decisions. Tests: 77 unit + 11 flow = 88 green. New JSON schema mirror for outcomes plus event/state schema extensions. Full docs in Diátaxis style: two new how-tos, a research-notes explanation, plus updates to data-model, cli, and mcp-tools references. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (34)
WalkthroughThis PR introduces three major interconnected capabilities: post-handoff outcome tracking via a new first-class entity with CRUD tools, semantic decision search using embeddings with substring fallback, and read-before-write enforcement for the deciding agent to reuse existing decisions. The changes expand the pipeline from five to six entity types and add an embedding cache layer for decision vectors, with comprehensive documentation, test coverage, and integration into existing rendering and agent workflows. ChangesOutcome Tracking and Decision Search
Sequence Diagram(s)sequenceDiagram
participant Agent as Deciding Agent
participant Search as dr_search_decisions
participant Propose as dr_propose_decision
participant Store as Store
participant Embeddings as embeddings cache
Agent->>Search: query topic (read-before-write)
Search->>Store: load decisions by status
Search->>Embeddings: retrieve cached vectors
Embeddings-->>Search: vectors or empty
alt embeddings available and non-empty
Search->>Search: compute query embedding
Search->>Search: cosine similarity ranking
Search->>Search: filter by min_score ≥0.85
else fallback
Search->>Search: substring search
Search-->>Agent: warnings included
end
Search-->>Agent: results with mode/scores
alt score ≥0.85 match found
Agent->>Agent: cite/suppress/relate decision
else no match or low score
Agent->>Propose: proceed with new decision
Propose->>Store: create decision
Propose->>Store: emit decision_proposed
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Three additive expansions driven by deep research into the broader DR/ADR ecosystem:
dr/outcomes/, gated to post-handoff. Five new MCP tools (dr_record_outcome,dr_set_outcome_status,dr_update_outcome,dr_list_outcomes,dr_get_outcome)..dr/cache/embeddings.json, populated on everydr_accept_decision.dr_search_decisionsreturns semantic results when populated, substring fallback when not.dr_reindex_embeddingsbackfills or rebuilds.OPENAI_EMBEDDING_MODELenv var;"none"disables.related_decisions. Operationalizes what the AgenticAKM literature names but doesn't ship.What's missing in the broader ecosystem (and why we built this now)
adr-tools,log4brains, Backstage TechDocs, MCP ADR Analysis Server, ...) ships outcome tracking. Most leave "Consequences" as a write-once field at decision time.Test plan
npm run typecheck(clean)npm run test:unit— 77 tests pass (was 48; +29 new inunit-outcomes,unit-embeddings)npm run test:flow— 11 tests pass (was 2; +9 new inflow-outcomes,flow-search, +1 happy-path now assertsembeddings_indexedevent)npm run build— both bundles build--helpmentionsOPENAI_EMBEDDING_MODELOPENAI_API_KEY(deferred; flow tests cover the deterministic path)Files
server/src/embeddings/— new module (client, text, indexer)server/src/tools/outcomes.ts,server/src/tools/search.ts— new tool surfacesserver/src/schemas/index.ts—OutcomeSchema,EmbeddingCacheSchema, new event kinds,next_outcome_seqschemas/outcome.schema.json+ updatedevent.schema.json,state.schema.jsondocs/how-to/track-outcomes.md,docs/how-to/search-decisions.md,docs/explanation/research-notes.mdserver/src/cli/agents/deciding.ts— read-before-write step inserted into the prompt🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Outcomeentity.Tests