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
|
@@ -0,0 +1,781 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ISO 42001 Annex A workflow architecture for governance artifacts.
|
|
4
|
+
*
|
|
5
|
+
* Captures non-runtime governance records and auto-links them to controls
|
|
6
|
+
* via attachControlEvidence.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.clearIso42001WorkflowData = clearIso42001WorkflowData;
|
|
43
|
+
exports.recordPolicyAlignment = recordPolicyAlignment;
|
|
44
|
+
exports.recordResourceInventory = recordResourceInventory;
|
|
45
|
+
exports.recordResourceCompetency = recordResourceCompetency;
|
|
46
|
+
exports.recordImpactAssessment = recordImpactAssessment;
|
|
47
|
+
exports.recordResponsibleDevelopmentObjectives = recordResponsibleDevelopmentObjectives;
|
|
48
|
+
exports.recordResponsibleDevelopmentProcess = recordResponsibleDevelopmentProcess;
|
|
49
|
+
exports.recordRequirementsSpecification = recordRequirementsSpecification;
|
|
50
|
+
exports.recordVerificationValidationPlan = recordVerificationValidationPlan;
|
|
51
|
+
exports.recordDeploymentPlan = recordDeploymentPlan;
|
|
52
|
+
exports.recordOperationsMonitoringPlan = recordOperationsMonitoringPlan;
|
|
53
|
+
exports.recordStakeholderTechnicalDocumentation = recordStakeholderTechnicalDocumentation;
|
|
54
|
+
exports.recordLifecycleEventLoggingPolicy = recordLifecycleEventLoggingPolicy;
|
|
55
|
+
exports.recordDataAcquisition = recordDataAcquisition;
|
|
56
|
+
exports.recordDataQualityCriteria = recordDataQualityCriteria;
|
|
57
|
+
exports.recordDataProvenanceProcess = recordDataProvenanceProcess;
|
|
58
|
+
exports.recordDataPreparationCriteria = recordDataPreparationCriteria;
|
|
59
|
+
exports.recordTransparencyDisclosure = recordTransparencyDisclosure;
|
|
60
|
+
exports.recordAdverseImpactReporting = recordAdverseImpactReporting;
|
|
61
|
+
exports.recordIncidentCommunicationPlan = recordIncidentCommunicationPlan;
|
|
62
|
+
exports.recordReportingObligations = recordReportingObligations;
|
|
63
|
+
exports.recordResponsibleUseProcess = recordResponsibleUseProcess;
|
|
64
|
+
exports.recordResponsibleUseObjectives = recordResponsibleUseObjectives;
|
|
65
|
+
exports.recordIntendedUseStatement = recordIntendedUseStatement;
|
|
66
|
+
exports.recordThirdPartyResponsibilityMatrix = recordThirdPartyResponsibilityMatrix;
|
|
67
|
+
exports.recordSupplierAssurance = recordSupplierAssurance;
|
|
68
|
+
exports.recordCustomerExpectationAlignment = recordCustomerExpectationAlignment;
|
|
69
|
+
exports.recordInternalAuditReport = recordInternalAuditReport;
|
|
70
|
+
exports.recordManagementReviewMinutes = recordManagementReviewMinutes;
|
|
71
|
+
exports.recordCorrectiveActionLog = recordCorrectiveActionLog;
|
|
72
|
+
exports.getIso42001WorkflowRecord = getIso42001WorkflowRecord;
|
|
73
|
+
exports.listIso42001WorkflowRecords = listIso42001WorkflowRecords;
|
|
74
|
+
exports.getIso42001WorkflowSummary = getIso42001WorkflowSummary;
|
|
75
|
+
exports.exportIso42001WorkflowState = exportIso42001WorkflowState;
|
|
76
|
+
exports.loadIso42001WorkflowState = loadIso42001WorkflowState;
|
|
77
|
+
const crypto = __importStar(require("crypto"));
|
|
78
|
+
const fs = __importStar(require("fs"));
|
|
79
|
+
const control_backbone_1 = require("./control_backbone");
|
|
80
|
+
const records = new Map();
|
|
81
|
+
function utcNow() {
|
|
82
|
+
return new Date().toISOString();
|
|
83
|
+
}
|
|
84
|
+
function clone(value) {
|
|
85
|
+
return JSON.parse(JSON.stringify(value));
|
|
86
|
+
}
|
|
87
|
+
function normalizeList(value) {
|
|
88
|
+
if (value === null || value === undefined) {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
if (Array.isArray(value)) {
|
|
92
|
+
return value
|
|
93
|
+
.map((item) => String(item).trim())
|
|
94
|
+
.filter(Boolean);
|
|
95
|
+
}
|
|
96
|
+
return String(value)
|
|
97
|
+
.replace(/;/g, ',')
|
|
98
|
+
.split(',')
|
|
99
|
+
.map((item) => item.trim())
|
|
100
|
+
.filter(Boolean);
|
|
101
|
+
}
|
|
102
|
+
function buildId(prefix, ...parts) {
|
|
103
|
+
const seed = `${prefix}:${parts.join(':')}:${utcNow()}`;
|
|
104
|
+
const digest = crypto.createHash('sha256').update(seed).digest('hex').slice(0, 12);
|
|
105
|
+
return `${prefix}_${digest}`;
|
|
106
|
+
}
|
|
107
|
+
function primaryEvidenceType(evidenceTypes) {
|
|
108
|
+
for (const item of evidenceTypes) {
|
|
109
|
+
if (item !== 'documented_information') {
|
|
110
|
+
return item;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return evidenceTypes[0] || 'documented_information';
|
|
114
|
+
}
|
|
115
|
+
function emitIsoEvidence(record) {
|
|
116
|
+
const evidenceTypes = Array.from(new Set(normalizeList(record.evidence_types).concat(['documented_information']))).sort();
|
|
117
|
+
const primaryType = primaryEvidenceType(evidenceTypes);
|
|
118
|
+
const evidence = {
|
|
119
|
+
evidence_id: buildId('evd', record.workflow_type, record.title),
|
|
120
|
+
title: record.title,
|
|
121
|
+
source: 'iso42001_workflows',
|
|
122
|
+
category: record.workflow_type,
|
|
123
|
+
collected_at: utcNow(),
|
|
124
|
+
collection_method: 'workflow',
|
|
125
|
+
system: 'iso42001_workflows',
|
|
126
|
+
system_id: record.record_id,
|
|
127
|
+
control_ids: record.control_ids,
|
|
128
|
+
status: record.status === 'approved' ? 'approved' : 'collected',
|
|
129
|
+
metadata: {
|
|
130
|
+
record_id: record.record_id,
|
|
131
|
+
workflow_type: record.workflow_type,
|
|
132
|
+
owner: record.owner,
|
|
133
|
+
status: record.status,
|
|
134
|
+
version: record.version,
|
|
135
|
+
evidence_type: primaryType,
|
|
136
|
+
evidence_types: evidenceTypes,
|
|
137
|
+
metadata: record.metadata,
|
|
138
|
+
},
|
|
139
|
+
tags: Array.from(new Set(record.tags.concat(['iso42001', record.workflow_type]))).sort(),
|
|
140
|
+
};
|
|
141
|
+
let updated = clone(evidence);
|
|
142
|
+
for (const controlId of Array.from(new Set(normalizeList(record.control_ids))).sort()) {
|
|
143
|
+
updated = (0, control_backbone_1.attachControlEvidence)({
|
|
144
|
+
controlId,
|
|
145
|
+
evidence: updated,
|
|
146
|
+
evidenceType: primaryType,
|
|
147
|
+
note: 'iso42001_workflow_auto_attach',
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return updated;
|
|
151
|
+
}
|
|
152
|
+
function upsertRecord(options) {
|
|
153
|
+
const rid = options.recordId || buildId(options.workflowType, options.title, options.owner);
|
|
154
|
+
const existing = records.get(rid);
|
|
155
|
+
const now = utcNow();
|
|
156
|
+
const cadence = options.reviewFrequencyDays ? Math.max(1, options.reviewFrequencyDays) : undefined;
|
|
157
|
+
const nextDue = cadence ? new Date(Date.now() + cadence * 86400 * 1000).toISOString() : undefined;
|
|
158
|
+
const record = {
|
|
159
|
+
record_id: rid,
|
|
160
|
+
workflow_type: options.workflowType,
|
|
161
|
+
title: options.title,
|
|
162
|
+
owner: options.owner,
|
|
163
|
+
status: options.status || 'approved',
|
|
164
|
+
version: (existing?.version || 0) + 1,
|
|
165
|
+
control_ids: Array.from(new Set(normalizeList(options.controlIds))).sort(),
|
|
166
|
+
evidence_types: Array.from(new Set(normalizeList(options.evidenceTypes))).sort(),
|
|
167
|
+
created_at: existing?.created_at || now,
|
|
168
|
+
updated_at: now,
|
|
169
|
+
review_frequency_days: cadence,
|
|
170
|
+
next_review_due_at: nextDue,
|
|
171
|
+
metadata: options.metadata ? clone(options.metadata) : {},
|
|
172
|
+
tags: Array.from(new Set(normalizeList(options.tags))).sort(),
|
|
173
|
+
};
|
|
174
|
+
records.set(record.record_id, clone(record));
|
|
175
|
+
emitIsoEvidence(record);
|
|
176
|
+
return clone(record);
|
|
177
|
+
}
|
|
178
|
+
function clearIso42001WorkflowData() {
|
|
179
|
+
records.clear();
|
|
180
|
+
}
|
|
181
|
+
// A.2
|
|
182
|
+
function recordPolicyAlignment(options) {
|
|
183
|
+
return upsertRecord({
|
|
184
|
+
workflowType: 'policy_alignment',
|
|
185
|
+
title: options.title,
|
|
186
|
+
owner: options.owner,
|
|
187
|
+
controlIds: ['A.2.3', 'Clause5'],
|
|
188
|
+
evidenceTypes: ['documented_information', 'policy_document', 'leadership_commitment_records'],
|
|
189
|
+
metadata: {
|
|
190
|
+
...(options.metadata || {}),
|
|
191
|
+
aligned_policies: Array.from(new Set(normalizeList(options.alignedPolicies))).sort(),
|
|
192
|
+
rationale: options.rationale,
|
|
193
|
+
},
|
|
194
|
+
tags: ['policy', 'alignment'],
|
|
195
|
+
reviewFrequencyDays: options.reviewFrequencyDays || 365,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
// A.4
|
|
199
|
+
function recordResourceInventory(options) {
|
|
200
|
+
return upsertRecord({
|
|
201
|
+
workflowType: 'resource_inventory',
|
|
202
|
+
title: options.title,
|
|
203
|
+
owner: options.owner,
|
|
204
|
+
controlIds: ['A.4.2', 'A.4.3', 'A.4.4', 'A.4.5'],
|
|
205
|
+
evidenceTypes: [
|
|
206
|
+
'documented_information',
|
|
207
|
+
'resource_inventory',
|
|
208
|
+
'data_governance_records',
|
|
209
|
+
'identity_and_mfa_report',
|
|
210
|
+
'repository_configuration_export',
|
|
211
|
+
'workflow_configuration_export',
|
|
212
|
+
'iam_policy_snapshot',
|
|
213
|
+
],
|
|
214
|
+
metadata: {
|
|
215
|
+
...(options.metadata || {}),
|
|
216
|
+
data_resources: Array.from(new Set(normalizeList(options.dataResources))).sort(),
|
|
217
|
+
tooling_resources: Array.from(new Set(normalizeList(options.toolingResources))).sort(),
|
|
218
|
+
compute_resources: Array.from(new Set(normalizeList(options.computeResources))).sort(),
|
|
219
|
+
human_resources: Array.from(new Set(normalizeList(options.humanResources))).sort(),
|
|
220
|
+
},
|
|
221
|
+
tags: ['resources', 'inventory'],
|
|
222
|
+
reviewFrequencyDays: options.reviewFrequencyDays || 90,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function recordResourceCompetency(options) {
|
|
226
|
+
return upsertRecord({
|
|
227
|
+
workflowType: 'resource_competency',
|
|
228
|
+
title: options.title,
|
|
229
|
+
owner: options.owner,
|
|
230
|
+
controlIds: ['A.4.6', 'Clause7'],
|
|
231
|
+
evidenceTypes: ['documented_information', 'identity_and_mfa_report', 'training_and_competency_records'],
|
|
232
|
+
metadata: {
|
|
233
|
+
...(options.metadata || {}),
|
|
234
|
+
roles: Array.from(new Set(normalizeList(options.roles))).sort(),
|
|
235
|
+
required_competencies: Array.from(new Set(normalizeList(options.requiredCompetencies))).sort(),
|
|
236
|
+
training_plan: Array.from(new Set(normalizeList(options.trainingPlan))).sort(),
|
|
237
|
+
},
|
|
238
|
+
tags: ['resources', 'competency'],
|
|
239
|
+
reviewFrequencyDays: options.reviewFrequencyDays || 180,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
// A.5
|
|
243
|
+
function recordImpactAssessment(options) {
|
|
244
|
+
return upsertRecord({
|
|
245
|
+
workflowType: 'impact_assessment',
|
|
246
|
+
title: options.title,
|
|
247
|
+
owner: options.owner,
|
|
248
|
+
controlIds: ['A.5.2', 'A.5.3', 'A.5.4', 'A.5.5', 'Clause6'],
|
|
249
|
+
evidenceTypes: ['documented_information', 'impact_assessment_report', 'risk_signal_report'],
|
|
250
|
+
metadata: {
|
|
251
|
+
...(options.metadata || {}),
|
|
252
|
+
system_id: options.systemId,
|
|
253
|
+
methodology: options.methodology,
|
|
254
|
+
individual_impacts: Array.from(new Set(normalizeList(options.individualImpacts))).sort(),
|
|
255
|
+
societal_impacts: Array.from(new Set(normalizeList(options.societalImpacts))).sort(),
|
|
256
|
+
mitigations: Array.from(new Set(normalizeList(options.mitigations))).sort(),
|
|
257
|
+
approved_by: options.approvedBy,
|
|
258
|
+
assessed_at: utcNow(),
|
|
259
|
+
},
|
|
260
|
+
tags: ['impact', 'risk'],
|
|
261
|
+
reviewFrequencyDays: options.reviewFrequencyDays || 90,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
// A.6
|
|
265
|
+
function recordResponsibleDevelopmentObjectives(options) {
|
|
266
|
+
return upsertRecord({
|
|
267
|
+
workflowType: 'responsible_development_objectives',
|
|
268
|
+
title: options.title,
|
|
269
|
+
owner: options.owner,
|
|
270
|
+
controlIds: ['A.6.1.2'],
|
|
271
|
+
evidenceTypes: ['documented_information', 'objectives_register'],
|
|
272
|
+
metadata: {
|
|
273
|
+
...(options.metadata || {}),
|
|
274
|
+
objectives: Array.from(new Set(normalizeList(options.objectives))).sort(),
|
|
275
|
+
linked_risks: Array.from(new Set(normalizeList(options.linkedRisks))).sort(),
|
|
276
|
+
},
|
|
277
|
+
tags: ['lifecycle', 'objectives'],
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
function recordResponsibleDevelopmentProcess(options) {
|
|
281
|
+
return upsertRecord({
|
|
282
|
+
workflowType: 'responsible_development_process',
|
|
283
|
+
title: options.title,
|
|
284
|
+
owner: options.owner,
|
|
285
|
+
controlIds: ['A.6.1.3'],
|
|
286
|
+
evidenceTypes: ['documented_information', 'sdlc_control_evidence'],
|
|
287
|
+
metadata: {
|
|
288
|
+
...(options.metadata || {}),
|
|
289
|
+
process_steps: Array.from(new Set(normalizeList(options.processSteps))).sort(),
|
|
290
|
+
gate_criteria: Array.from(new Set(normalizeList(options.gateCriteria))).sort(),
|
|
291
|
+
},
|
|
292
|
+
tags: ['lifecycle', 'sdlc'],
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
function recordRequirementsSpecification(options) {
|
|
296
|
+
return upsertRecord({
|
|
297
|
+
workflowType: 'requirements_specification',
|
|
298
|
+
title: options.title,
|
|
299
|
+
owner: options.owner,
|
|
300
|
+
controlIds: ['A.6.2.2'],
|
|
301
|
+
evidenceTypes: ['documented_information', 'requirements_specification', 'stakeholder_documentation'],
|
|
302
|
+
metadata: {
|
|
303
|
+
...(options.metadata || {}),
|
|
304
|
+
system_id: options.systemId,
|
|
305
|
+
requirements: Array.from(new Set(normalizeList(options.requirements))).sort(),
|
|
306
|
+
stakeholder_groups: Array.from(new Set(normalizeList(options.stakeholderGroups))).sort(),
|
|
307
|
+
},
|
|
308
|
+
tags: ['lifecycle', 'requirements'],
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
function recordVerificationValidationPlan(options) {
|
|
312
|
+
return upsertRecord({
|
|
313
|
+
workflowType: 'verification_validation',
|
|
314
|
+
title: options.title,
|
|
315
|
+
owner: options.owner,
|
|
316
|
+
controlIds: ['A.6.2.4'],
|
|
317
|
+
evidenceTypes: ['documented_information', 'policy_configuration', 'verification_validation_evidence'],
|
|
318
|
+
metadata: {
|
|
319
|
+
...(options.metadata || {}),
|
|
320
|
+
criteria: Array.from(new Set(normalizeList(options.criteria))).sort(),
|
|
321
|
+
test_evidence_refs: Array.from(new Set(normalizeList(options.testEvidenceRefs))).sort(),
|
|
322
|
+
pass_fail_threshold: options.passFailThreshold,
|
|
323
|
+
},
|
|
324
|
+
tags: ['lifecycle', 'verification', 'validation'],
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
function recordDeploymentPlan(options) {
|
|
328
|
+
return upsertRecord({
|
|
329
|
+
workflowType: 'deployment_plan',
|
|
330
|
+
title: options.title,
|
|
331
|
+
owner: options.owner,
|
|
332
|
+
controlIds: ['A.6.2.5'],
|
|
333
|
+
evidenceTypes: ['documented_information', 'deployment_approval_records'],
|
|
334
|
+
metadata: {
|
|
335
|
+
...(options.metadata || {}),
|
|
336
|
+
release_scope: options.releaseScope,
|
|
337
|
+
rollback_plan: options.rollbackPlan,
|
|
338
|
+
approvers: Array.from(new Set(normalizeList(options.approvers))).sort(),
|
|
339
|
+
},
|
|
340
|
+
tags: ['lifecycle', 'deployment'],
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
function recordOperationsMonitoringPlan(options) {
|
|
344
|
+
return upsertRecord({
|
|
345
|
+
workflowType: 'operations_monitoring',
|
|
346
|
+
title: options.title,
|
|
347
|
+
owner: options.owner,
|
|
348
|
+
controlIds: ['A.6.2.6', 'Clause8'],
|
|
349
|
+
evidenceTypes: [
|
|
350
|
+
'documented_information',
|
|
351
|
+
'event_logs',
|
|
352
|
+
'telemetry_metrics',
|
|
353
|
+
'operational_runbook',
|
|
354
|
+
'runtime_observability_report',
|
|
355
|
+
'standard_operating_procedure',
|
|
356
|
+
],
|
|
357
|
+
metadata: {
|
|
358
|
+
...(options.metadata || {}),
|
|
359
|
+
monitoring_signals: Array.from(new Set(normalizeList(options.monitoringSignals))).sort(),
|
|
360
|
+
maintenance_tasks: Array.from(new Set(normalizeList(options.maintenanceTasks))).sort(),
|
|
361
|
+
incident_response_refs: Array.from(new Set(normalizeList(options.incidentResponseRefs))).sort(),
|
|
362
|
+
},
|
|
363
|
+
tags: ['lifecycle', 'operations', 'monitoring'],
|
|
364
|
+
reviewFrequencyDays: options.reviewFrequencyDays || 30,
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
function recordStakeholderTechnicalDocumentation(options) {
|
|
368
|
+
return upsertRecord({
|
|
369
|
+
workflowType: 'stakeholder_documentation',
|
|
370
|
+
title: options.title,
|
|
371
|
+
owner: options.owner,
|
|
372
|
+
controlIds: ['A.6.2.7'],
|
|
373
|
+
evidenceTypes: ['documented_information', 'stakeholder_documentation'],
|
|
374
|
+
metadata: {
|
|
375
|
+
...(options.metadata || {}),
|
|
376
|
+
audience: Array.from(new Set(normalizeList(options.audience))).sort(),
|
|
377
|
+
document_refs: Array.from(new Set(normalizeList(options.documentRefs))).sort(),
|
|
378
|
+
},
|
|
379
|
+
tags: ['lifecycle', 'documentation'],
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
function recordLifecycleEventLoggingPolicy(options) {
|
|
383
|
+
return upsertRecord({
|
|
384
|
+
workflowType: 'lifecycle_event_logging',
|
|
385
|
+
title: options.title,
|
|
386
|
+
owner: options.owner,
|
|
387
|
+
controlIds: ['A.6.2.8', 'Clause8'],
|
|
388
|
+
evidenceTypes: [
|
|
389
|
+
'documented_information',
|
|
390
|
+
'event_logs',
|
|
391
|
+
'hash_chain_proof',
|
|
392
|
+
'continuous_evidence',
|
|
393
|
+
'runtime_observability_report',
|
|
394
|
+
'operational_runbook',
|
|
395
|
+
'standard_operating_procedure',
|
|
396
|
+
],
|
|
397
|
+
metadata: {
|
|
398
|
+
...(options.metadata || {}),
|
|
399
|
+
log_scope: Array.from(new Set(normalizeList(options.logScope))).sort(),
|
|
400
|
+
retention_days: options.retentionDays,
|
|
401
|
+
integrity_controls: Array.from(new Set(normalizeList(options.integrityControls))).sort(),
|
|
402
|
+
},
|
|
403
|
+
tags: ['lifecycle', 'event_logging'],
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
// A.7
|
|
407
|
+
function recordDataAcquisition(options) {
|
|
408
|
+
return upsertRecord({
|
|
409
|
+
workflowType: 'data_acquisition',
|
|
410
|
+
title: options.title,
|
|
411
|
+
owner: options.owner,
|
|
412
|
+
controlIds: ['A.7.2', 'A.7.3', 'A.4.2', 'A.4.3'],
|
|
413
|
+
evidenceTypes: [
|
|
414
|
+
'documented_information',
|
|
415
|
+
'data_governance_records',
|
|
416
|
+
'data_source_and_consent_log',
|
|
417
|
+
'resource_inventory',
|
|
418
|
+
],
|
|
419
|
+
metadata: {
|
|
420
|
+
...(options.metadata || {}),
|
|
421
|
+
data_sources: Array.from(new Set(normalizeList(options.dataSources))).sort(),
|
|
422
|
+
consent_basis: Array.from(new Set(normalizeList(options.consentBasis))).sort(),
|
|
423
|
+
owners: Array.from(new Set(normalizeList(options.owners))).sort(),
|
|
424
|
+
},
|
|
425
|
+
tags: ['data', 'acquisition'],
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
function recordDataQualityCriteria(options) {
|
|
429
|
+
return upsertRecord({
|
|
430
|
+
workflowType: 'data_quality',
|
|
431
|
+
title: options.title,
|
|
432
|
+
owner: options.owner,
|
|
433
|
+
controlIds: ['A.7.4'],
|
|
434
|
+
evidenceTypes: ['documented_information', 'data_governance_records', 'data_quality_report'],
|
|
435
|
+
metadata: {
|
|
436
|
+
...(options.metadata || {}),
|
|
437
|
+
quality_dimensions: Array.from(new Set(normalizeList(options.qualityDimensions))).sort(),
|
|
438
|
+
thresholds: options.thresholds,
|
|
439
|
+
validation_schedule: options.validationSchedule,
|
|
440
|
+
},
|
|
441
|
+
tags: ['data', 'quality'],
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
function recordDataProvenanceProcess(options) {
|
|
445
|
+
return upsertRecord({
|
|
446
|
+
workflowType: 'data_provenance',
|
|
447
|
+
title: options.title,
|
|
448
|
+
owner: options.owner,
|
|
449
|
+
controlIds: ['A.7.5'],
|
|
450
|
+
evidenceTypes: ['documented_information', 'data_lineage_records'],
|
|
451
|
+
metadata: {
|
|
452
|
+
...(options.metadata || {}),
|
|
453
|
+
lineage_method: options.lineageMethod,
|
|
454
|
+
systems: Array.from(new Set(normalizeList(options.systems))).sort(),
|
|
455
|
+
},
|
|
456
|
+
tags: ['data', 'provenance', 'lineage'],
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
function recordDataPreparationCriteria(options) {
|
|
460
|
+
return upsertRecord({
|
|
461
|
+
workflowType: 'data_preparation',
|
|
462
|
+
title: options.title,
|
|
463
|
+
owner: options.owner,
|
|
464
|
+
controlIds: ['A.7.6'],
|
|
465
|
+
evidenceTypes: [
|
|
466
|
+
'documented_information',
|
|
467
|
+
'operational_runbook',
|
|
468
|
+
'data_governance_records',
|
|
469
|
+
'standard_operating_procedure',
|
|
470
|
+
],
|
|
471
|
+
metadata: {
|
|
472
|
+
...(options.metadata || {}),
|
|
473
|
+
preparation_steps: Array.from(new Set(normalizeList(options.preparationSteps))).sort(),
|
|
474
|
+
acceptance_criteria: Array.from(new Set(normalizeList(options.acceptanceCriteria))).sort(),
|
|
475
|
+
},
|
|
476
|
+
tags: ['data', 'preparation'],
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
// A.8
|
|
480
|
+
function recordTransparencyDisclosure(options) {
|
|
481
|
+
return upsertRecord({
|
|
482
|
+
workflowType: 'transparency_disclosure',
|
|
483
|
+
title: options.title,
|
|
484
|
+
owner: options.owner,
|
|
485
|
+
controlIds: ['A.8.2'],
|
|
486
|
+
evidenceTypes: ['documented_information', 'user_disclosure_artifacts'],
|
|
487
|
+
metadata: {
|
|
488
|
+
...(options.metadata || {}),
|
|
489
|
+
channels: Array.from(new Set(normalizeList(options.channels))).sort(),
|
|
490
|
+
disclosure_scope: options.disclosureScope,
|
|
491
|
+
},
|
|
492
|
+
tags: ['transparency', 'disclosure'],
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
function recordAdverseImpactReporting(options) {
|
|
496
|
+
return upsertRecord({
|
|
497
|
+
workflowType: 'adverse_impact_reporting',
|
|
498
|
+
title: options.title,
|
|
499
|
+
owner: options.owner,
|
|
500
|
+
controlIds: ['A.8.3'],
|
|
501
|
+
evidenceTypes: ['documented_information', 'concern_reporting_records'],
|
|
502
|
+
metadata: {
|
|
503
|
+
...(options.metadata || {}),
|
|
504
|
+
channels: Array.from(new Set(normalizeList(options.channels))).sort(),
|
|
505
|
+
triage_sla: options.triageSla,
|
|
506
|
+
},
|
|
507
|
+
tags: ['transparency', 'adverse_impact'],
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
function recordIncidentCommunicationPlan(options) {
|
|
511
|
+
return upsertRecord({
|
|
512
|
+
workflowType: 'incident_communication',
|
|
513
|
+
title: options.title,
|
|
514
|
+
owner: options.owner,
|
|
515
|
+
controlIds: ['A.8.4'],
|
|
516
|
+
evidenceTypes: ['documented_information', 'incident_communication_plan'],
|
|
517
|
+
metadata: {
|
|
518
|
+
...(options.metadata || {}),
|
|
519
|
+
communication_matrix: Array.from(new Set(normalizeList(options.communicationMatrix))).sort(),
|
|
520
|
+
escalation_contacts: Array.from(new Set(normalizeList(options.escalationContacts))).sort(),
|
|
521
|
+
},
|
|
522
|
+
tags: ['transparency', 'incident'],
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
function recordReportingObligations(options) {
|
|
526
|
+
return upsertRecord({
|
|
527
|
+
workflowType: 'reporting_obligations',
|
|
528
|
+
title: options.title,
|
|
529
|
+
owner: options.owner,
|
|
530
|
+
controlIds: ['A.8.5'],
|
|
531
|
+
evidenceTypes: ['documented_information', 'regulatory_reporting_matrix'],
|
|
532
|
+
metadata: {
|
|
533
|
+
...(options.metadata || {}),
|
|
534
|
+
obligations: Array.from(new Set(normalizeList(options.obligations))).sort(),
|
|
535
|
+
recipients: Array.from(new Set(normalizeList(options.recipients))).sort(),
|
|
536
|
+
},
|
|
537
|
+
tags: ['transparency', 'reporting'],
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
// A.9
|
|
541
|
+
function recordResponsibleUseProcess(options) {
|
|
542
|
+
return upsertRecord({
|
|
543
|
+
workflowType: 'responsible_use_process',
|
|
544
|
+
title: options.title,
|
|
545
|
+
owner: options.owner,
|
|
546
|
+
controlIds: ['A.9.2'],
|
|
547
|
+
evidenceTypes: ['documented_information', 'operational_runbook', 'standard_operating_procedure'],
|
|
548
|
+
metadata: {
|
|
549
|
+
...(options.metadata || {}),
|
|
550
|
+
process_steps: Array.from(new Set(normalizeList(options.processSteps))).sort(),
|
|
551
|
+
enforcement_controls: Array.from(new Set(normalizeList(options.enforcementControls))).sort(),
|
|
552
|
+
},
|
|
553
|
+
tags: ['responsible_use', 'process'],
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
function recordResponsibleUseObjectives(options) {
|
|
557
|
+
return upsertRecord({
|
|
558
|
+
workflowType: 'responsible_use_objectives',
|
|
559
|
+
title: options.title,
|
|
560
|
+
owner: options.owner,
|
|
561
|
+
controlIds: ['A.9.3'],
|
|
562
|
+
evidenceTypes: ['documented_information', 'objectives_register'],
|
|
563
|
+
metadata: {
|
|
564
|
+
...(options.metadata || {}),
|
|
565
|
+
objectives: Array.from(new Set(normalizeList(options.objectives))).sort(),
|
|
566
|
+
metrics: Array.from(new Set(normalizeList(options.metrics))).sort(),
|
|
567
|
+
},
|
|
568
|
+
tags: ['responsible_use', 'objectives'],
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
function recordIntendedUseStatement(options) {
|
|
572
|
+
return upsertRecord({
|
|
573
|
+
workflowType: 'intended_use_statement',
|
|
574
|
+
title: options.title,
|
|
575
|
+
owner: options.owner,
|
|
576
|
+
controlIds: ['A.9.4'],
|
|
577
|
+
evidenceTypes: ['documented_information', 'policy_configuration', 'intended_use_statement'],
|
|
578
|
+
metadata: {
|
|
579
|
+
...(options.metadata || {}),
|
|
580
|
+
intended_uses: Array.from(new Set(normalizeList(options.intendedUses))).sort(),
|
|
581
|
+
prohibited_uses: Array.from(new Set(normalizeList(options.prohibitedUses))).sort(),
|
|
582
|
+
enforcement_hooks: Array.from(new Set(normalizeList(options.enforcementHooks))).sort(),
|
|
583
|
+
},
|
|
584
|
+
tags: ['responsible_use', 'intended_use'],
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
// A.10
|
|
588
|
+
function recordThirdPartyResponsibilityMatrix(options) {
|
|
589
|
+
return upsertRecord({
|
|
590
|
+
workflowType: 'third_party_responsibility',
|
|
591
|
+
title: options.title,
|
|
592
|
+
owner: options.owner,
|
|
593
|
+
controlIds: ['A.10.1'],
|
|
594
|
+
evidenceTypes: ['documented_information'],
|
|
595
|
+
metadata: {
|
|
596
|
+
...(options.metadata || {}),
|
|
597
|
+
responsibility_allocations: Array.from(new Set(normalizeList(options.responsibilityAllocations))).sort(),
|
|
598
|
+
},
|
|
599
|
+
tags: ['third_party', 'responsibility'],
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
function recordSupplierAssurance(options) {
|
|
603
|
+
return upsertRecord({
|
|
604
|
+
workflowType: 'supplier_assurance',
|
|
605
|
+
title: options.title,
|
|
606
|
+
owner: options.owner,
|
|
607
|
+
controlIds: ['A.10.2'],
|
|
608
|
+
evidenceTypes: ['documented_information', 'vendor_assessment_records', 'supplier_due_diligence_records'],
|
|
609
|
+
metadata: {
|
|
610
|
+
...(options.metadata || {}),
|
|
611
|
+
supplier: options.supplier,
|
|
612
|
+
assurance_checks: Array.from(new Set(normalizeList(options.assuranceChecks))).sort(),
|
|
613
|
+
review_outcome: options.reviewOutcome,
|
|
614
|
+
},
|
|
615
|
+
tags: ['third_party', 'supplier'],
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
function recordCustomerExpectationAlignment(options) {
|
|
619
|
+
return upsertRecord({
|
|
620
|
+
workflowType: 'customer_alignment',
|
|
621
|
+
title: options.title,
|
|
622
|
+
owner: options.owner,
|
|
623
|
+
controlIds: ['A.10.3'],
|
|
624
|
+
evidenceTypes: ['documented_information', 'customer_requirement_mapping'],
|
|
625
|
+
metadata: {
|
|
626
|
+
...(options.metadata || {}),
|
|
627
|
+
customer_segments: Array.from(new Set(normalizeList(options.customerSegments))).sort(),
|
|
628
|
+
requirement_mappings: Array.from(new Set(normalizeList(options.requirementMappings))).sort(),
|
|
629
|
+
},
|
|
630
|
+
tags: ['customer', 'alignment'],
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
// Clause 9 and Clause 10
|
|
634
|
+
function recordInternalAuditReport(options) {
|
|
635
|
+
return upsertRecord({
|
|
636
|
+
workflowType: 'internal_audit',
|
|
637
|
+
title: options.title,
|
|
638
|
+
owner: options.owner,
|
|
639
|
+
controlIds: ['Clause9'],
|
|
640
|
+
evidenceTypes: [
|
|
641
|
+
'documented_information',
|
|
642
|
+
'internal_audit_report',
|
|
643
|
+
'review_minutes',
|
|
644
|
+
'telemetry_metrics',
|
|
645
|
+
],
|
|
646
|
+
metadata: {
|
|
647
|
+
...(options.metadata || {}),
|
|
648
|
+
audit_scope: options.auditScope,
|
|
649
|
+
findings: Array.from(new Set(normalizeList(options.findings))).sort(),
|
|
650
|
+
nonconformities: Array.from(new Set(normalizeList(options.nonconformities))).sort(),
|
|
651
|
+
recommendations: Array.from(new Set(normalizeList(options.recommendations))).sort(),
|
|
652
|
+
},
|
|
653
|
+
tags: ['clause9', 'internal_audit'],
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
function recordManagementReviewMinutes(options) {
|
|
657
|
+
return upsertRecord({
|
|
658
|
+
workflowType: 'management_review',
|
|
659
|
+
title: options.title,
|
|
660
|
+
owner: options.owner,
|
|
661
|
+
controlIds: ['Clause9'],
|
|
662
|
+
evidenceTypes: [
|
|
663
|
+
'documented_information',
|
|
664
|
+
'management_review_minutes',
|
|
665
|
+
'review_minutes',
|
|
666
|
+
'telemetry_metrics',
|
|
667
|
+
'internal_audit_report',
|
|
668
|
+
],
|
|
669
|
+
metadata: {
|
|
670
|
+
...(options.metadata || {}),
|
|
671
|
+
attendees: Array.from(new Set(normalizeList(options.attendees))).sort(),
|
|
672
|
+
review_topics: Array.from(new Set(normalizeList(options.reviewTopics))).sort(),
|
|
673
|
+
decisions: Array.from(new Set(normalizeList(options.decisions))).sort(),
|
|
674
|
+
action_items: Array.from(new Set(normalizeList(options.actionItems))).sort(),
|
|
675
|
+
},
|
|
676
|
+
tags: ['clause9', 'management_review'],
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
function recordCorrectiveActionLog(options) {
|
|
680
|
+
return upsertRecord({
|
|
681
|
+
workflowType: 'corrective_action',
|
|
682
|
+
title: options.title,
|
|
683
|
+
owner: options.owner,
|
|
684
|
+
controlIds: ['Clause10'],
|
|
685
|
+
evidenceTypes: ['documented_information', 'corrective_action_log'],
|
|
686
|
+
metadata: {
|
|
687
|
+
...(options.metadata || {}),
|
|
688
|
+
issue_reference: options.issueReference,
|
|
689
|
+
root_cause: options.rootCause,
|
|
690
|
+
corrective_actions: Array.from(new Set(normalizeList(options.correctiveActions))).sort(),
|
|
691
|
+
preventive_actions: Array.from(new Set(normalizeList(options.preventiveActions))).sort(),
|
|
692
|
+
status: options.status || 'open',
|
|
693
|
+
},
|
|
694
|
+
tags: ['clause10', 'corrective_action', 'capa'],
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
function getIso42001WorkflowRecord(recordId) {
|
|
698
|
+
const record = records.get(recordId);
|
|
699
|
+
return record ? clone(record) : null;
|
|
700
|
+
}
|
|
701
|
+
function listIso42001WorkflowRecords(options) {
|
|
702
|
+
let rows = Array.from(records.values());
|
|
703
|
+
if (options?.workflowType) {
|
|
704
|
+
rows = rows.filter((row) => row.workflow_type === options.workflowType);
|
|
705
|
+
}
|
|
706
|
+
rows = rows.slice().sort((a, b) => {
|
|
707
|
+
if (a.workflow_type !== b.workflow_type) {
|
|
708
|
+
return a.workflow_type.localeCompare(b.workflow_type);
|
|
709
|
+
}
|
|
710
|
+
if (a.title !== b.title) {
|
|
711
|
+
return a.title.localeCompare(b.title);
|
|
712
|
+
}
|
|
713
|
+
return a.record_id.localeCompare(b.record_id);
|
|
714
|
+
});
|
|
715
|
+
return rows.map((row) => clone(row));
|
|
716
|
+
}
|
|
717
|
+
function getIso42001WorkflowSummary() {
|
|
718
|
+
const rows = listIso42001WorkflowRecords();
|
|
719
|
+
const workflowTypeCounts = {};
|
|
720
|
+
const controls = new Set();
|
|
721
|
+
for (const row of rows) {
|
|
722
|
+
workflowTypeCounts[row.workflow_type] = (workflowTypeCounts[row.workflow_type] || 0) + 1;
|
|
723
|
+
for (const control of row.control_ids) {
|
|
724
|
+
controls.add(control);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
return {
|
|
728
|
+
records_total: rows.length,
|
|
729
|
+
workflow_type_counts: workflowTypeCounts,
|
|
730
|
+
controls_tracked: Array.from(controls).sort(),
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
function exportIso42001WorkflowState(path) {
|
|
734
|
+
const payload = {
|
|
735
|
+
state_type: 'iso42001_workflow_state',
|
|
736
|
+
generated_at: utcNow(),
|
|
737
|
+
records: listIso42001WorkflowRecords(),
|
|
738
|
+
};
|
|
739
|
+
fs.writeFileSync(path, JSON.stringify(payload, null, 2), 'utf-8');
|
|
740
|
+
return payload;
|
|
741
|
+
}
|
|
742
|
+
function loadIso42001WorkflowState(path, options) {
|
|
743
|
+
const payload = JSON.parse(fs.readFileSync(path, 'utf-8'));
|
|
744
|
+
const rows = Array.isArray(payload.records) ? payload.records : [];
|
|
745
|
+
const parsed = new Map();
|
|
746
|
+
for (const row of rows) {
|
|
747
|
+
if (!row || typeof row !== 'object') {
|
|
748
|
+
continue;
|
|
749
|
+
}
|
|
750
|
+
const rid = String(row.record_id || '').trim() || buildId('iso', 'record');
|
|
751
|
+
parsed.set(rid, {
|
|
752
|
+
record_id: rid,
|
|
753
|
+
workflow_type: String(row.workflow_type || 'workflow'),
|
|
754
|
+
title: String(row.title || rid),
|
|
755
|
+
owner: String(row.owner || 'Unassigned'),
|
|
756
|
+
status: String(row.status || 'approved'),
|
|
757
|
+
version: Math.max(1, Number(row.version || 1)),
|
|
758
|
+
control_ids: Array.from(new Set(normalizeList(row.control_ids))).sort(),
|
|
759
|
+
evidence_types: Array.from(new Set(normalizeList(row.evidence_types))).sort(),
|
|
760
|
+
created_at: String(row.created_at || utcNow()),
|
|
761
|
+
updated_at: String(row.updated_at || utcNow()),
|
|
762
|
+
review_frequency_days: row.review_frequency_days === null || row.review_frequency_days === undefined
|
|
763
|
+
? undefined
|
|
764
|
+
: Math.max(1, Number(row.review_frequency_days || 1)),
|
|
765
|
+
next_review_due_at: row.next_review_due_at ? String(row.next_review_due_at) : undefined,
|
|
766
|
+
metadata: row.metadata && typeof row.metadata === 'object' ? clone(row.metadata) : {},
|
|
767
|
+
tags: Array.from(new Set(normalizeList(row.tags))).sort(),
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
if (options?.replaceRuntime !== false) {
|
|
771
|
+
records.clear();
|
|
772
|
+
}
|
|
773
|
+
for (const [rid, row] of parsed.entries()) {
|
|
774
|
+
records.set(rid, clone(row));
|
|
775
|
+
}
|
|
776
|
+
return {
|
|
777
|
+
state_type: typeof payload.state_type === 'string' ? payload.state_type : 'iso42001_workflow_state',
|
|
778
|
+
records_loaded: parsed.size,
|
|
779
|
+
replace_runtime: options?.replaceRuntime !== false,
|
|
780
|
+
};
|
|
781
|
+
}
|