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

91 lines
5.5 KiB
Python

#!/usr/bin/env python3
import os, re, json, hashlib, sys
WORK=os.path.dirname(os.path.abspath(__file__)); ROOT=os.path.dirname(os.path.dirname(WORK))
DRAFT=os.path.join(WORK,'청구취지작성규칙_공유물분할청구_beta_0.8.draft.md')
SRC=os.path.join(ROOT,'사건종류_공유물분할청구','청구취지작성규칙_공유물분할청구_v2.md')
doc=open(DRAFT,encoding='utf-8').read(); src=open(SRC,encoding='utf-8').read()
fails=[]
def chk(cond,msg):
print(('PASS ' if cond else 'FAIL ')+msg)
if not cond: fails.append(msg)
# 0. input hashes unchanged
snap=json.load(open(os.path.join(WORK,'identity_ledger.json'),encoding='utf-8'))['snapshot']
for k,v in snap.items():
h=hashlib.sha256(open(v['path'],'rb').read()).hexdigest()
chk(h==v['sha256'], f'input unchanged: {k}')
# 1. title & identity
chk(doc.split('\n')[0]=='# 공유물분할 청구 — 청구취지 작성 규칙','title exact')
chk('| 사건종류 | 공유물분할 청구 |' in doc and '| 사건키 | 공유물분할청구 |' in doc,'metadata identity')
meta=re.search(r'### 0\.1 메타데이터\n\n((?:\|.*\n)+)',doc).group(1).strip().split('\n')
fields=[r.split('|')[1].strip() for r in meta[2:]]
chk(fields==['사건종류','사건키','적용범위','적용제외'], f'metadata fields exactly four: {fields}')
# 2. template residue
chk(not re.search(r'(?<!#)###(?![# ])',doc),'no ### residue')
for tok in ['CASE_KEY','CASE_DISPLAY_NAME','RUN_ID','${']:
chk(tok not in doc, f'no token {tok}')
# 3. code fences & top-level structure
chk(doc.count('```')%2==0,'code fence pairs')
h2=re.findall(r'^## (.+)$',doc,re.M)
exp=['0. ','1. ','2. ','3. ','4. ','5. ','6. ','7. ','부록 A','부록 B']
chk(len(h2)==10 and all(h.startswith(e) for h,e in zip(h2,exp)), f'top-level order: {h2}')
# 4. table column consistency
bad=[]
blocks=re.findall(r'((?:^\|.*\n)+)',doc,re.M)
for b in blocks:
rows=[r for r in b.strip().split('\n')]
cols=[len(re.split(r'(?<!\\)\|',r.strip())) for r in rows]
if len(set(cols))!=1: bad.append((rows[0][:40],cols))
chk(not bad, f'table column consistency {bad[:3]}')
# 5. ID definitions & references
defs=set()
defs|=set(re.findall(r'#### (Q-SHP-\d\d)',doc)); defs|=set(re.findall(r'#### (R-[A-Z]+-\d\d)',doc))
defs|=set(re.findall(r'### 5\.\d (FORM-SHP-\d\d)',doc)); defs|=set(re.findall(r'\| (LEAF-SHP-\d\d)',doc))
defs|=set(re.findall(r'\| (STOP-SHP-[A-Z]+-\d\d) \|',doc)); defs|=set(re.findall(r'\| (E-SHP-\d\d) —',doc))
defs|=set(re.findall(r'\| (P-\d\d) \|',doc)); defs|=set(re.findall(r'\| (C-\d\d) \|',doc))
defs|=set(re.findall(r'\| (X-\d+) \|',doc)); defs|=set(re.findall(r'\| (R-\d) \|',doc)); defs.add('CHECK-SHP-ENFORCE')
refs=set(re.findall(r'\b(Q-SHP-\d\d|R-(?:SEL|PTY|OBJ|AMT|JOIN)-\d\d|FORM-SHP-\d\d|LEAF-SHP-\d\d|STOP-SHP-[A-Z]+-\d\d|E-SHP-\d\d|P-\d\d|C-\d\d|X-\d+|CHECK-SHP-ENFORCE)\b',doc))
# expand ranges like "R-AMT-01·02·04", "E-SHP-03·13", "FORM-SHP-01~06"
undef=sorted(r for r in refs if r not in defs)
chk(not undef, f'undefined referenced IDs: {undef}')
# all original IDs present
orig=set(re.findall(r'\b(Q-SHP-\d\d|RULE-SHP-\d\d|FORM-SHP-\d\d|LEAF-SHP-\d\d|STOP-SHP-[A-Z]+-\d\d|E-SHP-\d\d|CHECK-SHP-[A-Z]+)\b',src))
miss=sorted(o for o in orig if o not in doc)
chk(not miss, f'original IDs all present in beta: missing {miss}')
# 6. bracket variables, URLs, numbers preserved
vars_src=set(re.findall(r'\[[^\]\n]+\]',src)); vars_doc=set(re.findall(r'\[[^\]\n]+\]',doc))
mv=sorted(v for v in vars_src if v not in vars_doc and not v.startswith('[ ]'))
chk(not mv, f'bracket variables preserved: missing {mv}')
urls=re.findall(r'https?://\S+',src); mu=[u for u in urls if u not in doc]
chk(not mu, f'URLs preserved ({len(urls)}): missing {mu}')
nums=set(re.findall(r'\d{4}\. ?\d{1,2}\. ?\d{1,2}\.|\d{4}-\d\d-\d\d|\d{4}다\d+|제\d+조',src))
mn=sorted(n for n in nums if n not in doc)
chk(not mn, f'dates/case numbers/articles preserved ({len(nums)}): missing {mn}')
# 7. form blocks have all 9 fields
fields9=['선택 기준','작성 전에 연결할 정보','법적 전제','미확인 처리','주문 문장','조립','사용 금지 조건','근거','검토']
for n in range(1,8):
m=re.search(rf'### 5\.{n} FORM-SHP-0{n}.*?(?=\n### 5\.)',doc,re.S)
block=m.group(0)
ok=all(f'- {f}:' in block for f in fields9)
chk(ok, f'FORM-SHP-0{n} has 9 fields')
chk(block.count('> ')>=2, f'FORM-SHP-0{n} has 주문 block')
# 8. five states, statuses, URL prohibition
for s in ['작성 진행','재검토를 붙여 진행','해당 부분 보완 대기','다른 구성·절차로 전환','해당 구성 중단']:
chk(f'| {s} |' in doc, f'state defined: {s}')
chk('작성됨 / 부분 작성 / 보완 대기 / 전환 / 해당 구성 중단' in doc,'writing statuses')
chk('문구 검사 미완료 / 문구 검사 완료 / 법률·사실 쟁점 재검토 필요 / 변호사 제출 전 검토 완료' in doc,'review statuses')
chk('### A.3 URL 직접 접근·조회·우회 수집 금지' in doc,'URL prohibition section')
# 9. forbidden phrase
ph='이하 '+'동일'
chk(ph not in doc,'no abbreviation phrase')
# 10. 주문 문장 verbatim from source
src_orders=[l for l in src.split('\n') if l.startswith('> ')]
mo=[l for l in src_orders if l not in doc]
chk(not mo, f'all {len(src_orders)} 주문 lines verbatim: missing {mo}')
# 11. STOP state names consistent across §1.2/§2.3/§7.2 (spot: each STOP code in §7.2 table has state)
sec72=re.search(r'### 7\.2.*?### 7\.3',doc,re.S).group(0)
for code in re.findall(r'STOP-SHP-[A-Z]+-\d\d',src):
chk(code in sec72, f'{code} in §7.2')
print('\nTOTAL FAILS:',len(fails))
sys.exit(1 if fails else 0)