@hyperscale0/hsx 5.3.0 → 5.4.1

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 (62) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +46 -63
  3. package/bin/hsx.ts +0 -2
  4. package/dist/bin/hsx.js +0 -2
  5. package/dist/bin/hsx.js.map +1 -1
  6. package/dist/src/cli.d.ts +0 -2
  7. package/dist/src/cli.d.ts.map +1 -1
  8. package/dist/src/cli.js +9 -4
  9. package/dist/src/cli.js.map +1 -1
  10. package/dist/src/compile.d.ts.map +1 -1
  11. package/dist/src/compile.js +22 -9
  12. package/dist/src/compile.js.map +1 -1
  13. package/dist/src/examples-bundle.d.ts.map +1 -1
  14. package/dist/src/examples-bundle.js +16 -15
  15. package/dist/src/examples-bundle.js.map +1 -1
  16. package/dist/src/header-source.d.ts.map +1 -1
  17. package/dist/src/header-source.js +5 -0
  18. package/dist/src/header-source.js.map +1 -1
  19. package/dist/src/std-bundle.js +12 -12
  20. package/dist/src/std-bundle.js.map +1 -1
  21. package/dist/src/version.d.ts +1 -2
  22. package/dist/src/version.d.ts.map +1 -1
  23. package/dist/src/version.js +1 -2
  24. package/dist/src/version.js.map +1 -1
  25. package/docs/README.md +181 -30
  26. package/docs/examples.md +1 -0
  27. package/docs/headers.md +1 -1
  28. package/examples/cards.hsx +4 -0
  29. package/examples/collections.hsx +5 -2
  30. package/examples/escrow.hsx +2 -0
  31. package/examples/financing.hsx +3 -0
  32. package/examples/insurance.hsx +3 -0
  33. package/examples/lending.hsx +5 -0
  34. package/examples/library.hsx +3 -3
  35. package/examples/marketplace.hsx +6 -0
  36. package/examples/money.hsx +1 -0
  37. package/examples/rental-deposit.hsx +60 -0
  38. package/examples/repair-approval.hsx +1 -0
  39. package/examples/reporting.hsx +4 -1
  40. package/examples/savings.hsx +2 -0
  41. package/examples/serviced.hsx +5 -4
  42. package/examples/travel.hsx +3 -0
  43. package/examples/wallet.hsx +2 -0
  44. package/package.json +3 -3
  45. package/src/cli.ts +12 -6
  46. package/src/compile.ts +32 -9
  47. package/src/examples-bundle.ts +16 -15
  48. package/src/header-source.ts +10 -0
  49. package/src/std-bundle.ts +12 -12
  50. package/src/version.ts +1 -2
  51. package/std/cards.hsx +16 -0
  52. package/std/collections.hsx +15 -0
  53. package/std/escrow.hsx +20 -2
  54. package/std/financing.hsx +38 -3
  55. package/std/insurance.hsx +24 -5
  56. package/std/lending.hsx +18 -0
  57. package/std/marketplace.hsx +18 -0
  58. package/std/money.hsx +17 -0
  59. package/std/reporting.hsx +14 -0
  60. package/std/savings.hsx +32 -11
  61. package/std/travel.hsx +27 -4
  62. package/std/wallet.hsx +13 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ # HSX 5.4.1
