Skip to content

Commit bb2125e

Browse files
committed
feat(driver): materialized-awareness provenance wire (provenance-only, cycle untouched)
Wires the materialize F→34→F loop + ndarray HHTL fork_decision into the live cognitive-shader-driver cycle as a SIDE analysis. Per operator decision 2026-06-17: provenance-only — the gate/emit/persistence path is byte-for-byte unchanged; the analysis only records what the 34 would dispatch and whether the leaf residue forks. - contract: MaterializeProvenance (primitive-only Copy: first_tactic/steps/ rested/final_free_energy/fork:u8) as a new ShaderCrystal field; fork is ForkAction-as-u8 so the zero-dep crate doesn't import ndarray. - driver: materialize_provenance() builds a ThoughtCtx from the cycle's own observables (sd←std_dev exact, confidence←1−F, dissonance←|felt−demonstrated| DK gap), runs materialize, and computes fork_decision. The fork challenge is a std_dev dispersion proxy (CONJECTURE) with a std_dev-calibrated floor/σ — pending the real orthogonal CoarseResidue magnitude + real HHTL cascade depth (depth==max⇒leaf for now). - tests: confident cycle→Commit, scattered low-skill→ForkDomain; dispatch populates provenance (first_tactic==0 = at-rest case). 638 contract lib + driver tests green. Board: LATEST_STATE contract inventory + EPIPHANIES E-MATERIALIZED-AWARENESS-2 (the four-vocabulary unification grounded in shipped types). Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 22e50f5 commit bb2125e

5 files changed

Lines changed: 193 additions & 2 deletions

File tree

