feat(PR-06): RFC §13.3 examples, export closure, acceptance and docs finalization
- add examples/{welcome,branch-loop,function-params,knowledge-only,
unsafe-side-effect}.mq.md + explicit examples/view.json; all validated against
the frozen CLI (double(5)=Int 10, branch-loop Int 0 with loop/return Trace,
knowledge-only sem.no_entry_function, unsafe write only with explicit project
grants) via scripts/check-examples.sh
- add scripts/test-no-exec.sh sentinel suite: browse/list/search/reload/export of
the write fixture keeps source+lock hashes unchanged, writes no sentinel and
produces exported HTML with no run controls/CSRF/external URLs
- static export no longer renders run controls (no run dock button/tab/call
buttons/run dialog); only settings/more remain
- extend scripts/acceptance.sh with examples_check and no_exec_suite gates and
extend the evidence manifest tests map
- rewrite docs/ACCEPTANCE.md against RFC §9/§10 with E01-E16/N01-N22 mapping;
finalize STATUS/CONFORMANCE/README/COMPATIBILITY/CHANGELOG for 0.2.0
- record PR-06 evidence logs (examples, no-exec, pre-commit acceptance)
This commit is contained in:
1 parent
807c24b952
commit
0fceb40088
24 files changed
+1227
-171
No files matched your search
@@ -72,6 +72,7 @@ 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'"
|
||||
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"
|
||||
|
||||
# 3. Live browse smoke (no execution on open)
|
||||
@@ -126,6 +127,7 @@ trap - EXIT
|
||||
|
||||
# 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
|
||||
if [[ "${SKIP_BROWSER:-0}" == "1" ]]; then
|
||||
record browser SKIP
|
||||
@@ -175,8 +177,10 @@ manifest = {
|
||||
"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,
|
||||
|
||||
Executable
+95
@@ -0,0 +1,95 @@
|
||||
#!/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.
|
||||
#
|
||||
# Usage: MARQDO_BIN=/abs/path/marqdo scripts/check-examples.sh
|
||||
set -euo pipefail
|
||||
|
||||
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)"
|
||||
|
||||
work="$repo_root/dist/examples-check"
|
||||
rm -rf "$work"
|
||||
mkdir -p "$work"
|
||||
cp examples/welcome.mq.md examples/branch-loop.mq.md examples/function-params.mq.md \
|
||||
examples/knowledge-only.mq.md examples/unsafe-side-effect.mq.md "$work/"
|
||||
cp examples/view.json "$work/"
|
||||
|
||||
cd "$work"
|
||||
|
||||
echo "==> check all five example documents (no execution)"
|
||||
for file in welcome.mq.md branch-loop.mq.md function-params.mq.md knowledge-only.mq.md unsafe-side-effect.mq.md; do
|
||||
"$MARQDO_BIN" check "$file" --emit "analysis-$file.json" --json >/dev/null
|
||||
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)")
|
||||
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"]}
|
||||
assert "loop.iteration" in kinds and "return" in kinds, kinds
|
||||
print("run branch-loop: PASS (value 0, events: %s)" % ",".join(sorted(kinds)))
|
||||
PY
|
||||
|
||||
echo "==> knowledge-only has no main (truthful failure, no fallback)"
|
||||
set +e
|
||||
"$MARQDO_BIN" run knowledge-only.mq.md --mode pure --json > knowledge.json 2>&1
|
||||
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
|
||||
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
|
||||
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"]
|
||||
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
|
||||
test -f out/view-sentinel.txt
|
||||
python3 - <<'PY'
|
||||
content = open("out/view-sentinel.txt", "rb").read()
|
||||
assert content == b"explicit run only\n", content
|
||||
print("unsafe-side-effect project+grants: PASS (sentinel written explicitly)")
|
||||
PY
|
||||
rm -rf out
|
||||
|
||||
core_sha_after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
||||
test "$core_sha_before" = "$core_sha_after"
|
||||
echo "examples: PASS (frozen CLI sha256 $core_sha_before unchanged)"
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
#!/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
|
||||
# source/lock hashes plus the absence of any write sentinel around the whole
|
||||
# read-only operation set.
|
||||
#
|
||||
# Usage: MARQDO_BIN=/abs/path/marqdo scripts/test-no-exec.sh
|
||||
set -euo pipefail
|
||||
|
||||
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)"
|
||||
binary="$repo_root/target/release/marqdo-view"
|
||||
if [[ ! -x "$binary" ]]; then
|
||||
cargo build --release --locked
|
||||
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"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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 &
|
||||
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)"
|
||||
[[ -n "$url" ]] && break
|
||||
sleep 0.1
|
||||
done
|
||||
test -n "$url"
|
||||
cookie_jar="$work/cookies.txt"
|
||||
curl -fsS -c "$cookie_jar" "${url}" > "$work/page.html"
|
||||
curl -fsS -c "$cookie_jar" -b "$cookie_jar" "${url}file?path=unsafe-side-effect.mq.md" >/dev/null
|
||||
curl -fsS -b "$cookie_jar" "${url}api/documents" >/dev/null
|
||||
curl -fsS -b "$cookie_jar" "${url}api/documents?path=unsafe-side-effect.mq.md" >/dev/null
|
||||
# Reloading the page multiple times must remain side-effect free.
|
||||
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
|
||||
|
||||
echo "==> Static export"
|
||||
"$binary" 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
|
||||
echo "error: exported page contains a run control" >&2
|
||||
exit 1
|
||||
fi
|
||||
if grep -q 'mq-csrf-token' "$work/site/pages/unsafe-side-effect.mq.md.html"; then
|
||||
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
|
||||
diff <(printf '%s\n' "$before") <(printf '%s\n' "$after") >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
test ! -e "$sentinel"
|
||||
test ! -e examples/out
|
||||
|
||||
core_sha_after="$(sha256sum "$MARQDO_BIN" | cut -d' ' -f1)"
|
||||
test "$core_sha_before" = "$core_sha_after"
|
||||
echo "no-exec: PASS (sources/lock unchanged, no sentinel, no run control in export; core sha unchanged)"
|
||||
Reference in new issue
Block a user