monora-ai 2.1.0 → 2.1.4

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 (193) hide show
  1. package/README.md +339 -158
  2. package/dist/aims_governance.d.ts +238 -0
  3. package/dist/aims_governance.d.ts.map +1 -0
  4. package/dist/aims_governance.js +922 -0
  5. package/dist/alerts.d.ts +16 -0
  6. package/dist/alerts.d.ts.map +1 -1
  7. package/dist/alerts.js +16 -0
  8. package/dist/api.d.ts +6 -0
  9. package/dist/api.d.ts.map +1 -1
  10. package/dist/api.js +6 -0
  11. package/dist/assessment.d.ts +85 -0
  12. package/dist/assessment.d.ts.map +1 -1
  13. package/dist/assessment.js +525 -13
  14. package/dist/attribution.d.ts +44 -3
  15. package/dist/attribution.d.ts.map +1 -1
  16. package/dist/attribution.js +197 -10
  17. package/dist/autodetect.d.ts +68 -0
  18. package/dist/autodetect.d.ts.map +1 -1
  19. package/dist/autodetect.js +639 -0
  20. package/dist/bias.d.ts +130 -0
  21. package/dist/bias.d.ts.map +1 -0
  22. package/dist/bias.js +223 -0
  23. package/dist/cli/diagnostics.d.ts +5 -1
  24. package/dist/cli/diagnostics.d.ts.map +1 -1
  25. package/dist/cli/diagnostics.js +23 -6
  26. package/dist/cli/doctor.d.ts +25 -0
  27. package/dist/cli/doctor.d.ts.map +1 -0
  28. package/dist/cli/doctor.js +381 -0
  29. package/dist/cli/fix.d.ts +16 -0
  30. package/dist/cli/fix.d.ts.map +1 -0
  31. package/dist/cli/fix.js +284 -0
  32. package/dist/cli/init.d.ts +57 -0
  33. package/dist/cli/init.d.ts.map +1 -0
  34. package/dist/cli/init.js +205 -0
  35. package/dist/cli.js +1564 -177
  36. package/dist/complianceConsolidation.d.ts +17 -0
  37. package/dist/complianceConsolidation.d.ts.map +1 -0
  38. package/dist/complianceConsolidation.js +68 -0
  39. package/dist/complianceTargets.d.ts +111 -0
  40. package/dist/complianceTargets.d.ts.map +1 -0
  41. package/dist/complianceTargets.js +521 -0
  42. package/dist/config.d.ts +261 -16
  43. package/dist/config.d.ts.map +1 -1
  44. package/dist/config.js +381 -32
  45. package/dist/config_migrations.d.ts.map +1 -1
  46. package/dist/config_migrations.js +38 -1
  47. package/dist/config_schema.d.ts +2490 -1035
  48. package/dist/config_schema.d.ts.map +1 -1
  49. package/dist/config_schema.js +233 -64
  50. package/dist/context.d.ts +34 -0
  51. package/dist/context.d.ts.map +1 -1
  52. package/dist/context.js +118 -7
  53. package/dist/control_backbone.d.ts +128 -0
  54. package/dist/control_backbone.d.ts.map +1 -0
  55. package/dist/control_backbone.js +826 -0
  56. package/dist/data-governance.d.ts +187 -0
  57. package/dist/data-governance.d.ts.map +1 -0
  58. package/dist/data-governance.js +424 -0
  59. package/dist/dataResidency.d.ts +44 -0
  60. package/dist/dataResidency.d.ts.map +1 -0
  61. package/dist/dataResidency.js +203 -0
  62. package/dist/dispatcher.d.ts.map +1 -1
  63. package/dist/dispatcher.js +17 -5
  64. package/dist/evidence_store.d.ts +103 -0
  65. package/dist/evidence_store.d.ts.map +1 -0
  66. package/dist/evidence_store.js +459 -0
  67. package/dist/executiveSummary.d.ts +15 -0
  68. package/dist/executiveSummary.d.ts.map +1 -1
  69. package/dist/executiveSummary.js +135 -22
  70. package/dist/identity.d.ts +143 -0
  71. package/dist/identity.d.ts.map +1 -0
  72. package/dist/identity.js +231 -0
  73. package/dist/impact-assessment.d.ts +350 -0
  74. package/dist/impact-assessment.d.ts.map +1 -0
  75. package/dist/impact-assessment.js +580 -0
  76. package/dist/index.d.ts +21 -4
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +254 -5
  79. package/dist/instrumentation.d.ts +1 -1
  80. package/dist/instrumentation.d.ts.map +1 -1
  81. package/dist/instrumentation.js +123 -22
  82. package/dist/integrations/anthropic.d.ts +3 -0
  83. package/dist/integrations/anthropic.d.ts.map +1 -1
  84. package/dist/integrations/anthropic.js +282 -80
  85. package/dist/integrations/governance.d.ts +33 -0
  86. package/dist/integrations/governance.d.ts.map +1 -0
  87. package/dist/integrations/governance.js +208 -0
  88. package/dist/integrations/langchain.d.ts +4 -0
  89. package/dist/integrations/langchain.d.ts.map +1 -1
  90. package/dist/integrations/langchain.js +362 -142
  91. package/dist/integrations/openai.d.ts +9 -0
  92. package/dist/integrations/openai.d.ts.map +1 -1
  93. package/dist/integrations/openai.js +673 -73
  94. package/dist/iso42001_consolidation.d.ts +16 -0
  95. package/dist/iso42001_consolidation.d.ts.map +1 -0
  96. package/dist/iso42001_consolidation.js +413 -0
  97. package/dist/iso42001_workflows.d.ts +263 -0
  98. package/dist/iso42001_workflows.d.ts.map +1 -0
  99. package/dist/iso42001_workflows.js +781 -0
  100. package/dist/lifecycle.d.ts +299 -0
  101. package/dist/lifecycle.d.ts.map +1 -0
  102. package/dist/lifecycle.js +624 -0
  103. package/dist/lineage.d.ts +2 -2
  104. package/dist/lineage.d.ts.map +1 -1
  105. package/dist/lineage.js +9 -16
  106. package/dist/middleware/express.d.ts.map +1 -1
  107. package/dist/middleware/express.js +18 -3
  108. package/dist/middleware/nextjs.js +2 -2
  109. package/dist/model.d.ts +143 -0
  110. package/dist/model.d.ts.map +1 -0
  111. package/dist/model.js +371 -0
  112. package/dist/onboarding.d.ts +42 -0
  113. package/dist/onboarding.d.ts.map +1 -0
  114. package/dist/onboarding.js +1075 -0
  115. package/dist/oversight.d.ts +264 -0
  116. package/dist/oversight.d.ts.map +1 -0
  117. package/dist/oversight.js +497 -0
  118. package/dist/presets.js +7 -7
  119. package/dist/quotas.d.ts +171 -0
  120. package/dist/quotas.d.ts.map +1 -0
  121. package/dist/quotas.js +259 -0
  122. package/dist/register.d.ts +13 -0
  123. package/dist/register.d.ts.map +1 -0
  124. package/dist/register.js +99 -0
  125. package/dist/registry.d.ts +1 -0
  126. package/dist/registry.d.ts.map +1 -1
  127. package/dist/registry.js +7 -0
  128. package/dist/registryData.json +43 -6
  129. package/dist/report.d.ts +2 -1
  130. package/dist/report.d.ts.map +1 -1
  131. package/dist/report.js +189 -2
  132. package/dist/reporting.d.ts +125 -0
  133. package/dist/reporting.d.ts.map +1 -1
  134. package/dist/reporting.js +192 -2
  135. package/dist/resources.d.ts +285 -0
  136. package/dist/resources.d.ts.map +1 -0
  137. package/dist/resources.js +643 -0
  138. package/dist/risk.d.ts +120 -0
  139. package/dist/risk.d.ts.map +1 -0
  140. package/dist/risk.js +220 -0
  141. package/dist/runtime.d.ts +74 -0
  142. package/dist/runtime.d.ts.map +1 -1
  143. package/dist/runtime.js +416 -18
  144. package/dist/schemaInference.d.ts +92 -0
  145. package/dist/schemaInference.d.ts.map +1 -0
  146. package/dist/schemaInference.js +466 -0
  147. package/dist/schema_validation.js +2 -2
  148. package/dist/schemas/config.schema.json +118 -4
  149. package/dist/security_report.js +4 -4
  150. package/dist/signing.d.ts +1 -1
  151. package/dist/signing.d.ts.map +1 -1
  152. package/dist/signing.js +4 -0
  153. package/dist/sinks/file.d.ts +19 -1
  154. package/dist/sinks/file.d.ts.map +1 -1
  155. package/dist/sinks/file.js +82 -13
  156. package/dist/sinks/https.d.ts +10 -0
  157. package/dist/sinks/https.d.ts.map +1 -1
  158. package/dist/sinks/https.js +76 -16
  159. package/dist/sinks/stdout.d.ts +1 -0
  160. package/dist/sinks/stdout.d.ts.map +1 -1
  161. package/dist/sinks/stdout.js +12 -1
  162. package/dist/spec.d.ts +159 -0
  163. package/dist/spec.d.ts.map +1 -0
  164. package/dist/spec.js +391 -0
  165. package/dist/stakeholders.d.ts +199 -0
  166. package/dist/stakeholders.d.ts.map +1 -0
  167. package/dist/stakeholders.js +398 -0
  168. package/dist/standards.d.ts.map +1 -1
  169. package/dist/standards.js +160 -2
  170. package/dist/standards_ingest.d.ts.map +1 -1
  171. package/dist/standards_ingest.js +1 -4
  172. package/dist/telemetry.d.ts +16 -2
  173. package/dist/telemetry.d.ts.map +1 -1
  174. package/dist/telemetry.js +77 -14
  175. package/dist/templates/controls/gdpr_control_catalog.json +261 -0
  176. package/dist/templates/controls/iso42001_control_catalog.json +1443 -0
  177. package/dist/templates/controls/soc2_control_catalog.json +163 -0
  178. package/dist/templates/standards/iso42001_claims.json +72 -0
  179. package/dist/traced_emitter.d.ts.map +1 -1
  180. package/dist/traced_emitter.js +19 -9
  181. package/dist/trust_package.d.ts +20 -1
  182. package/dist/trust_package.d.ts.map +1 -1
  183. package/dist/trust_package.js +90 -2
  184. package/dist/verify.d.ts.map +1 -1
  185. package/dist/verify.js +9 -2
  186. package/dist/wal.d.ts.map +1 -1
  187. package/dist/wal.js +2 -1
  188. package/package.json +14 -1
  189. package/scripts/postinstall.js +105 -210
  190. package/templates/controls/gdpr_control_catalog.json +261 -0
  191. package/templates/controls/iso42001_control_catalog.json +1443 -0
  192. package/templates/controls/soc2_control_catalog.json +163 -0
  193. package/templates/standards/iso42001_claims.json +72 -0
