ark-runtime-kernel 1.0.0 → 1.1.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/README.md +121 -220
- package/bin/ark-check.mjs +142 -20
- package/bin/ark-mcp.mjs +0 -0
- package/dist/index.cjs +25 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -957
- package/dist/index.d.ts +4 -957
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/dist/nestjs/index.cjs +2301 -0
- package/dist/nestjs/index.cjs.map +1 -0
- package/dist/nestjs/index.d.cts +22 -0
- package/dist/nestjs/index.d.ts +22 -0
- package/dist/nestjs/index.js +2298 -0
- package/dist/nestjs/index.js.map +1 -0
- package/dist/types-7K_KQCgS.d.cts +991 -0
- package/dist/types-7K_KQCgS.d.ts +991 -0
- package/package.json +43 -8
- package/server.json +31 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,163 +1,9 @@
|
|
|
1
|
+
import { I as IntentRegistry, a as IntentName, D as DefineIntentOptions, b as IntentCreator, P as PolicyViolation, c as PolicySeverity, d as PolicyEnforcementMode, e as Policy, C as CreateArchitectureProfileOptions, A as ArchitectureProfile, f as CreateElevenLayerArkConfigOptions, g as ArkCheckConfig, h as DependencyGraph, G as GraphEdge, i as IntentRelationship, j as AuditStore, k as AuditRecord, l as AuditQuery, m as CreateAuditTrailOptions, n as AuditTrail, E as EventContractRegistry, o as EventContract, p as DomainEvent, q as EventContractValidationResult, O as OutboxStore, r as OutboxRecord, s as OutboxStatus, t as EventBusOptions, u as EventBus, v as CreateObservabilityReporterOptions, w as ObservabilityReporter, M as MetadataRegistry, R as ReadModelStore, x as CreateProjectionRegistryOptions, y as ProjectionRegistry, z as PolicyEngine, B as ArkManifest, W as WorkflowStore, S as SagaContext, F as WorkflowSnapshot, H as SagaDefinition, J as CreateWorkflowEngineOptions, K as SagaInstance, L as WorkflowEngine, N as CreateArkKernelOptions, Q as ArkKernel, T as TraceRecordType, U as TraceRecord, V as ObservabilityDriftReport } from './types-7K_KQCgS.js';
|
|
2
|
+
export { X as ArchitectureLayer, Y as ArchitectureLayerConfig, Z as ArchitectureRule, _ as ArkManifestArchitecture, $ as ArkManifestData, a0 as ArkManifestEntityLink, a1 as ArkManifestGraph, a2 as ArkManifestIntent, a3 as ArkManifestPolicy, a4 as ArkManifestProjection, a5 as AuditRecordInput, a6 as AuditRecordType, a7 as CorrelationId, a8 as EntityMeta, a9 as EventContractIssue, aa as EventHandler, ab as EventInterceptionInfo, ac as EventInterceptor, ad as EventInterceptorContext, ae as EventMetadata, af as EventPayloadPatch, ag as EventPayloadSchema, ah as EventPublisher, ai as EventSchemaField, aj as EventSchemaFieldType, ak as FieldMeta, al as GraphNode, am as IntentRelationshipKind, an as ObservabilityFlow, ao as ObservedLayerFlowMode, ap as PolicyEvaluationResult, aq as ProjectionCheckpoint, ar as ProjectionDefinition, as as PublishedEventRecord, at as RetryPolicy, au as SagaStatus, av as SagaStep, aw as TraceSink, ax as Unsubscribe, ay as WorkflowDefinition, az as WorkflowStatus, aA as WorkflowStep } from './types-7K_KQCgS.js';
|
|
3
|
+
|
|
1
4
|
/** Ark library version — single source of truth. */
|
|
2
5
|
declare const version = "1.0.0";
|
|
3
6
|
|
|
4
|
-
/**
|
|
5
|
-
* Core domain primitives for Ark.
|
|
6
|
-
* These types are the foundation for all governance concepts.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Semantic intent names follow a convention:
|
|
10
|
-
* - Domain.* for domain events and entities
|
|
11
|
-
* - Application.* for use-cases / orchestration
|
|
12
|
-
* - Adapter.* for integration points
|
|
13
|
-
* - Workflow.* for sagas and processes
|
|
14
|
-
* - Job.* for background jobs and scheduling
|
|
15
|
-
* - Presentation.* for UI/API adapters
|
|
16
|
-
* - Reporting.* for read models and projections
|
|
17
|
-
* - Metadata.* for extensibility contracts
|
|
18
|
-
* - Security.* / Audit.* / Observability.* for cross-cutting kernel concerns
|
|
19
|
-
* - Kernel.* for Ark-owned governance signals
|
|
20
|
-
*/
|
|
21
|
-
type IntentName = `Domain.${string}` | `Application.${string}` | `Adapter.${string}` | `Workflow.${string}` | `Job.${string}` | `Presentation.${string}` | `Reporting.${string}` | `Metadata.${string}` | `Security.${string}` | `Audit.${string}` | `Observability.${string}` | `Kernel.${string}`;
|
|
22
|
-
type CorrelationId = string;
|
|
23
|
-
interface EventMetadata {
|
|
24
|
-
occurredAt: string;
|
|
25
|
-
source: string;
|
|
26
|
-
kernelInstanceId?: string;
|
|
27
|
-
eventVersion?: string;
|
|
28
|
-
schemaVersion?: string;
|
|
29
|
-
allowInterception?: boolean;
|
|
30
|
-
interceptions?: Array<{
|
|
31
|
-
interceptorId: string;
|
|
32
|
-
timestamp: string;
|
|
33
|
-
}>;
|
|
34
|
-
correlationId?: CorrelationId;
|
|
35
|
-
causationId?: string;
|
|
36
|
-
traceId?: string;
|
|
37
|
-
spanId?: string;
|
|
38
|
-
parentSpanId?: string;
|
|
39
|
-
[key: string]: unknown;
|
|
40
|
-
}
|
|
41
|
-
interface DomainEvent<Name extends IntentName = IntentName, Payload = unknown> {
|
|
42
|
-
intent: Name;
|
|
43
|
-
payload: Payload;
|
|
44
|
-
metadata: EventMetadata;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Intent-specific types for the Ark kernel.
|
|
49
|
-
*
|
|
50
|
-
* Intents provide semantic naming for every important concept in the system
|
|
51
|
-
* (domain events, application operations, adapters, workflows).
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* An IntentCreator is a callable that creates a strongly-typed DomainEvent
|
|
56
|
-
* when invoked with a payload.
|
|
57
|
-
*
|
|
58
|
-
* It also carries the semantic `name`.
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* const OrderPlaced = defineIntent<'Domain.Order.OrderPlaced', { orderId: string }>('Domain.Order.OrderPlaced');
|
|
62
|
-
* const event = OrderPlaced({ orderId: 'o-1' });
|
|
63
|
-
*/
|
|
64
|
-
interface IntentCreator<Name extends IntentName, Payload = unknown> {
|
|
65
|
-
/**
|
|
66
|
-
* Creates a DomainEvent for this intent.
|
|
67
|
-
*/
|
|
68
|
-
(payload: Payload): DomainEvent<Name, Payload>;
|
|
69
|
-
/**
|
|
70
|
-
* The fully-qualified semantic name of the intent (e.g. "Domain.Order.OrderPlaced").
|
|
71
|
-
*/
|
|
72
|
-
readonly name: Name;
|
|
73
|
-
}
|
|
74
|
-
/** Kind of relationship between two intents. */
|
|
75
|
-
type IntentRelationshipKind = 'dependsOn' | 'produces';
|
|
76
|
-
/**
|
|
77
|
-
* Relationship declarations between intents.
|
|
78
|
-
* Used for dependency analysis and graph generation.
|
|
79
|
-
*/
|
|
80
|
-
interface IntentRelationship {
|
|
81
|
-
from: string;
|
|
82
|
-
to: string;
|
|
83
|
-
kind: IntentRelationshipKind;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* IntentRegistry
|
|
88
|
-
*
|
|
89
|
-
* Central registry for semantic intents.
|
|
90
|
-
* Supports registration, duplicate prevention, and declared dependency relationships.
|
|
91
|
-
*
|
|
92
|
-
* This is a core building block for governance, dependency graphs, and policy enforcement.
|
|
93
|
-
*/
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Options for declaring relationships when defining an intent.
|
|
97
|
-
*/
|
|
98
|
-
interface DefineIntentOptions {
|
|
99
|
-
/** Other intents this one depends on (semantic names) */
|
|
100
|
-
dependsOn?: IntentName[];
|
|
101
|
-
/** Intents that this one produces / triggers */
|
|
102
|
-
produces?: IntentName[];
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* IntentRegistry manages all registered intents and their declared relationships.
|
|
106
|
-
*/
|
|
107
|
-
declare class IntentRegistry {
|
|
108
|
-
private readonly intents;
|
|
109
|
-
private readonly dependencies;
|
|
110
|
-
private readonly productions;
|
|
111
|
-
/**
|
|
112
|
-
* Define/register a new intent.
|
|
113
|
-
*
|
|
114
|
-
* @param name - Semantic intent name following the convention (Domain.*, Application.*, etc.)
|
|
115
|
-
* @param options - Optional relationship declarations
|
|
116
|
-
* @throws Error if an intent with the same name is already registered
|
|
117
|
-
*/
|
|
118
|
-
define<N extends IntentName, P = unknown>(name: N, options?: DefineIntentOptions): IntentCreator<N, P>;
|
|
119
|
-
/**
|
|
120
|
-
* Declare that one intent depends on / relates to another.
|
|
121
|
-
* This information is used by the DependencyGraph (future iterations) and for policy checks.
|
|
122
|
-
*
|
|
123
|
-
* @param from - The source intent (e.g. an Application operation)
|
|
124
|
-
* @param to - The target intent it depends on (e.g. a Domain event or concept)
|
|
125
|
-
*/
|
|
126
|
-
declareDependency(from: string, to: string): void;
|
|
127
|
-
/**
|
|
128
|
-
* Declare that one intent produces / emits another (e.g. use case → domain event).
|
|
129
|
-
*/
|
|
130
|
-
declareProduction(from: string, to: string): void;
|
|
131
|
-
/**
|
|
132
|
-
* Retrieve a previously defined intent creator by name.
|
|
133
|
-
*/
|
|
134
|
-
get<N extends IntentName = IntentName, P = unknown>(name: string): IntentCreator<N, P> | undefined;
|
|
135
|
-
/**
|
|
136
|
-
* List all registered intent creators.
|
|
137
|
-
*/
|
|
138
|
-
list(): IntentCreator<IntentName, unknown>[];
|
|
139
|
-
/**
|
|
140
|
-
* Get all declared dependencies for a given intent.
|
|
141
|
-
*/
|
|
142
|
-
getDependencies(intentName: string): string[];
|
|
143
|
-
/**
|
|
144
|
-
* Get all intents produced / emitted by a given intent.
|
|
145
|
-
*/
|
|
146
|
-
getProductions(intentName: string): string[];
|
|
147
|
-
/**
|
|
148
|
-
* Get all declared relationships (useful for graph generation).
|
|
149
|
-
*/
|
|
150
|
-
getAllRelationships(): IntentRelationship[];
|
|
151
|
-
/**
|
|
152
|
-
* Check if an intent name has been registered.
|
|
153
|
-
*/
|
|
154
|
-
has(name: string): boolean;
|
|
155
|
-
/**
|
|
156
|
-
* Clear the registry. Primarily useful for tests.
|
|
157
|
-
*/
|
|
158
|
-
clear(): void;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
7
|
/**
|
|
162
8
|
* defineIntent
|
|
163
9
|
*
|
|
@@ -224,102 +70,6 @@ interface IntentNameValidation {
|
|
|
224
70
|
*/
|
|
225
71
|
declare function validateIntentName(name: string): IntentNameValidation;
|
|
226
72
|
|
|
227
|
-
/**
|
|
228
|
-
* Policy types for the Ark kernel.
|
|
229
|
-
*
|
|
230
|
-
* Policies allow declaring architectural rules that can be checked at runtime.
|
|
231
|
-
* Supports both hard policies (must never be violated) and soft policies (warnings).
|
|
232
|
-
*/
|
|
233
|
-
type PolicySeverity = 'hard' | 'soft';
|
|
234
|
-
type PolicyEnforcementMode = 'runtime' | 'static' | 'runtime-and-static' | 'advisory';
|
|
235
|
-
/**
|
|
236
|
-
* Represents a single violation of a policy.
|
|
237
|
-
*/
|
|
238
|
-
interface PolicyViolation {
|
|
239
|
-
/** Name of the policy that was violated */
|
|
240
|
-
policyName: string;
|
|
241
|
-
/** Severity level of the policy */
|
|
242
|
-
severity: PolicySeverity;
|
|
243
|
-
/** Human-readable explanation of the violation */
|
|
244
|
-
message: string;
|
|
245
|
-
/** Optional additional structured details */
|
|
246
|
-
details?: unknown;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* A Policy defines a rule that can be evaluated against a context.
|
|
250
|
-
*
|
|
251
|
-
* @template Context - The shape of data the policy evaluates (e.g. { registry, events })
|
|
252
|
-
*/
|
|
253
|
-
interface Policy<Context = unknown> {
|
|
254
|
-
/** Unique name of the policy (used in violations and reporting) */
|
|
255
|
-
readonly name: string;
|
|
256
|
-
/** Whether this is a hard rule (enforced strictly) or soft (advisory) */
|
|
257
|
-
readonly severity: PolicySeverity;
|
|
258
|
-
/** Optional tags for policy classification (e.g. 'layer', 'naming') */
|
|
259
|
-
readonly tags?: readonly string[];
|
|
260
|
-
readonly owner?: string;
|
|
261
|
-
readonly version?: string;
|
|
262
|
-
readonly rationale?: string;
|
|
263
|
-
readonly enforcementMode?: PolicyEnforcementMode;
|
|
264
|
-
readonly deprecated?: boolean | string;
|
|
265
|
-
readonly replacedBy?: string;
|
|
266
|
-
/**
|
|
267
|
-
* Evaluates the policy against the given context.
|
|
268
|
-
* Return true / [] for pass, false / single violation / array for failure.
|
|
269
|
-
*/
|
|
270
|
-
check(context: Context): boolean | PolicyViolation | PolicyViolation[];
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* PolicyEngine
|
|
275
|
-
*
|
|
276
|
-
* Evaluates collections of policies against a context.
|
|
277
|
-
* Supports hard and soft policies.
|
|
278
|
-
* - Hard policies: violations cause enforcement to throw.
|
|
279
|
-
* - Soft policies: violations are reported as warnings but do not throw.
|
|
280
|
-
*/
|
|
281
|
-
|
|
282
|
-
interface PolicyEvaluationResult {
|
|
283
|
-
passed: boolean;
|
|
284
|
-
violations: PolicyViolation[];
|
|
285
|
-
hardViolations: PolicyViolation[];
|
|
286
|
-
softViolations: PolicyViolation[];
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* The PolicyEngine is responsible for registering policies and evaluating
|
|
290
|
-
* them against a given context.
|
|
291
|
-
*/
|
|
292
|
-
declare class PolicyEngine<Context = unknown> {
|
|
293
|
-
private readonly policies;
|
|
294
|
-
constructor(initialPolicies?: Policy<Context>[]);
|
|
295
|
-
/**
|
|
296
|
-
* Adds a policy to the engine.
|
|
297
|
-
*/
|
|
298
|
-
add(policy: Policy<Context>): void;
|
|
299
|
-
/**
|
|
300
|
-
* Returns all registered policies.
|
|
301
|
-
*/
|
|
302
|
-
getPolicies(): Policy<Context>[];
|
|
303
|
-
/**
|
|
304
|
-
* Evaluates all policies against the provided context.
|
|
305
|
-
*/
|
|
306
|
-
evaluate(context: Context): PolicyEvaluationResult;
|
|
307
|
-
/**
|
|
308
|
-
* Enforces all policies.
|
|
309
|
-
*
|
|
310
|
-
* - Soft violations are collected and can be observed (returned or logged).
|
|
311
|
-
* - Hard violations cause an error to be thrown (by default).
|
|
312
|
-
*
|
|
313
|
-
* @returns Evaluation result (including any soft violations)
|
|
314
|
-
* @throws Error if any hard policy is violated
|
|
315
|
-
*/
|
|
316
|
-
enforce(context: Context): PolicyEvaluationResult;
|
|
317
|
-
/**
|
|
318
|
-
* Clears all registered policies.
|
|
319
|
-
*/
|
|
320
|
-
clear(): void;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
73
|
/**
|
|
324
74
|
* Typed error thrown when hard policies are violated.
|
|
325
75
|
*/
|
|
@@ -369,115 +119,10 @@ interface DefinePolicyOptions<Context = unknown> {
|
|
|
369
119
|
*/
|
|
370
120
|
declare function definePolicy<Context = unknown>(options: DefinePolicyOptions<Context>): Policy<Context>;
|
|
371
121
|
|
|
372
|
-
/**
|
|
373
|
-
* Architecture layer profiles.
|
|
374
|
-
*
|
|
375
|
-
* A profile turns semantic names such as `Domain.Order.Placed` into governed
|
|
376
|
-
* layer names and dependency rules.
|
|
377
|
-
*/
|
|
378
|
-
interface ArchitectureLayer {
|
|
379
|
-
name: string;
|
|
380
|
-
prefixes: string[];
|
|
381
|
-
description?: string;
|
|
382
|
-
order?: number;
|
|
383
|
-
}
|
|
384
|
-
interface ArchitectureRule {
|
|
385
|
-
from: string;
|
|
386
|
-
to: string;
|
|
387
|
-
allowed: boolean;
|
|
388
|
-
message?: string;
|
|
389
|
-
}
|
|
390
|
-
interface ArchitectureProfile {
|
|
391
|
-
name: string;
|
|
392
|
-
layers: ArchitectureLayer[];
|
|
393
|
-
rules: ArchitectureRule[];
|
|
394
|
-
resolveLayer(name: string): string | undefined;
|
|
395
|
-
}
|
|
396
|
-
interface CreateArchitectureProfileOptions {
|
|
397
|
-
name: string;
|
|
398
|
-
layers: ArchitectureLayer[];
|
|
399
|
-
rules?: ArchitectureRule[];
|
|
400
|
-
}
|
|
401
|
-
interface ArchitectureLayerConfig {
|
|
402
|
-
name: string;
|
|
403
|
-
patterns: string[];
|
|
404
|
-
intentPrefixes: string[];
|
|
405
|
-
/** Optional layers do not warn when their patterns match no files. */
|
|
406
|
-
optional?: boolean;
|
|
407
|
-
}
|
|
408
|
-
interface ArkCheckConfig {
|
|
409
|
-
include: string[];
|
|
410
|
-
layers: ArchitectureLayerConfig[];
|
|
411
|
-
rules: ArchitectureRule[];
|
|
412
|
-
}
|
|
413
|
-
interface CreateElevenLayerArkConfigOptions {
|
|
414
|
-
/** Source root used in generated file patterns. Default: "src". */
|
|
415
|
-
rootDir?: string;
|
|
416
|
-
/** Include entries for ark-check. Default: [rootDir]. */
|
|
417
|
-
include?: string[];
|
|
418
|
-
/** Mark generated layers optional. Default: true. */
|
|
419
|
-
optionalLayers?: boolean;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
122
|
declare function createArchitectureProfile(options: CreateArchitectureProfileOptions): ArchitectureProfile;
|
|
423
123
|
declare const elevenLayerProfile: ArchitectureProfile;
|
|
424
124
|
declare function createElevenLayerArkConfig(options?: CreateElevenLayerArkConfigOptions): ArkCheckConfig;
|
|
425
125
|
|
|
426
|
-
/**
|
|
427
|
-
* Dependency Graph types.
|
|
428
|
-
*
|
|
429
|
-
* Used to model declared + observed relationships between intents,
|
|
430
|
-
* and to generate visualizations (Mermaid) and detect violations.
|
|
431
|
-
*/
|
|
432
|
-
|
|
433
|
-
interface GraphEdge {
|
|
434
|
-
from: string;
|
|
435
|
-
to: string;
|
|
436
|
-
kind?: 'declared' | 'observed' | 'produces';
|
|
437
|
-
}
|
|
438
|
-
interface GraphNode {
|
|
439
|
-
id: string;
|
|
440
|
-
kind?: string;
|
|
441
|
-
}
|
|
442
|
-
interface DependencyGraph {
|
|
443
|
-
/**
|
|
444
|
-
* Register a declared dependency between two semantic names.
|
|
445
|
-
*/
|
|
446
|
-
registerDependency(from: string, to: string, kind?: GraphEdge['kind']): void;
|
|
447
|
-
/**
|
|
448
|
-
* Register an observed event flow (producer -> consumer).
|
|
449
|
-
*/
|
|
450
|
-
registerEventFlow(producer: string, consumer: string): void;
|
|
451
|
-
/**
|
|
452
|
-
* Return all nodes.
|
|
453
|
-
*/
|
|
454
|
-
getNodes(): GraphNode[];
|
|
455
|
-
/**
|
|
456
|
-
* Return all edges.
|
|
457
|
-
*/
|
|
458
|
-
getEdges(): GraphEdge[];
|
|
459
|
-
/**
|
|
460
|
-
* Export as JSON.
|
|
461
|
-
*/
|
|
462
|
-
toJSON(): {
|
|
463
|
-
nodes: GraphNode[];
|
|
464
|
-
edges: GraphEdge[];
|
|
465
|
-
};
|
|
466
|
-
/**
|
|
467
|
-
* Export as Mermaid flowchart.
|
|
468
|
-
*/
|
|
469
|
-
toMermaid(): string;
|
|
470
|
-
/**
|
|
471
|
-
* Export as Mermaid flowchart grouped into profile layers.
|
|
472
|
-
*/
|
|
473
|
-
toLayerMermaid(profile: ArchitectureProfile): string;
|
|
474
|
-
/**
|
|
475
|
-
* Detect violations by running provided policies or simple rules.
|
|
476
|
-
* For simplicity here we accept predicates that return violation messages.
|
|
477
|
-
*/
|
|
478
|
-
detectViolations(rules?: Array<(edges: GraphEdge[]) => string[]>): string[];
|
|
479
|
-
}
|
|
480
|
-
|
|
481
126
|
/**
|
|
482
127
|
* DependencyGraph implementation.
|
|
483
128
|
*
|
|
@@ -554,55 +199,6 @@ declare function defineArchitectureProfilePolicy<Context extends {
|
|
|
554
199
|
relationships?: IntentRelationship[];
|
|
555
200
|
}>(profile: ArchitectureProfile, options?: Omit<LayerPolicyOptions, 'rules' | 'resolveLayer'>): Policy<Context>;
|
|
556
201
|
|
|
557
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
558
|
-
type AuditRecordType = 'event.published' | 'event.rawPublish' | 'event.intercepted' | 'interceptor.error' | 'policy.softViolation' | 'policy.hardViolation' | 'layer.observedViolation' | 'handler.error' | 'hook.error' | 'workflow.started' | 'workflow.step.completed' | 'workflow.step.failed' | 'workflow.compensation.completed' | 'workflow.completed' | 'workflow.failed' | 'projection.applied' | 'metadata.changed';
|
|
559
|
-
interface AuditRecord {
|
|
560
|
-
id: string;
|
|
561
|
-
type: AuditRecordType;
|
|
562
|
-
timestamp: string;
|
|
563
|
-
source?: string;
|
|
564
|
-
actor?: string;
|
|
565
|
-
intent?: string;
|
|
566
|
-
correlationId?: string;
|
|
567
|
-
causationId?: string;
|
|
568
|
-
subject?: string;
|
|
569
|
-
details?: unknown;
|
|
570
|
-
}
|
|
571
|
-
interface AuditRecordInput {
|
|
572
|
-
type: AuditRecordType;
|
|
573
|
-
timestamp?: string;
|
|
574
|
-
source?: string;
|
|
575
|
-
actor?: string;
|
|
576
|
-
intent?: string;
|
|
577
|
-
correlationId?: string;
|
|
578
|
-
causationId?: string;
|
|
579
|
-
subject?: string;
|
|
580
|
-
details?: unknown;
|
|
581
|
-
}
|
|
582
|
-
interface AuditQuery {
|
|
583
|
-
type?: AuditRecordType;
|
|
584
|
-
intent?: string;
|
|
585
|
-
correlationId?: string;
|
|
586
|
-
subject?: string;
|
|
587
|
-
since?: string;
|
|
588
|
-
until?: string;
|
|
589
|
-
limit?: number;
|
|
590
|
-
}
|
|
591
|
-
interface AuditStore {
|
|
592
|
-
append(record: AuditRecord): MaybePromise<void>;
|
|
593
|
-
query(query?: AuditQuery): MaybePromise<AuditRecord[]>;
|
|
594
|
-
clear(): MaybePromise<void>;
|
|
595
|
-
}
|
|
596
|
-
interface AuditTrail {
|
|
597
|
-
record(input: AuditRecordInput): Promise<AuditRecord>;
|
|
598
|
-
query(query?: AuditQuery): Promise<AuditRecord[]>;
|
|
599
|
-
clear(): Promise<void>;
|
|
600
|
-
}
|
|
601
|
-
interface CreateAuditTrailOptions {
|
|
602
|
-
store?: AuditStore;
|
|
603
|
-
maxRecords?: number;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
202
|
declare class InMemoryAuditStore implements AuditStore {
|
|
607
203
|
private readonly maxRecords?;
|
|
608
204
|
private readonly records;
|
|
@@ -613,47 +209,6 @@ declare class InMemoryAuditStore implements AuditStore {
|
|
|
613
209
|
}
|
|
614
210
|
declare function createAuditTrail(options?: CreateAuditTrailOptions): AuditTrail;
|
|
615
211
|
|
|
616
|
-
type EventSchemaFieldType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'unknown';
|
|
617
|
-
interface EventSchemaField {
|
|
618
|
-
type: EventSchemaFieldType;
|
|
619
|
-
required?: boolean;
|
|
620
|
-
description?: string;
|
|
621
|
-
/** Allowed literal values for this field. Compared with Object.is. */
|
|
622
|
-
enum?: unknown[];
|
|
623
|
-
/** Nested object fields when type is "object". */
|
|
624
|
-
fields?: EventPayloadSchema;
|
|
625
|
-
/** Array item schema when type is "array". */
|
|
626
|
-
items?: EventSchemaField;
|
|
627
|
-
}
|
|
628
|
-
type EventPayloadSchema = Record<string, EventSchemaField>;
|
|
629
|
-
interface EventContract {
|
|
630
|
-
intent: IntentName;
|
|
631
|
-
version: string;
|
|
632
|
-
schema?: EventPayloadSchema;
|
|
633
|
-
owner?: string;
|
|
634
|
-
rationale?: string;
|
|
635
|
-
deprecated?: boolean | string;
|
|
636
|
-
allowAdditionalFields?: boolean;
|
|
637
|
-
}
|
|
638
|
-
interface EventContractIssue {
|
|
639
|
-
intent: string;
|
|
640
|
-
version?: string;
|
|
641
|
-
field?: string;
|
|
642
|
-
message: string;
|
|
643
|
-
}
|
|
644
|
-
interface EventContractValidationResult {
|
|
645
|
-
ok: boolean;
|
|
646
|
-
contract?: EventContract;
|
|
647
|
-
issues: EventContractIssue[];
|
|
648
|
-
}
|
|
649
|
-
interface EventContractRegistry {
|
|
650
|
-
register(contract: EventContract): void;
|
|
651
|
-
get(intent: string, version?: string): EventContract | undefined;
|
|
652
|
-
list(intent?: string): EventContract[];
|
|
653
|
-
validate(event: DomainEvent): EventContractValidationResult;
|
|
654
|
-
clear(): void;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
212
|
declare class EventContractRegistryImpl implements EventContractRegistry {
|
|
658
213
|
private readonly contracts;
|
|
659
214
|
register(contract: EventContract): void;
|
|
@@ -665,24 +220,6 @@ declare class EventContractRegistryImpl implements EventContractRegistry {
|
|
|
665
220
|
}
|
|
666
221
|
declare function createEventContractRegistry(): EventContractRegistry;
|
|
667
222
|
|
|
668
|
-
type OutboxStatus = 'pending' | 'dispatched' | 'failed';
|
|
669
|
-
interface OutboxRecord {
|
|
670
|
-
id: string;
|
|
671
|
-
event: DomainEvent;
|
|
672
|
-
status: OutboxStatus;
|
|
673
|
-
attempts: number;
|
|
674
|
-
createdAt: string;
|
|
675
|
-
updatedAt: string;
|
|
676
|
-
error?: string;
|
|
677
|
-
}
|
|
678
|
-
interface OutboxStore {
|
|
679
|
-
enqueue(event: DomainEvent): Promise<OutboxRecord>;
|
|
680
|
-
markDispatched(id: string): Promise<void>;
|
|
681
|
-
markFailed(id: string, error: unknown): Promise<void>;
|
|
682
|
-
list(status?: OutboxStatus): Promise<OutboxRecord[]>;
|
|
683
|
-
clear(): Promise<void>;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
223
|
declare class InMemoryOutboxStore implements OutboxStore {
|
|
687
224
|
private readonly records;
|
|
688
225
|
enqueue(event: DomainEvent): Promise<OutboxRecord>;
|
|
@@ -692,193 +229,6 @@ declare class InMemoryOutboxStore implements OutboxStore {
|
|
|
692
229
|
clear(): Promise<void>;
|
|
693
230
|
}
|
|
694
231
|
|
|
695
|
-
/**
|
|
696
|
-
* Event Bus types for the Ark kernel.
|
|
697
|
-
*
|
|
698
|
-
* The Event Bus is the central nervous system for Domain Events.
|
|
699
|
-
* It provides publish/subscribe, history for observability, and metadata handling.
|
|
700
|
-
*/
|
|
701
|
-
|
|
702
|
-
/** Standard trace record for observability and agent consumption. */
|
|
703
|
-
type TraceRecordType = 'event.published' | 'event.rawPublish' | 'event.intercepted' | 'interceptor.error' | 'policy.hardViolation' | 'policy.softViolation' | 'layer.observedViolation' | 'handler.error' | 'hook.error';
|
|
704
|
-
/**
|
|
705
|
-
* Runtime enforcement mode for observed producer→event layer flows.
|
|
706
|
-
* - 'off': flows are recorded (for drift reports) but never enforced.
|
|
707
|
-
* - 'soft': a `layer.observedViolation` trace + audit record is emitted; publish proceeds.
|
|
708
|
-
* - 'hard': publish throws `ObservedLayerFlowViolationError` before the event reaches
|
|
709
|
-
* history, outbox, or subscribers.
|
|
710
|
-
*/
|
|
711
|
-
type ObservedLayerFlowMode = 'off' | 'soft' | 'hard';
|
|
712
|
-
interface TraceRecord {
|
|
713
|
-
type: TraceRecordType;
|
|
714
|
-
timestamp: string;
|
|
715
|
-
intent: string;
|
|
716
|
-
correlationId?: string;
|
|
717
|
-
traceId?: string;
|
|
718
|
-
spanId?: string;
|
|
719
|
-
details?: unknown;
|
|
720
|
-
}
|
|
721
|
-
type TraceSink = (record: TraceRecord) => void;
|
|
722
|
-
/**
|
|
723
|
-
* Options when creating an EventBus.
|
|
724
|
-
*/
|
|
725
|
-
interface EventBusOptions<Context = unknown> {
|
|
726
|
-
/** Optional hook called after every successful publish */
|
|
727
|
-
onPublish?: (event: DomainEvent) => void | Promise<void>;
|
|
728
|
-
/** Native audit trail used to persist publish, policy, and handler events. */
|
|
729
|
-
auditTrail?: AuditTrail;
|
|
730
|
-
/** Event contracts used to validate payload shape and event versions. */
|
|
731
|
-
eventContracts?: EventContractRegistry;
|
|
732
|
-
/** When true, events without a registered contract are rejected. */
|
|
733
|
-
strictEventContracts?: boolean;
|
|
734
|
-
/** When true, metadata.source must be explicit and not "unknown". */
|
|
735
|
-
requireKnownSource?: boolean;
|
|
736
|
-
/**
|
|
737
|
-
* Architecture profile used to enforce the OBSERVED producer→event layer flow at
|
|
738
|
-
* publish time. Required for `enforceObservedLayerFlow` to have effect.
|
|
739
|
-
*/
|
|
740
|
-
architectureProfile?: ArchitectureProfile;
|
|
741
|
-
/**
|
|
742
|
-
* Enforce each published event's real producer→event flow (metadata.source → intent)
|
|
743
|
-
* against `architectureProfile` layer rules at runtime. Unlike the declared-model layer
|
|
744
|
-
* policy, this checks what the system actually did. Default: 'off'.
|
|
745
|
-
*/
|
|
746
|
-
enforceObservedLayerFlow?: ObservedLayerFlowMode;
|
|
747
|
-
/** Optional outbox store for durable delivery handoff. */
|
|
748
|
-
outbox?: OutboxStore;
|
|
749
|
-
/** Stable id stamped into event metadata for this kernel/event bus instance. */
|
|
750
|
-
instanceId?: string;
|
|
751
|
-
/** Lightweight tracing hooks for OpenTelemetry or custom tracer bridges. */
|
|
752
|
-
traceSinks?: TraceSink[];
|
|
753
|
-
/** Called when soft policies produce violations (publish still proceeds). */
|
|
754
|
-
onSoftViolation?: (result: PolicyEvaluationResult, event: DomainEvent) => void | Promise<void>;
|
|
755
|
-
/** Called when a subscriber handler throws or rejects. */
|
|
756
|
-
onHandlerError?: (error: unknown, event: DomainEvent, intentName: string) => void | Promise<void>;
|
|
757
|
-
/** When true, rethrow handler errors after calling onHandlerError. Default: false. */
|
|
758
|
-
rethrowHandlerErrors?: boolean;
|
|
759
|
-
/**
|
|
760
|
-
* Policies to evaluate on every publish.
|
|
761
|
-
* If provided, they run before subscribers are notified.
|
|
762
|
-
* Hard violations will cause publish to throw.
|
|
763
|
-
*/
|
|
764
|
-
policies?: Policy<Context>[];
|
|
765
|
-
/**
|
|
766
|
-
* Function to build the context object passed to policies for a given event.
|
|
767
|
-
* Default: { event }, or { event, relationships, edges } when registry/graph provided.
|
|
768
|
-
*/
|
|
769
|
-
getPolicyContext?: (event: DomainEvent) => Context;
|
|
770
|
-
/**
|
|
771
|
-
* Intent registry whose relationships are injected into the default policy context.
|
|
772
|
-
* Enables layer policies (e.g. architecturalPolicies.layerIsolation) on publish.
|
|
773
|
-
*/
|
|
774
|
-
intentRegistry?: IntentRegistry;
|
|
775
|
-
/**
|
|
776
|
-
* Dependency graph whose edges are injected into the default policy context.
|
|
777
|
-
*/
|
|
778
|
-
dependencyGraph?: DependencyGraph;
|
|
779
|
-
/**
|
|
780
|
-
* Pre-configured PolicyEngine to use (alternative to policies array).
|
|
781
|
-
*/
|
|
782
|
-
policyEngine?: PolicyEngine<Context>;
|
|
783
|
-
/**
|
|
784
|
-
* Maximum publish history entries to retain. Oldest evicted when exceeded.
|
|
785
|
-
* Default: unlimited.
|
|
786
|
-
*/
|
|
787
|
-
maxHistorySize?: number;
|
|
788
|
-
/**
|
|
789
|
-
* When true (default: true if intentRegistry is provided), reject publish/subscribe
|
|
790
|
-
* for intents not registered in intentRegistry and optionally validate naming.
|
|
791
|
-
*/
|
|
792
|
-
strictRegistry?: boolean;
|
|
793
|
-
/**
|
|
794
|
-
* When true (default: matches strictRegistry), validate intent names follow
|
|
795
|
-
* Domain.* / Application.* / Adapter.* / Workflow.* conventions at runtime.
|
|
796
|
-
*/
|
|
797
|
-
validateIntentNaming?: boolean;
|
|
798
|
-
}
|
|
799
|
-
/**
|
|
800
|
-
* A subscriber is a function that receives events of a specific intent.
|
|
801
|
-
*/
|
|
802
|
-
type EventHandler<N extends IntentName, P = unknown> = (event: DomainEvent<N, P>) => void | Promise<void>;
|
|
803
|
-
type EventPayloadPatch = Record<string, unknown> | unknown[];
|
|
804
|
-
interface EventInterceptorContext<N extends IntentName = IntentName, P = unknown> {
|
|
805
|
-
readonly event: Readonly<DomainEvent<N, P>>;
|
|
806
|
-
intercept(patch: EventPayloadPatch): void;
|
|
807
|
-
}
|
|
808
|
-
type EventInterceptor<N extends IntentName = IntentName, P = unknown> = (context: EventInterceptorContext<N, P>) => void | Promise<void>;
|
|
809
|
-
interface EventInterceptionInfo {
|
|
810
|
-
registrationId: string;
|
|
811
|
-
interceptorId: string;
|
|
812
|
-
intent: string;
|
|
813
|
-
createdAt: string;
|
|
814
|
-
lastInterceptedAt?: string;
|
|
815
|
-
}
|
|
816
|
-
/**
|
|
817
|
-
* Unsubscribe function returned by subscribe.
|
|
818
|
-
*/
|
|
819
|
-
type Unsubscribe = () => void;
|
|
820
|
-
/**
|
|
821
|
-
* Record of a published event for observability.
|
|
822
|
-
*/
|
|
823
|
-
interface PublishedEventRecord {
|
|
824
|
-
event: DomainEvent;
|
|
825
|
-
publishedAt: string;
|
|
826
|
-
subscribersNotified: number;
|
|
827
|
-
}
|
|
828
|
-
interface EventPublisher {
|
|
829
|
-
readonly source: string;
|
|
830
|
-
publish<N extends IntentName, P>(intent: IntentCreator<N, P>, payload: P, metadata?: Partial<EventMetadata>): Promise<void>;
|
|
831
|
-
}
|
|
832
|
-
/**
|
|
833
|
-
* The public EventBus interface.
|
|
834
|
-
*/
|
|
835
|
-
interface EventBus {
|
|
836
|
-
/**
|
|
837
|
-
* Publish an event.
|
|
838
|
-
* Accepts either a pre-built DomainEvent or an IntentCreator + payload (plus optional metadata).
|
|
839
|
-
*/
|
|
840
|
-
publish<N extends IntentName, P>(eventOrCreator: DomainEvent<N, P> | IntentCreator<N, P>, payloadOrMeta?: P | Partial<EventMetadata>, metadata?: Partial<EventMetadata>): Promise<void>;
|
|
841
|
-
/**
|
|
842
|
-
* Create a source-bound publisher capability. The returned publisher stamps
|
|
843
|
-
* metadata.source internally and rejects attempts to publish as another source.
|
|
844
|
-
*/
|
|
845
|
-
createPublisher<N extends IntentName, P>(source: N | IntentCreator<N, P>): EventPublisher;
|
|
846
|
-
/**
|
|
847
|
-
* Subscribe to events for a specific intent (by name or creator).
|
|
848
|
-
* Returns an unsubscribe function.
|
|
849
|
-
*/
|
|
850
|
-
subscribe<N extends IntentName, P>(intent: N | IntentCreator<N, P>, handler: EventHandler<N, P>): Unsubscribe;
|
|
851
|
-
/**
|
|
852
|
-
* Register an add-only interceptor for one intent.
|
|
853
|
-
* Interceptors may enrich payloads, but cannot overwrite existing payload fields.
|
|
854
|
-
*/
|
|
855
|
-
registerInterceptor<N extends IntentName, P>(intent: N | IntentCreator<N, P>, interceptor: EventInterceptor<N, P>, interceptorId?: string): string;
|
|
856
|
-
/**
|
|
857
|
-
* Remove a registered interceptor by registration id.
|
|
858
|
-
*/
|
|
859
|
-
unregisterInterceptor(registrationId: string): boolean;
|
|
860
|
-
/**
|
|
861
|
-
* List registered interceptors.
|
|
862
|
-
*/
|
|
863
|
-
listInterceptors(intent?: string): EventInterceptionInfo[];
|
|
864
|
-
/**
|
|
865
|
-
* Returns the history of published events (for observability and testing).
|
|
866
|
-
*/
|
|
867
|
-
getHistory(): PublishedEventRecord[];
|
|
868
|
-
/**
|
|
869
|
-
* Clears publish history (useful in tests).
|
|
870
|
-
*/
|
|
871
|
-
clearHistory(): void;
|
|
872
|
-
/**
|
|
873
|
-
* Returns the observability trace (publish, soft violations, handler errors).
|
|
874
|
-
*/
|
|
875
|
-
getTrace(): TraceRecord[];
|
|
876
|
-
/**
|
|
877
|
-
* Clears the observability trace.
|
|
878
|
-
*/
|
|
879
|
-
clearTrace(): void;
|
|
880
|
-
}
|
|
881
|
-
|
|
882
232
|
/**
|
|
883
233
|
* EventBus implementation.
|
|
884
234
|
*
|
|
@@ -971,133 +321,14 @@ declare class ObservedLayerFlowViolationError extends Error {
|
|
|
971
321
|
constructor(source: string, intentName: string, fromLayer: string, toLayer: string, message?: string);
|
|
972
322
|
}
|
|
973
323
|
|
|
974
|
-
interface ObservabilityFlow {
|
|
975
|
-
from: string;
|
|
976
|
-
to: string;
|
|
977
|
-
}
|
|
978
|
-
interface ObservabilityDriftReport {
|
|
979
|
-
generatedAt: string;
|
|
980
|
-
declaredProductions: ObservabilityFlow[];
|
|
981
|
-
observedProductions: ObservabilityFlow[];
|
|
982
|
-
declaredButUnobserved: ObservabilityFlow[];
|
|
983
|
-
observedButUndeclared: ObservabilityFlow[];
|
|
984
|
-
unknownSources: ObservabilityFlow[];
|
|
985
|
-
unregisteredObservedSources: string[];
|
|
986
|
-
unregisteredObservedIntents: string[];
|
|
987
|
-
registeredButNeverObserved: string[];
|
|
988
|
-
}
|
|
989
|
-
interface ObservabilityReporter {
|
|
990
|
-
report(): ObservabilityDriftReport;
|
|
991
|
-
}
|
|
992
|
-
interface CreateObservabilityReporterOptions {
|
|
993
|
-
registry?: IntentRegistry;
|
|
994
|
-
eventBus?: EventBus;
|
|
995
|
-
graph?: DependencyGraph;
|
|
996
|
-
}
|
|
997
|
-
|
|
998
324
|
declare function createObservabilityReporter(options: CreateObservabilityReporterOptions): ObservabilityReporter;
|
|
999
325
|
|
|
1000
|
-
/**
|
|
1001
|
-
* Metadata System (basic) for extensibility.
|
|
1002
|
-
*
|
|
1003
|
-
* Allows declaring entities, fields and simple rules/behaviors as data.
|
|
1004
|
-
* This can be used by tools, codegen, or AI to understand the domain without hardcoding.
|
|
1005
|
-
*/
|
|
1006
|
-
interface FieldMeta {
|
|
1007
|
-
type: string;
|
|
1008
|
-
identity?: boolean;
|
|
1009
|
-
required?: boolean;
|
|
1010
|
-
description?: string;
|
|
1011
|
-
relation?: {
|
|
1012
|
-
entity: string;
|
|
1013
|
-
kind?: 'one' | 'many';
|
|
1014
|
-
};
|
|
1015
|
-
readonly?: boolean;
|
|
1016
|
-
deprecated?: boolean | string;
|
|
1017
|
-
tags?: string[];
|
|
1018
|
-
[key: string]: unknown;
|
|
1019
|
-
}
|
|
1020
|
-
interface EntityRuleMeta {
|
|
1021
|
-
name: string;
|
|
1022
|
-
description?: string;
|
|
1023
|
-
severity?: 'hard' | 'soft';
|
|
1024
|
-
}
|
|
1025
|
-
interface EntityMeta {
|
|
1026
|
-
name: string;
|
|
1027
|
-
version?: string;
|
|
1028
|
-
owner?: string;
|
|
1029
|
-
layer?: string;
|
|
1030
|
-
tags?: string[];
|
|
1031
|
-
fields: Record<string, FieldMeta>;
|
|
1032
|
-
rules?: EntityRuleMeta[];
|
|
1033
|
-
/** Intent names this entity emits (domain events). */
|
|
1034
|
-
emits?: string[];
|
|
1035
|
-
/** Intent names this entity consumes / reacts to. */
|
|
1036
|
-
consumes?: string[];
|
|
1037
|
-
/** Read-model or projection names that derive from this entity. */
|
|
1038
|
-
projections?: string[];
|
|
1039
|
-
deprecated?: boolean | string;
|
|
1040
|
-
[key: string]: unknown;
|
|
1041
|
-
}
|
|
1042
|
-
interface MetadataRegistrationOptions {
|
|
1043
|
-
allowOverwrite?: boolean;
|
|
1044
|
-
}
|
|
1045
|
-
interface MetadataIssue {
|
|
1046
|
-
entity: string;
|
|
1047
|
-
field?: string;
|
|
1048
|
-
message: string;
|
|
1049
|
-
}
|
|
1050
|
-
interface MetadataValidationResult {
|
|
1051
|
-
ok: boolean;
|
|
1052
|
-
issues: MetadataIssue[];
|
|
1053
|
-
}
|
|
1054
|
-
interface MetadataRegistry {
|
|
1055
|
-
entity(name: string, meta: Omit<EntityMeta, 'name'>, options?: MetadataRegistrationOptions): EntityMeta;
|
|
1056
|
-
getEntity(name: string): EntityMeta | undefined;
|
|
1057
|
-
listEntities(): EntityMeta[];
|
|
1058
|
-
findEntitiesByIntent(intentName: string): EntityMeta[];
|
|
1059
|
-
validate(): MetadataValidationResult;
|
|
1060
|
-
toJSON(): EntityMeta[];
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
326
|
/**
|
|
1064
327
|
* Basic MetadataRegistry implementation.
|
|
1065
328
|
*/
|
|
1066
329
|
|
|
1067
330
|
declare function createMetadataRegistry(): MetadataRegistry;
|
|
1068
331
|
|
|
1069
|
-
interface ProjectionDefinition<State = unknown> {
|
|
1070
|
-
name: string;
|
|
1071
|
-
sourceIntents: IntentName[];
|
|
1072
|
-
initialState: State | (() => State);
|
|
1073
|
-
project(event: DomainEvent<IntentName, unknown>, state: State): MaybePromise<State>;
|
|
1074
|
-
}
|
|
1075
|
-
interface ProjectionCheckpoint {
|
|
1076
|
-
projection: string;
|
|
1077
|
-
appliedCount: number;
|
|
1078
|
-
lastIntent?: string;
|
|
1079
|
-
lastCorrelationId?: string;
|
|
1080
|
-
updatedAt?: string;
|
|
1081
|
-
}
|
|
1082
|
-
interface ReadModelStore {
|
|
1083
|
-
load<State = unknown>(name: string): MaybePromise<State | undefined>;
|
|
1084
|
-
save<State = unknown>(name: string, state: State): MaybePromise<void>;
|
|
1085
|
-
clear(name?: string): MaybePromise<void>;
|
|
1086
|
-
}
|
|
1087
|
-
interface ProjectionRegistry {
|
|
1088
|
-
register<State>(definition: ProjectionDefinition<State>): void;
|
|
1089
|
-
list(): ProjectionDefinition[];
|
|
1090
|
-
apply(event: DomainEvent<IntentName, unknown>): Promise<string[]>;
|
|
1091
|
-
getState<State = unknown>(name: string): Promise<State | undefined>;
|
|
1092
|
-
getCheckpoint(name: string): ProjectionCheckpoint | undefined;
|
|
1093
|
-
getCheckpoints(): ProjectionCheckpoint[];
|
|
1094
|
-
clear(): Promise<void>;
|
|
1095
|
-
}
|
|
1096
|
-
interface CreateProjectionRegistryOptions {
|
|
1097
|
-
store?: ReadModelStore;
|
|
1098
|
-
auditTrail?: AuditTrail;
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
332
|
declare class InMemoryReadModelStore implements ReadModelStore {
|
|
1102
333
|
private readonly states;
|
|
1103
334
|
load<State = unknown>(name: string): State | undefined;
|
|
@@ -1106,71 +337,6 @@ declare class InMemoryReadModelStore implements ReadModelStore {
|
|
|
1106
337
|
}
|
|
1107
338
|
declare function createProjectionRegistry(options?: CreateProjectionRegistryOptions): ProjectionRegistry;
|
|
1108
339
|
|
|
1109
|
-
/**
|
|
1110
|
-
* Machine-readable manifest types for agent and tooling consumption.
|
|
1111
|
-
*/
|
|
1112
|
-
|
|
1113
|
-
interface ArkManifestIntent {
|
|
1114
|
-
name: string;
|
|
1115
|
-
dependencies: string[];
|
|
1116
|
-
productions: string[];
|
|
1117
|
-
}
|
|
1118
|
-
interface ArkManifestPolicy {
|
|
1119
|
-
/** Stable slug for agents (derived from policy name). */
|
|
1120
|
-
id: string;
|
|
1121
|
-
name: string;
|
|
1122
|
-
severity: 'hard' | 'soft';
|
|
1123
|
-
tags?: string[];
|
|
1124
|
-
description?: string;
|
|
1125
|
-
owner?: string;
|
|
1126
|
-
version?: string;
|
|
1127
|
-
rationale?: string;
|
|
1128
|
-
enforcementMode?: PolicyEnforcementMode;
|
|
1129
|
-
deprecated?: boolean | string;
|
|
1130
|
-
replacedBy?: string;
|
|
1131
|
-
}
|
|
1132
|
-
interface ArkManifestEntityLink {
|
|
1133
|
-
entity: string;
|
|
1134
|
-
emits?: string[];
|
|
1135
|
-
consumes?: string[];
|
|
1136
|
-
}
|
|
1137
|
-
interface ArkManifestGraph {
|
|
1138
|
-
nodes: GraphNode[];
|
|
1139
|
-
edges: GraphEdge[];
|
|
1140
|
-
}
|
|
1141
|
-
interface ArkManifestArchitecture {
|
|
1142
|
-
profile: string;
|
|
1143
|
-
layers: ArchitectureLayer[];
|
|
1144
|
-
rules: ArchitectureRule[];
|
|
1145
|
-
}
|
|
1146
|
-
interface ArkManifestProjection {
|
|
1147
|
-
name: string;
|
|
1148
|
-
sourceIntents: string[];
|
|
1149
|
-
checkpoint?: ProjectionCheckpoint;
|
|
1150
|
-
}
|
|
1151
|
-
interface ArkManifestData {
|
|
1152
|
-
/** Manifest schema version for agent/tooling compatibility. */
|
|
1153
|
-
schemaVersion: string;
|
|
1154
|
-
version: string;
|
|
1155
|
-
exportedAt: string;
|
|
1156
|
-
intents: ArkManifestIntent[];
|
|
1157
|
-
relationships: IntentRelationship[];
|
|
1158
|
-
policies: ArkManifestPolicy[];
|
|
1159
|
-
entities: EntityMeta[];
|
|
1160
|
-
graph: ArkManifestGraph;
|
|
1161
|
-
architecture?: ArkManifestArchitecture;
|
|
1162
|
-
projections: ArkManifestProjection[];
|
|
1163
|
-
eventContracts: EventContract[];
|
|
1164
|
-
observability?: ObservabilityDriftReport;
|
|
1165
|
-
/** Cross-registry links for agent contract discovery. */
|
|
1166
|
-
links: {
|
|
1167
|
-
entityIntents: ArkManifestEntityLink[];
|
|
1168
|
-
};
|
|
1169
|
-
}
|
|
1170
|
-
interface ArkManifest {
|
|
1171
|
-
toJSON(): ArkManifestData;
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
340
|
/** Current Ark manifest JSON schema version. */
|
|
1175
341
|
declare const MANIFEST_SCHEMA_VERSION = "1.0";
|
|
1176
342
|
|
|
@@ -1194,81 +360,6 @@ interface CreateArkManifestOptions {
|
|
|
1194
360
|
*/
|
|
1195
361
|
declare function createArkManifest(options?: CreateArkManifestOptions): ArkManifest;
|
|
1196
362
|
|
|
1197
|
-
/**
|
|
1198
|
-
* Workflow / Saga support.
|
|
1199
|
-
*/
|
|
1200
|
-
|
|
1201
|
-
type SagaContext = Record<string, unknown>;
|
|
1202
|
-
type SagaStatus = 'idle' | 'running' | 'compensating' | 'completed' | 'failed';
|
|
1203
|
-
type WorkflowStatus = SagaStatus | 'waiting';
|
|
1204
|
-
interface RetryPolicy {
|
|
1205
|
-
attempts: number;
|
|
1206
|
-
delayMs?: number;
|
|
1207
|
-
}
|
|
1208
|
-
interface WorkflowStep<P extends SagaContext = SagaContext> {
|
|
1209
|
-
name: string;
|
|
1210
|
-
onEvent?: IntentName;
|
|
1211
|
-
retry?: RetryPolicy;
|
|
1212
|
-
timeoutMs?: number;
|
|
1213
|
-
execute: (payload: P, bus: EventBus) => MaybePromise<Partial<P> | void>;
|
|
1214
|
-
compensate?: (payload: P, bus: EventBus, error?: unknown) => MaybePromise<void>;
|
|
1215
|
-
}
|
|
1216
|
-
interface WorkflowStartTrigger<P extends SagaContext = SagaContext> {
|
|
1217
|
-
intent: IntentName;
|
|
1218
|
-
mapEventToPayload(event: DomainEvent<IntentName, unknown>): P;
|
|
1219
|
-
}
|
|
1220
|
-
interface WorkflowDefinition<P extends SagaContext = SagaContext> {
|
|
1221
|
-
name: string;
|
|
1222
|
-
steps: WorkflowStep<P>[];
|
|
1223
|
-
startOn?: WorkflowStartTrigger<P>;
|
|
1224
|
-
}
|
|
1225
|
-
interface WorkflowSnapshot<P extends SagaContext = SagaContext> {
|
|
1226
|
-
id: string;
|
|
1227
|
-
workflowName: string;
|
|
1228
|
-
status: WorkflowStatus;
|
|
1229
|
-
context: P;
|
|
1230
|
-
completedSteps: string[];
|
|
1231
|
-
currentStep?: string;
|
|
1232
|
-
failedStep?: string;
|
|
1233
|
-
attempts: Record<string, number>;
|
|
1234
|
-
startedAt: string;
|
|
1235
|
-
updatedAt: string;
|
|
1236
|
-
completedAt?: string;
|
|
1237
|
-
error?: string;
|
|
1238
|
-
}
|
|
1239
|
-
interface WorkflowStore {
|
|
1240
|
-
save<P extends SagaContext>(snapshot: WorkflowSnapshot<P>): MaybePromise<void>;
|
|
1241
|
-
get<P extends SagaContext = SagaContext>(id: string): MaybePromise<WorkflowSnapshot<P> | undefined>;
|
|
1242
|
-
list(workflowName?: string): MaybePromise<WorkflowSnapshot[]>;
|
|
1243
|
-
clear(): MaybePromise<void>;
|
|
1244
|
-
}
|
|
1245
|
-
interface WorkflowEngine {
|
|
1246
|
-
register<P extends SagaContext>(definition: WorkflowDefinition<P>): void;
|
|
1247
|
-
start<P extends SagaContext>(workflowName: string, initialPayload: P, options?: {
|
|
1248
|
-
id?: string;
|
|
1249
|
-
}): Promise<WorkflowSnapshot<P>>;
|
|
1250
|
-
get<P extends SagaContext = SagaContext>(id: string): Promise<WorkflowSnapshot<P> | undefined>;
|
|
1251
|
-
list(workflowName?: string): Promise<WorkflowSnapshot[]>;
|
|
1252
|
-
}
|
|
1253
|
-
interface CreateWorkflowEngineOptions {
|
|
1254
|
-
store?: WorkflowStore;
|
|
1255
|
-
auditTrail?: AuditTrail;
|
|
1256
|
-
defaultRetry?: RetryPolicy;
|
|
1257
|
-
}
|
|
1258
|
-
interface SagaStep<P extends SagaContext = SagaContext> extends WorkflowStep<P> {
|
|
1259
|
-
}
|
|
1260
|
-
interface SagaDefinition<P extends SagaContext = SagaContext> {
|
|
1261
|
-
name: string;
|
|
1262
|
-
steps: SagaStep<P>[];
|
|
1263
|
-
}
|
|
1264
|
-
interface SagaInstance<P extends SagaContext = SagaContext> {
|
|
1265
|
-
id: string;
|
|
1266
|
-
definition: SagaDefinition<P>;
|
|
1267
|
-
readonly status: SagaStatus;
|
|
1268
|
-
readonly completedSteps: string[];
|
|
1269
|
-
run(initialPayload: P): Promise<void>;
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
363
|
/**
|
|
1273
364
|
* In-process workflow engine with durable-store seams.
|
|
1274
365
|
*/
|
|
@@ -1285,50 +376,6 @@ declare function createSaga<P extends SagaContext = SagaContext>(def: SagaDefini
|
|
|
1285
376
|
id?: string;
|
|
1286
377
|
}): SagaInstance<P>;
|
|
1287
378
|
|
|
1288
|
-
interface ArkKernel {
|
|
1289
|
-
instanceId: string;
|
|
1290
|
-
profile: ArchitectureProfile;
|
|
1291
|
-
registry: IntentRegistry;
|
|
1292
|
-
graph: DependencyGraph;
|
|
1293
|
-
metadata: MetadataRegistry;
|
|
1294
|
-
auditTrail: AuditTrail;
|
|
1295
|
-
eventContracts: EventContractRegistry;
|
|
1296
|
-
outbox: OutboxStore;
|
|
1297
|
-
projections: ProjectionRegistry;
|
|
1298
|
-
policyEngine: PolicyEngine;
|
|
1299
|
-
eventBus: EventBus;
|
|
1300
|
-
workflowEngine: WorkflowEngine;
|
|
1301
|
-
observability: ObservabilityReporter;
|
|
1302
|
-
publisher<N extends IntentName, P>(source: N | IntentCreator<N, P>): EventPublisher;
|
|
1303
|
-
syncGraph(): void;
|
|
1304
|
-
manifest(): ArkManifest;
|
|
1305
|
-
}
|
|
1306
|
-
interface CreateArkKernelOptions {
|
|
1307
|
-
/**
|
|
1308
|
-
* When true (default), createArkKernel uses the hardened runtime defaults:
|
|
1309
|
-
* strict event contracts and hard observed-layer enforcement.
|
|
1310
|
-
* Set to false only for explicit migration/legacy paths.
|
|
1311
|
-
*/
|
|
1312
|
-
strict?: boolean;
|
|
1313
|
-
profile?: ArchitectureProfile;
|
|
1314
|
-
policies?: Policy[];
|
|
1315
|
-
auditTrail?: AuditTrail;
|
|
1316
|
-
eventContracts?: EventContractRegistry;
|
|
1317
|
-
outbox?: OutboxStore;
|
|
1318
|
-
metadata?: MetadataRegistry;
|
|
1319
|
-
projections?: ProjectionRegistry;
|
|
1320
|
-
maxHistorySize?: number;
|
|
1321
|
-
autoApplyProjections?: boolean;
|
|
1322
|
-
strictEventContracts?: boolean;
|
|
1323
|
-
requireKnownSource?: boolean;
|
|
1324
|
-
/**
|
|
1325
|
-
* Enforce observed producer→event layer flows against the profile at runtime.
|
|
1326
|
-
* Defaults to 'hard' when strict is true and 'off' when strict is false.
|
|
1327
|
-
*/
|
|
1328
|
-
enforceObservedLayerFlow?: ObservedLayerFlowMode;
|
|
1329
|
-
instanceId?: string;
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
379
|
declare function createArkKernel(options?: CreateArkKernelOptions): ArkKernel;
|
|
1333
380
|
declare function createStrictArkKernel(options?: CreateArkKernelOptions): ArkKernel;
|
|
1334
381
|
declare function createLenientArkKernel(options?: CreateArkKernelOptions): ArkKernel;
|
|
@@ -1493,4 +540,4 @@ interface AICodeGateOptions<Context = AICodeGateContext> {
|
|
|
1493
540
|
}
|
|
1494
541
|
declare function createAICodeGate<Context = AICodeGateContext>(options?: AICodeGateOptions<Context>): AICodeGate<Context>;
|
|
1495
542
|
|
|
1496
|
-
export { type AICodeGate, type AICodeGateContext, type AICodeGateOptions, type AICodeGateResult, type AICodeGateViolation, type AIGateExtension, type Adapter, type AdapterGovernanceIssue, type AdapterGovernanceResult,
|
|
543
|
+
export { type AICodeGate, type AICodeGateContext, type AICodeGateOptions, type AICodeGateResult, type AICodeGateViolation, type AIGateExtension, type Adapter, type AdapterGovernanceIssue, type AdapterGovernanceResult, ArchitectureProfile, ArkCheckConfig, ArkKernel, ArkManifest, type ArkTestHarness, type ArkTestSnapshot, AuditQuery, AuditRecord, AuditStore, AuditTrail, type BuildPublishPolicyContextOptions, type ContractCheckResult, type CreateAdapterOptions, CreateArchitectureProfileOptions, CreateArkKernelOptions, type CreateArkManifestOptions, CreateAuditTrailOptions, CreateElevenLayerArkConfigOptions, CreateObservabilityReporterOptions, CreateProjectionRegistryOptions, CreateWorkflowEngineOptions, DefineIntentOptions, type DefinePolicyOptions, type DefinePortOptions, DependencyGraph, DomainEvent, EventBus, EventBusOptions, EventContract, EventContractRegistry, EventContractRegistryImpl, EventContractValidationResult, EventContractViolationError, GraphEdge, type GraphPolicyContext, InMemoryAuditStore, InMemoryOutboxStore, InMemoryReadModelStore, InMemoryWorkflowStore, IntentCreator, IntentCreator as IntentDefinition, IntentName, type IntentNameValidation, IntentRegistry, IntentRelationship, InvalidIntentNameError, type LayerFlowRule, LayerPolicyContextError, type LayerPolicyOptions, MANIFEST_SCHEMA_VERSION, MetadataRegistry, ObservabilityDriftReport, ObservabilityReporter, ObservedLayerFlowViolationError, OutboxRecord, OutboxStatus, OutboxStore, Policy, PolicyEnforcementMode, PolicyEngine, PolicySeverity, PolicyViolation, PolicyViolationError, type Port, ProjectionRegistry, type PublishPolicyContext, ReadModelStore, SagaDefinition, SagaInstance, SourceMetadataOverrideError, type SyncRegistryOptions, TraceRecord, TraceRecordType, UnknownEventSourceError, UnregisteredIntentError, WorkflowEngine, WorkflowSnapshot, WorkflowStore, architecturalPolicies, buildPublishPolicyContext, checkAdapterGovernance, checkContract, createAICodeGate, createAdapter, createArchitectureProfile, createArkKernel, createArkManifest, createArkTestHarness, createAuditTrail, createDependencyGraph, createElevenLayerArkConfig, createEventBus, createEventContractRegistry, createIntentRegistry, createLenientArkKernel, createMetadataRegistry, createObservabilityReporter, createProjectionRegistry, createSaga, createStrictArkKernel, createWorkflowEngine, defaultIntentRegistry, defineArchitectureProfilePolicy, defineIntent, defineLayerPolicy, definePolicy, definePort, definePublishPolicy, elevenLayerProfile, isLayerPolicy, syncRegistryToGraph, validateIntentName, version };
|