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,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Deployment Registry — Worker Profile → Checkpoint Binding & Routing Control
|
|
3
|
+
* ===============================================================================
|
|
4
|
+
*
|
|
5
|
+
* PURPOSE: Establish auditable, reversible bindings between worker profiles and
|
|
6
|
+
* trained model checkpoints so that routing decisions are code-governed and
|
|
7
|
+
* rollback-safe.
|
|
8
|
+
*
|
|
9
|
+
* ARCHITECTURE:
|
|
10
|
+
* - Registry file: {stateDir}/.state/nocturnal/deployment-registry.json
|
|
11
|
+
* - File locking on all write operations
|
|
12
|
+
* - Immutable deployment records — rollback uses previousCheckpointId
|
|
13
|
+
* - Tight integration with model-training-registry for checkpoint validation
|
|
14
|
+
*
|
|
15
|
+
* PROFILE CONSTRAINTS (Phase 5 only):
|
|
16
|
+
* - local-reader → must bind a checkpoint whose targetModelFamily is a "reader" family
|
|
17
|
+
* - local-editor → must bind a checkpoint whose targetModelFamily is an "editor" family
|
|
18
|
+
* - No other profiles are accepted
|
|
19
|
+
*
|
|
20
|
+
* BINDING RULES:
|
|
21
|
+
* - Only a deployable checkpoint can be bound
|
|
22
|
+
* - The checkpoint's targetModelFamily must satisfy the profile's family constraint
|
|
23
|
+
* - binding sets routingEnabled = false; enableRoutingForProfile() must be called explicitly
|
|
24
|
+
* - rollbackDeployment() returns to previousCheckpointId (if any)
|
|
25
|
+
*
|
|
26
|
+
* DESIGN CONSTRAINTS:
|
|
27
|
+
* - No actual task routing execution (Phase 5 only)
|
|
28
|
+
* - No automatic promotion or failover
|
|
29
|
+
* - Registry is append-only for deployments; rollback creates a new binding
|
|
30
|
+
*/
|
|
31
|
+
import type { Checkpoint } from './model-training-registry.js';
|
|
32
|
+
/**
|
|
33
|
+
* Worker profiles supported in Phase 5.
|
|
34
|
+
* Only these two profiles may be registered.
|
|
35
|
+
*/
|
|
36
|
+
export type WorkerProfile = 'local-reader' | 'local-editor';
|
|
37
|
+
/**
|
|
38
|
+
* The set of valid Phase 5 worker profile names.
|
|
39
|
+
*/
|
|
40
|
+
export declare const SUPPORTED_PROFILES: readonly WorkerProfile[];
|
|
41
|
+
/**
|
|
42
|
+
* A deployment record — binds a worker profile to a specific checkpoint
|
|
43
|
+
* and controls whether routing is enabled for that profile.
|
|
44
|
+
*/
|
|
45
|
+
export interface Deployment {
|
|
46
|
+
/** Unique identifier for this deployment record */
|
|
47
|
+
deploymentId: string;
|
|
48
|
+
/** Worker profile this deployment targets (local-reader | local-editor) */
|
|
49
|
+
workerProfile: WorkerProfile;
|
|
50
|
+
/**
|
|
51
|
+
* The model family this deployment targets.
|
|
52
|
+
* Derived from the bound checkpoint at bind time; stored for quick queries.
|
|
53
|
+
*/
|
|
54
|
+
targetModelFamily: string;
|
|
55
|
+
/**
|
|
56
|
+
* The currently active checkpoint for this profile.
|
|
57
|
+
* null means the profile is bound but no checkpoint is active (e.g., after rollback).
|
|
58
|
+
*/
|
|
59
|
+
activeCheckpointId: string | null;
|
|
60
|
+
/**
|
|
61
|
+
* The previously active checkpoint (before the current activeCheckpointId).
|
|
62
|
+
* Used for rollback. null if no previous checkpoint exists.
|
|
63
|
+
*/
|
|
64
|
+
previousCheckpointId: string | null;
|
|
65
|
+
/**
|
|
66
|
+
* Whether routing to this worker profile is currently permitted.
|
|
67
|
+
* Must be explicitly enabled via enableRoutingForProfile().
|
|
68
|
+
* Cannot be true if activeCheckpointId is null.
|
|
69
|
+
*/
|
|
70
|
+
routingEnabled: boolean;
|
|
71
|
+
/** ISO-8601 timestamp — when this binding was first created */
|
|
72
|
+
deployedAt: string;
|
|
73
|
+
/** ISO-8601 timestamp — when this binding was last updated (checkpoint change or flag toggle) */
|
|
74
|
+
updatedAt: string;
|
|
75
|
+
/**
|
|
76
|
+
* Optional human-readable note about this deployment.
|
|
77
|
+
* E.g., "initial deployment", "rollback from eval failure", "promoted after 30-day holdout".
|
|
78
|
+
*/
|
|
79
|
+
note?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The complete deployment registry — all deployment records in one store.
|
|
83
|
+
*/
|
|
84
|
+
export interface ModelDeploymentRegistry {
|
|
85
|
+
deployments: Deployment[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Validate that a worker profile name is supported in Phase 5.
|
|
89
|
+
*
|
|
90
|
+
* @throws Error if the profile is not in SUPPORTED_PROFILES
|
|
91
|
+
*/
|
|
92
|
+
export declare function assertSupportedProfile(profile: string): asserts profile is WorkerProfile;
|
|
93
|
+
/**
|
|
94
|
+
* Check if a checkpoint has passed the promotion gate and can be deployed.
|
|
95
|
+
*
|
|
96
|
+
* This function checks:
|
|
97
|
+
* 1. The checkpoint has an eval summary attached (lineage complete)
|
|
98
|
+
* 2. The promotion state is 'shadow_ready' or 'promotable' (gate passed)
|
|
99
|
+
*
|
|
100
|
+
* @param stateDir - Workspace state directory
|
|
101
|
+
* @param checkpointId - Checkpoint to verify
|
|
102
|
+
* @returns true if the checkpoint can be deployed, false otherwise
|
|
103
|
+
*/
|
|
104
|
+
export declare function hasPassedPromotionGate(stateDir: string, checkpointId: string): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Assert that a checkpoint has passed the promotion gate.
|
|
107
|
+
* Throws if the checkpoint cannot be deployed.
|
|
108
|
+
*
|
|
109
|
+
* @param stateDir - Workspace state directory
|
|
110
|
+
* @param checkpointId - Checkpoint to verify
|
|
111
|
+
* @throws Error if the checkpoint has not passed the promotion gate
|
|
112
|
+
*/
|
|
113
|
+
export declare function assertPromotionGatePassed(stateDir: string, checkpointId: string): void;
|
|
114
|
+
/**
|
|
115
|
+
* Bind a checkpoint to a worker profile, creating or updating the deployment record.
|
|
116
|
+
*
|
|
117
|
+
* BINDING RULE (fail-closed):
|
|
118
|
+
* Only a checkpoint that is marked deployable in the training registry may be bound.
|
|
119
|
+
*
|
|
120
|
+
* PROFILE-FAMILY CONSTRAINT:
|
|
121
|
+
* The checkpoint's targetModelFamily must satisfy the profile's family keyword constraint.
|
|
122
|
+
* See: validateProfileFamilyConstraint()
|
|
123
|
+
*
|
|
124
|
+
* @param stateDir - Workspace state directory
|
|
125
|
+
* @param workerProfile - Target worker profile (local-reader | local-editor)
|
|
126
|
+
* @param checkpointId - Checkpoint to bind (must be deployable)
|
|
127
|
+
* @param note - Optional human-readable note
|
|
128
|
+
* @returns The new or updated Deployment record
|
|
129
|
+
*
|
|
130
|
+
* @throws Error if checkpoint is not found or not deployable
|
|
131
|
+
* @throws Error if checkpoint's targetModelFamily violates profile constraints
|
|
132
|
+
*/
|
|
133
|
+
export declare function bindCheckpointToWorkerProfile(stateDir: string, workerProfile: WorkerProfile, checkpointId: string, note?: string): Deployment;
|
|
134
|
+
/**
|
|
135
|
+
* Retrieve the deployment record for a worker profile.
|
|
136
|
+
*
|
|
137
|
+
* @returns Deployment if found, null otherwise
|
|
138
|
+
*/
|
|
139
|
+
export declare function getDeployment(stateDir: string, workerProfile: WorkerProfile): Deployment | null;
|
|
140
|
+
/**
|
|
141
|
+
* List all deployments, optionally filtered.
|
|
142
|
+
*
|
|
143
|
+
* @param stateDir - Workspace state directory
|
|
144
|
+
* @param filter - Optional filter criteria
|
|
145
|
+
*/
|
|
146
|
+
export declare function listDeployments(stateDir: string, filter?: {
|
|
147
|
+
workerProfile?: WorkerProfile;
|
|
148
|
+
routingEnabled?: boolean;
|
|
149
|
+
}): Deployment[];
|
|
150
|
+
/**
|
|
151
|
+
* Enable routing for a worker profile.
|
|
152
|
+
*
|
|
153
|
+
* PRECONDITIONS (fail-closed):
|
|
154
|
+
* 1. A deployment record must exist for this profile
|
|
155
|
+
* 2. activeCheckpointId must not be null
|
|
156
|
+
*
|
|
157
|
+
* @throws Error if no deployment exists
|
|
158
|
+
* @throws Error if activeCheckpointId is null (nothing to route to)
|
|
159
|
+
*/
|
|
160
|
+
export declare function enableRoutingForProfile(stateDir: string, workerProfile: WorkerProfile): Deployment;
|
|
161
|
+
/**
|
|
162
|
+
* Disable routing for a worker profile.
|
|
163
|
+
* This is always safe — it does not unbind the checkpoint.
|
|
164
|
+
*
|
|
165
|
+
* @throws Error if no deployment exists for the profile
|
|
166
|
+
*/
|
|
167
|
+
export declare function disableRoutingForProfile(stateDir: string, workerProfile: WorkerProfile): Deployment;
|
|
168
|
+
/**
|
|
169
|
+
* Roll back the deployment for a worker profile to its previous checkpoint.
|
|
170
|
+
*
|
|
171
|
+
* ROLLBACK RULE:
|
|
172
|
+
* - Can only roll back if previousCheckpointId is not null
|
|
173
|
+
* - Sets activeCheckpointId = previousCheckpointId
|
|
174
|
+
* - The old activeCheckpointId becomes the new previousCheckpointId
|
|
175
|
+
* - routingEnabled is set to false (must be re-enabled explicitly)
|
|
176
|
+
*
|
|
177
|
+
* @throws Error if no deployment exists
|
|
178
|
+
* @throws Error if no previous checkpoint is available
|
|
179
|
+
*/
|
|
180
|
+
export declare function rollbackDeployment(stateDir: string, workerProfile: WorkerProfile, note?: string): Deployment;
|
|
181
|
+
/**
|
|
182
|
+
* Check whether a worker profile currently has an enabled deployment
|
|
183
|
+
* with an active checkpoint that is still deployable.
|
|
184
|
+
*
|
|
185
|
+
* GOVERNANCE: Even if routing was previously enabled, a checkpoint that
|
|
186
|
+
* has been revoked (marked non-deployable via markCheckpointDeployable(false))
|
|
187
|
+
* must not be used for routing. This prevents routing traffic to a
|
|
188
|
+
* checkpoint that has been superseded or failed re-evaluation.
|
|
189
|
+
*/
|
|
190
|
+
export declare function isRoutingEnabledForProfile(stateDir: string, workerProfile: WorkerProfile): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Get the active checkpoint ID for a worker profile.
|
|
193
|
+
* Returns null if no deployment or no active checkpoint.
|
|
194
|
+
*/
|
|
195
|
+
export declare function getActiveCheckpointForProfile(stateDir: string, workerProfile: WorkerProfile): string | null;
|
|
196
|
+
/**
|
|
197
|
+
* Get the full deployment record with lineage context.
|
|
198
|
+
* Returns null if no deployment exists.
|
|
199
|
+
*
|
|
200
|
+
* Lineage includes: deployment record, active checkpoint, parent training run, eval summary.
|
|
201
|
+
*/
|
|
202
|
+
export declare function getDeploymentLineage(stateDir: string, workerProfile: WorkerProfile): {
|
|
203
|
+
deployment: Deployment;
|
|
204
|
+
activeCheckpoint: Checkpoint | null;
|
|
205
|
+
} | null;
|
|
206
|
+
/**
|
|
207
|
+
* Get the complete deployment registry (for debugging/admin purposes).
|
|
208
|
+
*/
|
|
209
|
+
export declare function getFullDeploymentRegistry(stateDir: string): ModelDeploymentRegistry;
|
|
210
|
+
/**
|
|
211
|
+
* Compute stats for the deployment registry.
|
|
212
|
+
*/
|
|
213
|
+
export declare function getDeploymentRegistryStats(stateDir: string): {
|
|
214
|
+
totalDeployments: number;
|
|
215
|
+
activeDeployments: number;
|
|
216
|
+
profilesWithBindings: number;
|
|
217
|
+
profilesWithRoutingEnabled: number;
|
|
218
|
+
};
|