feat: advance repository records and provenance

Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a023c0-a0a3-7c03-b395-5a0d2757214d
This commit is contained in:
tegwick 2026-08-21 22:07:48 +02:00
parent 329af60753
commit 35e86d7b85
24 changed files with 1618 additions and 51 deletions

View file

@ -7,8 +7,10 @@ from pathlib import Path
import yaml
from repo_manager.classification import require_valid_classification
from repo_manager.gitops import head_sha, is_git_repo
from repo_manager.index_store import RepoIndex, WorkRecordEntry, _now
from repo_manager.parse.record import iter_record_files, parse_record_file
from repo_manager.parse.register import iter_register_files, parse_register_file
from repo_manager.parse.workplan import iter_workplan_files, parse_workplan_file
@ -23,8 +25,12 @@ def load_classification(repo_root: Path) -> dict | None:
return None
data = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
if isinstance(data, dict) and "repo_classification" in data:
return data["repo_classification"]
return data if isinstance(data, dict) else None
classification = data["repo_classification"]
else:
classification = data if isinstance(data, dict) else None
if not isinstance(classification, dict):
return None
return require_valid_classification(classification)
def observe_repository(repo_root: Path, *, slug: str | None = None) -> tuple[dict, RepoIndex]:
@ -58,6 +64,11 @@ def observe_repository(repo_root: Path, *, slug: str | None = None) -> tuple[dic
title=wp.title,
source_path=wp.path,
uuid=wp.state_hub_workstream_id,
extra={
key: wp.frontmatter[key]
for key in ("depends_on", "related", "needs_human", "intervention_note")
if key in wp.frontmatter
},
)
)
for task in wp.tasks:
@ -70,6 +81,25 @@ def observe_repository(repo_root: Path, *, slug: str | None = None) -> tuple[dic
source_path=wp.path,
uuid=task.state_hub_task_id,
parent_id=wp.id,
extra={
key: task.raw[key]
for key in ("depends_on", "needs_human", "intervention_note", "blocking_reason")
if key in task.raw
},
)
)
for path in iter_record_files(repo_root):
for record in parse_record_file(path, repo_root=repo_root):
records.append(
WorkRecordEntry(
kind=record.kind,
id=record.id,
status=record.status,
title=record.title,
source_path=record.source_path,
uuid=record.uuid,
extra={"record": record.raw},
)
)
@ -116,6 +146,8 @@ def observe_repository(repo_root: Path, *, slug: str | None = None) -> tuple[dic
"workplan_count": sum(1 for r in records if r.kind == "workplan"),
"task_count": sum(1 for r in records if r.kind == "task"),
"register_entry_count": sum(1 for r in records if r.kind.startswith("register:")),
"intake_count": sum(1 for r in records if r.kind == "intake"),
"decision_count": sum(1 for r in records if r.kind == "decision"),
"record_count": len(records),
},
}