principles-disciple 1.129.0 → 1.131.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.
@@ -3,8 +3,8 @@ import * as path from 'path';
3
3
  import { clearInjectedProbationIds, getSession, resetFriction, setInjectedProbationIds, trackFriction, decayGfi, getGfiDecayElapsed } from '../core/session-tracker.js';
4
4
  import { WorkspaceContext } from '../core/workspace-context.js';
5
5
  import { defaultContextConfig } from '../types.js';
6
- // local-worker-routing: removed from prompt injection per PRI-291 (MVP-Quiet)
7
- // classifyTask is still available for non-prompt consumers
6
+ // local-worker-routing module and its routing helpers removed entirely per PRI-448.
7
+ // Routing guidance is no longer injected into prompts.
8
8
  import { extractSummary, getHistoryVersions, parseWorkingMemorySection, workingMemoryToInjection, autoCompressFocus, safeReadCurrentFocus } from '../core/focus-history.js';
9
9
  import { PathResolver } from '../core/path-resolver.js';
10
10
  import { selectPrinciplesForInjection, DEFAULT_PRINCIPLE_BUDGET } from '../core/principle-injection.js';
@@ -826,9 +826,8 @@ ${empathySilenceConstraint}
826
826
  const directiveText = renderPrinciplesToDirectives(dedupedV2, runtimeV2PrincipleIds, escapeXml);
827
827
  prependSystemContext += directiveText;
828
828
  }
829
- // Routing guidance removed per PRI-291 (MVP diet).
830
- // Local worker routing is MVP-Quiet per ADR-0014 §2.5.
831
- // The classifyTask helper and local-worker-routing module are preserved for non-prompt consumers.
829
+ // Routing guidance removed per PRI-291; local-worker-routing module and its
830
+ // routing helpers deleted per PRI-448. No routing-related content is injected.
832
831
  // 6. Principles (always on, highest priority, goes last for recency effect)
833
832
  if (principlesContent) {
834
833
  appendParts.push(`<core_principles>\n${principlesContent}\n</core_principles>`);
package/dist/index.js CHANGED
@@ -2,8 +2,6 @@ import * as path from 'path';
2
2
  import { loadFeatureFlagFromConfig } from './core/pd-config-loader.js';
3
3
  import { checkConversationAccessConfig, getPluginEntry } from './core/config-health.js';
4
4
  export { checkConversationAccessConfig, getPluginEntry } from './core/config-health.js';
5
- import { classifyTask } from './core/local-worker-routing.js';
6
- import { completeShadowObservation, recordShadowRouting } from './core/shadow-observation-registry.js';
7
5
  import { getCommandDescription } from './i18n/commands.js';
8
6
  import { WorkspaceContext } from './core/workspace-context.js';
9
7
  import { handleBeforePromptBuild } from './hooks/prompt.js';
@@ -12,7 +10,6 @@ import { handleAfterToolCall } from './hooks/pain.js';
12
10
  import { handleBeforeReset, handleBeforeCompaction, handleAfterCompaction } from './hooks/lifecycle.js';
13
11
  import { handleLlmOutput } from './hooks/llm.js';
14
12
  import * as TrajectoryCollector from './hooks/trajectory-collector.js';
15
- import { handleSubagentEnded } from './hooks/subagent.js';
16
13
  import { handleInitStrategy } from './commands/strategy.js';
17
14
  import { handleBootstrapTools, handleResearchTools } from './commands/capabilities.js';
18
15
  import { handleThinkingOs } from './commands/thinking-os.js';
@@ -41,15 +38,10 @@ import { migrateStaleWorkspaceGuidance } from './core/workspace-guidance-migrato
41
38
  import { SystemLogger } from './core/system-logger.js';
42
39
  import { PathResolver } from './core/path-resolver.js';
43
40
  import { resolveCommandWorkspaceDir, resolveToolHookWorkspaceDirSafe, resolveHookWorkspaceDir } from './utils/workspace-resolver.js';
44
- import { computeRuntimeShadowTaskFingerprint, PD_LOCAL_PROFILES } from './utils/shadow-fingerprint.js';
45
41
  import { validateWorkspaceDir } from './core/workspace-dir-validation.js';
46
- import { resolveWorkspaceDirFromApi } from './core/path-resolver.js';
47
42
  import { checkSurfaceGuard, guardHook, guardService } from './core/surface-guard.js';
48
43
  // Track started workspaces — one-time init + evolution worker per workspace
49
44
  const startedWorkspaces = new Set();
50
- // Map from childSessionKey → shadowObservationId
51
- // Used to complete shadow observations when subagent ends
52
- const pendingShadowObservations = new Map();
53
45
  // ── Conversation Access Health Check (PRI-343) ────────────────────────────
54
46
  // Re-exported from core/config-health.ts for backward compatibility.
55
47
  // Implementation moved to avoid circular imports with trajectory-collector.ts.
@@ -334,81 +326,6 @@ const plugin = {
334
326
  api.logger.error(`[PD] Error in llm_output: ${String(err)}`);
335
327
  }
336
328
  }));
