"""Stage B (2026-10-16), second part: the "근거표를 끝까지 읽었다" marker is written by a separate POST (sent by the page when the evidence table has been scrolled to its end), not by merely opening the page (D4).""" from pathlib import Path P = Path(__file__).resolve().parents[2] / "web" / "app.py" s = P.read_text(encoding="utf-8") a = ''' store.wjson(p.dir / "confirm_view.json", {"sha": _targets_sha(p, targets), "at": store.now(), "n": len(targets)}) rest = []''' b = ''' rest = []''' assert s.count(a) == 1 s = s.replace(a, b) a2 = '''@app.route("/pier//confirm_matched", methods=["GET", "POST"])''' b2 = '''@app.post("/pier//confirm_matched/read") def confirm_matched_read(name): """Marker: the evidence table of the current target list was read to its end (the page posts this when the scroll box is at the bottom).""" p = pier_or_404(name) targets = matched_targets(p) store.wjson(p.dir / "confirm_view.json", {"sha": _targets_sha(p, targets), "at": store.now(), "n": len(targets)}) return {"ok": True, "n": len(targets)} @app.route("/pier//confirm_matched", methods=["GET", "POST"])''' assert s.count(a2) == 1 s = s.replace(a2, b2) P.write_text(s, encoding="utf-8") print("patched")