Case_02_Comparison_Research - Stage 1 v.8: Part 1~4 YAMLs with R1~R3 patches, F-1/F-2 fixes, 피고과식별방지 prompt (defendant_qualification), dated backups, 실행검사/실패분석 reports - Stage 2 S2_00: v7.4 handoff (Task_S2_00_handoff, 경량화 전략서 + §2 개정) and v7.5 defendant qualification gate (피고관련작업_개정_S2_00.md), copies v.7/v.10/v.11, dated backups, 실행보고서/실패분석/결과물 리스트 - Stage 2 S2_10: v6/v7/v8 failure analyses, 재작성전략 10_06/10_08, case_kind_registry.json, 연구조사보고서_S2_10_재작성용.md (v.1), _추가.md (multi-claim methodology) and merged _v.2.md (claims[] 1~4, join PRELIMINARY/SELECTIVE/INDEPENDENT, V1~V6), S2_10_Test run outputs, 실행검사 v.10/v.11 - Stage_2 MEMORY.md / CLAUDE.md / work-history notes, AGENTS.md and README_KO.md updates Other corpora and tooling - Default_Agent_청구취지기재방법: 청구취지 규칙문서 전체 모음(원문·사건종류별·raw) and tmp drafts - 요건사실론: 사건종류별 문서(raw·filtered), plans, rf_draft - 판례모음, STT_앱구성_연구, API Crowdness 조사, update_numbers.py Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
37 lines
2.9 KiB
Python
37 lines
2.9 KiB
Python
"""Final read-only manifest and changed-Markdown validation."""
|
|
import json,re,hashlib,unicodedata,difflib
|
|
from pathlib import Path
|
|
m=json.loads(Path('plans/section4_edit_137_manifest.json').read_text())
|
|
result={'manifest_count':len(m),'batch_sizes':[sum(x['batch']==b for x in m) for b in range(1,8)],'source_preserved':0,'review_preserved':0,'outputs':0,'issues':[],'per_document':[]}
|
|
for r in m:
|
|
i=r['index'];src=Path(r['source']);v=Path(r['review']);out=Path(r['output']);issues=[]
|
|
if hashlib.sha256(src.read_bytes()).hexdigest()==r['source_sha256']:result['source_preserved']+=1
|
|
else:issues.append('source_changed')
|
|
if hashlib.sha256(v.read_bytes()).hexdigest()==r['review_sha256']:result['review_preserved']+=1
|
|
else:issues.append('review_changed')
|
|
if not out.exists():result['issues'].append({'index':i,'issues':['output_missing']});continue
|
|
result['outputs']+=1;s=src.read_text(encoding='utf-8');t=out.read_text(encoding='utf-8')
|
|
if not re.search(r'^content_hash:\s*"(?:sha256:)?[a-f0-9]{64}"',t,re.M):issues.append('body_hash_missing_or_malformed')
|
|
if not re.search(r'^doc_version:\s*"v1_edit"',t,re.M):issues.append('doc_version_not_v1_edit')
|
|
expected='요건사실론_'+r['case']+'_v1_edit.md'
|
|
if unicodedata.normalize('NFC',out.name)!=expected:issues.append('name_mismatch')
|
|
src_lines=set(s.splitlines());columns=None;fenced=False;table_errors=[]
|
|
for n,l in enumerate(t.splitlines(),1):
|
|
if l.startswith('```'):fenced=not fenced;continue
|
|
if fenced:continue
|
|
if re.match(r'^\|[\s:|-]+\|$',l):columns=len(re.split(r'(?<!\\)\|',l))-2;continue
|
|
if not l.startswith('|'):columns=None;continue
|
|
if l.startswith('|') and l.endswith('|') and columns and l not in src_lines:
|
|
count=len(re.split(r'(?<!\\)\|',l))-2
|
|
if count!=columns:table_errors.append({'line':n,'expected':columns,'actual':count})
|
|
if table_errors:issues.append({'changed_table_column_mismatch':table_errors})
|
|
audit=json.loads(Path(f'plans/section4_edit_audit/{i:03d}.json').read_text())
|
|
if audit.get('output_sha256') and audit['output_sha256']!=hashlib.sha256(out.read_bytes()).hexdigest():issues.append('audit_output_hash_stale')
|
|
if isinstance(audit.get('validation'),dict) and audit['validation'].get('output_sha256') and audit['validation']['output_sha256']!=hashlib.sha256(out.read_bytes()).hexdigest():issues.append('nested_audit_output_hash_stale')
|
|
if audit.get('comprehensive_diff_review')=='pending':issues.append('diff_review_pending')
|
|
result['per_document'].append({'index':i,'case':r['case'],'output_sha256':hashlib.sha256(out.read_bytes()).hexdigest(),'issues':issues})
|
|
if issues:result['issues'].append({'index':i,'issues':issues})
|
|
p=Path(m[0]['output']).parent;actual={unicodedata.normalize('NFC',x.name) for x in p.glob('*.md')};expected={unicodedata.normalize('NFC',Path(r['output']).name) for r in m}
|
|
result['unexpected_output_filenames']=sorted(actual-expected);result['missing_output_filenames']=sorted(expected-actual)
|
|
print(json.dumps(result,ensure_ascii=False,indent=2))
|