File size: 2,217 Bytes
b67a1e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
import json
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
OUT=ROOT/'doc_reality_sync'
errors=[]
required=[OUT/'DOC_REALITY_SYNC.md',OUT/'result.json',OUT/'plans',OUT/'reports',OUT/'patches']
for p in required:
    if not p.exists(): errors.append(f'missing: {p.relative_to(ROOT)}')
res={}
if (OUT/'result.json').exists():
    try: res=json.loads((OUT/'result.json').read_text(encoding='utf-8'))
    except Exception as e: errors.append(f'invalid result.json: {e}')
plans=list((OUT/'plans').glob('*.md')) if (OUT/'plans').exists() else []
reports=list((OUT/'reports').glob('*_doc_reality_report.md')) if (OUT/'reports').exists() else []
patches=list((OUT/'patches').glob('*_README.patch.md')) if (OUT/'patches').exists() else []
if res:
    if res.get('mode')!='READ_ONLY_DOC_REALITY_SYNC': errors.append('wrong mode')
    if res.get('plans')!=len(plans): errors.append('plan count mismatch')
    if res.get('reports')!=len(reports): errors.append('report count mismatch')
    if res.get('patch_artifacts')!=len(patches): errors.append('patch count mismatch')
for r in reports[:200]:
    txt=r.read_text(encoding='utf-8',errors='ignore').lower()
    for must in ['docs claim','repo reality','mismatches','minimal patch proposal','no source docs were edited']:
        if must not in txt: errors.append(f'{r.relative_to(ROOT)} missing {must}')
for jp in res.get('jobs',[]):
    p=Path(jp)
    if not p.exists(): errors.append(f'missing job {jp}'); continue
    data=json.loads(p.read_text(encoding='utf-8'))
    if data.get('mode')!='review_only': errors.append(f'{p.name} not review_only')
    f=' '.join(data.get('forbidden_actions',[])).lower()
    a=' '.join(data.get('allowed_actions',[])).lower()
    if 'modify source project files' not in f or 'commit' not in f or 'push' not in f: errors.append(f'{p.name} missing forbids')
    if 'projectintaketower' not in a: errors.append(f'{p.name} missing ProjectIntakeTower-only write action')
if errors:
    print('verify_doc_reality_sync: failed')
    for e in errors: print('-',e)
    raise SystemExit(1)
print(f'verify_doc_reality_sync: passed ({len(plans)} plans, {len(reports)} reports, {len(patches)} patch artifacts)')