.claude/board/EPIPHANIES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 2026-06-17 — E-MATERIALIZED-AWARENESS-2 — the driver wire is live (provenance-only); the four vocabularies are one 2-axis structure
2+
3+
**Status:** FINDING (shipped on branch `claude/materialize-awareness-f34-loop`): the `cognitive-shader-driver` now runs the `materialize` F→34→F loop + the ndarray HHTL `fork_decision` as a **side analysis** per cycle, recording `MaterializeProvenance` on `ShaderCrystal`. **Provenance-only — the gate/emit/persistence path is byte-for-byte unchanged** (operator decision 2026-06-17). 2 driver tests + 638 contract lib green.
4+
5+
**The unification, now grounded in shipped types.** The entropy×energy `Quadrant`, Csikszentmihalyi's `mul::FlowState(challenge,skill)`, Friston model-vs-surprise, and the Staunen↔Wisdom ladder are **one 2-axis structure**. CHALLENGE = surprise (`free_energy` / orthogonal leaf-residue magnitude); SKILL = engagement (`confidence`+`ATTEND_GAIN` / in-domain codebook capacity). The driver's observable→`ThoughtCtx` mapping is faithful (sd←std_dev exact, confidence←1−F = the driver's own `demonstrated_competence`, dissonance←|felt−demonstrated| = the Dunning-Kruger gap). The HHTL fork is the **anxiety escape**: Anxiety (challenge≫skill) at leaf → `ForkDomain` (mint a new classid = Friston model-switch); Flow → resolve in-domain; Boredom → Commit. Cross-repo: ndarray ships the fork math (PR #221 merged, `entropy_ladder::{residue_surprise, fork_decision, ForkAction}`), lance-graph drives it.
6+
7+
**[H]/[S] joints (unchanged from E-…-1, now with the wire built):** the fork challenge is a **`std_dev` dispersion proxy (CONJECTURE)** with a std_dev-calibrated floor/σ — the real orthogonal `CoarseResidue` magnitude is not yet surfaced into the cycle; HHTL cascade depth is stubbed `depth==max⇒leaf`; the σ-threshold awaits a Jirak-derived bound (`I-NOISE-FLOOR-JIRAK`). Promoting these to [G] = the next gated wire (surface real residue + cascade depth; optionally let the provenance feed a future gate path once measured to help).
8+
19
## 2026-06-16 — E-MATERIALIZED-AWARENESS-1 — awareness materializes iff it is *causal in dispatch*; the closed `F→34→F` loop is the reduction-to-practice (and the falsifier)
210

311
**Status:** FINDING for the criterion + loop (reduction-to-practice **shipped**: `lance-graph-contract::materialize`, 6 tests green, zero-dep/offline). The broader "this is the system's awareness" reading stays **[NOVEL — probe-gated]**: no prior art by construction (ours — the 2³-rung→NARS-candidate→34-tactic dispatch loop), validity established by the perturbation probe, not citation.

.claude/board/LATEST_STATE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,16 @@ the contract. This file exists to prevent that.
319319
| **#269** | 2026-04-26 | feat: Distance trait + SIMD Hamming/cosine wiring + PaletteDistanceTable + Dockerfile docs | Distance trait; SIMD Hamming/cosine wiring; PaletteDistanceTable 128KB; Dockerfile.md |
320320

321321

322+
---
323+
324+
## 2026-06-17 — Append: materialized-awareness driver wire (provenance-only) on branch claude/materialize-awareness-f34-loop
325+
326+
(Per APPEND-ONLY rule: new top-of-inventory entry.)
327+
328+
### Current Contract Inventory — new entry
329+
330+
**`lance-graph-contract::cognitive_shader::MaterializeProvenance`** (new type, 2026-06-17): primitive-only Copy record (`first_tactic:u8`, `steps:u16`, `rested:bool`, `final_free_energy:f32`, `fork:u8`) added as a field on `ShaderCrystal`. The `cognitive-shader-driver` runs the `materialize` F→34→F loop **and** the ndarray HHTL `fork_decision` as a **side analysis** over each cycle's already-computed observables (`free_energy`, `std_dev`, MUL, per-hit resonances) and records the outcome here. **Provenance-only — does NOT alter `bus.gate` or persistence** (operator decision 2026-06-17: cycle untouched). Observable→`ThoughtCtx` mapping is faithful (sd←std_dev, confidence←1−F, dissonance←|felt−demonstrated| DK gap); the fork's challenge is a **`std_dev` dispersion proxy (CONJECTURE)** with a std_dev-calibrated floor/σ, pending the real orthogonal `CoarseResidue` magnitude from the codec path and real HHTL cascade depth (depth==max⇒leaf for now). Driver helper `materialize_provenance(...)`; 2 driver tests (confident→Commit, scattered→ForkDomain; dispatch populates provenance) + the ndarray fork ladder (PR #221, merged). `fork:u8` = `ForkAction` (0 Commit /1 DescendDeeper /2 ForkBasin /3 ForkDomain). Note: `cognitive-shader-driver` is not in the default-workspace clippy member set. See `EPIPHANIES.md` E-MATERIALIZED-AWARENESS-1.
331+
322332
---
323333

324334
## 2026-06-16 — Append: `contract::materialize` shipped (branch claude/materialize-awareness-f34-loop)

crates/cognitive-shader-driver/src/driver.rs

Lines changed: 142 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,19 @@ use causal_edge::pearl::CausalMask;
3131
use causal_edge::plasticity::PlasticityState;
3232
use causal_edge::tables::{unpack_c, unpack_f, NarsTables};
3333
use lance_graph_contract::cognitive_shader::{
34-
AlphaComposite, CognitiveShaderDriver, EmitMode, MetaSummary, NullSink, ShaderBus,
35-
ShaderCrystal, ShaderDispatch, ShaderHit, ShaderResonance, ShaderSink, ALPHA_COMPOSITE_DIMS,
34+
AlphaComposite, CognitiveShaderDriver, EmitMode, MaterializeProvenance, MetaSummary, NullSink,
35+
ShaderBus, ShaderCrystal, ShaderDispatch, ShaderHit, ShaderResonance, ShaderSink,
36+
ALPHA_COMPOSITE_DIMS,
3637
};
3738
use lance_graph_contract::collapse_gate::{GateDecision, MergeMode, ALPHA_SATURATION_THRESHOLD};
3839
use lance_graph_contract::grammar::free_energy::{FreeEnergy, EPIPHANY_MARGIN};
3940
use lance_graph_contract::grammar::inference::NarsInference;
4041
use lance_graph_contract::grammar::thinking_styles::{
4142
GrammarStyleAwareness, ParamKey, ParseOutcome,
4243
};
44+
use lance_graph_contract::materialize::materialize;
4345
use lance_graph_contract::mul::{MulAssessment, MulThresholdProfile, SituationInput};
46+
use lance_graph_contract::recipe_kernels::ThoughtCtx;
4447
use lance_graph_contract::thinking::ThinkingStyle;
4548
use p64_bridge::cognitive_shader::CognitiveShader;
4649

@@ -484,6 +487,7 @@ impl ShaderDriver {
484487
},
485488
persisted_row: None,
486489
meta: MetaSummary::default(),
490+
materialize: MaterializeProvenance::default(),
487491
alpha_composite,
488492
};
489493
}
@@ -500,6 +504,7 @@ impl ShaderDriver {
500504
bus,
501505
persisted_row: None,
502506
meta: MetaSummary::default(),
507+
materialize: MaterializeProvenance::default(),
503508
alpha_composite,
504509
};
505510
}
@@ -518,6 +523,19 @@ impl ShaderDriver {
518523
_ => None,
519524
};
520525