2
+
3
+ Documentation only. The newcomer path now starts from a rental deposit
4
+ with a fixed late fee and a partial refund (`examples/rental-deposit.hsx`),
5
+ every sample program exposes agreement creation, the twelve standard
6
+ library headers explain their instruction cost in their comment blocks,
7
+ the reference explains objects versus agreements and admission versus
8
+ static acceptance before using the terms, and `llms-full.txt` links are
9
+ rebased to the package root. No compiler or standard library behaviour
10
+ changed.
11
+
12
+ # HSX 5.4.0
13
+
14
+ Standard library: financing collects the missing down payment as a
15
+ separate checkout action (`collect_down_payment`) after a signed plan,
16
+ with escrow cancel returning checkout cash when financing is abandoned;
17
+ insurance cover pays the insurer's net premium and the broker's
18
+ commission as two moves, the broker defaulting to `programOperator`;
19
+ savings memberships take a fixed seat with `preceding` recipients
20
+ counted before the pot is received; every header documents which
21
+ actions to expose and why. An instrument's own parameter shadows a
22
+ same-named sibling attachment instead of colliding with it.
23
+
24
+ Header admission refuses unsupported tunable constructors: only
25
+ `enum(choices)` and `integer(minimum, maximum)` carry arguments, so
26
+ `money(10 SAR, 20 SAR)` no longer loses its bounds silently. An
27
+ exposure alias cannot reuse another action's generated public name.
28
+ Undeclared subject-path diagnostics keep the imported header's source
29
+ location. The CLI refuses `--strict` and `--json` where they have no
30
+ effect and `check --out`, and output commands require a real
31
+ destination. The `HSX_TARGET_UDL_VERSION` export is gone and the
32
+ model-readable index heading is unversioned.
33
+
1
34
  # HSX 5.3.0
2
35
 
3
36
  Malformed strings, field constructors, lifecycle and action shapes,
package/README.md CHANGED
@@ -1,78 +1,61 @@
1
- # HSX 4
1
+ # HSX
2
2
 
3
- Read the [language reference](docs/README.md).
3
+ HSX is a typed composition language for a company's objects, agreements and
4
+ actions. Programs can model a repair approval, a rental deposit or a financing
5
+ plan. The compiler produces canonical UDL for an executor. It executes no actions.
6
+ This release supports SAR.
4
7
 
5
- Run `bun run check` to build and check this package.
8
+ ## Start here
6
9
 
7
- ## Browser language service
8
-
9
- Import `highlight` and `describe` from `@hyperscale0/hsx/language`, or
10
- `@hyperscale0/hsx/language` in the workspace. The entry has no Node imports and
11
- needs no editor framework. The playground uses it as you type and shows
12
- explanations when you point at the highlighted program or move the editor cursor.
10
+ Install the published package locally with `npm install @hyperscale0/hsx`.
11
+ Its `hsx` executable requires Node.js 22 or later. Use `npx hsx` for a local install:
13
12
 
14
- ```ts
15
- import { highlight, describe } from "@hyperscale0/hsx/language";
16
-
17
- const source = 'program shop "Shop"\nuse escrow';
18
- const spans = highlight(source);
19
- const hover = describe(source, source.indexOf("escrow"));
13
+ ```sh
14
+ npx hsx check rental.hsx
15
+ npx hsx build rental.hsx --out rental.udl.json
16
+ npx hsx cost rental.hsx
20
17
  ```
21
18
 
22
- Both functions accept incomplete source. Highlights are sorted, non-overlapping
23
- spans with half-open UTF-16 offsets. Whitespace has no span. Hover returns `null`
24
- for whitespace, unknown names and offsets outside a token. Highlight classes
25
- separate keywords, headers, instruments, actions, parties, roles, fields,
26
- parameters, types, states, money, numbers, percentages, durations, dates,
27
- strings, comments, operators, punctuation and other names.
28
-
29
- Header explanations, signatures, parameter defaults and bounds, states and action
30
- actors come from the same header manifest used by the compiler's consumers.
31
- Local explanations use the program's declarations. One keyword table owns the
32
- business explanations. Bounds retain UDL units, which are minor currency units,
33
- basis points and milliseconds for money, percentages and durations.
19
+ Start with the [first program and rental guide](docs/README.md). Save the
20
+ [rental source](examples/rental-deposit.hsx) as `rental.hsx` for these commands.
21
+ It holds 1,000 SAR, charges a one-time 50 SAR late fee, and returns the remainder.
22
+ The guide explains the fixed business binding and the host needed to execute it.
34
23
 
35
- Pass an optional `StandardLibrary` as the last argument to either function to
36
- resolve your own headers. Failed or incomplete headers keep lexical colouring.
37
- Local declaration resolution uses the parser when the document parses; incomplete
38
- documents retain token colouring, party declarations, imports and standard
39
- attachment parameters and actions. The service retains only the latest bundled
40
- library document and a bounded cache of header metadata. Returned values can be
41
- modified without changing later results.
24
+ The [header inventory](docs/headers.md) lists available instruments and tunables.
25
+ The [sample index](docs/examples.md) includes both complete action paths and
26
+ compositions that still need child-record actions or adapter bindings. A compile
27
+ pass does not prove that a flow is publicly executable or funded.
42
28
 
43
- ## Sample programs
44
-
45
- The [sample index](docs/examples.md) lists fifteen programs. Twelve introduce
46
- the standard headers through small businesses: tutoring, freelance work, used
47
- devices, prepaid workshops, tuition lending, community lending, device cover,
48
- collections, travel, employee cards, a savings circle and equipment loan reports.
49
- The authored repair approval example builds its lifecycle and evidence requirements directly. The two longer-standing examples show a minimal financed car sale and servicing
50
- with late charges and reminders.
29
+ ## Browser language service
51
30
 
52
31
  ```ts
