@stackmemoryai/stackmemory 0.3.22 → 0.3.25
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/dist/cli/commands/ralph.js +294 -0
- package/dist/cli/commands/ralph.js.map +7 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +2 -2
- package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js +586 -0
- package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js.map +7 -0
- package/dist/integrations/ralph/context/context-budget-manager.js +297 -0
- package/dist/integrations/ralph/context/context-budget-manager.js.map +7 -0
- package/dist/integrations/ralph/context/stackmemory-context-loader.js +356 -0
- package/dist/integrations/ralph/context/stackmemory-context-loader.js.map +7 -0
- package/dist/integrations/ralph/index.js +14 -0
- package/dist/integrations/ralph/index.js.map +7 -0
- package/dist/integrations/ralph/learning/pattern-learner.js +397 -0
- package/dist/integrations/ralph/learning/pattern-learner.js.map +7 -0
- package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js +444 -0
- package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js.map +7 -0
- package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js +459 -0
- package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js.map +7 -0
- package/dist/integrations/ralph/performance/performance-optimizer.js +354 -0
- package/dist/integrations/ralph/performance/performance-optimizer.js.map +7 -0
- package/dist/integrations/ralph/ralph-integration-demo.js +178 -0
- package/dist/integrations/ralph/ralph-integration-demo.js.map +7 -0
- package/dist/integrations/ralph/state/state-reconciler.js +400 -0
- package/dist/integrations/ralph/state/state-reconciler.js.map +7 -0
- package/dist/integrations/ralph/swarm/git-workflow-manager.js +309 -0
- package/dist/integrations/ralph/swarm/git-workflow-manager.js.map +7 -0
- package/dist/integrations/ralph/swarm/swarm-coordinator.js +656 -0
- package/dist/integrations/ralph/swarm/swarm-coordinator.js.map +7 -0
- package/dist/integrations/ralph/types.js +1 -0
- package/dist/integrations/ralph/types.js.map +7 -0
- package/dist/integrations/ralph/visualization/ralph-debugger.js +581 -0
- package/dist/integrations/ralph/visualization/ralph-debugger.js.map +7 -0
- package/package.json +1 -1
- package/scripts/deploy-ralph-swarm.sh +365 -0
- package/scripts/ralph-integration-test.js +274 -0
- package/scripts/ralph-loop-implementation.js +404 -0
- package/scripts/swarm-monitor.js +509 -0
- package/scripts/test-parallel-swarms.js +443 -0
- package/scripts/test-pre-publish-quick.sh +4 -2
- package/scripts/test-swarm-git-workflow.js +338 -0
- package/scripts/testing/ralph-cli-test.js +88 -0
- package/scripts/testing/ralph-integration-validation.js +727 -0
- package/scripts/testing/ralph-swarm-test-scenarios.js +613 -0
- package/scripts/validate-swarm-implementation.js +467 -0
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
import { logger } from "../../../core/monitoring/logger.js";
|
|
4
|
+
class IterationLifecycle extends EventEmitter {
|
|
5
|
+
config;
|
|
6
|
+
hooks = {};
|
|
7
|
+
checkpoints = [];
|
|
8
|
+
currentIteration;
|
|
9
|
+
iterationHistory = [];
|
|
10
|
+
activeTimers = /* @__PURE__ */ new Map();
|
|
11
|
+
constructor(config, hooks) {
|
|
12
|
+
super();
|
|
13
|
+
this.config = {
|
|
14
|
+
hooks: {
|
|
15
|
+
preIteration: config?.hooks?.preIteration ?? true,
|
|
16
|
+
postIteration: config?.hooks?.postIteration ?? true,
|
|
17
|
+
onStateChange: config?.hooks?.onStateChange ?? true,
|
|
18
|
+
onError: config?.hooks?.onError ?? true,
|
|
19
|
+
onComplete: config?.hooks?.onComplete ?? true
|
|
20
|
+
},
|
|
21
|
+
checkpoints: {
|
|
22
|
+
enabled: config?.checkpoints?.enabled ?? true,
|
|
23
|
+
frequency: config?.checkpoints?.frequency || 5,
|
|
24
|
+
retentionDays: config?.checkpoints?.retentionDays || 7
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
if (hooks) {
|
|
28
|
+
this.registerHooks(hooks);
|
|
29
|
+
}
|
|
30
|
+
this.setupEventHandlers();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Register lifecycle hooks
|
|
34
|
+
*/
|
|
35
|
+
registerHooks(hooks) {
|
|
36
|
+
this.hooks = { ...this.hooks, ...hooks };
|
|
37
|
+
logger.debug("Lifecycle hooks registered", {
|
|
38
|
+
registered: Object.keys(hooks)
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Start iteration with lifecycle management
|
|
43
|
+
*/
|
|
44
|
+
async startIteration(iterationNumber, context) {
|
|
45
|
+
logger.info("Starting iteration", { iteration: iterationNumber });
|
|
46
|
+
this.emitEvent({
|
|
47
|
+
type: "iteration.started",
|
|
48
|
+
timestamp: Date.now(),
|
|
49
|
+
iteration: iterationNumber,
|
|
50
|
+
data: { context }
|
|
51
|
+
});
|
|
52
|
+
let processedContext = context;
|
|
53
|
+
if (this.config.hooks.preIteration && this.hooks.preIteration) {
|
|
54
|
+
try {
|
|
55
|
+
processedContext = await this.hooks.preIteration(context);
|
|
56
|
+
logger.debug("Pre-iteration hook executed", {
|
|
57
|
+
original: context.tokenCount,
|
|
58
|
+
processed: processedContext.tokenCount
|
|
59
|
+
});
|
|
60
|
+
} catch (error) {
|
|
61
|
+
await this.handleError(error, { phase: "preIteration", context });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
this.startTimer(`iteration-${iterationNumber}`);
|
|
65
|
+
return processedContext;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Complete iteration with lifecycle management
|
|
69
|
+
*/
|
|
70
|
+
async completeIteration(iteration) {
|
|
71
|
+
logger.info("Completing iteration", { iteration: iteration.number });
|
|
72
|
+
this.currentIteration = iteration;
|
|
73
|
+
const duration = this.stopTimer(`iteration-${iteration.number}`);
|
|
74
|
+
if (this.config.hooks.postIteration && this.hooks.postIteration) {
|
|
75
|
+
try {
|
|
76
|
+
await this.hooks.postIteration(iteration);
|
|
77
|
+
logger.debug("Post-iteration hook executed");
|
|
78
|
+
} catch (error) {
|
|
79
|
+
await this.handleError(error, { phase: "postIteration", iteration });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (this.shouldCreateCheckpoint(iteration.number)) {
|
|
83
|
+
await this.createCheckpoint(iteration);
|
|
84
|
+
}
|
|
85
|
+
this.emitEvent({
|
|
86
|
+
type: "iteration.completed",
|
|
87
|
+
timestamp: Date.now(),
|
|
88
|
+
iteration: iteration.number,
|
|
89
|
+
data: {
|
|
90
|
+
iteration,
|
|
91
|
+
duration,
|
|
92
|
+
success: iteration.validation.testsPass
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
await this.cleanOldCheckpoints();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Handle iteration failure
|
|
99
|
+
*/
|
|
100
|
+
async failIteration(iterationNumber, error, context) {
|
|
101
|
+
logger.error("Iteration failed", {
|
|
102
|
+
iteration: iterationNumber,
|
|
103
|
+
error: error.message
|
|
104
|
+
});
|
|
105
|
+
this.stopTimer(`iteration-${iterationNumber}`);
|
|
106
|
+
if (this.config.hooks.onError && this.hooks.onError) {
|
|
107
|
+
try {
|
|
108
|
+
await this.hooks.onError(error, context);
|
|
109
|
+
} catch (hookError) {
|
|
110
|
+
logger.error("Error hook failed", { error: hookError.message });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
this.emitEvent({
|
|
114
|
+
type: "iteration.failed",
|
|
115
|
+
timestamp: Date.now(),
|
|
116
|
+
iteration: iterationNumber,
|
|
117
|
+
data: {
|
|
118
|
+
error: error.message,
|
|
119
|
+
stack: error.stack,
|
|
120
|
+
context
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Handle state change
|
|
126
|
+
*/
|
|
127
|
+
async handleStateChange(oldState, newState) {
|
|
128
|
+
logger.debug("State change detected", {
|
|
129
|
+
old: oldState.status,
|
|
130
|
+
new: newState.status,
|
|
131
|
+
iteration: newState.iteration
|
|
132
|
+
});
|
|
133
|
+
if (this.config.hooks.onStateChange && this.hooks.onStateChange) {
|
|
134
|
+
try {
|
|
135
|
+
await this.hooks.onStateChange(oldState, newState);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
await this.handleError(error, {
|
|
138
|
+
phase: "stateChange",
|
|
139
|
+
oldState,
|
|
140
|
+
newState
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
this.emitEvent({
|
|
145
|
+
type: "state.changed",
|
|
146
|
+
timestamp: Date.now(),
|
|
147
|
+
iteration: newState.iteration,
|
|
148
|
+
data: {
|
|
149
|
+
oldStatus: oldState.status,
|
|
150
|
+
newStatus: newState.status,
|
|
151
|
+
changes: this.detectStateChanges(oldState, newState)
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
if (newState.status === "completed" && oldState.status !== "completed") {
|
|
155
|
+
await this.handleCompletion(newState);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Handle loop completion
|
|
160
|
+
*/
|
|
161
|
+
async handleCompletion(state) {
|
|
162
|
+
logger.info("Loop completed", {
|
|
163
|
+
iterations: state.iteration,
|
|
164
|
+
duration: state.lastUpdateTime - state.startTime
|
|
165
|
+
});
|
|
166
|
+
if (this.config.hooks.onComplete && this.hooks.onComplete) {
|
|
167
|
+
try {
|
|
168
|
+
await this.hooks.onComplete(state);
|
|
169
|
+
} catch (error) {
|
|
170
|
+
await this.handleError(error, { phase: "completion", state });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
await this.createFinalCheckpoint(state);
|
|
174
|
+
this.cleanupTimers();
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Create checkpoint
|
|
178
|
+
*/
|
|
179
|
+
async createCheckpoint(iteration) {
|
|
180
|
+
const checkpoint = {
|
|
181
|
+
id: this.generateCheckpointId(),
|
|
182
|
+
iteration: iteration.number,
|
|
183
|
+
timestamp: Date.now(),
|
|
184
|
+
state: await this.captureCurrentState(),
|
|
185
|
+
gitCommit: await this.getCurrentGitCommit(),
|
|
186
|
+
verified: false
|
|
187
|
+
};
|
|
188
|
+
checkpoint.verified = await this.verifyCheckpoint(checkpoint);
|
|
189
|
+
this.checkpoints.push(checkpoint);
|
|
190
|
+
logger.info("Checkpoint created", {
|
|
191
|
+
id: checkpoint.id,
|
|
192
|
+
iteration: checkpoint.iteration,
|
|
193
|
+
verified: checkpoint.verified
|
|
194
|
+
});
|
|
195
|
+
if (this.hooks.onCheckpoint) {
|
|
196
|
+
try {
|
|
197
|
+
await this.hooks.onCheckpoint(checkpoint);
|
|
198
|
+
} catch (error) {
|
|
199
|
+
logger.error("Checkpoint hook failed", { error: error.message });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
this.emitEvent({
|
|
203
|
+
type: "checkpoint.created",
|
|
204
|
+
timestamp: Date.now(),
|
|
205
|
+
iteration: iteration.number,
|
|
206
|
+
data: { checkpoint }
|
|
207
|
+
});
|
|
208
|
+
return checkpoint;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Get checkpoints
|
|
212
|
+
*/
|
|
213
|
+
getCheckpoints() {
|
|
214
|
+
return [...this.checkpoints];
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get last checkpoint
|
|
218
|
+
*/
|
|
219
|
+
getLastCheckpoint() {
|
|
220
|
+
return this.checkpoints[this.checkpoints.length - 1];
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Restore from checkpoint
|
|
224
|
+
*/
|
|
225
|
+
async restoreFromCheckpoint(checkpointId) {
|
|
226
|
+
const checkpoint = this.checkpoints.find((c) => c.id === checkpointId);
|
|
227
|
+
if (!checkpoint) {
|
|
228
|
+
throw new Error(`Checkpoint not found: ${checkpointId}`);
|
|
229
|
+
}
|
|
230
|
+
logger.info("Restoring from checkpoint", {
|
|
231
|
+
id: checkpoint.id,
|
|
232
|
+
iteration: checkpoint.iteration
|
|
233
|
+
});
|
|
234
|
+
if (checkpoint.gitCommit) {
|
|
235
|
+
await this.restoreGitState(checkpoint.gitCommit);
|
|
236
|
+
}
|
|
237
|
+
await this.restoreRalphState(checkpoint.state);
|
|
238
|
+
logger.info("Checkpoint restored successfully");
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Get iteration events
|
|
242
|
+
*/
|
|
243
|
+
getEvents(filter) {
|
|
244
|
+
let events = [...this.iterationHistory];
|
|
245
|
+
if (filter?.type) {
|
|
246
|
+
events = events.filter((e) => e.type === filter.type);
|
|
247
|
+
}
|
|
248
|
+
if (filter?.iteration !== void 0) {
|
|
249
|
+
events = events.filter((e) => e.iteration === filter.iteration);
|
|
250
|
+
}
|
|
251
|
+
if (filter?.since) {
|
|
252
|
+
events = events.filter((e) => e.timestamp >= filter.since);
|
|
253
|
+
}
|
|
254
|
+
return events;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Clean up resources
|
|
258
|
+
*/
|
|
259
|
+
cleanup() {
|
|
260
|
+
this.cleanupTimers();
|
|
261
|
+
this.removeAllListeners();
|
|
262
|
+
this.iterationHistory = [];
|
|
263
|
+
this.checkpoints = [];
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Setup internal event handlers
|
|
267
|
+
*/
|
|
268
|
+
setupEventHandlers() {
|
|
269
|
+
this.on("*", (event) => {
|
|
270
|
+
logger.debug("Lifecycle event", {
|
|
271
|
+
type: event.type,
|
|
272
|
+
iteration: event.iteration
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Emit and track event
|
|
278
|
+
*/
|
|
279
|
+
emitEvent(event) {
|
|
280
|
+
this.iterationHistory.push(event);
|
|
281
|
+
this.emit(event.type, event);
|
|
282
|
+
this.emit("*", event);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Should create checkpoint based on frequency
|
|
286
|
+
*/
|
|
287
|
+
shouldCreateCheckpoint(iteration) {
|
|
288
|
+
if (!this.config.checkpoints.enabled) {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
return iteration % this.config.checkpoints.frequency === 0;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Generate checkpoint ID
|
|
295
|
+
*/
|
|
296
|
+
generateCheckpointId() {
|
|
297
|
+
return `chk-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Capture current state
|
|
301
|
+
*/
|
|
302
|
+
async captureCurrentState() {
|
|
303
|
+
return {
|
|
304
|
+
loopId: "current",
|
|
305
|
+
task: "",
|
|
306
|
+
criteria: "",
|
|
307
|
+
iteration: this.currentIteration?.number || 0,
|
|
308
|
+
status: "running",
|
|
309
|
+
startTime: Date.now(),
|
|
310
|
+
lastUpdateTime: Date.now()
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Get current git commit
|
|
315
|
+
*/
|
|
316
|
+
async getCurrentGitCommit() {
|
|
317
|
+
try {
|
|
318
|
+
return execSync("git rev-parse HEAD", { encoding: "utf8" }).trim();
|
|
319
|
+
} catch {
|
|
320
|
+
return "";
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Verify checkpoint integrity
|
|
325
|
+
*/
|
|
326
|
+
async verifyCheckpoint(checkpoint) {
|
|
327
|
+
try {
|
|
328
|
+
if (!checkpoint.state.loopId || !checkpoint.state.task) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
if (checkpoint.gitCommit) {
|
|
332
|
+
execSync(`git rev-parse ${checkpoint.gitCommit}`, { encoding: "utf8" });
|
|
333
|
+
}
|
|
334
|
+
return true;
|
|
335
|
+
} catch {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Clean old checkpoints based on retention
|
|
341
|
+
*/
|
|
342
|
+
async cleanOldCheckpoints() {
|
|
343
|
+
const cutoff = Date.now() - this.config.checkpoints.retentionDays * 24 * 60 * 60 * 1e3;
|
|
344
|
+
const before = this.checkpoints.length;
|
|
345
|
+
this.checkpoints = this.checkpoints.filter((c) => c.timestamp >= cutoff);
|
|
346
|
+
const removed = before - this.checkpoints.length;
|
|
347
|
+
if (removed > 0) {
|
|
348
|
+
logger.debug("Cleaned old checkpoints", { removed });
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Create final checkpoint
|
|
353
|
+
*/
|
|
354
|
+
async createFinalCheckpoint(state) {
|
|
355
|
+
const checkpoint = {
|
|
356
|
+
id: `final-${this.generateCheckpointId()}`,
|
|
357
|
+
iteration: state.iteration,
|
|
358
|
+
timestamp: Date.now(),
|
|
359
|
+
state,
|
|
360
|
+
gitCommit: await this.getCurrentGitCommit(),
|
|
361
|
+
verified: true
|
|
362
|
+
};
|
|
363
|
+
this.checkpoints.push(checkpoint);
|
|
364
|
+
logger.info("Final checkpoint created", {
|
|
365
|
+
id: checkpoint.id,
|
|
366
|
+
iterations: state.iteration
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Restore git state
|
|
371
|
+
*/
|
|
372
|
+
async restoreGitState(commit) {
|
|
373
|
+
execSync("git stash", { encoding: "utf8" });
|
|
374
|
+
execSync(`git checkout ${commit}`, { encoding: "utf8" });
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Restore Ralph state
|
|
378
|
+
*/
|
|
379
|
+
async restoreRalphState(state) {
|
|
380
|
+
logger.debug("Ralph state restored", { iteration: state.iteration });
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Detect state changes
|
|
384
|
+
*/
|
|
385
|
+
detectStateChanges(oldState, newState) {
|
|
386
|
+
const changes = [];
|
|
387
|
+
for (const key of Object.keys(newState)) {
|
|
388
|
+
if (JSON.stringify(oldState[key]) !== JSON.stringify(newState[key])) {
|
|
389
|
+
changes.push(key);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return changes;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Handle errors
|
|
396
|
+
*/
|
|
397
|
+
async handleError(error, context) {
|
|
398
|
+
logger.error("Lifecycle error", {
|
|
399
|
+
error: error.message,
|
|
400
|
+
context
|
|
401
|
+
});
|
|
402
|
+
if (this.config.hooks.onError && this.hooks.onError) {
|
|
403
|
+
try {
|
|
404
|
+
await this.hooks.onError(error, context);
|
|
405
|
+
} catch (hookError) {
|
|
406
|
+
logger.error("Error hook failed", { error: hookError.message });
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Start timer for metrics
|
|
412
|
+
*/
|
|
413
|
+
startTimer(name) {
|
|
414
|
+
const start = Date.now();
|
|
415
|
+
this.activeTimers.set(name, setTimeout(() => {
|
|
416
|
+
this.activeTimers.delete(name);
|
|
417
|
+
}, 0));
|
|
418
|
+
this.activeTimers.get(name).startTime = start;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Stop timer and get duration
|
|
422
|
+
*/
|
|
423
|
+
stopTimer(name) {
|
|
424
|
+
const timer = this.activeTimers.get(name);
|
|
425
|
+
if (!timer) return 0;
|
|
426
|
+
const duration = Date.now() - timer.startTime;
|
|
427
|
+
clearTimeout(timer);
|
|
428
|
+
this.activeTimers.delete(name);
|
|
429
|
+
return duration;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Clean up all timers
|
|
433
|
+
*/
|
|
434
|
+
cleanupTimers() {
|
|
435
|
+
for (const timer of this.activeTimers.values()) {
|
|
436
|
+
clearTimeout(timer);
|
|
437
|
+
}
|
|
438
|
+
this.activeTimers.clear();
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
export {
|
|
442
|
+
IterationLifecycle
|
|
443
|
+
};
|
|
444
|
+
//# sourceMappingURL=iteration-lifecycle.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/integrations/ralph/lifecycle/iteration-lifecycle.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Iteration Lifecycle Manager for Ralph-StackMemory Integration\n * Provides lifecycle hooks and event management for clean integration points\n */\n\nimport { EventEmitter } from 'events';\nimport { execSync } from 'child_process';\nimport { logger } from '../../../core/monitoring/logger.js';\nimport {\n RalphLoopState,\n RalphIteration,\n IterationEvent,\n IterationEventType,\n RalphStackMemoryConfig,\n Checkpoint,\n IterationContext,\n} from '../types.js';\n\nexport interface LifecycleHooks {\n preIteration?: (context: IterationContext) => Promise<IterationContext>;\n postIteration?: (iteration: RalphIteration) => Promise<void>;\n onStateChange?: (oldState: RalphLoopState, newState: RalphLoopState) => Promise<void>;\n onError?: (error: Error, context: any) => Promise<void>;\n onComplete?: (state: RalphLoopState) => Promise<void>;\n onCheckpoint?: (checkpoint: Checkpoint) => Promise<void>;\n}\n\nexport class IterationLifecycle extends EventEmitter {\n private config: RalphStackMemoryConfig['lifecycle'];\n private hooks: LifecycleHooks = {};\n private checkpoints: Checkpoint[] = [];\n private currentIteration?: RalphIteration;\n private iterationHistory: IterationEvent[] = [];\n private activeTimers: Map<string, NodeJS.Timeout> = new Map();\n\n constructor(\n config?: Partial<RalphStackMemoryConfig['lifecycle']>,\n hooks?: LifecycleHooks\n ) {\n super();\n \n this.config = {\n hooks: {\n preIteration: config?.hooks?.preIteration ?? true,\n postIteration: config?.hooks?.postIteration ?? true,\n onStateChange: config?.hooks?.onStateChange ?? true,\n onError: config?.hooks?.onError ?? true,\n onComplete: config?.hooks?.onComplete ?? true,\n },\n checkpoints: {\n enabled: config?.checkpoints?.enabled ?? true,\n frequency: config?.checkpoints?.frequency || 5,\n retentionDays: config?.checkpoints?.retentionDays || 7,\n },\n };\n\n if (hooks) {\n this.registerHooks(hooks);\n }\n\n this.setupEventHandlers();\n }\n\n /**\n * Register lifecycle hooks\n */\n registerHooks(hooks: LifecycleHooks): void {\n this.hooks = { ...this.hooks, ...hooks };\n \n logger.debug('Lifecycle hooks registered', {\n registered: Object.keys(hooks),\n });\n }\n\n /**\n * Start iteration with lifecycle management\n */\n async startIteration(\n iterationNumber: number,\n context: IterationContext\n ): Promise<IterationContext> {\n logger.info('Starting iteration', { iteration: iterationNumber });\n\n // Emit start event\n this.emitEvent({\n type: 'iteration.started',\n timestamp: Date.now(),\n iteration: iterationNumber,\n data: { context },\n });\n\n // Execute pre-iteration hook if configured\n let processedContext = context;\n if (this.config.hooks.preIteration && this.hooks.preIteration) {\n try {\n processedContext = await this.hooks.preIteration(context);\n logger.debug('Pre-iteration hook executed', {\n original: context.tokenCount,\n processed: processedContext.tokenCount,\n });\n } catch (error: any) {\n await this.handleError(error, { phase: 'preIteration', context });\n }\n }\n\n // Start iteration timer for metrics\n this.startTimer(`iteration-${iterationNumber}`);\n\n return processedContext;\n }\n\n /**\n * Complete iteration with lifecycle management\n */\n async completeIteration(iteration: RalphIteration): Promise<void> {\n logger.info('Completing iteration', { iteration: iteration.number });\n\n this.currentIteration = iteration;\n\n // Stop iteration timer\n const duration = this.stopTimer(`iteration-${iteration.number}`);\n\n // Execute post-iteration hook if configured\n if (this.config.hooks.postIteration && this.hooks.postIteration) {\n try {\n await this.hooks.postIteration(iteration);\n logger.debug('Post-iteration hook executed');\n } catch (error: any) {\n await this.handleError(error, { phase: 'postIteration', iteration });\n }\n }\n\n // Create checkpoint if needed\n if (this.shouldCreateCheckpoint(iteration.number)) {\n await this.createCheckpoint(iteration);\n }\n\n // Emit completion event\n this.emitEvent({\n type: 'iteration.completed',\n timestamp: Date.now(),\n iteration: iteration.number,\n data: {\n iteration,\n duration,\n success: iteration.validation.testsPass,\n },\n });\n\n // Clean old checkpoints\n await this.cleanOldCheckpoints();\n }\n\n /**\n * Handle iteration failure\n */\n async failIteration(\n iterationNumber: number,\n error: Error,\n context?: any\n ): Promise<void> {\n logger.error('Iteration failed', {\n iteration: iterationNumber,\n error: error.message,\n });\n\n // Stop iteration timer\n this.stopTimer(`iteration-${iterationNumber}`);\n\n // Execute error hook if configured\n if (this.config.hooks.onError && this.hooks.onError) {\n try {\n await this.hooks.onError(error, context);\n } catch (hookError: any) {\n logger.error('Error hook failed', { error: hookError.message });\n }\n }\n\n // Emit failure event\n this.emitEvent({\n type: 'iteration.failed',\n timestamp: Date.now(),\n iteration: iterationNumber,\n data: {\n error: error.message,\n stack: error.stack,\n context,\n },\n });\n }\n\n /**\n * Handle state change\n */\n async handleStateChange(\n oldState: RalphLoopState,\n newState: RalphLoopState\n ): Promise<void> {\n logger.debug('State change detected', {\n old: oldState.status,\n new: newState.status,\n iteration: newState.iteration,\n });\n\n // Execute state change hook if configured\n if (this.config.hooks.onStateChange && this.hooks.onStateChange) {\n try {\n await this.hooks.onStateChange(oldState, newState);\n } catch (error: any) {\n await this.handleError(error, {\n phase: 'stateChange',\n oldState,\n newState,\n });\n }\n }\n\n // Emit state change event\n this.emitEvent({\n type: 'state.changed',\n timestamp: Date.now(),\n iteration: newState.iteration,\n data: {\n oldStatus: oldState.status,\n newStatus: newState.status,\n changes: this.detectStateChanges(oldState, newState),\n },\n });\n\n // Check for completion\n if (newState.status === 'completed' && oldState.status !== 'completed') {\n await this.handleCompletion(newState);\n }\n }\n\n /**\n * Handle loop completion\n */\n async handleCompletion(state: RalphLoopState): Promise<void> {\n logger.info('Loop completed', {\n iterations: state.iteration,\n duration: state.lastUpdateTime - state.startTime,\n });\n\n // Execute completion hook if configured\n if (this.config.hooks.onComplete && this.hooks.onComplete) {\n try {\n await this.hooks.onComplete(state);\n } catch (error: any) {\n await this.handleError(error, { phase: 'completion', state });\n }\n }\n\n // Create final checkpoint\n await this.createFinalCheckpoint(state);\n\n // Clean up timers\n this.cleanupTimers();\n }\n\n /**\n * Create checkpoint\n */\n async createCheckpoint(iteration: RalphIteration): Promise<Checkpoint> {\n const checkpoint: Checkpoint = {\n id: this.generateCheckpointId(),\n iteration: iteration.number,\n timestamp: Date.now(),\n state: await this.captureCurrentState(),\n gitCommit: await this.getCurrentGitCommit(),\n verified: false,\n };\n\n // Verify checkpoint\n checkpoint.verified = await this.verifyCheckpoint(checkpoint);\n\n this.checkpoints.push(checkpoint);\n\n logger.info('Checkpoint created', {\n id: checkpoint.id,\n iteration: checkpoint.iteration,\n verified: checkpoint.verified,\n });\n\n // Execute checkpoint hook if available\n if (this.hooks.onCheckpoint) {\n try {\n await this.hooks.onCheckpoint(checkpoint);\n } catch (error: any) {\n logger.error('Checkpoint hook failed', { error: error.message });\n }\n }\n\n // Emit checkpoint event\n this.emitEvent({\n type: 'checkpoint.created',\n timestamp: Date.now(),\n iteration: iteration.number,\n data: { checkpoint },\n });\n\n return checkpoint;\n }\n\n /**\n * Get checkpoints\n */\n getCheckpoints(): Checkpoint[] {\n return [...this.checkpoints];\n }\n\n /**\n * Get last checkpoint\n */\n getLastCheckpoint(): Checkpoint | undefined {\n return this.checkpoints[this.checkpoints.length - 1];\n }\n\n /**\n * Restore from checkpoint\n */\n async restoreFromCheckpoint(checkpointId: string): Promise<void> {\n const checkpoint = this.checkpoints.find(c => c.id === checkpointId);\n \n if (!checkpoint) {\n throw new Error(`Checkpoint not found: ${checkpointId}`);\n }\n\n logger.info('Restoring from checkpoint', {\n id: checkpoint.id,\n iteration: checkpoint.iteration,\n });\n\n // Restore git state\n if (checkpoint.gitCommit) {\n await this.restoreGitState(checkpoint.gitCommit);\n }\n\n // Restore Ralph state\n await this.restoreRalphState(checkpoint.state);\n\n logger.info('Checkpoint restored successfully');\n }\n\n /**\n * Get iteration events\n */\n getEvents(filter?: {\n type?: IterationEventType;\n iteration?: number;\n since?: number;\n }): IterationEvent[] {\n let events = [...this.iterationHistory];\n\n if (filter?.type) {\n events = events.filter(e => e.type === filter.type);\n }\n\n if (filter?.iteration !== undefined) {\n events = events.filter(e => e.iteration === filter.iteration);\n }\n\n if (filter?.since) {\n events = events.filter(e => e.timestamp >= filter.since);\n }\n\n return events;\n }\n\n /**\n * Clean up resources\n */\n cleanup(): void {\n this.cleanupTimers();\n this.removeAllListeners();\n this.iterationHistory = [];\n this.checkpoints = [];\n }\n\n /**\n * Setup internal event handlers\n */\n private setupEventHandlers(): void {\n // Log all events in debug mode\n this.on('*', (event: IterationEvent) => {\n logger.debug('Lifecycle event', {\n type: event.type,\n iteration: event.iteration,\n });\n });\n }\n\n /**\n * Emit and track event\n */\n private emitEvent(event: IterationEvent): void {\n this.iterationHistory.push(event);\n this.emit(event.type, event);\n this.emit('*', event); // Wildcard for all events\n }\n\n /**\n * Should create checkpoint based on frequency\n */\n private shouldCreateCheckpoint(iteration: number): boolean {\n if (!this.config.checkpoints.enabled) {\n return false;\n }\n\n return iteration % this.config.checkpoints.frequency === 0;\n }\n\n /**\n * Generate checkpoint ID\n */\n private generateCheckpointId(): string {\n return `chk-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;\n }\n\n /**\n * Capture current state\n */\n private async captureCurrentState(): Promise<RalphLoopState> {\n // This would capture the full Ralph loop state\n // Placeholder implementation\n return {\n loopId: 'current',\n task: '',\n criteria: '',\n iteration: this.currentIteration?.number || 0,\n status: 'running',\n startTime: Date.now(),\n lastUpdateTime: Date.now(),\n };\n }\n\n /**\n * Get current git commit\n */\n private async getCurrentGitCommit(): Promise<string> {\n try {\n // execSync already imported at top\n return execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim();\n } catch {\n return '';\n }\n }\n\n /**\n * Verify checkpoint integrity\n */\n private async verifyCheckpoint(checkpoint: Checkpoint): Promise<boolean> {\n try {\n // Verify state consistency\n if (!checkpoint.state.loopId || !checkpoint.state.task) {\n return false;\n }\n\n // Verify git commit exists\n if (checkpoint.gitCommit) {\n // execSync already imported at top\n execSync(`git rev-parse ${checkpoint.gitCommit}`, { encoding: 'utf8' });\n }\n\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Clean old checkpoints based on retention\n */\n private async cleanOldCheckpoints(): Promise<void> {\n const cutoff = Date.now() - this.config.checkpoints.retentionDays * 24 * 60 * 60 * 1000;\n \n const before = this.checkpoints.length;\n this.checkpoints = this.checkpoints.filter(c => c.timestamp >= cutoff);\n const removed = before - this.checkpoints.length;\n\n if (removed > 0) {\n logger.debug('Cleaned old checkpoints', { removed });\n }\n }\n\n /**\n * Create final checkpoint\n */\n private async createFinalCheckpoint(state: RalphLoopState): Promise<void> {\n const checkpoint: Checkpoint = {\n id: `final-${this.generateCheckpointId()}`,\n iteration: state.iteration,\n timestamp: Date.now(),\n state,\n gitCommit: await this.getCurrentGitCommit(),\n verified: true,\n };\n\n this.checkpoints.push(checkpoint);\n \n logger.info('Final checkpoint created', {\n id: checkpoint.id,\n iterations: state.iteration,\n });\n }\n\n /**\n * Restore git state\n */\n private async restoreGitState(commit: string): Promise<void> {\n // Stash any uncommitted changes\n execSync('git stash', { encoding: 'utf8' });\n \n // Checkout the commit\n execSync(`git checkout ${commit}`, { encoding: 'utf8' });\n }\n\n /**\n * Restore Ralph state\n */\n private async restoreRalphState(state: RalphLoopState): Promise<void> {\n // This would restore the Ralph loop state files\n // Placeholder implementation\n logger.debug('Ralph state restored', { iteration: state.iteration });\n }\n\n /**\n * Detect state changes\n */\n private detectStateChanges(\n oldState: RalphLoopState,\n newState: RalphLoopState\n ): string[] {\n const changes: string[] = [];\n\n for (const key of Object.keys(newState) as (keyof RalphLoopState)[]) {\n if (JSON.stringify(oldState[key]) !== JSON.stringify(newState[key])) {\n changes.push(key);\n }\n }\n\n return changes;\n }\n\n /**\n * Handle errors\n */\n private async handleError(error: Error, context: any): Promise<void> {\n logger.error('Lifecycle error', {\n error: error.message,\n context,\n });\n\n if (this.config.hooks.onError && this.hooks.onError) {\n try {\n await this.hooks.onError(error, context);\n } catch (hookError: any) {\n logger.error('Error hook failed', { error: hookError.message });\n }\n }\n }\n\n /**\n * Start timer for metrics\n */\n private startTimer(name: string): void {\n const start = Date.now();\n this.activeTimers.set(name, setTimeout(() => {\n this.activeTimers.delete(name);\n }, 0) as any);\n (this.activeTimers.get(name) as any).startTime = start;\n }\n\n /**\n * Stop timer and get duration\n */\n private stopTimer(name: string): number {\n const timer = this.activeTimers.get(name);\n if (!timer) return 0;\n\n const duration = Date.now() - (timer as any).startTime;\n clearTimeout(timer);\n this.activeTimers.delete(name);\n\n return duration;\n }\n\n /**\n * Clean up all timers\n */\n private cleanupTimers(): void {\n for (const timer of this.activeTimers.values()) {\n clearTimeout(timer);\n }\n this.activeTimers.clear();\n }\n}"],
|
|
5
|
+
"mappings": "AAKA,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAoBhB,MAAM,2BAA2B,aAAa;AAAA,EAC3C;AAAA,EACA,QAAwB,CAAC;AAAA,EACzB,cAA4B,CAAC;AAAA,EAC7B;AAAA,EACA,mBAAqC,CAAC;AAAA,EACtC,eAA4C,oBAAI,IAAI;AAAA,EAE5D,YACE,QACA,OACA;AACA,UAAM;AAEN,SAAK,SAAS;AAAA,MACZ,OAAO;AAAA,QACL,cAAc,QAAQ,OAAO,gBAAgB;AAAA,QAC7C,eAAe,QAAQ,OAAO,iBAAiB;AAAA,QAC/C,eAAe,QAAQ,OAAO,iBAAiB;AAAA,QAC/C,SAAS,QAAQ,OAAO,WAAW;AAAA,QACnC,YAAY,QAAQ,OAAO,cAAc;AAAA,MAC3C;AAAA,MACA,aAAa;AAAA,QACX,SAAS,QAAQ,aAAa,WAAW;AAAA,QACzC,WAAW,QAAQ,aAAa,aAAa;AAAA,QAC7C,eAAe,QAAQ,aAAa,iBAAiB;AAAA,MACvD;AAAA,IACF;AAEA,QAAI,OAAO;AACT,WAAK,cAAc,KAAK;AAAA,IAC1B;AAEA,SAAK,mBAAmB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKA,cAAc,OAA6B;AACzC,SAAK,QAAQ,EAAE,GAAG,KAAK,OAAO,GAAG,MAAM;AAEvC,WAAO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