Skip to content

Commit f4857d8

Browse files
committed
Expand doc DAG inputs and test plan
1 parent 704fe5c commit f4857d8

4 files changed

Lines changed: 59 additions & 21 deletions

File tree

docs/helix/01-frame/features/F-016-doc-dag.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ stamps.
1313
- `depends_on` relationships
1414
- `prompt` and `inputs`
1515
- `review` stamps
16-
- Support an optional graph file for required roots and default prompts.
16+
- Support an optional graph file for required roots, ID mappings, and default
17+
prompts.
18+
- Resolve dynamic inputs deterministically with the following selectors:
19+
- `node:<id>` (explicit node reference)
20+
- `refs:<id>` (IDs extracted from a referenced document)
21+
- `code_refs:<id>` (ID references in code paths)
22+
- `paths:<glob>` (explicit path globs)
23+
- Provide an ID map for `refs` and `node` resolution (e.g. `US-{id}` to
24+
`docs/helix/01-frame/user-stories/US-{id}-*.md`).
1725
- Compute deterministic content hashes that include frontmatter (excluding
1826
`dun.review`).
1927
- Determine stale documents when parent hashes differ from `review.deps`.
@@ -23,6 +31,8 @@ stamps.
2331
prompt settings or graph defaults.
2432
- Provide `dun stamp` to update `dun.review` fields in docs.
2533
- Keep output deterministic for a given repo state.
34+
- Prompt templates must require a "Gaps & Conflicts" section and instruct the
35+
agent to flag unresolved conflicts before proceeding.
2636

2737
## Inputs
2838

@@ -37,6 +47,8 @@ stamps.
3747
to create it.
3848
- `dun stamp` updates `dun.review.self_hash` and `dun.review.deps`.
3949
- Prompt envelopes include parent context inputs by default.
50+
- Prompt envelopes include resolved requirements, ADRs, and code references
51+
when selectors are configured.
4052
- Results are stable across repeated runs with the same repo state.
4153

4254
## Traceability

docs/helix/01-frame/user-stories/US-013-doc-dag.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ stale when upstream requirements change.
88

99
- A document with a changed parent is flagged as stale until re-stamped.
1010
- Required documents missing from the DAG are reported as missing.
11-
- Dun emits prompts for stale or missing documents with parent context.
11+
- Dun emits prompts for stale or missing documents with parent context,
12+
including related requirements, ADRs, and code references.
13+
- If conflicts or gaps are detected, the prompt requires they are flagged
14+
before proceeding.

docs/helix/02-design/solution-designs/SD-013-doc-dag.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,23 @@ which artifacts are missing or stale when upstream docs change.
1616

1717
1. **Frontmatter parsing**: read `dun` blocks from Markdown to register nodes.
1818
2. **Optional graph defaults**: load `.dun/graphs/*.yaml` for required roots
19-
and default prompts for missing docs.
20-
3. **Hashing**: compute a stable hash of each doc including frontmatter,
19+
ID mappings, and default prompts for missing docs.
20+
3. **Input resolution**: resolve deterministic inputs via selectors:
21+
`node:<id>`, `refs:<id>`, `code_refs:<id>`, `paths:<glob>`.
22+
4. **Hashing**: compute a stable hash of each doc including frontmatter,
2123
excluding `dun.review`.
22-
4. **Staleness**: compare parent hashes to `dun.review.deps`.
23-
5. **Missing detection**: flag required roots or required descendants with no
24+
5. **Staleness**: compare parent hashes to `dun.review.deps`.
25+
6. **Missing detection**: flag required roots or required descendants with no
2426
files.
25-
6. **Prompting**: emit prompts for missing or stale docs with parent inputs.
26-
7. **Stamping**: `dun stamp` writes updated review hashes to frontmatter.
27+
7. **Prompting**: emit prompts for missing or stale docs with parent inputs
28+
and require gaps/conflicts to be flagged before implementation steps.
29+
8. **Stamping**: `dun stamp` writes updated review hashes to frontmatter.
2730

2831
## Components
2932

3033
- **Frontmatter Reader**: extracts `dun` config and review stamps.
3134
- **Doc Graph Builder**: builds the DAG from frontmatter + graph defaults.
35+
- **Input Resolver**: expands selectors into ordered input paths.
3236
- **Hasher**: computes doc content hashes.
3337
- **Doc-DAG Check**: emits missing/stale issues and prompts.
3438
- **Stamp Command**: updates review stamps in files.
@@ -37,14 +41,16 @@ which artifacts are missing or stale when upstream docs change.
3741

3842
1. `dun check` runs `doc-dag` check.
3943
2. Frontmatter reader registers nodes and dependencies.
40-
3. Graph builder adds required roots/defaults.
41-
4. Hasher computes current hashes.
42-
5. Staleness/missing detection runs.
43-
6. Prompt envelopes are emitted for actionable nodes.
44+
3. Graph builder adds required roots/defaults and ID map.
45+
4. Input resolver expands selectors to a sorted input list.
46+
5. Hasher computes current hashes.
47+
6. Staleness/missing detection runs.
48+
7. Prompt envelopes are emitted for actionable nodes.
4449

