Files
jhogyuandClaude Fable 5.1 5f9853e44b chore: snapshot of work since 2026-10-05 (Stage 1 v.8, S2_00 v7.4/v7.5 handoff, S2_10 rewrite research v.2, 청구취지·요건사실 corpora)
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>
2026-10-12 13:02:13 +09:00

46 lines
3.5 KiB
Python

from pathlib import Path
import json,re,hashlib,runpy
m=runpy.run_path(str(Path(__file__).with_name('agent3_extract.py')))
results=[]
def keyblocks(t):
return {h: b for h,b in m['pieces'](t) if re.match(r'#### (R-|6\.\d+\.\d+)',h)}
for x in m['batch']:
src=m['ROOT']/x['source'];dst=m['ROOT']/x['output']
s=src.read_text();d=dst.read_text();sb=keyblocks(s);db=keyblocks(d)
checks={
'source_hash_unchanged':hashlib.sha256(src.read_bytes()).hexdigest()==x['sha256'],
'case_in_h1':re.search(r'^# 요건사실 항목: '+re.escape(x['case'])+r'$',d,re.M) is not None,
'element_definitions':set(h for h in sb if h.startswith('#### R-'))==set(h for h in db if h.startswith('#### R-')),
'defense_definitions':set(h for h in sb if h.startswith('#### 6.'))==set(h for h in db if h.startswith('#### 6.')),
'path_headings':re.findall(r'^### 5\.P\d+ [^\n]+',s,re.M)==re.findall(r'^### 5\.P\d+ [^\n]+',d,re.M),
'no_external_urls':not re.search(r'https?://',d),
'even_code_fences':len(re.findall(r'^```',d,re.M))%2==0,
'element_authority_connections':True,
'element_burden_and_conditions':True,
'source_link_resolves':(dst.parent/'../raw'/src.name).resolve()==src.resolve(),
'source_status_preserved':re.search(r'^verification_status:.+$',s,re.M).group()==re.search(r'^verification_status:.+$',d,re.M).group(),
'all_core_ids_present':set(re.findall(r'R-PROV\d+-[45]-\d+',s[s.index('## §4.'):s.index('## §8.')])).issubset(set(re.findall(r'R-PROV\d+-[45]-\d+',d))),
}
for h,b in sb.items():
ob=db.get(h,'')
am=re.search(r'^- \*\*권위 ID\*\*:(.+)$',b,re.M)
if am and am.group(1).strip() not in ob:checks['element_authority_connections']=False
if h.startswith('#### R-'):
for field in ['적용 경로','요건분류','주장의 정도','주장책임 / 증명책임','추정·전환','다중 대응','흠결 빈발점']:
match=re.search(r'^- \*\*'+re.escape(field)+r'\*\*:(.*?)(?=\n- \*\*|\Z)',b,re.M|re.S)
if match and m['clean'](match.group()) not in ob:checks['element_burden_and_conditions']=False
table_issues=[];lines=d.splitlines();i=0
while i<len(lines):
if lines[i].startswith('|'):
start=i;group=[]
while i<len(lines) and lines[i].startswith('|'):group.append(lines[i]);i+=1
if len(group)>1:
counts=[len(re.split(r'(?<!\\)\|',l))-2 for l in group]
if len(set(counts))>1:table_issues.append({'line':start+1,'columns':list(set(counts))})
else:i+=1
checks['table_columns_consistent']=not table_issues
results.append({'case':x['case'],'source':x['source'],'output':x['output'],'checks':checks,'element_count':sum(h.startswith('#### R-') for h in db),'defense_count':sum(h.startswith('#### 6.') for h in db),'source_bytes':x['bytes'],'output_bytes':dst.stat().st_size,'table_issues':table_issues,'reviewed_scope':m['case_notes'][x['case']]['scope'],'reviewed_limitations':m['case_notes'][x['case']]['limits']})
p=m['BASE']/'agent3_validation.json';p.write_text(json.dumps(results,ensure_ascii=False,indent=2))
print(json.dumps({'documents':len(results),'failures':[{r['case']:[k for k,v in r['checks'].items() if not v]} for r in results if not all(r['checks'].values())],'elements':sum(r['element_count'] for r in results),'defenses':sum(r['defense_count'] for r in results),'source_bytes':sum(r['source_bytes'] for r in results),'output_bytes':sum(r['output_bytes'] for r in results)},ensure_ascii=False,indent=2))