Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .claude/board/STATUS_BOARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Pixel/tile position = geometry; `PaletteState(u8)` = material (needle); `FisherZ
| **D-CTX-1** | Virtual surfel reading over a 16 × 16 tile (all 256 ordinals): per pixel `(W, Σ = Σ w·d dᵀ)` read from the center↔Moore-neighbour Fisher-Z codes, consumed immediately | Shipped (#1357) | `cognitive-shader-driver/examples/virtual_surfel_probe.rs`; streamed readings = materialized `Vec<SurfelReading>` (2 fixtures + 32 random tiles × 2 identity weights); 0 heap allocations (oracle: pairs 29,760 B, relations 3,720 B, surfels 4,100 B); Morton = geometry (1,860 visits); position = address, a moved patch keeps its reading; swapping two ordinals changes the result; diagonal mutant caught; a stripe orients Σ along itself and turns with it, and `identity_weight = 0` flips it (the identity weight is an explicit argument, not a constant); gated pixels yield no surfel; all readings PSD, 256/256 SPD on the permutation tile; 10 tests, 7 disable runs red. Shared carrier moved to `examples/support/fisher_relation.rs` (D-CTX-0 unchanged, same law generation) |
| **D-CTX-2** | Isotropic Gaussian/EWA accumulation from virtual surfels: `s = (Σxx+Σyy)/2W`, `Σ_fp = ewa_sandwich(√s·I, I) = s·I`, `A = activation·W/2032`, 7 × 7 clipped window into a transient 2 KB field; footprint evaluator probe-local; identity weight 254 (operator DECISION 2026-10-06) | Shipped (#1357) | `cognitive-shader-driver/examples/ewa_render_probe.rs`; fused = materialized `Vec<Surfel>`→`Vec<Gaussian>`→field bit for bit (18 tiles); fused = independent closed-form gather within 1e-12·max (measured 6.7e-16); fused path 0 allocations (materialized: surfels 4,100 B, gaussians 8,200 B); sandwich = `s·I`, SPD, and scales an anisotropic Σ by `s`; footprint = closed-form isotropic Gaussian (≤ 1e-14 rel.); field total = Σ amplitude × own window mass, window mass ≤ 1.001, interior ≥ 0.99, total ≤ input activation; zero activation renders nothing; replay exact, law and palette both matter; 8 tests, 6 disable runs red. Surfel reading moved to `examples/support/virtual_surfel.rs` (D-CTX-1 unchanged) |
| **D-CTX-3** | Anisotropic Gaussian/EWA accumulation: footprint `Σ_fp = ewa_sandwich(Σ̂'^{1/2}, I)` with `Σ̂ = Σ_c/W` and eigenvalues floored at ½ (the law's own minimum isotropic scale, since every Moore offset has `|d|² ≥ 1`); isotropic readings collapse onto D-CTX-2 | Shipped (#1361) | `cognitive-shader-driver/examples/ewa_anisotropic_probe.rs`; fused = materialized bit for bit (16 tiles); fused = independent rotated closed-form gather (own eigen-decomposition) within 1e-12·max, measured 6.7e-16; isotropic readings give D-CTX-2's footprint (≤ 1e-14) and an all-isotropic tile renders as D-CTX-2 (196 surfels); a stripe spreads the render along itself (var x 0.886 vs y 0.499), turns with it, and its peak equals `A/(2π√det Σ_fp)`; without the floor a thin footprint holds > 1.3 of its mass (manufactured evidence) and cross code −127 gives a singular Σ̂, with it every footprint ≤ 1.001; the law never yields an isotropic scale below the floor; i8 quantization: worst 1.11° orientation and 1.27 % eigenvalue error over 2,672 anisotropic surfels (pinned 1.5° / 2 %); no BF16, no Σ codebook, `PaletteState` not widened; 0 allocations; 8 tests, 5 disable runs red. Isotropic law moved to `examples/support/ewa.rs` (D-CTX-2 unchanged) |
| **D-CTX-4** | One read-only measurement over the D-CTX-2 surface: strongest boundary, central-difference gradient argmax over the inner region `5..=10` (pixels whose value and difference cannot see the tile edge: footprint radius 3 + Moore 1 + difference 1), ties to the smaller Morton code; returns a 32-byte `BoundaryWitness { at, magnitude, gx, gy }`, no field | In PR | `cognitive-shader-driver/examples/boundary_measure_probe.rs`; streaming (Morton order, one register) = materialized row-major `Vec` + explicit argmax on 6 rendered fields and a synthetic one; 0 allocations (materialized 1,152 B); a material boundary is found within a pixel of the palette change, points across it (gx > 10·gy) and turns with it; a uniform tile reads flat (2.0e-14 against field max 255); contrast follows the law (weak pair 25.18 > mid > strong 5.37); tie-break checked on a tied set where row-major and Morton pick different winners; field unchanged by measuring; 7 tests, 5 disable runs red (incl. region widened by one pixel → uniform tile no longer flat). `pair_with_code` moved to `support/fisher_relation.rs` |
| **D-CTX-5** | Morton/HHTL visit order vs row-major, reusing `morton8x8` | Queued | result identical across orders, or order pinned in replay identity |
| **D-CTX-6** | Measurement → observation → `GadamerRevision` | Queued | rendered surface alone cannot change belief state |
| **D-CTX-4** | One read-only measurement over the D-CTX-2 surface: strongest boundary, central-difference gradient argmax over the inner region `5..=10` (pixels whose value and difference cannot see the tile edge: footprint radius 3 + Moore 1 + difference 1), ties to the smaller Morton code; returns a 32-byte `BoundaryWitness { at, magnitude, gx, gy }`, no field | Shipped (#1364) | `cognitive-shader-driver/examples/boundary_measure_probe.rs`; streaming (Morton order, one register) = materialized row-major `Vec` + explicit argmax on 6 rendered fields and a synthetic one; 0 allocations (materialized 1,152 B); a material boundary is found within a pixel of the palette change, points across it (gx > 10·gy) and turns with it; a uniform tile reads flat (2.0e-14 against field max 255); the rendered boundary response changes deterministically with the signed pair-law code (negative-code pair 25.18 > mid-negative pair > positive-code pair 5.37; an observation about the rendered surface, no epistemic or semantic strength derived from it); tie-break checked on a tied set where row-major and Morton pick different winners; field unchanged by measuring; 7 tests, 5 disable runs red (incl. region widened by one pixel → uniform tile no longer flat). `pair_with_code` moved to `support/fisher_relation.rs` |
| **D-CTX-5** | Morton/HHTL visit order vs row-major for the D-CTX-2 render: four orders (Morton = nibble-trie DFS = D-CTX-2's own, row-major, 4 × 4 tiled, reversed); addressing via the contract's `Morton8x8` (= `FacetTier::morton`), palette never read as a coordinate | In PR | `cognitive-shader-driver/examples/morton_order_probe.rs`; every order a distinct permutation; 7 × 7 footprint neighbours via the code = geometry over the whole tile; Morton order = D-CTX-2 bit for bit; **`f64` scatter depends on the visit order at the last bits** (row-major 134, tiled 85, reversed 181 pixels changed, ≤ 1.1e-15), so the order is part of that render's replay identity; an `i64` accumulator at 2⁻³² is order-free (identical bits for all four orders on 10 tiles) within 1.4e-9 of `f64` (bound 49·2⁻³³); trie ascent per step: Morton = tiled = reversed 1.0588 (270/255), row-major 1.2471, so `nibble_climb` cannot separate block-finishing orders; 0 allocations; 7 tests, 4 disable runs red, 1 equivalent mutant (round-per-add on the 2⁻³² grid equals integer summation) |
| **D-CTX-6** | Measurement → observation → `GadamerRevision` → replay over the D-CTX-2 surface: belief = `InterpretiveHorizon<(), [u64; 4]>`, one bit per pixel (roots = observed, claims = observed material boundary); the D-CTX-4 witness is presented as an inherited interpretation with no root, an observation reads only the resident palette (pixel + Moore neighbours) and is one new root; `delta.resulting` adopted only on `IncreaseEligible` | In PR | `cognitive-shader-driver/examples/observation_revision_probe.rs`; every inner pixel's rendered witness, presented to a horizon already holding observations, is `Reinterpretation`/`NoIncrease` and moves nothing; every observation is `HorizonExpansion` or `IndependentConfirmation` and the adopted claims equal an x/y palette oracle on 5 tiles; the render points at (5, 5) with |g| 1.65 when the only material change is at x = 2, outside the inner region, and the observation records a negative; two Fisher-Z laws render different fields but give identical final belief; replay is identical, `revision_index` = steps, and re-presenting every observation is `Echo`; one loop step allocates 0 B. Measured, not claimed useful: the steepest rendered pixel on the split tile is (6, 7), one pixel off the material boundary (x = 7, 8); steering by the render covers the 12 inner boundary pixels at step 24 vs 34 row-major, but quadrants at 35 vs 34. 7 tests, 5 disable runs red (adopt every revision; render claims a root; observation claims what was pointed at; ancestry forgets roots; wrong oracle). `strongest_boundary` moved to `support/boundary.rs` with an address-predicate variant |

## D-MORTON — Checked 8:8 Morton address arithmetic (2026-10-06)

Expand Down
9 changes: 9 additions & 0 deletions crates/cognitive-shader-driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ test = true
name = "boundary_measure_probe"
test = true

# D-CTX-5 visit-order probe; tests run under `cargo test`.
[[example]]
name = "morton_order_probe"
test = true

[[example]]
name = "observation_revision_probe"
test = true

# D-GSO-6 recipe selector probe; tests run under `cargo test`.
[[example]]
name = "recipe_selector_probe"
Expand Down
32 changes: 30 additions & 2 deletions crates/cognitive-shader-driver/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,37 @@ D-CTX-4. One read-only measurement over the rendered surface: where is it
steepest? The operator reads the D-CTX-2 field over the inner region whose
values cannot see the tile edge, and returns a 32-byte witness (location,
magnitude, gradient) instead of a gradient field. A material boundary is found
where the palette changes, its contrast follows the Fisher-Z relation of the
two materials, a uniform tile reads flat, and measuring never changes the field.
where the palette changes, the rendered boundary response changes
deterministically with the signed pair-law code of the two materials (an
observation about the surface, not a semantic strength), a uniform tile reads flat, and measuring never changes the field.

```bash
cargo run -p cognitive-shader-driver --example boundary_measure_probe
```

## morton_order_probe.rs

D-CTX-5. Does the order in which surfels are visited change the render? Four
orders over the same 16 × 16 tile (Morton, the order D-CTX-2 uses; row-major;
4 × 4 tiled; reversed). The `f64` scatter changes in its last bits with the
order, so that order is part of its replay identity; an `i64` fixed-point
accumulator gives the same bits for every order. The probe also measures each
order's trie ascent per step through `Morton8x8::nibble_climb`.

```bash
cargo run -p cognitive-shader-driver --example morton_order_probe
```

## observation_revision_probe.rs

D-CTX-6. Closes the loop: render → measurement → observation →
`GadamerRevision` → replay. The belief state is a revision horizon with one
bit per pixel. The rendered boundary witness is presented to the revision as
an inherited interpretation and never changes belief; only an observation of
the resident palette (a new independent root) is admitted. The render decides
where to look next, not what is found: two Fisher-Z laws give different fields
and the same final belief.

```bash
cargo run -p cognitive-shader-driver --example observation_revision_probe
```
95 changes: 30 additions & 65 deletions crates/cognitive-shader-driver/examples/boundary_measure_probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
//! Tests: `cargo test -p cognitive-shader-driver --example boundary_measure_probe`

use std::mem::size_of;
use std::ops::RangeInclusive;

use bgz_tensor::fisher_z::FisherZTable;
use lance_graph_contract::morton8x8::Morton8x8;
Expand All @@ -54,50 +53,9 @@ use virtual_surfel::{Tile, PIXELS};
mod ewa;
use ewa::{max_abs, render_isotropic, Field};

/// Pixels whose value and central difference do not see the tile edge.
const INNER: RangeInclusive<u8> = 5..=10;

// ── the operator ───────────────────────────────────────────────────────────

/// What the operator returns: where the surface is steepest, and how.
#[derive(Clone, Copy, Debug, PartialEq)]
struct BoundaryWitness {
at: Morton8x8,
magnitude: f64,
gx: f64,
gy: f64,
}

#[inline]
fn at(f: &Field, p: Morton8x8, dx: i8, dy: i8) -> f64 {
let n = p
.checked_offset(dx, dy)
.expect("inner pixels have all four neighbours");
f[n.code() as usize]
}

/// B: one pass in Morton order, one witness register.
fn strongest_boundary(f: &Field) -> Option<BoundaryWitness> {
let mut best: Option<BoundaryWitness> = None;
for code in 0..PIXELS as u16 {
let p = Morton8x8::from_code(code);
if !INNER.contains(&p.x()) || !INNER.contains(&p.y()) {
continue;
}
let gx = (at(f, p, 1, 0) - at(f, p, -1, 0)) / 2.0;
let gy = (at(f, p, 0, 1) - at(f, p, 0, -1)) / 2.0;
let magnitude = (gx * gx + gy * gy).sqrt();
if best.is_none_or(|b| magnitude > b.magnitude) {
best = Some(BoundaryWitness {
at: p,
magnitude,
gx,
gy,
});
}
}
best
}
#[path = "support/boundary.rs"]
mod boundary;
use boundary::{strongest_boundary, BoundaryWitness, INNER};

// ── A: materialized ────────────────────────────────────────────────────────

Expand Down Expand Up @@ -153,34 +111,34 @@ fn render(tile: &Tile, law: &PairwiseFisherZ<'_>) -> Field {
fn main() {
let table = FisherZTable::build(&representatives(1), 256);
let law = PairwiseFisherZ::borrow(&table);
let (weak_s, weak_b) = law.pair_with_code(-100..=-80);
let (strong_s, strong_b) = law.pair_with_code(80..=100);
let (neg_s, neg_b) = law.pair_with_code(-100..=-80);
let (pos_s, pos_b) = law.pair_with_code(80..=100);

let weak = render(&split(weak_s, weak_b, true), &law);
let (w, n_alloc, n_bytes) = allocations_during(|| strongest_boundary(&weak));
let negative = render(&split(neg_s, neg_b, true), &law);
let (w, n_alloc, n_bytes) = allocations_during(|| strongest_boundary(&negative));
let w = w.expect("non-empty inner region");
let (a, a_bytes) = strongest_boundary_materialized(&weak);
let strong = strongest_boundary(&render(&split(strong_s, strong_b, true), &law)).unwrap();
let flat = strongest_boundary(&render(&[weak_s; PIXELS], &law)).unwrap();
let flat_field = render(&[weak_s; PIXELS], &law);
let (a, a_bytes) = strongest_boundary_materialized(&negative);
let positive = strongest_boundary(&render(&split(pos_s, pos_b, true), &law)).unwrap();
let flat = strongest_boundary(&render(&[neg_s; PIXELS], &law)).unwrap();
let flat_field = render(&[neg_s; PIXELS], &law);

println!(
"D-CTX-4 strongest-boundary measurement over the D-CTX-2 surface, inner region {INNER:?}"
);
println!(" law generation : {:#018x}", law.generation);
println!(
" weak boundary (code -100..=-80) : at ({}, {}) |g| {:.4} gx {:+.4} gy {:+.4}",
" negative-code pair (-100..=-80) : at ({}, {}) |g| {:.4} gx {:+.4} gy {:+.4}",
w.at.x(),
w.at.y(),
w.magnitude,
w.gx,
w.gy
);
println!(
" strong boundary (code 80..=100) : at ({}, {}) |g| {:.4}",
strong.at.x(),
strong.at.y(),
strong.magnitude
" positive-code pair (80..=100) : at ({}, {}) |g| {:.4}",
positive.at.x(),
positive.at.y(),
positive.magnitude
);
println!(
" uniform tile : |g| {:.3e} against field max {:.3e}",
Expand All @@ -199,6 +157,7 @@ fn main() {
#[cfg(test)]
mod tests {
use super::*;
use std::ops::RangeInclusive;

fn table() -> FisherZTable {
FisherZTable::build(&representatives(1), 256)
Expand Down Expand Up @@ -278,11 +237,13 @@ mod tests {
}
}

/// FAILS IF: the measured contrast does not follow the law: a weakly
/// related pair must read as a stronger boundary than a strongly related
/// one, and identical material must read as none.
/// FAILS IF: the rendered boundary response does not change
/// deterministically with the signed pair-law code. The measured order
/// (negative-code pair > mid-negative pair > positive-code pair) is pinned
/// as an observation about the rendered surface only; no epistemic or
/// semantic strength is read from it. Identical material reads as none.
#[test]
fn the_contrast_follows_the_pair_law() {
fn boundary_response_changes_with_the_signed_pair_code() {
let table = table();
let law = PairwiseFisherZ::borrow(&table);
let measure = |range: RangeInclusive<i8>| {
Expand All @@ -291,9 +252,13 @@ mod tests {
.unwrap()
.magnitude
};
let (weak, mid, strong) = (measure(-100..=-80), measure(-40..=-20), measure(80..=100));
assert!(weak > mid && mid > strong, "{weak} {mid} {strong}");
assert!(strong > 0.0);
let (negative, mid_negative, positive) =
(measure(-100..=-80), measure(-40..=-20), measure(80..=100));
assert!(
negative > mid_negative && mid_negative > positive,
"{negative} {mid_negative} {positive}"
);
assert!(positive > 0.0);
}

/// FAILS IF: the tie-break is not "smaller Morton code wins". Two equal
Expand Down
Loading
Loading