@sponsio/sdk 0.1.0 → 0.2.0-alpha.8
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/contracts/benchmark/agentdojo.yaml +551 -0
- package/contracts/benchmark/odcv_bench.yaml +393 -0
- package/contracts/benchmark/redcode_exec.yaml +488 -0
- package/contracts/benchmark/swebench.yaml +176 -0
- package/contracts/benchmark/tau2_bench.yaml +984 -0
- package/contracts/capability/destructive.yaml +213 -0
- package/contracts/capability/factual-claims.yaml +79 -0
- package/contracts/capability/host-config-integrity.yaml +42 -9
- package/contracts/capability/self-modify.yaml +32 -1
- package/contracts/capability/shell.yaml +19 -10
- package/contracts/incident/claude-code-secret-bypass.yaml +48 -16
- package/contracts/incident/cursor-railway-wipe.yaml +60 -4
- package/contracts/incident/openclaw.yaml +9 -62
- package/contracts/premium/.gitkeep +5 -6
- package/dist/cli/cli.js +32 -0
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/packs.d.ts.map +1 -1
- package/dist/cli/packs.js +14 -8
- package/dist/cli/packs.js.map +1 -1
- package/dist/cli/patterns.d.ts +5 -4
- package/dist/cli/patterns.d.ts.map +1 -1
- package/dist/cli/patterns.js +11 -10
- package/dist/cli/patterns.js.map +1 -1
- package/dist/cli/prompt.js +5 -5
- package/dist/cli/prompt.js.map +1 -1
- package/dist/cli/scan.js +2 -2
- package/dist/cli/skill.d.ts +1 -1
- package/dist/cli/skill.js +1 -1
- package/dist/cli/validate.js +5 -5
- package/dist/cli/validate.js.map +1 -1
- package/dist/cloud/client.d.ts +76 -0
- package/dist/cloud/client.d.ts.map +1 -0
- package/dist/cloud/client.js +198 -0
- package/dist/cloud/client.js.map +1 -0
- package/dist/cloud/evidence.d.ts +108 -0
- package/dist/cloud/evidence.d.ts.map +1 -0
- package/dist/cloud/evidence.js +184 -0
- package/dist/cloud/evidence.js.map +1 -0
- package/dist/cloud/privacy.d.ts +67 -0
- package/dist/cloud/privacy.d.ts.map +1 -0
- package/dist/cloud/privacy.js +170 -0
- package/dist/cloud/privacy.js.map +1 -0
- package/dist/cloud/view-model.d.ts +49 -0
- package/dist/cloud/view-model.d.ts.map +1 -0
- package/dist/cloud/view-model.js +172 -0
- package/dist/cloud/view-model.js.map +1 -0
- package/dist/core/config-loader.d.ts.map +1 -1
- package/dist/core/config-loader.js +81 -9
- package/dist/core/config-loader.js.map +1 -1
- package/dist/core/evaluator.d.ts +11 -1
- package/dist/core/evaluator.d.ts.map +1 -1
- package/dist/core/evaluator.js +275 -13
- package/dist/core/evaluator.js.map +1 -1
- package/dist/core/formula.d.ts +76 -17
- package/dist/core/formula.d.ts.map +1 -1
- package/dist/core/formula.js +83 -1
- package/dist/core/formula.js.map +1 -1
- package/dist/core/grounding.d.ts +44 -8
- package/dist/core/grounding.d.ts.map +1 -1
- package/dist/core/grounding.js +197 -26
- package/dist/core/grounding.js.map +1 -1
- package/dist/core/nl-parser.d.ts +2 -2
- package/dist/core/nl-parser.d.ts.map +1 -1
- package/dist/core/nl-parser.js +617 -41
- package/dist/core/nl-parser.js.map +1 -1
- package/dist/core/pack-loader.d.ts.map +1 -1
- package/dist/core/pack-loader.js +14 -2
- package/dist/core/pack-loader.js.map +1 -1
- package/dist/core/parser.d.ts.map +1 -1
- package/dist/core/parser.js +30 -1
- package/dist/core/parser.js.map +1 -1
- package/dist/core/pattern-factory.d.ts.map +1 -1
- package/dist/core/pattern-factory.js +14 -1
- package/dist/core/pattern-factory.js.map +1 -1
- package/dist/core/patterns.d.ts +118 -1
- package/dist/core/patterns.d.ts.map +1 -1
- package/dist/core/patterns.js +189 -10
- package/dist/core/patterns.js.map +1 -1
- package/dist/core/session-log.d.ts.map +1 -1
- package/dist/core/session-log.js +20 -1
- package/dist/core/session-log.js.map +1 -1
- package/dist/core/sto.d.ts +21 -27
- package/dist/core/sto.d.ts.map +1 -1
- package/dist/core/sto.js +30 -33
- package/dist/core/sto.js.map +1 -1
- package/dist/core/tool-names.d.ts +59 -0
- package/dist/core/tool-names.d.ts.map +1 -0
- package/dist/core/tool-names.js +128 -0
- package/dist/core/tool-names.js.map +1 -0
- package/dist/index.d.ts +181 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +415 -67
- package/dist/index.js.map +1 -1
- package/dist/integrations/claude-agent.d.ts +5 -0
- package/dist/integrations/claude-agent.d.ts.map +1 -1
- package/dist/integrations/claude-agent.js +42 -13
- package/dist/integrations/claude-agent.js.map +1 -1
- package/dist/integrations/google-adk.d.ts +5 -3
- package/dist/integrations/google-adk.d.ts.map +1 -1
- package/dist/integrations/google-adk.js +9 -5
- package/dist/integrations/google-adk.js.map +1 -1
- package/dist/integrations/langchain.d.ts +7 -0
- package/dist/integrations/langchain.d.ts.map +1 -1
- package/dist/integrations/langchain.js +21 -3
- package/dist/integrations/langchain.js.map +1 -1
- package/dist/integrations/openai-agents.d.ts +22 -10
- package/dist/integrations/openai-agents.d.ts.map +1 -1
- package/dist/integrations/openai-agents.js +55 -15
- package/dist/integrations/openai-agents.js.map +1 -1
- package/dist/integrations/openai.d.ts +11 -0
- package/dist/integrations/openai.d.ts.map +1 -1
- package/dist/integrations/openai.js +130 -48
- package/dist/integrations/openai.js.map +1 -1
- package/dist/integrations/vercel-ai.d.ts +20 -9
- package/dist/integrations/vercel-ai.d.ts.map +1 -1
- package/dist/integrations/vercel-ai.js +131 -32
- package/dist/integrations/vercel-ai.js.map +1 -1
- package/package.json +17 -9
- package/prompts/onboard.md +26 -17
- package/prompts/scan.md +3 -5
- package/skills/SKILL.md +13 -83
- package/contracts/core/llm_safety.yaml +0 -140
- package/prompts/refresh.md +0 -118
package/dist/core/evaluator.d.ts
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
* X(φ) → true (weak next)
|
|
11
11
|
*/
|
|
12
12
|
import { Formula } from "./formula.js";
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* State valuation at a single timestep.
|
|
15
|
+
*
|
|
16
|
+
* Atoms emit boolean values. Counter-style Vars emit numbers.
|
|
17
|
+
* arg_value / ctx_value (used by ArgValue / CtxValue Terms) emit any
|
|
18
|
+
* raw value pushed by grounding; can be string, number, object, etc.
|
|
19
|
+
* Missing keys evaluate to ``undefined``.
|
|
20
|
+
*/
|
|
21
|
+
export type Valuation = Record<string, boolean | number | string | unknown>;
|
|
22
|
+
/** Numeric value of a numeric-looking string, else null. */
|
|
23
|
+
export declare function numericString(v: unknown): number | null;
|
|
14
24
|
export declare function evaluate(formula: Formula, trace: Valuation[], pos?: number): boolean;
|
|
15
25
|
//# sourceMappingURL=evaluator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/core/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,OAAO,EAIR,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/core/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,OAAO,EAIR,MAAM,cAAc,CAAC;AAGtB;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AA0J5E,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAYvD;AA8FD,wBAAgB,QAAQ,CACtB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,EAAE,EAClB,GAAG,GAAE,MAAU,GACd,OAAO,CAqFT"}
|
package/dist/core/evaluator.js
CHANGED
|
@@ -9,14 +9,269 @@
|
|
|
9
9
|
* U → false (ψ never discharged)
|
|
10
10
|
* X(φ) → true (weak next)
|
|
11
11
|
*/
|
|
12
|
+
import { predKey } from "./formula.js";
|
|
13
|
+
/**
|
|
14
|
+
* Resolve a Term to its underlying value at the current state.
|
|
15
|
+
*
|
|
16
|
+
* Var / Const: counter-style semantics (numeric value; 0 for missing).
|
|
17
|
+
* ArgValue / CtxValue: raw value from grounding (may be any type, or
|
|
18
|
+
* undefined when missing).
|
|
19
|
+
* UnaryFn / ArgLength: derived value (undefined when inner is missing
|
|
20
|
+
* or when the callable throws / .length is unsupported).
|
|
21
|
+
*/
|
|
12
22
|
function resolveArith(expr, state) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
switch (expr.kind) {
|
|
24
|
+
case "Const":
|
|
25
|
+
return expr.value;
|
|
26
|
+
case "Var": {
|
|
27
|
+
const key = expr.key();
|
|
28
|
+
const val = state[key];
|
|
29
|
+
if (typeof val === "number")
|
|
30
|
+
return val;
|
|
31
|
+
return 0; // counter-style default for missing
|
|
32
|
+
}
|
|
33
|
+
case "ArgValue":
|
|
34
|
+
return state[predKey("arg_value", expr.tool, expr.field)];
|
|
35
|
+
case "CtxValue":
|
|
36
|
+
return state[predKey("ctx_value", expr.key)];
|
|
37
|
+
case "ArgLength": {
|
|
38
|
+
const v = state[predKey("arg_value", expr.tool, expr.field)];
|
|
39
|
+
if (v == null)
|
|
40
|
+
return undefined;
|
|
41
|
+
try {
|
|
42
|
+
if (typeof v.length === "number") {
|
|
43
|
+
return v.length;
|
|
44
|
+
}
|
|
45
|
+
if (typeof v === "string")
|
|
46
|
+
return v.length;
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
case "UnaryFn": {
|
|
54
|
+
const inner = resolveArith(expr.arg, state);
|
|
55
|
+
if (inner === undefined || inner === null)
|
|
56
|
+
return undefined;
|
|
57
|
+
try {
|
|
58
|
+
return expr.fn(inner);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Structural value-equality, matching Python's `==` for the value
|
|
68
|
+
* shapes that flow through grounding (numbers, strings, booleans,
|
|
69
|
+
* arrays, plain objects).
|
|
70
|
+
*
|
|
71
|
+
* The naive `l === r` diverged from the Python evaluator (`left ==
|
|
72
|
+
* right`) for composite values: an `Eq(ArgValue(...), CtxValue(...))`
|
|
73
|
+
* over list- or object-valued args compares by *value* in Python
|
|
74
|
+
* (`[1] == [1]` is True) but `===` compares arrays/objects by
|
|
75
|
+
* *reference* in JS (`[1] === [1]` is False). With the v0.2 Term
|
|
76
|
+
* abstraction making value-equality reachable, that gap could pass a
|
|
77
|
+
* contract in Python and fail it in TS on the same trace. `valuesEqual`
|
|
78
|
+
* closes it with element-/key-wise deep comparison.
|
|
79
|
+
*/
|
|
80
|
+
function valuesEqual(a, b) {
|
|
81
|
+
if (a === b)
|
|
82
|
+
return true;
|
|
83
|
+
if (a === null || b === null || a === undefined || b === undefined) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
87
|
+
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return a.every((x, i) => valuesEqual(x, b[i]));
|
|
91
|
+
}
|
|
92
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
93
|
+
const ka = Object.keys(a);
|
|
94
|
+
const kb = Object.keys(b);
|
|
95
|
+
if (ka.length !== kb.length)
|
|
96
|
+
return false;
|
|
97
|
+
return ka.every((k) => Object.prototype.hasOwnProperty.call(b, k) &&
|
|
98
|
+
valuesEqual(a[k], b[k]));
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
// Plain decimal / float / scientific literal, byte-identical to the Python
|
|
103
|
+
// side (sponsio/formulas/_compare.py). Excludes inf/nan/hex/empty so
|
|
104
|
+
// Number() and Python float() agree exactly on every accepted string.
|
|
105
|
+
const ORDERED_NUMERIC_RE = /^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/;
|
|
106
|
+
// Unambiguous thousands grouping: 5,000 / 1,234,567 / 1,234,567.89.
|
|
107
|
+
const GROUPED_RE = /^[+-]?\d{1,3}(,\d{3})+(\.\d+)?$/;
|
|
108
|
+
// Unambiguous European grouping: a decimal comma after dot groups
|
|
109
|
+
// (5.000,00 / 1.234.567,89) or two or more dot groups (1.000.000). One dot
|
|
110
|
+
// group alone (5.000) is a plain float on its own.
|
|
111
|
+
const EU_GROUPED_RE = /^[+-]?\d{1,3}(\.\d{3})+,\d+$|^[+-]?\d{1,3}(\.\d{3}){2,}$/;
|
|
112
|
+
// One dot group behind a currency symbol or unit (€5.000 / 5.000 EUR): five
|
|
113
|
+
// thousand in Berlin, five with three decimals in Boston. Guessing either way
|
|
114
|
+
// changes the magnitude a thousandfold, so it is left unparsed and the
|
|
115
|
+
// numeric guard refuses it. Leading digit non-zero: nobody writes 0.500 for
|
|
116
|
+
// five hundred.
|
|
117
|
+
const EU_AMBIGUOUS_RE = /^[+-]?[1-9]\d{0,2}\.\d{3}$/;
|
|
118
|
+
// A leading currency symbol, optionally after the sign.
|
|
119
|
+
const CURRENCY_PREFIX_RE = /^([+-]?)\s*[$€£¥₹]\s*/;
|
|
120
|
+
// A trailing currency code or unit: "5000 USD", "5000USD", "12 %".
|
|
121
|
+
// No `\s*` adjacent to the anchor: `/\s*X\s*$/` is the polynomial-ReDoS
|
|
122
|
+
// shape CodeQL flags (a long run of spaces retries at every position).
|
|
123
|
+
// Whitespace is trimmed separately, and the lookbehind keeps the unit from
|
|
124
|
+
// eating the tail of a longer word.
|
|
125
|
+
const UNIT_SUFFIX_RE = /(?<![A-Za-z])(?:[A-Za-z]{2,4}|%)$/;
|
|
126
|
+
/**
|
|
127
|
+
* Strip the formatting a model wraps around a number. Mirrors
|
|
128
|
+
* ``_normalise`` in sponsio/formulas/_compare.py: a model writing a
|
|
129
|
+
* currency amount emits "$5,000" or "5000 USD" as readily as "5000", and
|
|
130
|
+
* treating those as "not a number" let them pass a cap that stopped the
|
|
131
|
+
* plain form. Commas are removed only in unambiguous thousands grouping,
|
|
132
|
+
* never from "5,50", where the comma may be a decimal separator. European
|
|
133
|
+
* grouping is read when unambiguous ("5.000,00", "1.000.000"); "€5.000" is
|
|
134
|
+
* returned unparsed so the guard refuses it, and a bare "5.000" stays 5.
|
|
135
|
+
*/
|
|
136
|
+
function normaliseNumeric(v) {
|
|
137
|
+
const original = v.trim();
|
|
138
|
+
let s = original.replace(CURRENCY_PREFIX_RE, "$1");
|
|
139
|
+
const currency = s !== original;
|
|
140
|
+
const strippedUnit = s.replace(UNIT_SUFFIX_RE, "").trimEnd();
|
|
141
|
+
// Only drop the suffix if a number is left; "USD" alone must stay
|
|
142
|
+
// unparsed, and the exponent in "1e5" must not be read as a unit.
|
|
143
|
+
let unit = false;
|
|
144
|
+
if (strippedUnit && strippedUnit !== s) {
|
|
145
|
+
const bare = strippedUnit.replace(/ /g, "");
|
|
146
|
+
if (GROUPED_RE.test(bare) ||
|
|
147
|
+
ORDERED_NUMERIC_RE.test(strippedUnit) ||
|
|
148
|
+
EU_GROUPED_RE.test(bare) ||
|
|
149
|
+
EU_AMBIGUOUS_RE.test(bare)) {
|
|
150
|
+
s = strippedUnit;
|
|
151
|
+
unit = true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
s = s.trim();
|
|
155
|
+
if (EU_GROUPED_RE.test(s))
|
|
156
|
+
return s.replace(/\./g, "").replace(",", ".");
|
|
157
|
+
if ((currency || unit) && EU_AMBIGUOUS_RE.test(s))
|
|
158
|
+
return original;
|
|
159
|
+
if (GROUPED_RE.test(s))
|
|
160
|
+
s = s.replace(/,/g, "");
|
|
161
|
+
return s;
|
|
162
|
+
}
|
|
163
|
+
/** Numeric value of a numeric-looking string, else null. */
|
|
164
|
+
export function numericString(v) {
|
|
165
|
+
if (typeof v === "string") {
|
|
166
|
+
const s = normaliseNumeric(v);
|
|
167
|
+
if (ORDERED_NUMERIC_RE.test(s)) {
|
|
168
|
+
const n = Number(s);
|
|
169
|
+
// Overflow to Infinity is kept, matching Python's float(): the value
|
|
170
|
+
// really is larger than the runtime can hold, so a cap should fire
|
|
171
|
+
// rather than be skipped on one runtime and not the other.
|
|
172
|
+
if (!Number.isNaN(n))
|
|
173
|
+
return n;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
// Values already reported, so a loop over the same bad argument warns once.
|
|
179
|
+
const WARNED_INCOMPARABLE = new Set();
|
|
180
|
+
/**
|
|
181
|
+
* Say so when a numeric guard meets a value it cannot read as a number.
|
|
182
|
+
*
|
|
183
|
+
* The comparison still falls through to False (the Hoare-vacuity
|
|
184
|
+
* convention), which for a ``G(!(amount > cap))`` guard means the call is
|
|
185
|
+
* NOT constrained. That is a contract not protecting what its author
|
|
186
|
+
* believes it protects, so it is reported once per value. Mirrors
|
|
187
|
+
* ``_warn_incomparable`` in sponsio/formulas/_compare.py.
|
|
188
|
+
*/
|
|
189
|
+
function warnIncomparable(value) {
|
|
190
|
+
const key = value.slice(0, 120);
|
|
191
|
+
if (WARNED_INCOMPARABLE.has(key))
|
|
192
|
+
return;
|
|
193
|
+
WARNED_INCOMPARABLE.add(key);
|
|
194
|
+
console.warn(`[sponsio] numeric guard received a non-numeric value ` +
|
|
195
|
+
`${JSON.stringify(value.slice(0, 60))}; the comparison cannot be ` +
|
|
196
|
+
`evaluated and the guard does NOT constrain this call. Normalise the ` +
|
|
197
|
+
`argument, or express the rule with \`arg_blacklist\` / ` +
|
|
198
|
+
`\`arg_field_has\` so it matches on text.`);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Whether two operands are order-comparable the way Python is: two numbers,
|
|
202
|
+
* two strings, or bool/number mixes (Python treats bool as int). Anything
|
|
203
|
+
* else raises TypeError in Python, so we must return False rather than let
|
|
204
|
+
* JavaScript silently coerce.
|
|
205
|
+
*/
|
|
206
|
+
function orderComparable(l, r) {
|
|
207
|
+
const tl = typeof l;
|
|
208
|
+
const tr = typeof r;
|
|
209
|
+
if (tl === "number" && tr === "number")
|
|
210
|
+
return true;
|
|
211
|
+
if (tl === "string" && tr === "string")
|
|
212
|
+
return true;
|
|
213
|
+
if ((tl === "boolean" || tl === "number") && (tr === "boolean" || tr === "number")) {
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Compare two resolved values with the canonical "missing" semantics.
|
|
220
|
+
*
|
|
221
|
+
* If either operand is undefined / null, the comparison is False (the
|
|
222
|
+
* comparison cannot decide). Same for type errors (mismatched types).
|
|
223
|
+
* This is the Hoare-vacuity convention. `eq` uses `valuesEqual` for
|
|
224
|
+
* Python `==` parity on composite values.
|
|
225
|
+
*
|
|
226
|
+
* Ordered comparisons coerce a plain-numeric string operand (e.g. a raw
|
|
227
|
+
* `"5000"` tool argument) to a number when the other operand is numeric, so
|
|
228
|
+
* a numeric guard compares numerically and fails closed — identically to the
|
|
229
|
+
* Python runtime. Non-coercible mismatched operands return False (mirroring
|
|
230
|
+
* Python's TypeError) instead of using JavaScript's implicit coercion.
|
|
231
|
+
* See issue #108.
|
|
232
|
+
*/
|
|
233
|
+
function safeCompare(op, left, right) {
|
|
234
|
+
if (left === undefined || left === null)
|
|
235
|
+
return false;
|
|
236
|
+
if (right === undefined || right === null)
|
|
237
|
+
return false;
|
|
238
|
+
let l = left;
|
|
239
|
+
let r = right;
|
|
240
|
+
if (op !== "eq") {
|
|
241
|
+
if (typeof l === "number" && typeof r === "string") {
|
|
242
|
+
const n = numericString(r);
|
|
243
|
+
if (n !== null)
|
|
244
|
+
r = n;
|
|
245
|
+
else
|
|
246
|
+
warnIncomparable(r);
|
|
247
|
+
}
|
|
248
|
+
else if (typeof r === "number" && typeof l === "string") {
|
|
249
|
+
const n = numericString(l);
|
|
250
|
+
if (n !== null)
|
|
251
|
+
l = n;
|
|
252
|
+
else
|
|
253
|
+
warnIncomparable(l);
|
|
254
|
+
}
|
|
255
|
+
if (!orderComparable(l, r))
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
try {
|
|
259
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
260
|
+
const la = l;
|
|
261
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
262
|
+
const ra = r;
|
|
263
|
+
switch (op) {
|
|
264
|
+
case "le": return la <= ra;
|
|
265
|
+
case "lt": return la < ra;
|
|
266
|
+
case "ge": return la >= ra;
|
|
267
|
+
case "gt": return la > ra;
|
|
268
|
+
case "eq": return valuesEqual(la, ra);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
return false;
|
|
20
275
|
}
|
|
21
276
|
export function evaluate(formula, trace, pos = 0) {
|
|
22
277
|
// Past end of trace — weak semantics
|
|
@@ -63,21 +318,28 @@ export function evaluate(formula, trace, pos = 0) {
|
|
|
63
318
|
return false;
|
|
64
319
|
}
|
|
65
320
|
return false; // ψ never became true
|
|
66
|
-
// --- Arithmetic ---
|
|
321
|
+
// --- Arithmetic / Term comparisons ---
|
|
67
322
|
case "Le":
|
|
68
|
-
return resolveArith(formula.left, state)
|
|
323
|
+
return safeCompare("le", resolveArith(formula.left, state), resolveArith(formula.right, state));
|
|
69
324
|
case "Lt":
|
|
70
|
-
return resolveArith(formula.left, state)
|
|
325
|
+
return safeCompare("lt", resolveArith(formula.left, state), resolveArith(formula.right, state));
|
|
71
326
|
case "Ge":
|
|
72
|
-
return resolveArith(formula.left, state)
|
|
327
|
+
return safeCompare("ge", resolveArith(formula.left, state), resolveArith(formula.right, state));
|
|
73
328
|
case "Gt":
|
|
74
|
-
return resolveArith(formula.left, state)
|
|
329
|
+
return safeCompare("gt", resolveArith(formula.left, state), resolveArith(formula.right, state));
|
|
75
330
|
case "Eq":
|
|
76
|
-
return resolveArith(formula.left, state)
|
|
331
|
+
return safeCompare("eq", resolveArith(formula.left, state), resolveArith(formula.right, state));
|
|
77
332
|
case "Var":
|
|
78
333
|
return Boolean(state[formula.key()] ?? false);
|
|
79
334
|
case "Const":
|
|
80
335
|
return formula.value !== 0;
|
|
336
|
+
// Terms cannot appear at formula-level (only as comparison operands)
|
|
337
|
+
// but the Formula type union includes them. Treat as truthy fallback.
|
|
338
|
+
case "ArgValue":
|
|
339
|
+
case "CtxValue":
|
|
340
|
+
case "ArgLength":
|
|
341
|
+
case "UnaryFn":
|
|
342
|
+
return false;
|
|
81
343
|
default: {
|
|
82
344
|
const _exhaustive = formula;
|
|
83
345
|
throw new Error(`Unknown formula kind: ${_exhaustive.kind}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../src/core/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../src/core/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAYvC;;;;;;;;GAQG;AACH,SAAS,YAAY,CAAC,IAAU,EAAE,KAAgB;IAChD,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,KAAK,KAAK,CAAC,CAAC,CAAC;YACX,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YACvB,IAAI,OAAO,GAAG,KAAK,QAAQ;gBAAE,OAAO,GAAG,CAAC;YACxC,OAAO,CAAC,CAAC,CAAC,oCAAoC;QAChD,CAAC;QACD,KAAK,UAAU;YACb,OAAO,KAAK,C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K,EAAE,KAAK,CAAC,CAAC,CAAC;QAElG,KAAK,IAAI;YACP,OAAO,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QAElG,KAAK,IAAI;YACP,OAAO,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QAElG,KAAK,KAAK;YACR,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC;QAEhD,KAAK,OAAO;YACV,OAAO,OAAO,CAAC,KAAK,KAAK,CAAC,CAAC;QAE7B,qEAAqE;QACrE,sEAAsE;QACtE,KAAK,UAAU,CAAC;QAChB,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW,CAAC;QACjB,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC;QAEf,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,WAAW,GAAU,OAAO,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,yBAA0B,WAAuB,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/core/formula.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Direct port of sponsio/formulas/formula.py.
|
|
5
5
|
* Three families: Propositional, Temporal (LTL), Arithmetic.
|
|
6
6
|
*/
|
|
7
|
-
export type Formula = Atom | Not | And | Or | Implies | G | F | X | U | Le | Lt | Ge | Gt | Eq | Var | Const;
|
|
7
|
+
export type Formula = Atom | Not | And | Or | Implies | G | F | X | U | Le | Lt | Ge | Gt | Eq | Var | Const | ArgValue | CtxValue | UnaryFn | ArgLength;
|
|
8
8
|
export declare class Atom {
|
|
9
9
|
readonly predicate: string;
|
|
10
10
|
readonly args: readonly string[];
|
|
@@ -68,36 +68,95 @@ export declare class Const {
|
|
|
68
68
|
readonly kind: "Const";
|
|
69
69
|
constructor(value: number);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Read ``args[field]`` from the current event when it is a call to ``tool``.
|
|
73
|
+
*
|
|
74
|
+
* Returns ``undefined`` ("missing" signal) when the current event is a
|
|
75
|
+
* call to a different tool, or not a tool call, or args[field] absent.
|
|
76
|
+
* Pair with ``Implies(called(tool), ...)`` to scope the rule cleanly.
|
|
77
|
+
*/
|
|
78
|
+
export declare class ArgValue {
|
|
79
|
+
readonly tool: string;
|
|
80
|
+
readonly field: string;
|
|
81
|
+
readonly kind: "ArgValue";
|
|
82
|
+
constructor(tool: string, field: string);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Read a fact pushed via ``guard.observeContext({ key: value })``.
|
|
86
|
+
*
|
|
87
|
+
* Returns ``undefined`` when the key has never been pushed for this trace.
|
|
88
|
+
*/
|
|
89
|
+
export declare class CtxValue {
|
|
90
|
+
readonly key: string;
|
|
91
|
+
readonly kind: "CtxValue";
|
|
92
|
+
constructor(key: string);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Apply a JavaScript callable to another Term's value.
|
|
96
|
+
*
|
|
97
|
+
* Common cases:
|
|
98
|
+
* new UnaryFn(s => String(s).toLowerCase(),
|
|
99
|
+
* new ArgValue("send_email", "subject"))
|
|
100
|
+
*
|
|
101
|
+
* If the inner Term resolves to undefined, UnaryFn also returns undefined.
|
|
102
|
+
* If the callable throws, UnaryFn returns undefined rather than crashing.
|
|
103
|
+
*
|
|
104
|
+
* The ``name`` field is for debug repr only.
|
|
105
|
+
*/
|
|
106
|
+
export declare class UnaryFn {
|
|
107
|
+
readonly fn: (v: unknown) => unknown;
|
|
108
|
+
readonly arg: Term;
|
|
109
|
+
readonly name: string;
|
|
110
|
+
readonly kind: "UnaryFn";
|
|
111
|
+
constructor(fn: (v: unknown) => unknown, arg: Term, name?: string);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Convenience: ``args[field].length`` for the current event.
|
|
115
|
+
*
|
|
116
|
+
* Equivalent to ``new UnaryFn(v => (v as { length: number }).length,
|
|
117
|
+
* new ArgValue(tool, field))`` but exposed as its own class for clean
|
|
118
|
+
* repr and faster eval. Returns ``undefined`` when missing or not a
|
|
119
|
+
* .length-bearing value.
|
|
120
|
+
*/
|
|
121
|
+
export declare class ArgLength {
|
|
122
|
+
readonly tool: string;
|
|
123
|
+
readonly field: string;
|
|
124
|
+
readonly kind: "ArgLength";
|
|
125
|
+
constructor(tool: string, field: string);
|
|
126
|
+
}
|
|
127
|
+
/** A Term is anything that resolves to a value at evaluation time. */
|
|
128
|
+
export type Term = Var | Const | ArgValue | CtxValue | UnaryFn | ArgLength;
|
|
129
|
+
/** Backward-compatible alias. */
|
|
130
|
+
export type ArithExpr = Term;
|
|
72
131
|
export declare class Le {
|
|
73
|
-
readonly left:
|
|
74
|
-
readonly right:
|
|
132
|
+
readonly left: Term;
|
|
133
|
+
readonly right: Term;
|
|
75
134
|
readonly kind: "Le";
|
|
76
|
-
constructor(left:
|
|
135
|
+
constructor(left: Term, right: Term);
|
|
77
136
|
}
|
|
78
137
|
export declare class Lt {
|
|
79
|
-
readonly left:
|
|
80
|
-
readonly right:
|
|
138
|
+
readonly left: Term;
|
|
139
|
+
readonly right: Term;
|
|
81
140
|
readonly kind: "Lt";
|
|
82
|
-
constructor(left:
|
|
141
|
+
constructor(left: Term, right: Term);
|
|
83
142
|
}
|
|
84
143
|
export declare class Ge {
|
|
85
|
-
readonly left:
|
|
86
|
-
readonly right:
|
|
144
|
+
readonly left: Term;
|
|
145
|
+
readonly right: Term;
|
|
87
146
|
readonly kind: "Ge";
|
|
88
|
-
constructor(left:
|
|
147
|
+
constructor(left: Term, right: Term);
|
|
89
148
|
}
|
|
90
149
|
export declare class Gt {
|
|
91
|
-
readonly left:
|
|
92
|
-
readonly right:
|
|
150
|
+
readonly left: Term;
|
|
151
|
+
readonly right: Term;
|
|
93
152
|
readonly kind: "Gt";
|
|
94
|
-
constructor(left:
|
|
153
|
+
constructor(left: Term, right: Term);
|
|
95
154
|
}
|
|
96
155
|
export declare class Eq {
|
|
97
|
-
readonly left:
|
|
98
|
-
readonly right:
|
|
156
|
+
readonly left: Term;
|
|
157
|
+
readonly right: Term;
|
|
99
158
|
readonly kind: "Eq";
|
|
100
|
-
constructor(left:
|
|
159
|
+
constructor(left: Term, right: Term);
|
|
101
160
|
}
|
|
102
161
|
export declare function predKey(predicate: string, ...args: string[]): string;
|
|
103
162
|
//# sourceMappingURL=formula.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formula.d.ts","sourceRoot":"","sources":["../../src/core/formula.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,MAAM,OAAO,GACf,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE,GAAG,OAAO,GAC/B,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GACb,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GACtB,GAAG,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"formula.d.ts","sourceRoot":"","sources":["../../src/core/formula.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,MAAM,OAAO,GACf,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE,GAAG,OAAO,GAC/B,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GACb,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GACtB,GAAG,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAI5D,qBAAa,IAAI;IAGb,QAAQ,CAAC,SAAS,EAAE,MAAM;IAC1B,QAAQ,CAAC,I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,CAAC,IAAI,EAAE,IAAI;IAAE,QAAQ,CAAC,KAAK,EAAE,IAAI;IADrD,QAAQ,CAAC,IAAI,EAAG,IAAI,CAAU;gBACT,IAAI,EAAE,IAAI,EAAW,KAAK,EAAE,IAAI;CACtD;AAaD,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAGpE"}
|
package/dist/core/formula.js
CHANGED
|
@@ -82,7 +82,21 @@ export class U {
|
|
|
82
82
|
this.right = right;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
// --- Arithmetic ---
|
|
85
|
+
// --- Arithmetic / Term abstraction ---
|
|
86
|
+
//
|
|
87
|
+
// Comparison nodes (Eq, Le, Lt, Ge, Gt) accept any ``Term`` on either
|
|
88
|
+
// side. A Term is anything that knows how to evaluate(state) -> value;
|
|
89
|
+
// the evaluator dispatches on `kind`. This lets contract authors
|
|
90
|
+
// compose runtime-bound values (``new ArgValue("issue_refund",
|
|
91
|
+
// "amount")``) against constants (``new Const(50)``) or against other
|
|
92
|
+
// runtime values (``new CtxValue("approved_amount")``) in the same
|
|
93
|
+
// comparison.
|
|
94
|
+
//
|
|
95
|
+
// Returning ``undefined`` from evaluation is the canonical "missing"
|
|
96
|
+
// signal: comparison evaluation treats either operand being missing as
|
|
97
|
+
// false (the comparison cannot decide). Wrap fragile comparisons in
|
|
98
|
+
// ``Implies(scopePredicate, comparison)`` to suppress them where the
|
|
99
|
+
// relevant arg is not applicable.
|
|
86
100
|
export class Var {
|
|
87
101
|
name;
|
|
88
102
|
kind = "Var";
|
|
@@ -105,6 +119,74 @@ export class Const {
|
|
|
105
119
|
this.value = value;
|
|
106
120
|
}
|
|
107
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Read ``args[field]`` from the current event when it is a call to ``tool``.
|
|
124
|
+
*
|
|
125
|
+
* Returns ``undefined`` ("missing" signal) when the current event is a
|
|
126
|
+
* call to a different tool, or not a tool call, or args[field] absent.
|
|
127
|
+
* Pair with ``Implies(called(tool), ...)`` to scope the rule cleanly.
|
|
128
|
+
*/
|
|
129
|
+
export class ArgValue {
|
|
130
|
+
tool;
|
|
131
|
+
field;
|
|
132
|
+
kind = "ArgValue";
|
|
133
|
+
constructor(tool, field) {
|
|
134
|
+
this.tool = tool;
|
|
135
|
+
this.field = field;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Read a fact pushed via ``guard.observeContext({ key: value })``.
|
|
140
|
+
*
|
|
141
|
+
* Returns ``undefined`` when the key has never been pushed for this trace.
|
|
142
|
+
*/
|
|
143
|
+
export class CtxValue {
|
|
144
|
+
key;
|
|
145
|
+
kind = "CtxValue";
|
|
146
|
+
constructor(key) {
|
|
147
|
+
this.key = key;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Apply a JavaScript callable to another Term's value.
|
|
152
|
+
*
|
|
153
|
+
* Common cases:
|
|
154
|
+
* new UnaryFn(s => String(s).toLowerCase(),
|
|
155
|
+
* new ArgValue("send_email", "subject"))
|
|
156
|
+
*
|
|
157
|
+
* If the inner Term resolves to undefined, UnaryFn also returns undefined.
|
|
158
|
+
* If the callable throws, UnaryFn returns undefined rather than crashing.
|
|
159
|
+
*
|
|
160
|
+
* The ``name`` field is for debug repr only.
|
|
161
|
+
*/
|
|
162
|
+
export class UnaryFn {
|
|
163
|
+
fn;
|
|
164
|
+
arg;
|
|
165
|
+
name;
|
|
166
|
+
kind = "UnaryFn";
|
|
167
|
+
constructor(fn, arg, name = "fn") {
|
|
168
|
+
this.fn = fn;
|
|
169
|
+
this.arg = arg;
|
|
170
|
+
this.name = name;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Convenience: ``args[field].length`` for the current event.
|
|
175
|
+
*
|
|
176
|
+
* Equivalent to ``new UnaryFn(v => (v as { length: number }).length,
|
|
177
|
+
* new ArgValue(tool, field))`` but exposed as its own class for clean
|
|
178
|
+
* repr and faster eval. Returns ``undefined`` when missing or not a
|
|
179
|
+
* .length-bearing value.
|
|
180
|
+
*/
|
|
181
|
+
export class ArgLength {
|
|
182
|
+
tool;
|
|
183
|
+
field;
|
|
184
|
+
kind = "ArgLength";
|
|
185
|
+
constructor(tool, field) {
|
|
186
|
+
this.tool = tool;
|
|
187
|
+
this.field = field;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
108
190
|
export class Le {
|
|
109
191
|
left;
|
|
110
192
|
right;
|
package/dist/core/formula.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formula.js","sourceRoot":"","sources":["../../src/core/formula.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,wBAAwB;AAExB,MAAM,OAAO,IAAI;IAGJ;IACA;IAHF,IAAI,GAAG,MAAe,CAAC;IAChC,YACW,SAAiB,EACjB,OAA0B,EAAE;QAD5B,cAAS,GAAT,SAAS,CAAQ;QACjB,SAAI,GAAJ,IAAI,CAAwB;IACpC,CAAC;IAEJ,GAAG;QACD,OAAO,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;CACF;AAED,MAAM,OAAO,GAAG;IAEO;IADZ,IAAI,GAAG,KAAc,CAAC;IAC/B,YAAqB,KAAc;QAAd,UAAK,GAAL,KAAK,CAAS;IAAG,CAAC;CACxC;AAED,MAAM,OAAO,GAAG;IAEO;IAAwB;IADpC,IAAI,GAAG,KAAc,CAAC;IAC/B,YAAqB,IAAa,EAAW,KAAc;QAAtC,SAAI,GAAJ,IAAI,CAAS;QAAW,UAAK,GAAL,KAAK,CAAS;IAAG,CAAC;CAChE;AAED,MAAM,OAAO,EAAE;IAEQ;IAAwB;IADpC,IAAI,GAAG,IAAa,CAAC;IAC9B,YAAqB,IAAa,EAAW,KAAc;QAAtC,SAAI,GAAJ,IAAI,CAAS;QAAW,UAAK,GAAL,KA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