added
This commit is contained in:
1 parent
ab924ce1be
commit
d54c1544f0
19 files changed
+2592
-34
No files matched your search
+30
-9
@@ -1,4 +1,4 @@
|
||||
"""Date boundaries, artifact validation and success-only local finalization."""
|
||||
"""Date boundaries, evidence validation and coverage-aware local finalization."""
|
||||
import argparse
|
||||
import datetime as dt
|
||||
import hashlib
|
||||
@@ -41,7 +41,7 @@ def validate_run(root, path, success=False):
|
||||
root = Path(root).resolve()
|
||||
e = read(path)
|
||||
require(e["window"] == window(e["run_date"]), "Window must be previous completed Denver week")
|
||||
require(e["status"] in {"complete", "incomplete"}, "Unknown run status")
|
||||
require(e["status"] in {"complete", "completed-with-gaps", "incomplete"}, "Unknown run status")
|
||||
report = inside(root, e["report_path"])
|
||||
receipt = read(inside(root, e["receipt_path"]))
|
||||
body = report.read_text(encoding="utf-8")
|
||||
@@ -117,17 +117,36 @@ def validate_run(root, path, success=False):
|
||||
require(bool(s.get("transcript_original_filename")) and re.fullmatch(r"[0-9a-fA-F]{64}", s.get("transcript_sha256", "")), "Transcript file provenance missing")
|
||||
require(s.get("transcript_completeness") in {"full", "partial"} and isinstance(s.get("transcript_limitations"), list), "Transcript completeness missing")
|
||||
require(s["transcript_completeness"] != "partial" or bool(s["transcript_limitations"]), "Partial transcript needs limitations")
|
||||
if success or e["status"] == "complete":
|
||||
require(e["status"] == "complete" and all(v == "complete" for v in e["coverage"].values()), "Incomplete research cannot finalize")
|
||||
require(receipt["validation_passed"] is True and not receipt["gaps"], "Receipt has failed validation or gaps")
|
||||
completed = e["status"] in {"complete", "completed-with-gaps"}
|
||||
if success:
|
||||
require(completed, "Incomplete research cannot finalize")
|
||||
if completed:
|
||||
require(receipt["validation_passed"] is True, "Receipt validation failed")
|
||||
partial = e["status"] == "completed-with-gaps"
|
||||
if partial:
|
||||
require(receipt["capture_completeness"] == "partial" and bool(receipt["gaps"]), "Partial completion needs explicit gaps")
|
||||
require(all(isinstance(g, str) and g.strip() and g in body for g in receipt["gaps"]), "Every gap must be disclosed in report")
|
||||
require(e.get("verified_subset_reviewed") is True, "Verified subset review missing")
|
||||
require(bool(e["sources"]), "Partial completion needs verified material")
|
||||
else:
|
||||
require(all(v == "complete" for v in e["coverage"].values()), "Incomplete coverage cannot claim complete")
|
||||
require(not receipt["gaps"], "Complete receipt has gaps")
|
||||
|
||||
config = read(root / "config/research.json")
|
||||
for method in ("standard_web", "exa"):
|
||||
if e["coverage"][method] != "complete":
|
||||
continue
|
||||
require(sum(s["method"] == method and s["status"] == "ok" for s in searches) >= config["baseline_searches_per_method"], "Independent discovery pass incomplete: " + method)
|
||||
checks = e.get("pool_checks", {})
|
||||
for pool in ("sec_edgar", "rock_fight"):
|
||||
if e["coverage"][pool] != "complete":
|
||||
continue
|
||||
require(bool(checks.get(pool)), "Missing direct pool enumeration: " + pool)
|
||||
require(all(c.get("status") == "ok" and c.get("url", "").startswith("https://") for c in checks[pool]), "Incomplete direct pool enumeration")
|
||||
pb = e["playbook"]
|
||||
if partial and pb.get("status") == "unavailable":
|
||||
require(not pb.get("sections") and bool(pb.get("limitation")) and pb["limitation"] in receipt["gaps"], "Unavailable playbook must omit mappings and disclose limitation")
|
||||
return e
|
||||
require(bool(pb["sections"]), "Playbook mapping unavailable")
|
||||
playbook = Path(pb["path"])
|
||||
require(playbook.is_file(), "Playbook unavailable")
|
||||
@@ -157,7 +176,7 @@ def validate_repo(root):
|
||||
require(inside(root, item["path"]).is_file(), "Missing indexed report")
|
||||
require(item["status"] == "draft", "Local research catalog does not authorize publication")
|
||||
matches = [e for e in evidence_runs if e["report_path"] == item["path"] and content_id(e["run_id"]) == item["content_id"]]
|
||||
require(len(matches) == 1 and matches[0]["status"] == "complete", "Catalog item lacks unique completed evidence")
|
||||
require(len(matches) == 1 and matches[0]["status"] in {"complete", "completed-with-gaps"}, "Catalog item lacks unique completed evidence")
|
||||
return {"status": "passed", "indexed_reports": len(index["items"])}
|
||||
|
||||
|
||||
@@ -183,9 +202,11 @@ def finalize(root, evidence):
|
||||
existing = next((i for i in index["items"] if i["content_id"] == catalog_id), None)
|
||||
item = {"id": e["run_id"], "report_path": e["report_path"], "evidence_path": str(evidence.relative_to(root)).replace("\\", "/"), "window": e["window"]}
|
||||
catalog = {"content_id": catalog_id, "title": "Outdoor Industry Intelligence — " + e["run_date"], "description": "Weekly strategic brief for " + e["window"]["start"] + " to " + e["window"]["end_exclusive"] + " (exclusive), America/Denver.", "content_type": "research-report", "path": e["report_path"], "status": "draft", "published_at": None, "updated_at": e["run_date"], "author": "Eddie Soehnel", "topics": ["outdoor-industry", "active-lifestyle"], "related_content_ids": []}
|
||||
require(existing is None or existing == catalog, "Existing run ID points to different catalog metadata")
|
||||
require(not any(i["path"] == e["report_path"] and i["content_id"] != catalog_id for i in index["items"]), "Report path already indexed by another ID")
|
||||
checkpoint = root / "state/last-successful-run.json"
|
||||
if e["status"] == "completed-with-gaps":
|
||||
catalog["description"] += " Completed with explicitly disclosed coverage gaps."
|
||||
require(existing is None or existing == catalog, "Existing run ID points to different catalog metadata")
|
||||
checkpoint = root / ("state/last-completed-with-gaps-run.json" if e["status"] == "completed-with-gaps" else "state/last-successful-run.json")
|
||||
if checkpoint.exists():
|
||||
previous = read(checkpoint)
|
||||
require(previous["id"] != e["run_id"] or previous == item, "Run ID conflicts with successful checkpoint")
|
||||
@@ -195,7 +216,7 @@ def finalize(root, evidence):
|
||||
atomic_json(root / "content-index.json", index)
|
||||
if not checkpoint.exists() or read(checkpoint)["window"]["end_exclusive"] <= e["window"]["end_exclusive"]:
|
||||
atomic_json(checkpoint, item)
|
||||
return {"status": "complete", "run_id": e["run_id"]}
|
||||
return {"status": e["status"], "run_id": e["run_id"]}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user