@hyperscale0/udl 2.6.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/CHANGELOG.md +2 -330
  2. package/LICENSING.md +1 -2
  3. package/README.md +3 -114
  4. package/TRADEMARKS.md +2 -2
  5. package/dist/diagnostics.d.ts +21 -201
  6. package/dist/diagnostics.d.ts.map +1 -1
  7. package/dist/diagnostics.js +29 -193
  8. package/dist/diagnostics.js.map +1 -1
  9. package/dist/evolution.d.ts +3 -132
  10. package/dist/evolution.d.ts.map +1 -1
  11. package/dist/evolution.js +29 -633
  12. package/dist/evolution.js.map +1 -1
  13. package/dist/finance.d.ts +5 -72
  14. package/dist/finance.d.ts.map +1 -1
  15. package/dist/finance.js +233 -737
  16. package/dist/finance.js.map +1 -1
  17. package/dist/index.d.ts +7 -18
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +7 -12
  20. package/dist/index.js.map +1 -1
  21. package/dist/instrument-references.d.ts.map +1 -1
  22. package/dist/instrument-references.js +3 -2
  23. package/dist/instrument-references.js.map +1 -1
  24. package/dist/schema.d.ts +2079 -4564
  25. package/dist/schema.d.ts.map +1 -1
  26. package/dist/schema.js +270 -1609
  27. package/dist/schema.js.map +1 -1
  28. package/dist/validation.d.ts +8 -104
  29. package/dist/validation.d.ts.map +1 -1
  30. package/dist/validation.js +653 -3271
  31. package/dist/validation.js.map +1 -1
  32. package/docs/README.md +147 -14
  33. package/package.json +7 -11
  34. package/spec/README.md +151 -164
  35. package/spec/darb.udl.json +249 -0
  36. package/spec/udl.schema.json +4104 -3202
  37. package/src/diagnostics.ts +51 -246
  38. package/src/evolution.ts +39 -1045
  39. package/src/finance.ts +287 -1127
  40. package/src/index.ts +18 -142
  41. package/src/instrument-references.ts +3 -2
  42. package/src/schema.ts +285 -1843
  43. package/src/validation.ts +870 -5611
  44. package/conformance/README.md +0 -82
  45. package/conformance/evolution/action-contract.expected.json +0 -10
  46. package/conformance/evolution/action-contract.live.udl +0 -44
  47. package/conformance/evolution/action-contract.next.udl +0 -45
  48. package/conformance/evolution/product-identity.expected.json +0 -10
  49. package/conformance/evolution/product-identity.live.udl +0 -55
  50. package/conformance/evolution/product-identity.next.udl +0 -55
  51. package/conformance/evolution/version-required.expected.json +0 -10
  52. package/conformance/evolution/version-required.live.udl +0 -55
  53. package/conformance/evolution/version-required.next.udl +0 -58
  54. package/conformance/invalid/action-without-transition.expected.json +0 -10
  55. package/conformance/invalid/action-without-transition.udl +0 -60
  56. package/conformance/invalid/agent-description-too-long.expected.json +0 -10
  57. package/conformance/invalid/agent-description-too-long.udl +0 -57
  58. package/conformance/invalid/blank-title.expected.json +0 -10
  59. package/conformance/invalid/blank-title.udl +0 -54
  60. package/conformance/invalid/call-binds-results.expected.json +0 -10
  61. package/conformance/invalid/call-binds-results.udl +0 -314
  62. package/conformance/invalid/call-unknown-action.expected.json +0 -10
  63. package/conformance/invalid/call-unknown-action.udl +0 -314
  64. package/conformance/invalid/composition-dial-duplicate-key.expected.json +0 -10
  65. package/conformance/invalid/composition-dial-duplicate-key.udl +0 -73
  66. package/conformance/invalid/depth-budget.expected.json +0 -10
  67. package/conformance/invalid/depth-budget.udl +0 -49
  68. package/conformance/invalid/duplicate-subject.expected.json +0 -10
  69. package/conformance/invalid/duplicate-subject.udl +0 -230
  70. package/conformance/invalid/forged-effects.expected.json +0 -10
  71. package/conformance/invalid/forged-effects.udl +0 -76
  72. package/conformance/invalid/format-version.expected.json +0 -10
  73. package/conformance/invalid/format-version.udl +0 -54
  74. package/conformance/invalid/instrument-id-not-snake-case.expected.json +0 -10
  75. package/conformance/invalid/instrument-id-not-snake-case.udl +0 -54
  76. package/conformance/invalid/invalid-aggregate-gate-shape.expected.json +0 -10
  77. package/conformance/invalid/invalid-aggregate-gate-shape.udl +0 -1819
  78. package/conformance/invalid/invalid-check-duration.expected.json +0 -10
  79. package/conformance/invalid/invalid-check-duration.udl +0 -219
  80. package/conformance/invalid/invalid-dial-anchor.expected.json +0 -10
  81. package/conformance/invalid/invalid-dial-anchor.udl +0 -219
  82. package/conformance/invalid/invalid-exception-parent-ref.expected.json +0 -10
  83. package/conformance/invalid/invalid-exception-parent-ref.udl +0 -2487
  84. package/conformance/invalid/invalid-exposure-shape.expected.json +0 -10
  85. package/conformance/invalid/invalid-exposure-shape.udl +0 -1819
  86. package/conformance/invalid/invalid-journeys.expected.json +0 -10
  87. package/conformance/invalid/invalid-journeys.udl +0 -77
  88. package/conformance/invalid/invalid-remainder.expected.json +0 -10
  89. package/conformance/invalid/invalid-remainder.udl +0 -220
  90. package/conformance/invalid/invalid-schema-keyword.expected.json +0 -10
  91. package/conformance/invalid/invalid-schema-keyword.udl +0 -220
  92. package/conformance/invalid/invalid-utf8.expected.json +0 -10
  93. package/conformance/invalid/invalid-utf8.udl +0 -1
  94. package/conformance/invalid/leaf-effect-mismatch.expected.json +0 -10
  95. package/conformance/invalid/leaf-effect-mismatch.udl +0 -314
  96. package/conformance/invalid/malformed-json.expected.json +0 -10
  97. package/conformance/invalid/malformed-json.udl +0 -1
  98. package/conformance/invalid/missing-create-action.expected.json +0 -10
  99. package/conformance/invalid/missing-create-action.udl +0 -48
  100. package/conformance/invalid/missing-exception-amount-field.expected.json +0 -10
  101. package/conformance/invalid/missing-exception-amount-field.udl +0 -2487
  102. package/conformance/invalid/missing-exception-contract.expected.json +0 -14
  103. package/conformance/invalid/missing-exception-contract.udl +0 -2523
  104. package/conformance/invalid/missing-exception-reason-field.expected.json +0 -10
  105. package/conformance/invalid/missing-exception-reason-field.udl +0 -2487
  106. package/conformance/invalid/not-an-object.expected.json +0 -10
  107. package/conformance/invalid/not-an-object.udl +0 -1
  108. package/conformance/invalid/payout-reconcile-not-a-bank-debit.expected.json +0 -10
  109. package/conformance/invalid/payout-reconcile-not-a-bank-debit.udl +0 -259
  110. package/conformance/invalid/piece-plan-without-partition.expected.json +0 -10
  111. package/conformance/invalid/piece-plan-without-partition.udl +0 -305
  112. package/conformance/invalid/private-action-independent-approval.expected.json +0 -10
  113. package/conformance/invalid/private-action-independent-approval.udl +0 -314
  114. package/conformance/invalid/quote-freeze-set-incomplete.expected.json +0 -10
  115. package/conformance/invalid/quote-freeze-set-incomplete.udl +0 -261
  116. package/conformance/invalid/quote-named-reference-gate.expected.json +0 -10
  117. package/conformance/invalid/quote-named-reference-gate.udl +0 -50
  118. package/conformance/invalid/reconcile-named-reference-gate.expected.json +0 -10
  119. package/conformance/invalid/reconcile-named-reference-gate.udl +0 -50
  120. package/conformance/invalid/unfund-order-not-reversed.expected.json +0 -10
  121. package/conformance/invalid/unfund-order-not-reversed.udl +0 -314
  122. package/conformance/invalid/unknown-key.expected.json +0 -10
  123. package/conformance/invalid/unknown-key.udl +0 -55
  124. package/conformance/invalid/unknown-reference-gate-field.expected.json +0 -10
  125. package/conformance/invalid/unknown-reference-gate-field.udl +0 -1819
  126. package/conformance/invalid/unknown-required-field.expected.json +0 -10
  127. package/conformance/invalid/unknown-required-field.udl +0 -220
  128. package/conformance/invalid/unreachable-state.expected.json +0 -10
  129. package/conformance/invalid/unreachable-state.udl +0 -55
  130. package/conformance/invalid/wrong-exception-amount-field.expected.json +0 -10
  131. package/conformance/invalid/wrong-exception-amount-field.udl +0 -2487
  132. package/conformance/invalid/wrong-exception-reason-field.expected.json +0 -10
  133. package/conformance/invalid/wrong-exception-reason-field.udl +0 -2487
  134. package/conformance/valid/agent-description.expected.json +0 -6
  135. package/conformance/valid/agent-description.udl +0 -66
  136. package/conformance/valid/attested.expected.json +0 -6
  137. package/conformance/valid/attested.udl +0 -251
  138. package/conformance/valid/cards.expected.json +0 -6
  139. package/conformance/valid/cards.udl +0 -1579
  140. package/conformance/valid/commerce-escrow.expected.json +0 -6
  141. package/conformance/valid/commerce-escrow.udl +0 -1512
  142. package/conformance/valid/compiled-crowdfunding.expected.json +0 -6
  143. package/conformance/valid/compiled-crowdfunding.udl +0 -1843
  144. package/conformance/valid/compiled-watch-club.expected.json +0 -6
  145. package/conformance/valid/compiled-watch-club.udl +0 -2486
  146. package/conformance/valid/complete-contract.expected.json +0 -6
  147. package/conformance/valid/complete-contract.udl +0 -218
  148. package/conformance/valid/effect-signatures.expected.json +0 -6
  149. package/conformance/valid/effect-signatures.udl +0 -75
  150. package/conformance/valid/hand-edited.expected.json +0 -6
  151. package/conformance/valid/hand-edited.udl +0 -1
  152. package/conformance/valid/insured-car-marketplace.expected.json +0 -6
  153. package/conformance/valid/insured-car-marketplace.udl +0 -1050
  154. package/conformance/valid/insured-travel.expected.json +0 -6
  155. package/conformance/valid/insured-travel.udl +0 -3469
  156. package/conformance/valid/minimal.expected.json +0 -6
  157. package/conformance/valid/minimal.udl +0 -62
  158. package/conformance/valid/piece-plan-calls.expected.json +0 -6
  159. package/conformance/valid/piece-plan-calls.udl +0 -314
  160. package/conformance/valid/protection.expected.json +0 -6
  161. package/conformance/valid/protection.udl +0 -1551
  162. package/conformance/valid/string-escaping.expected.json +0 -6
  163. package/conformance/valid/string-escaping.udl +0 -54
  164. package/conformance/valid/vocabulary.expected.json +0 -6
  165. package/conformance/valid/vocabulary.udl +0 -2012
  166. package/dist/allocation.d.ts +0 -60
  167. package/dist/allocation.d.ts.map +0 -1
  168. package/dist/allocation.js +0 -177
  169. package/dist/allocation.js.map +0 -1
  170. package/dist/check-profiles.d.ts +0 -57
  171. package/dist/check-profiles.d.ts.map +0 -1
  172. package/dist/check-profiles.js +0 -62
  173. package/dist/check-profiles.js.map +0 -1
  174. package/dist/distribution.d.ts +0 -15
  175. package/dist/distribution.d.ts.map +0 -1
  176. package/dist/distribution.js +0 -49
  177. package/dist/distribution.js.map +0 -1
  178. package/dist/effects.d.ts +0 -58
  179. package/dist/effects.d.ts.map +0 -1
  180. package/dist/effects.js +0 -1126
  181. package/dist/effects.js.map +0 -1
  182. package/dist/reference.d.ts +0 -3
  183. package/dist/reference.d.ts.map +0 -1
  184. package/dist/reference.js +0 -28
  185. package/dist/reference.js.map +0 -1
  186. package/dist/vocabulary.d.ts +0 -23
  187. package/dist/vocabulary.d.ts.map +0 -1
  188. package/dist/vocabulary.js +0 -1052
  189. package/dist/vocabulary.js.map +0 -1
  190. package/docs/funding-custody.md +0 -165
  191. package/docs/guide/01-a-document.md +0 -37
  192. package/docs/guide/02-money-steps.md +0 -23
  193. package/docs/guide/03-laws.md +0 -18
  194. package/docs/guide/04-fees-and-remainder.md +0 -36
  195. package/docs/guide/05-checks-updates-dials.md +0 -7
  196. package/docs/guide/06-effects.md +0 -11
  197. package/docs/guide/07-evolution.md +0 -11
  198. package/docs/guide/08-implementing.md +0 -13
  199. package/docs/guide/09-schedules-and-allocation.md +0 -132
  200. package/docs/llms-full.txt +0 -2008
  201. package/docs/llms.txt +0 -14
  202. package/docs/piece-plans.md +0 -148
  203. package/docs/reference/canonical.md +0 -16
  204. package/docs/reference/clauses.md +0 -1585
  205. package/docs/reference/cli.md +0 -24
  206. package/docs/reference/diagnostics.md +0 -38
  207. package/skills/udl/SKILL.md +0 -28
  208. package/src/allocation.ts +0 -259
  209. package/src/check-profiles.ts +0 -80
  210. package/src/distribution.ts +0 -61
  211. package/src/effects.ts +0 -1920
  212. package/src/reference.ts +0 -31
  213. package/src/vocabulary.ts +0 -1635
