@orkestrel/program 0.0.11 → 0.0.13

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/README.md CHANGED
@@ -1,17 +1,20 @@
1
1
  # @orkestrel/program
2
2
 
3
- A **program composition layer** over
4
- [`@orkestrel/qualifier`](https://github.com/orkestrel/qualifier) and
5
- [`@orkestrel/rater`](https://github.com/orkestrel/rater): a pure,
6
- JSON-serializable `ProgramDefinition` composes one qualification with an optional
7
- rating, plus optional notices, authority, and batch aggregate policy. `Program` executes
8
- the workflow in one direction qualify the subject, stop on terminal
9
- qualification, select eligible rating lines, rate only those lines, derive status,
10
- then evaluate optional authority returning a nested `ProgramResult` (or
11
- `AggregateResult` for batch `execute`). Globally ineligible or referred subjects
12
- never reach the rater. Execution never mutates its inputs every result is a
13
- fresh object. Environment-agnostic — no I/O, no browser or server assumptions.
14
- Part of the `@orkestrel` line.
3
+ > The program composition layer: a pure, JSON-serializable `ProgramDefinition`
4
+ > that composes one qualification with an optional rating, plus notices,
5
+ > authority, and batch aggregate policy, and a `Program` that executes that
6
+ > definition in one direction qualify, select, rate, derive status, then decide.
7
+
8
+ Build a definition with the `buildProgramDefinition` function, compile it with
9
+ `createProgram`, and call `execute` with one subject for a `ProgramResult` or
10
+ with a subject array for an `AggregateResult`. Execution never mutates its
11
+ inputs; every result is a fresh object. Injected qualifier, rater, and reason
12
+ instances stay caller-owned, and a standalone program owns the engine it creates.
13
+ Built over [`@orkestrel/qualifier`](https://github.com/orkestrel/qualifier),
14
+ [`@orkestrel/rater`](https://github.com/orkestrel/rater), and the shared
15
+ [`@orkestrel/reason`](https://github.com/orkestrel/reason) engine.
16
+ Environment-agnostic — no I/O, no browser or server assumptions. Part of the
17
+ `@orkestrel` line.
15
18
 
16
19
  ## Install
17
20
 
@@ -21,52 +24,56 @@ npm install @orkestrel/program
21
24
 
22
25
  ## Requirements
23
26
 
24
- - Node.js >= 24
25
- - ESM (`import`) and CommonJS (`require`) via the `exports` field
27
+ - Node.js >= 22.12.0
28
+ - ESM (`import`) and CommonJS (`require`) through the `exports` field
26
29
 
27
30
  ## Usage
28
31
 
29
32
  ```ts
30
- import { createProgram, programDefinition } from '@orkestrel/program'
31
- import { qualificationDefinition, rulingDefinition } from '@orkestrel/qualifier'
32
- import { lineDefinition, ratingDefinition } from '@orkestrel/rater'
33
+ import { buildProgramDefinition, createProgram } from '@orkestrel/program'
34
+ import { createQualificationDefinition, createRuling } from '@orkestrel/qualifier'
35
+ import { buildLineDefinition, buildRatingDefinition } from '@orkestrel/rater'
33
36
  import {
34
- atom,
35
- factorGroup,
36
- logicalDefinition,
37
- quantitativeDefinition,
38
- rule,
39
- staticFactor,
37
+ createAtom,
38
+ createFactorGroup,
39
+ createLogicalDefinition,
40
+ createQuantitativeDefinition,
41
+ createRule,
42
+ createStaticFactor,
40
43
  } from '@orkestrel/reason'
41
44
 
42
- const gates = logicalDefinition('gates', 'Eligibility gates', [
43
- rule('licensed', [atom('licensed', 'equals', false)], atom('blocked', 'equals', true)),
45
+ const gates = createLogicalDefinition('gates', 'Eligibility gates', [
46
+ createRule(
47
+ 'licensed',
48
+ [createAtom('licensed', 'equals', false)],
49
+ createAtom('blocked', 'equals', true),
50
+ ),
44
51
  ])
45
52
 
46
- const qualification = qualificationDefinition(
53
+ const qualification = createQualificationDefinition(
47
54
  'standard-qualification',
48
55
  'Standard qualification',
49
56
  [gates],
50
57
  {
51
58
  rulings: [
52
- rulingDefinition('license', 'gates', 'licensed', 'restriction', {
59
+ createRuling('license', 'gates', 'licensed', 'restriction', {
53
60
  message: 'A license is required',
54
61
  }),
55
62
  ],
56
63
  },
57
64
  )
58
65
 
59
- const base = lineDefinition(
66
+ const base = buildLineDefinition(
60
67
  'base',
61
68
  'Base premium',
62
- quantitativeDefinition('base-rate', 'Base rate', [
63
- factorGroup('amount', 'sum', [staticFactor('minimum', 100)]),
69
+ createQuantitativeDefinition('base-rate', 'Base rate', [
70
+ createFactorGroup('amount', 'sum', [createStaticFactor('minimum', 100)]),
64
71
  ]),
65
72
  )
66
73
 
67
- const rating = ratingDefinition('standard-rating', 'Standard rating', [base])
74
+ const rating = buildRatingDefinition('standard-rating', 'Standard rating', [base])
68
75
 
69
- const definition = programDefinition('standard', 'Standard program', qualification, rating)
76
+ const definition = buildProgramDefinition('standard', 'Standard program', qualification, rating)
70
77
 
71
78
  const program = createProgram(definition)
72
79
 
@@ -102,7 +109,7 @@ one aggregate-aware batch and returns an `AggregateResult`. Every single-subject
102
109
 
103
110
  For the full surface — `Program`, `ProgramManager`, `ProgramResult`,
104
111
  `AggregateResult`, validators, factories, errors, and options — see
105
- [`guides/src/program.md`](guides/src/program.md).
112
+ [`guides/program.md`](guides/program.md).
106
113
 
107
114
  ## Package
108
115