Skip to content

feat(recipe): require_inputs, sha256_file, linked-file check and receipt with tests (R-1 slices 8+9) - #7137

Merged
noahgift merged 25 commits into
mainfrom
R075h-recipe-9
Nov 16, 2026
Merged

noahgift merged 25 commits into
mainfrom
R075h-recipe-9

Conversation

@noahgift

@noahgift noahgift commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

What

Measured at head bfde49c (after merging main), 2026-11-16

  • cargo test -p apr-cli --lib train_recipe: rc 0, 40 passed. cargo test -p aprender-contracts --lib: rc 0, 2403 passed. cargo fmt --all -- --check rc 0; cargo deny check advisories ok.

Measured at head 1ecc46a, 2026-11-16

  • cargo test -p apr-cli --lib recipe: rc 0, 57 passed.
  • cargo clippy -p apr-cli --lib -- -D warnings: rc 0.
  • python3 scripts/ci/fail_fast.py ids: rc 0. cargo fmt -p apr-cli -- --check: rc 0.
  • Six hand mutations, each failed at least one test: the inode comparison always false; is_file replaced by exists; the canonical-path comparison always false; the inode number dropped from the comparison; the hash loop stopped after one read; the validated-not-applied list emptied. One no-op change passed, as a control. At 1ecc46a three more, each failing the new test on its 20-second limit: the regular-file check removed; the check moved to after the open; the check narrowed to directories only.
  • The increment is over the 200-line slice size, so it goes to two review lanes.

Review history

  • a163e81: FAIL x2 (Opus, Haiku). /dev/zero as data.train made require_inputs and receipt read without end; no test covered a path that is not a regular file; the wording said "published vector" for the file hash, which was only compared with the in-memory hash. Fixed in a317857: the regular-file test, a test that runs both calls against /dev/zero under a time limit, and the published one-million-a vector for the file hash.
  • a317857: Opus FAIL, Haiku PASS. The check ran after the open, and opening a named pipe waits for a writer, so a pipe still hung both calls; no test told pin-only hashing from hashing always. Fixed in 1ecc46a: the file type is asked before the open, the test covers a pipe as data.train and as eval.heldout, with and without a pin, and the pin-only hashing is taken back out.
  • Survivors reported by the Opus lane at a163e81 and not fixed: the device-number half of the linked-file comparison, the read size, the order of the base and data.train labels in the missing-file error, the wording of the pin error, and a receipt that ignores the not-applied list it is given.
  • 1ecc46a: Opus PASS, Haiku PASS (both non-author, same family as the author: degraded: same-family).

Known limits

  • A read error part-way through a file gives no hash; no test forces one.
  • require_inputs hashes the training file even when the recipe has no pin. That costs one read of the file and changes no result.
  • The file type is asked and then the file is opened. A path swapped for a pipe between the two is not seen.
  • The pipe test runs mkfifo and is built on Unix only.
  • Still not enforced (listed at the top of the contract): exit 5 and the --recipe flag conflicts; a seed above 9223372036854775807 is refused by the YAML reader as a type error.
  • The linked-file check compares device and inode numbers on Unix only. On other systems it compares resolved paths, so a hard link there is not seen.
  • The files are checked when require_inputs runs. A file swapped between that check and the training run is not seen.
  • The receipt hashes are computed when receipt is called, not when require_inputs ran.
  • The mutations above were made by hand; cargo mutants was not run.
  • Not run here: scripts/check_contract_test_binding.sh (CI runs it), clippy over the test module.

ont-delta: none
Closes #7136
keep-open: #5316 master ticket, later slices still open

🤖 Generated with Claude Code

noahgift and others added 24 commits November 15, 2026 19:11
…slice 1/6)

Pins contracts.nt, the census witness and the README contract count.

Pmat-Ticket: PMAT-5316

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…(R-1 slice 1/6)

Four falsification tests named fns that land in later slices, so
pv lint --strict-test-binding reported 4 missing. Slice 1 now carries one
shell-harness entry (pv validate); FALSIFY-APR-RECIPE-001..005 return in the
slice that adds each test. Loader and example paths are marked as landing later.

Pmat-Ticket: PMAT-5316

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…st ids)

pr-light's fail_fast ids step refused FALSIFY-APR-RECIPE-000: ids must start at 001.

Pmat-Ticket: PMAT-5316
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Schema types of `apr finetune --recipe` (RecipeMethod, the Raw* shapes, TrainRecipe);
the parser, rules and receipt follow in later slices. FALSIFY-APR-RECIPE-003 cites
the method-spelling test present at this head.

Pmat-Ticket: PMAT-5316
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
TrainRecipe::parse reads the required keys and anchors relative paths at the recipe's directory; FALSIFY-APR-RECIPE-002 cites the test that proves it.

Pmat-Ticket: PMAT-5316
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… (R-1 slice 4)

Tests the required-key refusals the parser already makes (missing eval, missing keys, wrong schema id, unknown keys, wrong type, bad seed); FALSIFY-APR-RECIPE-001 and 003 cite them.

Pmat-Ticket: PMAT-5316
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…lice 5)

