@plures/praxis 1.4.4 → 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-6MVRT7CK.js +363 -0
- package/dist/browser/factory/index.d.ts +2 -1
- package/dist/browser/index.d.ts +7 -4
- package/dist/browser/index.js +18 -6
- package/dist/browser/integrations/svelte.d.ts +4 -3
- package/dist/browser/project/index.d.ts +2 -1
- package/dist/browser/{reactive-engine.svelte-DgVTqHLc.d.ts → reactive-engine.svelte-BwWadvAW.d.ts} +2 -1
- package/dist/browser/rule-result-DcXWe9tn.d.ts +206 -0
- package/dist/browser/{rules-i1LHpnGd.d.ts → rules-BaWMqxuG.d.ts} +2 -205
- 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/cli/index.js +1 -1
- package/dist/node/index.cjs +367 -0
- package/dist/node/index.d.cts +4 -2
- package/dist/node/index.d.ts +4 -2
- package/dist/node/index.js +19 -7
- package/dist/node/integrations/svelte.d.cts +3 -2
- package/dist/node/integrations/svelte.d.ts +3 -2
- package/dist/node/integrations/svelte.js +2 -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/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/package.json +7 -1
- package/src/index.browser.ts +20 -0
- package/src/index.ts +21 -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/node/{chunk-ZO2LU4G4.js → chunk-WFRHXZBP.js} +3 -3
- package/dist/node/{validate-5PSWJTIC.js → validate-BY7JNY7H.js} +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -641,6 +641,7 @@ __export(src_exports, {
|
|
|
641
641
|
canvasToSchema: () => canvasToSchema,
|
|
642
642
|
canvasToYaml: () => canvasToYaml,
|
|
643
643
|
commitFromState: () => commitFromState,
|
|
644
|
+
createApp: () => createApp,
|
|
644
645
|
createBehaviorLedger: () => createBehaviorLedger,
|
|
645
646
|
createCanvasEditor: () => createCanvasEditor,
|
|
646
647
|
createChronicle: () => createChronicle,
|
|
@@ -676,7 +677,11 @@ __export(src_exports, {
|
|
|
676
677
|
defineFact: () => defineFact,
|
|
677
678
|
defineGate: () => defineGate,
|
|
678
679
|
defineModule: () => defineModule,
|
|
680
|
+
definePath: () => definePath,
|
|
679
681
|
defineRule: () => defineRule,
|
|
682
|
+
defineUnifiedConstraint: () => defineConstraint2,
|
|
683
|
+
defineUnifiedModule: () => defineModule2,
|
|
684
|
+
defineUnifiedRule: () => defineRule2,
|
|
680
685
|
diffContracts: () => diffContracts,
|
|
681
686
|
diffExpectations: () => diffExpectations,
|
|
682
687
|
diffLedgers: () => diffLedgers,
|
|
@@ -7910,6 +7915,363 @@ function fmtIds(ids) {
|
|
|
7910
7915
|
if (ids.length <= 3) return ids.join(", ");
|
|
7911
7916
|
return `${ids.slice(0, 2).join(", ")} (+${ids.length - 2} more)`;
|
|
7912
7917
|
}
|
|
7918
|
+
|
|
7919
|
+
// src/unified/core.ts
|
|
7920
|
+
var _idCounter = 0;
|
|
7921
|
+
function nextId() {
|
|
7922
|
+
return `px:${Date.now()}-${++_idCounter}`;
|
|
7923
|
+
}
|
|
7924
|
+
function createApp(config) {
|
|
7925
|
+
const paths = /* @__PURE__ */ new Map();
|
|
7926
|
+
for (const schema of config.schema) {
|
|
7927
|
+
paths.set(schema.path, {
|
|
7928
|
+
schema,
|
|
7929
|
+
value: schema.initial,
|
|
7930
|
+
subscribers: /* @__PURE__ */ new Set(),
|
|
7931
|
+
lastUpdated: 0,
|
|
7932
|
+
updateCount: 0
|
|
7933
|
+
});
|
|
7934
|
+
}
|
|
7935
|
+
let facts = [];
|
|
7936
|
+
const factMap = /* @__PURE__ */ new Map();
|
|
7937
|
+
const timeline = [];
|
|
7938
|
+
const maxTimeline = 1e4;
|
|
7939
|
+
function recordTimeline(path3, kind, data) {
|
|
7940
|
+
const entry = {
|
|
7941
|
+
id: nextId(),
|
|
7942
|
+
timestamp: Date.now(),
|
|
7943
|
+
path: path3,
|
|
7944
|
+
kind,
|
|
7945
|
+
data
|
|
7946
|
+
};
|
|
7947
|
+
timeline.push(entry);
|
|
7948
|
+
if (timeline.length > maxTimeline) {
|
|
7949
|
+
timeline.splice(0, timeline.length - maxTimeline);
|
|
7950
|
+
}
|
|
7951
|
+
}
|
|
7952
|
+
const ruleStates = (config.rules ?? []).map((rule) => ({
|
|
7953
|
+
rule,
|
|
7954
|
+
lastResult: null
|
|
7955
|
+
}));
|
|
7956
|
+
const constraints = config.constraints ?? [];
|
|
7957
|
+
const livenessConfig = config.liveness;
|
|
7958
|
+
const initTime = Date.now();
|
|
7959
|
+
let livenessTimer = null;
|
|
7960
|
+
if (livenessConfig) {
|
|
7961
|
+
const timeout = livenessConfig.timeoutMs ?? 5e3;
|
|
7962
|
+
livenessTimer = setTimeout(() => {
|
|
7963
|
+
for (const expectedPath of livenessConfig.expect) {
|
|
7964
|
+
const state2 = paths.get(expectedPath);
|
|
7965
|
+
if (!state2 || state2.updateCount === 0) {
|
|
7966
|
+
const elapsed = Date.now() - initTime;
|
|
7967
|
+
recordTimeline(expectedPath, "liveness", {
|
|
7968
|
+
stale: true,
|
|
7969
|
+
elapsed,
|
|
7970
|
+
message: `Path "${expectedPath}" never updated after ${elapsed}ms`
|
|
7971
|
+
});
|
|
7972
|
+
livenessConfig.onStale?.(expectedPath, elapsed);
|
|
7973
|
+
}
|
|
7974
|
+
}
|
|
7975
|
+
}, timeout);
|
|
7976
|
+
}
|
|
7977
|
+
function getPathValues(watchPaths) {
|
|
7978
|
+
const values = {};
|
|
7979
|
+
for (const p of watchPaths) {
|
|
7980
|
+
const state2 = paths.get(p);
|
|
7981
|
+
values[p] = state2 ? state2.value : void 0;
|
|
7982
|
+
}
|
|
7983
|
+
return values;
|
|
7984
|
+
}
|
|
7985
|
+
function notify(path3, value) {
|
|
7986
|
+
const state2 = paths.get(path3);
|
|
7987
|
+
if (!state2) return;
|
|
7988
|
+
for (const cb of state2.subscribers) {
|
|
7989
|
+
try {
|
|
7990
|
+
cb(value);
|
|
7991
|
+
} catch (err) {
|
|
7992
|
+
console.error(`[praxis] Subscriber error for "${path3}":`, err);
|
|
7993
|
+
}
|
|
7994
|
+
}
|
|
7995
|
+
}
|
|
7996
|
+
function checkConstraints(path3, value) {
|
|
7997
|
+
const violations = [];
|
|
7998
|
+
for (const c of constraints) {
|
|
7999
|
+
if (!c.watch.includes(path3)) continue;
|
|
8000
|
+
const values = getPathValues(c.watch);
|
|
8001
|
+
values[path3] = value;
|
|
8002
|
+
try {
|
|
8003
|
+
const result = c.validate(values);
|
|
8004
|
+
if (result !== true) {
|
|
8005
|
+
violations.push({
|
|
8006
|
+
kind: "constraint-violation",
|
|
8007
|
+
message: result,
|
|
8008
|
+
data: { constraintId: c.id, path: path3, description: c.description }
|
|
8009
|
+
});
|
|
8010
|
+
recordTimeline(path3, "constraint-check", {
|
|
8011
|
+
constraintId: c.id,
|
|
8012
|
+
violated: true,
|
|
8013
|
+
message: result
|
|
8014
|
+
});
|
|
8015
|
+
}
|
|
8016
|
+
} catch (err) {
|
|
8017
|
+
violations.push({
|
|
8018
|
+
kind: "constraint-violation",
|
|
8019
|
+
message: `Constraint "${c.id}" threw: ${err instanceof Error ? err.message : String(err)}`,
|
|
8020
|
+
data: { constraintId: c.id, error: err }
|
|
8021
|
+
});
|
|
8022
|
+
}
|
|
8023
|
+
}
|
|
8024
|
+
return violations;
|
|
8025
|
+
}
|
|
8026
|
+
function evaluateRules() {
|
|
8027
|
+
const newFacts = [];
|
|
8028
|
+
const retractions = [];
|
|
8029
|
+
for (const rs of ruleStates) {
|
|
8030
|
+
const values = getPathValues(rs.rule.watch);
|
|
8031
|
+
try {
|
|
8032
|
+
const result = rs.rule.evaluate(values, [...facts]);
|
|
8033
|
+
rs.lastResult = result;
|
|
8034
|
+
recordTimeline(rs.rule.watch[0] ?? "*", "rule-eval", {
|
|
8035
|
+
ruleId: rs.rule.id,
|
|
8036
|
+
kind: result.kind,
|
|
8037
|
+
reason: result.reason
|
|
8038
|
+
});
|
|
8039
|
+
switch (result.kind) {
|
|
8040
|
+
case "emit":
|
|
8041
|
+
newFacts.push(...result.facts);
|
|
8042
|
+
break;
|
|
8043
|
+
case "retract":
|
|
8044
|
+
retractions.push(...result.retractTags);
|
|
8045
|
+
break;
|
|
8046
|
+
case "noop":
|
|
8047
|
+
case "skip":
|
|
8048
|
+
break;
|
|
8049
|
+
}
|
|
8050
|
+
} catch (err) {
|
|
8051
|
+
console.error(`[praxis] Rule "${rs.rule.id}" error:`, err);
|
|
8052
|
+
}
|
|
8053
|
+
}
|
|
8054
|
+
if (retractions.length > 0) {
|
|
8055
|
+
const retractSet = new Set(retractions);
|
|
8056
|
+
for (const tag of retractSet) {
|
|
8057
|
+
factMap.delete(tag);
|
|
8058
|
+
}
|
|
8059
|
+
}
|
|
8060
|
+
for (const f of newFacts) {
|
|
8061
|
+
factMap.set(f.tag, f);
|
|
8062
|
+
}
|
|
8063
|
+
facts = Array.from(factMap.values());
|
|
8064
|
+
}
|
|
8065
|
+
function query(path3, opts) {
|
|
8066
|
+
let state2 = paths.get(path3);
|
|
8067
|
+
if (!state2) {
|
|
8068
|
+
state2 = {
|
|
8069
|
+
schema: { path: path3, initial: void 0 },
|
|
8070
|
+
value: void 0,
|
|
8071
|
+
subscribers: /* @__PURE__ */ new Set(),
|
|
8072
|
+
lastUpdated: 0,
|
|
8073
|
+
updateCount: 0
|
|
8074
|
+
};
|
|
8075
|
+
paths.set(path3, state2);
|
|
8076
|
+
}
|
|
8077
|
+
const ref = {
|
|
8078
|
+
get current() {
|
|
8079
|
+
const s = paths.get(path3);
|
|
8080
|
+
return applyQueryOpts(s?.value ?? state2.schema.initial, opts);
|
|
8081
|
+
},
|
|
8082
|
+
subscribe(cb) {
|
|
8083
|
+
const wrappedCb = (rawValue) => {
|
|
8084
|
+
const processed = applyQueryOpts(rawValue, opts);
|
|
8085
|
+
cb(processed);
|
|
8086
|
+
};
|
|
8087
|
+
const s = paths.get(path3);
|
|
8088
|
+
s.subscribers.add(wrappedCb);
|
|
8089
|
+
try {
|
|
8090
|
+
cb(ref.current);
|
|
8091
|
+
} catch (err) {
|
|
8092
|
+
console.error(`[praxis] query("${path3}") subscriber init error:`, err);
|
|
8093
|
+
}
|
|
8094
|
+
return () => {
|
|
8095
|
+
s.subscribers.delete(wrappedCb);
|
|
8096
|
+
};
|
|
8097
|
+
}
|
|
8098
|
+
};
|
|
8099
|
+
return ref;
|
|
8100
|
+
}
|
|
8101
|
+
function applyQueryOpts(value, opts) {
|
|
8102
|
+
if (!opts || !Array.isArray(value)) return value;
|
|
8103
|
+
let result = [...value];
|
|
8104
|
+
if (opts.where) result = result.filter(opts.where);
|
|
8105
|
+
if (opts.sort) result.sort(opts.sort);
|
|
8106
|
+
if (opts.select) result = result.map(opts.select);
|
|
8107
|
+
if (opts.limit) result = result.slice(0, opts.limit);
|
|
8108
|
+
return result;
|
|
8109
|
+
}
|
|
8110
|
+
function mutateInternal(path3, value) {
|
|
8111
|
+
const violations = checkConstraints(path3, value);
|
|
8112
|
+
if (violations.length > 0) {
|
|
8113
|
+
return { violations, emittedFacts: [] };
|
|
8114
|
+
}
|
|
8115
|
+
const state2 = paths.get(path3);
|
|
8116
|
+
if (!state2) {
|
|
8117
|
+
paths.set(path3, {
|
|
8118
|
+
schema: { path: path3, initial: value },
|
|
8119
|
+
value,
|
|
8120
|
+
subscribers: /* @__PURE__ */ new Set(),
|
|
8121
|
+
lastUpdated: Date.now(),
|
|
8122
|
+
updateCount: 1
|
|
8123
|
+
});
|
|
8124
|
+
} else {
|
|
8125
|
+
const before = state2.value;
|
|
8126
|
+
state2.value = value;
|
|
8127
|
+
state2.lastUpdated = Date.now();
|
|
8128
|
+
state2.updateCount++;
|
|
8129
|
+
recordTimeline(path3, "mutation", {
|
|
8130
|
+
before: summarize(before),
|
|
8131
|
+
after: summarize(value)
|
|
8132
|
+
});
|
|
8133
|
+
}
|
|
8134
|
+
notify(path3, value);
|
|
8135
|
+
const factsBefore = facts.length;
|
|
8136
|
+
evaluateRules();
|
|
8137
|
+
const emittedFacts = facts.slice(factsBefore);
|
|
8138
|
+
return { violations: [], emittedFacts };
|
|
8139
|
+
}
|
|
8140
|
+
function mutate(path3, value) {
|
|
8141
|
+
const { violations, emittedFacts } = mutateInternal(path3, value);
|
|
8142
|
+
return {
|
|
8143
|
+
accepted: violations.length === 0,
|
|
8144
|
+
violations,
|
|
8145
|
+
facts: emittedFacts
|
|
8146
|
+
};
|
|
8147
|
+
}
|
|
8148
|
+
function batchMutate(fn) {
|
|
8149
|
+
const allViolations = [];
|
|
8150
|
+
const pendingWrites = [];
|
|
8151
|
+
fn((path3, value) => {
|
|
8152
|
+
const violations = checkConstraints(path3, value);
|
|
8153
|
+
if (violations.length > 0) {
|
|
8154
|
+
allViolations.push(...violations);
|
|
8155
|
+
} else {
|
|
8156
|
+
pendingWrites.push({ path: path3, value });
|
|
8157
|
+
}
|
|
8158
|
+
});
|
|
8159
|
+
if (allViolations.length > 0) {
|
|
8160
|
+
return { accepted: false, violations: allViolations, facts: [] };
|
|
8161
|
+
}
|
|
8162
|
+
for (const { path: path3, value } of pendingWrites) {
|
|
8163
|
+
const state2 = paths.get(path3);
|
|
8164
|
+
if (state2) {
|
|
8165
|
+
const before = state2.value;
|
|
8166
|
+
state2.value = value;
|
|
8167
|
+
state2.lastUpdated = Date.now();
|
|
8168
|
+
state2.updateCount++;
|
|
8169
|
+
recordTimeline(path3, "mutation", {
|
|
8170
|
+
before: summarize(before),
|
|
8171
|
+
after: summarize(value)
|
|
8172
|
+
});
|
|
8173
|
+
} else {
|
|
8174
|
+
paths.set(path3, {
|
|
8175
|
+
schema: { path: path3, initial: value },
|
|
8176
|
+
value,
|
|
8177
|
+
subscribers: /* @__PURE__ */ new Set(),
|
|
8178
|
+
lastUpdated: Date.now(),
|
|
8179
|
+
updateCount: 1
|
|
8180
|
+
});
|
|
8181
|
+
}
|
|
8182
|
+
}
|
|
8183
|
+
for (const { path: path3, value } of pendingWrites) {
|
|
8184
|
+
notify(path3, value);
|
|
8185
|
+
}
|
|
8186
|
+
const factsBefore = facts.length;
|
|
8187
|
+
evaluateRules();
|
|
8188
|
+
return {
|
|
8189
|
+
accepted: true,
|
|
8190
|
+
violations: [],
|
|
8191
|
+
facts: facts.slice(factsBefore)
|
|
8192
|
+
};
|
|
8193
|
+
}
|
|
8194
|
+
function getLiveness() {
|
|
8195
|
+
const result = {};
|
|
8196
|
+
const now = Date.now();
|
|
8197
|
+
const watchPaths = livenessConfig?.expect ?? [];
|
|
8198
|
+
for (const p of watchPaths) {
|
|
8199
|
+
const state2 = paths.get(p);
|
|
8200
|
+
const lastUpdated = state2?.lastUpdated ?? 0;
|
|
8201
|
+
const elapsed = lastUpdated > 0 ? now - lastUpdated : now - initTime;
|
|
8202
|
+
const timeout = livenessConfig?.timeoutMs ?? 5e3;
|
|
8203
|
+
result[p] = {
|
|
8204
|
+
stale: state2?.updateCount === 0 || elapsed > timeout,
|
|
8205
|
+
lastUpdated,
|
|
8206
|
+
elapsed
|
|
8207
|
+
};
|
|
8208
|
+
}
|
|
8209
|
+
return result;
|
|
8210
|
+
}
|
|
8211
|
+
function destroy() {
|
|
8212
|
+
if (livenessTimer) clearTimeout(livenessTimer);
|
|
8213
|
+
for (const state2 of paths.values()) {
|
|
8214
|
+
state2.subscribers.clear();
|
|
8215
|
+
}
|
|
8216
|
+
paths.clear();
|
|
8217
|
+
facts = [];
|
|
8218
|
+
factMap.clear();
|
|
8219
|
+
timeline.length = 0;
|
|
8220
|
+
}
|
|
8221
|
+
return {
|
|
8222
|
+
query,
|
|
8223
|
+
mutate,
|
|
8224
|
+
batch: batchMutate,
|
|
8225
|
+
facts: () => [...facts],
|
|
8226
|
+
violations: () => {
|
|
8227
|
+
const allViolations = [];
|
|
8228
|
+
for (const c of constraints) {
|
|
8229
|
+
const values = getPathValues(c.watch);
|
|
8230
|
+
try {
|
|
8231
|
+
const result = c.validate(values);
|
|
8232
|
+
if (result !== true) {
|
|
8233
|
+
allViolations.push({
|
|
8234
|
+
kind: "constraint-violation",
|
|
8235
|
+
message: result,
|
|
8236
|
+
data: { constraintId: c.id }
|
|
8237
|
+
});
|
|
8238
|
+
}
|
|
8239
|
+
} catch {
|
|
8240
|
+
}
|
|
8241
|
+
}
|
|
8242
|
+
return allViolations;
|
|
8243
|
+
},
|
|
8244
|
+
timeline: () => [...timeline],
|
|
8245
|
+
evaluate: evaluateRules,
|
|
8246
|
+
destroy,
|
|
8247
|
+
liveness: getLiveness
|
|
8248
|
+
};
|
|
8249
|
+
}
|
|
8250
|
+
function summarize(value) {
|
|
8251
|
+
if (value === null || value === void 0) return value;
|
|
8252
|
+
if (typeof value !== "object") return value;
|
|
8253
|
+
if (Array.isArray(value)) return `[Array(${value.length})]`;
|
|
8254
|
+
const keys = Object.keys(value);
|
|
8255
|
+
if (keys.length > 10) return `{Object(${keys.length} keys)}`;
|
|
8256
|
+
return value;
|
|
8257
|
+
}
|
|
8258
|
+
|
|
8259
|
+
// src/unified/types.ts
|
|
8260
|
+
function definePath(path3, initial, opts) {
|
|
8261
|
+
return { path: path3, initial, ...opts };
|
|
8262
|
+
}
|
|
8263
|
+
|
|
8264
|
+
// src/unified/rules.ts
|
|
8265
|
+
init_rule_result();
|
|
8266
|
+
function defineRule2(rule) {
|
|
8267
|
+
return rule;
|
|
8268
|
+
}
|
|
8269
|
+
function defineConstraint2(constraint) {
|
|
8270
|
+
return constraint;
|
|
8271
|
+
}
|
|
8272
|
+
function defineModule2(name, rules) {
|
|
8273
|
+
return { name, rules };
|
|
8274
|
+
}
|
|
7913
8275
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7914
8276
|
0 && (module.exports = {
|
|
7915
8277
|
AcknowledgeContractGap,
|
|
@@ -7954,6 +8316,7 @@ function fmtIds(ids) {
|
|
|
7954
8316
|
canvasToSchema,
|
|
7955
8317
|
canvasToYaml,
|
|
7956
8318
|
commitFromState,
|
|
8319
|
+
createApp,
|
|
7957
8320
|
createBehaviorLedger,
|
|
7958
8321
|
createCanvasEditor,
|
|
7959
8322
|
createChronicle,
|
|
@@ -7989,7 +8352,11 @@ function fmtIds(ids) {
|
|
|
7989
8352
|
defineFact,
|
|
7990
8353
|
defineGate,
|
|
7991
8354
|
defineModule,
|
|
8355
|
+
definePath,
|
|
7992
8356
|
defineRule,
|
|
8357
|
+
defineUnifiedConstraint,
|
|
8358
|
+
defineUnifiedModule,
|
|
8359
|
+
defineUnifiedRule,
|
|
7993
8360
|
diffContracts,
|
|
7994
8361
|
diffExpectations,
|
|
7995
8362
|
diffLedgers,
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { P as PraxisState, a as PraxisEvent, b as PraxisFact } from './protocol-DcyGMmWY.cjs';
|
|
2
2
|
export { f as PRAXIS_PROTOCOL_VERSION, e as PraxisDiagnostics, d as PraxisStepConfig, g as PraxisStepFn, c as PraxisStepResult } from './protocol-DcyGMmWY.cjs';
|
|
3
|
-
import { L as LogicEngine, P as PraxisRegistry, b as RuleDescriptor, C as ConstraintDescriptor, d as ConstraintFn, e as Contract, f as RuleFn, g as PraxisModule, M as MissingArtifact, S as Severity, V as ValidationReport, A as Assumption } from './reactive-engine.svelte-
|
|
4
|
-
export { h as ConstraintId, i as ContractGap, D as DefineContractOptions, E as Example, j as PraxisEngineOptions, R as ReactiveEngineOptions, a as ReactiveLogicEngine, k as Reference, l as RuleId, m as
|
|
3
|
+
import { L as LogicEngine, P as PraxisRegistry, b as RuleDescriptor, C as ConstraintDescriptor, d as ConstraintFn, e as Contract, f as RuleFn, g as PraxisModule, M as MissingArtifact, S as Severity, V as ValidationReport, A as Assumption } from './reactive-engine.svelte-Cbq_V20o.cjs';
|
|
4
|
+
export { h as ConstraintId, i as ContractGap, D as DefineContractOptions, E as Example, j as PraxisEngineOptions, R as ReactiveEngineOptions, a as ReactiveLogicEngine, k as Reference, l as RuleId, m as createPraxisEngine, c as createReactiveEngine, n as defineContract, o as getContract, p as isContract } from './reactive-engine.svelte-Cbq_V20o.cjs';
|
|
5
5
|
import { P as PraxisDB, U as UnsubscribeFn$1 } from './terminal-adapter-Db-snPJ3.cjs';
|
|
6
6
|
export { C as CommandExecutor, I as InMemoryPraxisDB, a as PluresDBAdapterConfig, b as PluresDBInstance, d as PluresDBPraxisAdapter, e as PraxisLocalFirstOptions, T as TerminalAdapter, f as TerminalAdapterOptions, g as TerminalExecutionResult, h as TerminalNodeState, i as createInMemoryDB, j as createMockExecutor, k as createPluresDB, l as createPraxisLocalFirst, c as createTerminalAdapter, r as runTerminalCommand } from './terminal-adapter-Db-snPJ3.cjs';
|
|
7
7
|
import { PraxisSchema, ValidationResult, ModelDefinition, FieldDefinition, ComponentDefinition, LogicDefinition } from './schema.cjs';
|
|
8
8
|
export { NodeBindings, NodeDefinition, OrchestrationDefinition, TerminalNodeProps, ValidationError, createSchemaTemplate, validateSchema } from './schema.cjs';
|
|
9
|
+
export { R as RuleResult, T as TypedRuleFn, f as fact } from './rule-result-B9GMivAn.cjs';
|
|
10
|
+
export { LivenessConfig, MutationResult, PathSchema, PraxisApp, PraxisAppConfig, QueryOptions, ReactiveRef, UnifiedConstraint, UnifiedRule, createApp, definePath, defineConstraint as defineUnifiedConstraint, defineModule as defineUnifiedModule, defineRule as defineUnifiedRule } from './unified/index.cjs';
|
|
9
11
|
import '@plures/pluresdb/local-first';
|
|
10
12
|
|
|
11
13
|
/**
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { P as PraxisState, a as PraxisEvent, b as PraxisFact } from './protocol-DcyGMmWY.js';
|
|
2
2
|
export { f as PRAXIS_PROTOCOL_VERSION, e as PraxisDiagnostics, d as PraxisStepConfig, g as PraxisStepFn, c as PraxisStepResult } from './protocol-DcyGMmWY.js';
|
|
3
|
-
import { L as LogicEngine, P as PraxisRegistry, b as RuleDescriptor, C as ConstraintDescriptor, d as ConstraintFn, e as Contract, f as RuleFn, g as PraxisModule, M as MissingArtifact, S as Severity, V as ValidationReport, A as Assumption } from './reactive-engine.svelte-
|
|
4
|
-
export { h as ConstraintId, i as ContractGap, D as DefineContractOptions, E as Example, j as PraxisEngineOptions, R as ReactiveEngineOptions, a as ReactiveLogicEngine, k as Reference, l as RuleId, m as
|
|
3
|
+
import { L as LogicEngine, P as PraxisRegistry, b as RuleDescriptor, C as ConstraintDescriptor, d as ConstraintFn, e as Contract, f as RuleFn, g as PraxisModule, M as MissingArtifact, S as Severity, V as ValidationReport, A as Assumption } from './reactive-engine.svelte-BBZLMzus.js';
|
|
4
|
+
export { h as ConstraintId, i as ContractGap, D as DefineContractOptions, E as Example, j as PraxisEngineOptions, R as ReactiveEngineOptions, a as ReactiveLogicEngine, k as Reference, l as RuleId, m as createPraxisEngine, c as createReactiveEngine, n as defineContract, o as getContract, p as isContract } from './reactive-engine.svelte-BBZLMzus.js';
|
|
5
5
|
import { P as PraxisDB, U as UnsubscribeFn$1 } from './terminal-adapter-CvIvgTo4.js';
|
|
6
6
|
export { C as CommandExecutor, I as InMemoryPraxisDB, a as PluresDBAdapterConfig, b as PluresDBInstance, d as PluresDBPraxisAdapter, e as PraxisLocalFirstOptions, T as TerminalAdapter, f as TerminalAdapterOptions, g as TerminalExecutionResult, h as TerminalNodeState, i as createInMemoryDB, j as createMockExecutor, k as createPluresDB, l as createPraxisLocalFirst, c as createTerminalAdapter, r as runTerminalCommand } from './terminal-adapter-CvIvgTo4.js';
|
|
7
7
|
import { PraxisSchema, ValidationResult, ModelDefinition, FieldDefinition, ComponentDefinition, LogicDefinition } from './schema.js';
|
|
8
8
|
export { NodeBindings, NodeDefinition, OrchestrationDefinition, TerminalNodeProps, ValidationError, createSchemaTemplate, validateSchema } from './schema.js';
|
|
9
|
+
export { R as RuleResult, T as TypedRuleFn, f as fact } from './rule-result-Bo3sFMmN.js';
|
|
10
|
+
export { LivenessConfig, MutationResult, PathSchema, PraxisApp, PraxisAppConfig, QueryOptions, ReactiveRef, UnifiedConstraint, UnifiedRule, createApp, definePath, defineConstraint as defineUnifiedConstraint, defineModule as defineUnifiedModule, defineRule as defineUnifiedRule } from './unified/index.js';
|
|
9
11
|
import '@plures/pluresdb/local-first';
|
|
10
12
|
|
|
11
13
|
/**
|
package/dist/node/index.js
CHANGED
|
@@ -73,16 +73,15 @@ import {
|
|
|
73
73
|
import {
|
|
74
74
|
ReactiveLogicEngine,
|
|
75
75
|
createReactiveEngine
|
|
76
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-WFRHXZBP.js";
|
|
77
|
+
import {
|
|
78
|
+
PraxisRegistry
|
|
79
|
+
} from "./chunk-TEMFJOIH.js";
|
|
77
80
|
import {
|
|
78
81
|
LogicEngine,
|
|
79
82
|
PRAXIS_PROTOCOL_VERSION,
|
|
80
83
|
createPraxisEngine
|
|
81
84
|
} from "./chunk-JZDJU2DO.js";
|
|
82
|
-
import {
|
|
83
|
-
RuleResult,
|
|
84
|
-
fact
|
|
85
|
-
} from "./chunk-IG5BJ2MT.js";
|
|
86
85
|
import {
|
|
87
86
|
TerminalAdapter,
|
|
88
87
|
createMockExecutor,
|
|
@@ -105,8 +104,16 @@ import {
|
|
|
105
104
|
validateSchema
|
|
106
105
|
} from "./chunk-UATVJBNV.js";
|
|
107
106
|
import {
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
createApp,
|
|
108
|
+
defineConstraint as defineConstraint2,
|
|
109
|
+
defineModule as defineModule2,
|
|
110
|
+
definePath,
|
|
111
|
+
defineRule as defineRule2
|
|
112
|
+
} from "./chunk-6MVRT7CK.js";
|
|
113
|
+
import {
|
|
114
|
+
RuleResult,
|
|
115
|
+
fact
|
|
116
|
+
} from "./chunk-IG5BJ2MT.js";
|
|
110
117
|
import "./chunk-QGM4M3NI.js";
|
|
111
118
|
|
|
112
119
|
// src/core/reactive-engine.ts
|
|
@@ -3759,6 +3766,7 @@ export {
|
|
|
3759
3766
|
canvasToSchema,
|
|
3760
3767
|
canvasToYaml,
|
|
3761
3768
|
commitFromState,
|
|
3769
|
+
createApp,
|
|
3762
3770
|
createBehaviorLedger,
|
|
3763
3771
|
createCanvasEditor,
|
|
3764
3772
|
createChronicle,
|
|
@@ -3794,7 +3802,11 @@ export {
|
|
|
3794
3802
|
defineFact,
|
|
3795
3803
|
defineGate,
|
|
3796
3804
|
defineModule,
|
|
3805
|
+
definePath,
|
|
3797
3806
|
defineRule,
|
|
3807
|
+
defineConstraint2 as defineUnifiedConstraint,
|
|
3808
|
+
defineModule2 as defineUnifiedModule,
|
|
3809
|
+
defineRule2 as defineUnifiedRule,
|
|
3798
3810
|
diffContracts,
|
|
3799
3811
|
diffExpectations,
|
|
3800
3812
|
diffLedgers,
|
|
@@ -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,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ReactiveLogicEngine,
|
|
3
3
|
createReactiveEngine
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-WFRHXZBP.js";
|
|
5
|
+
import "../chunk-TEMFJOIH.js";
|
|
5
6
|
import "../chunk-JZDJU2DO.js";
|
|
6
7
|
import "../chunk-IG5BJ2MT.js";
|
|
7
|
-
import "../chunk-TEMFJOIH.js";
|
|
8
8
|
import "../chunk-QGM4M3NI.js";
|
|
9
9
|
|
|
10
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 };
|