337
- // ── Hook: Subagent Loop Closure ──
338
- api.on('subagent_spawning', guardHook('hook:subagent_spawning', api.logger, (event, _ctx) => {
339
- try {
340
- // FIX (B): Never fall back to '.' — fail-fast with ERROR log if workspaceDir cannot be resolved.
341
- // For subagent hooks, we use event.agentId as the target agent for workspace resolution.
342
- const workspaceDir = resolveWorkspaceDirFromApi(api, event.agentId);
343
- if (!workspaceDir) {
344
- api.logger.error(`[PD] subagent_spawning: cannot resolve workspaceDir for agent "${event.agentId}" — skipping shadow routing`);
345
- return { status: 'ok' };
346
- }
347
- api.logger?.debug?.(`[PD] workspaceDir resolved for subagent_spawning: ${workspaceDir}`);
348
- const { agentId, childSessionKey } = event;
349
- // Only handle PD local worker profiles
350
- if (!PD_LOCAL_PROFILES.has(agentId)) {
351
- return { status: 'ok' };
352
- }
353
- // Use the real runtime hook to record shadow evidence. We still consult the
354
- // routing/deployment state here, but the observation itself must originate
355
- // from actual subagent execution rather than an operator command path.
356
- const routingInput = { targetProfile: agentId };
357
- const decision = classifyTask(routingInput, workspaceDir);
358
- const shouldRecordShadow = decision.activeCheckpointState === 'shadow_ready' &&
359
- !!decision.activeCheckpointId &&
360
- decision.deploymentCheck.routingEnabled &&
361
- decision.deploymentCheck.checkpointDeployable;
362
- if (shouldRecordShadow) {
363
- const observation = recordShadowRouting(workspaceDir, {
364
- checkpointId: decision.activeCheckpointId,
365
- workerProfile: agentId,
366
- taskFingerprint: computeRuntimeShadowTaskFingerprint(event),
367
- });
368
- pendingShadowObservations.set(childSessionKey, observation.observationId);
369
- }
370
- return { status: 'ok' };
371
- }
372
- catch (err) {
373
- api.logger.error(`[PD] Error in subagent_spawning shadow routing: ${String(err)}`);
374
- return { status: 'ok' }; // Don't block spawn on shadow observation errors
375
- }
376
- }));
377
- api.on('subagent_ended', guardHook('hook:subagent_ended', api.logger, (event, ctx) => {
378
- try {
379
- // FIX (B): Never fall back to '.' — fail-fast with ERROR log if workspaceDir cannot be resolved.
380
- const workspaceDir = resolveWorkspaceDirFromApi(api, undefined);
381
- if (!workspaceDir) {
382
- api.logger.error(`[PD] subagent_ended: cannot resolve workspaceDir — skipping shadow observation completion`);
383
- return;
384
- }
385
- api.logger?.debug?.(`[PD] workspaceDir resolved for subagent_ended: ${workspaceDir}`);
386
- // Complete any pending shadow observation for this subagent session
387
- const shadowObsId = pendingShadowObservations.get(event.targetSessionKey);
388
- if (shadowObsId && workspaceDir) {
389
- try {
390
- const outcome = event.outcome === 'ok'
391
- ? 'accepted'
392
- : event.outcome === 'error'
393
- ? 'rejected'
394
- : 'escalated';
395
- completeShadowObservation(workspaceDir, {
396
- observationId: shadowObsId,
397
- outcome,
398
- failureSignals: event.outcome === 'error' ? { threwException: true, timedOut: false, invalidOutput: false, profileRejected: false, extra: {} } : undefined,
399
- });
400
- pendingShadowObservations.delete(event.targetSessionKey);
401
- }
402
- catch (err) {
403
- api.logger.error(`[PD] Failed to complete shadow observation: ${String(err)}`);
404
- }
405
- }
406
- handleSubagentEnded(event, { ...ctx, workspaceDir, api });
407
- }
408
- catch (err) {
409
- api.logger.error(`[PD] Error in subagent_ended: ${String(err)}`);
410
- }
411
- }));
412
329
  // ── Hook: Lifecycle ──
