anticipation-geometry
Bridges Princeton's KG-path reward function (arXiv:2603.14147) with Comp-Core's anticipation geometry. Provides domain-general anticipation scalars that work on any trajectory: motion vectors, conversation embeddings, knowledge graph paths, or task planning traces.
Full Public Reader
anticipation-geometry
Bridges Princeton's KG-path reward function (arXiv:2603.14147) with Comp-Core's anticipation geometry. Provides domain-general anticipation scalars that work on any trajectory: motion vectors, conversation embeddings, knowledge graph paths, or task planning traces.
Architecture
+-----------------------+
| Reasoning Path |
| (KG hops, conv turns, |
| motion frames, ...) |
+----------+------------+
|
+---------------+---------------+
| |
+----------v-----------+ +----------v-----------+
| KG-Path Reward | | Anticipation |
| (kg_reward.py) | | Geometry |
| | | (generalized_ |
| Signal 1: Validity | | anticipation.py) |
| Signal 2: Continuity| | |
| Signal 3: Grounding | | Scalar 1: Commitment|
| | | Scalar 2: Uncertainty|
+----------+-----------+ | Scalar 3: Pressure |
| | Scalar 4: Recovery |
| +----------+-----------+
| |
+---------------+---------------+
|
+----------v-----------+
| Combined Evaluation |
| (eval_harness.py) |
| |
| Ranking accuracy |
| Signal discrimin. |
| Cohen's d per signal|
+----------------------+Core Insight
Princeton and Comp-Core answer complementary questions about reasoning:
| Question | Princeton (KG Reward) | Comp-Core (Anticipation Geometry) |
|---|---|---|
| What it evaluates | Path validity (retrospective) | Path dynamics (prospective) |
| Core question | "Was this path correct?" | "Where is this path going?" |
| Input | Completed KG path | Ongoing state trajectory |
| Output | Composite reward score | 4 scalar fields per timestep |
| Strength | Hard correctness signal | Early warning / steering signal |
Combined, they enable: early detection of invalid reasoning, identification of exploration opportunities, and optimal steering at decision points.
Modules
`kg_reward.py` -- Princeton's 3-Signal Reward
Queries cc-graph-kernel to evaluate reasoning paths:
from kg_reward import KGPathReward
reward = KGPathReward(gk_url="http://localhost:8001")
path = [
("spore", "built_with", "swiftui"),
("swiftui", "is_a", "framework"),
]
breakdown = reward.score(path, query_entity="framework")
# breakdown.axiomatic_validity -> +1 per valid edge, -5 per invalid
# breakdown.chain_continuity -> +2 per continuous hop, -2 per break
# breakdown.terminal_grounding -> +3 if terminal matches query
# breakdown.composite -> weighted sum`generalized_anticipation.py` -- 4 Domain-General Scalars
Works on any sequence of vectors:
from generalized_anticipation import AnticipationGeometry
import numpy as np
geom = AnticipationGeometry(k_neighbors=5)
trajectory = [np.random.randn(384) for _ in range(50)]
packet = geom.compute(trajectory)
# packet.commitment -> [0,1] per step, high = locked in
# packet.uncertainty -> [0,1] per step, high = many futures
# packet.transition_pressure -> unbounded, high = regime change imminent
# packet.recovery_margin -> [0,1] per step, high = easy to backtrack
# packet.regime_at(t) -> "exploring" | "committing" | "locked" | ...`conversation_trajectory.py` -- Conversation Analysis
Embeds Supabase conversation turns and computes anticipation:
from conversation_trajectory import ConversationTrajectory
ct = ConversationTrajectory(supabase_url="...", supabase_key="...")
result = ct.analyze_turns([
"Let's discuss the architecture",
"Microservices vs monolith?",
"Let's go with microservices and event sourcing",
])
# result.topic_shifts -> indices where commitment drops
# result.decision_points -> indices where transition pressure spikes
# result.regime_labels -> per-turn regime classification`eval_harness.py` -- Comparative Evaluation
Generates gold/silver/bronze reasoning paths and compares strategies:
from eval_harness import EvaluationHarness
harness = EvaluationHarness(gk_url="http://localhost:8001")
results = harness.run(n_paths=50, max_hops=3)
results.print_report()
# Prints pairwise ranking accuracy, reward gaps, and per-signal Cohen's dThe Math
Anticipation Scalars
Given trajectory T = [s_0, ..., s_N] in R^d:
Commitment c(t) = 1 - ||s_t - s_{t-1}|| / max_delta
Uncertainty u(t) = H(angular distribution of KNN displacement vectors) / H_max
Transition Pressure p(t) = dc/dt - du/dt
Recovery Margin r(t) = 1 - min_dist_to_branching_point / max_range
KG-Path Reward
Given path P = [(s_1, p_1, o_1), ..., (s_n, p_n, o_n)]:
Validity = sum(+1 if edge in KG else -5)
Continuity = sum(+2 if o_i == s_{i+1} else -2)
Grounding = +3 if o_n == query_target else 0
Composite = w_v Validity + w_c Continuity + w_g * Grounding
Dependencies
- `numpy` (required)
- `requests` (required, for GK + Supabase queries)
- `sentence-transformers` (optional, for conversation embeddings; falls back to hash embedding)
Relationship to Existing Comp-Core
- cc-window-aligner (core/motion/): The original motion-domain semantic projector with tension, phase, momentum, stability. This package generalizes those concepts to arbitrary vector spaces.
- cc-graph-kernel (core/semantic/): The knowledge graph service. This package queries its REST API at :8001 for edge-existence checks and multi-hop traversals.
- cc-cognitive-pulse (packages/): The 5D trajectory linker for dream/concept positioning. This package operates at a different level: where cc-cognitive-pulse assigns static coordinates, anticipation-geometry computes dynamic scalars over time.
Promotion Decision
Attach run IDs, datasets, metrics, and reproduction commands.
Source Anchor
Comp-Core/packages/anticipation-geometry/README.md
Detected Structure
Method · Evaluation · Code Anchors · Architecture