@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.
Files changed (128) hide show
  1. package/README.md +251 -0
  2. package/dist/domains/finance/entity_rules.d.ts +4 -0
  3. package/dist/domains/finance/entity_rules.d.ts.map +1 -0
  4. package/dist/domains/finance/entity_rules.js +19 -0
  5. package/dist/domains/finance/entity_rules.js.map +1 -0
  6. package/dist/domains/finance/policy.yaml +85 -0
  7. package/dist/domains/health/entity_rules.d.ts +4 -0
  8. package/dist/domains/health/entity_rules.d.ts.map +1 -0
  9. package/dist/domains/health/entity_rules.js +20 -0
  10. package/dist/domains/health/entity_rules.js.map +1 -0
  11. package/dist/domains/health/policy.yaml +95 -0
  12. package/dist/domains/insurance/entity_rules.d.ts +4 -0
  13. package/dist/domains/insurance/entity_rules.d.ts.map +1 -0
  14. package/dist/domains/insurance/entity_rules.js +19 -0
  15. package/dist/domains/insurance/entity_rules.js.map +1 -0
  16. package/dist/domains/insurance/policy.yaml +88 -0
  17. package/dist/domains/registry.d.ts +20 -0
  18. package/dist/domains/registry.d.ts.map +1 -0
  19. package/dist/domains/registry.js +65 -0
  20. package/dist/domains/registry.js.map +1 -0
  21. package/dist/domains/types.d.ts +12 -0
  22. package/dist/domains/types.d.ts.map +1 -0
  23. package/dist/domains/types.js +2 -0
  24. package/dist/domains/types.js.map +1 -0
  25. package/dist/index.d.ts +32 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +15 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/sdk/governance.d.ts +121 -0
  30. package/dist/sdk/governance.d.ts.map +1 -0
  31. package/dist/sdk/governance.js +219 -0
  32. package/dist/sdk/governance.js.map +1 -0
  33. package/dist/src/api/index.d.ts +2 -0
  34. package/dist/src/api/index.d.ts.map +1 -0
  35. package/dist/src/api/index.js +2 -0
  36. package/dist/src/api/index.js.map +1 -0
  37. package/dist/src/certification/test_runner.d.ts +86 -0
  38. package/dist/src/certification/test_runner.d.ts.map +1 -0
  39. package/dist/src/certification/test_runner.js +422 -0
  40. package/dist/src/certification/test_runner.js.map +1 -0
  41. package/dist/src/classification/index.d.ts +2 -0
  42. package/dist/src/classification/index.d.ts.map +1 -0
  43. package/dist/src/classification/index.js +2 -0
  44. package/dist/src/classification/index.js.map +1 -0
  45. package/dist/src/classification/query_classifier.d.ts +13 -0
  46. package/dist/src/classification/query_classifier.d.ts.map +1 -0
  47. package/dist/src/classification/query_classifier.js +142 -0
  48. package/dist/src/classification/query_classifier.js.map +1 -0
  49. package/dist/src/config/index.d.ts +2 -0
  50. package/dist/src/config/index.d.ts.map +1 -0
  51. package/dist/src/config/index.js +2 -0
  52. package/dist/src/config/index.js.map +1 -0
  53. package/dist/src/context/index.d.ts +2 -0
  54. package/dist/src/context/index.d.ts.map +1 -0
  55. package/dist/src/context/index.js +2 -0
  56. package/dist/src/context/index.js.map +1 -0
  57. package/dist/src/gateway/index.d.ts +2 -0
  58. package/dist/src/gateway/index.d.ts.map +1 -0
  59. package/dist/src/gateway/index.js +2 -0
  60. package/dist/src/gateway/index.js.map +1 -0
  61. package/dist/src/gateway/pre_interaction_governance.d.ts +34 -0
  62. package/dist/src/gateway/pre_interaction_governance.d.ts.map +1 -0
  63. package/dist/src/gateway/pre_interaction_governance.js +187 -0
  64. package/dist/src/gateway/pre_interaction_governance.js.map +1 -0
  65. package/dist/src/interfaces/entity.d.ts +16 -0
  66. package/dist/src/interfaces/entity.d.ts.map +1 -0
  67. package/dist/src/interfaces/entity.js +2 -0
  68. package/dist/src/interfaces/entity.js.map +1 -0
  69. package/dist/src/normalization/index.d.ts +2 -0
  70. package/dist/src/normalization/index.d.ts.map +1 -0
  71. package/dist/src/normalization/index.js +2 -0
  72. package/dist/src/normalization/index.js.map +1 -0
  73. package/dist/src/normalization/response_normalizer.d.ts +30 -0
  74. package/dist/src/normalization/response_normalizer.d.ts.map +1 -0
  75. package/dist/src/normalization/response_normalizer.js +224 -0
  76. package/dist/src/normalization/response_normalizer.js.map +1 -0
  77. package/dist/src/orchestrator.d.ts +21 -0
  78. package/dist/src/orchestrator.d.ts.map +1 -0
  79. package/dist/src/orchestrator.js +355 -0
  80. package/dist/src/orchestrator.js.map +1 -0
  81. package/dist/src/policy/index.d.ts +3 -0
  82. package/dist/src/policy/index.d.ts.map +1 -0
  83. package/dist/src/policy/index.js +2 -0
  84. package/dist/src/policy/index.js.map +1 -0
  85. package/dist/src/policy/policy_engine.d.ts +47 -0
  86. package/dist/src/policy/policy_engine.d.ts.map +1 -0
  87. package/dist/src/policy/policy_engine.js +100 -0
  88. package/dist/src/policy/policy_engine.js.map +1 -0
  89. package/dist/src/reasoning/index.d.ts +2 -0
  90. package/dist/src/reasoning/index.d.ts.map +1 -0
  91. package/dist/src/reasoning/index.js +2 -0
  92. package/dist/src/reasoning/index.js.map +1 -0
  93. package/dist/src/reasoning/reasoning_validator.d.ts +28 -0
  94. package/dist/src/reasoning/reasoning_validator.d.ts.map +1 -0
  95. package/dist/src/reasoning/reasoning_validator.js +277 -0
  96. package/dist/src/reasoning/reasoning_validator.js.map +1 -0
  97. package/dist/src/reasoning/trace_validator.d.ts +33 -0
  98. package/dist/src/reasoning/trace_validator.d.ts.map +1 -0
  99. package/dist/src/reasoning/trace_validator.js +251 -0
  100. package/dist/src/reasoning/trace_validator.js.map +1 -0
  101. package/dist/src/state/interaction_state.d.ts +59 -0
  102. package/dist/src/state/interaction_state.d.ts.map +1 -0
  103. package/dist/src/state/interaction_state.js +75 -0
  104. package/dist/src/state/interaction_state.js.map +1 -0
  105. package/dist/src/telemetry/governance_logger.d.ts +36 -0
  106. package/dist/src/telemetry/governance_logger.d.ts.map +1 -0
  107. package/dist/src/telemetry/governance_logger.js +32 -0
  108. package/dist/src/telemetry/governance_logger.js.map +1 -0
  109. package/dist/src/telemetry/index.d.ts +2 -0
  110. package/dist/src/telemetry/index.d.ts.map +1 -0
  111. package/dist/src/telemetry/index.js +2 -0
  112. package/dist/src/telemetry/index.js.map +1 -0
  113. package/dist/src/telemetry/metrics.d.ts +49 -0
  114. package/dist/src/telemetry/metrics.d.ts.map +1 -0
  115. package/dist/src/telemetry/metrics.js +115 -0
  116. package/dist/src/telemetry/metrics.js.map +1 -0
  117. package/dist/src/tools/tool_guard.d.ts +39 -0
  118. package/dist/src/tools/tool_guard.d.ts.map +1 -0
  119. package/dist/src/tools/tool_guard.js +226 -0
  120. package/dist/src/tools/tool_guard.js.map +1 -0
  121. package/dist/src/types/index.d.ts +65 -0
  122. package/dist/src/types/index.d.ts.map +1 -0
  123. package/dist/src/types/index.js +2 -0
  124. package/dist/src/types/index.js.map +1 -0
  125. package/domains/finance/policy.yaml +85 -0
  126. package/domains/health/policy.yaml +95 -0
  127. package/domains/insurance/policy.yaml +88 -0
  128. package/package.json +58 -0
