create-principles-disciple 1.89.0 → 1.91.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.
Files changed (53) hide show
  1. package/console/dist/ui/api.d.ts +2 -1
  2. package/console/dist/ui/api.js +7 -1
  3. package/console/dist/ui/i18n/en.json +18 -1
  4. package/console/dist/ui/i18n/zh-CN.json +18 -1
  5. package/console/dist/ui/pages/focus/FocusPage.js +48 -4
  6. package/console/dist/ui/pages/principles/PrincipleDetailPage.js +70 -2
  7. package/console/dist/web/assets/app.js +1541 -1223
  8. package/console/package.json +2 -2
  9. package/core/dist/prompt-builder/__tests__/routing-guidance.test.d.ts +1 -2
  10. package/core/dist/prompt-builder/__tests__/routing-guidance.test.d.ts.map +1 -1
  11. package/core/dist/prompt-builder/__tests__/routing-guidance.test.js +1 -2
  12. package/core/dist/prompt-builder/__tests__/routing-guidance.test.js.map +1 -1
  13. package/core/dist/prompt-builder/routing-guidance.d.ts +0 -1
  14. package/core/dist/prompt-builder/routing-guidance.d.ts.map +1 -1
  15. package/core/dist/prompt-builder/routing-guidance.js +0 -1
  16. package/core/dist/prompt-builder/routing-guidance.js.map +1 -1
  17. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +5 -43
  18. package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
  19. package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js +205 -2
  20. package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js.map +1 -1
  21. package/core/dist/runtime-v2/adapter/__tests__/schema-prompt-adapter.test.js +17 -1
  22. package/core/dist/runtime-v2/adapter/__tests__/schema-prompt-adapter.test.js.map +1 -1
  23. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts +4 -1
  24. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  25. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js +6 -3
  26. package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js.map +1 -1
  27. package/core/dist/runtime-v2/adapter/tools/diagnostician-tool.d.ts +20 -7
  28. package/core/dist/runtime-v2/adapter/tools/diagnostician-tool.d.ts.map +1 -1
  29. package/core/dist/runtime-v2/adapter/tools/diagnostician-tool.js +19 -3
  30. package/core/dist/runtime-v2/adapter/tools/diagnostician-tool.js.map +1 -1
  31. package/core/dist/runtime-v2/feature-flags/__tests__/plugin-surface-registry.test.js +3 -3
  32. package/core/dist/runtime-v2/feature-flags/__tests__/plugin-surface-registry.test.js.map +1 -1
  33. package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.d.ts.map +1 -1
  34. package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.js +0 -18
  35. package/core/dist/runtime-v2/feature-flags/plugin-surface-registry.js.map +1 -1
  36. package/core/package.json +1 -1
  37. package/package.json +2 -2
  38. package/pd-cli/package.json +1 -1
  39. package/plugin/dist/hooks/prompt.js +4 -5
  40. package/plugin/dist/index.js +0 -83
  41. package/plugin/package.json +2 -2
  42. package/plugin/dist/core/local-worker-routing.d.ts +0 -124
  43. package/plugin/dist/core/local-worker-routing.js +0 -216
  44. package/plugin/dist/core/model-deployment-registry.d.ts +0 -218
  45. package/plugin/dist/core/model-deployment-registry.js +0 -502
  46. package/plugin/dist/core/model-training-registry.d.ts +0 -295
  47. package/plugin/dist/core/model-training-registry.js +0 -474
  48. package/plugin/dist/core/promotion-gate.d.ts +0 -243
  49. package/plugin/dist/core/promotion-gate.js +0 -554
  50. package/plugin/dist/core/shadow-observation-registry.d.ts +0 -217
  51. package/plugin/dist/core/shadow-observation-registry.js +0 -280
  52. package/plugin/dist/utils/shadow-fingerprint.d.ts +0 -16
  53. package/plugin/dist/utils/shadow-fingerprint.js +0 -34
