v0.1.0-pre.076
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# file: scripts/audit_pre_0_4_6_static_contracts.py
|
||||
# version: 1
|
||||
# version: 4
|
||||
|
||||
"""Audit static contracts that must remain true before the 0.4.6 alignment."""
|
||||
|
||||
@@ -35,7 +35,7 @@ def registered_commands(root: pathlib.Path) -> set[str]:
|
||||
match = re.search(r"generate_handler!\[(.*?)\]\);", text, re.DOTALL)
|
||||
if match is None:
|
||||
return set()
|
||||
return set(re.findall(r"^[ \t]*([A-Za-z_][A-Za-z0-9_]*)[ \t]*,", match.group(1), re.MULTILINE))
|
||||
return set(re.findall(r"([A-Za-z_][A-Za-z0-9_]*)[ \t]*,", match.group(1)))
|
||||
|
||||
def main() -> int:
|
||||
"""Run the pre-0.4.6 static audit."""
|
||||
@@ -62,7 +62,22 @@ def main() -> int:
|
||||
fail("ALIGN002", f"frontend commands missing from Tauri registration: {missing}")
|
||||
violations += 1
|
||||
|
||||
tauri_text = (root / "kb-app-demo-desktop" / "src" / "tauri.rs").read_text(encoding="utf-8")
|
||||
tauri_path = root / "kb-app-demo-desktop" / "src" / "tauri.rs"
|
||||
tauri_text = tauri_path.read_text(encoding="utf-8")
|
||||
forbidden_tauri_dependencies = (
|
||||
"kb_pipeline::",
|
||||
"kb_pipeline_demo_scenarios::",
|
||||
"kb_store::",
|
||||
)
|
||||
direct_dependencies = [
|
||||
dependency for dependency in forbidden_tauri_dependencies if dependency in tauri_text
|
||||
]
|
||||
if direct_dependencies:
|
||||
fail(
|
||||
"ALIGN009",
|
||||
f"tauri.rs must remain a thin IPC/runtime layer, direct domain dependencies: {direct_dependencies}",
|
||||
)
|
||||
violations += 1
|
||||
if 'window.label() != "main"' not in tauri_text or "disconnect_demo_ws_app_state" not in tauri_text:
|
||||
fail("ALIGN003", "global WebSocket shutdown must be tied to main-window destruction")
|
||||
violations += 1
|
||||
@@ -103,9 +118,37 @@ def main() -> int:
|
||||
fail("ALIGN008", "operation naming matrix is missing")
|
||||
violations += 1
|
||||
|
||||
tauri_source = (root / "kb-app-demo-desktop/src/tauri.rs").read_text(encoding="utf-8")
|
||||
command_files = []
|
||||
for command_path in (root / "kb-app-demo-desktop/src").glob("*.rs"):
|
||||
command_source = command_path.read_text(encoding="utf-8")
|
||||
if "#[tauri::command]" in command_source:
|
||||
command_files.append(command_path.name)
|
||||
if command_files != ["tauri.rs"]:
|
||||
fail("ALIGN009", f"#[tauri::command] must exist only in tauri.rs, found: {command_files}")
|
||||
violations += 1
|
||||
forbidden_files = [
|
||||
"tauri_backfill.rs",
|
||||
"tauri_core_extraction.rs",
|
||||
"tauri_decode_replay.rs",
|
||||
"tauri_execution.rs",
|
||||
"tauri_general_commands.rs",
|
||||
"tauri_http.rs",
|
||||
"tauri_sql.rs",
|
||||
"tauri_support.rs",
|
||||
"tauri_ws.rs",
|
||||
]
|
||||
for forbidden in forbidden_files:
|
||||
if (root / "kb-app-demo-desktop/src" / forbidden).exists():
|
||||
fail("ALIGN010", f"obsolete Tauri adapter module still exists: {forbidden}")
|
||||
violations += 1
|
||||
if "return crate::demo_decode_replay_options(state);" not in tauri_source:
|
||||
fail("ALIGN011", "tauri.rs must delegate demo_decode_replay_options through the crate façade")
|
||||
violations += 1
|
||||
if violations == 0:
|
||||
print("Pre-0.4.6 static contract audit: clean")
|
||||
return 0
|
||||
|
||||
print(f"Pre-0.4.6 static contract audit: {violations} violation(s)")
|
||||
return 0 if arguments.report_only else 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user