principles-disciple 1.148.0 → 1.150.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 CHANGED
@@ -25,7 +25,6 @@ All commands support **short aliases** for easier input:
25
25
  | `/pdb` | `/pd-bootstrap` | Scan environment tools |
26
26
  | `/pdr` | `/pd-research` | Research tools and capabilities |
27
27
  | `/pdt` | `/pd-thinking` | Manage thinking models |
28
- | `/pdrl` | `/pd-reflect` | Manually trigger nocturnal reflection |
29
28
  | `/pdd` | `/pd-daily` | Configure and send daily report |
30
29
  | `/pdg` | `/pd-grooming` | Workspace cleanup |
31
30
  | `/pdh` | `/pd-help` | Show command reference |
@@ -39,9 +38,6 @@ All commands support **short aliases** for easier input:
39
38
  | `/pd-rollback` | Rollback to previous state |
40
39
  | `/pd-export` | Export trajectory/correction data |
41
40
  | `/pd-samples` | Review correction samples |
42
- | `/pd-nocturnal-review` | Review nocturnal training samples |
43
- | `/nocturnal-train` | Nocturnal training operations |
44
- | `/nocturnal-rollout` | Nocturnal rollout and promotion |
45
41
  | `/pd-workflow-debug` | Debug workflow state |
46
42
 
47
43
  ### Configuration
@@ -69,8 +69,6 @@ export class EventLog {
69
69
  recordPainSignal(sessionId, data) {
70
70
  this.record('pain_signal', 'detected', sessionId, data);
71
71
  }
72
- // recordRuleMatch removed (PRI-451 Wave 1): dead code. Its only effect was
73
- // incrementing stats.pain.rulesMatched (also dead, removed in Wave 1.5).
74
72
  recordRulePromotion(data) {
75
73
  this.record('rule_promotion', 'promoted', undefined, data);
76
74
  }
@@ -350,9 +348,6 @@ export class EventLog {
350
348
  stats.empathy.rollbackCount++;
351
349
  stats.empathy.rolledBackScore += data.originalScore || 0;
352
350
  }
353
- // rule_match handler removed (PRI-451 Wave 1.5): recordRuleMatch is gone
354
- // (Wave 1.1), so no rule_match events are emitted; stats.pain.rulesMatched
355
- // was its only consumer and is also removed.
356
351
  else if (entry.type === 'rule_promotion') {
357
352
  // stats.pain.candidatesPromoted removed (PRI-451 Wave 1.5): dead counter.
358
353
  stats.evolution.rulesPromoted++;
package/dist/index.d.ts CHANGED
@@ -45,6 +45,6 @@ declare const plugin: {
45
45
  description: string;
46
46
  register(api: OpenClawPluginApi): void;
47
47
  };
48
- export { PrincipleTreeLedgerAdapter } from './core/principle-tree-ledger-adapter.js';
48
+ export { PrincipleTreeLedgerAdapter } from '@principles/core/runtime-v2';
49
49
  export { loadFeatureFlagFromWorkspace, isRecord };
50
50
  export default plugin;
package/dist/index.js CHANGED
@@ -31,7 +31,6 @@ import { CorrectionObserverService } from './service/correction-observer-service
31
31
  import { InternalizationAutoConsumerService } from './service/internalization-auto-consumer-service.js';
32
32
  import { TrajectoryService } from './service/trajectory-service.js';
33
33
  import { PDTaskService } from './core/pd-task-service.js';
34
- import { CentralSyncService } from './service/central-sync-service.js';
35
34
  import { ensureWorkspaceTemplates } from './core/init.js';
36
35
  import { migrateDirectoryStructure } from './core/migration.js';
37
36
  import { migrateStaleWorkspaceGuidance } from './core/workspace-guidance-migrator.js';
@@ -408,9 +407,6 @@ const plugin = {
408
407
  const guardedPdTask = guardService('service:pd-task', PDTaskService, api.logger);
409
408
  if (guardedPdTask)
410
409
  api.registerService(guardedPdTask);
411
- const guardedCentralSync = guardService('service:central-sync', CentralSyncService, api.logger);
412
- if (guardedCentralSync)
413
- api.registerService(guardedCentralSync);
414
410
  const guardedAutoConsumer = guardService('service:internalization-auto-consumer', InternalizationAutoConsumerService, api.logger);
415
411
  if (guardedAutoConsumer)
416
412
  api.registerService(guardedAutoConsumer);
@@ -745,7 +741,10 @@ const plugin = {
745
741
  });
746
742
  }
747
743
  };