package/README.md CHANGED
@@ -1,42 +1,118 @@
1
- # Monora SDK for Node.js v1.9.3
1
+ # Monora SDK for Node.js v2.1.4
2
2
 
3
3
  Lightweight governance and trace SDK for AI systems.
4
4
 
5
5
  ![Monora SDK screenshot](assets/sdk-screenshot.png)
6
6
 
7
- ## Features
7
+ ---
8
8
 
9
- - **Immutable Event Logs**: SHA-256 hash chains for tamper-evident audit trails
10
- - **Policy Enforcement**: Model allowlist/denylist with classification-based rules
11
- - **Model Registry**: Centralized model and provider metadata
12
- - **Tracing**: Distributed tracing for AI system observability
13
- - **Event Processing**: Background event dispatcher with batching and buffering
14
- - **Multiple Sinks**: Output to stdout, file (JSON-lines), or HTTPS endpoints
15
- - **Durable HTTPS Delivery**: Retry queue + idempotency headers for HTTP sinks
16
- - **Event Enrichment**: Automatic metadata (timestamp, host, process, environment)
17
- - **Attribution + Usage Telemetry**: Optional project registration and anonymous usage stats (opt-in)
18
- - **Compliance Assessment Hooks**: Built-in checks and usage profiles for audits
9
+ ## Streamlined Setup (Recommended)
19
10
 
