gdp-wired 0.43.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.
Files changed (79) hide show
  1. package/README.md +8 -3
  2. package/dist/core/c/reader.js +22 -7
  3. package/dist/core/check.js +3 -2
  4. package/dist/core/cli.d.ts +7 -0
  5. package/dist/core/cli.js +184 -12
  6. package/dist/core/counts.d.ts +1 -1
  7. package/dist/core/counts.js +30 -12
  8. package/dist/core/data.d.ts +6 -1
  9. package/dist/core/data.js +894 -152
  10. package/dist/core/dsl.d.ts +2 -0
  11. package/dist/core/dsl.js +88 -10
  12. package/dist/core/effect-prims.d.ts +60 -0
  13. package/dist/core/effect-prims.js +625 -0
  14. package/dist/core/effect.d.ts +17 -1
  15. package/dist/core/effect.js +108 -4
  16. package/dist/core/ex/harness.exs +2 -0
  17. package/dist/core/ex/reader.exs +17 -1
  18. package/dist/core/exists.d.ts +15 -1
  19. package/dist/core/exists.js +263 -41
  20. package/dist/core/extract-c.d.ts +2 -0
  21. package/dist/core/extract-c.js +22 -13
  22. package/dist/core/extract-check.d.ts +7 -0
  23. package/dist/core/extract-check.js +57 -4
  24. package/dist/core/extract-ex.js +5 -5
  25. package/dist/core/extract-go-check.js +22 -17
  26. package/dist/core/extract-go.d.ts +3 -0
  27. package/dist/core/extract-go.js +24 -9
  28. package/dist/core/extract-jvm.js +68 -16
  29. package/dist/core/extract-print.js +3 -0
  30. package/dist/core/extract-py.js +5 -5
  31. package/dist/core/extract-rb.js +5 -5
  32. package/dist/core/extract-read.d.ts +8 -0
  33. package/dist/core/extract-read.js +55 -0
  34. package/dist/core/extract-rs.js +28 -25
  35. package/dist/core/extract-shapes.js +20 -0
  36. package/dist/core/extract-sol.js +23 -12
  37. package/dist/core/extract-step.d.ts +59 -3
  38. package/dist/core/extract-step.js +334 -64
  39. package/dist/core/extract-swift.js +22 -15
  40. package/dist/core/extract.d.ts +1 -0
  41. package/dist/core/extract.js +27 -2
  42. package/dist/core/fresh.d.ts +2 -2
  43. package/dist/core/fresh.js +7 -3
  44. package/dist/core/go/reader.go +7 -1
  45. package/dist/core/infer.js +113 -40
  46. package/dist/core/jvm/Harness.java +8 -1
  47. package/dist/core/jvm/JavaReader.java +10 -2
  48. package/dist/core/jvm/Jvm.java +18 -2
  49. package/dist/core/jvm/KtReader.java +60 -5
  50. package/dist/core/machine.d.ts +2 -0
  51. package/dist/core/machine.js +32 -6
  52. package/dist/core/py/harness.py +128 -24
  53. package/dist/core/py/reader.py +50 -5
  54. package/dist/core/rb/reader.rb +52 -5
  55. package/dist/core/rs/src/main.rs +10 -0
  56. package/dist/core/sol/Replay.sol +52 -0
  57. package/dist/core/sol/harness.py +511 -0
  58. package/dist/core/solver.js +5 -4
  59. package/dist/core/system.d.ts +62 -1
  60. package/dist/core/system.js +274 -6
  61. package/dist/core/transfer.js +17 -0
  62. package/dist/core/watch.js +1 -1
  63. package/dist/interchange/check.d.ts +18 -1
  64. package/dist/interchange/check.js +19 -12
  65. package/dist/interchange/cli.d.ts +2 -0
  66. package/dist/interchange/cli.js +45 -0
  67. package/dist/interchange/format.d.ts +5 -1
  68. package/dist/interchange/format.js +25 -9
  69. package/dist/kernel/cdcl.js +65 -14
  70. package/dist/kernel/epr.js +35 -5
  71. package/dist/kernel/kernel.d.ts +2 -0
  72. package/dist/kernel/kernel.js +67 -40
  73. package/dist/kernel/prove.d.ts +22 -0
  74. package/dist/kernel/prove.js +156 -7
  75. package/dist/kernel/reader.js +3 -2
  76. package/dist/lean-kernel/emit.d.ts +9 -3
  77. package/dist/lean-kernel/emit.js +170 -29
  78. package/dist/lean-kernel/library.js +1 -1
  79. package/package.json +12 -3
