principles-disciple 1.201.0 → 1.202.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/bundle.js +166 -166
- package/dist/commands/archive-impl.d.ts +18 -0
- package/dist/commands/capabilities.d.ts +3 -0
- package/dist/commands/context.d.ts +5 -0
- package/dist/commands/disable-impl.d.ts +22 -0
- package/dist/commands/evolution-status.d.ts +4 -0
- package/dist/commands/export.d.ts +2 -0
- package/dist/commands/focus.d.ts +14 -0
- package/dist/commands/pain.d.ts +6 -0
- package/dist/commands/principle-rollback.d.ts +4 -0
- package/dist/commands/promote-impl.d.ts +22 -0
- package/dist/commands/rollback-impl.d.ts +32 -0
- package/dist/commands/rollback.d.ts +19 -0
- package/dist/commands/samples.d.ts +2 -0
- package/dist/commands/strategy.d.ts +2 -0
- package/dist/commands/thinking-os.d.ts +2 -0
- package/dist/commands/workflow-debug.d.ts +4 -0
- package/dist/config/defaults/runtime.d.ts +58 -0
- package/dist/config/errors.d.ts +86 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/constants/tools.d.ts +17 -0
- package/dist/core/__tests__/focus-history.test.d.ts +1 -0
- package/dist/core/behavior-example-pack-assembler.d.ts +38 -0
- package/dist/core/bootstrap-rules.d.ts +50 -0
- package/dist/core/code-implementation-storage.d.ts +71 -0
- package/dist/core/config-health.d.ts +17 -0
- package/dist/core/config-service.d.ts +15 -0
- package/dist/core/config.d.ts +111 -0
- package/dist/core/control-ui-db.d.ts +117 -0
- package/dist/core/correction-cue-learner.d.ts +33 -0
- package/dist/core/correction-types.d.ts +3 -0
- package/dist/core/detection-funnel.d.ts +47 -0
- package/dist/core/detection-service.d.ts +15 -0
- package/dist/core/dictionary-service.d.ts +15 -0
- package/dist/core/dictionary.d.ts +38 -0
- package/dist/core/empathy-keyword-matcher.d.ts +5 -0
- package/dist/core/empathy-types.d.ts +2 -0
- package/dist/core/event-log.d.ts +98 -0
- package/dist/core/evolution-engine.d.ts +119 -0
- package/dist/core/evolution-logger.d.ts +137 -0
- package/dist/core/evolution-reducer.d.ts +116 -0
- package/dist/core/evolution-types.d.ts +50 -0
- package/dist/core/file-store.d.ts +41 -0
- package/dist/core/focus-history.d.ts +50 -0
- package/dist/core/hygiene/tracker.d.ts +22 -0
- package/dist/core/init.d.ts +30 -0
- package/dist/core/intent-doc-reader-adapter.d.ts +36 -0
- package/dist/core/intent-doc-reader.d.ts +89 -0
- package/dist/core/migration.d.ts +6 -0
- package/dist/core/pain-diagnostic-gate.d.ts +45 -0
- package/dist/core/pain.d.ts +24 -0
- package/dist/core/path-resolver.d.ts +60 -0
- package/dist/core/paths.d.ts +59 -0
- package/dist/core/pd-config-loader.d.ts +96 -0
- package/dist/core/pd-task-reconciler.d.ts +89 -0
- package/dist/core/pd-task-service.d.ts +2 -0
- package/dist/core/pd-task-store.d.ts +5 -0
- package/dist/core/pd-task-types.d.ts +8 -0
- package/dist/core/principle-compiler/__tests__/compiler-replay-gate.test.d.ts +1 -0
- package/dist/core/principle-compiler/code-validator.d.ts +14 -0
- package/dist/core/principle-compiler/compiler.d.ts +45 -0
- package/dist/core/principle-compiler/index.d.ts +12 -0
- package/dist/core/principle-compiler/ledger-registrar.d.ts +28 -0
- package/dist/core/principle-compiler/template-generator.d.ts +7 -0
- package/dist/core/principle-injection.d.ts +10 -0
- package/dist/core/principle-internalization/filesystem-lifecycle-datasource.d.ts +15 -0
- package/dist/core/principle-internalization/lifecycle-read-model.d.ts +17 -0
- package/dist/core/principle-internalization/lifecycle-refresh.d.ts +2 -0
- package/dist/core/principle-internalization/principle-lifecycle-service.d.ts +28 -0
- package/dist/core/principle-training-state.d.ts +47 -0
- package/dist/core/principle-tree-ledger.d.ts +30 -0
- package/dist/core/profile.d.ts +62 -0
- package/dist/core/reflection/reflection-context.d.ts +31 -0
- package/dist/core/replay-engine.d.ts +12 -0
- package/dist/core/rule-context-assembler.d.ts +45 -0
- package/dist/core/rule-host.d.ts +178 -0
- package/dist/core/rule-implementation-runtime.d.ts +18 -0
- package/dist/core/runtime-v2-prompt-activation-reader.d.ts +22 -0
- package/dist/core/session-tracker.d.ts +119 -0
- package/dist/core/signal-collector-host.d.ts +113 -0
- package/dist/core/system-logger.d.ts +24 -0
- package/dist/core/thinking-models.d.ts +25 -0
- package/dist/core/thinking-os-parser.d.ts +35 -0
- package/dist/core/trajectory-types.d.ts +247 -0
- package/dist/core/trajectory.d.ts +279 -0
- package/dist/core/workflow-funnel-loader.d.ts +72 -0
- package/dist/core/workspace-context.d.ts +114 -0
- package/dist/core/workspace-dir-validation.d.ts +11 -0
- package/dist/core/workspace-guidance-migrator.d.ts +12 -0
- package/dist/hooks/after-tool-call-helpers.d.ts +97 -0
- package/dist/hooks/after-tool-call-types.d.ts +86 -0
- package/dist/hooks/gate-block-helper.d.ts +44 -0
- package/dist/hooks/gate.d.ts +16 -0
- package/dist/hooks/lifecycle.d.ts +5 -0
- package/dist/hooks/llm.d.ts +21 -0
- package/dist/hooks/message-sanitize.d.ts +24 -0
- package/dist/hooks/pain.d.ts +35 -0
- package/dist/hooks/prompt-helpers.d.ts +105 -0
- package/dist/hooks/prompt-types.d.ts +74 -0
- package/dist/hooks/prompt.d.ts +22 -0
- package/dist/hooks/raw-observation-adapter.d.ts +16 -0
- package/dist/hooks/raw-observation-types.d.ts +11 -0
- package/dist/hooks/trajectory-collector.d.ts +41 -0
- package/dist/hooks/trajectory-evidence.d.ts +11 -0
- package/dist/hooks/triage-adapter.d.ts +58 -0
- package/dist/hooks/trigger-cooldown-tracker.d.ts +42 -0
- package/dist/i18n/commands.d.ts +26 -0
- package/dist/index.d.ts +52 -0
- package/dist/openclaw-sdk.d.ts +338 -0
- package/dist/openclaw.plugin.json +1 -1
- package/dist/rulehost-evidence.d.ts +4 -0
- package/dist/service/correction-observer-service.d.ts +19 -0
- package/dist/service/evolution-dedup.d.ts +27 -0
- package/dist/service/evolution-worker.d.ts +105 -0
- package/dist/service/internalization-auto-consumer-service.d.ts +8 -0
- package/dist/service/keyword-optimization-service.d.ts +44 -0
- package/dist/service/phase3-input-filter.d.ts +73 -0
- package/dist/service/queue-io.d.ts +30 -0
- package/dist/service/queue-migration.d.ts +84 -0
- package/dist/service/runtime-summary-service.d.ts +156 -0
- package/dist/service/subagent-workflow/subagent-error-utils.d.ts +8 -0
- package/dist/service/subagent-workflow/types.d.ts +264 -0
- package/dist/service/subagent-workflow/workflow-store.d.ts +44 -0
- package/dist/service/trajectory-service.d.ts +2 -0
- package/dist/service/workflow-watchdog.d.ts +23 -0
- package/dist/types/event-types.d.ts +2 -0
- package/dist/types/hygiene-types.d.ts +2 -0
- package/dist/types/principle-tree-schema.d.ts +29 -0
- package/dist/types/queue.d.ts +2 -0
- package/dist/types/runtime-summary.d.ts +1 -0
- package/dist/types.d.ts +13 -0
- package/dist/utils/file-lock.d.ts +68 -0
- package/dist/utils/hashing.d.ts +9 -0
- package/dist/utils/io.d.ts +11 -0
- package/dist/utils/node-vm-polyfill.d.ts +9 -0
- package/dist/utils/retry.d.ts +210 -0
- package/dist/utils/session-key.d.ts +10 -0
- package/dist/utils/workspace-resolver.d.ts +82 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EvolutionLogger - 进化流程日志服务
|
|
3
|
+
*
|
|
4
|
+
* 提供两层日志:
|
|
5
|
+
* - 技术层:结构化 JSON,包含 trace_id、stage、metadata
|
|
6
|
+
* - 用户层:中文摘要,便于小白用户理解
|
|
7
|
+
*
|
|
8
|
+
* 日志写入两个地方:
|
|
9
|
+
* 1. SYSTEM_LOG (system.jsonl) - 技术细节
|
|
10
|
+
* 2. evolution_events 表 (SQLite) - 结构化查询
|
|
11
|
+
*/
|
|
12
|
+
import type { TrajectoryDatabase } from './trajectory.js';
|
|
13
|
+
export type EvolutionStage = 'pain_detected' | 'queued' | 'started' | 'analyzing' | 'principle_generated' | 'completed' | 'failed';
|
|
14
|
+
export type EvolutionLogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
15
|
+
export interface EvolutionLogEntry {
|
|
16
|
+
traceId: string;
|
|
17
|
+
stage: EvolutionStage;
|
|
18
|
+
level: EvolutionLogLevel;
|
|
19
|
+
message: string;
|
|
20
|
+
summary: string;
|
|
21
|
+
timestamp: string;
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
taskId?: string;
|
|
24
|
+
sessionId?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface EvolutionLogInput {
|
|
27
|
+
traceId: string;
|
|
28
|
+
stage: EvolutionStage;
|
|
29
|
+
level?: EvolutionLogLevel;
|
|
30
|
+
message: string;
|
|
31
|
+
summary: string;
|
|
32
|
+
metadata?: Record<string, unknown>;
|
|
33
|
+
taskId?: string;
|
|
34
|
+
sessionId?: string;
|
|
35
|
+
}
|
|
36
|
+
export declare const STAGE_LABELS: Record<EvolutionStage, string>;
|
|
37
|
+
export declare const STAGE_COLORS: Record<EvolutionStage, string>;
|
|
38
|
+
/**
|
|
39
|
+
* 创建新的 trace_id
|
|
40
|
+
* 格式: ev_{timestamp}_{random}
|
|
41
|
+
* 使用 crypto.randomBytes 确保不可预测性
|
|
42
|
+
*/
|
|
43
|
+
export declare function createTraceId(): string;
|
|
44
|
+
/**
|
|
45
|
+
* EvolutionLogger 类
|
|
46
|
+
* 管理进化流程的日志记录
|
|
47
|
+
*/
|
|
48
|
+
export declare class EvolutionLogger {
|
|
49
|
+
private readonly workspaceDir;
|
|
50
|
+
private readonly trajectory;
|
|
51
|
+
constructor(workspaceDir: string, trajectory?: TrajectoryDatabase);
|
|
52
|
+
/**
|
|
53
|
+
* 记录进化事件
|
|
54
|
+
* 同时写入 SYSTEM_LOG 和 evolution_events 表
|
|
55
|
+
*/
|
|
56
|
+
log(input: EvolutionLogInput): void;
|
|
57
|
+
/**
|
|
58
|
+
* 记录 pain_detected 事件
|
|
59
|
+
*/
|
|
60
|
+
logPainDetected(params: {
|
|
61
|
+
traceId: string;
|
|
62
|
+
source: string;
|
|
63
|
+
reason: string;
|
|
64
|
+
score: number;
|
|
65
|
+
toolName?: string;
|
|
66
|
+
filePath?: string;
|
|
67
|
+
sessionId?: string;
|
|
68
|
+
}): void;
|
|
69
|
+
/**
|
|
70
|
+
* 记录 queued 事件
|
|
71
|
+
*/
|
|
72
|
+
logQueued(params: {
|
|
73
|
+
traceId: string;
|
|
74
|
+
taskId: string;
|
|
75
|
+
score: number;
|
|
76
|
+
source: string;
|
|
77
|
+
reason: string;
|
|
78
|
+
}): void;
|
|
79
|
+
/**
|
|
80
|
+
* 记录 started 事件
|
|
81
|
+
*/
|
|
82
|
+
logStarted(params: {
|
|
83
|
+
traceId: string;
|
|
84
|
+
taskId: string;
|
|
85
|
+
}): void;
|
|
86
|
+
/**
|
|
87
|
+
* 记录 analyzing 事件
|
|
88
|
+
*/
|
|
89
|
+
logAnalyzing(params: {
|
|
90
|
+
traceId: string;
|
|
91
|
+
taskId: string;
|
|
92
|
+
analysisType?: string;
|
|
93
|
+
}): void;
|
|
94
|
+
/**
|
|
95
|
+
* 记录 principle_generated 事件
|
|
96
|
+
*/
|
|
97
|
+
logPrincipleGenerated(params: {
|
|
98
|
+
traceId: string;
|
|
99
|
+
taskId: string;
|
|
100
|
+
principleId: string;
|
|
101
|
+
principleText: string;
|
|
102
|
+
}): void;
|
|
103
|
+
/**
|
|
104
|
+
* 记录 completed 事件
|
|
105
|
+
*/
|
|
106
|
+
logCompleted(params: {
|
|
107
|
+
traceId: string;
|
|
108
|
+
taskId: string;
|
|
109
|
+
resolution: 'marker_detected' | 'auto_completed_timeout' | 'manual' | 'late_marker_principle_created' | 'late_marker_no_principle' | 'diagnostician_timeout' | 'noise_classified' | 'duplicate' | 'serverDuplicate';
|
|
110
|
+
durationMs?: number;
|
|
111
|
+
principlesGenerated?: number;
|
|
112
|
+
}): void;
|
|
113
|
+
/**
|
|
114
|
+
* 记录 failed 事件
|
|
115
|
+
*/
|
|
116
|
+
logFailed(params: {
|
|
117
|
+
traceId: string;
|
|
118
|
+
taskId: string;
|
|
119
|
+
error: string;
|
|
120
|
+
stack?: string;
|
|
121
|
+
}): void;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 获取 EvolutionLogger 实例(单例)
|
|
125
|
+
*
|
|
126
|
+
* 注意:带 trajectory 和不带 trajectory 的请求会返回不同的实例,
|
|
127
|
+
* 因为 trajectory 影响事件持久化行为。
|
|
128
|
+
*/
|
|
129
|
+
export declare function getEvolutionLogger(workspaceDir: string, trajectory?: TrajectoryDatabase): EvolutionLogger;
|
|
130
|
+
/**
|
|
131
|
+
* 清理指定 workspace 的 logger 缓存
|
|
132
|
+
*/
|
|
133
|
+
export declare function disposeEvolutionLogger(workspaceDir: string): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* 清理所有 logger 缓存(用于测试或进程退出)
|
|
136
|
+
*/
|
|
137
|
+
export declare function disposeAllEvolutionLoggers(): void;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { EvolutionLoopEvent, Principle, PrincipleDetectorSpec, PrincipleEvaluatorLevel, PrincipleSuggestedRule } from './evolution-types.js';
|
|
2
|
+
export interface EvolutionReducer {
|
|
3
|
+
emit(_event: EvolutionLoopEvent): void;
|
|
4
|
+
emitSync(_event: EvolutionLoopEvent): void;
|
|
5
|
+
getEventLog(): EvolutionLoopEvent[];
|
|
6
|
+
getCandidatePrinciples(): Principle[];
|
|
7
|
+
getProbationPrinciples(): Principle[];
|
|
8
|
+
getActivePrinciples(): Principle[];
|
|
9
|
+
getPrincipleById(_id: string): Principle | null;
|
|
10
|
+
promote(_principleId: string, _reason?: string): void;
|
|
11
|
+
deprecate(_principleId: string, _reason: string): void;
|
|
12
|
+
rollbackPrinciple(_principleId: string, _reason: string): void;
|
|
13
|
+
recordProbationFeedback(_principleId: string, _success: boolean): void;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new principle with generalized trigger/action from diagnostician.
|
|
16
|
+
* Called after diagnostician analysis to create principle directly.
|
|
17
|
+
*/
|
|
18
|
+
createPrincipleFromDiagnosis(params: {
|
|
19
|
+
painId: string;
|
|
20
|
+
painType: 'tool_failure' | 'subagent_error' | 'user_frustration';
|
|
21
|
+
triggerPattern: string;
|
|
22
|
+
action: string;
|
|
23
|
+
source: string;
|
|
24
|
+
evaluability?: PrincipleEvaluatorLevel;
|
|
25
|
+
detectorMetadata?: PrincipleDetectorSpec;
|
|
26
|
+
/** Highly abstracted principle text — if absent, falls back to action-based title */
|
|
27
|
+
abstractedPrinciple?: string;
|
|
28
|
+
/** Associated core axiom (e.g., "T-01") */
|
|
29
|
+
coreAxiomId?: string;
|
|
30
|
+
priority?: 'P0' | 'P1' | 'P2';
|
|
31
|
+
scope?: 'general' | 'domain';
|
|
32
|
+
domain?: string;
|
|
33
|
+
suggestedRules?: PrincipleSuggestedRule[];
|
|
34
|
+
}): string | null;
|
|
35
|
+
getStats(): {
|
|
36
|
+
candidateCount: number;
|
|
37
|
+
probationCount: number;
|
|
38
|
+
activeCount: number;
|
|
39
|
+
deprecatedCount: number;
|
|
40
|
+
lastPromotedAt: string | null;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export declare class EvolutionReducerImpl implements EvolutionReducer {
|
|
44
|
+
private readonly streamPath;
|
|
45
|
+
private readonly lockTargetPath;
|
|
46
|
+
private readonly blacklistPath;
|
|
47
|
+
private readonly principlesPath;
|
|
48
|
+
private readonly workspaceDir;
|
|
49
|
+
private readonly stateDir;
|
|
50
|
+
private readonly memoryEvents;
|
|
51
|
+
private readonly principles;
|
|
52
|
+
private readonly failureStreak;
|
|
53
|
+
private lastPromotedAt;
|
|
54
|
+
private isReplaying;
|
|
55
|
+
constructor(opts: {
|
|
56
|
+
workspaceDir: string;
|
|
57
|
+
stateDir?: string;
|
|
58
|
+
});
|
|
59
|
+
emit(event: EvolutionLoopEvent): void;
|
|
60
|
+
emitSync(event: EvolutionLoopEvent): void;
|
|
61
|
+
getEventLog(): EvolutionLoopEvent[];
|
|
62
|
+
getCandidatePrinciples(): Principle[];
|
|
63
|
+
getProbationPrinciples(): Principle[];
|
|
64
|
+
getActivePrinciples(): Principle[];
|
|
65
|
+
getPrincipleById(id: string): Principle | null;
|
|
66
|
+
promote(principleId: string, reason?: string): void;
|
|
67
|
+
deprecate(principleId: string, reason: string): void;
|
|
68
|
+
rollbackPrinciple(principleId: string, reason: string): void;
|
|
69
|
+
recordProbationFeedback(principleId: string, success: boolean): void;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a new principle with generalized trigger/action from diagnostician.
|
|
72
|
+
* Called after diagnostician analysis to create principle directly (no intermediate overfitted principle).
|
|
73
|
+
* @returns the new principle ID, or null if creation failed
|
|
74
|
+
*/
|
|
75
|
+
createPrincipleFromDiagnosis(params: {
|
|
76
|
+
painId: string;
|
|
77
|
+
painType: 'tool_failure' | 'subagent_error' | 'user_frustration';
|
|
78
|
+
triggerPattern: string;
|
|
79
|
+
action: string;
|
|
80
|
+
source: string;
|
|
81
|
+
evaluability?: PrincipleEvaluatorLevel;
|
|
82
|
+
detectorMetadata?: PrincipleDetectorSpec;
|
|
83
|
+
abstractedPrinciple?: string;
|
|
84
|
+
coreAxiomId?: string;
|
|
85
|
+
priority?: 'P0' | 'P1' | 'P2';
|
|
86
|
+
scope?: 'general' | 'domain';
|
|
87
|
+
domain?: string;
|
|
88
|
+
suggestedRules?: PrincipleSuggestedRule[];
|
|
89
|
+
}): string | null;
|
|
90
|
+
private syncPrincipleToFile;
|
|
91
|
+
private static detectPrincipleLanguage;
|
|
92
|
+
private static formatPrincipleForFile;
|
|
93
|
+
getStats(): {
|
|
94
|
+
candidateCount: number;
|
|
95
|
+
probationCount: number;
|
|
96
|
+
activeCount: number;
|
|
97
|
+
deprecatedCount: number;
|
|
98
|
+
lastPromotedAt: string | null;
|
|
99
|
+
};
|
|
100
|
+
private ensureDirs;
|
|
101
|
+
private loadFromStream;
|
|
102
|
+
private applyEvent;
|
|
103
|
+
private onCandidateCreated;
|
|
104
|
+
private onPrinciplePromoted;
|
|
105
|
+
private onPrincipleDeprecated;
|
|
106
|
+
private onPrincipleRolledBack;
|
|
107
|
+
private onPainDetected;
|
|
108
|
+
private updateFailureStreakFromPain;
|
|
109
|
+
private nextPrincipleId;
|
|
110
|
+
private getByStatus;
|
|
111
|
+
private sweepExpiredProbation;
|
|
112
|
+
private persistBlacklist;
|
|
113
|
+
private loadBlacklist;
|
|
114
|
+
private isBlacklisted;
|
|
115
|
+
}
|
|
116
|
+
export declare function stableContentHash(input: string): string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evolution Points System V2.0 - MVP
|
|
3
|
+
*
|
|
4
|
+
* Canonical definitions moved to @principles/core/runtime-v2/evolution/
|
|
5
|
+
* This file re-exports everything for backward compatibility.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: Principle → EvolutionPrinciple, PrincipleStatus → EvolutionPrincipleStatus
|
|
8
|
+
* to avoid collision with runtime-v2/types/principle-schema.ts Principle.
|
|
9
|
+
* Backward-compatible aliases are provided below.
|
|
10
|
+
*/
|
|
11
|
+
import type { TaskKind, TaskPriority } from './trajectory-types.js';
|
|
12
|
+
import type { EvolutionPrinciple as EvolutionPrincipleType, EvolutionPrincipleStatus as EvolutionPrincipleStatusType, EvolutionPrincipleSuggestedRule as EvolutionPrincipleSuggestedRuleType, EvolutionPrincipleValueMetricsSnapshot as EvolutionPrincipleValueMetricsSnapshotType, EvolutionPainDetectedData as EvolutionPainDetectedDataType } from '@principles/core/runtime-v2';
|
|
13
|
+
export { EvolutionTier, TIER_DEFINITIONS, getTierDefinition, getTierByPoints, TASK_DIFFICULTY_CONFIG, DEFAULT_EVOLUTION_CONFIG, isCompleteDetectorMetadata, } from '@principles/core/runtime-v2';
|
|
14
|
+
export type { TierPermissions, TierDefinition, TaskDifficulty, TaskDifficultyConfig, EvolutionEventType, EvolutionEvent, EvolutionScorecard, EvolutionStats, EvolutionStorage, EvolutionConfig, ArchivedEventStats, GateDecision, ToolCallContext, TierPromotionEvent, EvolutionPrincipleStatus, PrincipleEvaluatorLevel, Evaluability, PrincipleDetectorSpec, EvolutionPrinciple, EvolutionPrincipleSuggestedRule, EvolutionPrincipleValueMetricsSnapshot, EvolutionLoopEventType, EvolutionPainDetectedData, CandidateCreatedData, PrinciplePromotedData, PrincipleDeprecatedData, PrincipleRolledBackData, CircuitBreakerOpenedData, LegacyImportData, EvolutionLoopEvent, } from '@principles/core/runtime-v2';
|
|
15
|
+
/** @deprecated Use EvolutionPrinciple instead. Alias for backward compatibility. */
|
|
16
|
+
export type Principle = EvolutionPrincipleType;
|
|
17
|
+
/** @deprecated Use EvolutionPrincipleStatus instead. Alias for backward compatibility. */
|
|
18
|
+
export type PrincipleStatus = EvolutionPrincipleStatusType;
|
|
19
|
+
/** @deprecated Use EvolutionPrincipleSuggestedRule instead. Alias for backward compatibility. */
|
|
20
|
+
export type PrincipleSuggestedRule = EvolutionPrincipleSuggestedRuleType;
|
|
21
|
+
/** @deprecated Use EvolutionPrincipleValueMetricsSnapshot instead. Alias for backward compatibility. */
|
|
22
|
+
export type PrincipleValueMetricsSnapshot = EvolutionPrincipleValueMetricsSnapshotType;
|
|
23
|
+
/** @deprecated Use EvolutionPainDetectedData instead. Alias for backward compatibility. */
|
|
24
|
+
export type PainDetectedData = EvolutionPainDetectedDataType;
|
|
25
|
+
export type QueueStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'canceled';
|
|
26
|
+
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' | 'success' | 'failure' | 'skipped' | 'noise_classified' | 'retired';
|
|
27
|
+
export interface EvolutionQueueItem {
|
|
28
|
+
id: string;
|
|
29
|
+
taskKind: TaskKind;
|
|
30
|
+
priority: TaskPriority;
|
|
31
|
+
source: string;
|
|
32
|
+
traceId?: string;
|
|
33
|
+
task?: string;
|
|
34
|
+
score: number;
|
|
35
|
+
reason: string;
|
|
36
|
+
timestamp: string;
|
|
37
|
+
enqueued_at?: string;
|
|
38
|
+
started_at?: string;
|
|
39
|
+
completed_at?: string;
|
|
40
|
+
assigned_session_key?: string;
|
|
41
|
+
trigger_text_preview?: string;
|
|
42
|
+
status: QueueStatus;
|
|
43
|
+
resolution?: TaskResolution;
|
|
44
|
+
session_id?: string;
|
|
45
|
+
agent_id?: string;
|
|
46
|
+
retryCount: number;
|
|
47
|
+
maxRetries: number;
|
|
48
|
+
lastError?: string;
|
|
49
|
+
resultRef?: string;
|
|
50
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FileStore — generic interface for atomic JSON file persistence.
|
|
3
|
+
*
|
|
4
|
+
* Encapsulates the common "read JSON → modify → atomic write" pattern
|
|
5
|
+
* used throughout core modules. Implementations handle:
|
|
6
|
+
* - Missing file → default data
|
|
7
|
+
* - Malformed file → default data (graceful degradation)
|
|
8
|
+
* - Atomic writes via temp + rename
|
|
9
|
+
*/
|
|
10
|
+
export interface FileStore<T> {
|
|
11
|
+
/** Load data from file, returning defaults if missing or corrupt. */
|
|
12
|
+
load(): T;
|
|
13
|
+
/** Atomically write data to file. */
|
|
14
|
+
save(data: T): void;
|
|
15
|
+
/**
|
|
16
|
+
* Read-modify-write cycle.
|
|
17
|
+
* The mutate function receives current data and may modify it in place.
|
|
18
|
+
* The modified data is saved automatically after fn completes.
|
|
19
|
+
* If fn throws, the write is aborted and the file is unchanged.
|
|
20
|
+
*
|
|
21
|
+
* Returns the value returned by fn (useful for extracting computed results).
|
|
22
|
+
*
|
|
23
|
+
* NOTE: This method is NOT thread-safe. Caller must ensure no concurrent
|
|
24
|
+
* writes to the same file — use withLock() or equivalent to serialize access.
|
|
25
|
+
*/
|
|
26
|
+
mutate<R>(fn: (data: T) => R): R;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* JSON-backed FileStore implementation.
|
|
30
|
+
*
|
|
31
|
+
* Uses atomicWriteFileSync for crash-safe writes.
|
|
32
|
+
* Handles missing/corrupt files by returning the provided default factory result.
|
|
33
|
+
*/
|
|
34
|
+
export declare class JsonFileStore<T extends object> implements FileStore<T> {
|
|
35
|
+
private readonly filePath;
|
|
36
|
+
private readonly defaultFactory;
|
|
37
|
+
constructor(filePath: string, defaultFactory: () => T);
|
|
38
|
+
load(): T;
|
|
39
|
+
save(data: T): void;
|
|
40
|
+
mutate<R>(fn: (data: T) => R): R;
|
|
41
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { WorkingMemorySnapshot } from '@principles/core/prompt-builder';
|
|
2
|
+
export { extractVersion, extractDate, extractSummary, parseWorkingMemorySection, workingMemoryToInjection, extractMilestones, validateCurrentFocus, mergeWorkingMemory, compressFocusContent, } from '@principles/core/prompt-builder';
|
|
3
|
+
export type { FileArtifact, WorkingMemorySnapshot, } from '@principles/core/prompt-builder';
|
|
4
|
+
interface CompressionConfig {
|
|
5
|
+
lineThreshold: number;
|
|
6
|
+
sizeThreshold: number;
|
|
7
|
+
intervalMs: number;
|
|
8
|
+
keepCompletedTasks: number;
|
|
9
|
+
maxWorkingMemoryArtifacts: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function getHistoryDir(focusPath: string): string;
|
|
12
|
+
export declare function backupToHistory(focusPath: string, content: string): string | null;
|
|
13
|
+
export declare function cleanupHistory(focusPath: string, maxFiles?: number): void;
|
|
14
|
+
export declare function getHistoryVersions(focusPath: string, count?: number): Promise<string[]>;
|
|
15
|
+
export declare function compressFocus(focusPath: string, newContent: string): {
|
|
16
|
+
backupPath: string | null;
|
|
17
|
+
cleanedCount: number;
|
|
18
|
+
};
|
|
19
|
+
export declare function extractWorkingMemory(messages: {
|
|
20
|
+
role?: string;
|
|
21
|
+
content?: string | unknown[];
|
|
22
|
+
}[], workspaceDir?: string): WorkingMemorySnapshot;
|
|
23
|
+
export declare function cleanupStaleInfo(content: string, workspaceDir?: string, config?: CompressionConfig): string;
|
|
24
|
+
export declare function autoCompressFocus(focusPath: string, workspaceDir?: string, stateDir?: string): {
|
|
25
|
+
compressed: boolean;
|
|
26
|
+
oldLines: number;
|
|
27
|
+
newLines: number;
|
|
28
|
+
milestonesArchived: boolean;
|
|
29
|
+
backupPath: string | null;
|
|
30
|
+
reason: string;
|
|
31
|
+
newContent?: string;
|
|
32
|
+
};
|
|
33
|
+
export declare function needsAutoCompression(focusPath: string, stateDir?: string): boolean;
|
|
34
|
+
export declare function archiveMilestonesToDaily(workspaceDir: string, milestones: {
|
|
35
|
+
completedTasks: string[];
|
|
36
|
+
fileArtifacts: string[];
|
|
37
|
+
}, version: string): string | null;
|
|
38
|
+
export declare function recoverFromTemplate(focusPath: string, extensionRoot: string): {
|
|
39
|
+
success: boolean;
|
|
40
|
+
error?: string;
|
|
41
|
+
templatePath?: string;
|
|
42
|
+
};
|
|
43
|
+
export declare function safeReadCurrentFocus(focusPath: string, extensionRoot: string, logger?: {
|
|
44
|
+
warn?: (msg: string) => void;
|
|
45
|
+
info?: (msg: string) => void;
|
|
46
|
+
}): {
|
|
47
|
+
content: string;
|
|
48
|
+
recovered: boolean;
|
|
49
|
+
validationErrors: string[];
|
|
50
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HygieneStats, PersistenceAction } from '../../types/hygiene-types.js';
|
|
2
|
+
import type { PluginLogger } from '../../openclaw-sdk.js';
|
|
3
|
+
/**
|
|
4
|
+
* HygieneTracker - Tracks agent behavior regarding workspace organization and persistence.
|
|
5
|
+
*/
|
|
6
|
+
export declare class HygieneTracker {
|
|
7
|
+
private readonly statsFile;
|
|
8
|
+
private currentStats;
|
|
9
|
+
private readonly logger?;
|
|
10
|
+
constructor(stateDir: string, logger?: PluginLogger);
|
|
11
|
+
private loadStats;
|
|
12
|
+
private saveStats;
|
|
13
|
+
/**
|
|
14
|
+
* Records a persistence action (writing to memory or plan).
|
|
15
|
+
*/
|
|
16
|
+
recordPersistence(action: PersistenceAction): void;
|
|
17
|
+
/**
|
|
18
|
+
* Records a grooming action (cleaning up the workspace).
|
|
19
|
+
*/
|
|
20
|
+
recordGrooming(): void;
|
|
21
|
+
getStats(): HygieneStats;
|
|
22
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { OpenClawPluginApi, PluginLogger } from '../openclaw-sdk.js';
|
|
2
|
+
/**
|
|
3
|
+
* Ensures that the workspace has the necessary template files for Principles Disciple.
|
|
4
|
+
* This function flattens 'core' templates to the root so OpenClaw can find them.
|
|
5
|
+
*/
|
|
6
|
+
export declare function ensureWorkspaceTemplates(api: OpenClawPluginApi, workspaceDir: string, language?: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Core thinking model definitions (T-01 through T-10).
|
|
9
|
+
* Derived from the Core Principle Registry — the single source of truth.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CORE_THINKING_MODELS: Array<{
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Initialize core thinking models into the training store if it's empty.
|
|
18
|
+
* This ensures every workspace has evaluable principles for nocturnal reflection.
|
|
19
|
+
*
|
|
20
|
+
* @param stateDir - State directory path
|
|
21
|
+
* @param logger - Plugin logger
|
|
22
|
+
* @returns true if initialization was performed, false if already had principles
|
|
23
|
+
*/
|
|
24
|
+
export declare function ensureCorePrinciples(stateDir: string, logger: PluginLogger): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Ensures that the state directory has the necessary files (like pain_dictionary.json).
|
|
27
|
+
*/
|
|
28
|
+
export declare function ensureStateTemplates(ctx: {
|
|
29
|
+
logger: PluginLogger;
|
|
30
|
+
}, stateDir: string, language?: string): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRI-468 — Plugin adapter implementing the core `IntentDocReader` port.
|
|
3
|
+
*
|
|
4
|
+
* Bridges the plugin-owned `safeReadIntentDoc()` I/O function to the
|
|
5
|
+
* core-owned `IntentDocReader` interface so Stage A (in core) can read
|
|
6
|
+
* INTENT.md without core performing any filesystem I/O.
|
|
7
|
+
*
|
|
8
|
+
* This adapter only MAPS types — it adds no new I/O, no new flag checks,
|
|
9
|
+
* and no new telemetry. The underlying `safeReadIntentDoc()` already
|
|
10
|
+
* performs the flag-first check (SPEC §12), TTL+mtime cache, and size cap.
|
|
11
|
+
*
|
|
12
|
+
* ERR checklist:
|
|
13
|
+
* EP-01 / ERR-001: never `as` — field-by-field mapping with typeof checks
|
|
14
|
+
* EP-02 / ERR-025: plugin I/O file, whitelisted in architecture-regression
|
|
15
|
+
* EP-03 / ERR-002: every degraded path flows through with reason + nextAction
|
|
16
|
+
*
|
|
17
|
+
* Architecture: this file is I/O (delegates to fs-reading safeReadIntentDoc).
|
|
18
|
+
* It will be added to KNOWN_PLUGIN_CORE_FILES in architecture-regression.test.ts.
|
|
19
|
+
*/
|
|
20
|
+
import type { IntentDocReader, IntentLang } from '@principles/core/runtime-v2';
|
|
21
|
+
/**
|
|
22
|
+
* Detect which language's INTENT file exists on disk.
|
|
23
|
+
* Priority: zh-CN first, then en. Defaults to zh-CN if neither exists.
|
|
24
|
+
*
|
|
25
|
+
* This lets hooks avoid hardcoding a single language — the Owner may have
|
|
26
|
+
* created either INTENT.zh-CN.md or INTENT.en.md.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveIntentLang(workspaceDir: string): IntentLang;
|
|
29
|
+
/**
|
|
30
|
+
* Create an IntentDocReader bound to a specific workspace and language.
|
|
31
|
+
*
|
|
32
|
+
* The returned reader is stateless beyond the (workspace, lang) binding — each
|
|
33
|
+
* `readIntentDoc()` call delegates to `safeReadIntentDoc()`, which owns
|
|
34
|
+
* the TTL+mtime cache keyed by `${workspaceDir}:${lang}`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createIntentDocReader(workspaceDir: string, lang: IntentLang): IntentDocReader;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRI-467 — safeReadIntentDoc: plugin I/O wrapper for reading INTENT.md.
|
|
3
|
+
*
|
|
4
|
+
* Reads `.principles/INTENT.md` with:
|
|
5
|
+
* - Feature flag check FIRST (SPEC §12: flag off → flag_disabled without fs)
|
|
6
|
+
* - TTL + mtime cache (60s TTL, mtime check) mirroring prompt.ts cachedReadFile
|
|
7
|
+
* - 32KB size cap (INTENT_MAX_BYTES)
|
|
8
|
+
* - Never throws — all errors return structured `reason` + `nextAction`
|
|
9
|
+
*
|
|
10
|
+
* Trust boundary (SPEC §12.2):
|
|
11
|
+
* - Raw content is returned for the pure builder to escape; this reader does
|
|
12
|
+
* NOT escape or bound the content for prompt injection. The pure builder
|
|
13
|
+
* `buildIntentFrictionBlock` handles escaping + bounding.
|
|
14
|
+
*
|
|
15
|
+
* ERR checklist:
|
|
16
|
+
* EP-01 / ERR-001, ERR-005: raw content validated with typeof, never `as`
|
|
17
|
+
* EP-02 / ERR-025, ERR-070: production path; plugin I/O file in the whitelist
|
|
18
|
+
* EP-03 / ERR-002, ERR-014: every degraded path returns structured reason + nextAction
|
|
19
|
+
* EP-09: tests use real fs writes in temp dirs
|
|
20
|
+
*
|
|
21
|
+
* Architecture: this file is I/O (fs, path). It is whitelisted in
|
|
22
|
+
* architecture-regression.test.ts KNOWN_PLUGIN_CORE_FILES.
|
|
23
|
+
*/
|
|
24
|
+
import { type IntentDocSections, type IntentDocWarning, type IntentLang } from '@principles/core/runtime-v2';
|
|
25
|
+
export type SafeReadIntentDocReason = 'flag_disabled' | 'not_found' | 'oversized' | 'read_error';
|
|
26
|
+
export interface IntentDoc {
|
|
27
|
+
/** Raw INTENT.md content (unescaped — caller escapes for prompt injection). */
|
|
28
|
+
raw: string;
|
|
29
|
+
/** Parsed sections from the raw content. */
|
|
30
|
+
sections: IntentDocSections;
|
|
31
|
+
/** SHA-256 content hash for deduplication and audit. */
|
|
32
|
+
contentHash: string;
|
|
33
|
+
/** Absolute path to the INTENT.md file. */
|
|
34
|
+
path: string;
|
|
35
|
+
/** ISO timestamp when the doc was read. */
|
|
36
|
+
readAt: string;
|
|
37
|
+
/** Validation warnings (missing/empty/too_vague sections). */
|
|
38
|
+
warnings: IntentDocWarning[];
|
|
39
|
+
}
|
|
40
|
+
export interface SafeReadIntentDocResult {
|
|
41
|
+
/** True when the doc was successfully read and parsed. */
|
|
42
|
+
ok: boolean;
|
|
43
|
+
/** True when the INTENT.md file exists on disk. */
|
|
44
|
+
found: boolean;
|
|
45
|
+
/** True when the intent_engineering flag is enabled. */
|
|
46
|
+
flagEnabled: boolean;
|
|
47
|
+
/** The parsed IntentDoc, present only when ok=true. */
|
|
48
|
+
doc?: IntentDoc;
|
|
49
|
+
/** Structured reason for a degraded path (present when ok=false). */
|
|
50
|
+
reason?: SafeReadIntentDocReason;
|
|
51
|
+
/** Next action for the operator (present when ok=false). */
|
|
52
|
+
nextAction?: string;
|
|
53
|
+
/** Validation warnings (always present, empty when no warnings). */
|
|
54
|
+
warnings: IntentDocWarning[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Reset the intent doc cache for test isolation.
|
|
58
|
+
*
|
|
59
|
+
* - No args: clear the whole cache.
|
|
60
|
+
* - workspaceDir only: delete all entries for that workspace (any lang).
|
|
61
|
+
* Keys are formatted as `${workspaceDir}:${lang}`, so we match by prefix.
|
|
62
|
+
* - workspaceDir + lang: delete the single `${workspaceDir}:${lang}` entry.
|
|
63
|
+
*
|
|
64
|
+
* Note: prompt.ts resetPromptStateForTest passes workspaceDir only — the
|
|
65
|
+
* previous signature treated it as a literal cache key, which never matched
|
|
66
|
+
* the `${workspaceDir}:${lang}` format and silently left entries behind.
|
|
67
|
+
*/
|
|
68
|
+
export declare function resetIntentDocCacheForTest(workspaceDir?: string, lang?: IntentLang): void;
|
|
69
|
+
/**
|
|
70
|
+
* Safely read INTENT.md for prompt injection.
|
|
71
|
+
*
|
|
72
|
+
* Contract (SPEC §12):
|
|
73
|
+
* 1. Flag check FIRST via loadFeatureFlagFromConfig. Flag off → flag_disabled
|
|
74
|
+
* WITHOUT any fs access to INTENT.md.
|
|
75
|
+
* 2. Flag on → check TTL + mtime cache. If cached and fresh → return cached.
|
|
76
|
+
* 3. Otherwise → stat the file (oversized check), read, parse, validate, cache.
|
|
77
|
+
* 4. Never throws — all errors return structured reason + nextAction.
|
|
78
|
+
*
|
|
79
|
+
* @param workspaceDir - Absolute path to the workspace root
|
|
80
|
+
* @param lang - Mandatory language code ('zh-CN' | 'en'); selects INTENT.${lang}.md
|
|
81
|
+
* @param options - Optional logger for debug-level diagnostics
|
|
82
|
+
* @returns SafeReadIntentDocResult (never throws)
|
|
83
|
+
*/
|
|
84
|
+
export declare function safeReadIntentDoc(workspaceDir: string, lang: IntentLang, options?: {
|
|
85
|
+
logger?: {
|
|
86
|
+
debug?: (msg: string) => void;
|
|
87
|
+
warn?: (msg: string) => void;
|
|
88
|
+
};
|
|
89
|
+
}): SafeReadIntentDocResult;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { OpenClawPluginApi } from '../openclaw-sdk.js';
|
|
2
|
+
/**
|
|
3
|
+
* Handles migration of Principles Disciple files from legacy directories
|
|
4
|
+
* (docs/ and memory/.state/) to the new hidden directory structure (.principles/ and .state/).
|
|
5
|
+
*/
|
|
6
|
+
export declare function migrateDirectoryStructure(api: OpenClawPluginApi, workspaceDir: string): void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pain Diagnostic Gate — PRI-446 thin adapter
|
|
3
|
+
*
|
|
4
|
+
* @deprecated PRI-454 — Gate A (PainDiagnosticGate) is superseded by Gate B
|
|
5
|
+
* (TriggerController + EvidenceTriage). This module remains as the rollback
|
|
6
|
+
* path when `painEvidenceAdmission` or `painEvidenceAdmissionDefault` flags
|
|
7
|
+
* are OFF. Do not add new callers. New admission logic must use
|
|
8
|
+
* `evaluateTriggerController` from runtime-v2/evidence-triage.
|
|
9
|
+
*
|
|
10
|
+
* Disposition: Archive (do not delete) per PRI-454 plan step 6.
|
|
11
|
+
* Removal conditions: Both flags confirmed ON in production for 30 days,
|
|
12
|
+
* and all 5 MVP paths verified on Gate B. See
|
|
13
|
+
* docs/plans/2026-06-pain-evidence-admission-track.md.
|
|
14
|
+
*
|
|
15
|
+
* The pure decision logic (threshold tree, cooldown comparison, episode-key
|
|
16
|
+
* construction) now lives in principles-core
|
|
17
|
+
* (runtime-v2/pain-gate/pain-diagnostic-gate-policy.ts). This file is the
|
|
18
|
+
* stateful adapter that owns:
|
|
19
|
+
* - the cooldown Map (lastDiagnosedAtByEpisode)
|
|
20
|
+
* - Date.now() injection
|
|
21
|
+
* - SystemLogger for unknown-source telemetry
|
|
22
|
+
*
|
|
23
|
+
* It preserves the original export names (evaluatePainDiagnosticGate,
|
|
24
|
+
* isCooldownActiveForEpisode, resetPainDiagnosticGateForTest) so all 5 callers
|
|
25
|
+
* (gate-block-helper, llm, pain, prompt x2) and the characterization test keep
|
|
26
|
+
* working unchanged.
|
|
27
|
+
*
|
|
28
|
+
* ERR checklist:
|
|
29
|
+
* - ERR-011: this is a stateful adapter delegating to core pure logic.
|
|
30
|
+
*/
|
|
31
|
+
import { type PainDiagnosticSource, type PainDiagnosticGateReason, type PainDiagnosticGateInput, type PainDiagnosticGateDecision } from '@principles/core/runtime-v2';
|
|
32
|
+
export type { PainDiagnosticSource, PainDiagnosticGateReason, PainDiagnosticGateInput, PainDiagnosticGateDecision, };
|
|
33
|
+
export declare function resetPainDiagnosticGateForTest(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Check whether cooldown is currently active for a given episode.
|
|
36
|
+
* Used by the trigger controller (PEAT-B2) to align its cooldown decision
|
|
37
|
+
* with the PainDiagnosticGate's cooldown state.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isCooldownActiveForEpisode(source: string, sessionId: string | undefined, errorHash: string | undefined, cooldownMs?: number): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Evaluate the pain diagnostic gate. Delegates the pure decision to core and,
|
|
42
|
+
* when the decision is to diagnose, records the current time against the
|
|
43
|
+
* episode so subsequent calls within the cooldown window are suppressed.
|
|
44
|
+
*/
|
|
45
|
+
export declare function evaluatePainDiagnosticGate(input: PainDiagnosticGateInput): PainDiagnosticGateDecision;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare function computePainScore(rc: number, isSpiral: boolean, missingTestCommand: boolean, softScore: number, projectDir?: string): number;
|
|
2
|
+
/**
|
|
3
|
+
* Track principle value metrics when a pain signal is written.
|
|
4
|
+
* This is observation-only — it does NOT affect the pain flag write flow.
|
|
5
|
+
* If any principle matches the pain signal, its painPreventedCount is incremented.
|
|
6
|
+
* Errors are silently ignored to avoid disrupting the pain pipeline.
|
|
7
|
+
*/
|
|
8
|
+
export declare function trackPrincipleValue(workspaceDir: string, painData: {
|
|
9
|
+
reason?: string;
|
|
10
|
+
source?: string;
|
|
11
|
+
score?: string;
|
|
12
|
+
}, getActivePrinciples: () => {
|
|
13
|
+
id: string;
|
|
14
|
+
trigger: string;
|
|
15
|
+
valueMetrics?: {
|
|
16
|
+
painPreventedCount: number;
|
|
17
|
+
lastPainPreventedAt?: string;
|
|
18
|
+
calculatedAt: string;
|
|
19
|
+
};
|
|
20
|
+
}[], updatePrincipleMetrics: (_id: string, _metrics: {
|
|
21
|
+
painPreventedCount: number;
|
|
22
|
+
lastPainPreventedAt: string;
|
|
23
|
+
calculatedAt: string;
|
|
24
|
+
}) => void): void;
|