20
- ### New in v1.9.0
11
+ Use this local-first onboarding flow to get production-ready governance/reporting quickly:
12
+
13
+ ```bash
14
+ # 1. Install and generate a base config
15
+ npm install monora-ai
16
+ npx monora-ai init --preset production
21
17
 
22
- - **🔄 Circuit Breaker**: Fault tolerance for HTTPS sinks with automatic recovery
23
- - **📊 Telemetry/Analytics**: Prometheus and StatsD metrics export for observability
24
- - **📄 PDF Reports**: Generate compliance and EU AI Act PDF reports
25
- - **🌐 Next.js Middleware**: W3C Trace Context propagation for Next.js applications
18
+ # 2. Initialize onboarding contract + model spec + enrichment bundles
19
+ npx monora-ai onboard init --config monora.yml
26
20
 
27
- ## Installation
21
+ # 3. Validate logs + schema mapping + role mapping
22
+ npx monora-ai onboard validate --config monora.yml --pretty
23
+
24
+ # 4. Complete onboarding and auto-generate baseline reports
25
+ npx monora-ai onboard complete --config monora.yml --completed-by "platform-team" --pretty
26
+
27
+ # 5. Check onboarding status and generated artifacts
28
+ npx monora-ai onboard status --config monora.yml --pretty
29
+ ```
30
+
31
+ On completion, Monora writes baseline reports and summaries under `onboarding.artifacts.baseline_reports_dir` (default `./monora_reports/onboarding`):
32
+
33
+ - `soc2_baseline_report.json`
34
+ - `gdpr_baseline_report.json`
35
+ - `iso27001_baseline_report.json`
36
+ - `iso42001_baseline_report.json`
37
+ - `onboarding_validation.json`
38
+ - `onboarding_summary.json`
39
+
40
+ Each baseline report includes:
41
+
42
+ - `claims[].severity`
43
+ - `claims[].remediation`
44
+ - `findings_summary` (totals, status breakdown, remediation recommendations)
45
+
46
+ ---
47
+
48
+ ## CLI Reference
28
49
 
29
50
  ```bash
30
- npm install monora-ai
51
+ # Configuration
52
+ npx monora-ai init # Interactive setup wizard
53
+ npx monora-ai init --yes # Quick setup with defaults
54
+ npx monora-ai init --preset minimal # Minimal preset
55
+ npx monora-ai init --preset dev # Dev preset (file + pretty stdout)
56
+ npx monora-ai init --preset production # Production preset
57
+ npx monora-ai validate # Validate config file
58
+ npx monora-ai validate --mode lenient # Lenient validation
59
+ npx monora-ai doctor # Diagnose configuration issues
60
+ npx monora-ai config fix # Auto-fix common config issues
61
+
62
+ # Onboarding lifecycle
63
+ npx monora-ai onboard init --config monora.yml
64
+ npx monora-ai onboard validate --config monora.yml --input ./monora_events.jsonl --pretty
65
+ npx monora-ai onboard complete --config monora.yml --completed-by "platform-team" --pretty
66
+ npx monora-ai onboard status --config monora.yml --pretty
67
+
68
+ # Schema/model bootstrapping
69
+ npx monora-ai schema infer \
70
+ --input ./monora_events.jsonl \
71
+ --output ./monora_spec.json \
72
+ --compliance-target gdpr \
73
+ --compliance-target soc2 \
74
+ --compliance-target iso42001 \
75
+ --report ./monora_inference_report.json \
76
+ --contract ./onboarding/schema_contract.json
77
+
78
+ npx monora-ai model create \
79
+ --input ./monora_events.jsonl \
80
+ --output ./monora_model.json \
81
+ --model-name support-bot \
82
+ --risk-category high \
83
+ --compliance-target gdpr \
84
+ --compliance-target soc2 \
85
+ --compliance-target iso42001 \
86
+ --config-out ./monora_model_config.json \
87
+ --config-format json \
88
+ --contract-out ./onboarding/schema_contract.json
89
+
90
+ # Reports
91
+ npx monora-ai report --input events.jsonl --output report.json
92
+ npx monora-ai report --input events.jsonl --output report.md --format markdown
93
+
94
+ # Security & Verification
95
+ npx monora-ai security-review --input events.jsonl --output security.json
96
+ npx monora-ai verify --input events.jsonl --config monora.yml --pretty
97
+
98
+ # Trust Packages
99
+ npx monora-ai trust-package --input events.jsonl --trace-id trc_123 --output trust.json --control-standard SOC2
100
+
101
+ # HTTP Queue Management
102
+ npx monora-ai retry-queue --config monora.yml
103
+ npx monora-ai retry-queue --path ./monora_http_queue --clear
31
104
  ```
