|
| 1 | +--- |
| 2 | +dun: |
| 3 | + id: IP-013-doc-dag |
| 4 | + depends_on: |
| 5 | + - SD-013 |
| 6 | + - F-016 |
| 7 | + - US-013 |
| 8 | + - TP-013 |
| 9 | + - helix.prd |
| 10 | + review: |
| 11 | + self_hash: "" |
| 12 | + deps: {} |
| 13 | +--- |
| 14 | +# IP-013: Doc DAG + Review Stamps Implementation Plan |
| 15 | + |
| 16 | +## Goal Summary |
| 17 | + |
| 18 | +- Implement a frontmatter-driven doc DAG that detects missing/stale docs using |
| 19 | + review stamps (no git/mtime). |
| 20 | +- Resolve dynamic inputs deterministically (node/refs/code_refs/paths). |
| 21 | +- Provide prompt envelopes that require related requirements/ADRs/code context |
| 22 | + and a Gaps & Conflicts section. |
| 23 | + |
| 24 | +## Related Requirements / ADRs / Code |
| 25 | + |
| 26 | +### Requirements |
| 27 | + |
| 28 | +- F-016 Doc DAG + Review Stamps (`docs/helix/01-frame/features/F-016-doc-dag.md`) |
| 29 | +- US-013 Doc DAG With Review Stamps (`docs/helix/01-frame/user-stories/US-013-doc-dag.md`) |
| 30 | +- TP-013 Doc DAG + Review Stamps (`docs/helix/03-test/test-plans/TP-013-doc-dag.md`) |
| 31 | +- PRD (`docs/helix/01-frame/prd.md`) and architecture (`docs/helix/02-design/architecture.md`) |
| 32 | + |
| 33 | +### ADRs |
| 34 | + |
| 35 | +- No ADR explicitly scoped to Doc DAG yet. If ADR guidance is required for |
| 36 | + doc hashing or frontmatter rules, flag for review. |
| 37 | + |
| 38 | +### Code (current state) |
| 39 | + |
| 40 | +- Check orchestration: `internal/dun/engine.go` |
| 41 | +- Existing cascade logic (to supersede): `internal/dun/change_cascade.go` |
| 42 | +- Prompt envelopes + input loading: `internal/dun/agent.go` |
| 43 | +- Helix checks: `internal/plugins/builtin/helix/plugin.yaml` |
| 44 | + |
| 45 | +## Gaps & Conflicts |
| 46 | + |
| 47 | +- No ADR explicitly covers doc hashing/frontmatter normalization. Flag for |
| 48 | + review if policy guidance is required before finalizing hashing rules. |
| 49 | +- Helix lacks a standard implementation-plan prompt template; this plan will |
| 50 | + introduce one for Doc-DAG only. |
| 51 | + |
| 52 | +## Implementation Steps |
| 53 | + |
| 54 | +1. **Define frontmatter model + parser** |
| 55 | + - Files: `internal/dun/frontmatter.go`, `internal/dun/frontmatter_test.go` |
| 56 | + - Parse `dun` block: id, depends_on, prompt, inputs, review stamps. |
| 57 | + - Ensure stable serialization for hashing (exclude `dun.review`). |
| 58 | + |
| 59 | +2. **Implement doc hashing** |
| 60 | + - Files: `internal/dun/hash.go`, `internal/dun/hash_test.go` |
| 61 | + - Hash includes frontmatter (minus `dun.review`) + body, normalized newlines. |
| 62 | + |
| 63 | +3. **Add deterministic input resolver** |
| 64 | + - Files: `internal/dun/input_resolver.go`, `internal/dun/input_resolver_test.go` |
| 65 | + - Support selectors: `node:`, `refs:`, `code_refs:`, `paths:` |
| 66 | + - Resolve IDs using optional graph `id_map` and frontmatter registry. |
| 67 | + - Sort + dedupe inputs for stable prompts. |
| 68 | + |
| 69 | +4. **Load optional graph defaults (required roots + id_map)** |
| 70 | + - Files: `internal/dun/doc_dag.go` |
| 71 | + - Parse `.dun/graphs/*.yaml` into required roots, id_map, default prompts. |
| 72 | + |
| 73 | +5. **Build Doc DAG + staleness detection** |
| 74 | + - Files: `internal/dun/doc_dag.go`, `internal/dun/doc_dag_test.go` |
| 75 | + - Determine missing required nodes and stale descendants from review stamps. |
| 76 | + - Emit issues for `missing:<id>` and `stale:<id>`. |
| 77 | + |
| 78 | +6. **Emit prompt envelopes for missing/stale docs** |
| 79 | + - Files: `internal/dun/doc_dag.go`, `internal/dun/agent.go` |
| 80 | + - Use prompt from frontmatter or graph default. |
| 81 | + - Inputs default to parents unless overridden. |
| 82 | + - Ensure prompt requires “Gaps & Conflicts” section. |
| 83 | + |
| 84 | +7. **Add `dun stamp` command** |
| 85 | + - Files: `internal/dun/stamp.go`, `internal/dun/stamp_test.go`, |
| 86 | + `cmd/dun/main.go` |
| 87 | + - Update `dun.review.self_hash` and `dun.review.deps`. |
| 88 | + |
| 89 | +8. **Helix prompt + graph defaults** |
| 90 | + - Files: `internal/plugins/builtin/helix/prompts/implementation-plan.md` |
| 91 | + - Add `.dun/graphs/helix.yaml` with id_map + required roots for doc DAG. |
| 92 | + |
| 93 | +9. **Wire check type** |
| 94 | + - Files: `internal/dun/engine.go`, `internal/dun/types.go`, |
| 95 | + `internal/plugins/builtin/helix/plugin.yaml` |
| 96 | + - Register new `doc-dag` check in Helix plugin. |
| 97 | + |
| 98 | +10. **Tests (P0 first)** |
| 99 | + - Unit tests: frontmatter parse, hash excludes review, input resolver. |
| 100 | + - Integration test (day 1): cascade stale detection end-to-end with prompt |
| 101 | + inputs (TC-006 in TP-013). |
| 102 | + |
| 103 | +## Testing Plan |
| 104 | + |
| 105 | +- Follow `docs/helix/03-test/test-plans/TP-013-doc-dag.md`. |
| 106 | +- Day 1 integration test: `TestDocDagCascadeStale` in |
| 107 | + `internal/dun/engine_test.go` using fixture `internal/testdata/repos/doc-dag-cascade/`. |
| 108 | + |
| 109 | +## Rollout |
| 110 | + |
| 111 | +- Implement and test in isolation. |
| 112 | +- Add Helix prompt + graph defaults. |
| 113 | +- Re-run `dun check --agent-mode prompt` to confirm new check output. |
0 commit comments