fix(registrar): register newly closed workplans
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a023c0-a0a3-7c03-b395-5a0d2757214d
This commit is contained in:
parent
833fa6e746
commit
69adfff48d
2 changed files with 31 additions and 5 deletions
|
|
@ -67,12 +67,21 @@ def _missing_identifiers(repo: Path) -> dict[str, list[str]]:
|
||||||
parsed = parse_workplan_file(path, repo_root=repo)
|
parsed = parse_workplan_file(path, repo_root=repo)
|
||||||
if parsed.frontmatter.get("type") != "workplan" or not parsed.id:
|
if parsed.frontmatter.get("type") != "workplan" or not parsed.id:
|
||||||
continue
|
continue
|
||||||
# Closed records are frozen provenance under ADR-007. State Hub also
|
|
||||||
# deliberately refuses to create missing task rows for them.
|
|
||||||
if (parsed.status or "").strip().lower() in {"finished", "archived"}:
|
|
||||||
continue
|
|
||||||
if not parsed.state_hub_workstream_id:
|
if not parsed.state_hub_workstream_id:
|
||||||
workplans.append(parsed.id)
|
workplans.append(parsed.id)
|
||||||
|
# C-06 creates a newly discovered workplan and its tasks as one
|
||||||
|
# registration unit, including closed file-backed provenance.
|
||||||
|
# Include those task gaps so post-verification cannot report a
|
||||||
|
# false success after creating only the parent.
|
||||||
|
for task in parsed.tasks:
|
||||||
|
if task.id and not task.state_hub_task_id:
|
||||||
|
tasks.append(task.id)
|
||||||
|
continue
|
||||||
|
# Once a closed workplan is linked, missing task identifiers are
|
||||||
|
# frozen historical artefacts. State Hub's C-11 fixer deliberately
|
||||||
|
# refuses to create them.
|
||||||
|
if (parsed.status or "").strip().lower() in {"finished", "archived"}:
|
||||||
|
continue
|
||||||
for task in parsed.tasks:
|
for task in parsed.tasks:
|
||||||
if task.id and not task.state_hub_task_id:
|
if task.id and not task.state_hub_task_id:
|
||||||
tasks.append(task.id)
|
tasks.append(task.id)
|
||||||
|
|
|
||||||
|
|
@ -51,13 +51,30 @@ def test_requires_explicit_primary_confirmation(tmp_path: Path) -> None:
|
||||||
assert result.error and result.error["code"] == "confirmation_required"
|
assert result.error and result.error["code"] == "confirmation_required"
|
||||||
|
|
||||||
|
|
||||||
def test_closed_records_are_not_registrar_work(tmp_path: Path) -> None:
|
def test_unlinked_closed_workplan_is_registrar_work(tmp_path: Path) -> None:
|
||||||
repo = _fixture(tmp_path)
|
repo = _fixture(tmp_path)
|
||||||
workplan = repo / "workplans" / "DEMO-WP-0001.md"
|
workplan = repo / "workplans" / "DEMO-WP-0001.md"
|
||||||
workplan.write_text(
|
workplan.write_text(
|
||||||
workplan.read_text(encoding="utf-8").replace("status: active", "status: finished"),
|
workplan.read_text(encoding="utf-8").replace("status: active", "status: finished"),
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
)
|
)
|
||||||
|
assert rr._missing_identifiers(repo) == {
|
||||||
|
"workplans": ["DEMO-WP-0001"],
|
||||||
|
"tasks": ["DEMO-WP-0001-T01"],
|
||||||
|
"intakes": [],
|
||||||
|
"decisions": [],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_linked_closed_workplan_does_not_reopen_historical_task_gaps(tmp_path: Path) -> None:
|
||||||
|
repo = _fixture(tmp_path)
|
||||||
|
workplan = repo / "workplans" / "DEMO-WP-0001.md"
|
||||||
|
text = workplan.read_text(encoding="utf-8")
|
||||||
|
text = text.replace(
|
||||||
|
"status: active\n---",
|
||||||
|
'status: finished\nstate_hub_workstream_id: "11111111-1111-4111-8111-111111111111"\n---',
|
||||||
|
)
|
||||||
|
workplan.write_text(text, encoding="utf-8")
|
||||||
assert rr._missing_identifiers(repo) == {
|
assert rr._missing_identifiers(repo) == {
|
||||||
"workplans": [],
|
"workplans": [],
|
||||||
"tasks": [],
|
"tasks": [],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue