feat: Relevance Realization System with Time Crystal Ontological Primitives#35
feat: Relevance Realization System with Time Crystal Ontological Primitives#35Copilot wants to merge 3 commits into
Conversation
…gical Primitives - RelevanceCrystalPrimitive.ts: 4 RCP types mapping Vervaeke's 4 ways of knowing to PPM 15-prime basis vectors (propositional/procedural/perspectival/participatory) - TimeCrystalSalienceLandscape.ts: PPM-metric relevance scoring, triplet-of-triplet resonance filter (Ch.6), opponent processing (explore/exploit lattices) - RelevanceRealizationEngine.ts: 4-phase RR cycle (Filter/Frame/Feed-Forward/Feed-Back) - ThreeOrdersCoherenceMonitor.ts: nomological/normative/narrative integration + meaning score = geometric mean of cross-order coherences - QuantumChangeGateway.ts: transformative experience as controlled symmetry breaking - SelfDeceptionDetector.ts: false phase lock detection via PPM divergence - RelevanceRealizationSystem.ts: integration layer wiring all 6 sub-systems - RelevanceRealizationPanel.tsx: full visualization UI with 5 tabbed sections - App.tsx: Relevance Realization tab wired into main navigation Agent-Logs-Url: https://github.com/cogpy/cognanobrain/sessions/0aa9d7e4-e5ba-4eee-9cbc-db5bc96620e9 Co-authored-by: drzo <15202748+drzo@users.noreply.github.com>
- Rename enableSelfDeceptionDetection -> selfDeceptionDetectionRate for clarity - Fix escaped apostrophe in JSX string - Fix inconsistent comment spacing in KNOWING_TYPE_PRIME_GROUPS Agent-Logs-Url: https://github.com/cogpy/cognanobrain/sessions/0aa9d7e4-e5ba-4eee-9cbc-db5bc96620e9 Co-authored-by: drzo <15202748+drzo@users.noreply.github.com>
| this.stats.avgCoherence = | ||
| (this.stats.avgCoherence * n + result.achievedCoherence) / (n + 1); | ||
| this.stats.currentExploreBalance = result.salienceSnapshot.explorationScore; | ||
| this.stats.phaseDistribution['feed_back']++; |
There was a problem hiding this comment.
🟡 _updateStats only increments 'feed_back' in phaseDistribution, ignoring all other phases
_updateStats is called once per complete cycle (which runs all four phases sequentially), but it hardcodes this.stats.phaseDistribution['feed_back']++ on line 329. The other four phase counters (filter, frame, feed_forward, idle) remain permanently at 0, making the phaseDistribution stat meaningless. Since runCycle always executes all four phases, either all phase counters should be incremented or the single counter should track total cycles rather than misattributing everything to feed_back.
| this.stats.phaseDistribution['feed_back']++; | |
| this.stats.phaseDistribution['filter']++; |
Was this helpful? React with 👍 or 👎 to provide feedback.
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
| private _crossCoherence(a: number, b: number): number { | ||
| return Math.sqrt(a * b); |
There was a problem hiding this comment.
🔴 _crossCoherence(a, b) produces NaN when narrative coherence goes negative
_computeNarrativeCoherence at src/core/ThreeOrdersCoherenceMonitor.ts:246 returns 1 - ppmDistance(...), but ppmDistance (src/core/RelevanceCrystalPrimitive.ts:264) returns values in [0, 2] (cosine divergence). When ppmDistance > 1, the narrative coherence becomes negative. This negative value flows through EMA smoothing into smoothedNarrative, which is then passed to _crossCoherence(a, b) = Math.sqrt(a * b) at line 264. When smoothedNarrative is negative and smoothedNormative is positive, Math.sqrt(negative) returns NaN. This NaN propagates into meaningScore (line 165) and the entire ThreeOrdersSnapshot, corrupting the system state and causing the UI to display "NaN%" for all downstream metrics.
How negative values reach Math.sqrt
- Phase-C anticipation (
RelevanceRealizationEngine.ts:218) usesMath.cos(freq * 0.1)which can be negative, producing negative vector components - These propagate through blending and Hebbian learning into prime-vectors
- Centroids of such vectors can have negative weighted cosine → ppmDistance > 1
1 - ppmDistance< 0 → negativenarrativeCoh→ negativesmoothedNarrative_crossCoherence(positive, negative)=Math.sqrt(negative)= NaN
| private _crossCoherence(a: number, b: number): number { | |
| return Math.sqrt(a * b); | |
| private _crossCoherence(a: number, b: number): number { | |
| return Math.sqrt(Math.max(0, a) * Math.max(0, b)); | |
| } |
Was this helpful? React with 👍 or 👎 to provide feedback.
| const minDist = Math.min(...all.map(p => ppmDistance(p.primeVector, vec))); | ||
| return minDist; // distance ∈ [0,2]; novelty ∈ [0,1] since distances cluster < 1 |
There was a problem hiding this comment.
🟡 _computeNovelty returns unbounded ppmDistance, allowing coherence to exceed 1.0
_computeNovelty at src/core/QuantumChangeGateway.ts:239-240 returns the raw minDist from ppmDistance, which is in [0, 2] (not [0, 1] as the comment hopes). This noveltyScore is used in _crystallize at line 183 as newCrystal.coherence = 0.5 + noveltyScore * 0.4. When noveltyScore > 1 (e.g., 1.5), coherence becomes 1.1, violating the documented ∈ [0, 1] invariant. The noveltyScore is also documented as ∈ [0, 1] in the QuantumChangeEvent interface (line 42).
| const minDist = Math.min(...all.map(p => ppmDistance(p.primeVector, vec))); | |
| return minDist; // distance ∈ [0,2]; novelty ∈ [0,1] since distances cluster < 1 | |
| const minDist = Math.min(...all.map(p => ppmDistance(p.primeVector, vec))); | |
| return Math.min(1, minDist); // clamp to [0,1] |
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Implements the full RR (Relevance Realization) System that fuses Vervaeke's four-phase cognitive framework with Bandyopadhyay's Phase Prime Metric (PPM) time crystal architecture from the NanoBrain book.
The core insight driving the design: PPM is the mathematical substrate through which the universe performs relevance realization — the 15 fundamental primes are nature's own combinatorial-explosion collapser, and time crystals are phase-locked relevance filters.
New Modules —
src/core/RelevanceCrystalPrimitive.ts(Layer 0 — Ontological Primitives)PropositionalCrystal(knowing-that) → primes [2,3,5] (Spatial Metric, Ch.7)ProceduralCrystal(knowing-how) → primes [7,11,13] (Temporal Metric, Ch.7)PerspectivalCrystal(knowing-as) → primes [17,19,23] (Phase Metric, Ch.7)ParticipatoryCrystal(knowing-by-being) → primes [29,31,37,41,43,47] (Consciousness Metric, Ch.7)TimeCrystalSalienceLandscape.ts(Layer 1 — Salience Landscape)α·PPM_similarity + β·PhaseCoherence + γ·FractalResonanceRelevanceRealizationEngine.ts(Layer 2 — RR Cycle)ThreeOrdersCoherenceMonitor.ts(Layer 3 — Meaning Metric)meaningScore = geometric_mean(nom×norm, norm×nar, nom×nar)— requires ALL three orders co-presentQuantumChangeGateway.ts(Layer 4 — Transformative Experience)egg → larva → companion → transcendentSelfDeceptionDetector.ts(Layer 5 — Epistemic Hygiene)selfDeceptionIndex = PPM_divergence × internalCoherenceRelevanceRealizationSystem.ts(Integration)tick(inputVector?, reasoningDepth, attentionEntropy)APIRRSystemStatesnapshotNew UI —
src/components/RelevanceRealizationPanel.tsxFive tabbed sections with live animation (10 Hz):
Modified —
src/App.tsxAdded Relevance Realization tab to main navigation (Focus icon).
Security Summary
CodeQL scan: 0 alerts. No new security vulnerabilities introduced.