feat(521): decision-record parser (decisions_lib)
Adds scripts/decisions_lib.py, the shared parser for ErsatzTV decision records (docs/decisions.md + docs/decisions/*.md). Parses H2 sections into Record dataclasses, distinguishing migrated records (visible metadata block: key/status/since/supersedes/superseded-by + Rule/ Signals/Mechanics) from legacy-unmigrated ones with no metadata line. scripts/ is now an importable package (scripts/__init__.py, scripts/tests/__init__.py) so later tools can `import scripts.decisions_lib`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
# Decisions
|
||||
|
||||
## Index
|
||||
- [x](#y)
|
||||
|
||||
## 2026-07-17 — Migrated example (#406)
|
||||
`key: ci.runner-placement` · `status: active` · `since: 2026-07-17` · `supersedes: none` · `superseded-by: none`
|
||||
**Rule:** Every CI services container gets an explicit cap.
|
||||
**Signals:** ci, runners · paths: .gitea/workflows/docker-build.yml · issues: #390 #406
|
||||
**Mechanics:** docs/ci-cd.md → CI lanes
|
||||
|
||||
Rationale prose here.
|
||||
|
||||
## 2026-07-11 — Legacy unmigrated example (#231)
|
||||
Some prose with no metadata line at all.
|
||||
@@ -0,0 +1,31 @@
|
||||
from pathlib import Path
|
||||
import scripts.decisions_lib as dl
|
||||
|
||||
FIX = Path(__file__).parent / "fixtures" / "sample_decisions.md"
|
||||
|
||||
|
||||
def test_parses_migrated_record():
|
||||
recs = dl.parse_file(FIX)
|
||||
migrated = [r for r in recs if r.key == "ci.runner-placement"]
|
||||
assert len(migrated) == 1
|
||||
r = migrated[0]
|
||||
assert r.status == "active"
|
||||
assert r.since == "2026-07-17"
|
||||
assert r.supersedes == "none"
|
||||
assert r.superseded_by == "none"
|
||||
assert r.rule == "Every CI services container gets an explicit cap."
|
||||
assert "issues: #390 #406" in r.signals
|
||||
assert r.mechanics.startswith("docs/ci-cd.md")
|
||||
|
||||
|
||||
def test_legacy_record_is_unmigrated():
|
||||
recs = dl.parse_file(FIX)
|
||||
legacy = [r for r in recs if r.heading.endswith("(#231)")]
|
||||
assert len(legacy) == 1
|
||||
assert legacy[0].key is None
|
||||
assert legacy[0].status == "legacy-unmigrated"
|
||||
|
||||
|
||||
def test_index_section_parses_as_heading():
|
||||
recs = dl.parse_file(FIX)
|
||||
assert any(r.heading == "Index" for r in recs)
|
||||
Reference in New Issue
Block a user