create-principles-disciple 1.145.27 → 1.145.28
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/_release/product-identity.json +1 -1
- package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts +0 -1
- package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts.map +1 -1
- package/core/dist/runtime-v2/evidence-triage/triage-policy.js +0 -1
- package/core/dist/runtime-v2/evidence-triage/triage-policy.js.map +1 -1
- package/core/dist/runtime-v2/index.d.ts +0 -2
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +1 -2
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/package.json +1 -1
- package/host-runtime/dist/index.d.ts +0 -1
- package/host-runtime/dist/index.js +0 -3
- package/package.json +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +334 -334
- package/plugin/dist/hooks/pain-ingress-adapter.d.ts +1 -2
- package/plugin/dist/hooks/triage-adapter.d.ts +3 -1
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/release-manager/package.json +1 -1
- package/core/dist/runtime-v2/pain-gate/index.d.ts +0 -10
- package/core/dist/runtime-v2/pain-gate/index.d.ts.map +0 -1
- package/core/dist/runtime-v2/pain-gate/index.js +0 -9
- package/core/dist/runtime-v2/pain-gate/index.js.map +0 -1
- package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.d.ts +0 -123
- package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.d.ts.map +0 -1
- package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.js +0 -159
- package/core/dist/runtime-v2/pain-gate/pain-diagnostic-gate-policy.js.map +0 -1
- package/host-runtime/dist/pain-evidence-ingress.d.ts +0 -16
- package/host-runtime/dist/pain-evidence-ingress.js +0 -15
- package/plugin/dist/core/pain-diagnostic-gate.d.ts +0 -47
- package/plugin/dist/core/thinking-os-parser.d.ts +0 -33
- package/plugin/dist/core/workflow-funnel-loader.d.ts +0 -72
|
@@ -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;
|
|
@@ -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:
|
|
@@ -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.4",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true,
|
|
8
8
|
"onCapabilities": [
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pain Gate — PRI-446
|
|
3
|
-
*
|
|
4
|
-
* Pure pain-diagnostic gate decision logic (cooldown + threshold tree).
|
|
5
|
-
* No I/O, no plugin imports. The plugin adapter owns the cooldown Map and
|
|
6
|
-
* injects time/state into these pure functions.
|
|
7
|
-
*/
|
|
8
|
-
export type { PainDiagnosticSource, PainDiagnosticGateReason, PainDiagnosticGateInput, PainDiagnosticGateDecision, CooldownCheckInput, } from './pain-diagnostic-gate-policy.js';
|
|
9
|
-
export { DEFAULT_COOLDOWN_MS, DEFAULT_PAIN_TRIGGER, DEFAULT_HIGH_SEVERITY, DEFAULT_REPEATED_FAILURE, DEFAULT_SEMANTIC_PAIN_FLOOR, normalizedSource, buildEpisodeKey, evaluatePainDiagnosticGateDecision, isCooldownActive, } from './pain-diagnostic-gate-policy.js';
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/pain-gate/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACV,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,gBAAgB,EAChB,eAAe,EACf,kCAAkC,EAClC,gBAAgB,GACjB,MAAM,kCAAkC,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pain Gate — PRI-446
|
|
3
|
-
*
|
|
4
|
-
* Pure pain-diagnostic gate decision logic (cooldown + threshold tree).
|
|
5
|
-
* No I/O, no plugin imports. The plugin adapter owns the cooldown Map and
|
|
6
|
-
* injects time/state into these pure functions.
|
|
7
|
-
*/
|
|
8
|
-
export { DEFAULT_COOLDOWN_MS, DEFAULT_PAIN_TRIGGER, DEFAULT_HIGH_SEVERITY, DEFAULT_REPEATED_FAILURE, DEFAULT_SEMANTIC_PAIN_FLOOR, normalizedSource, buildEpisodeKey, evaluatePainDiagnosticGateDecision, isCooldownActive, } from './pain-diagnostic-gate-policy.js';
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime-v2/pain-gate/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,gBAAgB,EAChB,eAAe,EACf,kCAAkC,EAClC,gBAAgB,GACjB,MAAM,kCAAkC,CAAC"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pain Diagnostic Gate Policy — PRI-446 (migrated from the plugin 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 had executable consumers (PRI-651-B1 /
|
|
11
|
-
* PRI-752 / PRI-762) and Gate B (TriggerController) is the only admission
|
|
12
|
-
* authority — no runtime routing ever read the flags. This module is
|
|
13
|
-
* dead-in-production, kept alive only by its own tests and the deprecated
|
|
14
|
-
* plugin adapter. The module's own retirement (core export surface + policy
|
|
15
|
-
* + plugin shim) is a separate Owner decision per Phase 5 discipline.
|
|
16
|
-
*
|
|
17
|
-
* Pure decision logic for pain-diagnostic cooldown and gate evaluation.
|
|
18
|
-
*
|
|
19
|
-
* This module is the single source of truth for the gate's threshold decision
|
|
20
|
-
* tree. It is fully pure: no I/O, no Date.now(), no module-level mutable state.
|
|
21
|
-
* All time and cooldown state is passed in as parameters. The plugin-side
|
|
22
|
-
* pain-diagnostic-gate.ts is now a thin adapter that owns the cooldown Map and
|
|
23
|
-
* feeds Date.now() / the last-diagnosed timestamp into this function.
|
|
24
|
-
*
|
|
25
|
-
* Field precedence / thresholds are copied byte-for-byte from the prior plugin
|
|
26
|
-
* implementation; the plugin's pain-diagnostic-gate.test.ts (40 tests) passes
|
|
27
|
-
* unchanged through the adapter as the equivalence proof.
|
|
28
|
-
*
|
|
29
|
-
* ERR checklist:
|
|
30
|
-
* - ERR-001: inputs validated with Number.isFinite, not `as` casts.
|
|
31
|
-
* - ERR-002: every decision carries reason + detail.
|
|
32
|
-
* - EP-01: source string normalized with a Set membership check.
|
|
33
|
-
*/
|
|
34
|
-
/** Default cooldown window: 15 minutes. */
|
|
35
|
-
export declare const DEFAULT_COOLDOWN_MS: number;
|
|
36
|
-
/** Default pain-trigger threshold. */
|
|
37
|
-
export declare const DEFAULT_PAIN_TRIGGER = 40;
|
|
38
|
-
/** Default high-severity threshold (risky high-score). */
|
|
39
|
-
export declare const DEFAULT_HIGH_SEVERITY = 70;
|
|
40
|
-
/** Default repeated-failure threshold (consecutive errors). */
|
|
41
|
-
export declare const DEFAULT_REPEATED_FAILURE = 4;
|
|
42
|
-
/** Default semantic-pain floor. */
|
|
43
|
-
export declare const DEFAULT_SEMANTIC_PAIN_FLOOR = 60;
|
|
44
|
-
declare const PAIN_DIAGNOSTIC_SOURCES: readonly ['manual', 'tool_failure', 'dispatch_error', 'gate_blocked', 'user_empathy', 'llm_paralysis', 'semantic', 'subagent_error'];
|
|
45
|
-
export type PainDiagnosticSource = typeof PAIN_DIAGNOSTIC_SOURCES[number];
|
|
46
|
-
export type PainDiagnosticGateReason = 'manual' | 'high_gfi' | 'repeated_failure' | 'semantic_pain' | 'llm_paralysis' | 'risky_high_score' | 'subagent_error' | 'gate_blocked' | 'cooldown' | 'below_gate';
|
|
47
|
-
export interface PainDiagnosticGateInput {
|
|
48
|
-
source: PainDiagnosticSource | string;
|
|
49
|
-
score: number;
|
|
50
|
-
currentGfi: number;
|
|
51
|
-
consecutiveErrors?: number;
|
|
52
|
-
isRisky?: boolean;
|
|
53
|
-
errorHash?: string;
|
|
54
|
-
sessionId?: string;
|
|
55
|
-
nowMs?: number;
|
|
56
|
-
cooldownMs?: number;
|
|
57
|
-
thresholds?: {
|
|
58
|
-
painTrigger?: number;
|
|
59
|
-
highSeverity?: number;
|
|
60
|
-
highGfi?: number;
|
|
61
|
-
repeatedFailure?: number;
|
|
62
|
-
semanticPain?: number;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
export interface PainDiagnosticGateDecision {
|
|
66
|
-
shouldDiagnose: boolean;
|
|
67
|
-
reason: PainDiagnosticGateReason;
|
|
68
|
-
episodeKey: string;
|
|
69
|
-
detail: string;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Normalize a raw source string to a known PainDiagnosticSource.
|
|
73
|
-
*
|
|
74
|
-
* Unknown sources are passed through unchanged (the caller may still match them
|
|
75
|
-
* against custom thresholds) but flagged via the returned `unknown` flag so the
|
|
76
|
-
* plugin adapter can log it. Core itself does not log.
|
|
77
|
-
*/
|
|
78
|
-
export declare function normalizedSource(source: string): {
|
|
79
|
-
source: PainDiagnosticSource | string;
|
|
80
|
-
unknown: boolean;
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Build the episode key that scopes cooldown to a (session, source, hash) triple.
|
|
84
|
-
*/
|
|
85
|
-
export declare function buildEpisodeKey(input: PainDiagnosticGateInput): string;
|
|
86
|
-
/**
|
|
87
|
-
* Evaluate the pure gate decision.
|
|
88
|
-
*
|
|
89
|
-
* @param input - gate input (time in nowMs is the caller's responsibility)
|
|
90
|
-
* @param lastDiagnosedAtMs - the last time this episode was diagnosed, or undefined
|
|
91
|
-
* if never. Provided by the plugin adapter which owns the cooldown Map.
|
|
92
|
-
* @returns the gate decision. If shouldDiagnose is true, the caller MUST record
|
|
93
|
-
* nowMs against this episode (the plugin adapter does this in markDiagnosed).
|
|
94
|
-
*
|
|
95
|
-
* Note on the "unknown source" side effect: the prior plugin implementation
|
|
96
|
-
* logged unknown sources via SystemLogger. Core cannot log, so it surfaces the
|
|
97
|
-
* unknown flag through normalizedSource; the plugin adapter is responsible for
|
|
98
|
-
* logging when it observes an unknown source before calling this function.
|
|
99
|
-
*/
|
|
100
|
-
export declare function evaluatePainDiagnosticGateDecision(input: PainDiagnosticGateInput, lastDiagnosedAtMs?: number): PainDiagnosticGateDecision;
|
|
101
|
-
/**
|
|
102
|
-
* Pure cooldown check for an episode.
|
|
103
|
-
*
|
|
104
|
-
* Used by the trigger controller (PEAT-B2) and re-exported by the plugin adapter
|
|
105
|
-
* as isCooldownActiveForEpisode so its cooldown decision aligns with the gate.
|
|
106
|
-
*/
|
|
107
|
-
export interface CooldownCheckInput {
|
|
108
|
-
/** Source string used to build the episode key. */
|
|
109
|
-
readonly source: string;
|
|
110
|
-
/** Session id used to build the episode key. */
|
|
111
|
-
readonly sessionId?: string;
|
|
112
|
-
/** Error hash used to build the episode key. */
|
|
113
|
-
readonly errorHash?: string;
|
|
114
|
-
/** Cooldown window in ms. Falls back to DEFAULT_COOLDOWN_MS when undefined. */
|
|
115
|
-
readonly cooldownMs?: number;
|
|
116
|
-
/** Current time in ms (caller-injected; core has no clock). */
|
|
117
|
-
readonly nowMs: number;
|
|
118
|
-
/** Last time this episode was diagnosed, or undefined if never. */
|
|
119
|
-
readonly lastDiagnosedAtMs?: number;
|
|
120
|
-
}
|
|
121
|
-
export declare function isCooldownActive(input: CooldownCheckInput): boolean;
|
|
122
|
-
export {};
|
|
123
|
-
//# sourceMappingURL=pain-diagnostic-gate-policy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pain-diagnostic-gate-policy.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/pain-gate/pain-diagnostic-gate-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAIH,2CAA2C;AAC3C,eAAO,MAAM,mBAAmB,QAAiB,CAAC;AAClD,sCAAsC;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EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAID;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAM5G;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAKtE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,uBAAuB,EAC9B,iBAAiB,CAAC,EAAE,MAAM,GACzB,0BAA0B,CAoE5B;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAKnE"}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pain Diagnostic Gate Policy — PRI-446 (migrated from the plugin 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 had executable consumers (PRI-651-B1 /
|
|
11
|
-
* PRI-752 / PRI-762) and Gate B (TriggerController) is the only admission
|
|
12
|
-
* authority — no runtime routing ever read the flags. This module is
|
|
13
|
-
* dead-in-production, kept alive only by its own tests and the deprecated
|
|
14
|
-
* plugin adapter. The module's own retirement (core export surface + policy
|
|
15
|
-
* + plugin shim) is a separate Owner decision per Phase 5 discipline.
|
|
16
|
-
*
|
|
17
|
-
* Pure decision logic for pain-diagnostic cooldown and gate evaluation.
|
|
18
|
-
*
|
|
19
|
-
* This module is the single source of truth for the gate's threshold decision
|
|
20
|
-
* tree. It is fully pure: no I/O, no Date.now(), no module-level mutable state.
|
|
21
|
-
* All time and cooldown state is passed in as parameters. The plugin-side
|
|
22
|
-
* pain-diagnostic-gate.ts is now a thin adapter that owns the cooldown Map and
|
|
23
|
-
* feeds Date.now() / the last-diagnosed timestamp into this function.
|
|
24
|
-
*
|
|
25
|
-
* Field precedence / thresholds are copied byte-for-byte from the prior plugin
|
|
26
|
-
* implementation; the plugin's pain-diagnostic-gate.test.ts (40 tests) passes
|
|
27
|
-
* unchanged through the adapter as the equivalence proof.
|
|
28
|
-
*
|
|
29
|
-
* ERR checklist:
|
|
30
|
-
* - ERR-001: inputs validated with Number.isFinite, not `as` casts.
|
|
31
|
-
* - ERR-002: every decision carries reason + detail.
|
|
32
|
-
* - EP-01: source string normalized with a Set membership check.
|
|
33
|
-
*/
|
|
34
|
-
// ── Defaults (migrated verbatim; previously inline magic numbers) ──────────
|
|
35
|
-
/** Default cooldown window: 15 minutes. */
|
|
36
|
-
export const DEFAULT_COOLDOWN_MS = 15 * 60 * 1000;
|
|
37
|
-
/** Default pain-trigger threshold. */
|
|
38
|
-
export const DEFAULT_PAIN_TRIGGER = 40;
|
|
39
|
-
/** Default high-severity threshold (risky high-score). */
|
|
40
|
-
export const DEFAULT_HIGH_SEVERITY = 70;
|
|
41
|
-
/** Default repeated-failure threshold (consecutive errors). */
|
|
42
|
-
export const DEFAULT_REPEATED_FAILURE = 4;
|
|
43
|
-
/** Default semantic-pain floor. */
|
|
44
|
-
export const DEFAULT_SEMANTIC_PAIN_FLOOR = 60;
|
|
45
|
-
const PAIN_DIAGNOSTIC_SOURCES = [
|
|
46
|
-
'manual',
|
|
47
|
-
'tool_failure',
|
|
48
|
-
'dispatch_error',
|
|
49
|
-
'gate_blocked',
|
|
50
|
-
'user_empathy',
|
|
51
|
-
'llm_paralysis',
|
|
52
|
-
'semantic',
|
|
53
|
-
'subagent_error',
|
|
54
|
-
];
|
|
55
|
-
// ── Pure helpers ────────────────────────────────────────────────────────────
|
|
56
|
-
/**
|
|
57
|
-
* Normalize a raw source string to a known PainDiagnosticSource.
|
|
58
|
-
*
|
|
59
|
-
* Unknown sources are passed through unchanged (the caller may still match them
|
|
60
|
-
* against custom thresholds) but flagged via the returned `unknown` flag so the
|
|
61
|
-
* plugin adapter can log it. Core itself does not log.
|
|
62
|
-
*/
|
|
63
|
-
export function normalizedSource(source) {
|
|
64
|
-
if (source.startsWith('llm_') && source !== 'llm_paralysis') {
|
|
65
|
-
return { source: 'semantic', unknown: false };
|
|
66
|
-
}
|
|
67
|
-
const isKnown = PAIN_DIAGNOSTIC_SOURCES.includes(source);
|
|
68
|
-
return { source, unknown: !isKnown };
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Build the episode key that scopes cooldown to a (session, source, hash) triple.
|
|
72
|
-
*/
|
|
73
|
-
export function buildEpisodeKey(input) {
|
|
74
|
-
const { source } = normalizedSource(input.source);
|
|
75
|
-
const sessionId = input.sessionId || 'unknown';
|
|
76
|
-
const hash = input.errorHash || 'no-hash';
|
|
77
|
-
return `${sessionId}:${source}:${hash}`;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Evaluate the pure gate decision.
|
|
81
|
-
*
|
|
82
|
-
* @param input - gate input (time in nowMs is the caller's responsibility)
|
|
83
|
-
* @param lastDiagnosedAtMs - the last time this episode was diagnosed, or undefined
|
|
84
|
-
* if never. Provided by the plugin adapter which owns the cooldown Map.
|
|
85
|
-
* @returns the gate decision. If shouldDiagnose is true, the caller MUST record
|
|
86
|
-
* nowMs against this episode (the plugin adapter does this in markDiagnosed).
|
|
87
|
-
*
|
|
88
|
-
* Note on the "unknown source" side effect: the prior plugin implementation
|
|
89
|
-
* logged unknown sources via SystemLogger. Core cannot log, so it surfaces the
|
|
90
|
-
* unknown flag through normalizedSource; the plugin adapter is responsible for
|
|
91
|
-
* logging when it observes an unknown source before calling this function.
|
|
92
|
-
*/
|
|
93
|
-
export function evaluatePainDiagnosticGateDecision(input, lastDiagnosedAtMs) {
|
|
94
|
-
const { source } = normalizedSource(input.source);
|
|
95
|
-
const episodeKey = buildEpisodeKey(input);
|
|
96
|
-
const painTrigger = input.thresholds?.painTrigger ?? DEFAULT_PAIN_TRIGGER;
|
|
97
|
-
const highSeverity = input.thresholds?.highSeverity ?? DEFAULT_HIGH_SEVERITY;
|
|
98
|
-
const highGfi = input.thresholds?.highGfi ?? Math.max(highSeverity, painTrigger + 30);
|
|
99
|
-
const repeatedFailure = input.thresholds?.repeatedFailure ?? DEFAULT_REPEATED_FAILURE;
|
|
100
|
-
const semanticPain = input.thresholds?.semanticPain ?? Math.max(painTrigger, DEFAULT_SEMANTIC_PAIN_FLOOR);
|
|
101
|
-
const score = Number.isFinite(input.score) ? input.score : 0;
|
|
102
|
-
const currentGfi = Number.isFinite(input.currentGfi) ? input.currentGfi : 0;
|
|
103
|
-
const consecutiveErrors = typeof input.consecutiveErrors === 'number' && Number.isFinite(input.consecutiveErrors)
|
|
104
|
-
? input.consecutiveErrors
|
|
105
|
-
: 0;
|
|
106
|
-
const cooldownMs = input.cooldownMs ?? DEFAULT_COOLDOWN_MS;
|
|
107
|
-
const nowMs = input.nowMs ?? 0;
|
|
108
|
-
const withinCooldown = cooldownMs > 0 && lastDiagnosedAtMs !== undefined && nowMs - lastDiagnosedAtMs < cooldownMs;
|
|
109
|
-
const approve = (reason, detail) => {
|
|
110
|
-
if (withinCooldown) {
|
|
111
|
-
return {
|
|
112
|
-
shouldDiagnose: false,
|
|
113
|
-
reason: 'cooldown',
|
|
114
|
-
episodeKey,
|
|
115
|
-
detail: `recently diagnosed; ${detail}`,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
return { shouldDiagnose: true, reason, episodeKey, detail };
|
|
119
|
-
};
|
|
120
|
-
if (source === 'manual') {
|
|
121
|
-
return approve('manual', 'manual pain signal bypasses automatic gate');
|
|
122
|
-
}
|
|
123
|
-
if (source === 'subagent_error' && score >= painTrigger) {
|
|
124
|
-
return approve('subagent_error', `subagent error score ${score} >= ${painTrigger}`);
|
|
125
|
-
}
|
|
126
|
-
if (source === 'llm_paralysis' && score >= painTrigger) {
|
|
127
|
-
return approve('llm_paralysis', `llm paralysis score ${score} >= ${painTrigger}`);
|
|
128
|
-
}
|
|
129
|
-
if (source === 'gate_blocked' && score >= painTrigger) {
|
|
130
|
-
return approve('gate_blocked', `gate blocked score ${score} >= ${painTrigger}`);
|
|
131
|
-
}
|
|
132
|
-
if ((source === 'user_empathy' || source === 'semantic') && score >= semanticPain) {
|
|
133
|
-
return approve('semantic_pain', `semantic pain score ${score} >= ${semanticPain}`);
|
|
134
|
-
}
|
|
135
|
-
if (input.isRisky === true && score >= highSeverity) {
|
|
136
|
-
return approve('risky_high_score', `risky operation score ${score} >= ${highSeverity}`);
|
|
137
|
-
}
|
|
138
|
-
if (consecutiveErrors >= repeatedFailure) {
|
|
139
|
-
return approve('repeated_failure', `consecutive errors ${consecutiveErrors} >= ${repeatedFailure}`);
|
|
140
|
-
}
|
|
141
|
-
if (currentGfi >= highGfi) {
|
|
142
|
-
return approve('high_gfi', `GFI ${currentGfi.toFixed(1)} >= ${highGfi}`);
|
|
143
|
-
}
|
|
144
|
-
return {
|
|
145
|
-
shouldDiagnose: false,
|
|
146
|
-
reason: 'below_gate',
|
|
147
|
-
episodeKey,
|
|
148
|
-
detail: `score=${score}; gfi=${currentGfi.toFixed(1)}; consecutive=${consecutiveErrors}`,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
export function isCooldownActive(input) {
|
|
152
|
-
const effectiveCooldown = input.cooldownMs ?? DEFAULT_COOLDOWN_MS;
|
|
153
|
-
if (effectiveCooldown <= 0)
|
|
154
|
-
return false;
|
|
155
|
-
if (input.lastDiagnosedAtMs === undefined)
|
|
156
|
-
return false;
|
|
157
|
-
return input.nowMs - input.lastDiagnosedAtMs < effectiveCooldown;
|
|
158
|
-
}
|
|
159
|
-
//# sourceMappingURL=pain-diagnostic-gate-policy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pain-diagnostic-gate-policy.js","sourceRoot":"","sources":["../../../src/runtime-v2/pain-gate/pain-diagnostic-gate-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,8EAA8E;AAE9E,2CAA2C;AAC3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAClD,sCAAsC;AACtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAC1C,mCAAmC;AACnC,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAE9C,MAAM,uBAAuB,GAAG;IAC9B,QAAQ;IACR,cAAc;IACd,gBAAgB;IAChB,cAAc;IACd,cAAc;IACd,eAAe;IACf,UAAU;IACV,gBAAgB;CACR,CAAC;AA0CX,+EAA+E;AAE/E;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,IAAI,MAAM,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MAAM,EAAE,SAAS,KAAK,SAAS,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,iBAAiB,EAAE;KACzF,CAAC;AACJ,CAAC;AAuBD,MAAM,UAAU,gBAAgB,CAAC,KAAyB;IACxD,MAAM,iBAAiB,GAAG,KAAK,CAAC,UAAU,IAAI,mBAAmB,CAAC;IAClE,IAAI,iBAAiB,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,KAAK,CAAC,iBAAiB,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxD,OAAO,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;AACnE,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pain Evidence Ingress — PRI-642 SPEC §8.
|
|
3
|
-
*
|
|
4
|
-
* THIN RE-EXPORT: the ingress semantic authority lives in
|
|
5
|
-
* `@principles/core/runtime-v2` (pain-ingress.ts + pain-ingress-payload.ts)
|
|
6
|
-
* so that EVERY adapter — OpenClaw funnel, pd-cli, and future hosts —
|
|
7
|
-
* evaluates pain ingress facts through ONE implementation. Host adapters
|
|
8
|
-
* differ only in acquisition (session/trajectory/evidence I/O); the
|
|
9
|
-
* interpretation of those facts has a single home in core.
|
|
10
|
-
*
|
|
11
|
-
* This module keeps the existing `@principles/host-runtime` import surface
|
|
12
|
-
* stable for adapters that already import from here. It adds nothing
|
|
13
|
-
* semantic of its own.
|
|
14
|
-
*/
|
|
15
|
-
export { evaluatePainIngress, parsePainIngressReport, validateOriginCorrelationInvariant, SENTINEL_SESSION_IDS, isSentinelSessionId, } from '@principles/core/runtime-v2';
|
|
16
|
-
export type { PainIngressReport, PainIngressDecision, PainIngressParseResult, LegacyPainSubmission, PainOrigin, PainCorrelation, IngressEvidenceEntry, PainEvidenceBundle, PainEvidenceUnavailableReason, PainIngressV1Payload, } from '@principles/core/runtime-v2';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pain Evidence Ingress — PRI-642 SPEC §8.
|
|
3
|
-
*
|
|
4
|
-
* THIN RE-EXPORT: the ingress semantic authority lives in
|
|
5
|
-
* `@principles/core/runtime-v2` (pain-ingress.ts + pain-ingress-payload.ts)
|
|
6
|
-
* so that EVERY adapter — OpenClaw funnel, pd-cli, and future hosts —
|
|
7
|
-
* evaluates pain ingress facts through ONE implementation. Host adapters
|
|
8
|
-
* differ only in acquisition (session/trajectory/evidence I/O); the
|
|
9
|
-
* interpretation of those facts has a single home in core.
|
|
10
|
-
*
|
|
11
|
-
* This module keeps the existing `@principles/host-runtime` import surface
|
|
12
|
-
* stable for adapters that already import from here. It adds nothing
|
|
13
|
-
* semantic of its own.
|
|
14
|
-
*/
|
|
15
|
-
export { evaluatePainIngress, parsePainIngressReport, validateOriginCorrelationInvariant, SENTINEL_SESSION_IDS, isSentinelSessionId, } from '@principles/core/runtime-v2';
|
|
@@ -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,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
|
-
}
|