S8 — verified command sequence
Execution order for the S8 lab, with the panel/dashboard path beside each step.
lab.md is the learner-facing form; this file is generated from the verified
runner trace with secrets replaced by placeholders and kept in execution order.
Shell plumbing (set -euo pipefail, exec, if, cd) is omitted because it
carries no lab evidence and changes no state outside the shell.
The lab provisions no cloud resource. The only paid resource is the OpenRouter credit balance; the only credential is the API key.
0. Panel steps (no CLI path)
| Step | Panel path | What to do |
|---|---|---|
| Account | S6 OpenRouter account | Reuse it; do not create a second account |
| Top-up | Settings → Credits | Balance to $10; 5.5% purchase fee, $0.80 minimum (≈$10.55 charged) |
| Auto top-up | Settings → Credits | Off — an auto top-up would spend beyond the reimbursement |
| Key | Keys → Create key | course-s8-<id>; shown once; stored in .env, never committed |
| Privacy | Settings → Privacy | Leave the training toggles at course defaults for A–D |
| ZDR-only | Settings → Privacy → ZDR | Set ZDR only in Step 6, then retry C and D |
1. Store the key and confirm the account
umask 077
printf 'OPENROUTER_API_KEY=%s\n' '<paste-the-key-here>' > .env
chmod 600 .env
set -a; . ./.env; set +a
export RESULTS=results
mkdir -p "$RESULTS"
curl -sS https://openrouter.ai/api/v1/key -H "Authorization: Bearer $OPENROUTER_API_KEY" -o "$RESULTS/key-before.json"
jq '{usage, limit, limit_remaining, is_free_tier, free_model_daily_requests}' "$RESULTS/key-before.json"
umask 077 and chmod 600 make .env private. The curl reads the key's
usage, limit, remaining balance and free-tier state; the jq prints the fields
that go into evidence item 2.
2. Snapshot the catalogue
export SNAPSHOT_DIR=data
mkdir -p "$SNAPSHOT_DIR"
curl -sS https://openrouter.ai/api/v1/models/deepseek/deepseek-v4.1-flash-1017/endpoints -o "$SNAPSHOT_DIR/endpoints-deepseek.json"
curl -sS https://openrouter.ai/api/v1/models/google/gemini-4-hydrogen/endpoints -o "$SNAPSHOT_DIR/endpoints-gemini.json"
curl -sS https://openrouter.ai/api/v1/endpoints/zdr -o "$SNAPSHOT_DIR/endpoints-zdr.json"
curl -sS https://openrouter.ai/api/v1/models/user -H "Authorization: Bearer $OPENROUTER_API_KEY" -o "$SNAPSHOT_DIR/models-user-before.json"
export S8_SNAPSHOT_DIR="$SNAPSHOT_DIR"
export S8_SNAPSHOT_DATE="$(date -u +%F)"
The first two curl calls fetch every provider endpoint for each model. The
third fetches the ZDR preview with safety_retention per endpoint (the shipped
copy keeps the rows for the two studied models and records the catalogue total). The fourth
records the account's current model settings. The exports tell the notebook
where the fresh snapshots are and what date to stamp on them.
3. Redact the transcripts and strip EXIF
python3 redact.py --pack ../../assets/synthetic-media --out "$RESULTS/redaction"
uv run --with-requirements requirements-local.txt python redact.py --pack ../../assets/synthetic-media --out "$RESULTS/redaction"
The helper redacts all 100 transcripts, strips EXIF from all 20 photos, and
writes redaction-report.json with the before/after counts. The second form
pins Pillow 11.3.0 through the project environment.
4. Predict and apply the rule
No shell command. Open notebook.ipynb and run Steps 1–4: the join of the model
lists to the ZDR list prints the prediction table, and the six-part rule is
evaluated against the cases.
5. Make calls A–D
test -n "${OPENROUTER_API_KEY:-}"
export OPENROUTER_LIVE=1
python3 run_notebook.py notebook.ipynb
S8_OUT="$RESULTS" uv run --with-requirements requirements-local.txt python run_notebook.py notebook.ipynb
The notebook sends A (raw prompt to the first-party endpoint), B (the same
request with ZDR and data_collection: deny, refused), C (redacted text and the
stripped image, no provider pinned) and D (the same payload on Gemini Vertex).
It records status, serving provider, safety_retention, usage and cost.
6. ZDR-only retry
curl -sS https://openrouter.ai/api/v1/models/user -H "Authorization: Bearer $OPENROUTER_API_KEY" -o "$SNAPSHOT_DIR/models-user-zdr-only.json"
export OPENROUTER_ZDR_ONLY=1
python3 run_notebook.py notebook.ipynb
S8_OUT="$RESULTS" uv run --with-requirements requirements-local.txt python run_notebook.py notebook.ipynb
After the panel toggle, refetch the account settings, then rerun. C still succeeds; D fails closed because every remaining Gemini ZDR endpoint carries a safety-retention carve-out.
7. Rule and register
No shell command. Edit data/governance-rule.json and data/register.json,
then rerun the notebook to rescore the rows.
8. Verify
bash verify.sh "$RESULTS"
EXPECTED_MODE=live bash verify.sh "$RESULTS"
EXPECTED_MODE=canned bash verify.sh "$RESULTS"
The verifier asserts the artifact, the endpoint counts, the redaction and EXIF
diffs, the call statuses, the serving endpoint, the cost ceiling, the register
vocabulary, the secret scan, the withdrawn-provider scan and the command parity
between this file and lab.md.
9. Teardown
curl -sS https://openrouter.ai/api/v1/key -H "Authorization: Bearer $OPENROUTER_API_KEY" -o "$RESULTS/key-after.json"
jq '{usage, limit_remaining}' "$RESULTS/key-after.json"
rm -f "$RESULTS/redacted-transcripts.jsonl"
rm -rf "$RESULTS/photos"
unset OPENROUTER_API_KEY
rm -f .env
The balance is evidence item 10. The rm commands delete regenerable working
files; the reports, snapshots and inference_results.json stay. If the key is
kept for the capstone, skip unset and rm -f .env and say so in the teardown
log. Panel: confirm auto top-up is still off.
Reference run
uv run --with-requirements requirements-local.txt python --version
uv run --with-requirements requirements-local.txt python -c 'import PIL; print("Pillow", PIL.__version__)'
MODE=canned bash run.sh
MODE=live bash run.sh
REFRESH=1 MODE=live bash run.sh
MODE=live ZDR_ONLY=1 bash run.sh
run.sh runs the commands in this file in order. MODE=canned uses the shipped
snapshots and canned calls; MODE=live requires OPENROUTER_API_KEY;
REFRESH=1 fetches fresh snapshots into results/snapshots/; ZDR_ONLY=1
records the post-toggle retry. The learner types the commands in lab.md; the
runner is the verified reference, not the step.