@@ -1,243 +0,0 @@
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
- evidenceSummary: {
150
- evidenceMode: 'shadow' | 'eval-proxy' | 'mixed';
151
- shadowSampleCount: number;
152
- deltaSource: 'eval';
153
- };
154
- }
155
- /**
156
- * Parameters for evaluating the promotion gate.
157
- */
158
- export interface EvaluateGateParams {
159
- /** Checkpoint ID to evaluate */
160
- checkpointId: string;
161
- /** Target worker profile */
162
- targetProfile: TrainableWorkerProfile;
163
- /** Baseline metrics for comparison */
164
- baselineMetrics: BaselineMetrics;
165
- /** Minimum delta threshold for positive signal */
166
- minDelta?: number;
167
- /** Allowed margin for constraint metrics */
168
- allowedMargin?: number;
169
- }
170
- /**
171
- * Evaluate whether a checkpoint passes the promotion gate.
172
- *
173
- * @param stateDir - Workspace state directory
174
- * @param params - Evaluation parameters
175
- * @returns PromotionGateResult with pass/fail and details
176
- *
177
- * FAIL-CLOSED: Returns { passes: false } if:
178
- * - No eval attached to checkpoint
179
- * - Delta is negative or below threshold
180
- * - Any constraint metric regresses beyond allowed margin
181
- * - Profile is not in allowed rollout list
182
- */
183
- export declare function evaluatePromotionGate(stateDir: string, params: EvaluateGateParams): PromotionGateResult;
184
- /**
185
- * Parameters for advancing promotion state.
186
- */
187
- export interface AdvancePromotionParams {
188
- /** Checkpoint ID to promote */
189
- checkpointId: string;
190
- /** Target worker profile */
191
- targetProfile: TrainableWorkerProfile;
192
- /** Baseline metrics for comparison */
193
- baselineMetrics: BaselineMetrics;
194
- /** Orchestrator review passed (required for promotable) */
195
- orchestratorReviewPassed?: boolean;
196
- /** Human review note */
197
- reviewNote?: string;
198
- /** Minimum delta threshold */
199
- minDelta?: number;
200
- /** Allowed margin for constraints */
201
- allowedMargin?: number;
202
- }
203
- /**
204
- * Advance a checkpoint's promotion state.
205
- *
206
- * @param stateDir - Workspace state directory
207
- * @param params - Advancement parameters
208
- * @returns The updated PromotionRecord
209
- *
210
- * @throws Error if gate evaluation fails
211
- * @throws Error if state transition is not allowed
212
- */
213
- export declare function advancePromotion(stateDir: string, params: AdvancePromotionParams): PromotionRecord;
214
- /**
215
- * Get the current promotion state for a checkpoint.
216
- */
217
- export declare function getPromotionState(stateDir: string, checkpointId: string): PromotionState | null;
218
- /**
219
- * Get the promotion record for a checkpoint.
220
- */
221
- export declare function getPromotionRecord(stateDir: string, checkpointId: string): PromotionRecord | null;
222
- /**
223
- * List promotions by state.
224
- */
225
- export declare function listPromotionsByState(stateDir: string, state: PromotionState): PromotionRecord[];
226
- /**
227
- * List all promotions for a profile.
228
- */
229
- export declare function listPromotionsForProfile(stateDir: string, targetProfile: TrainableWorkerProfile): PromotionRecord[];
230
- /**
231
- * Reject a checkpoint, preventing it from being promoted.
232
- *
233
- * @param stateDir - Workspace state directory
234
- * @param checkpointId - Checkpoint to reject
235
- * @param reason - Reason for rejection
236
- * @returns The updated PromotionRecord
237
- */
238
- export declare function rejectCheckpoint(stateDir: string, checkpointId: string, reason: string): PromotionRecord;
239
- /**
240
- * Default baseline metrics for Phase 7.
241
- * These represent the "acceptable" thresholds that new checkpoints must meet.
242
- */
243
- export declare const DEFAULT_BASELINE_METRICS: BaselineMetrics;