prj-canon-federation/docs/evidence/2026-09-05-commerce-layout-validate.py
tegwick e83346e6a6 Record CommerceCanon foundation completion and validation
Assistant: codex
Assistant-Model: gpt-6-astra
Assistant-Session: 01a070b5-4994-7271-bd8b-7c3dbcedec4b
2026-09-05 20:42:38 +02:00

28 lines
2.3 KiB
Python

from pathlib import Path
import argparse,hashlib,json,re,yaml
parser=argparse.ArgumentParser()
parser.add_argument('--source-repo',type=Path,required=True)
repo=parser.parse_args().source_repo.resolve()
evidence=Path(__file__).resolve().parent
registry=yaml.safe_load((repo/'canon.yaml').read_text())
for key in ['repository','title','status','version','classification','kernel','models','standards']: assert key in registry,key
assert registry['models']==[] and registry['standards']==[]
for category in ['kernel','models','standards']:
for entry in registry[category]:
p=repo/entry['path']; assert p.is_file(),p
fm=yaml.safe_load(p.read_text().split('---')[1]); assert all(fm[k]==entry[k] for k in ['id','status'])
for name in ['INTENT.md','SCOPE.md','demand/README.md','docs/README.md','docs/RepositoryLayout.md']: assert (repo/name).is_file(),name
for name in ['kernel','models','standards','assimilation','mappings','concepts','profiles','patterns','validation']: assert (repo/'infospace'/name/'README.md').is_file(),name
checked=0
for name in ['SCOPE.md', 'README.md', 'AGENTS.md', 'mappings/README.md', 'profiles/README.md', 'docs/RepositoryLayout.md', 'docs/README.md', 'demand/README.md', 'assimilation/README.md', 'workplans/COMMERCE-WP-0001-foundation-layout.md', 'infospace/mappings/README.md', 'infospace/profiles/README.md', 'infospace/kernel/README.md', 'infospace/kernel/CommerceCanonCore.md', 'infospace/standards/README.md', 'infospace/validation/README.md', 'infospace/models/README.md', 'infospace/patterns/README.md', 'infospace/concepts/README.md', 'infospace/assimilation/README.md']:
p=repo/name
if p.name=='AGENTS.md':continue
for link in re.findall(r'\]\(([^)]+)\)',p.read_text()):
if '://' in link or link.startswith('#'):continue
assert (p.parent/link.split('#')[0]).exists(),(str(p),link)
checked+=1
hashes=json.load((evidence/'2026-09-05-commerce-layout-legacy-hashes.json').open())
for name,digest in hashes.items(): assert hashlib.sha256((repo/name).read_bytes()).hexdigest()==digest,name
result={'registry':'pass','documentation_conformance':'core','infospace_categories':9,'relative_links_checked':checked,'preserved_legacy_files':len(hashes),'legacy_sha256':'all unchanged','models_registered':0,'standards_registered':0}
print(json.dumps(result,indent=2))