principles-disciple 1.115.0 → 1.116.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.
@@ -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.0",
5
+ "version": "1.116.0",
6
6
  "activation": {
7
7
  "onCapabilities": [
8
8
  "hook"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "principles-disciple",
3
- "version": "1.115.0",
3
+ "version": "1.116.0",
4
4
  "description": "Native OpenClaw plugin for Principles Disciple",
5
5
  "type": "module",
6
6
  "main": "./dist/bundle.js",
@@ -94,17 +94,6 @@ export const EVENT_LOG_FLUSH_INTERVAL_MS = 30 * MS_PER_SECOND;
94
94
  /** Default busy timeout for SQLite operations (5 seconds) */
95
95
  export const DEFAULT_BUSY_TIMEOUT_MS = 5 * MS_PER_SECOND;
96
96
 
97
- // ── Nocturnal Runtime Settings ─────────────────────────────────────────────────
98
-
99
- /** Idle threshold (30 minutes) */
100
- export const DEFAULT_IDLE_THRESHOLD_MS = 30 * ONE_MINUTE_MS;
101
-
102
- /** Quota window (24 hours) */
103
- export const DEFAULT_QUOTA_WINDOW_MS = ONE_DAY_MS;
104
-
105
- /** Cool down period (30 minutes) */
106
- export const DEFAULT_COOLDOWN_MS = 30 * ONE_MINUTE_MS;
107
-
108
97
  // ── String & Size Limits ────────────────────────────────────────────────────────
109
98
 
110
99
  /** Max string length for trajectory/event logs */
package/src/core/paths.ts CHANGED
@@ -30,9 +30,6 @@ export const PD_DIRS = {
30
30
  SESSIONS: posixJoin('.state', 'sessions'),
31
31
  PAIN_SAMPLES: posixJoin('memory', 'pain'),
32
32
  LOCKS: posixJoin('memory', '.locks'),
33
- NOCTURNAL_SAMPLES: posixJoin('.state', 'nocturnal', 'samples'),
34
- NOCTURNAL_MEMORY: posixJoin('.state', 'nocturnal', 'memory'),
35
- NOCTURNAL_EXPORTS: posixJoin('.state', 'exports', 'orpo'),
36
33
  IMPL_CODE_DIR: posixJoin('.state', 'principles', 'implementations'),
37
34
  };
38
35
 
@@ -63,9 +60,6 @@ export const PD_FILES = {
63
60
  DICTIONARY: posixJoin(PD_DIRS.STATE, 'pain_dictionary.json'),
64
61
  PRINCIPLE_BLACKLIST: posixJoin(PD_DIRS.STATE, 'principle_blacklist.json'),
65
62
  WORKFLOWS_YAML: posixJoin(PD_DIRS.STATE, 'workflows.yaml'),
66
- NOCTURNAL_SAMPLES_DIR: PD_DIRS.NOCTURNAL_SAMPLES,
67
- NOCTURNAL_MEMORY_DIR: PD_DIRS.NOCTURNAL_MEMORY,
68
- NOCTURNAL_EXPORTS_DIR: PD_DIRS.NOCTURNAL_EXPORTS,
69
63
  IMPL_CODE_DIR: PD_DIRS.IMPL_CODE_DIR,
70
64
 
71
65
  MEMORY_MD: 'MEMORY.md',
@@ -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 as number;
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).
package/run-nocturnal.mjs DELETED
@@ -1,30 +0,0 @@
1
- import { randomUUID } from 'crypto';
2
- import * as fs from 'fs';
3
-
4
- const workspaceDir = '/home/csuzngjh/.openclaw/workspace-main';
5
- const stateDir = '/home/csuzngjh/.openclaw/workspace-main/.state';
6
-
7
- console.error('WorkspaceDir:', workspaceDir);
8
- console.error('StateDir:', stateDir);
9
-
10
- try {
11
- const bundlePath = './dist/nocturnal-service.bundle.js';
12
- console.error('Importing from:', bundlePath);
13
-
14
- const mod = await import(bundlePath);
15
-
16
- console.log('Available exports:', Object.keys(mod));
17
-
18
- if (!mod.executeNocturnalReflection) {
19
- throw new Error('executeNocturnalReflection not found in bundle. Available exports: ' + Object.keys(mod).join(', '));
20
- }
21
-
22
- console.error('Calling executeNocturnalReflection...');
23
- const result = await mod.executeNocturnalReflection(workspaceDir, stateDir);
24
-
25
- console.log(JSON.stringify(result, null, 2));
26
- } catch (err) {
27
- console.error('ERROR:', err.message);
28
- if (err.stack) console.error(err.stack);
29
- process.exit(1);
30
- }
@@ -1 +0,0 @@
1
- export {};