Skip to content

Commit 047024a

Browse files
committed
refactor(thinking-engine): D-PERT-1 — mechanical ResonanceDto -> PerturbationDto (M2)
The mechanical Morton-tile inverse-pyramid field (Psi) renames to PerturbationDto with a deprecated ResonanceDto alias at the definition site; the perspectival (Piaget Three-Mountains) ResonanceDto in awareness_dto.rs KEEPS its name, untouched. 8 files; cascade key-tier vocabulary untouched. thinking-engine 362 tests green; shader-driver (with-engine) 100 green; zero in-crate deprecated-alias usage remains. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MLBnPuScZy6w9di2QEjsXM
1 parent c0de26f commit 047024a

9 files changed

Lines changed: 90 additions & 52 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! Two DTO pipelines exist in isolation:
44
//!
55
//! ```text
6-
//! thinking-engine: Φ StreamDto → Ψ ResonanceDto → B BusDto → Γ ThoughtStruct
6+
//! thinking-engine: Φ StreamDto → Ψ PerturbationDto → B BusDto → Γ ThoughtStruct
77
//! cognitive-shader-driver: Φ ShaderDispatch → Ψ ShaderResonance → B ShaderBus → Γ ShaderCrystal
88
//! ```
99
//!
@@ -12,7 +12,7 @@
1212
//!
1313
//! ```text
1414
//! [1] StreamDto.codebook_indices → populate BindSpace content fingerprints
15-
//! [2] ResonanceDto.top_k → seed ShaderDispatch.rows (which rows to scan)
15+
//! [2] PerturbationDto.top_k → seed ShaderDispatch.rows (which rows to scan)
1616
//! [3] ShaderBus.cycle_fingerprint → produce BusDto (top-1 hit = codebook_index)
1717
//! [4] ShaderCrystal → produce ThoughtStruct with sensor provenance
1818
//! [5] Qualia17D → fill BindSpace QualiaColumn (17 → 18: pad 0)
@@ -88,7 +88,7 @@ pub fn ingest_codebook_indices(
8888
}
8989

9090
// ═══════════════════════════════════════════════════════════════════════════
91-
// ResonanceDto → ShaderDispatch (top-k seeds the scan window)
91+
// PerturbationDto → ShaderDispatch (top-k seeds the scan window)
9292
// ═══════════════════════════════════════════════════════════════════════════
9393

9494
/// Build a ShaderDispatch from resonance top-k.

crates/thinking-engine/Cargo.lock

Lines changed: 18 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/thinking-engine/src/bf16_engine.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//!
1313
//! Built from StackedN::cosine() via ClamCodebook, matching bgz-tensor pipeline.
1414
15-
use crate::dto::{BusDto, ResonanceDto};
15+
use crate::dto::{BusDto, PerturbationDto};
1616
use bgz_tensor::stacked_n::{bf16_to_f32, f32_to_bf16};
1717
use ndarray::hpc::heel_f64x8::cosine_f32_to_f64_simd;
1818
use ndarray::simd::F32x16;
@@ -283,7 +283,7 @@ impl BF16ThinkingEngine {
283283
}
284284

