@usefragments/core 1.10.2 → 1.11.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 (126) hide show
  1. package/dist/{chunk-MZ4SW3TP.js → chunk-3IOWHECM.js} +8 -1
  2. package/dist/{chunk-MZ4SW3TP.js.map → chunk-3IOWHECM.js.map} +1 -1
  3. package/dist/chunk-7ULGH74M.js +66 -0
  4. package/dist/chunk-7ULGH74M.js.map +1 -0
  5. package/dist/{chunk-YF65VYRY.js → chunk-ML5S6QNU.js} +191 -169
  6. package/dist/chunk-ML5S6QNU.js.map +1 -0
  7. package/dist/chunk-PWIJMOI4.js +202 -0
  8. package/dist/chunk-PWIJMOI4.js.map +1 -0
  9. package/dist/{chunk-XN3LSDPY.js → chunk-RPSEABY3.js} +622 -344
  10. package/dist/chunk-RPSEABY3.js.map +1 -0
  11. package/dist/chunk-RYFULE43.js +578 -0
  12. package/dist/chunk-RYFULE43.js.map +1 -0
  13. package/dist/codes/index.d.ts +2 -2
  14. package/dist/codes/index.js +3 -2
  15. package/dist/compiled-types/index.d.ts +327 -2
  16. package/dist/compiled-types/index.js +1 -1
  17. package/dist/generate/index.d.ts +3 -2
  18. package/dist/{governance-CLk_wkP9.d.ts → governance-BAsy1k2H.d.ts} +472 -513
  19. package/dist/governance-telemetry.d.ts +6 -0
  20. package/dist/governance-telemetry.js +1 -1
  21. package/dist/{index-_sxhUNqx.d.ts → index-C8bcXVav.d.ts} +448 -448
  22. package/dist/index.d.ts +9165 -1297
  23. package/dist/index.js +3041 -350
  24. package/dist/index.js.map +1 -1
  25. package/dist/manifest.d.ts +228 -0
  26. package/dist/manifest.js +24 -0
  27. package/dist/manifest.js.map +1 -0
  28. package/dist/preview/index.js +45 -1
  29. package/dist/preview/index.js.map +1 -1
  30. package/dist/preview-runtime.d.ts +1 -2
  31. package/dist/preview-runtime.js +150 -14
  32. package/dist/preview-runtime.js.map +1 -1
  33. package/dist/react-types.d.ts +1 -2
  34. package/dist/registry.d.ts +1412 -203
  35. package/dist/registry.js +30 -3
  36. package/dist/schemas/index.d.ts +1 -1
  37. package/dist/schemas/index.js +3 -2
  38. package/dist/storyAdapter.d.ts +1 -2
  39. package/dist/storyAdapter.js +11 -49
  40. package/dist/storyAdapter.js.map +1 -1
  41. package/dist/test-utils.d.ts +3 -2
  42. package/package.json +8 -2
  43. package/src/__tests__/contract-parser.test.ts +318 -277
  44. package/src/__tests__/preview-runtime-hook.test.tsx +315 -0
  45. package/src/__tests__/preview-runtime.test.tsx +30 -8
  46. package/src/__tests__/schema.test.ts +191 -14
  47. package/src/analysis-plan/analysis-plan-v1.test.ts +320 -0
  48. package/src/analysis-plan/coverage.ts +181 -0
  49. package/src/analysis-plan/digest.ts +141 -0
  50. package/src/analysis-plan/index.ts +34 -0
  51. package/src/analysis-plan/types.ts +207 -0
  52. package/src/codes/__tests__/codes.test.ts +9 -0
  53. package/src/codes/codes.ts +30 -0
  54. package/src/compiled-types/index.ts +640 -39
  55. package/src/compiled-types/parse.test.ts +145 -4
  56. package/src/component-contract.ts +95 -53
  57. package/src/composition.ts +7 -13
  58. package/src/constants.ts +3 -6
  59. package/src/contract/hash.test.ts +20 -0
  60. package/src/contract/hash.ts +66 -9
  61. package/src/contract/index.ts +24 -1
  62. package/src/contract/manifest.test.ts +94 -0
  63. package/src/contract/manifest.ts +68 -0
  64. package/src/contract/preimage.test.ts +219 -1
  65. package/src/contract/preimage.ts +326 -6
  66. package/src/contract/stamp.test.ts +3 -0
  67. package/src/contract/stamp.ts +1 -1
  68. package/src/contract-parser.ts +54 -30
  69. package/src/defineFragment.test.ts +476 -91
  70. package/src/defineFragment.ts +204 -114
  71. package/src/domain-ids.test.ts +52 -0
  72. package/src/domain-ids.ts +106 -0
  73. package/src/evaluation/evaluate.test.ts +522 -0
  74. package/src/evaluation/evaluate.ts +680 -0
  75. package/src/evaluation/evaluation-v2-receipt-v1.test.ts +760 -0
  76. package/src/evaluation/index.ts +58 -0
  77. package/src/evaluation/receipt.ts +753 -0
  78. package/src/evaluation/types.ts +406 -0
  79. package/src/facts/builders.ts +2 -0
  80. package/src/facts/compile.ts +29 -6
  81. package/src/facts/fact-index.ts +13 -3
  82. package/src/facts/fact-integrity-v1.test.ts +172 -0
  83. package/src/facts/facts.test.ts +15 -0
  84. package/src/facts/ids.ts +46 -3
  85. package/src/facts/index.ts +14 -1
  86. package/src/facts/integrity.ts +134 -0
  87. package/src/facts/types.ts +36 -0
  88. package/src/feature-plan/digest.ts +217 -0
  89. package/src/feature-plan/feature-plan-v1.test.ts +529 -0
  90. package/src/feature-plan/index.ts +65 -0
  91. package/src/feature-plan/types.ts +628 -0
  92. package/src/governance-integrity.test.ts +1 -0
  93. package/src/governance-integrity.ts +5 -3
  94. package/src/governance-telemetry.ts +8 -0
  95. package/src/governance.ts +52 -8
  96. package/src/index.ts +299 -37
  97. package/src/preview/validation.test.ts +62 -0
  98. package/src/preview/validation.ts +48 -2
  99. package/src/preview-runtime.tsx +227 -20
  100. package/src/registry-install-plan.ts +200 -109
  101. package/src/registry-shards.test.ts +263 -0
  102. package/src/registry.ts +237 -0
  103. package/src/repository-binding.test.ts +50 -0
  104. package/src/repository-binding.ts +96 -0
  105. package/src/rules/families.test.ts +36 -0
  106. package/src/rules/finding.ts +7 -2
  107. package/src/rules/index.ts +17 -1
  108. package/src/rules/rule-config.test.ts +66 -0
  109. package/src/rules/rule-config.ts +73 -0
  110. package/src/rules/rules.test.ts +26 -0
  111. package/src/rules/tokens-css-vars-must-be-defined.test.ts +51 -2
  112. package/src/rules/tokens-css-vars-must-be-defined.ts +34 -1
  113. package/src/schema.ts +293 -113
  114. package/src/schemas/index.ts +1 -1
  115. package/src/storyAdapter.test.ts +68 -12
  116. package/src/storyAdapter.ts +44 -75
  117. package/src/types.ts +258 -37
  118. package/dist/chunk-RANPUC6C.js +0 -72
  119. package/dist/chunk-RANPUC6C.js.map +0 -1
  120. package/dist/chunk-XN3LSDPY.js.map +0 -1
  121. package/dist/chunk-YF65VYRY.js.map +0 -1
  122. package/src/fragment-types.ts +0 -214
  123. package/src/react-create-element.test.ts +0 -22
  124. package/src/react-create-element.ts +0 -12
  125. package/src/storyFilters.test.ts +0 -350
  126. package/src/storyFilters.ts +0 -253
