migration: audit uncertain code and prepare handoff

This commit is contained in:
leefer
2026-07-31 16:48:13 +08:00
parent dec3cd1236
commit faac60b1a6
23 changed files with 979 additions and 1166 deletions
+31 -2
View File
@@ -17,6 +17,16 @@ SOURCE_RANGE = re.compile(
re.DOTALL,
)
# These exact original app.js line ranges were retired in slice 11 after the
# definition-only symbols passed static, runtime, and compatibility review.
RETIRED_FRONTEND_SOURCE_RANGES = (
(3537, 3540),
(4139, 4145),
(4973, 4989),
(9022, 9027),
(9052, 9055),
)
def sha256(path: Path) -> str:
return hashlib.sha256(path.read_bytes()).hexdigest()
@@ -38,8 +48,6 @@ def reassembled_frontend_runtime() -> str:
raise AssertionError(
f"app.js source coverage gap: expected line {next_line}, got {start}"
)
if len(content.splitlines(keepends=True)) != end - start + 1:
raise AssertionError(f"app.js line count changed in range {start}-{end}")
assembled.append(content)
next_line = end + 1
@@ -53,6 +61,27 @@ def reassembled_frontend_runtime() -> str:
return "".join(assembled)
def original_runtime_after_audited_retirements() -> str:
lines = (ORIGINAL_STATIC / "app.js").read_text(encoding="utf-8").splitlines(
keepends=True
)
retired = {
line_number
for start, end in RETIRED_FRONTEND_SOURCE_RANGES
for line_number in range(start, end + 1)
}
return "".join(
line for line_number, line in enumerate(lines, start=1) if line_number not in retired
)
def assert_frontend_runtime_matches_audited_baseline(testcase) -> None:
testcase.assertEqual(
reassembled_frontend_runtime(),
original_runtime_after_audited_retirements(),
)
def assert_moved_asset_matches(
testcase,
original_relative: str,