@manifesto-ai/core 2.13.0 → 5.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/README.md +45 -16
- package/dist/core/action-availability.d.ts +43 -3
- package/dist/core/apply.d.ts +10 -4
- package/dist/core/compute.d.ts +3 -3
- package/dist/core/context-validation.d.ts +11 -0
- package/dist/core/index.d.ts +2 -1
- package/dist/errors.d.ts +3 -0
- package/dist/evaluator/context.d.ts +29 -4
- package/dist/evaluator/flow.d.ts +2 -0
- package/dist/factories.d.ts +4 -4
- package/dist/index.d.ts +18 -7
- package/dist/index.js +1 -1
- package/dist/schema/context.d.ts +17 -0
- package/dist/schema/domain.d.ts +9 -0
- package/dist/schema/flow.d.ts +46 -1
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/patch.d.ts +5 -1
- package/dist/schema/result.d.ts +78 -6
- package/dist/schema/snapshot.d.ts +14 -1
- package/dist/schema/trace.d.ts +2 -0
- package/dist/utils/hash.d.ts +4 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/json-value.d.ts +26 -0
- package/package.json +6 -5
- package/dist/schema/host-context.d.ts +0 -11
package/README.md
CHANGED
|
@@ -6,14 +6,33 @@
|
|
|
6
6
|
|
|
7
7
|
## What is Core?
|
|
8
8
|
|
|
9
|
-
Core is responsible for evaluating domain semantics. Given a schema, snapshot, and
|
|
9
|
+
Core is responsible for evaluating domain semantics. Given a schema, snapshot, intent, and context, it computes what patches and requirements should result—but never executes them.
|
|
10
|
+
|
|
11
|
+
Most app developers should start with `@manifesto-ai/sdk`, not this package.
|
|
12
|
+
The direct Core examples below are for custom runtime authors, test harnesses,
|
|
13
|
+
and developer tooling that needs the pure compute/apply boundary.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
const app = createManifesto<TodoDomain>(TodoMel, effects).activate();
|
|
17
|
+
await app.action.addTodo.submit("Review docs");
|
|
18
|
+
console.log(app.snapshot().state.todos);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
If you are deciding where to start:
|
|
22
|
+
|
|
23
|
+
| Goal | Start Here |
|
|
24
|
+
|------|------------|
|
|
25
|
+
| Build a web app, backend route, script, or trusted agent | `@manifesto-ai/sdk` and the main Guide |
|
|
26
|
+
| Fulfill API/database work from MEL effects | SDK effect handlers |
|
|
27
|
+
| Add approval, audit history, or restore | Lineage/Governance after the base runtime works |
|
|
28
|
+
| Test pure domain computation or build runtime tooling | This Core package |
|
|
10
29
|
|
|
11
30
|
In the Manifesto architecture:
|
|
12
31
|
|
|
13
32
|
```
|
|
14
33
|
Host -> CORE -> ComputeResult
|
|
15
34
|
|
|
|
16
|
-
Computes patches &
|
|
35
|
+
Computes patches & requirements
|
|
17
36
|
(pure, no IO, deterministic)
|
|
18
37
|
```
|
|
19
38
|
|
|
@@ -23,7 +42,7 @@ Host -> CORE -> ComputeResult
|
|
|
23
42
|
|
|
24
43
|
| Responsibility | Description |
|
|
25
44
|
|----------------|-------------|
|
|
26
|
-
| Compute state transitions | Given (schema, snapshot, intent), produce patches and
|
|
45
|
+
| Compute state transitions | Given (schema, snapshot, intent, context), produce patches and requirements |
|
|
27
46
|
| Apply patches | Transform snapshots by applying patch operations |
|
|
28
47
|
| Validate schemas | Check DomainSchema structure for correctness |
|
|
29
48
|
| Explain values | Trace why a computed value has its current result |
|
|
@@ -37,13 +56,17 @@ Host -> CORE -> ComputeResult
|
|
|
37
56
|
| Execute effects | Host |
|
|
38
57
|
| Perform IO (network, filesystem) | Host |
|
|
39
58
|
| Persist snapshots | Host |
|
|
40
|
-
|
|
|
59
|
+
| Add optional approval/history protocols | `@manifesto-ai/governance` + `@manifesto-ai/lineage` |
|
|
41
60
|
| Handle UI/event bindings | SDK |
|
|
42
61
|
|
|
43
62
|
---
|
|
44
63
|
|
|
45
64
|
## Installation
|
|
46
65
|
|
|
66
|
+
Install Core directly only when you need direct compute fixtures, custom
|
|
67
|
+
runtime internals, or low-level tooling. App code gets Core through
|
|
68
|
+
`@manifesto-ai/sdk`.
|
|
69
|
+
|
|
47
70
|
```bash
|
|
48
71
|
npm install @manifesto-ai/core
|
|
49
72
|
# or
|
|
@@ -52,11 +75,11 @@ pnpm add @manifesto-ai/core
|
|
|
52
75
|
|
|
53
76
|
---
|
|
54
77
|
|
|
55
|
-
##
|
|
78
|
+
## Direct Core Fixture
|
|
56
79
|
|
|
57
80
|
```typescript
|
|
58
81
|
import { createCore, createSnapshot, createIntent } from "@manifesto-ai/core";
|
|
59
|
-
import type { DomainSchema } from "@manifesto-ai/core";
|
|
82
|
+
import type { Context, DomainSchema } from "@manifesto-ai/core";
|
|
60
83
|
|
|
61
84
|
// Create core instance
|
|
62
85
|
const core = createCore();
|
|
@@ -85,7 +108,7 @@ const schema: DomainSchema = {
|
|
|
85
108
|
flow: {
|
|
86
109
|
kind: "patch",
|
|
87
110
|
op: "set",
|
|
88
|
-
path: "count",
|
|
111
|
+
path: [{ kind: "prop", name: "count" }],
|
|
89
112
|
value: {
|
|
90
113
|
kind: "add",
|
|
91
114
|
left: { kind: "get", path: "count" },
|
|
@@ -96,8 +119,11 @@ const schema: DomainSchema = {
|
|
|
96
119
|
},
|
|
97
120
|
};
|
|
98
121
|
|
|
99
|
-
// Create
|
|
100
|
-
const context = {
|
|
122
|
+
// Create owner-neutral ADR-027 context (deterministic inputs)
|
|
123
|
+
const context: Context = {
|
|
124
|
+
runtime: { time: { timestamp: 0 }, random: { seed: "seed" } },
|
|
125
|
+
external: {},
|
|
126
|
+
};
|
|
101
127
|
|
|
102
128
|
// Create initial snapshot
|
|
103
129
|
const snapshot = createSnapshot({ count: 0 }, schema.hash, context);
|
|
@@ -107,9 +133,12 @@ const intent = createIntent("increment", "intent-1");
|
|
|
107
133
|
|
|
108
134
|
// Compute result (pure, deterministic)
|
|
109
135
|
const result = await core.compute(schema, snapshot, intent, context);
|
|
136
|
+
const patched = core.apply(schema, snapshot, result.patches);
|
|
137
|
+
const namespaced = core.applyNamespaceDeltas(patched, result.namespaceDelta ?? []);
|
|
138
|
+
const next = core.applySystemDelta(namespaced, result.systemDelta);
|
|
110
139
|
|
|
111
140
|
console.log(result.status); // -> "complete"
|
|
112
|
-
console.log(
|
|
141
|
+
console.log(next.state.count); // -> 1
|
|
113
142
|
```
|
|
114
143
|
|
|
115
144
|
> See [GUIDE.md](docs/GUIDE.md) for the full tutorial.
|
|
@@ -127,17 +156,17 @@ function createCore(): ManifestoCore;
|
|
|
127
156
|
// Core interface
|
|
128
157
|
interface ManifestoCore {
|
|
129
158
|
compute(schema, snapshot, intent, context): Promise<ComputeResult>;
|
|
130
|
-
apply(schema, snapshot, patches
|
|
159
|
+
apply(schema, snapshot, patches): Snapshot;
|
|
131
160
|
validate(schema): ValidationResult;
|
|
132
161
|
explain(schema, snapshot, path): ExplainResult;
|
|
133
162
|
}
|
|
134
163
|
|
|
135
164
|
// Key types
|
|
136
|
-
type DomainSchema = { id, version, hash, types, state, computed, actions, meta? };
|
|
137
|
-
type Snapshot = {
|
|
165
|
+
type DomainSchema = { id, version, hash, types, state, context?, computed, actions, meta? };
|
|
166
|
+
type Snapshot = { state, computed, system, input, meta, namespaces };
|
|
138
167
|
type Intent = { type, input?, intentId };
|
|
139
168
|
type Patch = { op: "set" | "unset" | "merge", path, value? };
|
|
140
|
-
type ComputeResult = { status,
|
|
169
|
+
type ComputeResult = { status, patches, namespaceDelta?, systemDelta, trace };
|
|
141
170
|
```
|
|
142
171
|
|
|
143
172
|
> See [core-SPEC.md](docs/core-SPEC.md) for the current living specification.
|
|
@@ -152,7 +181,7 @@ All communication between Core and Host happens through Snapshot. There is no hi
|
|
|
152
181
|
|
|
153
182
|
### Deterministic Computation
|
|
154
183
|
|
|
155
|
-
Given the same (schema, snapshot, intent), Core always produces the same result. This enables:
|
|
184
|
+
Given the same (schema, snapshot, intent, context), Core always produces the same result. This enables:
|
|
156
185
|
- Reliable testing without mocks
|
|
157
186
|
- Time-travel debugging
|
|
158
187
|
- Reproducible bug reports
|
|
@@ -194,7 +223,7 @@ For typical usage, see [`@manifesto-ai/sdk`](../sdk/) — the recommended entry
|
|
|
194
223
|
|
|
195
224
|
| Document | Purpose |
|
|
196
225
|
|----------|---------|
|
|
197
|
-
| [GUIDE.md](docs/GUIDE.md) |
|
|
226
|
+
| [GUIDE.md](docs/GUIDE.md) | Direct Core fixture guide for tests, custom runtimes, and tooling |
|
|
198
227
|
| [core-SPEC.md](docs/core-SPEC.md) | Current living specification |
|
|
199
228
|
| [VERSION-INDEX.md](docs/VERSION-INDEX.md) | Current and historical document map |
|
|
200
229
|
| [FDR-v1.0.0.md](docs/FDR-v1.0.0.md) | Historical design rationale |
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DomainSchema } from "../schema/domain.js";
|
|
2
2
|
import type { Snapshot } from "../schema/snapshot.js";
|
|
3
3
|
import type { Intent } from "../schema/patch.js";
|
|
4
|
-
type ActionAvailabilityErrorCode = "UNKNOWN_ACTION" | "INTERNAL_ERROR" | "TYPE_MISMATCH";
|
|
5
|
-
type ActionDispatchabilityErrorCode = "UNKNOWN_ACTION" | "INTERNAL_ERROR" | "TYPE_MISMATCH";
|
|
4
|
+
export type ActionAvailabilityErrorCode = "UNKNOWN_ACTION" | "INTERNAL_ERROR" | "TYPE_MISMATCH";
|
|
5
|
+
export type ActionDispatchabilityErrorCode = "UNKNOWN_ACTION" | "INTERNAL_ERROR" | "TYPE_MISMATCH";
|
|
6
6
|
export type ActionAvailabilityEvaluation = {
|
|
7
7
|
kind: "ok";
|
|
8
8
|
available: boolean;
|
|
@@ -28,6 +28,10 @@ export type ActionDispatchabilityEvaluation = {
|
|
|
28
28
|
export declare function evaluateActionAvailability(schema: DomainSchema, snapshot: Snapshot, actionName: string, timestamp?: number): ActionAvailabilityEvaluation;
|
|
29
29
|
/**
|
|
30
30
|
* Check whether an action is available for a new invocation.
|
|
31
|
+
*
|
|
32
|
+
* @deprecated Use {@link evaluateActionAvailability}: this wrapper throws on
|
|
33
|
+
* evaluation errors, violating the errors-are-values contract. It will be
|
|
34
|
+
* removed in the next major release.
|
|
31
35
|
*/
|
|
32
36
|
export declare function isActionAvailable(schema: DomainSchema, snapshot: Snapshot, actionName: string): boolean;
|
|
33
37
|
/**
|
|
@@ -36,10 +40,46 @@ export declare function isActionAvailable(schema: DomainSchema, snapshot: Snapsh
|
|
|
36
40
|
export declare function evaluateIntentDispatchability(schema: DomainSchema, snapshot: Snapshot, intent: Intent, timestamp?: number): ActionDispatchabilityEvaluation;
|
|
37
41
|
/**
|
|
38
42
|
* Check whether a specific bound intent is dispatchable.
|
|
43
|
+
*
|
|
44
|
+
* @deprecated Use {@link evaluateIntentDispatchability}: this wrapper throws
|
|
45
|
+
* on evaluation errors, violating the errors-are-values contract. It will be
|
|
46
|
+
* removed in the next major release.
|
|
39
47
|
*/
|
|
40
48
|
export declare function isIntentDispatchable(schema: DomainSchema, snapshot: Snapshot, intent: Intent): boolean;
|
|
49
|
+
export type AvailableActionError = {
|
|
50
|
+
readonly actionName: string;
|
|
51
|
+
readonly code: ActionAvailabilityErrorCode;
|
|
52
|
+
readonly message: string;
|
|
53
|
+
};
|
|
54
|
+
export type AvailableActionsEvaluation = {
|
|
55
|
+
kind: "ok";
|
|
56
|
+
/** Action names whose availability evaluated to true, in schema key order. */
|
|
57
|
+
actions: readonly string[];
|
|
58
|
+
/**
|
|
59
|
+
* Actions whose availability expression failed to evaluate. They are
|
|
60
|
+
* excluded from `actions` (an action whose legality cannot be evaluated
|
|
61
|
+
* is not available), but the failure stays observable as a value so one
|
|
62
|
+
* broken expression cannot poison the whole legality query.
|
|
63
|
+
*/
|
|
64
|
+
errors: readonly AvailableActionError[];
|
|
65
|
+
} | {
|
|
66
|
+
kind: "error";
|
|
67
|
+
code: "INTERNAL_ERROR";
|
|
68
|
+
message: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Evaluate availability for every action without re-entry semantics.
|
|
72
|
+
*
|
|
73
|
+
* Per-action evaluation failures are reported as values alongside the
|
|
74
|
+
* available list; only a snapshot-level preparation failure (computed
|
|
75
|
+
* evaluation) makes the whole query fail.
|
|
76
|
+
*/
|
|
77
|
+
export declare function evaluateAvailableActions(schema: DomainSchema, snapshot: Snapshot): AvailableActionsEvaluation;
|
|
41
78
|
/**
|
|
42
79
|
* Return all currently available actions in schema key order.
|
|
80
|
+
*
|
|
81
|
+
* @deprecated Use {@link evaluateAvailableActions}: this wrapper throws on
|
|
82
|
+
* evaluation errors, violating the errors-are-values contract. It will be
|
|
83
|
+
* removed in the next major release.
|
|
43
84
|
*/
|
|
44
85
|
export declare function getAvailableActions(schema: DomainSchema, snapshot: Snapshot): readonly string[];
|
|
45
|
-
export {};
|
package/dist/core/apply.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { DomainSchema } from "../schema/domain.js";
|
|
2
2
|
import type { Snapshot } from "../schema/snapshot.js";
|
|
3
3
|
import type { Patch } from "../schema/patch.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { NamespaceDelta } from "../schema/result.js";
|
|
5
5
|
/**
|
|
6
|
-
* Apply patches to snapshot.
|
|
6
|
+
* Apply domain patches to snapshot.state and recompute computed values.
|
|
7
7
|
*
|
|
8
|
-
* Patch targets are rooted at snapshot.
|
|
8
|
+
* Patch targets are rooted at snapshot.state only.
|
|
9
9
|
* System transitions are handled by applySystemDelta().
|
|
10
10
|
*/
|
|
11
|
-
export declare function apply(schema: DomainSchema, snapshot: Snapshot, patches: readonly Patch[]
|
|
11
|
+
export declare function apply(schema: DomainSchema, snapshot: Snapshot, patches: readonly Patch[]): Snapshot;
|
|
12
|
+
/**
|
|
13
|
+
* Apply namespace transitions to snapshot.namespaces.
|
|
14
|
+
*
|
|
15
|
+
* Patch targets are rooted at snapshot.namespaces[namespace].
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyNamespaceDeltas(snapshot: Snapshot, deltas: readonly NamespaceDelta[]): Snapshot;
|
package/dist/core/compute.d.ts
CHANGED
|
@@ -2,18 +2,18 @@ import type { DomainSchema } from "../schema/domain.js";
|
|
|
2
2
|
import type { Snapshot } from "../schema/snapshot.js";
|
|
3
3
|
import type { Intent } from "../schema/patch.js";
|
|
4
4
|
import type { ComputeResult } from "../schema/result.js";
|
|
5
|
-
import type
|
|
5
|
+
import { type Context as CoreContext } from "../schema/context.js";
|
|
6
6
|
/**
|
|
7
7
|
* Compute the result of dispatching an intent (synchronous).
|
|
8
8
|
*
|
|
9
9
|
* This is the canonical computation path. Each call is independent -
|
|
10
10
|
* there is no suspended context.
|
|
11
11
|
*/
|
|
12
|
-
export declare function computeSync(schema: DomainSchema, snapshot: Snapshot, intent: Intent, context:
|
|
12
|
+
export declare function computeSync(schema: DomainSchema, snapshot: Snapshot, intent: Intent, context: CoreContext): ComputeResult;
|
|
13
13
|
/**
|
|
14
14
|
* Compute the result of dispatching an intent (async wrapper).
|
|
15
15
|
*/
|
|
16
|
-
export declare function compute(schema: DomainSchema, snapshot: Snapshot, intent: Intent, context:
|
|
16
|
+
export declare function compute(schema: DomainSchema, snapshot: Snapshot, intent: Intent, context: CoreContext): Promise<ComputeResult>;
|
|
17
17
|
/**
|
|
18
18
|
* Validate only the caller-provided input portion of an intent.
|
|
19
19
|
* Returns an error message when the intent is malformed, or null when valid.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DomainSchema } from "../schema/domain.js";
|
|
2
|
+
import type { ValidationResult } from "../schema/result.js";
|
|
3
|
+
import type { JsonValue } from "../schema/context.js";
|
|
4
|
+
/**
|
|
5
|
+
* Validate a materialized ADR-027 external context value against a schema.
|
|
6
|
+
*
|
|
7
|
+
* This helper validates only the user-owned `Context.external` partition.
|
|
8
|
+
* Manifesto-owned `Context.runtime` is validated by the canonical `Context`
|
|
9
|
+
* schema at the compute boundary.
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateExternalContext(schema: DomainSchema, external: Record<string, JsonValue>): ValidationResult;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { validate } from "./validate.js";
|
|
2
|
-
export {
|
|
2
|
+
export { validateExternalContext } from "./context-validation.js";
|
|
3
|
+
export { apply, applyNamespaceDeltas } from "./apply.js";
|
|
3
4
|
export { compute, computeSync } from "./compute.js";
|
|
4
5
|
export { explain } from "./explain.js";
|
package/dist/errors.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { ErrorValue } from "./schema/snapshot.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const CoreErrorCode: z.ZodEnum<{
|
|
7
7
|
VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
8
|
+
INVALID_PATCH_PATH: "INVALID_PATCH_PATH";
|
|
8
9
|
PATH_NOT_FOUND: "PATH_NOT_FOUND";
|
|
9
10
|
TYPE_MISMATCH: "TYPE_MISMATCH";
|
|
10
11
|
DIVISION_BY_ZERO: "DIVISION_BY_ZERO";
|
|
@@ -12,6 +13,8 @@ export declare const CoreErrorCode: z.ZodEnum<{
|
|
|
12
13
|
UNKNOWN_ACTION: "UNKNOWN_ACTION";
|
|
13
14
|
ACTION_UNAVAILABLE: "ACTION_UNAVAILABLE";
|
|
14
15
|
INVALID_INPUT: "INVALID_INPUT";
|
|
16
|
+
INVALID_VALUE: "INVALID_VALUE";
|
|
17
|
+
INVALID_CONTEXT: "INVALID_CONTEXT";
|
|
15
18
|
CYCLIC_DEPENDENCY: "CYCLIC_DEPENDENCY";
|
|
16
19
|
UNKNOWN_FLOW: "UNKNOWN_FLOW";
|
|
17
20
|
CYCLIC_CALL: "CYCLIC_CALL";
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { Snapshot } from "../schema/snapshot.js";
|
|
2
2
|
import type { DomainSchema } from "../schema/domain.js";
|
|
3
|
+
import type { Context } from "../schema/context.js";
|
|
3
4
|
import { type TraceContext } from "../schema/trace.js";
|
|
5
|
+
export type EvalPhase = "flow" | "computed" | "availability" | "dispatchability" | "snapshot";
|
|
6
|
+
type RuntimeAllocationState = {
|
|
7
|
+
ordinal: number;
|
|
8
|
+
};
|
|
4
9
|
/**
|
|
5
10
|
* Evaluation context for expressions and flows
|
|
6
11
|
*/
|
|
@@ -26,9 +31,25 @@ export type EvalContext = {
|
|
|
26
31
|
*/
|
|
27
32
|
readonly intentId?: string;
|
|
28
33
|
/**
|
|
29
|
-
*
|
|
34
|
+
* Runtime context for bound action flow evaluation.
|
|
35
|
+
*/
|
|
36
|
+
readonly context?: Context;
|
|
37
|
+
/**
|
|
38
|
+
* Current evaluation phase. Runtime/context reads are legal only in flow.
|
|
39
|
+
*/
|
|
40
|
+
readonly phase: EvalPhase;
|
|
41
|
+
/**
|
|
42
|
+
* Context-local occurrence ordinal for deterministic runtime allocation.
|
|
43
|
+
*/
|
|
44
|
+
runtimeOrdinal?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Shared deterministic runtime allocator for cloned nested evaluation contexts.
|
|
47
|
+
*/
|
|
48
|
+
runtimeAllocator?: RuntimeAllocationState;
|
|
49
|
+
/**
|
|
50
|
+
* Current expression allocation path for deterministic runtime values.
|
|
30
51
|
*/
|
|
31
|
-
|
|
52
|
+
expressionPath?: string;
|
|
32
53
|
/**
|
|
33
54
|
* Trace context for deterministic trace ID generation
|
|
34
55
|
*/
|
|
@@ -39,14 +60,17 @@ export type EvalContext = {
|
|
|
39
60
|
readonly $item?: unknown;
|
|
40
61
|
readonly $index?: number;
|
|
41
62
|
readonly $array?: unknown[];
|
|
63
|
+
readonly collectionStack?: readonly number[];
|
|
42
64
|
};
|
|
43
65
|
/**
|
|
44
66
|
* Create a new evaluation context
|
|
45
67
|
*
|
|
46
68
|
* @param timestampOrTrace - Required timestamp or TraceContext for deterministic tracing.
|
|
47
|
-
* MUST be provided by Host via HostContext.now to ensure determinism.
|
|
48
69
|
*/
|
|
49
|
-
export declare function createContext(snapshot: Snapshot, schema: DomainSchema, currentAction: string | null, nodePath: string, intentId: string | undefined, timestampOrTrace: number | TraceContext
|
|
70
|
+
export declare function createContext(snapshot: Snapshot, schema: DomainSchema, currentAction: string | null, nodePath: string, intentId: string | undefined, timestampOrTrace: number | TraceContext, options?: {
|
|
71
|
+
readonly context?: Context;
|
|
72
|
+
readonly phase?: EvalPhase;
|
|
73
|
+
}): EvalContext;
|
|
50
74
|
/**
|
|
51
75
|
* Create context with collection variables for filter/map/find/etc.
|
|
52
76
|
*/
|
|
@@ -59,3 +83,4 @@ export declare function withSnapshot(ctx: EvalContext, snapshot: Snapshot): Eval
|
|
|
59
83
|
* Update context with new node path
|
|
60
84
|
*/
|
|
61
85
|
export declare function withNodePath(ctx: EvalContext, nodePath: string): EvalContext;
|
|
86
|
+
export {};
|
package/dist/evaluator/flow.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { FlowNode } from "../schema/flow.js";
|
|
2
2
|
import type { Snapshot, Requirement, ErrorValue } from "../schema/snapshot.js";
|
|
3
3
|
import type { Patch } from "../schema/patch.js";
|
|
4
|
+
import type { NamespaceDelta } from "../schema/result.js";
|
|
4
5
|
import type { TraceNode } from "../schema/trace.js";
|
|
5
6
|
import { type EvalContext } from "./context.js";
|
|
6
7
|
/**
|
|
@@ -14,6 +15,7 @@ export type FlowState = {
|
|
|
14
15
|
readonly snapshot: Snapshot;
|
|
15
16
|
readonly status: FlowStatus;
|
|
16
17
|
readonly patches: readonly Patch[];
|
|
18
|
+
readonly namespaceDelta: readonly NamespaceDelta[];
|
|
17
19
|
readonly requirements: readonly Requirement[];
|
|
18
20
|
readonly error: ErrorValue | null;
|
|
19
21
|
};
|
package/dist/factories.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Snapshot } from "./schema/snapshot.js";
|
|
2
2
|
import type { Intent } from "./schema/patch.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Context } from "./schema/context.js";
|
|
4
4
|
/**
|
|
5
|
-
* Create a new snapshot with initial
|
|
5
|
+
* Create a new snapshot with initial state
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
7
|
+
* @param state - Initial domain state
|
|
8
8
|
* @param schemaHash - Hash of the schema this snapshot conforms to
|
|
9
9
|
* @returns New snapshot
|
|
10
10
|
*/
|
|
11
|
-
export declare function createSnapshot<T>(
|
|
11
|
+
export declare function createSnapshot<T>(state: T, schemaHash: string, context: Context): Snapshot;
|
|
12
12
|
/**
|
|
13
13
|
* Create an intent
|
|
14
14
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -9,14 +9,17 @@ import type { DomainSchema } from "./schema/domain.js";
|
|
|
9
9
|
import type { Snapshot } from "./schema/snapshot.js";
|
|
10
10
|
import type { Intent, Patch } from "./schema/patch.js";
|
|
11
11
|
import type { SemanticPath } from "./schema/common.js";
|
|
12
|
-
import type { ComputeResult, ValidationResult, ExplainResult, SystemDelta } from "./schema/result.js";
|
|
13
|
-
import type {
|
|
12
|
+
import type { ComputeResult, ValidationResult, ExplainResult, NamespaceDelta, SystemDelta } from "./schema/result.js";
|
|
13
|
+
import type { Context, JsonValue } from "./schema/context.js";
|
|
14
14
|
import { compute, computeSync, validateIntentInput } from "./core/compute.js";
|
|
15
|
-
import { apply } from "./core/apply.js";
|
|
15
|
+
import { apply, applyNamespaceDeltas } from "./core/apply.js";
|
|
16
16
|
import { applySystemDelta } from "./core/system-delta.js";
|
|
17
17
|
import { validate } from "./core/validate.js";
|
|
18
18
|
import { explain } from "./core/explain.js";
|
|
19
|
+
import { validateExternalContext } from "./core/context-validation.js";
|
|
19
20
|
import { getAvailableActions, isActionAvailable, isIntentDispatchable } from "./core/action-availability.js";
|
|
21
|
+
export { evaluateActionAvailability, evaluateAvailableActions, evaluateIntentDispatchability, } from "./core/action-availability.js";
|
|
22
|
+
export type { ActionAvailabilityErrorCode, ActionAvailabilityEvaluation, ActionDispatchabilityErrorCode, ActionDispatchabilityEvaluation, AvailableActionError, AvailableActionsEvaluation, } from "./core/action-availability.js";
|
|
20
23
|
/**
|
|
21
24
|
* ManifestoCore interface
|
|
22
25
|
*/
|
|
@@ -27,16 +30,20 @@ export interface ManifestoCore {
|
|
|
27
30
|
* This is the ONLY entry point for computation.
|
|
28
31
|
* Each call is independent - there is no suspended context.
|
|
29
32
|
*/
|
|
30
|
-
compute(schema: DomainSchema, snapshot: Snapshot, intent: Intent, context:
|
|
33
|
+
compute(schema: DomainSchema, snapshot: Snapshot, intent: Intent, context: Context): Promise<ComputeResult>;
|
|
31
34
|
/**
|
|
32
35
|
* Compute the result of dispatching an intent (synchronous).
|
|
33
36
|
*/
|
|
34
|
-
computeSync(schema: DomainSchema, snapshot: Snapshot, intent: Intent, context:
|
|
37
|
+
computeSync(schema: DomainSchema, snapshot: Snapshot, intent: Intent, context: Context): ComputeResult;
|
|
35
38
|
/**
|
|
36
39
|
* Apply patches to a snapshot.
|
|
37
40
|
* Returns new snapshot with recomputed values.
|
|
38
41
|
*/
|
|
39
|
-
apply(schema: DomainSchema, snapshot: Snapshot, patches: readonly Patch[]
|
|
42
|
+
apply(schema: DomainSchema, snapshot: Snapshot, patches: readonly Patch[]): Snapshot;
|
|
43
|
+
/**
|
|
44
|
+
* Apply namespace transitions to a snapshot.
|
|
45
|
+
*/
|
|
46
|
+
applyNamespaceDeltas(snapshot: Snapshot, deltas: readonly NamespaceDelta[]): Snapshot;
|
|
40
47
|
/**
|
|
41
48
|
* Apply a system transition emitted by compute().
|
|
42
49
|
*/
|
|
@@ -61,6 +68,10 @@ export interface ManifestoCore {
|
|
|
61
68
|
* Check whether a specific bound intent is dispatchable against the current snapshot.
|
|
62
69
|
*/
|
|
63
70
|
isIntentDispatchable(schema: DomainSchema, snapshot: Snapshot, intent: Intent): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Validate a materialized ADR-027 external context value against the schema.
|
|
73
|
+
*/
|
|
74
|
+
validateExternalContext(schema: DomainSchema, external: Record<string, JsonValue>): ValidationResult;
|
|
64
75
|
}
|
|
65
76
|
/**
|
|
66
77
|
* Create a ManifestoCore instance
|
|
@@ -71,4 +82,4 @@ export * from "./utils/index.js";
|
|
|
71
82
|
export * from "./evaluator/index.js";
|
|
72
83
|
export * from "./errors.js";
|
|
73
84
|
export * from "./factories.js";
|
|
74
|
-
export { compute, computeSync, validateIntentInput, apply, applySystemDelta, validate, explain, isActionAvailable, getAvailableActions, isIntentDispatchable, };
|
|
85
|
+
export { compute, computeSync, validateIntentInput, apply, applyNamespaceDeltas, applySystemDelta, validate, validateExternalContext, explain, isActionAvailable, getAvailableActions, isIntentDispatchable, };
|