53
- import { examples, type HsxExample } from "@hyperscale0/hsx/examples";
32
+ import { highlight, describe } from "@hyperscale0/hsx/language";
33
+ import { examples } from "@hyperscale0/hsx/examples";
54
34
 
55
- const sample: HsxExample = examples[0]!;
56
- const spans = highlight(sample.source);
35
+ const source = examples[0]!.source;
36
+ const spans = highlight(source);
37
+ const hover = describe(source, source.indexOf("program"));
57
38
  ```
58
39
 
59
- Use `@hyperscale0/hsx/examples` inside the workspace. Each record has `id`, `title`,
60
- `summary`, `headers` and `source`. The ID is the filename without `.hsx`, the title
61
- is the program's display name, and headers follow its `use` declarations in source
62
- order. The summary joins the leading `//` comments with spaces. Put the business
63
- summary before the program declaration; later comments explain individual choices.
64
- The array is sorted by filename and imports no filesystem or compiler code.
40
+ Both functions accept incomplete source and need no Node or editor framework.
41
+ Spans use half-open UTF-16 offsets. Whitespace has no span; unknown hover targets
42
+ return `null`. Pass a `StandardLibrary` as the last argument for custom headers.
43
+ Header signatures and bounds come from compiler metadata. Bounds use minor
44
+ currency units, basis points and milliseconds.
45
+
46
+ Examples have `id`, `title`, `summary`, `headers` and `source`. The ID is the
47
+ filename without `.hsx`; leading comments supply the summary. The array is sorted
48
+ by filename and contains no filesystem imports. Workspace imports use
49
+ `@hyperscale0/hsx` instead of the published `@hyperscale0/hsx` name.
50
+
51
+ ## Working from source
65
52
 
66
- Add an `.hsx` file to `examples/`, then run `bun run generate`. It writes the
67
- example bundle and sample index alongside the standard-library outputs. Package
68
- preparation also creates both bundles for a fresh checkout. `bun run check`
69
- compiles every file, checks that the generated example bytes match the source,
70
- and exercises highlighting and hover at every sample offset. A stale bundle
71
- fails the check; regenerate after an example edit.
53
+ Run `bun install` and `bun run build` in this package's public source checkout.
54
+ Run `bun bin/hsx.ts check examples/rental-deposit.hsx` to use the source CLI.
55
+ `bun run check` checks types, compiles bundled examples and checks bundle freshness.
72
56
 
73
- The insurance and travel samples name ADL adapter bindings. Compilation preserves
74
- unbound declarations, but Product creation and recomposition reject unresolved
75
- or changed adapter dependencies during Build admission. Execution checks the
76
- frozen declaration too, including adapter unavailability after a Build was saved. Dates, agreement inputs and declared business parties still
77
- need values when the product runs. A compiled sample is not a connected provider
78
- or a funded agreement.
57
+ Edit prose in `docs/README.md`, programs in `examples/`, and header comments in
58
+ `std/`. Run `bun run generate` after changing these inputs. It emits the header
59
+ and example bundles, reference indexes and model-readable files. Do not edit
60
+ `docs/headers.md`, `docs/examples.md`, `llms.txt` or `llms-full.txt` by hand.
61
+ `bun run build` also builds the browser playground.
package/bin/hsx.ts CHANGED
@@ -11,7 +11,5 @@ process.exitCode = await runCli(process.argv.slice(2), {
11
11
  err: (line) => process.stderr.write(`${line}\n`),
12
12
  out: (line) => process.stdout.write(`${line}\n`),
13
13
  readFile: (path) => readFile(path, "utf8"),
14
- stdin: process.stdin,
15
- stdout: process.stdout,
16
14
  writeFile: (path, contents) => writeFile(path, contents, "utf8"),
17
15
  });
