arkgate 3.7.0 → 3.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +76 -1145
  2. package/README.md +59 -19
  3. package/bin/ark-check-runtime.mjs +1598 -0
  4. package/bin/ark-check.mjs +32 -1565
  5. package/bin/ark-mcp-runtime.mjs +1976 -0
  6. package/bin/ark-mcp.mjs +84 -1495
  7. package/bin/ark-shared.mjs +34 -38
  8. package/bin/ark.mjs +33 -66
  9. package/bin/lib/adapter-contract.mjs +161 -9
  10. package/bin/lib/agent-gates.mjs +1 -0
  11. package/bin/lib/analysis-completeness.mjs +28 -0
  12. package/bin/lib/analysis-engine.mjs +8 -8
  13. package/bin/lib/analysis-policy.mjs +27 -0
  14. package/bin/lib/architecture-scan.mjs +70 -357
  15. package/bin/lib/auto-patch.mjs +76 -8
  16. package/bin/lib/ci-and-commands.mjs +1 -1
  17. package/bin/lib/codex-home.mjs +43 -16
  18. package/bin/lib/design-delta.mjs +4 -0
  19. package/bin/lib/doctor-advisories.mjs +4 -3
  20. package/bin/lib/doctor-plan.mjs +40 -41
  21. package/bin/lib/enforcement-state.mjs +2 -0
  22. package/bin/lib/github-enforcement.mjs +443 -0
  23. package/bin/lib/hook-templates.mjs +12 -148
  24. package/bin/lib/html-report-advisories.mjs +1 -1
  25. package/bin/lib/html-report-depth.mjs +9 -0
  26. package/bin/lib/html-report.mjs +5 -5
  27. package/bin/lib/install-migrate.mjs +83 -79
  28. package/bin/lib/managed-upgrade.mjs +622 -0
  29. package/bin/lib/mcp-adoption.mjs +3 -1
  30. package/bin/lib/parse-health.mjs +6 -5
  31. package/bin/lib/port-proof.mjs +2 -2
  32. package/bin/lib/prepare-change.mjs +68 -38
  33. package/bin/lib/prepare-write.mjs +7 -1
  34. package/bin/lib/resident-doctor-client.mjs +55 -0
  35. package/bin/lib/resident-hook.mjs +247 -0
  36. package/bin/lib/resolved-candidate-facts.mjs +1160 -0
  37. package/bin/lib/scan-files.mjs +19 -6
  38. package/bin/lib/snippet-analysis.mjs +119 -0
  39. package/bin/lib/source-policy.mjs +24 -0
  40. package/bin/lib/typescript-host.mjs +15 -18
  41. package/bin/lib/unavailable-analysis.mjs +76 -0
  42. package/bin/lib/upgrade-command.mjs +115 -0
  43. package/bin/lib/weakest-link.mjs +21 -179
  44. package/bin/lib/write-path-capabilities.mjs +167 -16
  45. package/bin/lib/write-path-detect.mjs +3 -2
  46. package/dist/eslint/index.cjs +3 -3
  47. package/dist/eslint/index.d.ts +3 -0
  48. package/dist/eslint/index.js +3 -3
  49. package/dist/index.cjs +7 -7
  50. package/dist/index.d.ts +1073 -141
  51. package/dist/index.js +7 -7
  52. package/docs/agent-guide.md +103 -59
  53. package/docs/ai-gates.md +97 -16
  54. package/docs/demos/01-write-gate-self-correction.md +2 -2
  55. package/docs/enthusiast/README.md +10 -10
  56. package/docs/enthusiast/how-to-gallery-starter.md +2 -2
  57. package/docs/enthusiast/reference-commands.md +18 -1
  58. package/docs/enthusiast/tutorial-first-project.md +2 -2
  59. package/docs/package-surface.md +98 -12
  60. package/docs/typescript-support.md +109 -37
  61. package/package.json +32 -4
  62. package/schemas/ark.analysis-result.schema.json +159 -2
  63. package/schemas/ark.design-delta.schema.json +1 -0
  64. package/schemas/ark.enforcement-state.schema.json +84 -0
  65. package/schemas/ark.resolved-candidate-facts.schema.json +1 -0
  66. package/server.json +2 -2
  67. package/templates/skills/ark-explore.md +5 -5
  68. package/templates/skills/ark-fix.md +1 -1
  69. package/templates/skills/ark-runtime.md +15 -8
  70. package/templates/skills/ark-upgrade.md +122 -182
  71. package/bin/lib/ai-velocity.mjs +0 -293
  72. package/bin/lib/graph-cycles.mjs +0 -6
  73. package/bin/lib/safety-diagnostics.mjs +0 -284
  74. package/bin/lib/ts-resolve.mjs +0 -228
  75. package/dist/configTypes-DAPvBqK6.d.cts +0 -61
  76. package/dist/eslint/index.d.cts +0 -146
  77. package/dist/index.d.cts +0 -986
package/dist/index.d.ts CHANGED
@@ -234,11 +234,18 @@ declare function loadArkConfigContract(input: unknown, source?: string): ArkConf
234
234
  declare function parseArkConfigJson(json: string, source?: string): ArkConfigLoadResult;
235
235
 
236
236
  /** ArkGate library version — single source of truth. */
237
- declare const version = "3.7.0";
237
+ declare const version = "3.8.0";
238
238
 
239
239
  /** Versioned public result contract shared by every ArkGate enforcement adapter. */
240
- declare const ARK_ANALYSIS_RESULT_SCHEMA_VERSION: "1.1";
240
+ declare const ARK_ANALYSIS_RESULT_SCHEMA_VERSION: "1.3";
241
241
  type AdapterSeverity = 'error' | 'warning';
