Standard production layout: the OKR app (was nested under AINative_OKR_CASAN5/) is now
the repository root. No more wrapper directory.
- Promote AINative_OKR_CASAN5/* -> repo root (backend/ frontend/ packages/ apps/
.specify/ docs/ infra/ nginx/ scripts/ + configs). Merge tool dirs: .gitea (kept the
active deploy ci.yml, added harness-ci.yml + runbooks), .claude (agents/commands +
launch.json), .github moved up.
- Remove redundant: 00_SUBMISSION_PACKAGE, scattered root notes (FPT_CASAN_Full.md,
tu-tuong-casan.md, casan-tu-sinh..., casan_harness_assessment.md, source-review...,
README_CASAN5_REFINED.md), casan-next-plans/ and optimize-docs/ (competition/planning
artifacts — roadmap + design history preserved in git log / commit messages).
- Update all references to the old layout:
- .gitea/workflows/{ci,harness-ci}.yml, .github/workflows/{ci,deploy}.yml:
working-directory .; drop AINative_OKR_CASAN5/ prefix; .specify/{tests,scripts}
-> packages/casan-harness/... (.specify/logs state kept)
- .claude/launch.json, .gitea/*-runbook.md: path prefixes
- CLAUDE.md, README.md: docs/input -> apps/okr/domain/input
- policy-bundle.yaml: 8 policy paths -> packages/casan-harness/...; manifest re-signed
- secrets-scan.sh: fixture excludes -> new package/domain paths.
Full gate from the new root: PASS=64 FAIL=0 SKIP=3.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
74 lines
2.5 KiB
Python
Executable File
74 lines
2.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""CASAN Plan-09 — Evidence Pack verifier (MVP).
|
|
|
|
Recomputes the hash of every file in a pack and compares it to the stored
|
|
artifact-manifest.json. Any change to any packed file flips a hash and fails
|
|
verification. (The bash wrapper additionally verifies the RSA signature over
|
|
manifest-head.txt, which stops an attacker who rewrites the manifest too.)
|
|
|
|
Argv: <pack_dir>
|
|
Exit: 0 intact, 1 tamper detected / manifest missing.
|
|
"""
|
|
import hashlib
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
|
|
def main():
|
|
pack_dir = sys.argv[1]
|
|
manifest_path = os.path.join(pack_dir, "artifact-manifest.json")
|
|
if not os.path.isfile(manifest_path):
|
|
sys.stderr.write("EVIDENCE_PACK_NO_MANIFEST\n")
|
|
return 1
|
|
try:
|
|
manifest = json.load(open(manifest_path, encoding="utf-8"))
|
|
except ValueError:
|
|
sys.stderr.write("EVIDENCE_PACK_MANIFEST_CORRUPT\n")
|
|
return 1
|
|
|
|
stored = manifest.get("files", {})
|
|
mismatches = []
|
|
|
|
# Every file recorded in the manifest must still hash to the same value.
|
|
for fn, want in stored.items():
|
|
path = os.path.join(pack_dir, fn)
|
|
if not os.path.isfile(path):
|
|
mismatches.append(f"{fn}:missing")
|
|
continue
|
|
with open(path, "rb") as f:
|
|
got = hashlib.sha256(f.read()).hexdigest()
|
|
if got != want:
|
|
mismatches.append(f"{fn}:hash_changed")
|
|
|
|
# A new unmanifested file (except sig/head) is also tampering.
|
|
for fn in os.listdir(pack_dir):
|
|
if fn in ("artifact-manifest.json", "evidence-pack.sig", "manifest-head.txt"):
|
|
continue
|
|
if os.path.isfile(os.path.join(pack_dir, fn)) and fn not in stored:
|
|
mismatches.append(f"{fn}:unexpected_file")
|
|
|
|
# The stored manifest_head must match the recomputed head of `stored`.
|
|
canonical = json.dumps(stored, sort_keys=True, separators=(",", ":"))
|
|
head_now = hashlib.sha256(canonical.encode()).hexdigest()
|
|
if head_now != manifest.get("manifest_head"):
|
|
mismatches.append("manifest_head:mismatch")
|
|
|
|
if mismatches:
|
|
sys.stderr.write("EVIDENCE_PACK_TAMPERED " + " ".join(mismatches) + "\n")
|
|
return 1
|
|
|
|
cert = "unknown"
|
|
rs = os.path.join(pack_dir, "run-summary.json")
|
|
if os.path.isfile(rs):
|
|
try:
|
|
cert = str(json.load(open(rs, encoding="utf-8")).get("certified"))
|
|
except ValueError:
|
|
pass
|
|
print(f"EVIDENCE_PACK_INTACT files={len(stored)} certified={cert} head={head_now}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|