@@ -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
- if (o.k === 'map' ? !!o.w || (!!o.nil && I.keyOf(o.nil) !== I.keyOf(i.nil)) : o.k === 'list' ? o.ops.length > 0 : keyV(o) !== keyV(i))
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
- return { pc, locals, heap, called: [...new Set([...a.called, ...b.called])], locks: a.locks, defers: [...new Set([...a.defers, ...b.defers])] };
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
@@ -1664,8 +1672,12 @@ export class Stepper {
1664
1672
  if (!pa.inject && (this.scalar(t) || ['lock', 'none', 'map', 'list'].includes(t.k) || (t.k === 'rec' && this.mod.recs[t.name]?.own && !this.mod.recs[t.name].kinds.includes('protocol')) || (pa.dflt && !(pa.t.k === 'opt' && pa.dflt.e === 'none'))))
1665
1673
  return undefined;
1666
1674
  const fields = [];
1667
- deep(init.body, st => { const to = st.to, v = st.x; if (st.s === 'set' && to?.e === 'get' && to.x.e === 'var' && to.x.n === 'self' && v?.e === 'var' && v.n === pa.name)
1668
- fields.push(String(to.f)); });
1675
+ // (self.f = arg, or one place of a tuple's, self.a, self.f = a, arg)
1676
+ const pairs = (to, v) => (to?.e === 'tuple' && v?.e === 'tuple' && to.xs.length === v.xs.length ? to.xs.flatMap((t, i) => pairs(t, v.xs[i])) : [[to, v]]);
1677
+ deep(init.body, st => { if (st.s === 'set')
1678
+ for (const [to, v] of pairs(st.to, st.x))
1679
+ if (to?.e === 'get' && to.x.e === 'var' && to.x.n === 'self' && v?.e === 'var' && v.n === pa.name)
1680
+ fields.push(String(to.f)); });
1669
1681
  const ms = this.callsOn(r, fields);
1670
1682
  if (!pa.inject && !ms.length)
1671
1683
  return undefined;
@@ -1703,11 +1715,11 @@ export class Stepper {
1703
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)`); };
1704
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`);
1705
1717
  const has = (n, i) => kw.some(([k]) => k === n) || args.length > i;
