feat: migrate View 0.3.0 to marqdo 3.0.0-rc.4 contracts
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.
This commit is contained in:
Marqdo View committed 2026-11-25 21:58:15 +08:00
1 parent 7b34199c96
commit a802f96b6e
109 files changed
+14000 -6461

No files matched your search

+15 -4
View File
@@ -4,7 +4,8 @@
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 Trace binding.
the verified Observation v1 binding (source analysis digest, contiguous seq,
unique terminal) instead of any retired trace protocol.
"""
import http.cookiejar
import json
@@ -74,8 +75,18 @@ with opener.open(events_url, timeout=120) as stream:
assert terminal is not None, "no terminal SSE event"
assert terminal["state"] == "succeeded", terminal
assert terminal["result"]["success"] is True, terminal["result"]
assert terminal["trace"]["status"] == "verified", terminal.get("trace")
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 events=%d)"
% (accepted["run_id"], len(terminal["trace"]["events"]))
"explicit real run: PASS (run_id=%s observation=%s events=%d)"
% (accepted["run_id"], terminal["result"]["observation_status"], event_count)
)
+385 -157
View File
@@ -1,15 +1,20 @@
#!/usr/bin/env bash
# RFC-VIEW-0002 §9.4 one-command acceptance.
# marqdo-view 0.3.0 one-command acceptance for the rc.4 contract baseline
# (adaptation issue #4, acceptance gates G01-G12 from issue #5, public Analysis
# boundary issue #6).
#
# Usage:
# MARQDO_BIN=/abs/path/to/frozen/marqdo scripts/acceptance.sh
#
# Optional:
# VIEW_EVIDENCE_OUT=path override dist/acceptance/manifest.json
# SKIP_BROWSER=1 skip Chromium suite (recorded as SKIP, not PASS)
# VIEW_EVIDENCE_OUT=path primary manifest path
# (default docs/evidence/<CLI-SOURCE-SHA>/manifest.json)
# SKIP_BROWSER=1 skip the Chromium suite (recorded as SKIP, not PASS)
#
# The script never modifies or recompiles the frozen CLI; it records its
# SHA-256 before and after and fails if it changes.
# SHA-256 before and after and fails if it changes. A gate that cannot be
# judged from this environment is recorded as UNVERIFIED with a reason; it is
# never written as PASS.
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -22,33 +27,196 @@ export MARQDO_BIN
"$repo_root/scripts/frozen-beta.sh" verify "$MARQDO_BIN"
export MARQDO_FROZEN_BIN="$MARQDO_BIN"
metadata="$("$repo_root/scripts/frozen-beta.sh" metadata)"
cli_version="$(sed -n 's/^version=//p' <<<"$metadata")"
cli_source_sha="$(sed -n 's/^source_sha=//p' <<<"$metadata")"
cli_binary_sha="$(sed -n 's/^binary_sha=//p' <<<"$metadata")"
cli_archive_sha="$(sed -n 's/^archive_sha=//p' <<<"$metadata")"
work="$repo_root/dist/acceptance"
rm -rf "$work"
mkdir -p "$work"
mkdir -p "$work/logs"
statuses=""
record() { statuses+="$1=$2"$'\n'; echo "[acceptance] $1: $2"; }
declare -A gate_state=() gate_cmd=() gate_exit=() gate_log=() gate_note=()
gate_ids=(
G01_no_legacy G02_build G03_install G04_static G05_run G06_stream_snapshot
G07_binding_stale G08_negative G09_security G10_export G11_evidence_ci G12_docs
)
run_step() {
local name="$1"
shift
echo "==> $name"
if "$@"; then
record "$name" PASS
gate_run() {
local id="$1" label="$2" command="$3"
local log="$work/logs/$id.log" status
echo "==> [$id] $label"
set +e
bash -c "$command" 2>&1 | tee "$log"
status=${PIPESTATUS[0]}
set -e
gate_cmd[$id]="$command"
gate_exit[$id]="$status"
gate_log[$id]="${log#"$repo_root"/}"
if [[ "$status" -eq 0 ]]; then
gate_state[$id]=PASS
gate_note[$id]=""
else
record "$name" FAIL
return 1
gate_state[$id]=FAIL
gate_note[$id]="command exited $status; see log"
fi
return 0
}
core_before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
cli_source_sha="$(cat "$(dirname "$MARQDO_BIN")/SOURCE_SHA")"
view_source_sha="$(git rev-parse HEAD 2>/dev/null || echo unknown)"
gate_unverified() {
local id="$1" command="$2" note="$3"
echo "==> [$id] UNVERIFIED: $note"
gate_state[$id]=UNVERIFIED
gate_cmd[$id]="$command"
gate_exit[$id]=""
gate_log[$id]=""
gate_note[$id]="$note"
}
fail_now() {
local id="$1" note="$2"
echo "error: [$id] $note" >&2
gate_state[$id]=FAIL
gate_note[$id]="$note"
finish 1
}
finish() {
local requested="${1:-0}" state result unverified=()
for id in "${gate_ids[@]}"; do
if [[ -z "${gate_state[$id]:-}" ]]; then
gate_state[$id]=UNVERIFIED
gate_note[$id]="not reached because an earlier gate failed"
gate_log[$id]=""
gate_exit[$id]=""
fi
[[ "${gate_state[$id]}" == "UNVERIFIED" ]] && unverified+=("$id")
done
result=PASS
for id in "${gate_ids[@]}"; do
[[ "${gate_state[$id]}" == "FAIL" ]] && result=FAIL
done
if [[ "$result" != "FAIL" && ${#unverified[@]} -gt 0 ]]; then
result=PARTIAL
fi
local bundle_sha sums_sha test_count browser_state
bundle_sha="$(sha256sum "${bundle:-/nonexistent}/bin/marqdo-view" 2>/dev/null | cut -d' ' -f1 || true)"
sums_sha="$(sha256sum "${bundle:-/nonexistent}/SHA256SUMS" 2>/dev/null | cut -d' ' -f1 || true)"
[[ -n "$bundle_sha" ]] || bundle_sha="unavailable"
[[ -n "$sums_sha" ]] || sums_sha="unavailable"
test_count="${cargo_test_count:-0}"
browser_state="${browser_state:-UNVERIFIED}"
: >"$work/gates.tsv"
for id in "${gate_ids[@]}"; do
printf '%s\t%s\t%s\t%s\t%s\t%s\n' \
"$id" "${gate_state[$id]}" "${gate_exit[$id]:-}" "${gate_cmd[$id]:-}" \
"${gate_log[$id]:-}" "${gate_note[$id]:-}" >>"$work/gates.tsv"
done
: >"$work/unverified.txt"
for id in "${unverified[@]}"; do printf '%s\n' "$id" >>"$work/unverified.txt"; done
local evidence_path="${VIEW_EVIDENCE_OUT:-$repo_root/docs/evidence/$cli_source_sha/manifest.json}"
mkdir -p "$(dirname "$evidence_path")"
# Logs referenced by the manifest must live beside it, not in a git-ignored
# build directory.
local evidence_logs="$(dirname "$evidence_path")/logs"
rm -rf "$evidence_logs"
cp -R "$work/logs" "$evidence_logs" 2>/dev/null || true
mkdir -p "$evidence_logs"
python3 - "$work/gates.tsv" "$work/unverified.txt" "$evidence_path" \
"$work/manifest.json" "$cli_version" "$cli_source_sha" "$cli_binary_sha" \
"$cli_archive_sha" "$bundle_sha" "$sums_sha" "$result" "$test_count" \
"$browser_state" <<'PY_MANIFEST'
import datetime
import json
import pathlib
import subprocess
import sys
(gates_path, unverified_path, evidence_path, dist_path, cli_version,
cli_source_sha, cli_binary_sha, cli_archive_sha, view_binary_sha,
bundle_sha, result, test_count, browser_state) = sys.argv[1:]
repo = pathlib.Path.cwd()
gates = {}
for line in pathlib.Path(gates_path).read_text().splitlines():
gate_id, state, exit_code, command, log, note = line.split("\t")
entry = {"state": state, "command": command, "exit_code": int(exit_code) if exit_code else None}
if log:
prefix = "dist/acceptance/logs/"
if log.startswith(prefix):
log = f"docs/evidence/{cli_source_sha}/logs/{log[len(prefix):]}"
entry["log"] = log
if note:
entry["note"] = note
gates[gate_id] = entry
unverified = [line for line in pathlib.Path(unverified_path).read_text().splitlines() if line]
try:
view_commit = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True).stdout.strip()
except Exception:
view_commit = "unknown"
tool = json.loads((repo / "tool.json").read_text())
manifest = {
"schema": "marqdo.view.acceptance",
"schema_version": 1,
"product": {"name": "marqdo-view", "version": tool["version"], "target": "linux-x86_64-glibc2.39"},
"view_commit": view_commit,
"view_binary_sha256": "sha256:" + view_binary_sha,
"view_tool_bundle_digest": "sha256:" + bundle_sha,
"view_tool_bundle_digest_method": "sha256 of the canonical SHA256SUMS file bytes in the bundle",
"cli_version": cli_version,
"cli_source_sha": cli_source_sha,
"cli_archive_sha256": "sha256:" + cli_archive_sha,
"cli_binary_sha256": "sha256:" + cli_binary_sha,
"contracts": {"api_revision": 1, "analysis": 3, "observation": 1},
"markdown_profile": "marqdo.md.v1",
"product_range": ">=3.0.0-rc.3,<4.0.0",
"platform": "linux-x86_64-glibc2.39",
"generated_utc": datetime.datetime.now(datetime.timezone.utc).isoformat(),
"result": result,
"gates": gates,
"unverified": unverified,
"extras": {
"cargo_tests_passed": int(test_count),
"browser": browser_state,
"notes": "Generated from real command exit statuses. UNVERIFIED gates are not release evidence and must never be read as PASS.",
},
}
text = json.dumps(manifest, indent=2, sort_keys=True) + "\n"
pathlib.Path(evidence_path).write_text(text)
pathlib.Path(dist_path).write_text(text)
print("evidence manifest:", evidence_path)
PY_MANIFEST
echo
echo "acceptance: $result"
if [[ ${#unverified[@]} -gt 0 ]]; then
echo "unverified: ${unverified[*]}"
fi
echo "evidence: $evidence_path"
echo "cli: marqdo $cli_version source=$cli_source_sha archive=sha256:$cli_archive_sha"
echo "gate states:"
for id in "${gate_ids[@]}"; do
printf ' %-20s %s\n' "$id" "${gate_state[$id]}"
done
if [[ "$result" == "FAIL" || "$requested" -ne 0 ]]; then
exit 1
fi
exit 0
}
export PATH="${HOME}/.cargo/bin:${PATH}"
export CARGO_HOME="${CARGO_HOME:-$repo_root/.cargo-home}"
# 0. code quality / unit / contract tests
core_before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
if [[ "$core_before" != "$cli_binary_sha" ]]; then
echo "error: frozen CLI sha256 $core_before does not match pinned $cli_binary_sha" >&2
exit 1
fi
# A wrong CLI must fail the frozen identity check before any command runs.
check_wrong_cli() {
mkdir -p "$work/wrong-cli"
cp "$(dirname "$MARQDO_BIN")/SOURCE_SHA" "$work/wrong-cli/SOURCE_SHA"
@@ -63,43 +231,105 @@ FAKE
fi
test ! -e "$work/wrong-cli/executed"
}
run_step wrong_cli_refused check_wrong_cli
run_step fmt cargo fmt --all -- --check
run_step clippy cargo clippy --locked --all-targets -- -D warnings
run_step test cargo test --locked
run_step build cargo build --release --locked
if ! check_wrong_cli; then
echo "error: wrong-CLI refusal regression failed" >&2
exit 1
fi
# 1. controlled Tool bundle + frozen-CLI install smoke
run_step bundle env MARQDO_BIN="$MARQDO_BIN" ./scripts/package.sh
# ---------------------------------------------------------------- gates ----
gate_run G01_no_legacy "no retired contracts in src/tool.json/current docs" "./scripts/check-no-legacy.sh"
gate_run G12_docs "current docs describe the rc.4 baseline" "./scripts/check-docs.sh"
gate_run G02_build "fmt, clippy, tests and release build" \
"cargo fmt --all -- --check && cargo clippy --locked --all-targets -- -D warnings && cargo test --locked && cargo build --release --locked"
cargo_test_count="$(grep -hE 'test result: ok\. [0-9]+ passed' "$work/logs/G02_build.log" | awk '{sum += $4} END {print sum + 0}')"
if [[ "${gate_state[G02_build]}" != "PASS" ]]; then
finish 1
fi
# G03: package, clean archive install and dispatch only through the frozen CLI.
echo "==> [G03_install] package + archive install + tool dispatch"
if ! env MARQDO_BIN="$MARQDO_BIN" ./scripts/package.sh >"$work/logs/G03_package.log" 2>&1; then
gate_state[G03_install]=FAIL
gate_cmd[G03_install]="./scripts/package.sh"
gate_exit[G03_install]=1
gate_log[G03_install]="${work#"$repo_root"/}/logs/G03_package.log"
finish 1
fi
bundle="$repo_root/dist/marqdo-view"
read -r version target < <(python3 -c 'import json; p=json.load(open("dist/marqdo-view/RELEASE_INFO.json")); print(p["tool_version"], p["target"])')
archive="$repo_root/dist/marqdo-view-$version-$target.tar.gz"
archive_sha="$(sha256sum "$archive" | cut -d' ' -f1)"
# 2. clean install from the *archive*, in a moved temporary directory
dist_archive="$repo_root/dist/marqdo-view-$version-$target.tar.gz"
archive_sha="$(sha256sum "$dist_archive" | cut -d' ' -f1)"
mkdir -p "$work/extracted"
tar -xzf "$archive" -C "$work/extracted"
tar -xzf "$dist_archive" -C "$work/extracted"
extracted_bundle="$work/extracted/marqdo-view"
(cd "$extracted_bundle" && sha256sum -c SHA256SUMS)
(cd "$extracted_bundle" && sha256sum -c SHA256SUMS >>"$work/logs/G03_install.log" 2>&1)
tool_home="$work/tool-home"
mkdir -p "$tool_home"
export MARQDO_TOOL_HOME="$tool_home"
export VIEW_USE_INSTALLED_TOOL=1
run_step archive_install "$MARQDO_BIN" tool install "$extracted_bundle/tool.json"
check_tool_list() {
grep -q '^view ' <<<"$("$MARQDO_BIN" tool list)"
}
check_view_help() {
grep -q 'marqdo-view' <<<"$("$MARQDO_BIN" view --help)"
}
run_step tool_list check_tool_list
run_step view_help check_view_help
run_step verify "$MARQDO_BIN" view verify examples/mixed-modes/index.mq.md
run_step export "$MARQDO_BIN" view export examples/control-flow --out "$work/site"
run_step examples_check env MARQDO_BIN="$MARQDO_BIN" ./scripts/check-examples.sh
test -f "$work/site/manifest.json"
install_ok=1
{
echo "== bundle digest: sha256:$(sha256sum "$bundle/SHA256SUMS" | cut -d' ' -f1)"
"$MARQDO_BIN" tool install "$extracted_bundle/tool.json"
"$MARQDO_BIN" tool list
"$MARQDO_BIN" view --help
MARQDO_BIN="$MARQDO_BIN" ./scripts/install-smoke.sh "$bundle/tool.json"
} >>"$work/logs/G03_install.log" 2>&1 || install_ok=0
if [[ "$install_ok" -eq 1 ]]; then
printf 'x' >>"$tool_home/view/README.md" 2>/dev/null || true
if "$MARQDO_BIN" view --version >"$work/logs/G03_tamper.log" 2>&1; then
install_ok=0
echo "error: tampered installed tool was dispatched" >>"$work/logs/G03_tamper.log"
elif ! grep -q 'bundle hash mismatch' "$work/logs/G03_tamper.log"; then
install_ok=0
echo "error: tamper refusal did not report a bundle hash mismatch" >>"$work/logs/G03_tamper.log"
fi
"$MARQDO_BIN" tool remove view >>"$work/logs/G03_install.log" 2>&1 || install_ok=0
if "$MARQDO_BIN" view --version >>"$work/logs/G03_install.log" 2>&1; then
install_ok=0
echo "error: removed tool still dispatched" >>"$work/logs/G03_install.log"
fi
fi
if [[ "$install_ok" -eq 1 ]]; then
# Reinstall the clean bundle for the remaining gates (the removal test above
# intentionally deregistered the command).
if ! "$MARQDO_BIN" tool install "$extracted_bundle/tool.json" >>"$work/logs/G03_install.log" 2>&1; then
install_ok=0
echo "error: could not reinstall the clean Tool bundle" >>"$work/logs/G03_install.log"
fi
fi
if [[ "$install_ok" -eq 1 ]]; then
gate_state[G03_install]=PASS
else
gate_state[G03_install]=FAIL
fi
gate_cmd[G03_install]="scripts/package.sh && marqdo tool install/list/remove && marqdo view --help && scripts/install-smoke.sh && tamper refusal"
gate_exit[G03_install]=$(( install_ok == 1 ? 0 : 1 ))
gate_log[G03_install]="${work#"$repo_root"/}/logs/G03_install.log"
gate_note[G03_install]="$([[ "$install_ok" -eq 1 ]] && echo "" || echo "see G03_install.log")"
if [[ "$install_ok" -ne 1 ]]; then
finish 1
fi
# Tool dispatch starts View as a child. Keep both in one disposable group.
gate_run G04_static "static contract: view verify + Analysis v3 examples" \
"\"$MARQDO_BIN\" view verify examples/mixed-modes/index.mq.md && MARQDO_BIN=\"$MARQDO_BIN\" ./scripts/check-examples.sh"
# G05: live browse + one explicit real run through the installed Tool and SSE.
echo "==> [G05_run] live browse + explicit real run"
run_ok=1
start_server() {
local project="$1" log="$2"
setsid "$MARQDO_BIN" view "$project" --port 0 --no-open >"$log" 2>&1 &
server_pid=$!
local url=""
for _ in $(seq 1 100); do
url="$(grep -o 'http://127.0.0.1:[0-9]*/' "$log" | head -1 || true)"
[[ -n "$url" ]] && break
sleep 0.1
done
printf '%s\n' "$url"
}
server_pid=""
stop_server() {
if [[ -n "$server_pid" ]]; then
@@ -109,133 +339,131 @@ stop_server() {
fi
}
trap stop_server EXIT
# 3. Live browse smoke (no execution on open)
browse_log="$work/browse.log"
setsid "$MARQDO_BIN" view examples/welcome --port 0 --no-open >"$browse_log" 2>&1 &
server_pid=$!
browse_url=""
for _ in $(seq 1 100); do
browse_url="$(grep -o 'http://127.0.0.1:[0-9]*/' "$browse_log" | head -1 || true)"
[[ -n "$browse_url" ]] && break
sleep 0.1
done
browse_url="$(start_server examples/welcome "$work/browse.log")"
if [[ -n "$browse_url" ]] && curl -sf "${browse_url}api/documents" | grep -q '"schema": "marqdo.view-documents"'; then
record browse PASS
echo "browse: PASS" >>"$work/logs/G05_run.log"
else
record browse FAIL
cat "$browse_log" >&2
exit 1
run_ok=0
echo "browse: FAIL" >>"$work/logs/G05_run.log"
cat "$work/browse.log" >>"$work/logs/G05_run.log" 2>&1 || true
fi
stop_server
# 4. Explicit real run through the installed tool + CSRF flow
run_log="$work/run.log"
setsid "$MARQDO_BIN" view examples/control-flow --port 0 --no-open >"$run_log" 2>&1 &
server_pid=$!
run_url=""
for _ in $(seq 1 100); do
run_url="$(grep -o 'http://127.0.0.1:[0-9]*/' "$run_log" | head -1 || true)"
[[ -n "$run_url" ]] && break
sleep 0.1
done
if [[ -n "$run_url" ]]; then
if python3 "$repo_root/scripts/acceptance-run.py" "$run_url"
then
record real_run PASS
else
record real_run FAIL
exit 1
fi
run_url="$(start_server examples/control-flow "$work/run-server.log")"
if [[ -n "$run_url" ]] && python3 "$repo_root/scripts/acceptance-run.py" "$run_url" >>"$work/logs/G05_run.log" 2>&1; then
echo "explicit run: PASS" >>"$work/logs/G05_run.log"
else
record real_run FAIL
cat "$run_log" >&2
exit 1
run_ok=0
echo "explicit run: FAIL" >>"$work/logs/G05_run.log"
cat "$work/run-server.log" >>"$work/logs/G05_run.log" 2>&1 || true
fi
stop_server
gate_cmd[G05_run]="installed marqdo view examples/welcome + scripts/acceptance-run.py over SSE"
gate_exit[G05_run]=$(( run_ok == 1 ? 0 : 1 ))
gate_log[G05_run]="${work#"$repo_root"/}/logs/G05_run.log"
if [[ "$run_ok" -eq 1 ]]; then
gate_state[G05_run]=PASS
gate_note[G05_run]=""
else
gate_state[G05_run]=FAIL
gate_note[G05_run]="browse or explicit run failed; see G05_run.log"
finish 1
fi
# 5. project-local verification suites
run_step export_suite env MARQDO_BIN="$MARQDO_BIN" ./scripts/test-export.sh
run_step no_exec_suite env MARQDO_BIN="$MARQDO_BIN" ./scripts/test-no-exec.sh
run_step security_suite ./scripts/test-security.sh
gate_run G06_stream_snapshot "Observation v1 stream/snapshot equivalence + truncation" \
"python3 scripts/check-observation.py stream-snapshot"
gate_run G07_binding_stale "exact Analysis binding + stale-never-success mapping" \
"python3 scripts/check-observation.py binding && cargo test --lib execution::controller::tests::stale_and_incomplete_never_map_to_success && cargo test --test integration execution::source_edit_during_a_run_marks_the_result_stale_and_drops_anchor_ids && cargo test --test contract observation_contract::stale_and_wrong_root_bindings_are_observation_stale"
gate_note[G07_binding_stale]="CLI exact-byte binding probe + controller unit mapping + real run/source-change e2e + wrong-digest stale contract all PASS"
gate_run G08_negative "fail-closed matrix N01-N20: protocol + controller + security" \
"python3 scripts/check-observation.py fail-closed && cargo test --lib execution:: && cargo test --test contract observation_contract:: && cargo test --test contract core_contract:: && cargo test --test contract presentation_states:: && cargo test --test contract no_coupling:: && cargo test --test security"
gate_note[G08_negative]="N01-N11 decoder/contract negatives, N12-N13 controller hard rejection, N14-N15 CLI fail-closed probes, N16 G01 static check, N17 tool_v1 product-range unit test, N18-N20 security suite: all PASS"
gate_run G09_security "security baseline + zero-execution sentinel" \
"env MARQDO_BIN=\"$MARQDO_BIN\" ./scripts/test-no-exec.sh && ./scripts/test-security.sh"
browser_state=UNVERIFIED
if [[ "${SKIP_BROWSER:-0}" == "1" ]]; then
record browser SKIP
echo "browser: SKIP (SKIP_BROWSER=1)" >>"$work/logs/browser.log"
else
run_step browser env MARQDO_BIN="$MARQDO_BIN" ./scripts/test-browser.sh
if env MARQDO_BIN="$MARQDO_BIN" ./scripts/test-browser.sh >"$work/logs/browser.log" 2>&1; then
browser_state=PASS
else
browser_state=FAIL
gate_state[G09_security]=FAIL
gate_note[G09_security]="browser suite failed; see browser.log"
fi
fi
check_tampered_install() {
local output
printf 'x' >> "$tool_home/view/README.md" || return 1
if output="$("$MARQDO_BIN" view --version 2>&1)"; then
echo "error: tampered Tool installation was dispatched" >&2
return 1
gate_run G10_export "static export zero-execution + single renderer contract" \
"env MARQDO_BIN=\"$MARQDO_BIN\" ./scripts/test-export.sh && cargo test --locked --test contract"
if [[ "${CI:-}" == "true" || "${CI:-}" == "woodpecker" || -n "${WOODPECKER:-}" || -n "${GITHUB_ACTIONS:-}" ]]; then
gate_state[G11_evidence_ci]=PASS
gate_cmd[G11_evidence_ci]="this acceptance ran inside the unified CI job"
gate_exit[G11_evidence_ci]=0
gate_log[G11_evidence_ci]=""
gate_note[G11_evidence_ci]="manifest generated in the same CI invocation that produced the artifacts (GitHub Actions or Woodpecker sets CI=true)"
else
# A local manifest can still cite a real remote CI run, but only when the
# Woodpecker API confirms a successful pipeline for this exact commit SHA.
ci_state="UNVERIFIED"
ci_note="remote CI was not executed in this environment; this local manifest cannot attest CI. CI red => no release."
ci_cmd="remote CI run"
if [[ -n "${MARQDO_WOODPECKER_TOKEN:-}" && -n "${MARQDO_WOODPECKER_URL:-}" ]]; then
ci_commit="$(git rev-parse HEAD)"
ci_json="$(curl -fsS -H "Authorization: Bearer $MARQDO_WOODPECKER_TOKEN" \
"$MARQDO_WOODPECKER_URL/api/repos/2/pipelines?limit=20" 2>/dev/null || true)"
ci_result="$(CI_JSON="$ci_json" CI_COMMIT="$ci_commit" python3 - <<'PY_CI'
import json, os
text = os.environ.get("CI_JSON", "")
commit = os.environ.get("CI_COMMIT", "")
if not text:
print("UNVERIFIED\tno API response")
raise SystemExit(0)
try:
pipelines = json.loads(text)
except Exception as err:
print(f"UNVERIFIED\tAPI response is not JSON: {err}")
raise SystemExit(0)
for pipeline in pipelines:
if pipeline.get("commit") != commit:
continue
state = pipeline.get("status")
number = pipeline.get("number")
if state == "success":
print(f"PASS\tWoodpecker pipeline #{number} succeeded for {commit}")
else:
print(f"FAIL\tWoodpecker pipeline #{number} is {state} for {commit}")
raise SystemExit(0)
print(f"UNVERIFIED\tno Woodpecker pipeline for {commit}")
PY_CI
)"
ci_state="${ci_result%%$'\t'*}"
ci_note="${ci_result#*$'\t'}"
if [[ "$ci_state" == "PASS" || "$ci_state" == "FAIL" ]]; then
gate_state[G11_evidence_ci]="$ci_state"
gate_cmd[G11_evidence_ci]="$MARQDO_WOODPECKER_URL cflmy/marqdo-view pipelines (commit $ci_commit)"
gate_exit[G11_evidence_ci]=$([[ "$ci_state" == "PASS" ]] && echo 0 || echo 1)
gate_log[G11_evidence_ci]=""
gate_note[G11_evidence_ci]="$ci_note"
fi
fi
grep -q 'bundle hash mismatch' <<<"$output"
}
run_step tool_tamper_refused check_tampered_install
run_step tool_remove "$MARQDO_BIN" tool remove view
if [[ -z "${gate_state[G11_evidence_ci]:-}" ]]; then
gate_unverified G11_evidence_ci "$ci_cmd" "$ci_note"
fi
fi
# Leave the isolated tool home clean.
"$MARQDO_BIN" tool remove view >>"$work/logs/G10_export.log" 2>&1 || true
# 6. frozen core must be byte-identical
core_after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
if [[ "$core_before" != "$core_after" ]]; then
record core_sha FAIL
echo "error: frozen core binary changed during acceptance" >&2
exit 1
gate_state[G03_install]=FAIL
gate_note[G03_install]="frozen CLI SHA changed during acceptance"
finish 1
fi
record core_sha PASS
view_binary_sha="$(sha256sum "$bundle/bin/marqdo-view" | cut -d' ' -f1)"
evidence_path="${VIEW_EVIDENCE_OUT:-$work/manifest.json}"
mkdir -p "$(dirname "$evidence_path")"
python3 - "$evidence_path" "$statuses" "$view_source_sha" "$view_binary_sha" \
"$cli_source_sha" "$core_before" "$core_after" "$target" "$archive_sha" <<'PY_EVIDENCE'
import datetime
import json
import pathlib
import sys
(path, gates, view_source_sha, view_binary_sha, cli_source_sha,
core_before, core_after, target, archive_sha) = sys.argv[1:]
path = pathlib.Path(path)
statuses = dict(line.split("=", 1) for line in gates.splitlines())
manifest = {
"schema": "marqdo.view-conformance",
"schema_version": 1,
"view_source_sha": view_source_sha,
"view_binary_sha256": view_binary_sha,
"cli_source_sha": cli_source_sha,
"cli_binary_sha256_before": core_before,
"cli_binary_sha256_after": core_after,
"tool_protocol": 1,
"analysis_protocol": 2,
"trace_protocol": 2,
"target": target,
"archive_sha256": archive_sha,
"generated_at_utc": datetime.datetime.now(datetime.timezone.utc).isoformat(),
"tests": {
"contract": statuses.get("test", "FAIL"),
"examples": statuses.get("examples_check", "FAIL"),
"browser": statuses.get("browser", "SKIP"),
"export": statuses.get("export_suite", "FAIL"),
"no_exec": statuses.get("no_exec_suite", "FAIL"),
"security": statuses.get("security_suite", "FAIL"),
},
"gates": statuses,
"commands": {
"script": "scripts/acceptance.sh",
"notes": "Generated from real command exit statuses; install/verify/export/run use the frozen CLI archive copied to an isolated tool home.",
},
}
path.write_text(json.dumps(manifest, indent=2, sort_keys=True) + "\n")
print("evidence manifest:", path)
PY_EVIDENCE
echo
if [[ "${SKIP_BROWSER:-0}" == "1" ]]; then
echo "acceptance: PARTIAL (browser skipped)"
else
echo "acceptance: PASS"
fi
echo "evidence: $evidence_path"
echo "archive sha256: $archive_sha"
finish 0
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
# G12 (issue #5): current documentation must describe the rc.4 contracts as the
# only current capability. Historical CHANGELOG entries may name retired
# interfaces only under an explicit `## History` heading.
#
# Checked files:
# README.md, COMPATIBILITY.md, CHANGELOG.md, docs/STATUS.md, docs/ACCEPTANCE.md
#
# The script never rewrites files and never claims a gate is PASS: it only
# reports fact drift between the current docs and the rc.4 contract baseline.
#
# Usage: scripts/check-docs.sh
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo_root"
fail=0
hit() {
printf 'FAIL[%s] %s\n' "$1" "$2"
fail=1
}
legacy_pattern='Analysis v2|Trace v2|Execution Events|--trace-file|--event-stream|PROTOCOL_ANALYSIS|PROTOCOL_TRACE|TOOL_PROTOCOL|3\.0\.0-beta|>=3\.0\.0-rc\.2'
run_json_pattern='run[^.。\n]{0,20}--json|call[^.。\n]{0,20}--json|--json[^.。\n]{0,20}run|--json[^.。\n]{0,20}call'
# ------------------------------------------------------------- baseline ----
for file in README.md COMPATIBILITY.md docs/STATUS.md; do
[[ -f "$file" ]] || { hit "missing doc" "$file"; continue; }
grep -q '0\.3\.0' "$file" || hit "version drift" "$file: does not state View 0.3.0"
done
for file in README.md COMPATIBILITY.md docs/STATUS.md docs/ACCEPTANCE.md; do
[[ -f "$file" ]] || { hit "missing doc" "$file"; continue; }
while IFS=: read -r line text; do
[[ -n "$line" ]] && hit "legacy contract as current capability" "$file:$line: $text"
done < <(grep -nE "$legacy_pattern" "$file" || true)
while IFS=: read -r line text; do
[[ -n "$line" ]] && hit "retired run --json as current output" "$file:$line: $text"
done < <(grep -nE "$run_json_pattern" "$file" || true)
done
grep -qE 'Analysis[^A-Za-z0-9]+3' COMPATIBILITY.md || hit "contract drift" "COMPATIBILITY.md: no current Analysis 3 row"
grep -qE 'Observation[^A-Za-z0-9]+1' COMPATIBILITY.md || hit "contract drift" "COMPATIBILITY.md: no current Observation 1 row"
grep -qE 'api_revision[^A-Za-z0-9]+1|API revision[^A-Za-z0-9]+1' COMPATIBILITY.md \
|| hit "contract drift" "COMPATIBILITY.md: no current Tool api_revision 1 row"
grep -q '>=3.0.0-rc.3,<4.0.0' COMPATIBILITY.md || hit "product range drift" "COMPATIBILITY.md: expected >=3.0.0-rc.3,<4.0.0"
# ------------------------------------------------------------- CHANGELOG ---
if [[ ! -f CHANGELOG.md ]]; then
hit "missing doc" "CHANGELOG.md"
else
history_line="$(grep -nE '^##[[:space:]]+(History|历史)' CHANGELOG.md | head -1 | cut -d: -f1 || true)"
if [[ -z "$history_line" ]]; then
if grep -qE "$legacy_pattern" CHANGELOG.md; then
hit "CHANGELOG history" "CHANGELOG.md: retired interfaces appear without an explicit '## History' heading"
fi
else
# Only the current (pre-history) part may be scanned for legacy claims.
while IFS=: read -r line text; do
[[ -n "$line" ]] && hit "legacy contract as current CHANGELOG entry" "CHANGELOG.md:$line: $text"
done < <(head -n "$((history_line - 1))" CHANGELOG.md | grep -nE "$legacy_pattern" || true)
while IFS=: read -r line text; do
[[ -n "$line" ]] && hit "retired run --json in current CHANGELOG entry" "CHANGELOG.md:$line: $text"
done < <(head -n "$((history_line - 1))" CHANGELOG.md | grep -nE "$run_json_pattern" || true)
if ! head -n "$((history_line - 1))" CHANGELOG.md | grep -q '0\.3\.0'; then
hit "CHANGELOG current entry" "CHANGELOG.md: no 0.3.0 entry before '## History'"
fi
fi
fi
# --------------------------------------------------------------- report ----
if [[ "$fail" -ne 0 ]]; then
cat >&2 <<'EOF'
check-docs: FAIL
Update the current docs to the rc.4 baseline:
* one static source: `check --emit` Analysis revision 3 (ADR-0069);
* one runtime sequence: Observation revision 1 (`--output jsonl` /
`--observation-file`), no retired trace file or event stream;
* CLI Tool revision 1 with exact `requires` (api_revision 1, analysis 3,
observation 1), no `compatibility` field;
* product range >=3.0.0-rc.3,<4.0.0, acceptance pinned to rc.4.
Old release notes belong under CHANGELOG's explicit `## History` heading.
Do not claim PASS/UNVERIFIED results that have no generated evidence.
EOF
exit 1
fi
echo "check-docs: PASS (README/COMPATIBILITY/CHANGELOG/STATUS/ACCEPTANCE describe the rc.4 baseline; CHANGELOG history is explicit)"
+63 -41
View File
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
# RFC-VIEW-0002 §13.3/§13.4: prove the five 3.0 example documents against the
# frozen released CLI. Never rebuilds the Core; runs in a copied temp project so
# the repository examples are never modified.
# Prove the five 3.0 example documents against the frozen released CLI using
# the current public contracts: one `check --emit` Analysis v3 source and one
# Observation v1 sequence per `run`/`call`. Never rebuilds the Core; runs in a
# copied temp project so the repository examples are never modified.
#
# Usage: MARQDO_BIN=/abs/path/marqdo scripts/check-examples.sh
set -euo pipefail
@@ -10,7 +11,8 @@ repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo_root"
: "${MARQDO_BIN:?set MARQDO_BIN to the frozen marqdo binary}"
core_sha_before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
core="${MARQDO_BIN}"
core_sha_before="$(sha256sum "$core" | cut -d' ' -f1)"
work="$repo_root/dist/examples-check"
rm -rf "$work"
@@ -21,71 +23,91 @@ cp examples/view.json "$work/"
cd "$work"
echo "==> check all five example documents (no execution)"
echo "==> check all five example documents (one static source: check --emit)"
for file in welcome.mq.md branch-loop.mq.md function-params.mq.md knowledge-only.mq.md unsafe-side-effect.mq.md; do
if ! "$MARQDO_BIN" check "$file" --emit "analysis-$file.json" --json > "check-$file.json"; then
if ! "$core" check "$file" --emit "analysis-$file.json" --json > "check-$file.json"; then
echo "error: frozen CLI refused $file" >&2
cat "check-$file.json" >&2
exit 1
fi
test -s "analysis-$file.json"
done
echo "==> call function-params.double(n=5) -> 10"
call_json="$("$MARQDO_BIN" call function-params.mq.md double --arg n=5 --mode pure --json --trace-file call.trace.json)"
python3 - "$call_json" <<'PY'
import json, sys
data = json.loads(sys.argv[1])
assert data["success"] is True, data
assert data["value"] == {"type": "int", "decimal": "10"}, data["value"]
print("call double(5): PASS (Int 10)")
python3 - <<'PY'
import json
for name in ("welcome", "branch-loop", "function-params", "knowledge-only", "unsafe-side-effect"):
artifact = json.load(open(f"analysis-{name}.mq.md.json"))
assert artifact["schema"] == "marqdo.analysis", artifact["schema"]
assert artifact["schema_version"] == 3, artifact["schema_version"]
assert artifact["modules"] and artifact["modules"][0]["source"], name
assert artifact["modules"][0]["document"], name
assert artifact["project"]["entry_module_id"], name
print("Analysis v3: PASS (schema_version 3, exact source/document/entry present)")
PY
echo "==> run branch-loop main -> Int 0 with loop/return trace"
run_json="$("$MARQDO_BIN" run branch-loop.mq.md --mode pure --json --trace-file run.trace.json)"
python3 - "$run_json" "run.trace.json" <<'PY'
import json, sys
data = json.loads(sys.argv[1])
assert data["success"] is True, data
assert data["value"] == {"type": "int", "decimal": "0"}, data["value"]
trace = json.load(open(sys.argv[2]))
kinds = {event["kind"] for event in trace["events"]}
echo "==> call function-params.double(n=5) -> 10 via Observation v1"
"$core" call function-params.mq.md double --arg n=5 --mode pure --output json > call.json
python3 - <<'PY'
import json
snapshot = json.load(open("call.json"))
assert snapshot["schema"] == "marqdo.observation" and snapshot["schema_version"] == 1
assert snapshot["run"]["status"] == "ok", snapshot["run"]
terminal = snapshot["events"][-1]
assert terminal["kind"] == "run.completed", terminal
assert terminal["payload"]["value"] == {"type": "int", "decimal": "10"}, terminal["payload"]
print("call double(5): PASS (Observation v1, Int 10)")
PY
echo "==> run branch-loop main -> Int 0 with loop/return events"
"$core" run branch-loop.mq.md --mode pure --output json > run.json
python3 - <<'PY'
import json
snapshot = json.load(open("run.json"))
assert snapshot["run"]["status"] == "ok", snapshot["run"]
terminal = snapshot["events"][-1]
assert terminal["kind"] == "run.completed", terminal
assert terminal["payload"]["value"] == {"type": "int", "decimal": "0"}, terminal["payload"]
kinds = [event["kind"] for event in snapshot["events"]]
assert "loop.iteration" in kinds and "return" in kinds, kinds
print("run branch-loop: PASS (value 0, events: %s)" % ",".join(sorted(kinds)))
seqs = [event["seq"] for event in snapshot["events"]]
assert seqs == list(range(len(seqs))), seqs
assert len({event["run_id"] for event in snapshot["events"]}) == 1
print("run branch-loop: PASS (Int 0, contiguous seq, kinds: %s)" % ",".join(kinds))
PY
echo "==> knowledge-only has no main (truthful failure, no fallback)"
echo "==> knowledge-only has no main (truthful rejection, no fallback)"
set +e
"$MARQDO_BIN" run knowledge-only.mq.md --mode pure --json > knowledge.json 2>&1
"$core" run knowledge-only.mq.md --mode pure --output json > knowledge.json 2>/dev/null
status=$?
set -e
test "$status" -ne 0
python3 - knowledge.json <<'PY'
import json, sys
data = json.load(open(sys.argv[1]))
assert data["success"] is False, data
assert data["code"] == "sem.no_entry_function", data
python3 - <<'PY'
import json
snapshot = json.load(open("knowledge.json"))
terminal = snapshot["events"][-1]
assert terminal["kind"] == "run.rejected", terminal
assert terminal["payload"]["error"]["code"] == "sem.no_entry_function", terminal["payload"]
print("knowledge-only: PASS (explicit sem.no_entry_function)")
PY
echo "==> unsafe-side-effect writes nothing in pure mode"
set +e
"$MARQDO_BIN" run unsafe-side-effect.mq.md --mode pure --json > unsafe-pure.json 2>&1
"$core" run unsafe-side-effect.mq.md --mode pure --output json > unsafe-pure.json 2>/dev/null
status=$?
set -e
test "$status" -ne 0
test ! -e out/view-sentinel.txt
python3 - unsafe-pure.json <<'PY'
import json, sys
data = json.load(open(sys.argv[1]))
assert data["success"] is False, data
assert data["error"]["code"] == "permission.denied", data["error"]
python3 - <<'PY'
import json
snapshot = json.load(open("unsafe-pure.json"))
terminal = snapshot["events"][-1]
assert terminal["kind"] == "run.failed", terminal
assert terminal["payload"]["error"]["code"] == "permission.denied", terminal["payload"]
print("unsafe-side-effect pure: PASS (permission.denied, no file)")
PY
echo "==> unsafe-side-effect writes only with explicit project grants"
"$MARQDO_BIN" run unsafe-side-effect.mq.md --mode project \
--allow-write out --allow-write 'out/**' --json --trace-file unsafe.trace.json >/dev/null
"$core" run unsafe-side-effect.mq.md --mode project \
--allow-write out --allow-write 'out/**' --output json >/dev/null
test -f out/view-sentinel.txt
python3 - <<'PY'
content = open("out/view-sentinel.txt", "rb").read()
@@ -94,6 +116,6 @@ print("unsafe-side-effect project+grants: PASS (sentinel written explicitly)")
PY
rm -rf out
core_sha_after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
core_sha_after="$(sha256sum "$core" | cut -d' ' -f1)"
test "$core_sha_before" = "$core_sha_after"
echo "examples: PASS (frozen CLI sha256 $core_sha_before unchanged)"
+169
View File
@@ -0,0 +1,169 @@
#!/usr/bin/env bash
# G01 (issue #5 §4): fail if the current tree still contains retired public
# contracts, retired run/call argv, legacy Tool negotiation or dual-state
# compatibility shims.
#
# Scope:
# * src/ one decoder, one validator, no version branch;
# * tool.json CLI Tool revision 1 only (no `compatibility`);
# * current contract docs README/COMPATIBILITY/STATUS/ACCEPTANCE/
# CONFORMANCE/architecture/current audit/ADR-0012.
#
# Historical records are exempt by design and are never rewritten:
# docs/evidence/** (except README), docs/decisions/0001..0011,
# docs/architecture/RFC-VIEW-0001*, RFC-VIEW-0002.md, docs/audits/legacy-*,
# docs/audits/protocol-conformance.md, CHANGELOG.md (history is validated by
# scripts/check-docs.sh instead).
#
# Usage: scripts/check-no-legacy.sh
# Exit: 0 = 0 hits; 1 = at least one retired reference (actionable output).
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo_root"
fail=0
hit() {
printf 'FAIL[%s] %s\n' "$1" "$2"
fail=1
}
# ---------------------------------------------------------------- src/ ------
src_files() {
find src -type f \( -name '*.rs' -o -name '*.js' -o -name '*.css' \) -print0
}
# Negative unit tests may name a retired flag to assert it is never emitted.
# Everything from the conventional `#[cfg(test)]` attribute to EOF is test code
# and is not a production compatibility path, so scans skip it.
scan_src_pattern() {
local label="$1" pattern="$2" file line text
while IFS= read -r -d '' file; do
while IFS=: read -r line text; do
[[ -n "$line" ]] && hit "$label" "$file:$line: $text"
done < <(awk -v pat="$pattern" -v file="$file" '
/^[[:space:]]*#\[cfg\(test\)\]/ { intests = 1 }
intests { next }
$0 ~ pat { print FNR ":" $0 }
' "$file" || true)
done < <(src_files)
}
scan_src_pattern "legacy protocol module/name" 'analysis_v2|trace_v2|Trace v2|Execution Events'
scan_src_pattern "retired run/call flag" '--trace-file|--event-stream|trace_max|trace_path|trace_bytes'
scan_src_pattern "legacy Tool negotiation/migration" 'compatibility|record_version:[[:space:]]*1|PROTOCOL_ANALYSIS|PROTOCOL_TRACE|TOOL_PROTOCOL'
scan_src_pattern "dual-state/legacy branch" 'Option<Legacy|enum Either|legacy_mode|map_v1'
# Version branches belong to protocol modules only; the reader never sees them.
while IFS= read -r -d '' file; do
while IFS=: read -r line text; do
[[ -n "$line" ]] && hit "reader branches on schema_version" "$file:$line: $text"
done < <(awk '
/^[[:space:]]*#\[cfg\(test\)\]/ { intests = 1 }
intests { next }
/schema_version/ { print FNR ":" $0 }
' "$file" || true)
done < <(find src/reader -type f -name '*.rs' -print0 2>/dev/null || true)
# `fallback` is legitimate only as a comment phrase ("never decoded through a
# fallback") or for the unrelated OS-random fallback helper. Flag real code.
while IFS= read -r -d '' file; do
while IFS=: read -r line text; do
[[ -z "$line" ]] && continue
code="${text%%//*}"
[[ "$code" == *fallback* ]] || continue
case "$code" in
*fallback_counter*) ;;
*) hit "protocol fallback branch" "$file:$line: $text" ;;
esac
done < <(awk '
/^[[:space:]]*#\[cfg\(test\)\]/ { intests = 1 }
intests { next }
/fallback/ { print FNR ":" $0 }
' "$file" || true)
done < <(src_files)
# Retired `run`/`call --json` argv: the only accepted `--json` is the `check`
# diagnostic summary. Heuristic: find the enclosing Rust function; argv
# builders for check-like commands are the only permitted owners.
while IFS= read -r -d '' file; do
while IFS=: read -r line_no text; do
[[ -z "$line_no" ]] && continue
case "$text" in
//*|///*) continue ;;
esac
fn="$(awk -v target="$line_no" '
/^[[:space:]]*(pub[[:space:]]+)?(async[[:space:]]+)?fn[[:space:]]+[A-Za-z0-9_]+/ {
s=$0; sub(/^[[:space:]]*(pub[[:space:]]+)?(async[[:space:]]+)?fn[[:space:]]+/, "", s); sub(/[^A-Za-z0-9_].*/, "", s); current=s
}
NR==target { print current; exit }
' "$file")"
case "$fn" in
*check*|*diagnostic*|*analysis*) ;;
*) hit "retired run/call --json argv" "$file:$line_no: $text (enclosing fn: ${fn:-<top-level>})" ;;
esac
done < <(awk '
/^[[:space:]]*#\[cfg\(test\)\]/ { intests = 1 }
intests { next }
/--json/ { print FNR ":" $0 }
' "$file" || true)
done < <(src_files)
# ------------------------------------------------------------- tool.json ----
if grep -qE '"compatibility"' tool.json; then
while IFS=: read -r line text; do
hit "tool.json compatibility field" "tool.json:$line: $text"
done < <(grep -nE '"compatibility"' tool.json)
fi
if grep -qE 'record_version|PROTOCOL_ANALYSIS|PROTOCOL_TRACE|TOOL_PROTOCOL' tool.json; then
while IFS=: read -r line text; do
hit "legacy tool metadata" "tool.json:$line: $text"
done < <(grep -nE 'record_version|PROTOCOL_ANALYSIS|PROTOCOL_TRACE|TOOL_PROTOCOL' tool.json)
fi
# -------------------------------------------------------- current docs ------
current_docs=(
README.md
COMPATIBILITY.md
docs/STATUS.md
docs/ACCEPTANCE.md
docs/CONFORMANCE.md
docs/audits/protocol-contract-0002.md
docs/architecture/observation-v1-and-analysis-v3.md
docs/decisions/0012-rc4-current-contracts.md
docs/design/complete-reader.md
docs/design/state-matrix.md
docs/design/visual-tokens.md
docs/evidence/README.md
)
doc_pattern='Analysis v2|Trace v2|Execution Events|--trace-file|--event-stream|PROTOCOL_ANALYSIS|PROTOCOL_TRACE|TOOL_PROTOCOL|3\.0\.0-beta|>=3\.0\.0-rc\.2'
run_json_pattern='run[^.。\n]{0,20}--json|call[^.。\n]{0,20}--json|--json[^.。\n]{0,20}run|--json[^.。\n]{0,20}call'
for doc in "${current_docs[@]}"; do
if [[ ! -f "$doc" ]]; then
hit "missing current doc" "$doc"
continue
fi
while IFS=: read -r line text; do
[[ -n "$line" ]] && hit "legacy contract in current doc" "$doc:$line: $text"
done < <(grep -nE "$doc_pattern" "$doc" || true)
while IFS=: read -r line text; do
[[ -n "$line" ]] && hit "retired run --json in current doc" "$doc:$line: $text"
done < <(grep -nE "$run_json_pattern" "$doc" || true)
done
if [[ "$fail" -ne 0 ]]; then
cat >&2 <<'EOF'
check-no-legacy: FAIL
Remove the retired reference from the current tree (delete the code path,
rewrite the doc claim, or move history into CHANGELOG.md under its explicit
`## History` heading). Do not add a compatibility branch, fallback decoder or
migration shim: the rc.4 baseline has exactly one current contract per
boundary. Historical evidence under docs/evidence/** and historical ADRs are
exempt and untouched.
Current baseline: marqdo 3.0.0-rc.4, Analysis revision 3 (ADR-0069),
Observation revision 1, CLI Tool revision 1.
EOF
exit 1
fi
echo "check-no-legacy: PASS (0 retired references in src/, tool.json and current docs; rc.4 baseline)"
+230
View File
@@ -0,0 +1,230 @@
#!/usr/bin/env python3
"""Machine checks for the current observation/analysis contracts (G06/G07/G08).
These probes use only the frozen CLI's public interface and assert the exact
contract marqdo-view 0.3.0 consumes. They do not run the View binary; View-side
regressions are covered by the cargo test suite owned by the migration.
Usage:
MARQDO_BIN=/abs/path/marqdo python3 scripts/check-observation.py stream-snapshot
MARQDO_BIN=/abs/path/marqdo python3 scripts/check-observation.py binding
MARQDO_BIN=/abs/path/marqdo python3 scripts/check-observation.py fail-closed
"""
import hashlib
import json
import os
import pathlib
import shutil
import subprocess
import sys
import tempfile
ROOT = pathlib.Path(__file__).resolve().parents[1]
BIN = pathlib.Path(os.environ.get("MARQDO_BIN", "")).resolve()
def fail(message):
print(f"observation probe: FAIL: {message}", file=sys.stderr)
sys.exit(1)
def run(args, cwd, expect=0):
result = subprocess.run([str(BIN), *args], cwd=cwd, capture_output=True, text=True)
if result.returncode != expect:
fail(f"{' '.join(args)} exited {result.returncode}, expected {expect}\n{result.stderr}")
return result
def sha256_prefixed(data):
return "sha256:" + hashlib.sha256(data).hexdigest()
def workspace():
dist = ROOT / "dist"
dist.mkdir(exist_ok=True)
directory = tempfile.TemporaryDirectory(prefix="observation-contract-", dir=dist)
root = pathlib.Path(directory.name)
for source in (
"examples/function-params.mq.md",
"examples/branch-loop.mq.md",
"examples/knowledge-only.mq.md",
):
shutil.copy(ROOT / source, root / pathlib.Path(source).name)
return directory, root
def load_snapshot(path):
snapshot = json.loads(pathlib.Path(path).read_text())
if snapshot.get("schema") != "marqdo.observation" or snapshot.get("schema_version") != 1:
fail(f"not an Observation v1 snapshot: {path}")
events = snapshot["events"]
run_id = snapshot["run"]["id"]
if [event["seq"] for event in events] != list(range(len(events))):
fail("snapshot seq is not zero-based contiguous")
if any(event["run_id"] != run_id for event in events):
fail("snapshot mixes run_id values")
return snapshot, events
def stream_snapshot():
directory, root = workspace()
with directory:
stream = run(
["call", "function-params.mq.md", "double", "--arg", "n=5", "--mode", "pure",
"--output", "jsonl", "--observation-file", "obs.json"],
root,
).stdout
lines = [json.loads(line) for line in stream.splitlines() if line.strip()]
snapshot, events = load_snapshot(root / "obs.json")
if lines != events:
fail("JSONL stream and atomic snapshot disagree for the same execution")
if snapshot["run"]["status"] != "ok":
fail(f"unexpected run.status {snapshot['run']['status']}")
if events[-1]["kind"] != "run.completed":
fail("terminal event is not run.completed")
if events[-1]["payload"]["value"] != {"type": "int", "decimal": "10"}:
fail("call result is not Int 10")
print("stream/snapshot equivalence: PASS (%d events, one run_id, contiguous seq, one terminal)" % len(events))
truncated_out = run(
["run", "branch-loop.mq.md", "--mode", "pure", "--observe-max-events", "2",
"--output", "jsonl", "--observation-file", "truncated.json"],
root,
).stdout
truncated_lines = [json.loads(line) for line in truncated_out.splitlines() if line.strip()]
truncated_snapshot, truncated_events = load_snapshot(root / "truncated.json")
if truncated_lines != truncated_events:
fail("truncated stream and snapshot disagree")
truncated = truncated_snapshot["capture"]["truncated"]
if not truncated or truncated.get("reason") != "event_budget":
fail("missing observation.truncated capture metadata")
if truncated_events[-1]["kind"] != "run.completed":
fail("truncated run has no truthful terminal")
print("observation truncation: PASS (capture.truncated=%s, terminal=%s)"
% (truncated.get("reason"), truncated_events[-1]["kind"]))
def span_ok(span, length):
return (
isinstance(span, dict)
and isinstance(span.get("start"), int)
and isinstance(span.get("end"), int)
and 0 <= span["start"] <= span["end"] <= length
)
def binding():
directory, root = workspace()
with directory:
run(["check", "function-params.mq.md", "--emit", "analysis.json", "--json"], root)
analysis_bytes = (root / "analysis.json").read_bytes()
analysis = json.loads(analysis_bytes)
if analysis.get("schema") != "marqdo.analysis" or analysis.get("schema_version") != 3:
fail("check --emit did not produce Analysis revision 3")
expected_digest = sha256_prefixed(analysis_bytes)
module = analysis["modules"][0]
source = module["source"].encode("utf-8")
if module["source_digest"] != hashlib.sha256(source).hexdigest():
fail("module.source_digest does not hash the exact module.source bytes")
run(
["call", "function-params.mq.md", "double", "--arg", "n=5", "--mode", "pure",
"--output", "jsonl", "--observation-file", "obs.json"],
root,
)
snapshot, events = load_snapshot(root / "obs.json")
started = next((event for event in events if event["kind"] == "run.started"), None)
if started is None:
fail("no run.started event")
observed = started["payload"]["source"]
if observed.get("analysis_digest") != expected_digest:
fail("run.started analysis_digest does not bind the exact check --emit bytes")
if observed.get("root_id") != analysis["project"]["root_id"]:
fail("run.started root_id does not match Analysis project.root_id")
if snapshot["run"]["source"] != observed:
fail("snapshot run.source disagrees with run.started source")
module_ids = {candidate["id"] for candidate in analysis["modules"]}
for event in events:
payload = event["payload"]
if payload.get("module_id") is not None and payload["module_id"] not in module_ids:
fail(f"event {event['seq']} references unknown module_id")
span = payload.get("span")
if span is not None and not span_ok(span, len(source)):
fail(f"event {event['seq']} span is outside the exact source bytes")
# A source edit must invalidate the binding: a new check emits a different digest.
original = (root / "function-params.mq.md").read_bytes()
(root / "function-params.mq.md").write_bytes(original + b"\nsource changed\n")
result = subprocess.run(
[str(BIN), "check", "function-params.mq.md", "--emit", "analysis-edited.json", "--json"],
cwd=root, capture_output=True, text=True,
)
(root / "function-params.mq.md").write_bytes(original)
if result.returncode == 0:
edited = (root / "analysis-edited.json").read_bytes()
if sha256_prefixed(edited) == expected_digest:
fail("source edit did not change the Analysis digest")
print("exact Analysis binding: PASS (digest=%s, root/module/span checks, source edit invalidates)" % expected_digest)
def fail_closed():
directory, root = workspace()
with directory:
cases = [
(["run", "branch-loop.mq.md", "--mode", "pure", "--json"], "retired --json"),
(["run", "branch-loop.mq.md", "--mode", "pure", "--trace-file", "x.json"], "retired --trace-file"),
(["run", "branch-loop.mq.md", "--mode", "pure", "--event-stream", "jsonl"], "retired --event-stream"),
]
for args, label in cases:
result = subprocess.run([str(BIN), *args], cwd=root, capture_output=True, text=True)
if result.returncode != 2:
fail(f"{label}: expected exit 2, got {result.returncode}")
print(f"fail-closed {label}: PASS (exit 2, no fallback retry)")
strict = subprocess.run(
[str(BIN), "run", "branch-loop.mq.md", "--mode", "strict", "--output", "jsonl"],
cwd=root, capture_output=True, text=True,
)
if strict.returncode != 2 or "strict.unsupported_grant" not in strict.stderr:
fail(f"strict + jsonl: expected exit 2 strict.unsupported_grant, got {strict.returncode}: {strict.stderr}")
print("fail-closed strict live destination: PASS (exit 2, strict.unsupported_grant)")
# Retired manifest fixture: used only to prove the current CLI rejects it.
old = root / "old-tool"
(old / "bin").mkdir(parents=True)
(old / "bin" / "probe").write_text("#!/usr/bin/env bash\nexit 0\n")
os.chmod(old / "bin" / "probe", 0o755)
(old / "tool.json").write_text(json.dumps({
"schema": "marqdo.cli-tool",
"schema_version": 1,
"name": "old-probe",
"version": "0.2.0",
"command": "old-probe",
"entrypoint": "bin/probe",
"compatibility": {"schema": "retired-fixture", "versions": ["fixture-only"]},
}))
env = {**os.environ, "MARQDO_TOOL_HOME": str(root / "tool-home")}
legacy = subprocess.run(
[str(BIN), "tool", "install", str(old / "tool.json")],
cwd=root, capture_output=True, text=True, env=env,
)
if legacy.returncode == 0 or "compatibility" not in legacy.stderr:
fail(f"retired tool.json was not rejected: {legacy.returncode} {legacy.stderr}")
print("fail-closed retired tool.json: PASS (unknown field `compatibility`, no migrator)")
def main():
if not BIN.is_file() or not os.access(BIN, os.X_OK):
fail("set MARQDO_BIN to the unpacked frozen marqdo binary")
if len(sys.argv) != 2:
fail(__doc__)
mode = sys.argv[1]
if mode == "stream-snapshot":
stream_snapshot()
elif mode == "binding":
binding()
elif mode == "fail-closed":
fail_closed()
else:
fail(f"unknown mode {mode}")
if __name__ == "__main__":
main()
+23 -6
View File
@@ -1,11 +1,16 @@
#!/usr/bin/env bash
# Identity of the released CLI used by the RFC-VIEW-0002 acceptance gate.
# Identity of the released CLI used by the marqdo-view 0.3.0 acceptance gate.
#
# The pinned release is the current public-contract baseline:
# marqdo 3.0.0-rc.4 (Analysis v3 / ADR-0069, Observation v1, CLI Tool revision 1)
# The script only downloads, unpacks and verifies the official archive; it never
# rebuilds or modifies the CLI.
set -euo pipefail
version=3.0.0-beta.1
source_sha=2c7c4f31e7a388d3fcfa717a77067e696ed13854
binary_sha=062cb56e226bee55c21d238e195920caa985e62bb3877ba7b07abcc04dc0fe3f
archive_sha=507e4cd358f75f517433935ce90d5fc2eb5cecda4f19121a68b136c83b15f317
version=3.0.0-rc.4
source_sha=452e9a32bd9e40dba427d4180691c58bab74449e
binary_sha=a7306962689c635445a59043971ea2eb09298e01feeee81f0ba07b1f3e10306e
archive_sha=9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8
artifact="marqdo-$version-x86_64-unknown-linux-gnu"
root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -24,8 +29,20 @@ verify() {
fi
}
if [[ "${1:-}" == "metadata" && $# -eq 1 ]]; then
case "$1" in
metadata)
printf 'version=%s\n' "$version"
printf 'source_sha=%s\n' "$source_sha"
printf 'binary_sha=%s\n' "$binary_sha"
printf 'archive_sha=%s\n' "$archive_sha"
printf 'artifact=%s\n' "$artifact"
exit 0
;;
esac
fi
if [[ $# != 2 ]]; then
echo "usage: $0 fetch EMPTY_DIRECTORY | $0 verify /absolute/path/to/marqdo" >&2
echo "usage: $0 fetch EMPTY_DIRECTORY | $0 verify /absolute/path/to/marqdo | $0 metadata" >&2
exit 2
fi
case "$1" in
+22 -9
View File
@@ -1,5 +1,10 @@
#!/usr/bin/env bash
# Regenerate committed Analysis v2 goldens from the frozen CLI release binary.
# Regenerate committed Analysis v3 / Observation v1 goldens from the frozen CLI
# release binary.
#
# The current public contracts have exactly one static source (`check --emit`
# Analysis v3) and one runtime sequence (Observation v1, either `--output jsonl`
# or the atomic `--observation-file` snapshot of the same execution).
#
# Usage: MARQDO_BIN=/abs/path/marqdo scripts/gen-golden.sh
set -euo pipefail
@@ -14,21 +19,29 @@ if [[ ! -x "$MARQDO_BIN" ]]; then
fi
echo "golden core sha256: $(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
out="tests/golden/analysis-v2"
out="tests/golden/analysis-v3"
mkdir -p "$out"
"$MARQDO_BIN" check examples/mixed-modes/index.mq.md --emit "$out/mixed-modes.json"
"$MARQDO_BIN" check examples/control-flow/index.mq.md --emit "$out/control-flow.json"
"$MARQDO_BIN" check examples/tables-math/index.mq.md --emit "$out/tables-math.json"
"$MARQDO_BIN" check examples/welcome/00-welcome.mq.md --emit "$out/welcome.json"
# Trace v2 goldens come from the same frozen binary (pure mode, no grants).
out_trace="tests/golden/trace-v2"
mkdir -p "$out_trace"
"$MARQDO_BIN" check examples/unicode-spans/index.mq.md --emit "$out/unicode-spans.json"
"$MARQDO_BIN" check examples/unicode-spans/crlf.mq.md --emit "$out/unicode-spans-crlf.json"
# Observation v1 goldens come from the same frozen binary (pure mode, no grants).
out_obs="tests/golden/observation-v1"
mkdir -p "$out_obs"
( cd examples/control-flow \
&& "$MARQDO_BIN" run index.mq.md --mode pure --json --trace-file "$repo_root/$out_trace/control-flow.trace.json" > "$repo_root/$out_trace/control-flow.run.json" )
&& "$MARQDO_BIN" run index.mq.md --mode pure --output jsonl --observation-file "$repo_root/$out_obs/control-flow.snapshot.json" \
> "$repo_root/$out_obs/control-flow.jsonl" )
( cd examples/control-flow \
&& "$MARQDO_BIN" run index.mq.md --mode pure --json --trace-max-events 5 --trace-file "$repo_root/$out_trace/control-flow.truncated.trace.json" > "$repo_root/$out_trace/control-flow.truncated.run.json" )
&& "$MARQDO_BIN" run index.mq.md --mode pure --observe-max-events 5 \
--output jsonl --observation-file "$repo_root/$out_obs/control-flow.truncated.snapshot.json" \
> "$repo_root/$out_obs/control-flow.truncated.jsonl" )
if ( cd examples/mixed-modes \
&& "$MARQDO_BIN" run index.mq.md --mode pure --json --trace-file "$repo_root/$out_trace/mixed-modes.arity.trace.json" > "$repo_root/$out_trace/mixed-modes.arity.run.json" ); then
&& "$MARQDO_BIN" run index.mq.md --mode pure --output jsonl \
--observation-file "$repo_root/$out_obs/mixed-modes.arity.snapshot.json" \
> "$repo_root/$out_obs/mixed-modes.arity.jsonl" 2>/dev/null ); then
echo "error: mixed-modes without params unexpectedly ran" >&2
exit 1
fi
@@ -37,4 +50,4 @@ if "$MARQDO_BIN" check examples/diagnostics/index.mq.md --json >/dev/null 2>&1;
echo "error: examples/diagnostics unexpectedly passed check" >&2
exit 1
fi
echo "goldens: PASS"
echo "goldens: PASS (Analysis v3 + Observation v1 stream/snapshot)"
+48 -2
View File
@@ -2,6 +2,10 @@
# Install the built bundle with a frozen marqdo CLI into an isolated tool home,
# then prove the command is served by this program (not by the Core).
#
# The frozen CLI is the current Tool revision 1 baseline: it injects
# MARQDO_API_REVISION=1 and MARQDO_BIN only, with no legacy
# MARQDO_PROTOCOL_* negotiation variables.
#
# Usage: MARQDO_BIN=/abs/path/marqdo scripts/install-smoke.sh [tool.json]
set -euo pipefail
@@ -16,6 +20,19 @@ if [[ ! -x "$MARQDO_BIN" ]]; then
fi
before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
# The packaged manifest must declare the current exact contracts.
python3 - "$manifest" <<'PY'
import json
import sys
tool = json.load(open(sys.argv[1]))
assert tool["schema"] == "marqdo.cli-tool", tool
assert tool["schema_version"] == 1, tool
assert "compatibility" not in tool, "retired compatibility field present"
assert tool["requires"] == {"api_revision": 1, "analysis": 3, "observation": 1}, tool["requires"]
print("manifest: PASS (revision 1 requires api_revision=1 analysis=3 observation=1)")
PY
mkdir -p "$repo_root/dist"
tool_home="$(mktemp -d "$repo_root/dist/smoke-tool-home.XXXXXX")"
cleanup() {
@@ -25,7 +42,7 @@ trap cleanup EXIT
export MARQDO_TOOL_HOME="$tool_home"
"$MARQDO_BIN" tool install "$manifest" >/dev/null
"$MARQDO_BIN" tool list | grep -q 'view'
"$MARQDO_BIN" tool list | grep -q '^view '
help="$("$MARQDO_BIN" view --help)"
grep -q 'marqdo-view' <<<"$help"
grep -q 'export' <<<"$help"
@@ -33,10 +50,39 @@ grep -q 'verify' <<<"$help"
version="$("$MARQDO_BIN" view --version)"
grep -q 'marqdo-view' <<<"$version"
# Prove the current dispatch environment contract: the CLI injects
# MARQDO_API_REVISION=1 (and MARQDO_BIN), never the retired negotiation vars.
probe_dir="$tool_home/probe"
mkdir -p "$probe_dir/bin"
cat >"$probe_dir/bin/api-probe" <<'PROBE'
#!/usr/bin/env bash
printf 'MARQDO_API_REVISION=%s\n' "${MARQDO_API_REVISION:-<unset>}"
printf 'MARQDO_BIN=%s\n' "${MARQDO_BIN:-<unset>}"
printf 'retired=%s\n' "${MARQDO_PROTOCOL_ANALYSIS:-}${MARQDO_PROTOCOL_TRACE:-}${MARQDO_TOOL_PROTOCOL:-}"
PROBE
chmod 755 "$probe_dir/bin/api-probe"
cat >"$probe_dir/tool.json" <<'PROBE_JSON'
{
"schema": "marqdo.cli-tool",
"schema_version": 1,
"name": "api-probe",
"version": "0.0.1",
"command": "api-probe",
"entrypoint": "bin/api-probe",
"requires": {"api_revision": 1}
}
PROBE_JSON
"$MARQDO_BIN" tool install "$probe_dir/tool.json" >/dev/null
probe="$("$MARQDO_BIN" api-probe)"
grep -qx 'MARQDO_API_REVISION=1' <<<"$probe"
grep -q '^MARQDO_BIN=/' <<<"$probe"
grep -qx 'retired=' <<<"$probe"
"$MARQDO_BIN" tool remove api-probe >/dev/null
after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
if [[ "$before" != "$after" ]]; then
echo "error: frozen core binary changed during install smoke test" >&2
exit 1
fi
echo "install-smoke: PASS (core sha256 $before unchanged, tool home $tool_home)"
echo "install-smoke: PASS (view installed/dispatched, api_revision 1 injected, core sha256 $before unchanged, tool home $tool_home)"
+19 -8
View File
@@ -1,13 +1,16 @@
#!/usr/bin/env bash
# Build and assemble the Tool Protocol v1 release bundle.
# Build and assemble the CLI Tool revision 1 release bundle for marqdo-view 0.3.0.
#
# Produces:
# dist/marqdo-view/ stable bundle path (RFC §18)
# dist/marqdo-view/ stable bundle path
# dist/marqdo-view-<version>-<target>.tar.gz (+ .sha256)
#
# The bundle contains only the runtime binary, the manifest and the legal /
# compatibility files. CSS/JS/images are compiled into the binary (ADR-0002),
# release-note files. CSS/JS/images are compiled into the binary (ADR-0002),
# so there is exactly one asset source for Live and Export.
#
# The current public contracts are exact: api_revision 1, Analysis 3 and
# Observation 1. There is no version negotiation and no `compatibility` field.
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -67,6 +70,11 @@ import sys
bundle = pathlib.Path(sys.argv[1])
version, target, source_sha = sys.argv[2], sys.argv[3], sys.argv[4]
tool = json.loads((bundle / 'tool.json').read_text())
requires = tool.get('requires') or {}
if 'compatibility' in tool:
raise SystemExit('tool.json must not contain a compatibility field')
if requires != {'api_revision': 1, 'analysis': 3, 'observation': 1}:
raise SystemExit('tool.json requires must be exactly api_revision 1 / analysis 3 / observation 1')
files = []
for path in sorted(bundle.rglob('*')):
if not path.is_file():
@@ -88,12 +96,15 @@ info = {
'command': 'view',
'target': target,
'source_sha': source_sha,
'compatibility': {
'marqdo': '>=3.0.0-beta.1,<4.0.0',
'analysis': tool['compatibility']['analysis'],
'trace': [2],
'tool_protocol': 1,
'requires': {
'api_revision': 1,
'analysis': 3,
'observation': 1,
},
'release': {
'product_range': '>=3.0.0-rc.3,<4.0.0',
'markdown_profile': 'marqdo.md.v1',
'platform': 'linux-x86_64-glibc2.39',
},
'files': files,
}
+2 -1
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
# Browser acceptance for the Live reader: real Chromium, real frozen core.
# Browser acceptance for the Live reader: real Chromium, real frozen core
# pinned to marqdo 3.0.0-rc.4 (Analysis revision 3, Observation revision 1).
#
# Usage:
# MARQDO_BIN=/abs/path/marqdo scripts/test-browser.sh
+14 -9
View File
@@ -1,5 +1,9 @@
#!/usr/bin/env python3
"""HTTP and ZIP acceptance against an unmodified RC.2 release binary."""
"""HTTP and ZIP acceptance against the frozen rc.4 release binary.
The View consumes Observation v1 (`--output jsonl` / `--observation-file`);
there is no trace file or legacy JSON run envelope.
"""
import hashlib
import http.cookiejar
@@ -67,7 +71,7 @@ def verify_zip(payload, destination, expected_digest):
assert manifest["execution"]["source_verified"] and manifest["execution"]["status"] == "succeeded"
assert manifest["execution"]["parameters"] == "omitted"
assert manifest["source"]["document"] == "index.mq.md"
assert manifest["execution"]["core_protocol"] == {"analysis": 3, "trace": 2, "events": 1}
assert manifest["execution"]["contracts"] == {"api_revision": 1, "analysis": 3, "observation": 1}
for entry in manifest["files"] + manifest["assets"]:
data = archive.read(entry["path"])
assert sha(data) == entry["sha256"] and len(data) == entry["size"]
@@ -104,11 +108,12 @@ def check(root):
"import os, subprocess, sys, time\n"
f"core, count = {str(CORE)!r}, {str(count)!r}\n"
"if sys.argv[1] in ('run', 'call'):\n"
" assert '--event-stream' in sys.argv and '--json' not in sys.argv\n"
" assert sys.argv[sys.argv.index('--output') + 1] == 'jsonl' and '--observation-file' in sys.argv\n"
" assert '--json' not in sys.argv and '--trace-file' not in sys.argv\n"
" with open(count, 'a') as f: f.write(sys.argv[1]+'\\n')\n"
" if sys.argv[1] == 'call' and sys.argv[3] == 'write_markup':\n"
" result = subprocess.run([core, *sys.argv[1:]], check=False)\n"
" os.unlink(sys.argv[sys.argv.index('--trace-file') + 1])\n"
" os.unlink(sys.argv[sys.argv.index('--observation-file') + 1])\n"
" sys.exit(result.returncode)\n"
" if sys.argv[1] == 'call' and sys.argv[3] == 'scan': time.sleep(2)\n"
"os.execv(core, [core, *sys.argv[1:]])\n"
@@ -158,7 +163,7 @@ def check(root):
run_id, terminal = observe(submit("write_output", "one"))
assert terminal["state"] == "succeeded" and terminal["result"]["stdout"] == "4\n", terminal
assert terminal["result"]["trace_status"] == "verified"
assert terminal["result"]["observation_status"] == "verified"
assert count.read_text().splitlines() == ["call"]
selection = {
"schema": "marqdo.view-static-export-request",
@@ -167,7 +172,7 @@ def check(root):
"document": "index.mq.md",
"analysis_digest": digest,
"scope": "document",
"include": {"result_value": True, "stdout": True, "stderr": False, "arguments": False, "trace_summary": True},
"include": {"result_value": True, "stdout": True, "stderr": False, "arguments": False, "observation_summary": True},
"confirm_sensitive_output": True,
"client_export_request_id": "zip-one",
}
@@ -263,16 +268,16 @@ def check(root):
assert json.loads(archive.read("manifest.json"))["execution"]["status"] == "failed"
text_id, text = observe(submit("write_markup", "markup"))
assert text["state"] == "succeeded" and text["result"]["trace_status"] == "unavailable", text
assert text["state"] == "succeeded" and text["result"]["observation_status"] == "unavailable", text
assert text["result"]["stdout"] == attack_text.decode()
text_zip, _ = post(browser, base, "/api/exports", token, {**selection, "run_id": text_id})
with zipfile.ZipFile(io.BytesIO(text_zip)) as archive:
html = archive.read("index.html").decode()
assert "<script>" not in html and "&lt;script&gt;bad()" in html
assert json.loads(archive.read("manifest.json"))["execution"]["trace_status"] == "unavailable"
assert json.loads(archive.read("manifest.json"))["execution"]["observation_status"] == "unavailable"
first, headers = post(browser, base, "/api/exports", token, selection)
verify_zip(first, None, headers["X-Marqdo-Manifest-SHA256"])
print("active/cancelled export denied, verified failure gated, stdout escaped, missing Trace separate")
print("active/cancelled export denied, verified failure gated, stdout escaped, missing Observation separate")
print("selected IDs remain isolated, tampering detected, oversized request denied, failed and aborted packages cleaned")
calls = count.read_text().splitlines()
assert calls == ["call"] * 4, calls
+3 -2
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
# Contract-focused gate: formatting, lints, all tests, Tool v1 install smoke,
# static verify and static export against the frozen core. No browser.
# Contract-focused gate: formatting, lints, all tests, CLI Tool revision 1
# install smoke, static verify and static export against the frozen core.
# No browser. Current contracts: Analysis revision 3, Observation revision 1.
#
# Usage: MARQDO_BIN=/abs/path/marqdo scripts/test-contract.sh
set -euo pipefail
+1
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
# Static export acceptance: pure read-only, offline assets, safe paths.
# One renderer for Live and Export; no execution, no network.
#
# Usage: MARQDO_BIN=/abs/path/marqdo scripts/test-export.sh
set -euo pipefail
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# RFC-VIEW-0002 §13.4 / §6 / §10.3: opening, searching, switching and exporting
# must never execute a document. Uses the unsafe-side-effect fixture and checks
# Opening, searching, switching and exporting must never execute a document
# (zero-execution baseline, current rc.4 contracts). Uses the unsafe-side-effect fixture and checks
# source/lock hashes plus the absence of any write sentinel around the whole
# read-only operation set.
#
+1 -1
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Prove a frozen marqdo release binary is byte-identical before and after a
# command sequence (RFC-VIEW-0002 §2 / §9.4 / §10.2).
# command sequence (issue #4/#5 release evidence).
#
# Usage:
# scripts/verify-frozen-cli.sh /abs/path/marqdo [-- EXPECTED_SHA256] -- CMD [ARGS...]