principles-disciple 1.7.6 → 1.7.8
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/commands/context.js +5 -15
- package/dist/commands/evolution-status.js +2 -9
- package/dist/commands/export.js +61 -8
- package/dist/commands/nocturnal-review.d.ts +24 -0
- package/dist/commands/nocturnal-review.js +265 -0
- package/dist/commands/nocturnal-rollout.d.ts +27 -0
- package/dist/commands/nocturnal-rollout.js +671 -0
- package/dist/commands/nocturnal-train.d.ts +25 -0
- package/dist/commands/nocturnal-train.js +919 -0
- package/dist/commands/pain.js +8 -21
- package/dist/constants/tools.d.ts +2 -2
- package/dist/constants/tools.js +1 -1
- package/dist/core/adaptive-thresholds.d.ts +186 -0
- package/dist/core/adaptive-thresholds.js +300 -0
- package/dist/core/config.d.ts +2 -38
- package/dist/core/config.js +6 -61
- package/dist/core/event-log.d.ts +1 -2
- package/dist/core/event-log.js +0 -3
- package/dist/core/evolution-engine.js +1 -21
- package/dist/core/evolution-reducer.d.ts +7 -1
- package/dist/core/evolution-reducer.js +56 -4
- package/dist/core/evolution-types.d.ts +61 -9
- package/dist/core/evolution-types.js +31 -9
- package/dist/core/external-training-contract.d.ts +276 -0
- package/dist/core/external-training-contract.js +269 -0
- package/dist/core/local-worker-routing.d.ts +175 -0
- package/dist/core/local-worker-routing.js +525 -0
- package/dist/core/model-deployment-registry.d.ts +218 -0
- package/dist/core/model-deployment-registry.js +503 -0
- package/dist/core/model-training-registry.d.ts +295 -0
- package/dist/core/model-training-registry.js +475 -0
- package/dist/core/nocturnal-arbiter.d.ts +159 -0
- package/dist/core/nocturnal-arbiter.js +534 -0
- package/dist/core/nocturnal-candidate-scoring.d.ts +137 -0
- package/dist/core/nocturnal-candidate-scoring.js +266 -0
- package/dist/core/nocturnal-compliance.d.ts +175 -0
- package/dist/core/nocturnal-compliance.js +824 -0
- package/dist/core/nocturnal-dataset.d.ts +224 -0
- package/dist/core/nocturnal-dataset.js +443 -0
- package/dist/core/nocturnal-executability.d.ts +85 -0
- package/dist/core/nocturnal-executability.js +331 -0
- package/dist/core/nocturnal-export.d.ts +124 -0
- package/dist/core/nocturnal-export.js +275 -0
- package/dist/core/nocturnal-paths.d.ts +124 -0
- package/dist/core/nocturnal-paths.js +214 -0
- package/dist/core/nocturnal-trajectory-extractor.d.ts +242 -0
- package/dist/core/nocturnal-trajectory-extractor.js +307 -0
- package/dist/core/nocturnal-trinity.d.ts +311 -0
- package/dist/core/nocturnal-trinity.js +880 -0
- package/dist/core/paths.d.ts +6 -0
- package/dist/core/paths.js +6 -0
- package/dist/core/principle-training-state.d.ts +121 -0
- package/dist/core/principle-training-state.js +321 -0
- package/dist/core/promotion-gate.d.ts +238 -0
- package/dist/core/promotion-gate.js +529 -0
- package/dist/core/session-tracker.d.ts +10 -0
- package/dist/core/session-tracker.js +14 -0
- package/dist/core/shadow-observation-registry.d.ts +217 -0
- package/dist/core/shadow-observation-registry.js +308 -0
- package/dist/core/training-program.d.ts +233 -0
- package/dist/core/training-program.js +433 -0
- package/dist/core/trajectory.d.ts +95 -1
- package/dist/core/trajectory.js +220 -6
- package/dist/core/workspace-context.d.ts +0 -6
- package/dist/core/workspace-context.js +0 -12
- package/dist/hooks/bash-risk.d.ts +6 -6
- package/dist/hooks/bash-risk.js +8 -8
- package/dist/hooks/gate-block-helper.js +1 -1
- package/dist/hooks/gate.d.ts +1 -1
- package/dist/hooks/gate.js +2 -2
- package/dist/hooks/gfi-gate.d.ts +3 -3
- package/dist/hooks/gfi-gate.js +15 -14
- package/dist/hooks/pain.js +6 -9
- package/dist/hooks/progressive-trust-gate.d.ts +21 -49
- package/dist/hooks/progressive-trust-gate.js +51 -204
- package/dist/hooks/prompt.d.ts +11 -11
- package/dist/hooks/prompt.js +158 -72
- package/dist/hooks/subagent.js +43 -6
- package/dist/i18n/commands.js +8 -8
- package/dist/index.js +129 -28
- package/dist/service/evolution-worker.d.ts +42 -4
- package/dist/service/evolution-worker.js +321 -13
- package/dist/service/nocturnal-runtime.d.ts +183 -0
- package/dist/service/nocturnal-runtime.js +352 -0
- package/dist/service/nocturnal-service.d.ts +163 -0
- package/dist/service/nocturnal-service.js +787 -0
- package/dist/service/nocturnal-target-selector.d.ts +145 -0
- package/dist/service/nocturnal-target-selector.js +315 -0
- package/dist/service/phase3-input-filter.d.ts +2 -23
- package/dist/service/phase3-input-filter.js +3 -27
- package/dist/service/runtime-summary-service.d.ts +0 -10
- package/dist/service/runtime-summary-service.js +1 -54
- package/dist/tools/deep-reflect.js +2 -1
- package/dist/types/event-types.d.ts +2 -10
- package/dist/types/runtime-summary.d.ts +1 -8
- package/dist/types.d.ts +0 -3
- package/dist/types.js +0 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/templates/langs/en/skills/pd-mentor/SKILL.md +5 -5
- package/templates/langs/zh/skills/pd-mentor/SKILL.md +5 -5
- package/templates/pain_settings.json +0 -6
- package/dist/commands/trust.d.ts +0 -4
- package/dist/commands/trust.js +0 -78
- package/dist/core/trust-engine.d.ts +0 -96
- package/dist/core/trust-engine.js +0 -286
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Training Registry — Training Run, Checkpoint, and Eval Summary Lineage
|
|
3
|
+
* =============================================================================
|
|
4
|
+
*
|
|
5
|
+
* PURPOSE: Establish strict auditable lineage from training run → checkpoint → eval
|
|
6
|
+
* so that "deployable" is a controlled state, not a free-text field.
|
|
7
|
+
*
|
|
8
|
+
* ARCHITECTURE:
|
|
9
|
+
* - Registry file: {stateDir}/.state/nocturnal/training-registry.json
|
|
10
|
+
* - Three record types in one store: TrainingRun, Checkpoint, EvalSummary
|
|
11
|
+
* - File locking on all write operations
|
|
12
|
+
* - Family alignment enforced at every transition
|
|
13
|
+
*
|
|
14
|
+
* LINEAGE CHAIN (enforced):
|
|
15
|
+
* TrainingRun → Checkpoint → EvalSummary
|
|
16
|
+
* DatasetFingerprint → TrainingRun → Checkpoint → EvalSummary
|
|
17
|
+
*
|
|
18
|
+
* DEPLOYABILITY RULE:
|
|
19
|
+
* A Checkpoint can only be marked deployable if:
|
|
20
|
+
* 1. It has an attached EvalSummary
|
|
21
|
+
* 2. The EvalSummary has a verdict of 'pass' or 'compare_only' (not 'fail')
|
|
22
|
+
* 3. The EvalSummary's targetModelFamily matches the Checkpoint's targetModelFamily
|
|
23
|
+
* 4. The Checkpoint's trainRun is in 'completed' status
|
|
24
|
+
*
|
|
25
|
+
* DESIGN CONSTRAINTS:
|
|
26
|
+
* - No real training invocation (Phase 4 only)
|
|
27
|
+
* - No checkpoint deploy routing (Phase 5)
|
|
28
|
+
* - No automatic promotion
|
|
29
|
+
* - Registry is append-only for runs and checkpoints
|
|
30
|
+
* - EvalSummary attachment is the only mutable operation on a Checkpoint
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Training run status — lifecycle enforced transitions.
|
|
34
|
+
*/
|
|
35
|
+
export type TrainingRunStatus = 'pending' | 'running' | 'completed' | 'failed';
|
|
36
|
+
/**
|
|
37
|
+
* A training run record — tracks one training job.
|
|
38
|
+
*/
|
|
39
|
+
export interface TrainingRun {
|
|
40
|
+
/** Unique identifier for this training run */
|
|
41
|
+
trainRunId: string;
|
|
42
|
+
/**
|
|
43
|
+
* Experiment ID this run belongs to.
|
|
44
|
+
* Enables lookup by experimentId in addition to trainRunId.
|
|
45
|
+
*/
|
|
46
|
+
experimentId: string;
|
|
47
|
+
/** Target model family this run produces checkpoints for */
|
|
48
|
+
targetModelFamily: string;
|
|
49
|
+
/**
|
|
50
|
+
* Fingerprint of the dataset used for this run.
|
|
51
|
+
* Links back to the ORPO export's datasetFingerprint.
|
|
52
|
+
*/
|
|
53
|
+
datasetFingerprint: string;
|
|
54
|
+
/**
|
|
55
|
+
* Reference to the ORPO export that provided the training data.
|
|
56
|
+
* Format: {exportId}
|
|
57
|
+
*/
|
|
58
|
+
exportId: string;
|
|
59
|
+
/** Number of samples from the export used in this run */
|
|
60
|
+
sampleCount: number;
|
|
61
|
+
/**
|
|
62
|
+
* Fingerprint of the training configuration used.
|
|
63
|
+
* For Phase 4 this is a placeholder (e.g., 'default-v0.1.0').
|
|
64
|
+
* Future: references an actual config artifact.
|
|
65
|
+
*/
|
|
66
|
+
configFingerprint: string;
|
|
67
|
+
/** ISO-8601 creation timestamp */
|
|
68
|
+
createdAt: string;
|
|
69
|
+
/** ISO-8601 completion timestamp (set when status becomes completed/failed) */
|
|
70
|
+
completedAt?: string;
|
|
71
|
+
/** Current status */
|
|
72
|
+
status: TrainingRunStatus;
|
|
73
|
+
/** Human-readable reason for failure (if status === 'failed') */
|
|
74
|
+
failureReason?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Checkpoint IDs produced by this run.
|
|
77
|
+
* A run may produce multiple checkpoints (e.g., epoch saves).
|
|
78
|
+
*/
|
|
79
|
+
checkpointIds: string[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A checkpoint record — a deployable artifact from a training run.
|
|
83
|
+
*/
|
|
84
|
+
export interface Checkpoint {
|
|
85
|
+
/** Unique identifier for this checkpoint */
|
|
86
|
+
checkpointId: string;
|
|
87
|
+
/** The training run that produced this checkpoint */
|
|
88
|
+
trainRunId: string;
|
|
89
|
+
/** Target model family (must match the TrainingRun's targetModelFamily) */
|
|
90
|
+
targetModelFamily: string;
|
|
91
|
+
/**
|
|
92
|
+
* Path to the checkpoint artifact.
|
|
93
|
+
* In Phase 4 this is a placeholder path.
|
|
94
|
+
* Future: path to adapter weights, config, etc.
|
|
95
|
+
*/
|
|
96
|
+
artifactPath: string;
|
|
97
|
+
/** ISO-8601 creation timestamp */
|
|
98
|
+
createdAt: string;
|
|
99
|
+
/**
|
|
100
|
+
* Whether this checkpoint can be routed to a worker.
|
|
101
|
+
* MUST be false until an EvalSummary is attached with verdict 'pass' or 'compare_only'.
|
|
102
|
+
* Cannot be set back to true after false without a new passing eval.
|
|
103
|
+
*/
|
|
104
|
+
deployable: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Reference to the attached EvalSummary (evalId).
|
|
107
|
+
* Required for deployable === true.
|
|
108
|
+
*/
|
|
109
|
+
lastEvalSummaryRef?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* An eval summary record — result of benchmarking a checkpoint.
|
|
113
|
+
*/
|
|
114
|
+
export interface EvalSummary {
|
|
115
|
+
/** Unique identifier for this eval */
|
|
116
|
+
evalId: string;
|
|
117
|
+
/** The checkpoint this eval was run against */
|
|
118
|
+
checkpointId: string;
|
|
119
|
+
/** The benchmark run this eval came from */
|
|
120
|
+
benchmarkId: string;
|
|
121
|
+
/**
|
|
122
|
+
* Target model family — MUST match the checkpoint's targetModelFamily.
|
|
123
|
+
* Enforced at attachEvalSummary() time.
|
|
124
|
+
* This field prevents a gpt-4 checkpoint from being validated by a claude-3 eval.
|
|
125
|
+
*/
|
|
126
|
+
targetModelFamily: string;
|
|
127
|
+
/** Evaluation mode: prompt-assisted or reduced-prompt */
|
|
128
|
+
mode: 'prompt_assisted' | 'reduced_prompt';
|
|
129
|
+
/** Baseline score from the benchmark (mean score of baseline checkpoint) */
|
|
130
|
+
baselineScore: number;
|
|
131
|
+
/** Candidate score from the benchmark (mean score of this checkpoint) */
|
|
132
|
+
candidateScore: number;
|
|
133
|
+
/** delta = candidateScore - baselineScore */
|
|
134
|
+
delta: number;
|
|
135
|
+
/** Verdict from the benchmark: pass | fail | compare_only */
|
|
136
|
+
verdict: 'pass' | 'fail' | 'compare_only';
|
|
137
|
+
/** ISO-8601 creation timestamp */
|
|
138
|
+
createdAt: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The complete training registry — all record types in one store.
|
|
142
|
+
*/
|
|
143
|
+
export interface ModelTrainingRegistry {
|
|
144
|
+
trainingRuns: TrainingRun[];
|
|
145
|
+
checkpoints: Checkpoint[];
|
|
146
|
+
evalSummaries: EvalSummary[];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Register a new training run.
|
|
150
|
+
*
|
|
151
|
+
* @param stateDir - Workspace state directory
|
|
152
|
+
* @param params - Run parameters
|
|
153
|
+
* @returns The registered TrainingRun
|
|
154
|
+
*/
|
|
155
|
+
export declare function registerTrainingRun(stateDir: string, params: {
|
|
156
|
+
experimentId: string;
|
|
157
|
+
targetModelFamily: string;
|
|
158
|
+
datasetFingerprint: string;
|
|
159
|
+
exportId: string;
|
|
160
|
+
sampleCount: number;
|
|
161
|
+
configFingerprint: string;
|
|
162
|
+
}): TrainingRun;
|
|
163
|
+
/**
|
|
164
|
+
* Update a training run's status.
|
|
165
|
+
*
|
|
166
|
+
* @throws Error if run not found or transition is invalid
|
|
167
|
+
*/
|
|
168
|
+
export declare function updateTrainingRunStatus(stateDir: string, trainRunId: string, newStatus: TrainingRunStatus, failureReason?: string): TrainingRun;
|
|
169
|
+
/**
|
|
170
|
+
* Complete a training run (convenience wrapper).
|
|
171
|
+
*/
|
|
172
|
+
export declare function completeTrainingRun(stateDir: string, trainRunId: string): TrainingRun;
|
|
173
|
+
/**
|
|
174
|
+
* Fail a training run (convenience wrapper).
|
|
175
|
+
*/
|
|
176
|
+
export declare function failTrainingRun(stateDir: string, trainRunId: string, reason: string): TrainingRun;
|
|
177
|
+
/**
|
|
178
|
+
* Start a training run (convenience wrapper).
|
|
179
|
+
*/
|
|
180
|
+
export declare function startTrainingRun(stateDir: string, trainRunId: string): TrainingRun;
|
|
181
|
+
/**
|
|
182
|
+
* Get a training run by ID.
|
|
183
|
+
*/
|
|
184
|
+
export declare function getTrainingRun(stateDir: string, trainRunId: string): TrainingRun | null;
|
|
185
|
+
/**
|
|
186
|
+
* List all training runs, optionally filtered by status or family.
|
|
187
|
+
*/
|
|
188
|
+
export declare function listTrainingRuns(stateDir: string, filter?: {
|
|
189
|
+
status?: TrainingRunStatus;
|
|
190
|
+
targetModelFamily?: string;
|
|
191
|
+
}): TrainingRun[];
|
|
192
|
+
/**
|
|
193
|
+
* Register a checkpoint produced by a training run.
|
|
194
|
+
*
|
|
195
|
+
* @throws Error if the training run is not found
|
|
196
|
+
* @throws Error if the targetModelFamily does not match the run's family
|
|
197
|
+
*/
|
|
198
|
+
export declare function registerCheckpoint(stateDir: string, params: {
|
|
199
|
+
trainRunId: string;
|
|
200
|
+
targetModelFamily: string;
|
|
201
|
+
artifactPath: string;
|
|
202
|
+
}): Checkpoint;
|
|
203
|
+
/**
|
|
204
|
+
* Get a checkpoint by ID.
|
|
205
|
+
*/
|
|
206
|
+
export declare function getCheckpoint(stateDir: string, checkpointId: string): Checkpoint | null;
|
|
207
|
+
/**
|
|
208
|
+
* List all checkpoints, optionally filtered.
|
|
209
|
+
*/
|
|
210
|
+
export declare function listCheckpoints(stateDir: string, filter?: {
|
|
211
|
+
trainRunId?: string;
|
|
212
|
+
targetModelFamily?: string;
|
|
213
|
+
deployable?: boolean;
|
|
214
|
+
}): Checkpoint[];
|
|
215
|
+
/**
|
|
216
|
+
* List all deployable checkpoints for a target model family.
|
|
217
|
+
*/
|
|
218
|
+
export declare function listDeployableCheckpoints(stateDir: string, targetModelFamily: string): Checkpoint[];
|
|
219
|
+
/**
|
|
220
|
+
* Attach an eval summary to a checkpoint.
|
|
221
|
+
*
|
|
222
|
+
* @param stateDir - Workspace state directory
|
|
223
|
+
* @param checkpointId - The checkpoint to attach to
|
|
224
|
+
* @param summary - The eval summary to attach
|
|
225
|
+
*
|
|
226
|
+
* @throws Error if checkpoint not found
|
|
227
|
+
* @throws Error if targetModelFamily mismatch between summary and checkpoint
|
|
228
|
+
*/
|
|
229
|
+
export declare function attachEvalSummary(stateDir: string, checkpointId: string, summary: Omit<EvalSummary, 'createdAt'>): EvalSummary;
|
|
230
|
+
/**
|
|
231
|
+
* Get an eval summary by ID.
|
|
232
|
+
*/
|
|
233
|
+
export declare function getEvalSummary(stateDir: string, evalId: string): EvalSummary | null;
|
|
234
|
+
/**
|
|
235
|
+
* List eval summaries, optionally filtered.
|
|
236
|
+
*/
|
|
237
|
+
export declare function listEvalSummaries(stateDir: string, filter?: {
|
|
238
|
+
checkpointId?: string;
|
|
239
|
+
benchmarkId?: string;
|
|
240
|
+
verdict?: EvalSummary['verdict'];
|
|
241
|
+
targetModelFamily?: string;
|
|
242
|
+
}): EvalSummary[];
|
|
243
|
+
/**
|
|
244
|
+
* MARK the deployability status of a checkpoint.
|
|
245
|
+
*
|
|
246
|
+
* DEPLOYABILITY RULE (fail-closed):
|
|
247
|
+
* A checkpoint can only be marked deployable if ALL of:
|
|
248
|
+
* 1. It has an attached EvalSummary (lastEvalSummaryRef is set)
|
|
249
|
+
* 2. The attached EvalSummary has verdict 'pass' or 'compare_only' (not 'fail')
|
|
250
|
+
* 3. The EvalSummary's targetModelFamily matches the Checkpoint's targetModelFamily
|
|
251
|
+
* NOTE: This is enforced at attachEvalSummary() time (see attachEvalSummary).
|
|
252
|
+
* If a mismatched-family eval is attached, attachEvalSummary throws before
|
|
253
|
+
* the registry is modified, so no eval with wrong family can ever reach here.
|
|
254
|
+
* 4. The parent TrainingRun is in 'completed' status
|
|
255
|
+
*
|
|
256
|
+
* @param stateDir - Workspace state directory
|
|
257
|
+
* @param checkpointId - The checkpoint to mark
|
|
258
|
+
* @param deployable - true to mark as deployable; false to revoke
|
|
259
|
+
*
|
|
260
|
+
* @throws Error if checkpoint not found
|
|
261
|
+
* @throws Error if preconditions for deployable=true are not met
|
|
262
|
+
*/
|
|
263
|
+
export declare function markCheckpointDeployable(stateDir: string, checkpointId: string, deployable: boolean): Checkpoint;
|
|
264
|
+
/**
|
|
265
|
+
* Convenience: check if a checkpoint is deployable.
|
|
266
|
+
*/
|
|
267
|
+
export declare function isCheckpointDeployable(stateDir: string, checkpointId: string): boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Get the full lineage chain for a checkpoint.
|
|
270
|
+
* Returns: { run, checkpoint, eval? } or null if not found.
|
|
271
|
+
*/
|
|
272
|
+
export declare function getCheckpointLineage(stateDir: string, checkpointId: string): {
|
|
273
|
+
run: TrainingRun;
|
|
274
|
+
checkpoint: Checkpoint;
|
|
275
|
+
eval: EvalSummary | null;
|
|
276
|
+
} | null;
|
|
277
|
+
/**
|
|
278
|
+
* Get the complete registry (for debugging/admin purposes).
|
|
279
|
+
*/
|
|
280
|
+
export declare function getFullRegistry(stateDir: string): ModelTrainingRegistry;
|
|
281
|
+
/**
|
|
282
|
+
* Compute stats for the training registry.
|
|
283
|
+
*/
|
|
284
|
+
export declare function getTrainingRegistryStats(stateDir: string): {
|
|
285
|
+
totalRuns: number;
|
|
286
|
+
completedRuns: number;
|
|
287
|
+
failedRuns: number;
|
|
288
|
+
pendingRuns: number;
|
|
289
|
+
runningRuns: number;
|
|
290
|
+
totalCheckpoints: number;
|
|
291
|
+
deployableCheckpoints: number;
|
|
292
|
+
totalEvals: number;
|
|
293
|
+
passingEvals: number;
|
|
294
|
+
failingEvals: number;
|
|
295
|
+
};
|