monora-ai 2.0.0 → 2.1.3
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 +441 -150
- package/dist/aims_governance.d.ts +238 -0
- package/dist/aims_governance.d.ts.map +1 -0
- package/dist/aims_governance.js +922 -0
- package/dist/alerts.d.ts +16 -0
- package/dist/alerts.d.ts.map +1 -1
- package/dist/alerts.js +16 -0
- package/dist/api.d.ts +6 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +6 -0
- package/dist/assessment.d.ts +269 -0
- package/dist/assessment.d.ts.map +1 -0
- package/dist/assessment.js +1232 -0
- package/dist/attestation.js +23 -1
- package/dist/attribution.d.ts +349 -0
- package/dist/attribution.d.ts.map +1 -0
- package/dist/attribution.js +987 -0
- package/dist/autodetect.d.ts +69 -1
- package/dist/autodetect.d.ts.map +1 -1
- package/dist/autodetect.js +644 -1
- package/dist/bias.d.ts +130 -0
- package/dist/bias.d.ts.map +1 -0
- package/dist/bias.js +223 -0
- package/dist/circuit_breaker.js +3 -3
- package/dist/cli/diagnostics.d.ts +5 -1
- package/dist/cli/diagnostics.d.ts.map +1 -1
- package/dist/cli/diagnostics.js +31 -8
- package/dist/cli/doctor.d.ts +25 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +381 -0
- package/dist/cli/fix.d.ts +16 -0
- package/dist/cli/fix.d.ts.map +1 -0
- package/dist/cli/fix.js +284 -0
- package/dist/cli/init.d.ts +57 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +205 -0
- package/dist/cli.js +1611 -126
- package/dist/complianceTargets.d.ts +111 -0
- package/dist/complianceTargets.d.ts.map +1 -0
- package/dist/complianceTargets.js +521 -0
- package/dist/config.d.ts +301 -17
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +428 -36
- package/dist/config_migrations.d.ts +41 -0
- package/dist/config_migrations.d.ts.map +1 -1
- package/dist/config_migrations.js +205 -0
- package/dist/config_schema.d.ts +2900 -731
- package/dist/config_schema.d.ts.map +1 -1
- package/dist/config_schema.js +257 -55
- package/dist/context.d.ts +34 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +118 -7
- package/dist/control_backbone.d.ts +122 -0
- package/dist/control_backbone.d.ts.map +1 -0
- package/dist/control_backbone.js +698 -0
- package/dist/data-governance.d.ts +187 -0
- package/dist/data-governance.d.ts.map +1 -0
- package/dist/data-governance.js +424 -0
- package/dist/dataResidency.d.ts +44 -0
- package/dist/dataResidency.d.ts.map +1 -0
- package/dist/dataResidency.js +203 -0
- package/dist/dispatcher.d.ts +32 -0
- package/dist/dispatcher.d.ts.map +1 -1
- package/dist/dispatcher.js +91 -4
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +38 -0
- package/dist/evidence_store.d.ts +103 -0
- package/dist/evidence_store.d.ts.map +1 -0
- package/dist/evidence_store.js +459 -0
- package/dist/executiveSummary.d.ts +65 -8
- package/dist/executiveSummary.d.ts.map +1 -1
- package/dist/executiveSummary.js +289 -26
- package/dist/identity.d.ts +143 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +231 -0
- package/dist/impact-assessment.d.ts +350 -0
- package/dist/impact-assessment.d.ts.map +1 -0
- package/dist/impact-assessment.js +580 -0
- package/dist/index.d.ts +25 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +300 -4
- package/dist/instrumentation.d.ts +1 -1
- package/dist/instrumentation.d.ts.map +1 -1
- package/dist/instrumentation.js +243 -27
- package/dist/integrations/anthropic.d.ts +3 -0
- package/dist/integrations/anthropic.d.ts.map +1 -1
- package/dist/integrations/anthropic.js +284 -79
- package/dist/integrations/governance.d.ts +33 -0
- package/dist/integrations/governance.d.ts.map +1 -0
- package/dist/integrations/governance.js +208 -0
- package/dist/integrations/langchain.d.ts +7 -0
- package/dist/integrations/langchain.d.ts.map +1 -1
- package/dist/integrations/langchain.js +387 -143
- package/dist/integrations/openai.d.ts +9 -0
- package/dist/integrations/openai.d.ts.map +1 -1
- package/dist/integrations/openai.js +673 -73
- package/dist/iso42001_consolidation.d.ts +16 -0
- package/dist/iso42001_consolidation.d.ts.map +1 -0
- package/dist/iso42001_consolidation.js +413 -0
- package/dist/iso42001_workflows.d.ts +263 -0
- package/dist/iso42001_workflows.d.ts.map +1 -0
- package/dist/iso42001_workflows.js +781 -0
- package/dist/lifecycle.d.ts +299 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +624 -0
- package/dist/lineage.d.ts +2 -2
- package/dist/lineage.d.ts.map +1 -1
- package/dist/lineage.js +12 -17
- package/dist/middleware/express.d.ts.map +1 -1
- package/dist/middleware/express.js +33 -3
- package/dist/middleware/nextjs.d.ts.map +1 -1
- package/dist/middleware/nextjs.js +42 -68
- package/dist/model.d.ts +143 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +371 -0
- package/dist/onboarding.d.ts +42 -0
- package/dist/onboarding.d.ts.map +1 -0
- package/dist/onboarding.js +1022 -0
- package/dist/oversight.d.ts +264 -0
- package/dist/oversight.d.ts.map +1 -0
- package/dist/oversight.js +497 -0
- package/dist/pdf_report.d.ts.map +1 -1
- package/dist/pdf_report.js +42 -21
- package/dist/presets.d.ts +88 -0
- package/dist/presets.d.ts.map +1 -0
- package/dist/presets.js +520 -0
- package/dist/propagation.d.ts.map +1 -1
- package/dist/propagation.js +34 -2
- package/dist/quotas.d.ts +171 -0
- package/dist/quotas.d.ts.map +1 -0
- package/dist/quotas.js +259 -0
- package/dist/register.d.ts +13 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +99 -0
- package/dist/registry.d.ts +1 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +7 -0
- package/dist/registryData.json +43 -6
- package/dist/report.d.ts +2 -1
- package/dist/report.d.ts.map +1 -1
- package/dist/report.js +189 -2
- package/dist/reporting.d.ts +125 -0
- package/dist/reporting.d.ts.map +1 -1
- package/dist/reporting.js +196 -5
- package/dist/resources.d.ts +285 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +643 -0
- package/dist/risk.d.ts +120 -0
- package/dist/risk.d.ts.map +1 -0
- package/dist/risk.js +220 -0
- package/dist/runtime.d.ts +74 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +598 -22
- package/dist/schemaInference.d.ts +92 -0
- package/dist/schemaInference.d.ts.map +1 -0
- package/dist/schemaInference.js +466 -0
- package/dist/schema_validation.js +2 -2
- package/dist/schemas/config.schema.json +169 -6
- package/dist/schemas/event.schema.json +4 -0
- package/dist/security_report.js +4 -4
- package/dist/signing.d.ts +1 -1
- package/dist/signing.d.ts.map +1 -1
- package/dist/signing.js +4 -0
- package/dist/sinks/file.d.ts +19 -1
- package/dist/sinks/file.d.ts.map +1 -1
- package/dist/sinks/file.js +82 -13
- package/dist/sinks/https.d.ts +10 -0
- package/dist/sinks/https.d.ts.map +1 -1
- package/dist/sinks/https.js +76 -16
- package/dist/sinks/stdout.d.ts +1 -0
- package/dist/sinks/stdout.d.ts.map +1 -1
- package/dist/sinks/stdout.js +12 -1
- package/dist/spec.d.ts +159 -0
- package/dist/spec.d.ts.map +1 -0
- package/dist/spec.js +391 -0
- package/dist/stakeholders.d.ts +199 -0
- package/dist/stakeholders.d.ts.map +1 -0
- package/dist/stakeholders.js +398 -0
- package/dist/standards.d.ts.map +1 -1
- package/dist/standards.js +160 -2
- package/dist/standards_ingest.d.ts +2 -2
- package/dist/standards_ingest.d.ts.map +1 -1
- package/dist/standards_ingest.js +105 -23
- package/dist/streaming.d.ts.map +1 -1
- package/dist/streaming.js +7 -2
- package/dist/telemetry.d.ts +16 -2
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +79 -14
- package/dist/templates/controls/iso42001_control_catalog.json +1443 -0
- package/dist/traced_emitter.d.ts +3 -0
- package/dist/traced_emitter.d.ts.map +1 -1
- package/dist/traced_emitter.js +142 -25
- package/dist/trust_package.d.ts +21 -1
- package/dist/trust_package.d.ts.map +1 -1
- package/dist/trust_package.js +101 -4
- package/dist/verify.d.ts.map +1 -1
- package/dist/verify.js +9 -2
- package/dist/wal.d.ts.map +1 -1
- package/dist/wal.js +2 -1
- package/package.json +14 -1
- package/scripts/postinstall.js +119 -97
- package/templates/controls/iso42001_control_catalog.json +1443 -0
package/dist/config.js
CHANGED
|
@@ -36,44 +36,54 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.PRESETS = void 0;
|
|
39
|
+
exports.DEFAULT_CONFIG = exports.PRESETS = void 0;
|
|
40
40
|
exports.loadConfig = loadConfig;
|
|
41
41
|
exports.parseSinkConfig = parseSinkConfig;
|
|
42
42
|
exports.getPresetConfig = getPresetConfig;
|
|
43
43
|
exports.buildConfigFromOptions = buildConfigFromOptions;
|
|
44
|
+
exports.detectEnvironment = detectEnvironment;
|
|
45
|
+
exports.suggestPreset = suggestPreset;
|
|
44
46
|
const fs = __importStar(require("fs"));
|
|
45
47
|
const yaml = __importStar(require("js-yaml"));
|
|
46
48
|
const logger_1 = require("./logger");
|
|
47
49
|
const config_migrations_1 = require("./config_migrations");
|
|
50
|
+
const presets_1 = require("./presets");
|
|
48
51
|
/**
|
|
49
52
|
* Preset configurations for quick setup.
|
|
50
53
|
*/
|
|
54
|
+
const MINIMAL_PRESET = {
|
|
55
|
+
sinks: [{ type: 'file', path: './monora_events.jsonl', rotation: 'none' }],
|
|
56
|
+
immutability: { enabled: false },
|
|
57
|
+
reporting: { enabled: false },
|
|
58
|
+
instrumentation: { enabled: false },
|
|
59
|
+
telemetry: { enabled: true, backend: 'minimal' },
|
|
60
|
+
};
|
|
61
|
+
const DEV_PRESET = {
|
|
62
|
+
defaults: { environment: 'dev' },
|
|
63
|
+
sinks: [
|
|
64
|
+
{ type: 'file', path: './monora_events.jsonl', rotation: 'none' },
|
|
65
|
+
{ type: 'stdout', format: 'pretty' },
|
|
66
|
+
],
|
|
67
|
+
immutability: { enabled: true, verify_on_emit: false },
|
|
68
|
+
reporting: { enabled: true, output_dir: './monora_reports' },
|
|
69
|
+
instrumentation: { enabled: true, auto_patch: true },
|
|
70
|
+
telemetry: { enabled: true, backend: 'minimal' },
|
|
71
|
+
};
|
|
72
|
+
const PRODUCTION_PRESET = {
|
|
73
|
+
defaults: { environment: 'production' },
|
|
74
|
+
sinks: [{ type: 'file', path: './logs/monora_events.jsonl', rotation: 'daily', symlink: true }],
|
|
75
|
+
immutability: { enabled: true, verify_on_shutdown: true },
|
|
76
|
+
reporting: { enabled: true, output_dir: './monora_reports' },
|
|
77
|
+
wal: { enabled: true, path: './monora_wal' },
|
|
78
|
+
instrumentation: { enabled: true, auto_patch: true },
|
|
79
|
+
error_handling: { sink_failure_mode: 'warn' },
|
|
80
|
+
telemetry: { enabled: true, backend: 'minimal' },
|
|
81
|
+
};
|
|
51
82
|
exports.PRESETS = {
|
|
52
|
-
minimal:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
instrumentation: { enabled: false },
|
|
57
|
-
},
|
|
58
|
-
development: {
|
|
59
|
-
defaults: { environment: 'dev' },
|
|
60
|
-
sinks: [
|
|
61
|
-
{ type: 'stdout', format: 'json' },
|
|
62
|
-
{ type: 'file', path: './monora_events.jsonl' },
|
|
63
|
-
],
|
|
64
|
-
immutability: { enabled: true, verify_on_emit: false },
|
|
65
|
-
reporting: { enabled: true, output_dir: './monora_reports' },
|
|
66
|
-
instrumentation: { enabled: true, auto_patch: true },
|
|
67
|
-
},
|
|
68
|
-
production: {
|
|
69
|
-
defaults: { environment: 'production' },
|
|
70
|
-
sinks: [{ type: 'file', path: './logs/monora_events.jsonl' }],
|
|
71
|
-
immutability: { enabled: true, verify_on_shutdown: true },
|
|
72
|
-
reporting: { enabled: true, output_dir: './monora_reports' },
|
|
73
|
-
wal: { enabled: true, path: './monora_wal' },
|
|
74
|
-
instrumentation: { enabled: true, auto_patch: true },
|
|
75
|
-
error_handling: { sink_failure_mode: 'warn' },
|
|
76
|
-
},
|
|
83
|
+
minimal: MINIMAL_PRESET,
|
|
84
|
+
development: DEV_PRESET,
|
|
85
|
+
dev: DEV_PRESET,
|
|
86
|
+
production: PRODUCTION_PRESET,
|
|
77
87
|
compliance: {
|
|
78
88
|
defaults: { environment: 'production' },
|
|
79
89
|
sinks: [{ type: 'file', path: './logs/monora_events.jsonl' }],
|
|
@@ -89,6 +99,14 @@ exports.PRESETS = {
|
|
|
89
99
|
attestation: { enabled: true },
|
|
90
100
|
ai_act: { enabled: true, generate_transparency_report: true },
|
|
91
101
|
instrumentation: { enabled: true, auto_patch: true },
|
|
102
|
+
attribution: {
|
|
103
|
+
enabled: false,
|
|
104
|
+
telemetry: {
|
|
105
|
+
enabled: false,
|
|
106
|
+
send_data: false,
|
|
107
|
+
data_residency: null,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
92
110
|
},
|
|
93
111
|
poc: {
|
|
94
112
|
defaults: { environment: 'production' },
|
|
@@ -110,7 +128,7 @@ exports.PRESETS = {
|
|
|
110
128
|
instrumentation: { enabled: true, auto_patch: true },
|
|
111
129
|
},
|
|
112
130
|
};
|
|
113
|
-
|
|
131
|
+
exports.DEFAULT_CONFIG = {
|
|
114
132
|
config_version: '1.0.0',
|
|
115
133
|
defaults: {
|
|
116
134
|
data_classification: 'internal',
|
|
@@ -118,7 +136,7 @@ const DEFAULT_CONFIG = {
|
|
|
118
136
|
service_name: undefined,
|
|
119
137
|
environment: 'dev',
|
|
120
138
|
},
|
|
121
|
-
sinks: [{ type: '
|
|
139
|
+
sinks: [{ type: 'file', path: './monora_events.jsonl', rotation: 'none' }],
|
|
122
140
|
immutability: {
|
|
123
141
|
enabled: true,
|
|
124
142
|
scope: 'per_trace',
|
|
@@ -186,6 +204,7 @@ const DEFAULT_CONFIG = {
|
|
|
186
204
|
include_security_report: false,
|
|
187
205
|
max_events_per_trace: 10000,
|
|
188
206
|
redact_host: true,
|
|
207
|
+
trust_bundle_include_events: true,
|
|
189
208
|
},
|
|
190
209
|
data_handling: {
|
|
191
210
|
enabled: false,
|
|
@@ -259,10 +278,179 @@ const DEFAULT_CONFIG = {
|
|
|
259
278
|
enabled: true,
|
|
260
279
|
backend: 'minimal',
|
|
261
280
|
},
|
|
281
|
+
attribution: {
|
|
282
|
+
enabled: false,
|
|
283
|
+
project: {},
|
|
284
|
+
telemetry: {
|
|
285
|
+
enabled: false,
|
|
286
|
+
send_data: false,
|
|
287
|
+
data_residency: null,
|
|
288
|
+
endpoints: {
|
|
289
|
+
us: null, // Set via MONORA_ATTRIBUTION_ENDPOINT_US or config
|
|
290
|
+
eu: null, // Set via MONORA_ATTRIBUTION_ENDPOINT_EU or config
|
|
291
|
+
},
|
|
292
|
+
api_key_env: 'MONORA_ATTRIBUTION_KEY',
|
|
293
|
+
timeout_sec: 5.0,
|
|
294
|
+
retry_attempts: 2,
|
|
295
|
+
backoff_base_sec: 0.5,
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
audit: {},
|
|
299
|
+
quotas: {
|
|
300
|
+
enabled: false,
|
|
301
|
+
max_tokens_per_trace: 100000,
|
|
302
|
+
max_llm_calls_per_trace: 50,
|
|
303
|
+
max_trace_duration_sec: 3600,
|
|
304
|
+
max_cost_per_trace: 10.0,
|
|
305
|
+
action: 'warn',
|
|
306
|
+
},
|
|
307
|
+
identity: {
|
|
308
|
+
enabled: false,
|
|
309
|
+
require_user_id: false,
|
|
310
|
+
capture_roles: false,
|
|
311
|
+
capture_org: false,
|
|
312
|
+
redact_user_id: false,
|
|
313
|
+
},
|
|
314
|
+
risk_register: {
|
|
315
|
+
enabled: false,
|
|
316
|
+
models: {},
|
|
317
|
+
default_risk_level: 'high',
|
|
318
|
+
block_unassessed: false,
|
|
319
|
+
},
|
|
320
|
+
bias: {
|
|
321
|
+
enabled: false,
|
|
322
|
+
dimensions: [],
|
|
323
|
+
thresholds: {
|
|
324
|
+
demographic_parity_ratio: 0.8,
|
|
325
|
+
disparate_impact: 0.8,
|
|
326
|
+
},
|
|
327
|
+
alert_on_violation: true,
|
|
328
|
+
measurement_callback: null,
|
|
329
|
+
},
|
|
330
|
+
human_oversight: {
|
|
331
|
+
enabled: false,
|
|
332
|
+
require_review_for: [],
|
|
333
|
+
review_timeout_hours: 24,
|
|
334
|
+
escalation_policy: {
|
|
335
|
+
timeout_action: 'alert',
|
|
336
|
+
escalate_to: null,
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
// ISO 42001 A.5 - AI Impact Assessment
|
|
340
|
+
impact_assessment: {
|
|
341
|
+
enabled: false,
|
|
342
|
+
require_before_production: true,
|
|
343
|
+
review_interval_days: 365,
|
|
344
|
+
categories: ['fairness', 'privacy', 'safety', 'autonomy', 'economic', 'environmental'],
|
|
345
|
+
require_approvals: [
|
|
346
|
+
{ role: 'ai_governance' },
|
|
347
|
+
{ role: 'legal' },
|
|
348
|
+
{ role: 'ethics_board' },
|
|
349
|
+
],
|
|
350
|
+
risk_matrix: {
|
|
351
|
+
likelihood_weights: { rare: 1, unlikely: 2, possible: 3, likely: 4, certain: 5 },
|
|
352
|
+
severity_weights: { minimal: 1, minor: 2, moderate: 3, major: 4, catastrophic: 5 },
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
// ISO 42001 A.6 - AI System Life Cycle
|
|
356
|
+
lifecycle: {
|
|
357
|
+
enabled: false,
|
|
358
|
+
require_objectives: true,
|
|
359
|
+
require_requirements: true,
|
|
360
|
+
require_v_and_v: true,
|
|
361
|
+
stage_prerequisites: {
|
|
362
|
+
testing: ['requirements_defined'],
|
|
363
|
+
staging: ['verification_complete'],
|
|
364
|
+
production: ['validation_complete', 'deployment_approved'],
|
|
365
|
+
deprecated: ['decommission_plan'],
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
// ISO 42001 A.7 - Data Governance
|
|
369
|
+
data_governance: {
|
|
370
|
+
enabled: false,
|
|
371
|
+
require_quality_assessment: true,
|
|
372
|
+
default_quality_thresholds: {
|
|
373
|
+
completeness: 0.95,
|
|
374
|
+
accuracy: 0.90,
|
|
375
|
+
consistency: 0.95,
|
|
376
|
+
timeliness: 0.80,
|
|
377
|
+
uniqueness: 0.99,
|
|
378
|
+
representativeness: 0.70,
|
|
379
|
+
},
|
|
380
|
+
require_bias_assessment_for: ['training', 'validation'],
|
|
381
|
+
},
|
|
382
|
+
// ISO 42001 A.8/A.10 - Stakeholder & Third-Party Management
|
|
383
|
+
stakeholders: {
|
|
384
|
+
enabled: false,
|
|
385
|
+
require_supplier_assessment: true,
|
|
386
|
+
supplier_review_interval_days: 365,
|
|
387
|
+
risk_thresholds: {
|
|
388
|
+
critical_requires_approval: true,
|
|
389
|
+
high_requires_review: true,
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
// ISO 42001 A.4/A.2 - Resource Inventory & Policy Review
|
|
393
|
+
resources: {
|
|
394
|
+
enabled: false,
|
|
395
|
+
require_tooling_approval: true,
|
|
396
|
+
policy_review_interval_days: 365,
|
|
397
|
+
track_competencies: true,
|
|
398
|
+
},
|
|
399
|
+
onboarding: {
|
|
400
|
+
enabled: false,
|
|
401
|
+
required_in_production: true,
|
|
402
|
+
status: 'draft',
|
|
403
|
+
standards: ['SOC2', 'GDPR', 'ISO27001'],
|
|
404
|
+
artifacts: {
|
|
405
|
+
production_logs_path: './monora_events.jsonl',
|
|
406
|
+
schema_contract_path: './onboarding/schema_contract.json',
|
|
407
|
+
dataset_sample_path: null,
|
|
408
|
+
baseline_reports_dir: './monora_reports/onboarding',
|
|
409
|
+
},
|
|
410
|
+
validation: {
|
|
411
|
+
min_log_records: 100,
|
|
412
|
+
required_field_presence_threshold: 0.95,
|
|
413
|
+
type_conformance_threshold: 0.90,
|
|
414
|
+
},
|
|
415
|
+
completion: {
|
|
416
|
+
completed_at: null,
|
|
417
|
+
completed_by: null,
|
|
418
|
+
last_validated_at: null,
|
|
419
|
+
},
|
|
420
|
+
},
|
|
421
|
+
model_spec: {
|
|
422
|
+
name: 'monora_default',
|
|
423
|
+
version: 'v1',
|
|
424
|
+
event_ts_field: 'timestamp',
|
|
425
|
+
schema_ref: './onboarding/schema_contract.json',
|
|
426
|
+
roles: {
|
|
427
|
+
inputs: [],
|
|
428
|
+
outputs: [],
|
|
429
|
+
metadata: [],
|
|
430
|
+
identifiers: ['event_id', 'trace_id', 'span_id'],
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
enrichments: {
|
|
434
|
+
profile: 'recommended',
|
|
435
|
+
bundles: [
|
|
436
|
+
'core_observability',
|
|
437
|
+
'soc2_access',
|
|
438
|
+
'gdpr_privacy',
|
|
439
|
+
'iso27001_security',
|
|
440
|
+
],
|
|
441
|
+
toggles: {
|
|
442
|
+
identity_tracking: true,
|
|
443
|
+
risk_tracking: true,
|
|
444
|
+
bias_tracking: false,
|
|
445
|
+
oversight_tracking: true,
|
|
446
|
+
data_governance_tracking: true,
|
|
447
|
+
lifecycle_tracking: true,
|
|
448
|
+
},
|
|
449
|
+
},
|
|
262
450
|
};
|
|
263
451
|
function loadConfig(options) {
|
|
264
452
|
const { configPath, configDict, envPrefix = 'MONORA_' } = options || {};
|
|
265
|
-
let config = deepCopy(DEFAULT_CONFIG);
|
|
453
|
+
let config = deepCopy(exports.DEFAULT_CONFIG);
|
|
266
454
|
// Load from environment variables
|
|
267
455
|
const envConfig = configFromEnv(envPrefix);
|
|
268
456
|
mergeDicts(config, envConfig);
|
|
@@ -326,7 +514,13 @@ function envKeyToPath(key) {
|
|
|
326
514
|
const upperKey = key.toUpperCase();
|
|
327
515
|
let rest = parts.slice(1);
|
|
328
516
|
const path = [];
|
|
329
|
-
|
|
517
|
+
let prefix = [];
|
|
518
|
+
if (parts.length >= 2 && parts[0] === 'ATTRIBUTION' && ['TELEMETRY', 'PROJECT'].includes(parts[1])) {
|
|
519
|
+
path.push('attribution');
|
|
520
|
+
prefix = [parts[1].toLowerCase()];
|
|
521
|
+
rest = parts.slice(2);
|
|
522
|
+
}
|
|
523
|
+
else if (upperKey.startsWith('AI_ACT') ||
|
|
330
524
|
(parts.length >= 2 && parts[0] === 'AI' && parts[1] === 'ACT')) {
|
|
331
525
|
path.push('ai_act');
|
|
332
526
|
rest = parts.slice(2);
|
|
@@ -334,6 +528,9 @@ function envKeyToPath(key) {
|
|
|
334
528
|
else {
|
|
335
529
|
path.push(parts[0].toLowerCase());
|
|
336
530
|
}
|
|
531
|
+
if (prefix.length > 0) {
|
|
532
|
+
path.push(...prefix);
|
|
533
|
+
}
|
|
337
534
|
const buffer = [];
|
|
338
535
|
for (const part of rest) {
|
|
339
536
|
if (/^\d+$/.test(part)) {
|
|
@@ -558,8 +755,9 @@ function parseSinkConfig(sink) {
|
|
|
558
755
|
}
|
|
559
756
|
// HTTPS sink
|
|
560
757
|
if (sinkStr.startsWith('https://') || sinkStr.startsWith('http://')) {
|
|
758
|
+
const sinkType = sinkStr.startsWith('https://') ? 'https' : 'http';
|
|
561
759
|
return [{
|
|
562
|
-
type:
|
|
760
|
+
type: sinkType,
|
|
563
761
|
endpoint: sinkStr,
|
|
564
762
|
batch_size: 50,
|
|
565
763
|
timeout_sec: 10,
|
|
@@ -570,7 +768,7 @@ function parseSinkConfig(sink) {
|
|
|
570
768
|
return [{
|
|
571
769
|
type: 'file',
|
|
572
770
|
path: sinkStr,
|
|
573
|
-
rotation: '
|
|
771
|
+
rotation: 'none',
|
|
574
772
|
max_size_mb: 100,
|
|
575
773
|
}];
|
|
576
774
|
}
|
|
@@ -578,11 +776,16 @@ function parseSinkConfig(sink) {
|
|
|
578
776
|
* Get configuration for a named preset.
|
|
579
777
|
*/
|
|
580
778
|
function getPresetConfig(preset) {
|
|
581
|
-
if (
|
|
582
|
-
|
|
779
|
+
if (preset in exports.PRESETS) {
|
|
780
|
+
return deepCopy(exports.PRESETS[preset]);
|
|
781
|
+
}
|
|
782
|
+
try {
|
|
783
|
+
return (0, presets_1.getPresetConfig)(preset);
|
|
784
|
+
}
|
|
785
|
+
catch {
|
|
786
|
+
const valid = [...new Set([...Object.keys(exports.PRESETS), ...(0, presets_1.listPresets)()])].sort().join(', ');
|
|
583
787
|
throw new Error(`Unknown preset '${preset}'. Valid presets: ${valid}`);
|
|
584
788
|
}
|
|
585
|
-
return deepCopy(exports.PRESETS[preset]);
|
|
586
789
|
}
|
|
587
790
|
/**
|
|
588
791
|
* Build configuration from simplified options.
|
|
@@ -590,7 +793,7 @@ function getPresetConfig(preset) {
|
|
|
590
793
|
function buildConfigFromOptions(options = {}) {
|
|
591
794
|
const { preset, serviceName, sink, policies, configPath, configDict } = options;
|
|
592
795
|
// Start with defaults
|
|
593
|
-
let config = deepCopy(DEFAULT_CONFIG);
|
|
796
|
+
let config = deepCopy(exports.DEFAULT_CONFIG);
|
|
594
797
|
// Apply preset if specified
|
|
595
798
|
if (preset && preset !== 'auto') {
|
|
596
799
|
const presetConfig = getPresetConfig(preset);
|
|
@@ -625,3 +828,192 @@ function buildConfigFromOptions(options = {}) {
|
|
|
625
828
|
(0, config_migrations_1.applyConfigMigrations)(config);
|
|
626
829
|
return config;
|
|
627
830
|
}
|
|
831
|
+
/**
|
|
832
|
+
* Detect the runtime environment from common signals.
|
|
833
|
+
*
|
|
834
|
+
* Checks in order of priority:
|
|
835
|
+
* 1. Explicit NODE_ENV
|
|
836
|
+
* 2. CI/CD environment variables
|
|
837
|
+
* 3. Container orchestrator hints
|
|
838
|
+
* 4. Framework-specific variables
|
|
839
|
+
*
|
|
840
|
+
* @returns Detection result with environment, source, and confidence
|
|
841
|
+
*/
|
|
842
|
+
function detectEnvironment() {
|
|
843
|
+
const context = {};
|
|
844
|
+
// 1. Check explicit NODE_ENV (highest priority)
|
|
845
|
+
const nodeEnv = process.env.NODE_ENV?.toLowerCase();
|
|
846
|
+
if (nodeEnv) {
|
|
847
|
+
context.NODE_ENV = nodeEnv;
|
|
848
|
+
if (nodeEnv === 'production' || nodeEnv === 'prod') {
|
|
849
|
+
return {
|
|
850
|
+
environment: 'production',
|
|
851
|
+
source: 'NODE_ENV',
|
|
852
|
+
confidence: 'high',
|
|
853
|
+
context,
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
if (nodeEnv === 'staging' || nodeEnv === 'stage') {
|
|
857
|
+
return {
|
|
858
|
+
environment: 'staging',
|
|
859
|
+
source: 'NODE_ENV',
|
|
860
|
+
confidence: 'high',
|
|
861
|
+
context,
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
if (nodeEnv === 'test' || nodeEnv === 'testing') {
|
|
865
|
+
return {
|
|
866
|
+
environment: 'test',
|
|
867
|
+
source: 'NODE_ENV',
|
|
868
|
+
confidence: 'high',
|
|
869
|
+
context,
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
if (nodeEnv === 'development' || nodeEnv === 'dev') {
|
|
873
|
+
return {
|
|
874
|
+
environment: 'development',
|
|
875
|
+
source: 'NODE_ENV',
|
|
876
|
+
confidence: 'high',
|
|
877
|
+
context,
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
// 2. Check CI/CD environment variables
|
|
882
|
+
const ciVars = {
|
|
883
|
+
CI: process.env.CI,
|
|
884
|
+
GITHUB_ACTIONS: process.env.GITHUB_ACTIONS,
|
|
885
|
+
GITLAB_CI: process.env.GITLAB_CI,
|
|
886
|
+
CIRCLECI: process.env.CIRCLECI,
|
|
887
|
+
TRAVIS: process.env.TRAVIS,
|
|
888
|
+
JENKINS_URL: process.env.JENKINS_URL,
|
|
889
|
+
BUILDKITE: process.env.BUILDKITE,
|
|
890
|
+
AZURE_PIPELINES: process.env.TF_BUILD,
|
|
891
|
+
TEAMCITY_VERSION: process.env.TEAMCITY_VERSION,
|
|
892
|
+
BITBUCKET_PIPELINES: process.env.BITBUCKET_BUILD_NUMBER,
|
|
893
|
+
};
|
|
894
|
+
for (const [varName, value] of Object.entries(ciVars)) {
|
|
895
|
+
if (value && value !== 'false' && value !== '0') {
|
|
896
|
+
context[varName] = value;
|
|
897
|
+
return {
|
|
898
|
+
environment: 'ci',
|
|
899
|
+
source: varName,
|
|
900
|
+
confidence: 'high',
|
|
901
|
+
context,
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
// 3. Check container orchestrator hints
|
|
906
|
+
if (process.env.KUBERNETES_SERVICE_HOST) {
|
|
907
|
+
context.KUBERNETES_SERVICE_HOST = process.env.KUBERNETES_SERVICE_HOST;
|
|
908
|
+
// K8s typically means production or staging
|
|
909
|
+
return {
|
|
910
|
+
environment: 'production',
|
|
911
|
+
source: 'KUBERNETES_SERVICE_HOST',
|
|
912
|
+
confidence: 'medium',
|
|
913
|
+
context,
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
if (process.env.ECS_CONTAINER_METADATA_URI || process.env.AWS_EXECUTION_ENV) {
|
|
917
|
+
context.AWS = process.env.ECS_CONTAINER_METADATA_URI || process.env.AWS_EXECUTION_ENV || '';
|
|
918
|
+
return {
|
|
919
|
+
environment: 'production',
|
|
920
|
+
source: 'AWS_ECS',
|
|
921
|
+
confidence: 'medium',
|
|
922
|
+
context,
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
if (process.env.CLOUD_RUN_JOB || process.env.K_SERVICE) {
|
|
926
|
+
context.GCP = process.env.CLOUD_RUN_JOB || process.env.K_SERVICE || '';
|
|
927
|
+
return {
|
|
928
|
+
environment: 'production',
|
|
929
|
+
source: 'GCP_CLOUD_RUN',
|
|
930
|
+
confidence: 'medium',
|
|
931
|
+
context,
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
// 4. Check for common cloud platform variables
|
|
935
|
+
if (process.env.VERCEL) {
|
|
936
|
+
context.VERCEL = process.env.VERCEL;
|
|
937
|
+
const vercelEnv = process.env.VERCEL_ENV?.toLowerCase();
|
|
938
|
+
if (vercelEnv === 'production') {
|
|
939
|
+
return { environment: 'production', source: 'VERCEL_ENV', confidence: 'high', context };
|
|
940
|
+
}
|
|
941
|
+
if (vercelEnv === 'preview') {
|
|
942
|
+
return { environment: 'staging', source: 'VERCEL_ENV', confidence: 'high', context };
|
|
943
|
+
}
|
|
944
|
+
return { environment: 'development', source: 'VERCEL', confidence: 'medium', context };
|
|
945
|
+
}
|
|
946
|
+
if (process.env.RAILWAY_ENVIRONMENT) {
|
|
947
|
+
context.RAILWAY_ENVIRONMENT = process.env.RAILWAY_ENVIRONMENT;
|
|
948
|
+
const railwayEnv = process.env.RAILWAY_ENVIRONMENT.toLowerCase();
|
|
949
|
+
if (railwayEnv === 'production') {
|
|
950
|
+
return { environment: 'production', source: 'RAILWAY_ENVIRONMENT', confidence: 'high', context };
|
|
951
|
+
}
|
|
952
|
+
return { environment: 'staging', source: 'RAILWAY_ENVIRONMENT', confidence: 'medium', context };
|
|
953
|
+
}
|
|
954
|
+
if (process.env.HEROKU_APP_NAME) {
|
|
955
|
+
context.HEROKU_APP_NAME = process.env.HEROKU_APP_NAME;
|
|
956
|
+
// Heroku typically indicates production deployment
|
|
957
|
+
return {
|
|
958
|
+
environment: 'production',
|
|
959
|
+
source: 'HEROKU',
|
|
960
|
+
confidence: 'medium',
|
|
961
|
+
context,
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
if (process.env.FLY_APP_NAME) {
|
|
965
|
+
context.FLY_APP_NAME = process.env.FLY_APP_NAME;
|
|
966
|
+
return {
|
|
967
|
+
environment: 'production',
|
|
968
|
+
source: 'FLY_IO',
|
|
969
|
+
confidence: 'medium',
|
|
970
|
+
context,
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
// 5. Check for test runners
|
|
974
|
+
if (process.env.JEST_WORKER_ID) {
|
|
975
|
+
context.JEST_WORKER_ID = process.env.JEST_WORKER_ID;
|
|
976
|
+
return {
|
|
977
|
+
environment: 'test',
|
|
978
|
+
source: 'JEST_WORKER_ID',
|
|
979
|
+
confidence: 'high',
|
|
980
|
+
context,
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
if (process.env.VITEST) {
|
|
984
|
+
context.VITEST = process.env.VITEST;
|
|
985
|
+
return {
|
|
986
|
+
environment: 'test',
|
|
987
|
+
source: 'VITEST',
|
|
988
|
+
confidence: 'high',
|
|
989
|
+
context,
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
// 6. Default to development with low confidence
|
|
993
|
+
return {
|
|
994
|
+
environment: 'development',
|
|
995
|
+
source: 'default',
|
|
996
|
+
confidence: 'low',
|
|
997
|
+
context,
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Get a suggested preset based on detected environment.
|
|
1002
|
+
*
|
|
1003
|
+
* @returns Recommended preset name for the detected environment
|
|
1004
|
+
*/
|
|
1005
|
+
function suggestPreset() {
|
|
1006
|
+
const detection = detectEnvironment();
|
|
1007
|
+
switch (detection.environment) {
|
|
1008
|
+
case 'production':
|
|
1009
|
+
return 'strict_enterprise';
|
|
1010
|
+
case 'staging':
|
|
1011
|
+
return 'poc';
|
|
1012
|
+
case 'ci':
|
|
1013
|
+
case 'test':
|
|
1014
|
+
return 'minimal';
|
|
1015
|
+
case 'development':
|
|
1016
|
+
default:
|
|
1017
|
+
return 'development';
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
@@ -1,4 +1,45 @@
|
|
|
1
1
|
import type { MonoraConfig } from './config';
|
|
2
2
|
export declare const LATEST_CONFIG_VERSION = "1.0.0";
|
|
3
3
|
export declare function applyConfigMigrations(config: MonoraConfig): MonoraConfig;
|
|
4
|
+
/**
|
|
5
|
+
* Warning about configuration not being production-ready.
|
|
6
|
+
*/
|
|
7
|
+
export interface ProductionReadinessWarning {
|
|
8
|
+
category: string;
|
|
9
|
+
message: string;
|
|
10
|
+
recommendation: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Validate configuration against production best practices.
|
|
14
|
+
*
|
|
15
|
+
* Returns a list of warnings for settings that may not be appropriate
|
|
16
|
+
* for production use.
|
|
17
|
+
*
|
|
18
|
+
* @param config - The Monora configuration object.
|
|
19
|
+
* @returns List of ProductionReadinessWarning objects.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const warnings = validateProductionReadiness(config);
|
|
24
|
+
* for (const w of warnings) {
|
|
25
|
+
* console.log(`[${w.category}] ${w.message}`);
|
|
26
|
+
* console.log(` Recommendation: ${w.recommendation}`);
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function validateProductionReadiness(config: MonoraConfig): ProductionReadinessWarning[];
|
|
31
|
+
/**
|
|
32
|
+
* Check if a preset is appropriate for the given environment.
|
|
33
|
+
*
|
|
34
|
+
* @param presetName - Name of the preset being used.
|
|
35
|
+
* @param environment - Target environment.
|
|
36
|
+
* @returns Warning if there's a mismatch, null otherwise.
|
|
37
|
+
*/
|
|
38
|
+
export declare function checkPresetEnvironmentMismatch(presetName: string | null | undefined, environment: string): ProductionReadinessWarning | null;
|
|
39
|
+
/**
|
|
40
|
+
* Log production readiness warnings.
|
|
41
|
+
*
|
|
42
|
+
* @param warnings - List of warnings to log.
|
|
43
|
+
*/
|
|
44
|
+
export declare function logProductionWarnings(warnings: ProductionReadinessWarning[]): void;
|
|
4
45
|
//# sourceMappingURL=config_migrations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config_migrations.d.ts","sourceRoot":"","sources":["../src/config_migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG7C,eAAO,MAAM,qBAAqB,UAAU,CAAC;AAG7C,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"config_migrations.d.ts","sourceRoot":"","sources":["../src/config_migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG7C,eAAO,MAAM,qBAAqB,UAAU,CAAC;AAG7C,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CA2BxE;AA+LD;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,YAAY,GAAG,0BAA0B,EAAE,CA6G9F;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACrC,WAAW,EAAE,MAAM,GAClB,0BAA0B,GAAG,IAAI,CA2BnC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,0BAA0B,EAAE,GAAG,IAAI,CAalF"}
|