package/dist/bin/hsx.js CHANGED
@@ -9,8 +9,6 @@ process.exitCode = await runCli(process.argv.slice(2), {
9
9
  err: (line) => process.stderr.write(`${line}\n`),
10
10
  out: (line) => process.stdout.write(`${line}\n`),
11
11
  readFile: (path) => readFile(path, "utf8"),
12
- stdin: process.stdin,
13
- stdout: process.stdout,
14
12
  writeFile: (path, contents) => writeFile(path, contents, "utf8"),
15
13
  });
16
14
  //# sourceMappingURL=hsx.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hsx.js","sourceRoot":"","sources":["../../bin/hsx.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,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,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,MAAM,EAAE,OAAO,CAAC,MAAM;IACtB,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC;CACjE,CAAC,CAAC"}
1
+ {"version":3,"file":"hsx.js","sourceRoot":"","sources":["../../bin/hsx.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,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"}
package/dist/src/cli.d.ts CHANGED
@@ -3,8 +3,6 @@ export interface Io {
3
3
  err(line: string): void;
4
4
  readFile(path: string): Promise<string>;
5
5
  writeFile(path: string, text: string): Promise<void>;
6
- stdin?: NodeJS.ReadableStream;
7
- stdout?: NodeJS.WritableStream;
8
6
  }
9
7
  export declare function runCli(argv: readonly string[], io: Io): Promise<number>;
10
8
  //# sourceMappingURL=cli.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,EAAE;IACjB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAChC;AACD,wBAAsB,MAAM,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAiE7E"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,EAAE;IACjB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtD;AACD,wBAAsB,MAAM,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAuE7E"}
package/dist/src/cli.js CHANGED
@@ -5,6 +5,7 @@ import { HSX_VERSION } from "./version.js";
5
5
  import { compile } from "./compile.js";
6
6
  import { format } from "./format.js";
7
7
  import { serializeUdl } from "@hyperscale0/udl";
8
+ const usage = "hsx build|format|cost <file> [--out path]\nhsx check <file>\nhsx headers --json";
8
9
  const standardLibrary = {
9
10
  source: (header) => {
10
11
  for (const base of ["../std/", "../../std/"]) {
@@ -26,7 +27,7 @@ export async function runCli(argv, io) {
26
27
  return 0;
27
28
  }
28
29
  if (["--help", "help", "-h"].includes(command ?? "")) {
29
- io.out("hsx build|check|format|cost <file> [--out path]");
30
+ io.out(usage);
30
31
  return 0;
31
32
  }
32
33
  if (command === "--version") {
@@ -36,14 +37,18 @@ export async function runCli(argv, io) {
36
37
  if (!command ||
37
38
  !file ||
38
39
  !["build", "check", "format", "cost"].includes(command)) {
39
- io.err("usage: hsx build|check|format|cost <file> [--out path]");
40
+ io.err(`usage:\n${usage}`);
40
41
  return 2;
41
42
  }
42
43
  let output;
43
44
  for (let i = 0; i < options.length; i++) {
44
- if (options[i] === "--out" && options[i + 1] && output === undefined)
45
+ if (command !== "check" &&
46
+ options[i] === "--out" &&
47
+ options[i + 1] &&
48
+ !options[i + 1].startsWith("--") &&
49
+ output === undefined)
45
50
  output = options[++i];
46
- else if (!["--json", "--strict"].includes(options[i])) {
51
+ else {
47
52
  io.err(`unknown option ${options[i]}`);
48
53
  return 2;
49
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,MAAM,eAAe,GAAG;IACtB,MAAM,EAAE,CAAC,MAAc,EAAE,EAAE;QACzB,KAAK,MAAM,IAAI,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,MAAM,MAAM,EAAE,OA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AC,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,CAmjGf"}
@@ -746,11 +746,15 @@ export function compile(source, options = {}) {
746
746
  (!binding ||
747
747
  (binding.kind === "name" && binding.value === expr.value)))
748
748
  return expr;
749
- // A resolved party parameter takes precedence over a same-named attachment.
749
+ // A resolved party parameter or an own parameter bound to a value takes
750
+ // precedence over a same-named sibling attachment; `limits: limits`
751
+ // binds by identity and still names the sibling.
750
752
  if (attachmentInfo && !resolvedParties.has(expr.value)) {
751
753
  const [local, ...tail] = expr.value.split(".");
754
+ const own = environment.get(local);
755
+ const ownValue = own !== undefined && !(own.kind === "name" && own.value === local);
752
756
  const target = `${attachmentInfo.subjectKindId}_${local}`;
753
- if (attachmentSubjects.has(target))
757
+ if (!ownValue && attachmentSubjects.has(target))
754
758
  return { ...expr, value: [target, ...tail].join("_") };
755
759
  }
756
760
  if (expr.value.startsWith("party.")) {
@@ -1891,7 +1895,7 @@ export function compile(source, options = {}) {
1891
1895
  }
1892
1896
  if (automatic(a.actor))
1893
1897
  delete a.publicAction;
1894
- const checkSubjectPaths = (obj, span, key = "") => {
1898
+ const checkSubjectPaths = (obj, key = "") => {
1895
1899
  if (typeof obj === "string") {
1896
1900
  if ([
1897
1901
  "field",
@@ -1906,22 +1910,22 @@ export function compile(source, options = {}) {
1906
1910
  const subField = obj.split(".")[1];
1907
1911
  const req = a.subject?.requirements.find((r) => r.field.name === subField);
1908
1912
  if (!req) {
1909
- failWithCode({ span }, "subject_field_unknown", `subject.${subField} names no declared subject requirement in action ${name}`, `declare ${subField} in subject { ... }`);
1913
+ failWithCode(row, "subject_field_unknown", `subject.${subField} names no declared subject requirement in action ${name}`, `declare ${subField} in subject { ... }`);
1910
1914
  }
1911
1915
  }
1912
1916
  }
1913
1917
  else if (Array.isArray(obj)) {
1914
1918
  for (const item of obj)
1915
- checkSubjectPaths(item, span, key);
1919
+ checkSubjectPaths(item, key);
1916
1920
  }
1917
1921
  else if (obj !== null && typeof obj === "object") {
1918
1922
  for (const [key, val] of Object.entries(obj))
1919
- checkSubjectPaths(val, span, key);
1923
+ checkSubjectPaths(val, key);
1920
1924
  }
1921
1925
  };
1922
- checkSubjectPaths(a.requires, row.span);
1923
- checkSubjectPaths(a.set, row.span);
1924
- checkSubjectPaths(a.invoke, row.span);
1926
+ checkSubjectPaths(a.requires);
1927
+ checkSubjectPaths(a.set);
1928
+ checkSubjectPaths(a.invoke);
1925
1929
  currentAction = undefined;
1926
1930
  currentActionName = undefined;
1927
1931
  for (const requirement of a.subject?.requirements ?? []) {
@@ -2443,6 +2447,15 @@ export function compile(source, options = {}) {
2443
2447
  else
2444
2448
  action.publicAction = decl.name;
2445
2449
  }
2450
+ for (const decl of program.decls) {
2451
+ if (decl.kind !== "expose")
2452
+ continue;
2453
+ const parts = decl.target.split(".");
2454
+ parts.pop();
2455
+ const instrument = document.instruments.find((item) => item.id === parts.join("_"));
2456
+ if (Object.values(instrument.actions).filter((action) => action.publicAction === decl.name).length > 1)
2457
+ fail(decl, `public action ${decl.name} is used more than once on ${parts.join(".")}`, "give each exposed action a distinct public name");
2458
+ }
2446
2459
  const usedParties = new Set();
2447
2460
  const collectParties = (value) => {
2448
2461
  if (typeof value === "string") {