diff --git a/.crumb b/.crumb index 911b9a79..fdf3a46b 100644 --- a/.crumb +++ b/.crumb @@ -119,14 +119,14 @@ } ], "children_root": "sha256:a99206c1ace0afb823facb1b5490dc9130965e4d4b57a95e83977aa4a4862be0", - "compiled_at": "2026-10-12T02:06:41Z", + "compiled_at": "2026-10-12T02:19:18Z", "compiler": "crumb-compile/1", - "digest": "sha256:4894366ce04d8c27992fa287eeb68f24589eeb8c8bcbf7ab5e189c15f8b1f2cd", + "digest": "sha256:d6f9f40dd0581b4031e120ce560191e9045d249b533e842d513546a4088cd022", "evidence_files": 187, "evidence_root": "sha256:27ee0353cb4d4aae2b7dbce2bfe0d9f4ef2a94cd7a4555b84684d59372503280", - "files": 4034, - "generated_at_commit": "0b8a1008773ddb47bbf4bdb68fcbe88b1507a493", - "source_tree": "sha256:cb5b5619eed1659298027ff111ddb4ebc1f410bcad54138cfde8bd1ba6d71d0e" + "files": 4044, + "generated_at_commit": "384d34192db01602f69cd948bca11ea9c5494d9e", + "source_tree": "sha256:093fdaa4c406d52f66285f8fbc2761589656135526afaf5ddef462802b28855c" } }, "history": [], diff --git a/crates/aien-runtime/examples/np1_reference.rs b/crates/aien-runtime/examples/np1_reference.rs index 4df4dcf6..83abaab3 100644 --- a/crates/aien-runtime/examples/np1_reference.rs +++ b/crates/aien-runtime/examples/np1_reference.rs @@ -321,3 +321,127 @@ mod allen_tests { ); } } + +/// SPEC-v8 Section 5 deterministic replay checks (tokenizer only, no model run; +/// `AIEN_QWEN3_MODEL_DIR=`, skipped otherwise). Every prompt of +/// the v7 GB10 run is rebuilt from the frozen task file and seeds with the +/// product's own functions and the default ALLEN block, and its token ids must +/// equal the v7 record: attempt 1 of every model launch, and every retry +/// (`retry_prompt` with the previous attempt's recorded reason). Then each v7 +/// refused reply is put through the v8 `corrective_retry_prompt`, and that +/// prompt plus the task's token cap must fit the 4096-token KV context. +#[cfg(test)] +mod v8_replay { + use super::allen_prompt; + use aien_runtime::spine::{ + corrective_retry_prompt, retry_prompt, task_decision, token_ids_sha256, + }; + use serde_json::Value; + use std::path::{Path, PathBuf}; + + const KV_CONTEXT_TOKENS: usize = 4096; + + fn read(p: &Path) -> Value { + serde_json::from_slice(&std::fs::read(p).unwrap_or_else(|e| panic!("{p:?}: {e}"))).unwrap() + } + + fn copy_dir(from: &Path, to: &Path) { + for e in std::fs::read_dir(from).unwrap() { + let e = e.unwrap(); + let t = to.join(e.file_name()); + if e.file_type().unwrap().is_dir() { + std::fs::create_dir_all(&t).unwrap(); + copy_dir(&e.path(), &t); + } else { + std::fs::copy(e.path(), &t).unwrap(); + } + } + } + + #[test] + fn v7_prompts_replay_exactly_and_v8_corrective_prompts_fit() { + let Ok(dir) = std::env::var("AIEN_QWEN3_MODEL_DIR") else { + eprintln!("AIEN_QWEN3_MODEL_DIR not set: v8 replay checks skipped"); + return; + }; + let tok = aien_inference_abi::ChatTokenizer::from_model_dir(Path::new(&dir), None) + .expect("tokenizer"); + let ids = |prompt: &str| { + let msgs = vec![aien_runtime::ChatTurn { + role: "user".into(), + content: prompt.to_string(), + }]; + let text = format!( + "{}{}", + aien_runtime::format_chat(tok.template(), &msgs).expect("chat"), + aien_runtime::spine::COMPOSE_ASSISTANT_PREFIX + ); + tok.encode(&text).expect("encode") + }; + let camp: PathBuf = + Path::new(env!("CARGO_MANIFEST_DIR")).join("../../docs/campaigns/open-model-qwen3"); + let tasks = read(&camp.join("tasks-oq3-v5.json")); + let (mut checked, mut fits, mut bad) = (0, 0, Vec::::new()); + for t in tasks["tasks"].as_array().unwrap() { + let id = t["id"].as_str().unwrap(); + let rep = read(&camp.join(format!("evidence-v7/run/s3-reports/s3-report-{id}.json"))); + let attempts = rep["proposal_attempts"] + .as_array() + .cloned() + .unwrap_or_default(); + if attempts.is_empty() { + continue; // N1: refused before any model call + } + let tmp = tempfile::tempdir().unwrap(); + let ws = std::fs::canonicalize(tmp.path()).unwrap(); + if let Some(seed) = t["seed"].as_str() { + copy_dir(&camp.join(seed), &ws); + } + let ((base, _, _), _) = task_decision(t["goal"].as_str().unwrap(), &ws).unwrap(); + let base = allen_prompt(&base, "default"); + let cap = t["max_tokens"].as_u64().unwrap() as usize; + for (k, a) in attempts.iter().enumerate() { + let prompt = if k == 0 { + base.clone() + } else { + retry_prompt(&base, attempts[k - 1]["reason"].as_str().unwrap()) + }; + if let (Some(n), Some(h)) = + (a["prompt_tokens"].as_u64(), a["prompt_ids_sha256"].as_str()) + { + let got = ids(&prompt); + checked += 1; + if got.len() as u64 != n || token_ids_sha256(&got) != h { + bad.push(format!( + "{id} attempt {}: {} tokens vs v7 {n}", + k + 1, + got.len() + )); + } + } + if a["outcome"] == "refused" { + if let Some(text) = a["text"].as_str() { + let reason = a["reason"].as_str().unwrap(); + let n = ids(&corrective_retry_prompt(&base, reason, Some(text))).len(); + eprintln!( + "{id} after attempt {}: corrective prompt {n} tokens + cap {cap} = {}", + k + 1, + n + cap + ); + if n + cap <= KV_CONTEXT_TOKENS { + fits += 1; + } else { + bad.push(format!( + "{id} after attempt {}: {n} + {cap} > {KV_CONTEXT_TOKENS}", + k + 1 + )); + } + } + } + } + } + eprintln!("v8 replay: {checked} v7 prompts checked, {fits} corrective prompts fit"); + assert!(checked >= 10, "{checked}"); + assert!(bad.is_empty(), "{bad:#?}"); + } +} diff --git a/docs/campaigns/open-model-qwen3/SPEC-v8.md b/docs/campaigns/open-model-qwen3/SPEC-v8.md new file mode 100644 index 00000000..6c8b383a --- /dev/null +++ b/docs/campaigns/open-model-qwen3/SPEC-v8.md @@ -0,0 +1,119 @@ +# OPEN-MODEL-QWEN3 v8: corrective retry, qualification specification for Qwen3-8B + +**Status: DRAFT NOT FROZEN. NOT RUN. `frozen-v8.json` says DRAFT NOT FROZEN and every pin is the placeholder, so `run-qwen3-v8.sh` +refuses a real run.** Owning issue: aien-dev/aien-sovereign-core#384. Ruling: Drake 2026-10-12, aien-architecture#190 comment +6116159138 ("AIEN D1, Qwen3-8B Qualification v8": Option 3, validation-aware corrective feedback for rejected model replies). +Preceding result: RESULT-v7.md (FAIL, 259 of 334, kept as is with all its evidence). + +## 0. What v8 is + +v7 (`SPEC-v7-DRAFT.md`, frozen as `frozen-v7.json`) with one product change and one harness repair. Nothing else changes. + +```text +model = Qwen/Qwen3-8B rev b968826d9c46dd6066d109eabc6255188de91218, thinking off; the same weights and hashes as v7 +rows = the 334 declared rows of oq3-v5.decl.json, unchanged +tasks, caps, budgets, seeds = the v5 files, unchanged (documents 1024 tokens / 120 s, D6 1536 / 170 s, edits 96 / 29 s, N2 16 tokens) +attempt rule = unchanged: at most 3 attempts; attempt k > 1 starts only if the per-attempt budget is left (30 s documents, 12 s edits) +scoring = scoring-v5 score-rows.sh, unchanged; PASS only if every declared row is present once and PASS +new required = the five feature checks of Section 3 (v8-checks.sh); a v8 PASS needs the scorer PASS AND V8 CHECKS PASS +``` + +No row, threshold, task, cap, time budget, retry limit or effect authorization changes. Qwen3-8B is promoted only if the whole frozen v8 +campaign passes; a FAIL blocks the public bundle (ruling 2). If v8 fails, the remaining failures are classified before any other model or +acceleration is proposed. AIENOS CPU int8 and Omega GB10 inference acceleration are separate workstreams and not part of v8. + +## 1. Product change: corrective retry (sc#460) + +Before (v7): a refused attempt k-1 led to attempt k with the task prompt plus one sentence, "Your previous answer was refused (). +Start your answer with the line "filename: "." The model never saw what it had written. + +After (v8): `spine::corrective_retry_prompt` adds, after the exact refusal reason, the refused reply of attempt k-1 between the markers +`<<>>`, and asks for a new complete answer that meets every requirement of the goal. Rules: + +- Only attempt k-1's reply is shown, never an older one. The end marker inside a reply is replaced, so a reply cannot close the quote. + A reply longer than 8192 bytes is cut on a character boundary and marked (v7's longest refused reply was about 3 KB). +- After a timeout or an error there is no reply: the prompt is the v7 retry prompt byte for byte. +- The quoted reply is prompt text only. It never reaches the write path: only a reply that passes every check becomes a proposal, + and a committed write still needs the same authorization as before. +- Each attempt records `shown_refused_text_sha256`: the `text_sha256` of the reply its prompt showed (none on attempt 1). + +Unit tests (`crates/aien-runtime/tests/corrective_retry_test.rs`, 11, with `librx_compose` linked): see sc#460. aien-runtime 519 of 519. + +## 2. Harness repair: R1-P replays the exact GB10 prompt (sc#459) + +v7 R1-P failed because the CPU reference replay `np1_reference` was given the bare task prompt while the product puts the ALLEN style block +in front of it (164 against 99 tokens; the replies were identical). `np1_reference` now takes `NP1_REFERENCE_ALLEN=default`, which applies the +product's own `persona::prefix_prompt` with `PersonaContext::defaults()`, and records `"allen": "default"`. The v8 wrapper calls it so; it +differs from the v7 wrapper only in names and that one line (`test-v8.sh` proves it). Proof (`evidence-v8/r1p-replay-cpu.json`): the full +CPU run now gives prompt_ids_sha256 `eee4e094...adfe6`, 164 tokens, the v7 GB10 ids exactly, and the identical 26-token reply. The row R1-P +already compares `prompt_ids_sha256` and `prompt_tokens`, so it requires exact token identity, not a count. + +## 3. Feature checks and negative controls (`v8-checks.sh`, required for PASS) + +| Check | Requires | Negative control (proved red in `test-v8.sh`, 29 of 29) | +|---|---|---| +| C1 shown | attempt k>1 shows exactly attempt k-1's refused reply; nothing on attempt 1 or after a timeout or error | a retry that shows nothing after a refusal (the v7 records go red on D2, D3, D5, D6, N2) | +| C2 never kept | at most one parsed attempt, the last, and its reply equals no refused reply of the launch | accepted reply equal to a refused one | +| C3 limits | at most 3 attempts, numbered 1..n | 4 attempts | +| C4 replay | R1 CPU reference says `allen: default` and has the accepted attempt's prompt_tokens and prompt_ids_sha256 | the v7 replay (no block, 99 tokens) | +| C5 unchanged | attempt 1's prompt ids equal the v7 record of the same launch | a different attempt-1 prompt | + +Product negative controls inside the 334 rows stay as they are: N1 refused for its destination before any model call, N2 cut at 16 +tokens and refused on every attempt (in v8 its attempts 2 and 3 see the cut reply, C1, and must still be refused), containment rows, +nothing written outside the workspace, no write without authorization. + +## 4. Deterministic replay checks (before any chip time) + +`np1_reference` example test `v8_replay` (tokenizer only, `AIEN_QWEN3_MODEL_DIR`): every prompt of the v7 GB10 run, rebuilt from the frozen +task file and seeds with the product's own functions and the default ALLEN block, equals the v7 record token for token: 14 prompts +(attempt 1 of the ten model launches and the four recorded retries). Each v7 refused reply put through `corrective_retry_prompt` fits the +4096-token context with its task cap: largest D6 1013 + 1536 = 2549 tokens (D1 969 + 1024, D2 and D3 750 + 1024, D5 456 + 1024, N2 299 + 16). +Recorded at the freeze build in `evidence-v8/` (Section 6 item 5). + +## 5. Predictions (stated before any run; UNVERIFIED) + +Attempt 1 is unchanged (C5, proven by Section 4), and greedy decoding on this engine is repeatable: the v7 dry run and the v7 real run +gave the same reply sha256 and token counts on every attempt of D1, D2 and D3 (D1 d1786e61, D2 5581d0a6 then a41fb8e0, D3 9785e182 then +the same timeout). So the attempt-1 replies are predicted to equal v7's (90 percent). Then, launch by launch: + +- D4, E1, E2, R1: pass on attempt 1 as in v7 (85 percent). R1-P now PASS (95 percent): the prompt ids are proven equal in Section 2. +- N1, N2: refused as required, all their rows PASS (90 percent). +- D1: FAIL as in v7 (85 percent). Its first reply took 95.8 s of 120 s; 24.2 s were left, under the 30 s per-attempt minimum, so no second + attempt runs and the corrective retry never acts. The budget rule is not changed. +- D6: FAIL (80 percent). The first reply took 101.5 s of 170 s; a corrected 700-token essay needs about 100 s at the observed 7 tokens per + second, more than the 68.5 s left. +- D3: FAIL more likely than not (65 percent). 57.5 s are left after the first reply; an 18-line document of about 450 tokens needs about 65 s. +- D2, D5: these passed on attempt 2 in v7 with the old prompt; the corrective prompt changes attempt 2, so each may pass or fail + (pass 70 percent each). A regression here would be a result, recorded as such. +- Verdict: FAIL predicted (85 percent), because three of six document tasks are bound by the unchanged budgets, where feedback cannot act. + This prediction is a reason to run, not to skip: v8 measures what feedback does where a retry fits, and confirms or refutes the budget + reading of v7. +- V8 CHECKS PASS predicted (90 percent). + +## 6. Freeze checklist (all must be true; each is a yes or no with evidence) + +1. [ ] sc#459 (replay repair) and sc#460 (corrective retry) merged on main; this spec and its launchers merged. +2. [ ] Model files re-hashed on the chip host on the freeze day and equal to the `model` block of `frozen-v8.json` (= `frozen-v7.json`). +3. [ ] Clean build at the freeze commit (`evidence-v8/build.sh`), every pin in `frozen-v8.json` filled, checkouts clean. +4. [ ] `test-v8.sh` passes at the freeze commit; the v5 campaign file hashes still match (`evidence-v5/campaign-files.sha256`). +5. [ ] At the freeze build: aien-runtime tests pass with `librx_compose` linked (including `corrective_retry_test`), and the + deterministic replay checks of Section 4 and the R1 exact-ids test pass; outputs recorded in `evidence-v8/`. +6. [ ] `frozen-v8.json` status FROZEN in the freeze PR, merged before any launch; `quietlock check` clear. +7. [ ] Gate G6 dry run of part 1 on GB10 in its own 20-minute hold AFTER the freeze (`evidence-v8/run-dry.sh`): `g6-gate.sh` exit 0 over + D1 D2 D3 and `v8-checks.sh` PASS on the dry launches; `model_sha256` from the daemon's `CHECKPOINT_SHARDS` line equals `frozen-v8.json`. +8. [ ] Real run (`evidence-v8/run.sh`): four parts, each in its own 20-minute hold; it refuses without G6 PASS and V8 CHECKS PASS on the dry + launches. Every outcome is recorded; no part is rerun to pass. Authorization: Drake's ruling of 2026-10-12 ("followed by the authorized + GB10 qualification"). + +## 7. What v8 does not prove + +A v8 PASS would qualify Qwen3-8B with the corrective retry on these eleven launches, greedy decoding, thinking off, one run. It would not show +the model is better outside them, and the ALLEN subject is still a host-built fixture. A v8 FAIL says nothing about int8 or other +acceleration, which are separate workstreams. + +## 8. Launchers (`evidence-v8/`) + +As `evidence-v7/` with the v8 names: `build.sh `, `run-part.sh`, `run-dry.sh ` (G6 plus +`v8-checks.sh` over the dry D1 D2 D3, written to `records/v8-checks-dry.txt`), `run.sh ` (four real parts; +refuses without G6 PASS and V8 CHECKS PASS on the dry launches; runs `v8-checks.sh` over all eleven launches after part 4, written to +`records/v8-checks.txt`). Run base `~/workspace/oq3-v8-runs`, records `~/workspace/oq3-v8-real`. diff --git a/docs/campaigns/open-model-qwen3/evidence-v8/build.sh b/docs/campaigns/open-model-qwen3/evidence-v8/build.sh new file mode 100755 index 00000000..371bbd02 --- /dev/null +++ b/docs/campaigns/open-model-qwen3/evidence-v8/build.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# OPEN-MODEL-QWEN3 v8 build (SPEC-v8.md Section 3, as evidence-v7/build.sh with the v8 name): clean clone of +# sovereign-core at the given commit, pinned omega/physics/aienos via scripts/pins.sh --gpu, release build of aien-cli and +# the two campaign examples. CPU only; run `quietlock check` first and never inside another lane's hold. +set -u +SC_COMMIT=${1:?sovereign-core commit} +B=/home/drakestapleton/workspace/oq3-v8-build-${SC_COMMIT:0:7} +[ ! -e "$B" ] || { echo "build: $B exists" >&2; exit 2; } +mkdir -p "$B" +git clone -q https://github.com/aien-dev/aien-sovereign-core "$B/sc" && git -C "$B/sc" checkout -q "$SC_COMMIT" || exit 4 +cd "$B/sc" +bash scripts/pins.sh --gpu "$B/pins" > "$B/pins.out" 2>&1; echo "pins rc=$?" +. "$B/pins/env.sh" +export CARGO_TARGET_DIR=$B/target +unset AIEN_FORCE_CPU_STUB AIEN_OMEGA_GPU_LIB AIEN_OMEGA_COMPOSE_LIB AIEN_OMEGA_COMPOSE_DIR AIEN_OMEGA_COMPOSE_SHA AIEN_DEV_FALLBACK AIEN_BACKEND +env | grep '^AIEN_' | sort +date -u +%FT%TZ +echo "cargo build -vv --release -p aien-cli" +nice -n 19 cargo build -vv --release -p aien-cli > "$B/build-cli.log" 2>&1; echo "aien-cli rc=$?" +echo "cargo build -vv --release -p aien-runtime --example np1_reference --example np1_edit_merge" +nice -n 19 cargo build -vv --release -p aien-runtime --example np1_reference --example np1_edit_merge > "$B/build-examples.log" 2>&1; echo "examples rc=$?" +date -u +%FT%TZ +grep -o 'has_omega_[a-z_]*' "$B/build-cli.log" | sort -u +echo "sc $(git -C "$B/sc" rev-parse HEAD) dirty=$(git -C "$B/sc" status --porcelain | wc -l)" +for r in omega physics aienos; do [ -d "$B/pins/$r" ] && echo "$r $(git -C "$B/pins/$r" rev-parse HEAD) dirty=$(git -C "$B/pins/$r" status --porcelain | wc -l)"; done +cat "$B/pins/omega/physics.lock" "$B/pins/omega/aienos.lock" 2>/dev/null +sha256sum "$B/sc/Cargo.lock" "$B/target/release/aien-cli" "$B/target/release/examples/np1_reference" "$B/target/release/examples/np1_edit_merge" diff --git a/docs/campaigns/open-model-qwen3/evidence-v8/replay-check-prefreeze.txt b/docs/campaigns/open-model-qwen3/evidence-v8/replay-check-prefreeze.txt new file mode 100644 index 00000000..b95c1dd0 --- /dev/null +++ b/docs/campaigns/open-model-qwen3/evidence-v8/replay-check-prefreeze.txt @@ -0,0 +1,7 @@ +# SPEC-v8 Section 4 deterministic replay check, pre-freeze proof +# branch qwen3-v8/spec at main 384d341 (= 1a4c810 + sc#459) with the v8_replay test module appended to crates/aien-runtime/examples/np1_reference.rs (this PR) +# AIEN_QWEN3_MODEL_DIR=~/models/qwen3-8b; cargo test -p aien-runtime --example np1_reference v8_replay; 2026-10-12T02:18:23Z +v8 replay: 14 v7 prompts checked, 8 corrective prompts fit +test v8_replay::v7_prompts_replay_exactly_and_v8_corrective_prompts_fit ... ok +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out; finished in 0.95s +rc=0 diff --git a/docs/campaigns/open-model-qwen3/evidence-v8/run-dry.sh b/docs/campaigns/open-model-qwen3/evidence-v8/run-dry.sh new file mode 100755 index 00000000..0d208f00 --- /dev/null +++ b/docs/campaigns/open-model-qwen3/evidence-v8/run-dry.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# OPEN-MODEL-QWEN3 v8 gate G6: dry run of part 1 on GB10 in its own hold, then g6-gate.sh over D1 D2 D3 (SPEC-v8.md +# Section 5 item 7). Runs AFTER the freeze, as v6 did (frozen-v8.json FROZEN at the wrap commit): the -PIN and -GR rows +# compare the build and the generation record against the frozen pins and model hash, so a draft can only fail them (attempt 2, +# 2026-10-11, evidence-v8/attempt-2-g6-fail/). A dry run is never a verdict. Start detached ONLY on the coordinator's go for the hold: +# setsid nohup bash run-dry.sh folder> > 2>&1 < /dev/null & +set -u +WRAP_COMMIT=${1:?freeze commit}; export OQ3_BUILD=${2:?build folder} +HERE=$(cd "$(dirname "$0")" && pwd) +V=/home/drakestapleton/workspace/oq3-v8-real; R=$V/records +[ ! -e $V/dry-runs ] || { echo "run-dry: $V/dry-runs exists already (one dry run per freeze candidate; move it aside to rerun)"; exit 2; } +[ -x "$OQ3_BUILD/target/release/aien-cli" ] || { echo "run-dry: no aien-cli in $OQ3_BUILD"; exit 2; } +quietlock check || { echo "run-dry: quiet flag held, not starting"; exit 2; } +mkdir -p $R +[ -d $V/wrap ] || git clone -q https://github.com/aien-dev/aien-sovereign-core $V/wrap || { echo "run-dry: wrapper clone failed"; exit 4; } +git -C $V/wrap fetch -q origin && git -C $V/wrap checkout -q "$WRAP_COMMIT" || { echo "run-dry: checkout $WRAP_COMMIT failed"; exit 4; } +Q=$V/wrap/docs/campaigns/open-model-qwen3 +[ "$(jq -r .status $Q/frozen-v8.json | cut -c1-6)" = FROZEN ] || { echo "run-dry: frozen-v8.json at $WRAP_COMMIT is not FROZEN; freeze first (the -PIN and -GR rows need the pins and the model hash)"; exit 2; } +( cd $V/wrap/docs/campaigns/open-model-qwen3 && bash test-v8.sh > $R/test-v8.out 2>&1 ) || { echo "run-dry: test-v8.sh failed at $WRAP_COMMIT"; exit 2; } +cp "$HERE/run-part.sh" $V/run-part.sh; chmod +x $V/run-part.sh; sha256sum $V/run-part.sh "$0" > $R/launcher-dry.sha256 +date -u +%FT%TZ > $R/hold-dry-p1.start +# quietlock: holds over 20 minutes need Drake's approval token (attempt 1 at 22:10:23Z was refused with 40); on overrun the flag is kept and the command is never killed. +quietlock hold --owner laneB-oq3-v8-dry-p1 --minutes 20 --reason "OPEN-MODEL-QWEN3 v8 gate G6 dry run part 1, Qwen3-8B (not scored, sc#384)" -- $V/run-part.sh dry 1 > $R/hold-dry-p1.log 2>&1 +echo $? > $R/hold-dry-p1.rc; date -u +%FT%TZ > $R/hold-dry-p1.end +Q=$V/wrap/docs/campaigns/open-model-qwen3 +bash $Q/g6-gate.sh $R/dry-out/oq3-v8-DRYRUN-results.jsonl $Q/../scoring/declarations/oq3-v5.decl.json $V/dry-runs D1 D2 D3 > $R/g6-reasons.txt 2>&1 +rc=$?; [ $rc = 0 ] && echo "G6 PASS" > $R/g6.txt || echo "G6 FAIL (rc $rc, see g6-reasons.txt)" > $R/g6.txt +bash $Q/v8-checks.sh $V/dry-runs $Q/evidence-v7/run/s3-reports D1 D2 D3 > $R/v8-checks-dry.txt 2>&1; tail -1 $R/v8-checks-dry.txt +cat $R/g6.txt; grep -m1 -o 'CHECKPOINT_SHARDS.*' $V/dry-runs/D1/daemon-1.log 2>/dev/null | cut -c1-200 > $R/model_sha256-line.txt; cat $R/model_sha256-line.txt diff --git a/docs/campaigns/open-model-qwen3/evidence-v8/run-part.sh b/docs/campaigns/open-model-qwen3/evidence-v8/run-part.sh new file mode 100755 index 00000000..4b6f1295 --- /dev/null +++ b/docs/campaigns/open-model-qwen3/evidence-v8/run-part.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# OPEN-MODEL-QWEN3 v8 (SPEC-v8.md; real parts only once frozen on sc main). One part per quietlock hold. Never killed, never timed out. +# run-part.sh real <1|2|3|4> the qualification part +# run-part.sh dry 1 gate G6: part 1 in dry mode (same tasks file, scratch run base, never scored) +# As evidence-v7/run-part.sh with: the v8 wrapper, the Qwen3-8B model folder, the v8 build and run bases. +set -u +mode=$1 part=$2; V=/home/drakestapleton/workspace/oq3-v8-real; R=$V/records +B=${OQ3_BUILD:?OQ3_BUILD (the oq3-v8-build- folder)}; M=/home/drakestapleton/models/qwen3-8b +W=$V/wrap/docs/campaigns/open-model-qwen3/run-qwen3-v8.sh +tag=$mode-p$part +{ date -u +%FT%TZ; grep -E '^(MemFree|MemAvailable|Cached):' /proc/meminfo; } > $R/mem-$tag.txt +journalctl -k --no-pager 2>/dev/null | grep -c NVRM > $R/nvrm-before-$tag.txt +unset AIEN_FORCE_CPU_STUB AIEN_DEV_FALLBACK AIEN_BACKEND AIEN_COMPOSE_AUTHORIZE_REQUIRES_DESK AIEN_COMPOSE_MAX_TOKENS AIEN_COMPOSE_DOC_MAX_TOKENS \ + AIEN_COMPOSE_EDIT_BUDGET_MS AIEN_COMPOSE_DOC_BUDGET_MS AIEN_COMPOSE_BUDGET_MS AIEN_OMEGA_SPIN_US AIEN_OMEGA_CTA_BUDGET OQ3_DRY_TASKS OQ3_FROZEN +if [ "$mode" = dry ]; then + base=$V/dry-runs out=$R/dry-out + export OQ3_DRY_TASKS=$V/wrap/docs/campaigns/open-model-qwen3/tasks-oq3-v5.json +else + base=/home/drakestapleton/workspace/oq3-v8-runs out=$R/out +fi +AIEN_BIN=$B/target/release/aien-cli AIEN_MODEL_PATH=$M/model.safetensors.index.json AIEN_TOKENIZER_PATH=$M/tokenizer.json \ +AIEN_KV_CONTEXT_TOKENS=4096 AIEN_REQUIRE_BLACKWELL=1 AIEN_REQUIRE_CHECKPOINT=1 AIEN_GB10_QWEN3_DECLARED_ATTEMPT=1 \ +OQ3_PART=$part bash "$W" "$base" "$out" $B/sc $B/pins/omega $B/target/release/examples/np1_reference $B/target/release/examples/np1_edit_merge +rc=$? +journalctl -k --no-pager 2>/dev/null | grep -c NVRM > $R/nvrm-after-$tag.txt +exit $rc diff --git a/docs/campaigns/open-model-qwen3/evidence-v8/run.sh b/docs/campaigns/open-model-qwen3/evidence-v8/run.sh new file mode 100755 index 00000000..edca0524 --- /dev/null +++ b/docs/campaigns/open-model-qwen3/evidence-v8/run.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# OPEN-MODEL-QWEN3 v8 REAL qualification run (SPEC-v8.md Sections 3 and 5 item 8). Start detached ONLY on the +# coordinator's go, after run-dry.sh recorded "G6 PASS" and the freeze PR (frozen-v8.json FROZEN, all pins filled) is merged: +# setsid nohup bash run.sh folder> > 2>&1 < /dev/null & +# Four parts, each in its own 20-minute hold laneB-oq3-v8-pN. quietlock allows up to 20 minutes without Drake's approval token and on overrun +# keeps the flag until the command exits without killing it (quietlock strings, OBSERVED 2026-10-11). The 8B is predicted to run about +# twice the v6 part time (v6 parts took +# 7 to 8 minutes each). Stop if a part's wrapper exits non-zero (part 4 exits 1 on a FAIL verdict: the scorer's verdict, not a crash). +set -u +WRAP_COMMIT=${1:?sc main commit holding the FROZEN frozen-v8.json}; export OQ3_BUILD=${2:?build folder} +V=/home/drakestapleton/workspace/oq3-v8-real; R=$V/records +[ ! -e /home/drakestapleton/workspace/oq3-v8-runs ] || { echo "run: the v8 run base exists already (v8 runs once)"; exit 2; } +[ "$(cat $R/g6.txt 2>/dev/null)" = "G6 PASS" ] || { echo "run: no G6 PASS recorded by run-dry.sh"; exit 2; } +[ "$(tail -1 $R/v8-checks-dry.txt 2>/dev/null)" = "V8 CHECKS PASS" ] || { echo "run: no V8 CHECKS PASS on the dry launches (run-dry.sh)"; exit 2; } +quietlock check || { echo "run: quiet flag held, not starting"; exit 2; } +git -C $V/wrap fetch -q origin && git -C $V/wrap checkout -q "$WRAP_COMMIT" || { echo "run: checkout $WRAP_COMMIT failed"; exit 4; } +grep -q '"status": *"FROZEN' $V/wrap/docs/campaigns/open-model-qwen3/frozen-v8.json || { echo "run: frozen-v8.json at $WRAP_COMMIT is not FROZEN"; exit 2; } +( cd $V/wrap/docs/campaigns/open-model-qwen3 && bash test-v8.sh > $R/test-v8-real.out 2>&1 ) || { echo "run: test-v8.sh failed at $WRAP_COMMIT"; exit 2; } +sha256sum $V/run-part.sh "$0" > $R/launcher-real.sha256 +for p in 1 2 3 4; do + date -u +%FT%TZ > $R/hold-p$p.start + quietlock hold --owner laneB-oq3-v8-p$p --minutes 20 --reason "OPEN-MODEL-QWEN3 v8 REAL qualification run part $p, Qwen3-8B (frozen-v8 FROZEN, sc#384)" -- $V/run-part.sh real $p > $R/hold-p$p.log 2>&1 + rc=$?; echo $rc > $R/hold-p$p.rc; date -u +%FT%TZ > $R/hold-p$p.end + [ $rc = 0 ] || { echo "part $p rc=$rc, stopping" > $R/stopped; break; } +done +Q=$V/wrap/docs/campaigns/open-model-qwen3 +bash $Q/v8-checks.sh /home/drakestapleton/workspace/oq3-v8-runs $Q/evidence-v7/run/s3-reports D1 D2 D3 D4 D5 D6 E1 E2 N1 N2 R1 > $R/v8-checks.txt 2>&1; tail -1 $R/v8-checks.txt +date -u +%FT%TZ > $R/all.end diff --git a/docs/campaigns/open-model-qwen3/frozen-v8.json b/docs/campaigns/open-model-qwen3/frozen-v8.json new file mode 100644 index 00000000..6f002c83 --- /dev/null +++ b/docs/campaigns/open-model-qwen3/frozen-v8.json @@ -0,0 +1,47 @@ +{ + "status": "DRAFT NOT FROZEN (sc#384, SPEC-v8.md): v8 = v7 model Qwen/Qwen3-8B rev b968826d9c46dd6066d109eabc6255188de91218 with the corrective retry (sc#460) and the repaired R1 CPU replay (sc#459). Model hashes copied from frozen-v7.json (same weights) and re-hashed on the chip host on the freeze day (SPEC-v8 Section 6 item 2). Pins are filled from the clean freeze build.", + "placeholder": "TO FILL AT FREEZE", + "model": { + "model_revision": "b968826d9c46dd6066d109eabc6255188de91218", + "model_sha256": "17bc36882b981cdaa253076c43273e3b5e54251db26cb6a5f51de396c456f5a6", + "model_sha256_note": "from the daemon CHECKPOINT_SHARDS line (index+shards), identical on every daemon start of v7 dry attempt 2 D1 to D3; evidence-v7/attempt-2-g6-fail/model_sha256-line.txt", + "model_digest_kind": "index+shards", + "index_sha256": "f9fdbcb91c23971c13ec5d5f2573d2349e8f61f2f049371ec699281748fdb1bc", + "shards": [ + [ + "model-00001-of-00005.safetensors", + "31d6a825ae35f11fb85b195b4c42c146c051e446433125a215336abdf95cbf5f" + ], + [ + "model-00002-of-00005.safetensors", + "5991236cea6fe21f3d43cab0f0e84448734fbbe0789816202989f2ddc9d18282" + ], + [ + "model-00003-of-00005.safetensors", + "c5185c4794be2d8a9784d5753c9922db38df478ce11f9ed0b415b7304d896836" + ], + [ + "model-00004-of-00005.safetensors", + "b5ee7de71fbf17db3d5704e0c8f2bc7d005ca9e1d7ca2aeb19827b0cfcaa917a" + ], + [ + "model-00005-of-00005.safetensors", + "20c2d6366ab85c90786ccdd829cd2b9e7d30ef3b2ebbb998280e7e4014b542ff" + ] + ], + "tokenizer_sha256": "aeb13307a71acd8fe81861d94ad54ab689df773318809eed3cbe794b4492dae4", + "config_sha256": "f7c4eadfbbf522470667b797a3c89be2524832d2d599797248dc304fff447c30", + "generation_config_sha256": "2325da0f15bb848e018c5ae071b7943332e9f871d6b60e2ed22ca97d4cb993d2", + "tokenizer_config_sha256": "d5d09f07b48c3086c508b30d1c9114bd1189145b74e982a265350c923acd8101" + }, + "pins": { + "sovereign_core_commit": "TO FILL AT FREEZE", + "omega_lock_commit": "TO FILL AT FREEZE", + "physics_lock_commit": "TO FILL AT FREEZE", + "aienos_lock_commit": "TO FILL AT FREEZE", + "cargo_lock_sha256": "TO FILL AT FREEZE", + "aien_cli_sha256": "TO FILL AT FREEZE", + "np1_reference_sha256": "TO FILL AT FREEZE", + "np1_edit_merge_sha256": "TO FILL AT FREEZE" + } +} diff --git a/docs/campaigns/open-model-qwen3/run-qwen3-v8.sh b/docs/campaigns/open-model-qwen3/run-qwen3-v8.sh new file mode 100755 index 00000000..452f581d --- /dev/null +++ b/docs/campaigns/open-model-qwen3/run-qwen3-v8.sh @@ -0,0 +1,192 @@ +#!/usr/bin/env bash +# OPEN-MODEL-QWEN3 v8 qualification (SPEC-v8.md). As run-qwen3-v7.sh with names changed and the R1 CPU reference run with NP1_REFERENCE_ALLEN=default (SPEC-v8 Section 2). v7 derived from run-qwen3-v5.sh with names only changed: the frozen +# values file (frozen-v8.json), the pinned run base (oq3-v8-runs), the output tag (oq3-v8) and labels. Tasks (tasks-oq3-v5.json), +# seeds (seed-v5), declaration (oq3-v5.decl.json), row modules, v5-rows.sh, driver, receipt builder and scorer are the v5 files, +# byte-identical. It refuses a real run while any pin in frozen-v8.json holds the placeholder or its status does not say FROZEN, +# and afterwards unless every pin read from the checkouts and binaries equals it. The v5 header follows unchanged: +# OPEN-MODEL-QWEN3 v5 campaign (ACCEPTANCE-v5.md). It refuses a real run while any pin +# in frozen-v5.json holds the placeholder or its status does not say FROZEN, and afterwards unless every pin read +# from the checkouts and binaries equals it. Qwen3-4B, derived from run-qwen3-v4.sh: same driver (next-phase-1/run-campaign.sh), receipt builder, v8 rows and +# scorer; new tasks (tasks-oq3-v5.json), one declaration (qualification) and extra rows (v5-rows.sh, rows-oq3-v5.jq). +# Shell + jq only. Run inside the caller's hold, one part per hold. Environment as in ACCEPTANCE-v5 Section 7 +# (model, tokenizer, binary, KV context, hardware requirement, checkpoint requirement, declared attempt flag), then: +# OQ3_PART=1|2|3|4 run-qwen3-v5.sh RUN_BASE OUT_DIR SC_DIR OMEGA_DIR REFERENCE_BIN MERGE_BIN +# SC_DIR is the sovereign-core checkout the binaries were built from, OMEGA_DIR the omega checkout at its omega.lock; +# the commits and lock files are read from them (row -PIN). Parts (ACCEPTANCE-v5 Section 8): 1 = D1 D2 D3, +# 2 = D4 D5 D6, 3 = E1 E2 N1, 4 = N2 R1 and the QUALIFICATION score. Part k needs part k-1 completed in the same +# RUN_BASE with the same binaries, tasks file, declaration, frozen values, row modules and wrapper. +# Dry run (gate G6): OQ3_DRY_TASKS= +# lifts the pinned paths and the frozen-pin checks and writes oq3-v5-DRYRUN-* outputs. A dry run is never a verdict. +# A dry run still starts the real driver and daemon on the GPU. +set -u +PART=${OQ3_PART:-} +case $PART in 1) LAUNCHES="D1 D2 D3" ;; 2) LAUNCHES="D4 D5 D6" ;; 3) LAUNCHES="E1 E2 N1" ;; 4) LAUNCHES="N2 R1" ;; *) echo "run-qwen3-v8: OQ3_PART must be 1, 2, 3 or 4" >&2; exit 2 ;; esac +HERE=$(cd "$(dirname "$0")" && pwd) +NP1=$(cd "$HERE/../next-phase-1" && pwd) +FROZEN=${OQ3_FROZEN:-$HERE/frozen-v8.json} # D1: only a dry run may point elsewhere (checked below) +BASE=${1:?RUN_BASE} OUT=${2:?OUT_DIR} SCD=${3:?SC_DIR} OMD=${4:?OMEGA_DIR} REFBIN=${5:?REFERENCE_BIN} MERGEBIN=${6:?MERGE_BIN} +[ -z "${OQ3_FROZEN:-}" ] || [ -n "${OQ3_DRY_TASKS:-}" ] || { echo "run-qwen3-v8: OQ3_FROZEN is allowed in a dry run only" >&2; exit 2; } +PLACEHOLDER=$(jq -r .placeholder "$FROZEN") + +TASKS=$HERE/tasks-oq3-v5.json TAG=oq3-v8 +if [ -n "${OQ3_DRY_TASKS:-}" ]; then + TASKS=$OQ3_DRY_TASKS TAG=oq3-v8-DRYRUN + shape='[.tasks[] | [.id, .kind, .max_tokens, .budget_ms, .destination, .seed]]' + [ "$(jq -c "$shape" "$TASKS")" = "$(jq -c "$shape" "$HERE/tasks-oq3-v5.json")" ] || + { echo "run-qwen3-v8: dry-run tasks must keep the v5 ids, kinds, max_tokens, budgets, destinations and seeds" >&2; exit 2; } +else + # Real run: the run path is pinned (the prompt embeds the workspace path), the output directory is fresh, + # and every frozen pin must be filled in (the comparison with the recorded pins follows below). + PINNED_BASE=/home/drakestapleton/workspace/oq3-v8-runs + [ "$BASE" = "$PINNED_BASE" ] || { echo "run-qwen3-v8: RUN_BASE must be $PINNED_BASE" >&2; exit 2; } + if [ $PART = 1 ]; then + [ ! -e "$BASE" ] || { echo "run-qwen3-v8: $BASE already exists (the v6 run is fresh and happens once)" >&2; exit 2; } + [ ! -e "$OUT" ] || [ -z "$(ls -A "$OUT" 2>/dev/null)" ] || { echo "run-qwen3-v8: OUT_DIR must be new or empty" >&2; exit 2; } + fi + [ "$(jq --arg p "$PLACEHOLDER" '[.pins[] | select(. == $p)] | length' "$FROZEN")" = 0 ] || + { echo "run-qwen3-v8: the build pins are not frozen yet (frozen-v8.json, SPEC-v8 Section 6 item 3)" >&2; exit 2; } + # Filled pins are not a freeze: a draft freeze-fill change fills them first. The status line changes only at G8. + case "$(jq -r .status "$FROZEN")" in FROZEN*) ;; *) + echo "run-qwen3-v8: frozen-v8.json status is not FROZEN (SPEC-v8 Section 6 item 6)" >&2; exit 2 ;; esac +fi +DECL=$HERE/../scoring/declarations/oq3-v5.decl.json +SCORER=$HERE/../scoring/score-rows.sh +[ -f "$DECL" ] && [ -x "$SCORER" ] && [ -x "$REFBIN" ] && [ -x "$MERGEBIN" ] || { echo "run-qwen3-v8: declaration, scorer, reference binary or merge binary missing" >&2; exit 2; } +: "${AIEN_MODEL_PATH:?}" "${AIEN_TOKENIZER_PATH:?}" "${AIEN_BIN:?}" +need() { [ "$(printenv "$1")" = "$2" ] || { echo "$1 must be $2 (ACCEPTANCE-v5 Section 7)" >&2; exit 3; }; } +need AIEN_KV_CONTEXT_TOKENS 4096 +need AIEN_REQUIRE_BLACKWELL 1 +need AIEN_REQUIRE_CHECKPOINT 1 +need AIEN_GB10_QWEN3_DECLARED_ATTEMPT 1 +# The limits are set per launch below; a stale value from the caller is refused, never overridden silently. +# AIEN_COMPOSE_BUDGET_MS is the retired single budget (sc#284 refuses it too). AIEN_DEV_FALLBACK is new in v5, and so is +# AIEN_COMPOSE_AUTHORIZE_REQUIRES_DESK (the dev-only desk opt-out of sc#342, valid only with AIEN_DEV_FALLBACK=1). +for v in AIEN_FORCE_CPU_STUB AIEN_DEV_FALLBACK AIEN_COMPOSE_AUTHORIZE_REQUIRES_DESK AIEN_COMPOSE_MAX_TOKENS AIEN_COMPOSE_DOC_MAX_TOKENS AIEN_COMPOSE_EDIT_BUDGET_MS \ + AIEN_COMPOSE_DOC_BUDGET_MS AIEN_COMPOSE_BUDGET_MS AIEN_OMEGA_SPIN_US AIEN_OMEGA_CTA_BUDGET; do + [ -z "$(printenv $v)" ] || { echo "$v must be unset (ACCEPTANCE-v5 Section 7)" >&2; exit 3; } +done +MODEL_DIR=$(dirname "$AIEN_MODEL_PATH") +chk() { [ "$(sha256sum "$1" | cut -d' ' -f1)" = "$2" ] || { echo "digest mismatch: $1" >&2; exit 3; }; } +# The model the generation record must bind (row -GR): the index and every shard, re-hashed before each part. +chk "$AIEN_MODEL_PATH" "$(jq -r .model.index_sha256 "$FROZEN")" +while read -r n h; do chk "$MODEL_DIR/$n" "$h"; done < <(jq -r '.model.shards[] | "\(.[0]) \(.[1])"' "$FROZEN") +chk "$AIEN_TOKENIZER_PATH" "$(jq -r .model.tokenizer_sha256 "$FROZEN")" +chk "$MODEL_DIR/config.json" "$(jq -r .model.config_sha256 "$FROZEN")" +chk "$MODEL_DIR/generation_config.json" "$(jq -r .model.generation_config_sha256 "$FROZEN")" +chk "$MODEL_DIR/tokenizer_config.json" "$(jq -r .model.tokenizer_config_sha256 "$FROZEN")" +# Build pins, read from the checkouts and the binaries (row -PIN). A real run refuses any difference. +SC=$(git -C "$SCD" rev-parse HEAD 2>/dev/null) && OMC=$(git -C "$OMD" rev-parse HEAD 2>/dev/null) || + { echo "run-qwen3-v8: SC_DIR and OMEGA_DIR must be git checkouts" >&2; exit 2; } +OMG=$OMC +[ "$OMC" = "$(tr -d '[:space:]' <"$SCD/omega.lock")" ] || { echo "run-qwen3-v8: OMEGA_DIR HEAD differs from SC_DIR/omega.lock" >&2; exit 2; } +PINS=$(jq -n --arg sc "$SC" --arg om "$OMC" --arg ph "$(tr -d '[:space:]' <"$OMD/physics.lock" 2>/dev/null)" \ + --arg ao "$(tr -d '[:space:]' <"$OMD/aienos.lock" 2>/dev/null)" --arg cl "$(sha256sum "$SCD/Cargo.lock" | cut -d' ' -f1)" \ + --arg cli "$(sha256sum "$AIEN_BIN" | cut -d' ' -f1)" --arg ref "$(sha256sum "$REFBIN" | cut -d' ' -f1)" --arg mrg "$(sha256sum "$MERGEBIN" | cut -d' ' -f1)" \ + '{sovereign_core_commit: $sc, omega_lock_commit: $om, physics_lock_commit: $ph, aienos_lock_commit: $ao, cargo_lock_sha256: $cl, + aien_cli_sha256: $cli, np1_reference_sha256: $ref, np1_edit_merge_sha256: $mrg}') +if [ -z "${OQ3_DRY_TASKS:-}" ]; then + [ -z "$(git -C "$SCD" status --porcelain)" ] || { echo "run-qwen3-v8: SC_DIR has uncommitted changes" >&2; exit 2; } + [ "$(jq -c --argjson p "$PINS" '.pins == $p' "$FROZEN")" = true ] || + { echo "run-qwen3-v8: the recorded build pins differ from frozen-v8.json: $(jq -c --argjson p "$PINS" '.pins as $f | [$f | keys[] | select($f[.] != $p[.])]' "$FROZEN")" >&2; exit 2; } +fi +RES=$OUT/$TAG-results.jsonl +if [ $PART = 1 ]; then + [ ! -e "$BASE/part1.done" ] && [ ! -e "$RES" ] || { echo "run-qwen3-v8: part 1 already ran here" >&2; exit 2; } + mkdir -p "$BASE" "$OUT"; : >"$RES" +else + prev=$((PART - 1)) + [ -f "$BASE/part$prev.done" ] && [ ! -e "$BASE/part$PART.started" ] || { echo "run-qwen3-v8: part $PART needs a completed part $prev and runs once" >&2; exit 2; } + : >"$BASE/part$PART.started" +fi +sha256sum "$AIEN_BIN" "$REFBIN" "$MERGEBIN" "$TASKS" "$DECL" "$FROZEN" "$HERE/rows-oq3-v3.jq" "$HERE/rows-oq3-v4.jq" "$HERE/rows-oq3-v5.jq" \ + "$HERE/v5-rows.sh" "$HERE/run-campaign-allen.sh" "$HERE/build-allen-subject.sh" "$0" > "$BASE/identity-part$PART.sha256" +if [ $PART != 1 ] && ! cmp -s <(cut -d" " -f1 "$BASE/identity-part1.sha256") <(cut -d" " -f1 "$BASE/identity-part$PART.sha256"); then + echo "run-qwen3-v8: part $PART binaries, tasks, declaration, frozen values, rows or wrapper differ from part 1 (one build per run)" >&2; exit 2 +fi +printf '%s\n' "$PINS" >"$BASE/pins-part$PART.json" +# Memory before the part (row -MEAS), from /proc/meminfo, in kB. +MEM=$(awk '/^MemFree:/ {f=$2} /^Cached:/ {c=$2} END {printf "{\"mem_free_kb\":%d,\"cached_kb\":%d}", f, c}' /proc/meminfo) +printf '%s\n' "$MEM" >"$BASE/meminfo-part$PART.json" +# Launch wall time on CLOCK_BOOTTIME (monotonic, 10 ms ticks), in ms. +up_ms() { echo $(( $(tr -d . for any task that has a seed, which only fits edits. A non-edit +# task whose seed holds other files (D4: its source file; R1: the notes/ folder its destination needs, Section 2) is +# staged with seed null for the receipt builder only; the driver still gets the real seed from the tasks file +# (NP1_SEED_DIR below), and v5-rows.sh checks the D4 source file itself (row SRC). +STAGE_FILTER='(.tasks[] | select(.kind != "edit") | .seed) = null' +if [ $PART = 1 ]; then + mkdir -p "$STAGE" + for f in "$NP1"/*; do + n=$(basename "$f"); case $n in tasks-v8.json) continue ;; esac + ln -s "$f" "$STAGE/$n" + done + jq "$STAGE_FILTER" "$TASKS" >"$STAGE/tasks-v8.json" + ln -s "$HERE/seed-v5" "$STAGE/seed-v5" +fi +[ "$(jq "$STAGE_FILTER" "$TASKS")" = "$(cat "$STAGE/tasks-v8.json")" ] || { echo "run-qwen3-v8: staged tasks file differs from the tasks file" >&2; exit 2; } +# Product limits (ACCEPTANCE-v5 Section 2) come from the task's own max_tokens and budget_ms (row -D scores the +# same budget_ms); only D6 differs from the product values (Drake 2026-10-09, ACCEPTANCE-v5 Section 2.1). +for id in $LAUNCHES; do + t=$(jq -c --arg id "$id" '.tasks[] | select(.id == $id)' "$TASKS") + goal=$(jq -r .goal <<<"$t"); max=$(jq -r .max_tokens <<<"$t"); bud=$(jq -r .budget_ms <<<"$t"); kind=$(jq -r .kind <<<"$t"); seed=$(jq -r '.seed // empty' <<<"$t") + seed_dir=; [ -n "$seed" ] && seed_dir=$HERE/$seed + # An edit goal (names an existing file) uses the edit cap AIEN_COMPOSE_MAX_TOKENS and budget AIEN_COMPOSE_EDIT_BUDGET_MS; + # every other goal creates a new file and uses the document cap and budget. The other cap and budget stay at their product values. + if [ "$kind" = edit ]; then ecap=$max dcap=$(jq -r .limits.doc_max_tokens "$TASKS") ebud=$bud dbud=$(jq -r .limits.doc_budget_ms "$TASKS") + else ecap=$(jq -r .limits.edit_max_tokens "$TASKS") dcap=$max ebud=$(jq -r .limits.edit_budget_ms "$TASKS") dbud=$bud; fi + export AIEN_COMPOSE_EDIT_BUDGET_MS=$ebud AIEN_COMPOSE_DOC_BUDGET_MS=$dbud + t0=$(up_ms) + NP1_GOAL=$goal AIEN_COMPOSE_MAX_TOKENS=$ecap AIEN_COMPOSE_DOC_MAX_TOKENS=$dcap NP1_SEED_DIR=$seed_dir \ + NP1_DIR=$NP1 NP1_ALLEN_BUILDER=$HERE/build-allen-subject.sh OQ3_SC_DIR=$SCD OQ3_ALLEN_TARGET=$BASE/allen-target \ + bash "$HERE/run-campaign-allen.sh" "$BASE/$id" >"$BASE/$id.driver.out" 2>&1 + drc=$?; t1=$(up_ms) + jq -n --arg id "$id" --argjson w $((t1 - t0)) --argjson m "$MEM" --argjson p "$PINS" --argjson rc $drc \ + '{launch: $id, wall_ms: $w, wall_clock: "CLOCK_BOOTTIME, 10 ms ticks, around the driver call", driver_exit: $rc, meminfo_before: $m, pins: $p}' >"$BASE/$id.launch-v5.json" + echo "launch $id driver exit $drc in $((t1 - t0)) ms (edit cap $ecap, document cap $dcap, budgets $AIEN_COMPOSE_EDIT_BUDGET_MS/$AIEN_COMPOSE_DOC_BUDGET_MS ms${seed:+, seed $seed})" + ref= + if [ "$kind" = identity ] && [ -d "$BASE/$id/ws" ]; then + ws=$(cd "$BASE/$id/ws" && pwd -P) + NP1_REFERENCE_ALLEN=default "$REFBIN" "$MODEL_DIR" "$goal" "$ws" "$max" new >"$BASE/$id.reference.json" 2>"$BASE/$id.reference.err" + echo "launch $id CPU reference exit $?" + ref=$BASE/$id.reference.json + fi + if [ -f "$BASE/$id/run.json" ]; then + v8merge=null + if [ "$kind" = edit ] && [ -f "$BASE/$id/s3-report.json" ]; then + rf=$BASE/$id.accepted-reply.txt + if jq -e '[.proposal_attempts // [] | .[] | select(.outcome == "parsed")] | length > 0' "$BASE/$id/s3-report.json" >/dev/null 2>&1; then + jq -j '[.proposal_attempts[] | select(.outcome == "parsed")] | last | .text' "$BASE/$id/s3-report.json" >"$rf" + m=$("$MERGEBIN" "$(jq -r .destination <<<"$t")" "$HERE/$seed/$(jq -r .destination <<<"$t")" "$rf" 2>"$BASE/$id.merge.err") + if jq . <<<"$m" >/dev/null 2>&1; then v8merge=$(jq -c . <<<"$m"); fi + fi + echo "launch $id edit re-derivation: $(jq -r 'if . == null then "none" else "ok=\(.ok)" end' <<<"$v8merge")" + fi + v5env=(); [ "$(jq -r '.destination // empty' <<<"$t")" != "" ] && [ "${id#N}" = "$id" ] && \ + v5env=(TASK_ID="$id" TASK_SPEC="$TASKS" TASK_ACCEPTANCE="$HERE/ACCEPTANCE-v5.md") + env "${v5env[@]}" V6_ROWS=rows-v9.jq V8_MERGE="$v8merge" V6_TASK="$id" V6_MAX_TOKENS="$max" V6_REFERENCE="$ref" \ + SPEC="open-model-qwen3/SPEC-v8.md (rows of ACCEPTANCE-v5.md) spec_version 8${OQ3_DRY_TASKS:+ DRY RUN}" bash "$STAGE/make-receipt.sh" \ + "$BASE/$id" "$OUT" "$SC" "$OMC" "$OMG" 0 "OPEN-MODEL-QWEN3 v8${OQ3_DRY_TASKS:+ DRY RUN} launch $id" >"$BASE/$id.receipt.out" 2>&1 + rec=$OUT/$(head -1 "$BASE/$id.receipt.out" | sed -n 's/.*receipt \([0-9a-f]*\.json\).*/\1/p') + if [ -f "$rec" ]; then + bash "$NP1/v8-results.sh" "$id" "$rec" >>"$RES" + bash "$HERE/v5-rows.sh" "$BASE/$id" "$id" "$TASKS" "$OUT" "$(basename "$rec")" "$BASE/$id.launch-v5.json" "$FROZEN" >>"$RES" + else bash "$NP1/v8-results.sh" "$id" - "$DECL" "receipt not written" >>"$RES"; fi + echo "launch $id receipt $(basename "$rec")" + else + bash "$NP1/v8-results.sh" "$id" - "$DECL" "launch failed: no run.json" >>"$RES" + echo "launch $id FAILED to launch" + fi + jq -r --arg id "$id" 'select(.row | startswith($id + "/")) | select(.verdict != "PASS") | " \(.verdict) \(.row)"' "$RES" +done +: >"$BASE/part$PART.done" +if [ $PART -le 3 ]; then echo "part $PART done ($LAUNCHES); run part $((PART + 1)) in a new hold"; exit 0; fi +# Qualification verdict: the declaration and the result file only (ACCEPTANCE-v5 Section 5). Rows a receipt computes +# but the declaration does not hold (for N1: N1-B, N1-C, N1-H) are listed by the scorer as extras, never counted. +bash "$SCORER" "$DECL" "$RES" >"$OUT/$TAG-score.json"; rc=$? +echo "OPEN-MODEL-QWEN3 v8${OQ3_DRY_TASKS:+ DRY RUN (not a verdict)} QUALIFICATION (scoring-v5, score-rows.sh exit $rc): $(jq -r .verdict "$OUT/$TAG-score.json" 2>/dev/null || echo ERROR)" +exit $rc diff --git a/docs/campaigns/open-model-qwen3/test-v8.sh b/docs/campaigns/open-model-qwen3/test-v8.sh new file mode 100755 index 00000000..9d490ee7 --- /dev/null +++ b/docs/campaigns/open-model-qwen3/test-v8.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash +# OPEN-MODEL-QWEN3 v8 harness self-test (sc#384, SPEC-v8.md). All v7 checks (ALLEN driver, gate G6) plus the v8 pieces: the wrapper differs from v7 only in names and the ALLEN-aware R1 reference call, the feature checks (v8-checks.sh) go red and green, and the launchers require them. CPU only, no model, no GPU, no network. Shell + jq. +# Proves the two harness corrections: (a) the driver engages ALLEN before S1 and changes nothing else; (b) gate G6 checks every +# product row and goes red on the failure v6 missed. Thresholds and rows are untouched (declaration and task files are not read here +# except to list rows). +set -u +HERE=$(cd "$(dirname "$0")" && pwd); cd "$HERE" || exit 2 +T=$(mktemp -d); trap 'rm -rf "$T"' EXIT +pass=0 fail=0 +ok() { pass=$((pass + 1)); echo "ok: $1"; } +bad() { fail=$((fail + 1)); echo "FAIL: $1"; } +chk() { if eval "$2"; then ok "$1"; else bad "$1"; fi; } +DECL=../scoring/declarations/oq3-v5.decl.json G=./g6-gate.sh + +chk "all new scripts parse (bash -n)" 'for f in run-campaign-allen.sh build-allen-subject.sh g6-gate.sh run-qwen3-v8.sh v8-checks.sh evidence-v8/build.sh evidence-v8/run-part.sh evidence-v8/run-dry.sh evidence-v8/run.sh; do bash -n $f || exit 1; done' +# ---- driver: the only difference from the frozen driver is the ALLEN block, the mark-evidence path and the allen evidence in run.json +D=$(diff ../next-phase-1/run-campaign.sh run-campaign-allen.sh | grep -c "^<") +chk "driver diff against next-phase-1/run-campaign.sh removes only 5 lines (header comment, mark-evidence path, one find-exclusion line, the two run.json lines); all else is added ALLEN lines (removed: $D)" '[ "$D" = 5 ]' +chk "the ALLEN block runs before the measured window (.mark) and before S1" \ + 'a=$(grep -n "ALLEN_LINE=\$(grep" run-campaign-allen.sh | head -1 | cut -d: -f1); m=$(grep -n "^touch \"\$R/.mark\"" run-campaign-allen.sh | cut -d: -f1); s=$(grep -n "^run_step S1" run-campaign-allen.sh | cut -d: -f1); [ "$a" -lt "$m" ] && [ "$m" -lt "$s" ]' +chk "the driver refuses to run without the subject builder" 'out=$(env -u NP1_ALLEN_BUILDER AIEN_BIN=/bin/true AIEN_MODEL_PATH=x AIEN_TOKENIZER_PATH=y NP1_DIR=. bash run-campaign-allen.sh "$T/r" 2>&1); echo "$out" | grep -q NP1_ALLEN_BUILDER || echo "$out" | grep -q "daemon 1 failed"' +chk "the frozen next-phase-1 driver is unchanged by this lane" '! git diff --quiet origin/main -- ../next-phase-1 2>/dev/null || [ -z "$(git status --porcelain ../next-phase-1)" ]' + +# ---- wrapper: v7 differs from v6 only where intended +chk "run-qwen3-v8.sh uses the ALLEN driver and keeps the v6 refusals (pinned base, FROZEN status, placeholder pins)" \ + 'grep -q "run-campaign-allen.sh" run-qwen3-v8.sh && grep -q "PINNED_BASE=/home/drakestapleton/workspace/oq3-v8-runs" run-qwen3-v8.sh && grep -q "status is not FROZEN" run-qwen3-v8.sh && grep -q "build pins are not frozen" run-qwen3-v8.sh' +chk "frozen-v8.json is a consistent DRAFT (status DRAFT, every pin the placeholder) or FROZEN (status FROZEN, every pin 40 or 64 hex, no placeholder); same pin names as v7; model block equal to v7 (same weights)" \ + 'F=frozen-v8.json; [ "$(jq -c ".pins | keys" $F)" = "$(jq -c ".pins | keys" frozen-v7.json)" ] && [ "$(jq -c .model $F)" = "$(jq -c .model frozen-v7.json)" ] && case "$(jq -r .status $F)" in DRAFT*) [ "$(jq "[.pins[] | select(. != \"TO FILL AT FREEZE\")] | length" $F)" = 0 ] ;; FROZEN*) [ "$(jq "[.pins[] | select(test(\"^([0-9a-f]{40}|[0-9a-f]{64})$\") | not)] | length" $F)" = 0 ] ;; *) false ;; esac' +chk "a real v8 run is refused while frozen-v7.json is a draft" \ + 'out=$(OQ3_PART=1 AIEN_MODEL_PATH=x AIEN_TOKENIZER_PATH=y AIEN_BIN=z bash run-qwen3-v8.sh /home/drakestapleton/workspace/oq3-v8-runs-selftest-absent "$T/o" . . /bin/true /bin/true 2>&1); echo "$out" | grep -q "RUN_BASE must be"' +chk "OQ3_FROZEN outside a dry run is refused" 'out=$(OQ3_FROZEN=$HERE/frozen-v6.json OQ3_PART=1 bash run-qwen3-v8.sh a b c d e f 2>&1); echo "$out" | grep -q "allowed in a dry run only"' + +# ---- gate G6 on synthetic launches built from the declaration's own rows +mk() { # dir ; builds D1..D3 with every row PASS, S1..S8 ok, ALLEN engaged + local b=$1; mkdir -p "$b" + for L in D1 D2 D3; do mkdir -p "$b/$L" + jq -n '{steps: [range(1;9) | {step: ("S\(.)"), ok: true}], allen: {engaged_log_line: "ALLEN: engaged agent=ab head_sequence=2", fingerprint: "ab"}}' >"$b/$L/run.json" + done + jq -c '.rows[] | select(.row | test("^D[123]/")) | {row: .row, verdict: "PASS", rep: 1}' $DECL >"$b/res.jsonl" +} +mk "$T/g"; chk "G6 green: all rows PASS, ALLEN engaged" 'bash $G "$T/g/res.jsonl" $DECL "$T/g" D1 D2 D3 >"$T/o1"; [ $? = 0 ] && grep -q "G6 PASS" "$T/o1"' +mk "$T/a"; jq '(.steps[0].ok) = false | (.allen.engaged_log_line) = ""' "$T/a/D1/run.json" >"$T/a/x" && mv "$T/a/x" "$T/a/D1/run.json" +chk "G6 red (negative control, the v6 failure): S1 refused and no ALLEN line" 'bash $G "$T/a/res.jsonl" $DECL "$T/a" D1 D2 D3 >"$T/o2"; [ $? = 1 ] && grep -q "step S1 not ok" "$T/o2" && grep -q "ALLEN: engaged" "$T/o2"' +mk "$T/b"; sed -i 's|\("row":"D2/v1 Correctness: recall","verdict":"\)PASS|\1FAIL|' "$T/b/res.jsonl" +chk "G6 red: the recall row FAILs although the other four rows v6 checked pass" 'bash $G "$T/b/res.jsonl" $DECL "$T/b" D1 D2 D3 >"$T/o3"; [ $? = 1 ] && grep -q "D2 row .v1 Correctness: recall. = FAIL" "$T/o3"' +mk "$T/c"; grep -v '"row":"D3/D3-MEAS"' "$T/c/res.jsonl" >"$T/c/x" && mv "$T/c/x" "$T/c/res.jsonl" +chk "G6 red: a missing required row is a failure" 'bash $G "$T/c/res.jsonl" $DECL "$T/c" D1 D2 D3 >"$T/o4"; [ $? = 1 ] && grep -q "D3-MEAS. = missing" "$T/o4"' +mk "$T/d"; sed -i 's|\("row":"D1/D1-RQ1","verdict":"\)PASS|\1FAIL|; s|\("row":"D1/D1-CUT","verdict":"\)PASS|\1FAIL|' "$T/d/res.jsonl" +chk "G6 green: model-behaviour rows (RQ, CUT, F, SB) may FAIL" 'bash $G "$T/d/res.jsonl" $DECL "$T/d" D1 D2 D3 >"$T/o5"; [ $? = 0 ]' +mk "$T/e"; jq '(.steps[4].ok) = false' "$T/e/D2/run.json" >"$T/e/x" && mv "$T/e/x" "$T/e/D2/run.json" +sed -i 's|\("row":"D2/Q1","verdict":"\)PASS|\1FAIL|' "$T/e/res.jsonl" +chk "G6 green: a launch whose model reply was refused (S5 not ok) is checked on product rows only" 'bash $G "$T/e/res.jsonl" $DECL "$T/e" D1 D2 D3 >"$T/o6"; [ $? = 0 ] && grep -q "D2 committed=false" "$T/o6"' +mk "$T/f"; sed -i 's|\("row":"D1/D1-BE","verdict":"\)PASS|\1FAIL|' "$T/f/res.jsonl" +chk "G6 red: a product row (BE) FAILs" 'bash $G "$T/f/res.jsonl" $DECL "$T/f" D1 D2 D3 >"$T/o7"; [ $? = 1 ]' +# ---- gate G6 corrections after v7 dry attempt 2 (2026-10-11, evidence-v7/attempt-2-g6-fail/) +mk "$T/h"; jq '(.steps[3].ok) = false | (.steps[4].ok) = false' "$T/h/D1/run.json" >"$T/h/x" && mv "$T/h/x" "$T/h/D1/run.json" +sed -i 's|\("row":"D1/v1 Memory","verdict":"\)PASS|\1FAIL|' "$T/h/res.jsonl" +chk "G6 green: v1 Memory FAILs on a launch that did not commit (no record to digest, v6 class (a))" 'bash $G "$T/h/res.jsonl" $DECL "$T/h" D1 D2 D3 >"$T/o8"; [ $? = 0 ] && grep -q "D1 committed=false" "$T/o8"' +mk "$T/i"; sed -i 's|\("row":"D1/v1 Memory","verdict":"\)PASS|\1FAIL|' "$T/i/res.jsonl" +chk "G6 red: v1 Memory FAILs on a committed launch" 'bash $G "$T/i/res.jsonl" $DECL "$T/i" D1 D2 D3 >"$T/o9"; [ $? = 1 ] && grep -q "D1 row .v1 Memory. = FAIL" "$T/o9"' +mk "$T/j"; sed -i 's|\("row":"D3/D3-DEC","verdict":"\)PASS|\1FAIL|; s|\("row":"D3/D3-MEAS","verdict":"\)PASS|\1FAIL|' "$T/j/res.jsonl" +jq -n '{proposal_attempts: [{attempt: 1, outcome: "refused"}, {attempt: 2, outcome: "timeout", tokens: 0}]}' >"$T/j/D3/s3-report.json" +chk "G6 green with a NOTE: -DEC and -MEAS FAIL only because an attempt ended by timeout (model too slow for the budget)" 'bash $G "$T/j/res.jsonl" $DECL "$T/j" D1 D2 D3 >"$T/o10"; [ $? = 0 ] && grep -q "NOTE D3 attempt 2 ended by timeout" "$T/o10" && grep -q "D3 committed=true .* not_checked_timeout=2" "$T/o10"' +mk "$T/k"; sed -i 's|\("row":"D3/D3-DEC","verdict":"\)PASS|\1FAIL|' "$T/k/res.jsonl" +jq -n '{proposal_attempts: [{attempt: 1, outcome: "parsed"}]}' >"$T/k/D3/s3-report.json" +chk "G6 red: -DEC FAILs with no timeout in the attempts" 'bash $G "$T/k/res.jsonl" $DECL "$T/k" D1 D2 D3 >"$T/o11"; [ $? = 1 ] && grep -q "D3 row .D3-DEC. = FAIL" "$T/o11"' +# ---- v8 (SPEC-v8.md): wrapper, feature checks, launchers +chk "run-qwen3-v8.sh is run-qwen3-v7.sh with names changed plus exactly one changed working line, the R1 reference call with NP1_REFERENCE_ALLEN=default" \ + 'd=$(diff <(sed "s/v7/v8/g; s/QUALIFICATION-v8\.md/SPEC-v8.md/g; s/QUALIFICATION-v8 /SPEC-v8 /g; s/spec_version 7/spec_version 8/; s/SPEC-v8 Section 6)/SPEC-v8 Section 6 item 3)/; s/SPEC-v8 Section 7)/SPEC-v8 Section 6 item 6)/" run-qwen3-v7.sh) run-qwen3-v8.sh | grep "^>" | grep -v "^> #"); [ "$(printf "%s\n" "$d" | grep -c .)" = 1 ] && printf "%s" "$d" | grep -q "NP1_REFERENCE_ALLEN=default \"\$REFBIN\""' +chk "the v8 wrapper still reads the v5 tasks and the v5 declaration (rows and budgets unchanged)" \ + 'grep -q "TASKS=\$HERE/tasks-oq3-v5.json" run-qwen3-v8.sh && grep -q "oq3-v5.decl.json" run-qwen3-v8.sh' +mk8() { # dir ; a v8-shaped run base: D2 refused then parsed with the refused reply shown, R1 parsed with an exact reference + local b=$1 v=$1/v7; mkdir -p "$b/D2" "$b/R1" "$v" + jq -n '{proposal_attempts: [{attempt: 1, outcome: "refused", text_sha256: "aa", prompt_tokens: 260, prompt_ids_sha256: "p2"}, + {attempt: 2, outcome: "parsed", text_sha256: "bb", shown_refused_text_sha256: "aa"}]}' >"$b/D2/s3-report.json" + jq -n '{proposal_attempts: [{attempt: 1, outcome: "parsed", text_sha256: "cc", prompt_tokens: 164, prompt_ids_sha256: "p1"}]}' >"$b/R1/s3-report.json" + jq -n '{proposal_attempts: [{attempt: 1, prompt_tokens: 260, prompt_ids_sha256: "p2"}]}' >"$v/s3-report-D2.json" + jq -n '{proposal_attempts: [{attempt: 1, prompt_tokens: 164, prompt_ids_sha256: "p1"}]}' >"$v/s3-report-R1.json" + jq -n '{allen: "default", prompt_tokens: 164, prompt_ids_sha256: "p1"}' >"$b/R1.reference.json" +} +V8=./v8-checks.sh +mk8 "$T/v1"; chk "v8 checks green on a clean v8-shaped record" 'bash $V8 "$T/v1" "$T/v1/v7" D2 R1 >"$T/p1"; [ $? = 0 ] && grep -q "V8 CHECKS PASS" "$T/p1"' +mk8 "$T/v2"; jq ".proposal_attempts[1].shown_refused_text_sha256 = null" "$T/v2/D2/s3-report.json" >"$T/v2/x" && mv "$T/v2/x" "$T/v2/D2/s3-report.json" +chk "v8 checks red (C1): a retry after a refused reply that did not show it (the v7 behaviour)" 'bash $V8 "$T/v2" "$T/v2/v7" D2 R1 >"$T/p2"; [ $? = 1 ] && grep -q "D2 C1" "$T/p2"' +mk8 "$T/v3"; jq ".proposal_attempts[1].text_sha256 = \"aa\"" "$T/v3/D2/s3-report.json" >"$T/v3/x" && mv "$T/v3/x" "$T/v3/D2/s3-report.json" +chk "v8 checks red (C2, negative control): the accepted reply equals a refused reply" 'bash $V8 "$T/v3" "$T/v3/v7" D2 R1 >"$T/p3"; [ $? = 1 ] && grep -q "D2 C2" "$T/p3"' +mk8 "$T/v4"; jq "{allen: null, prompt_tokens: 99, prompt_ids_sha256: \"q\"}" "$T/v4/R1.reference.json" >"$T/v4/x" && mv "$T/v4/x" "$T/v4/R1.reference.json" +chk "v8 checks red (C4, negative control): the v7 CPU replay (no ALLEN block, 99 tokens)" 'bash $V8 "$T/v4" "$T/v4/v7" D2 R1 >"$T/p4"; [ $? = 1 ] && grep -q "R1 C4: reference allen=missing" "$T/p4" && grep -q "R1 C4: accepted attempt prompt" "$T/p4"' +mk8 "$T/v5"; jq ".proposal_attempts[0].prompt_ids_sha256 = \"other\"" "$T/v5/D2/s3-report.json" >"$T/v5/x" && mv "$T/v5/x" "$T/v5/D2/s3-report.json" +chk "v8 checks red (C5): attempt 1 prompt differs from v7" 'bash $V8 "$T/v5" "$T/v5/v7" D2 R1 >"$T/p5"; [ $? = 1 ] && grep -q "D2 C5" "$T/p5"' +mk8 "$T/v6"; jq ".proposal_attempts += [{attempt: 3, outcome: \"refused\"}, {attempt: 4, outcome: \"refused\"}]" "$T/v6/R1/s3-report.json" >"$T/v6/x" && mv "$T/v6/x" "$T/v6/R1/s3-report.json" +chk "v8 checks red (C3): more than 3 attempts or a gap in numbering" 'bash $V8 "$T/v6" "$T/v6/v7" D2 R1 >"$T/p6"; [ $? = 1 ] && grep -q "R1 C3" "$T/p6"' +chk "the real-run launcher requires V8 CHECKS PASS on the dry launches and runs v8-checks.sh on all eleven after part 4; the dry launcher records it" \ + 'grep -q "V8 CHECKS PASS\" \] ||" evidence-v8/run.sh && grep -q "v8-checks.sh /home/drakestapleton/workspace/oq3-v8-runs .* D1 D2 D3 D4 D5 D6 E1 E2 N1 N2 R1" evidence-v8/run.sh && grep -q "v8-checks.sh \$V/dry-runs .* D1 D2 D3 > \$R/v8-checks-dry.txt" evidence-v8/run-dry.sh' +echo "test-v8: $pass ok, $fail failed"; [ $fail = 0 ] diff --git a/docs/campaigns/open-model-qwen3/v8-checks.sh b/docs/campaigns/open-model-qwen3/v8-checks.sh new file mode 100755 index 00000000..0be1f40e --- /dev/null +++ b/docs/campaigns/open-model-qwen3/v8-checks.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +# OPEN-MODEL-QWEN3 v8 feature checks (SPEC-v8.md Section 3). CPU only, shell + jq, reads run records only. Required for a v8 +# campaign PASS in addition to the 334 declared rows (they add requirements; no row or threshold changes). +# v8-checks.sh RUN_BASE V7_S3_DIR LAUNCH... +# RUN_BASE the v8 run base (/s3-report.json per launch, R1.reference.json) +# V7_S3_DIR evidence-v7/run/s3-reports (the v7 GB10 records, s3-report-.json) +# C1 shown: attempt 1 shows nothing; attempt k>1 shows exactly attempt k-1's reply (shown_refused_text_sha256 == its +# text_sha256) when attempt k-1 was refused with a reply, and nothing after a timeout or an error. +# C2 never kept: a launch has at most one parsed attempt, it is the last one, and its reply equals no refused reply of the launch. +# C3 limits: at most 3 attempts, numbered 1..n. +# C4 replay: R1.reference.json says allen "default" and its prompt_tokens and prompt_ids_sha256 equal the accepted R1 attempt's +# (exact token identity; the declared row R1-P checks the same pair). +# C5 unchanged: attempt 1's prompt_tokens and prompt_ids_sha256 equal the v7 record of the same launch (only retries changed). +# N1 has no model attempt (refused before any model call): C1 to C3 hold vacuously, C5 requires both records to have no attempt. +# Prints one line per failure and "V8 CHECKS PASS" or "V8 CHECKS FAIL"; exit 0 or 1; exit 2 on usage. +set -u +BASE=${1:?RUN_BASE}; V7=${2:?V7_S3_DIR}; shift 2; [ $# -gt 0 ] || { echo "usage: v8-checks.sh RUN_BASE V7_S3_DIR LAUNCH..." >&2; exit 2; } +fail=0; bad() { echo "FAIL $*"; fail=1; } +for L in "$@"; do + S=$BASE/$L/s3-report.json; O=$V7/s3-report-$L.json + [ -f "$S" ] || { bad "$L: no s3-report.json"; continue; } + A=$(jq -c '.proposal_attempts // []' "$S") + # C1 + jq -r '. as $a | range(0; length) as $k | $a[$k] as $x + | (if $k == 0 then null + elif ($a[$k-1].outcome == "refused" and ($a[$k-1].text_sha256 // null) != null) then $a[$k-1].text_sha256 + else null end) as $want + | select(($x.shown_refused_text_sha256 // null) != $want) + | "attempt \($x.attempt) shown=\($x.shown_refused_text_sha256 // "none") expected=\($want // "none")"' <<<"$A" | + while read -r m; do echo "FAIL $L C1 $m"; done | grep . && fail=1 + # C2 + jq -e '([.[] | select(.outcome == "parsed")] | length) as $p | (last // {}) as $z + | ($p == 0) or ($p == 1 and ($z.outcome == "parsed") + and ([.[] | select(.outcome == "refused") | .text_sha256] | index($z.text_sha256) | not))' <<<"$A" >/dev/null || + bad "$L C2: more than one parsed attempt, a parsed attempt that is not last, or an accepted reply equal to a refused one" + # C3 + jq -e 'length <= 3 and ([.[].attempt] == [range(1; length + 1)])' <<<"$A" >/dev/null || bad "$L C3: attempts $(jq -c '[.[].attempt]' <<<"$A")" + # C5 + if [ -f "$O" ]; then + n8=$(jq -c '[.[0] // {} | .prompt_tokens, .prompt_ids_sha256]' <<<"$A"); n7=$(jq -c '[.proposal_attempts[0]? // {} | .prompt_tokens, .prompt_ids_sha256]' "$O") + [ "$n8" = "$n7" ] || bad "$L C5: attempt 1 prompt $n8, v7 $n7" + else bad "$L C5: no v7 record $O"; fi + # C4 + if [ "$L" = R1 ]; then + R=$BASE/R1.reference.json + if [ -f "$R" ]; then + acc=$(jq -c '[.[] | select(.outcome == "parsed")] | last // {} | [.prompt_tokens, .prompt_ids_sha256]' <<<"$A") + ref=$(jq -c '[.prompt_tokens, .prompt_ids_sha256]' "$R") + [ "$(jq -r '.allen // "missing"' "$R")" = default ] || bad "R1 C4: reference allen=$(jq -r '.allen // "missing"' "$R"), expected default" + [ "$acc" = "$ref" ] || bad "R1 C4: accepted attempt prompt $acc, CPU reference $ref" + else bad "R1 C4: no R1.reference.json"; fi + fi +done +[ $fail = 0 ] && echo "V8 CHECKS PASS" || echo "V8 CHECKS FAIL" +exit $fail