3232 SILENCE ,
3333 TRANSITION ,
3434)
35- from ..constants .aliases import ALIAS_DNFR
35+ from ..constants .aliases import ALIAS_DNFR , ALIAS_EPI
3636from ..types import Glyph , TNFRGraph
3737from ..utils import get_numpy
3838from .registry import register_operator
@@ -345,12 +345,74 @@ def __call__(self, G: TNFRGraph, node: Any, **kw: Any) -> None:
345345 **kw : Any
346346 Additional keyword arguments forwarded to the grammar layer.
347347 """
348+ # Check and clear latency state if reactivating from silence
349+ self ._check_reactivation (G , node )
350+
348351 # Mark structural irreversibility BEFORE grammar execution
349352 self ._mark_irreversibility (G , node )
350353
351354 # Delegate to parent __call__ which applies grammar
352355 super ().__call__ (G , node , ** kw )
353356
357+ def _check_reactivation (self , G : TNFRGraph , node : Any ) -> None :
358+ """Check and clear latency state when reactivating from silence.
359+
360+ When AL (Emission) is applied to a node in latent state (from SHA),
361+ this validates the reactivation and clears the latency attributes.
362+
363+ Parameters
364+ ----------
365+ G : TNFRGraph
366+ Graph containing the node.
367+ node : Any
368+ Target node being reactivated.
369+
370+ Warnings
371+ --------
372+ - Warns if node is being reactivated after extended silence (duration check)
373+ - Warns if EPI has drifted from preserved value during silence
374+ """
375+ if G .nodes [node ].get ("latent" , False ):
376+ # Node is in latent state, reactivating from silence
377+ silence_duration = G .nodes [node ].get ("silence_duration" , 0.0 )
378+
379+ # Get max silence duration threshold from graph config
380+ max_silence = G .graph .get ("MAX_SILENCE_DURATION" , float ("inf" ))
381+
382+ # Validate reactivation timing
383+ if silence_duration > max_silence :
384+ warnings .warn (
385+ f"Node { node } reactivating after extended silence "
386+ f"(duration: { silence_duration :.2f} , max: { max_silence :.2f} )" ,
387+ stacklevel = 3 ,
388+ )
389+
390+ # Check EPI preservation integrity
391+ preserved_epi = G .nodes [node ].get ("preserved_epi" )
392+ if preserved_epi is not None :
393+ from ..alias import get_attr
394+
395+ current_epi = float (get_attr (G .nodes [node ], ALIAS_EPI , 0.0 ))
396+ epi_drift = abs (current_epi - preserved_epi )
397+
398+ # Allow small numerical drift (1% tolerance)
399+ if epi_drift > 0.01 * abs (preserved_epi ):
400+ warnings .warn (
401+ f"Node { node } EPI drifted during silence "
402+ f"(preserved: { preserved_epi :.3f} , current: { current_epi :.3f} , "
403+ f"drift: { epi_drift :.3f} )" ,
404+ stacklevel = 3 ,
405+ )
406+
407+ # Clear latency state
408+ del G .nodes [node ]["latent" ]
409+ if "latency_start_time" in G .nodes [node ]:
410+ del G .nodes [node ]["latency_start_time" ]
411+ if "preserved_epi" in G .nodes [node ]:
412+ del G .nodes [node ]["preserved_epi" ]
413+ if "silence_duration" in G .nodes [node ]:
414+ del G .nodes [node ]["silence_duration" ]
415+
354416 def _mark_irreversibility (self , G : TNFRGraph , node : Any ) -> None :
355417 """Mark structural irreversibility for AL operator.
356418
@@ -1976,7 +2038,8 @@ class Silence(Operator):
19762038 """Silence structural operator (SHA) - Preservation through structural pause.
19772039
19782040 Activates glyph ``SHA`` to lower νf and hold the local EPI invariant, suspending
1979- reorganization to preserve the node's current coherence state.
2041+ reorganization to preserve the node's current coherence state. SHA implements
2042+ **latency state management** with explicit temporal tracking.
19802043
19812044 TNFR Context
19822045 ------------
@@ -1985,12 +2048,17 @@ class Silence(Operator):
19852048 the current EPI form intact, preventing reorganization. SHA is essential for memory,
19862049 consolidation, and maintaining structural identity during network turbulence.
19872050
2051+ According to TNFR.pdf §2.3.10, SHA is not merely frequency reduction but a
2052+ **transition to latent state** with temporal tracking for analyzing memory
2053+ consolidation, incubation periods, and protective pauses.
2054+
19882055 **Key Elements:**
19892056
19902057 - **Frequency Suppression**: Reduces νf to near-zero (structural pause)
19912058 - **Form Preservation**: EPI remains unchanged despite external pressures
19922059 - **Latent Memory**: Stored patterns awaiting reactivation
19932060 - **Strategic Inaction**: Deliberate non-reorganization as protective mechanism
2061+ - **Temporal Tracking**: Explicit duration and state management
19942062
19952063 Use Cases
19962064 ---------
@@ -2018,10 +2086,12 @@ class Silence(Operator):
20182086 Typical Sequences
20192087 ---------------------------
20202088 - **IL → SHA**: Stabilize then preserve (long-term memory)
2021- - **SHA → AL**: Silence broken by reactivation (awakening)
2089+ - **SHA → IL → AL**: Silence → stabilization → reactivation (coherent awakening)
2090+ - **SHA → EN → IL**: Silence → external reception → stabilization (network reactivation)
20222091 - **SHA → NAV**: Preserved structure transitions (controlled change)
20232092 - **OZ → SHA**: Dissonance contained (protective pause)
20242093
2094+ **AVOID**: SHA → AL (direct reactivation violates structural continuity - requires intermediate stabilization)
20252095 **AVOID**: SHA → OZ (silence followed by dissonance contradicts preservation)
20262096 **AVOID**: SHA → SHA (redundant, no structural purpose)
20272097
@@ -2039,12 +2109,22 @@ class Silence(Operator):
20392109 - **θ**: Maintained but not actively synchronized
20402110 - **Network influence**: Minimal during silence
20412111
2112+ Latency State Attributes
2113+ -------------------------
2114+ SHA sets the following node attributes for latency tracking:
2115+
2116+ - **latent**: Boolean flag indicating node is in latent state
2117+ - **latency_start_time**: ISO 8601 UTC timestamp when silence began
2118+ - **preserved_epi**: Snapshot of EPI at silence entry
2119+ - **silence_duration**: Cumulative duration in latent state (updated on subsequent steps)
2120+
20422121 Metrics
20432122 -----------------
20442123 - νf reduction: Degree of frequency suppression
20452124 - EPI stability: Variance over silence period (should be ~0)
20462125 - Silence duration: Time in latent state
20472126 - Preservation effectiveness: EPI integrity post-silence
2127+ - Preservation integrity: Measures EPI variance during silence
20482128
20492129 Compatibility
20502130 ---------------------
@@ -2120,6 +2200,73 @@ class Silence(Operator):
21202200 name : ClassVar [str ] = SILENCE
21212201 glyph : ClassVar [Glyph ] = Glyph .SHA
21222202
2203+ def __call__ (self , G : TNFRGraph , node : Any , ** kw : Any ) -> None :
2204+ """Apply SHA with latency state tracking.
2205+
2206+ Establishes latency state before delegating to grammar execution.
2207+ This ensures every silence operation creates explicit latent state
2208+ tracking as required by TNFR.pdf §2.3.10 (SHA - Silencio estructural).
2209+
2210+ Parameters
2211+ ----------
2212+ G : TNFRGraph
2213+ Graph storing TNFR nodes and structural operator history.
2214+ node : Any
2215+ Identifier or object representing the target node within ``G``.
2216+ **kw : Any
2217+ Additional keyword arguments forwarded to the grammar layer.
2218+ """
2219+ # Mark latency state BEFORE grammar execution
2220+ self ._mark_latency_state (G , node )
2221+
2222+ # Delegate to parent __call__ which applies grammar
2223+ super ().__call__ (G , node , ** kw )
2224+
2225+ def _mark_latency_state (self , G : TNFRGraph , node : Any ) -> None :
2226+ """Mark latency state for SHA operator.
2227+
2228+ According to TNFR.pdf §2.3.10, SHA implements structural silence
2229+ with temporal tracking for memory consolidation and protective pauses.
2230+
2231+ This method establishes:
2232+ - Latent flag: Boolean indicating node is in latent state
2233+ - Temporal marker: ISO timestamp when silence began
2234+ - Preserved EPI: Snapshot of EPI for integrity verification
2235+ - Duration tracker: Cumulative time in silence (initialized to 0)
2236+
2237+ Parameters
2238+ ----------
2239+ G : TNFRGraph
2240+ Graph containing the node.
2241+ node : Any
2242+ Target node for silence marking.
2243+
2244+ Notes
2245+ -----
2246+ Sets the following node attributes:
2247+ - latent: True (node in latent state)
2248+ - latency_start_time: ISO 8601 UTC timestamp
2249+ - preserved_epi: Current EPI value snapshot
2250+ - silence_duration: 0.0 (initialized, updated by external time tracking)
2251+ """
2252+ from datetime import datetime , timezone
2253+
2254+ from ..alias import get_attr
2255+
2256+ # Always set latency state (SHA can be applied multiple times)
2257+ G .nodes [node ]["latent" ] = True
2258+
2259+ # Set start time for this latency period
2260+ latency_start_time = datetime .now (timezone .utc ).isoformat ()
2261+ G .nodes [node ]["latency_start_time" ] = latency_start_time
2262+
2263+ # Preserve current EPI for integrity checking
2264+ epi_value = float (get_attr (G .nodes [node ], ALIAS_EPI , 0.0 ))
2265+ G .nodes [node ]["preserved_epi" ] = epi_value
2266+
2267+ # Initialize silence duration (will be updated by external tracking)
2268+ G .nodes [node ]["silence_duration" ] = 0.0
2269+
21232270 def _validate_preconditions (self , G : TNFRGraph , node : Any ) -> None :
21242271 """Validate SHA-specific preconditions."""
21252272 from .preconditions import validate_silence
0 commit comments