@hyperscale0/udl 2.2.0 → 2.4.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.
- package/CHANGELOG.md +38 -0
- package/README.md +5 -1
- package/conformance/invalid/invalid-journeys.expected.json +3 -19
- package/conformance/invalid/invalid-journeys.udl +47 -49
- package/conformance/valid/attested.expected.json +6 -0
- package/conformance/valid/attested.udl +251 -0
- package/conformance/valid/hand-edited.expected.json +1 -1
- package/conformance/valid/hand-edited.udl +1 -1
- package/conformance/valid/minimal.expected.json +1 -1
- package/conformance/valid/minimal.udl +0 -15
- package/conformance/valid/vocabulary.expected.json +6 -0
- package/conformance/valid/vocabulary.udl +1999 -0
- package/dist/allocation.d.ts +60 -0
- package/dist/allocation.d.ts.map +1 -0
- package/dist/allocation.js +177 -0
- package/dist/allocation.js.map +1 -0
- package/dist/diagnostics.d.ts +1 -31
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +0 -30
- package/dist/diagnostics.js.map +1 -1
- package/dist/distribution.d.ts +15 -0
- package/dist/distribution.d.ts.map +1 -0
- package/dist/distribution.js +49 -0
- package/dist/distribution.js.map +1 -0
- package/dist/effects.d.ts +0 -6
- package/dist/effects.d.ts.map +1 -1
- package/dist/effects.js +84 -22
- package/dist/effects.js.map +1 -1
- package/dist/evolution.d.ts +12 -0
- package/dist/evolution.d.ts.map +1 -1
- package/dist/evolution.js +42 -1
- package/dist/evolution.js.map +1 -1
- package/dist/finance.d.ts +18 -1
- package/dist/finance.d.ts.map +1 -1
- package/dist/finance.js +158 -27
- package/dist/finance.js.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/instrument-references.d.ts +5 -0
- package/dist/instrument-references.d.ts.map +1 -0
- package/dist/instrument-references.js +69 -0
- package/dist/instrument-references.js.map +1 -0
- package/dist/limits.d.ts +3 -3
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +3 -7
- package/dist/limits.js.map +1 -1
- package/dist/reference.d.ts +3 -0
- package/dist/reference.d.ts.map +1 -0
- package/dist/reference.js +28 -0
- package/dist/reference.js.map +1 -0
- package/dist/schema.d.ts +1232 -83
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +398 -60
- package/dist/schema.js.map +1 -1
- package/dist/validation.d.ts +27 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +327 -187
- package/dist/validation.js.map +1 -1
- package/dist/vocabulary.d.ts +23 -0
- package/dist/vocabulary.d.ts.map +1 -0
- package/dist/vocabulary.js +965 -0
- package/dist/vocabulary.js.map +1 -0
- package/docs/README.md +5 -1
- package/docs/funding-custody.md +165 -0
- package/docs/guide/09-schedules-and-allocation.md +130 -0
- package/docs/llms-full.txt +623 -101
- package/docs/llms.txt +1 -1
- package/docs/piece-plans.md +148 -0
- package/docs/reference/clauses.md +451 -63
- package/docs/reference/cli.md +3 -1
- package/docs/reference/diagnostics.md +33 -38
- package/package.json +5 -6
- package/spec/udl.schema.json +1095 -118
- package/src/allocation.ts +259 -0
- package/src/diagnostics.ts +0 -32
- package/src/distribution.ts +61 -0
- package/src/effects.ts +116 -22
- package/src/evolution.ts +63 -3
- package/src/finance.ts +218 -24
- package/src/index.ts +31 -3
- package/src/instrument-references.ts +98 -0
- package/src/limits.ts +3 -7
- package/src/reference.ts +31 -0
- package/src/schema.ts +417 -66
- package/src/validation.ts +452 -243
- package/src/vocabulary.ts +1508 -0
package/docs/llms.txt
CHANGED
|
@@ -0,0 +1,148 @@
|
|
|
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.
|