1706
- 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;
1707
1719
  if (!kind && this.inf) {
1708
1720
  // (inferred: a method named as a key's get, set or delete, given a key that is a string or a format)
1709
1721
  const k = keyShape(m), key = kw.find(([n]) => n === 'key' || n === 'name')?.[1] ?? args[0];
1710
- 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))) {
1711
1723
  kind = k;
1712
1724
  (d[k] ??= []).push(m);
1713
1725
  this.notes.add(`${store}.${m}: read as the store's ${k} by a key (inferred from its name)`);
@@ -1737,15 +1749,15 @@ export class Stepper {
1737
1749
  return refuse(at, `${at.text}: the store's ${m} awaited at one call and not at another`);
1738
1750
  this.storeAsync[store][m] = awaited;
1739
1751
  // (a key's operation takes its key, and a set its value: any other argument given the rule's state is refused)
1740
- const keyV = arg('key', 0), valV = kind === 'set' ? arg('value', 1) : undefined;
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;
1741
1753
  // (a set's options: nx and xx make it conditional, its result whether it set (True, else None, as redis-py's); its
1742
1754
  // expiry is left out, as every store's is; any other option is refused)
1743
1755
  const TTL = ['ex', 'px', 'exat', 'pxat', 'ttl', 'timeout', 'expire', 'expiry'];
1744
1756
  let only;
1745
1757
  for (const [n, v] of kw) {
1746
- if (n === 'key' || n === 'name' || n === 'value')
1758
+ if (n === 'key' || n === 'name' || n === 'value' || (kind === 'incr' && n === 'amount'))
1747
1759
  continue;
1748
- if (kind === 'set' && TTL.includes(n)) {
1760
+ if (sets && TTL.includes(n)) {
1749
1761
  this.notes.add(`${store}.${m}: its ${n} (the key's expiry) left out, as the store's expiry is`);
1750
1762
  continue;
1751
1763
  }
@@ -1759,12 +1771,27 @@ export class Stepper {
1759
1771
  }
1760
1772
  continue;
1761
1773
  }
1762
- return refuse(at, `${at.text}: the store's ${m} given ${n} (the subset reads a key, a value, nx, xx and the expiry)`);
1774
+ // (another option given a constant, None or a flag, as a tracing span or which tier to use: the store is read as
1775
+ // one map whatever it says, the check's too, and the note says so; one given a value of the request is refused)
1776
+ if (v.t === 'none' || (v.t === 'bool' && v.e.op === 'const') || (v.t === 'num' && v.e.op === 'const') || (v.t === 'str' && v.e.op === 'slit')) {
1777
+ this.notes.add(`${store}.${m}: its ${n} (${v.t === 'none' ? 'None' : v.t === 'str' ? JSON.stringify(v.e.value) : String(v.e.v)}) left out: the store read as one map whatever it says`);
1778
+ continue;
1779
+ }
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)`);
1763
1781
  }
1764
- given(all.filter(v => v !== keyV && v !== valV));
1765
- if (args.length > (kind === 'set' ? 2 : 1))
1766
- return refuse(at, `${at.text}: the store's ${m} given more than its key${kind === 'set' ? ' and value' : ''}`);
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' : ''}`);
1767
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
+ }
1768
1795
  const [id, o] = this.storeMap(store, tpl, kn, at, p), sm = [...this.storeMaps.values()].find(x => x.id === id);
1769
1796
  // (inside a try that may catch it: the store's operation may raise, as other code's may, before it acts)
1770
1797
  if (this.tries.length && !d.nothrow)
@@ -1785,6 +1812,15 @@ export class Stepper {
1785
1812
  }
1786
1813
  if (kind === 'delete')
1787
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';
1788
1824
  const v = arg('value', 1);
1789
1825
  let vals;
1790
1826
  if (sm.json) {
@@ -1809,11 +1845,10 @@ export class Stepper {
1809
1845
  }
1810
1846
  }
1811
1847
  else {
1812
- const v2 = sm.choice ? this.fit(v, o.decl.fields[0], at) : v;
1813
- if (sm.choice ? v2.t !== 'choice' : o.val.k === 'str' ? v.t !== 'str' : v.t !== 'num')
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')
1814
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}`);
1815
- if (!sm.choice && o.val.k === 'str')
1816
- return refuse(at, `${at.text}: a store of strings (its cells hold numbers)`);
1817
1852
  vals = new Map([['value', v2]]);
1818
1853
  }
1819
1854
  if (!only)
@@ -1821,7 +1856,9 @@ export class Stepper {
1821
1856
  // (nx: where the key holds nothing; xx: where it holds a value)
1822
1857
  const c = this.cellOf(o, k, p, at), when = only === 'nx' ? I.not(c.has) : c.has;
1823
1858
  const merged = new Map([...vals].map(([n, x]) => [n, this.ite(when, x, c.vals.get(n), at)]));
1824
- return [{ t: 'opt', has: when, v: { t: 'bool', e: I.T } }, this.writeCell(id, o, k, I.bite(when, I.T, c.has), merged, at, p)];
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];
1825
1862
  }
1826
1863
  // --- context managers of the module's, made by @contextmanager ---------------------------------------------------------
1827
1864
  // with self.cm(...): body, where cm is a generator the module reads, decorated @contextmanager: the generator run,
@@ -2045,6 +2082,8 @@ export class Stepper {
2045
2082
  // other code may change it: refused unless the caller states it. Its value read (a run refused where it is): the next
2046
2083
  // run answers it by the request, over its declared type; else it is left out, kept only where nothing reads it.
2047
2084
  pend = new Map();
2085
+ // (the calls of other code left out, by the callee's names: a check that can't run them, C's, makes them no-ops)
2086
+ leftOut = new Set();
2048
2087
  returnedBy = new Map();
2049
2088
  entryIds = new Set();
2050
2089
  boundary(x, b, p, awaited) {
@@ -2060,7 +2099,12 @@ export class Stepper {
2060
2099
  if (t)
2061
2100
  return this.answer(b.key, [b.name], b.patch, x, q, awaited, t, tag ? 'tagged' : 'inferred');
2062
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);
2063
2106
  this.pend.set(why, { ...b, why, at: x.p, ...(x.end ? { end: x.end } : {}) });
2107
+ this.leftOut.add(b.name).add(b.key);
2064
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`);
2065
2109
  return [{ t: 'opaque', why, ask: b.key }, this.passing(b.key, b.name, b.patch, x, q, awaited)];
2066
2110
  }
@@ -2181,7 +2225,7 @@ export class Stepper {
2181
2225
  if (!lines) {
2182
2226
  lines = new Map();
2183
2227
  const src = sourceOf(this.mod, m[1]) ?? '';
2184
- 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)
2185
2229
  lines.set(i + 1, { k: t[1], arg: t[2].trim() }); });
2186
2230
  this.tagLines.set(m[1], lines);
2187
2231
  }
