gdp-wired 0.44.0 → 0.45.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/core/c/reader.js +22 -7
- package/dist/core/check.js +3 -2
- package/dist/core/cli.d.ts +1 -0
- package/dist/core/cli.js +136 -6
- package/dist/core/counts.d.ts +1 -1
- package/dist/core/counts.js +30 -12
- package/dist/core/data.d.ts +6 -1
- package/dist/core/data.js +894 -152
- package/dist/core/dsl.d.ts +2 -0
- package/dist/core/dsl.js +88 -10
- package/dist/core/effect-prims.js +2 -2
- package/dist/core/ex/reader.exs +17 -1
- package/dist/core/exists.d.ts +15 -1
- package/dist/core/exists.js +263 -41
- package/dist/core/extract-c.js +19 -12
- package/dist/core/extract-check.d.ts +6 -0
- package/dist/core/extract-check.js +49 -3
- package/dist/core/extract-ex.js +3 -3
- package/dist/core/extract-go-check.js +19 -12
- package/dist/core/extract-go.js +20 -5
- package/dist/core/extract-jvm.js +63 -14
- package/dist/core/extract-print.js +3 -0
- package/dist/core/extract-py.js +3 -3
- package/dist/core/extract-rb.js +3 -3
- package/dist/core/extract-read.d.ts +8 -0
- package/dist/core/extract-read.js +55 -0
- package/dist/core/extract-rs.js +17 -19
- package/dist/core/extract-shapes.js +20 -0
- package/dist/core/extract-sol.js +19 -8
- package/dist/core/extract-step.d.ts +50 -3
- package/dist/core/extract-step.js +289 -58
- package/dist/core/extract-swift.js +20 -13
- package/dist/core/extract.d.ts +1 -0
- package/dist/core/extract.js +27 -2
- package/dist/core/fresh.d.ts +2 -2
- package/dist/core/fresh.js +7 -3
- package/dist/core/go/reader.go +7 -1
- package/dist/core/infer.js +115 -42
- package/dist/core/jvm/JavaReader.java +10 -2
- package/dist/core/jvm/Jvm.java +17 -1
- package/dist/core/jvm/KtReader.java +57 -5
- package/dist/core/machine.d.ts +1 -2
- package/dist/core/machine.js +27 -15
- package/dist/core/py/harness.py +77 -11
- package/dist/core/py/reader.py +50 -5
- package/dist/core/rb/reader.rb +52 -5
- package/dist/core/rs/src/main.rs +10 -0
- package/dist/core/sol/harness.py +6 -3
- package/dist/core/solver.js +5 -4
- package/dist/core/system.d.ts +62 -1
- package/dist/core/system.js +262 -3
- package/dist/core/transfer.js +17 -0
- package/dist/core/watch.js +1 -1
- package/dist/interchange/check.js +10 -10
- package/dist/interchange/format.d.ts +4 -0
- package/dist/interchange/format.js +13 -5
- package/dist/kernel/cdcl.js +33 -2
- package/dist/kernel/epr.js +35 -5
- package/dist/kernel/kernel.d.ts +2 -0
- package/dist/kernel/kernel.js +67 -40
- package/dist/kernel/prove.d.ts +22 -0
- package/dist/kernel/prove.js +156 -7
- package/dist/lean-kernel/emit.d.ts +9 -3
- package/dist/lean-kernel/emit.js +170 -29
- package/dist/lean-kernel/library.js +1 -1
- package/package.json +2 -2
|
@@ -28,7 +28,7 @@ import * as I from "./extract-ir.js";
|
|
|
28
28
|
import { Refusal, mergeOps, mergeWrites } from "./extract-read.js";
|
|
29
29
|
import { fromModel } from "./extract.js";
|
|
30
30
|
import { nonneg } from "./extract-print.js";
|
|
31
|
-
import { Outside, constantsOf, draw, drive } from "./extract-check.js";
|
|
31
|
+
import { HarnessFailure, Outside, constantsOf, draw, drive, noEvidence, retried } from "./extract-check.js";
|
|
32
32
|
// A string that is one of a choice's literals on every path (a literal, or literals by a condition): the choice's.
|
|
33
33
|
const asChoice = (k, vs) => { if (k.op === 'slit')
|
|
34
34
|
return vs.includes(k.value) ? I.llit(k.value, vs) : undefined; if (k.op !== 'kite')
|
|
@@ -62,12 +62,13 @@ function sortOfText(s, at) {
|
|
|
62
62
|
const t = one();
|
|
63
63
|
return { t: none ? { k: 'opt', of: t } : t };
|
|
64
64
|
}
|
|
65
|
-
const TAG_DECO = /(?:^|\.)gdp[._]?(skip|answer|strict)$/i;
|
|
65
|
+
const TAG_DECO = /(?:^|\.)gdp[._]?(skip|answer|strict|effect)$/i;
|
|
66
66
|
// A type an answer takes: a scalar, or one with None.
|
|
67
67
|
const answerable = (t) => { const i = t.k === 'opt' ? t.of : t; return i.k === 'int' || i.k === 'float' || i.k === 'bool' || i.k === 'str' || i.k === 'choice'; };
|
|
68
68
|
const typeText = (t) => (t.k === 'opt' ? `${typeText(t.of)} | None` : t.k === 'choice' ? t.values.map(v => JSON.stringify(v)).join(' | ') : t.k);
|
|
69
|
-
// A store's method by its name: one that reads, writes or deletes a key (async_, _cache and camel case aside).
|
|
70
69
|
const KEYED = Object.fromEntries([
|
|
70
|
+
...['add', 'setnx', 'putifempty', 'putifabsent', 'addifabsent'].map(n => [n, 'add']),
|
|
71
|
+
...['incr', 'incrby', 'increment', 'incrementby'].map(n => [n, 'incr']),
|
|
71
72
|
...['get', 'getcache', 'find', 'findbyid', 'fetch', 'load', 'lookup', 'read'].map(n => [n, 'get']),
|
|
72
73
|
...['set', 'setcache', 'put', 'save', 'store', 'write', 'upsert'].map(n => [n, 'set']),
|
|
73
74
|
...['delete', 'deletecache', 'remove', 'deletebyid', 'del', 'evict', 'invalidate'].map(n => [n, 'delete'])
|
|
@@ -624,7 +625,8 @@ export class Stepper {
|
|
|
624
625
|
const i = this.initHeap.get(id);
|
|
625
626
|
if (!i || ('origin' in o && o.origin !== 'state'))
|
|
626
627
|
continue;
|
|
627
|
-
|
|
628
|
+
// (a write a condition makes, nx's, on a path where that condition is false: none)
|
|
629
|
+
if (o.k === 'map' ? (!!o.w && !(o.w.on && p.pc.some(c => I.same(c, I.not(o.w.on))))) || (!!o.nil && I.keyOf(o.nil) !== I.keyOf(i.nil)) : o.k === 'list' ? o.ops.length > 0 : keyV(o) !== keyV(i))
|
|
628
630
|
return true;
|
|
629
631
|
}
|
|
630
632
|
return false;
|
|
@@ -671,7 +673,9 @@ export class Stepper {
|
|
|
671
673
|
const x = this.initHeap.get(id);
|
|
672
674
|
heap.set(id, x ? this.mergeObj(c, x, y, at) : y);
|
|
673
675
|
}
|
|
674
|
-
|
|
676
|
+
const effs = new Set([...(a.eff?.keys() ?? []), ...(b.eff?.keys() ?? [])]);
|
|
677
|
+
const eff = effs.size ? new Map([...effs].map(e => [e, I.bite(c, a.eff?.get(e) ?? I.F, b.eff?.get(e) ?? I.F)])) : undefined;
|
|
678
|
+
return { pc, locals, heap, called: [...new Set([...a.called, ...b.called])], locks: a.locks, defers: [...new Set([...a.defers, ...b.defers])], ...(eff ? { eff } : {}) };
|
|
675
679
|
}
|
|
676
680
|
mergeObj(c, a, b, at) {
|
|
677
681
|
if (a === b)
|
|
@@ -1311,6 +1315,7 @@ export class Stepper {
|
|
|
1311
1315
|
return [m.id, o];
|
|
1312
1316
|
}
|
|
1313
1317
|
cellOf(o, key, _p, _at) {
|
|
1318
|
+
keyKind(o.decl, key, _at);
|
|
1314
1319
|
let acc = this.baseCell(o.decl, key);
|
|
1315
1320
|
for (const w of [...(o.pre ?? []), ...(o.w ? [o.w] : [])]) {
|
|
1316
1321
|
const same = I.keq(key, w.key), a = acc;
|
|
@@ -1321,6 +1326,7 @@ export class Stepper {
|
|
|
1321
1326
|
// A cell written: a second key of a scalar map keyed by numbers (a transfer's two accounts) after the first, any
|
|
1322
1327
|
// earlier write of the same key dropped (this one is read through it).
|
|
1323
1328
|
writeCell(id, o, key, has, vals, at, p) {
|
|
1329
|
+
keyKind(o.decl, key, at);
|
|
1324
1330
|
if (o.w && !I.same(o.w.key, key)) {
|
|
1325
1331
|
if (!o.decl.scalar || o.decl.key !== 'num')
|
|
1326
1332
|
return refuse(at, `${at.text}: a second key of one map written in one step (the subset writes one a step, or several of a map of numbers or booleans keyed by numbers)`);
|
|
@@ -1366,13 +1372,13 @@ export class Stepper {
|
|
|
1366
1372
|
const [id, o] = this.mapObj(m, at, p), c = this.cellOf(o, k, p, at);
|
|
1367
1373
|
if (strict)
|
|
1368
1374
|
this.fail(p, I.not(c.has), at, `${at.text}: a key the dict doesn't hold deleted (a KeyError)`);
|
|
1369
|
-
return this.writeCell(id, o, k, I.F, new Map([...c.vals].map(([f, v]) => [f, (v.t === 'num' ? { t: 'num', e: I.num(0) } : v.t === 'bool' ? { t: 'bool', e: I.F } : v.t === 'choice' ? { t: 'choice', e: I.llit(lvalues(v.e)[0], lvalues(v.e)) } : v)])), at, strict ? this.assume(p, c.has) : p);
|
|
1375
|
+
return this.writeCell(id, o, k, I.F, new Map([...c.vals].map(([f, v]) => [f, (v.t === 'num' ? { t: 'num', e: I.num(0) } : v.t === 'bool' ? { t: 'bool', e: I.F } : v.t === 'choice' ? { t: 'choice', e: I.llit(lvalues(v.e)[0], lvalues(v.e)) } : o.decl.fields.find(x => x.name === f)?.sort.k === 'str' ? { t: 'str', e: { op: 'slit', value: '' } } : v)])), at, strict ? this.assume(p, c.has) : p);
|
|
1370
1376
|
}
|
|
1371
1377
|
mapDeclOf(name, t, at) {
|
|
1372
1378
|
if (t.k !== 'map')
|
|
1373
1379
|
return refuse(at, `${name}: ${this.why(t)}`);
|
|
1374
1380
|
const key = t.key.k === 'int' ? 'num' : t.key.k === 'str' ? 'str' : refuse(at, `${name}: a dict keyed by ${this.why(t.key)} (keys are integers or strings)`);
|
|
1375
|
-
const cell = (n, ft) => { const s = this.scalar(ft); if (!s || s.k === 'str')
|
|
1381
|
+
const cell = (n, ft) => { const s = this.scalar(ft); if (!s || (s.k === 'str' && !t.sv))
|
|
1376
1382
|
return refuse(at, `${name}: a dict of ${s?.k === 'str' ? 'strings' : this.why(ft)} (a cell holds integers, booleans and literals)`); return { name: n, sort: s, role: 'state' }; };
|
|
1377
1383
|
let fields, scalar = true;
|
|
1378
1384
|
// (a record's string field the module only ever sets to literals: a choice of them, said in the notes)
|
|
@@ -1602,7 +1608,7 @@ export class Stepper {
|
|
|
1602
1608
|
if (!disjoint(other.tpl, tpl))
|
|
1603
1609
|
refuse(at, `${store}: the key templates ${JSON.stringify(other.tpl)} and ${JSON.stringify(tpl)} may name one key`);
|
|
1604
1610
|
const sv = decl.values?.[tpl];
|
|
1605
|
-
const val = Array.isArray(sv) ? { k: 'choice', values: sv } : sv === 'int' || (!sv && decl.value === 'int') ? { k: 'int' } : !sv && decl.value === 'str' ? { k: 'str' } : { k: 'float' };
|
|
1611
|
+
const val = Array.isArray(sv) ? { k: 'choice', values: sv } : sv === 'int' || (!sv && decl.value === 'int') ? { k: 'int' } : sv === 'str' || (!sv && decl.value === 'str') ? { k: 'str' } : { k: 'float' };
|
|
1606
1612
|
const name = `${store}_${tpl.replace(/\{\}/g, '').replace(/[^A-Za-z0-9]+/g, '_').replace(/^_|_$/g, '')}`;
|
|
1607
1613
|
let d, json;
|
|
1608
1614
|
if (sv && typeof sv === 'object' && !Array.isArray(sv)) {
|
|
@@ -1626,7 +1632,7 @@ export class Stepper {
|
|
|
1626
1632
|
this.notes.add(`${store}: ${JSON.stringify(tpl)} keys hold JSON records (stated): ${json.map(f => `${f.name}${f.out ? ' (a string, left out)' : f.opt ? ' (maybe absent)' : ''}`).join(', ')}`);
|
|
1627
1633
|
}
|
|
1628
1634
|
else
|
|
1629
|
-
d = this.mapDeclOf(name, { k: 'map', key: { k: kn ? 'int' : 'str' }, val }, at);
|
|
1635
|
+
d = this.mapDeclOf(name, { k: 'map', key: { k: kn ? 'int' : 'str' }, val, ...(val.k === 'str' ? { sv: true } : {}) }, at);
|
|
1630
1636
|
const id = `store:${key}`;
|
|
1631
1637
|
sm = { store, tpl, id, decl: d, ...(json ? { json } : {}), ...(Array.isArray(sv) ? { choice: true } : {}) };
|
|
1632
1638
|
this.storeMaps.set(key, sm);
|
|
@@ -1652,6 +1658,8 @@ export class Stepper {
|
|
|
1652
1658
|
// (the stores whose keys the rule holds: stated, or an injected dependency the class calls a key's method on)
|
|
1653
1659
|
storeKeyed = new Set();
|
|
1654
1660
|
injectedFields = [];
|
|
1661
|
+
globalStores = [];
|
|
1662
|
+
inertAttrs = [];
|
|
1655
1663
|
// (the injected dependencies and stores: their type, whether the rule holds keys of theirs, whether the caller stated them)
|
|
1656
1664
|
deps = [];
|
|
1657
1665
|
// A constructor argument held as an injected dependency (a store): one its reader marks so, or one of no scalar type
|
|
@@ -1707,11 +1715,11 @@ export class Stepper {
|
|
|
1707
1715
|
refuse(at, `${at.text}: ${store}.${m} is given the rule's state, which other code may change (if it doesn't, a \`gdp: skip\` comment on its line says so)`); };
|
|
1708
1716
|
const arg = (n, i) => kw.find(([k]) => k === n || (n === 'key' && k === 'name'))?.[1] ?? args[i] ?? refuse(at, `${at.text}: the store's ${n} not given`);
|
|
1709
1717
|
const has = (n, i) => kw.some(([k]) => k === n) || args.length > i;
|
|
1710
|
-
let kind = (d.get ?? ['get', 'async_get_cache', 'get_cache']).includes(m) ? 'get' : (d.set ?? ['set', 'async_set_cache', 'set_cache']).includes(m) ? 'set' : (d.delete ?? ['delete', 'delete_cache', 'async_delete_cache']).includes(m) ? 'delete' : undefined;
|
|
1718
|
+
let kind = (d.get ?? ['get', 'async_get_cache', 'get_cache']).includes(m) ? 'get' : (d.set ?? ['set', 'async_set_cache', 'set_cache']).includes(m) ? 'set' : (d.delete ?? ['delete', 'delete_cache', 'async_delete_cache']).includes(m) ? 'delete' : d.add?.includes(m) ? 'add' : d.incr?.includes(m) ? 'incr' : undefined;
|
|
1711
1719
|
if (!kind && this.inf) {
|
|
1712
1720
|
// (inferred: a method named as a key's get, set or delete, given a key that is a string or a format)
|
|
1713
1721
|
const k = keyShape(m), key = kw.find(([n]) => n === 'key' || n === 'name')?.[1] ?? args[0];
|
|
1714
|
-
if (k && key && (key.t === 'str' || key.t === 'fmt') && (k !== 'set' || has('value', 1))) {
|
|
1722
|
+
if (k && key && (key.t === 'str' || key.t === 'fmt') && ((k !== 'set' && k !== 'add') || has('value', 1))) {
|
|
1715
1723
|
kind = k;
|
|
1716
1724
|
(d[k] ??= []).push(m);
|
|
1717
1725
|
this.notes.add(`${store}.${m}: read as the store's ${k} by a key (inferred from its name)`);
|
|
@@ -1741,15 +1749,15 @@ export class Stepper {
|
|
|
1741
1749
|
return refuse(at, `${at.text}: the store's ${m} awaited at one call and not at another`);
|
|
1742
1750
|
this.storeAsync[store][m] = awaited;
|
|
1743
1751
|
// (a key's operation takes its key, and a set its value: any other argument given the rule's state is refused)
|
|
1744
|
-
const keyV = arg('key', 0), valV = kind === '
|
|
1752
|
+
const sets = kind === 'set' || kind === 'add', keyV = arg('key', 0), valV = sets ? arg('value', 1) : kind === 'incr' && has('amount', 1) ? arg('amount', 1) : undefined;
|
|
1745
1753
|
// (a set's options: nx and xx make it conditional, its result whether it set (True, else None, as redis-py's); its
|
|
1746
1754
|
// expiry is left out, as every store's is; any other option is refused)
|
|
1747
1755
|
const TTL = ['ex', 'px', 'exat', 'pxat', 'ttl', 'timeout', 'expire', 'expiry'];
|
|
1748
1756
|
let only;
|
|
1749
1757
|
for (const [n, v] of kw) {
|
|
1750
|
-
if (n === 'key' || n === 'name' || n === 'value')
|
|
1758
|
+
if (n === 'key' || n === 'name' || n === 'value' || (kind === 'incr' && n === 'amount'))
|
|
1751
1759
|
continue;
|
|
1752
|
-
if (
|
|
1760
|
+
if (sets && TTL.includes(n)) {
|
|
1753
1761
|
this.notes.add(`${store}.${m}: its ${n} (the key's expiry) left out, as the store's expiry is`);
|
|
1754
1762
|
continue;
|
|
1755
1763
|
}
|
|
@@ -1771,10 +1779,19 @@ export class Stepper {
|
|
|
1771
1779
|
}
|
|
1772
1780
|
return refuse(at, `${at.text}: the store's ${m} given ${n}, a value the request decides (the subset reads a key, a value, nx, xx, the expiry and options given a constant)`);
|
|
1773
1781
|
}
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1782
|
+
// (a set's third argument, set(key, value, ttl) as most caches take it: the key's expiry, left out)
|
|
1783
|
+
const ttl = sets && args.length === 3 ? args[2] : undefined;
|
|
1784
|
+
if (ttl)
|
|
1785
|
+
this.notes.add(`${store}.${m}: its third argument (the key's expiry) left out, as the store's expiry is`);
|
|
1786
|
+
given(all.filter(v => v !== keyV && v !== valV && v !== ttl));
|
|
1787
|
+
if (args.length > (sets ? 3 : kind === 'incr' ? 2 : 1))
|
|
1788
|
+
return refuse(at, `${at.text}: the store's ${m} given more than its key${sets ? ', value and expiry' : kind === 'incr' ? ' and amount' : ''}`);
|
|
1777
1789
|
const { tpl, k, kn } = this.storeKey(keyV, at);
|
|
1790
|
+
// (what a template's keys hold, where nothing states it: strings where the first write sets one)
|
|
1791
|
+
if (sets && valV?.t === 'str' && !d.value && !d.values?.[tpl] && !this.storeMaps.has(`${store}\u0000${tpl}`)) {
|
|
1792
|
+
(d.values ??= {})[tpl] = 'str';
|
|
1793
|
+
this.notes.add(`${store}: ${JSON.stringify(tpl)} keys hold strings (inferred: a string set)`);
|
|
1794
|
+
}
|
|
1778
1795
|
const [id, o] = this.storeMap(store, tpl, kn, at, p), sm = [...this.storeMaps.values()].find(x => x.id === id);
|
|
1779
1796
|
// (inside a try that may catch it: the store's operation may raise, as other code's may, before it acts)
|
|
1780
1797
|
if (this.tries.length && !d.nothrow)
|
|
@@ -1795,6 +1812,15 @@ export class Stepper {
|
|
|
1795
1812
|
}
|
|
1796
1813
|
if (kind === 'delete')
|
|
1797
1814
|
return [{ t: 'none' }, this.mapDel({ t: 'ref', id }, k, at, p, false)];
|
|
1815
|
+
if (kind === 'incr') {
|
|
1816
|
+
if (sm.json || sm.choice || o.val.k === 'str')
|
|
1817
|
+
return refuse(at, `${at.text}: ${m} on a store that holds no numbers`);
|
|
1818
|
+
const by = valV ? this.numOf(valV, at, p) : I.num(1), c = this.cellOf(o, k, p, at);
|
|
1819
|
+
const now = { t: 'num', e: I.add(this.numOf(this.ite(c.has, c.vals.get('value'), { t: 'num', e: I.num(0) }, at), at, p), by) };
|
|
1820
|
+
return [now, this.writeCell(id, o, k, I.T, new Map([['value', now]]), at, p)];
|
|
1821
|
+
}
|
|
1822
|
+
if (kind === 'add')
|
|
1823
|
+
only = 'nx';
|
|
1798
1824
|
const v = arg('value', 1);
|
|
1799
1825
|
let vals;
|
|
1800
1826
|
if (sm.json) {
|
|
@@ -1819,11 +1845,10 @@ export class Stepper {
|
|
|
1819
1845
|
}
|
|
1820
1846
|
}
|
|
1821
1847
|
else {
|
|
1822
|
-
|
|
1823
|
-
|
|
1848
|
+
// (a bool set where numbers are held: 1 or 0, as Python's True is)
|
|
1849
|
+
const v2 = sm.choice ? this.fit(v, o.decl.fields[0], at) : v.t === 'bool' && o.val.k !== 'str' ? { t: 'num', e: I.nite(v.e, I.num(1), I.num(0)) } : v;
|
|
1850
|
+
if (sm.choice ? v2.t !== 'choice' : o.val.k === 'str' ? v.t !== 'str' : v2.t !== 'num')
|
|
1824
1851
|
return refuse(at, `${at.text}: a ${v.t === 'opaque' ? v.why : v.t} set in a store of ${o.val.k === 'float' ? 'numbers' : o.val.k}`);
|
|
1825
|
-
if (!sm.choice && o.val.k === 'str')
|
|
1826
|
-
return refuse(at, `${at.text}: a store of strings (its cells hold numbers)`);
|
|
1827
1852
|
vals = new Map([['value', v2]]);
|
|
1828
1853
|
}
|
|
1829
1854
|
if (!only)
|
|
@@ -1831,7 +1856,9 @@ export class Stepper {
|
|
|
1831
1856
|
// (nx: where the key holds nothing; xx: where it holds a value)
|
|
1832
1857
|
const c = this.cellOf(o, k, p, at), when = only === 'nx' ? I.not(c.has) : c.has;
|
|
1833
1858
|
const merged = new Map([...vals].map(([n, x]) => [n, this.ite(when, x, c.vals.get(n), at)]));
|
|
1834
|
-
|
|
1859
|
+
const w = this.writeCell(id, o, k, I.bite(when, I.T, c.has), merged, at, p), wo = w.heap.get(id);
|
|
1860
|
+
w.heap.set(id, { ...wo, w: { ...wo.w, on: when } });
|
|
1861
|
+
return [kind === 'add' ? { t: 'bool', e: when } : { t: 'opt', has: when, v: { t: 'bool', e: I.T } }, w];
|
|
1835
1862
|
}
|
|
1836
1863
|
// --- context managers of the module's, made by @contextmanager ---------------------------------------------------------
|
|
1837
1864
|
// with self.cm(...): body, where cm is a generator the module reads, decorated @contextmanager: the generator run,
|
|
@@ -2072,6 +2099,10 @@ export class Stepper {
|
|
|
2072
2099
|
if (t)
|
|
2073
2100
|
return this.answer(b.key, [b.name], b.patch, x, q, awaited, t, tag ? 'tagged' : 'inferred');
|
|
2074
2101
|
const why = `${x.text ?? b.name}: the value of ${b.name}, other code left out`;
|
|
2102
|
+
// (a call on an attribute of a store the rule doesn't state, a registry its constructor adds to: inert in the check)
|
|
2103
|
+
const ra = b.recv?.t === 'opaque' ? b.recv.sattr : b.recv?.t === 'sattr' ? { store: b.recv.store, path: b.recv.path } : undefined;
|
|
2104
|
+
if (ra && !this.inertAttrs.some(i => i.store === ra.store && i.path === ra.path))
|
|
2105
|
+
this.inertAttrs.push(ra);
|
|
2075
2106
|
this.pend.set(why, { ...b, why, at: x.p, ...(x.end ? { end: x.end } : {}) });
|
|
2076
2107
|
this.leftOut.add(b.name).add(b.key);
|
|
2077
2108
|
this.notes.add(`${b.name} (${x.p}): left out (${tag ? 'tagged: gdp: skip' : 'inferred: nothing the rule keeps reads its value'}), run as it is by the check`);
|
|
@@ -2194,7 +2225,7 @@ export class Stepper {
|
|
|
2194
2225
|
if (!lines) {
|
|
2195
2226
|
lines = new Map();
|
|
2196
2227
|
const src = sourceOf(this.mod, m[1]) ?? '';
|
|
2197
|
-
src.split('\n').forEach((l, i) => { const t = /(?:#|\/\/|--|%)\s*gdp:\s*(skip|answer|strict)\b[ \t]*([^#\n]*)$/.exec(l); if (t)
|
|
2228
|
+
src.split('\n').forEach((l, i) => { const t = /(?:#|\/\/|--|%)\s*gdp:\s*(skip|answer|strict|effect)\b[ \t]*([^#\n]*)$/.exec(l); if (t)
|
|
2198
2229
|
lines.set(i + 1, { k: t[1], arg: t[2].trim() }); });
|
|
2199
2230
|
this.tagLines.set(m[1], lines);
|
|
2200
2231
|
}
|
|
@@ -2304,7 +2335,7 @@ export class Stepper {
|
|
|
2304
2335
|
case 'expect': {
|
|
2305
2336
|
const [v, q] = this.ev(x.x, p);
|
|
2306
2337
|
const good = this.isOf(v, 'good', x);
|
|
2307
|
-
this.fail(q, I.not(good), x, `${x.text}: unwrap of ${v.t === 'res' ? 'an Err' : 'None'} (a panic)`);
|
|
2338
|
+
this.fail(q, I.not(good), x, x.npe ? `${x.text}: null unboxed (a NullPointerException)` : `${x.text}: unwrap of ${v.t === 'res' ? 'an Err' : 'None'} (a panic)`);
|
|
2308
2339
|
return [this.inner(v, 'good', x), this.assume(q, good)];
|
|
2309
2340
|
}
|
|
2310
2341
|
case 'opt_or': {
|
|
@@ -2359,6 +2390,12 @@ export class Stepper {
|
|
|
2359
2390
|
case 'upd': {
|
|
2360
2391
|
const [o, q] = this.ev(x.x, p);
|
|
2361
2392
|
let [c, q2] = this.copy(o, q, x);
|
|
2393
|
+
// (Elixir's %{m | k: v}, strict: a key the map doesn't hold is a KeyError)
|
|
2394
|
+
const r = c.t === 'ref' && x.strict ? this.mod.recs[q2.heap.get(c.id)?.ty ?? ''] : undefined, gone = x.fields.find(([f]) => r && !r.fields.some(y => y.name === f));
|
|
2395
|
+
if (gone) {
|
|
2396
|
+
this.fail(q2, I.T, x, `${x.text}: ${gone[0]}, a key the map doesn't hold (a KeyError)`);
|
|
2397
|
+
return [{ t: 'opaque', why: 'unreachable' }, { ...q2, pc: [...q2.pc, I.F] }];
|
|
2398
|
+
}
|
|
2362
2399
|
for (const [f, y] of x.fields) {
|
|
2363
2400
|
const [v, q3] = this.ev(y, q2);
|
|
2364
2401
|
q2 = this.setField(c, f, v, x, q3);
|
|
@@ -2373,6 +2410,9 @@ export class Stepper {
|
|
|
2373
2410
|
const v = p.locals.get(String(x.n));
|
|
2374
2411
|
// (Python's local read on a path that never set it, past a raise caught before its assignment: an
|
|
2375
2412
|
// UnboundLocalError on that path)
|
|
2413
|
+
// (Ruby's local read before it is set: nil)
|
|
2414
|
+
if (!v && !x.why && this.mod.lang === 'ruby')
|
|
2415
|
+
return [{ t: 'none' }, p];
|
|
2376
2416
|
if (!v && !x.why && this.mod.lang === 'python') {
|
|
2377
2417
|
this.fail(p, I.T, x, `${String(x.n)}: a local read before it is set (an UnboundLocalError)`);
|
|
2378
2418
|
return [{ t: 'opaque', why: 'unreachable' }, { ...p, pc: [...p.pc, I.F] }];
|
|
@@ -2385,11 +2425,38 @@ export class Stepper {
|
|
|
2385
2425
|
case 'cls': return [{ t: 'cls', rec: String(x.rec), ...(x.patch ? { patch: x.patch } : {}) }, p];
|
|
2386
2426
|
case 'builtin': return [{ t: 'builtin', n: String(x.n) }, p];
|
|
2387
2427
|
case 'lib': return [{ t: 'lib', q: String(x.q) }, p];
|
|
2388
|
-
case 'ext':
|
|
2428
|
+
case 'ext': {
|
|
2429
|
+
// (a module's object a stated store names, Django's `cache`, a client made at import: the store, the check
|
|
2430
|
+
// giving one in its place)
|
|
2431
|
+
const pt = x.patch;
|
|
2432
|
+
if (this.opts.stores?.[String(x.text)] && pt?.mod && pt.path?.length === 1) {
|
|
2433
|
+
const name = String(x.text), id = `store:${name}`;
|
|
2434
|
+
if (!this.initHeap.has(id)) {
|
|
2435
|
+
this.initHeap.set(id, { k: 'store', name });
|
|
2436
|
+
this.storeKeyed.add(name);
|
|
2437
|
+
this.globalStores.push({ name, mod: pt.mod });
|
|
2438
|
+
this.notes.add(`${name}: a store (stated), the module's object, the check giving one in its place`);
|
|
2439
|
+
}
|
|
2440
|
+
if (!p.heap.has(id))
|
|
2441
|
+
p.heap.set(id, this.initHeap.get(id));
|
|
2442
|
+
return [{ t: 'ref', id }, p];
|
|
2443
|
+
}
|
|
2444
|
+
return [{ t: 'ext', q: String(x.q), text: String(x.text), ...(x.patch ? { patch: x.patch } : {}), ...(x.ret ? { ret: x.ret } : {}), ...(x.nothrow ? { nothrow: true } : {}) }, p];
|
|
2445
|
+
}
|
|
2389
2446
|
case 'no': {
|
|
2390
2447
|
// (a call of other code a reader doesn't lower, `ext` its name: at the boundary, where it is inferred)
|
|
2391
2448
|
if (x.ext && !x.pre && !x.prepl) {
|
|
2392
2449
|
const names = [x.ext], ans = this.match(Object.keys(this.opts.answers ?? {}), names), patch = x.patch;
|
|
2450
|
+
// (a stub stated: nothing run, None returned, its arguments not read)
|
|
2451
|
+
const st = this.match(this.opts.stubs, names);
|
|
2452
|
+
if (st && patch) {
|
|
2453
|
+
const key = st.split('.').pop();
|
|
2454
|
+
if (!this.answers.has(key)) {
|
|
2455
|
+
this.answers.set(key, { key, patch, async: false, inputs: { name: '' }, sort: '', pass: true, effect: true, quiet: true, at: [] });
|
|
2456
|
+
this.notes.add(`${key} (${x.p}): stubbed (stated): it does nothing and returns None in the check`);
|
|
2457
|
+
}
|
|
2458
|
+
return [{ t: 'none' }, p];
|
|
2459
|
+
}
|
|
2393
2460
|
if (ans)
|
|
2394
2461
|
return this.answer(ans, names, patch, x, x.args ? this.argsRead(x, p) : p, false);
|
|
2395
2462
|
if (this.skipped(names)) {
|
|
@@ -2595,8 +2662,11 @@ export class Stepper {
|
|
|
2595
2662
|
case 'get': return this.get(x, p);
|
|
2596
2663
|
case 'idx': {
|
|
2597
2664
|
const [m, q] = this.ev(x.x, p), [k, q2] = this.ev(x.i, q);
|
|
2598
|
-
|
|
2665
|
+
// (an item of a value outside the subset: whether it holds one, and what, is that value's)
|
|
2666
|
+
if (m.t === 'opaque' && m.why === 'unreachable')
|
|
2599
2667
|
return [m, q2];
|
|
2668
|
+
if (m.t === 'opaque')
|
|
2669
|
+
return refuse(x, `${x.text}: an item of ${m.why} (whether it holds one is that value's)`);
|
|
2600
2670
|
if (m.t === 'val')
|
|
2601
2671
|
return this.valItem(m, k, x, q2);
|
|
2602
2672
|
const ord = this.orderedObj(m, q2);
|
|
@@ -2613,6 +2683,8 @@ export class Stepper {
|
|
|
2613
2683
|
}
|
|
2614
2684
|
case 'neg': {
|
|
2615
2685
|
const [v, q] = this.ev(x.x, p);
|
|
2686
|
+
if (v.t === 'opaque' && v.ask)
|
|
2687
|
+
return refuse(x, `${x.text ?? '-'}: arithmetic on ${v.why} (what it does depends on that value)`);
|
|
2616
2688
|
if (v.t === 'opaque')
|
|
2617
2689
|
return [v, q];
|
|
2618
2690
|
return [{ t: 'num', e: I.neg(this.numOf(v, x, q)) }, q];
|
|
@@ -2831,6 +2903,10 @@ export class Stepper {
|
|
|
2831
2903
|
}
|
|
2832
2904
|
if (obj.lazy)
|
|
2833
2905
|
return this.lazyField(o.id, obj, f, x, q);
|
|
2906
|
+
// (a class attribute set to a constant, which no method sets on the object: that constant)
|
|
2907
|
+
const ca = r.cattrs?.[f];
|
|
2908
|
+
if (ca !== undefined)
|
|
2909
|
+
return [ca === null ? { t: 'none' } : typeof ca === 'boolean' ? { t: 'bool', e: ca ? I.T : I.F } : typeof ca === 'number' ? (Number.isInteger(ca) ? { t: 'num', e: I.num(ca) } : { t: 'opaque', why: `${x.text}: a float` }) : { t: 'str', e: { op: 'slit', value: ca } }, q];
|
|
2834
2910
|
return refuse(x, `${x.text}: no field ${f} (the object's fields are those its constructor sets)`);
|
|
2835
2911
|
}
|
|
2836
2912
|
// A field of an object the caller gives, made an input where it is first read.
|
|
@@ -2877,12 +2953,22 @@ export class Stepper {
|
|
|
2877
2953
|
}
|
|
2878
2954
|
return [{ t: 'opaque', why: `${x.text}: a true division (a float; the subset reads math.floor or math.ceil of x / k, int(x / k), or x // k)` }, q2];
|
|
2879
2955
|
}
|
|
2956
|
+
// (other code's value left out, computed with: whether that raises is that value's, so it is read)
|
|
2957
|
+
const asked = [a, b].find(v => v.t === 'opaque' && v.ask);
|
|
2958
|
+
if (asked)
|
|
2959
|
+
return refuse(x, `${x.text}: arithmetic on ${asked.why} (what it does depends on that value)`);
|
|
2880
2960
|
if (a.t === 'opaque' || b.t === 'opaque')
|
|
2881
2961
|
return [a.t === 'opaque' ? a : b, q2];
|
|
2882
2962
|
if ((a.t === 'str' || a.t === 'fmt') && op === '+')
|
|
2883
2963
|
return [{ t: 'opaque', why: `${x.text}: strings joined` }, q2];
|
|
2884
|
-
if (a.t === 'str' && op === '%')
|
|
2885
|
-
|
|
2964
|
+
if (a.t === 'str' && op === '%') {
|
|
2965
|
+
// ('...%s...' % x or % (x, y): %s and %d holes, %% a percent sign)
|
|
2966
|
+
const f = a.e.op === 'slit' ? a.e.value.split(/(%[sd%])/) : undefined, xs = b.t === 'tuple' ? b.xs : [b];
|
|
2967
|
+
if (!f || f.filter(t => t === '%s' || t === '%d').length !== xs.length)
|
|
2968
|
+
return [{ t: 'opaque', why: `${x.text}: a string formatted` }, q2];
|
|
2969
|
+
let i = 0;
|
|
2970
|
+
return this.fstr(x, q2, f.flatMap((t) => (t === '%%' ? ['%'] : t === '%s' || t === '%d' ? [xs[i++]] : t ? [t] : [])));
|
|
2971
|
+
}
|
|
2886
2972
|
const na = this.numOf(a, x, q2), nb = this.numOf(b, x, q2);
|
|
2887
2973
|
switch (op) {
|
|
2888
2974
|
case '+': return [{ t: 'num', e: I.add(na, nb) }, q2];
|
|
@@ -3106,20 +3192,33 @@ export class Stepper {
|
|
|
3106
3192
|
}
|
|
3107
3193
|
// An f-string: with one hole between literal text, a key a store reads by (its template); else a value kept only
|
|
3108
3194
|
// where nothing reads it.
|
|
3109
|
-
|
|
3110
|
-
|
|
3195
|
+
// A constant string in a hole (a literal, a stated attribute: a store's name) is literal text of the template; a
|
|
3196
|
+
// % format ('%s.lock.%s' % (a, b)) is read as the f-string it spells.
|
|
3197
|
+
fstr(x, p, given) {
|
|
3198
|
+
const parts = given ?? x.parts;
|
|
3111
3199
|
let q = p, tpl = '', hole, n = 0, opaque = false, ask;
|
|
3112
3200
|
for (const part of parts) {
|
|
3113
3201
|
if (typeof part === 'string') {
|
|
3114
3202
|
tpl += part.replace(/\{\}/g, '{ }');
|
|
3115
3203
|
continue;
|
|
3116
3204
|
}
|
|
3117
|
-
|
|
3118
|
-
|
|
3205
|
+
let v;
|
|
3206
|
+
const plain = 't' in part || part.plain;
|
|
3207
|
+
if ('t' in part)
|
|
3208
|
+
v = part;
|
|
3209
|
+
else {
|
|
3210
|
+
const [v1, q2] = this.ev(part.x, q);
|
|
3211
|
+
v = v1;
|
|
3212
|
+
q = q2;
|
|
3213
|
+
}
|
|
3214
|
+
if (v.t === 'str' && v.e.op === 'slit' && plain) {
|
|
3215
|
+
tpl += v.e.value.replace(/\{\}/g, '{ }');
|
|
3216
|
+
continue;
|
|
3217
|
+
}
|
|
3119
3218
|
n++;
|
|
3120
3219
|
if (v.t === 'opaque' && v.ask)
|
|
3121
3220
|
ask ??= v;
|
|
3122
|
-
if (!
|
|
3221
|
+
if (!plain || n > 1 || !(v.t === 'str' || v.t === 'num')) {
|
|
3123
3222
|
opaque = true;
|
|
3124
3223
|
continue;
|
|
3125
3224
|
}
|
|
@@ -3136,11 +3235,12 @@ export class Stepper {
|
|
|
3136
3235
|
if (dead(p))
|
|
3137
3236
|
return [{ t: 'opaque', why: 'unreachable' }, p];
|
|
3138
3237
|
const fx = x.f, names = this.calleeNames(x), args0 = x.args, kw0 = x.kw;
|
|
3139
|
-
// The boundary first: an answered call, then a skipped one (
|
|
3140
|
-
const
|
|
3141
|
-
|
|
3238
|
+
// The boundary first: an effect, an answered call, then a skipped one (none's arguments read but an effect's).
|
|
3239
|
+
const quiet = this.match(this.opts.stubs, names), eff = quiet ?? this.match(this.opts.effects, names) ?? (this.tagAt(x.p)?.k === 'effect' ? names[0] : undefined);
|
|
3240
|
+
const ans = !eff ? this.match(Object.keys(this.opts.answers ?? {}), names) : undefined, skip = !eff && !ans && this.skipped(names);
|
|
3241
|
+
if (ans || skip || eff) {
|
|
3142
3242
|
let patch;
|
|
3143
|
-
if (!ans && !this.tries.length) { } // (left out outside a try: run as it is, no stub)
|
|
3243
|
+
if (!ans && !eff && !this.tries.length) { } // (left out outside a try: run as it is, no stub)
|
|
3144
3244
|
else if (fx.e === 'fn')
|
|
3145
3245
|
patch = { mod: this.mod.module, path: [String(fx.id)] };
|
|
3146
3246
|
else if (fx.e === 'get' && fx.x.e === 'var' && fx.x.n === 'self')
|
|
@@ -3148,7 +3248,10 @@ export class Stepper {
|
|
|
3148
3248
|
else if (fx.e === 'get') {
|
|
3149
3249
|
// A method of an object the caller gives, of another module's class: the class's method stubbed.
|
|
3150
3250
|
const [o] = this.ev(fx.x, p), obj = o.t === 'ref' ? p.heap.get(o.id) : undefined;
|
|
3151
|
-
|
|
3251
|
+
// (a class's method, Redis.from_url: stubbed on the class where the module reads it)
|
|
3252
|
+
if (o.t === 'cls' && o.patch?.path && (eff || ans))
|
|
3253
|
+
patch = { ...o.patch, path: [...o.patch.path, String(fx.f)] };
|
|
3254
|
+
else if (obj?.k === 'rec') {
|
|
3152
3255
|
const r = this.rec(obj.ty, x);
|
|
3153
3256
|
patch = { mod: r.module, path: [r.short, String(fx.f)] };
|
|
3154
3257
|
}
|
|
@@ -3168,6 +3271,22 @@ export class Stepper {
|
|
|
3168
3271
|
}
|
|
3169
3272
|
if (ans)
|
|
3170
3273
|
return this.answer(ans, names, patch, x, this.argsRead(x, p), awaited);
|
|
3274
|
+
if (eff) {
|
|
3275
|
+
if (!patch)
|
|
3276
|
+
return refuse(x, `${x.text}: an effect the check can't stub (a function of the module, a method of the object, a store or another module's)`);
|
|
3277
|
+
const key = eff.split('.').pop();
|
|
3278
|
+
const a = this.answers.get(key);
|
|
3279
|
+
if (a && !a.effect)
|
|
3280
|
+
return refuse(x, `${x.text}: ${key} an effect at one call and not at another`);
|
|
3281
|
+
if (!a) {
|
|
3282
|
+
this.answers.set(key, { key, patch, async: awaited, inputs: { name: '' }, sort: '', pass: true, effect: true, ...(quiet ? { quiet: true } : {}), at: [] });
|
|
3283
|
+
this.notes.add(quiet ? `${key} (${x.p}): stubbed (stated): it does nothing and returns None in the check` : `${key}: an effect (${this.opts.effects?.length ? 'stated' : 'tagged'}): each step says whether it called it (${key}.called), the check stubbing it`);
|
|
3284
|
+
}
|
|
3285
|
+
if (quiet)
|
|
3286
|
+
return [{ t: 'none' }, p];
|
|
3287
|
+
const q = this.argsRead(x, p);
|
|
3288
|
+
return [{ t: 'none' }, { ...q, eff: new Map(q.eff).set(key, I.T) }];
|
|
3289
|
+
}
|
|
3171
3290
|
for (const n of names)
|
|
3172
3291
|
this.leftOut.add(n);
|
|
3173
3292
|
this.notes.add(`${names[0]} (${x.p}): left out (stated: skip), run as it is by the check`);
|
|
@@ -3191,7 +3310,7 @@ export class Stepper {
|
|
|
3191
3310
|
return refuse(x, `${x.text}: a method of the store's ${o.path} (not stated)`);
|
|
3192
3311
|
[f, q] = this.get(fx, q);
|
|
3193
3312
|
if (o.t === 'opaque' && f.t === 'opaque')
|
|
3194
|
-
return this.inf ? this.boundary(x, { key: names[0] ?? String(x.text), name: names[0] ?? String(x.text), refusal: `${x.text}: a call on ${o.why}
|
|
3313
|
+
return this.inf ? this.boundary(x, { key: names[0] ?? String(x.text), name: names[0] ?? String(x.text), refusal: `${x.text}: a call on ${o.why}`, ...(o.sattr ? { recv: o } : {}) }, q, awaited) : refuse(x, `${x.text}: a call on ${o.why}`);
|
|
3195
3314
|
}
|
|
3196
3315
|
else
|
|
3197
3316
|
[f, q] = this.ev(fx, q);
|
|
@@ -4371,8 +4490,17 @@ const firm = (v) => ['ptr', 'struct', 'err', 'nil', 'map', 'list', 'push', 'pop'
|
|
|
4371
4490
|
// Whether some node of an IR tree (an object, depth first) is one f says yes to.
|
|
4372
4491
|
const deep = (x, f) => !!x && typeof x === 'object' && (!!f(x) || Object.values(x).some(y => deep(y, f)));
|
|
4373
4492
|
const callFree = (x) => !deep(x, o => o.e === 'call' || o.e === 'await' || o.e === 'no');
|
|
4374
|
-
//
|
|
4375
|
-
|
|
4493
|
+
// A key of the other kind than its map's (a string into a map keyed by numbers): never held where keys are compared as
|
|
4494
|
+
// they are (a Map, a dict, a hash), so refused; an object's keys (a record's, JavaScript's) are strings both.
|
|
4495
|
+
const kindOf = (k) => k.op === 'num' ? 'num' : k.op === 'svar' || k.op === 'slit' ? 'str' : k.op === 'kite' && kindOf(k.a) === kindOf(k.b) ? kindOf(k.a) : undefined;
|
|
4496
|
+
function keyKind(d, k, at) {
|
|
4497
|
+
const kk = kindOf(k);
|
|
4498
|
+
if (kk && kk !== d.key && d.js !== 'record' && !d.untyped)
|
|
4499
|
+
refuse(at, `${at.text ?? ''}: a ${kk === 'num' ? 'number' : 'string'} key of a map keyed by ${d.key === 'num' ? 'numbers' : 'strings'} (never one it holds)`);
|
|
4500
|
+
}
|
|
4501
|
+
// An expression that reaches none of the module's own code and not `self`, nor what raises wherever it runs (a reader's
|
|
4502
|
+
// `raises`: a name nothing binds).
|
|
4503
|
+
const foreign = (x) => !deep(x, o => o.e === 'fn' || (o.e === 'var' && o.n === 'self') || !!o.raises);
|
|
4376
4504
|
// Two key templates name disjoint keys: they differ at some position of their fixed prefixes or of their fixed
|
|
4377
4505
|
// suffixes (a hole's value can be any string, so only those parts tell keys apart).
|
|
4378
4506
|
export function disjoint(a, b) {
|
|
@@ -4659,8 +4787,11 @@ function readOnce(mod, opts, g) {
|
|
|
4659
4787
|
pre = I.and(I.not(I.or(...g.fails)), I.not(I.or(...g.paramsOut)), I.not(I.or(...g.refusals.splice(r0))));
|
|
4660
4788
|
g.fails = [];
|
|
4661
4789
|
g.init = false;
|
|
4662
|
-
// (a field a framework injects, @Autowired or @Inject on it
|
|
4663
|
-
|
|
4790
|
+
// (a field a framework injects, @Autowired or @Inject on it, or one a stated store names whatever the constructor
|
|
4791
|
+
// made it (a client made from a URL): the store the check gives, named by the field)
|
|
4792
|
+
const madeAs = (f) => made.heap.get('this').f.get(f), isStore = (v) => v?.t === 'ref' && made.heap.get(v.id)?.k === 'store';
|
|
4793
|
+
const stated = Object.keys(opts.stores ?? {}).filter(f => madeAs(f) && !isStore(madeAs(f)) && !r.fields.some(x => x.name === f)).map(f => ({ name: f, t: { k: 'any' } }));
|
|
4794
|
+
for (const fd of [...r.fields.filter(f => (g.inf && f.inject && !madeAs(f.name)) || (opts.stores?.[f.name] && madeAs(f.name) && !isStore(madeAs(f.name)))), ...stated]) {
|
|
4664
4795
|
const id = `store:${fd.name}`, o = { k: 'store', name: fd.name };
|
|
4665
4796
|
made.heap.set(id, o);
|
|
4666
4797
|
g.initHeap.set(id, o);
|
|
@@ -4672,7 +4803,7 @@ function readOnce(mod, opts, g) {
|
|
|
4672
4803
|
if (keyed)
|
|
4673
4804
|
g.storeKeyed.add(fd.name);
|
|
4674
4805
|
g.deps.push({ name: fd.name, ...(fd.t.k === 'rec' ? { ty: fd.t.name } : {}), keyed, stated: false });
|
|
4675
|
-
g.notes.add(`${r.short}.${fd.name}: an injected dependency (marked so), the check giving one`);
|
|
4806
|
+
g.notes.add(`${r.short}.${fd.name}: ${stated.includes(fd) ? 'a store (stated), the check giving one in its place after the constructor' : 'an injected dependency (marked so), the check giving one'}`);
|
|
4676
4807
|
}
|
|
4677
4808
|
// (two injected dependencies are taken as two objects: where they are of one type and the rule holds keys of one,
|
|
4678
4809
|
// the code may be given one object for both, which the rule would take as two; refused unless both are stated)
|
|
@@ -4701,7 +4832,7 @@ function readOnce(mod, opts, g) {
|
|
|
4701
4832
|
g.notes.add(`${r.short}.${fd.name}: declared on the class but not set by its constructor (left out)`);
|
|
4702
4833
|
// Each field a leaf: a variable (two for an optional one), a nested object's own, a map, a store, or left out.
|
|
4703
4834
|
const heap = new Map();
|
|
4704
|
-
const fields = new Map();
|
|
4835
|
+
const fields = new Map(), holding = new Set();
|
|
4705
4836
|
const build = (path, v, t, into, initPath) => {
|
|
4706
4837
|
const name = path.join('_'), f = path.at(-1), decl = t ?? undefined;
|
|
4707
4838
|
const scalarT = decl && decl.k !== 'opt' ? decl : undefined;
|
|
@@ -4748,9 +4879,14 @@ function readOnce(mod, opts, g) {
|
|
|
4748
4879
|
return;
|
|
4749
4880
|
}
|
|
4750
4881
|
if (o?.k === 'rec') {
|
|
4882
|
+
// (an object that holds itself, by a field of its own or of one it holds: its leaves would never end)
|
|
4883
|
+
if (holding.has(v.id))
|
|
4884
|
+
refuse(at, `${path.join('.')}: an object that holds itself`);
|
|
4885
|
+
holding.add(v.id);
|
|
4751
4886
|
const sub = new Map(), id = `state:${path.join('.')}`;
|
|
4752
4887
|
for (const [ff, vv] of o.f)
|
|
4753
4888
|
build([...path, ff], vv, g.mod.recs[o.ty]?.fields.find(x => x.name === ff)?.t, sub, initPath);
|
|
4889
|
+
holding.delete(v.id);
|
|
4754
4890
|
heap.set(id, { k: 'rec', ty: o.ty, f: sub, origin: 'state' });
|
|
4755
4891
|
leaves.push({ name: '', path, kind: 'frame', cls: o.ty });
|
|
4756
4892
|
into.set(f, { t: 'ref', id });
|
|
@@ -4790,8 +4926,9 @@ function readOnce(mod, opts, g) {
|
|
|
4790
4926
|
leaves.push({ name: '', path, kind: 'frame' });
|
|
4791
4927
|
return;
|
|
4792
4928
|
}
|
|
4793
|
-
// A field the constructor sets to None, of no declared type
|
|
4794
|
-
|
|
4929
|
+
// A field the constructor sets to None, of no declared type, or to a key's template (a lock's key made of its name):
|
|
4930
|
+
// a constant (a method setting it is refused).
|
|
4931
|
+
if (v.t === 'none' || v.t === 'fmt') {
|
|
4795
4932
|
into.set(f, v);
|
|
4796
4933
|
g.frozen.add(path.join('.'));
|
|
4797
4934
|
leaves.push({ name: '', path, kind: 'frame' });
|
|
@@ -4969,6 +5106,8 @@ function readOnce(mod, opts, g) {
|
|
|
4969
5106
|
if (kept) {
|
|
4970
5107
|
failedVar = g.newVar('failed', { k: 'bool' }, 'state', 'whether the step failed (an exception raised): the state is as it was');
|
|
4971
5108
|
}
|
|
5109
|
+
// (each effect: whether the step called it, on the method's path that did)
|
|
5110
|
+
const effectVars = [...g.answers.values()].filter(a => a.effect && !a.quiet).map(a => ({ key: a.key, v: g.newVar(`${a.key.replace(/\W+/g, '_')}_called`, { k: 'bool' }, 'state', `whether the step called ${a.key}`) }));
|
|
4972
5111
|
for (const [i, f] of finals.entries()) {
|
|
4973
5112
|
const fn = chosen[i];
|
|
4974
5113
|
const out = f.out;
|
|
@@ -5026,6 +5165,8 @@ function readOnce(mod, opts, g) {
|
|
|
5026
5165
|
state.push(rn);
|
|
5027
5166
|
init[rn.name] = { s: 'bool', e: I.F };
|
|
5028
5167
|
}
|
|
5168
|
+
for (const e of effectVars)
|
|
5169
|
+
fields.push([`effect:${e.key}`, e.v.name]);
|
|
5029
5170
|
if (fields.length === 1 && !failedVar && rv && !rn)
|
|
5030
5171
|
results[fn.name] = { k: 'scalar', name: rv.name };
|
|
5031
5172
|
else if (fields.length)
|
|
@@ -5052,6 +5193,12 @@ function readOnce(mod, opts, g) {
|
|
|
5052
5193
|
writes[o] = acc;
|
|
5053
5194
|
void v;
|
|
5054
5195
|
}
|
|
5196
|
+
for (const e of effectVars) {
|
|
5197
|
+
outputs.push(e.v.name);
|
|
5198
|
+
state.push(e.v);
|
|
5199
|
+
init[e.v.name] = { s: 'bool', e: I.F };
|
|
5200
|
+
writes[e.v.name] = { s: 'bool', e: I.or(...finals.map(f => I.and(f.sel, f.path.eff?.get(e.key) ?? I.F))) };
|
|
5201
|
+
}
|
|
5055
5202
|
if (failedVar) {
|
|
5056
5203
|
outputs.push(failedVar.name);
|
|
5057
5204
|
state.push(failedVar);
|
|
@@ -5062,8 +5209,10 @@ function readOnce(mod, opts, g) {
|
|
|
5062
5209
|
// Inputs no term reads are still the request's (the check builds the arguments from them).
|
|
5063
5210
|
const maps = g.maps.filter(d => [...g.initHeap.values()].some(o => o.k === 'map' && o.decl === d));
|
|
5064
5211
|
const stores = Object.fromEntries([...new Set([...Object.keys(opts.stores ?? {}), ...g.storeDecls.keys()])].map(n => [n, { ...g.storeDecl(n), async: g.storeAsync[n] ?? {} }]));
|
|
5065
|
-
for (const sm of g.storeMaps.values())
|
|
5066
|
-
|
|
5212
|
+
for (const sm of g.storeMaps.values()) {
|
|
5213
|
+
const str = sm.decl.fields[0]?.sort.k === 'str' && !sm.json;
|
|
5214
|
+
leaves.push({ name: sm.decl.name, path: [], kind: 'map', key: sm.decl.key, store: sm.store, tpl: sm.tpl, ...(stores[sm.store]?.value !== 'int' && stores[sm.store]?.values?.[sm.tpl] !== 'int' && !sm.json && !sm.choice && !str ? { float: true } : {}), ...(sm.json ? { json: sm.json } : {}), ...(sm.choice ? { choice: true } : {}), ...(str ? { str: true } : {}) });
|
|
5215
|
+
}
|
|
5067
5216
|
const layout = { k: 'rec', fields: state.filter(v => !outputs.includes(v.name)).map(v => [v.name, { k: 'scalar', name: v.name }]) };
|
|
5068
5217
|
for (const fn of chosen) {
|
|
5069
5218
|
const used = new Set();
|
|
@@ -5178,7 +5327,7 @@ function readOnce(mod, opts, g) {
|
|
|
5178
5327
|
...(g.leasts.length ? { leasts: g.leasts } : {}),
|
|
5179
5328
|
...(g.used.size ? { seqs: g.seqs.filter(d => g.used.has(d.name)), folds: g.folds } : {}),
|
|
5180
5329
|
};
|
|
5181
|
-
return { ints: Object.fromEntries(g.ints), ...(g.madeAt ? { madeAt: g.madeAt.name } : {}), model, leaves, args: argsOf, answers: [...g.answers.values()], ctor, kept, arms: [...g.arms].map(a => { const i = a.lastIndexOf(':'); return [a.slice(0, i), Number(a.slice(i + 1))]; }), ...(cls ? { cls } : {}), stores, results: resultKinds, ...(g.injectedFields.length ? { inject: g.injectedFields } : {}) };
|
|
5330
|
+
return { ints: Object.fromEntries(g.ints), ...(g.madeAt ? { madeAt: g.madeAt.name } : {}), model, leaves, args: argsOf, answers: [...g.answers.values()], ctor, kept, arms: [...g.arms].map(a => { const i = a.lastIndexOf(':'); return [a.slice(0, i), Number(a.slice(i + 1))]; }), ...(cls ? { cls } : {}), stores, results: resultKinds, ...(g.injectedFields.length ? { inject: g.injectedFields } : {}), ...(g.globalStores.length ? { globals: g.globalStores } : {}), ...(g.inertAttrs.length ? { inert: g.inertAttrs } : {}), ...(effectVars.length ? { effectsOf: Object.fromEntries(finals.map((f, i) => [chosen[i].name, effectVars.filter(e => f.path.eff?.has(e.key)).map(e => e.v.name)])) } : {}) };
|
|
5182
5331
|
}
|
|
5183
5332
|
// A type's range (64 bits and wider: the rule's numbers stop at ±2^53 before the type's do, and are refused there).
|
|
5184
5333
|
export const rangeOf = (ty) => (ty.bits === 0 || ty.bits >= 64 ? (ty.signed ? [-Infinity, Infinity] : [0, Infinity]) : ty.signed ? [-(2 ** (ty.bits - 1)), 2 ** (ty.bits - 1) - 1] : [0, 2 ** ty.bits - 1]);
|
|
@@ -5209,7 +5358,7 @@ export function padWrites(lists, base) {
|
|
|
5209
5358
|
export function mapWritesOf(g, d, sels, ws, fix = (_, w) => w) {
|
|
5210
5359
|
if (!ws.some(Boolean))
|
|
5211
5360
|
return undefined;
|
|
5212
|
-
const key0 = ws.find(Boolean).key, base = (k) => { const c = g.baseCell(d, k); return { key: k, has: c.has, vals: Object.fromEntries([...c.vals].map(([f, v]) => [f, { s: v.t === 'num' ? 'num' : v.t === 'choice' ? 'choice' : 'bool', e: v.e }])) }; };
|
|
5361
|
+
const key0 = ws.find(Boolean).key, base = (k) => { const c = g.baseCell(d, k); return { key: k, has: c.has, vals: Object.fromEntries([...c.vals].map(([f, v]) => [f, { s: v.t === 'num' ? 'num' : v.t === 'choice' ? 'choice' : v.t === 'str' ? 'str' : 'bool', e: v.e }])) }; };
|
|
5213
5362
|
let acc;
|
|
5214
5363
|
for (let i = sels.length - 1; i >= 0; i--) {
|
|
5215
5364
|
const w = ws[i] ? fix(i, ws[i], base) : base(acc?.key ?? key0), c = sels[i];
|
|
@@ -5254,24 +5403,61 @@ export function asset(rel) {
|
|
|
5254
5403
|
}
|
|
5255
5404
|
// A harness started on the two named pipes in `work` and both opened. It runs under sh, which, if the harness exits
|
|
5256
5405
|
// before it answered (it couldn't start: a file missing, an interpreter absent, the code not loading), opens the
|
|
5257
|
-
// pipes itself and answers the first request with the error, so nothing here waits on a harness that is gone.
|
|
5258
|
-
|
|
5406
|
+
// pipes itself and answers the first request with the error, so nothing here waits on a harness that is gone. The
|
|
5407
|
+
// reads here block, so the harness runs within GDP_CHECK_HARNESS_S seconds (120, all its requests): past them sh kills
|
|
5408
|
+
// it and answers `stopped` (a step of the code that doesn't end: a loop a reader read as one that does).
|
|
5409
|
+
export const harnessLimit = () => Number(proc?.env?.GDP_CHECK_HARNESS_S ?? 120);
|
|
5410
|
+
// The check's build of the code (its compiler, the code with the harness): each within GDP_COMPILE_S seconds (900).
|
|
5411
|
+
// The compiler's errors about the code's own files are the source's (a refusal, with its message), about the
|
|
5412
|
+
// harness's the check's own; a compiler that fails saying nothing of the code (killed, crashed, past its time) runs
|
|
5413
|
+
// once more (`first`: a failure already had), then fails the check's harness. Never "the rule and the code differ".
|
|
5414
|
+
export const compileLimit = () => Number(proc?.env?.GDP_COMPILE_S ?? 900) * 1000;
|
|
5415
|
+
export function buildCheck(tool, run, errorsOf, ofSource, first) {
|
|
5416
|
+
let last = first;
|
|
5417
|
+
for (let i = 0; i < 2; i++) {
|
|
5418
|
+
if (i > 0 || last === undefined) {
|
|
5419
|
+
try {
|
|
5420
|
+
return { ok: run() };
|
|
5421
|
+
}
|
|
5422
|
+
catch (e) {
|
|
5423
|
+
last = e;
|
|
5424
|
+
}
|
|
5425
|
+
}
|
|
5426
|
+
const errs = last.signal ? [] : errorsOf(last);
|
|
5427
|
+
if (errs.length) {
|
|
5428
|
+
const src = errs.filter(ofSource);
|
|
5429
|
+
return src.length ? { kind: 'source', why: `the source doesn't compile (${tool}): ${src.slice(0, 3).join(' | ').slice(0, 900)}` } : { kind: 'harness', why: `the check's harness for the code doesn't build (${tool}): ${errs.slice(0, 3).join(' | ').slice(0, 900)}` };
|
|
5430
|
+
}
|
|
5431
|
+
}
|
|
5432
|
+
const said = String(last.stderr || last?.message || last).split('\n').filter(l => l.trim()).slice(-2).join(' | ').slice(0, 300);
|
|
5433
|
+
return { kind: 'harness', why: `${tool} failed twice with nothing to say of the code (${last.signal ? `killed: ${last.signal}, ` : ''}${said})` };
|
|
5434
|
+
}
|
|
5435
|
+
// (a build's outcome as the check's evidence: the source refused, or the harness failed)
|
|
5436
|
+
export const builtEvidence = (b) => (b.kind === 'source' ? { source: b.why } : { harness: b.why });
|
|
5437
|
+
// (the harness past its time, or its transport failing, `transport` set: the check's failure, not the code's)
|
|
5438
|
+
export const stopped = (res) => { if (res.stopped || res.transport)
|
|
5439
|
+
throw new HarnessFailure(String(res.error)); return res; };
|
|
5440
|
+
const GUARD = 'i=$1 o=$2 l=$3; shift 3; trap \'kill $p $w 2>/dev/null; exit 143\' TERM; "$@" "$i" "$o" & p=$!; (trap \'kill $s 2>/dev/null; exit 0\' TERM; sleep "$l" & s=$!; wait $s; kill -9 $p) 2>/dev/null & w=$!; wait $p; e=$?; kill $w 2>/dev/null; [ "$e" = 0 ] && exit 0; trap - TERM; if [ "$e" = 137 ]; then exec 4>"$o"; printf \'{"error": "the code did not answer within %s s (a request that does not end)", "stopped": true}\\n\' "$l" >&4; exit 1; fi; exec 3<"$i" 4>"$o"; read -r _ <&3; printf \'{"error": "the harness exited (status %s) before it answered"}\\n\' "$e" >&4';
|
|
5259
5441
|
export function openHarness(work, cmd, args, o) {
|
|
5260
5442
|
const fs = node('node:fs'), cp = node('node:child_process');
|
|
5261
5443
|
cp.execFileSync('mkfifo', [`${work}/in`, `${work}/out`], {});
|
|
5262
|
-
const child = cp.spawn('sh', ['-c', GUARD, 'gdp-harness', `${work}/in`, `${work}/out`, cmd, ...args], o);
|
|
5444
|
+
const child = cp.spawn('sh', ['-c', GUARD, 'gdp-harness', `${work}/in`, `${work}/out`, String(harnessLimit()), cmd, ...args], o);
|
|
5263
5445
|
const wi = fs.openSync(`${work}/in`, 'w'), ro = fs.openSync(`${work}/out`, 'r');
|
|
5264
5446
|
return { child, wi, ro };
|
|
5265
5447
|
}
|
|
5266
5448
|
export function checkStep(h, read, r, sorts, opts) {
|
|
5449
|
+
return retried(() => checkStepOnce(h, read, r, sorts, opts), () => ({ ...noEvidence(), runMs: 0 }));
|
|
5450
|
+
}
|
|
5451
|
+
function checkStepOnce(h, read, r, sorts, opts) {
|
|
5267
5452
|
const o = opts.check ?? {}, m = read.model, bound = o.bound ?? 12;
|
|
5268
5453
|
const fs = node('node:fs'), os = node('node:os');
|
|
5269
5454
|
const work = fs.mkdtempSync(`${os.tmpdir()}/gdp-stepcheck-`);
|
|
5270
5455
|
let child, wi = -1, ro = -1;
|
|
5271
5456
|
const empty = { runs: 0, requests: 0, fromStates: 0, probes: { conditions: 0, witnesses: 0, steps: 0 }, refusedBoth: 0, outside: 0, edge: 0, compiledAgreed: 0, coverage: { arms: 0, hit: 0, missed: [] }, ms: 0, runMs: 0 };
|
|
5272
5457
|
try {
|
|
5458
|
+
// (no harness: no request ran, so never a difference: the check's own failure, or the code refused with why)
|
|
5273
5459
|
if (h.error)
|
|
5274
|
-
return { ...empty,
|
|
5460
|
+
return h.kind === 'harness' ? { ...empty, harness: h.error } : { ...empty, source: h.error };
|
|
5275
5461
|
({ child, wi, ro } = openHarness(work, h.cmd, h.args, { stdio: ['ignore', 'ignore', 'inherit'], env: { ...proc?.env, ...h.env } }));
|
|
5276
5462
|
const buf = new Uint8Array(1 << 20), dec = new TextDecoder();
|
|
5277
5463
|
let pend = '';
|
|
@@ -5293,10 +5479,10 @@ export function checkStep(h, read, r, sorts, opts) {
|
|
|
5293
5479
|
fs.writeSync(wi, `${JSON.stringify(cmd)}\n`);
|
|
5294
5480
|
const l = line();
|
|
5295
5481
|
if (l === undefined)
|
|
5296
|
-
throw new
|
|
5297
|
-
return JSON.parse(l);
|
|
5482
|
+
throw new HarnessFailure('the harness stopped before it answered');
|
|
5483
|
+
return stopped(JSON.parse(l));
|
|
5298
5484
|
};
|
|
5299
|
-
const hi = ask({ op: 'hello', ...h.hello, leaves: read.leaves, ctor: read.ctor, answers: read.answers, kept: read.kept, cls: read.cls ?? null, stores: read.stores, arms: read.arms, discard: opts.onError === 'discard', ...(read.inject ? { inject: read.inject } : {}) });
|
|
5485
|
+
const hi = ask({ op: 'hello', ...h.hello, leaves: read.leaves, ctor: read.ctor, answers: read.answers, kept: read.kept, cls: read.cls ?? null, stores: read.stores, arms: read.arms, discard: opts.onError === 'discard', ...(read.inject ? { inject: read.inject } : {}), ...(read.globals ? { globals: read.globals } : {}), ...(read.inert ? { inert: read.inert } : {}), ...(opts.fields ? { fields: opts.fields } : {}) });
|
|
5300
5486
|
if (hi.error)
|
|
5301
5487
|
return { ...empty, mismatch: `the code doesn't load with the check's harness: ${JSON.stringify(hi.error)}` };
|
|
5302
5488
|
const num = (x, at) => { const n = Number(x); if (typeof x === 'string' && Number.isSafeInteger(n) && String(n) === x)
|
|
@@ -5343,6 +5529,9 @@ export function checkStep(h, read, r, sorts, opts) {
|
|
|
5343
5529
|
throw new Error(`the code changes ${res.frame}, a field the rule leaves out`);
|
|
5344
5530
|
if (res.bad !== undefined)
|
|
5345
5531
|
return { ok: false, error: `the code can't be given it (${res.bad})` };
|
|
5532
|
+
// (the harness failed making the call: no step of the code, neither a refusal nor one taken)
|
|
5533
|
+
if (res.error !== undefined)
|
|
5534
|
+
throw new HarnessFailure(`the harness failed on a call: ${String(res.error)}`);
|
|
5346
5535
|
const kind = read.results[e.call] ?? 'none', failed = res.err !== undefined;
|
|
5347
5536
|
if (failed && !read.kept)
|
|
5348
5537
|
return { ok: false, error: `raised: ${res.err}` };
|
|
@@ -5369,6 +5558,8 @@ export function checkStep(h, read, r, sorts, opts) {
|
|
|
5369
5558
|
}
|
|
5370
5559
|
if (f === 'none')
|
|
5371
5560
|
o.none = !failed && (out === null || out === undefined) && kind === 'maybe';
|
|
5561
|
+
if (f.startsWith('effect:'))
|
|
5562
|
+
o[f] = !!res.effects?.[f.slice(7)];
|
|
5372
5563
|
}
|
|
5373
5564
|
return { ok: true, value: o };
|
|
5374
5565
|
},
|
|
@@ -5423,6 +5614,8 @@ export function checkStep(h, read, r, sorts, opts) {
|
|
|
5423
5614
|
return { ...ev, runMs: Math.round(performance.now() - r0) };
|
|
5424
5615
|
}
|
|
5425
5616
|
catch (x) {
|
|
5617
|
+
if (x instanceof HarnessFailure)
|
|
5618
|
+
throw x;
|
|
5426
5619
|
return { ...empty, mismatch: `the check's harness: ${x.message}` };
|
|
5427
5620
|
}
|
|
5428
5621
|
finally {
|
|
@@ -5453,6 +5646,42 @@ const g0 = (m, name) => { const v = m.state.find(x => x.name === name); return v
|
|
|
5453
5646
|
// A front end's whole run: the module read, the model printed and built, the code run beside it.
|
|
5454
5647
|
export function extractStep(mod, h, opts) {
|
|
5455
5648
|
const notes = [];
|
|
5649
|
+
// (an argument the code declares no type of, given one: `types`, by its name)
|
|
5650
|
+
for (const f of Object.values(mod.funcs))
|
|
5651
|
+
for (const pa of f.params) {
|
|
5652
|
+
const t = opts.types?.[pa.name];
|
|
5653
|
+
if (t && pa.t.k === 'any') {
|
|
5654
|
+
try {
|
|
5655
|
+
pa.t = sortOfText(t, f.p).t;
|
|
5656
|
+
notes.push(`${f.name}(${pa.name}): a ${t} (stated)`);
|
|
5657
|
+
}
|
|
5658
|
+
catch (e) {
|
|
5659
|
+
if (e instanceof Refusal)
|
|
5660
|
+
return { ok: false, refusals: [{ where: e.where, what: e.what }], notes };
|
|
5661
|
+
throw e;
|
|
5662
|
+
}
|
|
5663
|
+
}
|
|
5664
|
+
}
|
|
5665
|
+
// (and a field the class declares no type of: its declared type, by name)
|
|
5666
|
+
for (const r of Object.values(mod.recs))
|
|
5667
|
+
for (const [f, t] of Object.entries(opts.types ?? {})) {
|
|
5668
|
+
// (only a field its constructor sets: `self.<f> = ...`)
|
|
5669
|
+
const init = r.methods.__init__ ? mod.funcs[r.methods.__init__] : undefined;
|
|
5670
|
+
let sets = false;
|
|
5671
|
+
if (init)
|
|
5672
|
+
deep(init.body, st => { const to = st.to; if (st.s === 'set' && to?.e === 'get' && to.x.e === 'var' && to.x.n === 'self' && to.f === f)
|
|
5673
|
+
sets = true; });
|
|
5674
|
+
if (!r.own || r.fields.some(x => x.name === f) || !sets)
|
|
5675
|
+
continue;
|
|
5676
|
+
try {
|
|
5677
|
+
r.fields.push({ name: f, t: sortOfText(t, r.p).t });
|
|
5678
|
+
}
|
|
5679
|
+
catch (e) {
|
|
5680
|
+
if (e instanceof Refusal)
|
|
5681
|
+
return { ok: false, refusals: [{ where: e.where, what: e.what }], notes };
|
|
5682
|
+
throw e;
|
|
5683
|
+
}
|
|
5684
|
+
}
|
|
5456
5685
|
let read;
|
|
5457
5686
|
try {
|
|
5458
5687
|
read = readStep(mod, opts);
|
|
@@ -5517,6 +5746,8 @@ export function stepNames(read) {
|
|
|
5517
5746
|
out.push({ code: 'result', rule: `${method}_result`, role: 'result', method, ...(k === 'maybe' ? { none: `${method}_result_none` } : {}) });
|
|
5518
5747
|
if (vars.has('failed'))
|
|
5519
5748
|
out.push({ code: 'failed', rule: 'failed', role: 'failed' });
|
|
5749
|
+
for (const a of read.answers.filter(x => x.effect && !x.quiet))
|
|
5750
|
+
out.push({ code: `${a.key}.called`, rule: `${a.key.replace(/\W+/g, '_')}_called`, role: 'result' });
|
|
5520
5751
|
if (vars.has('now'))
|
|
5521
5752
|
out.push({ code: 'now', rule: 'now', role: 'clock' });
|
|
5522
5753
|
if (m.event)
|