Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7bc03cf
test(apr-cli): cover civil_from_days and now_utc_iso8601 in corpus-in…
noahgift Oct 18, 2026
a81754f
test(aprender-contracts): cover build_diff_info + pv-query-diff-info-…
noahgift Oct 18, 2026
7a0e874
test(compute): cover relu_inplace and mul_scalar_alloc (Refs #5582)
noahgift Oct 18, 2026
bb7d0f9
chore(contracts): regen contracts.nt and README contract count for th…
noahgift Oct 18, 2026
7be0385
fix(contracts): formal: lines carry declared Σ symbols (formal_prose …
noahgift Oct 18, 2026
62628ea
chore(contracts): regen ONT witness (pv-sat) for the folded contract …
noahgift Oct 18, 2026
2f2abe0
Revert #5577 corpus-ingest test from this fold: touching a cited evid…
noahgift Oct 18, 2026
9f6792d
ci: refresh event payload for closing-refs guard
noahgift Oct 18, 2026
6580ab0
ci: refresh event payload for closing-refs guard (keep-open marker)
noahgift Oct 19, 2026
1e3476e
merge origin/main — derived files regenerated, not hand-merged
noahgift Oct 19, 2026
e920693
Merge remote-tracking branch 'origin/main' into batch/test-fold-5577-…
noahgift Oct 19, 2026
f6272fd
Merge remote-tracking branch 'origin/main' into tmp-m
noahgift Oct 19, 2026
e4d4bc4
Merge remote-tracking branch 'origin/main' into fx5583
noahgift Oct 19, 2026
3f7aec7
fix(contracts): regenerate witness after merging main (WitnessStale f…
noahgift Oct 19, 2026
ef62a33
merge: origin/main (witness, contracts.nt, shapes.ttl regenerated)
noahgift Oct 19, 2026
e1c7f59
fix(contracts): regenerate shapes.ttl and witness with the in-tree pv…
noahgift Oct 19, 2026
467af39
merge: origin/main (witness, contracts.nt, shapes.ttl regenerated)
noahgift Oct 19, 2026
e6a27a9
Merge remote-tracking branch 'origin/main' into fx5583
noahgift Oct 19, 2026
c84a4e6
chore(readme): readme-sync, CONTRACT_COUNT 1985 -> 1987 after main me…
noahgift Oct 19, 2026
6f7bbfa
merge origin/main into batch/test-fold-5577-5582 (derived files regen…
noahgift Oct 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ publishing — all backed by YAML provable contracts that fail CI on drift.
| Metric | Count | Source of truth |
|-------:|------:|---|
| Workspace crates | **81** workspace crates | `cargo metadata --no-deps` (NOT `ls crates/` — 4 are `exclude`d, 1 has no Cargo.toml) |
| Provable contracts | **<!-- CONTRACT_COUNT_START -->1987<!-- CONTRACT_COUNT_END -->** provable contracts | `contracts/census.json` `.n_files` — the set `pv lint` walks (`pv census`, ONT-001 ONT-1; regenerated by `make contracts`, written by `make readme-sync`, guarded by `scripts/check_readme_claims.sh`) |
| Provable contracts | **<!-- CONTRACT_COUNT_START -->1989<!-- CONTRACT_COUNT_END -->** provable contracts | `contracts/census.json` `.n_files` — the set `pv lint` walks (`pv census`, ONT-001 ONT-1; regenerated by `make contracts`, written by `make readme-sync`, guarded by `scripts/check_readme_claims.sh`) |
| CLI commands | **113** CLI commands | `contracts/apr-cli-commands-v1.yaml` §`commands` (parse the list; `apr --help` also lists `help` itself, and `grep -c '^ - name:'` gives 119 — other same-indent `name:` keys exist in the file) |
| Book CLI chapters | **114** chapters | `ls book/src/cli/*.md` |
| Book lib chapters | **73** chapters | `ls book/src/lib/*.md` (parity with `pub mod`) |
Expand Down Expand Up @@ -403,7 +403,7 @@ falsification_tests:
prediction: apr validate bad-model.apr exits non-zero
```

The tree carries <!-- CONTRACT_COUNT_START -->1987<!-- CONTRACT_COUNT_END --> contracts across inference, training, quantization, attention, FFN,
The tree carries <!-- CONTRACT_COUNT_START -->1989<!-- CONTRACT_COUNT_END --> contracts across inference, training, quantization, attention, FFN,
tokenization, model formats, CLI safety — and this README itself.

## Migration from old crates
Expand Down
65 changes: 65 additions & 0 deletions contracts/blis-elementwise-inplace-v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
metadata:
id: C-BLIS-ELEMENTWISE-INPLACE
version: 1.0.0
created: '2026-10-18'
author: PAIML Engineering
kind: pattern
status: ACTIVE_ALGORITHM_LEVEL
description: |
Pins relu_inplace and mul_scalar_alloc in aprender-compute's BLIS elementwise
module (#5582): relu_inplace equals the out-of-place relu for every length
(including SIMD tail lengths), and mul_scalar_alloc returns a fresh vector of
the same length with every element scaled and the input untouched.
references:
- 'crates/aprender-compute/src/blis/elementwise.rs (relu_inplace, mul_scalar_alloc)'

equations:
relu_inplace_equals_relu:
formula: |
relu_inplace(x) == relu(x) elementwise, for any length incl. 0 and non-multiples of the SIMD width
relu(v) = max(v, 0)
domain: f32 slices
invariants:
- 'negatives and -0.0 map to 0.0; zero and positives are unchanged'
mul_scalar_alloc_scales:
formula: 'mul_scalar_alloc(x, s)[i] == x[i] * s; len preserved; x not mutated'
domain: f32 slices, finite scalar
invariants:
- 's == 1.0 is the identity'

proof_obligations:
- id: BEI-INV-001
type: invariant
property: in-place ReLU equals out-of-place ReLU
formal: '∀ x: relu_inplace(x) ≡ relu(x)'
applies_to: relu_inplace_equals_relu
- id: BEI-INV-002
type: invariant
property: mul_scalar_alloc scales each element and keeps length
formal: 'out[i] == x[i] * s and len(out) == len(x)'
applies_to: mul_scalar_alloc_scales

falsification_tests:
- id: FALSIFY-BLIS-ELEMENTWISE-INPLACE-001
rule: relu_inplace clamps negatives and matches relu across tail lengths
prediction: 'n in {0,1,7,8,9,31,33} match relu; [-2,-0,0,0.5,3,-1e-9,f32::MIN] -> [0,0,0,0.5,3,0,0]'
test: cargo test -p aprender-compute --lib blis::elementwise::tests::relu_inplace
if_fails: in-place ReLU diverges from the out-of-place kernel (negative activations leak through)
ship_blocking: false
mutation: 'replace x.max(0.0) with x.min(0.0) in relu_inplace; must turn RED'
- id: FALSIFY-BLIS-ELEMENTWISE-INPLACE-002
rule: mul_scalar_alloc scales every element, preserves length, leaves input untouched
prediction: '19-element ramp times 2.5 matches exactly; scalar 1.0 returns the input unchanged'
test: cargo test -p aprender-compute --lib blis::elementwise::tests::mul_scalar_alloc
if_fails: allocating scalar multiply drops, mis-scales or mutates elements
ship_blocking: false

qa_gate:
id: QA-BLIS-ELEMENTWISE-INPLACE-001
name: BLIS elementwise in-place/alloc gate
description: relu_inplace and mul_scalar_alloc semantics hold
checks:
- relu_inplace_equals_relu
- mul_scalar_alloc_scales
pass_criteria: FALSIFY-BLIS-ELEMENTWISE-INPLACE-001 and -002 pass
falsification: Any failure fails the gate
10 changes: 10 additions & 0 deletions contracts/contracts.nt
Original file line number Diff line number Diff line change
Expand Up @@ -9386,6 +9386,11 @@
<https://ont.paiml.dev/v1alpha1/contract/blake3-state-v1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://ont.paiml.dev/v1alpha1/Kernel> .
<https://ont.paiml.dev/v1alpha1/contract/blake3-state-v1> <https://ont.paiml.dev/v1alpha1/file> "contracts/forjar/blake3-state-v1.yaml"^^<http://www.w3.org/2001/XMLSchema#string> .
<https://ont.paiml.dev/v1alpha1/contract/blake3-state-v1> <https://ont.paiml.dev/v1alpha1/id> "blake3-state-v1"^^<http://www.w3.org/2001/XMLSchema#string> .
<https://ont.paiml.dev/v1alpha1/contract/blis-elementwise-inplace-v1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/prov#Entity> .
<https://ont.paiml.dev/v1alpha1/contract/blis-elementwise-inplace-v1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://ont.paiml.dev/v1alpha1/Contract> .
<https://ont.paiml.dev/v1alpha1/contract/blis-elementwise-inplace-v1> <https://ont.paiml.dev/v1alpha1/file> "contracts/blis-elementwise-inplace-v1.yaml"^^<http://www.w3.org/2001/XMLSchema#string> .
<https://ont.paiml.dev/v1alpha1/contract/blis-elementwise-inplace-v1> <https://ont.paiml.dev/v1alpha1/id> "blis-elementwise-inplace-v1"^^<http://www.w3.org/2001/XMLSchema#string> .
<https://ont.paiml.dev/v1alpha1/contract/blis-elementwise-inplace-v1> <https://ont.paiml.dev/v1alpha1/kind> "pattern"^^<http://www.w3.org/2001/XMLSchema#string> .
<https://ont.paiml.dev/v1alpha1/contract/blis-gemm-v1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/prov#Entity> .
<https://ont.paiml.dev/v1alpha1/contract/blis-gemm-v1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://ont.paiml.dev/v1alpha1/Contract> .
<https://ont.paiml.dev/v1alpha1/contract/blis-gemm-v1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://ont.paiml.dev/v1alpha1/Kernel> .
Expand Down Expand Up @@ -13106,6 +13111,11 @@
<https://ont.paiml.dev/v1alpha1/contract/pv-cli-surface-v1> <https://ont.paiml.dev/v1alpha1/file> "contracts/pv-cli-surface-v1.yaml"^^<http://www.w3.org/2001/XMLSchema#string> .
<https://ont.paiml.dev/v1alpha1/contract/pv-cli-surface-v1> <https://ont.paiml.dev/v1alpha1/id> "pv-cli-surface-v1"^^<http://www.w3.org/2001/XMLSchema#string> .
<https://ont.paiml.dev/v1alpha1/contract/pv-cli-surface-v1> <https://ont.paiml.dev/v1alpha1/kind> "pattern"^^<http://www.w3.org/2001/XMLSchema#string> .
<https://ont.paiml.dev/v1alpha1/contract/pv-query-diff-info-v1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/prov#Entity> .
<https://ont.paiml.dev/v1alpha1/contract/pv-query-diff-info-v1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://ont.paiml.dev/v1alpha1/Contract> .
<https://ont.paiml.dev/v1alpha1/contract/pv-query-diff-info-v1> <https://ont.paiml.dev/v1alpha1/file> "contracts/pv-query-diff-info-v1.yaml"^^<http://www.w3.org/2001/XMLSchema#string> .
<https://ont.paiml.dev/v1alpha1/contract/pv-query-diff-info-v1> <https://ont.paiml.dev/v1alpha1/id> "pv-query-diff-info-v1"^^<http://www.w3.org/2001/XMLSchema#string> .
<https://ont.paiml.dev/v1alpha1/contract/pv-query-diff-info-v1> <https://ont.paiml.dev/v1alpha1/kind> "pattern"^^<http://www.w3.org/2001/XMLSchema#string> .
<https://ont.paiml.dev/v1alpha1/contract/pv-version-identity-v1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/prov#Entity> .
<https://ont.paiml.dev/v1alpha1/contract/pv-version-identity-v1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://ont.paiml.dev/v1alpha1/Contract> .
<https://ont.paiml.dev/v1alpha1/contract/pv-version-identity-v1> <https://ont.paiml.dev/v1alpha1/file> "contracts/pv-version-identity-v1.yaml"^^<http://www.w3.org/2001/XMLSchema#string> .
Expand Down
43 changes: 43 additions & 0 deletions contracts/pv-query-diff-info-v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
metadata:
version: 1.0.0
created: '2026-10-18'
author: PAIML Engineering
description: "pv query diff info — build_diff_info reports the last commit that touched a contract file as a full sha plus a date-only string, and reports nothing for a path git has no history for."
kind: pattern
references:
- "aprender#5580 — coverage-gap ticket for aprender-contracts (build_diff_info was at 0.0%)"
- "crates/aprender-contracts/src/query/query_enrich.rs — build_diff_info"
- "crates/aprender-contracts/src/query/query_enrich_tests.rs — the falsifiers"

equations:
diff_info_is_sha_plus_date_only:
formula: "for a tracked path p: len(commit_hash) == 40 AND len(last_modified) == 10 AND days_ago == parse_iso_days_ago(last_modified, now)"
domain: "a contract path with at least one commit in git"
codomain: "Some(DiffInfo)"
invariants:
- "The time part of the author date is stripped; a date with a time suffix is a defect"
- "A path git has no history for yields None, not an empty DiffInfo"

proof_obligations:
- id: PVQDI-INV-001
type: invariant
property: "A tracked file yields a 40-hex sha and a 10-character Y-M-D date"
formal: "∀ tracked p: len(commit_hash(p)) = 40 ∧ len(last_modified(p)) = 10"
applies_to: diff_info_is_sha_plus_date_only
- id: PVQDI-INV-002
type: invariant
property: "A path with no git history yields None"
formal: "p ∉ git_history ⇒ build_diff_info(p) ≡ None"
applies_to: diff_info_is_sha_plus_date_only

falsification_tests:
- id: FALSIFY-PVQDI-001
rule: "date part keeps the time suffix"
prediction: "mutating date_part to the raw %aI string turns the tracked-file test RED"
test: "cargo test -p aprender-contracts --lib build_diff_info_reports_the_last_commit_of_a_tracked_file"
if_fails: "build_diff_info leaks a time component into last_modified"
- id: FALSIFY-PVQDI-002
rule: "missing path invents a DiffInfo"
prediction: "a nonexistent path returns None"
test: "cargo test -p aprender-contracts --lib build_diff_info_is_none_for_a_path_git_has_no_history_for"
if_fails: "build_diff_info returns Some for a path without history"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"census_id_set_sha256": "2cd65471402c5d974cca226206c779350b3419dda8b5db7b61d0fc70d2fb2549",
"census_id_set_sha256": "d3dfda18ea6caa1dfb2920d1803d8ddea6534bb557f22bed7db5e2a8c0bc2619",
"relations_sha256": "811c78184eb2609244c59534f015f0be2f90923120a3027c176ad56723d0d850",
"checkable_n": 87,
"result": {
Expand Down
41 changes: 41 additions & 0 deletions crates/aprender-compute/src/blis/elementwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,4 +993,45 @@ mod tests {
// 2*x + 1, then relu: [-3,0] [-1,0] [1] [3] [5]
assert_eq!(out, vec![0.0, 0.0, 1.0, 3.0, 5.0]);
}

// ── relu_inplace / mul_scalar_alloc (#5582) ───────────────────────────

#[test]
fn relu_inplace_clamps_negatives_and_keeps_zero_and_positives() {
let mut data = [-2.0f32, -0.0, 0.0, 0.5, 3.0, -1e-9, f32::MIN];
relu_inplace(&mut data);
assert_eq!(data, [0.0, 0.0, 0.0, 0.5, 3.0, 0.0, 0.0]);
}

#[test]
fn relu_inplace_matches_out_of_place_relu_across_tail_lengths() {
for n in [0usize, 1, 7, 8, 9, 31, 33] {
let input: Vec<f32> = (0..n).map(|i| ((i * 13 + 5) % 17) as f32 - 8.0).collect();
let mut expected = vec![0.0f32; n];
if n > 0 {
relu(&input, &mut expected).unwrap();
}
let mut actual = input.clone();
relu_inplace(&mut actual);
assert_eq!(actual, expected, "n={n}");
}
}

#[test]
fn mul_scalar_alloc_scales_every_element_and_preserves_length() {
let input: Vec<f32> = (0..19).map(|i| i as f32 - 9.0).collect();
let out = mul_scalar_alloc(&input, 2.5);
assert_eq!(out.len(), input.len());
for (o, i) in out.iter().zip(&input) {
assert_eq!(*o, i * 2.5);
}
}

#[test]
fn mul_scalar_alloc_by_one_is_identity_and_input_untouched() {
let input = vec![1.5f32, -2.0, 0.0, 7.25, -0.125, 3.0, 9.0, 11.0, -13.0];
let before = input.clone();
assert_eq!(mul_scalar_alloc(&input, 1.0), before);
assert_eq!(input, before);
}
}
41 changes: 41 additions & 0 deletions crates/aprender-contracts/src/query/query_enrich_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,44 @@ bindings:
assert_eq!(g_binding.status, "unbound");
assert!(g_binding.module_path.is_none());
}

fn entry_at(path: &str) -> types::ContractEntry {
let mut e = test_entry("diff-info", vec![], 0, 0);
e.path = path.into();
e
}

#[test]
fn build_diff_info_reports_the_last_commit_of_a_tracked_file() {
let manifest = concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml");
let info = build_diff_info(&entry_at(manifest)).expect("Cargo.toml is tracked");
assert_eq!(info.commit_hash.len(), 40, "full sha: {}", info.commit_hash);
assert!(info.commit_hash.bytes().all(|b| b.is_ascii_hexdigit()));
let parts: Vec<&str> = info.last_modified.split('-').collect();
assert_eq!(parts.len(), 3, "date part is Y-M-D: {}", info.last_modified);
assert_eq!(parts[0].len(), 4);
assert_eq!(info.last_modified.len(), 10, "time part is stripped");
assert!(info.days_ago < 36_500, "days_ago is relative to now");
}

#[test]
fn build_diff_info_days_ago_matches_parse_iso_days_ago() {
let manifest = concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml");
let info = build_diff_info(&entry_at(manifest)).expect("tracked");
let now = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_secs();
let expect = parse_iso_days_ago(&info.last_modified, now);
assert!(
info.days_ago.abs_diff(expect) <= 1,
"{} vs {expect}",
info.days_ago
);
}

#[test]
fn build_diff_info_is_none_for_a_path_git_has_no_history_for() {
let missing = concat!(env!("CARGO_MANIFEST_DIR"), "/no-such-file-5580.yaml");
assert!(build_diff_info(&entry_at(missing)).is_none());
}
3 changes: 2 additions & 1 deletion docs/findings/w5382.jsonl
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
{"id":"FND-20261018-apr-cli-from-pairs-untested","session":"w5382","kind":"coverage-gap","where":"crates/apr-cli/src/commands/hang_trace_classifier.rs:TraceDirListing::from_pairs","note":"public constructor had no direct test; the module tests build listings by hand, so from_pairs pairing was unexercised. Covered by 3 tests + FALSIFY-CRUX-F-14-004; mutation (reverse sizes) RED."}
{"id":"FND-20261018-compute-inplace-unreferenced","title":"aprender-compute pub fns with a single reference (their definition): blocking_8x48, packed_a/b_size_v2, with_reserve, get_checksums","evidence":"grep -rw over crates/aprender-compute/{src,tests,benches,examples} finds exactly one hit each; pmat --coverage-gaps timed out without cached llvm-cov","repro":"grep -rwn packed_a_size_v2 crates/aprender-compute","suspected_epic":"unknown","severity":"P3","found_at_sha":"e00034704047bc22f843f7b512f34d3524a0a403"}
{"id":"FND-20261018-ruchy-sessions-dark","title":"ecosystem::ruchy tests only run with feature ruchy-sessions, which default CI does not enable","evidence":"cargo test -p aprender-train --lib test_session_metrics runs 0 tests by default (7654 filtered); 7 with --features ruchy-sessions; mod gated at crates/aprender-train/src/ecosystem/mod.rs:16","repro":"cargo test -p aprender-train --lib test_session_metrics","suspected_epic":"unknown","severity":"P3","found_at_sha":"e00034704047bc22f843f7b512f34d3524a0a403"}
{"id":"FND-20261018-apr-cli-from-pairs-untested","session":"w5382","kind":"coverage-gap","where":"crates/apr-cli/src/commands/hang_trace_classifier.rs:TraceDirListing::from_pairs","note":"public constructor had no direct test; the module tests build listings by hand, so from_pairs pairing was unexercised. Covered by 3 tests + FALSIFY-CRUX-F-14-004; mutation (reverse sizes) RED."}
Loading