monora-ai 2.1.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 +333 -159
- 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 +85 -0
- package/dist/assessment.d.ts.map +1 -1
- package/dist/assessment.js +506 -13
- package/dist/attribution.d.ts +44 -3
- package/dist/attribution.d.ts.map +1 -1
- package/dist/attribution.js +197 -10
- package/dist/autodetect.d.ts +68 -0
- package/dist/autodetect.d.ts.map +1 -1
- package/dist/autodetect.js +639 -0
- package/dist/bias.d.ts +130 -0
- package/dist/bias.d.ts.map +1 -0
- package/dist/bias.js +223 -0
- package/dist/cli/diagnostics.d.ts +5 -1
- package/dist/cli/diagnostics.d.ts.map +1 -1
- package/dist/cli/diagnostics.js +23 -6
- 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 +1550 -176
- 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 +261 -16
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +381 -32
- package/dist/config_migrations.d.ts.map +1 -1
- package/dist/config_migrations.js +38 -1
- package/dist/config_schema.d.ts +2490 -1035
- package/dist/config_schema.d.ts.map +1 -1
- package/dist/config_schema.js +233 -64
- 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.map +1 -1
- package/dist/dispatcher.js +17 -5
- 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 +15 -0
- package/dist/executiveSummary.d.ts.map +1 -1
- package/dist/executiveSummary.js +135 -22
- 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 +20 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +247 -5
- package/dist/instrumentation.d.ts +1 -1
- package/dist/instrumentation.d.ts.map +1 -1
- package/dist/instrumentation.js +123 -22
- package/dist/integrations/anthropic.d.ts +3 -0
- package/dist/integrations/anthropic.d.ts.map +1 -1
- package/dist/integrations/anthropic.js +282 -80
- 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 +4 -0
- package/dist/integrations/langchain.d.ts.map +1 -1
- package/dist/integrations/langchain.js +362 -142
- 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 +9 -16
- package/dist/middleware/express.d.ts.map +1 -1
- package/dist/middleware/express.js +18 -3
- package/dist/middleware/nextjs.js +2 -2
- 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/presets.js +7 -7
- 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 +192 -2
- 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 +73 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +415 -18
- 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 +118 -4
- 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.map +1 -1
- package/dist/standards_ingest.js +1 -4
- package/dist/telemetry.d.ts +16 -2
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +77 -14
- package/dist/templates/controls/iso42001_control_catalog.json +1443 -0
- package/dist/traced_emitter.d.ts.map +1 -1
- package/dist/traced_emitter.js +19 -9
- package/dist/trust_package.d.ts +19 -1
- package/dist/trust_package.d.ts.map +1 -1
- package/dist/trust_package.js +89 -2
- 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 +105 -210
- package/templates/controls/iso42001_control_catalog.json +1443 -0
package/dist/assessment.js
CHANGED
|
@@ -56,6 +56,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
56
56
|
exports.runComplianceCheck = runComplianceCheck;
|
|
57
57
|
exports.reportUsageProfile = reportUsageProfile;
|
|
58
58
|
exports.onComplianceCheck = onComplianceCheck;
|
|
59
|
+
exports.generateRemediationPlan = generateRemediationPlan;
|
|
59
60
|
exports.generateAssessmentReport = generateAssessmentReport;
|
|
60
61
|
const fs = __importStar(require("fs"));
|
|
61
62
|
const path = __importStar(require("path"));
|
|
@@ -63,7 +64,7 @@ const attribution_1 = require("./attribution");
|
|
|
63
64
|
const config_1 = require("./config");
|
|
64
65
|
const verify_1 = require("./verify");
|
|
65
66
|
// Get version
|
|
66
|
-
let SDK_VERSION = '1.
|
|
67
|
+
let SDK_VERSION = '2.1.3';
|
|
67
68
|
try {
|
|
68
69
|
const pkgPath = path.join(__dirname, '..', 'package.json');
|
|
69
70
|
if (fs.existsSync(pkgPath)) {
|
|
@@ -509,6 +510,271 @@ function buildFrameworkChecks(config, frameworks) {
|
|
|
509
510
|
addCheck('iso42001_policy_enforcement', 'ISO 42001: policy enforcement is enabled', Boolean(policies.enforce), 'governance', 'Enable policy enforcement for ISO 42001 governance controls');
|
|
510
511
|
addCheck('iso42001_data_handling_enabled', 'ISO 42001: data handling/redaction is enabled', dataHandlingEnabled, 'privacy', 'Enable data_handling to support ISO 42001 risk controls');
|
|
511
512
|
addCheck('iso42001_review_documented', 'ISO 42001: compliance review metadata is documented', reviewDocumented, 'governance', 'Record review_date or reviewer in audit metadata for ISO 42001');
|
|
513
|
+
// A.5.x - Impact Assessment checks
|
|
514
|
+
const impactConfig = (config.impact_assessment || {});
|
|
515
|
+
const impactEnabled = Boolean(impactConfig.enabled);
|
|
516
|
+
addCheck('iso42001_impact_assessment_enabled', 'ISO 42001 A.5: Impact assessment module is enabled', impactEnabled, 'governance', 'Enable impact_assessment in config for ISO 42001 A.5.x compliance');
|
|
517
|
+
// Check for registered impact assessments
|
|
518
|
+
let hasImpactAssessments = false;
|
|
519
|
+
let hasApprovedAssessment = false;
|
|
520
|
+
try {
|
|
521
|
+
const { getRegistry: getImpactRegistry } = require('./impact-assessment');
|
|
522
|
+
const impactRegistry = getImpactRegistry();
|
|
523
|
+
const assessments = impactRegistry.listAssessments();
|
|
524
|
+
hasImpactAssessments = assessments.length > 0;
|
|
525
|
+
hasApprovedAssessment = assessments.some((a) => a.status === 'approved');
|
|
526
|
+
}
|
|
527
|
+
catch {
|
|
528
|
+
// Module not available
|
|
529
|
+
}
|
|
530
|
+
addCheck('iso42001_impact_assessment_registered', 'ISO 42001 A.5.2: At least one impact assessment is registered', hasImpactAssessments, 'governance', 'Create and register an AI impact assessment using createImpactAssessment()');
|
|
531
|
+
addCheck('iso42001_impact_assessment_approved', 'ISO 42001 A.5.3: At least one impact assessment is approved', hasApprovedAssessment, 'governance', 'Complete impact assessment approval workflow using finalizeAssessment()');
|
|
532
|
+
// A.6.x - Lifecycle checks
|
|
533
|
+
const lifecycleConfig = (config.lifecycle || {});
|
|
534
|
+
const lifecycleEnabled = Boolean(lifecycleConfig.enabled);
|
|
535
|
+
addCheck('iso42001_lifecycle_enabled', 'ISO 42001 A.6: Lifecycle management module is enabled', lifecycleEnabled, 'governance', 'Enable lifecycle in config for ISO 42001 A.6.x compliance');
|
|
536
|
+
// Check for registered system records
|
|
537
|
+
let hasSystemRecords = false;
|
|
538
|
+
let hasRequirements = false;
|
|
539
|
+
let hasVerification = false;
|
|
540
|
+
try {
|
|
541
|
+
const { getRegistry: getLifecycleRegistry } = require('./lifecycle');
|
|
542
|
+
const lifecycleRegistry = getLifecycleRegistry();
|
|
543
|
+
const systemRecords = lifecycleRegistry.listRecords();
|
|
544
|
+
hasSystemRecords = systemRecords.length > 0;
|
|
545
|
+
hasRequirements = systemRecords.some((r) => r.requirements && r.requirements.length > 0);
|
|
546
|
+
hasVerification = systemRecords.some((r) => r.verificationResults && r.verificationResults.length > 0);
|
|
547
|
+
}
|
|
548
|
+
catch {
|
|
549
|
+
// Module not available
|
|
550
|
+
}
|
|
551
|
+
addCheck('iso42001_system_record_registered', 'ISO 42001 A.6.1: At least one AI system record is registered', hasSystemRecords, 'governance', 'Create AI system record using createSystemRecord()');
|
|
552
|
+
addCheck('iso42001_requirements_defined', 'ISO 42001 A.6.2.2: System has defined requirements', hasRequirements, 'governance', 'Define system requirements using addRequirement()');
|
|
553
|
+
addCheck('iso42001_verification_recorded', 'ISO 42001 A.6.2.4: Verification results are recorded', hasVerification, 'governance', 'Record verification results using recordVerification()');
|
|
554
|
+
// A.7.x - Data Governance checks
|
|
555
|
+
const dataGovConfig = (config.data_governance || {});
|
|
556
|
+
const dataGovEnabled = Boolean(dataGovConfig.enabled);
|
|
557
|
+
addCheck('iso42001_data_governance_enabled', 'ISO 42001 A.7: Data governance module is enabled', dataGovEnabled, 'privacy', 'Enable data_governance in config for ISO 42001 A.7.x compliance');
|
|
558
|
+
// Check for registered datasets
|
|
559
|
+
let hasDatasets = false;
|
|
560
|
+
let hasQualityMetrics = false;
|
|
561
|
+
let hasBiasAssessment = false;
|
|
562
|
+
try {
|
|
563
|
+
const { getRegistry: getDataGovRegistry } = require('./data-governance');
|
|
564
|
+
const dataRegistry = getDataGovRegistry();
|
|
565
|
+
const datasets = dataRegistry.listRecords();
|
|
566
|
+
hasDatasets = datasets.length > 0;
|
|
567
|
+
hasQualityMetrics = datasets.some((d) => d.qualityMetrics !== undefined);
|
|
568
|
+
hasBiasAssessment = datasets.some((d) => d.biasAssessments && d.biasAssessments.length > 0);
|
|
569
|
+
}
|
|
570
|
+
catch {
|
|
571
|
+
// Module not available
|
|
572
|
+
}
|
|
573
|
+
addCheck('iso42001_dataset_registered', 'ISO 42001 A.7.2: At least one dataset is registered', hasDatasets, 'privacy', 'Register datasets using createDatasetRecord()');
|
|
574
|
+
addCheck('iso42001_data_quality_recorded', 'ISO 42001 A.7.4: Data quality metrics are recorded', hasQualityMetrics, 'privacy', 'Record data quality metrics using recordQualityMetrics()');
|
|
575
|
+
addCheck('iso42001_data_bias_assessed', 'ISO 42001 A.7.6: Dataset bias assessments are recorded', hasBiasAssessment, 'privacy', 'Record bias assessments using recordDatasetBiasAssessment()');
|
|
576
|
+
// A.8.x/A.10.x - Stakeholder checks
|
|
577
|
+
const stakeholdersConfig = (config.stakeholders || {});
|
|
578
|
+
const stakeholdersEnabled = Boolean(stakeholdersConfig.enabled);
|
|
579
|
+
addCheck('iso42001_stakeholders_enabled', 'ISO 42001 A.8/A.10: Stakeholder management module is enabled', stakeholdersEnabled, 'governance', 'Enable stakeholders in config for ISO 42001 A.8/A.10 compliance');
|
|
580
|
+
// Check for registered stakeholders/suppliers
|
|
581
|
+
let hasStakeholders = false;
|
|
582
|
+
let hasSuppliers = false;
|
|
583
|
+
let hasApprovedSuppliers = false;
|
|
584
|
+
try {
|
|
585
|
+
const { getRegistry: getStakeholderRegistry } = require('./stakeholders');
|
|
586
|
+
const stakeholderRegistry = getStakeholderRegistry();
|
|
587
|
+
const stakeholdersList = stakeholderRegistry.listStakeholders();
|
|
588
|
+
const suppliersList = stakeholderRegistry.listSuppliers();
|
|
589
|
+
hasStakeholders = stakeholdersList.length > 0;
|
|
590
|
+
hasSuppliers = suppliersList.length > 0;
|
|
591
|
+
hasApprovedSuppliers = suppliersList.some((s) => s.status === 'approved');
|
|
592
|
+
}
|
|
593
|
+
catch {
|
|
594
|
+
// Module not available
|
|
595
|
+
}
|
|
596
|
+
addCheck('iso42001_stakeholders_registered', 'ISO 42001 A.8.2: Stakeholders are registered', hasStakeholders, 'governance', 'Register stakeholders using registerStakeholder()');
|
|
597
|
+
addCheck('iso42001_suppliers_registered', 'ISO 42001 A.10.3: Suppliers are registered', hasSuppliers, 'governance', 'Register suppliers using registerSupplier()');
|
|
598
|
+
addCheck('iso42001_suppliers_approved', 'ISO 42001 A.10.3: Suppliers are assessed and approved', hasApprovedSuppliers, 'governance', 'Approve suppliers after assessment using updateSupplierStatus()');
|
|
599
|
+
// A.4.x/A.2.4 - Resource Inventory checks
|
|
600
|
+
const resourcesConfig = (config.resources || {});
|
|
601
|
+
const resourcesEnabled = Boolean(resourcesConfig.enabled);
|
|
602
|
+
addCheck('iso42001_resources_enabled', 'ISO 42001 A.4: Resource inventory module is enabled', resourcesEnabled, 'governance', 'Enable resources in config for ISO 42001 A.4.x compliance');
|
|
603
|
+
// Check for resource inventories and policy reviews
|
|
604
|
+
let hasInventories = false;
|
|
605
|
+
let hasTooling = false;
|
|
606
|
+
let hasPolicyReviews = false;
|
|
607
|
+
try {
|
|
608
|
+
const { getRegistry: getResourceRegistry } = require('./resources');
|
|
609
|
+
const resourceRegistry = getResourceRegistry();
|
|
610
|
+
const inventories = resourceRegistry.listInventories();
|
|
611
|
+
const policyReviews = resourceRegistry.listPolicyReviews();
|
|
612
|
+
hasInventories = inventories.length > 0;
|
|
613
|
+
hasTooling = inventories.some((i) => i.toolingResources && i.toolingResources.length > 0);
|
|
614
|
+
hasPolicyReviews = policyReviews.length > 0;
|
|
615
|
+
}
|
|
616
|
+
catch {
|
|
617
|
+
// Module not available
|
|
618
|
+
}
|
|
619
|
+
addCheck('iso42001_resource_inventory_exists', 'ISO 42001 A.4.2: Resource inventory exists', hasInventories, 'governance', 'Create resource inventory using createResourceInventory()');
|
|
620
|
+
addCheck('iso42001_tooling_resources_tracked', 'ISO 42001 A.4.4: Tooling resources are tracked', hasTooling, 'governance', 'Track tooling resources using addToolingResource()');
|
|
621
|
+
addCheck('iso42001_policy_reviews_scheduled', 'ISO 42001 A.2.4: Policy reviews are scheduled', hasPolicyReviews, 'governance', 'Schedule policy reviews using schedulePolicyReview()');
|
|
622
|
+
// ============================================================
|
|
623
|
+
// NEW ISO 42001 CHECKS - Phase 2 Gap Closure (39 checks)
|
|
624
|
+
// ============================================================
|
|
625
|
+
// Query ISO 42001 workflow records for checks
|
|
626
|
+
let workflowTypes = new Set();
|
|
627
|
+
try {
|
|
628
|
+
const { listWorkflowRecords } = require('./iso42001-workflows');
|
|
629
|
+
const workflowRecords = listWorkflowRecords();
|
|
630
|
+
workflowTypes = new Set(workflowRecords.map((r) => r.workflowType));
|
|
631
|
+
}
|
|
632
|
+
catch {
|
|
633
|
+
// Module not available
|
|
634
|
+
}
|
|
635
|
+
// ----------------------------------------------------------
|
|
636
|
+
// A.2 Policy & Governance (4 new checks)
|
|
637
|
+
// ----------------------------------------------------------
|
|
638
|
+
addCheck('iso42001_policy_alignment_recorded', 'ISO 42001 A.2.3: Policy alignment workflow is recorded', workflowTypes.has('policy_alignment'), 'governance', 'Record policy alignment using recordPolicyAlignment()');
|
|
639
|
+
const iso42001Config = (config.iso42001 || {});
|
|
640
|
+
const aimsContext = iso42001Config.aims_context || '';
|
|
641
|
+
addCheck('iso42001_aims_context_established', 'ISO 42001 A.2.2: AIMS context is established', Boolean(aimsContext), 'governance', 'Set iso42001.aims_context in config to document AIMS context');
|
|
642
|
+
const aimsScope = iso42001Config.aims_scope || '';
|
|
643
|
+
addCheck('iso42001_aims_scope_defined', 'ISO 42001 A.2: AIMS scope is defined', Boolean(aimsScope), 'governance', 'Set iso42001.aims_scope in config to define scope');
|
|
644
|
+
// Check for interested parties via stakeholders module
|
|
645
|
+
addCheck('iso42001_interested_parties_identified', 'ISO 42001 A.2: Interested parties are identified', hasStakeholders, 'governance', 'Register stakeholders using registerStakeholder()');
|
|
646
|
+
// ----------------------------------------------------------
|
|
647
|
+
// A.4 Resources (4 new checks)
|
|
648
|
+
// ----------------------------------------------------------
|
|
649
|
+
let hasHumanResources = false;
|
|
650
|
+
let hasComputeResources = false;
|
|
651
|
+
let hasDataResources = false;
|
|
652
|
+
try {
|
|
653
|
+
const { getRegistry: getResRegistry } = require('./resources');
|
|
654
|
+
const resReg = getResRegistry();
|
|
655
|
+
const allInventories = resReg.listInventories();
|
|
656
|
+
hasHumanResources = allInventories.some((i) => i.humanResources && i.humanResources.length > 0);
|
|
657
|
+
hasComputeResources = allInventories.some((i) => i.computeResources && i.computeResources.length > 0);
|
|
658
|
+
hasDataResources = allInventories.some((i) => i.metadata && i.metadata.data_resources);
|
|
659
|
+
}
|
|
660
|
+
catch {
|
|
661
|
+
// Module not available
|
|
662
|
+
}
|
|
663
|
+
addCheck('iso42001_human_resources_tracked', 'ISO 42001 A.4: Human resources are tracked', hasHumanResources, 'governance', 'Track human resources using addHumanResource()');
|
|
664
|
+
addCheck('iso42001_compute_resources_tracked', 'ISO 42001 A.4: Compute resources are tracked', hasComputeResources, 'governance', 'Track compute resources using addComputeResource()');
|
|
665
|
+
addCheck('iso42001_data_resources_tracked', 'ISO 42001 A.4: Data resources are documented', hasDataResources, 'governance', 'Document data resources in resource inventory metadata');
|
|
666
|
+
const hasCompetencyRecords = workflowTypes.has('resource_competency');
|
|
667
|
+
addCheck('iso42001_competency_training_documented', 'ISO 42001 A.4: Competency and training is documented', hasCompetencyRecords, 'governance', 'Record competency requirements using recordResourceCompetency()');
|
|
668
|
+
// ----------------------------------------------------------
|
|
669
|
+
// A.5 Impact Assessment (5 new checks)
|
|
670
|
+
// ----------------------------------------------------------
|
|
671
|
+
let hasCurrentAssessment = false;
|
|
672
|
+
let hasSocietalImpacts = false;
|
|
673
|
+
let hasIndividualImpacts = false;
|
|
674
|
+
let hasMitigations = false;
|
|
675
|
+
let hasRevalidation = false;
|
|
676
|
+
try {
|
|
677
|
+
const { getRegistry: getImpRegistry } = require('./impact-assessment');
|
|
678
|
+
const impReg = getImpRegistry();
|
|
679
|
+
const allAssessments = impReg.listAssessments();
|
|
680
|
+
const now = new Date().toISOString();
|
|
681
|
+
hasCurrentAssessment = allAssessments.some((a) => !a.validUntil || a.validUntil > now);
|
|
682
|
+
hasSocietalImpacts = allAssessments.some((a) => a.impacts && a.impacts.some((i) => i.impactType === 'societal'));
|
|
683
|
+
hasIndividualImpacts = allAssessments.some((a) => a.impacts && a.impacts.some((i) => i.impactType === 'individual'));
|
|
684
|
+
hasMitigations = allAssessments.some((a) => a.impacts && a.impacts.some((i) => i.mitigations && i.mitigations.length > 0));
|
|
685
|
+
hasRevalidation = allAssessments.some((a) => a.revalidationFrequency);
|
|
686
|
+
}
|
|
687
|
+
catch {
|
|
688
|
+
// Module not available
|
|
689
|
+
}
|
|
690
|
+
addCheck('iso42001_impact_assessment_current', 'ISO 42001 A.5.2: Impact assessment is current (not expired)', hasCurrentAssessment, 'governance', 'Ensure impact assessment validUntil is in the future');
|
|
691
|
+
addCheck('iso42001_societal_impacts_assessed', 'ISO 42001 A.5.5: Societal impacts are assessed', hasSocietalImpacts, 'governance', "Add societal impact records using addImpactRecord({impactType: 'societal'})");
|
|
692
|
+
addCheck('iso42001_individual_impacts_assessed', 'ISO 42001 A.5.4: Individual impacts are assessed', hasIndividualImpacts, 'governance', "Add individual impact records using addImpactRecord({impactType: 'individual'})");
|
|
693
|
+
addCheck('iso42001_impact_mitigations_documented', 'ISO 42001 A.5: Impact mitigations are documented', hasMitigations, 'governance', 'Document mitigations using addMitigation() on impact records');
|
|
694
|
+
addCheck('iso42001_impact_revalidation_scheduled', 'ISO 42001 A.5: Impact revalidation frequency is set', hasRevalidation, 'governance', 'Set revalidationFrequency on impact assessments');
|
|
695
|
+
// ----------------------------------------------------------
|
|
696
|
+
// A.6 Lifecycle (8 new checks)
|
|
697
|
+
// ----------------------------------------------------------
|
|
698
|
+
addCheck('iso42001_development_objectives_defined', 'ISO 42001 A.6.1.2: Development objectives are defined', workflowTypes.has('responsible_development_objectives'), 'governance', 'Record objectives using recordResponsibleDevelopmentObjectives()');
|
|
699
|
+
addCheck('iso42001_development_process_defined', 'ISO 42001 A.6.1.3: Development process is defined', workflowTypes.has('responsible_development_process'), 'governance', 'Record process using recordResponsibleDevelopmentProcess()');
|
|
700
|
+
// Check for design documents via lifecycle
|
|
701
|
+
let hasDesignDocs = false;
|
|
702
|
+
let hasValidation = false;
|
|
703
|
+
let hasDeploymentApproval = false;
|
|
704
|
+
let hasMonitoring = false;
|
|
705
|
+
try {
|
|
706
|
+
const { getRegistry: getLcRegistry } = require('./lifecycle');
|
|
707
|
+
const lcReg = getLcRegistry();
|
|
708
|
+
const lcRecords = lcReg.listRecords();
|
|
709
|
+
hasDesignDocs = lcRecords.some((r) => r.metadata && r.metadata.design_documents);
|
|
710
|
+
hasValidation = lcRecords.some((r) => r.validationResults && r.validationResults.length > 0);
|
|
711
|
+
hasDeploymentApproval = lcRecords.some((r) => (r.stage === 'staging' || r.stage === 'production') &&
|
|
712
|
+
r.metadata &&
|
|
713
|
+
r.metadata.deployment_approved);
|
|
714
|
+
hasMonitoring = lcRecords.some((r) => r.metadata && r.metadata.monitoring_configured);
|
|
715
|
+
}
|
|
716
|
+
catch {
|
|
717
|
+
// Module not available
|
|
718
|
+
}
|
|
719
|
+
addCheck('iso42001_design_documents_current', 'ISO 42001 A.6.2.1: Design documents are maintained', hasDesignDocs || workflowTypes.has('requirements_specification'), 'governance', 'Record requirements using recordRequirementsSpecification() or add design_documents to lifecycle metadata');
|
|
720
|
+
addCheck('iso42001_verification_validation_complete', 'ISO 42001 A.6.2.4: Verification and validation is complete', hasValidation || workflowTypes.has('verification_validation'), 'governance', 'Record V&V using recordVerificationValidation() or recordValidation()');
|
|
721
|
+
addCheck('iso42001_deployment_approval_documented', 'ISO 42001 A.6.2.5: Deployment approval is documented', hasDeploymentApproval || workflowTypes.has('deployment_plan'), 'governance', 'Record deployment approval using recordDeploymentPlan() or set deployment_approved in metadata');
|
|
722
|
+
addCheck('iso42001_operations_monitoring_active', 'ISO 42001 A.6.2.6: Operations monitoring is configured', hasMonitoring || workflowTypes.has('operations_monitoring'), 'governance', 'Record monitoring using recordOperationsMonitoring() or set monitoring_configured in metadata');
|
|
723
|
+
addCheck('iso42001_stakeholder_docs_communicated', 'ISO 42001 A.6.2.7: Stakeholder documentation is communicated', workflowTypes.has('stakeholder_documentation'), 'governance', 'Record documentation using recordStakeholderDocumentation()');
|
|
724
|
+
// Check hash chain for event logging integrity
|
|
725
|
+
const immutabilityConfig = (config.immutability || {});
|
|
726
|
+
const hashChainEnabled = Boolean(immutabilityConfig.enabled);
|
|
727
|
+
addCheck('iso42001_event_logging_integrity', 'ISO 42001 A.6.2.8: Event logging integrity controls are enabled', hashChainEnabled || workflowTypes.has('lifecycle_event_logging'), 'integrity', 'Enable immutability.enabled=true or recordLifecycleEventLogging()');
|
|
728
|
+
// ----------------------------------------------------------
|
|
729
|
+
// A.7 Data (5 new checks)
|
|
730
|
+
// ----------------------------------------------------------
|
|
731
|
+
addCheck('iso42001_data_sources_documented', 'ISO 42001 A.7.2: Data sources are documented', workflowTypes.has('data_acquisition'), 'privacy', 'Record data sources using recordDataAcquisition()');
|
|
732
|
+
// Check for consent basis in data governance
|
|
733
|
+
let hasConsentBasis = false;
|
|
734
|
+
let hasQualityDimensions = false;
|
|
735
|
+
let hasProvenance = false;
|
|
736
|
+
let hasPreparation = false;
|
|
737
|
+
try {
|
|
738
|
+
const { getRegistry: getDataReg } = require('./data-governance');
|
|
739
|
+
const dataReg = getDataReg();
|
|
740
|
+
const allDatasets = dataReg.listRecords();
|
|
741
|
+
hasConsentBasis = allDatasets.some((d) => d.metadata && (d.metadata.consent_basis || d.metadata.legal_basis));
|
|
742
|
+
hasQualityDimensions = allDatasets.some((d) => d.qualityMetrics);
|
|
743
|
+
hasProvenance = allDatasets.some((d) => d.provenance);
|
|
744
|
+
hasPreparation = allDatasets.some((d) => d.preparationSteps && d.preparationSteps.length > 0);
|
|
745
|
+
}
|
|
746
|
+
catch {
|
|
747
|
+
// Module not available
|
|
748
|
+
}
|
|
749
|
+
addCheck('iso42001_data_consent_basis_valid', 'ISO 42001 A.7.3: Data consent/legal basis is documented', hasConsentBasis || workflowTypes.has('data_acquisition'), 'privacy', 'Set consent_basis or legal_basis in dataset metadata');
|
|
750
|
+
addCheck('iso42001_data_quality_dimensions', 'ISO 42001 A.7.4: Data quality dimensions are defined', hasQualityDimensions || workflowTypes.has('data_quality'), 'privacy', 'Record quality metrics using recordQualityMetrics() or recordDataQuality()');
|
|
751
|
+
addCheck('iso42001_data_provenance_traceable', 'ISO 42001 A.7.5: Data provenance is traceable', hasProvenance || workflowTypes.has('data_provenance'), 'privacy', 'Record provenance using recordProvenance() or recordDataProvenance()');
|
|
752
|
+
addCheck('iso42001_data_preparation_documented', 'ISO 42001 A.7.6: Data preparation is documented', hasPreparation || workflowTypes.has('data_preparation'), 'privacy', 'Record preparation using recordPreparationStep() or recordDataPreparation()');
|
|
753
|
+
// ----------------------------------------------------------
|
|
754
|
+
// A.8 Transparency (4 new checks)
|
|
755
|
+
// ----------------------------------------------------------
|
|
756
|
+
addCheck('iso42001_transparency_channels', 'ISO 42001 A.8.2: Transparency disclosure channels are established', workflowTypes.has('transparency_disclosure'), 'transparency', 'Record transparency using recordTransparencyDisclosure()');
|
|
757
|
+
addCheck('iso42001_adverse_impact_process', 'ISO 42001 A.8.3: Adverse impact reporting process is defined', workflowTypes.has('adverse_impact_reporting'), 'transparency', 'Record process using recordAdverseImpactReporting()');
|
|
758
|
+
addCheck('iso42001_incident_escalation_defined', 'ISO 42001 A.8.4: Incident escalation plan is defined', workflowTypes.has('incident_communication'), 'transparency', 'Record plan using recordIncidentCommunication()');
|
|
759
|
+
addCheck('iso42001_regulatory_reporting_compliant', 'ISO 42001 A.8.5: Regulatory reporting obligations are tracked', workflowTypes.has('reporting_obligations'), 'transparency', 'Record obligations using recordReportingObligations()');
|
|
760
|
+
// ----------------------------------------------------------
|
|
761
|
+
// A.9 Responsible Use (3 new checks)
|
|
762
|
+
// ----------------------------------------------------------
|
|
763
|
+
addCheck('iso42001_use_process_documented', 'ISO 42001 A.9.2: Responsible use process is documented', workflowTypes.has('responsible_use_process'), 'governance', 'Record process using recordResponsibleUseProcess()');
|
|
764
|
+
addCheck('iso42001_use_objectives_measurable', 'ISO 42001 A.9.3: Responsible use objectives are measurable', workflowTypes.has('responsible_use_objectives'), 'governance', 'Record objectives using recordResponsibleUseObjectives()');
|
|
765
|
+
addCheck('iso42001_intended_use_defined', 'ISO 42001 A.9.4: Intended use statement is defined', workflowTypes.has('intended_use_statement'), 'governance', 'Record statement using recordIntendedUseStatement()');
|
|
766
|
+
// ----------------------------------------------------------
|
|
767
|
+
// A.10 Third-Party (3 new checks)
|
|
768
|
+
// ----------------------------------------------------------
|
|
769
|
+
addCheck('iso42001_responsibility_allocation', 'ISO 42001 A.10.1: Third-party responsibility allocation is clear', workflowTypes.has('third_party_responsibility'), 'governance', 'Record allocation using recordThirdPartyResponsibility()');
|
|
770
|
+
addCheck('iso42001_supplier_assessment_documented', 'ISO 42001 A.10.2: Supplier assessments are documented', workflowTypes.has('supplier_assurance'), 'governance', 'Record assessments using recordSupplierAssurance()');
|
|
771
|
+
addCheck('iso42001_customer_requirements_mapped', 'ISO 42001 A.10.3: Customer requirements are mapped', workflowTypes.has('customer_alignment'), 'governance', 'Record requirements using recordCustomerAlignment()');
|
|
772
|
+
// ----------------------------------------------------------
|
|
773
|
+
// Clause 9-10 Management (3 new checks)
|
|
774
|
+
// ----------------------------------------------------------
|
|
775
|
+
addCheck('iso42001_audit_findings_addressed', 'ISO 42001 Clause 9: Internal audit findings are addressed', workflowTypes.has('internal_audit'), 'governance', 'Record audits using recordInternalAudit()');
|
|
776
|
+
addCheck('iso42001_management_review_complete', 'ISO 42001 Clause 9: Management review is complete', workflowTypes.has('management_review'), 'governance', 'Record reviews using recordManagementReview()');
|
|
777
|
+
addCheck('iso42001_capa_effectiveness_verified', 'ISO 42001 Clause 10: Corrective action effectiveness is verified', workflowTypes.has('corrective_action'), 'governance', 'Record CAPA using recordCorrectiveAction()');
|
|
512
778
|
}
|
|
513
779
|
return { checks, warnings, recommendations };
|
|
514
780
|
}
|
|
@@ -520,10 +786,17 @@ function loadEvents(eventsPath) {
|
|
|
520
786
|
}
|
|
521
787
|
try {
|
|
522
788
|
const content = fs.readFileSync(eventsPath, 'utf8');
|
|
523
|
-
const events =
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
789
|
+
const events = [];
|
|
790
|
+
const lines = content.split('\n').filter((line) => line.trim());
|
|
791
|
+
lines.forEach((line, index) => {
|
|
792
|
+
try {
|
|
793
|
+
events.push(JSON.parse(line));
|
|
794
|
+
}
|
|
795
|
+
catch (err) {
|
|
796
|
+
const snippet = line.length > 120 ? `${line.slice(0, 120)}...` : line;
|
|
797
|
+
errors.push(`Failed to parse events line ${index + 1}: ${err} (${snippet})`);
|
|
798
|
+
}
|
|
799
|
+
});
|
|
527
800
|
return { events, errors };
|
|
528
801
|
}
|
|
529
802
|
catch (e) {
|
|
@@ -677,23 +950,243 @@ function onComplianceCheck(callback) {
|
|
|
677
950
|
};
|
|
678
951
|
}
|
|
679
952
|
/**
|
|
680
|
-
*
|
|
953
|
+
* Category priority weights for remediation ordering.
|
|
954
|
+
*/
|
|
955
|
+
const CATEGORY_PRIORITY = {
|
|
956
|
+
security: 100,
|
|
957
|
+
integrity: 90,
|
|
958
|
+
privacy: 85,
|
|
959
|
+
governance: 70,
|
|
960
|
+
auditability: 60,
|
|
961
|
+
reliability: 50,
|
|
962
|
+
completeness: 40,
|
|
963
|
+
};
|
|
964
|
+
/**
|
|
965
|
+
* Effort estimates based on check name patterns.
|
|
966
|
+
*/
|
|
967
|
+
const EFFORT_ESTIMATES = {
|
|
968
|
+
// Configuration changes - minimal effort
|
|
969
|
+
immutability_enabled: 'minimal',
|
|
970
|
+
verify_on_emit: 'minimal',
|
|
971
|
+
policies_enforce: 'minimal',
|
|
972
|
+
wal_enabled: 'minimal',
|
|
973
|
+
signing_enabled: 'low',
|
|
974
|
+
data_handling_enabled: 'minimal',
|
|
975
|
+
reporting_enabled: 'minimal',
|
|
976
|
+
// Metadata documentation - low effort
|
|
977
|
+
framework_declared: 'low',
|
|
978
|
+
audit_metadata: 'low',
|
|
979
|
+
use_case_documented: 'low',
|
|
980
|
+
review_documented: 'low',
|
|
981
|
+
data_categories_declared: 'low',
|
|
982
|
+
data_classification_set: 'low',
|
|
983
|
+
// Infrastructure changes - medium/high effort
|
|
984
|
+
logging_configured: 'medium',
|
|
985
|
+
incident_alerts: 'medium',
|
|
986
|
+
redaction_rules_configured: 'medium',
|
|
987
|
+
};
|
|
988
|
+
/**
|
|
989
|
+
* Get effort estimate for a check.
|
|
990
|
+
*/
|
|
991
|
+
function getEffortEstimate(checkName) {
|
|
992
|
+
for (const [pattern, effort] of Object.entries(EFFORT_ESTIMATES)) {
|
|
993
|
+
if (checkName.includes(pattern)) {
|
|
994
|
+
return effort;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
return 'medium';
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Determine priority based on category and framework context.
|
|
1001
|
+
*/
|
|
1002
|
+
function determinePriority(category, frameworks, checkName) {
|
|
1003
|
+
const basePriority = CATEGORY_PRIORITY[category] || 50;
|
|
1004
|
+
// Boost priority for certain patterns
|
|
1005
|
+
let priorityScore = basePriority;
|
|
1006
|
+
// Security and integrity issues are always high priority
|
|
1007
|
+
if (category === 'security' || category === 'integrity') {
|
|
1008
|
+
priorityScore += 20;
|
|
1009
|
+
}
|
|
1010
|
+
// Framework-specific boosts
|
|
1011
|
+
if (frameworks.includes('SOC2') && (category === 'auditability' || category === 'integrity')) {
|
|
1012
|
+
priorityScore += 15;
|
|
1013
|
+
}
|
|
1014
|
+
if (frameworks.includes('GDPR') && category === 'privacy') {
|
|
1015
|
+
priorityScore += 20;
|
|
1016
|
+
}
|
|
1017
|
+
if (frameworks.includes('ISO27001') && category === 'security') {
|
|
1018
|
+
priorityScore += 15;
|
|
1019
|
+
}
|
|
1020
|
+
if (frameworks.includes('ISO42001') && category === 'governance') {
|
|
1021
|
+
priorityScore += 15;
|
|
1022
|
+
}
|
|
1023
|
+
// Chain integrity failures are critical
|
|
1024
|
+
if (checkName.includes('chain') && checkName.includes('valid')) {
|
|
1025
|
+
return 'critical';
|
|
1026
|
+
}
|
|
1027
|
+
// Signing for security frameworks
|
|
1028
|
+
if (checkName.includes('signing') && frameworks.includes('ISO27001')) {
|
|
1029
|
+
priorityScore += 10;
|
|
1030
|
+
}
|
|
1031
|
+
if (priorityScore >= 100)
|
|
1032
|
+
return 'critical';
|
|
1033
|
+
if (priorityScore >= 80)
|
|
1034
|
+
return 'high';
|
|
1035
|
+
if (priorityScore >= 50)
|
|
1036
|
+
return 'medium';
|
|
1037
|
+
return 'low';
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Extract framework prefix from check name.
|
|
1041
|
+
*/
|
|
1042
|
+
function extractFrameworkFromCheck(checkName) {
|
|
1043
|
+
const frameworks = [];
|
|
1044
|
+
if (checkName.startsWith('soc2_'))
|
|
1045
|
+
frameworks.push('SOC2');
|
|
1046
|
+
if (checkName.startsWith('gdpr_'))
|
|
1047
|
+
frameworks.push('GDPR');
|
|
1048
|
+
if (checkName.startsWith('iso27001_'))
|
|
1049
|
+
frameworks.push('ISO27001');
|
|
1050
|
+
if (checkName.startsWith('iso42001_'))
|
|
1051
|
+
frameworks.push('ISO42001');
|
|
1052
|
+
return frameworks;
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Generate a remediation plan from compliance check results.
|
|
681
1056
|
*
|
|
682
|
-
* This
|
|
683
|
-
*
|
|
1057
|
+
* This function analyzes failed compliance checks and generates an
|
|
1058
|
+
* actionable remediation plan with prioritized fixes.
|
|
684
1059
|
*
|
|
685
|
-
* @param
|
|
686
|
-
* @returns
|
|
1060
|
+
* @param result - Compliance check result from runComplianceCheck().
|
|
1061
|
+
* @returns RemediationPlan with prioritized fixes.
|
|
687
1062
|
*
|
|
688
1063
|
* @example
|
|
689
1064
|
* ```typescript
|
|
690
|
-
* const
|
|
691
|
-
* eventsPath: './monora_events.jsonl',
|
|
1065
|
+
* const checkResult = await runComplianceCheck({
|
|
692
1066
|
* configPath: './monora.yml',
|
|
693
|
-
*
|
|
1067
|
+
* frameworks: ['SOC2', 'GDPR'],
|
|
694
1068
|
* });
|
|
1069
|
+
*
|
|
1070
|
+
* const plan = generateRemediationPlan(checkResult);
|
|
1071
|
+
*
|
|
1072
|
+
* console.log(`Total issues: ${plan.summary.totalIssues}`);
|
|
1073
|
+
* console.log(`Critical: ${plan.summary.criticalCount}`);
|
|
1074
|
+
*
|
|
1075
|
+
* for (const issue of plan.orderedFixes) {
|
|
1076
|
+
* console.log(`[${issue.priority}] ${issue.title}: ${issue.fix}`);
|
|
1077
|
+
* }
|
|
695
1078
|
* ```
|
|
696
1079
|
*/
|
|
1080
|
+
function generateRemediationPlan(result) {
|
|
1081
|
+
const items = [];
|
|
1082
|
+
const frameworks = result.frameworksAssessed || [];
|
|
1083
|
+
// Process failed checks
|
|
1084
|
+
for (const check of result.checks) {
|
|
1085
|
+
if (check.passed)
|
|
1086
|
+
continue;
|
|
1087
|
+
const checkFrameworks = extractFrameworkFromCheck(check.name);
|
|
1088
|
+
const affectedFrameworks = checkFrameworks.length > 0 ? checkFrameworks : frameworks;
|
|
1089
|
+
// Find matching recommendation
|
|
1090
|
+
const recommendation = result.recommendations.find((rec) => rec.toLowerCase().includes(check.name.replace(/_/g, ' ').toLowerCase()) ||
|
|
1091
|
+
rec.toLowerCase().includes(check.description.toLowerCase().slice(0, 30)));
|
|
1092
|
+
const item = {
|
|
1093
|
+
id: check.name,
|
|
1094
|
+
title: check.description,
|
|
1095
|
+
description: `Compliance check "${check.name}" failed for category: ${check.category}`,
|
|
1096
|
+
category: check.category,
|
|
1097
|
+
priority: determinePriority(check.category, affectedFrameworks, check.name),
|
|
1098
|
+
effort: getEffortEstimate(check.name),
|
|
1099
|
+
fix: recommendation || `Enable or configure ${check.name.replace(/_/g, ' ')} in your monora.yml`,
|
|
1100
|
+
frameworks: affectedFrameworks,
|
|
1101
|
+
};
|
|
1102
|
+
items.push(item);
|
|
1103
|
+
}
|
|
1104
|
+
// Add items from errors (critical issues)
|
|
1105
|
+
for (const error of result.errors) {
|
|
1106
|
+
const item = {
|
|
1107
|
+
id: `error_${items.length}`,
|
|
1108
|
+
title: 'Critical Error',
|
|
1109
|
+
description: error,
|
|
1110
|
+
category: 'integrity',
|
|
1111
|
+
priority: 'critical',
|
|
1112
|
+
effort: 'high',
|
|
1113
|
+
fix: error.includes('chain')
|
|
1114
|
+
? 'Investigate hash chain integrity. Events may have been tampered with or corrupted.'
|
|
1115
|
+
: 'Address the error before proceeding with compliance certification.',
|
|
1116
|
+
frameworks,
|
|
1117
|
+
};
|
|
1118
|
+
items.push(item);
|
|
1119
|
+
}
|
|
1120
|
+
// Group by priority
|
|
1121
|
+
const issuesByPriority = {
|
|
1122
|
+
critical: items.filter((i) => i.priority === 'critical'),
|
|
1123
|
+
high: items.filter((i) => i.priority === 'high'),
|
|
1124
|
+
medium: items.filter((i) => i.priority === 'medium'),
|
|
1125
|
+
low: items.filter((i) => i.priority === 'low'),
|
|
1126
|
+
};
|
|
1127
|
+
// Group by category
|
|
1128
|
+
const issuesByCategory = {};
|
|
1129
|
+
for (const item of items) {
|
|
1130
|
+
if (!issuesByCategory[item.category]) {
|
|
1131
|
+
issuesByCategory[item.category] = [];
|
|
1132
|
+
}
|
|
1133
|
+
issuesByCategory[item.category].push(item);
|
|
1134
|
+
}
|
|
1135
|
+
// Order fixes: critical first, then by category priority, then by effort (easiest first within priority)
|
|
1136
|
+
const effortOrder = {
|
|
1137
|
+
minimal: 0,
|
|
1138
|
+
low: 1,
|
|
1139
|
+
medium: 2,
|
|
1140
|
+
high: 3,
|
|
1141
|
+
};
|
|
1142
|
+
const orderedFixes = [...items].sort((a, b) => {
|
|
1143
|
+
// First by priority
|
|
1144
|
+
const priorityOrder = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
1145
|
+
const priorityDiff = priorityOrder[a.priority] - priorityOrder[b.priority];
|
|
1146
|
+
if (priorityDiff !== 0)
|
|
1147
|
+
return priorityDiff;
|
|
1148
|
+
// Then by category importance
|
|
1149
|
+
const categoryDiff = (CATEGORY_PRIORITY[b.category] || 50) - (CATEGORY_PRIORITY[a.category] || 50);
|
|
1150
|
+
if (categoryDiff !== 0)
|
|
1151
|
+
return categoryDiff;
|
|
1152
|
+
// Finally by effort (easier first)
|
|
1153
|
+
return effortOrder[a.effort] - effortOrder[b.effort];
|
|
1154
|
+
});
|
|
1155
|
+
// Calculate estimated total effort
|
|
1156
|
+
const effortCounts = { minimal: 0, low: 0, medium: 0, high: 0 };
|
|
1157
|
+
for (const item of items) {
|
|
1158
|
+
effortCounts[item.effort]++;
|
|
1159
|
+
}
|
|
1160
|
+
let estimatedEffort = 'None';
|
|
1161
|
+
if (items.length > 0) {
|
|
1162
|
+
if (effortCounts.high > 2 || items.length > 10) {
|
|
1163
|
+
estimatedEffort = 'Significant (multiple sessions)';
|
|
1164
|
+
}
|
|
1165
|
+
else if (effortCounts.high > 0 || effortCounts.medium > 3) {
|
|
1166
|
+
estimatedEffort = 'Moderate (few hours)';
|
|
1167
|
+
}
|
|
1168
|
+
else if (effortCounts.medium > 0 || effortCounts.low > 3) {
|
|
1169
|
+
estimatedEffort = 'Low (under an hour)';
|
|
1170
|
+
}
|
|
1171
|
+
else {
|
|
1172
|
+
estimatedEffort = 'Minimal (quick config changes)';
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
return {
|
|
1176
|
+
summary: {
|
|
1177
|
+
totalIssues: items.length,
|
|
1178
|
+
criticalCount: issuesByPriority.critical.length,
|
|
1179
|
+
highCount: issuesByPriority.high.length,
|
|
1180
|
+
mediumCount: issuesByPriority.medium.length,
|
|
1181
|
+
lowCount: issuesByPriority.low.length,
|
|
1182
|
+
estimatedEffort,
|
|
1183
|
+
},
|
|
1184
|
+
issuesByPriority,
|
|
1185
|
+
issuesByCategory,
|
|
1186
|
+
orderedFixes,
|
|
1187
|
+
generatedAt: new Date().toISOString(),
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
697
1190
|
async function generateAssessmentReport(options = {}) {
|
|
698
1191
|
// Run compliance check
|
|
699
1192
|
const checkResult = await runComplianceCheck({
|
package/dist/attribution.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export interface ProjectRegistration {
|
|
|
30
30
|
company?: string;
|
|
31
31
|
/** Your role (e.g., "ML Engineer", "DevOps", "CTO") */
|
|
32
32
|
role?: string;
|
|
33
|
-
/** Work email for best practices updates (
|
|
33
|
+
/** Work email for best practices updates (included in registration payload when enabled) */
|
|
34
34
|
email?: string;
|
|
35
35
|
/** How you found Monora (npm, pypi, github, blog, referral) */
|
|
36
36
|
source?: string;
|
|
@@ -260,9 +260,9 @@ export declare function configureHttp(config: {
|
|
|
260
260
|
eu?: string;
|
|
261
261
|
};
|
|
262
262
|
apiKeyEnv?: string;
|
|
263
|
-
|
|
263
|
+
timeoutSec?: number;
|
|
264
264
|
retryAttempts?: number;
|
|
265
|
-
|
|
265
|
+
backoffBaseSec?: number;
|
|
266
266
|
}): void;
|
|
267
267
|
/**
|
|
268
268
|
* Send a telemetry event (e.g., startup, shutdown, error).
|
|
@@ -305,4 +305,45 @@ export declare function setAuditMetadata(metadata: AuditMetadata): AuditMetadata
|
|
|
305
305
|
* @returns AuditMetadata object or null.
|
|
306
306
|
*/
|
|
307
307
|
export declare function getAuditMetadata(): AuditMetadata | null;
|
|
308
|
+
/**
|
|
309
|
+
* Check if first-run registration prompt has been shown.
|
|
310
|
+
*
|
|
311
|
+
* @returns True if already prompted, false otherwise.
|
|
312
|
+
*/
|
|
313
|
+
export declare function hasShownFirstRunPrompt(): boolean;
|
|
314
|
+
/**
|
|
315
|
+
* Check if user has registered (either via postinstall or programmatically).
|
|
316
|
+
*
|
|
317
|
+
* @returns True if registered, false otherwise.
|
|
318
|
+
*/
|
|
319
|
+
export declare function hasRegistration(): boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Prompt the user to register their project (interactive, optional).
|
|
322
|
+
*
|
|
323
|
+
* @param options - Optional context about the environment.
|
|
324
|
+
* @returns True if registration was completed, false otherwise.
|
|
325
|
+
*/
|
|
326
|
+
export declare function promptForRegistration(options?: {
|
|
327
|
+
environment?: string;
|
|
328
|
+
force?: boolean;
|
|
329
|
+
silent?: boolean;
|
|
330
|
+
}): Promise<boolean>;
|
|
331
|
+
/**
|
|
332
|
+
* Show first-run registration prompt if needed.
|
|
333
|
+
*
|
|
334
|
+
* This logs a one-time message suggesting the user run `npx monora init`
|
|
335
|
+
* to register their project for best practices updates. The message is
|
|
336
|
+
* only shown once per installation.
|
|
337
|
+
*
|
|
338
|
+
* @param options - Optional context about the environment.
|
|
339
|
+
* @returns True if prompt was shown, false if skipped.
|
|
340
|
+
*/
|
|
341
|
+
export declare function showFirstRunPromptIfNeeded(options?: {
|
|
342
|
+
environment?: string;
|
|
343
|
+
silent?: boolean;
|
|
344
|
+
}): boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Reset the first-run prompt state (for testing).
|
|
347
|
+
*/
|
|
348
|
+
export declare function resetFirstRunPrompt(): void;
|
|
308
349
|
//# sourceMappingURL=attribution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../src/attribution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;
|
|
1
|
+
{"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../src/attribution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAmDH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4FAA4F;IAC5F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IAC1D,mDAAmD;IACnD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,6BAA6B;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB;IAClB,UAAU,EAAE,MAAM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