feat(E04): 3D 결과 열쇠에 조건 · 옛 이름 읽기 · 엔진 판 = 엔진 파일 해시 (PLAN 564-2)

- section_key(start, end, condition) → 0.00_100.00_dry 꼴 · 건기 → 우기가 서로 덮지 않음
- 옛 시작_끝.json 은 그 안 조건 열쇠로 읽음(load · saved_summaries)
- ENGINE_VERSION 대신 engine_hash()(엔진 파일 넷 해시) — 판 올리기 잊음 없음
- 시험 533_3 router(건기 → 우기 둘 다 남음 · 옛 이름 · 엔진 해시) · 534_3 견본 파일 새 이름

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 19:57:56 +09:00
co-authored by Claude Opus 5.5
parent 6d4964ae55
commit f747e41e28
4 changed files with 105 additions and 29 deletions
+39 -4
View File
@@ -107,7 +107,7 @@ def test_analyze_cached_force_and_result(client, project, monkeypatch):
monkeypatch.setattr(run, "run_engine", counted)
first = client.post(f"/api/projects/{PID}/stab/analyze3d", json=BODY).json()
assert first == {"status": "accepted", "key": "0.00_100.00"}
assert first == {"status": "accepted", "key": "0.00_100.00_dry"}
done = _wait(client)
assert done["error"] is None and done["percent"] == 100
assert done["summary"]["cells"] == 5 and done["summary"]["verdict"] == "ng"
@@ -133,7 +133,7 @@ def test_analyze_cached_force_and_result(client, project, monkeypatch):
_wait(client)
assert len(calls) == 3
doc = client.get(f"/api/projects/{PID}/stab/result3d", params={"key": "0.00_100.00"}).json()
doc = client.get(f"/api/projects/{PID}/stab/result3d", params={"key": "0.00_100.00_dry"}).json()
grid = doc["grid"]
assert len(doc["f"]) == len(doc["z"]) == len(doc["v"]) == grid["nx"] * grid["ny"]
f = np.array([np.nan if v is None else v for v in doc["f"]])
@@ -143,7 +143,7 @@ def test_analyze_cached_force_and_result(client, project, monkeypatch):
assert doc["stale"] is False
over = client.get(f"/api/projects/{PID}/stab/result3d").json()
assert [s["key"] for s in over["saved"]] == ["0.00_100.00"] and over["editable"] is True
assert [s["key"] for s in over["saved"]] == ["0.00_100.00_dry"] and over["editable"] is True
assert len(over["line"]) == len(STATIONS) and over["sections"][0]["end_m"] == 100.0
# E02 지반을 바꾸면 저장본이 「옛 것」
(project / "E02_StabGround").mkdir()
@@ -179,7 +179,9 @@ def test_cancel_and_restart(client, monkeypatch):
body = _wait(client)
assert body["cancelled"] is True and body["error"] is None
assert (
client.get(f"/api/projects/{PID}/stab/result3d", params={"key": "0.00_100.00"}).status_code
client.get(
f"/api/projects/{PID}/stab/result3d", params={"key": "0.00_100.00_dry"}
).status_code
== 404
)
# 다시 시작
@@ -191,6 +193,39 @@ def test_cancel_and_restart(client, monkeypatch):
assert body["cancelled"] is False and body["percent"] == 100
def test_dry_then_wet_both_kept(client, project, monkeypatch):
"""건기 → 우기 = 다른 열쇠 · 앞 결과가 덮이지 않음 · 옛 이름(조건 없음) 파일도 읽음."""
monkeypatch.setattr(run, "run_engine", _fake_engine)
for condition in ("dry", "wet"):
body = client.post(
f"/api/projects/{PID}/stab/analyze3d", json={**BODY, "condition": condition}
).json()
assert body == {"status": "accepted", "key": f"0.00_100.00_{condition}"}
_wait(client)
over = client.get(f"/api/projects/{PID}/stab/result3d").json()
assert [(s["key"], s["condition"]) for s in over["saved"]] == [
("0.00_100.00_dry", "dry"),
("0.00_100.00_wet", "wet"),
]
folder = run.results_dir(project)
# 옛 이름 — 우기 파일을 조건 없는 이름으로 옮기면 우기 열쇠로 읽힘
(folder / "0.00_100.00_wet.json").rename(folder / "0.00_100.00.json")
over = client.get(f"/api/projects/{PID}/stab/result3d").json()
assert [s["key"] for s in over["saved"]] == ["0.00_100.00_dry", "0.00_100.00_wet"]
url = f"/api/projects/{PID}/stab/result3d"
assert client.get(url, params={"key": "0.00_100.00_wet"}).json()["stale"] is False
again = client.post(
f"/api/projects/{PID}/stab/analyze3d", json={**BODY, "condition": "wet"}
).json()
assert again["status"] == "cached"
def test_engine_hash_in_fingerprint(monkeypatch):
before = run.fingerprint("a", None, {})
monkeypatch.setattr(run, "engine_hash", lambda: "changed")
assert run.fingerprint("a", None, {}) != before
def test_bad_requests(client):
url = f"/api/projects/{PID}/stab/analyze3d"
assert client.post(url, json={"start_m": 100, "end_m": 50}).status_code == 400
+1 -1
View File
@@ -170,7 +170,7 @@ def project(tmp_path, monkeypatch) -> Path:
path.write_text(json.dumps(ground), encoding="utf-8")
r3 = root / "E04_Stab3D" / "results"
r3.mkdir(parents=True)
(r3 / "0.00_200.00.json").write_text(
(r3 / "0.00_200.00_wet.json").write_text(
json.dumps(
{
"fingerprint": "3d-1",