Skip to content

Commit 5f17459

Browse files
committed
B-META R2 unlocks: wire verb_table + disambiguator + trajectory_audit + quantum_mode + PhaseTag fix
- Re-exported VerbFamily, VerbRoleTable, SlotPrior, default_table from grammar/mod.rs - Re-exported Disambiguatable, GeneralizedResult, disambiguate_general - Added pub mod trajectory_audit + pub mod quantum_mode in deepnsm/lib.rs - Fixed PhaseTag from_angle/to_angle: u128::MAX as f32 was overflowing to infinity, producing NaN on round-trip. Switched to f64 intermediate and use only the low 64 bits (high 64 reserved for future precision)
1 parent 30e43f8 commit 5f17459

3 files changed

Lines changed: 34 additions & 4 deletions

File tree

crates/deepnsm/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ pub mod trajectory;
6565
pub mod markov_bundle;
6666
pub mod nsm_primes;
6767

68+
// PR #279 outlook epiphany E4 — Trajectory-as-statement-hash bridge to
69+
// PR #278 audit log. Converts grammatical structure to a 16384-bit
70+
// semantic hash key.
71+
pub mod trajectory_audit;
72+
73+
// PR #279 outlook epiphany E8 — Quantum mode (PhaseTag + holographic
74+
// addressing) sharing the 16384-dim substrate with Crystal mode.
75+
pub mod quantum_mode;
76+
6877
#[cfg(feature = "contract-ticket")]
6978
pub mod ticket_emit;
7079

crates/deepnsm/src/quantum_mode.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,22 @@ impl PhaseTag {
2020
}
2121

2222
pub fn from_angle(theta: f32) -> Self {
23-
let normalized = (theta / std::f32::consts::TAU).rem_euclid(1.0);
24-
PhaseTag((normalized * u128::MAX as f32) as u128)
23+
// Normalize to [0, 1) first.
24+
let normalized = ((theta / std::f32::consts::TAU).rem_euclid(1.0)) as f64;
25+
// f64 has ~15 digits — enough headroom for u64 precision; we cast
26+
// through u64 (u128::MAX as f32 overflows to infinity).
27+
let scaled = (normalized * (u64::MAX as f64)) as u128;
28+
// Place the u64 value in the low half, leave high half zero.
29+
// For higher resolution, a future PR can fold an additional 64-bit
30+
// entropy source into the upper half.
31+
PhaseTag(scaled)
2532
}
2633

2734
pub fn to_angle(self) -> f32 {
28-
(self.0 as f32 / u128::MAX as f32) * std::f32::consts::TAU
35+
// Use the low 64 bits (the high 64 are reserved for future precision).
36+
let low = (self.0 & u64::MAX as u128) as u64;
37+
let normalized = (low as f64) / (u64::MAX as f64);
38+
(normalized * std::f64::consts::TAU as f64) as f32
2939
}
3040

3141
pub fn distance(self, other: Self) -> u32 {
@@ -66,7 +76,10 @@ mod tests {
6676
let theta = 1.5f32;
6777
let p = PhaseTag::from_angle(theta);
6878
let recovered = p.to_angle();
69-
assert!((recovered - theta).abs() < 0.01);
79+
// f64 intermediate gives sub-1e-3 round-trip; f32 final cast caps
80+
// precision around 1e-6 of TAU (~6e-6 absolute).
81+
let diff = (recovered - theta).abs();
82+
assert!(diff < 0.001, "round-trip diff {} exceeds tolerance 0.001", diff);
7083
}
7184

7285
#[test]

crates/lance-graph-contract/src/grammar/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ pub mod role_keys;
2424
pub mod thinking_styles;
2525
pub mod free_energy;
2626

27+
// PR #279 outlook epiphany E3 — 144-cell verb-role lookup table.
28+
pub mod verb_table;
29+
30+
// PR #279 outlook epiphany E5 — generalized disambiguation primitive.
31+
pub mod disambiguator;
32+
2733
pub use ticket::{FailureTicket, PartialParse, CausalAmbiguity};
2834
pub use tekamolo::{TekamoloSlots, TekamoloSlot};
2935
pub use wechsel::{WechselAmbiguity, WechselRole};
@@ -43,6 +49,8 @@ pub use free_energy::{
4349
FreeEnergy, Hypothesis, Resolution,
4450
EPIPHANY_MARGIN, FAILURE_CEILING, HOMEOSTASIS_FLOOR,
4551
};
52+
pub use verb_table::{VerbFamily, VerbRoleTable, SlotPrior, default_table};
53+
pub use disambiguator::{Disambiguatable, GeneralizedResult, disambiguate_general};
4654

4755
/// Coverage of a local parse — if below [`LOCAL_COVERAGE_THRESHOLD`],
4856
/// the ticket is emitted for LLM fallback.

0 commit comments

Comments
 (0)