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
@@ -116,6 +116,18 @@ def cond_text(cond: dict) -> str:
return "|".join(str(cond.get(k) or "") for k in PICK_KEYS)
def by_class(master: mf.Master) -> dict[str, dict]:
"""자재품목을 「구분」 으로 미리 갈라 둠(마스터마다 한 번) — 고르기 후보를 찾을 때
3만 줄을 다 훑지 않게. 가른 차례는 파일 차례 그대로."""
got = getattr(master, "_by_class", None)
if got is None:
got = {}
for key, row in master.index.get(MARKET, {}).items():
got.setdefault(row.get("구분"), {})[key] = row
master._by_class = got
return got
def candidates(
master: mf.Master, cond: dict, env: dict | None = None, unit: str | None = None
) -> list[str]:
@@ -127,9 +139,8 @@ def candidates(
need = plain_unit(unit) if unit else ""
hits = [
key
for key, row in master.index.get(MARKET, {}).items()
if row.get("구분") == cond.get("구분")
and (not detail or row.get("상세구분") == detail)
for key, row in by_class(master).get(cond.get("구분"), {}).items()
if (not detail or row.get("상세구분") == detail)
and all(w in plain_spec(row.get("규격")) for w in want)
and (not need or plain_unit(row.get("단위")) == need)
]