ci: run View acceptance against the pinned official beta archive

This commit is contained in:
cflmy committed 2026-11-22 20:59:12 +08:00
1 parent 8c00ae3ea1
commit 95584c3120
9 files changed
+223 -190

No files matched your search

+71 -35
View File
@@ -1,11 +1,11 @@
#!/usr/bin/env bash
# RFC-VIEW-0001 §18.1 one-command acceptance.
# RFC-VIEW-0002 §9.4 one-command acceptance.
#
# Usage:
# MARQDO_BIN=/abs/path/to/frozen/marqdo scripts/acceptance.sh
#
# Optional:
# CLI_SOURCE_SHA=<sha> override the CLI source SHA for the evidence manifest
# VIEW_EVIDENCE_OUT=path override dist/acceptance/manifest.json
# SKIP_BROWSER=1 skip Chromium suite (recorded as SKIP, not PASS)
#
# The script never modifies or recompiles the frozen CLI; it records its
@@ -17,13 +17,16 @@ cd "$repo_root"
: "${MARQDO_BIN:?set MARQDO_BIN to the frozen marqdo release binary}"
[[ -x "$MARQDO_BIN" ]] || { echo "error: MARQDO_BIN not executable" >&2; exit 1; }
MARQDO_BIN="$(realpath "$MARQDO_BIN")"
export MARQDO_BIN
"$repo_root/scripts/frozen-beta.sh" verify "$MARQDO_BIN"
work="$repo_root/dist/acceptance"
rm -rf "$work"
mkdir -p "$work"
statuses=""
record() { statuses="${statuses}$1=$2\n"; echo "[acceptance] $1: $2"; }
record() { statuses+="$1=$2"$'\n'; echo "[acceptance] $1: $2"; }
run_step() {
local name="$1"
@@ -38,17 +41,28 @@ run_step() {
}
core_before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
cli_source_sha="${CLI_SOURCE_SHA:-}"
if [[ -z "$cli_source_sha" && -f "$(dirname "$MARQDO_BIN")/SOURCE_SHA" ]]; then
cli_source_sha="$(tr -d '[:space:]' < "$(dirname "$MARQDO_BIN")/SOURCE_SHA")"
fi
cli_source_sha="${cli_source_sha:-unknown}"
cli_source_sha="$(cat "$(dirname "$MARQDO_BIN")/SOURCE_SHA")"
view_source_sha="$(git rev-parse HEAD 2>/dev/null || echo unknown)"
export PATH="${HOME}/.cargo/bin:${PATH}"
export CARGO_HOME="${CARGO_HOME:-$repo_root/.cargo-home}"
# 0. code quality / unit / contract tests
check_wrong_cli() {
mkdir -p "$work/wrong-cli"
cp "$(dirname "$MARQDO_BIN")/SOURCE_SHA" "$work/wrong-cli/SOURCE_SHA"
cat >"$work/wrong-cli/marqdo" <<'FAKE'
#!/usr/bin/env bash
touch "$(dirname "$0")/executed"
FAKE
chmod +x "$work/wrong-cli/marqdo"
if scripts/frozen-beta.sh verify "$work/wrong-cli/marqdo"; then
echo "error: mismatched CLI passed the baseline check" >&2
return 1
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 --all-targets -- -D warnings
run_step test cargo test --locked
@@ -57,19 +71,28 @@ run_step build cargo build --release --locked
# 1. controlled Tool bundle + frozen-CLI install smoke
run_step bundle env MARQDO_BIN="$MARQDO_BIN" ./scripts/package.sh
bundle="$repo_root/dist/marqdo-view"
archive="$(ls -t "$repo_root"/dist/marqdo-view-*-x86_64-unknown-linux-gnu.tar.gz | head -1)"
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
mkdir -p "$work/extracted"
tar -xzf "$archive" -C "$work/extracted"
extracted_bundle="$work/extracted/marqdo-view"
(cd "$extracted_bundle" && sha256sum -c SHA256SUMS)
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"
run_step tool_list bash -c "'$MARQDO_BIN' tool list | grep -q view"
run_step view_help bash -c "'$MARQDO_BIN' view --help | grep -q 'marqdo-view'"
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
@@ -131,12 +154,22 @@ run_step no_exec_suite env MARQDO_BIN="$MARQDO_BIN" ./scripts/test-no-exec.sh
run_step security_suite ./scripts/test-security.sh
if [[ "${SKIP_BROWSER:-0}" == "1" ]]; then
record browser SKIP
elif [[ -d "$repo_root/tests/browser/node_modules/playwright" && -d "$repo_root/tests/.cache/pw-browsers" ]]; then
run_step browser env MARQDO_BIN="$MARQDO_BIN" ./scripts/test-browser.sh
else
record browser SKIP
run_step browser env MARQDO_BIN="$MARQDO_BIN" ./scripts/test-browser.sh
fi
check_tampered_install() {
local output
printf 'x' >> "$tool_home/view/bin/marqdo-view" || return 1
if output="$("$MARQDO_BIN" view --version 2>&1)"; then
echo "error: tampered Tool installation was dispatched" >&2
return 1
fi
grep -q 'bundle hash mismatch' <<<"$output"
}
run_step tool_tamper_refused check_tampered_install
run_step tool_remove "$MARQDO_BIN" tool remove view
# 6. frozen core must be byte-identical
core_after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
if [[ "$core_before" != "$core_after" ]]; then
@@ -147,33 +180,32 @@ fi
record core_sha PASS
view_binary_sha="$(sha256sum "$bundle/bin/marqdo-view" | cut -d' ' -f1)"
target="$(python3 -c 'import json;print(json.load(open("dist/marqdo-view/RELEASE_INFO.json"))["target"])')"
evidence_dir="$repo_root/docs/evidence/$cli_source_sha"
mkdir -p "$evidence_dir"
python3 - "$evidence_dir/manifest.json" <<PY
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 = pathlib.Path("$evidence_dir/manifest.json")
statuses = {}
for line in """${statuses}""".splitlines():
if "=" in line:
name, value = line.split("=", 1)
statuses[name] = value
(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",
"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",
"target": target,
"archive_sha256": archive_sha,
"generated_at_utc": datetime.datetime.now(datetime.timezone.utc).isoformat(),
"tests": {
"contract": statuses.get("test", "FAIL"),
@@ -189,11 +221,15 @@ manifest = {
"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")
path.write_text(json.dumps(manifest, indent=2, sort_keys=True) + "\n")
print("evidence manifest:", path)
PY
PY_EVIDENCE
echo
echo "acceptance: PASS"
echo "evidence: $evidence_dir/manifest.json"
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"
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# Identity of the released CLI used by the RFC-VIEW-0002 acceptance gate.
set -euo pipefail
version=3.0.0-beta.1
source_sha=2c7c4f31e7a388d3fcfa717a77067e696ed13854
binary_sha=062cb56e226bee55c21d238e195920caa985e62bb3877ba7b07abcc04dc0fe3f
archive_sha=507e4cd358f75f517433935ce90d5fc2eb5cecda4f19121a68b136c83b15f317
artifact="marqdo-$version-x86_64-unknown-linux-gnu"
root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
verify() {
local binary="$1"
local install
install="$(dirname "$binary")"
if [[ ! -f "$install/SOURCE_SHA" || "$(cat "$install/SOURCE_SHA")" != "$source_sha" ]]; then
echo "error: expected the official marqdo $version installation ($source_sha)" >&2
return 1
fi
"$root/verify-frozen-cli.sh" "$binary" -- "$binary_sha" >&2
if [[ "$("$binary" --version)" != "marqdo $version" ]]; then
echo "error: frozen marqdo version does not match $version" >&2
return 1
fi
}
if [[ $# != 2 ]]; then
echo "usage: $0 fetch EMPTY_DIRECTORY | $0 verify /absolute/path/to/marqdo" >&2
exit 2
fi
case "$1" in
fetch)
mkdir -p "$2"
destination="$(cd "$2" && pwd)"
if [[ -n "$(ls -A "$destination")" ]]; then
echo "error: frozen CLI destination must be empty: $destination" >&2
exit 2
fi
archive="$destination/$artifact.tar.gz"
curl -fsSL --retry 3 --connect-timeout 15 --max-time 90 \
"https://git.cflmy.cn/cflmy/marqdo-cli/releases/download/v$version/$artifact.tar.gz" -o "$archive"
printf '%s %s\n' "$archive_sha" "$archive" | sha256sum -c - >&2
tar -xzf "$archive" -C "$destination"
verify "$destination/$artifact/marqdo"
printf '%s\n' "$destination/$artifact/marqdo"
;;
verify)
verify "$2"
;;
*)
echo "unknown frozen CLI operation: $1" >&2
exit 2
;;
esac
+8 -5
View File
@@ -29,10 +29,12 @@ if [[ ! -d "$PLAYWRIGHT_BROWSERS_PATH" ]]; then
exit 1
fi
binary="$repo_root/target/release/marqdo-view"
if [[ ! -x "$binary" ]]; then
echo "==> cargo build --release --locked"
cargo build --release --locked
if [[ "${VIEW_USE_INSTALLED_TOOL:-0}" == 1 ]]; then
view=("$MARQDO_BIN" view)
else
binary="$repo_root/target/release/marqdo-view"
[[ -x "$binary" ]] || cargo build --release --locked
view=("$binary")
fi
server_pid=""
@@ -49,7 +51,7 @@ run_suite() {
local log
log="$(mktemp "$repo_root/tests/.cache/browser-server.XXXXXX.log")"
echo "==> browser suite: $project"
"$binary" "$project" --port 0 --no-open >"$log" 2>&1 &
"${view[@]}" "$project" --port 0 --no-open >"$log" 2>&1 &
server_pid=$!
local url=""
for _ in $(seq 1 100); do
@@ -77,6 +79,7 @@ run_suite() {
mkdir -p "$repo_root/tests/.cache" "$MQ_SCREENSHOT_DIR"
run_suite examples/welcome
run_suite examples/control-flow
run_suite examples/function-params.mq.md
run_suite tests/fixtures/security-project
core_after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
+8 -3
View File
@@ -11,12 +11,17 @@ cd "$repo_root"
[[ -x "$MARQDO_BIN" ]] || { echo "error: MARQDO_BIN not executable" >&2; exit 1; }
core_before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
binary="$repo_root/target/release/marqdo-view"
[[ -x "$binary" ]] || cargo build --release --locked
if [[ "${VIEW_USE_INSTALLED_TOOL:-0}" == 1 ]]; then
view=("$MARQDO_BIN" view)
else
binary="$repo_root/target/release/marqdo-view"
[[ -x "$binary" ]] || cargo build --release --locked
view=("$binary")
fi
site="$repo_root/dist/test-export-site"
rm -rf "$site"
MARQDO_BIN="$MARQDO_BIN" "$binary" export examples/welcome --out "$site"
MARQDO_BIN="$MARQDO_BIN" "${view[@]}" export examples/welcome --out "$site"
python3 - "$site" <<'PY'
import hashlib
+39 -23
View File
@@ -12,32 +12,49 @@ cd "$repo_root"
: "${MARQDO_BIN:?set MARQDO_BIN to the frozen marqdo binary}"
core_sha_before="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
binary="$repo_root/target/release/marqdo-view"
if [[ ! -x "$binary" ]]; then
cargo build --release --locked
if [[ "${VIEW_USE_INSTALLED_TOOL:-0}" == 1 ]]; then
view=("$MARQDO_BIN" view)
else
binary="$repo_root/target/release/marqdo-view"
[[ -x "$binary" ]] || cargo build --release --locked
view=("$binary")
fi
work="$repo_root/dist/no-exec"
rm -rf "$work"
mkdir -p "$work"
doc="examples/unsafe-side-effect.mq.md"
sentinel="examples/out/view-sentinel.txt"
mkdir -p "$repo_root/dist"
work="$(mktemp -d "$repo_root/dist/no-exec.XXXXXX")"
pid=""
cleanup() {
if [[ -n "$pid" ]]; then
kill "$pid" 2>/dev/null || true
wait "$pid" 2>/dev/null || true
fi
rm -rf "$work"
}
trap cleanup EXIT
project="$work/project"
mkdir "$project"
cp examples/unsafe-side-effect.mq.md "$project/"
cat > "$project/marqdo.yaml" <<'YAML'
project:
name: view-no-exec
version: 0.1.0
dependencies: {}
YAML
(cd "$project" && "$MARQDO_BIN" lock >/dev/null)
doc="$project/unsafe-side-effect.mq.md"
sentinel="$project/out/view-sentinel.txt"
hash_tree() {
find examples -type f -name '*.mq.md' -print0 | sort -z | xargs -0 sha256sum
if [[ -f examples/marqdo.yaml ]]; then sha256sum examples/marqdo.yaml; fi
if [[ -f examples/view.json ]]; then sha256sum examples/view.json; fi
if [[ -f marqdo.lock ]]; then sha256sum marqdo.lock; fi
sha256sum "$doc" "$project/marqdo.yaml" "$project/marqdo.lock"
}
rm -rf examples/out
before="$(hash_tree)"
test ! -e "$sentinel"
echo "==> Live read-only requests"
"$binary" "$doc" --port 0 --no-open >"$work/server.log" 2>&1 &
"${view[@]}" "$doc" --port 0 --no-open >"$work/server.log" 2>&1 &
pid=$!
trap 'kill "$pid" 2>/dev/null || true' EXIT
url=""
for _ in $(seq 1 100); do
url="$(grep -o 'http://127.0.0.1:[0-9]*/' "$work/server.log" | head -1 || true)"
@@ -54,10 +71,10 @@ curl -fsS -b "$cookie_jar" "${url}api/documents?path=unsafe-side-effect.mq.md" >
for _ in $(seq 1 5); do curl -fsS -b "$cookie_jar" "${url}" >/dev/null; done
kill "$pid" 2>/dev/null || true
wait "$pid" 2>/dev/null || true
trap - EXIT
pid=""
echo "==> Static export"
"$binary" export "$doc" --out "$work/site" >/dev/null
"${view[@]}" export "$doc" --out "$work/site" >/dev/null
test -f "$work/site/manifest.json"
# Export has no execution controls and no CSRF/session material.
if grep -q 'data-action="run"' "$work/site/pages/unsafe-side-effect.mq.md.html"; then
@@ -68,11 +85,6 @@ if grep -q 'mq-csrf-token' "$work/site/pages/unsafe-side-effect.mq.md.html"; the
echo "error: exported page contains a CSRF token" >&2
exit 1
fi
if grep -rqE 'https?://(?!127\.0\.0\.1|localhost)' --include='*.html' "$work/site" 2>/dev/null; then
echo "error: exported site references an external URL" >&2
exit 1
fi
after="$(hash_tree)"
if [[ "$before" != "$after" ]]; then
echo "error: read-only/export operations modified project sources" >&2
@@ -80,7 +92,11 @@ if [[ "$before" != "$after" ]]; then
exit 1
fi
test ! -e "$sentinel"
test ! -e examples/out
test ! -e "$project/out"
# Prove the fixture is capable of writing when an operator grants it.
"$MARQDO_BIN" run "$doc" --mode project --allow-write out --allow-write 'out/**' >/dev/null
grep -qx 'explicit run only' "$sentinel"
core_sha_after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
test "$core_sha_before" = "$core_sha_after"
+5 -2
View File
@@ -34,7 +34,6 @@ if [[ ! -x "$core" ]]; then
fi
sha_before="$(sha256sum "$core" | cut -d' ' -f1)"
version_line="$("$core" --version 2>&1 | head -1)"
if [[ -n "$expected" && "$expected" != "$sha_before" ]]; then
echo "error: frozen CLI SHA-256 mismatch" >&2
@@ -43,8 +42,10 @@ if [[ -n "$expected" && "$expected" != "$sha_before" ]]; then
exit 1
fi
version_line="$("$core" --version)"
command_status=0
if [[ $# -gt 0 ]]; then
"$@"
"$@" || command_status=$?
fi
sha_after="$(sha256sum "$core" | cut -d' ' -f1)"
@@ -59,3 +60,5 @@ printf 'verify-frozen-cli: PASS\n'
printf ' path: %s\n' "$core"
printf ' version: %s\n' "$version_line"
printf ' sha256: %s (unchanged)\n' "$sha_before"
exit "$command_status"