@principles/core 1.73.0 → 1.74.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.
- package/dist/runtime-v2/adapter/__tests__/schema-prompt-adapter.test.d.ts +2 -0
- package/dist/runtime-v2/adapter/__tests__/schema-prompt-adapter.test.d.ts.map +1 -0
- package/dist/runtime-v2/adapter/__tests__/schema-prompt-adapter.test.js +270 -0
- package/dist/runtime-v2/adapter/__tests__/schema-prompt-adapter.test.js.map +1 -0
- package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts +1 -1
- package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
- package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js +4 -3
- package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js.map +1 -1
- package/dist/runtime-v2/adapter/schema-prompt-adapter.d.ts +13 -0
- package/dist/runtime-v2/adapter/schema-prompt-adapter.d.ts.map +1 -0
- package/dist/runtime-v2/adapter/schema-prompt-adapter.js +266 -0
- package/dist/runtime-v2/adapter/schema-prompt-adapter.js.map +1 -0
- package/dist/runtime-v2/adapter/tools/diagnostician-tool.d.ts +3 -7
- package/dist/runtime-v2/adapter/tools/diagnostician-tool.d.ts.map +1 -1
- package/dist/runtime-v2/adapter/tools/diagnostician-tool.js +7 -19
- package/dist/runtime-v2/adapter/tools/diagnostician-tool.js.map +1 -1
- package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.test.js +97 -15
- package/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-builder.test.js.map +1 -1
- package/dist/runtime-v2/diagnostician-output.d.ts +0 -10
- package/dist/runtime-v2/diagnostician-output.d.ts.map +1 -1
- package/dist/runtime-v2/diagnostician-output.js +5 -10
- package/dist/runtime-v2/diagnostician-output.js.map +1 -1
- package/dist/runtime-v2/diagnostician-prompt-builder.d.ts +6 -1
- package/dist/runtime-v2/diagnostician-prompt-builder.d.ts.map +1 -1
- package/dist/runtime-v2/diagnostician-prompt-builder.js +23 -15
- package/dist/runtime-v2/diagnostician-prompt-builder.js.map +1 -1
- package/package.json +1 -1
- package/dist/runtime-v2/__tests__/nocturnal-compliance-trust-boundary.test.d.ts +0 -2
- package/dist/runtime-v2/__tests__/nocturnal-compliance-trust-boundary.test.d.ts.map +0 -1
- package/dist/runtime-v2/__tests__/nocturnal-compliance-trust-boundary.test.js +0 -215
- package/dist/runtime-v2/__tests__/nocturnal-compliance-trust-boundary.test.js.map +0 -1
- package/dist/runtime-v2/idle-trigger/__tests__/idle-trigger-config-resolve.test.d.ts +0 -2
- package/dist/runtime-v2/idle-trigger/__tests__/idle-trigger-config-resolve.test.d.ts.map +0 -1
- package/dist/runtime-v2/idle-trigger/__tests__/idle-trigger-config-resolve.test.js +0 -92
- package/dist/runtime-v2/idle-trigger/__tests__/idle-trigger-config-resolve.test.js.map +0 -1
- package/dist/runtime-v2/idle-trigger/__tests__/idle-trigger-decision.test.d.ts +0 -2
- package/dist/runtime-v2/idle-trigger/__tests__/idle-trigger-decision.test.d.ts.map +0 -1
- package/dist/runtime-v2/idle-trigger/__tests__/idle-trigger-decision.test.js +0 -134
- package/dist/runtime-v2/idle-trigger/__tests__/idle-trigger-decision.test.js.map +0 -1
- package/dist/runtime-v2/idle-trigger/__tests__/idle-trigger-edge-cases.test.d.ts +0 -2
- package/dist/runtime-v2/idle-trigger/__tests__/idle-trigger-edge-cases.test.d.ts.map +0 -1
- package/dist/runtime-v2/idle-trigger/__tests__/idle-trigger-edge-cases.test.js +0 -226
- package/dist/runtime-v2/idle-trigger/__tests__/idle-trigger-edge-cases.test.js.map +0 -1
- package/dist/runtime-v2/idle-trigger/idle-trigger-decision.d.ts +0 -3
- package/dist/runtime-v2/idle-trigger/idle-trigger-decision.d.ts.map +0 -1
- package/dist/runtime-v2/idle-trigger/idle-trigger-decision.js +0 -5
- package/dist/runtime-v2/idle-trigger/idle-trigger-decision.js.map +0 -1
- package/dist/runtime-v2/idle-trigger/idle-trigger-policy.d.ts +0 -4
- package/dist/runtime-v2/idle-trigger/idle-trigger-policy.d.ts.map +0 -1
- package/dist/runtime-v2/idle-trigger/idle-trigger-policy.js +0 -81
- package/dist/runtime-v2/idle-trigger/idle-trigger-policy.js.map +0 -1
- package/dist/runtime-v2/idle-trigger/idle-trigger-types.d.ts +0 -29
- package/dist/runtime-v2/idle-trigger/idle-trigger-types.d.ts.map +0 -1
- package/dist/runtime-v2/idle-trigger/idle-trigger-types.js +0 -15
- package/dist/runtime-v2/idle-trigger/idle-trigger-types.js.map +0 -1
- package/dist/runtime-v2/idle-trigger/index.d.ts +0 -5
- package/dist/runtime-v2/idle-trigger/index.d.ts.map +0 -1
- package/dist/runtime-v2/idle-trigger/index.js +0 -4
- package/dist/runtime-v2/idle-trigger/index.js.map +0 -1
- package/dist/runtime-v2/nocturnal/candidate-scoring.d.ts +0 -486
- package/dist/runtime-v2/nocturnal/candidate-scoring.d.ts.map +0 -1
- package/dist/runtime-v2/nocturnal/candidate-scoring.js +0 -493
- package/dist/runtime-v2/nocturnal/candidate-scoring.js.map +0 -1
- package/dist/runtime-v2/nocturnal/index.d.ts +0 -9
- package/dist/runtime-v2/nocturnal/index.d.ts.map +0 -1
- package/dist/runtime-v2/nocturnal/index.js +0 -5
- package/dist/runtime-v2/nocturnal/index.js.map +0 -1
- package/dist/runtime-v2/nocturnal/nocturnal-compliance.d.ts +0 -185
- package/dist/runtime-v2/nocturnal/nocturnal-compliance.d.ts.map +0 -1
- package/dist/runtime-v2/nocturnal/nocturnal-compliance.js +0 -912
- package/dist/runtime-v2/nocturnal/nocturnal-compliance.js.map +0 -1
- package/dist/runtime-v2/nocturnal/snapshot-contract.d.ts +0 -192
- package/dist/runtime-v2/nocturnal/snapshot-contract.d.ts.map +0 -1
- package/dist/runtime-v2/nocturnal/snapshot-contract.js +0 -185
- package/dist/runtime-v2/nocturnal/snapshot-contract.js.map +0 -1
- package/dist/runtime-v2/nocturnal/trinity-types.d.ts +0 -421
- package/dist/runtime-v2/nocturnal/trinity-types.d.ts.map +0 -1
- package/dist/runtime-v2/nocturnal/trinity-types.js +0 -182
- package/dist/runtime-v2/nocturnal/trinity-types.js.map +0 -1
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Nocturnal Compliance Engine — Opportunity-Based Principle Evaluation
|
|
3
|
-
* =====================================================================
|
|
4
|
-
*
|
|
5
|
-
* Replaces session-average compliance with opportunity-based compliance.
|
|
6
|
-
*
|
|
7
|
-
* CORE CONCEPTS:
|
|
8
|
-
*
|
|
9
|
-
* Opportunity — a session context where a principle COULD have been applied.
|
|
10
|
-
* An opportunity exists when the agent's action (or planned action)
|
|
11
|
-
* falls within the principle's applicability scope.
|
|
12
|
-
*
|
|
13
|
-
* Compliance — the principle was followed in an opportunity.
|
|
14
|
-
* Determined by absence of violation signals, not presence of
|
|
15
|
-
* positive confirmation (avoids LLM scoring).
|
|
16
|
-
*
|
|
17
|
-
* Violation — strong evidence the principle was NOT followed.
|
|
18
|
-
* Detected through deterministic event signals (pain, tool failures,
|
|
19
|
-
* gate blocks) — no LLM involved.
|
|
20
|
-
*
|
|
21
|
-
* Dilution prevention — compliance is computed ONLY over sessions where the
|
|
22
|
-
* principle had an opportunity. Unrelated sessions
|
|
23
|
-
* (where T-05's risky operations never occurred) do NOT
|
|
24
|
-
* dilute the compliance rate.
|
|
25
|
-
*
|
|
26
|
-
* DESIGN CONSTRAINTS (Phase 1):
|
|
27
|
-
* - T-xx principles only (deterministic / weak-heuristic evaluability)
|
|
28
|
-
* - No P_xxx automation (requires detector metadata — Task 1.3 scope)
|
|
29
|
-
* - No LLM-based scoring
|
|
30
|
-
* - No training logic
|
|
31
|
-
*
|
|
32
|
-
* FILE: No file persistence — stateless computation over event stream.
|
|
33
|
-
* Caller is responsible for writing results to principle-training-state.ts.
|
|
34
|
-
*/
|
|
35
|
-
/**
|
|
36
|
-
* Session events extracted from the event log.
|
|
37
|
-
* Compatible with EventLogEntry from event-types.ts.
|
|
38
|
-
*/
|
|
39
|
-
export interface SessionEvents {
|
|
40
|
-
sessionId: string;
|
|
41
|
-
toolCalls: ToolCallRecord[];
|
|
42
|
-
painSignals: PainSignalRecord[];
|
|
43
|
-
gateBlocks: GateBlockRecord[];
|
|
44
|
-
userCorrections: UserCorrectionRecord[];
|
|
45
|
-
planApprovals: PlanApprovalRecord[];
|
|
46
|
-
}
|
|
47
|
-
export interface ToolCallRecord {
|
|
48
|
-
toolName: string;
|
|
49
|
-
filePath?: string;
|
|
50
|
-
outcome: 'success' | 'failure' | 'blocked';
|
|
51
|
-
errorType?: string;
|
|
52
|
-
errorMessage?: string;
|
|
53
|
-
}
|
|
54
|
-
export interface PainSignalRecord {
|
|
55
|
-
source: string;
|
|
56
|
-
score: number;
|
|
57
|
-
severity?: 'mild' | 'moderate' | 'severe';
|
|
58
|
-
reason?: string;
|
|
59
|
-
}
|
|
60
|
-
export interface GateBlockRecord {
|
|
61
|
-
toolName: string;
|
|
62
|
-
filePath?: string;
|
|
63
|
-
reason: string;
|
|
64
|
-
}
|
|
65
|
-
export interface UserCorrectionRecord {
|
|
66
|
-
correctionCue?: string;
|
|
67
|
-
}
|
|
68
|
-
export interface PlanApprovalRecord {
|
|
69
|
-
toolName: string;
|
|
70
|
-
filePath?: string;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* The result of compliance computation for one principle.
|
|
74
|
-
*/
|
|
75
|
-
export interface ComplianceResult {
|
|
76
|
-
principleId: string;
|
|
77
|
-
/** Number of sessions/events where this principle had an applicable opportunity */
|
|
78
|
-
applicableOpportunityCount: number;
|
|
79
|
-
/** Number of opportunities where violation signals were detected */
|
|
80
|
-
observedViolationCount: number;
|
|
81
|
-
/** complianceRate = (opportunities - violations) / opportunities; 0 if none */
|
|
82
|
-
complianceRate: number;
|
|
83
|
-
/**
|
|
84
|
-
* Violation trend:
|
|
85
|
-
* +1 = violations increasing (worsening)
|
|
86
|
-
* 0 = stable
|
|
87
|
-
* -1 = violations decreasing (improving)
|
|
88
|
-
*/
|
|
89
|
-
violationTrend: number;
|
|
90
|
-
/**
|
|
91
|
-
* Explanation of why the result is what it is.
|
|
92
|
-
* For debugging, observability, and reviewer verification.
|
|
93
|
-
*/
|
|
94
|
-
explanation: string;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Opportunity detection result for a single session.
|
|
98
|
-
*/
|
|
99
|
-
interface OpportunityMatch {
|
|
100
|
-
applicable: boolean;
|
|
101
|
-
reason: string;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Violation detection result for a session with applicable opportunity.
|
|
105
|
-
*/
|
|
106
|
-
interface ViolationMatch {
|
|
107
|
-
violated: boolean;
|
|
108
|
-
reason: string;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Detects whether a given session presents an APPLICABLE OPPORTUNITY
|
|
112
|
-
* for a specific principle.
|
|
113
|
-
*
|
|
114
|
-
* An opportunity exists when the session context falls within the
|
|
115
|
-
* principle's applicability scope — regardless of whether the agent
|
|
116
|
-
* followed the principle.
|
|
117
|
-
*
|
|
118
|
-
* IMPORTANT: This does NOT assess compliance. It only answers:
|
|
119
|
-
* "Could the principle have applied here?"
|
|
120
|
-
*
|
|
121
|
-
* #216: For P_* principles (not T-xx), uses generic detection based on
|
|
122
|
-
* pain events and tool calls — any session with a pain signal is considered
|
|
123
|
-
* an opportunity for a pain-derived principle.
|
|
124
|
-
*/
|
|
125
|
-
export declare function detectOpportunity(principleId: string, session: SessionEvents): OpportunityMatch;
|
|
126
|
-
/**
|
|
127
|
-
* Detects whether a principle was VIOLATED in a session where an
|
|
128
|
-
* opportunity was applicable.
|
|
129
|
-
*
|
|
130
|
-
* Returns a ViolationMatch with violated=true if violation signals are present.
|
|
131
|
-
*
|
|
132
|
-
* #216: For P_* principles (pain-derived), violation is detected when the session
|
|
133
|
-
* has pain signals, tool failures, or gate blocks that match the principle's
|
|
134
|
-
* trigger pattern. Since P_* principles don't have T-xx specific detectors,
|
|
135
|
-
* we use the presence of negative signals as violation evidence.
|
|
136
|
-
*/
|
|
137
|
-
export declare function detectViolation(principleId: string, session: SessionEvents): ViolationMatch;
|
|
138
|
-
/**
|
|
139
|
-
* Computes compliance metrics for a single T-xx principle across a batch of sessions.
|
|
140
|
-
*
|
|
141
|
-
* DILUTION PREVENTION:
|
|
142
|
-
* - Sessions where the principle had NO opportunity are EXCLUDED from
|
|
143
|
-
* applicableOpportunityCount and do not affect complianceRate.
|
|
144
|
-
* - Example: T-05 sessions with no risky operations do not dilute
|
|
145
|
-
* the compliance rate computed from T-05 sessions with gate blocks.
|
|
146
|
-
*
|
|
147
|
-
* TREND COMPUTATION:
|
|
148
|
-
* - Sessions are ordered chronologically (most recent first).
|
|
149
|
-
* - Current window: last 3 applicable sessions.
|
|
150
|
-
* - Previous window: sessions 4-6 (if available).
|
|
151
|
-
* - If either window has < 1 applicable session, trend = 0 (insufficient data).
|
|
152
|
-
* - Otherwise: trend = prevViolationRate - currentViolationRate
|
|
153
|
-
* (+1 = improving, 0 = stable, -1 = worsening).
|
|
154
|
-
*/
|
|
155
|
-
export declare function computeCompliance(principleId: string, sessions: SessionEvents[], options?: {
|
|
156
|
-
trendWindowSize?: number;
|
|
157
|
-
}): ComplianceResult;
|
|
158
|
-
/**
|
|
159
|
-
* Computes compliance results for all T-01 through T-09 principles
|
|
160
|
-
* across the provided sessions.
|
|
161
|
-
*
|
|
162
|
-
* Sessions are assumed to be ordered most-recent-first.
|
|
163
|
-
*/
|
|
164
|
-
export declare function computeAllCompliance(sessions: SessionEvents[], options?: {
|
|
165
|
-
trendWindowSize?: number;
|
|
166
|
-
}): ComplianceResult[];
|
|
167
|
-
/**
|
|
168
|
-
* Converts raw EventLogEntry[] from event-types.ts into SessionEvents.
|
|
169
|
-
*
|
|
170
|
-
* Groups events by sessionId and maps to the SessionEvents interface.
|
|
171
|
-
* Events with no sessionId are grouped under sessionId = 'unknown'.
|
|
172
|
-
*/
|
|
173
|
-
export declare function groupEventsIntoSessions(events: RawEventEntry[]): Map<string, SessionEvents>;
|
|
174
|
-
/**
|
|
175
|
-
* Raw event entry from the events.jsonl log.
|
|
176
|
-
* Compatible with EventLogEntry from event-types.ts.
|
|
177
|
-
*/
|
|
178
|
-
export interface RawEventEntry {
|
|
179
|
-
ts: string;
|
|
180
|
-
type: string;
|
|
181
|
-
sessionId?: string;
|
|
182
|
-
data: Record<string, unknown>;
|
|
183
|
-
}
|
|
184
|
-
export {};
|
|
185
|
-
//# sourceMappingURL=nocturnal-compliance.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nocturnal-compliance.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/nocturnal/nocturnal-compliance.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAMH;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,eAAe,EAAE,oBAAoB,EAAE,CAAC;IACxC,aAAa,EAAE,kBAAkB,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,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