arkgate 2.12.0 → 3.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/CHANGELOG.md +122 -0
- package/README.md +90 -51
- package/bin/ark-check.mjs +156 -39
- package/bin/ark-mcp.mjs +119 -6
- package/bin/ark-shared.mjs +216 -129
- package/bin/ark.mjs +134 -34
- package/bin/lib/adapter-contract.mjs +93 -0
- package/bin/lib/agent-gates.mjs +13 -0
- package/bin/lib/analysis-engine.mjs +1171 -0
- package/bin/lib/architecture-scan.mjs +84 -127
- package/bin/lib/ci-and-commands.mjs +40 -3
- package/bin/lib/codex-home.mjs +7 -0
- package/bin/lib/config-contract.mjs +331 -0
- package/bin/lib/config-warnings.mjs +7 -205
- package/bin/lib/doctor-plan.mjs +43 -16
- package/bin/lib/enforcement-profiles.mjs +97 -0
- package/bin/lib/field-install.mjs +67 -10
- package/bin/lib/gate-files.mjs +42 -3
- package/bin/lib/graph-cycles.mjs +4 -54
- package/bin/lib/hook-templates.mjs +33 -1
- package/bin/lib/host-support-matrix.mjs +83 -0
- package/bin/lib/install-migrate.mjs +99 -30
- package/bin/lib/mcp-adoption.mjs +35 -3
- package/bin/lib/open-html.mjs +75 -0
- package/bin/lib/presets.mjs +45 -4
- package/bin/lib/safety-diagnostics.mjs +36 -15
- package/bin/lib/scan-files.mjs +12 -1
- package/bin/lib/skill-install.mjs +72 -1
- package/bin/lib/source-policy.mjs +36 -0
- package/bin/lib/start-preview.mjs +271 -0
- package/bin/lib/ts-resolve.mjs +13 -3
- package/bin/lib/weakest-link.mjs +417 -0
- package/bin/lib/write-path-capabilities.mjs +186 -0
- package/bin/lib/write-path-detect.mjs +62 -99
- package/compat/nestjs.cjs +2 -0
- package/compat/nestjs.d.ts +2 -0
- package/compat/nestjs.js +1 -0
- package/compat/runtime.cjs +2 -0
- package/compat/runtime.d.ts +2 -0
- package/compat/runtime.js +1 -0
- package/dist/configContract-BxSIwVRo.d.cts +259 -0
- package/dist/configContract-BxSIwVRo.d.ts +259 -0
- package/dist/eslint/index.cjs +500 -61
- package/dist/eslint/index.d.cts +36 -20
- package/dist/eslint/index.d.ts +36 -20
- package/dist/eslint/index.js +500 -61
- package/dist/index.cjs +1349 -2741
- package/dist/index.d.cts +449 -483
- package/dist/index.d.ts +449 -483
- package/dist/index.js +1325 -2687
- package/docs/agent-guide.md +58 -34
- package/docs/ai-gates.md +79 -21
- package/docs/configuration.md +97 -0
- package/docs/enthusiast/README.md +3 -3
- package/docs/enthusiast/how-to-agent-gates.md +7 -3
- package/docs/migrate-from-ark-runtime-kernel.md +5 -3
- package/docs/package-surface.md +19 -19
- package/docs/production-hardening.md +31 -5
- package/docs/threat-model.md +65 -0
- package/docs/typescript-support.md +30 -3
- package/package.json +46 -11
- package/schemas/ark.analysis-result.schema.json +91 -0
- package/schemas/ark.config.schema.json +750 -0
- package/server.json +2 -2
- package/templates/hooks/pre-commit-ark +37 -0
- package/templates/skills/ark-architect.md +3 -2
- package/templates/skills/ark-coverage.md +2 -2
- package/templates/skills/ark-runtime.md +8 -5
- package/templates/skills/ark-upgrade.md +36 -16
- package/tests/fixtures/ts-consumer/ark.config.json +2 -0
- package/dist/eslint/index.cjs.map +0 -1
- package/dist/eslint/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/nestjs/index.cjs +0 -2498
- package/dist/nestjs/index.cjs.map +0 -1
- package/dist/nestjs/index.d.cts +0 -22
- package/dist/nestjs/index.d.ts +0 -22
- package/dist/nestjs/index.js +0 -2474
- package/dist/nestjs/index.js.map +0 -1
- package/dist/runtime/index.cjs +0 -3352
- package/dist/runtime/index.cjs.map +0 -1
- package/dist/runtime/index.d.cts +0 -2
- package/dist/runtime/index.d.ts +0 -2
- package/dist/runtime/index.js +0 -3270
- package/dist/runtime/index.js.map +0 -1
- package/dist/types-BZ17b9i5.d.cts +0 -1068
- package/dist/types-BZ17b9i5.d.ts +0 -1068
package/dist/index.d.cts
CHANGED
|
@@ -1,534 +1,337 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { a as ArkConfigRule, b as ArkConfigLayer, A as ArkConfig, c as ArkConfigLoadResult } from './configContract-BxSIwVRo.cjs';
|
|
2
|
+
export { d as ARK_CONFIG_SCHEMA, e as ARK_CONFIG_SCHEMA_VERSION, l as loadArkConfigContract, p as parseArkConfigJson } from './configContract-BxSIwVRo.cjs';
|
|
3
3
|
|
|
4
4
|
/** ArkGate library version — single source of truth. */
|
|
5
|
-
declare const version = "
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
declare const version = "3.0.0";
|
|
6
|
+
|
|
7
|
+
/** Versioned public result contract shared by every ArkGate enforcement adapter. */
|
|
8
|
+
declare const ARK_ANALYSIS_RESULT_SCHEMA_VERSION: "1.0";
|
|
9
|
+
type AdapterSeverity = 'error' | 'warning';
|
|
10
|
+
type AdapterViolationInput = {
|
|
11
|
+
ruleId?: unknown;
|
|
12
|
+
code?: unknown;
|
|
13
|
+
message?: unknown;
|
|
14
|
+
file?: unknown;
|
|
15
|
+
line?: unknown;
|
|
16
|
+
column?: unknown;
|
|
17
|
+
target?: unknown;
|
|
18
|
+
fromLayer?: unknown;
|
|
19
|
+
toLayer?: unknown;
|
|
20
|
+
typeOnly?: unknown;
|
|
21
|
+
severity?: unknown;
|
|
22
|
+
};
|
|
23
|
+
type AdapterDiagnostic = {
|
|
24
|
+
ruleId: string;
|
|
25
|
+
severity: AdapterSeverity;
|
|
26
|
+
message: string;
|
|
27
|
+
location: {
|
|
28
|
+
file: string;
|
|
29
|
+
line: number;
|
|
30
|
+
column: number;
|
|
31
|
+
};
|
|
32
|
+
evidence: {
|
|
33
|
+
target?: string;
|
|
34
|
+
fromLayer?: string;
|
|
35
|
+
toLayer?: string;
|
|
36
|
+
typeOnly?: boolean;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
type AdapterResult = {
|
|
40
|
+
schemaVersion: typeof ARK_ANALYSIS_RESULT_SCHEMA_VERSION;
|
|
41
|
+
valid: boolean;
|
|
42
|
+
diagnostics: AdapterDiagnostic[];
|
|
43
|
+
};
|
|
44
|
+
declare function toAdapterDiagnostic(violation: AdapterViolationInput, fallbackSeverity?: AdapterSeverity): AdapterDiagnostic;
|
|
45
|
+
declare function createAdapterResult(input: {
|
|
46
|
+
valid: boolean;
|
|
47
|
+
violations?: readonly AdapterViolationInput[];
|
|
48
|
+
warnings?: readonly AdapterViolationInput[];
|
|
49
|
+
}): AdapterResult;
|
|
50
|
+
declare const ARK_ANALYSIS_RESULT_SCHEMA: {
|
|
51
|
+
readonly $schema: "https://json-schema.org/draft/2020-12/schema";
|
|
52
|
+
readonly $id: "https://unpkg.com/arkgate@2/schemas/ark.analysis-result.schema.json";
|
|
53
|
+
readonly title: "ArkGate analysis result";
|
|
54
|
+
readonly type: "object";
|
|
55
|
+
readonly additionalProperties: false;
|
|
56
|
+
readonly required: readonly ["schemaVersion", "valid", "diagnostics"];
|
|
57
|
+
readonly properties: {
|
|
58
|
+
readonly schemaVersion: {
|
|
59
|
+
readonly const: "1.0";
|
|
60
|
+
};
|
|
61
|
+
readonly valid: {
|
|
62
|
+
readonly type: "boolean";
|
|
63
|
+
};
|
|
64
|
+
readonly diagnostics: {
|
|
65
|
+
readonly type: "array";
|
|
66
|
+
readonly items: {
|
|
67
|
+
readonly type: "object";
|
|
68
|
+
readonly additionalProperties: false;
|
|
69
|
+
readonly required: readonly ["ruleId", "severity", "message", "location", "evidence"];
|
|
70
|
+
readonly properties: {
|
|
71
|
+
readonly ruleId: {
|
|
72
|
+
readonly type: "string";
|
|
73
|
+
readonly minLength: 1;
|
|
74
|
+
};
|
|
75
|
+
readonly severity: {
|
|
76
|
+
readonly enum: readonly ["error", "warning"];
|
|
77
|
+
};
|
|
78
|
+
readonly message: {
|
|
79
|
+
readonly type: "string";
|
|
80
|
+
readonly minLength: 1;
|
|
81
|
+
};
|
|
82
|
+
readonly location: {
|
|
83
|
+
readonly type: "object";
|
|
84
|
+
readonly additionalProperties: false;
|
|
85
|
+
readonly required: readonly ["file", "line", "column"];
|
|
86
|
+
readonly properties: {
|
|
87
|
+
readonly file: {
|
|
88
|
+
readonly type: "string";
|
|
89
|
+
readonly minLength: 1;
|
|
90
|
+
};
|
|
91
|
+
readonly line: {
|
|
92
|
+
readonly type: "integer";
|
|
93
|
+
readonly minimum: 1;
|
|
94
|
+
};
|
|
95
|
+
readonly column: {
|
|
96
|
+
readonly type: "integer";
|
|
97
|
+
readonly minimum: 1;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
readonly evidence: {
|
|
102
|
+
readonly type: "object";
|
|
103
|
+
readonly additionalProperties: false;
|
|
104
|
+
readonly properties: {
|
|
105
|
+
readonly target: {
|
|
106
|
+
readonly type: "string";
|
|
107
|
+
};
|
|
108
|
+
readonly fromLayer: {
|
|
109
|
+
readonly type: "string";
|
|
110
|
+
};
|
|
111
|
+
readonly toLayer: {
|
|
112
|
+
readonly type: "string";
|
|
113
|
+
};
|
|
114
|
+
readonly typeOnly: {
|
|
115
|
+
readonly type: "boolean";
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
};
|
|
19
124
|
|
|
20
125
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* This is the main entry point most users (and AI generators) will use.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* // Domain event
|
|
28
|
-
* const OrderPlaced = defineIntent<'Domain.Order.OrderPlaced', {
|
|
29
|
-
* orderId: string;
|
|
30
|
-
* amount: number;
|
|
31
|
-
* }>('Domain.Order.OrderPlaced');
|
|
32
|
-
*
|
|
33
|
-
* const event = OrderPlaced({ orderId: 'o-42', amount: 99.5 });
|
|
34
|
-
*
|
|
35
|
-
* // Application operation that declares a dependency at definition time
|
|
36
|
-
* const ConfirmOrder = defineIntent<'Application.ConfirmOrder', { orderId: string }>(
|
|
37
|
-
* 'Application.ConfirmOrder',
|
|
38
|
-
* { dependsOn: ['Domain.Order.OrderPlaced'] }
|
|
39
|
-
* );
|
|
40
|
-
* ```
|
|
126
|
+
* AI Code Gate (basic).
|
|
41
127
|
*
|
|
42
|
-
*
|
|
43
|
-
* - `Domain.*` for domain concepts and events
|
|
44
|
-
* - `Application.*` for use cases / orchestration
|
|
45
|
-
* - `Adapter.*` for external integrations
|
|
46
|
-
* - `Workflow.*` for sagas and long-running processes
|
|
47
|
-
* @param options - Optional initial relationship declarations (`dependsOn`, `produces`)
|
|
48
|
-
*/
|
|
49
|
-
declare function defineIntent<N extends IntentName, P = unknown>(name: N, options?: DefineIntentOptions): IntentCreator<N, P>;
|
|
50
|
-
/**
|
|
51
|
-
* Create an isolated IntentRegistry.
|
|
52
|
-
* Useful for testing, multiple bounded contexts, or advanced governance setups.
|
|
53
|
-
*/
|
|
54
|
-
declare function createIntentRegistry(): IntentRegistry;
|
|
55
|
-
/**
|
|
56
|
-
* The default registry backing the top-level `defineIntent` calls.
|
|
57
|
-
* You can inspect it or use it directly if needed.
|
|
58
|
-
*/
|
|
59
|
-
declare const defaultIntentRegistry: IntentRegistry;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Runtime validation for semantic intent naming conventions.
|
|
128
|
+
* Allows validation of generated source code against the defined architecture.
|
|
63
129
|
*/
|
|
64
|
-
interface
|
|
65
|
-
|
|
66
|
-
|
|
130
|
+
interface AICodeGateViolation {
|
|
131
|
+
/** Stable rule identifier for agents and CI pipelines. */
|
|
132
|
+
ruleId: string;
|
|
133
|
+
/** @deprecated Use ruleId — kept for backward compatibility. */
|
|
134
|
+
code: string;
|
|
135
|
+
message: string;
|
|
136
|
+
line?: number;
|
|
137
|
+
suggestion?: string;
|
|
138
|
+
source?: string;
|
|
139
|
+
filePath?: string;
|
|
140
|
+
target?: string;
|
|
141
|
+
fromLayer?: string;
|
|
142
|
+
toLayer?: string;
|
|
143
|
+
details?: unknown;
|
|
67
144
|
}
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Typed error thrown when hard policies are violated.
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
declare class PolicyViolationError extends Error {
|
|
78
|
-
readonly violations: PolicyViolation[];
|
|
79
|
-
constructor(violations: PolicyViolation[]);
|
|
145
|
+
/** Extension point for external analyzers (AST, semantic, etc.). */
|
|
146
|
+
interface AIGateExtension<Context = unknown> {
|
|
147
|
+
readonly name: string;
|
|
148
|
+
analyze(source: string, context?: Context): AICodeGateViolation[];
|
|
80
149
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
version?: string;
|
|
94
|
-
rationale?: string;
|
|
95
|
-
enforcementMode?: PolicyEnforcementMode;
|
|
96
|
-
deprecated?: boolean | string;
|
|
97
|
-
replacedBy?: string;
|
|
98
|
-
check: (context: Context) => boolean | PolicyViolation | PolicyViolation[];
|
|
150
|
+
interface AICodeGateContext {
|
|
151
|
+
filePath?: string;
|
|
152
|
+
agentId?: string;
|
|
153
|
+
layer?: string;
|
|
154
|
+
[key: string]: unknown;
|
|
155
|
+
}
|
|
156
|
+
interface AICodeGateResult {
|
|
157
|
+
valid: boolean;
|
|
158
|
+
violations: AICodeGateViolation[];
|
|
159
|
+
}
|
|
160
|
+
interface AICodeGate<Context = AICodeGateContext> {
|
|
161
|
+
validate(source: string, context?: Context): AICodeGateResult;
|
|
99
162
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Creates a Policy from a declarative configuration.
|
|
102
|
-
*
|
|
103
|
-
* The provided `check` function is called as-is. The PolicyEngine is responsible
|
|
104
|
-
* for normalizing results (booleans, single violations, arrays) into a consistent
|
|
105
|
-
* set of PolicyViolation objects.
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* ```ts
|
|
109
|
-
* const noDomainToInfra = definePolicy({
|
|
110
|
-
* name: 'Domain must not depend on infrastructure',
|
|
111
|
-
* severity: 'hard',
|
|
112
|
-
* check: (ctx) => {
|
|
113
|
-
* const violations: PolicyViolation[] = [];
|
|
114
|
-
* // ... logic using ctx.registry.getAllRelationships()
|
|
115
|
-
* return violations.length > 0 ? violations : true;
|
|
116
|
-
* }
|
|
117
|
-
* });
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
120
|
-
declare function definePolicy<Context = unknown>(options: DefinePolicyOptions<Context>): Policy<Context>;
|
|
121
|
-
|
|
122
|
-
declare function createArchitectureProfile(options: CreateArchitectureProfileOptions): ArchitectureProfile;
|
|
123
|
-
declare function createArchitectureProfileFromArkConfig(config: ArkCheckConfig, options?: CreateArchitectureProfileFromArkConfigOptions): ArchitectureProfile;
|
|
124
|
-
declare const elevenLayerProfile: ArchitectureProfile;
|
|
125
|
-
declare function createElevenLayerArkConfig(options?: CreateElevenLayerArkConfigOptions): ArkCheckConfig;
|
|
126
163
|
|
|
127
164
|
/**
|
|
128
|
-
*
|
|
165
|
+
* Policy types for the Ark kernel.
|
|
129
166
|
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* Supports simple violation detection via rule functions.
|
|
167
|
+
* Policies allow declaring architectural rules that can be checked at runtime.
|
|
168
|
+
* Supports both hard policies (must never be violated) and soft policies (warnings).
|
|
133
169
|
*/
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
170
|
+
type PolicySeverity = 'hard' | 'soft';
|
|
171
|
+
type PolicyEnforcementMode = 'runtime' | 'static' | 'runtime-and-static' | 'advisory';
|
|
137
172
|
/**
|
|
138
|
-
*
|
|
173
|
+
* Represents a single violation of a policy.
|
|
139
174
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
175
|
+
interface PolicyViolation {
|
|
176
|
+
/** Name of the policy that was violated */
|
|
177
|
+
policyName: string;
|
|
178
|
+
/** Severity level of the policy */
|
|
179
|
+
severity: PolicySeverity;
|
|
180
|
+
/** Human-readable explanation of the violation */
|
|
181
|
+
message: string;
|
|
182
|
+
/** Optional additional structured details */
|
|
183
|
+
details?: unknown;
|
|
144
184
|
}
|
|
145
185
|
/**
|
|
146
|
-
*
|
|
186
|
+
* A Policy defines a rule that can be evaluated against a context.
|
|
147
187
|
*
|
|
148
|
-
* -
|
|
149
|
-
* - `produces` → `produces` edges
|
|
150
|
-
*/
|
|
151
|
-
declare function syncRegistryToGraph(registry: IntentRegistry, graph: DependencyGraph, options?: SyncRegistryOptions): void;
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Built-in architectural policy helpers.
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
interface LayerFlowRule {
|
|
158
|
-
from: string;
|
|
159
|
-
to: string;
|
|
160
|
-
allowed: boolean;
|
|
161
|
-
message?: string;
|
|
162
|
-
}
|
|
163
|
-
interface LayerPolicyOptions {
|
|
164
|
-
name?: string;
|
|
165
|
-
severity?: 'hard' | 'soft';
|
|
166
|
-
/** Prefix rules — e.g. { from: 'Domain', to: 'Adapter', allowed: false } */
|
|
167
|
-
rules: LayerFlowRule[];
|
|
168
|
-
resolveLayer?: (name: string) => string | undefined;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Create a policy that enforces layer-crossing rules on graph edges or intent relationships.
|
|
188
|
+
* @template Context - The shape of data the policy evaluates (e.g. { registry, events })
|
|
172
189
|
*/
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
edges?: GraphEdge[];
|
|
187
|
-
relationships?: IntentRelationship[];
|
|
188
|
-
}>;
|
|
190
|
+
interface Policy<Context = unknown> {
|
|
191
|
+
/** Unique name of the policy (used in violations and reporting) */
|
|
192
|
+
readonly name: string;
|
|
193
|
+
/** Whether this is a hard rule (enforced strictly) or soft (advisory) */
|
|
194
|
+
readonly severity: PolicySeverity;
|
|
195
|
+
/** Optional tags for policy classification (e.g. 'layer', 'naming') */
|
|
196
|
+
readonly tags?: readonly string[];
|
|
197
|
+
readonly owner?: string;
|
|
198
|
+
readonly version?: string;
|
|
199
|
+
readonly rationale?: string;
|
|
200
|
+
readonly enforcementMode?: PolicyEnforcementMode;
|
|
201
|
+
readonly deprecated?: boolean | string;
|
|
202
|
+
readonly replacedBy?: string;
|
|
189
203
|
/**
|
|
190
|
-
*
|
|
191
|
-
*
|
|
204
|
+
* Evaluates the policy against the given context.
|
|
205
|
+
* Return true / [] for pass, false / single violation / array for failure.
|
|
192
206
|
*/
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
relationships?: IntentRelationship[];
|
|
196
|
-
}>;
|
|
197
|
-
};
|
|
198
|
-
declare function defineArchitectureProfilePolicy<Context extends {
|
|
199
|
-
edges?: GraphEdge[];
|
|
200
|
-
relationships?: IntentRelationship[];
|
|
201
|
-
}>(profile: ArchitectureProfile, options?: Omit<LayerPolicyOptions, 'rules' | 'resolveLayer'>): Policy<Context>;
|
|
207
|
+
check(context: Context): boolean | PolicyViolation | PolicyViolation[];
|
|
208
|
+
}
|
|
202
209
|
|
|
203
210
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* durable log/DB (see `docs/production-hardening.md`).
|
|
211
|
+
* Core domain primitives for Ark.
|
|
212
|
+
* These types are the foundation for all governance concepts.
|
|
207
213
|
*/
|
|
208
|
-
declare class InMemoryAuditStore implements AuditStore {
|
|
209
|
-
private readonly maxRecords?;
|
|
210
|
-
private readonly records;
|
|
211
|
-
constructor(maxRecords?: number | undefined);
|
|
212
|
-
append(record: AuditRecord): void;
|
|
213
|
-
query(query?: AuditQuery): AuditRecord[];
|
|
214
|
-
clear(): void;
|
|
215
|
-
}
|
|
216
214
|
/**
|
|
217
|
-
*
|
|
218
|
-
*
|
|
215
|
+
* Semantic intent names follow a convention:
|
|
216
|
+
* - Domain.* for domain events and entities
|
|
217
|
+
* - Application.* for use-cases / orchestration
|
|
218
|
+
* - Adapter.* for integration points
|
|
219
|
+
* - Workflow.* for sagas and processes
|
|
220
|
+
* - Job.* for background jobs and scheduling
|
|
221
|
+
* - Presentation.* for UI/API adapters
|
|
222
|
+
* - Reporting.* for read models and projections
|
|
223
|
+
* - Metadata.* for extensibility contracts
|
|
224
|
+
* - Security.* / Audit.* / Observability.* for cross-cutting kernel concerns
|
|
225
|
+
* - Kernel.* for Ark-owned governance signals
|
|
219
226
|
*/
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
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}`;
|
|
228
|
+
type CorrelationId = string;
|
|
229
|
+
interface EventMetadata {
|
|
230
|
+
occurredAt: string;
|
|
231
|
+
source: string;
|
|
232
|
+
kernelInstanceId?: string;
|
|
233
|
+
eventVersion?: string;
|
|
234
|
+
schemaVersion?: string;
|
|
235
|
+
allowInterception?: boolean;
|
|
236
|
+
interceptions?: Array<{
|
|
237
|
+
interceptorId: string;
|
|
238
|
+
timestamp: string;
|
|
239
|
+
}>;
|
|
240
|
+
correlationId?: CorrelationId;
|
|
241
|
+
causationId?: string;
|
|
242
|
+
traceId?: string;
|
|
243
|
+
spanId?: string;
|
|
244
|
+
parentSpanId?: string;
|
|
245
|
+
[key: string]: unknown;
|
|
230
246
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
* process exit. Use only for tests/demos/local single-process work; inject a durable
|
|
236
|
-
* `OutboxStore` in production (see `docs/production-hardening.md`).
|
|
237
|
-
*/
|
|
238
|
-
declare class InMemoryOutboxStore implements OutboxStore {
|
|
239
|
-
private readonly records;
|
|
240
|
-
enqueue(event: DomainEvent): Promise<OutboxRecord>;
|
|
241
|
-
markDispatched(id: string): Promise<void>;
|
|
242
|
-
markFailed(id: string, error: unknown): Promise<void>;
|
|
243
|
-
list(status?: OutboxStatus): Promise<OutboxRecord[]>;
|
|
244
|
-
clear(): Promise<void>;
|
|
247
|
+
interface DomainEvent<Name extends IntentName = IntentName, Payload = unknown> {
|
|
248
|
+
intent: Name;
|
|
249
|
+
payload: Payload;
|
|
250
|
+
metadata: EventMetadata;
|
|
245
251
|
}
|
|
246
252
|
|
|
247
253
|
/**
|
|
248
|
-
*
|
|
254
|
+
* Intent-specific types for the Ark kernel.
|
|
249
255
|
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
* policy → history/outbox/trace → handlers → onPublish hook
|
|
253
|
-
*/
|
|
254
|
-
|
|
255
|
-
declare function createEventBus<Context = unknown>(options?: EventBusOptions<Context>): EventBus;
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Helpers for building policy evaluation context on event publish.
|
|
256
|
+
* Intents provide semantic naming for every important concept in the system
|
|
257
|
+
* (domain events, application operations, adapters, workflows).
|
|
259
258
|
*/
|
|
260
259
|
|
|
261
260
|
/**
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
|
|
266
|
-
interface PublishPolicyContext {
|
|
267
|
-
event: DomainEvent;
|
|
268
|
-
relationships?: IntentRelationship[];
|
|
269
|
-
edges?: GraphEdge[];
|
|
270
|
-
}
|
|
271
|
-
interface GraphPolicyContext {
|
|
272
|
-
relationships?: IntentRelationship[];
|
|
273
|
-
edges?: GraphEdge[];
|
|
274
|
-
}
|
|
275
|
-
interface BuildPublishPolicyContextOptions {
|
|
276
|
-
intentRegistry?: IntentRegistry;
|
|
277
|
-
dependencyGraph?: DependencyGraph;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Build a getPolicyContext function that feeds registry + graph data to policies.
|
|
261
|
+
* An IntentCreator is a callable that creates a strongly-typed DomainEvent
|
|
262
|
+
* when invoked with a payload.
|
|
263
|
+
*
|
|
264
|
+
* It also carries the semantic `name`.
|
|
281
265
|
*
|
|
282
266
|
* @example
|
|
283
|
-
*
|
|
284
|
-
* const
|
|
285
|
-
* intentRegistry: registry,
|
|
286
|
-
* dependencyGraph: graph,
|
|
287
|
-
* policies: [architecturalPolicies.layerIsolation()],
|
|
288
|
-
* });
|
|
289
|
-
* ```
|
|
290
|
-
*/
|
|
291
|
-
declare function buildPublishPolicyContext(options: BuildPublishPolicyContextOptions): (event: DomainEvent) => PublishPolicyContext;
|
|
292
|
-
declare function definePublishPolicy(options: DefinePolicyOptions<PublishPolicyContext>): Policy<PublishPolicyContext>;
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Event bus governance errors.
|
|
296
|
-
*/
|
|
297
|
-
declare class UnregisteredIntentError extends Error {
|
|
298
|
-
readonly intentName: string;
|
|
299
|
-
constructor(intentName: string);
|
|
300
|
-
}
|
|
301
|
-
declare class InvalidIntentNameError extends Error {
|
|
302
|
-
readonly intentName: string;
|
|
303
|
-
readonly reason: string;
|
|
304
|
-
constructor(intentName: string, reason: string);
|
|
305
|
-
}
|
|
306
|
-
declare class LayerPolicyContextError extends Error {
|
|
307
|
-
constructor();
|
|
308
|
-
}
|
|
309
|
-
declare class EventContractViolationError extends Error {
|
|
310
|
-
readonly intentName: string;
|
|
311
|
-
readonly issues: unknown[];
|
|
312
|
-
constructor(intentName: string, issues: unknown[]);
|
|
313
|
-
}
|
|
314
|
-
declare class UnknownEventSourceError extends Error {
|
|
315
|
-
readonly intentName: string;
|
|
316
|
-
readonly source?: string;
|
|
317
|
-
constructor(intentName: string, source?: string);
|
|
318
|
-
}
|
|
319
|
-
declare class SourceMetadataOverrideError extends Error {
|
|
320
|
-
readonly boundSource: string;
|
|
321
|
-
readonly attemptedSource: string;
|
|
322
|
-
constructor(boundSource: string, attemptedSource: string);
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Thrown when the OBSERVED producer→event flow crosses a forbidden layer boundary
|
|
326
|
-
* under `enforceObservedLayerFlow: 'hard'`. Unlike declared-model policy errors, this
|
|
327
|
-
* reflects what the running system actually did at publish time.
|
|
267
|
+
* const OrderPlaced = defineIntent<'Domain.Order.OrderPlaced', { orderId: string }>('Domain.Order.OrderPlaced');
|
|
268
|
+
* const event = OrderPlaced({ orderId: 'o-1' });
|
|
328
269
|
*/
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Basic MetadataRegistry implementation.
|
|
341
|
-
*/
|
|
342
|
-
|
|
343
|
-
declare function createMetadataRegistry(): MetadataRegistry;
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Reference in-process read-model store. **Not production durability.**
|
|
347
|
-
* See `docs/production-hardening.md`.
|
|
348
|
-
*/
|
|
349
|
-
declare class InMemoryReadModelStore implements ReadModelStore {
|
|
350
|
-
private readonly states;
|
|
351
|
-
load<State = unknown>(name: string): State | undefined;
|
|
352
|
-
save<State = unknown>(name: string, state: State): void;
|
|
353
|
-
clear(name?: string): void;
|
|
354
|
-
}
|
|
355
|
-
declare function createProjectionRegistry(options?: CreateProjectionRegistryOptions): ProjectionRegistry;
|
|
356
|
-
|
|
357
|
-
/** Current Ark manifest JSON schema version. */
|
|
358
|
-
declare const MANIFEST_SCHEMA_VERSION = "1.0";
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Aggregates kernel registries into a single machine-readable manifest.
|
|
362
|
-
*/
|
|
363
|
-
|
|
364
|
-
interface CreateArkManifestOptions {
|
|
365
|
-
registry?: IntentRegistry;
|
|
366
|
-
policyEngine?: PolicyEngine;
|
|
367
|
-
metadata?: MetadataRegistry;
|
|
368
|
-
graph?: DependencyGraph;
|
|
369
|
-
profile?: ArchitectureProfile;
|
|
370
|
-
projections?: ProjectionRegistry;
|
|
371
|
-
eventContracts?: EventContractRegistry;
|
|
372
|
-
observability?: ObservabilityReporter;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Create a machine-readable snapshot of the current architectural contract.
|
|
376
|
-
* Intended for AI agents, codegen tools, and documentation generators.
|
|
377
|
-
*/
|
|
378
|
-
declare function createArkManifest(options?: CreateArkManifestOptions): ArkManifest;
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* In-process workflow engine with durable-store seams.
|
|
382
|
-
*/
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Reference in-process workflow store. **Not production durability.**
|
|
386
|
-
* See `docs/production-hardening.md`.
|
|
387
|
-
*/
|
|
388
|
-
declare class InMemoryWorkflowStore implements WorkflowStore {
|
|
389
|
-
private readonly snapshots;
|
|
390
|
-
save<P extends SagaContext>(snapshot: WorkflowSnapshot<P>): void;
|
|
391
|
-
get<P extends SagaContext = SagaContext>(id: string): WorkflowSnapshot<P> | undefined;
|
|
392
|
-
list(workflowName?: string): WorkflowSnapshot[];
|
|
393
|
-
clear(): void;
|
|
270
|
+
interface IntentCreator<Name extends IntentName, Payload = unknown> {
|
|
271
|
+
/**
|
|
272
|
+
* Creates a DomainEvent for this intent.
|
|
273
|
+
*/
|
|
274
|
+
(payload: Payload): DomainEvent<Name, Payload>;
|
|
275
|
+
/**
|
|
276
|
+
* The fully-qualified semantic name of the intent (e.g. "Domain.Order.OrderPlaced").
|
|
277
|
+
*/
|
|
278
|
+
readonly name: Name;
|
|
394
279
|
}
|
|
395
|
-
declare function createWorkflowEngine(bus: EventBus, options?: CreateWorkflowEngineOptions): WorkflowEngine;
|
|
396
|
-
declare function createSaga<P extends SagaContext = SagaContext>(def: SagaDefinition<P>, bus: EventBus, options?: CreateWorkflowEngineOptions & {
|
|
397
|
-
id?: string;
|
|
398
|
-
}): SagaInstance<P>;
|
|
399
280
|
|
|
400
281
|
/**
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
282
|
+
* Architecture layer profiles.
|
|
283
|
+
*
|
|
284
|
+
* A profile turns semantic names such as `Domain.Order.Placed` into governed
|
|
285
|
+
* layer names and dependency rules.
|
|
404
286
|
*/
|
|
405
|
-
declare const DEFAULT_MAX_HISTORY_SIZE = 1000;
|
|
406
|
-
declare function createArkKernel(options?: CreateArkKernelOptions): ArkKernel;
|
|
407
|
-
declare function createStrictArkKernel(options?: CreateArkKernelOptions): ArkKernel;
|
|
408
|
-
declare function createArkKernelFromConfig(config: ArkKernelConfig, options?: CreateArkKernelFromConfigOptions): ArkKernel;
|
|
409
|
-
declare function createStrictArkKernelFromConfig(config: ArkKernelConfig, options?: CreateArkKernelFromConfigOptions): ArkKernel;
|
|
410
|
-
declare function createLenientArkKernelFromConfig(config: ArkKernelConfig, options?: CreateArkKernelFromConfigOptions): ArkKernel;
|
|
411
|
-
declare function createLenientArkKernel(options?: CreateArkKernelOptions): ArkKernel;
|
|
412
|
-
|
|
413
|
-
interface ArkTestSnapshot {
|
|
414
|
-
events: DomainEvent[];
|
|
415
|
-
traces: TraceRecord[];
|
|
416
|
-
audit: AuditRecord[];
|
|
417
|
-
outbox: OutboxRecord[];
|
|
418
|
-
observability: ObservabilityDriftReport;
|
|
419
|
-
}
|
|
420
|
-
interface ArkTestHarness {
|
|
421
|
-
events(intent?: string): DomainEvent[];
|
|
422
|
-
traces(type?: TraceRecordType): TraceRecord[];
|
|
423
|
-
audit(query?: AuditQuery): Promise<AuditRecord[]>;
|
|
424
|
-
outbox(status?: OutboxStatus): Promise<OutboxRecord[]>;
|
|
425
|
-
observability(): ObservabilityDriftReport;
|
|
426
|
-
snapshot(): Promise<ArkTestSnapshot>;
|
|
427
|
-
clear(): Promise<void>;
|
|
428
|
-
}
|
|
429
287
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
288
|
+
interface ArchitectureLayer {
|
|
289
|
+
name: string;
|
|
290
|
+
prefixes: string[];
|
|
291
|
+
/**
|
|
292
|
+
* Custom matcher for teams whose intent names don't follow prefix conventions.
|
|
293
|
+
* Checked before any prefix matching, in layer declaration order. A layer may
|
|
294
|
+
* use `match` alone (with `prefixes: []`), prefixes alone, or both.
|
|
295
|
+
*/
|
|
296
|
+
match?: (name: string) => boolean;
|
|
297
|
+
description?: string;
|
|
298
|
+
order?: number;
|
|
441
299
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
300
|
+
type ArchitectureRule = ArkConfigRule;
|
|
301
|
+
interface ArchitectureProfile {
|
|
302
|
+
name: string;
|
|
303
|
+
layers: ArchitectureLayer[];
|
|
304
|
+
rules: ArchitectureRule[];
|
|
305
|
+
resolveLayer(name: string): string | undefined;
|
|
448
306
|
}
|
|
449
|
-
interface
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
307
|
+
interface CreateArchitectureProfileOptions {
|
|
308
|
+
name: string;
|
|
309
|
+
layers: ArchitectureLayer[];
|
|
310
|
+
rules?: ArchitectureRule[];
|
|
453
311
|
}
|
|
454
|
-
interface
|
|
312
|
+
interface CreateArchitectureProfileFromArkConfigOptions {
|
|
313
|
+
/** Runtime profile name. Default: config.name or "ark.config.json". */
|
|
455
314
|
name?: string;
|
|
456
|
-
layer?: string;
|
|
457
|
-
intent?: IntentName;
|
|
458
|
-
requiredKeys?: string[];
|
|
459
315
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
} | {
|
|
466
|
-
ok: false;
|
|
467
|
-
missing: string[];
|
|
316
|
+
type ArchitectureLayerConfig = ArkConfigLayer;
|
|
317
|
+
type ArkCheckConfig = Omit<ArkConfig, '$schema' | 'schemaVersion' | 'rules'> & {
|
|
318
|
+
$schema?: string;
|
|
319
|
+
schemaVersion?: ArkConfig['schemaVersion'];
|
|
320
|
+
rules?: ArchitectureRule[];
|
|
468
321
|
};
|
|
469
|
-
interface
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
322
|
+
interface CreateElevenLayerArkConfigOptions {
|
|
323
|
+
/** Source root used in generated file patterns. Default: "src". */
|
|
324
|
+
rootDir?: string;
|
|
325
|
+
/** Include entries for ark-check. Default: [rootDir]. */
|
|
326
|
+
include?: string[];
|
|
327
|
+
/** Mark generated layers optional. Default: true. */
|
|
328
|
+
optionalLayers?: boolean;
|
|
474
329
|
}
|
|
475
|
-
type AdapterGovernanceResult = {
|
|
476
|
-
ok: true;
|
|
477
|
-
issues: [];
|
|
478
|
-
} | {
|
|
479
|
-
ok: false;
|
|
480
|
-
issues: AdapterGovernanceIssue[];
|
|
481
|
-
};
|
|
482
330
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
*/
|
|
488
|
-
|
|
489
|
-
declare function definePort<T = unknown>(name: string, options?: DefinePortOptions): Port<T>;
|
|
490
|
-
declare function createAdapter<T>(port: Port<T>, impl: T, requiredKeysOrOptions?: string[] | CreateAdapterOptions, adapterOptions?: CreateAdapterOptions): Adapter<T>;
|
|
491
|
-
declare function checkContract(impl: unknown, requiredKeys?: string[]): ContractCheckResult;
|
|
492
|
-
declare function checkAdapterGovernance(adapter: Adapter): AdapterGovernanceResult;
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* AI Code Gate (basic).
|
|
496
|
-
*
|
|
497
|
-
* Allows validation of generated source code against the defined architecture.
|
|
498
|
-
*/
|
|
499
|
-
interface AICodeGateViolation {
|
|
500
|
-
/** Stable rule identifier for agents and CI pipelines. */
|
|
501
|
-
ruleId: string;
|
|
502
|
-
/** @deprecated Use ruleId — kept for backward compatibility. */
|
|
503
|
-
code: string;
|
|
504
|
-
message: string;
|
|
505
|
-
line?: number;
|
|
506
|
-
suggestion?: string;
|
|
507
|
-
source?: string;
|
|
508
|
-
filePath?: string;
|
|
509
|
-
target?: string;
|
|
510
|
-
fromLayer?: string;
|
|
511
|
-
toLayer?: string;
|
|
512
|
-
details?: unknown;
|
|
513
|
-
}
|
|
514
|
-
/** Extension point for external analyzers (AST, semantic, etc.). */
|
|
515
|
-
interface AIGateExtension<Context = unknown> {
|
|
516
|
-
readonly name: string;
|
|
517
|
-
analyze(source: string, context?: Context): AICodeGateViolation[];
|
|
518
|
-
}
|
|
519
|
-
interface AICodeGateContext {
|
|
520
|
-
filePath?: string;
|
|
521
|
-
agentId?: string;
|
|
522
|
-
layer?: string;
|
|
523
|
-
[key: string]: unknown;
|
|
524
|
-
}
|
|
525
|
-
interface AICodeGateResult {
|
|
526
|
-
valid: boolean;
|
|
527
|
-
violations: AICodeGateViolation[];
|
|
528
|
-
}
|
|
529
|
-
interface AICodeGate<Context = AICodeGateContext> {
|
|
530
|
-
validate(source: string, context?: Context): AICodeGateResult;
|
|
531
|
-
}
|
|
331
|
+
declare function createArchitectureProfile(options: CreateArchitectureProfileOptions): ArchitectureProfile;
|
|
332
|
+
declare function createArchitectureProfileFromArkConfig(config: ArkCheckConfig, options?: CreateArchitectureProfileFromArkConfigOptions): ArchitectureProfile;
|
|
333
|
+
declare const elevenLayerProfile: ArchitectureProfile;
|
|
334
|
+
declare function createElevenLayerArkConfig(options?: CreateElevenLayerArkConfigOptions): ArkCheckConfig;
|
|
532
335
|
|
|
533
336
|
/**
|
|
534
337
|
* Basic AI Code Gate implementation.
|
|
@@ -603,9 +406,172 @@ interface AICodeGateOptions<Context = AICodeGateContext> {
|
|
|
603
406
|
name: string;
|
|
604
407
|
patterns?: string[];
|
|
605
408
|
}>;
|
|
606
|
-
/** Explicit file-level escape hatch for reviewed non-literal
|
|
409
|
+
/** Explicit file-level escape hatch for reviewed non-literal import()/require() calls. */
|
|
607
410
|
allowNonLiteralDynamicImport?: (filePath?: string) => boolean;
|
|
608
411
|
}
|
|
609
412
|
declare function createAICodeGate<Context = AICodeGateContext>(options?: AICodeGateOptions<Context>): AICodeGate<Context>;
|
|
610
413
|
|
|
611
|
-
|
|
414
|
+
/**
|
|
415
|
+
* Stable, pure vocabulary for ArkGate's importable analysis engine.
|
|
416
|
+
*
|
|
417
|
+
* Parsing and filesystem discovery belong to adapters. This module intentionally
|
|
418
|
+
* contains only the versioned data contract and deterministic hash primitives.
|
|
419
|
+
*/
|
|
420
|
+
declare const ANALYSIS_IR_SCHEMA_VERSION: "1.0";
|
|
421
|
+
type AnalysisFileInput = {
|
|
422
|
+
path: string;
|
|
423
|
+
content: string;
|
|
424
|
+
};
|
|
425
|
+
type AnalysisFileChange = {
|
|
426
|
+
path: string;
|
|
427
|
+
content: string;
|
|
428
|
+
} | {
|
|
429
|
+
path: string;
|
|
430
|
+
delete: true;
|
|
431
|
+
};
|
|
432
|
+
type AnalysisCompilerOptions = Readonly<Record<string, unknown>>;
|
|
433
|
+
type AnalysisFile = AnalysisFileInput & {
|
|
434
|
+
contentHash: string;
|
|
435
|
+
layer: string | null;
|
|
436
|
+
};
|
|
437
|
+
type AnalysisImportEdge = {
|
|
438
|
+
from: string;
|
|
439
|
+
specifier: string;
|
|
440
|
+
to: string | null;
|
|
441
|
+
resolution: 'resolved' | 'unresolved';
|
|
442
|
+
fromLayer: string | null;
|
|
443
|
+
toLayer: string | null;
|
|
444
|
+
evidence: AnalysisEvidence;
|
|
445
|
+
};
|
|
446
|
+
/** A capability use is reserved for C04's symbol-aware implementation. */
|
|
447
|
+
type AnalysisCapabilityUse = {
|
|
448
|
+
file: string;
|
|
449
|
+
symbol: string;
|
|
450
|
+
capability: string;
|
|
451
|
+
evidence: AnalysisEvidence;
|
|
452
|
+
};
|
|
453
|
+
type AnalysisEvidence = {
|
|
454
|
+
kind: 'import' | 'policy';
|
|
455
|
+
file: string;
|
|
456
|
+
line: number;
|
|
457
|
+
excerpt: string;
|
|
458
|
+
};
|
|
459
|
+
type AnalysisViolation = {
|
|
460
|
+
ruleId: string;
|
|
461
|
+
message: string;
|
|
462
|
+
edge?: AnalysisImportEdge;
|
|
463
|
+
evidence: AnalysisEvidence;
|
|
464
|
+
};
|
|
465
|
+
type AnalysisIr = {
|
|
466
|
+
schemaVersion: typeof ANALYSIS_IR_SCHEMA_VERSION;
|
|
467
|
+
policyHash: string;
|
|
468
|
+
compilerOptionsHash: string;
|
|
469
|
+
files: AnalysisFile[];
|
|
470
|
+
layers: string[];
|
|
471
|
+
edges: AnalysisImportEdge[];
|
|
472
|
+
capabilityUses: AnalysisCapabilityUse[];
|
|
473
|
+
violations: AnalysisViolation[];
|
|
474
|
+
};
|
|
475
|
+
/**
|
|
476
|
+
* Stable FNV-1a hash. It is an identity/fingerprint, not a security primitive.
|
|
477
|
+
* The output is deliberately portable across the CLI, MCP, hooks, and browserless
|
|
478
|
+
* consumers without Node's crypto runtime.
|
|
479
|
+
*/
|
|
480
|
+
declare function deterministicHash(value: string): string;
|
|
481
|
+
/** Serialize JSON-like values with sorted object keys for reproducible hashes. */
|
|
482
|
+
declare function stableSerialize(value: unknown): string;
|
|
483
|
+
|
|
484
|
+
type SemanticDependencyKind = 'import' | 'export' | 'dynamic-import' | 'require';
|
|
485
|
+
type SemanticDependency = {
|
|
486
|
+
specifier?: string;
|
|
487
|
+
kind: SemanticDependencyKind;
|
|
488
|
+
line: number;
|
|
489
|
+
typeOnly: boolean;
|
|
490
|
+
unresolved: boolean;
|
|
491
|
+
node: unknown;
|
|
492
|
+
};
|
|
493
|
+
type ForbiddenCapabilityUse = {
|
|
494
|
+
name: string;
|
|
495
|
+
line: number;
|
|
496
|
+
node: unknown;
|
|
497
|
+
};
|
|
498
|
+
/** Extract every dependency form whose specifier is statically knowable, plus unresolved calls. */
|
|
499
|
+
declare function extractSemanticDependencies(ts: any, sourceFile: any): SemanticDependency[];
|
|
500
|
+
/** Resolve forbidden ambient capabilities through symbols, aliases, globalThis, and static keys. */
|
|
501
|
+
declare function collectForbiddenCapabilityUses(ts: any, sourceFile: any, forbidden: readonly string[]): ForbiddenCapabilityUse[];
|
|
502
|
+
|
|
503
|
+
type AnalysisContract = ArkConfigLoadResult & {
|
|
504
|
+
policyHash: string;
|
|
505
|
+
};
|
|
506
|
+
type AnalyzeProjectInput = {
|
|
507
|
+
contract: AnalysisContract;
|
|
508
|
+
files: readonly AnalysisFileInput[];
|
|
509
|
+
compilerOptions?: AnalysisCompilerOptions;
|
|
510
|
+
};
|
|
511
|
+
type AnalyzeChangeInput = AnalyzeProjectInput & {
|
|
512
|
+
changes: readonly AnalysisFileChange[];
|
|
513
|
+
};
|
|
514
|
+
type AnalysisResult = {
|
|
515
|
+
ir: AnalysisIr;
|
|
516
|
+
};
|
|
517
|
+
type ArchitectureEngineViolation = {
|
|
518
|
+
ruleId: string;
|
|
519
|
+
message: string;
|
|
520
|
+
file?: string;
|
|
521
|
+
line?: number;
|
|
522
|
+
target?: string;
|
|
523
|
+
fromLayer?: string;
|
|
524
|
+
toLayer?: string;
|
|
525
|
+
[key: string]: unknown;
|
|
526
|
+
};
|
|
527
|
+
type ArchitectureEngineEdge = {
|
|
528
|
+
from: string;
|
|
529
|
+
fromLayer: string;
|
|
530
|
+
to?: string;
|
|
531
|
+
toLayer?: string;
|
|
532
|
+
line: number;
|
|
533
|
+
kind: string;
|
|
534
|
+
typeOnly?: boolean;
|
|
535
|
+
targetTypeOnlyExports?: boolean;
|
|
536
|
+
sourcePureTypeModule?: boolean;
|
|
537
|
+
namedBindingsTypeOnly?: boolean;
|
|
538
|
+
portProofEligible?: boolean;
|
|
539
|
+
};
|
|
540
|
+
type EvaluateArchitectureGraphInput = {
|
|
541
|
+
config: ArkConfig;
|
|
542
|
+
rules: ArkConfig['rules'];
|
|
543
|
+
files: readonly string[];
|
|
544
|
+
contentViolations: readonly ArchitectureEngineViolation[];
|
|
545
|
+
edges: readonly ArchitectureEngineEdge[];
|
|
546
|
+
warnings?: readonly ArchitectureEngineViolation[];
|
|
547
|
+
safety?: unknown;
|
|
548
|
+
};
|
|
549
|
+
type ArchitectureEngineResult = {
|
|
550
|
+
violations: ArchitectureEngineViolation[];
|
|
551
|
+
warnings: ArchitectureEngineViolation[];
|
|
552
|
+
safety?: unknown;
|
|
553
|
+
};
|
|
554
|
+
type CollectAnalysisConfigWarningsInput = {
|
|
555
|
+
config: ArkConfig;
|
|
556
|
+
rules: ArkConfig['rules'];
|
|
557
|
+
files: readonly string[];
|
|
558
|
+
manifest?: {
|
|
559
|
+
architecture?: {
|
|
560
|
+
layers?: readonly {
|
|
561
|
+
name?: string;
|
|
562
|
+
prefixes?: readonly string[];
|
|
563
|
+
}[];
|
|
564
|
+
};
|
|
565
|
+
};
|
|
566
|
+
};
|
|
567
|
+
declare function loadContract(input: unknown, source?: string): AnalysisContract;
|
|
568
|
+
declare function analyzeProject(input: AnalyzeProjectInput): AnalysisResult;
|
|
569
|
+
declare function analyzeChange(input: AnalyzeChangeInput): AnalysisResult;
|
|
570
|
+
declare function explainViolation(violation: AnalysisViolation): string;
|
|
571
|
+
declare function detectArchitectureCycles(graph: ReadonlyMap<string, ReadonlySet<string>>): ArchitectureEngineViolation[];
|
|
572
|
+
/** Canonical graph and layer-policy evaluator shared by library, CLI, and MCP adapters. */
|
|
573
|
+
declare function evaluateArchitectureGraph(input: EvaluateArchitectureGraphInput): ArchitectureEngineResult;
|
|
574
|
+
/** Canonical config diagnostics over repo-relative file paths. */
|
|
575
|
+
declare function collectAnalysisConfigWarnings(input: CollectAnalysisConfigWarningsInput): ArchitectureEngineViolation[];
|
|
576
|
+
|
|
577
|
+
export { type AICodeGate, type AICodeGateContext, type AICodeGateOptions, type AICodeGateResult, type AICodeGateViolation, type AIGateExtension, ANALYSIS_IR_SCHEMA_VERSION, ARK_ANALYSIS_RESULT_SCHEMA, ARK_ANALYSIS_RESULT_SCHEMA_VERSION, type AdapterDiagnostic, type AdapterResult, type AdapterSeverity, type AdapterViolationInput, type AnalysisCapabilityUse, type AnalysisCompilerOptions, type AnalysisContract, type AnalysisEvidence, type AnalysisFile, type AnalysisFileChange, type AnalysisFileInput, type AnalysisImportEdge, type AnalysisIr, type AnalysisResult, type AnalysisViolation, type AnalyzeChangeInput, type AnalyzeProjectInput, type ArchitectureEngineEdge, type ArchitectureEngineResult, type ArchitectureEngineViolation, type ArchitectureLayer, type ArchitectureLayerConfig, type ArchitectureProfile, type ArchitectureRule, type ArkCheckConfig, ArkConfig, ArkConfigLoadResult, type CollectAnalysisConfigWarningsInput, type CreateArchitectureProfileFromArkConfigOptions, type CreateArchitectureProfileOptions, type CreateElevenLayerArkConfigOptions, type EvaluateArchitectureGraphInput, type ForbiddenCapabilityUse, type SemanticDependency, type SemanticDependencyKind, analyzeChange, analyzeProject, collectAnalysisConfigWarnings, collectForbiddenCapabilityUses, createAICodeGate, createAdapterResult, createArchitectureProfile, createArchitectureProfileFromArkConfig, createElevenLayerArkConfig, detectArchitectureCycles, deterministicHash, elevenLayerProfile, evaluateArchitectureGraph, explainViolation, extractSemanticDependencies, loadContract, stableSerialize, toAdapterDiagnostic, version };
|