@plures/praxis 1.4.0 → 2.0.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/dist/browser/{chunk-N63K4KWS.js → chunk-4IRUGWR3.js} +1 -1
- package/dist/browser/chunk-6MVRT7CK.js +363 -0
- package/dist/browser/chunk-6SJ44Q64.js +473 -0
- package/dist/browser/chunk-BQOYZBWA.js +282 -0
- package/dist/browser/chunk-IG5BJ2MT.js +91 -0
- package/dist/browser/{chunk-MJK3IYTJ.js → chunk-JZDJU2DO.js} +4 -84
- package/dist/browser/chunk-ZEW4LJAJ.js +353 -0
- package/dist/browser/{engine-YIEGSX7U.js → engine-3B5WJPGT.js} +2 -1
- package/dist/browser/expectations/index.d.ts +180 -0
- package/dist/browser/expectations/index.js +14 -0
- package/dist/browser/factory/index.d.ts +150 -0
- package/dist/browser/factory/index.js +15 -0
- package/dist/browser/index.d.ts +277 -3
- package/dist/browser/index.js +425 -60
- package/dist/browser/integrations/svelte.d.ts +4 -2
- package/dist/browser/integrations/svelte.js +3 -2
- package/dist/browser/project/index.d.ts +177 -0
- package/dist/browser/project/index.js +19 -0
- package/dist/browser/reactive-engine.svelte-BwWadvAW.d.ts +224 -0
- package/dist/browser/rule-result-DcXWe9tn.d.ts +206 -0
- package/dist/browser/rules-BaWMqxuG.d.ts +277 -0
- package/dist/browser/unified/index.d.ts +239 -0
- package/dist/browser/unified/index.js +20 -0
- package/dist/node/chunk-6MVRT7CK.js +363 -0
- package/dist/node/chunk-AZLNISFI.js +1690 -0
- package/dist/node/chunk-IG5BJ2MT.js +91 -0
- package/dist/node/{chunk-KMJWAFZV.js → chunk-JZDJU2DO.js} +4 -89
- package/dist/node/{chunk-7M3HV4XR.js → chunk-WFRHXZBP.js} +3 -3
- package/dist/node/cli/index.cjs +48 -0
- package/dist/node/cli/index.js +2 -2
- package/dist/node/{engine-FEN5IYZ5.js → engine-VFHCIEM4.js} +2 -1
- package/dist/node/index.cjs +2114 -0
- package/dist/node/index.d.cts +964 -280
- package/dist/node/index.d.ts +964 -280
- package/dist/node/index.js +575 -10
- package/dist/node/integrations/svelte.d.cts +3 -2
- package/dist/node/integrations/svelte.d.ts +3 -2
- package/dist/node/integrations/svelte.js +3 -2
- package/dist/node/{reactive-engine.svelte-DekxqFu0.d.ts → reactive-engine.svelte-BBZLMzus.d.ts} +3 -79
- package/dist/node/{reactive-engine.svelte-Cg0Yc2Hs.d.cts → reactive-engine.svelte-Cbq_V20o.d.cts} +3 -79
- package/dist/node/rule-result-B9GMivAn.d.cts +80 -0
- package/dist/node/rule-result-Bo3sFMmN.d.ts +80 -0
- package/dist/node/{server-SYZPDULV.js → server-FKLVY57V.js} +4 -2
- package/dist/node/unified/index.cjs +484 -0
- package/dist/node/unified/index.d.cts +240 -0
- package/dist/node/unified/index.d.ts +240 -0
- package/dist/node/unified/index.js +21 -0
- package/dist/node/{validate-TQGVIG7G.js → validate-BY7JNY7H.js} +2 -1
- package/package.json +38 -11
- package/src/__tests__/chronos-project.test.ts +799 -0
- package/src/__tests__/decision-ledger.test.ts +857 -402
- package/src/chronos/diff.ts +336 -0
- package/src/chronos/hooks.ts +227 -0
- package/src/chronos/index.ts +83 -0
- package/src/chronos/project-chronicle.ts +198 -0
- package/src/chronos/timeline.ts +152 -0
- package/src/decision-ledger/analyzer-types.ts +280 -0
- package/src/decision-ledger/analyzer.ts +518 -0
- package/src/decision-ledger/contract-verification.ts +456 -0
- package/src/decision-ledger/derivation.ts +158 -0
- package/src/decision-ledger/index.ts +59 -0
- package/src/decision-ledger/report.ts +378 -0
- package/src/decision-ledger/suggestions.ts +287 -0
- package/src/index.browser.ts +103 -0
- package/src/index.ts +98 -0
- package/src/unified/__tests__/unified.test.ts +396 -0
- package/src/unified/core.ts +517 -0
- package/src/unified/index.ts +32 -0
- package/src/unified/rules.ts +66 -0
- package/src/unified/types.ts +148 -0
- package/dist/browser/reactive-engine.svelte-DjynI82A.d.ts +0 -688
- package/dist/node/chunk-FWOXU4MM.js +0 -487
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { L as LogicEngine } from '../reactive-engine.svelte-
|
|
2
|
-
export { R as ReactiveEngineOptions, a as ReactiveLogicEngine, c as createReactiveEngine } from '../reactive-engine.svelte-
|
|
1
|
+
import { L as LogicEngine } from '../reactive-engine.svelte-Cbq_V20o.cjs';
|
|
2
|
+
export { R as ReactiveEngineOptions, a as ReactiveLogicEngine, c as createReactiveEngine } from '../reactive-engine.svelte-Cbq_V20o.cjs';
|
|
3
3
|
import { P as PraxisState, a as PraxisEvent } from '../protocol-DcyGMmWY.cjs';
|
|
4
|
+
import '../rule-result-B9GMivAn.cjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Svelte v5 Integration
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { L as LogicEngine } from '../reactive-engine.svelte-
|
|
2
|
-
export { R as ReactiveEngineOptions, a as ReactiveLogicEngine, c as createReactiveEngine } from '../reactive-engine.svelte-
|
|
1
|
+
import { L as LogicEngine } from '../reactive-engine.svelte-BBZLMzus.js';
|
|
2
|
+
export { R as ReactiveEngineOptions, a as ReactiveLogicEngine, c as createReactiveEngine } from '../reactive-engine.svelte-BBZLMzus.js';
|
|
3
3
|
import { P as PraxisState, a as PraxisEvent } from '../protocol-DcyGMmWY.js';
|
|
4
|
+
import '../rule-result-Bo3sFMmN.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Svelte v5 Integration
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ReactiveLogicEngine,
|
|
3
3
|
createReactiveEngine
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-KMJWAFZV.js";
|
|
4
|
+
} from "../chunk-WFRHXZBP.js";
|
|
6
5
|
import "../chunk-TEMFJOIH.js";
|
|
6
|
+
import "../chunk-JZDJU2DO.js";
|
|
7
|
+
import "../chunk-IG5BJ2MT.js";
|
|
7
8
|
import "../chunk-QGM4M3NI.js";
|
|
8
9
|
|
|
9
10
|
// src/integrations/svelte.ts
|
package/dist/node/{reactive-engine.svelte-DekxqFu0.d.ts → reactive-engine.svelte-BBZLMzus.d.ts}
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P as PraxisState, a as PraxisEvent, b as PraxisFact, c as PraxisStepResult, d as PraxisStepConfig, e as PraxisDiagnostics } from './protocol-DcyGMmWY.js';
|
|
2
|
+
import { R as RuleResult } from './rule-result-Bo3sFMmN.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Decision Ledger - Contract Types
|
|
@@ -162,83 +163,6 @@ interface ValidationReport {
|
|
|
162
163
|
timestamp: string;
|
|
163
164
|
}
|
|
164
165
|
|
|
165
|
-
/**
|
|
166
|
-
* The result of evaluating a rule. Every rule MUST return one of:
|
|
167
|
-
* - `RuleResult.emit(facts)` — rule produced facts
|
|
168
|
-
* - `RuleResult.noop(reason?)` — rule evaluated but had nothing to say
|
|
169
|
-
* - `RuleResult.skip(reason?)` — rule decided to skip (preconditions not met)
|
|
170
|
-
* - `RuleResult.retract(tags)` — rule retracts previously emitted facts
|
|
171
|
-
*/
|
|
172
|
-
declare class RuleResult {
|
|
173
|
-
/** The kind of result */
|
|
174
|
-
readonly kind: 'emit' | 'noop' | 'skip' | 'retract';
|
|
175
|
-
/** Facts produced (only for 'emit') */
|
|
176
|
-
readonly facts: PraxisFact[];
|
|
177
|
-
/** Fact tags to retract (only for 'retract') */
|
|
178
|
-
readonly retractTags: string[];
|
|
179
|
-
/** Optional reason (for noop/skip/retract — useful for debugging) */
|
|
180
|
-
readonly reason?: string;
|
|
181
|
-
/** The rule ID that produced this result (set by engine) */
|
|
182
|
-
ruleId?: string;
|
|
183
|
-
private constructor();
|
|
184
|
-
/**
|
|
185
|
-
* Rule produced facts.
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* return RuleResult.emit([
|
|
189
|
-
* { tag: 'sprint.behind', payload: { deficit: 5 } }
|
|
190
|
-
* ]);
|
|
191
|
-
*/
|
|
192
|
-
static emit(facts: PraxisFact[]): RuleResult;
|
|
193
|
-
/**
|
|
194
|
-
* Rule evaluated but had nothing to report.
|
|
195
|
-
* Unlike returning [], this is explicit and traceable.
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* if (ctx.completedHours >= expectedHours) {
|
|
199
|
-
* return RuleResult.noop('Sprint is on pace');
|
|
200
|
-
* }
|
|
201
|
-
*/
|
|
202
|
-
static noop(reason?: string): RuleResult;
|
|
203
|
-
/**
|
|
204
|
-
* Rule decided to skip because preconditions were not met.
|
|
205
|
-
* Distinct from noop: skip means "I can't evaluate", noop means "I evaluated and found nothing".
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
* if (!ctx.sprintName) {
|
|
209
|
-
* return RuleResult.skip('No active sprint');
|
|
210
|
-
* }
|
|
211
|
-
*/
|
|
212
|
-
static skip(reason?: string): RuleResult;
|
|
213
|
-
/**
|
|
214
|
-
* Rule retracts previously emitted facts by tag.
|
|
215
|
-
* Used when a condition that previously produced facts is no longer true.
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* // Sprint was behind, but caught up
|
|
219
|
-
* if (ctx.completedHours >= expectedHours) {
|
|
220
|
-
* return RuleResult.retract(['sprint.behind'], 'Sprint caught up');
|
|
221
|
-
* }
|
|
222
|
-
*/
|
|
223
|
-
static retract(tags: string[], reason?: string): RuleResult;
|
|
224
|
-
/** Whether this result produced facts */
|
|
225
|
-
get hasFacts(): boolean;
|
|
226
|
-
/** Whether this result retracts facts */
|
|
227
|
-
get hasRetractions(): boolean;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* A rule function that returns a typed RuleResult.
|
|
231
|
-
* New API — replaces the old PraxisFact[] return type.
|
|
232
|
-
*/
|
|
233
|
-
type TypedRuleFn<TContext = unknown> = (state: PraxisState & {
|
|
234
|
-
context: TContext;
|
|
235
|
-
events: PraxisEvent[];
|
|
236
|
-
}, events: PraxisEvent[]) => RuleResult;
|
|
237
|
-
/**
|
|
238
|
-
* Convenience: create a fact object (just a shorthand)
|
|
239
|
-
*/
|
|
240
|
-
declare function fact(tag: string, payload: unknown): PraxisFact;
|
|
241
|
-
|
|
242
166
|
/**
|
|
243
167
|
* Rules and Constraints System
|
|
244
168
|
*
|
|
@@ -634,4 +558,4 @@ declare class ReactiveLogicEngine<TContext extends object> {
|
|
|
634
558
|
*/
|
|
635
559
|
declare function createReactiveEngine<TContext extends object>(options: ReactiveEngineOptions<TContext>): ReactiveLogicEngine<TContext>;
|
|
636
560
|
|
|
637
|
-
export { type Assumption as A, type ConstraintDescriptor as C, type DefineContractOptions as D, type Example as E, LogicEngine as L, type MissingArtifact as M, PraxisRegistry as P, type ReactiveEngineOptions as R, type Severity as S, type
|
|
561
|
+
export { type Assumption as A, type ConstraintDescriptor as C, type DefineContractOptions as D, type Example as E, LogicEngine as L, type MissingArtifact as M, PraxisRegistry as P, type ReactiveEngineOptions as R, type Severity as S, type ValidationReport as V, ReactiveLogicEngine as a, type RuleDescriptor as b, createReactiveEngine as c, type ConstraintFn as d, type Contract as e, type RuleFn as f, type PraxisModule as g, type ConstraintId as h, type ContractGap as i, type PraxisEngineOptions as j, type Reference as k, type RuleId as l, createPraxisEngine as m, defineContract as n, getContract as o, isContract as p };
|
package/dist/node/{reactive-engine.svelte-Cg0Yc2Hs.d.cts → reactive-engine.svelte-Cbq_V20o.d.cts}
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P as PraxisState, a as PraxisEvent, b as PraxisFact, c as PraxisStepResult, d as PraxisStepConfig, e as PraxisDiagnostics } from './protocol-DcyGMmWY.cjs';
|
|
2
|
+
import { R as RuleResult } from './rule-result-B9GMivAn.cjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Decision Ledger - Contract Types
|
|
@@ -162,83 +163,6 @@ interface ValidationReport {
|
|
|
162
163
|
timestamp: string;
|
|
163
164
|
}
|
|
164
165
|
|
|
165
|
-
/**
|
|
166
|
-
* The result of evaluating a rule. Every rule MUST return one of:
|
|
167
|
-
* - `RuleResult.emit(facts)` — rule produced facts
|
|
168
|
-
* - `RuleResult.noop(reason?)` — rule evaluated but had nothing to say
|
|
169
|
-
* - `RuleResult.skip(reason?)` — rule decided to skip (preconditions not met)
|
|
170
|
-
* - `RuleResult.retract(tags)` — rule retracts previously emitted facts
|
|
171
|
-
*/
|
|
172
|
-
declare class RuleResult {
|
|
173
|
-
/** The kind of result */
|
|
174
|
-
readonly kind: 'emit' | 'noop' | 'skip' | 'retract';
|
|
175
|
-
/** Facts produced (only for 'emit') */
|
|
176
|
-
readonly facts: PraxisFact[];
|
|
177
|
-
/** Fact tags to retract (only for 'retract') */
|
|
178
|
-
readonly retractTags: string[];
|
|
179
|
-
/** Optional reason (for noop/skip/retract — useful for debugging) */
|
|
180
|
-
readonly reason?: string;
|
|
181
|
-
/** The rule ID that produced this result (set by engine) */
|
|
182
|
-
ruleId?: string;
|
|
183
|
-
private constructor();
|
|
184
|
-
/**
|
|
185
|
-
* Rule produced facts.
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* return RuleResult.emit([
|
|
189
|
-
* { tag: 'sprint.behind', payload: { deficit: 5 } }
|
|
190
|
-
* ]);
|
|
191
|
-
*/
|
|
192
|
-
static emit(facts: PraxisFact[]): RuleResult;
|
|
193
|
-
/**
|
|
194
|
-
* Rule evaluated but had nothing to report.
|
|
195
|
-
* Unlike returning [], this is explicit and traceable.
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* if (ctx.completedHours >= expectedHours) {
|
|
199
|
-
* return RuleResult.noop('Sprint is on pace');
|
|
200
|
-
* }
|
|
201
|
-
*/
|
|
202
|
-
static noop(reason?: string): RuleResult;
|
|
203
|
-
/**
|
|
204
|
-
* Rule decided to skip because preconditions were not met.
|
|
205
|
-
* Distinct from noop: skip means "I can't evaluate", noop means "I evaluated and found nothing".
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
* if (!ctx.sprintName) {
|
|
209
|
-
* return RuleResult.skip('No active sprint');
|
|
210
|
-
* }
|
|
211
|
-
*/
|
|
212
|
-
static skip(reason?: string): RuleResult;
|
|
213
|
-
/**
|
|
214
|
-
* Rule retracts previously emitted facts by tag.
|
|
215
|
-
* Used when a condition that previously produced facts is no longer true.
|
|
216
|
-
*
|
|
217
|
-
* @example
|
|
218
|
-
* // Sprint was behind, but caught up
|
|
219
|
-
* if (ctx.completedHours >= expectedHours) {
|
|
220
|
-
* return RuleResult.retract(['sprint.behind'], 'Sprint caught up');
|
|
221
|
-
* }
|
|
222
|
-
*/
|
|
223
|
-
static retract(tags: string[], reason?: string): RuleResult;
|
|
224
|
-
/** Whether this result produced facts */
|
|
225
|
-
get hasFacts(): boolean;
|
|
226
|
-
/** Whether this result retracts facts */
|
|
227
|
-
get hasRetractions(): boolean;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* A rule function that returns a typed RuleResult.
|
|
231
|
-
* New API — replaces the old PraxisFact[] return type.
|
|
232
|
-
*/
|
|
233
|
-
type TypedRuleFn<TContext = unknown> = (state: PraxisState & {
|
|
234
|
-
context: TContext;
|
|
235
|
-
events: PraxisEvent[];
|
|
236
|
-
}, events: PraxisEvent[]) => RuleResult;
|
|
237
|
-
/**
|
|
238
|
-
* Convenience: create a fact object (just a shorthand)
|
|
239
|
-
*/
|
|
240
|
-
declare function fact(tag: string, payload: unknown): PraxisFact;
|
|
241
|
-
|
|
242
166
|
/**
|
|
243
167
|
* Rules and Constraints System
|
|
244
168
|
*
|
|
@@ -634,4 +558,4 @@ declare class ReactiveLogicEngine<TContext extends object> {
|
|
|
634
558
|
*/
|
|
635
559
|
declare function createReactiveEngine<TContext extends object>(options: ReactiveEngineOptions<TContext>): ReactiveLogicEngine<TContext>;
|
|
636
560
|
|
|
637
|
-
export { type Assumption as A, type ConstraintDescriptor as C, type DefineContractOptions as D, type Example as E, LogicEngine as L, type MissingArtifact as M, PraxisRegistry as P, type ReactiveEngineOptions as R, type Severity as S, type
|
|
561
|
+
export { type Assumption as A, type ConstraintDescriptor as C, type DefineContractOptions as D, type Example as E, LogicEngine as L, type MissingArtifact as M, PraxisRegistry as P, type ReactiveEngineOptions as R, type Severity as S, type ValidationReport as V, ReactiveLogicEngine as a, type RuleDescriptor as b, createReactiveEngine as c, type ConstraintFn as d, type Contract as e, type RuleFn as f, type PraxisModule as g, type ConstraintId as h, type ContractGap as i, type PraxisEngineOptions as j, type Reference as k, type RuleId as l, createPraxisEngine as m, defineContract as n, getContract as o, isContract as p };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { b as PraxisFact, P as PraxisState, a as PraxisEvent } from './protocol-DcyGMmWY.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The result of evaluating a rule. Every rule MUST return one of:
|
|
5
|
+
* - `RuleResult.emit(facts)` — rule produced facts
|
|
6
|
+
* - `RuleResult.noop(reason?)` — rule evaluated but had nothing to say
|
|
7
|
+
* - `RuleResult.skip(reason?)` — rule decided to skip (preconditions not met)
|
|
8
|
+
* - `RuleResult.retract(tags)` — rule retracts previously emitted facts
|
|
9
|
+
*/
|
|
10
|
+
declare class RuleResult {
|
|
11
|
+
/** The kind of result */
|
|
12
|
+
readonly kind: 'emit' | 'noop' | 'skip' | 'retract';
|
|
13
|
+
/** Facts produced (only for 'emit') */
|
|
14
|
+
readonly facts: PraxisFact[];
|
|
15
|
+
/** Fact tags to retract (only for 'retract') */
|
|
16
|
+
readonly retractTags: string[];
|
|
17
|
+
/** Optional reason (for noop/skip/retract — useful for debugging) */
|
|
18
|
+
readonly reason?: string;
|
|
19
|
+
/** The rule ID that produced this result (set by engine) */
|
|
20
|
+
ruleId?: string;
|
|
21
|
+
private constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Rule produced facts.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* return RuleResult.emit([
|
|
27
|
+
* { tag: 'sprint.behind', payload: { deficit: 5 } }
|
|
28
|
+
* ]);
|
|
29
|
+
*/
|
|
30
|
+
static emit(facts: PraxisFact[]): RuleResult;
|
|
31
|
+
/**
|
|
32
|
+
* Rule evaluated but had nothing to report.
|
|
33
|
+
* Unlike returning [], this is explicit and traceable.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* if (ctx.completedHours >= expectedHours) {
|
|
37
|
+
* return RuleResult.noop('Sprint is on pace');
|
|
38
|
+
* }
|
|
39
|
+
*/
|
|
40
|
+
static noop(reason?: string): RuleResult;
|
|
41
|
+
/**
|
|
42
|
+
* Rule decided to skip because preconditions were not met.
|
|
43
|
+
* Distinct from noop: skip means "I can't evaluate", noop means "I evaluated and found nothing".
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* if (!ctx.sprintName) {
|
|
47
|
+
* return RuleResult.skip('No active sprint');
|
|
48
|
+
* }
|
|
49
|
+
*/
|
|
50
|
+
static skip(reason?: string): RuleResult;
|
|
51
|
+
/**
|
|
52
|
+
* Rule retracts previously emitted facts by tag.
|
|
53
|
+
* Used when a condition that previously produced facts is no longer true.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Sprint was behind, but caught up
|
|
57
|
+
* if (ctx.completedHours >= expectedHours) {
|
|
58
|
+
* return RuleResult.retract(['sprint.behind'], 'Sprint caught up');
|
|
59
|
+
* }
|
|
60
|
+
*/
|
|
61
|
+
static retract(tags: string[], reason?: string): RuleResult;
|
|
62
|
+
/** Whether this result produced facts */
|
|
63
|
+
get hasFacts(): boolean;
|
|
64
|
+
/** Whether this result retracts facts */
|
|
65
|
+
get hasRetractions(): boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A rule function that returns a typed RuleResult.
|
|
69
|
+
* New API — replaces the old PraxisFact[] return type.
|
|
70
|
+
*/
|
|
71
|
+
type TypedRuleFn<TContext = unknown> = (state: PraxisState & {
|
|
72
|
+
context: TContext;
|
|
73
|
+
events: PraxisEvent[];
|
|
74
|
+
}, events: PraxisEvent[]) => RuleResult;
|
|
75
|
+
/**
|
|
76
|
+
* Convenience: create a fact object (just a shorthand)
|
|
77
|
+
*/
|
|
78
|
+
declare function fact(tag: string, payload: unknown): PraxisFact;
|
|
79
|
+
|
|
80
|
+
export { RuleResult as R, type TypedRuleFn as T, fact as f };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { b as PraxisFact, P as PraxisState, a as PraxisEvent } from './protocol-DcyGMmWY.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The result of evaluating a rule. Every rule MUST return one of:
|
|
5
|
+
* - `RuleResult.emit(facts)` — rule produced facts
|
|
6
|
+
* - `RuleResult.noop(reason?)` — rule evaluated but had nothing to say
|
|
7
|
+
* - `RuleResult.skip(reason?)` — rule decided to skip (preconditions not met)
|
|
8
|
+
* - `RuleResult.retract(tags)` — rule retracts previously emitted facts
|
|
9
|
+
*/
|
|
10
|
+
declare class RuleResult {
|
|
11
|
+
/** The kind of result */
|
|
12
|
+
readonly kind: 'emit' | 'noop' | 'skip' | 'retract';
|
|
13
|
+
/** Facts produced (only for 'emit') */
|
|
14
|
+
readonly facts: PraxisFact[];
|
|
15
|
+
/** Fact tags to retract (only for 'retract') */
|
|
16
|
+
readonly retractTags: string[];
|
|
17
|
+
/** Optional reason (for noop/skip/retract — useful for debugging) */
|
|
18
|
+
readonly reason?: string;
|
|
19
|
+
/** The rule ID that produced this result (set by engine) */
|
|
20
|
+
ruleId?: string;
|
|
21
|
+
private constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Rule produced facts.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* return RuleResult.emit([
|
|
27
|
+
* { tag: 'sprint.behind', payload: { deficit: 5 } }
|
|
28
|
+
* ]);
|
|
29
|
+
*/
|
|
30
|
+
static emit(facts: PraxisFact[]): RuleResult;
|
|
31
|
+
/**
|
|
32
|
+
* Rule evaluated but had nothing to report.
|
|
33
|
+
* Unlike returning [], this is explicit and traceable.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* if (ctx.completedHours >= expectedHours) {
|
|
37
|
+
* return RuleResult.noop('Sprint is on pace');
|
|
38
|
+
* }
|
|
39
|
+
*/
|
|
40
|
+
static noop(reason?: string): RuleResult;
|
|
41
|
+
/**
|
|
42
|
+
* Rule decided to skip because preconditions were not met.
|
|
43
|
+
* Distinct from noop: skip means "I can't evaluate", noop means "I evaluated and found nothing".
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* if (!ctx.sprintName) {
|
|
47
|
+
* return RuleResult.skip('No active sprint');
|
|
48
|
+
* }
|
|
49
|
+
*/
|
|
50
|
+
static skip(reason?: string): RuleResult;
|
|
51
|
+
/**
|
|
52
|
+
* Rule retracts previously emitted facts by tag.
|
|
53
|
+
* Used when a condition that previously produced facts is no longer true.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Sprint was behind, but caught up
|
|
57
|
+
* if (ctx.completedHours >= expectedHours) {
|
|
58
|
+
* return RuleResult.retract(['sprint.behind'], 'Sprint caught up');
|
|
59
|
+
* }
|
|
60
|
+
*/
|
|
61
|
+
static retract(tags: string[], reason?: string): RuleResult;
|
|
62
|
+
/** Whether this result produced facts */
|
|
63
|
+
get hasFacts(): boolean;
|
|
64
|
+
/** Whether this result retracts facts */
|
|
65
|
+
get hasRetractions(): boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A rule function that returns a typed RuleResult.
|
|
69
|
+
* New API — replaces the old PraxisFact[] return type.
|
|
70
|
+
*/
|
|
71
|
+
type TypedRuleFn<TContext = unknown> = (state: PraxisState & {
|
|
72
|
+
context: TContext;
|
|
73
|
+
events: PraxisEvent[];
|
|
74
|
+
}, events: PraxisEvent[]) => RuleResult;
|
|
75
|
+
/**
|
|
76
|
+
* Convenience: create a fact object (just a shorthand)
|
|
77
|
+
*/
|
|
78
|
+
declare function fact(tag: string, payload: unknown): PraxisFact;
|
|
79
|
+
|
|
80
|
+
export { RuleResult as R, type TypedRuleFn as T, fact as f };
|
|
@@ -6,9 +6,11 @@ import {
|
|
|
6
6
|
getContractFromDescriptor
|
|
7
7
|
} from "./chunk-PGVSB6NR.js";
|
|
8
8
|
import {
|
|
9
|
-
LogicEngine
|
|
9
|
+
LogicEngine
|
|
10
|
+
} from "./chunk-JZDJU2DO.js";
|
|
11
|
+
import {
|
|
10
12
|
RuleResult
|
|
11
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-IG5BJ2MT.js";
|
|
12
14
|
import "./chunk-QGM4M3NI.js";
|
|
13
15
|
|
|
14
16
|
// src/mcp/server.ts
|