@reticlehq/engine 3.1.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 (123) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +36 -0
  3. package/dist/disagreement/body-failures.d.ts +4 -0
  4. package/dist/disagreement/body-failures.js +113 -0
  5. package/dist/disagreement/contradiction-evidence.d.ts +122 -0
  6. package/dist/disagreement/contradiction-evidence.js +194 -0
  7. package/dist/disagreement/contradiction-folds.d.ts +61 -0
  8. package/dist/disagreement/contradiction-folds.js +71 -0
  9. package/dist/disagreement/contradiction-types.d.ts +164 -0
  10. package/dist/disagreement/contradiction-types.js +1 -0
  11. package/dist/disagreement/contradictions.d.ts +5 -0
  12. package/dist/disagreement/contradictions.js +613 -0
  13. package/dist/disagreement/echo-mismatch.d.ts +10 -0
  14. package/dist/disagreement/echo-mismatch.js +299 -0
  15. package/dist/disagreement/reconcile.d.ts +39 -0
  16. package/dist/disagreement/reconcile.js +211 -0
  17. package/dist/disagreement/stale-response.d.ts +3 -0
  18. package/dist/disagreement/stale-response.js +186 -0
  19. package/dist/disagreement/unit-mismatch.d.ts +16 -0
  20. package/dist/disagreement/unit-mismatch.js +167 -0
  21. package/dist/disagreement/witness-disagreement.d.ts +42 -0
  22. package/dist/disagreement/witness-disagreement.js +43 -0
  23. package/dist/evidence/accepted-write.d.ts +35 -0
  24. package/dist/evidence/accepted-write.js +54 -0
  25. package/dist/evidence/already-true.d.ts +16 -0
  26. package/dist/evidence/already-true.js +89 -0
  27. package/dist/evidence/blind-spots.d.ts +133 -0
  28. package/dist/evidence/blind-spots.js +253 -0
  29. package/dist/evidence/body-capture-remedy.d.ts +42 -0
  30. package/dist/evidence/body-capture-remedy.js +96 -0
  31. package/dist/evidence/gap-ledger.d.ts +52 -0
  32. package/dist/evidence/gap-ledger.js +63 -0
  33. package/dist/evidence/honesty.d.ts +113 -0
  34. package/dist/evidence/honesty.js +105 -0
  35. package/dist/evidence/instrumentation-gaps.d.ts +91 -0
  36. package/dist/evidence/instrumentation-gaps.js +102 -0
  37. package/dist/evidence/learned-guards.d.ts +75 -0
  38. package/dist/evidence/learned-guards.js +78 -0
  39. package/dist/evidence/observability.d.ts +38 -0
  40. package/dist/evidence/observability.js +40 -0
  41. package/dist/evidence/page-teardown.d.ts +15 -0
  42. package/dist/evidence/page-teardown.js +17 -0
  43. package/dist/evidence/step-effect.d.ts +41 -0
  44. package/dist/evidence/step-effect.js +27 -0
  45. package/dist/evidence/uncaptured-bodies.d.ts +23 -0
  46. package/dist/evidence/uncaptured-bodies.js +41 -0
  47. package/dist/evidence/undeclared-change.d.ts +51 -0
  48. package/dist/evidence/undeclared-change.js +56 -0
  49. package/dist/evidence/unread-outcome.d.ts +10 -0
  50. package/dist/evidence/unread-outcome.js +77 -0
  51. package/dist/evidence/unsettled.d.ts +58 -0
  52. package/dist/evidence/unsettled.js +127 -0
  53. package/dist/evidence/verdict-intent-gap.d.ts +30 -0
  54. package/dist/evidence/verdict-intent-gap.js +35 -0
  55. package/dist/evidence/verified.d.ts +158 -0
  56. package/dist/evidence/verified.js +378 -0
  57. package/dist/index.d.ts +30 -0
  58. package/dist/index.js +25 -0
  59. package/dist/question/declared.d.ts +74 -0
  60. package/dist/question/declared.js +171 -0
  61. package/dist/question/lineage.d.ts +52 -0
  62. package/dist/question/lineage.js +122 -0
  63. package/dist/question/predicate/net-evidence.d.ts +21 -0
  64. package/dist/question/predicate/net-evidence.js +81 -0
  65. package/dist/question/predicate/observed-in-window.d.ts +24 -0
  66. package/dist/question/predicate/observed-in-window.js +38 -0
  67. package/dist/question/predicate/predicate-asks.d.ts +28 -0
  68. package/dist/question/predicate/predicate-asks.js +46 -0
  69. package/dist/question/predicate/predicate-console.d.ts +13 -0
  70. package/dist/question/predicate/predicate-console.js +138 -0
  71. package/dist/question/predicate/predicate-element.d.ts +13 -0
  72. package/dist/question/predicate/predicate-element.js +214 -0
  73. package/dist/question/predicate/predicate-eval-kit.d.ts +90 -0
  74. package/dist/question/predicate/predicate-eval-kit.js +126 -0
  75. package/dist/question/predicate/predicate-eval.d.ts +24 -0
  76. package/dist/question/predicate/predicate-eval.js +710 -0
  77. package/dist/question/predicate/predicate-parse.d.ts +15 -0
  78. package/dist/question/predicate/predicate-parse.js +173 -0
  79. package/dist/question/predicate/predicate-precheck.d.ts +8 -0
  80. package/dist/question/predicate/predicate-precheck.js +41 -0
  81. package/dist/question/predicate/predicate-request-body.d.ts +50 -0
  82. package/dist/question/predicate/predicate-request-body.js +120 -0
  83. package/dist/question/predicate/predicate-route.d.ts +66 -0
  84. package/dist/question/predicate/predicate-route.js +293 -0
  85. package/dist/question/predicate/predicate-schema.d.ts +170 -0
  86. package/dist/question/predicate/predicate-schema.js +509 -0
  87. package/dist/question/predicate/predicate-session.d.ts +72 -0
  88. package/dist/question/predicate/predicate-session.js +1 -0
  89. package/dist/question/predicate/predicate-to-links.d.ts +13 -0
  90. package/dist/question/predicate/predicate-to-links.js +38 -0
  91. package/dist/question/predicate/predicate.d.ts +26 -0
  92. package/dist/question/predicate/predicate.js +785 -0
  93. package/dist/question/predicate/property.d.ts +102 -0
  94. package/dist/question/predicate/property.js +135 -0
  95. package/dist/question/predicate/split-text-miss.d.ts +32 -0
  96. package/dist/question/predicate/split-text-miss.js +51 -0
  97. package/dist/question/predicate/testid-near-miss.d.ts +22 -0
  98. package/dist/question/predicate/testid-near-miss.js +33 -0
  99. package/dist/question/reaction.d.ts +17 -0
  100. package/dist/question/reaction.js +67 -0
  101. package/dist/window/adversary.d.ts +28 -0
  102. package/dist/window/adversary.js +90 -0
  103. package/dist/window/ambient.d.ts +63 -0
  104. package/dist/window/ambient.js +76 -0
  105. package/dist/window/appearance-budget.d.ts +41 -0
  106. package/dist/window/appearance-budget.js +47 -0
  107. package/dist/window/asset-noise.d.ts +42 -0
  108. package/dist/window/asset-noise.js +35 -0
  109. package/dist/window/body-relevance.d.ts +54 -0
  110. package/dist/window/body-relevance.js +78 -0
  111. package/dist/window/byte-size.d.ts +1 -0
  112. package/dist/window/byte-size.js +16 -0
  113. package/dist/window/engine-host.d.ts +35 -0
  114. package/dist/window/engine-host.js +20 -0
  115. package/dist/window/event-filters.d.ts +121 -0
  116. package/dist/window/event-filters.js +215 -0
  117. package/dist/window/json-salvage.d.ts +33 -0
  118. package/dist/window/json-salvage.js +96 -0
  119. package/dist/window/network-detail-merge.d.ts +8 -0
  120. package/dist/window/network-detail-merge.js +89 -0
  121. package/dist/window/ring-buffer.d.ts +41 -0
  122. package/dist/window/ring-buffer.js +152 -0
  123. package/package.json +71 -0
