feat(M02): 옛 표 틀 새 판으로 갱신 — Migrate --refresh-tables · 손 값 · 변수 · 보기 지킴 · _initial 도 같은 판 (브레인 최종 확인)

- 계산 열에 바인딩이 붙은 옛 틀만 골라 시스템 새 판으로
- 손댄 것이 없으면 시스템 파일 그대로 복사(판이 시스템과 같음) · 있으면 고쳐 쓰고 manifest 에 출처 판
- 기존 프로젝트 6개 작업본 · _initial 갱신 완료

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015LuapLYqN1GGFD8Y1PStD5
This commit is contained in:
2026-09-25 12:03:10 +09:00
co-authored by Claude Opus 5.5
parent abd0d4b126
commit 07953fa523
3 changed files with 112 additions and 8 deletions
@@ -295,3 +295,44 @@ def test_프로젝트_표_저장은_서버가_설계값을_걸러_씀(world: dic
stored = layers.read_template(_root(world, P1) / "templates", "table", "구조물집계표")["문서"]
assert stored["줄"][1] == {"id": "s40.00", "값": {"sta": "NO.2", "h_intake": 2}}
assert "알림" not in stored and all("|" not in c["id"] for c in stored["열"])
def test_옛_표_틀은_새_판으로_손_값은_지킴(world: dict[str, Any]) -> None:
from M02_MasterTemplete import M02_Template_Migrate as migrate
new = {
"판": 2,
"열": [{"id": "a", "식": "1", "펼침틀": {"묶음": "g"}}],
"줄": [],
"변수": {"k": 1},
}
old = {
"판": 1,
"열": [{"id": "a", "식": "1", "바인딩": {"종류": "pipe", "값": "식"}}, {"id": "memo"}],
"줄": [{"id": "s10.00", "값": {"sta": "NO.0+10", "memo": "손"}}],
"변수": {"k": 5},
}
layers.write_template(layers.system_dir(), "table", "구조물집계표", new)
root2, root1 = _root(world, P2, user=43), _root(world, P1)
for folder in (root1 / "templates", root1 / "templates/_initial", root2 / "templates"):
layers.write_template(folder, "table", "구조물집계표", old)
layers.write_template(
root2 / "templates", "table", "구조물집계표", {**old, "줄": [], "변수": {"k": 1}}
)
assert migrate.refresh_tables(root1, dry_run=True) == [
"templates/table/구조물집계표",
"_initial/table/구조물집계표",
]
migrate.refresh_tables(root1)
work = layers.read_template(root1 / "templates", "table", "구조물집계표")["문서"]
assert work["열"] == new["열"] and work["변수"] == {"k": 5} # 틀만 새 판 · 변수 · 손 값 지킴
assert work["줄"] == old["줄"]
system_version = layers.version_of(layers.system_dir() / "table/구조물집계표.json")
initial = root1 / "templates/_initial"
assert layers.version_of(initial / "table/구조물집계표.json") != system_version # 변수 다름
assert layers.read_manifest(root1 / "templates")["table/구조물집계표"]["판"] == system_version
assert migrate.refresh_tables(root1) == [] # 다시 돌려도 그대로
# 손댄 것 없는 작업본은 시스템 파일 그대로(판이 같음)
migrate.refresh_tables(root2)
assert layers.version_of(root2 / "templates/table/구조물집계표.json") == system_version