@baselineos/govern 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -0
- package/README.md +19 -0
- package/dist/index.d.ts +619 -0
- package/dist/index.js +1271 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2026 Baseline Protocol Foundation
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @baselineos/govern
|
|
2
|
+
|
|
3
|
+
Govern layer package for Baseline.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Implements governance controls, policy checks, and trust/safety guardrails in the Baseline layer runtime.
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm --filter @baselineos/govern build
|
|
13
|
+
pnpm --filter @baselineos/govern test
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Integration
|
|
17
|
+
|
|
18
|
+
- Depends on: `@baselineos/protocol-core`
|
|
19
|
+
- Consumed by: `@baselineos/cli`, `baselineos`
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured error types for @baselineos/govern
|
|
3
|
+
*
|
|
4
|
+
* Machine-parseable error codes with typed error hierarchy.
|
|
5
|
+
* All errors extend BaselineError for consistent handling.
|
|
6
|
+
*/
|
|
7
|
+
type GovernErrorCode = 'POLICY_NOT_FOUND' | 'POLICY_NOT_APPROVED' | 'POLICY_ALREADY_ENFORCED' | 'POLICY_ENFORCEMENT_BLOCKED' | 'APPROVAL_NOT_FOUND' | 'APPROVAL_ALREADY_RESOLVED' | 'APPROVAL_REQUIRED' | 'RISK_NOT_FOUND' | 'PERMISSION_NOT_FOUND' | 'COMPLIANCE_VIOLATION' | 'COMPLIANCE_STANDARD_UNKNOWN' | 'TEMPLATE_NOT_FOUND' | 'TEMPLATE_VALIDATION_FAILED' | 'VALIDATION_FAILED' | 'INTERNAL_ERROR';
|
|
8
|
+
declare class BaselineError extends Error {
|
|
9
|
+
readonly code: GovernErrorCode;
|
|
10
|
+
readonly details: Record<string, unknown>;
|
|
11
|
+
readonly timestamp: Date;
|
|
12
|
+
constructor(code: GovernErrorCode, message: string, details?: Record<string, unknown>);
|
|
13
|
+
toJSON(): Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
declare class GovernError extends BaselineError {
|
|
16
|
+
constructor(code: GovernErrorCode, message: string, details?: Record<string, unknown>);
|
|
17
|
+
}
|
|
18
|
+
declare class ComplianceError extends BaselineError {
|
|
19
|
+
readonly standard: string;
|
|
20
|
+
constructor(standard: string, message: string, details?: Record<string, unknown>);
|
|
21
|
+
}
|
|
22
|
+
declare class ValidationError extends BaselineError {
|
|
23
|
+
constructor(message: string, details?: Record<string, unknown>);
|
|
24
|
+
}
|
|
25
|
+
declare class TemplateError extends BaselineError {
|
|
26
|
+
readonly templateName: string;
|
|
27
|
+
constructor(templateName: string, message: string, details?: Record<string, unknown>);
|
|
28
|
+
}
|
|
29
|
+
declare function isBaselineError(error: unknown): error is BaselineError;
|
|
30
|
+
declare function toErrorResult(error: unknown): {
|
|
31
|
+
code: GovernErrorCode;
|
|
32
|
+
message: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Baseline Govern System
|
|
37
|
+
*
|
|
38
|
+
* Enterprise governance layer of the Baseline Protocol providing
|
|
39
|
+
* policy, risk, permission, cost, and compliance governance.
|
|
40
|
+
*
|
|
41
|
+
* @license Apache-2.0
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
type PolicySeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
45
|
+
type PolicyEnforcement = 'advisory' | 'warn' | 'block';
|
|
46
|
+
interface PolicyRuleCondition {
|
|
47
|
+
field: string;
|
|
48
|
+
equals?: unknown;
|
|
49
|
+
notEquals?: unknown;
|
|
50
|
+
includes?: unknown;
|
|
51
|
+
exists?: boolean;
|
|
52
|
+
}
|
|
53
|
+
interface PolicyRule {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
severity: PolicySeverity;
|
|
58
|
+
enforcement: PolicyEnforcement;
|
|
59
|
+
condition: PolicyRuleCondition;
|
|
60
|
+
message?: string;
|
|
61
|
+
}
|
|
62
|
+
interface Policy {
|
|
63
|
+
id: string;
|
|
64
|
+
name: string;
|
|
65
|
+
content: string;
|
|
66
|
+
created: Date;
|
|
67
|
+
version: string;
|
|
68
|
+
status: 'draft' | 'approved' | 'enforced' | 'deprecated';
|
|
69
|
+
approved?: Date;
|
|
70
|
+
approver?: string;
|
|
71
|
+
severity: PolicySeverity;
|
|
72
|
+
enforcement: PolicyEnforcement;
|
|
73
|
+
rules: PolicyRule[];
|
|
74
|
+
requireApproval: boolean;
|
|
75
|
+
options: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
interface PolicyViolation {
|
|
78
|
+
ruleId: string;
|
|
79
|
+
ruleName: string;
|
|
80
|
+
severity: PolicySeverity;
|
|
81
|
+
enforcement: PolicyEnforcement;
|
|
82
|
+
message: string;
|
|
83
|
+
}
|
|
84
|
+
interface PolicyEvaluation {
|
|
85
|
+
id: string;
|
|
86
|
+
policyId: string;
|
|
87
|
+
context: unknown;
|
|
88
|
+
passed: boolean;
|
|
89
|
+
score: number;
|
|
90
|
+
violations: PolicyViolation[];
|
|
91
|
+
enforcementAction: 'allow' | 'warn' | 'block' | 'approval_required';
|
|
92
|
+
requiresApproval: boolean;
|
|
93
|
+
evaluatedAt: Date;
|
|
94
|
+
}
|
|
95
|
+
interface ApprovalRequest {
|
|
96
|
+
id: string;
|
|
97
|
+
policyId: string;
|
|
98
|
+
resourceId: string;
|
|
99
|
+
requestedBy: string;
|
|
100
|
+
status: 'pending' | 'approved' | 'rejected';
|
|
101
|
+
requiredApprovers: string[];
|
|
102
|
+
approvals: Array<{
|
|
103
|
+
approver: string;
|
|
104
|
+
at: Date;
|
|
105
|
+
note?: string;
|
|
106
|
+
}>;
|
|
107
|
+
rejections: Array<{
|
|
108
|
+
approver: string;
|
|
109
|
+
at: Date;
|
|
110
|
+
note?: string;
|
|
111
|
+
}>;
|
|
112
|
+
createdAt: Date;
|
|
113
|
+
updatedAt: Date;
|
|
114
|
+
}
|
|
115
|
+
interface GovernanceAuditEvent {
|
|
116
|
+
id: string;
|
|
117
|
+
type: 'policy_created' | 'policy_approved' | 'policy_evaluated' | 'policy_enforced' | 'approval_requested' | 'approval_reviewed' | 'permission_granted' | 'permission_revoked' | 'cost_tracked' | 'compliance_checked';
|
|
118
|
+
actor: string;
|
|
119
|
+
policyId?: string;
|
|
120
|
+
resourceId?: string;
|
|
121
|
+
details: Record<string, unknown>;
|
|
122
|
+
timestamp: Date;
|
|
123
|
+
}
|
|
124
|
+
interface GovernEvidenceBundle {
|
|
125
|
+
policy?: Policy;
|
|
126
|
+
latestEvaluation?: PolicyEvaluation;
|
|
127
|
+
approvals: ApprovalRequest[];
|
|
128
|
+
auditTrail: GovernanceAuditEvent[];
|
|
129
|
+
}
|
|
130
|
+
interface RiskAssessment {
|
|
131
|
+
id: string;
|
|
132
|
+
context: RiskContext;
|
|
133
|
+
riskLevel: 'low' | 'medium' | 'high' | 'critical';
|
|
134
|
+
factors: string[];
|
|
135
|
+
recommendations: string[];
|
|
136
|
+
assessed: Date;
|
|
137
|
+
mitigation?: {
|
|
138
|
+
strategy: string;
|
|
139
|
+
implemented: Date;
|
|
140
|
+
status: string;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
interface RiskContext {
|
|
144
|
+
complexity?: 'low' | 'medium' | 'high';
|
|
145
|
+
impact?: 'low' | 'medium' | 'high';
|
|
146
|
+
[key: string]: unknown;
|
|
147
|
+
}
|
|
148
|
+
interface Permission {
|
|
149
|
+
id: string;
|
|
150
|
+
subject: string;
|
|
151
|
+
resource: string;
|
|
152
|
+
action: string;
|
|
153
|
+
granted: Date;
|
|
154
|
+
revoked?: Date;
|
|
155
|
+
status?: 'active' | 'revoked';
|
|
156
|
+
options: Record<string, unknown>;
|
|
157
|
+
}
|
|
158
|
+
interface CostEntry {
|
|
159
|
+
id: string;
|
|
160
|
+
resource: string;
|
|
161
|
+
amount: number;
|
|
162
|
+
tracked: Date;
|
|
163
|
+
options: Record<string, unknown>;
|
|
164
|
+
}
|
|
165
|
+
interface ComplianceCheck {
|
|
166
|
+
id: string;
|
|
167
|
+
standard: string;
|
|
168
|
+
context: unknown;
|
|
169
|
+
compliant: boolean;
|
|
170
|
+
violations: string[];
|
|
171
|
+
checked: Date;
|
|
172
|
+
}
|
|
173
|
+
interface GovernResult<T = unknown> {
|
|
174
|
+
success: boolean;
|
|
175
|
+
error?: string;
|
|
176
|
+
errorCode?: GovernErrorCode;
|
|
177
|
+
policy?: Policy;
|
|
178
|
+
evaluation?: PolicyEvaluation;
|
|
179
|
+
approval?: ApprovalRequest;
|
|
180
|
+
approvals?: ApprovalRequest[];
|
|
181
|
+
evidence?: GovernEvidenceBundle;
|
|
182
|
+
audit?: GovernanceAuditEvent[];
|
|
183
|
+
assessment?: RiskAssessment;
|
|
184
|
+
permission?: Permission;
|
|
185
|
+
cost?: CostEntry;
|
|
186
|
+
compliance?: ComplianceCheck;
|
|
187
|
+
enforcement?: unknown;
|
|
188
|
+
monitoring?: unknown;
|
|
189
|
+
analysis?: unknown;
|
|
190
|
+
optimization?: unknown;
|
|
191
|
+
report?: unknown;
|
|
192
|
+
remediation?: unknown;
|
|
193
|
+
data?: T;
|
|
194
|
+
}
|
|
195
|
+
interface GovernState {
|
|
196
|
+
initialized: boolean;
|
|
197
|
+
currentPolicies: Map<string, Policy>;
|
|
198
|
+
currentEvaluations: Map<string, PolicyEvaluation>;
|
|
199
|
+
approvalRequests: Map<string, ApprovalRequest>;
|
|
200
|
+
auditTrail: GovernanceAuditEvent[];
|
|
201
|
+
currentRisks: Map<string, RiskAssessment>;
|
|
202
|
+
currentPermissions: Map<string, Permission>;
|
|
203
|
+
currentCosts: Map<string, CostEntry>;
|
|
204
|
+
currentCompliance: Map<string, ComplianceCheck>;
|
|
205
|
+
governanceHistory: unknown[];
|
|
206
|
+
}
|
|
207
|
+
interface GovernStatus {
|
|
208
|
+
initialized: boolean;
|
|
209
|
+
policies: number;
|
|
210
|
+
evaluations: number;
|
|
211
|
+
approvals: number;
|
|
212
|
+
auditTrail: number;
|
|
213
|
+
risks: number;
|
|
214
|
+
permissions: number;
|
|
215
|
+
costs: number;
|
|
216
|
+
compliance: number;
|
|
217
|
+
governanceHistory: number;
|
|
218
|
+
}
|
|
219
|
+
interface GovernSystemOptions {
|
|
220
|
+
persistPath?: string;
|
|
221
|
+
}
|
|
222
|
+
declare class BaselineGovernSystem {
|
|
223
|
+
private persistPath;
|
|
224
|
+
private state;
|
|
225
|
+
readonly policies: {
|
|
226
|
+
create: (name: string, content: string, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
227
|
+
approve: (policyId: string, approver: string, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
228
|
+
enforce: (policyId: string, context: unknown, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
229
|
+
};
|
|
230
|
+
readonly approvals: {
|
|
231
|
+
request: (policyId: string, resourceId: string, requestedBy: string, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
232
|
+
review: (requestId: string, approver: string, decision: 'approved' | 'rejected', options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
233
|
+
get: (requestId: string) => GovernResult;
|
|
234
|
+
list: (policyId?: string) => GovernResult;
|
|
235
|
+
};
|
|
236
|
+
readonly risk: {
|
|
237
|
+
assess: (context: RiskContext, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
238
|
+
mitigate: (riskId: string, strategy: string, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
239
|
+
monitor: (riskId: string, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
240
|
+
};
|
|
241
|
+
readonly permissions: {
|
|
242
|
+
grant: (subject: string, resource: string, action: string, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
243
|
+
check: (subject: string, resource: string, action: string, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
244
|
+
revoke: (permissionId: string, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
245
|
+
};
|
|
246
|
+
readonly costs: {
|
|
247
|
+
track: (resource: string, amount: number, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
248
|
+
analyze: (timeframe: string, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
249
|
+
optimize: (context: unknown, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
250
|
+
};
|
|
251
|
+
readonly compliance: {
|
|
252
|
+
check: (standard: string, context: unknown, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
253
|
+
report: (standard: string, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
254
|
+
remediate: (violationId: string, action: string, options?: Record<string, unknown>) => Promise<GovernResult>;
|
|
255
|
+
};
|
|
256
|
+
constructor(options?: GovernSystemOptions);
|
|
257
|
+
private initializePolicies;
|
|
258
|
+
private initializeApprovals;
|
|
259
|
+
private initializeRisk;
|
|
260
|
+
private initializePermissions;
|
|
261
|
+
private initializeCosts;
|
|
262
|
+
private initializeCompliance;
|
|
263
|
+
private fail;
|
|
264
|
+
private asSeverity;
|
|
265
|
+
private asEnforcement;
|
|
266
|
+
private parseRules;
|
|
267
|
+
private evaluatePolicy;
|
|
268
|
+
private matchesCondition;
|
|
269
|
+
private getContextValue;
|
|
270
|
+
private severityToWeight;
|
|
271
|
+
private createApprovalRequest;
|
|
272
|
+
private findApprovedRequest;
|
|
273
|
+
private recordAudit;
|
|
274
|
+
private loadAuditTrail;
|
|
275
|
+
private persistAuditTrail;
|
|
276
|
+
private calculateRiskLevel;
|
|
277
|
+
private identifyRiskFactors;
|
|
278
|
+
private generateRiskRecommendations;
|
|
279
|
+
private breakdownCosts;
|
|
280
|
+
private generateCostRecommendations;
|
|
281
|
+
private identifyViolations;
|
|
282
|
+
private generateComplianceSummary;
|
|
283
|
+
private generateComplianceDetails;
|
|
284
|
+
getAuditTrail(policyId?: string, resourceId?: string): GovernanceAuditEvent[];
|
|
285
|
+
getEvidenceBundle(policyId: string, resourceId?: string): GovernEvidenceBundle;
|
|
286
|
+
executeGovernWorkflow(options?: Record<string, unknown>): Promise<GovernResult>;
|
|
287
|
+
getStatus(): GovernStatus;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Telemetry hooks for governance operations
|
|
292
|
+
*
|
|
293
|
+
* Emits structured events for observability: operation duration,
|
|
294
|
+
* outcome, resource usage, and compliance check results.
|
|
295
|
+
*/
|
|
296
|
+
interface TelemetryEvent {
|
|
297
|
+
operation: string;
|
|
298
|
+
subsystem: 'policy' | 'approval' | 'risk' | 'permission' | 'cost' | 'compliance';
|
|
299
|
+
success: boolean;
|
|
300
|
+
durationMs: number;
|
|
301
|
+
timestamp: Date;
|
|
302
|
+
details: Record<string, unknown>;
|
|
303
|
+
}
|
|
304
|
+
type TelemetryHook = (event: TelemetryEvent) => void;
|
|
305
|
+
declare class GovernTelemetry {
|
|
306
|
+
private hooks;
|
|
307
|
+
private events;
|
|
308
|
+
private maxHistory;
|
|
309
|
+
constructor(options?: {
|
|
310
|
+
maxHistory?: number;
|
|
311
|
+
});
|
|
312
|
+
addHook(hook: TelemetryHook): void;
|
|
313
|
+
removeHook(hook: TelemetryHook): void;
|
|
314
|
+
emit(event: TelemetryEvent): void;
|
|
315
|
+
track<T>(operation: string, subsystem: TelemetryEvent['subsystem'], fn: () => T, details?: Record<string, unknown>): T;
|
|
316
|
+
trackAsync<T>(operation: string, subsystem: TelemetryEvent['subsystem'], fn: () => Promise<T>, details?: Record<string, unknown>): Promise<T>;
|
|
317
|
+
getEvents(): readonly TelemetryEvent[];
|
|
318
|
+
getMetrics(): GovernMetrics;
|
|
319
|
+
clear(): void;
|
|
320
|
+
}
|
|
321
|
+
interface SubsystemMetrics {
|
|
322
|
+
operations: number;
|
|
323
|
+
avgDurationMs: number;
|
|
324
|
+
failureRate: number;
|
|
325
|
+
}
|
|
326
|
+
interface GovernMetrics {
|
|
327
|
+
totalOperations: number;
|
|
328
|
+
avgDurationMs: number;
|
|
329
|
+
failureRate: number;
|
|
330
|
+
subsystems: Record<string, SubsystemMetrics>;
|
|
331
|
+
since: Date;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
declare class ComplianceCache<T = unknown> {
|
|
335
|
+
private cache;
|
|
336
|
+
private maxSize;
|
|
337
|
+
private ttlMs;
|
|
338
|
+
private totalHits;
|
|
339
|
+
private totalMisses;
|
|
340
|
+
constructor(options?: {
|
|
341
|
+
maxSize?: number;
|
|
342
|
+
ttlMs?: number;
|
|
343
|
+
});
|
|
344
|
+
get(key: string): T | undefined;
|
|
345
|
+
set(key: string, value: T): void;
|
|
346
|
+
has(key: string): boolean;
|
|
347
|
+
clear(): void;
|
|
348
|
+
get size(): number;
|
|
349
|
+
get hitRate(): number;
|
|
350
|
+
getStats(): CacheStats;
|
|
351
|
+
static hashKey(standard: string, context: unknown): string;
|
|
352
|
+
}
|
|
353
|
+
interface CacheStats {
|
|
354
|
+
size: number;
|
|
355
|
+
maxSize: number;
|
|
356
|
+
ttlMs: number;
|
|
357
|
+
hits: number;
|
|
358
|
+
misses: number;
|
|
359
|
+
hitRate: number;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* COCOBOD Commodity Grading Policy Template
|
|
364
|
+
*
|
|
365
|
+
* Implements Ghana Cocoa Board (COCOBOD) commodity grading standards
|
|
366
|
+
* for cocoa bean quality classification and export compliance.
|
|
367
|
+
*
|
|
368
|
+
* Standards:
|
|
369
|
+
* - Grade I: Premium quality, max 3% defective beans
|
|
370
|
+
* - Grade II: Standard quality, max 5% defective beans
|
|
371
|
+
* - Substandard: Exceeds 5% defective — blocked from export
|
|
372
|
+
*
|
|
373
|
+
* Moisture content must not exceed 7.5% for any grade.
|
|
374
|
+
* All shipments require origin traceability documentation.
|
|
375
|
+
*/
|
|
376
|
+
|
|
377
|
+
interface CocobodGradingContext {
|
|
378
|
+
defectivePercentage: number;
|
|
379
|
+
moisturePercentage: number;
|
|
380
|
+
beanCount?: number;
|
|
381
|
+
origin?: string;
|
|
382
|
+
hasOriginCertificate: boolean;
|
|
383
|
+
hasQualityCertificate: boolean;
|
|
384
|
+
exportDestination?: string;
|
|
385
|
+
[key: string]: unknown;
|
|
386
|
+
}
|
|
387
|
+
interface CocobodGradeResult {
|
|
388
|
+
grade: 'I' | 'II' | 'substandard';
|
|
389
|
+
exportEligible: boolean;
|
|
390
|
+
violations: string[];
|
|
391
|
+
}
|
|
392
|
+
declare function assessCocobodGrade(context: CocobodGradingContext): CocobodGradeResult;
|
|
393
|
+
declare const COCOBOD_TEMPLATE: {
|
|
394
|
+
readonly name: "COCOBOD-GRADING";
|
|
395
|
+
readonly description: "Ghana Cocoa Board commodity grading and export compliance";
|
|
396
|
+
readonly version: "1.0.0";
|
|
397
|
+
readonly jurisdiction: "GH";
|
|
398
|
+
readonly rules: ({
|
|
399
|
+
id: string;
|
|
400
|
+
name: string;
|
|
401
|
+
description: string;
|
|
402
|
+
severity: PolicySeverity;
|
|
403
|
+
enforcement: PolicyEnforcement;
|
|
404
|
+
condition: {
|
|
405
|
+
field: string;
|
|
406
|
+
greaterThan: number;
|
|
407
|
+
equals?: undefined;
|
|
408
|
+
};
|
|
409
|
+
message: string;
|
|
410
|
+
} | {
|
|
411
|
+
id: string;
|
|
412
|
+
name: string;
|
|
413
|
+
description: string;
|
|
414
|
+
severity: PolicySeverity;
|
|
415
|
+
enforcement: PolicyEnforcement;
|
|
416
|
+
condition: {
|
|
417
|
+
field: string;
|
|
418
|
+
equals: boolean;
|
|
419
|
+
greaterThan?: undefined;
|
|
420
|
+
};
|
|
421
|
+
message: string;
|
|
422
|
+
})[];
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* FIC-AML Anti-Money Laundering Compliance Template
|
|
427
|
+
*
|
|
428
|
+
* Implements Ghana Financial Intelligence Centre (FIC) Anti-Money
|
|
429
|
+
* Laundering requirements under the Anti-Money Laundering Act, 2020
|
|
430
|
+
* (Act 1044).
|
|
431
|
+
*
|
|
432
|
+
* Requirements:
|
|
433
|
+
* - Customer Due Diligence (CDD) for all transactions
|
|
434
|
+
* - Enhanced Due Diligence (EDD) for high-risk customers/PEPs
|
|
435
|
+
* - Suspicious Transaction Reporting (STR) threshold: GHS 20,000
|
|
436
|
+
* - Cash Transaction Reporting (CTR) threshold: GHS 50,000
|
|
437
|
+
* - Record retention: minimum 5 years
|
|
438
|
+
* - Sanctions screening against UN, EU, and Ghana sanctions lists
|
|
439
|
+
*/
|
|
440
|
+
|
|
441
|
+
interface FicAmlContext {
|
|
442
|
+
transactionAmount: number;
|
|
443
|
+
currency: string;
|
|
444
|
+
customerType: 'individual' | 'entity';
|
|
445
|
+
isPEP: boolean;
|
|
446
|
+
hasKYC: boolean;
|
|
447
|
+
hasEDD: boolean;
|
|
448
|
+
sanctionsScreened: boolean;
|
|
449
|
+
sanctionsCleared: boolean;
|
|
450
|
+
sourceOfFunds?: string;
|
|
451
|
+
recordRetentionYears?: number;
|
|
452
|
+
riskRating?: 'low' | 'medium' | 'high';
|
|
453
|
+
[key: string]: unknown;
|
|
454
|
+
}
|
|
455
|
+
interface FicAmlResult {
|
|
456
|
+
compliant: boolean;
|
|
457
|
+
requiresSTR: boolean;
|
|
458
|
+
requiresCTR: boolean;
|
|
459
|
+
requiresEDD: boolean;
|
|
460
|
+
violations: string[];
|
|
461
|
+
}
|
|
462
|
+
declare function assessFicAml(context: FicAmlContext): FicAmlResult;
|
|
463
|
+
declare const FIC_AML_TEMPLATE: {
|
|
464
|
+
readonly name: "FIC-AML-1044";
|
|
465
|
+
readonly description: "Ghana FIC Anti-Money Laundering Act 1044 compliance";
|
|
466
|
+
readonly version: "1.0.0";
|
|
467
|
+
readonly jurisdiction: "GH";
|
|
468
|
+
readonly rules: readonly [{
|
|
469
|
+
readonly id: "fic-kyc";
|
|
470
|
+
readonly name: "Customer Due Diligence";
|
|
471
|
+
readonly description: "KYC verification required for all transactions";
|
|
472
|
+
readonly severity: PolicySeverity;
|
|
473
|
+
readonly enforcement: PolicyEnforcement;
|
|
474
|
+
readonly condition: {
|
|
475
|
+
readonly field: "hasKYC";
|
|
476
|
+
readonly equals: false;
|
|
477
|
+
};
|
|
478
|
+
readonly message: "FIC Act 1044: Customer Due Diligence not completed";
|
|
479
|
+
}, {
|
|
480
|
+
readonly id: "fic-sanctions";
|
|
481
|
+
readonly name: "Sanctions Screening";
|
|
482
|
+
readonly description: "All customers must be screened against sanctions lists";
|
|
483
|
+
readonly severity: PolicySeverity;
|
|
484
|
+
readonly enforcement: PolicyEnforcement;
|
|
485
|
+
readonly condition: {
|
|
486
|
+
readonly field: "sanctionsScreened";
|
|
487
|
+
readonly equals: false;
|
|
488
|
+
};
|
|
489
|
+
readonly message: "FIC Act 1044: Sanctions screening not performed";
|
|
490
|
+
}, {
|
|
491
|
+
readonly id: "fic-edd";
|
|
492
|
+
readonly name: "Enhanced Due Diligence";
|
|
493
|
+
readonly description: "EDD required for PEPs and high-risk customers";
|
|
494
|
+
readonly severity: PolicySeverity;
|
|
495
|
+
readonly enforcement: PolicyEnforcement;
|
|
496
|
+
readonly condition: {
|
|
497
|
+
readonly field: "isPEP";
|
|
498
|
+
readonly equals: true;
|
|
499
|
+
};
|
|
500
|
+
readonly message: "FIC Act 1044: Enhanced Due Diligence required for PEP";
|
|
501
|
+
}, {
|
|
502
|
+
readonly id: "fic-source-of-funds";
|
|
503
|
+
readonly name: "Source of Funds";
|
|
504
|
+
readonly description: "Source of funds required for large transactions";
|
|
505
|
+
readonly severity: PolicySeverity;
|
|
506
|
+
readonly enforcement: PolicyEnforcement;
|
|
507
|
+
readonly condition: {
|
|
508
|
+
readonly field: "sourceOfFunds";
|
|
509
|
+
readonly exists: false;
|
|
510
|
+
};
|
|
511
|
+
readonly message: "FIC Act 1044: Source of funds declaration required";
|
|
512
|
+
}];
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* AfCFTA Rules of Origin Compliance Gate
|
|
517
|
+
*
|
|
518
|
+
* Implements the African Continental Free Trade Area (AfCFTA) Rules
|
|
519
|
+
* of Origin requirements for intra-African trade.
|
|
520
|
+
*
|
|
521
|
+
* Key rules:
|
|
522
|
+
* - Wholly obtained criterion: goods entirely produced in a state party
|
|
523
|
+
* - Substantial transformation: change in tariff classification (CTC)
|
|
524
|
+
* - Value-added criterion: minimum 40% local value content
|
|
525
|
+
* - Certificate of Origin required from an authorized body
|
|
526
|
+
* - Goods must be shipped directly or through approved transit routes
|
|
527
|
+
* - Cumulation: materials from other AfCFTA state parties count as originating
|
|
528
|
+
*/
|
|
529
|
+
|
|
530
|
+
interface AfcftaContext {
|
|
531
|
+
originCountry: string;
|
|
532
|
+
destinationCountry: string;
|
|
533
|
+
localValuePercentage: number;
|
|
534
|
+
hasCertificateOfOrigin: boolean;
|
|
535
|
+
isDirectShipment: boolean;
|
|
536
|
+
tariffClassificationChanged: boolean;
|
|
537
|
+
isWhollyObtained: boolean;
|
|
538
|
+
hsCode?: string;
|
|
539
|
+
productDescription?: string;
|
|
540
|
+
transitCountries?: string[];
|
|
541
|
+
cumulationCountries?: string[];
|
|
542
|
+
[key: string]: unknown;
|
|
543
|
+
}
|
|
544
|
+
interface AfcftaResult {
|
|
545
|
+
compliant: boolean;
|
|
546
|
+
originSatisfied: boolean;
|
|
547
|
+
preferentialTariffEligible: boolean;
|
|
548
|
+
violations: string[];
|
|
549
|
+
}
|
|
550
|
+
declare function isAfcftaStateParty(countryCode: string): boolean;
|
|
551
|
+
declare function assessAfcfta(context: AfcftaContext): AfcftaResult;
|
|
552
|
+
declare const AFCFTA_TEMPLATE: {
|
|
553
|
+
readonly name: "AFCFTA-ROO";
|
|
554
|
+
readonly description: "AfCFTA Rules of Origin for intra-African preferential trade";
|
|
555
|
+
readonly version: "1.0.0";
|
|
556
|
+
readonly jurisdiction: "AU";
|
|
557
|
+
readonly rules: readonly [{
|
|
558
|
+
readonly id: "afcfta-certificate";
|
|
559
|
+
readonly name: "Certificate of Origin";
|
|
560
|
+
readonly description: "Valid Certificate of Origin from authorized body required";
|
|
561
|
+
readonly severity: PolicySeverity;
|
|
562
|
+
readonly enforcement: PolicyEnforcement;
|
|
563
|
+
readonly condition: {
|
|
564
|
+
readonly field: "hasCertificateOfOrigin";
|
|
565
|
+
readonly equals: false;
|
|
566
|
+
};
|
|
567
|
+
readonly message: "AfCFTA: Certificate of Origin not provided";
|
|
568
|
+
}, {
|
|
569
|
+
readonly id: "afcfta-origin";
|
|
570
|
+
readonly name: "Rules of Origin";
|
|
571
|
+
readonly description: "Product must satisfy wholly obtained, CTC, or 40% value-added criterion";
|
|
572
|
+
readonly severity: PolicySeverity;
|
|
573
|
+
readonly enforcement: PolicyEnforcement;
|
|
574
|
+
readonly condition: {
|
|
575
|
+
readonly field: "localValuePercentage";
|
|
576
|
+
readonly lessThan: 40;
|
|
577
|
+
};
|
|
578
|
+
readonly message: "AfCFTA: Rules of Origin not satisfied";
|
|
579
|
+
}, {
|
|
580
|
+
readonly id: "afcfta-state-party";
|
|
581
|
+
readonly name: "State Party Requirement";
|
|
582
|
+
readonly description: "Both origin and destination must be AfCFTA state parties";
|
|
583
|
+
readonly severity: PolicySeverity;
|
|
584
|
+
readonly enforcement: PolicyEnforcement;
|
|
585
|
+
readonly condition: {
|
|
586
|
+
readonly field: "originCountry";
|
|
587
|
+
readonly notAfcftaParty: true;
|
|
588
|
+
};
|
|
589
|
+
readonly message: "AfCFTA: Origin country is not a state party";
|
|
590
|
+
}, {
|
|
591
|
+
readonly id: "afcfta-direct-shipment";
|
|
592
|
+
readonly name: "Direct Shipment";
|
|
593
|
+
readonly description: "Goods must be shipped directly or through approved transit";
|
|
594
|
+
readonly severity: PolicySeverity;
|
|
595
|
+
readonly enforcement: PolicyEnforcement;
|
|
596
|
+
readonly condition: {
|
|
597
|
+
readonly field: "isDirectShipment";
|
|
598
|
+
readonly equals: false;
|
|
599
|
+
};
|
|
600
|
+
readonly message: "AfCFTA: Direct shipment rule not met";
|
|
601
|
+
}];
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Ghana Policy Templates Registry
|
|
606
|
+
*
|
|
607
|
+
* Provides domain-specific compliance templates for the Baseline
|
|
608
|
+
* Govern system, starting with Ghanaian regulatory standards and
|
|
609
|
+
* AfCFTA trade compliance.
|
|
610
|
+
*/
|
|
611
|
+
|
|
612
|
+
declare const GHANA_TEMPLATES: {
|
|
613
|
+
readonly 'COCOBOD-GRADING': "cocobod";
|
|
614
|
+
readonly 'FIC-AML-1044': "fic-aml";
|
|
615
|
+
readonly 'AFCFTA-ROO': "afcfta";
|
|
616
|
+
};
|
|
617
|
+
type GhanaTemplateStandard = keyof typeof GHANA_TEMPLATES;
|
|
618
|
+
|
|
619
|
+
export { AFCFTA_TEMPLATE, type AfcftaContext, type AfcftaResult, type ApprovalRequest, BaselineError, BaselineGovernSystem, COCOBOD_TEMPLATE, type CacheStats, type CocobodGradeResult, type CocobodGradingContext, ComplianceCache, type ComplianceCheck, ComplianceError, type CostEntry, FIC_AML_TEMPLATE, type FicAmlContext, type FicAmlResult, GHANA_TEMPLATES, type GhanaTemplateStandard, GovernError, type GovernErrorCode, type GovernEvidenceBundle, type GovernMetrics, type GovernResult, type GovernState, type GovernStatus, GovernTelemetry, type GovernanceAuditEvent, type Permission, type Policy, type PolicyEnforcement, type PolicyEvaluation, type PolicyRule, type PolicySeverity, type RiskAssessment, type RiskContext, type SubsystemMetrics, type TelemetryEvent, type TelemetryHook, TemplateError, ValidationError, assessAfcfta, assessCocobodGrade, assessFicAml, isAfcftaStateParty, isBaselineError, toErrorResult };
|