@@ -2291,7 +2335,7 @@ export class Stepper {
2291
2335
  case 'expect': {
2292
2336
  const [v, q] = this.ev(x.x, p);
2293
2337
  const good = this.isOf(v, 'good', x);
2294
- 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)`);
2295
2339
  return [this.inner(v, 'good', x), this.assume(q, good)];
2296
2340
  }
2297
2341
  case 'opt_or': {
@@ -2346,6 +2390,12 @@ export class Stepper {
2346
2390
  case 'upd': {
2347
2391
  const [o, q] = this.ev(x.x, p);
2348
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
+ }
2349
2399
  for (const [f, y] of x.fields) {
2350
2400
  const [v, q3] = this.ev(y, q2);
2351
2401
  q2 = this.setField(c, f, v, x, q3);
@@ -2360,6 +2410,9 @@ export class Stepper {
2360
2410
  const v = p.locals.get(String(x.n));
2361
2411
  // (Python's local read on a path that never set it, past a raise caught before its assignment: an
2362
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];
2363
2416
  if (!v && !x.why && this.mod.lang === 'python') {
2364
2417
  this.fail(p, I.T, x, `${String(x.n)}: a local read before it is set (an UnboundLocalError)`);
2365
2418
  return [{ t: 'opaque', why: 'unreachable' }, { ...p, pc: [...p.pc, I.F] }];
@@ -2372,14 +2425,43 @@ export class Stepper {
2372
2425
  case 'cls': return [{ t: 'cls', rec: String(x.rec), ...(x.patch ? { patch: x.patch } : {}) }, p];
2373
2426
  case 'builtin': return [{ t: 'builtin', n: String(x.n) }, p];
2374
2427
  case 'lib': return [{ t: 'lib', q: String(x.q) }, p];
2375
- case 'ext': 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];
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
+ }
2376
2446
  case 'no': {
2377
2447
  // (a call of other code a reader doesn't lower, `ext` its name: at the boundary, where it is inferred)
2378
2448
  if (x.ext && !x.pre && !x.prepl) {
2379
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
+ }
2380
2460
  if (ans)
2381
2461
  return this.answer(ans, names, patch, x, x.args ? this.argsRead(x, p) : p, false);
2382
2462
  if (this.skipped(names)) {
2463
+ for (const n of names)
2464
+ this.leftOut.add(n);
2383
2465
  this.notes.add(`${names[0]} (${x.p}): left out (stated: skip), run as it is by the check`);
2384
2466
  return [{ t: 'opaque', why: `${names[0]}: the value of a call left out (skip)` }, this.passing(names[0], names[0], patch, x, x.args ? this.argsRead(x, p) : p, false)];
2385
2467
  }
@@ -2580,8 +2662,11 @@ export class Stepper {
2580
2662
  case 'get': return this.get(x, p);
2581
2663
  case 'idx': {
2582
2664
  const [m, q] = this.ev(x.x, p), [k, q2] = this.ev(x.i, q);
2583
- if (m.t === 'opaque')
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')
2584
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)`);
2585
2670
  if (m.t === 'val')
2586
2671
  return this.valItem(m, k, x, q2);
2587
2672
  const ord = this.orderedObj(m, q2);
@@ -2598,6 +2683,8 @@ export class Stepper {
2598
2683
  }
2599
2684
  case 'neg': {
2600
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)`);
2601
2688
  if (v.t === 'opaque')
2602
2689
  return [v, q];
2603
2690
  return [{ t: 'num', e: I.neg(this.numOf(v, x, q)) }, q];
@@ -2816,6 +2903,10 @@ export class Stepper {
2816
2903
  }
2817
2904
  if (obj.lazy)
2818
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];
2819
2910
  return refuse(x, `${x.text}: no field ${f} (the object's fields are those its constructor sets)`);
2820
2911
  }
2821
2912
  // A field of an object the caller gives, made an input where it is first read.
@@ -2862,12 +2953,22 @@ export class Stepper {
2862
2953
  }
