@orkestrel/reason 0.0.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.
- package/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/src/core/index.cjs +6087 -0
- package/dist/src/core/index.cjs.map +1 -0
- package/dist/src/core/index.d.cts +4852 -0
- package/dist/src/core/index.d.ts +4852 -0
- package/dist/src/core/index.js +5912 -0
- package/dist/src/core/index.js.map +1 -0
- package/package.json +83 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Orkestrel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# @orkestrel/reason
|
|
2
|
+
|
|
3
|
+
A zero-dependency, synchronous, deterministic **reasoning engine**: declarative,
|
|
4
|
+
JSON-serializable **definitions** are evaluated against **subjects** (plain
|
|
5
|
+
data records) to produce traceable **results**. Four strategies behind one
|
|
6
|
+
dispatch surface — `quantitative` (factor-based numeric scoring), `logical`
|
|
7
|
+
(rule-based boolean deduction with forward / backward chaining), `symbolic`
|
|
8
|
+
(algebraic equation solving by variable isolation), `inferential` (fact
|
|
9
|
+
derivation with unification variables and proof trees) — each a
|
|
10
|
+
`ReasonerInterface` registered on the thin `Reason` orchestrator, with three
|
|
11
|
+
injectable operators (`Evaluator` / `Transformer` / `Aggregator`) doing the
|
|
12
|
+
shared arithmetic. Every result is a fresh object carrying `success`, a
|
|
13
|
+
human-readable `trace`, and accumulated `errors`; nothing mutates its inputs.
|
|
14
|
+
Environment-agnostic — no I/O, no browser or server assumptions. Part of the
|
|
15
|
+
`@orkestrel` line.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm install @orkestrel/reason
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Requirements
|
|
24
|
+
|
|
25
|
+
- Node.js >= 24
|
|
26
|
+
- ESM-only (no CommonJS build)
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import {
|
|
32
|
+
createQuantitativeReasoner,
|
|
33
|
+
createReason,
|
|
34
|
+
factorGroup,
|
|
35
|
+
fieldFactor,
|
|
36
|
+
quantitativeDefinition,
|
|
37
|
+
staticFactor,
|
|
38
|
+
} from '@orkestrel/reason'
|
|
39
|
+
|
|
40
|
+
const reason = createReason({ reasoners: [createQuantitativeReasoner()] })
|
|
41
|
+
|
|
42
|
+
const definition = quantitativeDefinition('risk', 'Risk score', [
|
|
43
|
+
factorGroup('drivers', 'sum', [
|
|
44
|
+
fieldFactor('age', 'age'), // reads subject.age, parseNumber-coerced
|
|
45
|
+
staticFactor('floor', 10), // a fixed contribution
|
|
46
|
+
]),
|
|
47
|
+
])
|
|
48
|
+
|
|
49
|
+
const result = reason.reason({ age: 25 }, definition) // one subject → one result
|
|
50
|
+
if (result.reasoning === 'quantitative') result.value // 35 — narrow by the discriminant
|
|
51
|
+
result.trace // the step-by-step account of how the value came to be
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`reason` dispatches by `definition.reasoning` — pass an ARRAY of subjects and
|
|
55
|
+
the batch overload maps them in order to an equal-length result array.
|
|
56
|
+
Results are a discriminated union (`reasoning` names the axis): narrow with
|
|
57
|
+
the discriminant and read the strategy-specific payload (`value` /
|
|
58
|
+
`conclusion` / `solutions` / `derived`).
|
|
59
|
+
|
|
60
|
+
## Guide
|
|
61
|
+
|
|
62
|
+
For the full surface — the orchestrator, the four reasoners, the three
|
|
63
|
+
operators, the definitions & subjects capability layer, the two workspace
|
|
64
|
+
builders (`DefinitionBuilder` / `SubjectBuilder`), validators, errors, and the
|
|
65
|
+
observation surface — see [`guides/src/reason.md`](guides/src/reason.md).
|
|
66
|
+
|
|
67
|
+
## Package
|
|
68
|
+
|
|
69
|
+
Published as a single typed entry point per the `exports` field in
|
|
70
|
+
`package.json`.
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT © [Orkestrel](https://github.com/orkestrel) — see [LICENSE](./LICENSE).
|