fix: reconcile intake and decision identifiers
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a023c0-a0a3-7c03-b395-5a0d2757214d
This commit is contained in:
parent
60f4a5ca93
commit
165fc3d50f
2 changed files with 72 additions and 21 deletions
|
|
@ -20,6 +20,7 @@ from typing import Any
|
|||
import httpx
|
||||
|
||||
from repo_manager.gitops import GitError, commit_paths, push_ff
|
||||
from repo_manager.parse.record import iter_record_files, parse_record_file
|
||||
from repo_manager.parse.workplan import parse_workplan_file
|
||||
|
||||
LOCK_PATH = Path("/tmp/repo-manager-identifier-registrar.lock")
|
||||
|
|
@ -57,25 +58,37 @@ def _git(repo: Path, *args: str) -> subprocess.CompletedProcess[str]:
|
|||
def _missing_identifiers(repo: Path) -> dict[str, list[str]]:
|
||||
workplans: list[str] = []
|
||||
tasks: list[str] = []
|
||||
intakes: list[str] = []
|
||||
decisions: list[str] = []
|
||||
workplans_dir = repo / "workplans"
|
||||
if not workplans_dir.is_dir():
|
||||
return {"workplans": workplans, "tasks": tasks}
|
||||
if workplans_dir.is_dir():
|
||||
# Closed archives are frozen under ADR-007 and are not registration work.
|
||||
for path in sorted(workplans_dir.glob("*.md")):
|
||||
parsed = parse_workplan_file(path, repo_root=repo)
|
||||
if parsed.frontmatter.get("type") != "workplan" or not parsed.id:
|
||||
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:
|
||||
workplans.append(parsed.id)
|
||||
for task in parsed.tasks:
|
||||
if task.id and not task.state_hub_task_id:
|
||||
tasks.append(task.id)
|
||||
|
||||
# Closed archives are frozen under ADR-007 and are not registration work.
|
||||
for path in sorted(workplans_dir.glob("*.md")):
|
||||
parsed = parse_workplan_file(path, repo_root=repo)
|
||||
if parsed.frontmatter.get("type") != "workplan" or not parsed.id:
|
||||
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:
|
||||
workplans.append(parsed.id)
|
||||
for task in parsed.tasks:
|
||||
if task.id and not task.state_hub_task_id:
|
||||
tasks.append(task.id)
|
||||
return {"workplans": workplans, "tasks": tasks}
|
||||
for path in iter_record_files(repo):
|
||||
for record in parse_record_file(path, repo_root=repo):
|
||||
if record.uuid:
|
||||
continue
|
||||
target = intakes if record.kind == "intake" else decisions
|
||||
target.append(record.id)
|
||||
return {
|
||||
"workplans": workplans,
|
||||
"tasks": tasks,
|
||||
"intakes": intakes,
|
||||
"decisions": decisions,
|
||||
}
|
||||
|
||||
|
||||
def _check_git(repo: Path) -> tuple[dict[str, Any], str | None]:
|
||||
|
|
@ -168,7 +181,7 @@ def registrar_reconcile(
|
|||
},
|
||||
cid,
|
||||
)
|
||||
if not before["workplans"] and not before["tasks"]:
|
||||
if not any(before.values()):
|
||||
evidence["missing_after"] = before
|
||||
return RegistrarResult("noop", evidence, None, cid)
|
||||
|
||||
|
|
@ -223,7 +236,7 @@ def registrar_reconcile(
|
|||
evidence["statehub_stderr_tail"] = completed.stderr[-2000:]
|
||||
after = _missing_identifiers(repo)
|
||||
evidence["missing_after"] = after
|
||||
if completed.returncode not in {0, 2} or after["workplans"] or after["tasks"]:
|
||||
if completed.returncode not in {0, 2} or any(after.values()):
|
||||
return RegistrarResult(
|
||||
"failed",
|
||||
evidence,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue