@hyperscale0/udl 2.0.4 → 2.1.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 (58) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +15 -1
  3. package/conformance/invalid/call-binds-results.expected.json +10 -0
  4. package/conformance/invalid/call-binds-results.udl +314 -0
  5. package/conformance/invalid/call-unknown-action.expected.json +10 -0
  6. package/conformance/invalid/call-unknown-action.udl +314 -0
  7. package/conformance/invalid/leaf-effect-mismatch.expected.json +10 -0
  8. package/conformance/invalid/leaf-effect-mismatch.udl +314 -0
  9. package/conformance/invalid/piece-plan-without-partition.expected.json +10 -0
  10. package/conformance/invalid/piece-plan-without-partition.udl +305 -0
  11. package/conformance/invalid/private-action-independent-approval.expected.json +10 -0
  12. package/conformance/invalid/private-action-independent-approval.udl +314 -0
  13. package/conformance/invalid/unfund-order-not-reversed.expected.json +10 -0
  14. package/conformance/invalid/unfund-order-not-reversed.udl +314 -0
  15. package/conformance/valid/piece-plan-calls.expected.json +6 -0
  16. package/conformance/valid/piece-plan-calls.udl +314 -0
  17. package/dist/diagnostics.d.ts +36 -0
  18. package/dist/diagnostics.d.ts.map +1 -1
  19. package/dist/diagnostics.js +36 -0
  20. package/dist/diagnostics.js.map +1 -1
  21. package/dist/effects.d.ts +24 -3
  22. package/dist/effects.d.ts.map +1 -1
  23. package/dist/effects.js +906 -8
  24. package/dist/effects.js.map +1 -1
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/limits.d.ts +2 -0
  30. package/dist/limits.d.ts.map +1 -1
  31. package/dist/limits.js +2 -0
  32. package/dist/limits.js.map +1 -1
  33. package/dist/schema.d.ts +594 -11
  34. package/dist/schema.d.ts.map +1 -1
  35. package/dist/schema.js +111 -1
  36. package/dist/schema.js.map +1 -1
  37. package/dist/validation.d.ts.map +1 -1
  38. package/dist/validation.js +289 -4
  39. package/dist/validation.js.map +1 -1
  40. package/docs/assets/brand/manifest.json +30 -0
  41. package/docs/assets/brand/udl-horizontal-white.svg +1 -0
  42. package/docs/assets/brand/udl-horizontal.svg +1 -0
  43. package/docs/assets/brand/udl-stacked-white.svg +1 -0
  44. package/docs/assets/brand/udl-stacked.svg +1 -0
  45. package/docs/assets/udl.svg +7 -14
  46. package/docs/llms-full.txt +199 -32
  47. package/docs/llms.txt +1 -1
  48. package/docs/reference/clauses.md +162 -1
  49. package/docs/reference/cli.md +1 -1
  50. package/docs/reference/diagnostics.md +38 -32
  51. package/package.json +2 -2
  52. package/spec/udl.schema.json +321 -1
  53. package/src/diagnostics.ts +36 -0
  54. package/src/effects.ts +1603 -9
  55. package/src/index.ts +15 -0
  56. package/src/limits.ts +2 -0
  57. package/src/schema.ts +149 -2
  58. package/src/validation.ts +469 -4
package/src/index.ts CHANGED
@@ -16,9 +16,13 @@ export {
16
16
  export { fixedIsoDurationMs } from "./duration.js";
17
17
  export {
18
18
  deriveUdlActionEffects,
19
+ resolveUdlActionPlans,
19
20
  movementClass,
20
21
  udlEffectKinds,
21
22
  type DerivedUdlEffects,
23
+ type ResolvedActionPlan,
24
+ type ResolvedActionPlanLeaf,
25
+ type ResolvedActionPlansResult,
22
26
  type UdlEffectKind,
23
27
  type UdlMovementClass,
24
28
  } from "./effects.js";
@@ -54,6 +58,17 @@ export {
54
58
  udlPublicActionSchema,
55
59
  } from "./schema.js";
56
60
  export type {
61
+ UdlPiece,
62
+ UdlPiecePlan,
63
+ UdlPieceStage,
64
+ UdlPieceStageStage,
65
+ UdlCall,
66
+ UdlPrivateParameterKind,
67
+ UdlPrivateParameter,
68
+ UdlPrivateLeaf,
69
+ UdlPrivateAction,
70
+ UdlActionLibraryModule,
71
+ UdlActionLibrary,
57
72
  UdlAggregate,
58
73
  UdlAggregateCondition,
59
74
  UdlBinding,
package/src/limits.ts CHANGED
@@ -7,6 +7,8 @@ export const UDL_LIMITS = Object.freeze({
7
7
  financeTransitions: 64,
8
8
  financeActions: 64,
9
9
  financeWork: 4_096,
10
+ maxActionExpansion: 256,
11
+ maxActionLeaves: 256,
10
12
  maxDepth: 24,
11
13
  maxKeyLength: 128,
12
14
  // The 33-instrument catalog includes its executable authored journeys.
package/src/schema.ts CHANGED
@@ -1,7 +1,17 @@
1
1
  import { z } from "zod";
2
2
 
3
3
  import { udlCheckEvidenceProfiles } from "./check-profiles.js";
4
- import type { UdlEffectKind } from "./effects.js";
4
+
5
+ export const udlEffectKinds = [
6
+ "decides",
7
+ "holds",
8
+ "moves",
9
+ "notifies",
10
+ "reads",
11
+ "schedules",
12
+ ] as const;
13
+
14
+ export type UdlEffectKind = (typeof udlEffectKinds)[number];
5
15
 
6
16
  export const UDL_FORMAT_VERSION = 1 as const;
7
17
 
@@ -639,8 +649,98 @@ const udlEffectsShape = {
639
649
  } satisfies Record<UdlEffectKind, z.ZodType>;
640
650
  const udlEffectsSchema = z.strictObject(udlEffectsShape);
641
651
 
652
+ export const udlPieceSchema = z.strictObject({
653
+ amount: udlFieldNameSchema,
654
+ id: udlSnakeCaseSchema,
655
+ refund_to: udlFieldNameSchema,
656
+ release_to: udlFieldNameSchema,
657
+ });
658
+
659
+ export const udlPiecePlanSchema = z.strictObject({
660
+ fund_order: z.array(udlSnakeCaseSchema),
661
+ id: udlSnakeCaseSchema,
662
+ pieces: z.array(udlPieceSchema).min(1).max(256),
663
+ refund_order: z.array(udlSnakeCaseSchema),
664
+ release_order: z.array(udlSnakeCaseSchema),
665
+ total: udlFieldNameSchema,
666
+ unfund_order: z.array(udlSnakeCaseSchema),
667
+ });
668
+
669
+ export const udlPieceStageStageSchema = z.enum([
670
+ "fund",
671
+ "release",
672
+ "refund",
673
+ "unfund",
674
+ ]);
675
+
676
+ export const udlPieceStageSchema = z.strictObject({
677
+ plan: udlSnakeCaseSchema,
678
+ stage: udlPieceStageStageSchema,
679
+ });
680
+
681
+ export const udlCallSchema = z.strictObject({
682
+ action: z
683
+ .string()
684
+ .regex(
685
+ /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_]*$/,
686
+ "must name an action as library_id.action_id",
687
+ ),
688
+ bind: z.record(udlFieldNameSchema, z.string()),
689
+ id: udlSnakeCaseSchema,
690
+ });
691
+
692
+ export const udlPrivateParameterKindSchema = z.enum([
693
+ "account",
694
+ "instance",
695
+ "money",
696
+ "piece",
697
+ "text",
698
+ ]);
699
+
700
+ export const udlPrivateParameterSchema = z.strictObject({
701
+ currency: z.string().optional(),
702
+ kind: udlPrivateParameterKindSchema,
703
+ });
704
+
705
+ export const udlPrivateLeafSchema = z.strictObject({
706
+ bind: z.record(fieldPathSchema, z.string()),
707
+ capture: stringMapSchema.optional(),
708
+ effects: z
709
+ .array(
710
+ z.strictObject({
711
+ kind: z.enum(udlEffectKinds),
712
+ signature: nonEmptyTextSchema,
713
+ }),
714
+ )
715
+ .min(1, "must declare at least one effect"),
716
+ evidence: nonEmptyTextSchema,
717
+ id: udlSnakeCaseSchema,
718
+ operation: udlKernelOperationSchema,
719
+ });
720
+
721
+ export const udlPrivateActionSchema = z.strictObject({
722
+ approval: z.enum(["inherit", "independent"]),
723
+ calls: z.array(udlCallSchema),
724
+ leaves: z.array(udlPrivateLeafSchema),
725
+ order: z.array(udlSnakeCaseSchema),
726
+ parameters: z.record(udlFieldNameSchema, udlPrivateParameterSchema),
727
+ principal: z.enum(["api_key", "user_session"]),
728
+ recovery: z.enum(["local", "external"]),
729
+ });
730
+
731
+ export const udlActionLibraryModuleSchema = z.strictObject({
732
+ actionOrder: z.array(udlSnakeCaseSchema),
733
+ actions: z.record(udlSnakeCaseSchema, udlPrivateActionSchema),
734
+ });
735
+
736
+ export const udlActionLibrarySchema = z.record(
737
+ udlSnakeCaseSchema,
738
+ udlActionLibraryModuleSchema,
739
+ );
740
+
642
741
  const udlActionShape = {
643
742
  agentDescription: udlAgentDescriptionSchema.optional(),
743
+ calls: z.array(udlCallSchema).min(1).optional(),
644
744
  captureInput: z.record(udlFieldNameSchema, udlFieldNameSchema).optional(),
645
745
  /** Names the quoting action whose offer this action spends. */
646
746
  commit: udlActionNameSchema.optional(),
@@ -657,6 +757,7 @@ const udlActionShape = {
657
757
  input: jsonObjectSchema.optional(),
658
758
  moves: z.array(udlMoveSchema).default([]),
659
759
  payout: udlPayoutSchema.optional(),
760
+ pieceStage: udlPieceStageSchema.optional(),
660
761
  port: udlPortSchema.optional(),
661
762
  quote: udlQuoteSchema.optional(),
662
763
  publicAction: udlPublicActionSchema
@@ -675,7 +776,7 @@ const udlActionShape = {
675
776
  sandboxFailurePoint: z.enum(["funding", "release"]).optional(),
676
777
  setsAt: udlSetsAtSchema.optional(),
677
778
  signedSum: udlSignedSumSchema.optional(),
678
- steps: z.array(udlStepSchema),
779
+ steps: z.array(udlStepSchema).default([]),
679
780
  summary: nonEmptyTextSchema,
680
781
  updates: z.array(udlFieldNameSchema).min(1).optional(),
681
782
  };
@@ -709,6 +810,7 @@ const udlAggregateSchema = z.union([
709
810
  ]);
710
811
 
711
812
  const udlInstrumentShape = {
813
+ actionLibrary: udlActionLibrarySchema.optional(),
712
814
  actionOrder: z.array(udlActionNameSchema).min(1),
713
815
  agentDescription: udlAgentDescriptionSchema.optional(),
714
816
  aggregateInvariants: z.array(udlAggregateSchema).min(1).optional(),
@@ -730,6 +832,7 @@ const udlInstrumentShape = {
730
832
  nav: z.array(nonEmptyTextSchema).min(1).optional(),
731
833
  parties: z.record(udlPartyRoleSchema, udlFieldNameSchema).optional(),
732
834
  partitions: z.array(udlPartitionSchema).min(1).optional(),
835
+ piecePlan: udlPiecePlanSchema.optional(),
733
836
  required: z.array(udlFieldNameSchema),
734
837
  subject: udlInstrumentSubjectSchema.optional(),
735
838
  summary: nonEmptyTextSchema,
@@ -761,6 +864,7 @@ interface UdlClauseVocabularyMetadata {
761
864
  readonly effects?: readonly UdlClauseEffect[];
762
865
  readonly linearOutputs?: readonly string[];
763
866
  readonly linearSink?: true;
867
+ readonly literalKeys?: true;
764
868
  readonly spelling: string;
765
869
  }
766
870
 
@@ -777,12 +881,26 @@ export type UdlClauseVocabularyEntry = UdlClauseVocabularyMetadata &
777
881
  );
778
882
 
779
883
  export const udlClauseVocabulary = [
884
+ {
885
+ cardinality: "one",
886
+ literalKeys: true,
887
+ scope: "instrument",
888
+ spelling: "action library",
889
+ target: "actionLibrary",
890
+ },
780
891
  {
781
892
  cardinality: "one",
782
893
  scope: "action",
783
894
  spelling: "agent description",
784
895
  target: "agentDescription",
785
896
  },
897
+ {
898
+ cardinality: "many",
899
+ literalKeys: true,
900
+ scope: "action",
901
+ spelling: "calls",
902
+ target: "calls",
903
+ },
786
904
  {
787
905
  cardinality: "one",
788
906
  scope: "action",
@@ -933,6 +1051,20 @@ export const udlClauseVocabulary = [
933
1051
  spelling: "payout",
934
1052
  target: "payout",
935
1053
  },
1054
+ {
1055
+ cardinality: "one",
1056
+ literalKeys: true,
1057
+ scope: "instrument",
1058
+ spelling: "piece plan",
1059
+ target: "piecePlan",
1060
+ },
1061
+ {
1062
+ cardinality: "one",
1063
+ literalKeys: true,
1064
+ scope: "action",
1065
+ spelling: "piece stage",
1066
+ target: "pieceStage",
1067
+ },
936
1068
  {
937
1069
  cardinality: "one",
938
1070
  effects: [
@@ -1395,3 +1527,18 @@ export type UdlRemainder = z.infer<typeof udlRemainderSchema>;
1395
1527
  export type UdlStep = z.infer<typeof udlStepSchema>;
1396
1528
  export type UdlSubject = z.infer<typeof udlSubjectSchema>;
1397
1529
  export type UdlAction = z.infer<typeof udlActionSchema>;
1530
+ export type UdlPiece = z.infer<typeof udlPieceSchema>;
1531
+ export type UdlPiecePlan = z.infer<typeof udlPiecePlanSchema>;
1532
+ export type UdlPieceStage = z.infer<typeof udlPieceStageSchema>;
1533
+ export type UdlPieceStageStage = z.infer<typeof udlPieceStageStageSchema>;
1534
+ export type UdlCall = z.infer<typeof udlCallSchema>;
1535
+ export type UdlPrivateParameterKind = z.infer<
1536
+ typeof udlPrivateParameterKindSchema
1537
+ >;
1538
+ export type UdlPrivateParameter = z.infer<typeof udlPrivateParameterSchema>;
1539
+ export type UdlPrivateLeaf = z.infer<typeof udlPrivateLeafSchema>;
1540
+ export type UdlPrivateAction = z.infer<typeof udlPrivateActionSchema>;
1541
+ export type UdlActionLibraryModule = z.infer<
1542
+ typeof udlActionLibraryModuleSchema
1543
+ >;
1544
+ export type UdlActionLibrary = z.infer<typeof udlActionLibrarySchema>;