@governed-ai/runtime 1.0.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/README.md +251 -0
- package/dist/domains/finance/entity_rules.d.ts +4 -0
- package/dist/domains/finance/entity_rules.d.ts.map +1 -0
- package/dist/domains/finance/entity_rules.js +19 -0
- package/dist/domains/finance/entity_rules.js.map +1 -0
- package/dist/domains/finance/policy.yaml +85 -0
- package/dist/domains/health/entity_rules.d.ts +4 -0
- package/dist/domains/health/entity_rules.d.ts.map +1 -0
- package/dist/domains/health/entity_rules.js +20 -0
- package/dist/domains/health/entity_rules.js.map +1 -0
- package/dist/domains/health/policy.yaml +95 -0
- package/dist/domains/insurance/entity_rules.d.ts +4 -0
- package/dist/domains/insurance/entity_rules.d.ts.map +1 -0
- package/dist/domains/insurance/entity_rules.js +19 -0
- package/dist/domains/insurance/entity_rules.js.map +1 -0
- package/dist/domains/insurance/policy.yaml +88 -0
- package/dist/domains/registry.d.ts +20 -0
- package/dist/domains/registry.d.ts.map +1 -0
- package/dist/domains/registry.js +65 -0
- package/dist/domains/registry.js.map +1 -0
- package/dist/domains/types.d.ts +12 -0
- package/dist/domains/types.d.ts.map +1 -0
- package/dist/domains/types.js +2 -0
- package/dist/domains/types.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/sdk/governance.d.ts +121 -0
- package/dist/sdk/governance.d.ts.map +1 -0
- package/dist/sdk/governance.js +219 -0
- package/dist/sdk/governance.js.map +1 -0
- package/dist/src/api/index.d.ts +2 -0
- package/dist/src/api/index.d.ts.map +1 -0
- package/dist/src/api/index.js +2 -0
- package/dist/src/api/index.js.map +1 -0
- package/dist/src/certification/test_runner.d.ts +86 -0
- package/dist/src/certification/test_runner.d.ts.map +1 -0
- package/dist/src/certification/test_runner.js +422 -0
- package/dist/src/certification/test_runner.js.map +1 -0
- package/dist/src/classification/index.d.ts +2 -0
- package/dist/src/classification/index.d.ts.map +1 -0
- package/dist/src/classification/index.js +2 -0
- package/dist/src/classification/index.js.map +1 -0
- package/dist/src/classification/query_classifier.d.ts +13 -0
- package/dist/src/classification/query_classifier.d.ts.map +1 -0
- package/dist/src/classification/query_classifier.js +142 -0
- package/dist/src/classification/query_classifier.js.map +1 -0
- package/dist/src/config/index.d.ts +2 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +2 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/context/index.d.ts +2 -0
- package/dist/src/context/index.d.ts.map +1 -0
- package/dist/src/context/index.js +2 -0
- package/dist/src/context/index.js.map +1 -0
- package/dist/src/gateway/index.d.ts +2 -0
- package/dist/src/gateway/index.d.ts.map +1 -0
- package/dist/src/gateway/index.js +2 -0
- package/dist/src/gateway/index.js.map +1 -0
- package/dist/src/gateway/pre_interaction_governance.d.ts +34 -0
- package/dist/src/gateway/pre_interaction_governance.d.ts.map +1 -0
- package/dist/src/gateway/pre_interaction_governance.js +187 -0
- package/dist/src/gateway/pre_interaction_governance.js.map +1 -0
- package/dist/src/interfaces/entity.d.ts +16 -0
- package/dist/src/interfaces/entity.d.ts.map +1 -0
- package/dist/src/interfaces/entity.js +2 -0
- package/dist/src/interfaces/entity.js.map +1 -0
- package/dist/src/normalization/index.d.ts +2 -0
- package/dist/src/normalization/index.d.ts.map +1 -0
- package/dist/src/normalization/index.js +2 -0
- package/dist/src/normalization/index.js.map +1 -0
- package/dist/src/normalization/response_normalizer.d.ts +30 -0
- package/dist/src/normalization/response_normalizer.d.ts.map +1 -0
- package/dist/src/normalization/response_normalizer.js +224 -0
- package/dist/src/normalization/response_normalizer.js.map +1 -0
- package/dist/src/orchestrator.d.ts +21 -0
- package/dist/src/orchestrator.d.ts.map +1 -0
- package/dist/src/orchestrator.js +355 -0
- package/dist/src/orchestrator.js.map +1 -0
- package/dist/src/policy/index.d.ts +3 -0
- package/dist/src/policy/index.d.ts.map +1 -0
- package/dist/src/policy/index.js +2 -0
- package/dist/src/policy/index.js.map +1 -0
- package/dist/src/policy/policy_engine.d.ts +47 -0
- package/dist/src/policy/policy_engine.d.ts.map +1 -0
- package/dist/src/policy/policy_engine.js +100 -0
- package/dist/src/policy/policy_engine.js.map +1 -0
- package/dist/src/reasoning/index.d.ts +2 -0
- package/dist/src/reasoning/index.d.ts.map +1 -0
- package/dist/src/reasoning/index.js +2 -0
- package/dist/src/reasoning/index.js.map +1 -0
- package/dist/src/reasoning/reasoning_validator.d.ts +28 -0
- package/dist/src/reasoning/reasoning_validator.d.ts.map +1 -0
- package/dist/src/reasoning/reasoning_validator.js +277 -0
- package/dist/src/reasoning/reasoning_validator.js.map +1 -0
- package/dist/src/reasoning/trace_validator.d.ts +33 -0
- package/dist/src/reasoning/trace_validator.d.ts.map +1 -0
- package/dist/src/reasoning/trace_validator.js +251 -0
- package/dist/src/reasoning/trace_validator.js.map +1 -0
- package/dist/src/state/interaction_state.d.ts +59 -0
- package/dist/src/state/interaction_state.d.ts.map +1 -0
- package/dist/src/state/interaction_state.js +75 -0
- package/dist/src/state/interaction_state.js.map +1 -0
- package/dist/src/telemetry/governance_logger.d.ts +36 -0
- package/dist/src/telemetry/governance_logger.d.ts.map +1 -0
- package/dist/src/telemetry/governance_logger.js +32 -0
- package/dist/src/telemetry/governance_logger.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +2 -0
- package/dist/src/telemetry/index.d.ts.map +1 -0
- package/dist/src/telemetry/index.js +2 -0
- package/dist/src/telemetry/index.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +49 -0
- package/dist/src/telemetry/metrics.d.ts.map +1 -0
- package/dist/src/telemetry/metrics.js +115 -0
- package/dist/src/telemetry/metrics.js.map +1 -0
- package/dist/src/tools/tool_guard.d.ts +39 -0
- package/dist/src/tools/tool_guard.d.ts.map +1 -0
- package/dist/src/tools/tool_guard.js +226 -0
- package/dist/src/tools/tool_guard.js.map +1 -0
- package/dist/src/types/index.d.ts +65 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +2 -0
- package/dist/src/types/index.js.map +1 -0
- package/domains/finance/policy.yaml +85 -0
- package/domains/health/policy.yaml +95 -0
- package/domains/insurance/policy.yaml +88 -0
- package/package.json +58 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
const BULK_DATA_PATTERNS = [
|
|
2
|
+
/\ball\s+patients?\b/i,
|
|
3
|
+
/\bevery\s+(?:patient|record|user|account|client|claim)\b/i,
|
|
4
|
+
/\bbulk\s+(?:export|download|access|retrieve|fetch|query)\b/i,
|
|
5
|
+
/\bselect\s+\*\s+from\b/i,
|
|
6
|
+
/\bdump\s+(?:all|database|table|records)\b/i,
|
|
7
|
+
/\blist\s+all\s+(?:patients?|records?|users?|accounts?|clients?|claims?)\b/i,
|
|
8
|
+
/\bexport\s+(?:all|entire|full|complete)\b/i,
|
|
9
|
+
];
|
|
10
|
+
const SENSITIVE_FIELD_PATTERNS = [
|
|
11
|
+
/\bssn\b/i,
|
|
12
|
+
/\bsocial.?security\b/i,
|
|
13
|
+
/\bcredit.?card\b/i,
|
|
14
|
+
/\bbank.?account\b/i,
|
|
15
|
+
/\bpassword\b/i,
|
|
16
|
+
/\bsecret\b/i,
|
|
17
|
+
/\bprivate.?key\b/i,
|
|
18
|
+
/\baccess.?token\b/i,
|
|
19
|
+
/\bapi.?key\b/i,
|
|
20
|
+
];
|
|
21
|
+
const BLOCKED_TOOLS = new Set([
|
|
22
|
+
"database_drop",
|
|
23
|
+
"delete_all_records",
|
|
24
|
+
"truncate_table",
|
|
25
|
+
"raw_sql_execute",
|
|
26
|
+
"system_shell",
|
|
27
|
+
"file_system_write",
|
|
28
|
+
"admin_override",
|
|
29
|
+
]);
|
|
30
|
+
function containsPattern(value, patterns) {
|
|
31
|
+
for (const pattern of patterns) {
|
|
32
|
+
if (pattern.test(value)) {
|
|
33
|
+
return pattern;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
function flattenParams(params) {
|
|
39
|
+
const values = [];
|
|
40
|
+
for (const [key, val] of Object.entries(params)) {
|
|
41
|
+
values.push(key);
|
|
42
|
+
if (typeof val === "string") {
|
|
43
|
+
values.push(val);
|
|
44
|
+
}
|
|
45
|
+
else if (Array.isArray(val)) {
|
|
46
|
+
for (const item of val) {
|
|
47
|
+
if (typeof item === "string") {
|
|
48
|
+
values.push(item);
|
|
49
|
+
}
|
|
50
|
+
else if (item && typeof item === "object") {
|
|
51
|
+
values.push(...flattenParams(item));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (val && typeof val === "object") {
|
|
56
|
+
values.push(...flattenParams(val));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return values;
|
|
60
|
+
}
|
|
61
|
+
function createDefaultRules() {
|
|
62
|
+
return [
|
|
63
|
+
{
|
|
64
|
+
id: "blocked_tool",
|
|
65
|
+
description: "Block tools that are explicitly forbidden",
|
|
66
|
+
severity: "critical",
|
|
67
|
+
check: (request) => {
|
|
68
|
+
if (BLOCKED_TOOLS.has(request.toolName)) {
|
|
69
|
+
return {
|
|
70
|
+
rule: "blocked_tool",
|
|
71
|
+
severity: "critical",
|
|
72
|
+
description: `Tool '${request.toolName}' is blocked by governance policy. Destructive or administrative tools are not permitted.`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: "bulk_data_access",
|
|
80
|
+
description: "Prevent bulk or mass data access operations",
|
|
81
|
+
severity: "critical",
|
|
82
|
+
check: (request) => {
|
|
83
|
+
const paramValues = flattenParams(request.parameters);
|
|
84
|
+
for (const value of paramValues) {
|
|
85
|
+
const match = containsPattern(value, BULK_DATA_PATTERNS);
|
|
86
|
+
if (match) {
|
|
87
|
+
return {
|
|
88
|
+
rule: "bulk_data_access",
|
|
89
|
+
severity: "critical",
|
|
90
|
+
description: `Bulk data access detected in tool '${request.toolName}'. Mass data retrieval is not permitted. Specify a single entity.`,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: "sensitive_field_access",
|
|
99
|
+
description: "Block access to sensitive personally identifiable fields",
|
|
100
|
+
severity: "critical",
|
|
101
|
+
check: (request) => {
|
|
102
|
+
const paramValues = flattenParams(request.parameters);
|
|
103
|
+
for (const value of paramValues) {
|
|
104
|
+
const match = containsPattern(value, SENSITIVE_FIELD_PATTERNS);
|
|
105
|
+
if (match) {
|
|
106
|
+
return {
|
|
107
|
+
rule: "sensitive_field_access",
|
|
108
|
+
severity: "critical",
|
|
109
|
+
description: `Sensitive field access detected in tool '${request.toolName}'. Access to personally identifiable or credential fields is not permitted.`,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: "unauthorized_entity_retrieval",
|
|
118
|
+
description: "Block entity retrieval without a scoped identifier",
|
|
119
|
+
severity: "high",
|
|
120
|
+
check: (request) => {
|
|
121
|
+
const entityTools = ["get_patient", "get_client", "get_account", "get_user", "fetch_record", "retrieve_entity"];
|
|
122
|
+
if (!entityTools.includes(request.toolName)) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const hasId = request.parameters.id || request.parameters.entityId || request.parameters.patientId || request.parameters.clientId || request.parameters.accountId || request.parameters.userId;
|
|
126
|
+
if (!hasId) {
|
|
127
|
+
return {
|
|
128
|
+
rule: "unauthorized_entity_retrieval",
|
|
129
|
+
severity: "high",
|
|
130
|
+
description: `Tool '${request.toolName}' requires a scoped entity identifier. Unscoped entity retrieval is not permitted.`,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: "excessive_limit",
|
|
138
|
+
description: "Block queries requesting excessive record counts",
|
|
139
|
+
severity: "high",
|
|
140
|
+
check: (request) => {
|
|
141
|
+
const raw = request.parameters.limit ?? request.parameters.count ?? request.parameters.size ?? request.parameters.pageSize;
|
|
142
|
+
if (raw == null)
|
|
143
|
+
return null;
|
|
144
|
+
const limit = typeof raw === "number" ? raw : Number(raw);
|
|
145
|
+
if (!Number.isNaN(limit) && limit > 100) {
|
|
146
|
+
return {
|
|
147
|
+
rule: "excessive_limit",
|
|
148
|
+
severity: "high",
|
|
149
|
+
description: `Tool '${request.toolName}' requested ${limit} records, exceeding the maximum of 100. Reduce the limit to prevent bulk data exposure.`,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: "cross_entity_access",
|
|
157
|
+
description: "Detect potential cross-entity data access in a single call",
|
|
158
|
+
severity: "high",
|
|
159
|
+
check: (request) => {
|
|
160
|
+
const idFields = ["patientId", "clientId", "accountId", "userId", "entityId"];
|
|
161
|
+
const ids = new Set();
|
|
162
|
+
for (const field of idFields) {
|
|
163
|
+
const val = request.parameters[field];
|
|
164
|
+
if (typeof val === "string" && val.length > 0) {
|
|
165
|
+
ids.add(val);
|
|
166
|
+
}
|
|
167
|
+
if (Array.isArray(val)) {
|
|
168
|
+
for (const item of val) {
|
|
169
|
+
if (typeof item === "string" && item.length > 0) {
|
|
170
|
+
ids.add(item);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (ids.size > 1) {
|
|
176
|
+
return {
|
|
177
|
+
rule: "cross_entity_access",
|
|
178
|
+
severity: "high",
|
|
179
|
+
description: `Tool '${request.toolName}' references multiple distinct entities. Cross-entity data access in a single call is not permitted.`,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return null;
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
];
|
|
186
|
+
}
|
|
187
|
+
export class ToolGuard {
|
|
188
|
+
rules = new Map();
|
|
189
|
+
constructor(rules) {
|
|
190
|
+
const activeRules = rules ?? createDefaultRules();
|
|
191
|
+
for (const rule of activeRules) {
|
|
192
|
+
this.rules.set(rule.id, rule);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
evaluate(request) {
|
|
196
|
+
const violations = [];
|
|
197
|
+
for (const rule of this.rules.values()) {
|
|
198
|
+
const violation = rule.check(request);
|
|
199
|
+
if (violation) {
|
|
200
|
+
violations.push(violation);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const hasCritical = violations.some((v) => v.severity === "critical");
|
|
204
|
+
const hasHigh = violations.some((v) => v.severity === "high");
|
|
205
|
+
const blocked = hasCritical || hasHigh;
|
|
206
|
+
return {
|
|
207
|
+
allowed: !blocked,
|
|
208
|
+
blockedReason: blocked
|
|
209
|
+
? violations.map((v) => v.description).join("; ")
|
|
210
|
+
: null,
|
|
211
|
+
violations,
|
|
212
|
+
toolName: request.toolName,
|
|
213
|
+
sanitizedParameters: blocked ? null : request.parameters,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
addRule(rule) {
|
|
217
|
+
this.rules.set(rule.id, rule);
|
|
218
|
+
}
|
|
219
|
+
removeRule(ruleId) {
|
|
220
|
+
this.rules.delete(ruleId);
|
|
221
|
+
}
|
|
222
|
+
listRules() {
|
|
223
|
+
return [...this.rules.values()];
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=tool_guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool_guard.js","sourceRoot":"","sources":["../../../src/tools/tool_guard.ts"],"names":[],"mappings":"AAmCA,MAAM,kBAAkB,GAAG;IACzB,sBAAsB;IACtB,2DAA2D;IAC3D,6DAA6D;IAC7D,yBAAyB;IACzB,4CAA4C;IAC5C,4EAA4E;IAC5E,4CAA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AAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtC,IAAI,SAAS,EAAE,CAAC;gBACd,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QAED,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC;QACtE,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC;QAC9D,MAAM,OAAO,GAAG,WAAW,IAAI,OAAO,CAAC;QAEvC,OAAO;YACL,OAAO,EAAE,CAAC,OAAO;YACjB,aAAa,EAAE,OAAO;gBACpB,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gBACjD,CAAC,CAAC,IAAI;YACR,UAAU;YACV,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,mBAAmB,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU;SACzD,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,IAAoB;QAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,UAAU,CAAC,MAAc;QACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,SAAS;QACP,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { QueryClassification } from "../classification/query_classifier";
|
|
2
|
+
import type { PreInteractionResult } from "../gateway/pre_interaction_governance";
|
|
3
|
+
import type { PostInteractionResult, Violation } from "../reasoning/reasoning_validator";
|
|
4
|
+
import type { TraceValidationResult } from "../reasoning/trace_validator";
|
|
5
|
+
import type { NormalizedResponse } from "../normalization/response_normalizer";
|
|
6
|
+
import type { ToolGuardResult } from "../tools/tool_guard";
|
|
7
|
+
export interface GovernanceLLMResult {
|
|
8
|
+
response: string;
|
|
9
|
+
confidence: number;
|
|
10
|
+
reasoning: string;
|
|
11
|
+
evidence: string[];
|
|
12
|
+
missingData: string[];
|
|
13
|
+
confidenceLabel: string;
|
|
14
|
+
}
|
|
15
|
+
export interface GovernanceRetrievalContext {
|
|
16
|
+
patientId: string | null;
|
|
17
|
+
patientName: string | null;
|
|
18
|
+
biomarkerData: Array<{
|
|
19
|
+
biomarkerId: string;
|
|
20
|
+
value: number;
|
|
21
|
+
unit?: string;
|
|
22
|
+
sourceDocumentId?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
}>;
|
|
25
|
+
documents: Array<{
|
|
26
|
+
documentId: string;
|
|
27
|
+
reportDate?: string;
|
|
28
|
+
rawText?: string;
|
|
29
|
+
}>;
|
|
30
|
+
extractedData?: any;
|
|
31
|
+
retrievalConfidence: number;
|
|
32
|
+
}
|
|
33
|
+
export interface GovernanceToolCall {
|
|
34
|
+
toolName: string;
|
|
35
|
+
parameters: Record<string, any>;
|
|
36
|
+
}
|
|
37
|
+
export interface GovernanceContext {
|
|
38
|
+
sessionPatientId: string | null;
|
|
39
|
+
retrievalContext?: GovernanceRetrievalContext;
|
|
40
|
+
reasoningMode?: string;
|
|
41
|
+
isRefinement?: boolean;
|
|
42
|
+
previousResponse?: string | null;
|
|
43
|
+
conversationSummary?: string | null;
|
|
44
|
+
activeTopic?: string | null;
|
|
45
|
+
patientSnapshotSummary?: string | null;
|
|
46
|
+
toolCalls?: GovernanceToolCall[];
|
|
47
|
+
}
|
|
48
|
+
export type GovernanceLLMCall = (query: string, context: GovernanceContext) => Promise<GovernanceLLMResult>;
|
|
49
|
+
export interface GovernanceResult {
|
|
50
|
+
finalResponse: string;
|
|
51
|
+
blocked: boolean;
|
|
52
|
+
blockedStage: "pre_interaction" | "post_interaction" | "tool_guard" | "trace_validation" | null;
|
|
53
|
+
blockedReason: string | null;
|
|
54
|
+
classification: QueryClassification;
|
|
55
|
+
preInteraction: PreInteractionResult;
|
|
56
|
+
postInteraction: PostInteractionResult | null;
|
|
57
|
+
normalization: NormalizedResponse | null;
|
|
58
|
+
violations: Violation[];
|
|
59
|
+
llmCalled: boolean;
|
|
60
|
+
domain: string;
|
|
61
|
+
sessionId: string | null;
|
|
62
|
+
toolGuardResults: ToolGuardResult[];
|
|
63
|
+
traceValidation: TraceValidationResult | null;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AACzF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAA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,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,YAAY,GAAG,kBAAkB,GAAG,IAAI,CAAC;IAChG,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,cAAc,EAAE,mBAAmB,CAAC;IACpC,cAAc,EAAE,oBAAoB,CAAC;IACrC,eAAe,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC9C,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACzC,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,eAAe,EAAE,qBAAqB,GAAG,IAAI,CAAC;CAC/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
domain: finance
|
|
2
|
+
version: "1.0"
|
|
3
|
+
|
|
4
|
+
blocked_query_types:
|
|
5
|
+
investment_advice:
|
|
6
|
+
action: block
|
|
7
|
+
response: >-
|
|
8
|
+
I cannot provide specific investment advice or recommend buying, selling,
|
|
9
|
+
or holding any financial instruments. Investment decisions should be made
|
|
10
|
+
in consultation with a licensed financial advisor who understands your
|
|
11
|
+
complete financial situation and risk tolerance.
|
|
12
|
+
|
|
13
|
+
tax_advice:
|
|
14
|
+
action: block
|
|
15
|
+
response: >-
|
|
16
|
+
I cannot provide tax advice or guidance on tax filings, deductions, or
|
|
17
|
+
strategies. Tax matters require the expertise of a licensed tax
|
|
18
|
+
professional or certified public accountant who can evaluate your specific
|
|
19
|
+
circumstances.
|
|
20
|
+
|
|
21
|
+
account_fraud:
|
|
22
|
+
action: block
|
|
23
|
+
response: >-
|
|
24
|
+
I cannot assist with any activity that could constitute fraud, including
|
|
25
|
+
misrepresentation of financial information, unauthorized account access,
|
|
26
|
+
or manipulation of financial records.
|
|
27
|
+
|
|
28
|
+
privacy_request:
|
|
29
|
+
action: block
|
|
30
|
+
response: >-
|
|
31
|
+
I cannot disclose information about other account holders or their
|
|
32
|
+
financial data. Account privacy is protected under strict regulatory
|
|
33
|
+
policies. Please reference only your own account.
|
|
34
|
+
|
|
35
|
+
safety_override:
|
|
36
|
+
action: block
|
|
37
|
+
response: >-
|
|
38
|
+
It is not possible to bypass or override compliance rules and governance
|
|
39
|
+
constraints. These safeguards exist to protect financial integrity and
|
|
40
|
+
regulatory compliance.
|
|
41
|
+
|
|
42
|
+
regulatory_violation:
|
|
43
|
+
action: block
|
|
44
|
+
response: >-
|
|
45
|
+
I cannot assist with any action that would violate financial regulations,
|
|
46
|
+
including but not limited to insider trading, money laundering, or
|
|
47
|
+
circumventing know-your-customer requirements.
|
|
48
|
+
|
|
49
|
+
privacy_rules:
|
|
50
|
+
- id: no_cross_account_access
|
|
51
|
+
description: Prevent access to another account holder's financial data
|
|
52
|
+
severity: critical
|
|
53
|
+
|
|
54
|
+
- id: no_bulk_account_disclosure
|
|
55
|
+
description: Prevent bulk disclosure of account information
|
|
56
|
+
severity: critical
|
|
57
|
+
|
|
58
|
+
- id: require_account_identity
|
|
59
|
+
description: Require a verified account identity before returning financial data
|
|
60
|
+
severity: high
|
|
61
|
+
|
|
62
|
+
- id: no_raw_identifier_exposure
|
|
63
|
+
description: Do not expose internal account numbers or routing numbers in responses
|
|
64
|
+
severity: high
|
|
65
|
+
|
|
66
|
+
safety_rules:
|
|
67
|
+
- id: no_investment_recommendations
|
|
68
|
+
description: System must not recommend specific investments or trades
|
|
69
|
+
severity: critical
|
|
70
|
+
|
|
71
|
+
- id: no_tax_guidance
|
|
72
|
+
description: System must not provide specific tax filing advice
|
|
73
|
+
severity: critical
|
|
74
|
+
|
|
75
|
+
- id: no_compliance_bypass
|
|
76
|
+
description: Reject any attempt to override regulatory compliance safeguards
|
|
77
|
+
severity: critical
|
|
78
|
+
|
|
79
|
+
- id: require_advisor_caveat
|
|
80
|
+
description: Include a financial-advisor consultation caveat in advisory responses
|
|
81
|
+
severity: high
|
|
82
|
+
|
|
83
|
+
- id: flag_low_confidence
|
|
84
|
+
description: Flag responses with low data confidence so the user is aware of limitations
|
|
85
|
+
severity: medium
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
domain: health
|
|
2
|
+
version: "1.0"
|
|
3
|
+
|
|
4
|
+
blocked_query_types:
|
|
5
|
+
diagnosis_request:
|
|
6
|
+
action: block
|
|
7
|
+
response: >-
|
|
8
|
+
I cannot provide medical diagnoses. It is not possible for this system
|
|
9
|
+
to diagnose conditions. Diagnosis requires clinical examination,
|
|
10
|
+
comprehensive testing, and professional medical judgment. Please consult
|
|
11
|
+
your healthcare provider or doctor for diagnostic evaluation.
|
|
12
|
+
|
|
13
|
+
medication_advice:
|
|
14
|
+
action: block
|
|
15
|
+
response: >-
|
|
16
|
+
I cannot provide medication advice, including recommendations to start,
|
|
17
|
+
stop, or change medications. Medication decisions should only be made by
|
|
18
|
+
your prescribing physician or healthcare provider. Please consult your
|
|
19
|
+
doctor based on your complete medical history.
|
|
20
|
+
|
|
21
|
+
population_query:
|
|
22
|
+
action: block
|
|
23
|
+
response: >-
|
|
24
|
+
I cannot provide information about multiple patients or patient
|
|
25
|
+
populations. For privacy and security reasons, patient data is protected
|
|
26
|
+
and not authorized for bulk access. Please specify a specific patient to
|
|
27
|
+
discuss their individual data.
|
|
28
|
+
|
|
29
|
+
privacy_request:
|
|
30
|
+
action: block
|
|
31
|
+
response: >-
|
|
32
|
+
I cannot disclose information about all patients or their conditions.
|
|
33
|
+
Patient privacy is protected under strict authorization policies. This
|
|
34
|
+
system is not authorized to share data about multiple patients. Please
|
|
35
|
+
specify a specific individual patient.
|
|
36
|
+
|
|
37
|
+
safety_override:
|
|
38
|
+
action: block
|
|
39
|
+
response: >-
|
|
40
|
+
It is not possible to bypass or override safety rules and governance
|
|
41
|
+
constraints. I am unable to ignore safety protocols. These safeguards
|
|
42
|
+
exist to protect patient safety. For any diagnosis or medical decisions,
|
|
43
|
+
please consult your healthcare provider.
|
|
44
|
+
|
|
45
|
+
ethical_violation:
|
|
46
|
+
action: block
|
|
47
|
+
response: >-
|
|
48
|
+
I cannot hide, suppress, or remove medical findings from reports. This
|
|
49
|
+
is not possible and would be an ethical violation. It is my obligation to
|
|
50
|
+
maintain data integrity and transparency. All clinically relevant data,
|
|
51
|
+
including abnormal results, must remain transparent and accessible for
|
|
52
|
+
proper patient care. I refuse to comply with this request as it is
|
|
53
|
+
inappropriate.
|
|
54
|
+
|
|
55
|
+
privacy_rules:
|
|
56
|
+
- id: no_bulk_patient_access
|
|
57
|
+
description: Prevent access to multiple patient records in a single query
|
|
58
|
+
severity: critical
|
|
59
|
+
|
|
60
|
+
- id: no_cross_patient_data
|
|
61
|
+
description: Prevent leaking data from one patient into another patient's session
|
|
62
|
+
severity: critical
|
|
63
|
+
|
|
64
|
+
- id: require_patient_identity
|
|
65
|
+
description: Require a resolved patient identity before returning clinical data
|
|
66
|
+
severity: high
|
|
67
|
+
|
|
68
|
+
- id: no_raw_identifier_exposure
|
|
69
|
+
description: Do not expose internal database IDs or raw identifiers in responses
|
|
70
|
+
severity: medium
|
|
71
|
+
|
|
72
|
+
safety_rules:
|
|
73
|
+
- id: no_diagnosis
|
|
74
|
+
description: System must not produce or confirm clinical diagnoses
|
|
75
|
+
severity: critical
|
|
76
|
+
|
|
77
|
+
- id: no_prescriptions
|
|
78
|
+
description: System must not recommend starting, stopping, or changing medications
|
|
79
|
+
severity: critical
|
|
80
|
+
|
|
81
|
+
- id: no_safety_bypass
|
|
82
|
+
description: Reject any attempt to override or disable governance safeguards
|
|
83
|
+
severity: critical
|
|
84
|
+
|
|
85
|
+
- id: no_data_suppression
|
|
86
|
+
description: Do not hide, suppress, or remove clinically relevant findings
|
|
87
|
+
severity: critical
|
|
88
|
+
|
|
89
|
+
- id: require_consultation_caveat
|
|
90
|
+
description: Include a healthcare-provider consultation caveat in clinical responses
|
|
91
|
+
severity: high
|
|
92
|
+
|
|
93
|
+
- id: flag_low_confidence
|
|
94
|
+
description: Flag responses with low retrieval confidence so the user is aware of data limitations
|
|
95
|
+
severity: medium
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
domain: insurance
|
|
2
|
+
version: "1.0"
|
|
3
|
+
|
|
4
|
+
blocked_query_types:
|
|
5
|
+
claims_adjudication:
|
|
6
|
+
action: block
|
|
7
|
+
response: >-
|
|
8
|
+
I cannot adjudicate or approve insurance claims. Claims decisions require
|
|
9
|
+
review by a licensed claims adjuster who can assess the full documentation,
|
|
10
|
+
policy terms, and applicable regulations.
|
|
11
|
+
|
|
12
|
+
coverage_determination:
|
|
13
|
+
action: block
|
|
14
|
+
response: >-
|
|
15
|
+
I cannot make binding coverage determinations. Coverage decisions depend
|
|
16
|
+
on your specific policy terms, exclusions, and applicable state
|
|
17
|
+
regulations. Please contact your insurance representative for an official
|
|
18
|
+
coverage determination.
|
|
19
|
+
|
|
20
|
+
privacy_request:
|
|
21
|
+
action: block
|
|
22
|
+
response: >-
|
|
23
|
+
I cannot disclose information about other policyholders or their claims.
|
|
24
|
+
Policyholder privacy is protected under strict regulatory and contractual
|
|
25
|
+
obligations.
|
|
26
|
+
|
|
27
|
+
safety_override:
|
|
28
|
+
action: block
|
|
29
|
+
response: >-
|
|
30
|
+
It is not possible to bypass or override compliance rules and governance
|
|
31
|
+
constraints. These safeguards exist to protect policyholder rights and
|
|
32
|
+
regulatory compliance.
|
|
33
|
+
|
|
34
|
+
fraudulent_claim:
|
|
35
|
+
action: block
|
|
36
|
+
response: >-
|
|
37
|
+
I cannot assist with submitting false or misleading claim information.
|
|
38
|
+
Insurance fraud is a serious offense with legal consequences. All claim
|
|
39
|
+
information must be truthful and accurately documented.
|
|
40
|
+
|
|
41
|
+
regulatory_violation:
|
|
42
|
+
action: block
|
|
43
|
+
response: >-
|
|
44
|
+
I cannot assist with any action that would violate insurance regulations,
|
|
45
|
+
including unfair claims practices, discriminatory underwriting, or
|
|
46
|
+
misrepresentation of policy terms.
|
|
47
|
+
|
|
48
|
+
privacy_rules:
|
|
49
|
+
- id: no_cross_policyholder_access
|
|
50
|
+
description: Prevent access to another policyholder's claims or policy data
|
|
51
|
+
severity: critical
|
|
52
|
+
|
|
53
|
+
- id: no_bulk_policyholder_disclosure
|
|
54
|
+
description: Prevent bulk disclosure of policyholder information
|
|
55
|
+
severity: critical
|
|
56
|
+
|
|
57
|
+
- id: require_policyholder_identity
|
|
58
|
+
description: Require a verified policyholder identity before returning policy or claims data
|
|
59
|
+
severity: high
|
|
60
|
+
|
|
61
|
+
- id: no_raw_identifier_exposure
|
|
62
|
+
description: Do not expose internal policy numbers or claim IDs in responses
|
|
63
|
+
severity: medium
|
|
64
|
+
|
|
65
|
+
safety_rules:
|
|
66
|
+
- id: no_claims_adjudication
|
|
67
|
+
description: System must not approve or deny insurance claims
|
|
68
|
+
severity: critical
|
|
69
|
+
|
|
70
|
+
- id: no_coverage_binding
|
|
71
|
+
description: System must not make binding coverage determinations
|
|
72
|
+
severity: critical
|
|
73
|
+
|
|
74
|
+
- id: no_compliance_bypass
|
|
75
|
+
description: Reject any attempt to override regulatory compliance safeguards
|
|
76
|
+
severity: critical
|
|
77
|
+
|
|
78
|
+
- id: no_fraud_assistance
|
|
79
|
+
description: Refuse any request that could facilitate insurance fraud
|
|
80
|
+
severity: critical
|
|
81
|
+
|
|
82
|
+
- id: require_representative_caveat
|
|
83
|
+
description: Include an insurance-representative consultation caveat in policy responses
|
|
84
|
+
severity: high
|
|
85
|
+
|
|
86
|
+
- id: flag_low_confidence
|
|
87
|
+
description: Flag responses with low data confidence so the user is aware of limitations
|
|
88
|
+
severity: medium
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@governed-ai/runtime",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Agent-agnostic governance middleware for AI applications. Provides classification, pre/post-interaction governance, tool guarding, trace validation, telemetry, and certification.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./sdk": {
|
|
14
|
+
"types": "./dist/sdk/governance.d.ts",
|
|
15
|
+
"import": "./dist/sdk/governance.js"
|
|
16
|
+
},
|
|
17
|
+
"./orchestrator": {
|
|
18
|
+
"types": "./dist/src/orchestrator.d.ts",
|
|
19
|
+
"import": "./dist/src/orchestrator.js"
|
|
20
|
+
},
|
|
21
|
+
"./domains": {
|
|
22
|
+
"types": "./dist/domains/registry.d.ts",
|
|
23
|
+
"import": "./dist/domains/registry.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist/",
|
|
28
|
+
"domains/**/*.yaml"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc -p tsconfig.build.json && node scripts/fix-esm-imports.cjs && node -e \"const fs=require('fs');const path=require('path');function copyYaml(src,dest){const entries=fs.readdirSync(src,{withFileTypes:true});for(const e of entries){const s=path.join(src,e.name);const d=path.join(dest,e.name);if(e.isDirectory()){fs.mkdirSync(d,{recursive:true});copyYaml(s,d)}else if(e.name.endsWith('.yaml')){fs.copyFileSync(s,d)}}};copyYaml('domains','dist/domains')\"",
|
|
32
|
+
"prepublishOnly": "npm run build"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"governance",
|
|
36
|
+
"ai",
|
|
37
|
+
"safety",
|
|
38
|
+
"compliance",
|
|
39
|
+
"middleware",
|
|
40
|
+
"agent",
|
|
41
|
+
"llm",
|
|
42
|
+
"health",
|
|
43
|
+
"finance",
|
|
44
|
+
"insurance"
|
|
45
|
+
],
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"yaml": "^2.0.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"express": ">=4.0.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"express": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|