arkgate 3.7.0 → 3.8.1

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 (79) hide show
  1. package/CHANGELOG.md +113 -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-layer-match.mjs +9 -4
  6. package/bin/ark-mcp-runtime.mjs +1976 -0
  7. package/bin/ark-mcp.mjs +84 -1495
  8. package/bin/ark-shared.mjs +34 -38
  9. package/bin/ark.mjs +33 -66
  10. package/bin/lib/adapter-contract.mjs +161 -9
  11. package/bin/lib/agent-gates.mjs +1 -0
  12. package/bin/lib/analysis-completeness.mjs +28 -0
  13. package/bin/lib/analysis-engine.mjs +8 -8
  14. package/bin/lib/analysis-policy.mjs +27 -0
  15. package/bin/lib/architecture-scan.mjs +70 -357
  16. package/bin/lib/auto-patch.mjs +76 -8
  17. package/bin/lib/ci-and-commands.mjs +1 -1
  18. package/bin/lib/codex-home.mjs +43 -16
  19. package/bin/lib/design-delta.mjs +4 -0
  20. package/bin/lib/doctor-advisories.mjs +4 -3
  21. package/bin/lib/doctor-plan.mjs +40 -41
  22. package/bin/lib/enforcement-state.mjs +2 -0
  23. package/bin/lib/github-enforcement.mjs +443 -0
  24. package/bin/lib/hook-templates.mjs +12 -148
  25. package/bin/lib/html-report-advisories.mjs +1 -1
  26. package/bin/lib/html-report-depth.mjs +9 -0
  27. package/bin/lib/html-report.mjs +5 -5
  28. package/bin/lib/install-migrate.mjs +83 -79
  29. package/bin/lib/managed-upgrade.mjs +622 -0
  30. package/bin/lib/mcp-adoption.mjs +3 -1
  31. package/bin/lib/parse-health.mjs +6 -5
  32. package/bin/lib/port-proof.mjs +2 -2
  33. package/bin/lib/prepare-change.mjs +68 -38
  34. package/bin/lib/prepare-write.mjs +7 -1
  35. package/bin/lib/resident-doctor-client.mjs +55 -0
  36. package/bin/lib/resident-hook.mjs +247 -0
  37. package/bin/lib/resolved-candidate-facts.mjs +1160 -0
  38. package/bin/lib/scan-files.mjs +19 -6
  39. package/bin/lib/snippet-analysis.mjs +119 -0
  40. package/bin/lib/source-policy.mjs +24 -0
  41. package/bin/lib/typescript-host.mjs +15 -18
  42. package/bin/lib/unavailable-analysis.mjs +76 -0
  43. package/bin/lib/upgrade-command.mjs +115 -0
  44. package/bin/lib/weakest-link.mjs +21 -179
  45. package/bin/lib/write-path-capabilities.mjs +167 -16
  46. package/bin/lib/write-path-detect.mjs +3 -2
  47. package/dist/eslint/index.cjs +3 -3
  48. package/dist/eslint/index.d.ts +4 -1
  49. package/dist/eslint/index.js +3 -3
  50. package/dist/index.cjs +6 -6
  51. package/dist/index.d.ts +1111 -151
  52. package/dist/index.js +7 -7
  53. package/docs/agent-guide.md +106 -62
  54. package/docs/ai-gates.md +97 -16
  55. package/docs/configuration.md +3 -0
  56. package/docs/demos/01-write-gate-self-correction.md +2 -2
  57. package/docs/enthusiast/README.md +10 -10
  58. package/docs/enthusiast/how-to-gallery-starter.md +2 -2
  59. package/docs/enthusiast/reference-commands.md +18 -1
  60. package/docs/enthusiast/tutorial-first-project.md +2 -2
  61. package/docs/package-surface.md +98 -12
  62. package/docs/typescript-support.md +108 -37
  63. package/package.json +32 -4
  64. package/schemas/ark.analysis-result.schema.json +159 -2
  65. package/schemas/ark.design-delta.schema.json +1 -0
  66. package/schemas/ark.enforcement-state.schema.json +84 -0
  67. package/schemas/ark.resolved-candidate-facts.schema.json +1 -0
  68. package/server.json +2 -2
  69. package/templates/skills/ark-explore.md +5 -5
  70. package/templates/skills/ark-fix.md +1 -1
  71. package/templates/skills/ark-runtime.md +15 -8
  72. package/templates/skills/ark-upgrade.md +122 -182
  73. package/bin/lib/ai-velocity.mjs +0 -293
  74. package/bin/lib/graph-cycles.mjs +0 -6
  75. package/bin/lib/safety-diagnostics.mjs +0 -284
  76. package/bin/lib/ts-resolve.mjs +0 -228
  77. package/dist/configTypes-DAPvBqK6.d.cts +0 -61
  78. package/dist/eslint/index.d.cts +0 -146
  79. 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.1";
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,170 +863,720 @@ 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
- };
686
-
687
- type ArchitectureDependency = {
688
- from: string;
689
- to: string;
690
- };
691
- type ArchitectureActualChange = {
692
- path: string;
693
- operation: ArchitectureChangeOperation;
694
- };
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';
707
- };
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[];
716
- };
717
- type AnalyzeArchitectureConvergenceInput = {
718
- changeMap: ArchitectureChangeMapContract;
719
- changes: readonly ArchitectureActualChange[];
720
- baseDependencies: readonly ArchitectureDependency[];
721
- candidateDependencies: readonly ArchitectureDependency[];
722
- };
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;
729
- line: number;
730
- typeOnly: boolean;
731
- unresolved: boolean;
732
- node: unknown;
733
- };
734
- type ForbiddenCapabilityUse = {
735
- name: string;
736
- line: number;
737
- node: unknown;
738
- };
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[];
866
+ /**
867
+ * Portable identity/fingerprint primitives for pure Domain contracts.
868
+ *
869
+ * FNV-1a is intentional: no Node crypto dependency for CLI/MCP/browserless consumers.
870
+ */
871
+ /** Stable FNV-1a hash. Identity/fingerprint only — not a security primitive. */
872
+ declare function deterministicHash(value: string): string;
873
+ /** Serialize JSON-like values with sorted object keys for reproducible hashes. */
874
+ declare function stableSerialize(value: unknown): string;
743
875
 
