Repository navigation
feat(ENG-014): per-agent decision log + traceable provenance DAG - #11
Merged
Merged
Conversation
Make decision provenance first-class — the same "make an implicit thing explicit" pattern as ENG-006 (approvals), applied to *why* the unit did what it did. Decisions form a DAG traceable to the originating request, layered over (and referencing, never copying) the append-only audit log. - core: `Decision` zod schema (OpenTelemetry-trace-compatible: rootRequestId ≈ trace id, parentDecisionIds = span parents; DAG, not a tree) + a `DecisionLog` port (record/get/listByRoot/byWorkItem/traverseToRoot) added to `Persistence`. A pure, unit-tested `traceToRoot` BFS shared by backends. - db: append-only `decisions` table (parent-id edge set, hierarchy FKs, link back to the audit event) + repo fns + `DbDecisionLog` + migration 0005. - integrations: `KnowledgeBackedDecisionLog` — the hybrid recommended in the ticket: Postgres indexes the queryable node/edges, the KB stores a human-readable Markdown body (PR-reviewable files on the GitHub backend). - server: a per-epic root request node (trace id = epicId) seeded idempotently; each agent step (shape · decompose · implement · QA) emits a structured decision chained to its parent(s) + work item + audit event; traversal API (`GET /api/decisions`, `/:id`, `/:id/trace`). Provenance writes are best-effort so they never break the lifecycle. Tests: decision schema + DAG traversal (linear/multi-parent/unknown); KnowledgeBackedDecisionLog fan-out + read delegation + KB-failure resilience; doc renderer. typecheck/lint/test (113)/build all green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes ENG-014 (Wave 4). Makes decision provenance first-class — the same "make an implicit thing explicit" pattern as ENG-006 (approvals), applied to why the unit did what it did. Decisions form a DAG traceable to the originating request, layered over (and referencing, never copying — invariant #2) the append-only audit log.
What's added
Decisionzod schema (OpenTelemetry-trace-compatible:rootRequestId≈ trace id,parentDecisionIds= span parents; a DAG, not a tree) and aDecisionLogport (record/get/listByRoot/byWorkItem/traverseToRoot) added toPersistence. A pure, unit-testedtraceToRootBFS is single-sourced and shared by backends.decisionstable (parent-id edge set, hierarchy FKs, link back to the audit event), repo functions,DbDecisionLog, and migration0005.KnowledgeBackedDecisionLog, the hybrid the ticket recommends: Postgres indexes the queryable node/edges (integrity, traversal); the KB stores a human-readable Markdown body — PR-reviewable files on the GitHub backend.epicId) seeded idempotently; each agent step (shape · decompose · implement · QA) emits a structured decision chained to its parent(s), work item, and audit event; a traversal API (GET /api/decisions?root=…|?ticketId=…,/api/decisions/:id,/api/decisions/:id/trace). Provenance writes are best-effort so they never break the lifecycle.Acceptance criteria
coreDecisionLogport (Postgres index + GitHub-doc body).Design note
The decision graph indexes in Postgres (like the audit log, it's the queryable substrate) and writes its body to whatever KB the backend uses — this is the ticket's "A as the index, B for the body" hybrid, and keeps
corebackend-agnostic (invariant #5). No graph DB stood up.Tests
Decision schema + DAG traversal (linear / multi-parent / unknown id);
KnowledgeBackedDecisionLogfan-out + read delegation + KB-failure resilience; doc renderer.pnpm typecheck·lint·test(113) ·buildall green.🤖 Generated with Claude Code