open-standards/wai/tools/quantum-docs/ci.sh
Transaction Science b894f1bbc5 wai-quantum contract over the course and the docs: the course's schemas in schemas/, its checks named, every page run, the translations in step, and the views in English
The course's documents join the version contract. The course as kept and as
served (wai.quantum.course/1) and each exercise (wai.quantum.exercise/1) move
from course/schema/ to the crate's schemas/, named and versioned as the rest;
a check, a lesson as served and a hint are wai.quantum.course-check/1, and a
check now names its engine beside its schema; the command line's progress
file is wai.quantum.learn-progress/1. The engine's test holds the course,
every exercise, every lesson in each locale and a check and hint of some to
them; the learn test holds the progress file; the contract workflow requires
both, and the eval and lease tests, by name, and runs when the answer and
eval sets its tests read change.

The docs runner reads every page the branches added: the error-correction
page, the version policy, the deprecations page, the service's self-hosting,
scheduler and provenance pages, and the views' README. Each block the other
branches wrote either runs or says why it cannot (a sweep fixture added), and
the job service it starts keeps its store in its scratch. The crate's README
names wai-quantum 0.7. The Chinese READMEs hold the English pages' code again:
the sections for error correction, sets and sweeps, the service's dry runs,
the scheduler, scoring a model, the answer layer, views and versions are
translated, and the compile pages name the gate set basis. The command
line's Chinese words cover task, qec, eval and version, and submit as it
reads now. The documentation index links the policy, the deprecations, the
error-correction page and the service's pages in both languages.

The policy lists every schema file and says the answer layer is a draft
outside its promise. The 0.7.0 heading names what the four branches bring.

The views page bundles the Studio components that now read their words
through the locale module; build-views.mjs gives it the English words alone,
so no other language's words reach a host. The result parts the Studio and
the views share read their words through it too, so the Studio's result pane
stays translated, its English unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 08:43:06 -04:00

55 lines
3 KiB
Shell

#!/usr/bin/env bash
# The documentation's whole check, as CI runs it (.github/workflows/wai-quantum-docs.yml)
# and as a person runs it on a build host:
#
# bash wai/tools/quantum-docs/ci.sh [check_docs.py's own arguments, as --only PATH]
#
# 1. builds the command line and the job service from this checkout;
# 2. builds the Python package's wheel with maturin (pinned) and installs it in a
# fresh venv with the pinned, hashed test requirements;
# 3. starts a job service here, as the service's workflow starts it;
# 4. runs check_docs.py over every page docs.json names: every runnable block run,
# every shown output held to the real one, every receipt verified, the Rust
# blocks built, and every block that cannot run checked for what it names.
#
# Needs cargo (the toolchain rust-toolchain.toml names), uv and curl. Scratch goes under
# $WORK (default: $RUNNER_TEMP/wai-quantum-docs, or a new temporary directory); cargo
# builds into $CARGO_TARGET_DIR (default: $WORK/target).
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WAI="$(cd "$HERE/../.." && pwd)"
WORK="${WORK:-${RUNNER_TEMP:-$(mktemp -d)}/wai-quantum-docs}"
mkdir -p "$WORK"
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$WORK/target}"
PY="${WAI_QUANTUM_PYTHON:-3.12}"
MATURIN=1.15.0
step() { echo; echo "== $*"; }
step "the command line and the job service, from this checkout"
(cd "$WAI/wai-quantum-cli" && cargo build --locked --release)
(cd "$WAI/wai-quantum-service" && cargo build --locked --release)
CLI="$CARGO_TARGET_DIR/release/wai-quantum"
SVC="$CARGO_TARGET_DIR/release/wai-quantum-service"
"$CLI" --version
step "the Python package (maturin $MATURIN), in a fresh venv"
rm -rf "$WORK/tools" "$WORK/dist" "$WORK/venv"
uv venv -q --python "$PY" "$WORK/tools"
uv pip install -q --python "$WORK/tools/bin/python" "maturin==$MATURIN"
(cd "$WAI/wai-quantum-py" && "$WORK/tools/bin/maturin" build --release --locked -o "$WORK/dist")
uv venv -q --python "$PY" "$WORK/venv"
uv pip install -q --python "$WORK/venv/bin/python" --require-hashes -r "$WAI/wai-quantum-py/tests/requirements.lock"
uv pip install -q --python "$WORK/venv/bin/python" --no-deps "$(ls "$WORK"/dist/wai_quantum-*.whl)"
step "a job service, started here"
port=$(( 18600 + RANDOM % 500 ))
cfg="$WORK/qsvc"; rm -rf "$cfg"; mkdir -p "$cfg"
WAI_QSVC_KEY="$cfg/service.key" WAI_QSVC_STORE="$cfg/store" WAI_QSVC_ADDR="127.0.0.1:$port" WAI_QSVC_BUDGET_GB=4 WAI_QSVC_JOB_GB=2 WAI_QSVC_WORKERS=1 \
WAI_QSVC_MIN_FREE_PCT=0 WAI_QSVC_CLIENT_BURST=10000 "$SVC" serve > "$cfg/service.log" 2>&1 &
pid=$!
trap 'kill $pid 2>/dev/null || true' EXIT
for _ in $(seq 1 100); do curl -fs -o /dev/null "http://127.0.0.1:$port/v1/health" && break; sleep 0.2; done
curl -fs -o /dev/null "http://127.0.0.1:$port/v1/health" || { echo "::error::the job service did not start"; cat "$cfg/service.log"; exit 1; }
step "every page, run"
python3 "$HERE/check_docs.py" --cli "$CLI" --service "http://127.0.0.1:$port" --python "$WORK/venv/bin/python" --rust "$@"