conductor-bridge 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -0
- package/dist/bridge/index.d.ts +8 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +8 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/bridge/json-interchange.d.ts +94 -0
- package/dist/bridge/json-interchange.d.ts.map +1 -0
- package/dist/bridge/json-interchange.js +301 -0
- package/dist/bridge/json-interchange.js.map +1 -0
- package/dist/cli/commands/amend.d.ts +12 -0
- package/dist/cli/commands/amend.d.ts.map +1 -0
- package/dist/cli/commands/amend.js +205 -0
- package/dist/cli/commands/amend.js.map +1 -0
- package/dist/cli/commands/daemon.d.ts +12 -0
- package/dist/cli/commands/daemon.d.ts.map +1 -0
- package/dist/cli/commands/daemon.js +60 -0
- package/dist/cli/commands/daemon.js.map +1 -0
- package/dist/cli/commands/dispatch.d.ts +12 -0
- package/dist/cli/commands/dispatch.d.ts.map +1 -0
- package/dist/cli/commands/dispatch.js +207 -0
- package/dist/cli/commands/dispatch.js.map +1 -0
- package/dist/cli/commands/handoff.d.ts +31 -0
- package/dist/cli/commands/handoff.d.ts.map +1 -0
- package/dist/cli/commands/handoff.js +273 -0
- package/dist/cli/commands/handoff.js.map +1 -0
- package/dist/cli/commands/init.d.ts +12 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +301 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/status.d.ts +12 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +206 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/index.d.ts +17 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +148 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/handoff/encryption.d.ts +85 -0
- package/dist/handoff/encryption.d.ts.map +1 -0
- package/dist/handoff/encryption.js +308 -0
- package/dist/handoff/encryption.js.map +1 -0
- package/dist/handoff/index.d.ts +8 -0
- package/dist/handoff/index.d.ts.map +1 -0
- package/dist/handoff/index.js +10 -0
- package/dist/handoff/index.js.map +1 -0
- package/dist/handoff/mycelium-arc.d.ts +116 -0
- package/dist/handoff/mycelium-arc.d.ts.map +1 -0
- package/dist/handoff/mycelium-arc.js +410 -0
- package/dist/handoff/mycelium-arc.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -0
- package/dist/parsers/index.d.ts +10 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +12 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/plan-parser.d.ts +29 -0
- package/dist/parsers/plan-parser.d.ts.map +1 -0
- package/dist/parsers/plan-parser.js +503 -0
- package/dist/parsers/plan-parser.js.map +1 -0
- package/dist/parsers/spec-parser.d.ts +10 -0
- package/dist/parsers/spec-parser.d.ts.map +1 -0
- package/dist/parsers/spec-parser.js +382 -0
- package/dist/parsers/spec-parser.js.map +1 -0
- package/dist/parsers/state-parser.d.ts +21 -0
- package/dist/parsers/state-parser.d.ts.map +1 -0
- package/dist/parsers/state-parser.js +378 -0
- package/dist/parsers/state-parser.js.map +1 -0
- package/dist/parsers/types.d.ts +190 -0
- package/dist/parsers/types.d.ts.map +1 -0
- package/dist/parsers/types.js +7 -0
- package/dist/parsers/types.js.map +1 -0
- package/dist/schemas/cognitive-state.d.ts +1523 -0
- package/dist/schemas/cognitive-state.d.ts.map +1 -0
- package/dist/schemas/cognitive-state.js +328 -0
- package/dist/schemas/cognitive-state.js.map +1 -0
- package/dist/schemas/enums.d.ts +124 -0
- package/dist/schemas/enums.d.ts.map +1 -0
- package/dist/schemas/enums.js +108 -0
- package/dist/schemas/enums.js.map +1 -0
- package/dist/schemas/index.d.ts +9 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +9 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/sync/adhd-continuity.d.ts +91 -0
- package/dist/sync/adhd-continuity.d.ts.map +1 -0
- package/dist/sync/adhd-continuity.js +302 -0
- package/dist/sync/adhd-continuity.js.map +1 -0
- package/dist/sync/convergence-tracker.d.ts +111 -0
- package/dist/sync/convergence-tracker.d.ts.map +1 -0
- package/dist/sync/convergence-tracker.js +299 -0
- package/dist/sync/convergence-tracker.js.map +1 -0
- package/dist/sync/index.d.ts +11 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +15 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/state-sync.d.ts +105 -0
- package/dist/sync/state-sync.d.ts.map +1 -0
- package/dist/sync/state-sync.js +403 -0
- package/dist/sync/state-sync.js.map +1 -0
- package/dist/sync/watcher.d.ts +90 -0
- package/dist/sync/watcher.d.ts.map +1 -0
- package/dist/sync/watcher.js +281 -0
- package/dist/sync/watcher.js.map +1 -0
- package/dist/utils/atomic-write.d.ts +31 -0
- package/dist/utils/atomic-write.d.ts.map +1 -0
- package/dist/utils/atomic-write.js +69 -0
- package/dist/utils/atomic-write.js.map +1 -0
- package/dist/utils/error-handling.d.ts +70 -0
- package/dist/utils/error-handling.d.ts.map +1 -0
- package/dist/utils/error-handling.js +109 -0
- package/dist/utils/error-handling.js.map +1 -0
- package/dist/utils/file-lock.d.ts +46 -0
- package/dist/utils/file-lock.d.ts.map +1 -0
- package/dist/utils/file-lock.js +117 -0
- package/dist/utils/file-lock.js.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/rlm-navigator.d.ts +160 -0
- package/dist/utils/rlm-navigator.d.ts.map +1 -0
- package/dist/utils/rlm-navigator.js +368 -0
- package/dist/utils/rlm-navigator.js.map +1 -0
- package/dist/utils/safe-path.d.ts +44 -0
- package/dist/utils/safe-path.d.ts.map +1 -0
- package/dist/utils/safe-path.js +96 -0
- package/dist/utils/safe-path.js.map +1 -0
- package/dist/utils/timed-io.d.ts +51 -0
- package/dist/utils/timed-io.d.ts.map +1 -0
- package/dist/utils/timed-io.js +128 -0
- package/dist/utils/timed-io.js.map +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convergence Tracker
|
|
3
|
+
*
|
|
4
|
+
* Tracks RC^+xi convergence in the Conductor context.
|
|
5
|
+
* Measures epistemic tension and detects attractor basins.
|
|
6
|
+
*
|
|
7
|
+
* Formula: xi_n = ||A_{n+1} - A_n||_2 (epistemic tension)
|
|
8
|
+
* Epsilon: 0.1 (convergence threshold)
|
|
9
|
+
* Stable: 3 exchanges at xi < epsilon = CONVERGED
|
|
10
|
+
*
|
|
11
|
+
* DETERMINISM GUARANTEES (ThinkingMachines [He2025] compliance):
|
|
12
|
+
*
|
|
13
|
+
* 1. FIXED STATE VECTOR ORDER: The 6-dimensional state vector is computed
|
|
14
|
+
* in a hardcoded order: [progress, blocked, active, trackCompletion,
|
|
15
|
+
* momentum, energy]. This order never changes.
|
|
16
|
+
*
|
|
17
|
+
* 2. FIXED REDUCTION SEQUENCE: L2 norm uses Array.reduce() which processes
|
|
18
|
+
* elements left-to-right per ECMAScript spec. Same inputs → same output.
|
|
19
|
+
*
|
|
20
|
+
* 3. FIXED ATTRACTOR PRIORITY: Attractor detection evaluates conditions in
|
|
21
|
+
* fixed order: RECOVERY > EXPLORING > TEACHING > FOCUSED.
|
|
22
|
+
* First match wins, no dynamic reordering.
|
|
23
|
+
*
|
|
24
|
+
* 4. CONSTANT THRESHOLDS: EPSILON (0.1), STABLE_EXCHANGES_REQUIRED (3),
|
|
25
|
+
* normalization divisors (5, 3) are compile-time constants.
|
|
26
|
+
*
|
|
27
|
+
* Reference: [He2025] "Defeating Nondeterminism in LLM Inference"
|
|
28
|
+
* https://thinkingmachines.ai/blog/defeating-nondeterminism-in-llm-inference/
|
|
29
|
+
*/
|
|
30
|
+
import { ConvergenceAttractor, ConvergenceStability, MomentumPhase } from '../schemas/enums.js';
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// Constants
|
|
33
|
+
// ============================================================================
|
|
34
|
+
const EPSILON = 0.1; // Convergence threshold
|
|
35
|
+
const STABLE_EXCHANGES_REQUIRED = 3;
|
|
36
|
+
const MAX_TRAJECTORY_LENGTH = 50;
|
|
37
|
+
// Momentum to numeric mapping
|
|
38
|
+
const MOMENTUM_VALUES = {
|
|
39
|
+
[MomentumPhase.COLD_START]: 0,
|
|
40
|
+
[MomentumPhase.BUILDING]: 1,
|
|
41
|
+
[MomentumPhase.ROLLING]: 2,
|
|
42
|
+
[MomentumPhase.PEAK]: 3,
|
|
43
|
+
[MomentumPhase.DECLINING]: 2,
|
|
44
|
+
[MomentumPhase.CRASHED]: 0,
|
|
45
|
+
};
|
|
46
|
+
// Energy to numeric mapping
|
|
47
|
+
const ENERGY_VALUES = {
|
|
48
|
+
high: 3,
|
|
49
|
+
medium: 2,
|
|
50
|
+
low: 1,
|
|
51
|
+
depleted: 0,
|
|
52
|
+
};
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// State Vector Computation
|
|
55
|
+
// ============================================================================
|
|
56
|
+
/**
|
|
57
|
+
* Extract state vector from plan and cognitive state.
|
|
58
|
+
*/
|
|
59
|
+
export function extractStateVector(plan, cognitiveState) {
|
|
60
|
+
// Count tasks by state
|
|
61
|
+
let total = 0;
|
|
62
|
+
let complete = 0;
|
|
63
|
+
let blocked = 0;
|
|
64
|
+
let active = 0;
|
|
65
|
+
for (const track of plan.tracks) {
|
|
66
|
+
for (const task of track.tasks) {
|
|
67
|
+
total++;
|
|
68
|
+
if (task.state === 'complete')
|
|
69
|
+
complete++;
|
|
70
|
+
if (task.state === 'blocked')
|
|
71
|
+
blocked++;
|
|
72
|
+
if (task.state === 'in_progress')
|
|
73
|
+
active++;
|
|
74
|
+
// Count subtasks
|
|
75
|
+
for (const subtask of task.subtasks) {
|
|
76
|
+
total++;
|
|
77
|
+
if (subtask.state === 'complete')
|
|
78
|
+
complete++;
|
|
79
|
+
if (subtask.state === 'blocked')
|
|
80
|
+
blocked++;
|
|
81
|
+
if (subtask.state === 'in_progress')
|
|
82
|
+
active++;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const completedTracks = plan.tracks.filter((t) => t.status === 'complete').length;
|
|
87
|
+
return {
|
|
88
|
+
progress: total > 0 ? complete / total : 0,
|
|
89
|
+
blocked: total > 0 ? blocked / total : 0,
|
|
90
|
+
active: total > 0 ? active / total : 0,
|
|
91
|
+
trackCompletion: plan.tracks.length > 0 ? completedTracks / plan.tracks.length : 0,
|
|
92
|
+
momentum: cognitiveState
|
|
93
|
+
? MOMENTUM_VALUES[cognitiveState.momentum_phase] ?? 1
|
|
94
|
+
: 1,
|
|
95
|
+
energy: cognitiveState
|
|
96
|
+
? ENERGY_VALUES[cognitiveState.energy_level] ?? 2
|
|
97
|
+
: 2,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Compute L2 norm between two state vectors.
|
|
102
|
+
*/
|
|
103
|
+
export function computeL2Norm(v1, v2) {
|
|
104
|
+
const diffs = [
|
|
105
|
+
v1.progress - v2.progress,
|
|
106
|
+
v1.blocked - v2.blocked,
|
|
107
|
+
v1.active - v2.active,
|
|
108
|
+
v1.trackCompletion - v2.trackCompletion,
|
|
109
|
+
(v1.momentum - v2.momentum) / 5, // Normalize momentum (0-5 → 0-1)
|
|
110
|
+
(v1.energy - v2.energy) / 3, // Normalize energy (0-3 → 0-1)
|
|
111
|
+
];
|
|
112
|
+
const sumSquares = diffs.reduce((sum, d) => sum + d * d, 0);
|
|
113
|
+
return Math.sqrt(sumSquares / diffs.length); // Normalized L2
|
|
114
|
+
}
|
|
115
|
+
// ============================================================================
|
|
116
|
+
// Attractor Detection
|
|
117
|
+
// ============================================================================
|
|
118
|
+
/**
|
|
119
|
+
* Detect which attractor basin the current state is in.
|
|
120
|
+
*
|
|
121
|
+
* Attractors:
|
|
122
|
+
* - focused: High progress, low blocked, steady momentum
|
|
123
|
+
* - exploring: Active work, building momentum
|
|
124
|
+
* - recovery: Low energy, crashed momentum
|
|
125
|
+
* - teaching: (Not derived from tasks, set explicitly)
|
|
126
|
+
*/
|
|
127
|
+
export function detectAttractor(vector, cognitiveState) {
|
|
128
|
+
// Check for recovery state
|
|
129
|
+
if (vector.energy <= 1 ||
|
|
130
|
+
vector.momentum === 0 ||
|
|
131
|
+
vector.blocked > 0.3) {
|
|
132
|
+
return ConvergenceAttractor.RECOVERY;
|
|
133
|
+
}
|
|
134
|
+
// Check for exploring state
|
|
135
|
+
if (vector.active > 0.2 &&
|
|
136
|
+
vector.momentum >= 1 &&
|
|
137
|
+
vector.momentum <= 2 &&
|
|
138
|
+
vector.progress < 0.5) {
|
|
139
|
+
return ConvergenceAttractor.EXPLORING;
|
|
140
|
+
}
|
|
141
|
+
// Check for teaching (explicitly set via cognitive state)
|
|
142
|
+
if (cognitiveState?.active_mode === 'teaching') {
|
|
143
|
+
return ConvergenceAttractor.TEACHING;
|
|
144
|
+
}
|
|
145
|
+
// Default to focused
|
|
146
|
+
return ConvergenceAttractor.FOCUSED;
|
|
147
|
+
}
|
|
148
|
+
// ============================================================================
|
|
149
|
+
// Convergence Tracking
|
|
150
|
+
// ============================================================================
|
|
151
|
+
/**
|
|
152
|
+
* Convergence tracker class.
|
|
153
|
+
*
|
|
154
|
+
* Maintains state across exchanges and detects convergence.
|
|
155
|
+
*/
|
|
156
|
+
export class ConductorConvergenceTracker {
|
|
157
|
+
previousVector = null;
|
|
158
|
+
trajectory = [];
|
|
159
|
+
stableCount = 0;
|
|
160
|
+
currentAttractor = ConvergenceAttractor.FOCUSED;
|
|
161
|
+
/**
|
|
162
|
+
* Record an exchange and compute convergence metrics.
|
|
163
|
+
*/
|
|
164
|
+
recordExchange(plan, cognitiveState) {
|
|
165
|
+
const currentVector = extractStateVector(plan, cognitiveState);
|
|
166
|
+
// Compute xi_n (epistemic tension)
|
|
167
|
+
let xi_n = 0;
|
|
168
|
+
if (this.previousVector) {
|
|
169
|
+
xi_n = computeL2Norm(currentVector, this.previousVector);
|
|
170
|
+
}
|
|
171
|
+
// Update trajectory
|
|
172
|
+
this.trajectory.push(xi_n);
|
|
173
|
+
if (this.trajectory.length > MAX_TRAJECTORY_LENGTH) {
|
|
174
|
+
this.trajectory.shift();
|
|
175
|
+
}
|
|
176
|
+
// Check for stability
|
|
177
|
+
if (xi_n < EPSILON) {
|
|
178
|
+
this.stableCount++;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
this.stableCount = 0;
|
|
182
|
+
}
|
|
183
|
+
// Detect attractor
|
|
184
|
+
const attractor = detectAttractor(currentVector, cognitiveState);
|
|
185
|
+
// Detect stability state
|
|
186
|
+
let stability;
|
|
187
|
+
if (this.stableCount >= STABLE_EXCHANGES_REQUIRED) {
|
|
188
|
+
stability = ConvergenceStability.STABLE;
|
|
189
|
+
}
|
|
190
|
+
else if (this.trajectory.length >= 3) {
|
|
191
|
+
// Check for oscillation (alternating high/low)
|
|
192
|
+
const recent = this.trajectory.slice(-3);
|
|
193
|
+
const isOscillating = (recent[0] > EPSILON && recent[1] < EPSILON && recent[2] > EPSILON) ||
|
|
194
|
+
(recent[0] < EPSILON && recent[1] > EPSILON && recent[2] < EPSILON);
|
|
195
|
+
stability = isOscillating
|
|
196
|
+
? ConvergenceStability.OSCILLATING
|
|
197
|
+
: ConvergenceStability.CONVERGING;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
stability = ConvergenceStability.CONVERGING;
|
|
201
|
+
}
|
|
202
|
+
// Update state
|
|
203
|
+
this.previousVector = currentVector;
|
|
204
|
+
this.currentAttractor = attractor;
|
|
205
|
+
return {
|
|
206
|
+
xi_n,
|
|
207
|
+
attractor,
|
|
208
|
+
stability,
|
|
209
|
+
stableExchangeCount: this.stableCount,
|
|
210
|
+
isConverged: this.stableCount >= STABLE_EXCHANGES_REQUIRED,
|
|
211
|
+
trajectory: [...this.trajectory],
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get RC^+xi glyph for display.
|
|
216
|
+
*
|
|
217
|
+
* Format: RC^+xi[attractor:stability:xi]
|
|
218
|
+
* Example: RC^+xi[focused:stable:0.05]
|
|
219
|
+
*/
|
|
220
|
+
getGlyph() {
|
|
221
|
+
const xi = this.trajectory.length > 0
|
|
222
|
+
? this.trajectory[this.trajectory.length - 1].toFixed(2)
|
|
223
|
+
: '0.00';
|
|
224
|
+
const attractorShort = this.currentAttractor.charAt(0).toUpperCase();
|
|
225
|
+
const stabilityShort = this.stableCount >= STABLE_EXCHANGES_REQUIRED ? 'S' : 'C';
|
|
226
|
+
return `RC^+xi[${attractorShort}:${stabilityShort}:${xi}]`;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Create a convergence record for persistence.
|
|
230
|
+
*/
|
|
231
|
+
createRecord(sessionId, exchangeNumber, cognitiveState) {
|
|
232
|
+
const xi_n = this.trajectory.length > 0
|
|
233
|
+
? this.trajectory[this.trajectory.length - 1]
|
|
234
|
+
: 0;
|
|
235
|
+
return {
|
|
236
|
+
timestamp: new Date().toISOString(),
|
|
237
|
+
session_id: sessionId,
|
|
238
|
+
exchange_number: exchangeNumber,
|
|
239
|
+
expert: cognitiveState?.active_intervention_expert,
|
|
240
|
+
paradigm: cognitiveState?.active_paradigm,
|
|
241
|
+
altitude: cognitiveState?.current_altitude,
|
|
242
|
+
burnout_level: cognitiveState?.burnout_level,
|
|
243
|
+
energy_level: cognitiveState?.energy_level,
|
|
244
|
+
xi_n,
|
|
245
|
+
attractor: this.currentAttractor,
|
|
246
|
+
stability: this.stableCount >= STABLE_EXCHANGES_REQUIRED
|
|
247
|
+
? ConvergenceStability.STABLE
|
|
248
|
+
: ConvergenceStability.CONVERGING,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Reset tracker state.
|
|
253
|
+
*/
|
|
254
|
+
reset() {
|
|
255
|
+
this.previousVector = null;
|
|
256
|
+
this.trajectory = [];
|
|
257
|
+
this.stableCount = 0;
|
|
258
|
+
this.currentAttractor = ConvergenceAttractor.FOCUSED;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
// ============================================================================
|
|
262
|
+
// Utility Functions
|
|
263
|
+
// ============================================================================
|
|
264
|
+
/**
|
|
265
|
+
* Analyze convergence trajectory for insights.
|
|
266
|
+
*/
|
|
267
|
+
export function analyzeTrajectory(trajectory) {
|
|
268
|
+
if (trajectory.length < 2) {
|
|
269
|
+
return { trend: 'stable', averageXi: trajectory[0] ?? 0, volatility: 0 };
|
|
270
|
+
}
|
|
271
|
+
// Compute average
|
|
272
|
+
const averageXi = trajectory.reduce((sum, x) => sum + x, 0) / trajectory.length;
|
|
273
|
+
// Compute volatility (standard deviation)
|
|
274
|
+
const variance = trajectory.reduce((sum, x) => sum + (x - averageXi) ** 2, 0) / trajectory.length;
|
|
275
|
+
const volatility = Math.sqrt(variance);
|
|
276
|
+
// Compute trend (linear regression slope)
|
|
277
|
+
const n = trajectory.length;
|
|
278
|
+
const xMean = (n - 1) / 2;
|
|
279
|
+
const yMean = averageXi;
|
|
280
|
+
let numerator = 0;
|
|
281
|
+
let denominator = 0;
|
|
282
|
+
for (let i = 0; i < n; i++) {
|
|
283
|
+
numerator += (i - xMean) * (trajectory[i] - yMean);
|
|
284
|
+
denominator += (i - xMean) ** 2;
|
|
285
|
+
}
|
|
286
|
+
const slope = denominator !== 0 ? numerator / denominator : 0;
|
|
287
|
+
let trend;
|
|
288
|
+
if (slope < -0.01) {
|
|
289
|
+
trend = 'improving'; // xi decreasing = converging
|
|
290
|
+
}
|
|
291
|
+
else if (slope > 0.01) {
|
|
292
|
+
trend = 'degrading'; // xi increasing = diverging
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
trend = 'stable';
|
|
296
|
+
}
|
|
297
|
+
return { trend, averageXi, volatility };
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=convergence-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convergence-tracker.js","sourceRoot":"","sources":["../../src/sync/convergence-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA8BhG,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC,wBAAwB;AAC7C,MAAM,yBAAyB,GAAG,CAAC,CAAC;AACpC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,8BAA8B;AAC9B,MAAM,eAAe,GAA2B;IAC9C,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;IAC7B,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC3B,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;IAC1B,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;IACvB,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,CAAC;IAC5B,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;CAC3B,CAAC;AAEF,4BAA4B;AAC5B,MAAM,aAAa,GAA2B;IAC5C,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,GAAG,EAAE,CAAC;IACN,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAgB,EAChB,cAA6B;IAE7B,uBAAuB;IACvB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,OAAO,GAAG,CAAC,CAA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C1C,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC;IAC5B,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,KAAK,GAAG,SAAS,CAAC;IAExB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,SAAS,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAE,GAAG,KAAK,CAAC,CAAC;QACpD,WAAW,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9D,IAAI,KAA2C,CAAC;IAChD,IAAI,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,GAAG,WAAW,CAAC,CAAC,6BAA6B;IACpD,CAAC;SAAM,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC;QACxB,KAAK,GAAG,WAAW,CAAC,CAAC,4BAA4B;IACnD,CAAC;SAAM,CAAC;QACN,KAAK,GAAG,QAAQ,CAAC;IACnB,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync Module
|
|
3
|
+
*
|
|
4
|
+
* Bidirectional state synchronization between Conductor (Markdown)
|
|
5
|
+
* and USD Substrate (JSON).
|
|
6
|
+
*/
|
|
7
|
+
export { syncConductorToUSD, syncUSDToConductor, syncBidirectional, deriveMomentumFromTasks, deriveEnergyFromTasks, deriveCognitiveState, computeFileChecksum, hasFileChanged, type SyncConfig, type SyncResult, type DerivedCognitiveState, } from './state-sync.js';
|
|
8
|
+
export { ConductorConvergenceTracker, extractStateVector, computeL2Norm, detectAttractor, analyzeTrajectory, type StateVector, type ConvergenceState, } from './convergence-tracker.js';
|
|
9
|
+
export { ConductorWatcher, createWatcher, type WatcherConfig, type WatcherStats, type WatcherEvent, } from './watcher.js';
|
|
10
|
+
export { SessionBreakType, detectBreakType, applyMomentumPenalty, generateResumeSummary, createSessionHandoff, getRecoveryRecommendations, type BreakAnalysis, type ResumeSummary, type MomentumState, } from './adhd-continuity.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,qBAAqB,GAC3B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACtB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync Module
|
|
3
|
+
*
|
|
4
|
+
* Bidirectional state synchronization between Conductor (Markdown)
|
|
5
|
+
* and USD Substrate (JSON).
|
|
6
|
+
*/
|
|
7
|
+
// State sync
|
|
8
|
+
export { syncConductorToUSD, syncUSDToConductor, syncBidirectional, deriveMomentumFromTasks, deriveEnergyFromTasks, deriveCognitiveState, computeFileChecksum, hasFileChanged, } from './state-sync.js';
|
|
9
|
+
// Convergence tracking
|
|
10
|
+
export { ConductorConvergenceTracker, extractStateVector, computeL2Norm, detectAttractor, analyzeTrajectory, } from './convergence-tracker.js';
|
|
11
|
+
// File watcher
|
|
12
|
+
export { ConductorWatcher, createWatcher, } from './watcher.js';
|
|
13
|
+
// ADHD continuity
|
|
14
|
+
export { SessionBreakType, detectBreakType, applyMomentumPenalty, generateResumeSummary, createSessionHandoff, getRecoveryRecommendations, } from './adhd-continuity.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,aAAa;AACb,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,GAIf,MAAM,iBAAiB,CAAC;AAEzB,uBAAuB;AACvB,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAElC,eAAe;AACf,OAAO,EACL,gBAAgB,EAChB,aAAa,GAId,MAAM,cAAc,CAAC;AAEtB,kBAAkB;AAClB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,GAI3B,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State Sync Module
|
|
3
|
+
*
|
|
4
|
+
* Handles bidirectional synchronization between:
|
|
5
|
+
* - Conductor (Markdown files) → USD Substrate (JSON)
|
|
6
|
+
* - USD Substrate (JSON) → Conductor (Markdown files)
|
|
7
|
+
*
|
|
8
|
+
* Key concepts:
|
|
9
|
+
* - Conductor is source of truth for TASK state (checkboxes)
|
|
10
|
+
* - USD Substrate is source of truth for COGNITIVE state (energy, burnout, momentum)
|
|
11
|
+
* - Sync derives cognitive state from task progress and vice versa
|
|
12
|
+
*
|
|
13
|
+
* DETERMINISM GUARANTEES (ThinkingMachines [He2025] compliance):
|
|
14
|
+
*
|
|
15
|
+
* 1. FIXED MOMENTUM DERIVATION ORDER: Conditions in deriveMomentumFromTasks()
|
|
16
|
+
* are checked in priority order: CRASHED > DECLINING > COLD_START >
|
|
17
|
+
* BUILDING > ROLLING > PEAK. First match wins.
|
|
18
|
+
*
|
|
19
|
+
* 2. FIXED ENERGY DERIVATION ORDER: Conditions in deriveEnergyFromTasks()
|
|
20
|
+
* are checked in order: HIGH > DEPLETED > LOW > MEDIUM (default).
|
|
21
|
+
*
|
|
22
|
+
* 3. SEQUENTIAL SYNC: syncBidirectional() runs Conductor→USD first,
|
|
23
|
+
* then USD→Conductor. Never parallel to prevent race conditions.
|
|
24
|
+
*
|
|
25
|
+
* 4. FILE-ORDER ITERATION: Tasks are processed in markdown file order
|
|
26
|
+
* (line numbers), not by arbitrary collection ordering.
|
|
27
|
+
*
|
|
28
|
+
* Reference: [He2025] "Defeating Nondeterminism in LLM Inference"
|
|
29
|
+
*/
|
|
30
|
+
import type { ParsedPlan } from '../parsers/types.js';
|
|
31
|
+
import { MomentumPhase, EnergyLevel } from '../schemas/enums.js';
|
|
32
|
+
export interface SyncConfig {
|
|
33
|
+
conductorDir: string;
|
|
34
|
+
cognitiveStatePath: string;
|
|
35
|
+
autoSave: boolean;
|
|
36
|
+
autoSaveIntervalMs: number;
|
|
37
|
+
}
|
|
38
|
+
export interface SyncResult {
|
|
39
|
+
success: boolean;
|
|
40
|
+
direction: 'conductor-to-usd' | 'usd-to-conductor' | 'bidirectional';
|
|
41
|
+
changes: string[];
|
|
42
|
+
warnings: string[];
|
|
43
|
+
timestamp: string;
|
|
44
|
+
}
|
|
45
|
+
export interface DerivedCognitiveState {
|
|
46
|
+
momentum_phase: MomentumPhase;
|
|
47
|
+
energy_level: EnergyLevel;
|
|
48
|
+
progress_percent: number;
|
|
49
|
+
tasks_completed: number;
|
|
50
|
+
tasks_total: number;
|
|
51
|
+
tracks_completed: number;
|
|
52
|
+
tracks_total: number;
|
|
53
|
+
has_blocked_tasks: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Derive momentum phase from task completion trajectory.
|
|
57
|
+
*
|
|
58
|
+
* Momentum is about VELOCITY of progress, not just completion count.
|
|
59
|
+
* We look at recent activity patterns to determine phase.
|
|
60
|
+
*/
|
|
61
|
+
export declare function deriveMomentumFromTasks(plan: ParsedPlan, recentCompletions?: number, sessionDurationMinutes?: number): MomentumPhase;
|
|
62
|
+
/**
|
|
63
|
+
* Derive energy level from task patterns.
|
|
64
|
+
*
|
|
65
|
+
* Energy correlates with:
|
|
66
|
+
* - Task completion velocity (higher = more energy)
|
|
67
|
+
* - Blocked task ratio (higher = lower energy)
|
|
68
|
+
* - Session duration (longer = lower energy)
|
|
69
|
+
*/
|
|
70
|
+
export declare function deriveEnergyFromTasks(plan: ParsedPlan, sessionDurationMinutes?: number, recentBlockedCount?: number): EnergyLevel;
|
|
71
|
+
/**
|
|
72
|
+
* Derive complete cognitive state from task data.
|
|
73
|
+
*/
|
|
74
|
+
export declare function deriveCognitiveState(plan: ParsedPlan, sessionDurationMinutes?: number, recentCompletions?: number): DerivedCognitiveState;
|
|
75
|
+
/**
|
|
76
|
+
* Sync Conductor state to USD Substrate.
|
|
77
|
+
*
|
|
78
|
+
* Reads plan.md and state.md, derives cognitive state,
|
|
79
|
+
* writes to cognitive_state.json.
|
|
80
|
+
*/
|
|
81
|
+
export declare function syncConductorToUSD(config: SyncConfig): Promise<SyncResult>;
|
|
82
|
+
/**
|
|
83
|
+
* Sync USD Substrate state to Conductor.
|
|
84
|
+
*
|
|
85
|
+
* Reads cognitive_state.json, updates state.md with
|
|
86
|
+
* cognitive context (warnings, recommendations).
|
|
87
|
+
*/
|
|
88
|
+
export declare function syncUSDToConductor(config: SyncConfig): Promise<SyncResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Perform bidirectional sync.
|
|
91
|
+
*
|
|
92
|
+
* 1. Read both sources
|
|
93
|
+
* 2. Conductor → USD (task state → cognitive state)
|
|
94
|
+
* 3. USD → Conductor (cognitive warnings → state.md)
|
|
95
|
+
*/
|
|
96
|
+
export declare function syncBidirectional(config: SyncConfig): Promise<SyncResult>;
|
|
97
|
+
/**
|
|
98
|
+
* Compute checksum for a file.
|
|
99
|
+
*/
|
|
100
|
+
export declare function computeFileChecksum(filePath: string): Promise<string>;
|
|
101
|
+
/**
|
|
102
|
+
* Check if a file has changed since last checksum.
|
|
103
|
+
*/
|
|
104
|
+
export declare function hasFileChanged(currentChecksum: string, previousChecksum: string): boolean;
|
|
105
|
+
//# sourceMappingURL=state-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-sync.d.ts","sourceRoot":"","sources":["../../src/sync/state-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAKH,OAAO,KAAK,EACV,UAAU,EAIX,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EACL,aAAa,EACb,WAAW,EAMZ,MAAM,qBAAqB,CAAC;AAM7B,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,E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