285285
/// Think until convergence.
286-
pub fn think(&mut self, max_cycles: usize) -> ResonanceDto {
286+
pub fn think(&mut self, max_cycles: usize) -> PerturbationDto {
287287
for _ in 0..max_cycles {
288288
let prev = self.energy.clone();
289289
self.cycle();
@@ -297,11 +297,15 @@ impl BF16ThinkingEngine {
297297
break;
298298
}
299299
}
300-
ResonanceDto::from_energy_f32(&self.energy, self.cycles)
300+
PerturbationDto::from_energy_f32(&self.energy, self.cycles)
301301
}
302302

303303
/// Think with temperature.
304-
pub fn think_with_temperature(&mut self, max_cycles: usize, temperature: f32) -> ResonanceDto {
304+
pub fn think_with_temperature(
305+
&mut self,
306+
max_cycles: usize,
307+
temperature: f32,
308+
) -> PerturbationDto {
305309
for _ in 0..max_cycles {
306310
let prev = self.energy.clone();
307311
self.cycle_with_temperature(temperature);
@@ -315,7 +319,7 @@ impl BF16ThinkingEngine {
315319
break;
316320
}
317321
}
318-
ResonanceDto::from_energy_f32(&self.energy, self.cycles)
322+
PerturbationDto::from_energy_f32(&self.energy, self.cycles)
319323
}
320324

321325
/// Perturb with codebook indices.
@@ -344,7 +348,7 @@ impl BF16ThinkingEngine {
344348

345349
/// Commit dominant peak.
346350
pub fn commit(&self) -> BusDto {
347-
let resonance = ResonanceDto::from_energy_f32(&self.energy, self.cycles);
351+
let resonance = PerturbationDto::from_energy_f32(&self.energy, self.cycles);
348352
BusDto {
349353
codebook_index: resonance.top_k[0].0,
350354
energy: resonance.top_k[0].1,

crates/thinking-engine/src/composite_engine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//! ```
1313
1414
use crate::builder::BuiltEngine;
15-
use crate::dto::ResonanceDto;
15+
use crate::dto::PerturbationDto;
1616

1717
/// Result of multi-model composition.
1818
pub struct CompositeResult {
@@ -111,7 +111,7 @@ impl CompositeEngine {
111111

112112
for (name, engine) in &mut self.lenses {
113113
engine.think(max_cycles);
114-
let res = ResonanceDto::from_energy_f32(engine.energy(), engine.cycles());
114+
let res = PerturbationDto::from_energy_f32(engine.energy(), engine.cycles());
115115

116116
for &(idx, energy) in &res.top_k {
117117
if energy > 1e-10 {

crates/thinking-engine/src/dto.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! DTOs: bus adapters between cognitive speed zones.
22
//!
3-
//! Φ Dispersion: StreamDto — sensor output enters the field
4-
//! Ψ Interference: ResonanceDto — the ripple field IS f64[4096]
5-
//! B Consequence: BusDto — committed thought with provenance
6-
//! Γ Collapse: ThoughtStruct — stabilized, persisted, text is lazy
3+
//! Φ Dispersion: StreamDto — sensor output enters the field
4+
//! Ψ Interference: PerturbationDto — the ripple field IS f64[4096]
5+
//! B Consequence: BusDto — committed thought with provenance
6+
//! Γ Collapse: ThoughtStruct — stabilized, persisted, text is lazy
77
88
use crate::engine::CODEBOOK_SIZE;
99

@@ -47,24 +47,37 @@ pub struct StreamDto {
4747
}
4848

4949
// ═══════════════════════════════════════════════════════════════════════════
50-
// Ψ — ResonanceDto: the ripple field
50+
// Ψ — PerturbationDto: the ripple field
5151
// ═══════════════════════════════════════════════════════════════════════════
5252

53-
/// ResonanceDto IS f64[4096] energy. Not a struct with candidate lists.
53+
/// PerturbationDto IS f64[4096] energy. Not a struct with candidate lists.
5454
///
5555
/// High energy at entry 42 = "thought 42 resonates."
5656
/// Zero at entry 200 = "thought 200 destructively interfered."
5757
/// Spike at entry 7 = "thought 7 crystallizing."
58+
///
59+
/// D-PERT-1: renamed from `ResonanceDto` — this is the mechanical
60+
/// Morton-tile inverse-pyramid perturbation field (Ψ), distinct from the
61+
/// PERSPECTIVAL (Piaget Three-Mountains) `ResonanceDto` in
62+
/// `awareness_dto.rs`, which keeps the `ResonanceDto` name.
5863
#[derive(Clone, Debug)]
59-
pub struct ResonanceDto {
64+
pub struct PerturbationDto {
6065
/// Energy distribution. f32 — matches u8 distance table precision.
6166
pub energy: Vec<f32>,
6267
pub cycle_count: u16,
6368
pub converged: bool,
6469
pub top_k: [(u16, f32); 8],
6570
}
6671

67-
impl ResonanceDto {
72+
/// D-PERT-1: `ResonanceDto` (mechanical Ψ) renamed to `PerturbationDto`.
73+
/// `ResonanceDto` now names only the perspectival awareness DTO in
74+
/// `awareness_dto.rs`.
75+
#[deprecated(
76+
note = "renamed to PerturbationDto (D-PERT-1); ResonanceDto now names only the perspectival awareness DTO"
77+
)]
78+
pub type ResonanceDto = PerturbationDto;
79+
80+
impl PerturbationDto {
6881
/// Build from f32 energy array (fixed-size legacy compat).
6982
pub fn from_energy(energy: &[f32; CODEBOOK_SIZE], cycles: u16) -> Self {
7083
Self::from_energy_f32(energy.as_slice(), cycles)
@@ -237,7 +250,7 @@ mod tests {
237250
energy[100] = 0.3;
238251
energy[200] = 0.2;
239252

240-
let res = ResonanceDto::from_energy(&energy, 5);
253+
let res = PerturbationDto::from_energy(&energy, 5);
241254
assert_eq!(res.top_k[0].0, 42);
242255
assert!((res.top_k[0].1 - 0.5).abs() < 1e-10);
243256
assert_eq!(res.top_k[1].0, 100);

crates/thinking-engine/src/dual_engine.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! Same input, same perturbation, different encoding → measure disagreement.
55
66
use crate::builder::BuiltEngine;
7-
use crate::dto::ResonanceDto;
7+
use crate::dto::PerturbationDto;
88

99
/// Results from running both engines on the same input.
1010
pub struct DualResult {
@@ -105,8 +105,10 @@ impl DualEngine {
105105
self.engine_a.think(max_cycles);
106106
self.engine_b.think(max_cycles);
107107

108-
let res_a = ResonanceDto::from_energy_f32(self.engine_a.energy(), self.engine_a.cycles());
109-
let res_b = ResonanceDto::from_energy_f32(self.engine_b.energy(), self.engine_b.cycles());
108+
let res_a =
109+
PerturbationDto::from_energy_f32(self.engine_a.energy(), self.engine_a.cycles());
110+
let res_b =
111+
PerturbationDto::from_energy_f32(self.engine_b.energy(), self.engine_b.cycles());
110112

111113
let a_indices: Vec<u16> = res_a
112114
.top_k

crates/thinking-engine/src/engine.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
//! FIX 4: GPU Vulkan compute shader: ~10μs per cycle (see GPU design doc)
155155
//! ```
156156
157-
use crate::dto::{BusDto, ResonanceDto};
157+
use crate::dto::{BusDto, PerturbationDto};
158158
use ndarray::hpc::heel_f64x8::cosine_f64_simd;
159159
use ndarray::simd::F32x16;
160160
use ndarray::simd_amx;
@@ -383,7 +383,11 @@ impl ThinkingEngine {
383383
/// Applies softmax(energy/T) after each cycle. This exponentiates
384384
/// small differences into large ones, breaking the attractor collapse
385385
/// on uniform tables. T=1.0 ≈ standard normalization.
386-
pub fn think_with_temperature(&mut self, max_cycles: usize, temperature: f32) -> ResonanceDto {
386+
pub fn think_with_temperature(
387+
&mut self,
388+
max_cycles: usize,
389+
temperature: f32,
390+
) -> PerturbationDto {
387391
for _ in 0..max_cycles {
388392
let prev = self.energy.clone();
389393
self.cycle();
@@ -415,12 +419,12 @@ impl ThinkingEngine {
415419
break;
416420
}
417421
}
418-
ResonanceDto::from_energy_f32(&self.energy, self.cycles)
422+
PerturbationDto::from_energy_f32(&self.energy, self.cycles)
419423
}
420424

421425
/// Run until convergence. Returns the resonance state.
422426
/// Uses `cycle_auto` which tries VNNI first, falls back to F32x16.
423-
pub fn think(&mut self, max_cycles: usize) -> ResonanceDto {
427+
pub fn think(&mut self, max_cycles: usize) -> PerturbationDto {
424428
for _ in 0..max_cycles {
425429
let prev = self.energy.clone();
426430
self.cycle();
@@ -435,7 +439,7 @@ impl ThinkingEngine {
435439
break;
436440
}
437441
}
438-
ResonanceDto::from_energy_f32(&self.energy, self.cycles)
442+
PerturbationDto::from_energy_f32(&self.energy, self.cycles)
439443
}
440444

441445
/// ONE thinking cycle via AMX/VNNI dispatch path.
@@ -533,7 +537,7 @@ impl ThinkingEngine {
533537

534538
/// Commit: dominant peak → BusDto.
535539
pub fn commit(&self) -> BusDto {
536-
let resonance = ResonanceDto::from_energy_f32(&self.energy, self.cycles);
540+
let resonance = PerturbationDto::from_energy_f32(&self.energy, self.cycles);
537541
BusDto {
538542
codebook_index: resonance.top_k[0].0,
539543
energy: resonance.top_k[0].1,

crates/thinking-engine/src/f32_engine.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! Think cycle: signed MatVec with ReLU + normalization.
99
//! No floor heuristic. No threshold. Full signed accumulation.
1010
11-
use crate::dto::{BusDto, ResonanceDto};
11+
use crate::dto::{BusDto, PerturbationDto};
1212

1313
/// F32 thinking engine. Distance table at full f32 precision.
1414
pub struct F32ThinkingEngine {
@@ -206,25 +206,29 @@ impl F32ThinkingEngine {
206206
}
207207

208208
/// Think until convergence or max_cycles.
209-
pub fn think(&mut self, max_cycles: usize) -> ResonanceDto {
209+
pub fn think(&mut self, max_cycles: usize) -> PerturbationDto {
210210
for _ in 0..max_cycles {
211211
let delta = self.cycle();
212212
if delta < self.convergence_threshold {
213213
break;
214214
}
215215
}
216-
ResonanceDto::from_energy_f32(&self.energy, self.cycles)
216+
PerturbationDto::from_energy_f32(&self.energy, self.cycles)
217217
}
218218

219219
/// Think with temperature scaling (1/T applied to MatVec output before normalization).
220-
pub fn think_with_temperature(&mut self, max_cycles: usize, temperature: f32) -> ResonanceDto {
220+
pub fn think_with_temperature(
221+
&mut self,
222+
max_cycles: usize,
223+
temperature: f32,
224+
) -> PerturbationDto {
221225
for _ in 0..max_cycles {
222226
let delta = self.cycle_with_temp(temperature);
223227
if delta < self.convergence_threshold {
224228
break;
225229
}
226230
}
227-
ResonanceDto::from_energy_f32(&self.energy, self.cycles)
231+
PerturbationDto::from_energy_f32(&self.energy, self.cycles)
228232
}
229233

230234
/// Access the energy distribution.
@@ -263,7 +267,7 @@ impl F32ThinkingEngine {
263267

264268
/// Commit dominant peak as BusDto.
265269
pub fn commit(&self) -> BusDto {
266-
let resonance = ResonanceDto::from_energy_f32(&self.energy, self.cycles);
270+
let resonance = PerturbationDto::from_energy_f32(&self.energy, self.cycles);
267271
BusDto {
268272
codebook_index: resonance.top_k[0].0,
269273
energy: resonance.top_k[0].1,

0 commit comments

Comments
 (0)