principles-disciple 2.2.3 → 2.2.5
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/bundle.js +439 -449
- package/dist/core/evolution-reducer.d.ts +0 -2
- package/dist/core/session-tracker.d.ts +0 -4
- package/dist/core/workspace-context.d.ts +0 -8
- package/dist/hooks/after-tool-call-helpers.d.ts +0 -7
- package/dist/hooks/pain-ingress-adapter.d.ts +1 -2
- package/dist/hooks/pain.d.ts +3 -4
- package/dist/hooks/prompt-helpers.d.ts +2 -12
- package/dist/hooks/prompt-types.d.ts +0 -4
- package/dist/hooks/prompt.d.ts +1 -11
- package/dist/hooks/triage-adapter.d.ts +3 -1
- package/dist/host-runtime/openclaw-host-runtime.d.ts +0 -1
- package/dist/openclaw.plugin.json +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +4 -5
- package/dist/core/pain-diagnostic-gate.d.ts +0 -47
- package/dist/core/principle-injection.d.ts +0 -10
- package/dist/core/thinking-os-parser.d.ts +0 -33
- package/dist/core/workflow-funnel-loader.d.ts +0 -72
|
@@ -10,7 +10,6 @@ export interface EvolutionReducer {
|
|
|
10
10
|
promote(_principleId: string, _reason?: string): void;
|
|
11
11
|
deprecate(_principleId: string, _reason: string): void;
|
|
12
12
|
rollbackPrinciple(_principleId: string, _reason: string): void;
|
|
13
|
-
recordProbationFeedback(_principleId: string, _success: boolean): void;
|
|
14
13
|
/**
|
|
15
14
|
* Creates a new principle with generalized trigger/action from diagnostician.
|
|
16
15
|
* Called after diagnostician analysis to create principle directly.
|
|
@@ -66,7 +65,6 @@ export declare class EvolutionReducerImpl implements EvolutionReducer {
|
|
|
66
65
|
promote(principleId: string, reason?: string): void;
|
|
67
66
|
deprecate(principleId: string, reason: string): void;
|
|
68
67
|
rollbackPrinciple(principleId: string, reason: string): void;
|
|
69
|
-
recordProbationFeedback(principleId: string, success: boolean): void;
|
|
70
68
|
/**
|
|
71
69
|
* Creates a new principle with generalized trigger/action from diagnostician.
|
|
72
70
|
* Called after diagnostician analysis to create principle directly (no intermediate overfitted principle).
|
|
@@ -30,7 +30,6 @@ export interface SessionState {
|
|
|
30
30
|
dailyToolFailures: number;
|
|
31
31
|
dailyPainSignals: number;
|
|
32
32
|
dailyGfiPeak: number;
|
|
33
|
-
injectedProbationIds?: string[];
|
|
34
33
|
injectedPrincipleIds?: string[];
|
|
35
34
|
injectedActivationIds?: string[];
|
|
36
35
|
receiptAutoCorrects?: number;
|
|
@@ -62,7 +61,6 @@ export declare function resetFriction(sessionId: string, workspaceDir?: string,
|
|
|
62
61
|
amount?: number;
|
|
63
62
|
}): SessionState;
|
|
64
63
|
export declare function trackBlock(sessionId: string): SessionState;
|
|
65
|
-
export declare function setInjectedProbationIds(sessionId: string, ids: string[], workspaceDir?: string): SessionState;
|
|
66
64
|
/**
|
|
67
65
|
* PRI-534: record the principle ids injected into this session's prompt context.
|
|
68
66
|
* PRI-755 (review fix): call this on EVERY prompt build with the CURRENT set —
|
|
@@ -81,7 +79,6 @@ export declare function setInjectedPrincipleIds(sessionId: string | undefined, i
|
|
|
81
79
|
activationIds?: readonly string[]): void;
|
|
82
80
|
/** PRI-534: count one applied live auto-correction in this session. */
|
|
83
81
|
export declare function trackReceiptAutoCorrect(sessionId: string | undefined, workspaceDir?: string): void;
|
|
84
|
-
export declare function getInjectedProbationIds(sessionId: string, workspaceDir?: string): string[];
|
|
85
82
|
/**
|
|
86
83
|
* PRI-755: read-only view of the principle ids injected into this session's
|
|
87
84
|
* prompt context. Tri-state: an array (possibly empty) means the injection set
|
|
@@ -100,7 +97,6 @@ export declare function getInjectedPrincipleIds(sessionId: string): readonly str
|
|
|
100
97
|
* A consumer must never treat "no pairing" as "some other activation".
|
|
101
98
|
*/
|
|
102
99
|
export declare function getInjectedActivationIds(sessionId: string): readonly string[] | undefined;
|
|
103
|
-
export declare function clearInjectedProbationIds(sessionId: string, workspaceDir?: string): SessionState;
|
|
104
100
|
export declare function getSession(sessionId: string): SessionState | undefined;
|
|
105
101
|
export declare function listSessions(workspaceDir?: string): SessionState[];
|
|
106
102
|
export declare function clearSession(sessionId: string): void;
|
|
@@ -7,7 +7,6 @@ import { EvolutionReducerImpl } from './evolution-reducer.js';
|
|
|
7
7
|
import type { TrajectoryDatabase } from './trajectory.js';
|
|
8
8
|
import { PrincipleLifecycleService } from './principle-internalization/principle-lifecycle-service.js';
|
|
9
9
|
import { type PrincipleSubtree, type LedgerPrinciple, type PrincipleValueMetrics } from './principle-tree-ledger.js';
|
|
10
|
-
import type { Principle as ActivePrinciple } from './evolution-types.js';
|
|
11
10
|
import { RuleHost } from './rule-host.js';
|
|
12
11
|
import type { RuleHostLogger } from './rule-host.js';
|
|
13
12
|
interface PrincipleTreeLedgerAccessor {
|
|
@@ -74,13 +73,6 @@ export declare class WorkspaceContext {
|
|
|
74
73
|
* Phase 15 lifecycle/read-model surface for metrics, assessments, and route recommendations.
|
|
75
74
|
*/
|
|
76
75
|
get principleLifecycle(): PrincipleLifecycleService;
|
|
77
|
-
/**
|
|
78
|
-
* Retrieve active Principle -> Rule -> Implementation subtrees without bypassing reducer authority.
|
|
79
|
-
*/
|
|
80
|
-
getActivePrincipleSubtrees(): {
|
|
81
|
-
principle: ActivePrinciple;
|
|
82
|
-
subtree: PrincipleSubtree;
|
|
83
|
-
}[];
|
|
84
76
|
private getTrajectoryOptions;
|
|
85
77
|
/**
|
|
86
78
|
* Creates or retrieves a WorkspaceContext instance from an OpenClaw hook context.
|
|
@@ -59,13 +59,6 @@ export declare function handleFrictionTrackingForSuccess(sessionId: string, even
|
|
|
59
59
|
* Record hygiene tracking for memory/plan persistence actions on success.
|
|
60
60
|
*/
|
|
61
61
|
export declare function recordHygieneTracking(event: PluginHookAfterToolCallEvent, observation: ToolCallObservation, wctx: WorkspaceContext): void;
|
|
62
|
-
/**
|
|
63
|
-
* Record probation feedback for injected probation IDs.
|
|
64
|
-
*
|
|
65
|
-
* On success: positive feedback for matching principles.
|
|
66
|
-
* On failure: negative feedback for matching principles.
|
|
67
|
-
*/
|
|
68
|
-
export declare function handleProbationFeedback(sessionId: string, toolName: string, workspaceDir: string, wctx: WorkspaceContext, isSuccess: boolean): void;
|
|
69
62
|
/**
|
|
70
63
|
* Evaluate whether a tool failure should trigger pain diagnosis.
|
|
71
64
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { PainIngressDecision } from '@principles/
|
|
2
|
-
import type { PainEvidenceEntry } from '@principles/core/runtime-v2';
|
|
1
|
+
import type { PainEvidenceEntry, PainIngressDecision } from '@principles/core/runtime-v2';
|
|
3
2
|
import type { WorkspaceContext } from '../core/workspace-context.js';
|
|
4
3
|
export interface PluginIngressInput {
|
|
5
4
|
wctx: WorkspaceContext;
|
package/dist/hooks/pain.d.ts
CHANGED
|
@@ -7,9 +7,8 @@
|
|
|
7
7
|
* 1. classifyToolCallOutcome — determine failure/success + source
|
|
8
8
|
* 2. buildToolCallObservation — normalize event into observation
|
|
9
9
|
* 3. handleFrictionTracking — GFI, event log, trajectory recording
|
|
10
|
-
* 4.
|
|
11
|
-
* 5.
|
|
12
|
-
* 6. emitPainIfAdmitted — pain signal emission
|
|
10
|
+
* 4. evaluatePainAdmission — triage + gate evaluation
|
|
11
|
+
* 5. emitPainIfAdmitted — pain signal emission
|
|
13
12
|
*
|
|
14
13
|
* The manual pain path (toolName === 'pain') remains inline because it
|
|
15
14
|
* has a different control flow (early return, no triage, no gate on cooldown).
|
|
@@ -44,7 +43,7 @@ export declare function handleAfterToolCall(event: PluginHookAfterToolCallEvent,
|
|
|
44
43
|
}, api?: OpenClawPluginApi): void;
|
|
45
44
|
/**
|
|
46
45
|
* OpenClaw-owned enrichment for the shared ordinary after-tool kernel.
|
|
47
|
-
* Session/GFI, event-log,
|
|
46
|
+
* Session/GFI, event-log, PROFILE and hygiene behavior stays here;
|
|
48
47
|
* the shared runtime owns classification/admission and the atomic trajectory write.
|
|
49
48
|
*/
|
|
50
49
|
export declare function prepareOrdinaryAfterToolCallForSharedRuntime(event: PluginHookAfterToolCallEvent, ctx: PluginHookToolContext & {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* EP-03: Pure functions never swallow errors; invalid input returns empty string
|
|
16
16
|
* EP-09: Pure functions are independently unit-testable without mocks
|
|
17
17
|
*/
|
|
18
|
-
import type { ExtractedUserMessage, CorePrincipleEntry,
|
|
18
|
+
import type { ExtractedUserMessage, CorePrincipleEntry, AppendSystemContextParts } from './prompt-types.js';
|
|
19
19
|
/**
|
|
20
20
|
* Extract the actual user message from the raw prompt text.
|
|
21
21
|
*
|
|
@@ -69,22 +69,12 @@ export declare function assembleHeartbeatChecklist(content: string): string;
|
|
|
69
69
|
* @returns Formatted lines (empty string if no principles)
|
|
70
70
|
*/
|
|
71
71
|
export declare function formatCorePrinciples(principles: CorePrincipleEntry[]): string;
|
|
72
|
-
/**
|
|
73
|
-
* Format evolution principles (active + probation) into prompt-ready text.
|
|
74
|
-
*
|
|
75
|
-
* Pure logic — uses escapeXml for safe XML embedding.
|
|
76
|
-
*
|
|
77
|
-
* @param active Active principles (high priority)
|
|
78
|
-
* @param probation Probation principles (contextual, caution)
|
|
79
|
-
* @returns Formatted lines (empty string if no principles)
|
|
80
|
-
*/
|
|
81
|
-
export declare function formatEvolutionPrinciples(active: EvolutionPrincipleEntry[], probation: EvolutionPrincipleEntry[]): string;
|
|
82
72
|
/**
|
|
83
73
|
* Assemble appendSystemContext from ordered parts.
|
|
84
74
|
*
|
|
85
75
|
* Content order (most important last):
|
|
86
76
|
* behavioral_constraints → project_context → intent_block → working_memory →
|
|
87
|
-
* thinking_os →
|
|
77
|
+
* thinking_os → core_principles
|
|
88
78
|
*
|
|
89
79
|
* PRI-467: intent_block (INTENT.md reference) sits after project_context
|
|
90
80
|
* (stable reference data, lower priority than principles) and before
|
|
@@ -46,9 +46,6 @@ export interface CorePrincipleEntry {
|
|
|
46
46
|
id: string;
|
|
47
47
|
text: string;
|
|
48
48
|
}
|
|
49
|
-
/** Input for formatting evolution principles (active + probation). */
|
|
50
|
-
export interface EvolutionPrincipleEntry extends CorePrincipleEntry {
|
|
51
|
-
}
|
|
52
49
|
/** Parts assembled into appendSystemContext. Order = priority (low → high). */
|
|
53
50
|
export interface AppendSystemContextParts {
|
|
54
51
|
behavioralConstraints?: string;
|
|
@@ -63,7 +60,6 @@ export interface AppendSystemContextParts {
|
|
|
63
60
|
intentBlock?: string;
|
|
64
61
|
workingMemory?: string;
|
|
65
62
|
thinkingOs?: string;
|
|
66
|
-
evolutionPrinciples?: string;
|
|
67
63
|
corePrinciples?: string;
|
|
68
64
|
}
|
|
69
65
|
/** Input for the heartbeat checklist wrapper. */
|
package/dist/hooks/prompt.d.ts
CHANGED
|
@@ -4,16 +4,6 @@ import type { ContextInjectionConfig } from '../types.js';
|
|
|
4
4
|
import type { ActivePrinciplePromptResult } from '@principles/host-runtime';
|
|
5
5
|
import { SignalCollectorHost } from '../core/signal-collector-host.js';
|
|
6
6
|
import type { PromptHookApi } from './prompt-types.js';
|
|
7
|
-
import type { InjectablePrinciple } from '../core/principle-injection.js';
|
|
8
|
-
export interface LegacyPrinciplePromptSelection {
|
|
9
|
-
active: InjectablePrinciple[];
|
|
10
|
-
probation: InjectablePrinciple[];
|
|
11
|
-
content: string;
|
|
12
|
-
selectedIds: ReadonlySet<string>;
|
|
13
|
-
/** PRI-562 Phase 0: either budget-bounded selection dropped candidates. */
|
|
14
|
-
wasTruncated: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare function selectLegacyPrinciplesForPrompt(workspaceDir: string, reducer: Pick<WorkspaceContext['evolutionReducer'], 'getActivePrinciples' | 'getProbationPrinciples'>, logger?: PluginLogger): LegacyPrinciplePromptSelection;
|
|
17
7
|
/**
|
|
18
8
|
* Reset all module-level prompt state for a workspace.
|
|
19
9
|
* Intended for test isolation — call in beforeEach().
|
|
@@ -33,4 +23,4 @@ export declare function getSignalCollectorHost(wctx: WorkspaceContext, logger?:
|
|
|
33
23
|
export declare function loadContextInjectionConfig(workspaceDir: string): ContextInjectionConfig;
|
|
34
24
|
export declare function handleBeforePromptBuild(event: PluginHookBeforePromptBuildEvent, ctx: PluginHookAgentContext & {
|
|
35
25
|
api?: PromptHookApi;
|
|
36
|
-
}, sharedActivePrinciplePrompt?: ActivePrinciplePromptResult
|
|
26
|
+
}, sharedActivePrinciplePrompt?: ActivePrinciplePromptResult): Promise<PluginHookBeforePromptBuildResult | void>;
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
* - Knows about OpenClaw hook conventions (sessionId, toolName, etc.)
|
|
10
10
|
*
|
|
11
11
|
* PRI-651-B1: hooks are Gate B only — this adapter feeds TriggerController.
|
|
12
|
-
* Gate A (evaluatePainDiagnosticGate) retired from runtime;
|
|
12
|
+
* Gate A (evaluatePainDiagnosticGate) was retired from runtime; its archived
|
|
13
|
+
* plugin adapter and core policy were removed on 2026-10-27. Gate B
|
|
14
|
+
* (TriggerController) is the only admission authority.
|
|
13
15
|
* Core only sees SourceKind and TriageResult.
|
|
14
16
|
*
|
|
15
17
|
* ERR checklist:
|
|
@@ -3,7 +3,6 @@ import type { HostEventResult } from '@principles/core/host';
|
|
|
3
3
|
import type { PluginHookAgentContext, PluginHookAfterToolCallEvent, PluginHookBeforePromptBuildEvent, PluginHookBeforePromptBuildResult, PluginHookBeforeToolCallEvent, PluginHookBeforeToolCallResult, PluginHookToolContext } from '../openclaw-sdk.js';
|
|
4
4
|
export interface OpenClawHostRuntimeOptions {
|
|
5
5
|
beforePromptBuild(event: PluginHookBeforePromptBuildEvent, context: PluginHookAgentContext, prompt: ActivePrinciplePromptResult): Promise<PluginHookBeforePromptBuildResult | void>;
|
|
6
|
-
promptExcludePrincipleIds?(event: PluginHookBeforePromptBuildEvent, context: PluginHookAgentContext): ReadonlySet<string>;
|
|
7
6
|
ruleContextProvider?(event: PluginHookBeforeToolCallEvent, context: PluginHookToolContext, request: ProductionRuleContextRequest): unknown | Promise<unknown>;
|
|
8
7
|
ruleInputEnrichmentProvider?(event: PluginHookBeforeToolCallEvent, context: PluginHookToolContext, request: ProductionRuleContextRequest): unknown | Promise<unknown>;
|
|
9
8
|
onBeforeToolResult?(event: PluginHookBeforeToolCallEvent, context: PluginHookToolContext, result: HostEventResult): PluginHookBeforeToolCallResult | void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "principles-disciple",
|
|
3
3
|
"name": "Principles Disciple",
|
|
4
4
|
"description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
|
|
5
|
-
"version": "2.2.
|
|
5
|
+
"version": "2.2.5",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true,
|
|
8
8
|
"onCapabilities": [
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "principles-disciple",
|
|
3
3
|
"name": "Principles Disciple",
|
|
4
4
|
"description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
|
|
5
|
-
"version": "2.2.
|
|
5
|
+
"version": "2.2.5",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true,
|
|
8
8
|
"onCapabilities": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "principles-disciple",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -72,11 +72,10 @@
|
|
|
72
72
|
"test:all": "vitest run",
|
|
73
73
|
"lint": "eslint \"src/**/*.ts\"",
|
|
74
74
|
"bootstrap-rules": "node scripts/bootstrap-rules.mjs",
|
|
75
|
-
"compile-principles": "node scripts/compile-principles.mjs"
|
|
76
|
-
"sync-plugin": "node scripts/sync-plugin.mjs"
|
|
75
|
+
"compile-principles": "node scripts/compile-principles.mjs"
|
|
77
76
|
},
|
|
78
77
|
"devDependencies": {
|
|
79
|
-
"@principles/host-runtime": "^0.
|
|
78
|
+
"@principles/host-runtime": "^0.14.1",
|
|
80
79
|
"@types/better-sqlite3": "^9.6.0",
|
|
81
80
|
"@types/js-yaml": "^4.0.9",
|
|
82
81
|
"@types/micromatch": "^4.0.10",
|
|
@@ -102,7 +101,7 @@
|
|
|
102
101
|
}
|
|
103
102
|
},
|
|
104
103
|
"dependencies": {
|
|
105
|
-
"@principles/core": "^1.297.
|
|
104
|
+
"@principles/core": "^1.297.4",
|
|
106
105
|
"@sinclair/typebox": "^0.34.52",
|
|
107
106
|
"better-sqlite3": "^13.0.3",
|
|
108
107
|
"commander": "^12.0.0",
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pain Diagnostic Gate — PRI-446 thin adapter
|
|
3
|
-
*
|
|
4
|
-
* @deprecated PRI-454 — Gate A (PainDiagnosticGate) is superseded by Gate B
|
|
5
|
-
* (TriggerController + EvidenceTriage). Do not add new callers. New admission
|
|
6
|
-
* logic must use `evaluateTriggerController` from runtime-v2/evidence-triage.
|
|
7
|
-
*
|
|
8
|
-
* Reality note (PRI-763, 2026-09-12): the `painEvidenceAdmission` /
|
|
9
|
-
* `painEvidenceAdmissionDefault` flags were RETIRED and REMOVED from the
|
|
10
|
-
* registry (PRI-763) — they never re-activated this module and had zero
|
|
11
|
-
* executable consumers (PRI-651-B1 / PRI-752 / PRI-762). Gate B
|
|
12
|
-
* (TriggerController) is the only admission authority. This adapter keeps
|
|
13
|
-
* ZERO production importers; only tests import it. The module itself is left
|
|
14
|
-
* archived (Phase 5 discipline: core export surface and plugin shim are not
|
|
15
|
-
* removed in the flag-contract PR — retirement of this module is a separate
|
|
16
|
-
* Owner decision).
|
|
17
|
-
*
|
|
18
|
-
* The pure decision logic (threshold tree, cooldown comparison, episode-key
|
|
19
|
-
* construction) now lives in principles-core
|
|
20
|
-
* (runtime-v2/pain-gate/pain-diagnostic-gate-policy.ts). This file is the
|
|
21
|
-
* stateful adapter that owns:
|
|
22
|
-
* - the cooldown Map (lastDiagnosedAtByEpisode)
|
|
23
|
-
* - Date.now() injection
|
|
24
|
-
* - SystemLogger for unknown-source telemetry
|
|
25
|
-
*
|
|
26
|
-
* It preserves the original export names (evaluatePainDiagnosticGate,
|
|
27
|
-
* isCooldownActiveForEpisode, resetPainDiagnosticGateForTest) for the
|
|
28
|
-
* remaining test consumers (auto-entry-gate, characterization, mocks).
|
|
29
|
-
*
|
|
30
|
-
* ERR checklist:
|
|
31
|
-
* - ERR-011: this is a stateful adapter delegating to core pure logic.
|
|
32
|
-
*/
|
|
33
|
-
import { type PainDiagnosticSource, type PainDiagnosticGateReason, type PainDiagnosticGateInput, type PainDiagnosticGateDecision } from '@principles/core/runtime-v2';
|
|
34
|
-
export type { PainDiagnosticSource, PainDiagnosticGateReason, PainDiagnosticGateInput, PainDiagnosticGateDecision, };
|
|
35
|
-
export declare function resetPainDiagnosticGateForTest(): void;
|
|
36
|
-
/**
|
|
37
|
-
* Check whether cooldown is currently active for a given episode.
|
|
38
|
-
* Used by the trigger controller (PEAT-B2) to align its cooldown decision
|
|
39
|
-
* with the PainDiagnosticGate's cooldown state.
|
|
40
|
-
*/
|
|
41
|
-
export declare function isCooldownActiveForEpisode(source: string, sessionId: string | undefined, errorHash: string | undefined, cooldownMs?: number): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Evaluate the pain diagnostic gate. Delegates the pure decision to core and,
|
|
44
|
-
* when the decision is to diagnose, records the current time against the
|
|
45
|
-
* episode so subsequent calls within the cooldown window are suppressed.
|
|
46
|
-
*/
|
|
47
|
-
export declare function evaluatePainDiagnosticGate(input: PainDiagnosticGateInput): PainDiagnosticGateDecision;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Principle Injection — Budget-Aware Principle Selection
|
|
3
|
-
*
|
|
4
|
-
* Phase: PRI-75 Prompt Injection SDK Migration Phase 2
|
|
5
|
-
*
|
|
6
|
-
* This file is now a thin re-export layer.
|
|
7
|
-
* All pure logic lives in @principles/core/prompt-builder/principle-selection.ts.
|
|
8
|
-
*/
|
|
9
|
-
export { formatPrinciple, selectPrinciplesForInjection, DEFAULT_PRINCIPLE_BUDGET, } from '@principles/core/prompt-builder';
|
|
10
|
-
export type { InjectablePrinciple, PrincipleSelectionResult } from '@principles/core/prompt-builder';
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Thinking OS XML Parser
|
|
3
|
-
*
|
|
4
|
-
* Parses THINKING_OS.md to extract directive definitions.
|
|
5
|
-
* The Core Principle Registry in @principles/core (core-principle-registry.ts)
|
|
6
|
-
* is the single source of truth for directive ids/names; THINKING_OS.md
|
|
7
|
-
* templates mirror it and the drift test enforces alignment (PRI-607).
|
|
8
|
-
*
|
|
9
|
-
* XML structure:
|
|
10
|
-
* <directive id="T-01" name="Survey Before Acting">
|
|
11
|
-
* <trigger>...</trigger>
|
|
12
|
-
* <must>...</must>
|
|
13
|
-
* <forbidden>...</forbidden>
|
|
14
|
-
* </directive>
|
|
15
|
-
*/
|
|
16
|
-
export interface ThinkingOsDirective {
|
|
17
|
-
id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
layer: string;
|
|
20
|
-
trigger: string;
|
|
21
|
-
must: string;
|
|
22
|
-
forbidden: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Parse THINKING_OS.md content and extract all <directive> blocks.
|
|
26
|
-
* Returns empty array if no directives found.
|
|
27
|
-
*/
|
|
28
|
-
export declare function parseThinkingOsMd(content: string): ThinkingOsDirective[];
|
|
29
|
-
/**
|
|
30
|
-
* Load THINKING_OS.md from the plugin templates for a given language.
|
|
31
|
-
* Falls back to the workspace THINKING_OS.md if it exists.
|
|
32
|
-
*/
|
|
33
|
-
export declare function loadThinkingOsFromWorkspace(workspaceDir: string, language?: string): ThinkingOsDirective[];
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WorkflowFunnelLoader — Loads and watches workflows.yaml as the SSOT
|
|
3
|
-
* for WORKFLOW_FUNNELS definition table.
|
|
4
|
-
*
|
|
5
|
-
* D-01: workflows.yaml is the single source of truth (SSOT).
|
|
6
|
-
* D-02: workflows.yaml lives in .state/ directory per workspace.
|
|
7
|
-
* D-03: Developers manually maintain workflows.yaml (no auto-registration).
|
|
8
|
-
* D-04: Code only reads YAML, never writes it.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* A single stage in a workflow funnel.
|
|
12
|
-
* Policy fields are optional — existing stages without policy fields remain valid.
|
|
13
|
-
*/
|
|
14
|
-
export interface WorkflowStage {
|
|
15
|
-
name: string;
|
|
16
|
-
eventType: string;
|
|
17
|
-
eventCategory: string;
|
|
18
|
-
statsField: string;
|
|
19
|
-
timeoutMs?: number;
|
|
20
|
-
successCriteria?: string;
|
|
21
|
-
legacyDisabled?: boolean;
|
|
22
|
-
observability?: {
|
|
23
|
-
enabled?: boolean;
|
|
24
|
-
emitEvents?: string[];
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Funnel-level policy that applies to all stages unless overridden per-stage.
|
|
29
|
-
*/
|
|
30
|
-
export interface FunnelPolicy {
|
|
31
|
-
timeoutMs?: number;
|
|
32
|
-
stageOrder?: 'strict' | 'relaxed';
|
|
33
|
-
legacyDisabled?: boolean;
|
|
34
|
-
observability?: {
|
|
35
|
-
enabled?: boolean;
|
|
36
|
-
emitEvents?: string[];
|
|
37
|
-
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* A workflow funnel definition.
|
|
42
|
-
*/
|
|
43
|
-
export interface WorkflowFunnel {
|
|
44
|
-
workflowId: string;
|
|
45
|
-
stages: WorkflowStage[];
|
|
46
|
-
policy?: FunnelPolicy;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Root of workflows.yaml schema.
|
|
50
|
-
*/
|
|
51
|
-
export interface WorkflowFunnelConfig {
|
|
52
|
-
version: string;
|
|
53
|
-
funnels: WorkflowFunnel[];
|
|
54
|
-
}
|
|
55
|
-
export declare class WorkflowFunnelLoader {
|
|
56
|
-
private readonly funnels;
|
|
57
|
-
private readonly fullFunnels;
|
|
58
|
-
private readonly configPath;
|
|
59
|
-
private watchHandle?;
|
|
60
|
-
private readonly warnings;
|
|
61
|
-
constructor(stateDir: string);
|
|
62
|
-
load(): void;
|
|
63
|
-
watch(): void;
|
|
64
|
-
dispose(): void;
|
|
65
|
-
getStages(workflowId: string): WorkflowStage[];
|
|
66
|
-
getFunnel(workflowId: string): WorkflowFunnel | undefined;
|
|
67
|
-
getAllFunnels(): Map<string, WorkflowStage[]>;
|
|
68
|
-
getAllFunnelsWithPolicy(): Map<string, WorkflowFunnel>;
|
|
69
|
-
getWarnings(): string[];
|
|
70
|
-
getConfigPath(): string;
|
|
71
|
-
private cloneFunnel;
|
|
72
|
-
}
|