feat: migrate View 0.3.0 to marqdo 3.0.0-rc.4 contracts
ci/woodpecker/push/woodpecker Pipeline was successful
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:
1 parent
7b34199c96
commit
a802f96b6e
109 files changed
+14000
-6461
No files matched your search
+385
-157
@@ -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
|
||||
Reference in new issue
Block a user