2863
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];
2864
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)`);
2865
2960
  if (a.t === 'opaque' || b.t === 'opaque')
2866
2961
  return [a.t === 'opaque' ? a : b, q2];
2867
2962
  if ((a.t === 'str' || a.t === 'fmt') && op === '+')
2868
2963
  return [{ t: 'opaque', why: `${x.text}: strings joined` }, q2];
2869
- if (a.t === 'str' && op === '%')
2870
- return [{ t: 'opaque', why: `${x.text}: a string formatted` }, q2];
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
+ }
2871
2972
  const na = this.numOf(a, x, q2), nb = this.numOf(b, x, q2);
2872
2973
  switch (op) {
2873
2974
  case '+': return [{ t: 'num', e: I.add(na, nb) }, q2];
@@ -3091,20 +3192,33 @@ export class Stepper {
3091
3192
  }
3092
3193
  // An f-string: with one hole between literal text, a key a store reads by (its template); else a value kept only
3093
3194
  // where nothing reads it.
3094
- fstr(x, p) {
3095
- const parts = x.parts;
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;
3096
3199
  let q = p, tpl = '', hole, n = 0, opaque = false, ask;
3097
3200
  for (const part of parts) {
3098
3201
  if (typeof part === 'string') {
3099
3202
  tpl += part.replace(/\{\}/g, '{ }');
3100
3203
  continue;
3101
3204
  }
3102
- const [v, q2] = this.ev(part.x, q);
3103
- q = q2;
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
+ }
3104
3218
  n++;
3105
3219
  if (v.t === 'opaque' && v.ask)
3106
3220
  ask ??= v;
3107
- if (!part.plain || n > 1 || !(v.t === 'str' || (v.t === 'num' && part.plain))) {
3221
+ if (!plain || n > 1 || !(v.t === 'str' || v.t === 'num')) {
3108
3222
  opaque = true;
3109
3223
  continue;
3110
3224
  }
@@ -3121,11 +3235,12 @@ export class Stepper {
3121
3235
  if (dead(p))
3122
3236
  return [{ t: 'opaque', why: 'unreachable' }, p];
3123
3237
  const fx = x.f, names = this.calleeNames(x), args0 = x.args, kw0 = x.kw;
3124
- // The boundary first: an answered call, then a skipped one (neither's arguments read).
3125
- const ans = this.match(Object.keys(this.opts.answers ?? {}), names), skip = !ans && this.skipped(names);
3126
- if (ans || skip) {
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) {
3127
3242
  let patch;
3128
- 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)
3129
3244
  else if (fx.e === 'fn')
3130
3245
  patch = { mod: this.mod.module, path: [String(fx.id)] };
3131
3246
  else if (fx.e === 'get' && fx.x.e === 'var' && fx.x.n === 'self')
@@ -3133,10 +3248,16 @@ export class Stepper {
3133
3248
  else if (fx.e === 'get') {
3134
3249
  // A method of an object the caller gives, of another module's class: the class's method stubbed.
3135
3250
  const [o] = this.ev(fx.x, p), obj = o.t === 'ref' ? p.heap.get(o.id) : undefined;
3136
- if (obj?.k === 'rec') {
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') {
3137
3255
  const r = this.rec(obj.ty, x);
3138
3256
  patch = { mod: r.module, path: [r.short, String(fx.f)] };
3139
3257
  }
3258
+ // (a method of a store or an injected dependency: stubbed on the one the check gives)
3259
+ else if (obj?.k === 'store')
3260
+ patch = { store: obj.name, path: [String(fx.f)] };
3140
3261
  else {
3141
3262
  const [v] = this.ev(fx, p);
3142
3263
  if (v.t === 'ext' || v.t === 'cls')
@@ -3150,6 +3271,24 @@ export class Stepper {
3150
3271
  }
3151
3272
  if (ans)
3152
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
+ }
3290
+ for (const n of names)
3291
+ this.leftOut.add(n);
3153
3292
  this.notes.add(`${names[0]} (${x.p}): left out (stated: skip), run as it is by the check`);
3154
3293
  return [{ t: 'opaque', why: `${x.text}: the value of a call left out (skip)` }, this.passing(names[0], names[0], patch, x, this.argsRead(x, p), awaited)];
3155
3294
  }
@@ -3171,7 +3310,7 @@ export class Stepper {
3171
3310
  return refuse(x, `${x.text}: a method of the store's ${o.path} (not stated)`);
3172
3311
  [f, q] = this.get(fx, q);
3173
3312
  if (o.t === 'opaque' && f.t === 'opaque')
3174
- 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}` }, q, awaited) : refuse(x, `${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}`);
3175
3314
  }
3176
3315
  else
3177
3316
  [f, q] = this.ev(fx, q);
@@ -4351,8 +4490,17 @@ const firm = (v) => ['ptr', 'struct', 'err', 'nil', 'map', 'list', 'push', 'pop'
4351
4490
  // Whether some node of an IR tree (an object, depth first) is one f says yes to.
4352
4491
  const deep = (x, f) => !!x && typeof x === 'object' && (!!f(x) || Object.values(x).some(y => deep(y, f)));
4353
4492
  const callFree = (x) => !deep(x, o => o.e === 'call' || o.e === 'await' || o.e === 'no');
4354
- // An expression that reaches none of the module's own code and not `self`.
4355
- const foreign = (x) => !deep(x, o => o.e === 'fn' || (o.e === 'var' && o.n === 'self'));
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);
4356
4504
  // Two key templates name disjoint keys: they differ at some position of their fixed prefixes or of their fixed
4357
4505
  // suffixes (a hole's value can be any string, so only those parts tell keys apart).
4358
4506
  export function disjoint(a, b) {
@@ -4639,8 +4787,11 @@ function readOnce(mod, opts, g) {
4639
4787
  pre = I.and(I.not(I.or(...g.fails)), I.not(I.or(...g.paramsOut)), I.not(I.or(...g.refusals.splice(r0))));
4640
4788
  g.fails = [];
4641
4789
  g.init = false;
4642
- // (a field a framework injects, @Autowired or @Inject on it: the store the check gives, named by the field)
4643
- for (const fd of g.inf ? r.fields.filter(f => f.inject && !made.heap.get('this').f.has(f.name)) : []) {
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]) {
4644
4795
  const id = `store:${fd.name}`, o = { k: 'store', name: fd.name };
4645
4796
  made.heap.set(id, o);
4646
4797
  g.initHeap.set(id, o);
@@ -4652,7 +4803,7 @@ function readOnce(mod, opts, g) {
4652
4803
  if (keyed)
4653
4804
  g.storeKeyed.add(fd.name);
4654
4805
  g.deps.push({ name: fd.name, ...(fd.t.k === 'rec' ? { ty: fd.t.name } : {}), keyed, stated: false });
4655
- 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'}`);
4656
4807
  }
