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,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local Worker Routing Policy — Task Classification and Routing Decisions
|
|
3
|
+
* ======================================================================
|
|
4
|
+
*
|
|
5
|
+
* PURPOSE: Provide an explainable, testable policy that decides whether a given
|
|
6
|
+
* task can be delegated to a local-worker profile (local-reader or local-editor)
|
|
7
|
+
* or must stay on the main agent.
|
|
8
|
+
*
|
|
9
|
+
* ARCHITECTURE:
|
|
10
|
+
* - This module is POLICY ONLY — it makes routing decisions but does NOT execute them
|
|
11
|
+
* - The main agent (or a delegation hook in a future phase) is responsible for
|
|
12
|
+
* actually routing the task based on the RoutingDecision returned here
|
|
13
|
+
* - All decisions are deterministic and based on structured input fields
|
|
14
|
+
* - No model inference, no learning, no dynamic adaptation
|
|
15
|
+
*
|
|
16
|
+
* TASK CLASSIFICATION TAXONOMY:
|
|
17
|
+
* reader_eligible — clearly suitable for local-reader
|
|
18
|
+
* editor_eligible — clearly suitable for local-editor
|
|
19
|
+
* high_entropy_disallowed — high-complexity tasks that must stay on main agent
|
|
20
|
+
* risk_disallowed — tasks with destructive or high-risk signals
|
|
21
|
+
* ambiguous_scope — tasks that are unclear and need main-agent judgment
|
|
22
|
+
* deployment_unavailable — no enabled deployment exists for the target profile
|
|
23
|
+
*
|
|
24
|
+
* FAIL-CLOSED PRINCIPLE:
|
|
25
|
+
* - When in doubt → stay_main
|
|
26
|
+
* - Unclear intent → stay_main
|
|
27
|
+
* - High complexity → stay_main
|
|
28
|
+
* - Any risk signal → stay_main
|
|
29
|
+
* - No enabled deployment → stay_main
|
|
30
|
+
*
|
|
31
|
+
* DESIGN CONSTRAINTS:
|
|
32
|
+
* - No actual task execution
|
|
33
|
+
* - No automatic learning or route optimization
|
|
34
|
+
* - No Trinity or adaptive threshold logic
|
|
35
|
+
* - Routing decisions are fully explainable (return `reason` + `blockers[]`)
|
|
36
|
+
*/
|
|
37
|
+
import type { WorkerProfile } from './model-deployment-registry.js';
|
|
38
|
+
/**
|
|
39
|
+
* The input contract for a routing decision.
|
|
40
|
+
* All fields are optional — the classifier handles missing data gracefully
|
|
41
|
+
* by treating it as ambiguous (stay_main).
|
|
42
|
+
*/
|
|
43
|
+
export interface RoutingInput {
|
|
44
|
+
/**
|
|
45
|
+
* A short label or name for the task intent.
|
|
46
|
+
* E.g., "read_file", "edit_config", "debug_memory_leak", "design_system"
|
|
47
|
+
*/
|
|
48
|
+
taskIntent?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Natural-language description of the task.
|
|
51
|
+
* The classifier examines this for keywords indicating complexity/risk.
|
|
52
|
+
*/
|
|
53
|
+
taskDescription?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Specific tools requested or implied by the task.
|
|
56
|
+
* These are examined for risk signals (e.g., bash, rm, git push).
|
|
57
|
+
*/
|
|
58
|
+
requestedTools?: string[];
|
|
59
|
+
/**
|
|
60
|
+
* Specific files involved or targeted.
|
|
61
|
+
* Examined for risk-path indicators (e.g., .git/, node_modules, production configs).
|
|
62
|
+
*/
|
|
63
|
+
requestedFiles?: string[];
|
|
64
|
+
/**
|
|
65
|
+
* Shape of expected output.
|
|
66
|
+
* E.g., "json", "markdown", "one_line", "full_report"
|
|
67
|
+
*/
|
|
68
|
+
expectedOutputShape?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Explicit risk signals detected in the task.
|
|
71
|
+
* E.g., ["destructive", "production", "irreversible", "large_scale"]
|
|
72
|
+
* Any non-empty riskSignals → automatic stay_main.
|
|
73
|
+
*/
|
|
74
|
+
riskSignals?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* Complexity hints for the task.
|
|
77
|
+
* E.g., ["multi_step", "cross_file", "ambiguous", "requires_planning"]
|
|
78
|
+
*/
|
|
79
|
+
complexityHints?: string[];
|
|
80
|
+
/**
|
|
81
|
+
* Target worker profile for routing consideration.
|
|
82
|
+
* If omitted, both profiles are evaluated and the best match is returned.
|
|
83
|
+
*/
|
|
84
|
+
targetProfile?: WorkerProfile;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The result of a routing classification decision.
|
|
88
|
+
* Always includes a `reason` and a `blockers` list for full explainability.
|
|
89
|
+
*/
|
|
90
|
+
export interface RoutingDecision {
|
|
91
|
+
/**
|
|
92
|
+
* The routing verdict.
|
|
93
|
+
* - `route_local` — the task may be delegated to `targetProfile`
|
|
94
|
+
* - `stay_main` — the task must remain on the main agent
|
|
95
|
+
*/
|
|
96
|
+
decision: 'route_local' | 'stay_main';
|
|
97
|
+
/**
|
|
98
|
+
* Which profile the task should be routed to (if decision === 'route_local').
|
|
99
|
+
* Null if decision === 'stay_main'.
|
|
100
|
+
*/
|
|
101
|
+
targetProfile: WorkerProfile | null;
|
|
102
|
+
/**
|
|
103
|
+
* The task classification category that led to this decision.
|
|
104
|
+
*/
|
|
105
|
+
classification: 'reader_eligible' | 'editor_eligible' | 'high_entropy_disallowed' | 'risk_disallowed' | 'ambiguous_scope' | 'profile_mismatch' | 'deployment_unavailable';
|
|
106
|
+
/**
|
|
107
|
+
* Human-readable explanation of the routing decision.
|
|
108
|
+
* Must be specific enough that a developer can understand why a task was accepted/rejected.
|
|
109
|
+
*/
|
|
110
|
+
reason: string;
|
|
111
|
+
/**
|
|
112
|
+
* List of specific reasons that blocked routing (if decision === 'stay_main').
|
|
113
|
+
* Empty if decision === 'route_local'.
|
|
114
|
+
*/
|
|
115
|
+
blockers: string[];
|
|
116
|
+
/**
|
|
117
|
+
* Whether a deployment check was performed and whether it passed.
|
|
118
|
+
* Useful for diagnostics when deployment_unavailable is the classification.
|
|
119
|
+
*/
|
|
120
|
+
deploymentCheck: {
|
|
121
|
+
performed: boolean;
|
|
122
|
+
profileAvailable: boolean;
|
|
123
|
+
routingEnabled: boolean;
|
|
124
|
+
/** Whether the active checkpoint is currently marked as deployable in the training registry. */
|
|
125
|
+
checkpointDeployable: boolean;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* The active checkpoint ID that would be used for routing (if decision === 'route_local').
|
|
129
|
+
* This is the checkpoint from the deployment registry.
|
|
130
|
+
* Null if decision === 'stay_main' or if no checkpoint is active.
|
|
131
|
+
*
|
|
132
|
+
* USE FOR SHADOW OBSERVATIONS:
|
|
133
|
+
* When routing in shadow mode (checkpoint is in shadow_ready state),
|
|
134
|
+
* the caller should record a shadow observation using this checkpoint ID.
|
|
135
|
+
*/
|
|
136
|
+
activeCheckpointId: string | null;
|
|
137
|
+
/**
|
|
138
|
+
* The promotion state of the active checkpoint.
|
|
139
|
+
* Indicates whether this is a regular deployment or a shadow rollout.
|
|
140
|
+
* Useful for determining whether to record shadow observations.
|
|
141
|
+
*/
|
|
142
|
+
activeCheckpointState?: 'promotable' | 'shadow_ready' | 'candidate_only';
|
|
143
|
+
/**
|
|
144
|
+
* Deprecated: runtime shadow observations are now recorded from real
|
|
145
|
+
* subagent lifecycle hooks instead of from classifyTask().
|
|
146
|
+
*/
|
|
147
|
+
shadowObservationId?: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Classify a task and produce a routing decision.
|
|
151
|
+
*
|
|
152
|
+
* This is the main entry point for routing policy evaluation.
|
|
153
|
+
* It:
|
|
154
|
+
* 1. Classifies the task kind based on keywords and heuristics
|
|
155
|
+
* 2. Checks deployment availability for the target profile
|
|
156
|
+
* 3. Returns a fully explainable RoutingDecision
|
|
157
|
+
*
|
|
158
|
+
* @param input - The routing input describing the task
|
|
159
|
+
* @param stateDir - Workspace state directory (for deployment registry lookup)
|
|
160
|
+
* @returns RoutingDecision with classification, reason, blockers, and routing verdict
|
|
161
|
+
*/
|
|
162
|
+
export declare function classifyTask(input: RoutingInput, stateDir: string): RoutingDecision;
|
|
163
|
+
/**
|
|
164
|
+
* Convenience: check if a specific profile can handle a task.
|
|
165
|
+
* Equivalent to calling classifyTask with targetProfile set.
|
|
166
|
+
*/
|
|
167
|
+
export declare function canRouteToProfile(input: RoutingInput, stateDir: string, profile: WorkerProfile): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Check if any local worker routing is currently enabled for any profile.
|
|
170
|
+
*/
|
|
171
|
+
export declare function isAnyLocalRoutingEnabled(stateDir: string): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* List all profiles that currently have routing enabled.
|
|
174
|
+
*/
|
|
175
|
+
export declare function listEnabledProfiles(stateDir: string): WorkerProfile[];
|