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
11 changes: 11 additions & 0 deletions .claude/board/EPIPHANIES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 2026-07-17 — E-RUNG-ASCENT-WIRED-1 — the rung ascent loop is now WIRED in the shader driver (D-TRI-6, plateau P3); RungLevel deduped to the contract; the correctness gate was an axis mismatch, not the ladder

**Status:** SHIPPED (plateau P3, PR pending). Executes the §3a wiring E-MASLOW-PYRAMID-OF-COGNITION-1 named as "the missing wiring". Four deliverables, all green.

- **The centerpiece (D):** the driver already held a per-driver `RungElevator` and called `on_gate` once per dispatch, but its rung never reached projection selection — stage [3] cascade used `req.layer_mask` verbatim. Now the elevator's CURRENT level (advanced by the previous cycle's gate) selects THIS cycle's cascade breadth via `rung_widened_layer_mask`, closing the loop across cycles.
- **The one real correctness gate (HAZARD a) was an AXIS mismatch, not the ladder:** p64 `CognitiveShader::cascade`'s `layer_mask` is an 8-bit PREDICATE-PLANE mask (CAUSES..BECOMES), NOT the 3-bit SPO projection mask `RungLevel::causal_mask_bits()` returns. Feeding `causal_mask_bits()` raw is a category error AND collapses base-Surface to plane 0. Fix: the rung's *Pearl level* selects a predicate-plane widen-set (mirrors `p64_bridge::edge_to_layer_mask`), applied as a UNION gated on elevation-above-base → **identity at base (zero regression), superset-monotone above** (elevation only widens). D-TRI-6 settlement probe (sustained BLOCK ascends → sustained FLOW relaxes to base; mask widens then returns to identity) green.
- **Dedup (A):** thinking-engine's `RungLevel` was variant-identical to the contract's; collapsed to `pub use lance_graph_contract::cognitive_shader::RungLevel` (added `as_u8()` to the contract; discriminant-parity test IS the "measure" step — a repr(u8) variant-identical enum needs no jc battery). Deleted the dead `should_elevate`, `LayerId` (zero consumers), and `Agent.current_rung` (write-once Surface, never mutated — the ascent loop lives on the driver's elevator, not the orphaned Agent).
- **(B)** scenario.rs Pearl-numbering doc wobble fixed (interventions = rung 2, not 3). **(C)** nars_engine deprecation silenced with a justified `#[allow(deprecated)]` (v2 `inference_type()` already routes through `from_mantissa` internally; `temporal()` inert under v2) — planner clippy `-D warnings` exit 0.
- **Verified:** contract 905 tests + parity green, planner 215 + clippy exit 0, driver 103 + both D-TRI-6 probes green, thinking-engine lib builds. System-1 arm (`apply_delta(rung_delta())`) left test-only — the driver hot path has no emergence/coherence scalar to feed it; fabricating one is forbidden.
- Cross-ref: TD-THINKING-ENGINE-EXCLUDED-DEBT-1 + TD-ONTOLOGY-CLIPPY-DEBT-1 (pre-existing debts surfaced, out of P3 scope).

Comment thread
AdaWorldAPI marked this conversation as resolved.
## 2026-07-17 — E-MASLOW-PYRAMID-OF-COGNITION-1 — observation/gestalt FIRST, then SPO 2³ decomposition → CausalEdge64 → NARS candidate design; the ladder type is shipped, the stateful ascent loop is the missing wiring (operator-directed)

**Status:** RULING (design banked, PR #707 §3a) + AUDIT (fleet sweep, same day). Operator: "Maslow pyramid of cognition, observation/gestalt first, then SPO 2³ decomposition, CausalEdge64, design NARS candidates" — each level engages only when the level below fails to settle; the base is wide (the D-TRI-6 EXPECTATION is that most stimuli settle at resonance, O(1) palette lookup), the apex narrow (counterfactual design, fork+simulate). Pyramid width IS the cost amortization. Middle-tier emissions ARE NARS candidates (doctrine `mailbox-kanban-model.md:42`); the upper tier DESIGNS (revises) them, it does not introduce NARS — and the shipped driver runs that revision optionally-per-cycle where the pyramid gates it on non-settlement (a named behavior delta, D-TRI-6-gated).
Expand Down
2 changes: 1 addition & 1 deletion .claude/board/STATUS_BOARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Plan: `.claude/plans/triangle-tenants-gestalt-separation-v1.md`. Design shipped;
| D-TRI-3 | Nail->hammer dispatch probe: object resonance -> atom retrieval vs inverted baseline; no inverted read path exists structurally | lance-graph | Queued | plan §3, §6 |
| D-TRI-4 | Chess<->thinking transfer measurement (validity + reliability) — the quarantine-lift gate | lance-graph + stockfish-rs | Queued | plan §5, §6 |
| D-TRI-5 | Emulation != resonance: counterfactual-goalstate emulation vs resonance-only baseline on opponent move prediction (operator correction §2a; builds on D-SF-OPPONENT-1/3) | lance-graph + stockfish-rs | Queued | plan §2a, §6 |
| D-TRI-6 | Pyramid settlement: settle-rung distribution over real shader cycles (base-heavy expected); homeostatic descent verified; elevator threshold jc-calibrated | lance-graph | Queued | plan §3a, §6 |
| D-TRI-6 | Pyramid settlement: settle-rung distribution over real shader cycles (base-heavy expected); homeostatic descent verified; elevator threshold jc-calibrated | lance-graph | In PR (P3) — ascent loop WIRED (driver rung→predicate-plane widen; identity-at-base, superset-monotone); settlement probe green; real-cycle distribution + jc threshold calibration still open | plan §3a, §6 |
Comment thread
coderabbitai[bot] marked this conversation as resolved.

## epiphany-integration-2026-07-04-v3 — membranes, parity, unified ruff phases

Expand Down
8 changes: 8 additions & 0 deletions .claude/board/TECH_DEBT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Technical Debt Log — Open + Paid (double-entry, append-only)

## TD-THINKING-ENGINE-EXCLUDED-DEBT-1 — thinking-engine (excluded, off-CI) carries ~40 pre-existing clippy lints + test-compile failures (2026-07-17)

**Surfaced during P3** (rung dedup). thinking-engine is a workspace-EXCLUDED crate (root Cargo.toml `exclude`), so no CI/clippy gate runs on it — it has accumulated ~40 `clippy -D warnings` lints (loop-index, `map_or` simplify, too-many-args, missing-Default; all in modules P3 never touched — e.g. `cognitive_stack.rs:242` MetaCognition::new, `world_model.rs:154` from_engine_state) and at least one test-compile break (`DualResult` missing `convergence_signed`/`convergence_unsigned` fields, a stale test). The **lib builds clean**; only `--tests` and `clippy -D warnings` fail. Correlates with E-RUNG-ASCENT-WIRED-1's finding that the whole crate is orphaned from the production spine (only bridge_gate→callcenter + dto→driver[feature] are external wires). PAYOFF: gated on the P4 ancestry-consolidation decision (wire the gems into the spine → then it earns a CI slot and the debt gets paid; or retire the orphaned cluster). Not paid in P3 (out of scope; excluded crate).

## TD-ONTOLOGY-CLIPPY-DEBT-1 — lance-graph-ontology (member) has pre-existing clippy -D warnings errors that block dependent `-p` clippy (2026-07-17)

**Surfaced during P3.** `cargo clippy -p cognitive-shader-driver -- -D warnings` fails (exit 101) entirely inside `lance-graph-ontology` (a transitive dep): `doc-lazy-continuation` ×N, `iter-cloned-collect` (`.iter().copied().collect()` → `to_vec()`), and deprecated `oxrdf::Subject` type-alias uses (ttl_parse.rs, owl.rs, op_emitter.rs, lib.rs). P3 touches none of ontology; the driver's OWN code is clippy-clean (0 findings in driver.rs). Pre-existing by construction (not in P3's diff). PAYOFF: mechanical (doc reflow + `to_vec()` + `NamedOrBlankNode` migration), its own small PR — not P3 scope. Flags that repo CI likely does not run full-workspace `clippy -D warnings`, or main is already red there.

Comment thread
AdaWorldAPI marked this conversation as resolved.
## TD-BGZ-TENSOR-PRE-LANE-REVIEW — bgz-tensor's adaptive codec predates turbovec/PolarQuant/helix; engineering follow-up review queued (2026-07-16)

**Open.** Operator nudge: `bgz-tensor` (incl. `adaptive_codec.rs`'s
Expand Down
177 changes: 159 additions & 18 deletions crates/cognitive-shader-driver/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,25 @@ impl ShaderDriver {
// below is written ONCE against `backing` — no `#[cfg]` branches here.
let backing = self.backing();

// ── Rung ascent loop (D-TRI-6) ──────────────────────────────────────
// The persistent per-driver RungElevator's CURRENT level — advanced by
// the PREVIOUS cycle's gate via `on_gate` at the end of this fn — selects
// THIS cycle's cascade plane breadth. A dispatch whose requested base
// rung differs from the elevator's tracked base resets the elevator
// first, so streaks never leak across unrelated dispatch bases. At base
// the mask is unchanged (no regression); above base it widens by union
// (see `rung_widened_layer_mask` + its HAZARD(a) note).
let effective_layer_mask = {
let mut elevator = self
.rung_elevator
.write()
.expect("rung_elevator RwLock poisoned");
if elevator.base != req.rung {
*elevator = RungElevator::new(req.rung);
}
rung_widened_layer_mask(elevator.base, elevator.level, req.layer_mask)
};
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// [1] Cheap meta prefilter (u32 column sweep).
let passed_rows = backing.prefilter(req.rows, &req.meta_prefilter);

Expand Down Expand Up @@ -303,7 +322,7 @@ impl ShaderDriver {
// Rows with edge=0 default to palette 0 (identity probe).
let edge = backing.edge(row as usize);
let query = edge.s_idx();
let raw = shader.cascade(query, req.radius, req.layer_mask);
let raw = shader.cascade(query, req.radius, effective_layer_mask);
for hit in raw.into_iter().take(4) {
let resonance = 1.0 / (1.0 + (hit.distance as f32 / max_dist));

Expand Down Expand Up @@ -532,6 +551,32 @@ impl ShaderDriver {
None
};

// Advance the persistent per-driver `RungElevator` with THIS cycle's
// already-decided `gate`, BEFORE the sink callbacks. The sink early
// returns (`on_resonance` / `on_bus` returning false) must NOT bypass
// the rung transition — a sink that stops processing would otherwise
// freeze the ascent ladder, now that the elevator drives the cascade
// (CodeRabbit #708). Sustained BLOCK elevates over the dispatched base;
// sustained FLOW relaxes back to it. The base-reset is REPEATED here,
// inside the SAME critical section as `on_gate` (not only at the
// top-of-`run()` read): the elevator is a `&self` per-driver `RwLock`
// singleton, so a concurrent dispatch with a different `req.rung` may
// have reset `base` in the window since the top read; re-validating here
// keeps reset+advance atomic, so this cycle's gate is never counted
// against another request's base (codex r3603015026). The resulting
// level is what the NEXT dispatch on this base consults — closing the
// ascent loop across cycles.
let elevated_rung: u8 = {
let mut elevator = self
.rung_elevator
.write()
.expect("rung_elevator RwLock poisoned");
if elevator.base != req.rung {
*elevator = RungElevator::new(req.rung);
}
elevator.on_gate(gate) as u8
};

// [7] Sink callbacks.
if !sink.on_resonance(&resonance_dto) {
return ShaderCrystal {
Expand Down Expand Up @@ -580,23 +625,6 @@ impl ShaderDriver {
_ => None,
};

// Feed this cycle's already-decided `gate` into the persistent
// per-driver `RungElevator` (sustained-BLOCK elevation over the
// dispatched base — see the field doc on `ShaderDriver::rung_elevator`).
// A dispatch requesting a different base rung than the elevator
// currently tracks resets it to that new base first, so streaks
// never leak across unrelated dispatch contexts.
let elevated_rung: u8 = {
let mut elevator = self
.rung_elevator
.write()
.expect("rung_elevator RwLock poisoned");
if elevator.base != req.rung {
*elevator = RungElevator::new(req.rung);
}
elevator.on_gate(gate) as u8
};

// Materialized-awareness provenance — runs the F→34→F loop + HHTL fork as
// a SIDE analysis over this cycle's observables. Provenance-only: it has
// NOT influenced `gate` above and does not influence persistence; it only
Expand Down Expand Up @@ -646,6 +674,54 @@ impl ShaderDriver {
}
}

// ═══════════════════════════════════════════════════════════════════════════
// Rung ascent loop — rung → predicate-plane widening (D-TRI-6)
// ═══════════════════════════════════════════════════════════════════════════

/// Combine the dispatch's 8-bit predicate-plane mask with the CURRENT rung.
/// At (or below) the dispatched base rung this returns `req_mask` UNCHANGED —
/// zero behaviour change for a thought sitting at its requested depth. Above
/// base, each Pearl level the rung has climbed UNIONs in additional predicate
/// planes, so the consulted set is a strict SUPERSET of `req_mask`: elevation
/// only ever WIDENS the cascade, never narrows it.
///
/// HAZARD (a) — axis translation (CORRECTNESS GATE). The p64
/// `CognitiveShader::cascade` `layer_mask` is an 8-bit PREDICATE-PLANE mask
/// (CAUSES..BECOMES; bit `z` gates plane `z`), NOT the 3-bit SPO projection
/// mask `RungLevel::causal_mask_bits()` returns. Feeding `causal_mask_bits()`
/// raw would be a category error AND, at base Surface (0b001), would collapse
/// the cascade to plane 0 only — a severe regression. So the rung's *Pearl
/// level* selects a predicate-plane widen-set, mirroring the Pearl→predicate
/// routing already in `p64_bridge::edge_to_layer_mask`. Because the widen is a
/// UNION, a caller that already asked for all planes (`0xFF`, the
/// `ShaderDispatch` default) sees no change — you cannot consult more than every
/// plane. The specific planes each Pearl level unlocks are a calibration a later
/// probe may retune; the identity-at-base and superset-monotone properties are
/// invariant.
fn rung_widened_layer_mask(base: RungLevel, level: RungLevel, req_mask: u8) -> u8 {
if (level as u8) <= (base as u8) {
return req_mask;
}
// p64 predicate-plane bit positions (mirror p64_bridge::{CAUSES..BECOMES}):
// CAUSES=0 ENABLES=1 SUPPORTS=2 CONTRADICTS=3 REFINES=4 ABSTRACTS=5
// GROUNDS=6 BECOMES=7.
const ENABLES: u8 = 1 << 1;
const CONTRADICTS: u8 = 1 << 3;
const REFINES: u8 = 1 << 4;
const ABSTRACTS: u8 = 1 << 5;
const BECOMES: u8 = 1 << 7;
// Pearl-level → predicate widen-set (superset-monotone):
// L1 observation → nothing beyond req_mask,
// L2 intervention → +ENABLES +REFINES,
// L3 counterfactual → also +CONTRADICTS +ABSTRACTS +BECOMES.
let widen = match level.pearl_level() {
1 => 0,
2 => ENABLES | REFINES,
_ => ENABLES | REFINES | CONTRADICTS | ABSTRACTS | BECOMES,
};
req_mask | widen
}

// ═══════════════════════════════════════════════════════════════════════════
// Pillar-7 — α-front-to-back composite helper (stage [7] sink mode)
// ═══════════════════════════════════════════════════════════════════════════
Expand Down Expand Up @@ -1779,3 +1855,68 @@ mod tests {
assert_eq!(hit_big.confidence_to_alpha(), 1.0);
}
}

#[cfg(test)]
mod rung_ascent_tests {
use super::rung_widened_layer_mask;
use lance_graph_contract::cognitive_shader::{RungElevator, RungLevel};
use lance_graph_contract::collapse_gate::GateDecision;

// A narrow dispatch mask so union-widening is observable. The production
// default is 0xFF (all 8 planes); at 0xFF elevation cannot widen further,
// so the probe uses a single-plane base — mimics a Surface observation.
const BASE_MASK: u8 = 0b0000_0001; // CAUSES only

#[test]
fn d_tri_6_rung_ascends_relaxes_and_cascade_mask_tracks() {
let mut e = RungElevator::new(RungLevel::Surface);

// (i) at base: mask is EXACTLY the dispatch mask — no regression.
assert_eq!(
rung_widened_layer_mask(e.base, e.level, BASE_MASK),
BASE_MASK
);

// sustained BLOCK ascends. threshold = 2, so 6 BLOCKs climb 3 rungs:
// Surface(0) → Shallow(1) → Contextual(2) → Analogical(3, Pearl L2).
for _ in 0..6 {
e.on_gate(GateDecision::BLOCK);
}
assert_eq!(e.level, RungLevel::Analogical);
assert_eq!(e.level.pearl_level(), 2);

// (ii) elevated across a Pearl boundary → strict SUPERSET of the dispatch
// mask (widened, changed, never narrowed).
let widened = rung_widened_layer_mask(e.base, e.level, BASE_MASK);
assert_ne!(
widened, BASE_MASK,
"elevation must change the consulted mask"
);
assert_eq!(widened & BASE_MASK, BASE_MASK, "must be a superset");
assert!(widened.count_ones() > BASE_MASK.count_ones(), "must widen");

// sustained FLOW relaxes back to base (never below): Analogical(3) → base
// Surface is 3 de-elevations = 6 FLOWs.
for _ in 0..6 {
e.on_gate(GateDecision::FLOW_BUNDLE);
}
assert_eq!(e.level, e.base);
assert_eq!(e.level, RungLevel::Surface);

// back at base → mask returns to identity.
assert_eq!(
rung_widened_layer_mask(e.base, e.level, BASE_MASK),
BASE_MASK
);
}

#[test]
fn all_planes_dispatch_mask_saturates_widening_to_noop() {
// At the ShaderDispatch default (0xFF), elevation can't widen further.
let mut e = RungElevator::new(RungLevel::Surface);
for _ in 0..8 {
e.on_gate(GateDecision::BLOCK); // climb well past Pearl L3
}
assert_eq!(rung_widened_layer_mask(e.base, e.level, 0xFF), 0xFF);
}
}
34 changes: 34 additions & 0 deletions crates/lance-graph-contract/src/cognitive_shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ impl RungLevel {
}
}

/// The wire ordinal for this rung (`0..=9`) — the inverse of [`from_u8`].
/// The (now-deduped) thinking-engine call sites read a rung as `u8` for DTO
/// fields and damping factors through this.
#[inline]
pub const fn as_u8(self) -> u8 {
self as u8
}

/// One rung up, saturating at [`Transcendent`](RungLevel::Transcendent).
#[inline]
pub const fn elevate(self) -> Self {
Expand Down Expand Up @@ -775,6 +783,32 @@ mod tests {
}
}

#[test]
fn rung_discriminant_parity_with_deduped_thinking_engine_enum() {
// D-TRI-6 dedup guard: thinking-engine's RungLevel (deleted; now a
// re-export of THIS type) carried the identical #[repr(u8)] discriminants
// Surface=0 … Transcendent=9. A repr(u8) variant-identical enum is
// provably substitutable by a discriminant equality assertion — this IS
// the "measure" step (there is no jc metric API).
let expected = [
(RungLevel::Surface, 0u8),
(RungLevel::Shallow, 1),
(RungLevel::Contextual, 2),
(RungLevel::Analogical, 3),
(RungLevel::Abstract, 4),
(RungLevel::Structural, 5),
(RungLevel::Counterfactual, 6),
(RungLevel::Meta, 7),
(RungLevel::Recursive, 8),
(RungLevel::Transcendent, 9),
];
for (rung, ord) in expected {
assert_eq!(rung as u8, ord, "variant discriminant drift");
assert_eq!(rung.as_u8(), ord, "as_u8 must equal the discriminant");
assert_eq!(RungLevel::from_u8(ord), rung, "from_u8 roundtrip");
}
}

#[test]
fn elevator_elevates_on_sustained_block_and_relaxes_on_sustained_flow() {
use crate::collapse_gate::GateDecision;
Expand Down
Loading
Loading