413
330
  api.on('before_reset', guardHook('hook:before_reset', api.logger, (event, ctx) => {
414
331
  const wsResult = resolveHookWorkspaceDir(ctx, api, 'before_reset');
@@ -2,7 +2,7 @@
2
2
  "id": "principles-disciple",
3
3
  "name": "Principles Disciple",
4
4
  "description": "Evolutionary programming agent framework with strategic guardrails and reflection loops.",
5
- "version": "1.129.0",
5
+ "version": "1.131.0",
6
6
  "activation": {
7
7
  "onCapabilities": [
8
8
  "hook"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "principles-disciple",
3
- "version": "1.129.0",
3
+ "version": "1.131.0",
4
4
  "description": "Native OpenClaw plugin for Principles Disciple",
5
5
  "type": "module",
6
6
  "main": "./dist/bundle.js",
@@ -1,124 +0,0 @@
1
- /**
2
- * Local Worker Routing Policy — Task Classification and Routing Decisions
3
- * ======================================================================
4
- *
5
- * Phase: PRI-74 Routing Guidance Migration (follow-up to PRI-75 Prompt Injection SDK Migration)
6
- *
7
- * This file is a THIN ADAPTER.
8
- * Pure classification logic lives in @principles/core/prompt-builder/routing-guidance.ts.
9
- * This file handles I/O (deployment registry, promotion state) and combines
10
- * pure classification with deployment checks.
11
- *
12
- * ARCHITECTURE:
13
- * - Pure: classifyTaskKind, buildReason, buildBlockers, keyword constants → core
14
- * - I/O: getDeployment, isRoutingEnabledForProfile, isCheckpointDeployable, getPromotionState → plugin
15
- *
16
- * TASK CLASSIFICATION TAXONOMY:
17
- * Pure-classification output from classifyTaskKind() in @principles/core/prompt-builder/routing-guidance.ts:
18
- * reader_eligible — clearly suitable for local-reader
19
- * editor_eligible — clearly suitable for local-editor
20
- * high_entropy_disallowed — high-complexity tasks that must stay on main agent
21
- * ambiguous_scope — tasks that are unclear and need main-agent judgment
22
- * Plugin layer adds I/O-bound categories via deployment checks in classifyTask():
23
- * profile_mismatch — target profile incompatible with task classification
24
- * deployment_unavailable — no enabled deployment exists for the target profile
25
- *
26
- * FAIL-CLOSED PRINCIPLE:
27
- * - When in doubt → stay_main
28
- * - Unclear intent → stay_main
29
- * - High complexity → stay_main
30
- * - No enabled deployment → stay_main
31
- */
32
- import type { WorkerProfile } from './model-deployment-registry.js';
33
- import { type RoutingInput as CoreRoutingInput } from '@principles/core/prompt-builder';
34
- export type { RoutingInput } from '@principles/core/prompt-builder';
35
- /**
36
- * The result of a routing classification decision.
37
- * Always includes a `reason` and a `blockers` list for full explainability.
38
- */
39
- export interface RoutingDecision {
40
- /**
41
- * The routing verdict.
42
- * - `route_local` — the task may be delegated to `targetProfile`
43
- * - `stay_main` — the task must remain on the main agent
44
- */
45
- decision: 'route_local' | 'stay_main';
46
- /**
47
- * Which profile the task should be routed to (if decision === 'route_local').
48
- * Null if decision === 'stay_main'.
49
- */
50
- targetProfile: WorkerProfile | null;
51
- /**
52
- * The task classification category that led to this decision.
53
- */
54
- classification: 'reader_eligible' | 'editor_eligible' | 'high_entropy_disallowed' | 'ambiguous_scope' | 'profile_mismatch' | 'deployment_unavailable';
55
- /**
56
- * Human-readable explanation of the routing decision.
57
- * Must be specific enough that a developer can understand why a task was accepted/rejected.
58
- */
59
- reason: string;
60
- /**
61
- * List of specific reasons that blocked routing (if decision === 'stay_main').
62
- * Empty if decision === 'route_local'.
63
- */
64
- blockers: string[];
65
- /**
66
- * Whether a deployment check was performed and whether it passed.
67
- * Useful for diagnostics when deployment_unavailable is the classification.
68
- */
69
- deploymentCheck: {
70
- performed: boolean;
71
- profileAvailable: boolean;
72
- routingEnabled: boolean;
73
- /** Whether the active checkpoint is currently marked as deployable in the training registry. */
74
- checkpointDeployable: boolean;
75
- };
76
- /**
77
- * The active checkpoint ID that would be used for routing (if decision === 'route_local').
78
- * This is the checkpoint from the deployment registry.
79
- * Null if decision === 'stay_main' or if no checkpoint is active.
80
- *
81
- * USE FOR SHADOW OBSERVATIONS:
82
- * When routing in shadow mode (checkpoint is in shadow_ready state),
83
- * the caller should record a shadow observation using this checkpoint ID.
84
- */
85
- activeCheckpointId: string | null;
86
- /**
87
- * The promotion state of the active checkpoint.
88
- * Indicates whether this is a regular deployment or a shadow rollout.
89
- * Useful for determining whether to record shadow observations.
90
- */
91
- activeCheckpointState?: 'promotable' | 'shadow_ready' | 'candidate_only';
92
- /**
93
- * Deprecated: runtime shadow observations are now recorded from real
94
- * subagent lifecycle hooks instead of from classifyTask().
95
- */
96
- shadowObservationId?: string;
97
- }
98
- /**
99
- * Classify a task and produce a routing decision.
100
- *
101
- * This is the main entry point for routing policy evaluation.
102
- * It:
103
- * 1. Classifies the task kind based on keywords and heuristics (core pure function)
104
- * 2. Checks deployment availability for the target profile (plugin I/O)
105
- * 3. Returns a fully explainable RoutingDecision
106
- *
107
- * @param input - The routing input describing the task
108
- * @param stateDir - Workspace state directory (for deployment registry lookup)
109
- * @returns RoutingDecision with classification, reason, blockers, and routing verdict
110
- */
111
- export declare function classifyTask(input: CoreRoutingInput, stateDir: string): RoutingDecision;
112
- /**
113
- * Convenience: check if a specific profile can handle a task.
114
- * Equivalent to calling classifyTask with targetProfile set.
115
- */
116
- export declare function canRouteToProfile(input: CoreRoutingInput, stateDir: string, profile: WorkerProfile): boolean;
117
- /**
118
- * Check if any local worker routing is currently enabled for any profile.
119
- */
120
- export declare function isAnyLocalRoutingEnabled(stateDir: string): boolean;
121
- /**
122
- * List all profiles that currently have routing enabled.
123
- */
124
- export declare function listEnabledProfiles(stateDir: string): WorkerProfile[];
@@ -1,216 +0,0 @@
1
- /**
2
- * Local Worker Routing Policy — Task Classification and Routing Decisions
3
- * ======================================================================
4
- *
5
- * Phase: PRI-74 Routing Guidance Migration (follow-up to PRI-75 Prompt Injection SDK Migration)
6
- *
7
- * This file is a THIN ADAPTER.
8
- * Pure classification logic lives in @principles/core/prompt-builder/routing-guidance.ts.
9
- * This file handles I/O (deployment registry, promotion state) and combines
10
- * pure classification with deployment checks.
11
- *
12
- * ARCHITECTURE:
13
- * - Pure: classifyTaskKind, buildReason, buildBlockers, keyword constants → core
14
- * - I/O: getDeployment, isRoutingEnabledForProfile, isCheckpointDeployable, getPromotionState → plugin
15
- *
16
- * TASK CLASSIFICATION TAXONOMY:
17
- * Pure-classification output from classifyTaskKind() in @principles/core/prompt-builder/routing-guidance.ts:
18
- * reader_eligible — clearly suitable for local-reader
19
- * editor_eligible — clearly suitable for local-editor
20
- * high_entropy_disallowed — high-complexity tasks that must stay on main agent
21
- * ambiguous_scope — tasks that are unclear and need main-agent judgment
22
- * Plugin layer adds I/O-bound categories via deployment checks in classifyTask():
23
- * profile_mismatch — target profile incompatible with task classification
24
- * deployment_unavailable — no enabled deployment exists for the target profile
25
- *
26
- * FAIL-CLOSED PRINCIPLE:
27
- * - When in doubt → stay_main
28
- * - Unclear intent → stay_main
29
- * - High complexity → stay_main
30
- * - No enabled deployment → stay_main
31
- */
32
- import { isRoutingEnabledForProfile, getDeployment, } from './model-deployment-registry.js';
33
- import { isCheckpointDeployable } from './model-training-registry.js';
34
- import { getPromotionState } from './promotion-gate.js';
35
- // Core pure functions — migrated to @principles/core/prompt-builder
36
- import { classifyTaskKind as coreClassifyTaskKind, buildReason as coreBuildReason, buildBlockers as coreBuildBlockers, } from '@principles/core/prompt-builder';
37
- // ---------------------------------------------------------------------------
38
- // Public API
39
- // ---------------------------------------------------------------------------
40
- /**
41
- * Classify a task and produce a routing decision.
42
- *
43
- * This is the main entry point for routing policy evaluation.
44
- * It:
45
- * 1. Classifies the task kind based on keywords and heuristics (core pure function)
46
- * 2. Checks deployment availability for the target profile (plugin I/O)
47
- * 3. Returns a fully explainable RoutingDecision
48
- *
49
- * @param input - The routing input describing the task
50
- * @param stateDir - Workspace state directory (for deployment registry lookup)
51
- * @returns RoutingDecision with classification, reason, blockers, and routing verdict
52
- */
53
- export function classifyTask(input, stateDir) {
54
- // --- Determine the raw task classification (delegated to core pure function) ---
55
- const classification = coreClassifyTaskKind(input);
56
- // --- Determine the target profile ---
57
- // If input specifies a target, use it. Otherwise, pick based on classification.
58
- // NOTE: When explicitly specified, we must validate profile-task compatibility below.
59
- const targetProfile = input.targetProfile ??
60
- (classification === 'reader_eligible'
61
- ? 'local-reader'
62
- : classification === 'editor_eligible'
63
- ? 'local-editor'
64
- : null);
65
- // --- Profile-task compatibility check ---
66
- // Only applies when input.targetProfile is EXPLICITLY set.
67
- // When auto-derived (input.targetProfile is null), compatibility is already
68
- // guaranteed by the auto-derivation logic above (reader_eligible → local-reader).
69
- // This check prevents routing a reader task to an editor profile (or vice versa)
70
- // when the caller explicitly requests the wrong profile.
71
- const isProfileCompatible = input.targetProfile === undefined
72
- ? true // Auto-derived profile is always compatible by construction
73
- : targetProfile === 'local-reader'
74
- ? classification === 'reader_eligible'
75
- : targetProfile === 'local-editor'
76
- ? classification === 'editor_eligible'
77
- : false;
78
- // --- Deployment availability check ---
79
- let deploymentCheck = {
80
- performed: false,
81
- profileAvailable: false,
82
- routingEnabled: false,
83
- checkpointDeployable: false,
84
- };
85
- if (targetProfile) {
86
- const deployment = getDeployment(stateDir, targetProfile);
87
- const activeCheckpointId = deployment?.activeCheckpointId ?? null;
88
- // Re-check deployability on every routing decision — a checkpoint may have been revoked
89
- const checkpointDeployable = activeCheckpointId
90
- ? isCheckpointDeployable(stateDir, activeCheckpointId)
91
- : false;
92
- deploymentCheck = {
93
- performed: true,
94
- profileAvailable: deployment !== null,
95
- routingEnabled: isRoutingEnabledForProfile(stateDir, targetProfile),
96
- checkpointDeployable,
97
- };
98
- }
99
- // --- Build the decision (delegated to core pure functions) ---
100
- const blockers = coreBuildBlockers(classification, input);
101
- const reason = coreBuildReason(classification, input);
102
- // FAIL-CLOSED: route_local only if:
103
- // 1. Classification is eligible (reader_eligible or editor_eligible)
104
- // 2. A target profile was identified
105
- // 3. The task's natural profile is compatible with the target profile
106
- // 4. Deployment is available and routing is enabled
107
- const isEligibleForRouting = (classification === 'reader_eligible' || classification === 'editor_eligible') &&
108
- targetProfile !== null &&
109
- isProfileCompatible &&
110
- deploymentCheck.routingEnabled;
111
- const decision = isEligibleForRouting
112
- ? 'route_local'
113
- : 'stay_main';
114
- // Derive the final classification — preserves the root cause of stay_main:
115
- // - profile_mismatch: task would be eligible but wrong profile requested
116
- // - deployment_unavailable: eligible and compatible but no routing enabled
117
- // - raw classification: blocked by high_entropy / risk / ambiguous
118
- const isEligible = classification === 'reader_eligible' || classification === 'editor_eligible';
119
- const finalClassification = isEligibleForRouting
120
- ? classification
121
- : isEligible && targetProfile !== null && !isProfileCompatible
122
- ? 'profile_mismatch'
123
- : isEligible
124
- ? 'deployment_unavailable'
125
- : classification;
126
- // Build explainability fields specific to the stay_main reason
127
- let finalReason = reason;
128
- let finalBlockers = blockers;
129
- if (decision === 'stay_main') {
130
- if (finalClassification === 'profile_mismatch') {
131
- const wanted = classification === 'reader_eligible' ? 'local-reader' : 'local-editor';
132
- finalReason = `Task is ${classification} but was explicitly targeted at ${targetProfile}. ` +
133
- `Routing requires "${wanted}" profile. Ensure the task intent matches the requested profile.`;
134
- finalBlockers = [
135
- `profile mismatch: task is ${classification} but targetProfile is ${targetProfile}`,
136
- `required profile: ${wanted}`,
137
- ];
138
- }
139
- else if (finalClassification === 'deployment_unavailable') {
140
- if (!deploymentCheck.performed) {
141
- finalReason = reason;
142
- }
143
- else if (!deploymentCheck.profileAvailable) {
144
- finalReason = `Task is ${classification} but no deployment exists for ${targetProfile}. ` +
145
- `Bind a checkpoint via bindCheckpointToWorkerProfile() and enable routing.`;
146
- finalBlockers = [`no deployment found for profile: ${targetProfile}`];
147
- }
148
- else if (!deploymentCheck.checkpointDeployable) {
149
- finalReason = `Task is ${classification} but the active checkpoint has been revoked (no longer deployable). ` +
150
- `Re-bind a passing checkpoint or re-evaluate the current one.`;
151
- finalBlockers = [
152
- `active checkpoint is no longer deployable: ${targetProfile}`,
153
- 'revoked checkpoints must not be used for routing',
154
- ];
155
- }
156
- else if (!deploymentCheck.routingEnabled) {
157
- finalReason = `Task is ${classification} and deployment exists for ${targetProfile} but routing is not enabled. ` +
158
- `Enable routing via enableRoutingForProfile() in the deployment registry.`;
159
- finalBlockers = [`routing is disabled for profile: ${targetProfile}`];
160
- }
161
- }
162
- }
163
- // --- Get active checkpoint ID and state for shadow observation integration ---
164
- let activeCheckpointId = null;
165
- let activeCheckpointState = null;
166
- if (targetProfile && deploymentCheck.performed) {
167
- const deployment = getDeployment(stateDir, targetProfile);
168
- activeCheckpointId = deployment?.activeCheckpointId ?? null;
169
- if (activeCheckpointId) {
170
- const promotionState = getPromotionState(stateDir, activeCheckpointId);
171
- if (promotionState === 'shadow_ready' || promotionState === 'promotable' || promotionState === 'candidate_only') {
172
- activeCheckpointState = promotionState;
173
- }
174
- }
175
- }
176
- return {
177
- decision,
178
- targetProfile: decision === 'route_local' ? targetProfile : null,
179
- classification: finalClassification,
180
- reason: finalReason,
181
- blockers: decision === 'stay_main' ? finalBlockers : [],
182
- deploymentCheck,
183
- activeCheckpointId,
184
- activeCheckpointState: activeCheckpointState ?? undefined,
185
- shadowObservationId: undefined,
186
- };
187
- }
188
- /**
189
- * Convenience: check if a specific profile can handle a task.
190
- * Equivalent to calling classifyTask with targetProfile set.
191
- */
192
- export function canRouteToProfile(input, stateDir, profile) {
193
- const decision = classifyTask({ ...input, targetProfile: profile }, stateDir);
194
- return decision.decision === 'route_local';
195
- }
196
- // ---------------------------------------------------------------------------
197
- // Read-Only Query Helpers
198
- // ---------------------------------------------------------------------------
199
- /**
200
- * Check if any local worker routing is currently enabled for any profile.
201
- */
202
- export function isAnyLocalRoutingEnabled(stateDir) {
203
- return isRoutingEnabledForProfile(stateDir, 'local-reader') ||
204
- isRoutingEnabledForProfile(stateDir, 'local-editor');
205
- }
206
- /**
207
- * List all profiles that currently have routing enabled.
208
- */
209
- export function listEnabledProfiles(stateDir) {
210
- const enabled = [];
211
- if (isRoutingEnabledForProfile(stateDir, 'local-reader'))
212
- enabled.push('local-reader');
213
- if (isRoutingEnabledForProfile(stateDir, 'local-editor'))
214
- enabled.push('local-editor');
215
- return enabled;
216
- }