32
105
 
106
+ ---
107
+
33
108
  ## Quick Start
34
109
 
110
+ After setup, initialize Monora in your app:
111
+
35
112
  ```typescript
36
113
  import { init, llmCall, trace } from 'monora-ai';
37
114
 
38
- // Initialize SDK
39
- init({ configPath: './monora.yml' });
115
+ await init({ configPath: './monora.yml' });
40
116
 
41
117
  const ask = llmCall({ purpose: 'support' })(function ask(
42
118
  question: string,
@@ -52,6 +128,179 @@ trace('my-ai-task', (span) => {
52
128
  });
53
129
  ```
54
130
 
131
+ Production gate behavior:
132
+
133
+ - If `defaults.environment=production`
134
+ - And `onboarding.enabled=true`
135
+ - And `onboarding.required_in_production=true`
136
+ - And `onboarding.status!=completed`
137
+
138
+ `init()` fails fast with an onboarding-required error.
139
+
140
+ ---
141
+
142
+ ## Presets
143
+
144
+ Use presets to generate opinionated configs:
145
+
146
+ - minimal: file sink only, relaxed validation, minimal setup
147
+ - dev: file + pretty stdout, relaxed validation for local development
148
+ - production: file sink with daily rotation + symlink, strict validation
149
+
150
+ Example:
151
+
152
+ ```bash
153
+ npx monora-ai init --preset dev
154
+ ```
155
+
156
+ ---
157
+
158
+ ## Configuration
159
+
160
+ `monora.yml` is the default config path (`monora.json` is also supported). For onboarding-driven production setup:
161
+
162
+ ```yaml
163
+ defaults:
164
+ data_classification: internal
165
+ environment: production
166
+
167
+ onboarding:
168
+ enabled: true
169
+ required_in_production: true
170
+ status: draft # draft | validated | completed
171
+ standards: [SOC2, GDPR, ISO27001, ISO42001]
172
+ artifacts:
173
+ production_logs_path: ./monora_events.jsonl
174
+ schema_contract_path: ./onboarding/schema_contract.json
175
+ dataset_sample_path: ./onboarding/dataset_sample.jsonl # optional
176
+ baseline_reports_dir: ./monora_reports/onboarding
177
+ validation:
178
+ min_log_records: 100
179
+ required_field_presence_threshold: 0.95
180
+ type_conformance_threshold: 0.90
181
+
182
+ model_spec:
183
+ name: monora_default
184
+ version: v1
185
+ event_ts_field: timestamp
186
+ schema_ref: ./onboarding/schema_contract.json
187
+ roles:
188
+ inputs: [body.prompt]
189
+ outputs: [body.response]
190
+ metadata: [event_type, service_name, timestamp]
191
+ identifiers: [event_id, trace_id, span_id]
192
+
193
+ enrichments:
194
+ profile: recommended
195
+ bundles: [core_observability, soc2_access, gdpr_privacy, iso27001_security]
196
+ toggles:
197
+ identity_tracking: true
198
+ risk_tracking: true
199
+ bias_tracking: false
200
+ oversight_tracking: true
201
+ data_governance_tracking: true
202
+ lifecycle_tracking: true
203
+ ```
204
+
205
+ Notes:
206
+
207
+ - `onboard validate` returns `coverage.profiling` and `coverage.inference` (field profiles, role suggestions, timestamp suggestion, schema mapping gaps).
208
+ - `onboard complete` generates one report per selected standard and records outputs in `artifacts.baseline_reports`.
209
+ - Enrichment bundles map to existing Monora observability, access, privacy, and security controls.
210
+
211
+ ### Programmatic Onboarding API
212
+
213
+ ```typescript
214
+ import {
215
+ buildModelSpec,
216
+ validateOnboarding,
217
+ completeOnboarding,
218
+ } from 'monora-ai';
219
+
220
+ const modelSpec = buildModelSpec({
221
+ schemaRef: './onboarding/schema_contract.json',
222
+ roles: {
223
+ inputs: ['body.prompt'],
224
+ outputs: ['body.response'],
225
+ metadata: ['event_type', 'service_name', 'timestamp'],
226
+ identifiers: ['event_id', 'trace_id', 'span_id'],
227
+ },
228
+ });
229
+
230
+ const validation = validateOnboarding({ configPath: './monora.yml' });
231
+ if (validation.status === 'validated') {
232
+ const completion = completeOnboarding({
233
+ configPath: './monora.yml',
234
+ completedBy: 'platform-team',
235
+ });
236
+ console.log(completion.status);
237
+ }
238
+ ```
239
+
240
+ Allowlist/denylist patterns use glob syntax (minimatch), for example `gpt-*` matches `gpt-4o-mini`.
241
+
242
+ ### HTTP Retry Queue + Idempotency
243
+
244
+ ```yaml
245
+ sinks:
246
+ - type: https
247
+ endpoint: https://api.example.com/events # replace with your endpoint
248
+ retry_queue:
249
+ enabled: true
250
+ path: ./monora_http_queue
251
+ max_items: 10000
252
+ flush_interval_sec: 5.0
253
+ idempotency:
254
+ enabled: true
255
+ header_name: Idempotency-Key
256
+ ```
257
+
258
+ Idempotency keys are computed per batch as a SHA-256 digest of the canonical event JSON in order.
259
+
260
+ ```bash
261
+ npx monora-ai retry-queue --config monora.yml
262
+ npx monora-ai retry-queue --path ./monora_http_queue --clear
263
+ ```
264
+
265
+ ---
266
+
267
+ ### File Sink Rotation
268
+
269
+ ```yaml
270
+ sinks:
271
+ - type: file
272
+ path: ./monora_events.jsonl
273
+ rotation: daily # none | daily | size
274
+ symlink: true # keeps monora_events.jsonl and monora_events.latest.jsonl pointing to the newest file
275
+ ```
276
+
277
+ When rotation is enabled, use `./monora_events.latest.jsonl` in scripts to always read the current file.
278
+
279
+ ---
280
+
281
+ ## Features
282
+
283
+ - **Immutable Event Logs**: SHA-256 hash chains for tamper-evident audit trails
284
+ - **Policy Enforcement**: Model allowlist/denylist with classification-based rules
285
+ - **Model Registry**: Centralized model and provider metadata
286
+ - **Tracing**: Distributed tracing for AI system observability
287
+ - **Event Processing**: Background event dispatcher with batching and buffering
288
+ - **Multiple Sinks**: Output to stdout, file (JSON-lines), or HTTPS endpoints
289
+ - **Durable HTTPS Delivery**: Retry queue + idempotency headers for HTTP sinks
290
+ - **Event Enrichment**: Automatic metadata (timestamp, host, process, environment)
291
+ - **Attribution + Usage Telemetry**: Optional project registration and anonymous usage stats (opt-in)
292
+ - **Compliance Assessment Hooks**: Built-in checks and usage profiles for audits
293
+
294
+ ### New in v2.1.4
295
+
296
+ - **SOC2/GDPR Workflow Parity**: First-class SOC2/GDPR control catalogs and standard-aware workflow gap prioritization
297
+ - **ISO42001 Onboarding Defaults**: Onboarding standards defaults now include `SOC2`, `GDPR`, `ISO27001`, and `ISO42001`
298
+ - **Trust Package Selector**: `trust-package --control-standard ISO42001|SOC2|GDPR` selects bundled catalogs without custom paths
299
+
300
+ ---
301
+
302
+ ## Usage Examples
303
+
55
304
  ### Decorator Helpers (TypeScript)
