Skip to content

Commit b6a43fe

Browse files
tbitcsoz-agent
andcommitted
fix: check alternate paths before creating LEDGER.md/ARCHITECTURE.md stubs
Auditor and upgrader now check docs/LEDGER.md and docs/architecture/** before reporting missing or creating stubs. Prevents duplicate files when projects store these at non-standard paths. Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent ef76880 commit b6a43fe

2 files changed

Lines changed: 29 additions & 15 deletions

File tree

src/specsmith/auditor.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,15 @@ def check_governance_files(root: Path) -> list[AuditResult]:
7979

8080
for f in REQUIRED_FILES:
8181
path = root / f
82+
found = path.exists()
83+
# LEDGER.md: also check docs/LEDGER.md (some imported projects place it there)
84+
if not found and f == "LEDGER.md":
85+
found = (root / "docs" / "LEDGER.md").exists()
8286
results.append(
8387
AuditResult(
8488
name=f"file-exists:{f}",
85-
passed=path.exists(),
86-
message=f"Required file {f} {'exists' if path.exists() else 'MISSING'}",
89+
passed=found,
90+
message=f"Required file {f} {'exists' if found else 'MISSING'}",
8791
)
8892
)
8993

@@ -232,16 +236,20 @@ def check_ledger_health(root: Path) -> list[AuditResult]:
232236
"""Check ledger quality and staleness."""
233237
results: list[AuditResult] = []
234238
ledger_path = root / "LEDGER.md"
235-
236239
if not ledger_path.exists():
237-
results.append(
238-
AuditResult(
239-
name="ledger-exists",
240-
passed=False,
241-
message="LEDGER.md not found",
240+
# Also check docs/LEDGER.md (some imported projects place it there)
241+
alt = root / "docs" / "LEDGER.md"
242+
if alt.exists():
243+
ledger_path = alt
244+
else:
245+
results.append(
246+
AuditResult(
247+
name="ledger-exists",
248+
passed=False,
249+
message="LEDGER.md not found",
250+
)
242251
)
243-
)
244-
return results
252+
return results
245253

246254
text = ledger_path.read_text(encoding="utf-8")
247255
lines = text.splitlines()

src/specsmith/upgrader.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,20 @@ def _sync_full(
246246
out.write_text(tmpl.render(**ctx), encoding="utf-8")
247247
synced.append(f"{output_rel} (created)")
248248

249-
# 6. Essential docs — create stubs if missing (these are needed for audit to pass)
250-
if not (root / "LEDGER.md").exists():
249+
# 6. Essential docs — create stubs only if truly missing (check alternate paths)
250+
has_ledger = (root / "LEDGER.md").exists() or (root / "docs" / "LEDGER.md").exists()
251+
if not has_ledger:
251252
(root / "LEDGER.md").write_text("# Ledger\n\nNo entries yet.\n", encoding="utf-8")
252253
synced.append("LEDGER.md (created)")
253254

254-
if not (root / "docs" / "ARCHITECTURE.md").exists():
255+
has_arch = (root / "docs" / "ARCHITECTURE.md").exists()
256+
if not has_arch and (root / "docs").is_dir():
257+
# Check subdirectories (e.g. docs/architecture/CPSC-RE-ARCHITECTURE.md)
258+
has_arch = bool(
259+
list((root / "docs").glob("**/architecture*"))
260+
+ list((root / "docs").glob("**/ARCHITECTURE*"))
261+
)
262+
if not has_arch:
255263
try:
256264
from specsmith.architect import generate_architecture
257265

@@ -265,8 +273,6 @@ def _sync_full(
265273
encoding="utf-8",
266274
)
267275
synced.append("docs/ARCHITECTURE.md (stub created)")
268-
269-
# Initialize credit tracking if not present
270276
specsmith_dir = root / ".specsmith"
271277
credit_budget = specsmith_dir / "credit-budget.json"
272278
if not credit_budget.exists():

0 commit comments

Comments
 (0)