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,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Promotion Gate — Checkpoint Promotion State Machine and Gate Logic
|
|
3
|
+
* ==================================================================
|
|
4
|
+
*
|
|
5
|
+
* PURPOSE: Control when a checkpoint can advance from training → shadow → promotion.
|
|
6
|
+
* Training success alone is not enough — a checkpoint must prove it improves
|
|
7
|
+
* bounded worker behavior under the existing offline benchmark and does not
|
|
8
|
+
* regress runtime safety signals.
|
|
9
|
+
*
|
|
10
|
+
* PROMOTION STATES:
|
|
11
|
+
* - rejected: The checkpoint must not be routed
|
|
12
|
+
* - candidate_only: The checkpoint is valid but not yet ready for shadow
|
|
13
|
+
* - shadow_ready: The checkpoint may enter controlled shadow rollout
|
|
14
|
+
* - promotable: The checkpoint may replace the active checkpoint
|
|
15
|
+
*
|
|
16
|
+
* STATE TRANSITIONS:
|
|
17
|
+
* training_completed
|
|
18
|
+
* ↓
|
|
19
|
+
* candidate_only ←── (eval attached, lineage complete)
|
|
20
|
+
* ↓
|
|
21
|
+
* shadow_ready ←── (positive delta, safe constraints)
|
|
22
|
+
* ↓
|
|
23
|
+
* promotable ←── (shadow window passed, orchestrator review passed)
|
|
24
|
+
* ↓
|
|
25
|
+
* deployed
|
|
26
|
+
*
|
|
27
|
+
* PRIMARY OBJECTIVE:
|
|
28
|
+
* maximize reduced_prompt_holdout_delta
|
|
29
|
+
*
|
|
30
|
+
* CONSTRAINT METRICS (must all pass for promotion):
|
|
31
|
+
* - arbiterRejectRate <= baseline + allowedMargin
|
|
32
|
+
* - executabilityRejectRate <= baseline + allowedMargin
|
|
33
|
+
* - reviewedSubsetQuality >= baseline
|
|
34
|
+
* - routingScopeNotExpanded == true
|
|
35
|
+
*
|
|
36
|
+
* DESIGN CONSTRAINTS:
|
|
37
|
+
* - No automatic promotion without explicit gate approval
|
|
38
|
+
* - Orchestrator review remains mandatory for all promotions
|
|
39
|
+
* - Rollback path must be always available
|
|
40
|
+
* - First rollout limited to `local-reader` only
|
|
41
|
+
*/
|
|
42
|
+
import { type TrainableWorkerProfile } from './external-training-contract.js';
|
|
43
|
+
/**
|
|
44
|
+
* Candidate delta must exceed this to enter shadow_ready.
|
|
45
|
+
*/
|
|
46
|
+
export declare const DEFAULT_MIN_DELTA = 0.05;
|
|
47
|
+
/**
|
|
48
|
+
* Default allowed margin for constraint metrics.
|
|
49
|
+
* Constraint metrics can regress by at most this amount.
|
|
50
|
+
*/
|
|
51
|
+
export declare const DEFAULT_ALLOWED_MARGIN = 0.05;
|
|
52
|
+
/**
|
|
53
|
+
* Minimum shadow window duration in milliseconds.
|
|
54
|
+
* A checkpoint must remain in shadow_ready for at least this duration
|
|
55
|
+
* before it can be promoted to promotable.
|
|
56
|
+
*
|
|
57
|
+
* Phase 7 default: 1 hour (3600000 ms)
|
|
58
|
+
* This gives time for real-world feedback before full promotion.
|
|
59
|
+
*/
|
|
60
|
+
export declare const MIN_SHADOW_WINDOW_MS: number;
|
|
61
|
+
/**
|
|
62
|
+
* Promotion states for a checkpoint.
|
|
63
|
+
*/
|
|
64
|
+
export type PromotionState = 'rejected' | 'candidate_only' | 'shadow_ready' | 'promotable';
|
|
65
|
+
/**
|
|
66
|
+
* Constraint metrics for promotion gate.
|
|
67
|
+
*/
|
|
68
|
+
export interface PromotionConstraints {
|
|
69
|
+
arbiterRejectRate: number;
|
|
70
|
+
executabilityRejectRate: number;
|
|
71
|
+
reviewedSubsetQuality: number;
|
|
72
|
+
routingScopeNotExpanded: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Baseline metrics for comparison.
|
|
76
|
+
*/
|
|
77
|
+
export interface BaselineMetrics {
|
|
78
|
+
arbiterRejectRate: number;
|
|
79
|
+
executabilityRejectRate: number;
|
|
80
|
+
reviewedSubsetQuality: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A promotion record — tracks the state and lineage of a promoted checkpoint.
|
|
84
|
+
*/
|
|
85
|
+
export interface PromotionRecord {
|
|
86
|
+
/** Unique identifier for this promotion record */
|
|
87
|
+
promotionId: string;
|
|
88
|
+
/** Checkpoint being promoted */
|
|
89
|
+
checkpointId: string;
|
|
90
|
+
/** Current promotion state */
|
|
91
|
+
state: PromotionState;
|
|
92
|
+
/** Worker profile this promotion targets */
|
|
93
|
+
targetProfile: TrainableWorkerProfile;
|
|
94
|
+
/** Target model family */
|
|
95
|
+
targetModelFamily: string;
|
|
96
|
+
/** Reduced-prompt holdout delta (primary objective) */
|
|
97
|
+
reducedPromptDelta: number;
|
|
98
|
+
/** Constraint metrics at time of promotion */
|
|
99
|
+
constraintMetrics: PromotionConstraints;
|
|
100
|
+
/** Baseline metrics used for comparison */
|
|
101
|
+
baselineMetrics: BaselineMetrics;
|
|
102
|
+
/** Whether orchestrator review was passed */
|
|
103
|
+
orchestratorReviewPassed: boolean;
|
|
104
|
+
/** Human review note (if any) */
|
|
105
|
+
reviewNote?: string;
|
|
106
|
+
/** ISO-8601 timestamp when state last changed */
|
|
107
|
+
stateChangedAt: string;
|
|
108
|
+
/** ISO-8601 timestamp when promotion record was created */
|
|
109
|
+
createdAt: string;
|
|
110
|
+
/** ISO-8601 timestamp when shadow window opened (if applicable) */
|
|
111
|
+
shadowStartedAt?: string;
|
|
112
|
+
/** ISO-8601 timestamp when promotable was achieved */
|
|
113
|
+
promotableAt?: string;
|
|
114
|
+
/** Previous promotion record ID (for rollback chain) */
|
|
115
|
+
previousPromotionId?: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The complete promotion registry.
|
|
119
|
+
*/
|
|
120
|
+
export interface PromotionRegistry {
|
|
121
|
+
promotions: PromotionRecord[];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Result of evaluating the promotion gate.
|
|
125
|
+
*/
|
|
126
|
+
export interface PromotionGateResult {
|
|
127
|
+
/** Whether the checkpoint passes the gate */
|
|
128
|
+
passes: boolean;
|
|
129
|
+
/** The promotion state if passed */
|
|
130
|
+
suggestedState?: PromotionState;
|
|
131
|
+
/** Reasons for rejection (if not passed) */
|
|
132
|
+
blockers: string[];
|
|
133
|
+
/** Details about each constraint check */
|
|
134
|
+
constraintChecks: {
|
|
135
|
+
constraint: string;
|
|
136
|
+
actual: number;
|
|
137
|
+
baseline: number;
|
|
138
|
+
threshold: number;
|
|
139
|
+
passed: boolean;
|
|
140
|
+
/** Source of the evidence: 'shadow' (real runtime) or 'eval-proxy' (fallback) */
|
|
141
|
+
source?: 'shadow' | 'eval-proxy';
|
|
142
|
+
}[];
|
|
143
|
+
/** Primary objective (delta) check */
|
|
144
|
+
deltaCheck: {
|
|
145
|
+
actual: number;
|
|
146
|
+
threshold: number;
|
|
147
|
+
passed: boolean;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Parameters for evaluating the promotion gate.
|
|
152
|
+
*/
|
|
153
|
+
export interface EvaluateGateParams {
|
|
154
|
+
/** Checkpoint ID to evaluate */
|
|
155
|
+
checkpointId: string;
|
|
156
|
+
/** Target worker profile */
|
|
157
|
+
targetProfile: TrainableWorkerProfile;
|
|
158
|
+
/** Baseline metrics for comparison */
|
|
159
|
+
baselineMetrics: BaselineMetrics;
|
|
160
|
+
/** Minimum delta threshold for positive signal */
|
|
161
|
+
minDelta?: number;
|
|
162
|
+
/** Allowed margin for constraint metrics */
|
|
163
|
+
allowedMargin?: number;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Evaluate whether a checkpoint passes the promotion gate.
|
|
167
|
+
*
|
|
168
|
+
* @param stateDir - Workspace state directory
|
|
169
|
+
* @param params - Evaluation parameters
|
|
170
|
+
* @returns PromotionGateResult with pass/fail and details
|
|
171
|
+
*
|
|
172
|
+
* FAIL-CLOSED: Returns { passes: false } if:
|
|
173
|
+
* - No eval attached to checkpoint
|
|
174
|
+
* - Delta is negative or below threshold
|
|
175
|
+
* - Any constraint metric regresses beyond allowed margin
|
|
176
|
+
* - Profile is not in allowed rollout list
|
|
177
|
+
*/
|
|
178
|
+
export declare function evaluatePromotionGate(stateDir: string, params: EvaluateGateParams): PromotionGateResult;
|
|
179
|
+
/**
|
|
180
|
+
* Parameters for advancing promotion state.
|
|
181
|
+
*/
|
|
182
|
+
export interface AdvancePromotionParams {
|
|
183
|
+
/** Checkpoint ID to promote */
|
|
184
|
+
checkpointId: string;
|
|
185
|
+
/** Target worker profile */
|
|
186
|
+
targetProfile: TrainableWorkerProfile;
|
|
187
|
+
/** Baseline metrics for comparison */
|
|
188
|
+
baselineMetrics: BaselineMetrics;
|
|
189
|
+
/** Orchestrator review passed (required for promotable) */
|
|
190
|
+
orchestratorReviewPassed?: boolean;
|
|
191
|
+
/** Human review note */
|
|
192
|
+
reviewNote?: string;
|
|
193
|
+
/** Minimum delta threshold */
|
|
194
|
+
minDelta?: number;
|
|
195
|
+
/** Allowed margin for constraints */
|
|
196
|
+
allowedMargin?: number;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Advance a checkpoint's promotion state.
|
|
200
|
+
*
|
|
201
|
+
* @param stateDir - Workspace state directory
|
|
202
|
+
* @param params - Advancement parameters
|
|
203
|
+
* @returns The updated PromotionRecord
|
|
204
|
+
*
|
|
205
|
+
* @throws Error if gate evaluation fails
|
|
206
|
+
* @throws Error if state transition is not allowed
|
|
207
|
+
*/
|
|
208
|
+
export declare function advancePromotion(stateDir: string, params: AdvancePromotionParams): PromotionRecord;
|
|
209
|
+
/**
|
|
210
|
+
* Get the current promotion state for a checkpoint.
|
|
211
|
+
*/
|
|
212
|
+
export declare function getPromotionState(stateDir: string, checkpointId: string): PromotionState | null;
|
|
213
|
+
/**
|
|
214
|
+
* Get the promotion record for a checkpoint.
|
|
215
|
+
*/
|
|
216
|
+
export declare function getPromotionRecord(stateDir: string, checkpointId: string): PromotionRecord | null;
|
|
217
|
+
/**
|
|
218
|
+
* List promotions by state.
|
|
219
|
+
*/
|
|
220
|
+
export declare function listPromotionsByState(stateDir: string, state: PromotionState): PromotionRecord[];
|
|
221
|
+
/**
|
|
222
|
+
* List all promotions for a profile.
|
|
223
|
+
*/
|
|
224
|
+
export declare function listPromotionsForProfile(stateDir: string, targetProfile: TrainableWorkerProfile): PromotionRecord[];
|
|
225
|
+
/**
|
|
226
|
+
* Reject a checkpoint, preventing it from being promoted.
|
|
227
|
+
*
|
|
228
|
+
* @param stateDir - Workspace state directory
|
|
229
|
+
* @param checkpointId - Checkpoint to reject
|
|
230
|
+
* @param reason - Reason for rejection
|
|
231
|
+
* @returns The updated PromotionRecord
|
|
232
|
+
*/
|
|
233
|
+
export declare function rejectCheckpoint(stateDir: string, checkpointId: string, reason: string): PromotionRecord;
|
|
234
|
+
/**
|
|
235
|
+
* Default baseline metrics for Phase 7.
|
|
236
|
+
* These represent the "acceptable" thresholds that new checkpoints must meet.
|
|
237
|
+
*/
|
|
238
|
+
export declare const DEFAULT_BASELINE_METRICS: BaselineMetrics;
|