56
305
 
57
306
  ```typescript
@@ -87,32 +336,32 @@ Enable decorators in your `tsconfig.json`:
87
336
  }
88
337
  ```
89
338
 
90
- ### Guided Setup (Wizard)
91
-
92
- ```bash
93
- npx monora-ai init
94
- # or
95
- ./node_modules/.bin/monora init
96
- ```
339
+ ### High-level Runtime Helpers
97
340
 
98
- This generates a `monora.yml` you can load with `loadConfig({ configPath: './monora.yml' })`.
341
+ ```typescript
342
+ import { init, logEvent, toolCall, agentStep, setViolationHandler } from 'monora-ai';
99
343
 
100
- ### Reports & Security Review
344
+ init({ configPath: './monora.yml' });
101
345
 
102
- The runtime automatically generates compliance reports at trace completion (default: `./monora_reports/<trace_id>/compliance.json`) and emits a `trust_summary` event. Configure behavior with the `reporting` section in `monora.yml`.
346
+ setViolationHandler((violation) => {
347
+ console.error('Violation:', violation.message);
348
+ });
103
349
 
104
- ```bash
105
- npx monora-ai report --input events.jsonl --output report.json
106
- npx monora-ai report --input events.jsonl --output report.md --format markdown
350
+ const fetchTool = toolCall({ toolName: 'fetch', purpose: 'integration' })(async (url: string) => {
351
+ return { ok: true, url };
352
+ });
107
353
 
108
- npx monora-ai security-review --input events.jsonl --output security.json
109
- npx monora-ai security-review --input events.jsonl --output security.json --sign gpg --gpg-key "you@example.com"
354
+ const plan = agentStep({ agentName: 'planner', stepType: 'planning', purpose: 'analysis' })(
355
+ (goal: string) => [`step for ${goal}`]
356
+ );
110
357
 