744
876
  /**
745
- * Stable, pure vocabulary for ArkGate's importable analysis engine.
877
+ * Versioned type vocabulary for resolved candidate facts (schema 1.0).
746
878
  *
747
- * Parsing and filesystem discovery belong to adapters. This module intentionally
748
- * contains only the versioned data contract and deterministic hash primitives.
879
+ * Pure declarations + schema version identity. Create/load live in
880
+ * resolvedCandidateFacts.ts; JSON Schema lives in resolvedCandidateFactsSchema.ts.
749
881
  */
750
- declare const ANALYSIS_IR_SCHEMA_VERSION: "1.0";
751
- type AnalysisFileInput = {
752
- path: string;
753
- content: string;
882
+ declare const RESOLVED_CANDIDATE_FACTS_SCHEMA_VERSION: "1.0";
883
+ type ResolvedFactsCompleteness = 'complete' | 'partial' | 'unavailable';
884
+ type ResolvedDependencyKind = 'import' | 'export' | 'dynamic-import' | 'require';
885
+ type ResolvedDependencyState = 'resolved-project' | 'resolved-external' | 'unresolved' | 'dynamic';
886
+ type ResolvedCapability = 'network' | 'filesystem' | 'clock' | 'randomness' | 'environment' | 'process' | 'persistence';
887
+ type ResolvedFactsReason = {
888
+ code: string;
889
+ message: string;
890
+ file?: string;
754
891
  };
755
- type AnalysisFileChange = {
756
- path: string;
757
- content: string;
758
- } | {
892
+ type ResolvedFileFact = {
759
893
  path: string;
760
- delete: true;
761
- };
762
- type AnalysisCompilerOptions = Readonly<Record<string, unknown>>;
763
- type AnalysisFile = AnalysisFileInput & {
764
894
  contentHash: string;
765
- layer: string | null;
895
+ parseStatus: 'parsed' | 'invalid';
896
+ parseDiagnosticCount: number;
897
+ exportsOnlyTypes: boolean;
898
+ typeOnlyExportNames: string[];
899
+ hasTopLevelSideEffects: boolean;
766
900
  };
767
- type AnalysisImportEdge = {
901
+ type ResolvedDependencyFact = {
768
902
  from: string;
769
- specifier: string;
770
- to: string | null;
771
- resolution: 'resolved' | 'unresolved';
772
- fromLayer: string | null;
773
- toLayer: string | null;
774
- evidence: AnalysisEvidence;
903
+ specifier?: string;
904
+ kind: ResolvedDependencyKind;
905
+ typeOnly: boolean;
906
+ line: number;
907
+ resolution: ResolvedDependencyState;
908
+ target?: string;
909
+ namedBindings?: string[];
910
+ targetTypeOnlyExports?: boolean;
911
+ sourcePureTypeModule?: boolean;
912
+ namedBindingsTypeOnly?: boolean;
913
+ portProofEligible?: boolean;
775
914
  };
776
- /** A capability use is reserved for C04's symbol-aware implementation. */
777
- type AnalysisCapabilityUse = {
915
+ type ResolvedCapabilityFact = {
916
+ file: string;
917
+ line: number;
918
+ symbol: string;
919
+ capability: ResolvedCapability;
920
+ source: 'ambient-global' | 'import-based';
921
+ };
922
+ type ResolvedAmbientFact = {
778
923
  file: string;
924
+ line: number;
779
925
  symbol: string;
780
- capability: string;
781
- evidence: AnalysisEvidence;
782
926
  };
783
- type AnalysisEvidence = {
784
- kind: 'import' | 'policy';
927
+ type ResolvedPublishFact = {
785
928
  file: string;
786
929
  line: number;
787
- excerpt: string;
930
+ rawIntentName?: string;
931
+ objectHasIntent: boolean;
932
+ arkPublishCandidate: boolean;
933
+ hasSource: boolean;
934
+ sourceIntent?: string;
788
935
  };
789
- type AnalysisViolation = {
790
- ruleId: string;
791
- message: string;
792
- edge?: AnalysisImportEdge;
793
- /** U04 (additive): present on CAPABILITY_VIOLATION — the denied capability id. */
794
- capability?: string;
795
- /** U04 (additive): the matched module specifier or ambient path. */
936
+ type ResolvedIntentReferenceFact = {
937
+ file: string;
938
+ line: number;
939
+ intent: string;
940
+ };
941
+ type ResolvedSafetyKind = 'ts-suppression' | 'any-cast' | 'dynamic-import' | 'dynamic-require' | 'in-memory-store';
942
+ /** Neutral syntax evidence for policy-controlled safety diagnostics. */
943
+ type ResolvedSafetyFact = {
944
+ file: string;
945
+ line: number;
946
+ kind: ResolvedSafetyKind;
796
947
  symbol?: string;
797
- evidence: AnalysisEvidence;
798
948
  };
799
- type AnalysisIr = {
800
- schemaVersion: typeof ANALYSIS_IR_SCHEMA_VERSION;
801
- policyHash: string;
949
+ type ResolvedCandidateFactsInput = {
950
+ schemaVersion: typeof RESOLVED_CANDIDATE_FACTS_SCHEMA_VERSION;
951
+ completeness: ResolvedFactsCompleteness;
952
+ completenessReasons: readonly ResolvedFactsReason[];
953
+ resolverIdentity: string;
954
+ compilerIdentity: string;
802
955
  compilerOptionsHash: string;
803
- files: AnalysisFile[];
804
- layers: string[];
805
- edges: AnalysisImportEdge[];
806
- capabilityUses: AnalysisCapabilityUse[];
807
- violations: AnalysisViolation[];
956
+ tsconfigHash: string;
957
+ evidenceRequirementsHash: string;
958
+ projectPackageName?: string;
959
+ files: readonly ResolvedFileFact[];
960
+ dependencies: readonly ResolvedDependencyFact[];
961
+ capabilityUses: readonly ResolvedCapabilityFact[];
962
+ ambientUses: readonly ResolvedAmbientFact[];
963
+ publishCalls: readonly ResolvedPublishFact[];
964
+ intentReferences: readonly ResolvedIntentReferenceFact[];
965
+ safetyUses: readonly ResolvedSafetyFact[];
966
+ };
967
+ type ResolvedCandidateFacts = Omit<ResolvedCandidateFactsInput, 'candidateTreeHash'> & {
968
+ completenessReasons: ResolvedFactsReason[];
969
+ candidateTreeHash: string;
970
+ files: ResolvedFileFact[];
971
+ dependencies: ResolvedDependencyFact[];
972
+ capabilityUses: ResolvedCapabilityFact[];
973
+ ambientUses: ResolvedAmbientFact[];
974
+ publishCalls: ResolvedPublishFact[];
975
+ intentReferences: ResolvedIntentReferenceFact[];
976
+ safetyUses: ResolvedSafetyFact[];
977
+ factsHash: string;
808
978
  };
979
+
809
980
  /**
810
- * Stable FNV-1a hash. It is an identity/fingerprint, not a security primitive.
811
- * The output is deliberately portable across the CLI, MCP, hooks, and browserless
812
- * consumers without Node's crypto runtime.
981
+ * Canonical create/load for versioned resolved candidate facts.
982
+ *
983
+ * Types: resolvedCandidateFactsTypes.ts · Schema: resolvedCandidateFactsSchema.ts ·
984
+ * Hash: stableHash.ts. Plan-B god-module pilot cluster (pattern-b:god-module).
813
985
  */
814
- declare function deterministicHash(value: string): string;
815
- /** Serialize JSON-like values with sorted object keys for reproducible hashes. */
816
- declare function stableSerialize(value: unknown): string;
817
986
 
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
- };
987
+ /** Identity of the policy-controlled evidence a resolver must attempt to collect. */
988
+ declare function resolvedFactsEvidenceRequirementsHash(config: ArkConfig): string;
989
+ declare function createResolvedCandidateFacts(input: ResolvedCandidateFactsInput): ResolvedCandidateFacts;
990
+ declare function loadResolvedCandidateFacts(input: unknown): ResolvedCandidateFacts;
991
+
992
+ declare const RESOLVED_CANDIDATE_FACTS_SCHEMA: {
993
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
994
+ readonly $id: "https://unpkg.com/arkgate@3/schemas/ark.resolved-candidate-facts.schema.json";
995
+ readonly title: "ArkGate resolved candidate facts";
996
+ readonly type: "object";
997
+ readonly additionalProperties: false;
998
+ readonly required: readonly ["schemaVersion", "completeness", "completenessReasons", "resolverIdentity", "compilerIdentity", "compilerOptionsHash", "tsconfigHash", "candidateTreeHash", "evidenceRequirementsHash", "files", "dependencies", "capabilityUses", "ambientUses", "publishCalls", "intentReferences", "safetyUses", "factsHash"];
999
+ readonly properties: {
1000
+ readonly schemaVersion: {
1001
+ readonly const: "1.0";
1002
+ };
1003
+ readonly completeness: {
1004
+ readonly enum: readonly ["complete", "partial", "unavailable"];
1005
+ };
1006
+ readonly completenessReasons: {
1007
+ readonly type: "array";
1008
+ readonly items: {
1009
+ readonly type: "object";
1010
+ readonly additionalProperties: false;
1011
+ readonly required: readonly ["code", "message"];
1012
+ readonly properties: {
1013
+ readonly code: {
1014
+ readonly type: "string";
1015
+ readonly minLength: 1;
1016
+ };
1017
+ readonly message: {
1018
+ readonly type: "string";
1019
+ readonly minLength: 1;
1020
+ };
1021
+ readonly file: {
1022
+ readonly type: "string";
1023
+ readonly minLength: 1;
1024
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1025
+ };
1026
+ };
1027
+ };
1028
+ };
1029
+ readonly resolverIdentity: {
1030
+ readonly type: "string";
1031
+ readonly minLength: 1;
1032
+ };
1033
+ readonly compilerIdentity: {
1034
+ readonly type: "string";
1035
+ readonly minLength: 1;
1036
+ };
1037
+ readonly compilerOptionsHash: {
1038
+ readonly type: "string";
1039
+ readonly minLength: 1;
1040
+ };
1041
+ readonly tsconfigHash: {
1042
+ readonly type: "string";
1043
+ readonly minLength: 1;
1044
+ };
1045
+ readonly candidateTreeHash: {
1046
+ readonly type: "string";
1047
+ readonly minLength: 1;
1048
+ };
1049
+ readonly evidenceRequirementsHash: {
1050
+ readonly type: "string";
1051
+ readonly minLength: 1;
1052
+ };
1053
+ readonly projectPackageName: {
1054
+ readonly type: "string";
1055
+ readonly minLength: 1;
1056
+ };
1057
+ readonly files: {
1058
+ readonly type: "array";
1059
+ readonly uniqueItems: true;
1060
+ readonly items: {
1061
+ readonly type: "object";
1062
+ readonly additionalProperties: false;
1063
+ readonly required: readonly ["path", "contentHash", "parseStatus", "parseDiagnosticCount", "exportsOnlyTypes", "typeOnlyExportNames", "hasTopLevelSideEffects"];
1064
+ readonly properties: {
1065
+ readonly path: {
1066
+ readonly type: "string";
1067
+ readonly minLength: 1;
1068
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1069
+ };
1070
+ readonly contentHash: {
1071
+ readonly type: "string";
1072
+ readonly minLength: 1;
1073
+ };
1074
+ readonly parseStatus: {
1075
+ readonly enum: readonly ["parsed", "invalid"];
1076
+ };
1077
+ readonly parseDiagnosticCount: {
1078
+ readonly type: "integer";
1079
+ readonly minimum: 0;
1080
+ };
1081
+ readonly exportsOnlyTypes: {
1082
+ readonly type: "boolean";
1083
+ };
1084
+ readonly typeOnlyExportNames: {
1085
+ readonly type: "array";
1086
+ readonly items: {
1087
+ readonly type: "string";
1088
+ readonly minLength: 1;
1089
+ };
1090
+ };
1091
+ readonly hasTopLevelSideEffects: {
1092
+ readonly type: "boolean";
1093
+ };
1094
+ };
1095
+ readonly allOf: readonly [{
1096
+ readonly if: {
1097
+ readonly properties: {
1098
+ readonly parseStatus: {
1099
+ readonly const: "parsed";
1100
+ };
1101
+ };
1102
+ };
1103
+ readonly then: {
1104
+ readonly properties: {
1105
+ readonly parseDiagnosticCount: {
1106
+ readonly const: 0;
1107
+ };
1108
+ };
1109
+ };
1110
+ }, {
1111
+ readonly if: {
1112
+ readonly properties: {
1113
+ readonly parseStatus: {
1114
+ readonly const: "invalid";
1115
+ };
1116
+ };
1117
+ };
1118
+ readonly then: {
1119
+ readonly properties: {
1120
+ readonly parseDiagnosticCount: {
1121
+ readonly minimum: 1;
1122
+ };
1123
+ };
1124
+ };
1125
+ }];
1126
+ };
1127
+ };
1128
+ readonly dependencies: {
1129
+ readonly type: "array";
1130
+ readonly items: {
1131
+ readonly type: "object";
1132
+ readonly additionalProperties: false;
1133
+ readonly required: readonly ["from", "kind", "typeOnly", "line", "resolution"];
1134
+ readonly properties: {
1135
+ readonly from: {
1136
+ readonly type: "string";
1137
+ readonly minLength: 1;
1138
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1139
+ };
1140
+ readonly specifier: {
1141
+ readonly type: "string";
1142
+ readonly minLength: 1;
1143
+ };
1144
+ readonly kind: {
1145
+ readonly enum: readonly ["import", "export", "dynamic-import", "require"];
1146
+ };
1147
+ readonly typeOnly: {
1148
+ readonly type: "boolean";
1149
+ };
1150
+ readonly line: {
1151
+ readonly type: "integer";
1152
+ readonly minimum: 1;
1153
+ };
1154
+ readonly resolution: {
1155
+ readonly enum: readonly ["resolved-project", "resolved-external", "unresolved", "dynamic"];
1156
+ };
1157
+ readonly target: {
1158
+ readonly type: "string";
1159
+ readonly minLength: 1;
1160
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1161
+ };
1162
+ readonly namedBindings: {
1163
+ readonly type: "array";
1164
+ readonly items: {
1165
+ readonly type: "string";
1166
+ readonly minLength: 1;
1167
+ };
1168
+ };
1169
+ readonly targetTypeOnlyExports: {
1170
+ readonly type: "boolean";
1171
+ };
1172
+ readonly sourcePureTypeModule: {
1173
+ readonly type: "boolean";
1174
+ };
1175
+ readonly namedBindingsTypeOnly: {
1176
+ readonly type: "boolean";
1177
+ };
1178
+ readonly portProofEligible: {
1179
+ readonly type: "boolean";
1180
+ };
1181
+ };
1182
+ readonly allOf: readonly [{
1183
+ readonly if: {
1184
+ readonly properties: {
1185
+ readonly resolution: {
1186
+ readonly const: "resolved-project";
1187
+ };
1188
+ };
1189
+ };
1190
+ readonly then: {
1191
+ readonly required: readonly ["target"];
1192
+ };
1193
+ readonly else: {
1194
+ readonly not: {
1195
+ readonly required: readonly ["target"];
1196
+ };
1197
+ };
1198
+ }, {
1199
+ readonly if: {
1200
+ readonly properties: {
1201
+ readonly resolution: {
1202
+ readonly const: "dynamic";
1203
+ };
1204
+ };
1205
+ };
1206
+ readonly else: {
1207
+ readonly required: readonly ["specifier"];
1208
+ };
1209
+ }];
1210
+ };
1211
+ };
1212
+ readonly capabilityUses: {
1213
+ readonly type: "array";
1214
+ readonly items: {
1215
+ readonly type: "object";
1216
+ readonly additionalProperties: false;
1217
+ readonly required: readonly ["file", "line", "symbol", "capability", "source"];
1218
+ readonly properties: {
1219
+ readonly file: {
1220
+ readonly type: "string";
1221
+ readonly minLength: 1;
1222
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1223
+ };
1224
+ readonly line: {
1225
+ readonly type: "integer";
1226
+ readonly minimum: 1;
1227
+ };
1228
+ readonly symbol: {
1229
+ readonly type: "string";
1230
+ readonly minLength: 1;
1231
+ };
1232
+ readonly capability: {
1233
+ readonly enum: readonly ["network", "filesystem", "clock", "randomness", "environment", "process", "persistence"];
1234
+ };
1235
+ readonly source: {
1236
+ readonly enum: readonly ["ambient-global", "import-based"];
1237
+ };
1238
+ };
1239
+ };
1240
+ };
1241
+ readonly ambientUses: {
1242
+ readonly type: "array";
1243
+ readonly items: {
1244
+ readonly type: "object";
1245
+ readonly additionalProperties: false;
1246
+ readonly required: readonly ["file", "line", "symbol"];
1247
+ readonly properties: {
1248
+ readonly file: {
1249
+ readonly type: "string";
1250
+ readonly minLength: 1;
1251
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1252
+ };
1253
+ readonly line: {
1254
+ readonly type: "integer";
1255
+ readonly minimum: 1;
1256
+ };
1257
+ readonly symbol: {
1258
+ readonly type: "string";
1259
+ readonly minLength: 1;
1260
+ };
1261
+ };
1262
+ };
1263
+ };
1264
+ readonly publishCalls: {
1265
+ readonly type: "array";
1266
+ readonly items: {
1267
+ readonly type: "object";
1268
+ readonly additionalProperties: false;
1269
+ readonly required: readonly ["file", "line", "objectHasIntent", "arkPublishCandidate", "hasSource"];
1270
+ readonly properties: {
1271
+ readonly file: {
1272
+ readonly type: "string";
1273
+ readonly minLength: 1;
1274
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1275
+ };
1276
+ readonly line: {
1277
+ readonly type: "integer";
1278
+ readonly minimum: 1;
1279
+ };
1280
+ readonly rawIntentName: {
1281
+ readonly type: "string";
1282
+ readonly minLength: 1;
1283
+ };
1284
+ readonly objectHasIntent: {
1285
+ readonly type: "boolean";
1286
+ };
1287
+ readonly arkPublishCandidate: {
1288
+ readonly type: "boolean";
1289
+ };
1290
+ readonly hasSource: {
1291
+ readonly type: "boolean";
1292
+ };
1293
+ readonly sourceIntent: {
1294
+ readonly type: "string";
1295
+ readonly minLength: 1;
1296
+ };
1297
+ };
1298
+ };
1299
+ };
1300
+ readonly intentReferences: {
1301
+ readonly type: "array";
1302
+ readonly items: {
1303
+ readonly type: "object";
1304
+ readonly additionalProperties: false;
1305
+ readonly required: readonly ["file", "line", "intent"];
1306
+ readonly properties: {
1307
+ readonly file: {
1308
+ readonly type: "string";
1309
+ readonly minLength: 1;
1310
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1311
+ };
1312
+ readonly line: {
1313
+ readonly type: "integer";
1314
+ readonly minimum: 1;
1315
+ };
1316
+ readonly intent: {
1317
+ readonly type: "string";
1318
+ readonly minLength: 1;
1319
+ };
1320
+ };
1321
+ };
1322
+ };
1323
+ readonly safetyUses: {
1324
+ readonly type: "array";
1325
+ readonly items: {
1326
+ readonly type: "object";
1327
+ readonly additionalProperties: false;
1328
+ readonly required: readonly ["file", "line", "kind"];
1329
+ readonly properties: {
1330
+ readonly file: {
1331
+ readonly type: "string";
1332
+ readonly minLength: 1;
1333
+ readonly pattern: "^(?!/)(?![A-Za-z]:/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*[\\u0000-\\u001f\\u007f])(?!.*\\/$).+$";
1334
+ };
1335
+ readonly line: {
1336
+ readonly type: "integer";
1337
+ readonly minimum: 1;
1338
+ };
1339
+ readonly kind: {
1340
+ readonly enum: readonly ["ts-suppression", "any-cast", "dynamic-import", "dynamic-require", "in-memory-store"];
1341
+ };
1342
+ readonly symbol: {
1343
+ readonly type: "string";
1344
+ readonly minLength: 1;
1345
+ };
1346
+ };
1347
+ readonly allOf: readonly [{
1348
+ readonly if: {
1349
+ readonly properties: {
1350
+ readonly kind: {
1351
+ readonly const: "in-memory-store";
1352
+ };
1353
+ };
1354
+ };
1355
+ readonly then: {
1356
+ readonly required: readonly ["symbol"];
1357
+ };
1358
+ readonly else: {
1359
+ readonly not: {
1360
+ readonly required: readonly ["symbol"];
1361
+ };
1362
+ };
1363
+ }];
1364
+ };
1365
+ };
1366
+ readonly factsHash: {
1367
+ readonly type: "string";
1368
+ readonly minLength: 1;
1369
+ };
1370
+ };
1371
+ readonly allOf: readonly [{
1372
+ readonly if: {
1373
+ readonly properties: {
1374
+ readonly completeness: {
1375
+ readonly const: "complete";
1376
+ };
1377
+ };
1378
+ };
1379
+ readonly then: {
1380
+ readonly properties: {
1381
+ readonly completenessReasons: {
1382
+ readonly maxItems: 0;
1383
+ };
1384
+ readonly files: {
1385
+ readonly items: {
1386
+ readonly properties: {
1387
+ readonly parseStatus: {
1388
+ readonly const: "parsed";
1389
+ };
1390
+ };
1391
+ };
1392
+ };
1393
+ };
1394
+ };
1395
+ }, {
1396
+ readonly if: {
1397
+ readonly properties: {
1398
+ readonly completeness: {
1399
+ readonly enum: readonly ["partial", "unavailable"];
1400
+ };
1401
+ };
1402
+ };
1403
+ readonly then: {
1404
+ readonly properties: {
1405
+ readonly completenessReasons: {
1406
+ readonly minItems: 1;
1407
+ };
1408
+ };
1409
+ };
1410
+ }];
1411
+ };
1412
+
1413
+ /**
1414
+ * Stable, pure vocabulary for ArkGate's importable analysis engine.
1415
+ *
1416
+ * This module owns the Analysis IR types and re-exports the resolved-candidate-facts
1417
+ * pilot cluster (plan-B / pattern-b:god-module). Parsing and filesystem discovery
1418
+ * belong to adapters.
1419
+ *
1420
+ * Cluster:
1421
+ * - `stableHash` — identity/fingerprint primitives
1422
+ * - `resolvedCandidateFactsTypes` — versioned fact types
1423
+ * - `resolvedCandidateFacts` — create/load/canonicalize
1424
+ * - `resolvedCandidateFactsSchema` — published JSON Schema
1425
+ *
1426
+ * Consumer import paths through this facade remain stable (same pattern as Kernel
1427
+ * `analysis.ts` after U02).
1428
+ */
1429
+
1430
+ declare const ANALYSIS_IR_SCHEMA_VERSION: "1.0";
1431
+ type AnalysisFileInput = {
1432
+ path: string;
1433
+ content: string;
1434
+ };
1435
+ type AnalysisFileChange = {
1436
+ path: string;
1437
+ content: string;
1438
+ } | {
1439
+ path: string;
1440
+ delete: true;
1441
+ };
1442
+ type AnalysisCompilerOptions = Readonly<Record<string, unknown>>;
1443
+ type AnalysisFile = AnalysisFileInput & {
1444
+ contentHash: string;
1445
+ layer: string | null;
1446
+ };
1447
+ type AnalysisImportEdge = {
1448
+ from: string;
1449
+ specifier: string;
1450
+ to: string | null;
1451
+ resolution: 'resolved' | 'unresolved';
1452
+ fromLayer: string | null;
1453
+ toLayer: string | null;
1454
+ evidence: AnalysisEvidence;
1455
+ };
1456
+ /** A capability use is reserved for C04's symbol-aware implementation. */
1457
+ type AnalysisCapabilityUse = {
1458
+ file: string;
1459
+ symbol: string;
1460
+ capability: string;
1461
+ evidence: AnalysisEvidence;
1462
+ };
1463
+ type AnalysisEvidence = {
1464
+ kind: 'import' | 'policy';
1465
+ file: string;
1466
+ line: number;
1467
+ excerpt: string;
1468
+ };
1469
+ type AnalysisViolation = {
1470
+ ruleId: string;
1471
+ message: string;
1472
+ edge?: AnalysisImportEdge;
1473
+ /** U04 (additive): present on CAPABILITY_VIOLATION — the denied capability id. */
1474
+ capability?: string;
1475
+ /** U04 (additive): the matched module specifier or ambient path. */
1476
+ symbol?: string;
1477
+ evidence: AnalysisEvidence;
1478
+ };
1479
+ type AnalysisIr = {
1480
+ schemaVersion: typeof ANALYSIS_IR_SCHEMA_VERSION;
1481
+ policyHash: string;
1482
+ compilerOptionsHash: string;
1483
+ files: AnalysisFile[];
1484
+ layers: string[];
1485
+ edges: AnalysisImportEdge[];
1486
+ capabilityUses: AnalysisCapabilityUse[];
1487
+ violations: AnalysisViolation[];
1488
+ };
1489
+
1490
+ declare const ARK_CHANGE_MAP_SCHEMA_VERSION: "1.0";
1491
+ type ArchitectureChangeOperation = 'create' | 'update' | 'delete';
1492
+ type ArchitectureChangeMapFile = {
1493
+ path: string;
1494
+ operation: ArchitectureChangeOperation;
1495
+ layer: string;
1496
+ };
1497
+ type ArchitectureChangeMapDependency = {
1498
+ from: string;
1499
+ to: string;
1500
+ };
1501
+ type ArchitectureChangeMap = {
1502
+ $schema: string;
1503
+ schemaVersion: typeof ARK_CHANGE_MAP_SCHEMA_VERSION;
1504
+ files: ArchitectureChangeMapFile[];
1505
+ dependencies: ArchitectureChangeMapDependency[];
1506
+ };
1507
+ type ArchitectureChangeMapContract = {
1508
+ map: ArchitectureChangeMap;
1509
+ hash: string;
1510
+ };
1511
+
1512
+ type ArchitectureDependency = {
1513
+ from: string;
1514
+ to: string;
1515
+ };
1516
+ type ArchitectureActualChange = {
1517
+ path: string;
1518
+ operation: ArchitectureChangeOperation;
1519
+ };
1520
+ type ArchitectureConvergenceClassification = 'satisfied' | 'missing' | 'contradictory' | 'unplanned';
1521
+ type ArchitectureConvergenceFinding = {
1522
+ id: string;
1523
+ classification: ArchitectureConvergenceClassification;
1524
+ subject: 'file' | 'dependency';
1525
+ message: string;
1526
+ nextAction?: string;
1527
+ path?: string;
1528
+ from?: string;
1529
+ to?: string;
1530
+ expectedOperation?: ArchitectureChangeOperation;
1531
+ actualOperation?: ArchitectureChangeOperation | 'added' | 'removed';
1532
+ };
1533
+ type ArchitectureConvergenceResult = {
1534
+ schemaVersion: '1.0';
1535
+ readOnly: true;
1536
+ changeMapHash: string;
1537
+ structurallyConverged: boolean;
1538
+ behavioralCompletion: 'not-evaluated';
1539
+ summary: Record<ArchitectureConvergenceClassification, number>;
1540
+ findings: ArchitectureConvergenceFinding[];
1541
+ };
1542
+ type AnalyzeArchitectureConvergenceInput = {
1543
+ changeMap: ArchitectureChangeMapContract;
1544
+ changes: readonly ArchitectureActualChange[];
1545
+ baseDependencies: readonly ArchitectureDependency[];
1546
+ candidateDependencies: readonly ArchitectureDependency[];
1547
+ };
1548
+ declare function analyzeArchitectureConvergence(input: AnalyzeArchitectureConvergenceInput): ArchitectureConvergenceResult;
1549
+
1550
+ type SemanticDependencyKind = 'import' | 'export' | 'dynamic-import' | 'require';
1551
+ type SemanticDependency = {
1552
+ specifier?: string;
1553
+ kind: SemanticDependencyKind;
1554
+ line: number;
1555
+ typeOnly: boolean;
1556
+ unresolved: boolean;
1557
+ node: unknown;
1558
+ };
1559
+ type ForbiddenCapabilityUse = {
1560
+ name: string;
1561
+ line: number;
1562
+ node: unknown;
1563
+ };
1564
+ /** Extract every dependency form whose specifier is statically knowable, plus unresolved calls. */
1565
+ declare function extractSemanticDependencies(ts: any, sourceFile: any): SemanticDependency[];
1566
+ /** Resolve forbidden ambient capabilities through symbols, aliases, globalThis, and static keys. */
1567
+ declare function collectForbiddenCapabilityUses(ts: any, sourceFile: any, forbidden: readonly string[]): ForbiddenCapabilityUse[];
1568
+
1569
+ declare const POLICY_DELTA_SCHEMA_VERSION: "1.0";
1570
+ type PolicyDeltaClassification = 'strengthening' | 'neutral' | 'judgment-required' | 'weakening';
1571
+ type PolicyDeltaFinding = {
1572
+ id: string;
1573
+ path: string;
1574
+ classification: Exclude<PolicyDeltaClassification, 'neutral'>;
1575
+ message: string;
1576
+ nextAction?: string;
1577
+ before?: unknown;
1578
+ after?: unknown;
1579
+ };
829
1580
  type PolicyDelta = {
830
1581
  schemaVersion: typeof POLICY_DELTA_SCHEMA_VERSION;
831
1582
  classification: PolicyDeltaClassification;
@@ -865,8 +1616,107 @@ type AnalyzeChangeInput = AnalyzeProjectInput & {
865
1616
  changeMap?: ArchitectureChangeMapContract;
866
1617
  };
867
1618
  type AnalysisResult = {
1619
+ mode: 'lexical-compatibility';
1620
+ completeness: ResolvedFactsCompleteness;
1621
+ completenessReasons: ResolvedFactsReason[];
1622
+ valid: boolean;
868
1623
  ir: AnalysisIr;
869
1624
  };
1625
+ type AnalyzeResolvedProjectInput = {
1626
+ contract: AnalysisContract;
1627
+ facts: unknown;
1628
+ };
1629
+ type PreflightResolvedChangeInput = {
1630
+ contract: AnalysisContract;
1631
+ baseFacts: unknown;
1632
+ candidateFacts: unknown;
1633
+ changes: readonly AnalysisFileChange[];
1634
+ changeMap?: ArchitectureChangeMapContract;
1635
+ };
1636
+ type ResolvedAnalysisFile = ResolvedFileFact & {
1637
+ layer: string | null;
1638
+ };
1639
+ type ResolvedAnalysisIr = {
1640
+ schemaVersion: '1.0';
1641
+ policyHash: string;
1642
+ compilerOptionsHash: string;
1643
+ files: ResolvedAnalysisFile[];
1644
+ layers: string[];
1645
+ edges: ArchitectureEngineEdge[];
1646
+ capabilityUses: ResolvedCapabilityFact[];
1647
+ violations: ArchitectureEngineViolation[];
1648
+ warnings: ArchitectureEngineViolation[];
1649
+ };
1650
+ type ResolvedSafetyReport = {
1651
+ tsSuppressions: {
1652
+ file: string;
1653
+ line: number;
1654
+ }[];
1655
+ anyCasts: {
1656
+ file: string;
1657
+ line: number;
1658
+ }[];
1659
+ nonLiteralDynamicImports: {
1660
+ file: string;
1661
+ line: number;
1662
+ kind: 'import' | 'require';
1663
+ }[];
1664
+ inMemoryProductionStores: {
1665
+ file: string;
1666
+ line: number;
1667
+ store: string;
1668
+ }[];
1669
+ disabledPeerIsolationRules: {
1670
+ from: string;
1671
+ to: string;
1672
+ }[];
1673
+ thresholds: {
1674
+ maxTsSuppressions: number;
1675
+ maxAnyCasts: number;
1676
+ };
1677
+ };
1678
+ type ResolvedAnalysisResult = {
1679
+ mode: 'resolved-candidate-facts';
1680
+ completeness: ResolvedFactsCompleteness;
1681
+ completenessReasons: ResolvedFactsReason[];
1682
+ valid: boolean;
1683
+ strictValid: boolean;
1684
+ policyHash: string;
1685
+ factsHash: ResolvedCandidateFacts['factsHash'];
1686
+ resolverIdentity: ResolvedCandidateFacts['resolverIdentity'];
1687
+ candidateTreeHash: ResolvedCandidateFacts['candidateTreeHash'];
1688
+ safety: ResolvedSafetyReport;
1689
+ ir: ResolvedAnalysisIr;
1690
+ };
1691
+ type ResolvedChangePreflightResult = {
1692
+ schemaVersion: '1.0';
1693
+ mode: 'resolved-candidate-facts';
1694
+ valid: boolean;
1695
+ readOnly: true;
1696
+ policyHash: string;
1697
+ resolverIdentity: string;
1698
+ compilerIdentity: string;
1699
+ compilerOptionsHash: string;
1700
+ tsconfigHash: string;
1701
+ baseCompilerOptionsHash: string;
1702
+ candidateCompilerOptionsHash: string;
1703
+ baseTsconfigHash: string;
1704
+ candidateTsconfigHash: string;
1705
+ evidenceRequirementsHash: string;
1706
+ baseFactsHash: string;
1707
+ candidateFactsHash: string;
1708
+ baseTreeHash: string;
1709
+ candidateTreeHash: string;
1710
+ baseCompleteness: ResolvedFactsCompleteness;
1711
+ candidateCompleteness: ResolvedFactsCompleteness;
1712
+ baseCompletenessReasons: ResolvedFactsReason[];
1713
+ candidateCompletenessReasons: ResolvedFactsReason[];
1714
+ changeMapHash?: string;
1715
+ convergence?: ArchitectureConvergenceResult;
1716
+ changes: PreparedChangeFile[];
1717
+ violations: ArchitectureEngineViolation[];
1718
+ warnings: ArchitectureEngineViolation[];
1719
+ };
870
1720
  type AnalyzePolicyDeltaInput = {
871
1721
  baseConfig: unknown;
872
1722
  candidateConfig: unknown;
@@ -898,7 +1748,7 @@ type ArchitectureEngineViolation = {
898
1748
  };
899
1749
  type ArchitectureEngineEdge = {
900
1750
  from: string;
901
- fromLayer: string;
1751
+ fromLayer: string | null;
902
1752
  to?: string;
903
1753
  toLayer?: string;
904
1754
  line: number;
@@ -931,12 +1781,17 @@ type PreparedChangeFile = {
931
1781
  };
932
1782
  type ChangePreflightResult = {
933
1783
  schemaVersion: '1.0';
1784
+ mode: 'lexical-compatibility';
934
1785
  valid: boolean;
935
1786
  readOnly: true;
936
1787
  policyHash: string;
937
1788
  compilerOptionsHash: string;
938
1789
  baseTreeHash: string;
939
1790
  candidateTreeHash: string;
1791
+ baseCompleteness: ResolvedFactsCompleteness;
1792
+ candidateCompleteness: ResolvedFactsCompleteness;
1793
+ baseCompletenessReasons: ResolvedFactsReason[];
1794
+ candidateCompletenessReasons: ResolvedFactsReason[];
940
1795
  changeMapHash?: string;
941
1796
  convergence?: ArchitectureConvergenceResult;
942
1797
  changes: PreparedChangeFile[];
@@ -973,6 +1828,17 @@ declare function detectArchitectureCycles(graph: ReadonlyMap<string, ReadonlySet
973
1828
  /** Canonical graph and layer-policy evaluator shared by library, CLI, and MCP adapters. */
974
1829
  declare function evaluateArchitectureGraph(input: EvaluateArchitectureGraphInput): ArchitectureEngineResult;
975
1830
 
1831
+ /**
1832
+ * Pure evaluation of validated, resolver-supplied candidate facts (ADR 0011).
1833
+ *
1834
+ * Filesystem discovery and TypeScript resolution remain Tooling concerns. This
1835
+ * module only classifies canonical paths against the supplied contract and
1836
+ * produces the one architecture verdict consumed by every resolved adapter.
1837
+ */
1838
+
1839
+ /** Validate supplied facts and evaluate their graph without host effects. */
1840
+ declare function analyzeResolvedProject(input: AnalyzeResolvedProjectInput): ResolvedAnalysisResult;
1841
+
976
1842
  /**
977
1843
  * Evaluate one create/update/delete set as a single in-memory candidate.
978
1844
  * The function never writes and returns hashes that bind a later host commit to
@@ -980,7 +1846,101 @@ declare function evaluateArchitectureGraph(input: EvaluateArchitectureGraphInput
980
1846
  */
981
1847
  declare function preflightChange(input: AnalyzeChangeInput): ChangePreflightResult;
982
1848
 
1849
+ /**
1850
+ * Validate that the supplied candidate is exactly the declared in-memory
1851
+ * overlay, then return its canonical resolved verdict. No project file is read
1852
+ * or written here.
1853
+ */
1854
+ declare function preflightResolvedChange(input: PreflightResolvedChangeInput): ResolvedChangePreflightResult;
1855
+
983
1856
  /** Canonical config diagnostics over repo-relative file paths. */
984
1857
  declare function collectAnalysisConfigWarnings(input: CollectAnalysisConfigWarningsInput): ArchitectureEngineViolation[];
985
1858
 
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 };
1859
+ /** Public, evidence-backed enforcement state shared by doctor adapters. */
1860
+ declare const ARK_ENFORCEMENT_STATE_SCHEMA_VERSION: "1.1";
1861
+ type EnforcementVerification = boolean | 'unverified';
1862
+ type EnforcementEvidenceField = 'configured' | 'installed' | 'active' | 'runtimeObserved' | 'operationCoverage' | 'bypassable' | 'required' | 'hard';
1863
+ type EnforcementEvidence = {
1864
+ field: 'configured' | 'installed' | 'runtimeObserved' | 'hard';
1865
+ source: string;
1866
+ value: boolean;
1867
+ } | {
1868
+ field: 'active' | 'operationCoverage' | 'bypassable' | 'required';
1869
+ source: string;
1870
+ value: EnforcementVerification;
1871
+ };
1872
+ /**
1873
+ * State for one enforcement boundary.
1874
+ *
1875
+ * `configured` records valid wiring, while `installed` requires the referenced
1876
+ * package or executable to resolve. Runtime/provider facts remain
1877
+ * `unverified` until observed; local files never prove `required: true`.
1878
+ */
1879
+ type EnforcementBoundaryState = {
1880
+ supported: boolean;
1881
+ analyzed: boolean;
1882
+ configured: boolean;
1883
+ installed: boolean;
1884
+ active: EnforcementVerification;
1885
+ runtimeObserved: boolean;
1886
+ operation: string | null;
1887
+ operationCoverage: EnforcementVerification;
1888
+ bypassable: EnforcementVerification;
1889
+ required: EnforcementVerification;
1890
+ hard: boolean;
1891
+ evidence: readonly EnforcementEvidence[];
1892
+ };
1893
+ type ArkEnforcementHost = 'claude' | 'grok' | 'cursor' | 'codex' | 'unknown';
1894
+ type ArkEnforcementState = {
1895
+ schemaVersion: typeof ARK_ENFORCEMENT_STATE_SCHEMA_VERSION;
1896
+ activeHost: ArkEnforcementHost;
1897
+ localWrite: EnforcementBoundaryState;
1898
+ advisoryMcp: EnforcementBoundaryState;
1899
+ ciMerge: EnforcementBoundaryState;
1900
+ };
1901
+
1902
+ /** Public neutral contract for the opt-in new-code design-fitness ratchet. */
1903
+ declare const ARK_DESIGN_DELTA_SCHEMA_VERSION: "1.0";
1904
+ type DesignSmellId = 'io-under-application' | 'handler-in-persistence' | 'god-module' | 'domain-logic-in-ui' | 'facade-sql-in-routes' | 'mixed-pattern-cluster' | 'soft-contract';
1905
+ type DesignDeltaIdentity = {
1906
+ kind: 'git-tree' | 'candidate-tree';
1907
+ value: string;
1908
+ commit?: string;
1909
+ };
1910
+ type DesignSmellEvidence = {
1911
+ kind: string;
1912
+ path: string;
1913
+ line?: number;
1914
+ symbol?: string;
1915
+ detail?: string;
1916
+ magnitude: number;
1917
+ };
1918
+ type DesignSmellFinding = {
1919
+ smellId: DesignSmellId;
1920
+ fingerprint: string;
1921
+ identity: string;
1922
+ evidence: DesignSmellEvidence;
1923
+ repairHint: string;
1924
+ };
1925
+ type DesignDeltaChange = DesignSmellFinding & {
1926
+ classification: 'new' | 'worsened';
1927
+ baseMagnitude: number;
1928
+ candidateMagnitude: number;
1929
+ };
1930
+ type ArkDesignDeltaResult = {
1931
+ schemaVersion: typeof ARK_DESIGN_DELTA_SCHEMA_VERSION;
1932
+ mode: 'git-base' | 'write-candidate';
1933
+ complete: boolean;
1934
+ valid: boolean;
1935
+ base: DesignDeltaIdentity;
1936
+ candidate: DesignDeltaIdentity;
1937
+ supportedSmellIds: readonly DesignSmellId[];
1938
+ touchedPaths: readonly string[];
1939
+ changes: readonly DesignDeltaChange[];
1940
+ baseFindingCount: number;
1941
+ candidateFindingCount: number;
1942
+ historicalResidualCount: number;
1943
+ error?: string;
1944
+ };
1945
+
1946
+ 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 };