Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Enforce browser verification for frontend changes

rcourtman024aa16d9205
diff --git a/.github/workflows/canonical-governance.yml b/.github/workflows/canonical-governance.yml
index cb0c5f67f8..51446d8d45 100644
--- a/.github/workflows/canonical-governance.yml
+++ b/.github/workflows/canonical-governance.yml
@@ -171,6 +171,12 @@ jobs:
echo "Canonical completion guard failed for commit ${commit}."
status=1
fi
+ if ! git diff-tree --no-commit-id --name-only -r "${commit}" \
+ | python3 scripts/release_control/browser_verification_guard.py \
+ --files-from-stdin --commit "${commit}"; then
+ echo "Browser verification guard failed for commit ${commit}."
+ status=1
+ fi
echo "::endgroup::"
done
exit ${status}
@@ -209,6 +215,9 @@ jobs:
- name: Run canonical completion guard unit tests
run: python3 scripts/release_control/canonical_completion_guard_test.py
+ - name: Run browser verification guard unit tests
+ run: python3 scripts/release_control/browser_verification_guard_test.py
+
- name: Run control plane audit unit tests
run: python3 scripts/release_control/control_plane_audit_test.py
diff --git a/.husky/pre-commit b/.husky/pre-commit
index d529f48132..7e5c9bf7f5 100755
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -67,6 +67,9 @@ staged_files_match() {
printf '%s\n' "$STAGED_FILES" | grep -qE "$1"
}
+echo "Running browser verification guard..."
+python3 scripts/release_control/browser_verification_guard.py
+
# Governance checks gating.
# Run the full governance audit + Go test suite only when:
# (a) the internal governance directory is present (skipped on fresh public-repo clones), AND
@@ -118,6 +121,7 @@ python3 scripts/release_control/readiness_assertion_guard.py --staged --active-t
echo "Running release-control helper unit tests..."
python3 scripts/release_control/canonical_completion_guard_test.py
+python3 scripts/release_control/browser_verification_guard_test.py
python3 scripts/release_control/control_plane_audit_test.py
python3 scripts/release_control/contract_audit_test.py
python3 scripts/release_control/format_staged_go_test.py
diff --git a/docs/release-control/v6/internal/CANONICAL_DEVELOPMENT_PROTOCOL.md b/docs/release-control/v6/internal/CANONICAL_DEVELOPMENT_PROTOCOL.md
index 816416dc9c..6506b9fe02 100644
--- a/docs/release-control/v6/internal/CANONICAL_DEVELOPMENT_PROTOCOL.md
+++ b/docs/release-control/v6/internal/CANONICAL_DEVELOPMENT_PROTOCOL.md
@@ -198,6 +198,56 @@ must be declared explicitly in `registry.json` and mirrored in the contract's
state. Shared-boundary entries must use the exact registry-derived sentence
shape rather than freeform wording.
+## Frontend Browser Verification Gate
+
+Every change with a user-visible effect in `frontend-modern` must be exercised
+in the current built application before it can be committed or described as
+complete. Unit tests, DOM assertions, accessibility snapshots, type checking,
+and successful builds remain required where applicable, but none of them prove
+that the rendered result is visible, usable, aligned, unclipped, and coherent.
+
+The verification pass must be task-specific and must:
+
+1. list the changed route or routes
+2. inspect actual pixels at a normal desktop width and a supported narrow width
+3. exercise every applicable changed state, including default, open, closed,
+ selected, disabled, empty, loading, error, and persisted/reloaded states
+4. exercise the deepest changed interaction rather than stopping at its parent
+ container
+5. cover applicable pointer, outside-click, Escape, keyboard-focus, dismissal,
+ and cross-control behavior
+6. explicitly inspect placement, clipping, stacking, scrolling, and focus
+ return for menus, popovers, nested overlays, dialogs, drawers, and tooltips
+7. repeat the affected matrix after any code change made in response to the
+ browser pass
+
+A control that exists in the DOM but is clipped, obscured, visually disabled,
+misaligned, off-screen, or otherwise unusable fails this gate. Known browser
+defects in the changed journey remain part of the current task and block the
+commit unless the user explicitly narrows the requested scope.
+
+The durable proof boundary is
+`frontend-modern/browser-verification.json`. Every commit that changes
+user-visible source under `frontend-modern/src/` or the frontend HTML entry
+must update that receipt with:
+
+1. `base_sha`, equal to the parent revision whose current build was exercised
+2. the exact changed user-visible frontend source paths and SHA-256 digests of
+ their final staged content
+3. the verified routes
+4. at least one desktop and one narrow viewport
+5. the states inspected
+6. the interactions exercised
+7. a UTC verification timestamp and `result: "passed"`
+
+`scripts/release_control/browser_verification_guard.py` enforces the receipt
+against the staged index locally and against each changed commit in canonical
+governance CI. A stale receipt, later source edit, incomplete path coverage,
+missing responsive viewport, or omitted state/interaction evidence is a hard failure. Agents may
+print a non-passing receipt skeleton with
+`python3 scripts/release_control/browser_verification_guard.py --print-template`
+after staging the intended frontend paths.
+
## Task Completion Protocol
Every substantial task must finish by checking these questions:
@@ -273,12 +323,11 @@ Every substantial task must finish by checking these questions:
Missing evidence items, current-vs-target score, and proof counts are
signals that help locate the real same-lane gap.
10ab. Have I checked real browser truth for a customer-facing surface?
- For important customer-facing UI, code-level proof is not enough by
- itself. If the surface is meant to be trusted or used normally, exercise
- it in-browser and judge whether it actually deserves more iteration in its
- current shape. If the slice changed frontend code, inspect the changed
- surface in Playwright after the current build before treating the work as
- progress, improvement, or done.
+ For customer-facing UI, code-level proof is not enough. Complete the
+ Frontend Browser Verification Gate against the current build, exercise the
+ deepest changed interaction and adjacent states, inspect desktop and narrow
+ pixels, and stage a fresh browser-verification receipt before treating the
+ work as progress, improvement, or done.
They are not the work item by themselves unless the remaining gap is
explicitly governance-only.
For ordinary lane work, identify the runtime, product, ownership, or
diff --git a/docs/release-control/v6/internal/SOURCE_OF_TRUTH.md b/docs/release-control/v6/internal/SOURCE_OF_TRUTH.md
index 85575aa274..ffe56ef27f 100644
--- a/docs/release-control/v6/internal/SOURCE_OF_TRUTH.md
+++ b/docs/release-control/v6/internal/SOURCE_OF_TRUTH.md
@@ -1,6 +1,6 @@
# Pulse v6 Source Of Truth
-Last updated: 2026-07-22
+Last updated: 2026-08-02
Status: ACTIVE
This file is the stable human governance layer for the active v6 release
@@ -382,6 +382,12 @@ Assertion design rules:
a slice requires its own isolated hooks, staged scope, and dirty state —
for example when a subagent needs to mutate independently and land back
cleanly.
+26. User-visible frontend work is incomplete until the current build has been
+ exercised in-browser through the deepest changed interaction at desktop
+ and narrow widths. The commit must carry a fresh, parent-bound browser
+ verification receipt with exact routes, changed paths, final-content
+ digests, states, and interactions. DOM presence, unit tests, snapshots, and
+ a successful build cannot substitute for rendered-pixel and behavior proof.
## Non-Negotiable Release Gates
diff --git a/docs/release-control/v6/internal/status.json b/docs/release-control/v6/internal/status.json
index f57f3bd8da..7cf306dd72 100644
--- a/docs/release-control/v6/internal/status.json
+++ b/docs/release-control/v6/internal/status.json
@@ -1,6 +1,6 @@
{
"version": "6.0",
- "updated_at": "2026-07-22",
+ "updated_at": "2026-08-02",
"scope": {
"active_repos": [
"pulse",
@@ -5010,6 +5010,66 @@
"kind": "file"
}
]
+ },
+ {
+ "id": "RA44",
+ "summary": "Every commit with a user-visible Pulse frontend source change carries fresh browser verification bound to that commit's parent and final staged content: the current build is exercised through the deepest changed interaction, actual rendered pixels are inspected at desktop and narrow widths, affected states and cross-control behavior are recorded, and DOM-only, stale, or pre-final-edit proof cannot satisfy completion.",
+ "kind": "invariant",
+ "blocking_level": "repo-ready",
+ "proof_type": "automated",
+ "lane_ids": [
+ "L8"
+ ],
+ "subsystem_ids": [
+ "frontend-primitives"
+ ],
+ "release_gate_ids": [],
+ "proof_commands": [
+ {
+ "id": "ra44-frontend-browser-verification-guard",
+ "run": [
+ "python3",
+ "scripts/release_control/browser_verification_guard_test.py"
+ ]
+ }
+ ],
+ "evidence": [
+ {
+ "repo": "pulse",
+ "path": ".github/workflows/canonical-governance.yml",
+ "kind": "file",
+ "evidence_tier": "test-proof"
+ },
+ {
+ "repo": "pulse",
+ "path": ".husky/pre-commit",
+ "kind": "file",
+ "evidence_tier": "test-proof"
+ },
+ {
+ "repo": "pulse",
+ "path": "docs/release-control/v6/internal/CANONICAL_DEVELOPMENT_PROTOCOL.md",
+ "kind": "file"
+ },
+ {
+ "repo": "pulse",
+ "path": "internal/repoctl/canonical_development_protocol_test.go",
+ "kind": "file",
+ "evidence_tier": "test-proof"
+ },
+ {
+ "repo": "pulse",
+ "path": "scripts/release_control/browser_verification_guard.py",
+ "kind": "file",
+ "evidence_tier": "test-proof"
+ },
+ {
+ "repo": "pulse",
+ "path": "scripts/release_control/browser_verification_guard_test.py",
+ "kind": "file",
+ "evidence_tier": "test-proof"
+ }
+ ]
}
],
"evidence_reference_policy": {
diff --git a/internal/repoctl/canonical_development_protocol_test.go b/internal/repoctl/canonical_development_protocol_test.go
index c9b34d9f3b..f41cbc5609 100644
--- a/internal/repoctl/canonical_development_protocol_test.go
+++ b/internal/repoctl/canonical_development_protocol_test.go
@@ -1714,6 +1714,8 @@ func TestCanonicalCompletionGuardIsWiredIntoPreCommit(t *testing.T) {
"control_plane_audit.py --check --staged",
"canonical_completion_guard.py",
"Running canonical completion guard...",
+ "browser_verification_guard.py",
+ "Running browser verification guard...",
"Running status audit...",
"status_audit.py --check",
"Running registry audit...",
@@ -1725,6 +1727,7 @@ func TestCanonicalCompletionGuardIsWiredIntoPreCommit(t *testing.T) {
"Running readiness assertion guard...",
"readiness_assertion_guard.py --staged --active-target --proof-type automated",
"canonical_completion_guard_test.py",
+ "browser_verification_guard_test.py",
"control_plane_audit_test.py",
"contract_audit_test.py",
"format_staged_go_test.py",
@@ -1855,6 +1858,7 @@ func TestCanonicalGovernanceRunsInCI(t *testing.T) {
"PULSE_REPO_ROOT_PULSE_ENTERPRISE",
"PULSE_REPO_ROOT_PULSE_MOBILE",
"python3 scripts/release_control/canonical_completion_guard.py --files-from-stdin",
+ "python3 scripts/release_control/browser_verification_guard.py",
"python3 scripts/release_control/status_audit.py --check",
"python3 scripts/release_control/control_plane_audit.py --check",
"python3 scripts/release_control/registry_audit.py --check",
@@ -1863,6 +1867,7 @@ func TestCanonicalGovernanceRunsInCI(t *testing.T) {
"python3 scripts/release_control/readiness_assertion_guard.py --active-target --proof-type hybrid",
"go test ./internal/repoctl -count=1",
"python3 scripts/release_control/canonical_completion_guard_test.py",
+ "python3 scripts/release_control/browser_verification_guard_test.py",
"python3 scripts/release_control/control_plane_audit_test.py",
"python3 scripts/release_control/contract_audit_test.py",
"python3 scripts/release_control/governance_stage_guard_test.py",
diff --git a/scripts/release_control/browser_verification_guard.py b/scripts/release_control/browser_verification_guard.py
new file mode 100644
index 0000000000..152ed8f6b8
--- /dev/null
+++ b/scripts/release_control/browser_verification_guard.py
@@ -0,0 +1,283 @@
+#!/usr/bin/env python3
+"""Require fresh browser proof for staged user-visible frontend changes."""
+
+from __future__ import annotations
+
+import argparse
+from datetime import datetime
+import hashlib
+import json
+from pathlib import Path, PurePosixPath
+import subprocess
+import sys
+from typing import Iterable, Sequence
+
+
+REPO_ROOT = Path(__file__).resolve().parents[2]
+RECEIPT_PATH = "frontend-modern/browser-verification.json"
+FRONTEND_SOURCE_PREFIX = "frontend-modern/src/"
+FRONTEND_ENTRY_FILES = {"frontend-modern/index.html"}
+FRONTEND_SOURCE_SUFFIXES = {".css", ".scss", ".ts", ".tsx"}
+
+
+def run_git(args: Sequence[str], *, repo_root: Path = REPO_ROOT) -> str:
+ result = subprocess.run(
+ ["git", *args],
+ cwd=repo_root,
+ check=True,
+ capture_output=True,
+ text=True,
+ )
+ return result.stdout.strip()
+
+
+def git_blob_bytes(object_name: str, *, repo_root: Path = REPO_ROOT) -> bytes | None:
+ result = subprocess.run(
+ ["git", "show", object_name],
+ cwd=repo_root,
+ check=False,
+ capture_output=True,
+ )
+ return result.stdout if result.returncode == 0 else None
+
+
+def staged_files(*, repo_root: Path = REPO_ROOT) -> list[str]:
+ output = run_git(
+ ["diff", "--cached", "--name-only", "--diff-filter=ACMRD"],
+ repo_root=repo_root,
+ )
+ return [line.strip() for line in output.splitlines() if line.strip()]
+
+
+def stdin_files(lines: Iterable[str]) -> list[str]:
+ return [line.strip() for line in lines if line.strip()]
+
+
+def is_frontend_test_or_fixture(path: str) -> bool:
+ pure_path = PurePosixPath(path)
+ name = pure_path.name
+ return (
+ "__tests__" in pure_path.parts
+ or "__fixtures__" in pure_path.parts
+ or ".test." in name
+ or ".spec." in name
+ or ".stories." in name
+ )
+
+
+def is_user_visible_frontend_source(path: str) -> bool:
+ if path in FRONTEND_ENTRY_FILES:
+ return True
+ if not path.startswith(FRONTEND_SOURCE_PREFIX):
+ return False
+ if is_frontend_test_or_fixture(path):
+ return False
+ return PurePosixPath(path).suffix in FRONTEND_SOURCE_SUFFIXES
+
+
+def frontend_runtime_paths(paths: Iterable[str]) -> list[str]:
+ return sorted({path for path in paths if is_user_visible_frontend_source(path)})
+
+
+def load_receipt_text(
+ *,
+ commit: str | None,
+ repo_root: Path = REPO_ROOT,
+) -> str:
+ object_name = f"{commit}:{RECEIPT_PATH}" if commit else f":{RECEIPT_PATH}"
+ return run_git(["show", object_name], repo_root=repo_root)
+
+
+def expected_base_sha(*, commit: str | None, repo_root: Path = REPO_ROOT) -> str:
+ revision = f"{commit}^" if commit else "HEAD"
+ return run_git(["rev-parse", revision], repo_root=repo_root)
+
+
+def content_sha256(
+ paths: Sequence[str],
+ *,
+ commit: str | None,
+ repo_root: Path = REPO_ROOT,
+) -> dict[str, str]:
+ digests: dict[str, str] = {}
+ for path in paths:
+ object_name = f"{commit}:{path}" if commit else f":{path}"
+ content = git_blob_bytes(object_name, repo_root=repo_root)
+ digests[path] = "deleted" if content is None else hashlib.sha256(content).hexdigest()
+ return digests
+
+
+def validate_receipt(
+ payload: object,
+ *,
+ changed_paths: Sequence[str],
+ expected_base: str,
+ expected_content_sha256: dict[str, str],
+) -> list[str]:
+ errors: list[str] = []
+ if not isinstance(payload, dict):
+ return ["receipt root must be a JSON object"]
+
+ if payload.get("version") != 1:
+ errors.append("version must be 1")
+ if payload.get("result") != "passed":
+ errors.append('result must be "passed"')
+ if payload.get("base_sha") != expected_base:
+ errors.append(f"base_sha must match the verified parent {expected_base}")
+
+ receipt_paths = payload.get("changed_paths")
+ if not isinstance(receipt_paths, list) or not all(
+ isinstance(path, str) and path for path in receipt_paths
+ ):
+ errors.append("changed_paths must be a non-empty string array")
+ elif sorted(set(receipt_paths)) != sorted(set(changed_paths)):
+ errors.append("changed_paths must exactly match staged user-visible frontend source files")
+
+ if payload.get("content_sha256") != expected_content_sha256:
+ errors.append("content_sha256 must exactly match the final staged frontend source content")
+
+ routes = payload.get("routes")
+ if not isinstance(routes, list) or not routes or not all(
+ isinstance(route, str) and route.strip() for route in routes
+ ):
+ errors.append("routes must be a non-empty string array")
+
+ states = payload.get("states")
+ if not isinstance(states, list) or not states or not all(
+ isinstance(state, str) and state.strip() for state in states
+ ):
+ errors.append("states must be a non-empty string array")
+
+ interactions = payload.get("interactions")
+ if not isinstance(interactions, list) or not interactions or not all(
+ isinstance(interaction, str) and interaction.strip() for interaction in interactions
+ ):
+ errors.append("interactions must be a non-empty string array")
+
+ viewports = payload.get("viewports")
+ valid_viewports: list[dict] = []
+ if isinstance(viewports, list):
+ valid_viewports = [
+ viewport
+ for viewport in viewports
+ if isinstance(viewport, dict)
+ and isinstance(viewport.get("width"), int)
+ and viewport["width"] > 0
+ and isinstance(viewport.get("height"), int)
+ and viewport["height"] > 0
+ ]
+ if len(valid_viewports) != len(viewports or []) or not valid_viewports:
+ errors.append("viewports must contain valid positive integer width/height objects")
+ else:
+ if not any(viewport["width"] >= 1024 for viewport in valid_viewports):
+ errors.append("viewports must include a desktop width of at least 1024 pixels")
+ if not any(viewport["width"] <= 768 for viewport in valid_viewports):
+ errors.append("viewports must include a narrow width of at most 768 pixels")
+
+ verified_at = payload.get("verified_at")
+ if not isinstance(verified_at, str) or not verified_at.endswith("Z"):
+ errors.append("verified_at must be an ISO-8601 UTC timestamp ending in Z")
+ else:
+ try:
+ datetime.fromisoformat(verified_at.removesuffix("Z") + "+00:00")
+ except ValueError:
+ errors.append("verified_at must be a valid ISO-8601 UTC timestamp")
+
+ return errors
+
+
+def build_template(paths: Sequence[str], *, repo_root: Path = REPO_ROOT) -> dict:
+ changed_paths = frontend_runtime_paths(paths)
+ return {
+ "version": 1,
+ "base_sha": expected_base_sha(commit=None, repo_root=repo_root),
+ "verified_at": "YYYY-MM-DDTHH:MM:SSZ",
+ "result": "replace-with-passed-after-verification",
+ "changed_paths": changed_paths,
+ "content_sha256": content_sha256(changed_paths, commit=None, repo_root=repo_root),
+ "routes": ["/replace-with-verified-route"],
+ "viewports": [
+ {"width": 1280, "height": 800},
+ {"width": 390, "height": 844},
+ ],
+ "states": ["replace with every state inspected"],
+ "interactions": ["replace with every interaction exercised"],
+ }
+
+
+def parse_args(argv: Sequence[str] | None = None) -> argparse.Namespace:
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument(
+ "--files-from-stdin",
+ action="store_true",
+ help="Read the changed path list from stdin instead of the staged index.",
+ )
+ parser.add_argument(
+ "--commit",
+ help="Validate the receipt stored in this commit against that commit's parent.",
+ )
+ parser.add_argument(
+ "--print-template",
+ action="store_true",
+ help="Print a non-passing receipt template for the current staged frontend paths.",
+ )
+ return parser.parse_args(argv)
+
+
+def main(argv: Sequence[str] | None = None) -> int:
+ args = parse_args(argv)
+ paths = stdin_files(sys.stdin) if args.files_from_stdin else staged_files()
+
+ if args.print_template:
+ print(json.dumps(build_template(paths), indent=2))
+ return 0
+
+ changed_frontend_paths = frontend_runtime_paths(paths)
+ if not changed_frontend_paths:
+ print("Browser verification guard skipped (no user-visible frontend source changes).")
+ return 0
+
+ if RECEIPT_PATH not in paths:
+ print(
+ f"BLOCKED: {RECEIPT_PATH} must be updated and staged for user-visible frontend changes.",
+ file=sys.stderr,
+ )
+ print(
+ "Run the current build in a browser, exercise the complete interaction matrix, "
+ "then record routes, desktop and narrow viewports, states, and interactions.",
+ file=sys.stderr,
+ )
+ return 1
+
+ try:
+ payload = json.loads(load_receipt_text(commit=args.commit))
+ expected_base = expected_base_sha(commit=args.commit)
+ except (json.JSONDecodeError, subprocess.CalledProcessError) as exc:
+ print(f"BLOCKED: unable to load browser verification receipt: {exc}", file=sys.stderr)
+ return 1
+
+ errors = validate_receipt(
+ payload,
+ changed_paths=changed_frontend_paths,
+ expected_base=expected_base,
+ expected_content_sha256=content_sha256(
+ changed_frontend_paths,
+ commit=args.commit,
+ ),
+ )
+ if errors:
+ print("BLOCKED: browser verification receipt is invalid:", file=sys.stderr)
+ for error in errors:
+ print(f" - {error}", file=sys.stderr)
+ return 1
+
+ print(
+ "Browser verification guard passed "
+ f"({len(changed_frontend_paths)} frontend source file(s), "
+ f"{len(payload['routes'])} route(s), {len(payload['viewports'])} viewport(s))."
+ )
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/scripts/release_control/browser_verification_guard_test.py b/scripts/release_control/browser_verification_guard_test.py
new file mode 100644
index 0000000000..9c2bbd7bbc
--- /dev/null
+++ b/scripts/release_control/browser_verification_guard_test.py
@@ -0,0 +1,120 @@
+#!/usr/bin/env python3
+
+from __future__ import annotations
+
+from io import StringIO
+import unittest
+from unittest.mock import patch
+
+from browser_verification_guard import (
+ RECEIPT_PATH,
+ frontend_runtime_paths,
+ main,
+ validate_receipt,
+)
+
+
+BASE_SHA = "a" * 40
+CHANGED_PATH = "frontend-modern/src/components/Example.tsx"
+CONTENT_SHA = "c" * 64
+
+
+def valid_receipt() -> dict:
+ return {
+ "version": 1,
+ "base_sha": BASE_SHA,
+ "verified_at": "2026-08-02T20:15:00Z",
+ "result": "passed",
+ "changed_paths": [CHANGED_PATH],
+ "content_sha256": {CHANGED_PATH: CONTENT_SHA},
+ "routes": ["/proxmox/overview"],
+ "viewports": [
+ {"width": 1280, "height": 800},
+ {"width": 390, "height": 844},
+ ],
+ "states": ["toolbar closed", "View menu open", "Columns disclosure open"],
+ "interactions": ["Open View, open Columns, dismiss with Escape"],
+ }
+
+
+class BrowserVerificationGuardTest(unittest.TestCase):
+ def test_blocks_frontend_change_when_receipt_is_not_in_commit(self) -> None:
+ with (
+ patch("sys.stdin", StringIO(CHANGED_PATH + "\n")),
+ patch("sys.stderr", new=StringIO()),
+ ):
+ self.assertEqual(main(["--files-from-stdin"]), 1)
+
+ def test_frontend_runtime_paths_exclude_tests_and_receipt(self) -> None:
+ self.assertEqual(
+ frontend_runtime_paths(
+ [
+ CHANGED_PATH,
+ "frontend-modern/src/components/Example.test.tsx",
+ "frontend-modern/src/components/__tests__/Example.tsx",
+ RECEIPT_PATH,
+ "frontend-modern/index.html",
+ "internal/api/server.go",
+ ]
+ ),
+ ["frontend-modern/index.html", CHANGED_PATH],
+ )
+
+ def test_accepts_receipt_bound_to_changed_paths_and_two_viewports(self) -> None:
+ self.assertEqual(
+ validate_receipt(
+ valid_receipt(),
+ changed_paths=[CHANGED_PATH],
+ expected_base=BASE_SHA,
+ expected_content_sha256={CHANGED_PATH: CONTENT_SHA},
+ ),
+ [],
+ )
+
+ def test_rejects_stale_base_and_incomplete_changed_path_coverage(self) -> None:
+ receipt = valid_receipt()
+ receipt["base_sha"] = "b" * 40
+ receipt["changed_paths"] = ["frontend-modern/src/components/Other.tsx"]
+
+ errors = validate_receipt(
+ receipt,
+ changed_paths=[CHANGED_PATH],
+ expected_base=BASE_SHA,
+ expected_content_sha256={CHANGED_PATH: CONTENT_SHA},
+ )
+
+ self.assertTrue(any("base_sha" in error for error in errors))
+ self.assertTrue(any("changed_paths" in error for error in errors))
+
+ def test_rejects_dom_only_proof_without_states_interactions_or_narrow_viewport(self) -> None:
+ receipt = valid_receipt()
+ receipt["viewports"] = [{"width": 1280, "height": 800}]
+ receipt["states"] = []
+ receipt["interactions"] = []
+
+ errors = validate_receipt(
+ receipt,
+ changed_paths=[CHANGED_PATH],
+ expected_base=BASE_SHA,
+ expected_content_sha256={CHANGED_PATH: CONTENT_SHA},
+ )
+
+ self.assertTrue(any("narrow width" in error for error in errors))
+ self.assertTrue(any("states" in error for error in errors))
+ self.assertTrue(any("interactions" in error for error in errors))
+
+ def test_rejects_source_content_changed_after_browser_verification(self) -> None:
+ receipt = valid_receipt()
+
+ errors = validate_receipt(
+ receipt,
+ changed_paths=[CHANGED_PATH],
+ expected_base=BASE_SHA,
+ expected_content_sha256={CHANGED_PATH: "d" * 64},
+ )
+
+ self.assertTrue(any("content_sha256" in error for error in errors))
+
+
+if __name__ == "__main__":
+ unittest.main()