principles-disciple 1.245.0 → 1.245.2

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.
@@ -10,7 +10,7 @@
10
10
  * - Cache invalidated after every write (D-05)
11
11
  * - 200-term hard cap enforced before any write (T-38-01)
12
12
  */
13
- import type { CorrectionKeyword, CorrectionKeywordStore, CorrectionMatchResult } from './correction-types.js';
13
+ import type { CorrectionKeyword, CorrectionKeywordStore } from './correction-types.js';
14
14
  export declare function _resetCorrectionCueCache(): void;
15
15
  export declare function loadCorrectionKeywordStore(stateDir: string): CorrectionKeywordStore;
16
16
  export declare function saveCorrectionKeywordStore(stateDir: string, store: CorrectionKeywordStore): void;
@@ -19,8 +19,6 @@ export declare class CorrectionCueLearner {
19
19
  private readonly store;
20
20
  private readonly stateDir;
21
21
  constructor(stateDir: string);
22
- match(text: string): CorrectionMatchResult;
23
- recordHits(terms: string[]): void;
24
22
  recordTruePositive(term: string): void;
25
23
  recordFalsePositive(term: string): void;
26
24
  add(keyword: Omit<CorrectionKeyword, 'addedAt'>): void;
@@ -1,3 +1,3 @@
1
- import type { CorrectionKeyword, CorrectionKeywordStore, CorrectionMatchResult } from '@principles/core/runtime-v2';
2
- export type { CorrectionKeyword, CorrectionKeywordStore, CorrectionMatchResult, };
1
+ import type { CorrectionKeyword, CorrectionKeywordStore } from '@principles/core/runtime-v2';
2
+ export type { CorrectionKeyword, CorrectionKeywordStore, };
3
3
  export { MAX_CORRECTION_KEYWORDS, CORRECTION_SEED_KEYWORDS, } from '@principles/core/runtime-v2';
@@ -1,278 +1,9 @@
1
1
  /**
2
- * Trajectory database type definitions.
2
+ * Trajectory domain type surface for the plugin.
3
3
  *
4
- * PURPOSE: Track task outcomes, trust changes, and evolution progress over time.
5
- * USAGE: Insights, trends, and Phase 3 supporting evidence (where explicitly allowed).
6
- * NOT FOR: Control decisions, Phase 3 eligibility, or real-time operations.
4
+ * SINGLE HOME since PRI-774: all trajectory types live in
5
+ * `@principles/core/trajectory-types` (principles-core/src/trajectory-types.ts).
6
+ * This file is a compatibility re-export shim for existing plugin importers —
7
+ * do NOT add new type definitions here.
7
8
  */
8
- export type CorrectionSampleReviewStatus = 'pending' | 'approved' | 'rejected';
9
- export type CorrectionExportMode = 'raw' | 'redacted';
10
- export interface TrajectoryDataStats {
11
- dbPath: string;
12
- dbSizeBytes: number;
13
- assistantTurns: number;
14
- userTurns: number;
15
- toolCalls: number;
16
- painEvents: number;
17
- pendingSamples: number;
18
- approvedSamples: number;
19
- blobBytes: number;
20
- lastIngestAt: string | null;
21
- }
22
- export interface TrajectoryAssistantTurnInput {
23
- sessionId: string;
24
- runId: string;
25
- provider: string;
26
- model: string;
27
- rawText: string;
28
- sanitizedText: string;
29
- usageJson: unknown;
30
- empathySignalJson: unknown;
31
- stopReason?: string | null;
32
- thinkingBlocksCount?: number | null;
33
- createdAt?: string;
34
- }
35
- export interface TrajectoryUserTurnInput {
36
- sessionId: string;
37
- turnIndex: number;
38
- rawText: string;
39
- correctionDetected: boolean;
40
- correctionCue?: string | null;
41
- referencesAssistantTurnId?: number | null;
42
- createdAt?: string;
43
- }
44
- export interface TrajectoryToolCallInput {
45
- sessionId: string;
46
- toolName: string;
47
- outcome: 'success' | 'failure' | 'blocked';
48
- durationMs?: number | null;
49
- exitCode?: number | null;
50
- errorType?: string | null;
51
- errorMessage?: string | null;
52
- gfiBefore?: number | null;
53
- gfiAfter?: number | null;
54
- paramsJson?: unknown;
55
- resultPreview?: string | null;
56
- createdAt?: string;
57
- }
58
- export interface TrajectoryPainEventInput {
59
- sessionId: string;
60
- source: string;
61
- score: number;
62
- reason?: string | null;
63
- severity?: string | null;
64
- origin?: string | null;
65
- confidence?: number | null;
66
- text?: string;
67
- createdAt?: string;
68
- /** PRI-406: Canonical pain identity (e.g. manual_<ts>_<hash> or pain_<ts>_<hash>). */
69
- canonicalPainId?: string;
70
- /** PRI-406: Runtime V2 diagnostician task ID linked to this pain event. */
71
- runtimeTaskId?: string;
72
- /** PRI-640: Host attribution ('openclaw' | 'codex'); omit for manual/legacy (persists NULL = unknown). */
73
- hostKind?: 'openclaw' | 'codex';
74
- }
75
- export interface TrajectoryGateBlockInput {
76
- sessionId?: string | null;
77
- toolName: string;
78
- filePath?: string | null;
79
- reason: string;
80
- createdAt?: string;
81
- }
82
- type DailyMetricRow = {
83
- day: string;
84
- tool_calls: number;
85
- failures: number;
86
- user_corrections: number;
87
- };
88
- export interface TrajectoryTrustChangeInput {
89
- sessionId?: string | null;
90
- previousScore: number;
91
- newScore: number;
92
- delta: number;
93
- reason: string;
94
- createdAt?: string;
95
- }
96
- export interface TrajectoryPrincipleEventInput {
97
- principleId?: string | null;
98
- eventType: string;
99
- payload: unknown;
100
- createdAt?: string;
101
- }
102
- export interface TrajectoryTaskOutcomeInput {
103
- sessionId: string;
104
- taskId?: string | null;
105
- outcome: string;
106
- summary?: string | null;
107
- principleIdsJson?: unknown;
108
- createdAt?: string;
109
- }
110
- export interface TrajectorySessionInput {
111
- sessionId: string;
112
- startedAt?: string;
113
- }
114
- export type TaskKind = 'pain_diagnosis' | 'sleep_reflection' | 'model_eval' | 'keyword_optimization';
115
- export type TaskPriority = 'high' | 'medium' | 'low';
116
- interface EvolutionTaskInputBase {
117
- taskId: string;
118
- traceId: string;
119
- source: string;
120
- reason?: string | null;
121
- score?: number;
122
- status?: string;
123
- enqueuedAt?: string | null;
124
- startedAt?: string | null;
125
- completedAt?: string | null;
126
- resolution?: string | null;
127
- createdAt?: string;
128
- updatedAt?: string;
129
- }
130
- export interface EvolutionTaskInputV2 extends EvolutionTaskInputBase {
131
- taskKind?: TaskKind;
132
- priority?: TaskPriority;
133
- retryCount?: number;
134
- maxRetries?: number;
135
- lastError?: string | null;
136
- resultRef?: string | null;
137
- }
138
- export type EvolutionTaskInput = EvolutionTaskInputV2;
139
- export interface EvolutionEventInput {
140
- traceId: string;
141
- taskId?: string | null;
142
- stage: string;
143
- level?: string;
144
- message: string;
145
- summary?: string | null;
146
- metadata?: unknown;
147
- createdAt?: string;
148
- }
149
- export interface EvolutionTaskRecord {
150
- id: number;
151
- taskId: string;
152
- traceId: string;
153
- source: string;
154
- reason: string | null;
155
- score: number;
156
- status: string;
157
- enqueuedAt: string | null;
158
- startedAt: string | null;
159
- completedAt: string | null;
160
- resolution: string | null;
161
- createdAt: string;
162
- updatedAt: string;
163
- taskKind: TaskKind | null;
164
- priority: TaskPriority | null;
165
- retryCount: number | null;
166
- maxRetries: number | null;
167
- lastError: string | null;
168
- resultRef: string | null;
169
- }
170
- export interface EvolutionEventRecord {
171
- id: number;
172
- traceId: string;
173
- taskId: string | null;
174
- stage: string;
175
- level: string;
176
- message: string;
177
- summary: string | null;
178
- metadata: Record<string, unknown>;
179
- createdAt: string;
180
- }
181
- export interface EvolutionTaskFilters {
182
- status?: string;
183
- dateFrom?: string;
184
- dateTo?: string;
185
- limit?: number;
186
- offset?: number;
187
- }
188
- export interface AssistantTurnRecord {
189
- id: number;
190
- sessionId: string;
191
- runId: string;
192
- provider: string;
193
- model: string;
194
- rawText: string;
195
- sanitizedText: string;
196
- blobRef: string | null;
197
- stopReason: string | null;
198
- thinkingBlocksCount: number | null;
199
- createdAt: string;
200
- }
201
- export interface CorrectionSampleRecord {
202
- sampleId: string;
203
- sessionId: string;
204
- badAssistantTurnId: number;
205
- userCorrectionTurnId: number;
206
- recoveryToolSpanJson: string;
207
- diffExcerpt: string;
208
- principleIdsJson: string;
209
- qualityScore: number;
210
- reviewStatus: CorrectionSampleReviewStatus;
211
- exportMode: CorrectionExportMode;
212
- createdAt: string;
213
- updatedAt: string;
214
- }
215
- export interface TrajectoryExportResult {
216
- filePath: string;
217
- count: number;
218
- mode?: CorrectionExportMode;
219
- }
220
- export interface TrajectoryDatabaseOptions {
221
- workspaceDir: string;
222
- blobInlineThresholdBytes?: number;
223
- busyTimeoutMs?: number;
224
- orphanBlobGraceDays?: number;
225
- }
226
- /**
227
- * Raw row from tool_calls for RuleContext v2 history assembly.
228
- * Fields are raw strings from SQLite — the assembler validates them as unknown.
229
- */
230
- export interface RuleHostContextRow {
231
- readonly id: number;
232
- readonly toolName: string;
233
- readonly outcome: string;
234
- readonly paramsJson: string;
235
- }
236
- /** A single tool call selected by an Owner as labelled RuleHost evidence. */
237
- export interface RuleHostEvidenceRow extends RuleHostContextRow {
238
- readonly sessionId: string;
239
- }
240
- /**
241
- * Result of getRuleHostContextRows: FIFO-ordered rows + truncated flag.
242
- * truncated=true when more than `limit` rows existed (limit+1 read trick).
243
- */
244
- export interface RuleHostContextResult {
245
- readonly rows: readonly RuleHostContextRow[];
246
- readonly truncated: boolean;
247
- }
248
- export type { DailyMetricRow };
249
- export type SignalConfirmationStatus = 'pending' | 'confirmed' | 'rejected' | 'abandoned';
250
- /** 入队载荷(id 由 store 派生:sha256(sessionId:userTurnRowid) 前 12 位)。 */
251
- export interface SignalConfirmationInput {
252
- readonly sessionId: string;
253
- /** Stage1 写入 user_turns 返回的 rowid(G1 回写寻址键;UNIQUE 幂等)。 */
254
- readonly userTurnRowid: number;
255
- /** 与 realtime 路径一致的 occurrence 身份(ADR-0020 §11.4,批量确认复现同一 canonical pain)。 */
256
- readonly occurrenceId: string;
257
- readonly excerpt: string;
258
- /** Stage1 命中的词列表(JSON 落库)。 */
259
- readonly terms: readonly string[];
260
- /** Stage1 建议类别:correction | empathy。 */
261
- readonly suggestedType: string;
262
- readonly createdAt: string;
263
- }
264
- /** signal_confirmations 行(camelCase 投影)。 */
265
- export interface SignalConfirmationRow {
266
- readonly id: string;
267
- readonly sessionId: string;
268
- readonly userTurnRowid: number;
269
- readonly occurrenceId: string;
270
- readonly excerpt: string;
271
- readonly terms: readonly string[];
272
- readonly suggestedType: string;
273
- readonly status: SignalConfirmationStatus;
274
- readonly attempts: number;
275
- readonly createdAt: string;
276
- readonly resolvedAt: string | null;
277
- readonly resolution: string | null;
278
- }
9
+ export type { AssistantTurnRecord, CorrectionExportMode, CorrectionSampleRecord, CorrectionSampleReviewStatus, DailyMetricRow, EvolutionEventInput, EvolutionEventRecord, EvolutionTaskFilters, EvolutionTaskInput, EvolutionTaskInputV2, EvolutionTaskRecord, RuleHostContextResult, RuleHostContextRow, RuleHostEvidenceRow, SignalConfirmationInput, SignalConfirmationRow, SignalConfirmationStatus, TrajectoryAssistantTurnInput, TrajectoryDataStats, TrajectoryDatabaseOptions, TrajectoryExportResult, TrajectoryGateBlockInput, TrajectoryPainEventInput, TrajectoryPrincipleEventInput, TrajectorySessionInput, TrajectoryTaskOutcomeInput, TrajectoryToolCallInput, TrajectoryTrustChangeInput, TrajectoryUserTurnInput, TaskKind, TaskPriority, } from '@principles/core/trajectory-types';