7474
7575## 3. Implementation Interfaces (The Bridge)
7676
77- We need to bridge the generic ` State ` from v1.0 with the rigorous ` Vector3D ` of v2.1.
77+ We need to bridge the generic ` State ` from v1.0 with the rigorous ` VectorN ` of v2.1.
7878
7979### 3.1 The Kinematics Type Definition
8080
8181Create these in ` src/core/kinematics/types.ts ` .
8282
8383``` typescript
84- export type Vector3D = number []; // Embedding vector
84+ export type VectorN = number []; // N-dimensional embedding vector
8585
8686// The Physics State (Hidden from the generic Orchestrator)
8787export interface KinematicState {
88- position: Vector3D ; // S_i (Filtered)
89- velocity: Vector3D ; // v_i
90- heading: Vector3D ; // D_i
88+ position: VectorN ; // S_i (Filtered)
89+ velocity: VectorN ; // v_i
90+ heading: VectorN ; // D_i
9191 stepIndex: number ;
9292}
9393
9494// The Control Signal returned by the PID controller
9595export interface ControlSignal {
96- correctionVector: Vector3D ; // u(i)
96+ correctionVector: VectorN ; // u(i)
9797 magnitude: number ; // How strong the correction is (0-1)
9898 isStable: boolean ; // Should we stop?
9999 log: string ; // Explanation for debug traces
@@ -113,7 +113,7 @@ import { State } from '../types';
113113
114114// Adapters must implement this to translate their Domain State (JSON) into Physics State (Vector)
115115export interface StateEmbedder <S extends State > {
116- embed(state : S ): Promise <Vector3D >;
116+ embed(state : S ): Promise <VectorN >;
117117}
118118
119119// The v2.1 Configuration
@@ -138,8 +138,8 @@ A pure, deterministic class that holds the math. It does not know about LLMs or
138138class PhysicsEngine {
139139 update(
140140 prev : KinematicState ,
141- observation : Vector3D
142- ): { next: KinematicState ; error: Vector3D } {
141+ observation : VectorN
142+ ): { next: KinematicState ; error: VectorN } {
143143 // 1. EKF Predict & Update
144144 // 2. Calculate Heading D_i
145145 // 3. Calculate Cross-track Error e_i (Vector Rejection)
@@ -163,7 +163,7 @@ class KinematicProbePolicy<S> implements ProbePolicy<S, Action, Feedback> {
163163 ) {}
164164
165165 async decide(state : S , ladder : Ladder ): Promise <Action > {
166- // 1. Convert generic State -> Vector3D (using Embedder)
166+ // 1. Convert generic State -> VectorN (using Embedder)
167167 const observation = await this .embedder .embed (state );
168168
169169 // 2. Update Physics Engine
@@ -194,7 +194,7 @@ class KinematicProbePolicy<S> implements ProbePolicy<S, Action, Feedback> {
194194When implementing v2.1, follow this sequence to avoid breaking existing code:
195195
1961961 . ** Scaffold** : Create ` src/core/kinematics/ ` folder.
197- 2 . ** Math First** : Implement ` Vector3D ` operations (dot product, norm, projection, rejection) in ` src/core/kinematics/math.ts ` . ** Do not use external heavy math libs** , keep it lightweight.
197+ 2 . ** Math First** : Implement ` VectorN ` operations (dot product, norm, projection, rejection) in ` src/core/geometry/vector.ts ` (previously ` src/core/ kinematics/math.ts` ) . ** Do not use external heavy math libs** , keep it lightweight.
1981983 . ** Engine** : Implement ` PhysicsEngine ` with EKF and Heading logic.
1991994 . ** Controller** : Implement ` PIDController ` .
2002005 . ** Integration** : Create ` KinematicProbePolicy ` .
@@ -219,7 +219,7 @@ const controlled = cyberloop(agent, {
219219 middleware: [
220220 kinematicsMiddleware ({
221221 embedder , // StateEmbedder<S> — same as Section 3.2
222- goalEmbedding , // Vector3D — task origin τ
222+ goalEmbedding , // VectorN — task origin τ
223223 pid: { Kp: 0.5 , Ki: 0.0 , Kd: 0.1 , stabilityThreshold: 0.6 },
224224 physics: { processNoise: 0.1 , measureNoise: 0.5 },
225225 }),
0 commit comments