Refresh WORK-RECORDS.md after every live record is archived.
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Build and Publish Multi-Context Image / build-and-push (push) Successful in 35s

C-33 returned early when the generator produced no rows, so a leftover
index kept listing archived workplans as active. Rewrite that file to an
empty table instead of leaving the stale rows in place.

Assistant: grok
Assistant-Session: 01a04d7c-846d-77e3-af8d-020019e4eb61
This commit is contained in:
tegwick 2026-08-29 14:39:42 +02:00
parent ef0b6df3b8
commit 037c8360e2
2 changed files with 55 additions and 4 deletions

View file

@ -1131,7 +1131,16 @@ def _generate_work_record_index(repo_dir: Path, repo_slug: str) -> str | None:
return None
rows.sort(key=lambda r: (_WORK_RECORD_INDEX_KIND_ORDER.get(r[0], 99), r[4], r[1]))
return _work_record_index_document(repo_slug, rows)
def _work_record_index_document(
repo_slug: str, rows: list[tuple[str, str, str, str, str]]
) -> str:
"""Render WORK-RECORDS.md. An empty row list still produces the header
and table so a leftover index can be rewritten after every live record
is archived or removed.
"""
lines = [
f"# Work Records — {repo_slug}",
"",
@ -1144,7 +1153,10 @@ def _generate_work_record_index(repo_dir: Path, repo_slug: str) -> str | None:
"| Kind | ID | Status | Lane | Source |",
"| --- | --- | --- | --- | --- |",
]
lines.extend(f"| {kind} | {rid} | {status} | {lane} | {source} |" for kind, rid, status, lane, source in rows)
lines.extend(
f"| {kind} | {rid} | {status} | {lane} | {source} |"
for kind, rid, status, lane, source in rows
)
lines.append("")
return "\n".join(lines)
@ -1155,11 +1167,16 @@ def _check_work_record_index_freshness(
"""C-33: WORK-RECORDS.md missing or stale relative to the current
file-derived work-record set."""
content = _generate_work_record_index(repo_dir, repo_slug)
if content is None:
return
index_file = repo_dir / _WORK_RECORD_INDEX_NAME
existing = index_file.read_text(encoding="utf-8") if index_file.is_file() else None
if existing == content:
if content is None:
if existing is None:
return
empty = _work_record_index_document(repo_slug, [])
if existing == empty:
return
content = empty
elif existing == content:
return
report.add(
severity="WARN", check_id="C-33",