Files
Liti-agent-Development/Default_Agent_청구취지기재방법/tmp/audit_gr_med_once.py
T
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

43 lines
4.4 KiB
Python

from pathlib import Path
import re,json,hashlib,subprocess,unicodedata
ROOT=Path.cwd()
def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest()
def add(p,s):
assert not p.exists()
subprocess.run(['apply_patch','*** Begin Patch\n*** Add File: '+str(p.relative_to(ROOT))+'\n'+''.join('+'+l+'\n' for l in s.splitlines())+'*** End Patch\n'],check=True,capture_output=True)
for key in ['지료청구','진료비치료비의료비청구']:
w=ROOT/f'tmp/규칙문서재작성_{key}_20260913_batch5';snap=json.loads((w/'snapshot.json').read_text());s=Path(snap['source']).read_text();d=(w/'draft.md').read_text(); checks=[]
def ck(name,ok,detail=''):checks.append((name,bool(ok),detail))
ck('원본 해시',sha(Path(snap['source']))==snap['source_sha'])
ck('형식 해시',sha(ROOT/'1. 베타 0.5 다듬기/output_format_v1.txt')==snap['format_sha'])
ck('registry 해시',sha(ROOT/'case_kind_registry.json')==snap['registry_sha'])
ck('UTF8 재읽기',d.encode().decode('utf8')==d)
ck('정확한 표시명 제목',d.splitlines()[0]==snap['title'])
calc=''.join(c for c in unicodedata.normalize('NFC',snap['display']) if unicodedata.category(c)[0] in 'LN');ck('표시명에서 산출한 키',calc==key)
ck('메타데이터 4개',len([l for l in d.split('### 사용 순서')[0].splitlines() if l.startswith('| ')])-1==4)
ck('최상위 0~7 A B',re.findall(r'^## (.*)',d,re.M)==['0. 메타데이터와 사용법','1. 청구권·사실정보 연결과 보완','2. 유형 선택과 작성 경로','3. 당사자·대상·범위의 작성 규칙','4. 금액·기간·조건·부수청구','5. 표준 문형과 조립','6. 청구원인 작성 단계에 전달할 사항','7. 진행·보완·전환·중단 기준','부록 A. 근거와 적용 제한','부록 B. 문서 관리·제작 검증'])
ck('코드펜스 짝',len(re.findall(r'^```',d,re.M))%2==0)
ck('치환 잔재 없음',not re.search(r'CASE_KEY|CASE_DISPLAY_NAME|RUN_ID|\$\{',d))
for name,rx in [('Q',r'Q-[A-Z0-9]+(?:-[A-Z0-9]+)*'),('RULE',r'RULE-[A-Z0-9]+(?:-[A-Z0-9]+)*'),('FORM',r'FORM-[A-Z0-9]+(?:-[A-Z0-9]+)*'),('LEAF',r'LEAF-[A-Z0-9]+(?:-[A-Z0-9]+)*'),('STOP',r'STOP-[A-Z0-9]+(?:-[A-Z0-9]+)*'),('CHECK',r'CHECK-[A-Z0-9]+(?:-[A-Z0-9]+)*'),('사건번호',r'\d{2,4}(?:다|두)\d+'),('URL',r'https?://[^\s)<>|]+')]:
a=set(re.findall(rx,s));b=set(re.findall(rx,d));ck(name+' 원문 집합 보존',a<=b,str(sorted(a-b)))
sourceforms=re.findall(r'^### (FORM-\S+) —',s,re.M);df=re.findall(r'^### (FORM-\S+) —',d,re.M);ck('전체 문형 개수·이름',sourceforms==df,str(len(df)))
for field in ['선택 기준','작성 전에 연결할 정보','법적 전제','미확인 처리','주문 문장','조립','사용 금지 조건','근거','검토']:
ck('문형별 '+field,len(re.findall(r'^- '+field+':',d,re.M))==len(df))
ck('처리상태5',all(x in d for x in ['작성 진행','재검토를 붙여 진행','해당 부분 보완 대기','다른 구성·절차로 전환','해당 구성 중단']))
ck('작성·검토 별개',all(x in d for x in ['문구 검사 미완료','변호사 제출 전 검토 완료','작성 상태는']))
ck('URL직접·우회금지',all(x in d for x in ['HTTP 요청','우회 원문 수집도 금지','필요한 원문·검토 결과의 제공']))
# Deterministic source-unit correspondence; nonliteral candidates require human semantic decision.
lines=(w/'source_ledger.md').read_text().splitlines(); misses=[]; matches=[]
norm=lambda x:re.sub(r'[`*#]','',x).strip().rstrip('.')
dn=norm(d)
for l in lines:
if not l.startswith('| U'):continue
c=re.split(r'(?<!\\)\|',l)[1:-1];uid=c[0].strip();unit=c[2].strip().replace('\\|','|');u=norm(unit)
if u and u in dn:matches.append(uid)
else:misses.append((uid,c[1].strip(),unit))
report='# 단일 검증 회차 — 기계 검사\n\n'+ '\n'.join(f'- {"PASS" if ok else "FAIL"}: {name} {detail}' for name,ok,detail in checks)+f'\n\n총 {len(checks)}개, PASS {sum(ok for _,ok,_ in checks)}개. 문자열 보조 매칭 {len(matches)}개 / 비동일 수동 대조 {len(misses)}개. 이는 의미 판정을 대신하지 않는다.\n'
report+='\n## 비동일 단위 직접 대조 대상\n\n'+'\n'.join(f'- {uid} {loc}: {unit}' for uid,loc,unit in misses)
add(w/'mechanical_once.md',report)
print(key,len(checks),sum(ok for _,ok,_ in checks),len(matches),len(misses))
print('\n'.join(f'{uid} {loc}: {unit}' for uid,loc,unit in misses))