526+
// Materialized-awareness provenance — runs the F→34→F loop + HHTL fork as
527+
// a SIDE analysis over this cycle's observables. Provenance-only: it has
528+
// NOT influenced `gate` above and does not influence persistence; it only
529+
// records "what the 34 would dispatch and whether the leaf residue forks".
530+
let candidate_resonances: Vec<f32> = hits.iter().map(|h| h.resonance).collect();
531+
let materialize_prov = materialize_provenance(
532+
&free_energy,
533+
std_dev,
534+
top_resonance,
535+
awareness_skill,
536+
&candidate_resonances,
537+
);
538+
521539
// [8] NARS revision — phi-1 humility ceiling.
522540
// System observes its own outcome and revises per-style awareness.
523541
// This is what makes the cognitive loop close: every cycle updates
@@ -545,6 +563,7 @@ impl ShaderDriver {
545563
bus,
546564
persisted_row,
547565
meta,
566+
materialize: materialize_prov,
548567
alpha_composite,
549568
};
550569
sink.on_crystal(&crystal);
@@ -772,6 +791,66 @@ fn entropy_std(hits: &[ShaderHit]) -> (f32, f32) {
772791
(ent, var.sqrt())
773792
}
774793

794+
/// Run the materialized-awareness analysis *alongside* the cycle — provenance
795+
/// only, never alters the gate. Builds a `ThoughtCtx` from the cycle's
796+
/// already-computed observables, runs the F→34→F loop, and computes the HHTL
797+
/// fork action from a dispersion proxy (CONJECTURE pending the real orthogonal
798+
/// `CoarseResidue` magnitude from the codec path).
799+
///
800+
/// Observable → `ThoughtCtx` mapping (faithful to fields the cycle already builds):
801+
/// - `free_energy` ← `F.total` (surprise)
802+
/// - `sd` ← `std_dev` (CollapseGate dispersion — exact)
803+
/// - `confidence` ← `1 - F.total` (the driver's own `demonstrated_competence`)
804+
/// - `dissonance` ← `|top_resonance - (1 - F.total)|` (the Dunning-Kruger gap:
805+
/// what the cycle *feels* vs what it has *demonstrated*)
806+
/// - `temperature` ← `std_dev` clamp (spread ⇒ explore; proxy)
807+
/// - `rung` ← `1` (no HHTL cascade depth surfaced in this cycle; proxy)
808+
fn materialize_provenance(
809+
free_energy: &FreeEnergy,
810+
std_dev: f32,
811+
top_resonance: f32,
812+
awareness_skill: f64,
813+
candidate_resonances: &[f32],
814+
) -> MaterializeProvenance {
815+
let demonstrated = (1.0 - free_energy.total).clamp(0.0, 1.0);
816+
let mut ctx = ThoughtCtx::new(candidate_resonances.to_vec());
817+
ctx.free_energy = free_energy.total.clamp(0.0, 1.0);
818+
ctx.sd = std_dev;
819+
ctx.confidence = demonstrated;
820+
ctx.dissonance = (top_resonance.clamp(0.0, 1.0) - demonstrated)
821+
.abs()
822+
.clamp(0.0, 1.0);
823+
ctx.temperature = std_dev.clamp(0.0, 1.0);
824+
ctx.rung = 1;
825+
826+
let trace = materialize(&mut ctx, 64);
827+
828+
// HHTL fork: `std_dev` (dispersion) is the CONJECTURE residue-magnitude proxy
829+
// until the real orthogonal `CoarseResidue` is surfaced into the cycle. The
830+
// floor/sigma_k are calibrated to std_dev's ~[0.05, 0.35] working range (NOT
831+
// the codec's NOISE_FLOOR), so a confident low-spread cycle reads as low
832+
// challenge (Commit) and a scattered one as high (fork). `depth == max_depth`
833+
// treats the read as a leaf, so ForkDomain is reachable when skill is short.
834+
const STD_DEV_RESIDUE_FLOOR: f64 = 0.05;
835+
const STD_DEV_RESIDUE_SIGMA_K: f64 = 6.0;
836+
let fork = ndarray::hpc::entropy_ladder::fork_decision(
837+
std_dev as f64,
838+
awareness_skill,
839+
1,
840+
1,
841+
STD_DEV_RESIDUE_FLOOR,
842+
STD_DEV_RESIDUE_SIGMA_K,
843+
) as u8;
844+
845+
MaterializeProvenance {
846+
first_tactic: trace.steps.first().map(|s| s.tactic_id).unwrap_or(0),
847+
steps: trace.steps.len() as u16,
848+
rested: trace.rested,
849+
final_free_energy: trace.final_free_energy,
850+
fork,
851+
}
852+
}
853+
775854
#[allow(dead_code)]
776855
fn collapse_gate(sd: f32) -> GateDecision {
777856
// Matches thinking_engine::cognitive_stack::{SD_FLOW_THRESHOLD, SD_BLOCK_THRESHOLD}.
@@ -924,6 +1003,67 @@ mod tests {
9241003
assert_eq!(crystal.bus.resonance.style_ord, auto_style::ANALYTICAL);
9251004
}
9261005

1006+
#[test]
1007+
fn dispatch_populates_materialize_provenance() {
1008+
let bs = Arc::new(demo_bindspace());
1009+
let sr = Arc::new(demo_semiring());
1010+
let driver = CognitiveShaderBuilder::new()
1011+
.bindspace(bs)
1012+
.semiring(sr)
1013+
.planes(demo_planes())
1014+
.build();
1015+
let req = ShaderDispatch {
1016+
rows: ColumnWindow::new(0, 4),
1017+
meta_prefilter: MetaFilter::ALL,
1018+
layer_mask: 0xFF,
1019+
radius: u16::MAX,
1020+
style: StyleSelector::Ordinal(auto_style::ANALYTICAL),
1021+
..Default::default()
1022+
};
1023+
let crystal = driver.dispatch(&req);
1024+
let m = crystal.materialize;
1025+
// Sane provenance. `first_tactic == 0` is the legitimate "already at rest,
1026+
// nothing dispatched" case (this demo cycle is confident → settles at once);
1027+
// any dispatched step must name a real tactic.
1028+
assert!(
1029+
m.first_tactic <= 34,
1030+
"tactic id in 0..=34, got {}",
1031+
m.first_tactic
1032+
);
1033+
if m.steps > 0 {
1034+
assert!(
1035+
(1..=34).contains(&m.first_tactic),
1036+
"a dispatched step must name a real tactic, got {}",
1037+
m.first_tactic
1038+
);
1039+
}
1040+
assert!(
1041+
m.fork <= 3,
1042+
"fork action is a valid ForkAction u8, got {}",
1043+
m.fork
1044+
);
1045+
assert!(m.final_free_energy.is_finite() && (0.0..=1.0).contains(&m.final_free_energy));
1046+
}
1047+
1048+
#[test]
1049+
fn materialize_provenance_confident_commits_scattered_forks() {
1050+
// Confident cycle: high resonance, low dispersion, ample skill → Boredom →
1051+
// Commit (fork 0). The leaf residue is small, the domain over-explains.
1052+
let fe_lo = FreeEnergy::compose(0.95, 0.05);
1053+
let confident = materialize_provenance(&fe_lo, 0.05, 0.95, 0.9, &[0.95, 0.9, 0.88]);
1054+
assert_eq!(confident.fork, 0, "confident cycle commits (no fork)");
1055+
1056+
// Scattered cycle: low resonance, high dispersion, short skill → Anxiety at
1057+
// leaf → ForkDomain (fork 3): the orthogonal leaf residue is strong enough
1058+
// that free energy forks into a new domain.
1059+
let fe_hi = FreeEnergy::compose(0.3, 0.4);
1060+
let scattered = materialize_provenance(&fe_hi, 0.4, 0.3, 0.1, &[0.3, 0.28, 0.31]);
1061+
assert_eq!(
1062+
scattered.fork, 3,
1063+
"scattered low-skill cycle forks to a new domain"
1064+
);
1065+
}
1066+
9271067
#[test]
9281068
fn dispatch_with_prefilter_excludes_rows() {
9291069
let bs = Arc::new(demo_bindspace());

crates/cognitive-shader-driver/src/wire.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,7 @@ mod tests {
14701470
brier: 0.1,
14711471
should_admit_ignorance: false,
14721472
},
1473+
materialize: Default::default(),
14731474
alpha_composite: None,
14741475
};
14751476
let wire = WireCrystal::from(&crystal);

crates/lance-graph-contract/src/cognitive_shader.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,9 @@ pub struct ShaderCrystal {
382382
pub persisted_row: Option<u32>,
383383
/// Meta assessment (Brier, confidence, should_admit_ignorance).
384384
pub meta: MetaSummary,
385+
/// Provenance of the side-run materialized-awareness analysis (the 34-tactic
386+
/// dispatch + HHTL fork). Provenance-only: does not affect `bus.gate`.
387+
pub materialize: MaterializeProvenance,
385388
/// Pillar-7 α-front-to-back composite, populated only when stage [7]
386389
/// dispatched on `MergeMode::AlphaFrontToBack`. `None` for the
387390
/// existing top-K aggregation modes (Bundle / Xor / Superposition).
@@ -397,6 +400,34 @@ pub struct MetaSummary {
397400
pub should_admit_ignorance: bool,
398401
}
399402

403+
/// Provenance of the materialized-awareness analysis run *alongside* the cycle.
404+
///
405+
/// **Provenance-only — does NOT alter the gate/emit decision.** The driver runs
406+
/// the `materialize` F→34→F loop and the HHTL `fork_decision` as a side analysis
407+
/// over the cycle's already-computed observables (`free_energy`, dispersion, MUL),
408+
/// then records the outcome here. It answers "which of the 34 would this awareness
409+
/// state dispatch, would the loop settle, and would the leaf residue fork to a new
410+
/// domain" without changing hot-path semantics. Primitive-only so the contract
411+
/// crate stays zero-dep (`fork` is `ForkAction as u8`, not the ndarray enum).
412+
///
413+
/// A zeroed value (`first_tactic == 0`) means the analysis did not run for this
414+
/// cycle (e.g. a sink-aborted early return).
415+
#[derive(Clone, Copy, Debug, Default, PartialEq)]
416+
pub struct MaterializeProvenance {
417+
/// Tactic id (1..=34) the awareness state dispatched first; `0` = not run.
418+
pub first_tactic: u8,
419+
/// Dispatch steps the F→34→F loop took before settling (or hitting the cap).
420+
pub steps: u16,
421+
/// Did the loop settle into rest (gate FLOW and surprise below the floor)?
422+
pub rested: bool,
423+
/// Residual free energy at rest.
424+
pub final_free_energy: f32,
425+
/// HHTL fork action as `u8` (0 Commit, 1 DescendDeeper, 2 ForkBasin,
426+
/// 3 ForkDomain). CONJECTURE: the challenge is a dispersion (std_dev) proxy,
427+
/// pending the real orthogonal `CoarseResidue` magnitude from the codec path.
428+
pub fork: u8,
429+
}
430+
400431
// ═══════════════════════════════════════════════════════════════════════════
401432
// ShaderSink — EmbedAnything commit-adapter pattern
402433
// ═══════════════════════════════════════════════════════════════════════════
@@ -501,6 +532,7 @@ mod tests {
501532
bus: ShaderBus::empty(),
502533
persisted_row: None,
503534
meta: MetaSummary::default(),
535+
materialize: MaterializeProvenance::default(),
504536
alpha_composite: None,
505537
});
506538
}

0 commit comments

Comments
 (0)