package/docs/llms.txt DELETED
@@ -1,14 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts from @hyperscale0/udl 2.6.1. Edit the source, not llms.txt. -->
2
-
3
- # UDL documentation
4
-
5
- - [Start here](README.md)
6
- - [Write a document](guide/01-a-document.md)
7
- - [Understand the laws](guide/03-laws.md)
8
- - [Evolve a stored document](guide/07-evolution.md)
9
- - [Implement UDL](guide/08-implementing.md)
10
- - [Clause reference](reference/clauses.md)
11
- - [Diagnostic reference](reference/diagnostics.md)
12
- - [Canonical bytes](reference/canonical.md)
13
- - [Command reference](reference/cli.md)
14
- - [Conformance contract](../conformance/README.md)
@@ -1,148 +0,0 @@
1
- # Piece plans and private action composition
2
-
3
- UDL preserves the authored graph and the order needed to interpret it.
4
- `piecePlan` declares a finite partition, `pieceStage` names a stage, `calls`
5
- binds private actions, and `actionLibrary` supplies their definitions. HSX
6
- spells these clauses `piece_plan`, `piece_stage`, `calls` and `action_library`.
7
- The shapes live in [`schema.ts`](../src/schema.ts); resolution and finance
8
- validation live in [`validation.ts`](../src/validation.ts). The
9
- [clause reference](reference/clauses.md) describes the complete vocabulary.
10
-
11
- ## Worked sale example
12
-
13
- The following decoded instrument fragment uses the sale settlement's price
14
- partition and refund action. Add it to an instrument with its required
15
- immutable fields, matching partition, lifecycle and captured escrow account.
16
- It omits the surrounding document and other actions. It is formatted for
17
- reading; canonical serialization sorts object keys and retains array order.
18
-
19
- ```json
20
- {
21
- "piecePlan": {
22
- "id": "price",
23
- "total": "price",
24
- "pieces": [
25
- {
26
- "id": "seller",
27
- "amount": "piece1Amount",
28
- "release_to": "sellerAccountId",
29
- "refund_to": "buyerAccountId"
30
- },
31
- {
32
- "id": "platform_fee",
33
- "amount": "piece2Amount",
34
- "release_to": "platformAccountId",
35
- "refund_to": "buyerAccountId"
36
- },
37
- {
38
- "id": "seller_cancel_fee",
39
- "amount": "piece3Amount",
40
- "release_to": "platformAccountId",
41
- "refund_to": "sellerAccountId"
42
- }
43
- ],
44
- "fund_order": ["seller", "platform_fee", "seller_cancel_fee"],
45
- "release_order": ["platform_fee", "seller_cancel_fee"],
46
- "refund_order": ["platform_fee", "seller_cancel_fee"],
47
- "unfund_order": ["seller_cancel_fee", "platform_fee", "seller"]
48
- },
49
- "actionLibrary": {
50
- "settlement_piece": {
51
- "actionOrder": ["move"],
52
- "actions": {
53
- "move": {
54
- "parameters": {
55
- "piece": { "kind": "piece" },
56
- "source": { "kind": "account" },
57
- "destination": { "kind": "account" }
58
- },
59
- "principal": "api_key",
60
- "approval": "inherit",
61
- "recovery": "local",
62
- "order": ["transfer"],
63
- "calls": [],
64
- "leaves": [
65
- {
66
- "id": "transfer",
67
- "operation": "internal_transfer.create",
68
- "bind": {
69
- "amount": "$piece.amount",
70
- "currency": "$piece.currency",
71
- "sourceAccountId": "$source",
72
- "destinationAccountId": "$destination"
73
- },
74
- "effects": [
75
- { "kind": "moves", "signature": "moves.transfer.internal" }
76
- ],
77
- "evidence": "transferId"
78
- }
79
- ]
80
- }
81
- }
82
- }
83
- },
84
- "actions": {
85
- "refund_piece": {
86
- "pieceStage": { "plan": "price", "stage": "refund" },
87
- "calls": [
88
- {
89
- "id": "move_piece",
90
- "action": "settlement_piece.move",
91
- "bind": {
92
- "piece": "$piece",
93
- "source": "$instance.refs.escrowAccountId",
94
- "destination": "$piece.refund_to"
95
- }
96
- }
97
- ],
98
- "steps": [],
99
- "summary": "Refund a piece of a sale settlement"
100
- }
101
- }
102
- }
103
- ```
104
-
105
- The containing instrument's `actionOrder` includes `refund_piece` at its
106
- authored position. Both library `actionOrder` and private action `order` must
107
- be exact permutations of their members. The stage derives a required
108
- `pieceId` enum, here `platform_fee` or `seller_cancel_fee`. The selector does
109
- not add another transfer; the private leaf moves its amount once.
110
-
111
- For the sale's example amounts, `piece1Amount` is `245000`, `piece2Amount` is
112
- `3750`, and `piece3Amount` is `1250`, all SAR minor units. They partition
113
- `price` of `250000`. Cancellation's separate decision action returns the seller
114
- piece to the buyer. The refund stage then returns `3750` to the buyer and pays
115
- `1250` to the seller. Unfund follows its reverse order and returns every funded
116
- piece to the buyer instead. The service fee stays outside the price partition.
117
-
118
- `resolveUdlActionPlans` returns plans and issues. A plan identifies its action
119
- and optional piece ID, with resolved effects and leaves. Each leaf retains
120
- `originPath`, step, effects and evidence. Resolution expands static calls; it
121
- does not replace the source graph in canonical UDL. A private library entry is
122
- not a public action. [`refactor-clauses.spec.ts`](../test/refactor-clauses.spec.ts)
123
- checks piece constraints, graph order, cycles, bindings, authority and evidence.
124
-
125
- ## Conservation and diagnostics
126
-
127
- UDL 2.3.0 checks funded amounts over piece progress. A partially funded path
128
- must return only the pieces actually funded; selecting one piece is not proof
129
- that a whole stage completed. For a piece plan, `expandPieceProgress` bounds the reachable lifecycle/progress
130
- states at 256. Instruments without a piece plan use the separate action-plan
131
- combination bound. These bounds belong to the proof, not to a runtime retry
132
- loop. [`udl.spec.ts`](../test/udl.spec.ts) includes the stranded-funded-piece
133
- refusal; [`validation.ts`](../src/validation.ts) owns the progress expansion.
134
-
135
- [`diagnostics.ts`](../src/diagnostics.ts) defines the refusal codes:
136
-
137
- | Code | Refusal | Repair |
138
- | --------- | ---------------------- | ---------------------------------------------------------------------------------------- |
139
- | `UDL4001` | Money graph violation | Balance each funded amount and close every hold on each lifecycle path |
140
- | `UDL5013` | Piece stage violation | Select a declared plan/stage, valid ordered piece IDs and a call-based stage action |
141
- | `UDL2010` | Action graph violation | Resolve targets and remove cycles, collisions or invalid order within depth/count limits |
142
-
143
- A partition mismatch or incompatible immutable field is `UDL4002`. A typed
144
- binding failure is `UDL2011`; an authority boundary is `UDL2012`; incomplete
145
- effects or evidence are `UDL2013`. These failures are not permission to skip
146
- the independent conservation oracle. Keep actions that need another principal,
147
- independent approval or external recovery as separate calls at the public
148
- boundary, not flattened private work.
@@ -1,16 +0,0 @@
1
- # Canonical bytes
2
-
3
- An admitted UDL document has one canonical byte sequence.
4
-
5
- - Encode JSON as UTF-8 without a byte-order mark.
6
- - Sort every object's keys by ascending UTF-16 code unit. Compare code units, not locale order or Unicode collation order.
7
- - Preserve array order exactly as authored. Never sort an array.
8
- - Indent nested values with two ASCII spaces. Write one ASCII space after each colon.
9
- - Write empty objects as `{}` and empty arrays as `[]`.
10
- - Serialize JSON numbers with JavaScript `JSON.stringify` semantics. An admitted integer uses base-10 digits with an optional leading minus and no leading zeros. Negative zero serializes as `0`. UDL money is not a JSON number. It is a base-10 integer minor-unit string paired with a currency code.
11
- - Apply ECMAScript well-formed `JSON.stringify` string escaping. Escape U+0000 through U+001F. Escape every lone surrogate as `\uXXXX`. Write every other code point literally, including U+007F and U+2028.
12
- - End the document with exactly one line feed byte, `0A`. Write no other trailing whitespace.
13
-
14
- `serializeUdl(document)` validates and writes these bytes. `canonicalizeUdl(input)` parses, validates, and writes them. Canonicalizing canonical bytes returns the same bytes.
15
-
16
- `canonicalDigest(document)` computes SHA-256 over the canonical UTF-8 bytes and returns a promise for the lowercase hexadecimal digest. `udl canon file.udl --digest` prints that digest. It does not hash the source bytes before canonicalization.