@hyperscale0/hsx 5.8.0 → 6.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.
- package/CHANGELOG.md +14 -0
- package/README.md +3 -4
- package/bin/hsx.ts +0 -5
- package/dist/bin/hsx.d.ts +0 -4
- package/dist/bin/hsx.d.ts.map +1 -1
- package/dist/bin/hsx.js +0 -4
- package/dist/bin/hsx.js.map +1 -1
- package/dist/src/attachment-economics.d.ts +5 -0
- package/dist/src/attachment-economics.d.ts.map +1 -0
- package/dist/src/attachment-economics.js +55 -0
- package/dist/src/attachment-economics.js.map +1 -0
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +9 -21
- package/dist/src/compile.js.map +1 -1
- package/dist/src/examples-bundle.d.ts.map +1 -1
- package/dist/src/examples-bundle.js +3 -4
- package/dist/src/examples-bundle.js.map +1 -1
- package/dist/src/headers.d.ts +1 -1
- package/dist/src/headers.d.ts.map +1 -1
- package/dist/src/headers.js +0 -1
- package/dist/src/headers.js.map +1 -1
- package/dist/src/parse.js +2 -0
- package/dist/src/parse.js.map +1 -1
- package/dist/src/std-bundle.d.ts.map +1 -1
- package/dist/src/std-bundle.js +1 -2
- package/dist/src/std-bundle.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/docs/README.md +39 -20
- package/examples/insurance.hsx +1 -0
- package/examples/money.hsx +1 -0
- package/examples/wallet.hsx +1 -0
- package/package.json +5 -6
- package/src/attachment-economics.ts +103 -0
- package/src/compile.ts +15 -22
- package/src/examples-bundle.ts +3 -4
- package/src/headers.ts +0 -1
- package/src/parse.ts +2 -0
- package/src/std-bundle.ts +1 -2
- package/src/version.ts +1 -1
- package/std/reporting.hsx +105 -676
- package/docs/examples.md +0 -22
- package/docs/headers.md +0 -46
- package/examples/travel.hsx +0 -29
- package/std/travel.hsx +0 -123
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# HSX 6.0.0
|
|
2
|
+
|
|
3
|
+
Breaking: the `travel` std header is gone, with its `travel.package` and
|
|
4
|
+
`travel.booking` instruments and the travel agency sample. Programs that
|
|
5
|
+
`use travel` no longer compile; build a booking from `escrow.hold` and an
|
|
6
|
+
authored instrument instead. `reporting.portfolio` drops the
|
|
7
|
+
`origination_cohorts` and `bureau_facility` report definitions, which refused
|
|
8
|
+
every request. The compiler no longer declares `programFines` or `programCosts`;
|
|
9
|
+
`late_charge` routes fines and recovery through its `fines_to` and `costs_to`
|
|
10
|
+
party tunables. `account(owner, cash, external)` is an ordinary keyed account
|
|
11
|
+
instead of a refusal. The package stops generating the header and sample
|
|
12
|
+
index pages and the two llms text files; `hsx headers` prints the instrument
|
|
13
|
+
inventory.
|
|
14
|
+
|
|
1
15
|
# HSX 5.8.0
|
|
2
16
|
|
|
3
17
|
The checker names misspelled fields, parties and states at the misspelled word,
|
package/README.md
CHANGED
|
@@ -21,8 +21,8 @@ Start with the [first program and rental guide](docs/README.md). Save the
|
|
|
21
21
|
It holds 1,000 SAR, charges a one-time 50 SAR late fee, and returns the remainder.
|
|
22
22
|
The guide explains the fixed business binding and the host needed to execute it.
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
The [
|
|
24
|
+
`npx hsx headers` prints every std instrument and its tunables from the bundled
|
|
25
|
+
headers. The [samples](examples/) include both complete action paths and
|
|
26
26
|
compositions that still need child-record actions or adapter bindings. A compile
|
|
27
27
|
pass does not prove that a flow is publicly executable or funded.
|
|
28
28
|
|
|
@@ -56,6 +56,5 @@ Run `bun bin/hsx.ts check examples/rental-deposit.hsx` to use the source CLI.
|
|
|
56
56
|
|
|
57
57
|
Edit prose in `docs/README.md`, programs in `examples/`, and header comments in
|
|
58
58
|
`std/`. Run `bun run generate` after changing these inputs. It emits the header
|
|
59
|
-
and example bundles
|
|
60
|
-
`docs/headers.md`, `docs/examples.md`, `llms.txt` or `llms-full.txt` by hand.
|
|
59
|
+
and example bundles.
|
|
61
60
|
`bun run build` also builds the browser playground.
|
package/bin/hsx.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* The `hsx` executable. Everything it does lives in `runCli`; this file only
|
|
4
|
-
* binds that function to the real filesystem and the real streams.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
2
|
import { readFile, writeFile } from "node:fs/promises";
|
|
8
3
|
import { runCli } from "../src/cli.ts";
|
|
9
4
|
|
package/dist/bin/hsx.d.ts
CHANGED
package/dist/bin/hsx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hsx.d.ts","sourceRoot":"","sources":["../../bin/hsx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hsx.d.ts","sourceRoot":"","sources":["../../bin/hsx.ts"],"names":[],"mappings":""}
|
package/dist/bin/hsx.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* The `hsx` executable. Everything it does lives in `runCli`; this file only
|
|
4
|
-
* binds that function to the real filesystem and the real streams.
|
|
5
|
-
*/
|
|
6
2
|
import { readFile, writeFile } from "node:fs/promises";
|
|
7
3
|
import { runCli } from "../src/cli.js";
|
|
8
4
|
process.exitCode = await runCli(process.argv.slice(2), {
|
package/dist/bin/hsx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hsx.js","sourceRoot":"","sources":["../../bin/hsx.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"hsx.js","sourceRoot":"","sources":["../../bin/hsx.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,CAAC,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IACrD,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;IAChD,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;IAChD,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC1C,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC;CACjE,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type AttachmentPartyBinding, type UdlDocument, type UdlInstrument } from "@hyperscale0/udl";
|
|
2
|
+
import type { Entry, Expr } from "./ast.ts";
|
|
3
|
+
/** An attachment specializes its own instrument; imported definitions stay generic. */
|
|
4
|
+
export declare function applyAttachmentEconomics(document: UdlDocument, instrument: UdlInstrument, parties: Record<string, AttachmentPartyBinding>, declarations: Entry[], data: (expression: Expr) => unknown): void;
|
|
5
|
+
//# sourceMappingURL=attachment-economics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-economics.d.ts","sourceRoot":"","sources":["../../src/attachment-economics.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAE3B,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAG5C,uFAAuF;AACvF,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,WAAW,EACrB,UAAU,EAAE,aAAa,EACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,EAC/C,YAAY,EAAE,KAAK,EAAE,EACrB,IAAI,EAAE,CAAC,UAAU,EAAE,IAAI,KAAK,OAAO,GAClC,IAAI,CAoFN"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { subjectPartyRoles, udlMoveSchema, } from "@hyperscale0/udl";
|
|
2
|
+
import { fail } from "./diagnostics.js";
|
|
3
|
+
/** An attachment specializes its own instrument; imported definitions stay generic. */
|
|
4
|
+
export function applyAttachmentEconomics(document, instrument, parties, declarations, data) {
|
|
5
|
+
const selected = new Set();
|
|
6
|
+
for (const declaration of declarations) {
|
|
7
|
+
const selector = declaration.key.slice("economics ".length);
|
|
8
|
+
const [actionName, moveKey, extra] = selector.split(".");
|
|
9
|
+
const action = Object.hasOwn(instrument.actions, actionName)
|
|
10
|
+
? instrument.actions[actionName]
|
|
11
|
+
: undefined;
|
|
12
|
+
if (!action)
|
|
13
|
+
fail(declaration, `unknown economics action ${actionName}`, `choose ${instrument.actionOrder.join(", ")}, before its public alias`);
|
|
14
|
+
const move = moveKey
|
|
15
|
+
? action.moves.find((move) => move.key === moveKey)
|
|
16
|
+
: action.moves.length === 1
|
|
17
|
+
? action.moves[0]
|
|
18
|
+
: undefined;
|
|
19
|
+
if (!move || extra)
|
|
20
|
+
fail(declaration, `economics ${selector} must select one money move`, action.moves.length
|
|
21
|
+
? `choose ${action.moves.map((move) => `${actionName}.${move.key}`).join(", ")}`
|
|
22
|
+
: "choose an action that transfers or reserves money");
|
|
23
|
+
if (move.operation === "internal_transfer.void")
|
|
24
|
+
fail(declaration, `economics ${selector} cannot classify a void`, "declare the purpose on the reservation or its posting");
|
|
25
|
+
if (selected.has(move))
|
|
26
|
+
fail(declaration, `repeated economics for ${selector}`, "declare each money move's purpose once");
|
|
27
|
+
selected.add(move);
|
|
28
|
+
const parsed = udlMoveSchema.safeParse({
|
|
29
|
+
...move,
|
|
30
|
+
economics: data(declaration.value),
|
|
31
|
+
});
|
|
32
|
+
if (!parsed.success || !parsed.data.economics)
|
|
33
|
+
fail(declaration, `invalid economics for ${selector}`, "declare purpose and sourceParty using the move economics fields");
|
|
34
|
+
const economics = parsed.data.economics;
|
|
35
|
+
if (move.economics &&
|
|
36
|
+
(move.economics.purpose !== economics.purpose ||
|
|
37
|
+
move.economics.sourceParty !== economics.sourceParty ||
|
|
38
|
+
move.economics.reversalOf !== economics.reversalOf))
|
|
39
|
+
fail(declaration, `economics ${selector} conflicts with the instrument's declared purpose`, "keep the instrument's economics or choose an unclassified move");
|
|
40
|
+
const source = economics.sourceParty;
|
|
41
|
+
const role = subjectPartyRoles.includes(source);
|
|
42
|
+
if (!role && document.parties[source]?.kind !== "business")
|
|
43
|
+
fail(declaration, `unknown economic source party ${source}`, "bind sourceParty to owner, actor, operator or a declared business");
|
|
44
|
+
if (!Object.values(parties).some((binding) => "role" in binding ? binding.role === source : binding.party === source)) {
|
|
45
|
+
let key = "economicSource";
|
|
46
|
+
for (let index = 2; Object.hasOwn(parties, key); index++)
|
|
47
|
+
key = `economicSource${index}`;
|
|
48
|
+
parties[key] = role
|
|
49
|
+
? { role: source }
|
|
50
|
+
: { party: source };
|
|
51
|
+
}
|
|
52
|
+
move.economics = economics;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=attachment-economics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-economics.js","sourceRoot":"","sources":["../../src/attachment-economics.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,GAKd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,uFAAuF;AACvF,MAAM,UAAU,wBAAwB,CACtC,QAAqB,EACrB,UAAyB,EACzB,OAA+C,EAC/C,YAAqB,EACrB,IAAmC;IAEnC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,QAA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ACvC,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,KAAK,MAAM,CACvE,EACD,CAAC;YACD,IAAI,GAAG,GAAG,gBAAgB,CAAC;YAC3B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE;gBACtD,GAAG,GAAG,iBAAiB,KAAK,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI;gBACjB,CAAC,CAAC,EAAE,IAAI,EAAE,MAA0B,EAAE;gBACtC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QACxB,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compile.ts"],"names":[],"mappings":"AAOA,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAeL,KAAK,WAAW,EAQjB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compile.ts"],"names":[],"mappings":"AAOA,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAeL,KAAK,WAAW,EAQjB,MAAM,kBAAkB,CAAC;AAU1B,OAAO,EAIL,KAAK,UAAU,EAKf,KAAK,IAAI,EACV,MAAM,UAAU,CAAC;AAClB,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;CACpC;AACD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,aAAa,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3E;AACD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,eAAe,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AACD,MAAM,WAAW,cAAc;IAC7B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC;CAClE;AACD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,SAAS,CAAC,EAAE;QACV,QAAQ,EAAE,WAAW,CAAC;QACtB,YAAY,EAAE,eAAe,CAAC;QAC9B,SAAS,EAAE,qBAAqB,EAAE,CAAC;KACpC,CAAC;CACH;AAqTD,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,cAAmB,GAC3B,aAAa,CAgnHf"}
|
package/dist/src/compile.js
CHANGED
|
@@ -5,6 +5,7 @@ import { validateUdl, resolveField, sameObjectField, subjectPartyRoles, RESERVED
|
|
|
5
5
|
import { bindingDependencies, parameterDiagnostics, BindingContractError, } from "./binding-contract.js";
|
|
6
6
|
import { tunableBounds } from "./tunables.js";
|
|
7
7
|
import { parseProgram } from "./parse.js";
|
|
8
|
+
import { applyAttachmentEconomics } from "./attachment-economics.js";
|
|
8
9
|
import { parseHeader } from "./header-source.js";
|
|
9
10
|
import { lineColAt, } from "./ast.js";
|
|
10
11
|
import { bundledStandardLibrary } from "./std-library.js";
|
|
@@ -361,8 +362,6 @@ export function compile(source, options = {}) {
|
|
|
361
362
|
parties: Object.assign(Object.create(null), {
|
|
362
363
|
programOperator: { kind: "business", role: "program_operator" },
|
|
363
364
|
programTax: { kind: "business", role: "tax_payable" },
|
|
364
|
-
programFines: { kind: "business", role: "fine_payable" },
|
|
365
|
-
programCosts: { kind: "business", role: "cost_recovery" },
|
|
366
365
|
}),
|
|
367
366
|
objects: [],
|
|
368
367
|
instruments: [],
|
|
@@ -1302,8 +1301,6 @@ export function compile(source, options = {}) {
|
|
|
1302
1301
|
f.book = t.args[1] ? text(t.args[1]) : "cash";
|
|
1303
1302
|
if (t.args[2]) {
|
|
1304
1303
|
const mode = text(t.args[2]);
|
|
1305
|
-
if (mode === "external")
|
|
1306
|
-
fail(t, "external account mode was removed", "use a reservation and instruction-bound evidence");
|
|
1307
1304
|
if (mode === "contra")
|
|
1308
1305
|
f.contra = true;
|
|
1309
1306
|
else
|
|
@@ -2082,6 +2079,8 @@ export function compile(source, options = {}) {
|
|
|
2082
2079
|
inst.actions[name] = a;
|
|
2083
2080
|
inst.actionOrder.push(name);
|
|
2084
2081
|
}
|
|
2082
|
+
if (attachmentInfo && !attachmentInfo.child)
|
|
2083
|
+
applyAttachmentEconomics(document, inst, attachmentInfo.parties, attachmentInfo.economics, data);
|
|
2085
2084
|
for (const key of [
|
|
2086
2085
|
"invariants",
|
|
2087
2086
|
"reports",
|
|
@@ -2225,9 +2224,13 @@ export function compile(source, options = {}) {
|
|
|
2225
2224
|
const renames = new Map();
|
|
2226
2225
|
const renameEntries = new Map();
|
|
2227
2226
|
const exposed = new Map();
|
|
2227
|
+
const economics = [];
|
|
2228
2228
|
const tunableEntries = [];
|
|
2229
2229
|
for (const row of attachmentBlock.entries) {
|
|
2230
|
-
if (row.key
|
|
2230
|
+
if (row.key.startsWith("economics ")) {
|
|
2231
|
+
economics.push(row);
|
|
2232
|
+
}
|
|
2233
|
+
else if (row.key === "rename") {
|
|
2231
2234
|
for (const r of asBlock(row.value).entries) {
|
|
2232
2235
|
if (renames.has(r.key))
|
|
2233
2236
|
fail(r, `duplicate rename ${r.key}`, "rename each subject field once");
|
|
@@ -2271,6 +2274,7 @@ export function compile(source, options = {}) {
|
|
|
2271
2274
|
exposed,
|
|
2272
2275
|
parties,
|
|
2273
2276
|
attachments,
|
|
2277
|
+
economics,
|
|
2274
2278
|
}, templateFamily ? { ...templateFamily } : undefined, standardOrigins.get(template));
|
|
2275
2279
|
}
|
|
2276
2280
|
catch (error) {
|
|
@@ -2891,22 +2895,6 @@ export function compile(source, options = {}) {
|
|
|
2891
2895
|
fail(objects.get(kind.id), `entry action ${name} must create an attachment as actor`, "expose its create action and bind its acting party to actor");
|
|
2892
2896
|
}
|
|
2893
2897
|
}
|
|
2894
|
-
const usedParties = new Set();
|
|
2895
|
-
const collectParties = (value) => {
|
|
2896
|
-
if (typeof value === "string") {
|
|
2897
|
-
usedParties.add(value);
|
|
2898
|
-
if (value.startsWith("party."))
|
|
2899
|
-
usedParties.add(value.split(".")[1]);
|
|
2900
|
-
}
|
|
2901
|
-
else if (Array.isArray(value))
|
|
2902
|
-
value.forEach(collectParties);
|
|
2903
|
-
else if (value && typeof value === "object")
|
|
2904
|
-
Object.values(value).forEach(collectParties);
|
|
2905
|
-
};
|
|
2906
|
-
collectParties(document.instruments);
|
|
2907
|
-
for (const party of ["programFines", "programCosts"])
|
|
2908
|
-
if (!usedParties.has(party) && !names.has(party))
|
|
2909
|
-
delete document.parties[party];
|
|
2910
2898
|
const validated = validateUdl(document);
|
|
2911
2899
|
if (!validated.ok)
|
|
2912
2900
|
return {
|