feat: resume Human Gate evidence reviews (Closes #1435)
CI / lint (pull_request) Successful in 4m12s
CI / build-release (pull_request) Successful in 7s
CI / browser-journey (pull_request) Successful in 7m38s
CI / release-candidate (pull_request) Has been skipped

This commit is contained in:
timmy committed 2026-08-26 15:16:03 +00:00
1 parent 1e9c3444fa
commit aba217f89b
16 files changed
+214 -40

No files matched your search

+37 -2
View File
@@ -27,6 +27,7 @@ def test_release_artifact_reopens_human_gates_with_one_fresh_mobile_snapshot(
fake_thread = threading.Thread(target=fake.serve_forever, daemon=True)
fake_thread.start()
current = {"gate": "g1"}
evidence_url = {"value": "/evidence/manifest"}
list_requests: list[str] = []
browser_errors: list[str] = []
@@ -39,7 +40,7 @@ def test_release_artifact_reopens_human_gates_with_one_fresh_mobile_snapshot(
"revision": 1,
"priority": 5,
"checks": [],
"artifacts": [],
"artifacts": [{"name": "Signed manifest", "url": evidence_url["value"]}],
"links": [],
"provenance": {},
"history": [],
@@ -49,6 +50,7 @@ def test_release_artifact_reopens_human_gates_with_one_fresh_mobile_snapshot(
with release_server(
archives[0], tmp_path, f"http://127.0.0.1:{fake.server_port}"
) as origin, sync_playwright() as playwright:
evidence_url["value"] = origin + "/evidence/manifest"
browser = playwright.chromium.launch(args=["--ignore-certificate-errors"])
context = browser.new_context(
viewport={"width": width, "height": height}, ignore_https_errors=True
@@ -58,7 +60,9 @@ def test_release_artifact_reopens_human_gates_with_one_fresh_mobile_snapshot(
def human_gates_route(route):
path = route.request.url.split("?", 1)[0]
if path.endswith("/api/v1/human-gates"):
if route.request.method == "POST":
payload = {"receipt_id": "receipt-1", "state": "released"}
elif path.endswith("/api/v1/human-gates"):
list_requests.append(current["gate"])
payload = {"pending_count": 1, "items": [gate(current["gate"])]}
else:
@@ -66,6 +70,7 @@ def test_release_artifact_reopens_human_gates_with_one_fresh_mobile_snapshot(
route.fulfill(status=200, content_type="application/json", body=json.dumps(payload))
page.route("**/api/v1/human-gates**", human_gates_route)
page.route("**/api/v1/human-gates/**", human_gates_route)
page.goto(origin + "/", wait_until="networkidle")
page.locator('input[name="device_label"]').fill("Human Gates release phone")
page.locator('input[name="access_token"]').fill(ACCESS_TOKEN)
@@ -75,6 +80,36 @@ def test_release_artifact_reopens_human_gates_with_one_fresh_mobile_snapshot(
page.evaluate("document.querySelector('#open-human-gates').click()")
expect(page.locator("#human-gates")).to_be_visible()
expect(page.locator("#human-gate-detail")).to_contain_text("First candidate")
page.locator('[data-gate-checklist="exact_hash"]').check()
page.locator('[data-gate-checklist="artifacts_reviewed"]').check()
page.locator('[data-gate-checklist="provenance_reviewed"]').check()
page.locator("[data-gate-reason]").fill("Awaiting final approval")
with page.expect_popup() as popup_info:
page.get_by_role("link", name="Signed manifest").click()
popup = popup_info.value
popup.wait_for_load_state("domcontentloaded")
assert not page.url.endswith("/evidence/manifest")
expect(page.locator("#human-gates")).to_be_visible()
expect(page.locator("#human-gate-detail")).to_contain_text("First candidate")
popup.close()
page.reload(wait_until="networkidle")
page.evaluate("document.querySelector('#open-human-gates').click()")
expect(page.locator("#human-gates")).to_be_visible()
expect(page.locator('[data-gate-checklist="exact_hash"]')).to_be_checked()
expect(page.locator('[data-gate-checklist="artifacts_reviewed"]')).to_be_checked()
expect(page.locator('[data-gate-checklist="provenance_reviewed"]')).to_be_checked()
expect(page.locator("[data-gate-reason]")).to_have_value("Awaiting final approval")
progress_key = page.evaluate(
"Object.keys(localStorage).find(key => key.startsWith('stackchain.human-gate-review.v1:'))"
)
assert progress_key and progress_key.endswith(":g1:1")
assert page.evaluate("key => localStorage.getItem(key) !== null", progress_key)
page.locator('[data-gate-decision="release"]').click()
expect(page.locator("#human-gates-status")).to_contain_text("Decision saved")
assert not page.evaluate("key => localStorage.getItem(key) !== null", progress_key)
page.evaluate("document.querySelector('#close-human-gates').click()")
before_reopen = len(list_requests)