arkgate 4.7.5 → 4.8.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/CHANGELOG.md +39 -3
- package/README.md +24 -12
- package/bin/lib/analysis-engine.mjs +6 -6
- package/bin/lib/ark-order-error.mjs +18 -0
- package/bin/lib/ark-order-facts.mjs +53 -0
- package/bin/lib/ark-order-invariants.mjs +160 -0
- package/bin/lib/ark-order-sensors.mjs +118 -0
- package/bin/lib/ark-order-types.mjs +11 -0
- package/bin/lib/ark-run-sensors.mjs +13 -5
- package/bin/lib/config-contract.mjs +16 -72
- package/bin/lib/config-extras.mjs +151 -0
- package/bin/lib/diagnostic-catalog.mjs +7 -2
- package/bin/lib/extra-merge-teeth.mjs +8 -2
- package/bin/lib/install-migrate.mjs +4 -2
- package/bin/lib/managed-upgrade.mjs +1 -1
- package/bin/lib/mcp-adoption.mjs +9 -3
- package/bin/lib/remediation.mjs +48 -9
- package/bin/lib/resolved-candidate-facts.mjs +43 -0
- package/bin/lib/skill-install.mjs +17 -2
- package/bin/lib/start-preview.mjs +1 -0
- package/bin/lib/status-manifest.mjs +1 -1
- package/bin/lib/write-path-capabilities.mjs +2 -2
- package/dist/{configTypes-CgJimx9o.d.ts → configTypes-BdCe_gvv.d.ts} +22 -6
- package/dist/diagnosticCatalog-RiKPUFRG.d.ts +2307 -0
- package/dist/eslint/index.cjs +7 -6
- package/dist/eslint/index.d.ts +33 -2
- package/dist/eslint/index.js +7 -6
- package/dist/index.cjs +35 -35
- package/dist/index.d.ts +271 -2554
- package/dist/index.js +35 -35
- package/dist/nestjs/index.cjs +18 -0
- package/dist/nestjs/index.d.ts +24 -0
- package/dist/nestjs/index.js +18 -0
- package/dist/order/index.cjs +1 -0
- package/dist/order/index.d.ts +79 -0
- package/dist/order/index.js +1 -0
- package/dist/runtime/index.cjs +25 -0
- package/dist/runtime/index.d.ts +497 -0
- package/dist/runtime/index.js +25 -0
- package/dist/types-C9KApBzX.d.ts +1237 -0
- package/dist/types-DCSlrRnV.d.ts +181 -0
- package/docs/README.md +4 -5
- package/docs/agent-guide.md +1 -1
- package/docs/ai-gates.md +9 -2
- package/docs/configuration.md +13 -6
- package/docs/develop.md +12 -3
- package/docs/diagnostics.md +57 -3
- package/docs/package-surface.md +21 -17
- package/docs/product-voice.md +2 -1
- package/docs/use.md +8 -0
- package/package.json +21 -2
- package/schemas/ark.config.schema.json +54 -2
- package/schemas/ark.resolved-candidate-facts.schema.json +1 -1
- package/server.json +2 -2
- package/templates/agent-skills/README.md +1 -1
- package/templates/agent-skills/ark-adopt/SKILL.md +2 -2
- package/templates/agent-skills/ark-contract/SKILL.md +1 -1
- package/templates/agent-skills/ark-place/SKILL.md +15 -6
- package/templates/agent-skills/ark-runtime/SKILL.md +10 -15
- package/templates/skills/ark-adopt.md +2 -2
- package/templates/skills/ark-contract.md +1 -1
- package/templates/skills/ark-place.md +15 -6
- package/templates/skills/ark-runtime.md +10 -15
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
export { k as AICodeGate, l as AICodeGateContext, m as AICodeGateOptions, n as AICodeGateResult, o as AICodeGateViolation, p as AIGateExtension, q as ANALYSIS_IR_SCHEMA_VERSION, r as ARK_ANALYSIS_RESULT_SCHEMA, s as ARK_ANALYSIS_RESULT_SCHEMA_VERSION, t as ARK_DESIGN_DELTA_SCHEMA_VERSION, u as ARK_ENFORCEMENT_STATE_SCHEMA_VERSION, v as AdapterCompletenessReason, w as AdapterDiagnostic, x as AdapterResult, y as AdapterSeverity, z as AdapterViolationInput, B as AnalysisCapabilityUse, C as AnalysisCompilerOptions, D as AnalysisCompleteness, F as AnalysisContract, G as AnalysisEvidence, H as AnalysisFile, I as AnalysisFileChange, J as AnalysisFileInput, K as AnalysisImportEdge, L as AnalysisIr, M as AnalysisMode, N as AnalysisResult, O as AnalysisViolation, P as AnalyzeArchitectureConvergenceInput, Q as AnalyzeChangeInput, S as AnalyzePolicyDeltaInput, T as AnalyzeProjectInput, U as AnalyzeResolvedProjectInput, V as ArchitectureActualChange, W as ArchitectureChangeMap, X as ArchitectureChangeMapContract, Y as ArchitectureChangeMapDependency, Z as ArchitectureChangeMapFile, _ as ArchitectureChangeOperation, $ as ArchitectureConvergenceClassification, a0 as ArchitectureConvergenceFinding, a1 as ArchitectureConvergenceResult, a2 as ArchitectureDependency, a3 as ArchitectureEngineEdge, a4 as ArchitectureEngineResult, a5 as ArchitectureEngineViolation, a6 as ArkDesignDeltaResult, a7 as ArkEnforcementHost, a8 as ArkEnforcementState, aa as ChangePreflightResult, ac as CollectAnalysisConfigWarningsInput, ad as DIAGNOSTIC_CATALOG, ae as DIAGNOSTIC_CATALOG_SCHEMA_VERSION, af as DIAGNOSTIC_DOCS_RELATIVE_PATH, ag as DIAGNOSTIC_RULE_IDS, ah as DesignDeltaChange, ai as DesignDeltaEnforcementScope, aj as DesignDeltaIdentity, ak as DesignSmellEvidence, al as DesignSmellFinding, am as DesignSmellId, an as DiagnosticCatalogEntry, ao as DiagnosticCategory, ap as EnforcementBoundaryState, aq as EnforcementEvidence, ar as EnforcementEvidenceField, as as EnforcementVerification, at as EvaluateArchitectureGraphInput, au as ForbiddenCapabilityUse, aw as POLICY_DELTA_SCHEMA_VERSION, ax as PolicyDelta, ay as PolicyDeltaAcknowledgement, az as PolicyDeltaAnalysis, aA as PolicyDeltaClassification, aB as PolicyDeltaFinding, aC as PreflightResolvedChangeInput, aD as PreparedChangeFile, aE as RESOLVED_CANDIDATE_FACTS_SCHEMA, aF as RESOLVED_CANDIDATE_FACTS_SCHEMA_VERSION, aG as ResolvedAmbientFact, aH as ResolvedAnalysisFile, aI as ResolvedAnalysisIr, aJ as ResolvedAnalysisResult, e as ResolvedArkRunCompositionRootHitFact, a as ResolvedArkRunDeclarationFact, b as ResolvedArkRunKernelCallFact, R as ResolvedArkRunKernelCallKind, c as ResolvedArkRunManagedNewFact, aK as ResolvedCandidateFacts, aL as ResolvedCandidateFactsInput, aM as ResolvedCapability, aN as ResolvedCapabilityFact, aO as ResolvedChangePreflightResult, d as ResolvedDependencyFact, aP as ResolvedDependencyKind, aQ as ResolvedDependencyState, aR as ResolvedFactsCompleteness, f as ResolvedFactsReason, aS as ResolvedFileFact, aT as ResolvedIntentReferenceFact, aU as ResolvedPublishFact, aV as ResolvedSafetyFact, aW as ResolvedSafetyKind, aX as ResolvedSafetyReport, aY as SemanticDependency, aZ as SemanticDependencyKind, b2 as analyzeArchitectureConvergence, b3 as analyzeChange, b4 as analyzePolicyDelta, b5 as analyzeProject, b6 as analyzeResolvedProject, b9 as catalogFixForRuleId, ba as catalogWhyForRuleId, bb as classifyArkPolicyDelta, bc as collectAnalysisConfigWarnings, be as collectForbiddenCapabilityUses, bf as createAICodeGate, bg as createAdapterResult, bh as createArchitectureProfile, bi as createArchitectureProfileFromArkConfig, bj as createElevenLayerArkConfig, bk as createResolvedCandidateFacts, bm as detectArchitectureCycles, bn as deterministicHash, bo as diagnosticDocsFragment, bp as diagnosticDocsPath, bq as elevenLayerProfile, br as evaluateArchitectureGraph, bu as explainViolation, bw as extractSemanticDependencies, bx as getDiagnosticCatalogEntry, by as isCataloguedOrArkRuleFamily, bz as isKnownDiagnosticCode, bA as loadContract, bB as loadResolvedCandidateFacts, bC as policyDeltaAcknowledgementMatches, bD as preflightChange, bE as preflightResolvedChange, bF as resolvedFactsEvidenceRequirementsHash, bG as serializeDiagnosticCatalog, bH as stableSerialize, bI as toAdapterDiagnostic, bJ as version } from '../diagnosticCatalog-RiKPUFRG.js';
|
|
2
|
+
import { P as PolicyViolation, g as PolicySeverity, h as PolicyEnforcementMode, i as Policy, I as IntentName, j as IntentCreator, k as IntentRelationship, b as ArchitectureProfile, D as DomainEvent } from '../types-DCSlrRnV.js';
|
|
3
|
+
export { A as ArchitectureLayer, a as ArchitectureLayerConfig, c as ArchitectureRule, d as ArkCheckConfig, l as CorrelationId, C as CreateArchitectureProfileFromArkConfigOptions, e as CreateArchitectureProfileOptions, f as CreateElevenLayerArkConfigOptions, E as EventMetadata, m as IntentRelationshipKind } from '../types-DCSlrRnV.js';
|
|
4
|
+
import { I as IntentRegistry, D as DefineIntentOptions, a as DependencyGraph, G as GraphEdge, b as AuditStore, c as AuditRecord, d as AuditQuery, e as CreateAuditTrailOptions, f as AuditTrail, E as EventContractRegistry, g as EventContract, h as EventContractValidationResult, M as MetadataRegistry, R as ReadModelStore, i as CreateProjectionRegistryOptions, P as ProjectionRegistry, j as EventBufferStore, k as EventBufferRecord, l as EventBufferStatus, m as EventBusOptions, n as EventBus, o as CreateObservabilityReporterOptions, O as ObservabilityReporter, p as PolicyEngine, q as ArkManifest, W as WorkflowStore, S as SagaContext, r as WorkflowSnapshot, s as SagaDefinition, t as CreateWorkflowEngineOptions, u as SagaInstance, v as WorkflowEngine, C as CreateArkKernelOptions, A as ArkKernel, w as ArkKernelConfig, x as CreateArkKernelFromConfigOptions, T as TraceRecordType, y as TraceRecord, z as OutboxStatus, B as OutboxRecord, F as ObservabilityDriftReport } from '../types-C9KApBzX.js';
|
|
5
|
+
export { H as ARK_RUN_COMPONENT_LIFETIMES, J as ARK_RUN_EPHEMERAL_DEFAULT, K as ARK_RUN_GRAPH_DEFAULT_SLICE, L as ARK_RUN_GRAPH_NODE_KINDS, N as ARK_RUN_GRAPH_PROCESS_EDGE_KINDS, Q as ARK_RUN_GRAPH_SCHEMA_VERSION, U as ARK_RUN_GRAPH_SLICES, V as ARK_RUN_GRAPH_TECHNICAL_EDGE_KINDS, X as ARK_RUN_INFORMATION_PACKAGE_SCHEMA_VERSION, Y as ARK_RUN_INSPECTOR_DEFAULT_HOST, Z as ARK_RUN_INSPECTOR_DEFAULT_PORT, _ as ARK_RUN_INSPECTOR_EVENTS_PATH, $ as ARK_RUN_INSPECTOR_GRAPH_PATH, a0 as ARK_RUN_INSPECTOR_SCHEMA_VERSION, a1 as ARK_RUN_INSPECTOR_SNAPSHOT_PATH, a2 as ARK_RUN_INSPECTOR_SSE_EVENT, a3 as ARK_RUN_INSPECTOR_TRANSPORT_FALLBACK, a4 as ARK_RUN_TRANSPORT_KINDS, a5 as ArkManifestArchitecture, a6 as ArkManifestData, a7 as ArkManifestEntityLink, a8 as ArkManifestGraph, a9 as ArkManifestIntent, aa as ArkManifestPolicy, ab as ArkManifestProjection, ac as ArkRunBrokerAdapter, ad as ArkRunComponentLifetime, ae as ArkRunDeliveredVia, af as ArkRunExtendedInfo, ag as ArkRunGraph, ah as ArkRunGraphEdge, ai as ArkRunGraphEdgeKind, aj as ArkRunGraphMatch, ak as ArkRunGraphMatchInput, al as ArkRunGraphNode, am as ArkRunGraphNodeKind, an as ArkRunGraphProcessEdgeKind, ao as ArkRunGraphQuery, ap as ArkRunGraphResolvedQuery, aq as ArkRunGraphSlice, ar as ArkRunGraphTechnicalEdgeKind, as as ArkRunInformationPackageComponent, at as ArkRunInspectorBind, au as ArkRunInspectorBindError, av as ArkRunInspectorBindInput, aw as ArkRunInspectorHandle, ax as ArkRunInspectorProductionError, ay as ArkRunInspectorSnapshot, az as ArkRunInspectorSnapshotInput, aA as ArkRunInspectorSource, aB as ArkRunInspectorTransportFacts, aC as ArkRunPublisher, aD as ArkRunRegisterOptions, aE as ArkRunRegistrationHandle, aF as ArkRunSendOptions, aG as ArkRunSendPlan, aH as ArkRunSendPlanInput, aI as ArkRunSendResult, aJ as ArkRunTransportKind, aK as AuditRecordInput, aL as AuditRecordType, aM as DependencyInformationPackage, aN as EntityMeta, aO as EventContractIssue, aP as EventHandler, aQ as EventInterceptionInfo, aR as EventInterceptor, aS as EventInterceptorContext, aT as EventPayloadPatch, aU as EventPayloadSchema, aV as EventPublisher, aW as EventSchemaField, aX as EventSchemaFieldType, aY as FieldMeta, aZ as GraphNode, a_ as InvalidArkRunGraphQueryError, a$ as InvalidArkRunSendOptionError, b0 as ObservabilityFlow, b1 as ObservedLayerFlowMode, b2 as OutboxStore, b3 as PolicyEvaluationResult, b4 as ProjectionCheckpoint, b5 as ProjectionDefinition, b6 as PublishedEventRecord, b7 as RetryPolicy, b8 as SagaStatus, b9 as SagaStep, ba as StartArkRunInspectorOptions, bb as TraceSink, bc as Unsubscribe, bd as WorkflowDefinition, be as WorkflowStatus, bf as WorkflowStep, bg as arkRunGraphQueryFromSearchParams, bh as arkRunInspectorUrl, bi as buildArkRunInspectorSnapshot, bj as buildDependencyInformationPackage, bk as closeArkRunGraphQuery, bl as closedArkRunEphemeral, bm as closedArkRunTransportKind, bn as formatArkRunGraphMermaid, bo as formatArkRunInspectorSseEvent, bp as isArkRunInspectorLoopbackHost, bq as isArkRunInspectorProductionEnv, br as requestArkRunGraph, bs as resolveArkRunInspectorBind, bt as resolveArkRunSendPlan, bu as startArkRunInspector } from '../types-C9KApBzX.js';
|
|
6
|
+
import '../configTypes-BdCe_gvv.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Typed error thrown when hard policies are violated.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
declare class PolicyViolationError extends Error {
|
|
13
|
+
readonly violations: PolicyViolation[];
|
|
14
|
+
constructor(violations: PolicyViolation[]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* definePolicy
|
|
19
|
+
*
|
|
20
|
+
* Factory function to create architectural policies in a declarative way.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
interface DefinePolicyOptions<Context = unknown> {
|
|
24
|
+
name: string;
|
|
25
|
+
severity?: PolicySeverity;
|
|
26
|
+
tags?: readonly string[];
|
|
27
|
+
owner?: string;
|
|
28
|
+
version?: string;
|
|
29
|
+
rationale?: string;
|
|
30
|
+
enforcementMode?: PolicyEnforcementMode;
|
|
31
|
+
deprecated?: boolean | string;
|
|
32
|
+
replacedBy?: string;
|
|
33
|
+
check: (context: Context) => boolean | PolicyViolation | PolicyViolation[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a Policy from a declarative configuration.
|
|
37
|
+
*
|
|
38
|
+
* The provided `check` function is called as-is. The PolicyEngine is responsible
|
|
39
|
+
* for normalizing results (booleans, single violations, arrays) into a consistent
|
|
40
|
+
* set of PolicyViolation objects.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const noDomainToInfra = definePolicy({
|
|
45
|
+
* name: 'Domain must not depend on infrastructure',
|
|
46
|
+
* severity: 'hard',
|
|
47
|
+
* check: (ctx) => {
|
|
48
|
+
* const violations: PolicyViolation[] = [];
|
|
49
|
+
* // ... logic using ctx.registry.getAllRelationships()
|
|
50
|
+
* return violations.length > 0 ? violations : true;
|
|
51
|
+
* }
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
declare function definePolicy<Context = unknown>(options: DefinePolicyOptions<Context>): Policy<Context>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* defineIntent
|
|
59
|
+
*
|
|
60
|
+
* The primary ergonomic function for declaring semantic intents.
|
|
61
|
+
*
|
|
62
|
+
* Uses a default shared registry for convenience, while still allowing
|
|
63
|
+
* isolated registries via `createIntentRegistry()`.
|
|
64
|
+
*
|
|
65
|
+
* Intents are the core of Ark's governance model. They give every
|
|
66
|
+
* architectural concept (domain events, use cases, adapter operations, workflows)
|
|
67
|
+
* an explicit, namespaced, machine-readable identity.
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Define a new semantic intent.
|
|
72
|
+
*
|
|
73
|
+
* This is the main entry point most users (and AI generators) will use.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* // Domain event
|
|
78
|
+
* const OrderPlaced = defineIntent<'Domain.Order.OrderPlaced', {
|
|
79
|
+
* orderId: string;
|
|
80
|
+
* amount: number;
|
|
81
|
+
* }>('Domain.Order.OrderPlaced');
|
|
82
|
+
*
|
|
83
|
+
* const event = OrderPlaced({ orderId: 'o-42', amount: 99.5 });
|
|
84
|
+
*
|
|
85
|
+
* // Application operation that declares a dependency at definition time
|
|
86
|
+
* const ConfirmOrder = defineIntent<'Application.ConfirmOrder', { orderId: string }>(
|
|
87
|
+
* 'Application.ConfirmOrder',
|
|
88
|
+
* { dependsOn: ['Domain.Order.OrderPlaced'] }
|
|
89
|
+
* );
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @param name - Unique semantic name. Recommended convention:
|
|
93
|
+
* - `Domain.*` for domain concepts and events
|
|
94
|
+
* - `Application.*` for use cases / orchestration
|
|
95
|
+
* - `Adapter.*` for external integrations
|
|
96
|
+
* - `Workflow.*` for sagas and long-running processes
|
|
97
|
+
* @param options - Optional initial relationship declarations (`dependsOn`, `produces`)
|
|
98
|
+
*/
|
|
99
|
+
declare function defineIntent<N extends IntentName, P = unknown>(name: N, options?: DefineIntentOptions): IntentCreator<N, P>;
|
|
100
|
+
/**
|
|
101
|
+
* Create an isolated IntentRegistry.
|
|
102
|
+
* Useful for testing, multiple bounded contexts, or advanced governance setups.
|
|
103
|
+
*/
|
|
104
|
+
declare function createIntentRegistry(): IntentRegistry;
|
|
105
|
+
/**
|
|
106
|
+
* The default registry backing the top-level `defineIntent` calls.
|
|
107
|
+
* You can inspect it or use it directly if needed.
|
|
108
|
+
*/
|
|
109
|
+
declare const defaultIntentRegistry: IntentRegistry;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Runtime validation for semantic intent naming conventions.
|
|
113
|
+
*/
|
|
114
|
+
interface IntentNameValidation {
|
|
115
|
+
valid: boolean;
|
|
116
|
+
reason?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Validate that an intent name follows Ark naming conventions.
|
|
120
|
+
*/
|
|
121
|
+
declare function validateIntentName(name: string): IntentNameValidation;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* DependencyGraph implementation.
|
|
125
|
+
*
|
|
126
|
+
* Collects declared and observed relationships.
|
|
127
|
+
* Generates Mermaid diagrams and JSON.
|
|
128
|
+
* Supports simple violation detection via rule functions.
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
declare function createDependencyGraph(): DependencyGraph;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Bridge IntentRegistry relationships into a DependencyGraph.
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
interface SyncRegistryOptions {
|
|
138
|
+
/** Skip edges whose target intent is not registered (default: false). */
|
|
139
|
+
requireRegisteredTargets?: boolean;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Sync declared intent relationships from a registry into a dependency graph.
|
|
143
|
+
*
|
|
144
|
+
* - `dependsOn` → `declared` edges
|
|
145
|
+
* - `produces` → `produces` edges
|
|
146
|
+
*/
|
|
147
|
+
declare function syncRegistryToGraph(registry: IntentRegistry, graph: DependencyGraph, options?: SyncRegistryOptions): void;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Built-in architectural policy helpers.
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
interface LayerFlowRule {
|
|
154
|
+
from: string;
|
|
155
|
+
to: string;
|
|
156
|
+
allowed: boolean;
|
|
157
|
+
message?: string;
|
|
158
|
+
}
|
|
159
|
+
interface LayerPolicyOptions {
|
|
160
|
+
name?: string;
|
|
161
|
+
severity?: 'hard' | 'soft';
|
|
162
|
+
/** Prefix rules — e.g. { from: 'Domain', to: 'Adapter', allowed: false } */
|
|
163
|
+
rules: LayerFlowRule[];
|
|
164
|
+
resolveLayer?: (name: string) => string | undefined;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Create a policy that enforces layer-crossing rules on graph edges or intent relationships.
|
|
168
|
+
*/
|
|
169
|
+
declare function defineLayerPolicy<Context extends {
|
|
170
|
+
edges?: GraphEdge[];
|
|
171
|
+
relationships?: IntentRelationship[];
|
|
172
|
+
}>(options: LayerPolicyOptions): Policy<Context>;
|
|
173
|
+
/** True when a policy requires graph/registry context to enforce layer rules. */
|
|
174
|
+
declare function isLayerPolicy(policy: Policy): boolean;
|
|
175
|
+
/** Preset architectural policy factories. */
|
|
176
|
+
declare const architecturalPolicies: {
|
|
177
|
+
/**
|
|
178
|
+
* @deprecated Use cleanArchitectureMatrix() for full layer rules.
|
|
179
|
+
* Blocks Domain → Adapter declared dependencies only.
|
|
180
|
+
*/
|
|
181
|
+
layerIsolation(): Policy<{
|
|
182
|
+
edges?: GraphEdge[];
|
|
183
|
+
relationships?: IntentRelationship[];
|
|
184
|
+
}>;
|
|
185
|
+
/**
|
|
186
|
+
* Clean-architecture dependency matrix (declared dependsOn / declared edges only).
|
|
187
|
+
* Does not block observed event flows (Domain events consumed by Application).
|
|
188
|
+
*/
|
|
189
|
+
cleanArchitectureMatrix(): Policy<{
|
|
190
|
+
edges?: GraphEdge[];
|
|
191
|
+
relationships?: IntentRelationship[];
|
|
192
|
+
}>;
|
|
193
|
+
};
|
|
194
|
+
declare function defineArchitectureProfilePolicy<Context extends {
|
|
195
|
+
edges?: GraphEdge[];
|
|
196
|
+
relationships?: IntentRelationship[];
|
|
197
|
+
}>(profile: ArchitectureProfile, options?: Omit<LayerPolicyOptions, 'rules' | 'resolveLayer'>): Policy<Context>;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Reference in-process audit store. **Not production durability** — records do not
|
|
201
|
+
* survive process restarts. For production, inject an `AuditStore` that writes to your
|
|
202
|
+
* durable log/DB (see `docs/production-hardening.md`).
|
|
203
|
+
*/
|
|
204
|
+
declare class InMemoryAuditStore implements AuditStore {
|
|
205
|
+
private readonly maxRecords?;
|
|
206
|
+
private readonly records;
|
|
207
|
+
constructor(maxRecords?: number | undefined);
|
|
208
|
+
append(record: AuditRecord): void;
|
|
209
|
+
query(query?: AuditQuery): AuditRecord[];
|
|
210
|
+
clear(): void;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Create an audit trail. Defaults to `InMemoryAuditStore` (**not** production durability).
|
|
214
|
+
* Pass `options.store` for a durable backend.
|
|
215
|
+
*/
|
|
216
|
+
declare function createAuditTrail(options?: CreateAuditTrailOptions): AuditTrail;
|
|
217
|
+
|
|
218
|
+
declare class EventContractRegistryImpl implements EventContractRegistry {
|
|
219
|
+
private readonly contracts;
|
|
220
|
+
register(contract: EventContract): void;
|
|
221
|
+
get(intent: string, version?: string): EventContract | undefined;
|
|
222
|
+
list(intent?: string): EventContract[];
|
|
223
|
+
validate(event: DomainEvent): EventContractValidationResult;
|
|
224
|
+
clear(): void;
|
|
225
|
+
private key;
|
|
226
|
+
}
|
|
227
|
+
declare function createEventContractRegistry(): EventContractRegistry;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Basic MetadataRegistry implementation.
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
declare function createMetadataRegistry(): MetadataRegistry;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Reference in-process read-model store. **Not production durability.**
|
|
237
|
+
* See `docs/production-hardening.md`.
|
|
238
|
+
*/
|
|
239
|
+
declare class InMemoryReadModelStore implements ReadModelStore {
|
|
240
|
+
private readonly states;
|
|
241
|
+
load<State = unknown>(name: string): State | undefined;
|
|
242
|
+
save<State = unknown>(name: string, state: State): void;
|
|
243
|
+
clear(name?: string): void;
|
|
244
|
+
}
|
|
245
|
+
declare function createProjectionRegistry(options?: CreateProjectionRegistryOptions): ProjectionRegistry;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Reference in-process event buffer. **Not production durability** — state is lost on
|
|
249
|
+
* process exit. Use only for tests/demos/local single-process work; inject a durable
|
|
250
|
+
* This is not an atomic outbox (see `docs/production-hardening.md`).
|
|
251
|
+
*/
|
|
252
|
+
declare class InMemoryEventBuffer implements EventBufferStore {
|
|
253
|
+
private readonly records;
|
|
254
|
+
enqueue(event: DomainEvent): Promise<EventBufferRecord>;
|
|
255
|
+
markDispatched(id: string): Promise<void>;
|
|
256
|
+
markFailed(id: string, error: unknown): Promise<void>;
|
|
257
|
+
list(status?: EventBufferStatus): Promise<EventBufferRecord[]>;
|
|
258
|
+
clear(): Promise<void>;
|
|
259
|
+
}
|
|
260
|
+
/** @deprecated Use InMemoryEventBuffer. */
|
|
261
|
+
declare const InMemoryOutboxStore: typeof InMemoryEventBuffer;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* EventBus implementation — public surface + publish orchestration.
|
|
265
|
+
*
|
|
266
|
+
* Publish pipeline stages live in cohesive modules (R8):
|
|
267
|
+
* guards → interceptors → contract re-check → observed layer flow →
|
|
268
|
+
* policy → history/outbox/trace → handlers → onPublish hook
|
|
269
|
+
*/
|
|
270
|
+
|
|
271
|
+
declare function createEventBus<Context = unknown>(options?: EventBusOptions<Context>): EventBus;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Helpers for building policy evaluation context on event publish.
|
|
275
|
+
*/
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Standard context for policies evaluated during event publish.
|
|
279
|
+
* Includes the event plus optional registry relationships and graph edges
|
|
280
|
+
* so layer policies (e.g. architecturalPolicies.layerIsolation) can run.
|
|
281
|
+
*/
|
|
282
|
+
interface PublishPolicyContext {
|
|
283
|
+
event: DomainEvent;
|
|
284
|
+
relationships?: IntentRelationship[];
|
|
285
|
+
edges?: GraphEdge[];
|
|
286
|
+
}
|
|
287
|
+
interface GraphPolicyContext {
|
|
288
|
+
relationships?: IntentRelationship[];
|
|
289
|
+
edges?: GraphEdge[];
|
|
290
|
+
}
|
|
291
|
+
interface BuildPublishPolicyContextOptions {
|
|
292
|
+
intentRegistry?: IntentRegistry;
|
|
293
|
+
dependencyGraph?: DependencyGraph;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Build a getPolicyContext function that feeds registry + graph data to policies.
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```ts
|
|
300
|
+
* const bus = createEventBus({
|
|
301
|
+
* intentRegistry: registry,
|
|
302
|
+
* dependencyGraph: graph,
|
|
303
|
+
* policies: [architecturalPolicies.layerIsolation()],
|
|
304
|
+
* });
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
declare function buildPublishPolicyContext(options: BuildPublishPolicyContextOptions): (event: DomainEvent) => PublishPolicyContext;
|
|
308
|
+
declare function definePublishPolicy(options: DefinePolicyOptions<PublishPolicyContext>): Policy<PublishPolicyContext>;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Event bus governance errors.
|
|
312
|
+
*/
|
|
313
|
+
declare class UnregisteredIntentError extends Error {
|
|
314
|
+
readonly intentName: string;
|
|
315
|
+
constructor(intentName: string);
|
|
316
|
+
}
|
|
317
|
+
declare class InvalidIntentNameError extends Error {
|
|
318
|
+
readonly intentName: string;
|
|
319
|
+
readonly reason: string;
|
|
320
|
+
constructor(intentName: string, reason: string);
|
|
321
|
+
}
|
|
322
|
+
declare class LayerPolicyContextError extends Error {
|
|
323
|
+
constructor();
|
|
324
|
+
}
|
|
325
|
+
declare class EventContractViolationError extends Error {
|
|
326
|
+
readonly intentName: string;
|
|
327
|
+
readonly issues: unknown[];
|
|
328
|
+
constructor(intentName: string, issues: unknown[]);
|
|
329
|
+
}
|
|
330
|
+
declare class UnknownEventSourceError extends Error {
|
|
331
|
+
readonly intentName: string;
|
|
332
|
+
readonly source?: string;
|
|
333
|
+
constructor(intentName: string, source?: string);
|
|
334
|
+
}
|
|
335
|
+
declare class SourceMetadataOverrideError extends Error {
|
|
336
|
+
readonly boundSource: string;
|
|
337
|
+
readonly attemptedSource: string;
|
|
338
|
+
constructor(boundSource: string, attemptedSource: string);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Thrown when the OBSERVED producer→event flow crosses a forbidden layer boundary
|
|
342
|
+
* under `enforceObservedLayerFlow: 'hard'`. Unlike declared-model policy errors, this
|
|
343
|
+
* reflects what the running system actually did at publish time.
|
|
344
|
+
*/
|
|
345
|
+
declare class ObservedLayerFlowViolationError extends Error {
|
|
346
|
+
readonly source: string;
|
|
347
|
+
readonly intentName: string;
|
|
348
|
+
readonly fromLayer: string;
|
|
349
|
+
readonly toLayer: string;
|
|
350
|
+
constructor(source: string, intentName: string, fromLayer: string, toLayer: string, message?: string);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
declare function createObservabilityReporter(options: CreateObservabilityReporterOptions): ObservabilityReporter;
|
|
354
|
+
|
|
355
|
+
/** Current Ark manifest JSON schema version. */
|
|
356
|
+
declare const MANIFEST_SCHEMA_VERSION = "1.0";
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Aggregates kernel registries into a single machine-readable manifest.
|
|
360
|
+
*/
|
|
361
|
+
|
|
362
|
+
interface CreateArkManifestOptions {
|
|
363
|
+
registry?: IntentRegistry;
|
|
364
|
+
policyEngine?: PolicyEngine;
|
|
365
|
+
metadata?: MetadataRegistry;
|
|
366
|
+
graph?: DependencyGraph;
|
|
367
|
+
profile?: ArchitectureProfile;
|
|
368
|
+
projections?: ProjectionRegistry;
|
|
369
|
+
eventContracts?: EventContractRegistry;
|
|
370
|
+
observability?: ObservabilityReporter;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Create a machine-readable snapshot of the current architectural contract.
|
|
374
|
+
* Intended for AI agents, codegen tools, and documentation generators.
|
|
375
|
+
*/
|
|
376
|
+
declare function createArkManifest(options?: CreateArkManifestOptions): ArkManifest;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* In-process workflow engine with durable-store seams.
|
|
380
|
+
*/
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Reference in-process workflow store. **Not production durability.**
|
|
384
|
+
* See `docs/production-hardening.md`.
|
|
385
|
+
*/
|
|
386
|
+
declare class InMemoryWorkflowStore implements WorkflowStore {
|
|
387
|
+
private readonly snapshots;
|
|
388
|
+
save<P extends SagaContext>(snapshot: WorkflowSnapshot<P>, _tx?: unknown): void;
|
|
389
|
+
get<P extends SagaContext = SagaContext>(id: string, _tx?: unknown): WorkflowSnapshot<P> | undefined;
|
|
390
|
+
list(workflowName?: string): WorkflowSnapshot[];
|
|
391
|
+
claim(workerId: string, timeoutMs: number, workflowName?: string): WorkflowSnapshot | undefined;
|
|
392
|
+
clear(): void;
|
|
393
|
+
}
|
|
394
|
+
declare function createWorkflowEngine(bus: EventBus, options?: CreateWorkflowEngineOptions): WorkflowEngine;
|
|
395
|
+
declare function createSaga<P extends SagaContext = SagaContext>(def: SagaDefinition<P>, bus: EventBus, options?: CreateWorkflowEngineOptions & {
|
|
396
|
+
id?: string;
|
|
397
|
+
}): SagaInstance<P>;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Default cap for in-memory history, trace, and audit records. Without a cap a
|
|
401
|
+
* long-running process grows without bound on every publish. Pass
|
|
402
|
+
* `maxHistorySize: Infinity` to explicitly opt back into unbounded retention.
|
|
403
|
+
*/
|
|
404
|
+
declare const DEFAULT_MAX_HISTORY_SIZE = 1000;
|
|
405
|
+
declare function createArkKernel(options?: CreateArkKernelOptions): ArkKernel;
|
|
406
|
+
/**
|
|
407
|
+
* Preferred ArkRun factory. Each call is a new isolated instance — there is no
|
|
408
|
+
* process-wide singleton.
|
|
409
|
+
*/
|
|
410
|
+
declare function createStrictArkKernel(options?: CreateArkKernelOptions): ArkKernel;
|
|
411
|
+
declare function createArkKernelFromConfig(config: ArkKernelConfig, options?: CreateArkKernelFromConfigOptions): ArkKernel;
|
|
412
|
+
declare function createStrictArkKernelFromConfig(config: ArkKernelConfig, options?: CreateArkKernelFromConfigOptions): ArkKernel;
|
|
413
|
+
declare function createLenientArkKernelFromConfig(config: ArkKernelConfig, options?: CreateArkKernelFromConfigOptions): ArkKernel;
|
|
414
|
+
declare function createLenientArkKernel(options?: CreateArkKernelOptions): ArkKernel;
|
|
415
|
+
|
|
416
|
+
interface ArkTestSnapshot {
|
|
417
|
+
events: DomainEvent[];
|
|
418
|
+
traces: TraceRecord[];
|
|
419
|
+
audit: AuditRecord[];
|
|
420
|
+
outbox: OutboxRecord[];
|
|
421
|
+
observability: ObservabilityDriftReport;
|
|
422
|
+
}
|
|
423
|
+
interface ArkTestHarness {
|
|
424
|
+
events(intent?: string): DomainEvent[];
|
|
425
|
+
traces(type?: TraceRecordType): TraceRecord[];
|
|
426
|
+
audit(query?: AuditQuery): Promise<AuditRecord[]>;
|
|
427
|
+
outbox(status?: OutboxStatus): Promise<OutboxRecord[]>;
|
|
428
|
+
observability(): ObservabilityDriftReport;
|
|
429
|
+
snapshot(): Promise<ArkTestSnapshot>;
|
|
430
|
+
clear(): Promise<void>;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
declare function createArkTestHarness(kernel: ArkKernel): ArkTestHarness;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Ports & Adapters basic contracts.
|
|
437
|
+
*/
|
|
438
|
+
interface Port<T = unknown> {
|
|
439
|
+
readonly name: string;
|
|
440
|
+
readonly ownerLayer?: string;
|
|
441
|
+
readonly intent?: IntentName;
|
|
442
|
+
readonly allowedAdapters?: string[];
|
|
443
|
+
readonly __port?: T;
|
|
444
|
+
}
|
|
445
|
+
interface Adapter<T = unknown> {
|
|
446
|
+
readonly name?: string;
|
|
447
|
+
readonly layer?: string;
|
|
448
|
+
readonly intent?: IntentName;
|
|
449
|
+
readonly port: Port<T>;
|
|
450
|
+
readonly impl: T;
|
|
451
|
+
}
|
|
452
|
+
interface DefinePortOptions {
|
|
453
|
+
ownerLayer?: string;
|
|
454
|
+
intent?: IntentName;
|
|
455
|
+
allowedAdapters?: string[];
|
|
456
|
+
}
|
|
457
|
+
interface CreateAdapterOptions {
|
|
458
|
+
name?: string;
|
|
459
|
+
layer?: string;
|
|
460
|
+
intent?: IntentName;
|
|
461
|
+
requiredKeys?: string[];
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Simple contract checker (duck typing + optional required keys).
|
|
465
|
+
*/
|
|
466
|
+
type ContractCheckResult = {
|
|
467
|
+
ok: true;
|
|
468
|
+
} | {
|
|
469
|
+
ok: false;
|
|
470
|
+
missing: string[];
|
|
471
|
+
};
|
|
472
|
+
interface AdapterGovernanceIssue {
|
|
473
|
+
ruleId: 'ADAPTER_NOT_ALLOWED_FOR_PORT';
|
|
474
|
+
message: string;
|
|
475
|
+
port: string;
|
|
476
|
+
adapter?: string;
|
|
477
|
+
}
|
|
478
|
+
type AdapterGovernanceResult = {
|
|
479
|
+
ok: true;
|
|
480
|
+
issues: [];
|
|
481
|
+
} | {
|
|
482
|
+
ok: false;
|
|
483
|
+
issues: AdapterGovernanceIssue[];
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Ports and Adapters utilities.
|
|
488
|
+
*
|
|
489
|
+
* definePort + createAdapter with basic runtime contract validation.
|
|
490
|
+
*/
|
|
491
|
+
|
|
492
|
+
declare function definePort<T = unknown>(name: string, options?: DefinePortOptions): Port<T>;
|
|
493
|
+
declare function createAdapter<T>(port: Port<T>, impl: T, requiredKeysOrOptions?: string[] | CreateAdapterOptions, adapterOptions?: CreateAdapterOptions): Adapter<T>;
|
|
494
|
+
declare function checkContract(impl: unknown, requiredKeys?: string[]): ContractCheckResult;
|
|
495
|
+
declare function checkAdapterGovernance(adapter: Adapter): AdapterGovernanceResult;
|
|
496
|
+
|
|
497
|
+
export { type Adapter, type AdapterGovernanceIssue, type AdapterGovernanceResult, ArchitectureProfile, ArkKernel, ArkKernelConfig, ArkManifest, type ArkTestHarness, type ArkTestSnapshot, AuditQuery, AuditRecord, AuditStore, AuditTrail, type BuildPublishPolicyContextOptions, type ContractCheckResult, type CreateAdapterOptions, CreateArkKernelFromConfigOptions, CreateArkKernelOptions, type CreateArkManifestOptions, CreateAuditTrailOptions, CreateObservabilityReporterOptions, CreateProjectionRegistryOptions, CreateWorkflowEngineOptions, DEFAULT_MAX_HISTORY_SIZE, DefineIntentOptions, type DefinePolicyOptions, type DefinePortOptions, DependencyGraph, DomainEvent, EventBufferRecord, EventBufferStatus, EventBufferStore, EventBus, EventBusOptions, EventContract, EventContractRegistry, EventContractRegistryImpl, EventContractValidationResult, EventContractViolationError, GraphEdge, type GraphPolicyContext, InMemoryAuditStore, InMemoryEventBuffer, 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, 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, createAdapter, createArkKernel, createArkKernelFromConfig, createArkManifest, createArkTestHarness, createAuditTrail, createDependencyGraph, createEventBus, createEventContractRegistry, createIntentRegistry, createLenientArkKernel, createLenientArkKernelFromConfig, createMetadataRegistry, createObservabilityReporter, createProjectionRegistry, createSaga, createStrictArkKernel, createStrictArkKernelFromConfig, createWorkflowEngine, defaultIntentRegistry, defineArchitectureProfilePolicy, defineIntent, defineLayerPolicy, definePolicy, definePort, definePublishPolicy, isLayerPolicy, syncRegistryToGraph, validateIntentName };
|