Empty strings, the heldout-aliases-train check, and the training block are validated by field; FALSIFY-APR-RECIPE-003 cites the tests.

Pmat-Ticket: PMAT-5316
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…training numbers (R-1 slice 6)

Tests of the rules slice 5 added; FALSIFY-APR-RECIPE-003 and 005 cite them.

Pmat-Ticket: PMAT-5316
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
check_teacher validates the distillation block and TrainRecipe::load reads a recipe file; FALSIFY-APR-RECIPE-002 and 003 cite the tests.

Pmat-Ticket: PMAT-5316
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…lice 8)

require_inputs checks the files a real run reads and the data pin before any model is loaded; sha256_file streams a hash. FALSIFY-APR-RECIPE-002 and 005 cite the tests.

Pmat-Ticket: PMAT-5316
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ice 9)

require_inputs refuses a heldout linked to the training file; TrainRecipe::receipt carries the recipe, data and eval hashes and the engines. FALSIFY-APR-RECIPE-003 and 005 cite the tests.

Pmat-Ticket: PMAT-5316
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
# Conflicts:
#	contracts/apr-recipe-v1.yaml
Pmat-Ticket: PMAT-5316

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…der-error limit

Review of #7130 at 4d8e724: no test planted an unknown key under eval, teacher or output, and the contract claimed every fault is listed in one message, which is false for a wrong type or an unknown key (the YAML reader stops at the first). Adds the three rows, one test that pins the limit, and narrows the contract wording.

Pmat-Ticket: PMAT-5316

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Review of #7130 at d5c336a: the contract states heldout != train, teacher <=> distill and training numbers > 0, and the loader at this head checks none of them. Comment-only: names them as not yet enforced and drops stale slice numbering.

Pmat-Ticket: PMAT-5316

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…or optional keys

Keeps the review fixes of #7130 (reader-error limit, unknown-key rows), narrows the contract's not-yet-enforced list to what the loader still lacks, adds valid_optional_fields_are_kept and an infinity row for learning_rate.

Pmat-Ticket: PMAT-5316

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ests catch length and digit faults

Review of #7132 at a4a3cd7 (2 lanes FAIL): lexical_normalize dropped a repeated leading '..' and kept '..' above the root; is_sha256 survived two mutations. Rewrites the '..' arm, skips the same-file rule when data.train is missing, adds tests for both, and narrows FALSIFY-APR-RECIPE-005 to the pin's shape.

Pmat-Ticket: PMAT-5316

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…slices 5+6 (PMAT-5316 slice 7)

Merges R075h-recipe-6 (reviewed at ad76fcc) and keeps its review fixes. Adds tests that fail when a check is removed: alpha bounds inclusive, NaN and negative teacher numbers, the teacher rule waits for a known method, the same-file rule is silent for an empty heldout, load names the file in a refusal. The contract's not-yet-enforced list drops the teacher rule.

Pmat-Ticket: PMAT-5316

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…h and the qlora refusal (PMAT-5316 slice 7)

Review of #7135 at 15ba17a (2 lanes FAIL): a temperature bound of 1 passed every test, the not-UTF-8 error was not checked for the file name, no test put a teacher under qlora, and the body said a teacher block is not judged under an unknown method when only the presence rule waits. Adds a test for each; no change to the parser.

Pmat-Ticket: PMAT-5316

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…le and the receipt (R-1 slices 8+9)

require_inputs refuses a directory and a hard-linked held-out file, a pin on an absent file is not compared, sha256_file is tested past one buffer, and the receipt fields are asserted. The contract's not-yet-enforced list drops require_inputs and the receipt.

Pmat-Ticket: PMAT-5316
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…w of a163e81)

sha256_file returns nothing for a directory or a device instead of reading it, so /dev/zero as data.train no longer hangs require_inputs or the receipt. The training file is hashed only when a pin is set. Adds the one-million-a vector for the file hash.

Pmat-Ticket: PMAT-5316
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…is not opened (review of a317857)

Opening a pipe waits for a writer, so the check after the open still hung require_inputs and the receipt. The test now covers a pipe as data.train and eval.heldout, with and without a pin. The pin-only hashing of a317857 is taken back out: no test could tell it from hashing always.

Pmat-Ticket: PMAT-5316
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Pmat-Ticket: PMAT-5316

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@noahgift
noahgift marked this pull request as ready for review November 16, 2026 10:05
@noahgift
noahgift enabled auto-merge (squash) November 16, 2026 10:07
@github-actions

Copy link
Copy Markdown

§13.11 rung 1 — quorum shadow verdict

S13-SHADOW pr=7137 head=bfde49cd9ee0a1645d11ccc10a1eac3673718edb verdict=REFUSE class=Q1 arm_rc=1

Shadow mode: this records a verdict and merges nothing. A refusal
to arm is not a block (§13 adds zero rows to §7) — the pull request is
exactly as green as it was.

@noahgift
noahgift merged commit 784802d into main Nov 16, 2026
28 checks passed
@noahgift
noahgift deleted the R075h-recipe-9 branch November 16, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apr-recipe-v1: require_inputs, sha256_file, linked-file check and receipt with their tests (R-1 slices 8+9)

1 participant