perf(M01): 요소·표 저장도 흔들리는 로직만 검사 — 「어느 로직이 무엇을 보는지」 지도 (일감 33)

- 인력 한 줄 저장 7.0초 → 0.9초 · 자재품목 7.2초 → 2.0초 · 소요량 표 1.7초 ·
  자재품목 저장 뒤 목록 2.5초 → 0.45초 · 켠 뒤 첫 목록 3.4초 → 1.6초
- 로직 줄을 셀 때 `Master.get` 을 덧옷(`_Watch`)으로 감싸 그 줄이 본 자리를 모음 —
  키 · 「ID:원문번호」 · 없는 키를 물은 것까지 · 재료 고르기 줄은 자재품목 묶음 통째
- 저장은 그 지도로 흔들리는 줄만 검사(고친 키 · 고치기 전후 원문번호 · 지운 줄) ·
  요소를 고친 저장은 연결·준용 검사를 그대로 돌림
- 저장 뒤 목록은 흔들린 자리를 알려 받아(`stale(names, marks)`) 그 줄만 다시 셈 ·
  다른 창이 고친 파일이면 예전처럼 통째로 다시 셈
- 자재품목을 「구분」 으로 미리 갈라 둠(`master_material.by_class`) — 고르기 후보를
  3만 줄에서 훑지 않음 · 가른 차례는 파일 차례 그대로라 고르는 줄은 안 바뀜
- 전수 확인 — 요소·표 파일 90 개마다 줄을 통째로 비우고 로직 1,354 줄을 다시 검사,
  달라진 줄이 모두 지도 안(지도 밖 0)
- 시험 `test_m01_cache.py` 에 셋 더함(열둘) — 쓰이는 요소를 지우면 저장이 막힘 ·
  요소를 고쳐 저장한 뒤 막힘 표시가 줄마다 검사한 것과 같음 · 인력 줄을 비운 전수 대조

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JgUhN55Z3BCYhUJTjwTNfj
This commit is contained in:
2026-09-22 02:59:52 +09:00
co-authored by Claude Opus 5
parent 589403f536
commit 3a4823b6da
6 changed files with 193 additions and 34 deletions
+4 -2
View File
@@ -665,7 +665,8 @@ def save(batch: list[dict]) -> list[dict]:
for part in batch:
_apply(after[part["file"]], part.get("changes") or [], part["file"], book)
mk.finish(book)
# 고친 줄 그 줄을 부르던 줄만 검사 — 마스터 전체 검사는 `check_master` 몫
# 저장이 흔드는 줄만 검사(고친 줄 · 그 줄을 부르던 줄 · 그 요소를 보던 줄) —
# 마스터 전체 검사는 `check_master` 몫
narrowed = cache.narrow(FOLDER, batch, before, after)
old = set(cache.check_saved(before, names, mk.load_book(book_path), narrowed))
new = [x for x in cache.check_saved(after, names, book, narrowed) if x not in old]
@@ -683,5 +684,6 @@ def save(batch: list[dict]) -> list[dict]:
tmp.write_text(text, encoding="utf-8", newline="\n")
os.replace(tmp, FOLDER / name)
out.append({"file": name, "version": version_of(text.encode("utf-8"))})
cache.stale(dict.fromkeys(names)) # 저장 뒤에는 그 파일을 바로 다시 읽게
# 저장 뒤에는 그 파일을 바로 다시 읽게 · 흔들린 자리를 알려 줘 그 줄만 다시 세게
cache.stale(dict.fromkeys(names), narrowed[2])
return out