@@ -0,0 +1,785 @@
1
+ import { ElementState, PredicateKind, ReticleCommand, THROTTLED_STARVED_NOTE, capDepth, isSameDocument, selectPath, } from '@reticlehq/core';
2
+ import { satisfiesProperty } from './property.js';
3
+ import { predicateToExpectedLinks } from './predicate-to-links.js';
4
+ import { isAmbient, ambientKeyOf } from '../../window/ambient.js';
5
+ import { evalRoute } from './predicate-route.js';
6
+ import { describeSuperseded } from './observed-in-window.js';
7
+ import { evalElement } from './predicate-element.js';
8
+ import { PredicateSchema, matchValue, evalNet, evalConsole, evalAnimation, evalSignal, evalSettled, } from './predicate-eval.js';
9
+ export { PredicateSchema, PredicateKind };
10
+ /**
11
+ * A composite result that carries a child's "nobody could evaluate this" up to the verdict rule.
12
+ *
13
+ * `decideVerified` already treats `inconclusive` correctly and does it ahead of the failure clause,
14
+ * so all a composite has to do is stop dropping the field on its way out. `pass` stays false because
15
+ * nothing was proven; what changes is that the verdict reads UNKNOWN rather than blaming the app for
16
+ * a clause the CALL under-specified.
17
+ */
18
+ function unreadableComposite(child, evidence) {
19
+ const reason = child.inconclusive ?? 'a sub-predicate could not be evaluated';
20
+ return { pass: false, failureReason: reason, inconclusive: reason, evidence };
21
+ }
22
+ function oneOf(names) {
23
+ return 1 === names.length ? names[0] : undefined;
24
+ }
25
+ /**
26
+ * `readState`'s truncation report, when the caps actually fired.
27
+ *
28
+ * Its PRESENCE is the warning — the field is omitted entirely on an intact read, which is what lets
29
+ * "the list is short" stay distinguishable from "I shortened the list".
30
+ */
31
+ function truncationOf(result) {
32
+ if ('object' !== typeof result || null === result)
33
+ return undefined;
34
+ const report = result.truncation;
35
+ return 'object' === typeof report && null !== report
36
+ ? report
37
+ : undefined;
38
+ }
39
+ /** A scoped `readState` reply, narrowed to the shape `selectPath` would have produced. */
40
+ function asSelection(result) {
41
+ if ('object' !== typeof result || null === result)
42
+ return undefined;
43
+ const record = result;
44
+ return 'boolean' === typeof record.found
45
+ ? { found: record.found, value: record.value }
46
+ : undefined;
47
+ }
48
+ /**
49
+ * A NAMED store needs no whole-store read. `reticle_state`'s scoped mode selects the path out of the
50
+ * RAW store IN-PAGE and returns only it, so the assertion resolves in one round trip against a payload
51
+ * the size of the value — not the store. The unnamed case below still needs the wide read, because
52
+ * that is how it discovers WHICH store carries the path; only the named branch changes.
53
+ *
54
+ * A scoped read answers `found: false` for both "no such store" and "no such path", so the two are
55
+ * kept distinct here using the `storeNames` list the reply always carries — otherwise the payload gets
56
+ * cheaper while the message gets worse.
57
+ */
58
+ async function evalStateNamed(session, p, storeName) {
59
+ const scoped = await session.command(ReticleCommand.STATE_READ, {
60
+ store: storeName,
61
+ path: p.path,
62
+ });
63
+ if (!scoped.ok) {
64
+ return {
65
+ pass: false,
66
+ failureReason: 'state read failed',
67
+ observed: 'the store could not be read',
68
+ expected: 'a readable registered store',
69
+ assertion: 'state.unreadable',
70
+ };
71
+ }
72
+ const reply = (scoped.result ?? {});
73
+ const names = Array.isArray(reply.storeNames) ? reply.storeNames : [];
74
+ // Resolve the value. A CURRENT SDK honours the scoped read and answers `{ found, value }` selected
75
+ // in-page — the whole point of this path. An OLDER SDK (version skew) or any transport that ignores
76
+ // `path` answers the whole-store shape `{ stores }`; walk the path server-side there so the verdict
77
+ // stays correct across SDK versions. The scoped win is simply unavailable on the old ones.
78
+ const scopedSel = asSelection(scoped.result);
79
+ const wholeStores = reply.stores;
80
+ const scopedKeys = Array.isArray(reply.availableKeys)
81
+ ? reply.availableKeys
82
+ : undefined;
83
+ let selection;
84
+ if (scopedSel !== undefined) {
85
+ selection =
86
+ scopedKeys === undefined
87
+ ? { found: scopedSel.found, value: scopedSel.value }
88
+ : { found: scopedSel.found, value: scopedSel.value, availableKeys: scopedKeys };
89
+ }
90
+ else if (wholeStores !== undefined) {
91
+ selection = selectPath(wholeStores[storeName], p.path);
92
+ }
93
+ else {
94
+ selection = { found: false };
95
+ }
96
+ // "no store named X" and "X has no such path" both surface as found:false; keep them distinct using
97
+ // the store list the reply carries, or the message regresses while the payload improves.
98
+ const storeAbsent = wholeStores !== undefined
99
+ ? !(storeName in wholeStores)
100
+ : names.length > 0 && !names.includes(storeName);
101
+ if (!selection.found && storeAbsent) {
102
+ return {
103
+ pass: false,
104
+ failureReason: `no store named '${storeName}' is registered (${names.join(', ')})`,
105
+ observed: `store '${storeName}' is not registered`,
106
+ expected: `a registered store named '${storeName}'`,
107
+ assertion: 'state.store-missing',
108
+ evidence: { searchedStores: names },
109
+ };
110
+ }
111
+ // A scoped sub-tree can itself be too big for the caps; a comparison against a value known to be
112
+ // incomplete is an unanswered question, not a failure. Same rule the whole-store path applies.
113
+ if (truncationOf(scoped.result) !== undefined) {
114
+ const reason = `state '${p.path}' could not be read intact — the transport caps truncated it, so the ` +
115
+ 'value was never compared. Assert a narrower path, or a smaller field inside it';
116
+ return { pass: false, failureReason: reason, inconclusive: reason };
117
+ }
118
+ if (!selection.found) {
119
+ return {
120
+ pass: false,
121
+ failureReason: `state path '${p.path}' not found in store '${storeName}'`,
122
+ observed: `no path '${p.path}' in store '${storeName}'`,
123
+ expected: `store '${storeName}' to expose '${p.path}'`,
124
+ assertion: 'state.path-missing',
125
+ evidence: { availableKeys: selection.availableKeys },
126
+ };
127
+ }
128
+ /*
129
+ * A PROPERTY assertion runs before equality and can stand alone.
130
+ *
131
+ * `satisfies` is what makes a generated value verifiable at all: its exact bytes differ every run
132
+ * and are right every time, so `equals` can only ever be wrong about it. Both may be supplied and
133
+ * then both must hold — `satisfies` narrows, it never excuses.
134
+ */
135
+ if (p.satisfies !== undefined) {
136
+ const r = satisfiesProperty(selection.value, p.satisfies);
137
+ if (!r.ok) {
138
+ return {
139
+ pass: false,
140
+ failureReason: `state '${p.path}' ${r.because}`,
141
+ observed: `${p.path} = ${JSON.stringify(capDepth(selection.value, 0))}`,
142
+ expected: `${p.path} to satisfy ${p.satisfies.property}`,
143
+ assertion: `state.${p.satisfies.property}`,
144
+ evidence: { store: storeName, path: p.path, value: capDepth(selection.value, 1) },
145
+ };
146
+ }
147
+ if (p.equals === undefined) {
148
+ return {
149
+ pass: true,
150
+ evidence: {
151
+ store: storeName,
152
+ path: p.path,
153
+ value: capDepth(selection.value, 1),
154
+ satisfied: r.because,
155
+ },
156
+ };
157
+ }
158
+ }
159
+ const want = p.equals === undefined ? '*' : p.equals;
160
+ if (matchValue(selection.value, want)) {
161
+ return {
162
+ pass: true,
163
+ evidence: { store: storeName, path: p.path, value: capDepth(selection.value, 1) },
164
+ };
165
+ }
166
+ return {
167
+ pass: false,
168
+ failureReason: `state '${p.path}' is ${JSON.stringify(capDepth(selection.value, 0))}, expected ${JSON.stringify(want)}`,
169
+ observed: `${p.path} = ${JSON.stringify(capDepth(selection.value, 0))}`,
170
+ expected: `${p.path} = ${JSON.stringify(want)}`,
171
+ assertion: 'state.equals',
172
+ evidence: { store: storeName, path: p.path, value: capDepth(selection.value, 1) },
173
+ };
174
+ }
175
+ async function evalState(session, p) {
176
+ // Named store: one scoped read, no whole-store payload (issue #336).
177
+ if (p.store !== undefined)
178
+ return await evalStateNamed(session, p, p.store);
179
+ const res = await session.command(ReticleCommand.STATE_READ, {});
180
+ if (!res.ok) {
181
+ return {
182
+ pass: false,
183
+ failureReason: 'state read failed',
184
+ observed: 'the store could not be read',
185
+ expected: 'a readable registered store',
186
+ assertion: 'state.unreadable',
187
+ };
188
+ }
189
+ const stores = (res.result ?? {}).stores ?? {};
190
+ const names = Object.keys(stores);
191
+ // Ambiguity is about the PATH, not the store count.
192
+ //
193
+ // Registering more than one store is normal — an app store, a query cache, and the render meter
194
+ // Reticle registers itself — and asking "which of these three?" when only one of them HAS the
195
+ // path is a question with one possible answer. It was costing a real verdict: a bench-app drive
196
+ // asserting `{path:'view'}` returned `unknown` while the same response body carried the matching
197
+ // `view` state diff. `unknown` is not a pass, so that is a verification that did not happen.
198
+ //
199
+ // So narrow to the stores that actually carry the path, and refuse only when THOSE collide.
200
+ const candidates = p.store === undefined ? names.filter((n) => selectPath(stores[n], p.path).found) : [];
201
+ const storeName = p.store ?? (1 === names.length ? names[0] : oneOf(candidates));
202
+ if (storeName === undefined) {
203
+ // With no store registered there is nothing to read, and with two stores that both carry the
204
+ // path there is no way to pick — neither is a finding about the app, no assertion was evaluated,
205
+ // so both are inconclusive rather than failed: an unevaluated predicate is never a failure.
206
+ //
207
+ // Zero candidates is the one case that is NOT a question: every registered store was searched
208
+ // and none exposes the path, so the assertion cannot hold anywhere. That is the same verdict a
209
+ // named store has always produced for a missing path, and it falls through to it below.
210
+ if (0 === names.length) {
211
+ const reason = 'no registered store to read state from';
212
+ return { pass: false, failureReason: reason, inconclusive: reason };
213
+ }
214
+ if (candidates.length > 1) {
215
+ // Names the stores that actually collide. Listing all of them made the reader weigh
216
+ // candidates that could never have matched.
217
+ const reason = `multiple stores (${candidates.join(', ')}) expose '${p.path}'; name one with \`store\``;
218
+ return { pass: false, failureReason: reason, inconclusive: reason };
219
+ }
220
+ return {
221
+ pass: false,
222
+ failureReason: `state path '${p.path}' not found in any registered store (${names.join(', ')})`,
223
+ observed: `no path '${p.path}' in ${names.join(', ')}`,
224
+ expected: `some registered store to expose '${p.path}'`,
225
+ assertion: 'state.path-missing',
226
+ evidence: { searchedStores: names },
227
+ };
228
+ }
229
+ let selection = selectPath(stores[storeName], p.path);
230
+ // The whole-store read walks into a value the transport caps may already have mangled.
231
+ //
232
+ // `readState` has a SCOPED mode that selects the path out of the RAW store before sanitising, added
233
+ // precisely so a large or deep path still resolves. This path was not using it, so a store with one
234
+ // big collection in it truncated the small value sitting beside it, and the comparison then ran
235
+ // against the literal string "[TRUNCATED]" and returned a confident `no`. Measured on the Atlas
236
+ // fixture: a one-element array reported as a failed assertion while the same payload's state diffs
237
+ // showed the assertion holding.
238
+ //
239
+ // Re-read only when a cap actually fired, so an intact read costs exactly what it did before.
240
+ if (truncationOf(res.result) !== undefined) {
241
+ const scoped = await session.command(ReticleCommand.STATE_READ, {
242
+ store: storeName,
243
+ path: p.path,
244
+ });
245
+ const result = scoped.ok ? scoped.result : undefined;
246
+ const scopedTruncation = truncationOf(result);
247
+ if (scopedTruncation !== undefined) {
248
+ // Even the raw sub-tree was too big. Nothing here knows what the value IS, so nothing here can
249
+ // say the assertion failed — that would be an accusation the evidence does not support.
250
+ const reason = `state '${p.path}' could not be read intact — the transport caps truncated it, so the ` +
251
+ 'value was never compared. Assert a narrower path, or a smaller field inside it';
252
+ return { pass: false, failureReason: reason, inconclusive: reason };
253
+ }
254
+ if (result !== undefined) {
255
+ const scopedSelection = asSelection(result);
256
+ if (scopedSelection !== undefined)
257
+ selection = scopedSelection;
258
+ }
259
+ }
260
+ if (!selection.found) {
261
+ return {
262
+ pass: false,
263
+ failureReason: `state path '${p.path}' not found in store '${storeName}'`,
264
+ observed: `no path '${p.path}' in store '${storeName}'`,
265
+ expected: `store '${storeName}' to expose '${p.path}'`,
266
+ assertion: 'state.path-missing',
267
+ evidence: { availableKeys: selection.availableKeys },
268
+ };
269
+ }
270
+ /*
271
+ * A PROPERTY assertion runs before equality and can stand alone.
272
+ *
273
+ * `satisfies` is what makes a generated value verifiable at all: its exact bytes differ every run
274
+ * and are right every time, so `equals` can only ever be wrong about it. Both may be supplied and
275
+ * then both must hold — `satisfies` narrows, it never excuses.
276
+ */
277
+ if (p.satisfies !== undefined) {
278
+ const r = satisfiesProperty(selection.value, p.satisfies);
279
+ if (!r.ok) {
280
+ return {
281
+ pass: false,
282
+ failureReason: `state '${p.path}' ${r.because}`,
283
+ observed: `${p.path} = ${JSON.stringify(capDepth(selection.value, 0))}`,
284
+ expected: `${p.path} to satisfy ${p.satisfies.property}`,
285
+ assertion: `state.${p.satisfies.property}`,
286
+ evidence: { store: storeName, path: p.path, value: capDepth(selection.value, 1) },
287
+ };
288
+ }
289
+ if (p.equals === undefined) {
290
+ return {
291
+ pass: true,
292
+ evidence: {
293
+ store: storeName,
294
+ path: p.path,
295
+ value: capDepth(selection.value, 1),
296
+ satisfied: r.because,
297
+ },
298
+ };
299
+ }
300
+ }
301
+ const want = p.equals === undefined ? '*' : p.equals;
302
+ if (matchValue(selection.value, want)) {
303
+ return {
304
+ pass: true,
305
+ evidence: { store: storeName, path: p.path, value: capDepth(selection.value, 1) },
306
+ };
307
+ }
308
+ return {
309
+ pass: false,
310
+ failureReason: `state '${p.path}' is ${JSON.stringify(capDepth(selection.value, 0))}, expected ${JSON.stringify(want)}`,
311
+ observed: `${p.path} = ${JSON.stringify(capDepth(selection.value, 0))}`,
312
+ expected: `${p.path} = ${JSON.stringify(want)}`,
313
+ assertion: 'state.equals',
314
+ evidence: { store: storeName, path: p.path, value: capDepth(selection.value, 1) },
315
+ };
316
+ }
317
+ /**
318
+ * Oracles whose ONLY source of truth is the event window.
319
+ *
320
+ * Element, text and state read the page as it is right now, so supersession cannot reach them. Route
321
+ * is the deliberate omission: it has a second source — where the app is at this moment — and a
322
+ * reload is precisely the case it was given that fallback for, so emptying its window must not take
323
+ * the answer away.
324
+ */
325
+ const WINDOW_ONLY_KINDS = new Set([
326
+ PredicateKind.NET,
327
+ PredicateKind.CONSOLE,
328
+ PredicateKind.ANIMATION,
329
+ PredicateKind.SIGNAL,
330
+ PredicateKind.SETTLED,
331
+ ]);
332
+ /** Names the oracle that answered, in the same shape every other `assertion` here uses. */
333
+ const SUPERSEDED_ASSERTION = 'window.evidence-superseded';
334
+ /** The predicate's own event-time floor, if its kind carries one. */
335
+ function predicateSince(predicate) {
336
+ return 'since' in predicate && 'number' === typeof predicate.since ? predicate.since : 0;
337
+ }
338
+ /**
339
+ * A miss on a throttled tab is not a missing render. The browser has starved the tab, so a timeout
340
+ * there may mean it never ran — which must not look like "the text is absent".
341
+ *
342
+ * Sets `inconclusive` only. The PROSE is already handled one layer up by
343
+ * `annotateStarvedFailure` (session-health.ts), which suffixes the same fact onto the
344
+ * failureReason so the concrete diagnosis still leads; writing it here as well would put the
345
+ * sentence in every throttled failure twice. What was missing was never the sentence — it was the
346
+ * FIELD an agent gates on, so a starved wait graded `assertion-failed` and sent somebody to fix
347
+ * working code.
348
+ *
349
+ * Idempotent, and a more specific `inconclusive` (unreadable locator, superseded window) is never
350
+ * overwritten.
351
+ */
352
+ function annotateThrottledMiss(session, predicate, result) {
353
+ if (result.pass)
354
+ return result;
355
+ if (result.inconclusive !== undefined)
356
+ return result;
357
+ const preconditionFailure = session.preconditionFailure?.();
358
+ if (preconditionFailure !== undefined) {
359
+ return { ...result, inconclusive: preconditionFailure };
360
+ }
361
+ if (true !== session.throttled?.())
362
+ return result;
363
+ if (failureRestsOnSeeing(predicate))
364
+ return result;
365
+ return { ...result, inconclusive: THROTTLED_STARVED_NOTE };
366
+ }
367
+ /**
368
+ * Does this predicate FAIL by having seen something, rather than by not having seen it?
369
+ *
370
+ * The starved-tab caveat only applies to a negative reading. Throttling can stop the tab rendering,
371
+ * so "I did not find it" may mean "I could not look" — but nothing about a starved tab conjures
372
+ * elements that were not there, so "I found 13 of them" is as true on a throttled tab as anywhere.
373
+ * An `absent: true` predicate inverts exactly that: its failure IS the positive observation.
374
+ *
375
+ * Getting this wrong understated real product failures. An absence assertion that matched a
376
+ * framework debug page's `ProgrammingError` heading came back `unknown`, and `unknown` is what an
377
+ * agent re-drives or walks away from — so the proof it was holding never reached anybody.
378
+ *
379
+ * `not` flips the polarity again, and nests, so this recurses rather than checking one level.
380
+ * Composites (`allOf` / `anyOf`) deliberately fall through to `false`: a composite fails for a
381
+ * reason this cannot name, and keeping the caveat is the conservative half of the trade — an
382
+ * over-cautious `unknown` costs a re-drive, a missing one costs a wrong verdict.
383
+ */
384
+ function failureRestsOnSeeing(predicate) {
385
+ if (PredicateKind.NOT === predicate.kind)
386
+ return !failureRestsOnSeeing(predicate.predicate);
387
+ if ('absent' in predicate && true === predicate.absent)
388
+ return true;
389
+ // `count: 0` is absence written as arithmetic, and fails the same way: by matching something.
390
+ return 'count' in predicate && 0 === predicate.count;
391
+ }
392
+ export async function evaluatePredicate(session, predicate, since = 0, diagnose = true) {
393
+ return annotateThrottledMiss(session, predicate, await evaluatePredicateRaw(session, predicate, since, diagnose));
394
+ }
395
+ async function evaluatePredicateRaw(session, predicate, since = 0,
396
+ // Compute the (extra-round-trip) near-miss diagnostics on element failures. Default true so a
397
+ // one-shot assert is fully diagnostic; the wait loop passes false on its interim polls (which read
398
+ // only `pass`) and true on the final timeout eval, so a flood no longer pays for a diagnostic nobody
399
+ // reads. Only element/text failures have a near-miss; everything else ignores this.
400
+ diagnose = true) {
401
+ // A predicate's own `since` is a TIGHTER event-time floor than the caller's — an agent that took
402
+ // `since` from the act it just performed is scoping the assertion to that action's aftermath. It is
403
+ // applied here, once, rather than in each eval: the floor means the same thing for every kind that
404
+ // reads the event stream, and net/console re-applying it is a no-op.
405
+ const raw = session.eventsSince(Math.max(since, predicateSince(predicate)));
406
+ // Scoped ONCE, here, for the same reason the contradiction pass scopes at its own choke point:
407
+ // reasoning about a dead page's evidence is a defect in every oracle below rather than in whichever
408
+ // one happened to read it, and this is the single place they all take their window from.
409
+ const events = raw.filter((e) => isSameDocument(e.documentId, session.currentDocumentId));
410
+ const superseded = raw.length - events.length;
411
+ // An empty window was always allowed to mean "it did not happen"; that reading is only unsafe once
412
+ // supersession is what emptied it. Without this, dropping stale evidence would trade a wrong pass
413
+ // for a wrong FAILURE — and a failure names a component and sends an agent to fix working code.
414
+ // `inconclusive` is the established way to say "nothing was proven and nobody could have proven
415
+ // it", and `decideVerified` already reads it as UNKNOWN ahead of the failure clause.
416
+ if (superseded > 0 && 0 === events.length && WINDOW_ONLY_KINDS.has(predicate.kind)) {
417
+ const reason = describeSuperseded('observations', superseded);
418
+ return {
419
+ pass: false,
420
+ failureReason: reason,
421
+ inconclusive: reason,
422
+ observed: 'every observation in this window belongs to a document since replaced',
423
+ expected: `evidence recorded under the document now on screen for ${predicate.kind}`,
424
+ assertion: SUPERSEDED_ASSERTION,
425
+ };
426
+ }
427
+ switch (predicate.kind) {
428
+ case PredicateKind.ELEMENT:
429
+ return evalElement(session, predicate.query, predicate.state, predicate.absent ?? false, diagnose);
430
+ case PredicateKind.TEXT:
431
+ return evalElement(session,
432
+ // `scope` passes straight through: the text predicate has always been an element query
433
+ // with only `text` filled in, so scoping it needs the field, not a second code path.
434
+ undefined === predicate.scope
435
+ ? { text: predicate.contains }
436
+ : {
437
+ text: predicate.contains,
438
+ scope: predicate.scope,
439
+ ...(true === predicate.self ? { self: true } : {}),
440
+ }, true === predicate.visible ? ElementState.VISIBLE : undefined, predicate.absent ?? false, diagnose);
441
+ case PredicateKind.NET:
442
+ return evalNet(events, predicate);
443
+ case PredicateKind.ROUTE:
444
+ // `since` so an unanswered request already in flight before this window is not counted
445
+ // against the app — see unansweredIn.
446
+ return evalRoute(events, predicate, session.url, Math.max(since, predicateSince(predicate)));
447
+ case PredicateKind.CONSOLE:
448
+ return evalConsole(events, predicate);
449
+ case PredicateKind.ANIMATION:
450
+ return evalAnimation(events, predicate);
451
+ case PredicateKind.SIGNAL:
452
+ return evalSignal(events, predicate);
453
+ case PredicateKind.STATE:
454
+ return evalState(session, predicate);
455
+ case PredicateKind.SETTLED: {
456
+ // Drop events on learned-ambient regions (chat/ticker churn) before the settle check — by ref
457
+ // alone, NOT by attribution: window-attribution ("happened during the action window") is a time
458
+ // heuristic, never causation, so a chat message arriving mid-window must not hold settle open.
459
+ const counts = session.ambientCounts?.();
460
+ const settleEvents = counts === undefined ? events : events.filter((e) => !isAmbient(counts, ambientKeyOf(e)));
461
+ return evalSettled(settleEvents, predicate, session.elapsed());
462
+ }
463
+ case PredicateKind.ALL_OF: {
464
+ const results = await Promise.all(predicate.predicates.map((p) => evaluatePredicate(session, p, since, diagnose)));
465
+ // A clause that genuinely failed OUTRANKS one nobody could read. Softening a real failure to
466
+ // UNKNOWN would hide the defect the agent came for, which is the more expensive of the two
467
+ // mistakes; the reverse — grading an unreadable clause as a defect in the app — is the one
468
+ // that was happening.
469
+ const failed = results.find((r) => !r.pass && r.inconclusive === undefined);
470
+ if (failed !== undefined) {
471
+ return {
472
+ pass: false,
473
+ failureReason: failed.failureReason ?? 'a sub-predicate of allOf failed',
474
+ // A conjunction is decided as soon as ONE clause is: nothing the others do later can
475
+ // rescue it. This is what makes the early exit reach real calls, since an exact count is
476
+ // usually asserted alongside the UI change it is meant to accompany.
477
+ ...(true === failed.decided ? { decided: true } : {}),
478
+ evidence: results,
479
+ };
480
+ }
481
+ const unreadable = results.find((r) => r.inconclusive !== undefined);
482
+ if (unreadable !== undefined)
483
+ return unreadableComposite(unreadable, results);
484
+ return { pass: true, evidence: results.map((r) => r.evidence) };
485
+ }
486
+ case PredicateKind.ANY_OF: {
487
+ const results = await Promise.all(predicate.predicates.map((p) => evaluatePredicate(session, p, since, diagnose)));
488
+ const passed = results.find((r) => r.pass);
489
+ if (passed !== undefined)
490
+ return { pass: true, evidence: passed.evidence };
491
+ // "No sub-predicate matched" is a claim anyOf is not entitled to make while one of them was
492
+ // never read: the unreadable clause might have been the one that would have matched.
493
+ const unreadable = results.find((r) => r.inconclusive !== undefined);
494
+ if (unreadable !== undefined)
495
+ return unreadableComposite(unreadable, results);
496
+ return { pass: false, failureReason: 'no sub-predicate of anyOf matched', evidence: results };
497
+ }
498
+ case PredicateKind.NOT: {
499
+ const inner = await evaluatePredicate(session, predicate.predicate, since, diagnose);
500
+ // The sharpest case of the three, and the only one that produced a GREEN. `not` read the
501
+ // child's `pass: false` as "the inner predicate did not hold" and passed — so an assertion
502
+ // nobody could evaluate became a verdict of verified, manufactured out of a missing reading.
503
+ // You cannot negate an answer nobody had.
504
+ if (inner.inconclusive !== undefined)
505
+ return unreadableComposite(inner, inner);
506
+ // A green negation used to return a bare `{ pass: true }`, so the payload fell back to
507
+ // whatever the caller had — every element matching the OUTER locator. Three clauses negating
508
+ // three different names then produced byte-identical responses, which reads as a checker that
509
+ // dropped the name rather than one that correctly found all three absent. The evidence is the
510
+ // whole answer here: what was looked for, and that it was not there.
511
+ return inner.pass
512
+ ? { pass: false, failureReason: 'negated predicate unexpectedly held', evidence: inner }
513
+ : { pass: true, evidence: { negated: predicate.predicate, held: false, saw: inner } };
514
+ }
515
+ default:
516
+ return { pass: false, failureReason: 'unknown predicate' };
517
+ }
518
+ }
519
+ /** Backstop poll cadence — guarantees a re-check even if no event fires (e.g. a `settled` wait). */
520
+ const POLL_INTERVAL_MS = 150;
521
+ /** Minimum gap between consecutive event-driven rechecks, so an event flood can't drive back-to-back
522
+ * DOM/STATE round-trips. Small enough that added pass-detection latency is negligible next to the
523
+ * poll cadence, large enough to collapse a per-frame event storm into a bounded recheck rate. */
524
+ const MIN_RECHECK_GAP_MS = 25;
525
+ /**
526
+ * How long an exact-count predicate keeps watching AFTER it first reads true.
527
+ *
528
+ * A count only rises while a window is open, so "exactly N" is a statement about the END of one and
529
+ * cannot be settled early — yet every wait here resolves the moment a check passes. Live, on a real
530
+ * payments dashboard: a Refund confirm fired TWO POSTs 59 ms apart, and
531
+ * `until: { kind:'net', method:'POST', urlContains:'/refund', count:1 }` returned
532
+ * `pass: true, matched: 1`. Not a counting bug — `evalNet` counts occurrences correctly. The wait had
533
+ * already stopped looking. So `count: 1` silently meant "at least 1", which is the assertion the
534
+ * caller wrote `count` specifically to avoid, and the branch implementing it claims to catch "the
535
+ * double-submit / useEffect-double-fire / retry-storm regression class".
536
+ *
537
+ * 300 ms is chosen against the measured defect: the observed double-submit gap was 59 ms, a React
538
+ * double-effect fires within one commit, and a retry storm is faster still. It is a real ceiling, not
539
+ * a proof — a duplicate arriving 400 ms later still passes. Widening it costs every exact-count
540
+ * assertion that latency, so this trades an unbounded false green for a bounded one and says so.
541
+ */
542
+ const COUNT_CONFIRM_MS = 300;
543
+ /**
544
+ * Does this predicate assert an exact cardinality anywhere inside it?
545
+ *
546
+ * Only these hold after passing. A presence-only predicate ("at least one") IS satisfiable early and
547
+ * must stay that way, or every ordinary wait pays the confirmation delay for nothing.
548
+ */
549
+ function assertsExactCount(predicate) {
550
+ if (PredicateKind.ALL_OF === predicate.kind || PredicateKind.ANY_OF === predicate.kind) {
551
+ return predicate.predicates.some(assertsExactCount);
552
+ }
553
+ if (PredicateKind.NOT === predicate.kind)
554
+ return assertsExactCount(predicate.predicate);
555
+ // `signal` carries `count` for the same reason `net` does, and for the same defect: its schema
556
+ // calls the double-fire "the defect no state-only oracle can see", because a handler wired twice
557
+ // leaves the store in the right shape and a presence check green on both. Reading `net` alone
558
+ // meant a signal count resolved on its first match, so `count: 1` silently meant "at least 1" on
559
+ // the one channel able to see the bug. `evalSignal` counts correctly; the wait stopped early.
560
+ return ((PredicateKind.NET === predicate.kind || PredicateKind.SIGNAL === predicate.kind) &&
561
+ predicate.count !== undefined);
562
+ }
563
+ /**
564
+ * Evaluate now, else wait for it to become true (on each event + a poll) until timeout. `since` is
565
+ * the event-time floor (see evaluatePredicate) so a waiter cannot resolve on a stale buffered event.
566
+ */
567
+ export function waitForPredicate(session, predicate, timeoutMs, since = 0) {
568
+ return new Promise((resolve) => {
569
+ let done = false;
570
+ const failed = (error) => ({
571
+ pass: false,
572
+ failureReason: error instanceof Error ? error.message : String(error),
573
+ });
574
+ let cooldownTimer;
575
+ /** One-shot re-check timed to when a time-based predicate could first pass. See retryAfterMs. */
576
+ let hintTimer;
577
+ // An exact-count wait keeps watching after it first reads true — see COUNT_CONFIRM_MS.
578
+ const holdsForCount = assertsExactCount(predicate);
579
+ let confirming = false;
580
+ let confirmTimer;
581
+ /** Report a wait that could not run, and END it — see guardedCheck. */
582
+ const failWait = (error) => {
583
+ session.note?.('reticle_wait_failed', {
584
+ predicate: predicate.kind,
585
+ error: error instanceof Error ? error.message : String(error),
586
+ });
587
+ finish({
588
+ ...failed(error),
589
+ failureReason: 'the wait could not be evaluated and was ended rather than left pending: ' +
590
+ (error instanceof Error ? error.message : String(error)),
591
+ });
592
+ };
593
+ const finish = (result) => {
594
+ if (done)
595
+ return;
596
+ done = true;
597
+ unsub();
598
+ unsubDisconnect?.();
599
+ clearInterval(interval);
600
+ clearTimeout(timer);
601
+ if (cooldownTimer !== undefined)
602
+ clearTimeout(cooldownTimer);
603
+ if (hintTimer !== undefined)
604
+ clearTimeout(hintTimer);
605
+ if (confirmTimer !== undefined)
606
+ clearTimeout(confirmTimer);
607
+ resolve(result);
608
+ };
609
+ // Coalesce re-checks: at most ONE evaluatePredicate is ever in flight (each can be a browser
610
+ // MATCH/STATE_READ round-trip). Events that arrive while one is running set a single trailing
611
+ // re-check instead of each firing their own command — otherwise a page emitting an event per
612
+ // animation frame fans out hundreds of concurrent round-trips and collapses under backpressure.
613
+ //
614
+ // Beyond coalescing, PACE the trailing rechecks: without a gap the next eval fired the instant the
615
+ // previous finished, so under an event flood one round-trip was permanently in flight (~184/sec at
616
+ // 5ms RTT) — each a live-DOM scan on the app's main thread, the "the dashboard is janky while the
617
+ // agent waits" case. The FIRST check on an idle loop still runs immediately (leading edge, so fast
618
+ // detection is unchanged); only back-to-back rechecks under sustained load wait MIN_RECHECK_GAP_MS.
619
+ let inFlight = false;
620
+ let cooling = false;
621
+ let pendingRecheck = false;
622
+ const check = () => {
623
+ if (done)
624
+ return;
625
+ if (inFlight || cooling) {
626
+ pendingRecheck = true;
627
+ return;
628
+ }
629
+ inFlight = true;
630
+ // Interim poll: read only `pass`, so skip the extra near-miss round-trips (diagnose=false). The
631
+ // final timeout eval below runs with full diagnostics.
632
+ void evaluatePredicate(session, predicate, since, false)
633
+ .then((r) => {
634
+ if (!r.pass) {
635
+ // Final already: stop rather than spend a budget that cannot change the answer. Only
636
+ // where the evaluator could PROVE it (see EvalResult.decided) — an ordinary miss keeps
637
+ // waiting, because "it has not happened yet" and "it will not happen" are the same
638
+ // reading until the budget ends.
639
+ if (true === r.decided) {
640
+ finish(r);
641
+ return;
642
+ }
643
+ // A time-based failure knows when it could stop being one — re-check THEN rather than on
644
+ // the next blind tick. Without this, every `settled` wait paid up to a full poll interval
645
+ // of dead time after the quiet window had already closed: measured at 566–627ms across
646
+ // the fleet for a 500ms window, on the call an agent makes after almost every action.
647
+ // Additive — the backstop interval below still runs, so a missed hint costs nothing.
648
+ const hint = r.retryAfterMs;
649
+ if ('number' === typeof hint && hint > 0 && hint < POLL_INTERVAL_MS) {
650
+ clearTimeout(hintTimer);
651
+ hintTimer = setTimeout(check, hint);
652
+ }
653
+ return;
654
+ }
655
+ // "Exactly N" cannot be concluded from a passing sample — the count can still rise. Hold,
656
+ // re-evaluate WITH diagnostics, and let that second read be the verdict: if an N+1th
657
+ // arrived in the meantime it now fails, carrying observed/expected rather than a bare no.
658
+ if (!holdsForCount) {
659
+ finish(r);
660
+ return;
661
+ }
662
+ if (confirming)
663
+ return;
664
+ confirming = true;
665
+ confirmTimer = setTimeout(() => {
666
+ void evaluatePredicate(session, predicate, since)
667
+ .then(finish)
668
+ .catch((error) => {
669
+ finish(failed(error));
670
+ });
671
+ }, COUNT_CONFIRM_MS);
672
+ })
673
+ .catch((error) => {
674
+ finish(failed(error));
675
+ })
676
+ .finally(() => {
677
+ inFlight = false;
678
+ if (done)
679
+ return;
680
+ // Enter a short cooldown; process a coalesced recheck when it ends. The 150ms poll is the
681
+ // backstop, so a missed trailing edge is caught within one interval regardless.
682
+ cooling = true;
683
+ cooldownTimer = setTimeout(() => {
684
+ cooling = false;
685
+ if (pendingRecheck && !done) {
686
+ pendingRecheck = false;
687
+ check();
688
+ }
689
+ }, MIN_RECHECK_GAP_MS);
690
+ });
691
+ };
692
+ /**
693
+ * Run a re-check so that NOTHING can leave this promise pending.
694
+ *
695
+ * `check` is fired from an event listener and an interval, neither of which is inside the
696
+ * awaited chain. A synchronous throw there reached the process as an uncaughtException; a
697
+ * rejection reached it as an unhandledRejection. Either way the wait never resolved and the tool
698
+ * handler never returned — the agent sees a call that simply never comes back.
699
+ *
700
+ * This half covers the SYNCHRONOUS throw only. The rejection half is handled inside `check`, by
701
+ * the `.catch` on its own promise chain — `check` returns void and voids the promise it starts,
702
+ * so there is nothing to hand back here to await. Said explicitly because the obvious-looking
703
+ * `if (result instanceof Promise) result.catch(…)` that used to sit here was dead code that read
704
+ * like the rejection guard, and removing `check`'s own `.catch` as redundant would have restored
705
+ * the exact hang this exists to prevent.
706
+ *
707
+ * That is the exact shape reported from a Plane (Next 14 + MobX) session, which tears the page
708
+ * session down and rebuilds it on EVERY navigation, so a `{kind:"route"}` predicate always races
709
+ * a teardown of the very session it is watching: `browser.command ok:true` for the click, and
710
+ * then no `tool.handler` for that callId, ever.
711
+ *
712
+ * A wait that cannot evaluate is a FAILED wait, not an eternal one. It now says so and finishes.
713
+ */
714
+ const guardedCheck = () => {
715
+ try {
716
+ check();
717
+ }
718
+ catch (error) {
719
+ failWait(error);
720
+ }
721
+ };
722
+ // Bound to the CALL that started this wait. The listener fires from the WebSocket message
723
+ // handler and the interval from the timer queue — neither is in the awaited chain, so without
724
+ // this every re-check opened a new call at depth 0 and emitted a `browser.command` with no
725
+ // `tool.handler`. Measured on one healthy run: 23 such orphans, which is precisely the
726
+ // documented signature of a HUNG call. A diagnostic that fires on healthy runs is not one.
727
+ const boundCheck = session.keepCallerContext?.(guardedCheck) ?? guardedCheck;
728
+ const unsub = session.onEvent(() => {
729
+ boundCheck();
730
+ });
731
+ const unsubDisconnect = session.onDisconnect?.(() => {
732
+ // `observationLost` is what stops this being graded as an app defect. `pass: false` is still
733
+ // correct — the consequence was not seen to hold — but on its own it reached the verdict rule
734
+ // as ASSERTION_FAILED, so a reload mid-wait reported "the declared consequence did not hold"
735
+ // against a healthy component, by file and line. The flag is structured rather than inferred
736
+ // from this string, because every other `failureReason` here is prose about the APP.
737
+ finish({ pass: false, failureReason: 'session disconnected', observationLost: true });
738
+ });
739
+ const interval = setInterval(boundCheck, POLL_INTERVAL_MS);
740
+ const timer = setTimeout(() => {
741
+ void evaluatePredicate(session, predicate, since)
742
+ .then((r) => {
743
+ // Spread the near-miss, do NOT hand-copy two fields. The oracle computes observed / expected
744
+ // / assertion — the structured cause the repair literature ranks above prose — and the old
745
+ // `{ pass, evidence, failureReason }` construction DISCARDED them on every timed-out wait and
746
+ // assert. So the highest-value localization signal was computed and then thrown away exactly
747
+ // on the failure path where it matters, no matter what the schema declared.
748
+ finish(annotateThrottledMiss(session, predicate, {
749
+ ...r,
750
+ pass: false,
751
+ failureReason: r.failureReason ?? 'timed out waiting for predicate',
752
+ }));
753
+ })
754
+ .catch((error) => {
755
+ finish(failed(error));
756
+ });
757
+ }, timeoutMs);
758
+ check();
759
+ });
760
+ }
761
+ /**
762
+ * The ExpectedLinks a GREEN verdict actually PROVED — not merely the ones it declared. Identical to
763
+ * predicateToExpectedLinks except for `anyOf`: an OR greens on a SINGLE branch, so only the branch that
764
+ * held may contribute its link. Grading a green anyOf off the declared links would let the honesty grade
765
+ * claim a signal/net consequence that was only one of the options and never fired — and a `minGrade:net`
766
+ * gate would then trust a verdict that proved nothing but presence. That is the exact false green the
767
+ * grade exists to prevent, sitting inside the grade itself.
768
+ *
769
+ * Call ONLY on a green verdict: a leaf and every `allOf` branch are returned unconditionally because a
770
+ * green top verdict guarantees they held (allOf needs all; a bare leaf IS the verdict). Only anyOf, where
771
+ * green ⇏ this-branch-held, re-checks each branch and keeps the winners.
772
+ */
773
+ export async function provenExpectedLinks(session, predicate, since = 0) {
774
+ if (PredicateKind.ALL_OF === predicate.kind) {
775
+ const per = await Promise.all(predicate.predicates.map((p) => provenExpectedLinks(session, p, since)));
776
+ return per.flat();
777
+ }
778
+ if (PredicateKind.ANY_OF === predicate.kind) {
779
+ const per = await Promise.all(predicate.predicates.map(async (p) => (await evaluatePredicate(session, p, since)).pass
780
+ ? provenExpectedLinks(session, p, since)
781
+ : []));
782
+ return per.flat();
783
+ }
784
+ return predicateToExpectedLinks(predicate);
785
+ }