748
- export { PrincipleTreeLedgerAdapter } from './core/principle-tree-ledger-adapter.js';
744
+ // PrincipleTreeLedgerAdapter is exported from @principles/core/runtime-v2 (canonical,
745
+ // consolidated in PRI-459). The plugin-local duplicate was removed; re-export the core
746
+ // symbol so any external consumer importing from the plugin still resolves it.
747
+ export { PrincipleTreeLedgerAdapter } from '@principles/core/runtime-v2';
749
748
  /* istanbul ignore next — test exports for evolution worker gate */
750
749
  export { loadFeatureFlagFromWorkspace, isRecord };
751
750
  export default plugin;
@@ -16,7 +16,7 @@ function pushWarning(warnings, message) {
16
16
  }
17
17
  }
18
18
  /**
19
- * YAML-SSOT-03: resolve a dot-path (e.g. 'evolution.nocturnalDreamerCompleted') from dailyStats.
19
+ * YAML-SSOT-03: resolve a dot-path (e.g. 'evolution.rulehostEvaluated') from dailyStats.
20
20
  * Returns { count, resolvable } to distinguish "field not found / non-numeric" from "legitimate zero".
21
21
  */
22
22
  function resolveStatsField(stats, dotPath) {
@@ -1,2 +1,2 @@
1
- export type { EventType, EventCategory, EventLogEntry, ToolCallEventData, PainSignalEventData, RuleMatchEventData, RulePromotionEventData, HookExecutionEventData, GateBlockEventData, GateBypassEventData, PlanApprovalEventData, EvolutionTaskEventData, EmpathyRollbackEventData, HeartbeatDiagnosisEventData, DiagnosisTaskEventData, DiagnosticianReportEventData, PrincipleCandidateEventData, RuleEnforcedEventData, RuleHostEvaluatedEventData, RuleHostBlockedEventData, RuleHostRequireApprovalEventData, RuleHostAutoCorrectProposedEventData, RuleHostAutoCorrectAppliedEventData, RuntimeV2PromptActivationsInjectedEventData, RuleHostUnhealthyEventData, ToolCallStats, ErrorStats, EmpathyEventStats, GfiStats, EvolutionStats as EventEvolutionStats, HookStats, DailyStats, } from '@principles/core/runtime-v2';
1
+ export type { EventType, EventCategory, EventLogEntry, ToolCallEventData, PainSignalEventData, RulePromotionEventData, HookExecutionEventData, GateBlockEventData, GateBypassEventData, PlanApprovalEventData, EvolutionTaskEventData, EmpathyRollbackEventData, HeartbeatDiagnosisEventData, DiagnosisTaskEventData, DiagnosticianReportEventData, PrincipleCandidateEventData, RuleEnforcedEventData, RuleHostEvaluatedEventData, RuleHostBlockedEventData, RuleHostRequireApprovalEventData, RuleHostAutoCorrectProposedEventData, RuleHostAutoCorrectAppliedEventData, RuntimeV2PromptActivationsInjectedEventData, RuleHostUnhealthyEventData, ToolCallStats, ErrorStats, EmpathyEventStats, GfiStats, EvolutionStats as EventEvolutionStats, HookStats, DailyStats, } from '@principles/core/runtime-v2';
2
2
  export { createEmptyDailyStats, } from '@principles/core/runtime-v2';
@@ -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.148.0",
5
+ "version": "1.150.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.148.0",
3
+ "version": "1.150.0",
4
4
  "description": "Native OpenClaw plugin for Principles Disciple",
5
5
  "type": "module",
6
6
  "main": "./dist/bundle.js",
@@ -47,7 +47,6 @@
47
47
  "lint": "eslint \"src/**/*.ts\"",
48
48
  "bootstrap-rules": "node scripts/bootstrap-rules.mjs",
49
49
  "compile-principles": "node scripts/compile-principles.mjs",
50
- "validate-live-path": "tsx scripts/validate-live-path.ts",
51
50
  "sync-plugin": "node scripts/sync-plugin.mjs"
52
51
  },