111
- npx monora-ai trust-package --input events.jsonl --trace-id trc_123 --output trust.json --config monora.yml
112
- npx monora-ai verify --input events.jsonl --config monora.yml --pretty
113
- npx monora-ai retry-queue --config monora.yml
358
+ logEvent('custom', { message: 'hello' }, { purpose: 'manual' });
114
359
  ```
115
360
 
361
+ ### Reports & Trust Packages
362
+
363
+ The runtime automatically generates compliance reports at trace completion (default: `./monora_reports/<trace_id>/compliance.json`) and emits a `trust_summary` event.
364
+
116
365
  ```typescript
117
366
  import { exportTrustPackage } from 'monora-ai';
118
367
 
@@ -125,7 +374,7 @@ const trustPackage = exportTrustPackage('trc_123', {
125
374
  ### Data Handling + Alerts
126
375
 
127
376
  ```typescript
128
- import { DataHandlingEngine, buildDataViolation, ViolationWebhookDispatcher } from 'monora-ai';
377
+ import { DataHandlingEngine, ViolationWebhookDispatcher } from 'monora-ai';
129
378
 
130
379
  const dataHandling = new DataHandlingEngine({
131
380
  enabled: true,
@@ -146,77 +395,7 @@ dispatcher.start();
146
395
  dispatcher.send({ event_type: 'policy_violation', message: 'Example violation' });
147
396
  ```
148
397
 
149
- ### High-level Runtime Helpers
150
-
151
- ```typescript
152
- import { init, logEvent, toolCall, agentStep, setViolationHandler } from 'monora-ai';
153
-
154
- init({ configPath: './monora.yml' });
155
-
156
- setViolationHandler((violation) => {
157
- console.error('Violation:', violation.message);
158
- });
159
-
160
- const fetchTool = toolCall({ toolName: 'fetch', purpose: 'integration' })(async (url: string) => {
161
- return { ok: true, url };
162
- });
163
-
164
- const plan = agentStep({ agentName: 'planner', stepType: 'planning', purpose: 'analysis' })(
165
- (goal: string) => [`step for ${goal}`]
166
- );
167
-
168
- logEvent('custom', { message: 'hello' }, { purpose: 'manual' });
169
- ```
170
-
171
- ## Configuration
172
-
173
- Create a `monora.json` or `monora.yaml` file:
174
-
175
- ```json
176
- {
177
- "defaults": {
178
- "data_classification": "internal",
179
- "environment": "production"
180
- },
181
- "policies": {
182
- "model_allowlist": ["gpt-4*", "claude-3-*"],
183
- "model_denylist": ["deepseek:*"],
184
- "enforce": true
185
- },
186
- "immutability": {
187
- "enabled": true,
188
- "scope": "per_trace",
189
- "hash_algorithm": "sha256"
190
- }
191
- }
192
- ```
193
-
194
- ### HTTP Retry Queue + Idempotency
195
-
196
- ```yaml
197
- sinks:
198
- - type: https
199
- endpoint: https://api.example.com/events
200
- retry_queue:
201
- enabled: true
202
- path: ./monora_http_queue
203
- max_items: 10000
204
- flush_interval_sec: 5.0
205
- idempotency:
206
- enabled: true
207
- header_name: Idempotency-Key
208
- ```
209
-
210
- Idempotency keys are computed per batch as a SHA-256 digest of the canonical
211
- event JSON in order. Reordering events or changing batch boundaries changes the
212
- idempotency key.
213
-
214
- Inspect or clear the local retry queue:
215
-
216
- ```bash
217
- npx monora-ai retry-queue --config monora.yml
218
- npx monora-ai retry-queue --path ./monora_http_queue --clear
219
- ```
398
+ ---
220
399
 
221
400
  ## API Documentation
222
401
 
@@ -226,7 +405,7 @@ npx monora-ai retry-queue --path ./monora_http_queue --clear
226
405
  import { PolicyEngine } from 'monora-ai';
227
406
 
228
407
  const engine = new PolicyEngine({
229
- model_allowlist: ['gpt-4*'],
408
+ model_allowlist: ['gpt-*', 'claude-*', 'o1-*', 'gemini-*'],
230
409
  model_denylist: ['deepseek:*'],
231
410
  enforce: true
232
411
  });
@@ -295,23 +474,10 @@ const gaps = detectSequenceGaps(events);
295
474
  console.log('Sequence gaps:', gaps);
296
475
  ```
297
476
 
298
- ### Security Reports
299
-
300
- Generate JSON security review reports locally with CLI:
301
-
302
- Auth: none (local CLI). Errors: invalid JSONL/config or GPG signing failures.
303
-
304
- ```bash
305
- npx monora-ai security-review --input events.jsonl --output security.json
306
- npx monora-ai security-review --input events.jsonl --output security.json --config monora.yml
307
- ```
308
-
309
477
  ### Data Handling
310
478
 
311
479
  Use the data handling engine for redaction or blocking decisions (modes: `redact`, `block`, `allow`):
312
480
 
313
- Auth: none. Errors: `DataHandlingViolation` in block mode or invalid regex patterns.
314
-
315
481
  ```typescript
316
482
  import { DataHandlingEngine } from 'monora-ai';
317
483
 
@@ -327,8 +493,6 @@ const { value, applied } = engine.sanitizePayload('request', payload, 'confident
327
493
 
328
494
  Send policy violation payloads to a webhook:
329
495
 
330
- Auth: set headers such as `Authorization`. Errors: network failures, non-2xx responses, or queue overflow.
331
-
332
496
  ```typescript
333
497
  import { ViolationWebhookDispatcher } from 'monora-ai';
334
498
 
@@ -351,8 +515,6 @@ dispatcher.send({ event_type: 'policy_violation', message: 'Blocked model' });
351
515
 
352
516
  ### Event Building and Dispatching
353
517
 
354
- Event builder and dispatcher classes are available in the current Node SDK.
355
-
356
518
  ```typescript
357
519
  import { EventBuilder, EventDispatcher, StdoutSink, FileSink } from 'monora-ai';
358
520
 
@@ -374,7 +536,7 @@ const event = builder.build('llm_call', {
374
536
 
375
537
  // Setup event dispatcher with sinks
376
538
  const sinks = [
377
- new StdoutSink('json'),
539
+ new StdoutSink('pretty'),
378
540
  new FileSink('./events.jsonl', { batchSize: 100 }),
379
541
  ];
380
542
 
@@ -390,8 +552,6 @@ dispatcher.close();
390
552
 
391
553
  ### Sink Options
392
554
 
393
- These sink implementations are exported and ready for use.
394
-
395
555
  ```typescript
396
556
  // Stdout Sink
397
557
  const stdoutSink = new StdoutSink('pretty'); // or 'json'
@@ -404,7 +564,8 @@ const fileSink = new FileSink('./logs/events.jsonl', {
404
564
  maxSizeMb: 100,
405
565
  });
406
566
 
407
- // HTTPS Sink with retry
567
+ // HTTPS sinks are optional; the wizard will not enable them unless you provide an endpoint.
568
+ // HTTPS Sink with retry (example only)
408
569
  const httpsSink = new HttpSink(
409
570
  'https://api.example.com/events',
410
571
  { 'Authorization': 'Bearer token' },
@@ -417,7 +578,9 @@ const httpsSink = new HttpSink(
417
578
  );
418
579
  ```
419
580
 
420
- ## v1.9.0 Features
581
+ ---
582
+
583
+ ## Advanced Features
421
584
 
422
585
  ### Circuit Breaker
423
586
 
@@ -442,21 +605,19 @@ const httpsSink = new HttpSink(
442
605
 
443
606
  ### Telemetry/Analytics
444
607
 
445
- Telemetry is enabled by default with a minimal in-memory backend (queue depth,
446
- sink errors, retry queue size). Opt out with `telemetry.enabled: false`.
608
+ Telemetry is enabled by default with a minimal in-memory backend (queue depth, sink errors, retry queue size). Set `telemetry.backend` to `minimal`, `memory`, `prometheus`, `statsd`, or `none`. Opt out with `telemetry.backend: none` (or `telemetry.enabled: false`).
447
609
 
448
610
  Export metrics to Prometheus or StatsD:
449
611
 
450
612
  ```typescript
451
- import { init, initMetrics, recordEvent, recordViolation } from 'monora-ai';
613
+ import { init } from 'monora-ai';
452
614
 
453
- // Configure telemetry
454
615
  init({
455
616
  configPath: './monora.yml',
456
617
  config: {
457
618
  telemetry: {
458
619
  enabled: true,
459
- backend: 'prometheus', // or 'statsd'
620
+ backend: 'prometheus', // or 'statsd' | 'memory' | 'minimal' | 'none'
460
621
  prometheus: {
461
622
  port: 9090,
462
623
  start_server: true,
@@ -474,8 +635,7 @@ init({
474
635
 
475
636
  ### Attribution & Usage Telemetry (Opt-In)
476
637
 
477
- Collect optional attribution details and anonymous usage stats with explicit opt-in.
478
- No data leaves your environment unless `send_data` is enabled.
638
+ Collect optional attribution details and anonymous usage stats with explicit opt-in. No data leaves your environment unless `send_data` is enabled.
479
639
 
480
640
  ```typescript
481
641
  import { init } from 'monora-ai';
@@ -498,7 +658,7 @@ init({
498
658
  telemetry: {
499
659
  enabled: true,
500
660
  send_data: true,
501
- data_residency: 'eu'
661
+ data_residency: 'us'
502
662
  }
503
663
  }
504
664
  }
@@ -524,8 +684,7 @@ Additional presets: `default_secure`, `experimental`, `audit_first`, `low_latenc
524
684
 
525
685
  ### Migration Guidance (POC -> Production)
526
686
 
527
- When you promote a POC to production, Monora will warn if you use a POC/dev preset
528
- in a production environment. You can also run the readiness checks directly:
687
+ When you promote a POC to production, Monora will warn if you use a POC/dev preset in a production environment. You can also run the readiness checks directly:
529
688
 
530
689
  ```typescript
531
690
  import {
@@ -591,15 +750,14 @@ const result = await runComplianceCheck({
591
750
  const profile = reportUsageProfile();
592
751
  ```
593
752
 
594
- Compliance scores are weighted by framework and control category (integrity,
595
- auditability, privacy, and governance) instead of a flat pass rate.
753
+ Compliance scores are weighted by framework and control category (integrity, auditability, privacy, and governance) instead of a flat pass rate.
596
754
 
597
755
  ### Standards Mapping (SOC 2 / GDPR / ISO)
598
756
 
599
757
  Evaluate external claims against Monora evidence (event IDs, causal paths, guardrails):
600
758
 
601
759
  ```bash
602
- monora standards-check \
760
+ npx monora-ai standards-check \
603
761
  --input ./monora_events.jsonl \
604
762
  --report ./SOC2_Report.pdf \
605
763
  --claims ./claims.json \
@@ -610,37 +768,39 @@ monora standards-check \
610
768
  Generate a claims manifest interactively (with optional coverage preview):
611
769
 
612
770
  ```bash
613
- monora standards-wizard \
771
+ npx monora-ai standards-wizard \
614
772
  --standard SOC2 \
615
773
  --output ./claims.json \
616
774
  --input ./monora_events.jsonl \
617
775
  --config ./monora.yml
618
776
  ```
619
777
 
620
- Start with `templates/standards_claims_template.json` and customize the claims to
621
- match the sections you care about. Packaged standards templates are also available:
778
+ Start with `templates/standards_claims_template.json` and customize the claims. Packaged standards templates:
622
779
 
623
780
  - SOC 2: `templates/standards/soc2_claims.json`
624
781
  - GDPR: `templates/standards/gdpr_claims.json`
625
782
  - ISO 27001: `templates/standards/iso27001_claims.json`
783
+ - ISO 42001: `templates/standards/iso42001_claims.json`
784
+
785
+ Packaged control catalogs for trust-package/control-coverage workflows:
626
786
 
627
- If your report is JSON and already contains a `claims` list, you can pass it via
628
- `--report` without `--claims`.
787
+ - SOC 2: `templates/controls/soc2_control_catalog.json`
788
+ - GDPR: `templates/controls/gdpr_control_catalog.json`
789
+ - ISO 42001: supported via default control catalog resolution
629
790
 
630
- Supported checks: `policy_violations_max`, `unknown_models_max`, `forbidden_models_max`,
631
- `hash_chain_status`, `signatures_status`, `sequence_gaps_max`, `errors_max`, `config_required`.
791
+ Supported checks: `policy_violations_max`, `unknown_models_max`, `forbidden_models_max`, `hash_chain_status`, `signatures_status`, `sequence_gaps_max`, `errors_max`, `config_required`.
632
792
 
633
793
  ### Report Ingestion + Excerpts (SOC 2 / GDPR / ISO)
634
794
 
635
795
  Ingest a report, extract text, and attach verified excerpts to your claims manifest:
636
796
 
637
797
  ```bash
638
- monora standards-ingest \
798
+ npx monora-ai standards-ingest \
639
799
  --report ./SOC2_Report.pdf \
640
800
  --output ./report_ingest.json \
641
801
  --text-out ./SOC2_Report.txt
642
802
 
643
- monora standards-excerpt \
803
+ npx monora-ai standards-excerpt \
644
804
  --ingest ./report_ingest.json \
645
805
  --claims ./claims.json \
646
806
  --excerpts ./excerpts.json \
@@ -651,7 +811,7 @@ monora standards-excerpt \
651
811
  Auto-suggest and approve excerpts interactively:
652
812
 
653
813
  ```bash
654
- monora standards-review \
814
+ npx monora-ai standards-review \
655
815
  --ingest ./report_ingest.json \
656
816
  --claims ./claims.json \
657
817
  --output ./claims_with_excerpts.json
@@ -660,7 +820,7 @@ monora standards-review \
660
820
  Or produce suggestions as JSON:
661
821
 
662
822
  ```bash
663
- monora standards-suggest \
823
+ npx monora-ai standards-suggest \
664
824
  --ingest ./report_ingest.json \
665
825
  --claims ./claims.json \
666
826
  --output ./suggestions.json \
@@ -771,6 +931,27 @@ export const createUser = withMonoraAction(
771
931
  );
772
932
  ```
773
933
 
934
+ ---
935
+
936
+ ## Troubleshooting
937
+
938
+ - Validation fails due to null values: run `npx monora-ai config fix --config monora.yml` or validate with `npx monora-ai validate --mode lenient`.
939
+ - Telemetry backend errors: set `telemetry.backend` to `minimal`, `memory`, `prometheus`, `statsd`, or `none`.
940
+ - Daily rotation changed filenames: use `./monora_events.latest.jsonl` or set `rotation: none`.
941
+ - CLI command not found: use `npx monora-ai <command>` (or `npm exec -- monora <command>`).
942
+ - Console flooded with JSON: remove the stdout sink, set `format: pretty`, or export `MONORA_QUIET=1`.
943
+ - HTTPS sink errors: only enable HTTPS sinks when you have a real endpoint; the wizard leaves them off by default.
944
+
945
+ ---
946
+
947
+ ## Migration Guide (Verbose/Null-Heavy Configs)
948
+
949
+ 1. Run `npx monora-ai config fix --config monora.yml` (creates a `.bak` backup).
950
+ 2. Optionally regenerate a minimal baseline with `npx monora-ai init --preset minimal` and copy over only the sections you use.
951
+ 3. Validate with `npx monora-ai validate --mode lenient`, then switch to `--mode strict` for production.
952
+
953
+ ---
954
+
774
955
  ## License
775
956
 
776
957
  MIT