242
+ type AnalysisCompleteness = 'complete' | 'partial' | 'unavailable';
243
+ type AnalysisMode = 'lexical-compatibility' | 'resolved-candidate-facts';
244
+ type AdapterCompletenessReason = {
245
+ code: string;
246
+ message: string;
247
+ file?: string;
248
+ };
242
249
  type AdapterViolationInput = {
243
250
  ruleId?: unknown;
244
251
  code?: unknown;
@@ -251,8 +258,11 @@ type AdapterViolationInput = {
251
258
  toLayer?: unknown;
252
259
  typeOnly?: unknown;
253
260
  targetTypeOnlyExports?: unknown;
261
+ sourcePureTypeModule?: unknown;
254
262
  namedBindingsTypeOnly?: unknown;
263
+ portProofEligible?: unknown;
255
264
  peerIsolation?: unknown;
265
+ edgeKind?: unknown;
256
266
  severity?: unknown;
257
267
  nextAction?: unknown;
258
268
  /** U04: the denied capability id on CAPABILITY_VIOLATION. */
@@ -272,35 +282,195 @@ type AdapterDiagnostic = {
272
282
  fromLayer?: string;
273
283
  toLayer?: string;
274
284
  typeOnly?: boolean;
285
+ targetTypeOnlyExports?: boolean;
286
+ sourcePureTypeModule?: boolean;
287
+ namedBindingsTypeOnly?: boolean;
288
+ portProofEligible?: boolean;
289
+ peerIsolation?: boolean;
290
+ capability?: string;
291
+ edgeKind?: string;
275
292
  };
276
293
  /** Added in schema 1.1; optional in TypeScript so 1.0 consumer-owned values remain valid. */
277
294
  nextAction?: string;
278
295
  };
279
- type AdapterResult = {
280
- schemaVersion: '1.0' | typeof ARK_ANALYSIS_RESULT_SCHEMA_VERSION;
296
+ type LegacyAdapterResult = {
297
+ schemaVersion: '1.0' | '1.1';
298
+ valid: boolean;
299
+ diagnostics: AdapterDiagnostic[];
300
+ completeness?: never;
301
+ mode?: never;
302
+ };
303
+ type Version12AdapterResultBase = {
304
+ schemaVersion: '1.2';
305
+ diagnostics: AdapterDiagnostic[];
306
+ mode?: never;
307
+ };
308
+ type Version12AdapterResult = (Version12AdapterResultBase & {
309
+ completeness: 'complete';
281
310
  valid: boolean;
311
+ }) | (Version12AdapterResultBase & {
312
+ completeness: 'partial' | 'unavailable';
313
+ valid: false;
314
+ });
315
+ type CurrentAdapterResultBase = {
316
+ schemaVersion: typeof ARK_ANALYSIS_RESULT_SCHEMA_VERSION;
317
+ completenessReasons: AdapterCompletenessReason[];
282
318
  diagnostics: AdapterDiagnostic[];
283
319
  };
320
+ type ResolvedAdapterEvidence = {
321
+ policyHash: string;
322
+ resolverIdentity: string;
323
+ factsHash: string;
324
+ candidateTreeHash: string;
325
+ };
326
+ type CurrentAdapterResult = (CurrentAdapterResultBase & Partial<ResolvedAdapterEvidence> & {
327
+ mode: 'lexical-compatibility';
328
+ valid: boolean;
329
+ completeness: 'complete';
330
+ }) | (CurrentAdapterResultBase & Partial<ResolvedAdapterEvidence> & {
331
+ mode: 'lexical-compatibility';
332
+ valid: false;
333
+ completeness: 'partial' | 'unavailable';
334
+ }) | (CurrentAdapterResultBase & ResolvedAdapterEvidence & {
335
+ mode: 'resolved-candidate-facts';
336
+ valid: boolean;
337
+ completeness: 'complete';
338
+ }) | (CurrentAdapterResultBase & ResolvedAdapterEvidence & {
339
+ mode: 'resolved-candidate-facts';
340
+ valid: false;
341
+ completeness: 'partial';
342
+ }) | (CurrentAdapterResultBase & Partial<ResolvedAdapterEvidence> & {
343
+ mode: 'resolved-candidate-facts';
344
+ valid: false;
345
+ completeness: 'unavailable';
346
+ });
347
+ type AdapterResult = LegacyAdapterResult | Version12AdapterResult | CurrentAdapterResult;
284
348
  declare function toAdapterDiagnostic(violation: AdapterViolationInput, fallbackSeverity?: AdapterSeverity): AdapterDiagnostic;
285
349
  declare function createAdapterResult(input: {
286
350
  valid: boolean;
351
+ completeness?: AnalysisCompleteness;
352
+ mode?: AnalysisMode;
353
+ policyHash?: unknown;
354
+ resolverIdentity?: unknown;
355
+ factsHash?: unknown;
356
+ candidateTreeHash?: unknown;
357
+ completenessReasons?: readonly AdapterCompletenessReason[];
287
358
  violations?: readonly AdapterViolationInput[];
288
359
  warnings?: readonly AdapterViolationInput[];
289
- }): AdapterResult;
360
+ }): CurrentAdapterResult;
290
361
  declare const ARK_ANALYSIS_RESULT_SCHEMA: {
291
362
  readonly $schema: "https://json-schema.org/draft/2020-12/schema";
292
- readonly $id: "https://unpkg.com/arkgate@2/schemas/ark.analysis-result.schema.json";
363
+ readonly $id: "https://unpkg.com/arkgate@3/schemas/ark.analysis-result.schema.json";
293
364
  readonly title: "ArkGate analysis result";
294
365
  readonly type: "object";
295
366
  readonly additionalProperties: false;
296
- readonly required: readonly ["schemaVersion", "valid", "diagnostics"];
367
+ readonly required: readonly ["schemaVersion", "mode", "valid", "completeness", "completenessReasons", "diagnostics"];
368
+ readonly allOf: readonly [{
369
+ readonly if: {
370
+ readonly properties: {
371
+ readonly completeness: {
372
+ readonly enum: readonly ["partial", "unavailable"];
373
+ };
374
+ };
375
+ readonly required: readonly ["completeness"];
376
+ };
377
+ readonly then: {
378
+ readonly properties: {
379
+ readonly valid: {
380
+ readonly const: false;
381
+ };
382
+ };
383
+ };
384
+ }, {
385
+ readonly if: {
386
+ readonly properties: {
387
+ readonly mode: {
388
+ readonly const: "resolved-candidate-facts";
389
+ };
390
+ readonly completeness: {
391
+ readonly enum: readonly ["complete", "partial"];
392
+ };
393
+ };
394
+ readonly required: readonly ["mode", "completeness"];
395
+ };
396
+ readonly then: {
397
+ readonly required: readonly ["policyHash", "resolverIdentity", "factsHash", "candidateTreeHash"];
398
+ };
399
+ }, {
400
+ readonly if: {
401
+ readonly properties: {
402
+ readonly completeness: {
403
+ readonly const: "complete";
404
+ };
405
+ };
406
+ readonly required: readonly ["completeness"];
407
+ };
408
+ readonly then: {
409
+ readonly properties: {
410
+ readonly completenessReasons: {
411
+ readonly maxItems: 0;
412
+ };
413
+ };
414
+ };
415
+ readonly else: {
416
+ readonly properties: {
417
+ readonly completenessReasons: {
418
+ readonly minItems: 1;
419
+ };
420
+ };
421
+ };
422
+ }];
297
423
  readonly properties: {
298
424
  readonly schemaVersion: {
299
- readonly const: "1.1";
425
+ readonly const: "1.3";
426
+ };
427
+ readonly mode: {
428
+ readonly enum: readonly ["lexical-compatibility", "resolved-candidate-facts"];
300
429
  };
301
430
  readonly valid: {
302
431
  readonly type: "boolean";
303
432
  };
433
+ readonly completeness: {
434
+ readonly enum: readonly ["complete", "partial", "unavailable"];
435
+ };
436
+ readonly completenessReasons: {
437
+ readonly type: "array";
438
+ readonly items: {
439
+ readonly type: "object";
440
+ readonly additionalProperties: false;
441
+ readonly required: readonly ["code", "message"];
442
+ readonly properties: {
443
+ readonly code: {
444
+ readonly type: "string";
445
+ readonly minLength: 1;
446
+ };
447
+ readonly message: {
448
+ readonly type: "string";
449
+ readonly minLength: 1;
450
+ };
451
+ readonly file: {
452
+ readonly type: "string";
453
+ readonly minLength: 1;
454
+ };
455
+ };
456
+ };
457
+ };
458
+ readonly policyHash: {
459
+ readonly type: "string";
460
+ readonly minLength: 1;
461
+ };
462
+ readonly resolverIdentity: {
463
+ readonly type: "string";
464
+ readonly minLength: 1;
465
+ };
466
+ readonly factsHash: {
467
+ readonly type: "string";
468
+ readonly minLength: 1;
469
+ };
470
+ readonly candidateTreeHash: {
471
+ readonly type: "string";
472
+ readonly minLength: 1;
473
+ };
304
474
  readonly diagnostics: {
305
475
  readonly type: "array";
306
476
  readonly items: {
@@ -354,6 +524,29 @@ declare const ARK_ANALYSIS_RESULT_SCHEMA: {
354
524
  readonly typeOnly: {
355
525
  readonly type: "boolean";
356
526
  };
527
+ readonly targetTypeOnlyExports: {
528
+ readonly type: "boolean";
529
+ };
530
+ readonly sourcePureTypeModule: {
531
+ readonly type: "boolean";
532
+ };
533
+ readonly namedBindingsTypeOnly: {
534
+ readonly type: "boolean";
535
+ };
536
+ readonly portProofEligible: {
537
+ readonly type: "boolean";
538
+ };
539
+ readonly peerIsolation: {
540
+ readonly type: "boolean";
541
+ };
542
+ readonly capability: {
543
+ readonly type: "string";
544
+ readonly minLength: 1;
545
+ };
546
+ readonly edgeKind: {
547
+ readonly type: "string";
548
+ readonly minLength: 1;
549
+ };
357
550
  };
358
551
  };
359
552
  readonly nextAction: {
@@ -398,7 +591,15 @@ interface AICodeGateContext {
398
591
  [key: string]: unknown;
399
592
  }
400
593
  interface AICodeGateResult {
594
+ /** Single-source snippets do not carry project-wide resolver evidence. */
595
+ mode: 'lexical-compatibility';
596
+ /** A snippet result is intentionally never an authoritative complete verdict. */
597
+ completeness: 'partial';
598
+ completenessReasons: string[];
599
+ /** Authoritative verdict. Always false until the complete candidate is resolved. */
401
600
  valid: boolean;
601
+ /** Compatibility signal for the bounded lexical checks performed here. */
602
+ lexicalValid: boolean;
402
603
  violations: AICodeGateViolation[];
403
604
  }
404
605
  interface AICodeGate<Context = AICodeGateContext> {
@@ -662,92 +863,111 @@ interface AICodeGateOptions<Context = AICodeGateContext> {
662
863
  }
663
864
  declare function createAICodeGate<Context = AICodeGateContext>(options?: AICodeGateOptions<Context>): AICodeGate<Context>;
664
865
 
665
- declare const ARK_CHANGE_MAP_SCHEMA_VERSION: "1.0";
666
- type ArchitectureChangeOperation = 'create' | 'update' | 'delete';
667
- type ArchitectureChangeMapFile = {
668
- path: string;
669
- operation: ArchitectureChangeOperation;
670
- layer: string;
671
- };
672
- type ArchitectureChangeMapDependency = {
673
- from: string;
674
- to: string;
675
- };
676
- type ArchitectureChangeMap = {
677
- $schema: string;
678
- schemaVersion: typeof ARK_CHANGE_MAP_SCHEMA_VERSION;
679
- files: ArchitectureChangeMapFile[];
680
- dependencies: ArchitectureChangeMapDependency[];
681
- };
682
- type ArchitectureChangeMapContract = {
683
- map: ArchitectureChangeMap;
684
- hash: string;
685
- };
866
+ /**
867
+ * Stable, pure vocabulary for ArkGate's importable analysis engine.
868
+ *
869
+ * Parsing and filesystem discovery belong to adapters. This module intentionally
870
+ * contains only the versioned data contract and deterministic hash primitives.
871
+ */
686
872
 
687
- type ArchitectureDependency = {
688
- from: string;
689
- to: string;
873
+ declare const ANALYSIS_IR_SCHEMA_VERSION: "1.0";
874
+ declare const RESOLVED_CANDIDATE_FACTS_SCHEMA_VERSION: "1.0";
875
+ type ResolvedFactsCompleteness = 'complete' | 'partial' | 'unavailable';
876
+ type ResolvedDependencyKind = 'import' | 'export' | 'dynamic-import' | 'require';
877
+ type ResolvedDependencyState = 'resolved-project' | 'resolved-external' | 'unresolved' | 'dynamic';
878
+ type ResolvedCapability = 'network' | 'filesystem' | 'clock' | 'randomness' | 'environment' | 'process' | 'persistence';
879
+ type ResolvedFactsReason = {
880
+ code: string;
881
+ message: string;
882
+ file?: string;
690
883
  };
691
- type ArchitectureActualChange = {
884
+ type ResolvedFileFact = {
692
885
  path: string;
693
- operation: ArchitectureChangeOperation;
886
+ contentHash: string;
887
+ parseStatus: 'parsed' | 'invalid';
888
+ parseDiagnosticCount: number;
889
+ exportsOnlyTypes: boolean;
890
+ typeOnlyExportNames: string[];
891
+ hasTopLevelSideEffects: boolean;
694
892
  };
695
- type ArchitectureConvergenceClassification = 'satisfied' | 'missing' | 'contradictory' | 'unplanned';
696
- type ArchitectureConvergenceFinding = {
697
- id: string;
698
- classification: ArchitectureConvergenceClassification;
699
- subject: 'file' | 'dependency';
700
- message: string;
701
- nextAction?: string;
702
- path?: string;
703
- from?: string;
704
- to?: string;
705
- expectedOperation?: ArchitectureChangeOperation;
706
- actualOperation?: ArchitectureChangeOperation | 'added' | 'removed';
893
+ type ResolvedDependencyFact = {
894
+ from: string;
895
+ specifier?: string;
896
+ kind: ResolvedDependencyKind;
897
+ typeOnly: boolean;
898
+ line: number;
899
+ resolution: ResolvedDependencyState;
900
+ target?: string;
901
+ namedBindings?: string[];
902
+ targetTypeOnlyExports?: boolean;
903
+ sourcePureTypeModule?: boolean;
904
+ namedBindingsTypeOnly?: boolean;
905
+ portProofEligible?: boolean;
707
906
  };
708
- type ArchitectureConvergenceResult = {
709
- schemaVersion: '1.0';
710
- readOnly: true;
711
- changeMapHash: string;
712
- structurallyConverged: boolean;
713
- behavioralCompletion: 'not-evaluated';
714
- summary: Record<ArchitectureConvergenceClassification, number>;
715
- findings: ArchitectureConvergenceFinding[];
907
+ type ResolvedCapabilityFact = {
908
+ file: string;
909
+ line: number;
910
+ symbol: string;
911
+ capability: ResolvedCapability;
912
+ source: 'ambient-global' | 'import-based';
716
913
  };
717
- type AnalyzeArchitectureConvergenceInput = {
718
- changeMap: ArchitectureChangeMapContract;
719
- changes: readonly ArchitectureActualChange[];
720
- baseDependencies: readonly ArchitectureDependency[];
721
- candidateDependencies: readonly ArchitectureDependency[];
914
+ type ResolvedAmbientFact = {
915
+ file: string;
916
+ line: number;
917
+ symbol: string;
722
918
  };
723
- declare function analyzeArchitectureConvergence(input: AnalyzeArchitectureConvergenceInput): ArchitectureConvergenceResult;
724
-
725
- type SemanticDependencyKind = 'import' | 'export' | 'dynamic-import' | 'require';
726
- type SemanticDependency = {
727
- specifier?: string;
728
- kind: SemanticDependencyKind;
919
+ type ResolvedPublishFact = {
920
+ file: string;
729
921
  line: number;
730
- typeOnly: boolean;
731
- unresolved: boolean;
732
- node: unknown;
922
+ rawIntentName?: string;
923
+ objectHasIntent: boolean;
924
+ arkPublishCandidate: boolean;
925
+ hasSource: boolean;
926
+ sourceIntent?: string;
733
927
  };
734
- type ForbiddenCapabilityUse = {
735
- name: string;
928
+ type ResolvedIntentReferenceFact = {
929
+ file: string;
736
930
  line: number;
737
- node: unknown;
931
+ intent: string;
932
+ };
933
+ type ResolvedSafetyKind = 'ts-suppression' | 'any-cast' | 'dynamic-import' | 'dynamic-require' | 'in-memory-store';
934
+ /** Neutral syntax evidence for policy-controlled safety diagnostics. */
935
+ type ResolvedSafetyFact = {
936
+ file: string;
937
+ line: number;
938
+ kind: ResolvedSafetyKind;
939
+ symbol?: string;
940
+ };
941
+ type ResolvedCandidateFactsInput = {
942
+ schemaVersion: typeof RESOLVED_CANDIDATE_FACTS_SCHEMA_VERSION;
943
+ completeness: ResolvedFactsCompleteness;
944
+ completenessReasons: readonly ResolvedFactsReason[];
945
+ resolverIdentity: string;
946
+ compilerIdentity: string;
947
+ compilerOptionsHash: string;
948
+ tsconfigHash: string;
949
+ evidenceRequirementsHash: string;
950
+ projectPackageName?: string;
951
+ files: readonly ResolvedFileFact[];
952
+ dependencies: readonly ResolvedDependencyFact[];
953
+ capabilityUses: readonly ResolvedCapabilityFact[];
954
+ ambientUses: readonly ResolvedAmbientFact[];
955
+ publishCalls: readonly ResolvedPublishFact[];
956
+ intentReferences: readonly ResolvedIntentReferenceFact[];
957
+ safetyUses: readonly ResolvedSafetyFact[];
958
+ };
959
+ type ResolvedCandidateFacts = Omit<ResolvedCandidateFactsInput, 'candidateTreeHash'> & {
960
+ completenessReasons: ResolvedFactsReason[];
961
+ candidateTreeHash: string;
962
+ files: ResolvedFileFact[];
963
+ dependencies: ResolvedDependencyFact[];
964
+ capabilityUses: ResolvedCapabilityFact[];
965
+ ambientUses: ResolvedAmbientFact[];
966
+ publishCalls: ResolvedPublishFact[];
967
+ intentReferences: ResolvedIntentReferenceFact[];
968
+ safetyUses: ResolvedSafetyFact[];
969
+ factsHash: string;
738
970
  };
739
- /** Extract every dependency form whose specifier is statically knowable, plus unresolved calls. */
740
- declare function extractSemanticDependencies(ts: any, sourceFile: any): SemanticDependency[];
741
- /** Resolve forbidden ambient capabilities through symbols, aliases, globalThis, and static keys. */
742
- declare function collectForbiddenCapabilityUses(ts: any, sourceFile: any, forbidden: readonly string[]): ForbiddenCapabilityUse[];
743
-
744
- /**
745
- * Stable, pure vocabulary for ArkGate's importable analysis engine.
746
- *
747
- * Parsing and filesystem discovery belong to adapters. This module intentionally
748
- * contains only the versioned data contract and deterministic hash primitives.
749
- */
750
- declare const ANALYSIS_IR_SCHEMA_VERSION: "1.0";
751
971
  type AnalysisFileInput = {
752
972
  path: string;
753
973
  content: string;
@@ -814,62 +1034,664 @@ type AnalysisIr = {
814
1034
  declare function deterministicHash(value: string): string;
815
1035
  /** Serialize JSON-like values with sorted object keys for reproducible hashes. */
816
1036
  declare function stableSerialize(value: unknown): string;
817
-
818
- declare const POLICY_DELTA_SCHEMA_VERSION: "1.0";
819
- type PolicyDeltaClassification = 'strengthening' | 'neutral' | 'judgment-required' | 'weakening';
820
- type PolicyDeltaFinding = {
821
- id: string;
822
- path: string;
823
- classification: Exclude<PolicyDeltaClassification, 'neutral'>;
824
- message: string;
825
- nextAction?: string;
826
- before?: unknown;
827
- after?: unknown;
828
- };
829
- type PolicyDelta = {
830
- schemaVersion: typeof POLICY_DELTA_SCHEMA_VERSION;
831
- classification: PolicyDeltaClassification;
832
- findings: PolicyDeltaFinding[];
833
- };
834
- type PolicyDeltaAcknowledgement = {
835
- schemaVersion: typeof POLICY_DELTA_SCHEMA_VERSION;
836
- basePolicyHash: string;
837
- candidatePolicyHash: string;
838
- findingIds: readonly string[];
839
- reason: string;
840
- };
841
- declare function classifyArkPolicyDelta(base: ArkConfig, candidate: ArkConfig): PolicyDelta;
842
- declare function policyDeltaAcknowledgementMatches(acknowledgement: PolicyDeltaAcknowledgement | undefined, expected: {
843
- basePolicyHash: string;
844
- candidatePolicyHash: string;
845
- findingIds: readonly string[];
846
- }): boolean;
847
-
848
- /**
849
- * Public type vocabulary of the canonical analysis API (U02 pilot 2).
850
- *
851
- * Declarations only — the C02 entry point src/kernel/analysis.ts re-exports
852
- * everything here, so consumer import paths never change.
853
- */
854
-
855
- type AnalysisContract = ArkConfigLoadResult & {
856
- policyHash: string;
857
- };
858
- type AnalyzeProjectInput = {
859
- contract: AnalysisContract;
860
- files: readonly AnalysisFileInput[];
861
- compilerOptions?: AnalysisCompilerOptions;
862
- };
863
- type AnalyzeChangeInput = AnalyzeProjectInput & {
864
- changes: readonly AnalysisFileChange[];
865
- changeMap?: ArchitectureChangeMapContract;
866
- };
867
- type AnalysisResult = {
868
- ir: AnalysisIr;
869
- };
870
- type AnalyzePolicyDeltaInput = {
871
- baseConfig: unknown;
872
- candidateConfig: unknown;
1037
+ /** Identity of the policy-controlled evidence a resolver must attempt to collect. */
1038
+ declare function resolvedFactsEvidenceRequirementsHash(config: ArkConfig): string;
1039
+ declare function createResolvedCandidateFacts(input: ResolvedCandidateFactsInput): ResolvedCandidateFacts;
1040
+ declare function loadResolvedCandidateFacts(input: unknown): ResolvedCandidateFacts;
1041
+ declare const RESOLVED_CANDIDATE_FACTS_SCHEMA: {
1042
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
1043
+ readonly $id: "https://unpkg.com/arkgate@3/schemas/ark.resolved-candidate-facts.schema.json";
1044
+ readonly title: "ArkGate resolved candidate facts";
1045
+ readonly type: "object";
1046
+ readonly additionalProperties: false;
1047
+ readonly required: readonly ["schemaVersion", "completeness", "completenessReasons", "resolverIdentity", "compilerIdentity", "compilerOptionsHash", "tsconfigHash", "candidateTreeHash", "evidenceRequirementsHash", "files", "dependencies", "capabilityUses", "ambientUses", "publishCalls", "intentReferences", "safetyUses", "factsHash"];
1048
+ readonly properties: {
1049
+ readonly schemaVersion: {
1050
+ readonly const: "1.0";
1051
+ };
1052
+ readonly completeness: {
1053
+ readonly enum: readonly ["complete", "partial", "unavailable"];
1054
+ };
1055
+ readonly completenessReasons: {
1056
+ readonly type: "array";
1057
+ readonly items: {
1058
+ readonly type: "object";
1059
+ readonly additionalProperties: false;
1060
+ readonly required: readonly ["code", "message"];
1061
+ readonly properties: {
1062
+ readonly code: {
1063
+ readonly type: "string";
1064
+ readonly minLength: 1;
1065
+ };
1066
+ readonly message: {
1067
+ readonly type: "string";
1068
+ readonly minLength: 1;
1069
+ };
1070
+ readonly file: {
1071
+ readonly type: "string";
1072
+ readonly minLength: 1;
1073
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1074
+ };
1075
+ };
1076
+ };
1077
+ };
1078
+ readonly resolverIdentity: {
1079
+ readonly type: "string";
1080
+ readonly minLength: 1;
1081
+ };
1082
+ readonly compilerIdentity: {
1083
+ readonly type: "string";
1084
+ readonly minLength: 1;
1085
+ };
1086
+ readonly compilerOptionsHash: {
1087
+ readonly type: "string";
1088
+ readonly minLength: 1;
1089
+ };
1090
+ readonly tsconfigHash: {
1091
+ readonly type: "string";
1092
+ readonly minLength: 1;
1093
+ };
1094
+ readonly candidateTreeHash: {
1095
+ readonly type: "string";
1096
+ readonly minLength: 1;
1097
+ };
1098
+ readonly evidenceRequirementsHash: {
1099
+ readonly type: "string";
1100
+ readonly minLength: 1;
1101
+ };
1102
+ readonly projectPackageName: {
1103
+ readonly type: "string";
1104
+ readonly minLength: 1;
1105
+ };
1106
+ readonly files: {
1107
+ readonly type: "array";
1108
+ readonly uniqueItems: true;
1109
+ readonly items: {
1110
+ readonly type: "object";
1111
+ readonly additionalProperties: false;
1112
+ readonly required: readonly ["path", "contentHash", "parseStatus", "parseDiagnosticCount", "exportsOnlyTypes", "typeOnlyExportNames", "hasTopLevelSideEffects"];
1113
+ readonly properties: {
1114
+ readonly path: {
1115
+ readonly type: "string";
1116
+ readonly minLength: 1;
1117
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1118
+ };
1119
+ readonly contentHash: {
1120
+ readonly type: "string";
1121
+ readonly minLength: 1;
1122
+ };
1123
+ readonly parseStatus: {
1124
+ readonly enum: readonly ["parsed", "invalid"];
1125
+ };
1126
+ readonly parseDiagnosticCount: {
1127
+ readonly type: "integer";
1128
+ readonly minimum: 0;
1129
+ };
1130
+ readonly exportsOnlyTypes: {
1131
+ readonly type: "boolean";
1132
+ };
1133
+ readonly typeOnlyExportNames: {
1134
+ readonly type: "array";
1135
+ readonly items: {
1136
+ readonly type: "string";
1137
+ readonly minLength: 1;
1138
+ };
1139
+ };
1140
+ readonly hasTopLevelSideEffects: {
1141
+ readonly type: "boolean";
1142
+ };
1143
+ };
1144
+ readonly allOf: readonly [{
1145
+ readonly if: {
1146
+ readonly properties: {
1147
+ readonly parseStatus: {
1148
+ readonly const: "parsed";
1149
+ };
1150
+ };
1151
+ };
1152
+ readonly then: {
1153
+ readonly properties: {
1154
+ readonly parseDiagnosticCount: {
1155
+ readonly const: 0;
1156
+ };
1157
+ };
1158
+ };
1159
+ }, {
1160
+ readonly if: {
1161
+ readonly properties: {
1162
+ readonly parseStatus: {
1163
+ readonly const: "invalid";
1164
+ };
1165
+ };
1166
+ };
1167
+ readonly then: {
1168
+ readonly properties: {
1169
+ readonly parseDiagnosticCount: {
1170
+ readonly minimum: 1;
1171
+ };
1172
+ };
1173
+ };
1174
+ }];
1175
+ };
1176
+ };
1177
+ readonly dependencies: {
1178
+ readonly type: "array";
1179
+ readonly items: {
1180
+ readonly type: "object";
1181
+ readonly additionalProperties: false;
1182
+ readonly required: readonly ["from", "kind", "typeOnly", "line", "resolution"];
1183
+ readonly properties: {
1184
+ readonly from: {
1185
+ readonly type: "string";
1186
+ readonly minLength: 1;
1187
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1188
+ };
1189
+ readonly specifier: {
1190
+ readonly type: "string";
1191
+ readonly minLength: 1;
1192
+ };
1193
+ readonly kind: {
1194
+ readonly enum: readonly ["import", "export", "dynamic-import", "require"];
1195
+ };
1196
+ readonly typeOnly: {
1197
+ readonly type: "boolean";
1198
+ };
1199
+ readonly line: {
1200
+ readonly type: "integer";
1201
+ readonly minimum: 1;
1202
+ };
1203
+ readonly resolution: {
1204
+ readonly enum: readonly ["resolved-project", "resolved-external", "unresolved", "dynamic"];
1205
+ };
1206
+ readonly target: {
1207
+ readonly type: "string";
1208
+ readonly minLength: 1;
1209
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1210
+ };
1211
+ readonly namedBindings: {
1212
+ readonly type: "array";
1213
+ readonly items: {
1214
+ readonly type: "string";
1215
+ readonly minLength: 1;
1216
+ };
1217
+ };
1218
+ readonly targetTypeOnlyExports: {
1219
+ readonly type: "boolean";
1220
+ };
1221
+ readonly sourcePureTypeModule: {
1222
+ readonly type: "boolean";
1223
+ };
1224
+ readonly namedBindingsTypeOnly: {
1225
+ readonly type: "boolean";
1226
+ };
1227
+ readonly portProofEligible: {
1228
+ readonly type: "boolean";
1229
+ };
1230
+ };
1231
+ readonly allOf: readonly [{
1232
+ readonly if: {
1233
+ readonly properties: {
1234
+ readonly resolution: {
1235
+ readonly const: "resolved-project";
1236
+ };
1237
+ };
1238
+ };
1239
+ readonly then: {
1240
+ readonly required: readonly ["target"];
1241
+ };
1242
+ readonly else: {
1243
+ readonly not: {
1244
+ readonly required: readonly ["target"];
1245
+ };
1246
+ };
1247
+ }, {
1248
+ readonly if: {
1249
+ readonly properties: {
1250
+ readonly resolution: {
1251
+ readonly const: "dynamic";
1252
+ };
1253
+ };
1254
+ };
1255
+ readonly else: {
1256
+ readonly required: readonly ["specifier"];
1257
+ };
1258
+ }];
1259
+ };
1260
+ };
1261
+ readonly capabilityUses: {
1262
+ readonly type: "array";
1263
+ readonly items: {
1264
+ readonly type: "object";
1265
+ readonly additionalProperties: false;
1266
+ readonly required: readonly ["file", "line", "symbol", "capability", "source"];
1267
+ readonly properties: {
1268
+ readonly file: {
1269
+ readonly type: "string";
1270
+ readonly minLength: 1;
1271
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1272
+ };
1273
+ readonly line: {
1274
+ readonly type: "integer";
1275
+ readonly minimum: 1;
1276
+ };
1277
+ readonly symbol: {
1278
+ readonly type: "string";
1279
+ readonly minLength: 1;
1280
+ };
1281
+ readonly capability: {
1282
+ readonly enum: readonly ["network", "filesystem", "clock", "randomness", "environment", "process", "persistence"];
1283
+ };
1284
+ readonly source: {
1285
+ readonly enum: readonly ["ambient-global", "import-based"];
1286
+ };
1287
+ };
1288
+ };
1289
+ };
1290
+ readonly ambientUses: {
1291
+ readonly type: "array";
1292
+ readonly items: {
1293
+ readonly type: "object";
1294
+ readonly additionalProperties: false;
1295
+ readonly required: readonly ["file", "line", "symbol"];
1296
+ readonly properties: {
1297
+ readonly file: {
1298
+ readonly type: "string";
1299
+ readonly minLength: 1;
1300
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1301
+ };
1302
+ readonly line: {
1303
+ readonly type: "integer";
1304
+ readonly minimum: 1;
1305
+ };
1306
+ readonly symbol: {
1307
+ readonly type: "string";
1308
+ readonly minLength: 1;
1309
+ };
1310
+ };
1311
+ };
1312
+ };
1313
+ readonly publishCalls: {
1314
+ readonly type: "array";
1315
+ readonly items: {
1316
+ readonly type: "object";
1317
+ readonly additionalProperties: false;
1318
+ readonly required: readonly ["file", "line", "objectHasIntent", "arkPublishCandidate", "hasSource"];
1319
+ readonly properties: {
1320
+ readonly file: {
1321
+ readonly type: "string";
1322
+ readonly minLength: 1;
1323
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1324
+ };
1325
+ readonly line: {
1326
+ readonly type: "integer";
1327
+ readonly minimum: 1;
1328
+ };
1329
+ readonly rawIntentName: {
1330
+ readonly type: "string";
1331
+ readonly minLength: 1;
1332
+ };
1333
+ readonly objectHasIntent: {
1334
+ readonly type: "boolean";
1335
+ };
1336
+ readonly arkPublishCandidate: {
1337
+ readonly type: "boolean";
1338
+ };
1339
+ readonly hasSource: {
1340
+ readonly type: "boolean";
1341
+ };
1342
+ readonly sourceIntent: {
1343
+ readonly type: "string";
1344
+ readonly minLength: 1;
1345
+ };
1346
+ };
1347
+ };
1348
+ };
1349
+ readonly intentReferences: {
1350
+ readonly type: "array";
1351
+ readonly items: {
1352
+ readonly type: "object";
1353
+ readonly additionalProperties: false;
1354
+ readonly required: readonly ["file", "line", "intent"];
1355
+ readonly properties: {
1356
+ readonly file: {
1357
+ readonly type: "string";
1358
+ readonly minLength: 1;
1359
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1360
+ };
1361
+ readonly line: {
1362
+ readonly type: "integer";
1363
+ readonly minimum: 1;
1364
+ };
1365
+ readonly intent: {
1366
+ readonly type: "string";
1367
+ readonly minLength: 1;
1368
+ };
1369
+ };
1370
+ };
1371
+ };
1372
+ readonly safetyUses: {
1373
+ readonly type: "array";
1374
+ readonly items: {
1375
+ readonly type: "object";
1376
+ readonly additionalProperties: false;
1377
+ readonly required: readonly ["file", "line", "kind"];
1378
+ readonly properties: {
1379
+ readonly file: {
1380
+ readonly type: "string";
1381
+ readonly minLength: 1;
1382
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1383
+ };
1384
+ readonly line: {
1385
+ readonly type: "integer";
1386
+ readonly minimum: 1;
1387
+ };
1388
+ readonly kind: {
1389
+ readonly enum: readonly ["ts-suppression", "any-cast", "dynamic-import", "dynamic-require", "in-memory-store"];
1390
+ };
1391
+ readonly symbol: {
1392
+ readonly type: "string";
1393
+ readonly minLength: 1;
1394
+ };
1395
+ };
1396
+ readonly allOf: readonly [{
1397
+ readonly if: {
1398
+ readonly properties: {
1399
+ readonly kind: {
1400
+ readonly const: "in-memory-store";
1401
+ };
1402
+ };
1403
+ };
1404
+ readonly then: {
1405
+ readonly required: readonly ["symbol"];
1406
+ };
1407
+ readonly else: {
1408
+ readonly not: {
1409
+ readonly required: readonly ["symbol"];
1410
+ };
1411
+ };
1412
+ }];
1413
+ };
1414
+ };
1415
+ readonly factsHash: {
1416
+ readonly type: "string";
1417
+ readonly minLength: 1;
1418
+ };
1419
+ };
1420
+ readonly allOf: readonly [{
1421
+ readonly if: {
1422
+ readonly properties: {
1423
+ readonly completeness: {
1424
+ readonly const: "complete";
1425
+ };
1426
+ };
1427
+ };
1428
+ readonly then: {
1429
+ readonly properties: {
1430
+ readonly completenessReasons: {
1431
+ readonly maxItems: 0;
1432
+ };
1433
+ readonly files: {
1434
+ readonly items: {
1435
+ readonly properties: {
1436
+ readonly parseStatus: {
1437
+ readonly const: "parsed";
1438
+ };
1439
+ };
1440
+ };
1441
+ };
1442
+ };
1443
+ };
1444
+ }, {
1445
+ readonly if: {
1446
+ readonly properties: {
1447
+ readonly completeness: {
1448
+ readonly enum: readonly ["partial", "unavailable"];
1449
+ };
1450
+ };
1451
+ };
1452
+ readonly then: {
1453
+ readonly properties: {
1454
+ readonly completenessReasons: {
1455
+ readonly minItems: 1;
1456
+ };
1457
+ };
1458
+ };
1459
+ }];
1460
+ };
1461
+
1462
+ declare const ARK_CHANGE_MAP_SCHEMA_VERSION: "1.0";
1463
+ type ArchitectureChangeOperation = 'create' | 'update' | 'delete';
1464
+ type ArchitectureChangeMapFile = {
1465
+ path: string;
1466
+ operation: ArchitectureChangeOperation;
1467
+ layer: string;
1468
+ };
1469
+ type ArchitectureChangeMapDependency = {
1470
+ from: string;
1471
+ to: string;
1472
+ };
1473
+ type ArchitectureChangeMap = {
1474
+ $schema: string;
1475
+ schemaVersion: typeof ARK_CHANGE_MAP_SCHEMA_VERSION;
1476
+ files: ArchitectureChangeMapFile[];
1477
+ dependencies: ArchitectureChangeMapDependency[];
1478
+ };
1479
+ type ArchitectureChangeMapContract = {
1480
+ map: ArchitectureChangeMap;
1481
+ hash: string;
1482
+ };
1483
+
1484
+ type ArchitectureDependency = {
1485
+ from: string;
1486
+ to: string;
1487
+ };
1488
+ type ArchitectureActualChange = {
1489
+ path: string;
1490
+ operation: ArchitectureChangeOperation;
1491
+ };
1492
+ type ArchitectureConvergenceClassification = 'satisfied' | 'missing' | 'contradictory' | 'unplanned';
1493
+ type ArchitectureConvergenceFinding = {
1494
+ id: string;
1495
+ classification: ArchitectureConvergenceClassification;
1496
+ subject: 'file' | 'dependency';
1497
+ message: string;
1498
+ nextAction?: string;
1499
+ path?: string;
1500
+ from?: string;
1501
+ to?: string;
1502
+ expectedOperation?: ArchitectureChangeOperation;
1503
+ actualOperation?: ArchitectureChangeOperation | 'added' | 'removed';
1504
+ };
1505
+ type ArchitectureConvergenceResult = {
1506
+ schemaVersion: '1.0';
1507
+ readOnly: true;
1508
+ changeMapHash: string;
1509
+ structurallyConverged: boolean;
1510
+ behavioralCompletion: 'not-evaluated';
1511
+ summary: Record<ArchitectureConvergenceClassification, number>;
1512
+ findings: ArchitectureConvergenceFinding[];
1513
+ };
1514
+ type AnalyzeArchitectureConvergenceInput = {
1515
+ changeMap: ArchitectureChangeMapContract;
1516
+ changes: readonly ArchitectureActualChange[];
1517
+ baseDependencies: readonly ArchitectureDependency[];
1518
+ candidateDependencies: readonly ArchitectureDependency[];
1519
+ };
1520
+ declare function analyzeArchitectureConvergence(input: AnalyzeArchitectureConvergenceInput): ArchitectureConvergenceResult;
1521
+
1522
+ type SemanticDependencyKind = 'import' | 'export' | 'dynamic-import' | 'require';
1523
+ type SemanticDependency = {
1524
+ specifier?: string;
1525
+ kind: SemanticDependencyKind;
1526
+ line: number;
1527
+ typeOnly: boolean;
1528
+ unresolved: boolean;
1529
+ node: unknown;
1530
+ };
1531
+ type ForbiddenCapabilityUse = {
1532
+ name: string;
1533
+ line: number;
1534
+ node: unknown;
1535
+ };
1536
+ /** Extract every dependency form whose specifier is statically knowable, plus unresolved calls. */
1537
+ declare function extractSemanticDependencies(ts: any, sourceFile: any): SemanticDependency[];
1538
+ /** Resolve forbidden ambient capabilities through symbols, aliases, globalThis, and static keys. */
1539
+ declare function collectForbiddenCapabilityUses(ts: any, sourceFile: any, forbidden: readonly string[]): ForbiddenCapabilityUse[];
1540
+
1541
+ declare const POLICY_DELTA_SCHEMA_VERSION: "1.0";
1542
+ type PolicyDeltaClassification = 'strengthening' | 'neutral' | 'judgment-required' | 'weakening';
1543
+ type PolicyDeltaFinding = {
1544
+ id: string;
1545
+ path: string;
1546
+ classification: Exclude<PolicyDeltaClassification, 'neutral'>;
1547
+ message: string;
1548
+ nextAction?: string;
1549
+ before?: unknown;
1550
+ after?: unknown;
1551
+ };
1552
+ type PolicyDelta = {
1553
+ schemaVersion: typeof POLICY_DELTA_SCHEMA_VERSION;
1554
+ classification: PolicyDeltaClassification;
1555
+ findings: PolicyDeltaFinding[];
1556
+ };
1557
+ type PolicyDeltaAcknowledgement = {
1558
+ schemaVersion: typeof POLICY_DELTA_SCHEMA_VERSION;
1559
+ basePolicyHash: string;
1560
+ candidatePolicyHash: string;
1561
+ findingIds: readonly string[];
1562
+ reason: string;
1563
+ };
1564
+ declare function classifyArkPolicyDelta(base: ArkConfig, candidate: ArkConfig): PolicyDelta;
1565
+ declare function policyDeltaAcknowledgementMatches(acknowledgement: PolicyDeltaAcknowledgement | undefined, expected: {
1566
+ basePolicyHash: string;
1567
+ candidatePolicyHash: string;
1568
+ findingIds: readonly string[];
1569
+ }): boolean;
1570
+
1571
+ /**
1572
+ * Public type vocabulary of the canonical analysis API (U02 pilot 2).
1573
+ *
1574
+ * Declarations only — the C02 entry point src/kernel/analysis.ts re-exports
1575
+ * everything here, so consumer import paths never change.
1576
+ */
1577
+
1578
+ type AnalysisContract = ArkConfigLoadResult & {
1579
+ policyHash: string;
1580
+ };
1581
+ type AnalyzeProjectInput = {
1582
+ contract: AnalysisContract;
1583
+ files: readonly AnalysisFileInput[];
1584
+ compilerOptions?: AnalysisCompilerOptions;
1585
+ };
1586
+ type AnalyzeChangeInput = AnalyzeProjectInput & {
1587
+ changes: readonly AnalysisFileChange[];
1588
+ changeMap?: ArchitectureChangeMapContract;
1589
+ };
1590
+ type AnalysisResult = {
1591
+ mode: 'lexical-compatibility';
1592
+ completeness: ResolvedFactsCompleteness;
1593
+ completenessReasons: ResolvedFactsReason[];
1594
+ valid: boolean;
1595
+ ir: AnalysisIr;
1596
+ };
1597
+ type AnalyzeResolvedProjectInput = {
1598
+ contract: AnalysisContract;
1599
+ facts: unknown;
1600
+ };
1601
+ type PreflightResolvedChangeInput = {
1602
+ contract: AnalysisContract;
1603
+ baseFacts: unknown;
1604
+ candidateFacts: unknown;
1605
+ changes: readonly AnalysisFileChange[];
1606
+ changeMap?: ArchitectureChangeMapContract;
1607
+ };
1608
+ type ResolvedAnalysisFile = ResolvedFileFact & {
1609
+ layer: string | null;
1610
+ };
1611
+ type ResolvedAnalysisIr = {
1612
+ schemaVersion: '1.0';
1613
+ policyHash: string;
1614
+ compilerOptionsHash: string;
1615
+ files: ResolvedAnalysisFile[];
1616
+ layers: string[];
1617
+ edges: ArchitectureEngineEdge[];
1618
+ capabilityUses: ResolvedCapabilityFact[];
1619
+ violations: ArchitectureEngineViolation[];
1620
+ warnings: ArchitectureEngineViolation[];
1621
+ };
1622
+ type ResolvedSafetyReport = {
1623
+ tsSuppressions: {
1624
+ file: string;
1625
+ line: number;
1626
+ }[];
1627
+ anyCasts: {
1628
+ file: string;
1629
+ line: number;
1630
+ }[];
1631
+ nonLiteralDynamicImports: {
1632
+ file: string;
1633
+ line: number;
1634
+ kind: 'import' | 'require';
1635
+ }[];
1636
+ inMemoryProductionStores: {
1637
+ file: string;
1638
+ line: number;
1639
+ store: string;
1640
+ }[];
1641
+ disabledPeerIsolationRules: {
1642
+ from: string;
1643
+ to: string;
1644
+ }[];
1645
+ thresholds: {
1646
+ maxTsSuppressions: number;
1647
+ maxAnyCasts: number;
1648
+ };
1649
+ };
1650
+ type ResolvedAnalysisResult = {
1651
+ mode: 'resolved-candidate-facts';
1652
+ completeness: ResolvedFactsCompleteness;
1653
+ completenessReasons: ResolvedFactsReason[];
1654
+ valid: boolean;
1655
+ strictValid: boolean;
1656
+ policyHash: string;
1657
+ factsHash: ResolvedCandidateFacts['factsHash'];
1658
+ resolverIdentity: ResolvedCandidateFacts['resolverIdentity'];
1659
+ candidateTreeHash: ResolvedCandidateFacts['candidateTreeHash'];
1660
+ safety: ResolvedSafetyReport;
1661
+ ir: ResolvedAnalysisIr;
1662
+ };
1663
+ type ResolvedChangePreflightResult = {
1664
+ schemaVersion: '1.0';
1665
+ mode: 'resolved-candidate-facts';
1666
+ valid: boolean;
1667
+ readOnly: true;
1668
+ policyHash: string;
1669
+ resolverIdentity: string;
1670
+ compilerIdentity: string;
1671
+ compilerOptionsHash: string;
1672
+ tsconfigHash: string;
1673
+ baseCompilerOptionsHash: string;
1674
+ candidateCompilerOptionsHash: string;
1675
+ baseTsconfigHash: string;
1676
+ candidateTsconfigHash: string;
1677
+ evidenceRequirementsHash: string;
1678
+ baseFactsHash: string;
1679
+ candidateFactsHash: string;
1680
+ baseTreeHash: string;
1681
+ candidateTreeHash: string;
1682
+ baseCompleteness: ResolvedFactsCompleteness;
1683
+ candidateCompleteness: ResolvedFactsCompleteness;
1684
+ baseCompletenessReasons: ResolvedFactsReason[];
1685
+ candidateCompletenessReasons: ResolvedFactsReason[];
1686
+ changeMapHash?: string;
1687
+ convergence?: ArchitectureConvergenceResult;
1688
+ changes: PreparedChangeFile[];
1689
+ violations: ArchitectureEngineViolation[];
1690
+ warnings: ArchitectureEngineViolation[];
1691
+ };
1692
+ type AnalyzePolicyDeltaInput = {
1693
+ baseConfig: unknown;
1694
+ candidateConfig: unknown;
873
1695
  acknowledgement?: PolicyDeltaAcknowledgement;
874
1696
  baseSource?: string;
875
1697
  candidateSource?: string;
@@ -898,7 +1720,7 @@ type ArchitectureEngineViolation = {
898
1720
  };
899
1721
  type ArchitectureEngineEdge = {
900
1722
  from: string;
901
- fromLayer: string;
1723
+ fromLayer: string | null;
902
1724
  to?: string;
903
1725
  toLayer?: string;
904
1726
  line: number;
@@ -931,12 +1753,17 @@ type PreparedChangeFile = {
931
1753
  };
932
1754
  type ChangePreflightResult = {
933
1755
  schemaVersion: '1.0';
1756
+ mode: 'lexical-compatibility';
934
1757
  valid: boolean;
935
1758
  readOnly: true;
936
1759
  policyHash: string;
937
1760
  compilerOptionsHash: string;
938
1761
  baseTreeHash: string;
939
1762
  candidateTreeHash: string;
1763
+ baseCompleteness: ResolvedFactsCompleteness;
1764
+ candidateCompleteness: ResolvedFactsCompleteness;
1765
+ baseCompletenessReasons: ResolvedFactsReason[];
1766
+ candidateCompletenessReasons: ResolvedFactsReason[];
940
1767
  changeMapHash?: string;
941
1768
  convergence?: ArchitectureConvergenceResult;
942
1769
  changes: PreparedChangeFile[];
@@ -973,6 +1800,17 @@ declare function detectArchitectureCycles(graph: ReadonlyMap<string, ReadonlySet
973
1800
  /** Canonical graph and layer-policy evaluator shared by library, CLI, and MCP adapters. */
974
1801
  declare function evaluateArchitectureGraph(input: EvaluateArchitectureGraphInput): ArchitectureEngineResult;
975
1802
 
1803
+ /**
1804
+ * Pure evaluation of validated, resolver-supplied candidate facts (ADR 0011).
1805
+ *
1806
+ * Filesystem discovery and TypeScript resolution remain Tooling concerns. This
1807
+ * module only classifies canonical paths against the supplied contract and
1808
+ * produces the one architecture verdict consumed by every resolved adapter.
1809
+ */
1810
+
1811
+ /** Validate supplied facts and evaluate their graph without host effects. */
1812
+ declare function analyzeResolvedProject(input: AnalyzeResolvedProjectInput): ResolvedAnalysisResult;
1813
+
976
1814
  /**
977
1815
  * Evaluate one create/update/delete set as a single in-memory candidate.
978
1816
  * The function never writes and returns hashes that bind a later host commit to
@@ -980,7 +1818,101 @@ declare function evaluateArchitectureGraph(input: EvaluateArchitectureGraphInput
980
1818
  */
981
1819
  declare function preflightChange(input: AnalyzeChangeInput): ChangePreflightResult;
982
1820
 
1821
+ /**
1822
+ * Validate that the supplied candidate is exactly the declared in-memory
1823
+ * overlay, then return its canonical resolved verdict. No project file is read
1824
+ * or written here.
1825
+ */
1826
+ declare function preflightResolvedChange(input: PreflightResolvedChangeInput): ResolvedChangePreflightResult;
1827
+
983
1828
  /** Canonical config diagnostics over repo-relative file paths. */
984
1829
  declare function collectAnalysisConfigWarnings(input: CollectAnalysisConfigWarningsInput): ArchitectureEngineViolation[];
985
1830
 
986
- 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, ARK_CONFIG_SCHEMA, ARK_CONFIG_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 AnalyzeArchitectureConvergenceInput, type AnalyzeChangeInput, type AnalyzePolicyDeltaInput, type AnalyzeProjectInput, type ArchitectureActualChange, type ArchitectureChangeMap, type ArchitectureChangeMapContract, type ArchitectureChangeMapDependency, type ArchitectureChangeMapFile, type ArchitectureChangeOperation, type ArchitectureConvergenceClassification, type ArchitectureConvergenceFinding, type ArchitectureConvergenceResult, type ArchitectureDependency, type ArchitectureEngineEdge, type ArchitectureEngineResult, type ArchitectureEngineViolation, type ArchitectureLayer, type ArchitectureLayerConfig, type ArchitectureProfile, type ArchitectureRule, type ArkCheckConfig, ArkConfig, ArkConfigLoadResult, type ChangePreflightResult, type CollectAnalysisConfigWarningsInput, type CreateArchitectureProfileFromArkConfigOptions, type CreateArchitectureProfileOptions, type CreateElevenLayerArkConfigOptions, type EvaluateArchitectureGraphInput, type ForbiddenCapabilityUse, POLICY_DELTA_SCHEMA_VERSION, type PolicyDelta, type PolicyDeltaAcknowledgement, type PolicyDeltaAnalysis, type PolicyDeltaClassification, type PolicyDeltaFinding, type PreparedChangeFile, type SemanticDependency, type SemanticDependencyKind, analyzeArchitectureConvergence, analyzeChange, analyzePolicyDelta, analyzeProject, classifyArkPolicyDelta, collectAnalysisConfigWarnings, collectForbiddenCapabilityUses, createAICodeGate, createAdapterResult, createArchitectureProfile, createArchitectureProfileFromArkConfig, createElevenLayerArkConfig, detectArchitectureCycles, deterministicHash, elevenLayerProfile, evaluateArchitectureGraph, explainViolation, extractSemanticDependencies, loadArkConfigContract, loadContract, parseArkConfigJson, policyDeltaAcknowledgementMatches, preflightChange, stableSerialize, toAdapterDiagnostic, version };
1831
+ /** Public, evidence-backed enforcement state shared by doctor adapters. */
1832
+ declare const ARK_ENFORCEMENT_STATE_SCHEMA_VERSION: "1.1";
1833
+ type EnforcementVerification = boolean | 'unverified';
1834
+ type EnforcementEvidenceField = 'configured' | 'installed' | 'active' | 'runtimeObserved' | 'operationCoverage' | 'bypassable' | 'required' | 'hard';
1835
+ type EnforcementEvidence = {
1836
+ field: 'configured' | 'installed' | 'runtimeObserved' | 'hard';
1837
+ source: string;
1838
+ value: boolean;
1839
+ } | {
1840
+ field: 'active' | 'operationCoverage' | 'bypassable' | 'required';
1841
+ source: string;
1842
+ value: EnforcementVerification;
1843
+ };
1844
+ /**
1845
+ * State for one enforcement boundary.
1846
+ *
1847
+ * `configured` records valid wiring, while `installed` requires the referenced
1848
+ * package or executable to resolve. Runtime/provider facts remain
1849
+ * `unverified` until observed; local files never prove `required: true`.
1850
+ */
1851
+ type EnforcementBoundaryState = {
1852
+ supported: boolean;
1853
+ analyzed: boolean;
1854
+ configured: boolean;
1855
+ installed: boolean;
1856
+ active: EnforcementVerification;
1857
+ runtimeObserved: boolean;
1858
+ operation: string | null;
1859
+ operationCoverage: EnforcementVerification;
1860
+ bypassable: EnforcementVerification;
1861
+ required: EnforcementVerification;
1862
+ hard: boolean;
1863
+ evidence: readonly EnforcementEvidence[];
1864
+ };
1865
+ type ArkEnforcementHost = 'claude' | 'grok' | 'cursor' | 'codex' | 'unknown';
1866
+ type ArkEnforcementState = {
1867
+ schemaVersion: typeof ARK_ENFORCEMENT_STATE_SCHEMA_VERSION;
1868
+ activeHost: ArkEnforcementHost;
1869
+ localWrite: EnforcementBoundaryState;
1870
+ advisoryMcp: EnforcementBoundaryState;
1871
+ ciMerge: EnforcementBoundaryState;
1872
+ };
1873
+
1874
+ /** Public neutral contract for the opt-in new-code design-fitness ratchet. */
1875
+ declare const ARK_DESIGN_DELTA_SCHEMA_VERSION: "1.0";
1876
+ type DesignSmellId = 'io-under-application' | 'handler-in-persistence' | 'god-module' | 'domain-logic-in-ui' | 'facade-sql-in-routes' | 'mixed-pattern-cluster' | 'soft-contract';
1877
+ type DesignDeltaIdentity = {
1878
+ kind: 'git-tree' | 'candidate-tree';
1879
+ value: string;
1880
+ commit?: string;
1881
+ };
1882
+ type DesignSmellEvidence = {
1883
+ kind: string;
1884
+ path: string;
1885
+ line?: number;
1886
+ symbol?: string;
1887
+ detail?: string;
1888
+ magnitude: number;
1889
+ };
1890
+ type DesignSmellFinding = {
1891
+ smellId: DesignSmellId;
1892
+ fingerprint: string;
1893
+ identity: string;
1894
+ evidence: DesignSmellEvidence;
1895
+ repairHint: string;
1896
+ };
1897
+ type DesignDeltaChange = DesignSmellFinding & {
1898
+ classification: 'new' | 'worsened';
1899
+ baseMagnitude: number;
1900
+ candidateMagnitude: number;
1901
+ };
1902
+ type ArkDesignDeltaResult = {
1903
+ schemaVersion: typeof ARK_DESIGN_DELTA_SCHEMA_VERSION;
1904
+ mode: 'git-base' | 'write-candidate';
1905
+ complete: boolean;
1906
+ valid: boolean;
1907
+ base: DesignDeltaIdentity;
1908
+ candidate: DesignDeltaIdentity;
1909
+ supportedSmellIds: readonly DesignSmellId[];
1910
+ touchedPaths: readonly string[];
1911
+ changes: readonly DesignDeltaChange[];
1912
+ baseFindingCount: number;
1913
+ candidateFindingCount: number;
1914
+ historicalResidualCount: number;
1915
+ error?: string;
1916
+ };
1917
+
1918
+ 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, ARK_CONFIG_SCHEMA, ARK_CONFIG_SCHEMA_VERSION, ARK_DESIGN_DELTA_SCHEMA_VERSION, ARK_ENFORCEMENT_STATE_SCHEMA_VERSION, type AdapterCompletenessReason, type AdapterDiagnostic, type AdapterResult, type AdapterSeverity, type AdapterViolationInput, type AnalysisCapabilityUse, type AnalysisCompilerOptions, type AnalysisCompleteness, type AnalysisContract, type AnalysisEvidence, type AnalysisFile, type AnalysisFileChange, type AnalysisFileInput, type AnalysisImportEdge, type AnalysisIr, type AnalysisMode, type AnalysisResult, type AnalysisViolation, type AnalyzeArchitectureConvergenceInput, type AnalyzeChangeInput, type AnalyzePolicyDeltaInput, type AnalyzeProjectInput, type AnalyzeResolvedProjectInput, type ArchitectureActualChange, type ArchitectureChangeMap, type ArchitectureChangeMapContract, type ArchitectureChangeMapDependency, type ArchitectureChangeMapFile, type ArchitectureChangeOperation, type ArchitectureConvergenceClassification, type ArchitectureConvergenceFinding, type ArchitectureConvergenceResult, type ArchitectureDependency, type ArchitectureEngineEdge, type ArchitectureEngineResult, type ArchitectureEngineViolation, type ArchitectureLayer, type ArchitectureLayerConfig, type ArchitectureProfile, type ArchitectureRule, type ArkCheckConfig, ArkConfig, ArkConfigLoadResult, type ArkDesignDeltaResult, type ArkEnforcementHost, type ArkEnforcementState, type ChangePreflightResult, type CollectAnalysisConfigWarningsInput, type CreateArchitectureProfileFromArkConfigOptions, type CreateArchitectureProfileOptions, type CreateElevenLayerArkConfigOptions, type DesignDeltaChange, type DesignDeltaIdentity, type DesignSmellEvidence, type DesignSmellFinding, type DesignSmellId, type EnforcementBoundaryState, type EnforcementEvidence, type EnforcementEvidenceField, type EnforcementVerification, type EvaluateArchitectureGraphInput, type ForbiddenCapabilityUse, POLICY_DELTA_SCHEMA_VERSION, type PolicyDelta, type PolicyDeltaAcknowledgement, type PolicyDeltaAnalysis, type PolicyDeltaClassification, type PolicyDeltaFinding, type PreflightResolvedChangeInput, type PreparedChangeFile, RESOLVED_CANDIDATE_FACTS_SCHEMA, RESOLVED_CANDIDATE_FACTS_SCHEMA_VERSION, type ResolvedAmbientFact, type ResolvedAnalysisFile, type ResolvedAnalysisIr, type ResolvedAnalysisResult, type ResolvedCandidateFacts, type ResolvedCandidateFactsInput, type ResolvedCapability, type ResolvedCapabilityFact, type ResolvedChangePreflightResult, type ResolvedDependencyFact, type ResolvedDependencyKind, type ResolvedDependencyState, type ResolvedFactsCompleteness, type ResolvedFactsReason, type ResolvedFileFact, type ResolvedIntentReferenceFact, type ResolvedPublishFact, type ResolvedSafetyFact, type ResolvedSafetyKind, type ResolvedSafetyReport, type SemanticDependency, type SemanticDependencyKind, analyzeArchitectureConvergence, analyzeChange, analyzePolicyDelta, analyzeProject, analyzeResolvedProject, classifyArkPolicyDelta, collectAnalysisConfigWarnings, collectForbiddenCapabilityUses, createAICodeGate, createAdapterResult, createArchitectureProfile, createArchitectureProfileFromArkConfig, createElevenLayerArkConfig, createResolvedCandidateFacts, detectArchitectureCycles, deterministicHash, elevenLayerProfile, evaluateArchitectureGraph, explainViolation, extractSemanticDependencies, loadArkConfigContract, loadContract, loadResolvedCandidateFacts, parseArkConfigJson, policyDeltaAcknowledgementMatches, preflightChange, preflightResolvedChange, resolvedFactsEvidenceRequirementsHash, stableSerialize, toAdapterDiagnostic, version };