4657
4808
  // (two injected dependencies are taken as two objects: where they are of one type and the rule holds keys of one,
4658
4809
  // the code may be given one object for both, which the rule would take as two; refused unless both are stated)
@@ -4681,7 +4832,7 @@ function readOnce(mod, opts, g) {
4681
4832
  g.notes.add(`${r.short}.${fd.name}: declared on the class but not set by its constructor (left out)`);
4682
4833
  // Each field a leaf: a variable (two for an optional one), a nested object's own, a map, a store, or left out.
4683
4834
  const heap = new Map();
4684
- const fields = new Map();
4835
+ const fields = new Map(), holding = new Set();
4685
4836
  const build = (path, v, t, into, initPath) => {
4686
4837
  const name = path.join('_'), f = path.at(-1), decl = t ?? undefined;
4687
4838
  const scalarT = decl && decl.k !== 'opt' ? decl : undefined;
@@ -4728,9 +4879,14 @@ function readOnce(mod, opts, g) {
4728
4879
  return;
4729
4880
  }
4730
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);
4731
4886
  const sub = new Map(), id = `state:${path.join('.')}`;
4732
4887
  for (const [ff, vv] of o.f)
4733
4888
  build([...path, ff], vv, g.mod.recs[o.ty]?.fields.find(x => x.name === ff)?.t, sub, initPath);
4889
+ holding.delete(v.id);
4734
4890
  heap.set(id, { k: 'rec', ty: o.ty, f: sub, origin: 'state' });
4735
4891
  leaves.push({ name: '', path, kind: 'frame', cls: o.ty });
4736
4892
  into.set(f, { t: 'ref', id });
@@ -4770,8 +4926,9 @@ function readOnce(mod, opts, g) {
4770
4926
  leaves.push({ name: '', path, kind: 'frame' });
4771
4927
  return;
4772
4928
  }
4773
- // A field the constructor sets to None, of no declared type: a constant (a method setting it is refused).
4774
- if (v.t === 'none') {
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') {
4775
4932
  into.set(f, v);
4776
4933
  g.frozen.add(path.join('.'));
4777
4934
  leaves.push({ name: '', path, kind: 'frame' });
@@ -4789,7 +4946,8 @@ function readOnce(mod, opts, g) {
4789
4946
  // --- the requests: each method (or function) one -------------------------------------------------------------------
4790
4947
  const r = cls ? g.rec(cls, at) : undefined;
4791
4948
  const chosen = cls
4792
- ? (opts.methods ?? writing ?? Object.keys(r.methods).filter(m => !m.startsWith('_') && r.methods[m])).map(m => (r.methods[m] ? g.func(r.methods[m], at) : refuse(at, `no method ${r.short}.${m} in ${mod.file}`)))
4949
+ // (by default its public methods but the one it is made by, Rust's new, which takes no object)
4950
+ ? (opts.methods ?? writing ?? Object.keys(r.methods).filter(m => !m.startsWith('_') && r.methods[m] && !(mod.lang === 'rust' && m === 'new'))).map(m => (r.methods[m] ? g.func(r.methods[m], at) : refuse(at, `no method ${r.short}.${m} in ${mod.file}`)))
4793
4951
  : entries.map(e => g.func(e.id, at));
4794
4952
  if (!chosen.length)
4795
4953
  refuse(at, `${cls ? r.short : 'the entry'} has no methods to read`);
@@ -4948,6 +5106,8 @@ function readOnce(mod, opts, g) {
4948
5106
  if (kept) {
4949
5107
  failedVar = g.newVar('failed', { k: 'bool' }, 'state', 'whether the step failed (an exception raised): the state is as it was');
4950
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}`) }));
4951
5111
  for (const [i, f] of finals.entries()) {
4952
5112
  const fn = chosen[i];
4953
5113
  const out = f.out;
@@ -5005,6 +5165,8 @@ function readOnce(mod, opts, g) {
5005
5165
  state.push(rn);
5006
5166
  init[rn.name] = { s: 'bool', e: I.F };
5007
5167
  }
5168
+ for (const e of effectVars)
5169
+ fields.push([`effect:${e.key}`, e.v.name]);
5008
5170
  if (fields.length === 1 && !failedVar && rv && !rn)
5009
5171
  results[fn.name] = { k: 'scalar', name: rv.name };
5010
5172
  else if (fields.length)
@@ -5031,6 +5193,12 @@ function readOnce(mod, opts, g) {
5031
5193
  writes[o] = acc;
5032
5194
  void v;
5033
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
+ }
5034
5202
  if (failedVar) {
5035
5203
  outputs.push(failedVar.name);
5036
5204
  state.push(failedVar);
@@ -5041,8 +5209,10 @@ function readOnce(mod, opts, g) {
5041
5209
  // Inputs no term reads are still the request's (the check builds the arguments from them).
5042
5210
  const maps = g.maps.filter(d => [...g.initHeap.values()].some(o => o.k === 'map' && o.decl === d));
5043
5211
  const stores = Object.fromEntries([...new Set([...Object.keys(opts.stores ?? {}), ...g.storeDecls.keys()])].map(n => [n, { ...g.storeDecl(n), async: g.storeAsync[n] ?? {} }]));
5044
- for (const sm of g.storeMaps.values())
5045
- 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 ? { float: true } : {}), ...(sm.json ? { json: sm.json } : {}), ...(sm.choice ? { choice: true } : {}) });
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
+ }
5046
5216
  const layout = { k: 'rec', fields: state.filter(v => !outputs.includes(v.name)).map(v => [v.name, { k: 'scalar', name: v.name }]) };
5047
5217
  for (const fn of chosen) {
5048
5218
  const used = new Set();
@@ -5157,7 +5327,7 @@ function readOnce(mod, opts, g) {
5157
5327
  ...(g.leasts.length ? { leasts: g.leasts } : {}),
5158
5328
  ...(g.used.size ? { seqs: g.seqs.filter(d => g.used.has(d.name)), folds: g.folds } : {}),
5159
5329
  };
5160
- 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)])) } : {}) };
5161
5331
  }
5162
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).
5163
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]);
@@ -5188,7 +5358,7 @@ export function padWrites(lists, base) {
5188
5358
  export function mapWritesOf(g, d, sels, ws, fix = (_, w) => w) {
5189
5359
  if (!ws.some(Boolean))
5190
5360
  return undefined;
5191
- 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 }])) }; };
5192
5362
  let acc;
5193
5363
  for (let i = sels.length - 1; i >= 0; i--) {
5194
5364
  const w = ws[i] ? fix(i, ws[i], base) : base(acc?.key ?? key0), c = sels[i];
@@ -5223,19 +5393,72 @@ export function iteTerm(c, a, b) {
5223
5393
  const proc = globalThis.process;
5224
5394
  export const node = (id) => { const m = proc?.getBuiltinModule?.(id); if (!m)
5225
5395
  throw new Error(`the extractor runs the code's toolchain through ${id} (Node 20.16 or later, or Bun)`); return m; };
5396
+ // A file gdp-wired runs beside its modules (a front end's reader or harness, core/<lang>/...): its path, or a clear
5397
+ // error when the install lacks it.
5398
+ export function asset(rel) {
5399
+ const p = node('node:url').fileURLToPath(new URL(`./${rel}`, import.meta.url));
5400
+ if (!node('node:fs').existsSync(p))
5401
+ throw new Error(`gdp-wired's ${rel} is missing from its install (${p}): reinstall gdp-wired`);
5402
+ return p;
5403
+ }
5404
+ // A harness started on the two named pipes in `work` and both opened. It runs under sh, which, if the harness exits
5405
+ // before it answered (it couldn't start: a file missing, an interpreter absent, the code not loading), opens the
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';
5441
+ export function openHarness(work, cmd, args, o) {
5442
+ const fs = node('node:fs'), cp = node('node:child_process');
5443
+ cp.execFileSync('mkfifo', [`${work}/in`, `${work}/out`], {});
5444
+ const child = cp.spawn('sh', ['-c', GUARD, 'gdp-harness', `${work}/in`, `${work}/out`, String(harnessLimit()), cmd, ...args], o);
5445
+ const wi = fs.openSync(`${work}/in`, 'w'), ro = fs.openSync(`${work}/out`, 'r');
5446
+ return { child, wi, ro };
5447
+ }
5226
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) {
5227
5452
  const o = opts.check ?? {}, m = read.model, bound = o.bound ?? 12;
5228
- const fs = node('node:fs'), cp = node('node:child_process'), os = node('node:os');
5453
+ const fs = node('node:fs'), os = node('node:os');
5229
5454
  const work = fs.mkdtempSync(`${os.tmpdir()}/gdp-stepcheck-`);
5230
5455
  let child, wi = -1, ro = -1;
5231
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 };
5232
5457
  try {
5458
+ // (no harness: no request ran, so never a difference: the check's own failure, or the code refused with why)
5233
5459
  if (h.error)
5234
- return { ...empty, mismatch: h.error };
5235
- cp.execFileSync('mkfifo', [`${work}/in`, `${work}/out`], {});
5236
- child = cp.spawn(h.cmd, [...h.args, `${work}/in`, `${work}/out`], { stdio: ['ignore', 'ignore', 'inherit'], env: { ...proc?.env, ...h.env } });
5237
- wi = fs.openSync(`${work}/in`, 'w');
5238
- ro = fs.openSync(`${work}/out`, 'r');
5460
+ return h.kind === 'harness' ? { ...empty, harness: h.error } : { ...empty, source: h.error };
5461
+ ({ child, wi, ro } = openHarness(work, h.cmd, h.args, { stdio: ['ignore', 'ignore', 'inherit'], env: { ...proc?.env, ...h.env } }));
5239
5462
  const buf = new Uint8Array(1 << 20), dec = new TextDecoder();
5240
5463
  let pend = '';
5241
5464
  const line = () => {
@@ -5256,10 +5479,10 @@ export function checkStep(h, read, r, sorts, opts) {
5256
5479
  fs.writeSync(wi, `${JSON.stringify(cmd)}\n`);
5257
5480
  const l = line();
5258
5481
  if (l === undefined)
5259
- throw new Error('the harness stopped');
5260
- return JSON.parse(l);
5482
+ throw new HarnessFailure('the harness stopped before it answered');
5483
+ return stopped(JSON.parse(l));
5261
5484
  };
5262
- 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 } : {}) });
5263
5486
  if (hi.error)
5264
5487
  return { ...empty, mismatch: `the code doesn't load with the check's harness: ${JSON.stringify(hi.error)}` };
5265
5488
  const num = (x, at) => { const n = Number(x); if (typeof x === 'string' && Number.isSafeInteger(n) && String(n) === x)
@@ -5300,10 +5523,15 @@ export function checkStep(h, read, r, sorts, opts) {
5300
5523
  throw new Error(JSON.stringify(res.error)); return toSnap(res.state); },
5301
5524
  call: (self, e, args) => {
5302
5525
  const res = ask({ op: 'call', id: self, m: e.call, a: args, now, answers: answersOf(e.call) });
5526
+ if (res.outside !== undefined)
5527
+ return { ok: false, outside: true, error: res.outside };
5303
5528
  if (res.frame)
5304
5529
  throw new Error(`the code changes ${res.frame}, a field the rule leaves out`);
5305
5530
  if (res.bad !== undefined)
5306
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)}`);
5307
5535
  const kind = read.results[e.call] ?? 'none', failed = res.err !== undefined;
5308
5536
  if (failed && !read.kept)
5309
5537
  return { ok: false, error: `raised: ${res.err}` };
@@ -5330,6 +5558,8 @@ export function checkStep(h, read, r, sorts, opts) {
5330
5558
  }
5331
5559
  if (f === 'none')
5332
5560
  o.none = !failed && (out === null || out === undefined) && kind === 'maybe';
5561
+ if (f.startsWith('effect:'))
5562
+ o[f] = !!res.effects?.[f.slice(7)];
5333
5563
  }
5334
5564
  return { ok: true, value: o };
5335
5565
  },
@@ -5384,6 +5614,8 @@ export function checkStep(h, read, r, sorts, opts) {
5384
5614
  return { ...ev, runMs: Math.round(performance.now() - r0) };
5385
5615
  }
5386
5616
  catch (x) {
5617
+ if (x instanceof HarnessFailure)
5618
+ throw x;
5387
5619
  return { ...empty, mismatch: `the check's harness: ${x.message}` };
5388
5620
  }
5389
5621
  finally {
@@ -5414,6 +5646,42 @@ const g0 = (m, name) => { const v = m.state.find(x => x.name === name); return v
5414
5646
  // A front end's whole run: the module read, the model printed and built, the code run beside it.
5415
5647
  export function extractStep(mod, h, opts) {
5416
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
+ }
5417
5685
  let read;
5418
5686
  try {
5419
5687
  read = readStep(mod, opts);
@@ -5478,6 +5746,8 @@ export function stepNames(read) {
5478
5746
  out.push({ code: 'result', rule: `${method}_result`, role: 'result', method, ...(k === 'maybe' ? { none: `${method}_result_none` } : {}) });
5479
5747
  if (vars.has('failed'))
5480
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' });
5481
5751
  if (vars.has('now'))
5482
5752
  out.push({ code: 'now', rule: 'now', role: 'clock' });
5483
5753
  if (m.event)