0.3.0-0-pre.4-fix.3

This commit is contained in:
2026-09-20 13:40:19 +02:00
parent 023825b89b
commit 86b8af3b61
10 changed files with 200 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# file: scripts/audit_distribution_layout.py
# version: 4
# version: 5
"""Audit the static distribution layout expected by supported POCs."""
@@ -47,6 +47,47 @@ REQUIRED_PATHS = (
)
def audit_snake_web_shell(root: pathlib.Path) -> list[str]:
"""Validate the KSP-derived bounded SimpleBar shell contract."""
violations: list[str] = []
html_path = root / "Web/game-snake-poc/frontend/main.html"
app_scss_path = root / "Web/game-snake-poc/frontend/sass/_app.scss"
main_ts_path = root / "Web/game-snake-poc/frontend/ts/main.ts"
if not html_path.exists() or not app_scss_path.exists() or not main_ts_path.exists():
return violations
html = html_path.read_text(encoding="utf-8")
app_scss = app_scss_path.read_text(encoding="utf-8")
main_ts = main_ts_path.read_text(encoding="utf-8")
required_html = (
'<main class="app-main container-fluid p-0">',
'<div class="row g-0 h-100 flex-nowrap">',
'<section class="col app-content app-scrollable h-100" data-simplebar>',
)
for fragment in required_html:
if fragment not in html:
violations.append(f"DIST-LAYOUT-003: Snake Web shell missing required HTML contract: {fragment}")
if '<main class="app-main container-fluid p-0" data-simplebar>' in html:
violations.append("DIST-LAYOUT-004: data-simplebar must be attached to the bounded app-content zone, not app-main")
required_scss = (
".app-scrollable {",
"height: 100%;",
"max-height: 100%;",
)
for fragment in required_scss:
if fragment not in app_scss:
violations.append(f"DIST-LAYOUT-005: Snake Web shell missing required Sass contract: {fragment}")
required_ts = (
'import ResizeObserver from "resize-observer-polyfill";',
'import "simplebar";',
').ResizeObserver = ResizeObserver;',
)
for fragment in required_ts:
if fragment not in main_ts:
violations.append(f"DIST-LAYOUT-006: Snake Web shell missing SimpleBar bootstrap contract: {fragment}")
return violations
def main() -> int:
"""Validate that every static distribution boundary exists."""
@@ -56,12 +97,14 @@ def main() -> int:
root = pathlib.Path(arguments.root).resolve()
missing: list[str] = []
forbidden_present: list[str] = []
contract_violations: list[str] = []
for relative in REQUIRED_PATHS:
if not (root / relative).exists():
missing.append(relative)
for relative in FORBIDDEN_PATHS:
if (root / relative).exists():
forbidden_present.append(relative)
contract_violations.extend(audit_snake_web_shell(root))
if missing:
for relative in missing:
print(f"DIST-LAYOUT-001: missing required path: {relative}", file=sys.stderr)
@@ -72,6 +115,11 @@ def main() -> int:
print(f"DIST-LAYOUT-002: generated path must stay outside repository: {relative}", file=sys.stderr)
print(f"Distribution layout audit: {len(forbidden_present)} violation(s)", file=sys.stderr)
return 1
if contract_violations:
for violation in contract_violations:
print(violation, file=sys.stderr)
print(f"Distribution layout audit: {len(contract_violations)} violation(s)", file=sys.stderr)
return 1
print(f"Distribution layout audit: clean ({len(REQUIRED_PATHS)} required path(s), {len(FORBIDDEN_PATHS)} forbidden path(s) absent)")
return 0