principles-disciple 1.184.0 → 1.186.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/dist/core/rule-host.js +1 -1
- package/dist/service/evolution-dedup.d.ts +1 -1
- package/dist/service/evolution-worker.d.ts +6 -30
- package/dist/service/evolution-worker.js +5 -6
- package/dist/service/queue-migration.d.ts +2 -26
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/service/evolution-queue-migration.d.ts +0 -128
- package/dist/service/evolution-queue-migration.js +0 -53
package/dist/core/rule-host.js
CHANGED
|
@@ -161,7 +161,7 @@ export class RuleHost {
|
|
|
161
161
|
try {
|
|
162
162
|
const { loaded, skipped } = this._loadFromActivationsTable(this.workspaceDir, supportsContextV2);
|
|
163
163
|
if (loaded.length === 0) {
|
|
164
|
-
this._emitEmptyLoadWarn('armed but empty — 0 active code_tool_hook activations loaded (RuleHost will not block or require approval)', 'If this is unexpected, run `pd
|
|
164
|
+
this._emitEmptyLoadWarn('armed but empty — 0 active code_tool_hook activations loaded (RuleHost will not block or require approval)', 'If this is unexpected, run `pd activation list --channel code_tool_hook` to inspect activations, or `pd activation promote --activation-id <id> --confirm` to enable a live rule');
|
|
165
165
|
}
|
|
166
166
|
return { loaded, skipped };
|
|
167
167
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Dedup logic for preventing duplicate pain tasks and redundant reflections.
|
|
5
5
|
* Extracted from evolution-worker.ts.
|
|
6
6
|
*/
|
|
7
|
-
import type { EvolutionQueueItem } from '
|
|
7
|
+
import type { EvolutionQueueItem } from '../core/evolution-types.js';
|
|
8
8
|
/**
|
|
9
9
|
* Dedup window for pain queue tasks (30 minutes).
|
|
10
10
|
*/
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { OpenClawPluginServiceContext, OpenClawPluginApi, PluginLogger } from '../openclaw-sdk.js';
|
|
2
2
|
import { WorkspaceContext } from '../core/workspace-context.js';
|
|
3
|
-
import type { TaskKind, TaskPriority } from '../core/trajectory-types.js';
|
|
4
3
|
export type { TaskKind, TaskPriority } from '../core/trajectory-types.js';
|
|
5
4
|
export { loadEvolutionQueue, saveEvolutionQueue, withQueueLock, acquireQueueLock, requireQueueLock } from './queue-io.js';
|
|
6
5
|
export { EVOLUTION_QUEUE_LOCK_SUFFIX, LOCK_MAX_RETRIES, LOCK_RETRY_DELAY_MS, LOCK_STALE_MS } from './queue-io.js';
|
|
@@ -24,36 +23,13 @@ export type { WatchdogResult };
|
|
|
24
23
|
* Pain diagnosis is Runtime v2 only: after_tool_call / pd pain record ->
|
|
25
24
|
* PainSignalBridge -> SplitDiagnosticianRunner. EvolutionWorker does not read
|
|
26
25
|
* .pain_flag or process pain_diagnosis queue items.
|
|
26
|
+
*
|
|
27
|
+
* Types (QueueStatus / TaskResolution / EvolutionQueueItem) are re-exported
|
|
28
|
+
* from queue-migration.ts, which sources them from evolution-types.ts
|
|
29
|
+
* (canonical single source of truth).
|
|
27
30
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export type TaskResolution = 'marker_detected' | 'auto_completed_timeout' | 'failed_max_retries' | 'runtime_unavailable' | 'canceled' | 'late_marker_principle_created' | 'late_marker_no_principle' | 'stub_fallback' | 'skipped_thin_violation' | 'noise_classified' | 'retired';
|
|
31
|
-
export interface EvolutionQueueItem {
|
|
32
|
-
id: string;
|
|
33
|
-
taskKind: TaskKind;
|
|
34
|
-
priority: TaskPriority;
|
|
35
|
-
source: string;
|
|
36
|
-
traceId?: string;
|
|
37
|
-
task?: string;
|
|
38
|
-
score: number;
|
|
39
|
-
reason: string;
|
|
40
|
-
timestamp: string;
|
|
41
|
-
enqueued_at?: string;
|
|
42
|
-
started_at?: string;
|
|
43
|
-
completed_at?: string;
|
|
44
|
-
assigned_session_key?: string;
|
|
45
|
-
trigger_text_preview?: string;
|
|
46
|
-
status: QueueStatus;
|
|
47
|
-
resolution?: TaskResolution;
|
|
48
|
-
session_id?: string;
|
|
49
|
-
agent_id?: string;
|
|
50
|
-
retryCount: number;
|
|
51
|
-
maxRetries: number;
|
|
52
|
-
lastError?: string;
|
|
53
|
-
resultRef?: string;
|
|
54
|
-
painEventId?: number;
|
|
55
|
-
}
|
|
56
|
-
import { migrateToV2, isLegacyQueueItem, migrateQueueToV2, LegacyEvolutionQueueItem, DEFAULT_TASK_KIND, DEFAULT_PRIORITY, DEFAULT_MAX_RETRIES, validateQueueItem, VALID_TASK_KINDS, isValidQueueItem, type RawQueueItem } from './queue-migration.js';
|
|
31
|
+
export type { QueueStatus, TaskResolution, EvolutionQueueItem } from './queue-migration.js';
|
|
32
|
+
import { migrateToV2, isLegacyQueueItem, migrateQueueToV2, LegacyEvolutionQueueItem, DEFAULT_TASK_KIND, DEFAULT_PRIORITY, DEFAULT_MAX_RETRIES, validateQueueItem, VALID_TASK_KINDS, isValidQueueItem, type RawQueueItem, type EvolutionQueueItem } from './queue-migration.js';
|
|
57
33
|
export { migrateToV2, isLegacyQueueItem, migrateQueueToV2, LegacyEvolutionQueueItem, DEFAULT_TASK_KIND, DEFAULT_PRIORITY, DEFAULT_MAX_RETRIES, validateQueueItem, VALID_TASK_KINDS, isValidQueueItem };
|
|
58
34
|
export type { RawQueueItem };
|
|
59
35
|
export declare function extractEvolutionTaskId(task: string): string | null;
|
|
@@ -347,11 +347,6 @@ export async function registerEvolutionTaskSession(workspaceResolve, taskId, ses
|
|
|
347
347
|
// Previously this inlined JSON.parse + migrate cast without validating,
|
|
348
348
|
// so malformed queue items could reach the find() below. Reusing the
|
|
349
349
|
// shared loader keeps a single chokepoint for queue validation.
|
|
350
|
-
// Note: loadEvolutionQueue returns core/evolution-types.EvolutionQueueItem,
|
|
351
|
-
// which saveEvolutionQueue also accepts. We deliberately avoid annotating
|
|
352
|
-
// with the local EvolutionQueueItem interface (line 87) to prevent the
|
|
353
|
-
// known type-drift between the two definitions (see follow-up: unify the
|
|
354
|
-
// three EvolutionQueueItem copies).
|
|
355
350
|
const queue = loadEvolutionQueue(queuePath);
|
|
356
351
|
const task = queue.find((item) => item.id === taskId && item.status === 'in_progress');
|
|
357
352
|
if (!task) {
|
|
@@ -388,7 +383,11 @@ async function processEvolutionQueueWithResult(wctx, logger, eventLog, api) {
|
|
|
388
383
|
if (!fs.existsSync(queuePath)) {
|
|
389
384
|
return { queue: queueResult, errors };
|
|
390
385
|
}
|
|
391
|
-
|
|
386
|
+
// rc-1/rc-2/rc-4 (ERR-001/ERR-005/ERR-007): use the canonical loader
|
|
387
|
+
// instead of raw JSON.parse + cast. loadEvolutionQueue handles parse,
|
|
388
|
+
// migrate, and element-wise validation; malformed items are dropped
|
|
389
|
+
// with a console.warn (rc-9: no silent fallback).
|
|
390
|
+
const queue = loadEvolutionQueue(queuePath);
|
|
392
391
|
// Purge stale failed tasks before processing (keeps queue lean)
|
|
393
392
|
const purgeResult = purgeStaleFailedTasks(queue, logger);
|
|
394
393
|
if (purgeResult.purged > 0) {
|
|
@@ -5,32 +5,8 @@
|
|
|
5
5
|
* to the V2 schema. Zero I/O, zero imports from evolution-worker.ts.
|
|
6
6
|
*/
|
|
7
7
|
import type { TaskKind, TaskPriority } from '../core/trajectory-types.js';
|
|
8
|
-
|
|
9
|
-
export type
|
|
10
|
-
export interface EvolutionQueueItem {
|
|
11
|
-
id: string;
|
|
12
|
-
taskKind: TaskKind;
|
|
13
|
-
priority: TaskPriority;
|
|
14
|
-
source: string;
|
|
15
|
-
traceId?: string;
|
|
16
|
-
task?: string;
|
|
17
|
-
score: number;
|
|
18
|
-
reason: string;
|
|
19
|
-
timestamp: string;
|
|
20
|
-
enqueued_at?: string;
|
|
21
|
-
started_at?: string;
|
|
22
|
-
completed_at?: string;
|
|
23
|
-
assigned_session_key?: string;
|
|
24
|
-
trigger_text_preview?: string;
|
|
25
|
-
status: QueueStatus;
|
|
26
|
-
resolution?: TaskResolution;
|
|
27
|
-
session_id?: string;
|
|
28
|
-
agent_id?: string;
|
|
29
|
-
retryCount: number;
|
|
30
|
-
maxRetries: number;
|
|
31
|
-
lastError?: string;
|
|
32
|
-
resultRef?: string;
|
|
33
|
-
}
|
|
8
|
+
import type { EvolutionQueueItem } from '../core/evolution-types.js';
|
|
9
|
+
export type { QueueStatus, TaskResolution, EvolutionQueueItem } from '../core/evolution-types.js';
|
|
34
10
|
/**
|
|
35
11
|
* Legacy queue item shape (pre-V2) for migration compatibility.
|
|
36
12
|
* These items lack taskKind, priority, retryCount, maxRetries, lastError fields.
|
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.
|
|
5
|
+
"version": "1.186.0",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onCapabilities": [
|
|
8
8
|
"hook"
|
package/package.json
CHANGED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Evolution Queue Migration — V1 to V2 Schema
|
|
3
|
-
*
|
|
4
|
-
* Pure transformation functions and shared queue types.
|
|
5
|
-
*/
|
|
6
|
-
import type { TaskKind, TaskPriority } from '../core/trajectory-types.js';
|
|
7
|
-
export type { TaskKind, TaskPriority } from '../core/trajectory-types.js';
|
|
8
|
-
/**
|
|
9
|
-
* Queue item status values.
|
|
10
|
-
*/
|
|
11
|
-
export type QueueStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'canceled';
|
|
12
|
-
/**
|
|
13
|
-
* Task resolution strings.
|
|
14
|
-
*/
|
|
15
|
-
export type TaskResolution = 'marker_detected' | 'auto_completed_timeout' | 'failed_max_retries' | 'runtime_unavailable' | 'canceled' | 'late_marker_principle_created' | 'late_marker_no_principle' | 'stub_fallback' | 'skipped_thin_violation' | 'noise_classified' | 'retired';
|
|
16
|
-
/**
|
|
17
|
-
* Recent pain context for sleep_reflection tasks.
|
|
18
|
-
* Attached to queue items to provide pain signal context.
|
|
19
|
-
*/
|
|
20
|
-
export interface RecentPainContext {
|
|
21
|
-
mostRecent: {
|
|
22
|
-
score: number;
|
|
23
|
-
source: string;
|
|
24
|
-
reason: string;
|
|
25
|
-
timestamp: string;
|
|
26
|
-
sessionId: string;
|
|
27
|
-
} | null;
|
|
28
|
-
recentPainCount: number;
|
|
29
|
-
recentMaxPainScore: number;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Default values for new V2 fields when migrating legacy items.
|
|
33
|
-
*/
|
|
34
|
-
export declare const DEFAULT_TASK_KIND: TaskKind;
|
|
35
|
-
export declare const DEFAULT_PRIORITY: TaskPriority;
|
|
36
|
-
export declare const DEFAULT_MAX_RETRIES = 3;
|
|
37
|
-
/**
|
|
38
|
-
* Legacy (pre-V2) queue item schema.
|
|
39
|
-
*/
|
|
40
|
-
export interface LegacyEvolutionQueueItem {
|
|
41
|
-
id: string;
|
|
42
|
-
source: string;
|
|
43
|
-
traceId?: string;
|
|
44
|
-
task?: string;
|
|
45
|
-
score: number;
|
|
46
|
-
reason: string;
|
|
47
|
-
timestamp: string;
|
|
48
|
-
enqueued_at?: string;
|
|
49
|
-
started_at?: string;
|
|
50
|
-
completed_at?: string;
|
|
51
|
-
assigned_session_key?: string;
|
|
52
|
-
trigger_text_preview?: string;
|
|
53
|
-
status?: string;
|
|
54
|
-
resolution?: string;
|
|
55
|
-
session_id?: string;
|
|
56
|
-
agent_id?: string;
|
|
57
|
-
taskKind?: string;
|
|
58
|
-
priority?: string;
|
|
59
|
-
retryCount?: number;
|
|
60
|
-
maxRetries?: number;
|
|
61
|
-
lastError?: string;
|
|
62
|
-
resultRef?: string;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* V2 queue item schema.
|
|
66
|
-
*/
|
|
67
|
-
export interface EvolutionQueueItem {
|
|
68
|
-
id: string;
|
|
69
|
-
taskKind: TaskKind;
|
|
70
|
-
priority: TaskPriority;
|
|
71
|
-
source: string;
|
|
72
|
-
traceId?: string;
|
|
73
|
-
task?: string;
|
|
74
|
-
score: number;
|
|
75
|
-
reason: string;
|
|
76
|
-
timestamp: string;
|
|
77
|
-
enqueued_at?: string;
|
|
78
|
-
started_at?: string;
|
|
79
|
-
completed_at?: string;
|
|
80
|
-
assigned_session_key?: string;
|
|
81
|
-
trigger_text_preview?: string;
|
|
82
|
-
status: QueueStatus;
|
|
83
|
-
resolution?: TaskResolution;
|
|
84
|
-
session_id?: string;
|
|
85
|
-
agent_id?: string;
|
|
86
|
-
retryCount: number;
|
|
87
|
-
maxRetries: number;
|
|
88
|
-
lastError?: string;
|
|
89
|
-
resultRef?: string;
|
|
90
|
-
recentPainContext?: RecentPainContext;
|
|
91
|
-
}
|
|
92
|
-
export type RawQueueItem = Record<string, unknown>;
|
|
93
|
-
/**
|
|
94
|
-
* Migrate a legacy queue item to V2 schema.
|
|
95
|
-
* Old items without taskKind are assumed to be pain_diagnosis for backward compatibility.
|
|
96
|
-
*/
|
|
97
|
-
export declare function migrateToV2(item: LegacyEvolutionQueueItem): {
|
|
98
|
-
id: string;
|
|
99
|
-
taskKind: TaskKind;
|
|
100
|
-
priority: TaskPriority;
|
|
101
|
-
source: string;
|
|
102
|
-
traceId?: string;
|
|
103
|
-
task?: string;
|
|
104
|
-
score: number;
|
|
105
|
-
reason: string;
|
|
106
|
-
timestamp: string;
|
|
107
|
-
enqueued_at?: string;
|
|
108
|
-
started_at?: string;
|
|
109
|
-
completed_at?: string;
|
|
110
|
-
assigned_session_key?: string;
|
|
111
|
-
trigger_text_preview?: string;
|
|
112
|
-
status: QueueStatus;
|
|
113
|
-
resolution?: TaskResolution;
|
|
114
|
-
session_id?: string;
|
|
115
|
-
agent_id?: string;
|
|
116
|
-
retryCount: number;
|
|
117
|
-
maxRetries: number;
|
|
118
|
-
lastError?: string;
|
|
119
|
-
resultRef?: string;
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Check if an item is a legacy (pre-V2) queue item.
|
|
123
|
-
*/
|
|
124
|
-
export declare function isLegacyQueueItem(item: RawQueueItem): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Migrate entire queue to V2 schema if needed.
|
|
127
|
-
*/
|
|
128
|
-
export declare function migrateQueueToV2(queue: RawQueueItem[]): ReturnType<typeof migrateToV2>[];
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Evolution Queue Migration — V1 to V2 Schema
|
|
3
|
-
*
|
|
4
|
-
* Pure transformation functions and shared queue types.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Default values for new V2 fields when migrating legacy items.
|
|
8
|
-
*/
|
|
9
|
-
export const DEFAULT_TASK_KIND = 'pain_diagnosis';
|
|
10
|
-
export const DEFAULT_PRIORITY = 'medium';
|
|
11
|
-
export const DEFAULT_MAX_RETRIES = 3;
|
|
12
|
-
/**
|
|
13
|
-
* Migrate a legacy queue item to V2 schema.
|
|
14
|
-
* Old items without taskKind are assumed to be pain_diagnosis for backward compatibility.
|
|
15
|
-
*/
|
|
16
|
-
export function migrateToV2(item) {
|
|
17
|
-
return {
|
|
18
|
-
id: item.id,
|
|
19
|
-
taskKind: item.taskKind || DEFAULT_TASK_KIND,
|
|
20
|
-
priority: item.priority || DEFAULT_PRIORITY,
|
|
21
|
-
source: item.source,
|
|
22
|
-
traceId: item.traceId,
|
|
23
|
-
task: item.task,
|
|
24
|
-
score: item.score,
|
|
25
|
-
reason: item.reason,
|
|
26
|
-
timestamp: item.timestamp,
|
|
27
|
-
enqueued_at: item.enqueued_at,
|
|
28
|
-
started_at: item.started_at,
|
|
29
|
-
completed_at: item.completed_at,
|
|
30
|
-
assigned_session_key: item.assigned_session_key,
|
|
31
|
-
trigger_text_preview: item.trigger_text_preview,
|
|
32
|
-
status: item.status || 'pending',
|
|
33
|
-
resolution: item.resolution,
|
|
34
|
-
session_id: item.session_id,
|
|
35
|
-
agent_id: item.agent_id,
|
|
36
|
-
retryCount: item.retryCount || 0,
|
|
37
|
-
maxRetries: item.maxRetries || DEFAULT_MAX_RETRIES,
|
|
38
|
-
lastError: item.lastError,
|
|
39
|
-
resultRef: item.resultRef,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Check if an item is a legacy (pre-V2) queue item.
|
|
44
|
-
*/
|
|
45
|
-
export function isLegacyQueueItem(item) {
|
|
46
|
-
return item && typeof item === 'object' && !('taskKind' in item);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Migrate entire queue to V2 schema if needed.
|
|
50
|
-
*/
|
|
51
|
-
export function migrateQueueToV2(queue) {
|
|
52
|
-
return queue.map(item => isLegacyQueueItem(item) ? migrateToV2(item) : item);
|
|
53
|
-
}
|