package/README.md ADDED
@@ -0,0 +1,251 @@
1
+ # @governed-ai/runtime
2
+
3
+ Agent-agnostic governance middleware for AI applications. Provides classification, pre/post-interaction governance, tool guarding, trace validation, telemetry, and certification — embeddable in any AI agent across any domain (health, finance, insurance, etc.).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @governed-ai/runtime
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ There are two ways to use the governance runtime:
14
+
15
+ ### Option A: In-Process (Library Mode)
16
+
17
+ Import the orchestrator directly and run governance within your application process. You supply your own LLM callback — governance never imports an LLM provider.
18
+
19
+ ```typescript
20
+ import {
21
+ runGovernance,
22
+ DomainRegistry,
23
+ QueryClassifier,
24
+ PreInteractionGovernance,
25
+ PostInteractionGovernance,
26
+ ResponseNormalizer,
27
+ GovernanceLogger,
28
+ InteractionStateManager,
29
+ ToolGuard,
30
+ TraceValidator,
31
+ type GovernancePipelineConfig,
32
+ type GovernanceLLMCall,
33
+ } from "@governed-ai/runtime";
34
+
35
+ // 1. Set up the domain registry (built-in: health, finance, insurance)
36
+ const domainRegistry = new DomainRegistry("insurance");
37
+ const domainConfig = domainRegistry.getDomain("insurance");
38
+
39
+ // 2. Wire up the pipeline components
40
+ const pipelineConfig: GovernancePipelineConfig = {
41
+ queryClassifier: new QueryClassifier(),
42
+ preInteractionGovernance: new PreInteractionGovernance(
43
+ new QueryClassifier(),
44
+ yourEntityRepository, // your domain's entity lookup
45
+ yourEntityResolver, // your domain's entity resolver
46
+ domainConfig.policyEngine,
47
+ domainConfig.entityRules,
48
+ ),
49
+ postInteractionGovernance: new PostInteractionGovernance(),
50
+ responseNormalizer: new ResponseNormalizer(),
51
+ governanceLogger: new GovernanceLogger(),
52
+ stateManager: new InteractionStateManager(),
53
+ toolGuard: new ToolGuard(),
54
+ traceValidator: new TraceValidator(),
55
+ };
56
+
57
+ // 3. Define your LLM callback
58
+ const myLLMCall: GovernanceLLMCall = async (query, context) => {
59
+ const result = await yourLLMProvider.generate(query, context);
60
+ return {
61
+ response: result.text,
62
+ confidence: result.confidence,
63
+ reasoning: result.reasoning,
64
+ evidence: result.sources,
65
+ missingData: result.gaps,
66
+ confidenceLabel: result.confidenceLabel,
67
+ };
68
+ };
69
+
70
+ // 4. Run governance
71
+ const result = await runGovernance(
72
+ "What is my claim status?",
73
+ { sessionPatientId: "policyholder-123" },
74
+ myLLMCall,
75
+ pipelineConfig,
76
+ "insurance",
77
+ "session-abc",
78
+ );
79
+
80
+ if (result.blocked) {
81
+ console.log("Blocked:", result.blockedReason);
82
+ } else {
83
+ console.log("Response:", result.finalResponse);
84
+ }
85
+ ```
86
+
87
+ ### Option B: HTTP Service (SDK Mode)
88
+
89
+ Deploy the governance runtime as a standalone API service, then use the lightweight SDK from any application.
90
+
91
+ **Server side** (see `api-example/server.ts` for a full reference implementation):
92
+ ```bash
93
+ # Start the governance API server
94
+ npx tsx api-example/server.ts
95
+ ```
96
+
97
+ **Client side:**
98
+ ```typescript
99
+ import { createGovernance } from "@governed-ai/runtime/sdk";
100
+
101
+ const governance = createGovernance({
102
+ baseUrl: "https://your-governance-service.example.com",
103
+ });
104
+
105
+ const result = await governance.run(
106
+ "What is my deductible?",
107
+ { sessionPatientId: "policyholder-456" },
108
+ "insurance",
109
+ "session-xyz",
110
+ );
111
+
112
+ if (result.status === "blocked") {
113
+ console.log("Blocked:", result.blockedReason);
114
+ } else {
115
+ console.log("Response:", result.answer);
116
+ }
117
+ ```
118
+
119
+ ## Built-in Domains
120
+
121
+ The package ships with policy definitions for three domains:
122
+
123
+ | Domain | Policy File | Entity Type |
124
+ |--------|------------|-------------|
125
+ | `health` | `domains/health/policy.yaml` | Patient |
126
+ | `finance` | `domains/finance/policy.yaml` | Client |
127
+ | `insurance` | `domains/insurance/policy.yaml` | Policyholder |
128
+
129
+ Each domain defines blocked query types, privacy rules, and safety rules in its YAML policy file.
130
+
131
+ ## Registering Custom Domains
132
+
133
+ ```typescript
134
+ import {
135
+ DomainRegistry,
136
+ PolicyEngine,
137
+ type DomainEntityRules,
138
+ } from "@governed-ai/runtime";
139
+
140
+ const registry = new DomainRegistry("health");
141
+
142
+ // Register a custom domain with a policy definition object
143
+ registry.registerDomain("legal", {
144
+ policyEngine: new PolicyEngine({
145
+ domain: "legal",
146
+ version: "1.0",
147
+ blocked_query_types: {
148
+ legal_advice: {
149
+ action: "block",
150
+ response: "I cannot provide legal advice.",
151
+ },
152
+ },
153
+ privacy_rules: [
154
+ { id: "client_privilege", description: "Protect attorney-client privilege", severity: "critical" },
155
+ ],
156
+ safety_rules: [
157
+ { id: "no_legal_opinion", description: "Do not issue legal opinions", severity: "critical" },
158
+ ],
159
+ }),
160
+ entityRules: {
161
+ domain: "legal",
162
+ entityLabel: "client",
163
+ entityLabelPlural: "clients",
164
+ // ... other entity rules
165
+ } as DomainEntityRules,
166
+ });
167
+ ```
168
+
169
+ ## Certification
170
+
171
+ Run the built-in UAT certification suite to validate your agent's governance compliance:
172
+
173
+ ```typescript
174
+ import { CertificationTestRunner } from "@governed-ai/runtime";
175
+
176
+ const runner = new CertificationTestRunner();
177
+ const report = await runner.run(myLLMCall, pipelineConfig, {
178
+ domain: "insurance",
179
+ categories: ["safety", "privacy", "tool_governance"],
180
+ });
181
+
182
+ console.log(`Pass rate: ${report.passRate * 100}%`);
183
+ console.log(`Verdict: ${report.verdict}`);
184
+ // "certified" | "conditional" | "failed"
185
+ ```
186
+
187
+ Or via the SDK:
188
+ ```typescript
189
+ const report = await governance.certifyAgent({
190
+ domain: "insurance",
191
+ categories: ["safety", "privacy"],
192
+ });
193
+ ```
194
+
195
+ ## Telemetry
196
+
197
+ Track governance metrics across all queries:
198
+
199
+ ```typescript
200
+ import { GovernanceMetricsAggregator, GovernanceLogger } from "@governed-ai/runtime";
201
+
202
+ const metrics = new GovernanceMetricsAggregator();
203
+ const logger = new GovernanceLogger(metrics);
204
+
205
+ // Use this logger in your pipeline config
206
+ // Later, retrieve metrics:
207
+ const stats = metrics.getMetrics();
208
+ console.log(`Total queries: ${stats.totalQueries}`);
209
+ console.log(`Blocked: ${stats.blockedQueries}`);
210
+ ```
211
+
212
+ ## Pipeline Stages
213
+
214
+ Every query passes through these stages in order:
215
+
216
+ 1. **Session Init** — Create/resume session state
217
+ 2. **Classify** — Identify query type and intent
218
+ 3. **Pre-Interaction** — Check against domain policy (blocked types, entity validation)
219
+ 4. **Tool Guard** — Validate any tool calls (PII access, destructive ops, bulk limits)
220
+ 5. **LLM Call** — Your LLM generates a response
221
+ 6. **Trace Validation** — Check reasoning for hallucinations, overconfidence, circular logic
222
+ 7. **Post-Interaction** — Validate response safety and accuracy
223
+ 8. **Normalize** — Add caveats, structure evidence, format response
224
+ 9. **Log & Persist** — Record decision and update session state
225
+
226
+ Any stage can block the query, returning a safe fallback response with the `blockedStage` and `blockedReason` fields set.
227
+
228
+ ## API Reference
229
+
230
+ ### Exports
231
+
232
+ | Export | Description |
233
+ |--------|-------------|
234
+ | `runGovernance` | Core orchestrator function |
235
+ | `createGovernance` / `governance` | SDK client (HTTP mode) |
236
+ | `DomainRegistry` | Domain policy registry |
237
+ | `PolicyEngine` | YAML policy loader/evaluator |
238
+ | `QueryClassifier` | Query intent classifier |
239
+ | `PreInteractionGovernance` | Pre-interaction policy checks |
240
+ | `PostInteractionGovernance` | Post-interaction safety checks |
241
+ | `ResponseNormalizer` | Response formatting and caveats |
242
+ | `GovernanceLogger` | Governance decision logger |
243
+ | `GovernanceMetricsAggregator` | Telemetry metrics collector |
244
+ | `InteractionStateManager` | Session state tracker |
245
+ | `ToolGuard` | Tool call validator |
246
+ | `TraceValidator` | Reasoning trace validator |
247
+ | `CertificationTestRunner` | UAT certification runner |
248
+
249
+ ## License
250
+
251
+ MIT
@@ -0,0 +1,4 @@
1
+ import type { DomainEntityRules } from "../types";
2
+ export declare const financeEntityRules: DomainEntityRules;
3
+ export default financeEntityRules;
4
+ //# sourceMappingURL=entity_rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity_rules.d.ts","sourceRoot":"","sources":["../../../domains/finance/entity_rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,eAAO,MAAM,kBAAkB,EAAE,iBAwBhC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,19 @@
1
+ export const financeEntityRules = {
2
+ domain: "finance",
3
+ entityLabel: "account holder",
4
+ entityLabelPlural: "account holders",
5
+ numericIdPattern: /account\s+(?:id\s+)?#?(\d{3,})/i,
6
+ numericIdFallbackPattern: /(?:acct|account)\s+#?(\d{3,})/i,
7
+ notFoundResponse: (id) => `No account found with ID ${id}. The account identifier is invalid or not found in the system. Please verify the account number and try again.`,
8
+ ambiguousResponse: (suggestion) => `The reference provided is ambiguous. Did you mean ${suggestion}? Please clarify the account holder's full name so I can retrieve the correct records.`,
9
+ entityNotFoundResponse: "No account holder found with that name or identifier in the system. Unable to retrieve any financial information. Please verify the account holder name and try again.",
10
+ stopWords: [
11
+ "Show", "Compare", "Analyze", "Check", "Get", "Find", "List", "Display",
12
+ "What", "Does", "Tell", "Give", "Assess", "Explain", "Did", "Will",
13
+ "According", "Based", "The", "His", "Her", "From", "With", "About", "For",
14
+ "Report", "Balance", "Statement", "Transaction", "Portfolio", "Account",
15
+ "Investment", "Fund", "Stock", "Bond", "Revenue", "Expense", "Profit",
16
+ ],
17
+ };
18
+ export default financeEntityRules;
19
+ //# sourceMappingURL=entity_rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity_rules.js","sourceRoot":"","sources":["../../../domains/finance/entity_rules.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAsB;IACnD,MAAM,EAAE,SAAS;IACjB,WAAW,EAAE,gBAAgB;IAC7B,iBAAiB,EAAE,iBAAiB;IAEpC,gBAAgB,EAAE,iCAAiC;IACnD,wBAAwB,EAAE,gCAAgC;IAE1D,gBAAgB,EAAE,CAAC,EAAU,EAAE,EAAE,CAC/B,4BAA4B,EAAE,iHAAiH;IAEjJ,iBAAiB,EAAE,CAAC,UAAkB,EAAE,EAAE,CACxC,qDAAqD,UAAU,wFAAwF;IAEzJ,sBAAsB,EACpB,wKAAwK;IAE1K,SAAS,EAAE;QACT,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS;QACvE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM;QAClE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK;QACzE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS;QACvE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ;KACtE;CACF,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -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,4 @@
1
+ import type { DomainEntityRules } from "../types";
2
+ export declare const healthEntityRules: DomainEntityRules;
3
+ export default healthEntityRules;
4
+ //# sourceMappingURL=entity_rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity_rules.d.ts","sourceRoot":"","sources":["../../../domains/health/entity_rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,eAAO,MAAM,iBAAiB,EAAE,iBAyB/B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,20 @@
1
+ export const healthEntityRules = {
2
+ domain: "health",
3
+ entityLabel: "patient",
4
+ entityLabelPlural: "patients",
5
+ numericIdPattern: /patient\s+(?:id\s+)?#?(\d{3,})/i,
6
+ numericIdFallbackPattern: /(?:id|ID)\s+#?(\d{3,})/,
7
+ notFoundResponse: (id) => `No patient found with ID ${id}. The patient identifier is invalid or not found in the system. Please verify the patient ID and try again.`,
8
+ ambiguousResponse: (suggestion) => `The name provided is ambiguous. Did you mean ${suggestion}? Which patient are you referring to? Please clarify by providing the full patient name so I can retrieve the correct records.`,
9
+ entityNotFoundResponse: "No patient found with that name or identifier in the system. The patient was not found and no record or data exists for this name. Unable to retrieve any information. Please verify the patient name and try again.",
10
+ stopWords: [
11
+ "Show", "Compare", "Analyze", "Check", "Get", "Find", "List", "Display",
12
+ "What", "Does", "Tell", "Give", "Assess", "Explain", "Did", "Will",
13
+ "According", "Based", "The", "His", "Her", "From", "With", "About", "For",
14
+ "Report", "Level", "Levels", "Data", "Trend", "History", "Values",
15
+ "Result", "Results", "Cholesterol", "Creatinine", "Hemoglobin", "Glucose",
16
+ "Vitamin", "Medication", "Symptoms", "Diagnosis", "Patient",
17
+ ],
18
+ };
19
+ export default healthEntityRules;
20
+ //# sourceMappingURL=entity_rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity_rules.js","sourceRoot":"","sources":["../../../domains/health/entity_rules.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IAClD,MAAM,EAAE,QAAQ;IAChB,WAAW,EAAE,SAAS;IACtB,iBAAiB,EAAE,UAAU;IAE7B,gBAAgB,EAAE,iCAAiC;IACnD,wBAAwB,EAAE,wBAAwB;IAElD,gBAAgB,EAAE,CAAC,EAAU,EAAE,EAAE,CAC/B,4BAA4B,EAAE,6GAA6G;IAE7I,iBAAiB,EAAE,CAAC,UAAkB,EAAE,EAAE,CACxC,gDAAgD,UAAU,gIAAgI;IAE5L,sBAAsB,EACpB,sNAAsN;IAExN,SAAS,EAAE;QACT,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS;QACvE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM;QAClE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK;QACzE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ;QACjE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS;QACzE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS;KAC5D;CACF,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -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,4 @@
1
+ import type { DomainEntityRules } from "../types";
2
+ export declare const insuranceEntityRules: DomainEntityRules;
3
+ export default insuranceEntityRules;
4
+ //# sourceMappingURL=entity_rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity_rules.d.ts","sourceRoot":"","sources":["../../../domains/insurance/entity_rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,eAAO,MAAM,oBAAoB,EAAE,iBAwBlC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,19 @@
1
+ export const insuranceEntityRules = {
2
+ domain: "insurance",
3
+ entityLabel: "policyholder",
4
+ entityLabelPlural: "policyholders",
5
+ numericIdPattern: /policy\s+(?:id\s+)?#?(\d{3,})/i,
6
+ numericIdFallbackPattern: /(?:policy|claim)\s+#?(\d{3,})/i,
7
+ notFoundResponse: (id) => `No policyholder found with ID ${id}. The policy identifier is invalid or not found in the system. Please verify the policy number and try again.`,
8
+ ambiguousResponse: (suggestion) => `The reference provided is ambiguous. Did you mean ${suggestion}? Please clarify the policyholder's full name so I can retrieve the correct records.`,
9
+ entityNotFoundResponse: "No policyholder found with that name or identifier in the system. Unable to retrieve any policy or claims information. Please verify the policyholder name and try again.",
10
+ stopWords: [
11
+ "Show", "Compare", "Analyze", "Check", "Get", "Find", "List", "Display",
12
+ "What", "Does", "Tell", "Give", "Assess", "Explain", "Did", "Will",
13
+ "According", "Based", "The", "His", "Her", "From", "With", "About", "For",
14
+ "Report", "Claim", "Claims", "Policy", "Coverage", "Premium", "Deductible",
15
+ "Benefit", "Copay", "Provider", "Network", "Underwriting",
16
+ ],
17
+ };
18
+ export default insuranceEntityRules;
19
+ //# sourceMappingURL=entity_rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity_rules.js","sourceRoot":"","sources":["../../../domains/insurance/entity_rules.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACrD,MAAM,EAAE,WAAW;IACnB,WAAW,EAAE,cAAc;IAC3B,iBAAiB,EAAE,eAAe;IAElC,gBAAgB,EAAE,gCAAgC;IAClD,wBAAwB,EAAE,gCAAgC;IAE1D,gBAAgB,EAAE,CAAC,EAAU,EAAE,EAAE,CAC/B,iCAAiC,EAAE,+GAA+G;IAEpJ,iBAAiB,EAAE,CAAC,UAAkB,EAAE,EAAE,CACxC,qDAAqD,UAAU,sFAAsF;IAEvJ,sBAAsB,EACpB,2KAA2K;IAE7K,SAAS,EAAE;QACT,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS;QACvE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM;QAClE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK;QACzE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY;QAC1E,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc;KAC1D;CACF,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -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
@@ -0,0 +1,20 @@
1
+ import { type IPolicyEngine } from "../src/policy/policy_engine";
2
+ import type { DomainEntityRules } from "./types";
3
+ export interface DomainConfig {
4
+ policyEngine: IPolicyEngine;
5
+ entityRules: DomainEntityRules;
6
+ }
7
+ export declare class DomainRegistry {
8
+ private domains;
9
+ private defaultDomain;
10
+ constructor(defaultDomain?: string);
11
+ private loadBuiltinDomains;
12
+ registerDomain(name: string, config: DomainConfig): void;
13
+ getDomain(name?: string): DomainConfig;
14
+ hasDomain(name: string): boolean;
15
+ listDomains(): string[];
16
+ getDefaultDomain(): string;
17
+ getPolicyEngine(domain?: string): IPolicyEngine;
18
+ getEntityRules(domain?: string): DomainEntityRules;
19
+ }
20
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../domains/registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAKjD,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,aAAa,CAAC;IAC5B,WAAW,EAAE,iBAAiB,CAAC;CAChC;AAUD,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,aAAa,CAAS;gBAElB,aAAa,GAAE,MAAiB;IAK5C,OAAO,CAAC,kBAAkB;IAkB1B,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI;IAIxD,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY;IAWtC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIhC,WAAW,IAAI,MAAM,EAAE;IAIvB,gBAAgB,IAAI,MAAM;IAI1B,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,aAAa;IAI/C,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,iBAAiB;CAGnD"}