@@ -65,31 +65,51 @@ impl Cam64 {
6565
6666 /// Raw u64 value.
6767 #[ inline]
68- pub fn raw ( self ) -> u64 { self . 0 }
68+ pub fn raw ( self ) -> u64 {
69+ self . 0
70+ }
6971
7072 /// Construct from raw u64.
7173 #[ inline]
72- pub fn from_raw ( v : u64 ) -> Self { Self ( v) }
74+ pub fn from_raw ( v : u64 ) -> Self {
75+ Self ( v)
76+ }
7377
7478 // ── Named lane accessors ─────────────────────────────────────────────────
7579
7680 /// Vocabulary bucket of the active subject (lane 0).
7781 /// Bucket = rank >> 5 → 128 buckets of 32 adjacent vocabulary items each.
78- pub fn entity_state ( self ) -> u8 { self . lane ( 0 ) }
82+ pub fn entity_state ( self ) -> u8 {
83+ self . lane ( 0 )
84+ }
7985 /// Vocabulary bucket of the active predicate (lane 1).
80- pub fn predicate_state ( self ) -> u8 { self . lane ( 1 ) }
86+ pub fn predicate_state ( self ) -> u8 {
87+ self . lane ( 1 )
88+ }
8189 /// Vocabulary bucket of the active object, or 0 if absent (lane 2).
82- pub fn object_state ( self ) -> u8 { self . lane ( 2 ) }
90+ pub fn object_state ( self ) -> u8 {
91+ self . lane ( 2 )
92+ }
8393 /// `MorphFlags` bits 0-7: tense, number, person, passive, negated (lane 3).
84- pub fn morph_state ( self ) -> u8 { self . lane ( 3 ) }
94+ pub fn morph_state ( self ) -> u8 {
95+ self . lane ( 3 )
96+ }
8597 /// `MorphFlags` bits 8-13: clause structure flags (lane 4).
86- pub fn clause_state ( self ) -> u8 { self . lane ( 4 ) }
98+ pub fn clause_state ( self ) -> u8 {
99+ self . lane ( 4 )
100+ }
87101 /// Discourse / anaphora: entity-stack depth (bits 0-6) + coreference flag (bit 7) (lane 5).
88- pub fn discourse_state ( self ) -> u8 { self . lane ( 5 ) }
102+ pub fn discourse_state ( self ) -> u8 {
103+ self . lane ( 5 )
104+ }
89105 /// Causal / temporal / conditional markers (lane 6).
90- pub fn causal_state ( self ) -> u8 { self . lane ( 6 ) }
106+ pub fn causal_state ( self ) -> u8 {
107+ self . lane ( 6 )
108+ }
91109 /// Episodic basin markers: novelty/entropy/epiphany flags (lane 7).
92- pub fn basin_state ( self ) -> u8 { self . lane ( 7 ) }
110+ pub fn basin_state ( self ) -> u8 {
111+ self . lane ( 7 )
112+ }
93113
94114 // ── Construction helpers ─────────────────────────────────────────────────
95115
@@ -109,38 +129,46 @@ impl Cam64 {
109129 ) -> Self {
110130 // Lanes 0-2: vocabulary-bucket of each role (128 buckets of 32 ranks).
111131 // Adjacent vocabulary items share a bucket → helps basin-matching.
112- let entity_lane = ( triple. subject ( ) >> 5 ) as u8 ;
113- let pred_lane = ( triple. predicate ( ) >> 5 ) as u8 ;
114- let obj_lane = if triple. object ( ) != NO_ROLE {
132+ let entity_lane = ( triple. subject ( ) >> 5 ) as u8 ;
133+ let pred_lane = ( triple. predicate ( ) >> 5 ) as u8 ;
134+ let obj_lane = if triple. object ( ) != NO_ROLE {
115135 ( triple. object ( ) >> 5 ) as u8
116136 } else {
117137 0
118138 } ;
119139
120140 // Lanes 3-4: split MorphFlags across two bytes.
121- let morph_bits = morph. bits ( ) ;
141+ let morph_bits = morph. bits ( ) ;
122142 // MorphFlags is defined over bits 0-13 (bits 14-15 spare; see morphology.rs).
123143 // clause_lane below carries bits 8-15, so a future flag at bit 14/15 would
124144 // land there with no defined meaning — guard the invariant in debug builds.
125- debug_assert ! ( morph_bits <= 0x3FFF , "MorphFlags bit 14/15 set — cam64 clause lane has no slot for it" ) ;
126- let morph_lane = ( morph_bits & 0xFF ) as u8 ;
127- let clause_lane = ( ( morph_bits >> 8 ) & 0xFF ) as u8 ;
145+ debug_assert ! (
146+ morph_bits <= 0x3FFF ,
147+ "MorphFlags bit 14/15 set — cam64 clause lane has no slot for it"
148+ ) ;
149+ let morph_lane = ( morph_bits & 0xFF ) as u8 ;
150+ let clause_lane = ( ( morph_bits >> 8 ) & 0xFF ) as u8 ;
128151
129152 // Lane 5: discourse — stack depth (bits 0-6) + coreference flag (bit 7).
130153 let depth_clamped = entity_stack_depth. min ( 127 ) ;
131154 let discourse_lane = depth_clamped | if coreference_resolved { 0x80 } else { 0 } ;
132155
133156 // Lane 6: causal/temporal — bit 0 = temporal marker present (v1;
134157 // causal/conditional markers in bits 1-7 reserved for v2).
135- let causal_lane = if has_temporal { 0x01u8 } else { 0x00 } ;
158+ let causal_lane = if has_temporal { 0x01u8 } else { 0x00 } ;
136159
137160 // Lane 7: basin — bit 0 = novelty_high (v1 placeholder; epiphany/wisdom baked in v2).
138- let basin_lane = if novelty_high { 0x01u8 } else { 0x00 } ;
161+ let basin_lane = if novelty_high { 0x01u8 } else { 0x00 } ;
139162
140163 Self :: from_lanes ( [
141- entity_lane, pred_lane, obj_lane,
142- morph_lane, clause_lane,
143- discourse_lane, causal_lane, basin_lane,
164+ entity_lane,
165+ pred_lane,
166+ obj_lane,
167+ morph_lane,
168+ clause_lane,
169+ discourse_lane,
170+ causal_lane,
171+ basin_lane,
144172 ] )
145173 }
146174
@@ -179,7 +207,7 @@ impl Cam64 {
179207 #[ inline]
180208 pub fn continues_basin ( self , prev : Cam64 ) -> bool {
181209 let diff = self . 0 ^ prev. 0 ;
182- let diff_bits = diff. count_ones ( ) ;
210+ let diff_bits = diff. count_ones ( ) ;
183211 let shared_bits = 64 - diff_bits; // XNOR popcount via complement
184212 shared_bits >= CAM64_CONTINUATION_MIN_SHARED && diff_bits <= CAM64_CONTINUATION_MAX_DIFF
185213 }
@@ -209,9 +237,14 @@ impl core::fmt::Debug for Cam64 {
209237 f,
210238 "Cam64(entity={:#04x} pred={:#04x} obj={:#04x} morph={:#04x} \
211239 clause={:#04x} discourse={:#04x} causal={:#04x} basin={:#04x})",
212- self . entity_state( ) , self . predicate_state( ) , self . object_state( ) ,
213- self . morph_state( ) , self . clause_state( ) , self . discourse_state( ) ,
214- self . causal_state( ) , self . basin_state( ) ,
240+ self . entity_state( ) ,
241+ self . predicate_state( ) ,
242+ self . object_state( ) ,
243+ self . morph_state( ) ,
244+ self . clause_state( ) ,
245+ self . discourse_state( ) ,
246+ self . causal_state( ) ,
247+ self . basin_state( ) ,
215248 )
216249 }
217250}
@@ -256,7 +289,7 @@ mod tests {
256289 let t = SpoTriple :: new ( 1 , 2 , 3 ) ;
257290 // Set a flag that lands in the high byte (RELATIVE_CLAUSE = bit 11)
258291 let m = MorphFlags :: default ( )
259- . set ( MorphFlags :: NEGATED ) // bit 9 → high byte bit 1
292+ . set ( MorphFlags :: NEGATED ) // bit 9 → high byte bit 1
260293 . set ( MorphFlags :: RELATIVE_CLAUSE ) ; // bit 11 → high byte bit 3
261294 let c = Cam64 :: from_triple ( & t, m, 0 , false , false , false ) ;
262295 // morph_lane = low byte of flags
@@ -270,7 +303,7 @@ mod tests {
270303 let t = SpoTriple :: new ( 1 , 2 , 3 ) ;
271304 let m = MorphFlags :: default ( ) ;
272305 let c_yes = Cam64 :: from_triple ( & t, m, 5 , true , false , false ) ;
273- let c_no = Cam64 :: from_triple ( & t, m, 5 , false , false , false ) ;
306+ let c_no = Cam64 :: from_triple ( & t, m, 5 , false , false , false ) ;
274307 assert ! ( c_yes. has_coreference( ) ) ;
275308 assert ! ( !c_no. has_coreference( ) ) ;
276309 assert_eq ! ( c_yes. entity_stack_depth( ) , 5 ) ;
0 commit comments