fix(855-E 2-E4): Doc_Copy 문서 고르기가 M01 로직 줄을 안 읽음 · 문서 지문 수 꼴(4 · 4.0) 안 가림

- doc_of: 실어 온 사본 문서 › 값 사본 색인이 든 그 키 줄(옛 저장본 · `_held`) › M01 수식 문서 › M01 문서 없는 키 =
  색인 줄 변환 — M01 키마다 `whole.logic` 을 읽던 것(sub4 표 L2 ⓑ-3 「Doc_Copy.doc_of · given_of 읽힘 18,002」) 걷음
- doc_fp: 정수 값 실수 = 정수(저장본 부름 문서 4 · M01 문서 4.0 이 다른 지문 → 서고 같은 내용 · M01 새판 거짓 판정) ·
  저장본 `원본.판`(13 파일) = 옛 지문도 받음(same_origin)
- test_703 「자료집 같은 이름 물음」 빨강(같은 내용 지문) = 이 고침으로 통과 · 713_1 · 804_7 = 받은 M01 쪽 고침으로 이미 통과
- test_795_2: 값 사본에 로직 줄이 없는 꼴(855-F B9-6) — 로직 몫 확인 = 수식 부름 문서
- 검증: 관련 40 파일 + 지킴 + 관문 360 통과 · 빌더 --check 같음 · typecheck 0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 11:03:13 +09:00
co-authored by Claude Opus 5.5
parent 2e7bb92044
commit 8bf45a60e3
2 changed files with 45 additions and 15 deletions
+40 -11
View File
@@ -65,9 +65,21 @@ LOGIC = ("변수", "식", "금액", "끝수", "결과단위") # fmt: skip
LABEL = ("이름", "규격", "단위", "비고", "출처") # fmt: skip
def doc_fp(doc: Any) -> str:
def _whole_num(v: Any) -> Any:
"""수 꼴 맞춤 — 정수 값 실수(4.0) = 정수(4)(저장본 · M01 문서 읽기 꼴이 달라도 같은 지문 · 855-E 2-E4)."""
if isinstance(v, dict):
return {k: _whole_num(x) for k, x in v.items()}
if isinstance(v, list):
return [_whole_num(x) for x in v]
if isinstance(v, float) and v.is_integer():
return int(v)
return v
def doc_fp(doc: Any, legacy: bool = False) -> str:
"""문서 계산 내용 지문(848-2) — 셈 칸(`LOGIC`)만 · 줄 · 변수의 글 칸 뺌 · 서버 표지 칸 뺌 ·
`기계덮음`(②) · `위덮음`(①) · `손고침` 은 셈 칸 밖 = 바뀌어도 같은 지문."""
`기계덮음`(②) · `위덮음`(①) · `손고침` 은 셈 칸 밖 = 바뀌어도 같은 지문 · 수 꼴(4 · 4.0) 안 가림 ·
`legacy` = 수 꼴 가리던 옛 지문(저장본 `원본.판` 대조만)."""
from M02_MasterTemplete import M02_Doc_Sk as dsk
doc = doc if isinstance(doc, dict) else {}
@@ -75,7 +87,8 @@ def doc_fp(doc: Any) -> str:
got = {k: doc.get(k) for k in LOGIC}
for part in ("변수", "식", "금액"):
got[part] = [bare(x) for x in got[part] or []]
return fp(dsk._strip(got))
got = dsk._strip(got)
return fp(got) if legacy else fp(_whole_num(ml._norm(got)))
# ── M01 문서(정본 폴더) ────────────────────────────────────────────────
@@ -108,18 +121,34 @@ def _carried(whole: Any, key: str) -> dict | None:
return None
def _held(whole: Any, key: str) -> dict | None:
"""값 사본 색인(`skc.Copy`)이 든 그 키 줄(옛 저장본 · 새 값 사본엔 로직 줄 없음) · 없음 = None."""
for _ in range(8):
box = getattr(whole, "_box", None) if isinstance(whole, skc.Copy) else None
if box and key in box:
return whole.index.get(key[:2], {}).get(key)
own = vars(whole) if hasattr(whole, "__dict__") else {}
whole = own.get("_whole")
if whole is None:
return None
return None
def doc_of(whole: Any, key: str) -> dict | None:
"""키 하나의 문서 — 색인이 실어 온 사본 문서 › 값 사본 줄 = 지금 M01 줄이면 M01 문서 · 다르면 그 줄
변환 · 없으면 None."""
"""키 하나의 문서 — 색인이 실어 온 사본 문서 › 값 사본 줄(옛 저장본) = 지금 M01 줄이면 M01 문서 · 다르면
그 줄 변환 › M01 문서 › M01 문서 없는 키 = 색인 줄 변환(견본 · 마스터 밖 줄) · 없으면 None ·
M01 로직 줄은 안 읽음(855-E 2-E4)."""
if (got := _carried(whole, str(key))) is not None:
return cp.deepcopy(got)
try:
row = whole.logic(key)
except _ERR:
row = None
live = folder().get(key)
row = _held(whole, str(key))
if row is None and live is not None:
return cp.deepcopy(live)
if row is None:
return cp.deepcopy(live) if live else None
try:
row = whole.logic(key)
except _ERR:
return None
if live and (_live(key) is None or skc._fp(_live(key)) == skc._fp(prices.to_json(row))):
return cp.deepcopy(live)
try:
@@ -442,4 +471,4 @@ def state(copy: dict) -> dict[str, Any]:
def same_origin(base: dict, live: Any) -> bool:
"""`원본.판` 대 지금 M01 문서 — 계산 내용 지문(`doc_fp`) · 옛 통째 지문(`fp`) 둘 다 받음."""
return base.get("판") in (doc_fp(live), fp(live))
return base.get("판") in (doc_fp(live), doc_fp(live, True), fp(live))