package/src/governance.ts CHANGED
@@ -133,10 +133,15 @@ const componentCapabilityRecordSchema = z.object({
133
133
  capability: z.string().min(1),
134
134
  });
135
135
 
136
+ const requiredComponentGovernanceValueSchema = z.custom<unknown>(
137
+ (value) => value !== undefined,
138
+ "Expected an explicitly present governance value"
139
+ );
140
+
136
141
  const propValueAvoidRecordSchema = z.object({
137
142
  kind: z.literal("prop.value.avoid"),
138
143
  prop: z.string().min(1),
139
- value: z.unknown(),
144
+ value: requiredComponentGovernanceValueSchema,
140
145
  because: z.string(),
141
146
  suggest: z.string().optional(),
142
147
  severity: governanceSeveritySchema,
@@ -145,10 +150,10 @@ const propValueAvoidRecordSchema = z.object({
145
150
  const propValueForbidRecordSchema = z.object({
146
151
  kind: z.literal("prop.value.forbid"),
147
152
  prop: z.string().min(1),
148
- value: z.unknown(),
153
+ value: requiredComponentGovernanceValueSchema,
149
154
  when: z.object({ path: z.string().min(1).optional() }).optional(),
150
155
  because: z.string(),
151
- fix: z.object({ replaceWith: z.unknown() }).optional(),
156
+ fix: z.object({ replaceWith: requiredComponentGovernanceValueSchema }).optional(),
152
157
  severity: governanceSeveritySchema,
153
158
  });
154
159
 
@@ -587,10 +592,15 @@ export interface ComponentGovernanceBuilder<TProps> {
587
592
  accessibility(): AccessibilityGovernanceBuilder;
588
593
  }
589
594
 
590
- export interface GovernedFragmentDefinition<
595
+ /**
596
+ * One-argument governed definition. Requires an explicit `govern` function
597
+ * and/or `governance` records — both optional keys previously let plain v2
598
+ * definitions satisfy this type (the optional-key type lie).
599
+ */
600
+ type GovernedFragmentDefinitionBase<
591
601
  TProps = unknown,
592
602
  TComponent extends FragmentComponent<TProps> = FragmentComponent<TProps>,
593
- > {
603
+ > = {
594
604
  component: TComponent;
595
605
  meta: FragmentMeta;
596
606
  guidance: FragmentGuidance;
@@ -605,9 +615,22 @@ export interface GovernedFragmentDefinition<
605
615
  };
606
616
  contract?: FragmentContract;
607
617
  _provenance?: FragmentProvenance;
608
- govern?: (g: ComponentGovernanceBuilder<TProps>) => ComponentGovernanceRecord[];
609
- governance?: ComponentGovernanceRecord[];
610
- }
618
+ };
619
+
620
+ export type GovernedFragmentDefinition<
621
+ TProps = unknown,
622
+ TComponent extends FragmentComponent<TProps> = FragmentComponent<TProps>,
623
+ > = GovernedFragmentDefinitionBase<TProps, TComponent> &
624
+ (
625
+ | {
626
+ govern: (g: ComponentGovernanceBuilder<TProps>) => ComponentGovernanceRecord[];
627
+ governance?: ComponentGovernanceRecord[];
628
+ }
629
+ | {
630
+ governance: ComponentGovernanceRecord[];
631
+ govern?: (g: ComponentGovernanceBuilder<TProps>) => ComponentGovernanceRecord[];
632
+ }
633
+ );
611
634
 
612
635
  export type ResolvedGovernedFragmentDefinition<
613
636
  TProps = unknown,
@@ -668,6 +691,27 @@ export function resolveComponentGovernance<TProps>(
668
691
  return componentGovernanceRecordsSchema.parse(records);
669
692
  }
670
693
 
694
+ /**
695
+ * Resolve the component governance records that belong in the FCID preimage.
696
+ *
697
+ * Prefer an already-resolved `governance` array (Cloud mint / compiled payloads).
698
+ * Fall back to evaluating `govern` when present. Returns `undefined` when the
699
+ * fragment carries no governance surface — callers omit the field from identity.
700
+ */
701
+ export function resolveGovernanceRecordsForIdentity(
702
+ definition: Pick<GovernedFragmentDefinition, "govern" | "governance"> | null | undefined
703
+ ): ComponentGovernanceRecord[] | undefined {
704
+ if (!definition) return undefined;
705
+ if (Array.isArray(definition.governance)) {
706
+ return componentGovernanceRecordsSchema.parse(definition.governance);
707
+ }
708
+ if (typeof definition.govern === "function") {
709
+ const builder = createComponentGovernanceBuilder();
710
+ return componentGovernanceRecordsSchema.parse(definition.govern(builder));
711
+ }
712
+ return undefined;
713
+ }
714
+
671
715
  export function normalizeGovernanceConfig<TConfig extends { govern?: GovernanceConfig }>(
672
716
  config: TConfig
673
717
  ): TConfig {
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  // Brand and default constants
7
- export { BRAND, DEFAULTS } from "./constants.js";
7
+ export { BRAND, DEFAULTS, FRAGMENT_V3_SCHEMA_URL } from "./constants.js";
8
8
  export type { Brand, Defaults } from "./constants.js";
9
9
 
10
10
  export {
@@ -167,14 +167,20 @@ export type {
167
167
  FragmentsConfig,
168
168
  SnippetPolicyConfig,
169
169
  RegistryOptions,
170
+ FragmentIndex,
171
+ FragmentRegistry,
172
+ RegistryComponentEntry,
173
+ RegistryPropEntry,
174
+ FragmentContextOptions,
170
175
  CompiledFragment,
176
+ CompiledFragmentDesign,
177
+ CompiledFragmentMatrix,
178
+ CompiledFragmentPreview,
171
179
  CompiledFragmentsFile,
172
180
  ObservedComponentUsage,
173
181
  ObservedUsageProp,
174
182
  BlockDefinition,
175
183
  CompiledBlock,
176
- RecipeDefinition, // @deprecated - use BlockDefinition
177
- CompiledRecipe, // @deprecated - use CompiledBlock
178
184
  // Contract and provenance types
179
185
  FragmentContract,
180
186
  FragmentGenerated,
@@ -186,6 +192,18 @@ export type {
186
192
  CompositionMetadata,
187
193
  FragmentProvenance,
188
194
  FragmentDefinitionV2,
195
+ // v3 types (arity-discriminated)
196
+ FragmentMetaV3,
197
+ FragmentStateV3,
198
+ FragmentDontExampleV3,
199
+ FragmentGuidanceV3,
200
+ FragmentMatrixV3,
201
+ FragmentPreviewV3,
202
+ FragmentDesignV3,
203
+ PropAnnotation,
204
+ FragmentAnnotationsV3,
205
+ FragmentDefinitionV3Body,
206
+ FragmentDefinitionV3,
189
207
  // Screenshot types
190
208
  ScreenshotConfig,
191
209
  ServiceConfig,
@@ -207,8 +225,6 @@ export type {
207
225
  FigmaInstanceMapping,
208
226
  FigmaChildrenMapping,
209
227
  FigmaTextContentMapping,
210
- // Storybook filter configuration
211
- StorybookFilterConfig,
212
228
  // Token configuration
213
229
  AppConfig,
214
230
  DesignSystemConfig,
@@ -284,12 +300,18 @@ export type {
284
300
  // Fragments Registry Protocol contracts
285
301
  export {
286
302
  REGISTRY_ARTIFACT_SCHEMA_VERSION,
303
+ REGISTRY_INDEX_SCHEMA_VERSION,
287
304
  REGISTRY_INSTALL_RECEIPT_SCHEMA_VERSION,
288
305
  REGISTRY_MANIFEST_SCHEMA_VERSION,
306
+ REGISTRY_POINTER_SCHEMA_VERSION,
307
+ REGISTRY_SHARD_SCHEMA_VERSION,
308
+ assembleRegistryArtifact,
289
309
  assertValidRegistryArtifact,
290
310
  buildRegistryArtifact,
291
311
  buildRegistryFile,
312
+ buildRegistryPointer,
292
313
  computeRegistryHash,
314
+ defaultRegistryShardPath,
293
315
  finalizeRegistryManifest,
294
316
  hashRegistryFileContent,
295
317
  registryArtifactDigest,
@@ -303,14 +325,21 @@ export {
303
325
  registryFileRoleSchema,
304
326
  registryFileSchema,
305
327
  registryFileSize,
328
+ registryIndexSchema,
306
329
  registryInstallProfileSchema,
307
330
  registryInstallReceiptComponentSchema,
308
331
  registryInstallReceiptFileSchema,
309
332
  registryInstallReceiptSchema,
310
333
  registryManifestCanonicalPreimage,
311
334
  registryManifestDraftSchema,
335
+ registryManifestFileMetadata,
336
+ registryManifestFilePaths,
312
337
  registryManifestSchema,
338
+ registryPointerSchema,
339
+ registryShardSchema,
340
+ registryShardsForPaths,
313
341
  registrySourceSchema,
342
+ shardRegistryArtifact,
314
343
  } from "./registry.js";
315
344
  export type {
316
345
  RegistryArtifact,
@@ -324,13 +353,17 @@ export type {
324
353
  RegistryFileContent,
325
354
  RegistryFileInput,
326
355
  RegistryFileRole,
356
+ RegistryIndex,
327
357
  RegistryInstallProfile,
328
358
  RegistryInstallReceipt,
329
359
  RegistryInstallReceiptComponent,
330
360
  RegistryInstallReceiptFile,
331
361
  RegistryManifest,
332
362
  RegistryManifestDraft,
363
+ RegistryPointer,
364
+ RegistryShard,
333
365
  RegistrySource,
366
+ ShardedRegistryArtifact,
334
367
  } from "./registry.js";
335
368
 
336
369
  export {
@@ -338,13 +371,21 @@ export {
338
371
  buildRegistryInstallPlan,
339
372
  buildRegistryInstallReceipt,
340
373
  collectRegistryInstallDependencies,
374
+ expandRegistryComponentClosure,
341
375
  normalizeRegistryRepoPath,
342
- selectedRegistryComponentNames,
376
+ resolveRegistryComponentId,
377
+ resolveRegistryInstallSelection,
378
+ resolveRegistryInstallSources,
343
379
  sourceToRegistryTargetPath,
344
380
  } from "./registry-install-plan.js";
345
381
  export type {
346
382
  BuildRegistryInstallPlanInput,
347
383
  RegistryInstallPlan,
384
+ RegistryInstallSelection,
385
+ RegistryInstallSelectionInput,
386
+ RegistryInstallSourceFile,
387
+ RegistryInstallSources,
388
+ RegistryInstallSourcesInput,
348
389
  RegistryWritePlan,
349
390
  } from "./registry-install-plan.js";
350
391
 
@@ -427,10 +468,10 @@ export {
427
468
  figmaPropMappingSchema,
428
469
  // Contract and provenance schemas
429
470
  fragmentContractSchema,
471
+ fragmentSourceValues,
430
472
  fragmentGeneratedSchema,
431
473
  fragmentBanSchema,
432
474
  blockDefinitionSchema,
433
- recipeDefinitionSchema, // @deprecated - use blockDefinitionSchema
434
475
  // AI metadata schema
435
476
  aiMetadataSchema,
436
477
  // v2 schemas
@@ -438,6 +479,18 @@ export {
438
479
  fragmentProvenanceSchema,
439
480
  fragmentDefinitionV2Schema,
440
481
  governedFragmentDefinitionSchema,
482
+ // v3 schemas
483
+ fragmentMetaV3Schema,
484
+ fragmentStateV3Schema,
485
+ fragmentDontExampleV3Schema,
486
+ fragmentGuidanceV3Schema,
487
+ fragmentMatrixV3Schema,
488
+ fragmentPreviewV3Schema,
489
+ fragmentDesignV3Schema,
490
+ propAnnotationSchema,
491
+ fragmentAnnotationsV3Schema,
492
+ fragmentDefinitionV3BodySchema,
493
+ fragmentDefinitionV3Schema,
441
494
  } from "./schema.js";
442
495
 
443
496
  // Main API
@@ -448,8 +501,6 @@ export {
448
501
  normalizeToV1,
449
502
  defineBlock,
450
503
  compileBlock,
451
- defineRecipe,
452
- compileRecipe,
453
504
  } from "./defineFragment.js";
454
505
  export type { InferProps } from "./defineFragment.js";
455
506
 
@@ -467,6 +518,8 @@ export {
467
518
  isPresetSourcedRule,
468
519
  markPresetSourcedRules,
469
520
  normalizeGovernanceConfig,
521
+ resolveComponentGovernance,
522
+ resolveGovernanceRecordsForIdentity,
470
523
  scaleGovernanceRecordSchema,
471
524
  } from "./governance.js";
472
525
  export type {
@@ -501,15 +554,6 @@ export {
501
554
  } from "./policy-exclude.js";
502
555
  export type { PolicyExclude, PolicyExcludeInput } from "./policy-exclude.js";
503
556
 
504
- // Storybook adapter filtering
505
- export {
506
- checkStoryExclusion,
507
- detectSubComponentPaths,
508
- isForceIncluded,
509
- isConfigExcluded,
510
- } from "./storyFilters.js";
511
- export type { ExclusionReason, ExclusionResult, CheckStoryExclusionOpts } from "./storyFilters.js";
512
-
513
557
  // Context generation for AI agents
514
558
  export { generateContext } from "./context.js";
515
559
  export type { ContextOptions, ContextResult } from "./context.js";
@@ -517,23 +561,6 @@ export type { ContextOptions, ContextResult } from "./context.js";
517
561
  // Figma property mapping DSL
518
562
  export { figma, isFigmaPropMapping, resolveFigmaMapping } from "./figma.js";
519
563
 
520
- // Fragment JSON types (for .fragment.json files)
521
- export type {
522
- Fragment,
523
- FragmentFigma,
524
- FragmentUsage as FragmentJsonUsage,
525
- FragmentDoNotItem,
526
- FragmentPattern,
527
- FragmentAccessibility,
528
- FragmentRelated,
529
- FragmentMeta as FragmentJsonMeta,
530
- FragmentIndex,
531
- FragmentRegistry,
532
- RegistryComponentEntry,
533
- RegistryPropEntry,
534
- FragmentContextOptions,
535
- } from "./fragment-types.js";
536
-
537
564
  // Token parsing and token-domain helpers
538
565
  export {
539
566
  calculateDeltaE,
@@ -649,6 +676,12 @@ export {
649
676
  ruleA11yRequiredAccessibleName,
650
677
  ruleA11yStandard,
651
678
  } from "./rules/index.js";
679
+ export {
680
+ capConfiguredSeverity,
681
+ configuredFindingSeverity,
682
+ readRuleConfig,
683
+ type RuleConfigView,
684
+ } from "./rules/rule-config.js";
652
685
  export { indexComponentIdentityUsage, type ComponentIdentityUsage } from "./identity/usage.js";
653
686
  export { nearestSignedScaleValue } from "./rules/utils.js";
654
687
  export {
@@ -705,7 +738,11 @@ export type { RuleTier, PresetRuleState } from "./rules/index.js";
705
738
  // Contract-site health denominator: how many style-declaration sites the
706
739
  // token-vocabulary rule actually judged. Consumed by the CLI's per-scan
707
740
  // `contract-site-health:v1` metric next to the identity usage index.
708
- export { contractTokenReferenceCensus } from "./rules/index.js";
741
+ export {
742
+ contractTokenReferenceCensus,
743
+ EMPTY_VOCABULARY_MESSAGE,
744
+ emptyVocabularyConfigFile,
745
+ } from "./rules/index.js";
709
746
  export type { ContractTokenReferenceCensus } from "./rules/index.js";
710
747
 
711
748
  // Rule families — the ONE expansion of a broad `govern.rules` id (`tokens/hardcoded-values`)
@@ -826,24 +863,39 @@ export {
826
863
  } from "./facts/index.js";
827
864
  export type { SupersededImportPathPreference } from "./facts/index.js";
828
865
  export {
829
- canonicalPreimage,
830
866
  AGENT_CONTEXT_RELATIVE_PATH,
867
+ artifactContentHash,
831
868
  CATALOG_FIXTURE_A_FCID,
832
869
  catalogFixtureA,
833
870
  catalogFixtureAContractPayload,
834
871
  catalogFixtureATokensDtcg,
872
+ canonicalPreimage,
873
+ CONTRACT_DISPLAY_ONLY_FIELDS,
835
874
  CONTRACT_DOMAINS,
875
+ CONTRACT_ENFORCEMENT_FIELDS,
836
876
  CONTRACT_PREIMAGE_CAPABILITY_HEADER,
837
877
  CONTRACT_PREIMAGE_SCHEMA,
878
+ ContractCatalogValidationError,
838
879
  contractComponentsFromFragments,
839
880
  contractHash,
840
881
  contractPolicyFromGovernanceConfig,
882
+ deriveArtifactId,
841
883
  diffContractDomains,
842
884
  formatStampHeader,
843
885
  formatStampPin,
844
886
  formatStampVersionHash,
887
+ FRAGMENTS_MANIFEST_FILENAME,
888
+ FRAGMENTS_MANIFEST_SCHEMA_VERSION,
889
+ FRAGMENTS_MANIFEST_TOKEN_RULE,
890
+ fragmentsManifestFcid,
891
+ fragmentsManifestGrammarSchema,
892
+ fragmentsManifestPatternSchema,
893
+ fragmentsManifestPrimitiveSchema,
894
+ fragmentsManifestSchema,
845
895
  parseContractStamp,
896
+ parseFragmentsManifest,
846
897
  projectContractPreimage,
898
+ projectEnforcementContract,
847
899
  serializeContractStamp,
848
900
  sha256Hex,
849
901
  verifiedContractPreimageFromPin,
@@ -866,6 +918,7 @@ export type {
866
918
  ContractCatalogInput,
867
919
  ContractComponentInput,
868
920
  ContractDomain,
921
+ ContractEnforcementField,
869
922
  ContractIdentityPin,
870
923
  ContractPolicyInput,
871
924
  ContractPreimage,
@@ -874,6 +927,10 @@ export type {
874
927
  ContractStampRecord,
875
928
  ContractTokenInput,
876
929
  ContractWaiverInput,
930
+ FragmentsManifest,
931
+ FragmentsManifestGrammar,
932
+ FragmentsManifestPattern,
933
+ FragmentsManifestPrimitive,
877
934
  } from "./contract/index.js";
878
935
  export {
879
936
  governanceConfigWithLocalCanonical,
@@ -920,6 +977,9 @@ export type {
920
977
  FactLocation,
921
978
  FactEvidence,
922
979
  CanonicalCandidateFact,
980
+ CanonicalFactConflictV1,
981
+ CanonicalFactConflictValueV1,
982
+ CanonicalFactIntegrityV1,
923
983
  CanonicalMappingFact,
924
984
  CanonicalReplacementFact,
925
985
  ComponentLevelFact,
@@ -978,8 +1038,210 @@ export type {
978
1038
  SuppressionDirectiveFact,
979
1039
  ComponentFactInput,
980
1040
  } from "./facts/index.js";
1041
+ export {
1042
+ CANONICAL_FACT_MAX_CONFLICTS_V1,
1043
+ CANONICAL_FACT_MAX_PROVENANCE_PER_VALUE_V1,
1044
+ CANONICAL_FACT_MAX_VALUES_PER_CONFLICT_V1,
1045
+ canonicalFactConflictV1Schema,
1046
+ canonicalFactConflictValueV1Schema,
1047
+ canonicalFactIntegrityV1Schema,
1048
+ normalizeCanonicalFactIntegrityV1,
1049
+ } from "./facts/index.js";
1050
+
1051
+ // V1 authority and analysis contracts. These remain browser-safe and have no
1052
+ // Cloud, provider, engine, model, or Node-only dependency.
1053
+ export {
1054
+ analysisPlanIdFromDigest,
1055
+ analysisPlanIdSchema,
1056
+ analysisPlanIdStringSchema,
1057
+ digestHexSchema,
1058
+ digestHexStringSchema,
1059
+ evaluationReceiptIdFromDigest,
1060
+ mintEvaluationReceiptId,
1061
+ evaluationReceiptIdSchema,
1062
+ evaluationReceiptIdStringSchema,
1063
+ featurePlanIdFromEntropy,
1064
+ featurePlanIdSchema,
1065
+ featurePlanIdStringSchema,
1066
+ featureRevisionIdFromDigest,
1067
+ featureRevisionIdSchema,
1068
+ featureRevisionIdStringSchema,
1069
+ parseAnalysisPlanId,
1070
+ parseDigestHex,
1071
+ parseEvaluationReceiptId,
1072
+ parseFeaturePlanId,
1073
+ parseFeatureRevisionId,
1074
+ } from "./domain-ids.js";
1075
+ export type {
1076
+ AnalysisPlanId,
1077
+ DigestHex,
1078
+ EvaluationReceiptId,
1079
+ FeaturePlanId,
1080
+ FeatureRevisionId,
1081
+ } from "./domain-ids.js";
1082
+ export {
1083
+ PROVIDER_ID_MAX_BYTES_V1,
1084
+ REPOSITORY_BINDING_ID_MAX_BYTES_V1,
1085
+ normalizeRepositoryBindingKeyV1,
1086
+ repositoryBindingDigestV1,
1087
+ repositoryBindingKeyV1Schema,
1088
+ } from "./repository-binding.js";
1089
+ export type { RepositoryBindingKeyV1, RepositoryBindingKeyV1Input } from "./repository-binding.js";
1090
+ export {
1091
+ ANALYSIS_LIMIT_CEILINGS_V1,
1092
+ ANALYSIS_PLAN_MAX_CAPABILITIES_V1,
1093
+ ANALYSIS_PLAN_MAX_DIALECTS_PER_REGION_V1,
1094
+ ANALYSIS_PLAN_MAX_REGIONS_V1,
1095
+ CoverageValidationErrorV1,
1096
+ analysisLimitsV1Schema,
1097
+ analysisObligationsDigestV1,
1098
+ analysisPlanDigestV1,
1099
+ analysisPlanInputV1Schema,
1100
+ analysisPlanV1Schema,
1101
+ analysisRegionV1Schema,
1102
+ buildAnalysisPlanV1,
1103
+ coverageArtifactDigestV1,
1104
+ coverageRegionV1Schema,
1105
+ coverageStateV1Schema,
1106
+ coverageSummaryV1Schema,
1107
+ deriveCoverageSummaryV1,
1108
+ normalizeAnalysisPlanInputV1,
1109
+ parseAnalysisPlanV1,
1110
+ } from "./analysis-plan/index.js";
1111
+ export type {
1112
+ AnalysisLimitsV1,
1113
+ AnalysisPlanInputV1,
1114
+ AnalysisPlanV1,
1115
+ AnalysisRegionV1,
1116
+ CoverageRegionV1,
1117
+ CoverageStateV1,
1118
+ CoverageSummaryV1,
1119
+ } from "./analysis-plan/index.js";
1120
+
1121
+ export {
1122
+ AGENT_FEATURE_CONTEXT_MAX_BYTES_V1,
1123
+ FEATURE_PLAN_MAX_ACCEPTANCE_ITEMS_V1,
1124
+ FEATURE_PLAN_MAX_DECISIONS_V1,
1125
+ FEATURE_PLAN_MAX_EVIDENCE_REFS_V1,
1126
+ FEATURE_PLAN_MAX_GAPS_V1,
1127
+ FEATURE_PLAN_MAX_SCENARIOS_V1,
1128
+ FEATURE_PLAN_MAX_TEXT_BYTES_V1,
1129
+ FEATURE_PLAN_MAX_USES_PER_KIND_V1,
1130
+ agentFeatureContextV1Schema,
1131
+ approvedFeatureManifestInputV1Schema,
1132
+ approvedFeatureManifestRevisionDigestV1,
1133
+ approvedFeatureManifestV1Schema,
1134
+ buildApprovedFeatureManifestV1,
1135
+ buildFeatureProposalV1,
1136
+ capabilityGapV1Schema,
1137
+ componentUseDecisionV1Schema,
1138
+ decisionRequestV1Schema,
1139
+ decisionResolutionV1Schema,
1140
+ evidenceRefV1Schema,
1141
+ featureAcceptanceItemV1Schema,
1142
+ featurePinsV1Schema,
1143
+ featureProposalInputV1Schema,
1144
+ featureProposalRevisionDigestV1,
1145
+ featureProposalV1Schema,
1146
+ gapDispositionV1Schema,
1147
+ layoutConcernV1Schema,
1148
+ layoutOwnershipV1Schema,
1149
+ normalizeApprovedFeatureManifestInputV1,
1150
+ normalizeFeatureProposalInputV1,
1151
+ parseAgentFeatureContextV1,
1152
+ parseApprovedFeatureManifestV1,
1153
+ parseFeatureProposalV1,
1154
+ patternStatusV1Schema,
1155
+ patternUseDecisionV1Schema,
1156
+ placementDecisionV1Schema,
1157
+ responsiveDecisionV1Schema,
1158
+ scenarioRequirementV1Schema,
1159
+ tokenUseDecisionV1Schema,
1160
+ } from "./feature-plan/index.js";
1161
+ export type {
1162
+ AgentFeatureContextV1,
1163
+ ApprovedFeatureManifestInputV1,
1164
+ ApprovedFeatureManifestV1,
1165
+ CapabilityGapV1,
1166
+ ComponentUseDecisionV1,
1167
+ DecisionRequestV1,
1168
+ DecisionResolutionV1,
1169
+ EvidenceRefV1,
1170
+ FeatureAcceptanceItemV1,
1171
+ FeaturePinsV1,
1172
+ FeatureProposalInputV1,
1173
+ FeatureProposalV1,
1174
+ GapDispositionV1,
1175
+ LayoutConcernV1,
1176
+ LayoutOwnershipV1,
1177
+ PatternStatusV1,
1178
+ PatternUseDecisionV1,
1179
+ PlacementDecisionV1,
1180
+ ResponsiveDecisionV1,
1181
+ ScenarioRequirementV1,
1182
+ TokenUseDecisionV1,
1183
+ } from "./feature-plan/index.js";
981
1184
 
982
1185
  // Topology — map file paths to product areas (area-scoped governance).
983
1186
  // Also available at the `@usefragments/core/topology` subpath.
984
1187
  export { resolveArea } from "./topology/index.js";
985
1188
  export type { Area, AreaCriticality, AreaMatch, Topology } from "./topology/index.js";
1189
+
1190
+ // Evaluation Module — the pure governance kernel (architecture spec §§1–2):
1191
+ // deterministic verdicts with kernel-owned FCID verification, four-state
1192
+ // finding classification, and three-state trust facts. Shipped in shadow mode
1193
+ // alongside the legacy CLI/Cloud verdict machines.
1194
+ export {
1195
+ EVALUATION_MAX_FINDINGS_V2,
1196
+ EVALUATION_MAX_MAP_ENTRIES_V2,
1197
+ EVALUATION_MAX_POLICY_RULES_V2,
1198
+ EVALUATION_MAX_REASON_CODES_V2,
1199
+ EVALUATION_MAX_WAIVERS_V2,
1200
+ EVALUATION_MAX_WAIVER_MATCHES_V2,
1201
+ EVALUATION_RECEIPT_STRING_MAX_BYTES_V1,
1202
+ EVALUATOR_VERSION,
1203
+ EVALUATOR_VERSION_V2,
1204
+ effectiveEvaluationWaiverV2Schema,
1205
+ evaluate,
1206
+ evaluationInputV2Schema,
1207
+ evaluationReceiptDigestV1,
1208
+ evaluationReceiptMintInputV1Schema,
1209
+ evaluationReceiptV1Schema,
1210
+ evaluationResultV2Schema,
1211
+ parseEvaluationReceiptV1,
1212
+ providerProofDigestV1,
1213
+ providerProofV1Schema,
1214
+ } from "./evaluation/index.js";
1215
+ export type {
1216
+ EffectivePolicy,
1217
+ EffectiveRulePolicy,
1218
+ EvaluatedFinding,
1219
+ EvaluationBaseline,
1220
+ EvaluationContractInput,
1221
+ EvaluationEvidence,
1222
+ EvaluationFindingInput,
1223
+ EvaluationFindingState,
1224
+ EvaluationInput,
1225
+ EvaluationIntegrityInput,
1226
+ EvaluationMappingTrust,
1227
+ EvaluationReason,
1228
+ EvaluationResult,
1229
+ EvaluationScope,
1230
+ EvaluationSourceTrust,
1231
+ EvaluationTrust,
1232
+ EvaluationVerdict,
1233
+ EvaluationWaiver,
1234
+ EffectiveEvaluationWaiverV2,
1235
+ EvaluationAuthorityV1,
1236
+ EvaluationEvidenceTrustV1,
1237
+ EvaluationInputV2,
1238
+ EvaluationIntegrityInputV2,
1239
+ EvaluationReasonV2,
1240
+ EvaluationReceiptMintInputV1,
1241
+ EvaluationReceiptSemanticV1,
1242
+ EvaluationReceiptV1,
1243
+ EvaluationResultV2,
1244
+ FindingV2,
1245
+ ProviderProofSemanticV1,
1246
+ ProviderProofV1,
1247
+ } from "./evaluation/index.js";
@@ -128,6 +128,68 @@ describe("@usefragments/core/preview artifact validation", () => {
128
128
  ).toThrow(/unsupported source "storybook"/);
129
129
  });
130
130
 
131
+ it("requires component map keys to match unique normalized component keys", () => {
132
+ const mismatched = {
133
+ ...manifest,
134
+ components: {
135
+ RenamedButton: {
136
+ ...manifest.components.Button,
137
+ componentKey: "Button",
138
+ },
139
+ },
140
+ };
141
+ const duplicated = {
142
+ ...manifest,
143
+ components: {
144
+ Button: manifest.components.Button,
145
+ " Button ": {
146
+ ...manifest.components.Button,
147
+ componentKey: " Button ",
148
+ },
149
+ },
150
+ };
151
+
152
+ expect(() =>
153
+ definePreviewArtifactManifest(mismatched as unknown as PreviewArtifactManifest)
154
+ ).toThrow(/componentKey must match its components map key/);
155
+ expect(() =>
156
+ definePreviewArtifactManifest(duplicated as unknown as PreviewArtifactManifest)
157
+ ).toThrow(/duplicate normalized componentKey/);
158
+ });
159
+
160
+ it("requires supported previewability values and unique non-empty variant ids", () => {
161
+ const invalid = {
162
+ ...manifest,
163
+ components: {
164
+ Button: {
165
+ ...manifest.components.Button,
166
+ previewability: "unknown",
167
+ variants: [
168
+ ...manifest.components.Button.variants,
169
+ {
170
+ ...manifest.components.Button.variants[0],
171
+ id: " default ",
172
+ },
173
+ {
174
+ ...manifest.components.Button.variants[0],
175
+ id: " ",
176
+ },
177
+ ],
178
+ },
179
+ },
180
+ };
181
+
182
+ expect(() =>
183
+ definePreviewArtifactManifest(invalid as unknown as PreviewArtifactManifest)
184
+ ).toThrow(/previewability must be one of/);
185
+ expect(() =>
186
+ definePreviewArtifactManifest(invalid as unknown as PreviewArtifactManifest)
187
+ ).toThrow(/variants.1.id must be unique within the component/);
188
+ expect(() =>
189
+ definePreviewArtifactManifest(invalid as unknown as PreviewArtifactManifest)
190
+ ).toThrow(/variants.2.id must be a non-empty string/);
191
+ });
192
+
131
193
  it("rejects malformed design comparison evidence", () => {
132
194
  const invalid = {
133
195
  ...manifest,