53
52
  "devDependencies": {
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * Nocturnal Pipeline — End-to-End Acceptance Test
4
+ * PD Pipeline — End-to-End Acceptance Test
5
5
  *
6
- * Verifies that all components of the Nocturnal reflection pipeline
6
+ * Verifies that all components of the PD reflection pipeline
7
7
  * work correctly in a real environment (not unit tests).
8
8
  *
9
9
  * Usage:
@@ -71,7 +71,7 @@ function main() {
71
71
  process.exit(1);
72
72
  }
73
73
 
74
- console.log('\n🧪 Nocturnal Pipeline Acceptance Test');
74
+ console.log('\n🧪 PD Pipeline Acceptance Test');
75
75
  console.log('═'.repeat(55));
76
76
  console.log(`Workspace: ${workspaceDir}`);
77
77
  console.log(`Database: ${dbPath}\n`);
@@ -1,32 +0,0 @@
1
- import type { LedgerAdapter, LedgerPrincipleEntry } from '@principles/core/runtime-v2';
2
- /**
3
- * PrincipleTreeLedgerAdapter — bridges 11-field LedgerPrincipleEntry to 18+ field LedgerPrinciple.
4
- *
5
- * This adapter maintains an in-memory idempotency map. Create once and reuse
6
- * across calls within the same process lifetime. Do not create a new instance
7
- * per intake call.
8
- */
9
- export declare class PrincipleTreeLedgerAdapter implements LedgerAdapter {
10
- #private;
11
- constructor(opts: {
12
- stateDir: string;
13
- });
14
- /**
15
- * Write a probation entry to the ledger.
16
- *
17
- * Idempotency: if the same candidateId was already written, returns the
18
- * existing entry without writing again.
19
- *
20
- * @throws CandidateIntakeError with code LEDGER_WRITE_FAILED on write failure.
21
- */
22
- writeProbationEntry(entry: LedgerPrincipleEntry): LedgerPrincipleEntry;
23
- /**
24
- * Check if a ledger entry already exists for a given candidate.
25
- *
26
- * Queries both the in-memory Map (fast path for same-process repeat calls)
27
- * and the ledger file (for cross-process idempotency across CLI invocations).
28
- *
29
- * @returns The existing LedgerPrincipleEntry if found, null otherwise.
30
- */
31
- existsForCandidate(candidateId: string): LedgerPrincipleEntry | null;
32
- }
@@ -1,125 +0,0 @@
1
- import { CandidateIntakeError, INTAKE_ERROR_CODES } from '@principles/core/runtime-v2';
2
- import { addPrincipleToLedger, loadLedger } from './principle-tree-ledger.js';
3
- const VALID_EVALUABILITIES = ['deterministic', 'weak_heuristic', 'manual_only'];
4
- /**
5
- * PrincipleTreeLedgerAdapter — bridges 11-field LedgerPrincipleEntry to 18+ field LedgerPrinciple.
6
- *
7
- * This adapter maintains an in-memory idempotency map. Create once and reuse
8
- * across calls within the same process lifetime. Do not create a new instance
9
- * per intake call.
10
- */
11
- export class PrincipleTreeLedgerAdapter {
12
- #stateDir;
13
- #entryMap = new Map();
14
- constructor(opts) {
15
- this.#stateDir = opts.stateDir;
16
- }
17
- /**
18
- * Write a probation entry to the ledger.
19
- *
20
- * Idempotency: if the same candidateId was already written, returns the
21
- * existing entry without writing again.
22
- *
23
- * @throws CandidateIntakeError with code LEDGER_WRITE_FAILED on write failure.
24
- */
25
- writeProbationEntry(entry) {
26
- const candidateId = this.#extractCandidateId(entry.sourceRef);
27
- const existing = this.#entryMap.get(candidateId);
28
- if (existing)
29
- return existing;
30
- const ledgerPrinciple = this.#expandToLedgerPrinciple(entry, candidateId);
31
- try {
32
- addPrincipleToLedger(this.#stateDir, ledgerPrinciple);
33
- }
34
- catch (err) {
35
- throw new CandidateIntakeError(INTAKE_ERROR_CODES.LEDGER_WRITE_FAILED, `Failed to write principle ${entry.id} to ledger: ${String(err)}`, { cause: err });
36
- }
37
- this.#entryMap.set(candidateId, entry);
38
- return entry;
39
- }
40
- /**
41
- * Check if a ledger entry already exists for a given candidate.
42
- *
43
- * Queries both the in-memory Map (fast path for same-process repeat calls)
44
- * and the ledger file (for cross-process idempotency across CLI invocations).
45
- *
46
- * @returns The existing LedgerPrincipleEntry if found, null otherwise.
47
- */
48
- existsForCandidate(candidateId) {
49
- // Fast path: check in-memory Map (covers same-process repeat calls)
50
- const cached = this.#entryMap.get(candidateId);
51
- if (cached)
52
- return cached;
53
- // Cross-process path: check ledger file by derivedFromPainIds
54
- const ledger = loadLedger(this.#stateDir);
55
- const found = Object.values(ledger.tree.principles).find((p) => p.derivedFromPainIds.includes(candidateId));
56
- if (!found)
57
- return null;
58
- // Reconstruct LedgerPrincipleEntry from LedgerPrinciple fields
59
- // Note: sourceRef, artifactRef, taskRef are not stored in LedgerPrinciple,
60
- // so we cannot fully reconstruct the original LedgerPrincipleEntry.
61
- // Return minimal entry sufficient for idempotency signaling.
62
- return {
63
- id: found.id,
64
- title: '',
65
- status: 'probation',
66
- sourceRef: `candidate://${candidateId}`,
67
- artifactRef: '',
68
- taskRef: '',
69
- text: found.text,
70
- triggerPattern: found.triggerPattern,
71
- action: found.action,
72
- evaluability: 'weak_heuristic',
73
- createdAt: found.createdAt,
74
- };
75
- }
76
- /**
77
- * Extract candidateId from sourceRef by stripping the 'candidate://' prefix.
78
- *
79
- * @internal
80
- */
81
- #extractCandidateId(sourceRef) {
82
- if (sourceRef.startsWith('candidate://')) {
83
- return sourceRef.slice('candidate://'.length);
84
- }
85
- return sourceRef;
86
- }
87
- /**
88
- * Expand an 11-field LedgerPrincipleEntry to an 18+ field LedgerPrinciple.
89
- *
90
- * Applies the field expansion table from CONTEXT.md:
91
- * - status: 'probation' → 'candidate'
92
- * - triggerPattern/action: pass through (empty string if absent)
93
- * - All defaults applied per CONTEXT.md expansion table
94
- * - sourceRef/artifactRef/taskRef are NOT written to LedgerPrinciple (not stored)
95
- * - title is NOT written to LedgerPrinciple — intentionally excluded; title
96
- * is available in LedgerPrincipleEntry but LedgerPrinciple has no title field
97
- *
98
- * @internal
99
- */
100
- #expandToLedgerPrinciple(entry, candidateId) {
101
- if (!VALID_EVALUABILITIES.includes(entry.evaluability)) {
102
- throw new CandidateIntakeError(INTAKE_ERROR_CODES.INPUT_INVALID, `Invalid evaluability value: ${entry.evaluability}. Must be one of: ${VALID_EVALUABILITIES.join(', ')}`);
103
- }
104
- const result = {
105
- id: entry.id,
106
- version: 1,
107
- text: entry.text,
108
- triggerPattern: entry.triggerPattern ?? '',
109
- action: entry.action ?? '',
110
- status: 'candidate',
111
- evaluability: entry.evaluability,
112
- priority: 'P1',
113
- scope: 'general',
114
- valueScore: 0,
115
- adherenceRate: 0,
116
- painPreventedCount: 0,
117
- derivedFromPainIds: [candidateId],
118
- ruleIds: [],
119
- conflictsWithPrincipleIds: [],
120
- createdAt: entry.createdAt,
121
- updatedAt: entry.createdAt,
122
- };
123
- return result;
124
- }
125
- }
@@ -1,138 +0,0 @@
1
- export interface WorkspaceInfo {
2
- name: string;
3
- path: string;
4
- lastSync: string | null;
5
- }
6
- /**
7
- * Central database that aggregates data from all agent workspaces.
8
- * Stored in ~/.openclaw/.central/ (NOT in memory/ which is for embeddings)
9
- */
10
- export declare class CentralDatabase {
11
- private readonly dbPath;
12
- private readonly db;
13
- private readonly workspaces;
14
- private _closed;
15
- /** Whether this connection has been closed. Used by the singleton to auto-reopen. */
16
- get isClosed(): boolean;
17
- constructor(dbPath?: string);
18
- dispose(): void;
19
- private static tableExists;
20
- private initSchema;
21
- private discoverWorkspaces;
22
- /**
23
- * Sync data from a single workspace into the central database
24
- */
25
- syncWorkspace(workspaceName: string): number;
26
- syncEnabled(): Map<string, number>;
27
- /**
28
- * Sync all workspaces (legacy method - syncs all regardless of config)
29
- */
30
- syncAll(): Map<string, number>;
31
- private getEnabledWorkspaceFilter;
32
- /**
33
- * Get aggregated overview stats (only from enabled workspaces)
34
- */
35
- getOverviewStats(): {
36
- totalSessions: number;
37
- totalToolCalls: number;
38
- totalFailures: number;
39
- totalPainEvents: number;
40
- totalCorrections: number;
41
- totalThinkingEvents: number;
42
- totalSamples: number;
43
- pendingSamples: number;
44
- approvedSamples: number;
45
- rejectedSamples: number;
46
- workspaceCount: number;
47
- enabledWorkspaceCount: number;
48
- workspaceNames: string[];
49
- enabledWorkspaceNames: string[];
50
- };
51
- /**
52
- * Get daily trend data
53
- */
54
- getDailyTrend(days?: number): {
55
- day: string;
56
- toolCalls: number;
57
- failures: number;
58
- userCorrections: number;
59
- thinkingTurns: number;
60
- }[];
61
- /**
62
- * Get top regressions
63
- */
64
- getTopRegressions(limit?: number): {
65
- toolName: string;
66
- errorType: string;
67
- occurrences: number;
68
- }[];
69
- /**
70
- * Get thinking model stats
71
- */
72
- getThinkingModelStats(): {
73
- totalModels: number;
74
- activeModels: number;
75
- models: {
76
- modelId: string;
77
- hits: number;
78
- coverageRate: number;
79
- }[];
80
- };
81
- /**
82
- * Get workspace list
83
- */
84
- getWorkspaces(): WorkspaceInfo[];
85
- getWorkspaceConfigs(): {
86
- workspaceName: string;
87
- enabled: boolean;
88
- displayName: string | null;
89
- syncEnabled: boolean;
90
- }[];
91
- updateWorkspaceConfig(workspaceName: string, updates: {
92
- enabled?: boolean;
93
- displayName?: string | null;
94
- syncEnabled?: boolean;
95
- }): void;
96
- isWorkspaceEnabled(workspaceName: string): boolean;
97
- getEnabledWorkspaces(): WorkspaceInfo[];
98
- addCustomWorkspace(name: string, workspacePath: string): void;
99
- removeWorkspace(workspaceName: string): void;
100
- getGlobalConfig(key: string): string | null;
101
- setGlobalConfig(key: string, value: string): void;
102
- /**
103
- * Clear all aggregated data (for testing/reset)
104
- */
105
- clearAll(): void;
106
- /**
107
- * Get total task outcomes count across enabled workspaces (D-02)
108
- */
109
- getTaskOutcomes(): number;
110
- /**
111
- * Get total principle events count across enabled workspaces (D-03)
112
- */
113
- getPrincipleEventCount(): number;
114
- /**
115
- * Get sample counts grouped by review_status across enabled workspaces (D-06)
116
- */
117
- getSampleCountersByStatus(): Record<string, number>;
118
- /**
119
- * Get top N most recent pending/approved samples across all enabled workspaces (D-04)
120
- */
121
- getSamplePreview(limit?: number): {
122
- sampleId: string;
123
- sessionId: string;
124
- workspace: string;
125
- qualityScore: number;
126
- reviewStatus: string;
127
- createdAt: string;
128
- }[];
129
- /**
130
- * Get the most recent lastSync timestamp across all workspaces (D-05)
131
- */
132
- getMostRecentSync(): string | null;
133
- }
134
- export declare function getCentralDatabase(): CentralDatabase;
135
- /**
136
- * Reset the singleton instance. Used for testing.
137
- */
138
- export declare function resetCentralDatabase(): void;