feat(evidence): structure v3 domain rules for review

This commit is contained in:
Codex
2026-08-26 12:38:30 +02:00
parent 9d4f994d3e
commit 9898726069
9 changed files with 254 additions and 24 deletions
+19 -10
View File
@@ -707,22 +707,31 @@ def migrate_workspace_evidence(
documents_by_id = {document.id: document for document in documents}
if len(documents_by_id) != len(documents):
raise EvidencePreparationError("duplicate_evidence_id")
migrated = tuple(sorted(
document.id for document in documents if document.schema_version in {1, 2}
))
unchanged = tuple(sorted(
document.id for document in documents if document.schema_version == 3
))
upgraded = {
evidence_id: document.model_copy(update={"schema_version": 3})
for evidence_id, document in documents_by_id.items()
}
migrated_ids: list[str] = []
unchanged_ids: list[str] = []
curated_root = evidence_root / "curated"
for evidence_id, document in upgraded.items():
path = curated_root / document.kind / f"{evidence_id.removeprefix('evidence:')}.md"
try:
presentation_is_current = path.read_text(encoding="utf-8") == dump_curated_markdown(
document,
)
except (OSError, UnicodeDecodeError):
presentation_is_current = False
target = unchanged_ids if presentation_is_current else migrated_ids
target.append(evidence_id)
migrated = tuple(sorted(migrated_ids))
unchanged = tuple(sorted(unchanged_ids))
if not migrated:
return EvidenceMigrationReport(
migrated=(),
unchanged=unchanged,
findings=validate_workspace_evidence(workspace_root).findings,
)
upgraded = {
evidence_id: document.model_copy(update={"schema_version": 3})
for evidence_id, document in documents_by_id.items()
}
findings = _stage_and_apply_authoring_tree(workspace_root, upgraded, manifest)
return EvidenceMigrationReport(
migrated=migrated,