ci/woodpecker/push/woodpecker Pipeline was successful
Replace the retired rc.2 Analysis v2/Trace v2/Execution Events v1 stack with the
single current contract family:
- Analysis v3 (ADR-0069 public boundary): one check --emit artifact carries the
exact source, Markdown AST, heading scopes (heading_span + complete span),
anchors, state-bearing references, calls, resources and diagnostics; the old
revision-3 shape is rejected with a rebuild hint.
- Observation v1: one run/call --output jsonl stream (+ atomic
--observation-file snapshot) decoded by one decoder and projected into the
reader/SSE/export layers; stale/malformed/truncated/incomplete never render
as success.
- CLI Tool revision 1: requires {api_revision:1, analysis:3, observation:1},
product range >=3.0.0-rc.3,<4.0.0, only MARQDO_BIN and
MARQDO_API_REVISION are consumed.
- Remove compatibility branches, retired flags/env vars and duplicate decoders;
re-record Analysis v3 and Observation v1 fixtures; rewrite contract,
integration and security tests (173 passing locally).
- Add check-no-legacy/check-docs/check-observation gates, rc.4 pins in the
CI pipelines, 0.3.0 Tool bundle and evidence manifest support.
See issues #4, #5 and #6; acceptance baseline is CLI source
452e9a32bd9e40dba427d4180691c58bab74449e, archive
9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8.
93 lines
3.3 KiB
Python
Executable File
93 lines
3.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Explicit real-run acceptance over the frozen CLI + Live SSE server.
|
|
|
|
Usage: python3 scripts/acceptance-run.py http://127.0.0.1:PORT/
|
|
Prints a PASS line and exits non-zero on any failure. Never polls: it creates
|
|
one run, observes one SSE stream until the single terminal event, and asserts
|
|
the verified Observation v1 binding (source analysis digest, contiguous seq,
|
|
unique terminal) instead of any retired trace protocol.
|
|
"""
|
|
import http.cookiejar
|
|
import json
|
|
import re
|
|
import sys
|
|
import urllib.request
|
|
|
|
url = sys.argv[1]
|
|
origin = url.rstrip("/")
|
|
jar = http.cookiejar.CookieJar()
|
|
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(jar))
|
|
|
|
|
|
def get(path):
|
|
with opener.open(origin + path, timeout=30) as response:
|
|
return response.read().decode("utf-8")
|
|
|
|
|
|
page = get("/")
|
|
csrf = re.search(r'name="mq-csrf-token" content="([0-9a-f]+)"', page)
|
|
assert csrf, "csrf token missing"
|
|
digest = re.search(r'data-analysis-digest="(sha256:[0-9a-f]{64})"', page)
|
|
assert digest, "analysis digest missing"
|
|
body = json.dumps({
|
|
"document": "index.mq.md",
|
|
"target": {"kind": "entry"},
|
|
"parameters": [],
|
|
"analysis_digest": digest.group(1),
|
|
"mode": "pure",
|
|
"grants": {"read": [], "write": []},
|
|
"client_request_id": "acceptance-real-run-1",
|
|
}).encode()
|
|
request = urllib.request.Request(
|
|
origin + "/api/runs",
|
|
data=body,
|
|
headers={
|
|
"Content-Type": "application/json",
|
|
"Origin": origin,
|
|
"X-View-CSRF": csrf.group(1),
|
|
},
|
|
method="POST",
|
|
)
|
|
with opener.open(request, timeout=60) as response:
|
|
assert response.status == 202, response.status
|
|
accepted = json.loads(response.read().decode("utf-8"))
|
|
assert accepted["state"] == "accepted", accepted
|
|
events_url = origin + accepted["events_url"]
|
|
terminal = None
|
|
with opener.open(events_url, timeout=120) as stream:
|
|
data_lines = []
|
|
for raw in stream:
|
|
line = raw.decode("utf-8").rstrip("\n")
|
|
if line.startswith("data: "):
|
|
data_lines.append(line[6:])
|
|
elif line == "" and data_lines:
|
|
event = json.loads("\n".join(data_lines))
|
|
data_lines = []
|
|
if event.get("state") in (
|
|
"succeeded",
|
|
"failed",
|
|
"cancelled",
|
|
"timed_out",
|
|
"unavailable",
|
|
):
|
|
terminal = event
|
|
break
|
|
assert terminal is not None, "no terminal SSE event"
|
|
assert terminal["state"] == "succeeded", terminal
|
|
assert terminal["result"]["success"] is True, terminal["result"]
|
|
assert terminal["result"]["observation_status"] == "verified", terminal["result"]
|
|
assert terminal["result"]["observation_protocol"] == 1, terminal["result"]
|
|
assert terminal["result"]["observation_truncated"] is False, terminal["result"]
|
|
summary = terminal.get("observation_summary") or terminal["result"].get("observation_summary")
|
|
assert summary is not None, "missing observation summary"
|
|
assert summary.get("status") in ("verified", "ok"), summary
|
|
event_count = 0
|
|
if isinstance(summary.get("events"), list):
|
|
event_count = len(summary["events"])
|
|
elif isinstance(summary.get("counts"), dict):
|
|
event_count = sum(int(value) for value in summary["counts"].values())
|
|
print(
|
|
"explicit real run: PASS (run_id=%s observation=%s events=%d)"
|
|
% (accepted["run_id"], terminal["result"]["observation_status"], event_count)
|
|
)
|