perf(M01): 저장 검사를 고친 줄 둘레로 좁히고 서버가 뜰 때 마스터를 미리 읽음 (일감 33)
- 저장(`POST /save`) 6.8초 → 0.8초 — 고친 줄과 그 줄을 부르던 줄만 검사 (안 보는 줄이 부르는 키는 목록이 미리 세어 둔 것을 씀 · 돌고 도는 길은 전체 그림으로) - 로직 줄만 고쳤으면 품셈재료 연결 · 인력 준용 검사(`check_links`)도 건너뜀 - 로직 밖 파일(요소 · 표)이 섞인 저장은 예전처럼 전부 검사 — 전체 검사는 `check_master` 몫 - 켠 뒤 첫 목록 3.4초 → 0.03초 — M01 라우터가 뜰 때 뒤에서 한 번 읽어 둠(`cache.warm`) - 저장 전 검사(`check_saved`)를 M01 쪽(`_Store_Cache`)으로 옮김 — 좁히는 값이 있는 자리 · `check_master` 가 700줄에 닿음 - 시험 `test_m01_cache.py` 에 넷 더함 — 없는 로직 키 · 없는 요소 키 · 돌고 도는 참조 · 다른 파일에서 그 줄을 부르던 줄이 깨짐(모두 422) · 미리 읽은 뒤 첫 목록 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JgUhN55Z3BCYhUJTjwTNfj
This commit is contained in:
@@ -174,16 +174,6 @@ def master(folder: Path = MASTER) -> mf.Master:
|
||||
return mf.Master(load(folder=folder))
|
||||
|
||||
|
||||
def check_saved(files: dict[str, dict], changed: list[str], book: dict | None = None) -> list[str]:
|
||||
"""저장 전 검사(M01) — 고친 파일의 틀 + 모든 로직의 변수 · 키 + 조합.
|
||||
|
||||
`files` = 폴더 전부(고친 뒤) · `book` = 키 대장.
|
||||
"""
|
||||
whole = mf.Master(files)
|
||||
out = [x for name in changed for x in check_form(name, files[name])]
|
||||
return out + check_logics(files, whole, book) + mcb.check_all(files, whole)
|
||||
|
||||
|
||||
def calc(files: dict[str, dict], ref: str, given: dict) -> dict:
|
||||
"""시험 계산(M01) — `ref` = 로직 키 · 멈추면 FormulaError."""
|
||||
return mf.run(mf.Master(files), ref, given)
|
||||
@@ -562,17 +552,25 @@ def _elements_into(files: dict[str, dict], by_section: dict) -> None:
|
||||
|
||||
|
||||
# ── (3) 로직 ──────────────────────────────────────────────────────────
|
||||
def check_logics(files: dict[str, dict], whole: mf.Master, book: dict | None = None) -> list[str]:
|
||||
out, graph = [], {}
|
||||
def check_logics(
|
||||
files: dict[str, dict], whole: mf.Master, book: dict | None = None, narrow=None
|
||||
) -> list[str]:
|
||||
"""`narrow` = (검사할 로직 키, 안 보는 줄이 부르는 키) — 주면 그 키만 검사하고
|
||||
품셈재료 연결 · 인력 준용(`check_links`)도 건너뜀(로직 줄 고침이 못 건드리는 자리)."""
|
||||
only, graph = narrow or (None, {})
|
||||
out, graph = [], dict(graph)
|
||||
for name, data in files.items():
|
||||
if data.get("그룹") != "로직":
|
||||
continue
|
||||
for row in data.get("줄", []):
|
||||
key = str(row.get("키"))
|
||||
if only is not None and key not in only:
|
||||
continue
|
||||
found, calls = mf.check_logic(whole, row)
|
||||
out += [f"{name} · {x}" for x in found]
|
||||
graph[str(row.get("키"))] = calls
|
||||
graph[key] = calls
|
||||
out += [f"돌고 도는 참조 · {' → '.join(loop)}" for loop in mf.find_loops(graph)]
|
||||
return out + duplicate_keys(files, book) + check_links(whole)
|
||||
return out + duplicate_keys(files, book) + ([] if only else check_links(whole))
|
||||
|
||||
|
||||
def duplicate_keys(files: dict[str, dict], book: dict | None = None) -> list[str]:
|
||||
|
||||
Reference in New Issue
Block a user