4550
## Data Model
4651

4752
- **Node**: id, path, depends_on, prompt, inputs, review
53+
- **Input selector**: node, refs, code_refs, paths
4854
- **Review**: self_hash, deps map, reviewed_at
4955
- **Edge**: parent -> child from `depends_on`
5056

@@ -61,11 +67,13 @@ which artifacts are missing or stale when upstream docs change.
6167
- New check type: `doc-dag`.
6268
- New command: `dun stamp`.
6369
- Optional graph files: `.dun/graphs/*.yaml`.
70+
- Optional ID map in graph file for resolving refs.
6471

6572
## Files (Planned)
6673

6774
- `internal/dun/doc_dag.go` (graph build + staleness detection)
6875
- `internal/dun/frontmatter.go` (parse/serialize frontmatter)
76+
- `internal/dun/input_resolver.go` (resolve selectors to inputs)
6977
- `internal/dun/hash.go` (doc hashing)
7078
- `internal/dun/stamp.go` (stamp logic)
7179
- `cmd/dun/main.go` (wire `dun stamp`)

docs/helix/03-test/test-plans/TP-013-doc-dag.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ From US-013:
1414
|----|---------------------|
1515
| AC-1 | A document with a changed parent is flagged as stale until re-stamped |
1616
| AC-2 | Required documents missing from the DAG are reported as missing |
17-
| AC-3 | Dun emits prompts for stale/missing docs with parent context |
17+
| AC-3 | Dun emits prompts for stale/missing docs with parent context, related requirements, ADRs, and code references, and requires gaps/conflicts to be flagged |
18+
| AC-4 | Dynamic input selectors resolve deterministically (node, refs, code_refs, paths) |
1819

1920
## 2. Existing Test Coverage
2021

@@ -39,13 +40,14 @@ No existing tests cover doc-DAG behavior. All acceptance criteria are gaps.
3940
| GAP-001 | No test for cascade stale detection | P0 | AC-1 |
4041
| GAP-002 | No test for missing required roots | P0 | AC-2 |
4142
| GAP-003 | No test for prompt envelope content | P0 | AC-3 |
43+
| GAP-004 | No test for dynamic input selector resolution | P0 | AC-4 |
4244

4345
### 3.2 Secondary Gaps (P1)
4446

4547
| Gap ID | Description | Priority | Acceptance Criteria |
4648
|--------|-------------|----------|---------------------|
47-
| GAP-004 | No test for `dun stamp` updating review deps | P1 | AC-1 |
48-
| GAP-005 | No test for deterministic ordering | P1 | AC-3 |
49+
| GAP-005 | No test for `dun stamp` updating review deps | P1 | AC-1 |
50+
| GAP-006 | No test for deterministic ordering | P1 | AC-3 |
4951

5052
## 4. Proposed Test Cases
5153

@@ -88,7 +90,19 @@ func TestDocDagMissingRequiredRoot(t *testing.T) {
8890
}
8991
```
9092

91-
#### TC-004: Stamp Updates Review Deps
93+
#### TC-004: Input Selector Resolution
94+
**File**: `internal/dun/input_resolver_test.go`
95+
**Priority**: P0
96+
**Covers**: AC-4
97+
98+
```go
99+
func TestInputSelectorsResolveDeterministically(t *testing.T) {
100+
// Given: node, refs, code_refs, and paths selectors
101+
// Then: resolved inputs are stable, deduped, and ordered
102+
}
103+
```
104+
105+
#### TC-005: Stamp Updates Review Deps
92106
**File**: `internal/dun/stamp_test.go`
93107
**Priority**: P1
94108
**Covers**: AC-1
@@ -103,16 +117,16 @@ func TestStampUpdatesReviewDeps(t *testing.T) {
103117

104118
### 4.2 Integration Tests (Required for Day 1)
105119

106-
#### TC-005: Cascade Stale Detection (End-to-End)
120+
#### TC-006: Cascade Stale Detection (End-to-End)
107121
**File**: `internal/dun/engine_test.go`
108122
**Priority**: P0
109-
**Covers**: AC-1, AC-3
123+
**Covers**: AC-1, AC-3, AC-4
110124

111125
```go
112126
func TestDocDagCascadeStale(t *testing.T) {
113127
// Given: fixture repo with parent+child, stamped
114128
// When: parent changes
115-
// Then: child is stale and prompt is emitted
129+
// Then: child is stale and prompt is emitted with related inputs
116130
}
117131
```
118132

@@ -124,9 +138,10 @@ func TestDocDagCascadeStale(t *testing.T) {
124138
**Expected**:
125139
- `doc-dag` check status = warn/fail
126140
- Issue `stale:helix.architecture`
127-
- Prompt envelope includes PRD content as input
141+
- Prompt envelope includes PRD content plus resolved ADR/code refs
142+
- Prompt requires "Gaps & Conflicts" section
128143

129-
#### TC-006: Missing Required Doc Prompt
144+
#### TC-007: Missing Required Doc Prompt
130145
**File**: `internal/dun/engine_test.go`
131146
**Priority**: P0
132147
**Covers**: AC-2, AC-3

0 commit comments

Comments
 (0)