principles-disciple 1.115.0 → 1.115.1
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/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/core/trajectory.ts +28 -1
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "principles-disciple",
|
|
3
3
|
"name": "Principles Disciple",
|
|
4
4
|
"description": "Evolutionary programming agent framework with strategic guardrails and reflection loops.",
|
|
5
|
-
"version": "1.115.
|
|
5
|
+
"version": "1.115.1",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onCapabilities": [
|
|
8
8
|
"hook"
|
package/package.json
CHANGED
package/src/core/trajectory.ts
CHANGED
|
@@ -241,6 +241,10 @@ export class TrajectoryDatabase {
|
|
|
241
241
|
this.recordSession({ sessionId: input.sessionId, startedAt: input.createdAt });
|
|
242
242
|
let insertedId = -1;
|
|
243
243
|
this.withWrite(() => {
|
|
244
|
+
// Try INSERT; on UNIQUE constraint violation for canonical_pain_id, do UPDATE instead.
|
|
245
|
+
// SQLite UPSERT (ON CONFLICT) does not support partial unique indexes, so we
|
|
246
|
+
// handle the conflict manually.
|
|
247
|
+
try {
|
|
244
248
|
const runResult = this.db.prepare(`
|
|
245
249
|
INSERT INTO pain_events (
|
|
246
250
|
session_id, source, score, reason, severity, origin, confidence, text, created_at,
|
|
@@ -259,7 +263,30 @@ export class TrajectoryDatabase {
|
|
|
259
263
|
input.canonicalPainId ?? null,
|
|
260
264
|
input.runtimeTaskId ?? null,
|
|
261
265
|
);
|
|
262
|
-
insertedId = runResult.lastInsertRowid
|
|
266
|
+
insertedId = Number(runResult.lastInsertRowid);
|
|
267
|
+
} catch (insertErr: unknown) {
|
|
268
|
+
if (
|
|
269
|
+
input.canonicalPainId &&
|
|
270
|
+
insertErr instanceof Error &&
|
|
271
|
+
insertErr.message.includes('UNIQUE constraint failed') &&
|
|
272
|
+
insertErr.message.includes('canonical_pain_id')
|
|
273
|
+
) {
|
|
274
|
+
this.db.prepare(`
|
|
275
|
+
UPDATE pain_events
|
|
276
|
+
SET runtime_task_id = COALESCE(?, runtime_task_id)
|
|
277
|
+
WHERE canonical_pain_id = ?
|
|
278
|
+
`).run(input.runtimeTaskId ?? null, input.canonicalPainId);
|
|
279
|
+
const rawRow = this.db.prepare('SELECT id FROM pain_events WHERE canonical_pain_id = ?').get(input.canonicalPainId);
|
|
280
|
+
// Runtime Contract #1/#2: validate DB row instead of `as` cast
|
|
281
|
+
if (rawRow && typeof rawRow === 'object' && Object.hasOwn(rawRow, 'id') && typeof (rawRow as Record<string, unknown>).id === 'number') {
|
|
282
|
+
insertedId = (rawRow as { id: number }).id;
|
|
283
|
+
} else {
|
|
284
|
+
insertedId = -1;
|
|
285
|
+
}
|
|
286
|
+
} else {
|
|
287
|
+
throw insertErr;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
263
290
|
});
|
|
264
291
|
// FTS indexing is best-effort — run outside the transaction so it cannot
|
|
265
292
|
// roll back the committed pain event row (MEM-03, MEM-04).
|