fix(scripts): migrate_vbrief ingests PRD/SPECIFICATION structured content into spec narratives (#397)#399
Conversation
…tent into spec narratives (#397)
|
@greptileai review |
|
| Filename | Overview |
|---|---|
| scripts/migrate_vbrief.py | Adds _parse_prd_narratives(), _HEADING_TO_NARRATIVE_KEY, and Step 2b to ingest PRD/SPECIFICATION structured headings into specification.vbrief.json; bold-footer regex correctly fixed; two minor defensive-coding gaps (heading punctuation, setdefault on non-dict plan) |
| tests/cli/test_migrate_vbrief.py | Adds 14 new tests covering space-separated/CamelCase headings, footer stripping (italic and bold), empty sections, key-preservation, deprecated SPECIFICATION.md skip, skeleton creation, and integration logging |
| CHANGELOG.md | CHANGELOG entry added under [Unreleased] Fixed section accurately describing the new _parse_prd_narratives function, Step 2b, and the 14 new tests |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[migrate called] --> B[Step 1: Create lifecycle folders]
B --> C[Step 2: Read existing sources]
C --> D{PRD.md exists?}
D -- Yes --> E[Read and parse PRD.md]
D -- No --> F{SPEC.md not deprecated?}
E --> F
F -- Yes --> G[Parse SPEC.md sections, override PRD overlaps]
F -- No --> H{ingested_narratives non-empty?}
G --> H
H -- No --> I[Step 3: Build PROJECT-DEFINITION]
H -- Yes --> J{spec_vbrief exists?}
J -- No --> K[Create skeleton spec_vbrief]
J -- Yes --> L[Merge into plan.narratives, no overwrite]
K --> L
L --> M[Write specification.vbrief.json, log INGEST]
M --> I
I --> N[Step 4: Convert roadmap to pending vBRIEFs]
N --> O[Step 5: Deprecation redirects]
O --> P[Return success and actions]
Prompt To Fix All With AI
This is a comment left during a code review.
Path: scripts/migrate_vbrief.py
Line: 110
Comment:
**Heading lookup silently drops sections with trailing punctuation**
`heading.strip()` removes whitespace but not punctuation. A PRD section `## Goals:` or `## Problem Statement:` lowercases to `"goals:"` / `"problem statement:"`, which has no match in `_HEADING_TO_NARRATIVE_KEY`, so the section is silently skipped with no warning. Consider stripping trailing punctuation (colons, commas, periods) before the map lookup.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: scripts/migrate_vbrief.py
Line: 543
Comment:
**`setdefault` chain raises `AttributeError` on malformed spec_vbrief**
If `specification.vbrief.json` is valid JSON but structurally abnormal — e.g. `{"plan": null}` — then `spec_vbrief.setdefault("plan", {})` returns `None` (the key exists), and `None.setdefault("narratives", {})` raises an unhandled `AttributeError` that bubbles out of `migrate()` instead of the clean `(False, [error])` tuple the caller expects. Contrast with `_build_project_definition` at line 333 which defensively uses `isinstance` guards.
How can I resolve this? If you propose a fix, please make it concise.Reviews (2): Last reviewed commit: "fix: address Greptile review findings (b..." | Re-trigger Greptile
Summary
Changes
Acceptance Criteria
Pre-existing test failure
Closes #397