@reticlehq/engine 3.6.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/disagreement/contradiction-evidence.d.ts +66 -1
- package/dist/disagreement/contradiction-evidence.js +141 -2
- package/dist/disagreement/contradiction-types.d.ts +8 -1
- package/dist/disagreement/contradictions.d.ts +12 -0
- package/dist/disagreement/contradictions.js +37 -70
- package/dist/disagreement/stale-response.js +7 -2
- package/dist/evidence/already-true.d.ts +5 -0
- package/dist/evidence/already-true.js +27 -6
- package/dist/evidence/baseline.js +2 -6
- package/dist/evidence/blind-spots.d.ts +14 -3
- package/dist/evidence/blind-spots.js +48 -10
- package/dist/evidence/instrumentation-gaps.js +3 -1
- package/dist/evidence/state-bookkeeping.d.ts +2 -0
- package/dist/evidence/state-bookkeeping.js +2 -0
- package/dist/evidence/superseded-checks.d.ts +29 -0
- package/dist/evidence/superseded-checks.js +30 -0
- package/dist/evidence/unsettled.js +4 -2
- package/dist/evidence/verified.d.ts +6 -1
- package/dist/evidence/verified.js +32 -4
- package/dist/question/declared.d.ts +20 -0
- package/dist/question/declared.js +20 -1
- package/dist/question/predicate/net-blind-spots.d.ts +49 -0
- package/dist/question/predicate/net-blind-spots.js +153 -0
- package/dist/question/predicate/predicate-element.d.ts +14 -0
- package/dist/question/predicate/predicate-element.js +76 -5
- package/dist/question/predicate/predicate-eval-kit.d.ts +25 -0
- package/dist/question/predicate/predicate-eval-kit.js +31 -0
- package/dist/question/predicate/predicate-eval.d.ts +1 -1
- package/dist/question/predicate/predicate-eval.js +47 -167
- package/dist/question/predicate/predicate-parse.js +34 -0
- package/dist/question/predicate/predicate-request-body.d.ts +6 -1
- package/dist/question/predicate/predicate-request-body.js +7 -2
- package/dist/question/predicate/predicate-route.d.ts +2 -0
- package/dist/question/predicate/predicate-route.js +30 -0
- package/dist/question/predicate/predicate-schema.d.ts +11 -0
- package/dist/question/predicate/predicate-schema.js +52 -1
- package/dist/question/predicate/predicate-state.js +7 -0
- package/dist/question/predicate/predicate.js +5 -11
- package/dist/question/predicate/split-text-miss.d.ts +6 -0
- package/dist/question/predicate/split-text-miss.js +10 -0
- package/dist/state-bookkeeping.d.ts +25 -0
- package/dist/state-bookkeeping.js +70 -0
- package/package.json +2 -2
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Split out of `contradictions.ts` when that file crossed the line cap — and the seam was already
|
|
5
5
|
* there rather than invented for the occasion. Everything here answers a question ABOUT NETWORK
|
|
6
6
|
* EVIDENCE: what did this event mean, was it a write, did a retry rescue it, is it the toolchain's
|
|
7
|
-
* own traffic rather than the app's, is this cadence a poll
|
|
7
|
+
* own traffic rather than the app's, is this cadence a poll, what did a write carry, which page did
|
|
8
|
+
* a list request ask for, and which `net` clause would name this call. Nothing here knows what a
|
|
8
9
|
* contradiction is.
|
|
9
10
|
*
|
|
10
11
|
* The rules next door read this vocabulary and decide what disagrees. Keeping the two apart means a
|
|
@@ -66,6 +67,14 @@ export declare function hrefAsUrl(value: string | undefined): URL | undefined;
|
|
|
66
67
|
* Returns false when `from`/`to` are missing, so older events without hrefs keep the existing rule.
|
|
67
68
|
*/
|
|
68
69
|
export declare function isSameDocumentHashAnchor(event: ReticleEvent): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* A `replaceState` that keeps the pathname recorded state in the URL. It is not a navigation.
|
|
72
|
+
*
|
|
73
|
+
* Search and an in-page fragment may change (`?zoom=125`, `#main-content`). A hash-router fragment
|
|
74
|
+
* (`#/invoices`) is still a new view, and so is a replace onto a different pathname. Missing hrefs
|
|
75
|
+
* stay under the blank-destination rule: an event that cannot show the path stayed put is not exempt.
|
|
76
|
+
*/
|
|
77
|
+
export declare function isSamePathnameReplace(event: ReticleEvent): boolean;
|
|
69
78
|
/**
|
|
70
79
|
* Split the window into the app's traffic and the dev toolchain's own (see `DevToolingChannel`).
|
|
71
80
|
*
|
|
@@ -127,3 +136,59 @@ export declare const POLL_JITTER_RATIO = 0.4;
|
|
|
127
136
|
* apart they are, which is the classic double submit and every case this rule was written for.
|
|
128
137
|
*/
|
|
129
138
|
export declare function isSteadyCadence(times: readonly number[]): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* What this request CARRIED, as far as the record knows — `undefined` when it does not know.
|
|
141
|
+
*
|
|
142
|
+
* The page's shape fingerprint first: it is present on every request from an instrumented page,
|
|
143
|
+
* including the overwhelming majority where body capture is off. A captured body is the fallback for
|
|
144
|
+
* a realm that records one without a fingerprint (desktop IPC). Neither means the record does not
|
|
145
|
+
* say what this request carried — a body the page could not read as text, or an SDK too old to
|
|
146
|
+
* compute a fingerprint — and that is an ABSENCE of identity, not an identity shared with every
|
|
147
|
+
* other silent request.
|
|
148
|
+
*
|
|
149
|
+
* A Server Action's action id joins both halves, and it is the half that survives a `FormData`
|
|
150
|
+
* body: several actions POST to the page's own URL, so without it every call is an unknown identity
|
|
151
|
+
* pooled with all the others, and no fingerprint can separate two that share a shape. The id alone
|
|
152
|
+
* SPLITS two different actions; it cannot say that two runs of one action carried the same thing,
|
|
153
|
+
* and `carried` keeps that limit on the record for the finding to say.
|
|
154
|
+
*/
|
|
155
|
+
export interface WriteIdentity {
|
|
156
|
+
/** The value the grouping compares. */
|
|
157
|
+
readonly key: string;
|
|
158
|
+
/** Whether the key also describes WHAT the request carried, not only which action ran. */
|
|
159
|
+
readonly carried: boolean;
|
|
160
|
+
}
|
|
161
|
+
export declare function identityOf(event: ReticleEvent): WriteIdentity | undefined;
|
|
162
|
+
/** Split calls to one endpoint into the sets that sent the same thing. Callers check first that
|
|
163
|
+
* every identity is known; an unknown one would otherwise pool with every other unknown. */
|
|
164
|
+
export declare function groupByIdentity<T extends {
|
|
165
|
+
identity: WriteIdentity | undefined;
|
|
166
|
+
}>(calls: readonly T[]): T[][];
|
|
167
|
+
/**
|
|
168
|
+
* The `net` clause that declares each of these failures, worded as a condition.
|
|
169
|
+
*
|
|
170
|
+
* A designed error path (a 402 paywall, a 429, a 428 confirmation) asserted through the UI it renders
|
|
171
|
+
* gets `ui-advanced-request-failed`, and declaring the failing call in the oracle is what exempts it
|
|
172
|
+
* (`matchesDeclaredFailure`). Nothing in the finding said so, so agents dropped the check or
|
|
173
|
+
* weakened it until it proved nothing (#1418). The clause is built from the call itself, so it is
|
|
174
|
+
* exactly what would match, and it is conditional: the finding is still a finding, and a clause
|
|
175
|
+
* pasted to make a red go away would be the same false green with extra steps.
|
|
176
|
+
*
|
|
177
|
+
* Built from the DISPLAY url, which is redacted, never from `matchUrl`, which is not: the detail is
|
|
178
|
+
* copied into crawl anomalies, and a hint must not put back a token the description took out. A
|
|
179
|
+
* call whose path cannot be named exactly and narrowly gets no clause rather than a loose one: a
|
|
180
|
+
* bare `/` is a substring of every url and would exempt unrelated failures with the same method.
|
|
181
|
+
*/
|
|
182
|
+
export declare function declareFailureHint(calls: readonly {
|
|
183
|
+
method: string;
|
|
184
|
+
url: string;
|
|
185
|
+
matchUrl?: string;
|
|
186
|
+
status: number | undefined;
|
|
187
|
+
}[]): string;
|
|
188
|
+
export declare function pageNumber(text: unknown): number | undefined;
|
|
189
|
+
/** The endpoint and its page parameter, for a GET that carries one. */
|
|
190
|
+
export declare function pageRequest(event: ReticleEvent): {
|
|
191
|
+
path: string;
|
|
192
|
+
param: string;
|
|
193
|
+
value: string;
|
|
194
|
+
} | undefined;
|
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
* Split out of `contradictions.ts` when that file crossed the line cap — and the seam was already
|
|
5
5
|
* there rather than invented for the occasion. Everything here answers a question ABOUT NETWORK
|
|
6
6
|
* EVIDENCE: what did this event mean, was it a write, did a retry rescue it, is it the toolchain's
|
|
7
|
-
* own traffic rather than the app's, is this cadence a poll
|
|
7
|
+
* own traffic rather than the app's, is this cadence a poll, what did a write carry, which page did
|
|
8
|
+
* a list request ask for, and which `net` clause would name this call. Nothing here knows what a
|
|
8
9
|
* contradiction is.
|
|
9
10
|
*
|
|
10
11
|
* The rules next door read this vocabulary and decide what disagrees. Keeping the two apart means a
|
|
11
12
|
* new rule cannot quietly redefine what "in flight" or "ours" means for itself, which is how two
|
|
12
13
|
* rules end up disagreeing about the same window.
|
|
13
14
|
*/
|
|
14
|
-
import { EventType, MUTATING_METHODS, asNumber, asString, isDevToolingUrl, isForeignTraffic, urlForMatch, } from '@reticlehq/core';
|
|
15
|
+
import { EventType, MUTATING_METHODS, NEXT_ACTION_FIELD, PredicateKind, REQUEST_SHAPE_FIELD, ROUTE_CHANGE_HOW_FIELD, RouteChangeHow, asNumber, asString, isDevToolingUrl, isForeignTraffic, urlForMatch, } from '@reticlehq/core';
|
|
15
16
|
export function netCall(e) {
|
|
16
17
|
const status = asNumber(e.data['status']);
|
|
17
18
|
return {
|
|
@@ -114,6 +115,28 @@ export function isSameDocumentHashAnchor(event) {
|
|
|
114
115
|
return false;
|
|
115
116
|
return isInPageFragment(to.hash);
|
|
116
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* A `replaceState` that keeps the pathname recorded state in the URL. It is not a navigation.
|
|
120
|
+
*
|
|
121
|
+
* Search and an in-page fragment may change (`?zoom=125`, `#main-content`). A hash-router fragment
|
|
122
|
+
* (`#/invoices`) is still a new view, and so is a replace onto a different pathname. Missing hrefs
|
|
123
|
+
* stay under the blank-destination rule: an event that cannot show the path stayed put is not exempt.
|
|
124
|
+
*/
|
|
125
|
+
export function isSamePathnameReplace(event) {
|
|
126
|
+
if (event.type !== EventType.ROUTE_CHANGE)
|
|
127
|
+
return false;
|
|
128
|
+
if (asString(event.data[ROUTE_CHANGE_HOW_FIELD]) !== RouteChangeHow.REPLACE)
|
|
129
|
+
return false;
|
|
130
|
+
const from = hrefAsUrl(asString(event.data['from']));
|
|
131
|
+
const to = hrefAsUrl(asString(event.data['to']));
|
|
132
|
+
if (from === undefined || to === undefined)
|
|
133
|
+
return false;
|
|
134
|
+
if (from.origin !== to.origin || from.pathname !== to.pathname)
|
|
135
|
+
return false;
|
|
136
|
+
if (from.hash !== to.hash && !isInPageFragment(to.hash))
|
|
137
|
+
return false;
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
117
140
|
/**
|
|
118
141
|
* Split the window into the app's traffic and the dev toolchain's own (see `DevToolingChannel`).
|
|
119
142
|
*
|
|
@@ -201,3 +224,119 @@ export function isSteadyCadence(times) {
|
|
|
201
224
|
return false;
|
|
202
225
|
return gaps.every((gap) => Math.abs(gap - median) <= median * POLL_JITTER_RATIO);
|
|
203
226
|
}
|
|
227
|
+
export function identityOf(event) {
|
|
228
|
+
const action = asString(event.data[NEXT_ACTION_FIELD]);
|
|
229
|
+
const shape = asString(event.data[REQUEST_SHAPE_FIELD]);
|
|
230
|
+
const body = asString(event.data['requestBody']);
|
|
231
|
+
const carried = shape !== undefined && 0 !== shape.length
|
|
232
|
+
? shape
|
|
233
|
+
: body === undefined || 0 === body.length
|
|
234
|
+
? undefined
|
|
235
|
+
: body;
|
|
236
|
+
if (action === undefined || 0 === action.length) {
|
|
237
|
+
return carried === undefined ? undefined : { key: carried, carried: true };
|
|
238
|
+
}
|
|
239
|
+
return carried === undefined
|
|
240
|
+
? { key: action, carried: false }
|
|
241
|
+
: { key: `${action}:${carried}`, carried: true };
|
|
242
|
+
}
|
|
243
|
+
/** Split calls to one endpoint into the sets that sent the same thing. Callers check first that
|
|
244
|
+
* every identity is known; an unknown one would otherwise pool with every other unknown. */
|
|
245
|
+
export function groupByIdentity(calls) {
|
|
246
|
+
const byIdentity = new Map();
|
|
247
|
+
for (const call of calls) {
|
|
248
|
+
const key = call.identity?.key ?? '';
|
|
249
|
+
byIdentity.set(key, [...(byIdentity.get(key) ?? []), call]);
|
|
250
|
+
}
|
|
251
|
+
return [...byIdentity.values()];
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* The `net` clause that declares each of these failures, worded as a condition.
|
|
255
|
+
*
|
|
256
|
+
* A designed error path (a 402 paywall, a 429, a 428 confirmation) asserted through the UI it renders
|
|
257
|
+
* gets `ui-advanced-request-failed`, and declaring the failing call in the oracle is what exempts it
|
|
258
|
+
* (`matchesDeclaredFailure`). Nothing in the finding said so, so agents dropped the check or
|
|
259
|
+
* weakened it until it proved nothing (#1418). The clause is built from the call itself, so it is
|
|
260
|
+
* exactly what would match, and it is conditional: the finding is still a finding, and a clause
|
|
261
|
+
* pasted to make a red go away would be the same false green with extra steps.
|
|
262
|
+
*
|
|
263
|
+
* Built from the DISPLAY url, which is redacted, never from `matchUrl`, which is not: the detail is
|
|
264
|
+
* copied into crawl anomalies, and a hint must not put back a token the description took out. A
|
|
265
|
+
* call whose path cannot be named exactly and narrowly gets no clause rather than a loose one: a
|
|
266
|
+
* bare `/` is a substring of every url and would exempt unrelated failures with the same method.
|
|
267
|
+
*/
|
|
268
|
+
export function declareFailureHint(calls) {
|
|
269
|
+
const clauses = calls.flatMap((c) => {
|
|
270
|
+
const urlContains = narrowPathOf(c);
|
|
271
|
+
if (urlContains === undefined)
|
|
272
|
+
return [];
|
|
273
|
+
const clause = {
|
|
274
|
+
kind: PredicateKind.NET,
|
|
275
|
+
method: c.method.toUpperCase(),
|
|
276
|
+
urlContains,
|
|
277
|
+
...(c.status === undefined || 0 === c.status ? { ok: false } : { status: c.status }),
|
|
278
|
+
};
|
|
279
|
+
return [JSON.stringify(clause)];
|
|
280
|
+
});
|
|
281
|
+
if (0 === clauses.length)
|
|
282
|
+
return '';
|
|
283
|
+
const subject = 1 === clauses.length ? 'this failure is' : 'these failures are';
|
|
284
|
+
return `. If ${subject} the outcome you expect, declare it in the predicate: ${clauses.join(', ')}`;
|
|
285
|
+
}
|
|
286
|
+
/** Resolves a relative call url so its path can be read; the host is never shown or matched. */
|
|
287
|
+
const RELATIVE_URL_BASE = 'http://reticle.invalid';
|
|
288
|
+
/**
|
|
289
|
+
* The display url's path, when it is both safe to show and narrow enough to declare one call.
|
|
290
|
+
*
|
|
291
|
+
* Only when it is literally in the url the declaration is matched against: `urlContains` is a
|
|
292
|
+
* substring test, so a path the parser re-encoded, or one the redaction changed, would never match.
|
|
293
|
+
*/
|
|
294
|
+
function narrowPathOf(call) {
|
|
295
|
+
let path;
|
|
296
|
+
try {
|
|
297
|
+
path = new URL(call.url, RELATIVE_URL_BASE).pathname;
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
return undefined;
|
|
301
|
+
}
|
|
302
|
+
if (0 === path.replace(/\/+$/, '').length)
|
|
303
|
+
return undefined;
|
|
304
|
+
if (!call.url.includes(path) || !(call.matchUrl ?? call.url).includes(path))
|
|
305
|
+
return undefined;
|
|
306
|
+
return path;
|
|
307
|
+
}
|
|
308
|
+
/** Query parameters that say which page of a list is being asked for. */
|
|
309
|
+
const PAGE_PARAMS = ['page', 'offset', 'cursor', 'after', 'start', 'skip', 'from'];
|
|
310
|
+
/** "Page 2", "page 2 of 6", "2 / 6", "2 of 6". */
|
|
311
|
+
const PAGE_LABEL = /\bpage\s+(\d+)\b|\b(\d+)\s*(?:of|\/)\s*\d+\b/i;
|
|
312
|
+
export function pageNumber(text) {
|
|
313
|
+
if ('string' !== typeof text)
|
|
314
|
+
return undefined;
|
|
315
|
+
const match = PAGE_LABEL.exec(text);
|
|
316
|
+
const raw = match?.[1] ?? match?.[2];
|
|
317
|
+
return raw === undefined ? undefined : Number(raw);
|
|
318
|
+
}
|
|
319
|
+
/** The endpoint and its page parameter, for a GET that carries one. */
|
|
320
|
+
export function pageRequest(event) {
|
|
321
|
+
if (event.type !== EventType.NET_REQUEST)
|
|
322
|
+
return undefined;
|
|
323
|
+
const method = event.data['method'];
|
|
324
|
+
if ('string' !== typeof method || 'GET' !== method.toUpperCase())
|
|
325
|
+
return undefined;
|
|
326
|
+
const raw = event.data['url'];
|
|
327
|
+
if ('string' !== typeof raw)
|
|
328
|
+
return undefined;
|
|
329
|
+
let url;
|
|
330
|
+
try {
|
|
331
|
+
url = new URL(raw, 'http://app.invalid');
|
|
332
|
+
}
|
|
333
|
+
catch {
|
|
334
|
+
return undefined;
|
|
335
|
+
}
|
|
336
|
+
for (const param of PAGE_PARAMS) {
|
|
337
|
+
const value = url.searchParams.get(param);
|
|
338
|
+
if (value !== null)
|
|
339
|
+
return { path: url.pathname, param, value };
|
|
340
|
+
}
|
|
341
|
+
return undefined;
|
|
342
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Contradiction, ContradictionKind, ReticleEvent } from '@reticlehq/core';
|
|
2
2
|
import type { NoteFn } from '../window/engine-host.js';
|
|
3
|
-
import type { DeclaredNetFailure } from '../question/declared.js';
|
|
3
|
+
import type { DeclaredNetFailure, DeclaredRead } from '../question/declared.js';
|
|
4
4
|
/**
|
|
5
5
|
* What a contradiction IS, separated from the rules that find one.
|
|
6
6
|
*
|
|
@@ -167,4 +167,11 @@ export interface ContradictionOptions {
|
|
|
167
167
|
* declared, nothing is unrelated.
|
|
168
168
|
*/
|
|
169
169
|
namedNetUrls?: readonly string[] | undefined;
|
|
170
|
+
/**
|
|
171
|
+
* Endpoints the assertion declared as reads (`net { repeatable: true }`). Repeats on them are not
|
|
172
|
+
* a double submit, so `duplicate-request` skips them (#1353). A call matches when its URL contains
|
|
173
|
+
* `urlContains` and, if the clause named a method, its method is that one: a repeatable GET never
|
|
174
|
+
* excuses a POST. Nothing else reads it: they are still waited for and still counted.
|
|
175
|
+
*/
|
|
176
|
+
repeatableNetUrls?: readonly DeclaredRead[] | undefined;
|
|
170
177
|
}
|
|
@@ -3,6 +3,18 @@ import type { Contradiction, OwnContradiction, ContradictionOptions } from './co
|
|
|
3
3
|
export type { Contradiction, OwnContradiction, ContradictionOptions, } from './contradiction-types.js';
|
|
4
4
|
/** Net-shaped events — the only ones that carry a URL a dev-tooling channel could occupy. */
|
|
5
5
|
export declare function findContradictions(allEvents: readonly ReticleEvent[], options?: ContradictionOptions): Contradiction[];
|
|
6
|
+
/**
|
|
7
|
+
* The page label moved and the request did not.
|
|
8
|
+
*
|
|
9
|
+
* Measured on a real payments dashboard: "Next" relabels the table "Page 2 of 6" and the app
|
|
10
|
+
* refetches `GET /payments?page=1`, so 103 of 128 rows can never be reached. Every channel looks
|
|
11
|
+
* healthy on its own: the request is a 200, the label changed, the table rendered rows. The
|
|
12
|
+
* disagreement is between the label and the query string.
|
|
13
|
+
*
|
|
14
|
+
* Fires only on direct evidence, never on a guess: the window must show the label's page number
|
|
15
|
+
* changing AND a GET to the same endpoint carrying the same page parameter the last one carried.
|
|
16
|
+
* Client-side paging that fetches nothing is legitimate and stays silent.
|
|
17
|
+
*/
|
|
6
18
|
/**
|
|
7
19
|
* @param prior events before the window: where the last page request to each endpoint is learned.
|
|
8
20
|
*/
|
|
@@ -1,39 +1,25 @@
|
|
|
1
|
-
import { ContradictionKind, EventType,
|
|
1
|
+
import { ContradictionKind, EventType, isAbsenceDerived, isSameDocument, isSameEditEpoch, } from '@reticlehq/core';
|
|
2
2
|
import { describeSuperseded } from '../question/predicate/observed-in-window.js';
|
|
3
|
-
import { describe, isMutating, isSameDocumentHashAnchor, isSteadyCadence, netCall, recoveredByRetry, splitForeignTraffic, } from './contradiction-evidence.js';
|
|
3
|
+
import { declareFailureHint, describe, groupByIdentity, identityOf, isMutating, isSameDocumentHashAnchor, isSamePathnameReplace, isSteadyCadence, netCall, pageNumber, pageRequest, recoveredByRetry, splitForeignTraffic, } from './contradiction-evidence.js';
|
|
4
4
|
import { findStaleResponses } from './stale-response.js';
|
|
5
5
|
import { findBodyFailures } from './body-failures.js';
|
|
6
6
|
import { findEchoMismatches } from './echo-mismatch.js';
|
|
7
7
|
import { findUnitMismatches } from './unit-mismatch.js';
|
|
8
8
|
import { asString } from '@reticlehq/core';
|
|
9
|
-
import { matchesDeclaredFailure } from '../question/declared.js';
|
|
9
|
+
import { isDeclaredRead, matchesDeclaredFailure } from '../question/declared.js';
|
|
10
10
|
import { runRegisteredFolds } from './contradiction-folds.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return carried === undefined
|
|
24
|
-
? { key: action, carried: false }
|
|
25
|
-
: { key: `${action}:${carried}`, carried: true };
|
|
26
|
-
}
|
|
27
|
-
/** Split calls to one endpoint into the sets that sent the same thing. Callers check first that
|
|
28
|
-
* every identity is known; an unknown one would otherwise pool with every other unknown. */
|
|
29
|
-
function groupByIdentity(calls) {
|
|
30
|
-
const byIdentity = new Map();
|
|
31
|
-
for (const call of calls) {
|
|
32
|
-
const key = call.identity?.key ?? '';
|
|
33
|
-
byIdentity.set(key, [...(byIdentity.get(key) ?? []), call]);
|
|
34
|
-
}
|
|
35
|
-
return [...byIdentity.values()];
|
|
36
|
-
}
|
|
11
|
+
import { isMeaningfulStateChange } from '../state-bookkeeping.js';
|
|
12
|
+
/**
|
|
13
|
+
* The contradiction hunter.
|
|
14
|
+
*
|
|
15
|
+
* Every other check reads ONE channel and asks "did something bad happen there?". This asks what a
|
|
16
|
+
* person watching the screen structurally cannot: do the channels DISAGREE? The DOM, the store, the
|
|
17
|
+
* app's own signals, the console and the network arrive in one causally ordered window, so the case
|
|
18
|
+
* where the screen says one thing and the network says the opposite is visible — and that gap is
|
|
19
|
+
* where false greens live, because a screenshot, a DOM assertion and a human all agree there.
|
|
20
|
+
*
|
|
21
|
+
* Pure: a window of events in, findings out. No session, no IO, no clock.
|
|
22
|
+
*/
|
|
37
23
|
function uiAdvanced(events) {
|
|
38
24
|
return events.some((e) => e.type === EventType.DOM_ADDED ||
|
|
39
25
|
e.type === EventType.DOM_REMOVED ||
|
|
@@ -49,6 +35,10 @@ function uiAdvanced(events) {
|
|
|
49
35
|
* the structural check below cannot decide, not the primary signal.
|
|
50
36
|
*/
|
|
51
37
|
const ACKNOWLEDGED = /error|fail|invalid|reject|denied|unable|could not|couldn't/i;
|
|
38
|
+
// Refusal wording belongs to explicit signals; "checkout.blocking" can be an ordinary loading flag.
|
|
39
|
+
// Token boundaries keep "unblocked" and "blockchain" as success claims.
|
|
40
|
+
const REFUSAL_SIGNAL = /(?:^|[^a-z])(?:refus(?:e[ds]?|al|ing)|forbid(?:den|ding|s)?|blocked|not[ _-]+allowed)(?:$|[^a-z])/i;
|
|
41
|
+
const signalAcknowledgesFailure = (name) => ACKNOWLEDGED.test(name) || REFUSAL_SIGNAL.test(name);
|
|
52
42
|
/**
|
|
53
43
|
* Below this length an error string is too generic to be evidence — "no", "err", a bare code — and
|
|
54
44
|
* could coincide with unrelated state text.
|
|
@@ -114,7 +104,7 @@ function failureAcknowledged(events) {
|
|
|
114
104
|
// A failure-shaped SIGNAL is an acknowledgement too. An app that fires `auth:denied` has plainly
|
|
115
105
|
// not proceeded as if it succeeded, whatever its state paths happen to be named.
|
|
116
106
|
if (e.type === EventType.SIGNAL)
|
|
117
|
-
return
|
|
107
|
+
return signalAcknowledgesFailure(asString(e.data['name']) ?? '');
|
|
118
108
|
if (e.type !== EventType.STATE_CHANGE)
|
|
119
109
|
return false;
|
|
120
110
|
const path = asString(e.data['path']) ?? '';
|
|
@@ -123,6 +113,8 @@ function failureAcknowledged(events) {
|
|
|
123
113
|
});
|
|
124
114
|
}
|
|
125
115
|
const ALERT_ROLE = 'alert';
|
|
116
|
+
/** Reticle's own instrumentation's signals (core's `RETICLE_HYDRATION_SIGNAL`); not imported: coupling only shrinks. */
|
|
117
|
+
const RETICLE_SIGNAL_NAMESPACE = 'reticle:';
|
|
126
118
|
const ARIA_INVALID = 'aria-invalid';
|
|
127
119
|
const MUST_DO_SOMETHING = new Set(['click', 'dblclick', 'submit']);
|
|
128
120
|
/**
|
|
@@ -307,7 +299,12 @@ function findWindowContradictions(allEvents, options) {
|
|
|
307
299
|
// consequences are location.hash, focus, and scroll — not a DOM mutation. Treating it as a
|
|
308
300
|
// blank destination made "did my skip link work" unanswerable. Hash-router paths (`#/invoices`)
|
|
309
301
|
// still go through the rule: those ARE a new view.
|
|
310
|
-
|
|
302
|
+
//
|
|
303
|
+
// A `replaceState` that keeps the pathname is the same kind of non-navigation: the URL recorded
|
|
304
|
+
// state (a zoom, a filter, a selected tab) and the view did not change. A replace onto a new
|
|
305
|
+
// pathname, or a push onto one, is still a navigation.
|
|
306
|
+
const notANavigation = routed &&
|
|
307
|
+
routeEvents.every((event) => isSameDocumentHashAnchor(event) || isSamePathnameReplace(event));
|
|
311
308
|
// `dom.text` counts as rendered, and it has to: React reconciles a destination IN PLACE far more
|
|
312
309
|
// often than it adds nodes. Measured on three ordinary sidebar navigations of the bench app — every
|
|
313
310
|
// one emitted { dom.attr:2, dom.text:2, render.commit, state.change } and ZERO dom.added/removed,
|
|
@@ -322,7 +319,7 @@ function findWindowContradictions(allEvents, options) {
|
|
|
322
319
|
e.type === EventType.DOM_REMOVED ||
|
|
323
320
|
e.type === EventType.DOM_TEXT);
|
|
324
321
|
const fetched = events.some((e) => e.type === EventType.NET_REQUEST || e.type === EventType.NET_PENDING);
|
|
325
|
-
if (routed && !
|
|
322
|
+
if (routed && !notANavigation && !rendered && !fetched && true !== options.renderProved) {
|
|
326
323
|
// A console error in the SAME window turns "nothing rendered" from an absence into a positive
|
|
327
324
|
// claim: the destination did not merely fail to produce content, it crashed while trying to.
|
|
328
325
|
// Reported once as `unknown` when this held — a React hooks error and an empty destination were
|
|
@@ -378,7 +375,9 @@ function findWindowContradictions(allEvents, options) {
|
|
|
378
375
|
// A failure-shaped signal is not a success claim, so it must not be read as one: saying "the app
|
|
379
376
|
// claimed success" about an app that plainly reported a failure is true in outline and wrong in
|
|
380
377
|
// its reasoning, which is how a checker stops being believed.
|
|
381
|
-
|
|
378
|
+
// Nor is a signal Reticle's instrumentation fires: a revoked member's tab sent to /login by the
|
|
379
|
+
// intended 401 hydrated, and that read as a success claim graded the working revocation `no`.
|
|
380
|
+
const successSignals = signals.filter((name) => !name.startsWith(RETICLE_SIGNAL_NAMESPACE) && !signalAcknowledgesFailure(name));
|
|
382
381
|
// An app that RETRACTED has not claimed success, whenever it fired the optimistic signal.
|
|
383
382
|
//
|
|
384
383
|
// The weaker UI rule below already consulted this and the sharper signal rule did not, so an app
|
|
@@ -426,7 +425,7 @@ function findWindowContradictions(allEvents, options) {
|
|
|
426
425
|
kind: ContradictionKind.UI_ADVANCED_REQUEST_FAILED,
|
|
427
426
|
claim: 'the UI moved forward (DOM/store/route changed)',
|
|
428
427
|
counter: `${String(unexpectedWrites.length)} request(s) in the same window failed`,
|
|
429
|
-
detail: unexpectedWrites.map(describe).join('; ')
|
|
428
|
+
detail: `${unexpectedWrites.map(describe).join('; ')}${declareFailureHint(unexpectedWrites)}`,
|
|
430
429
|
});
|
|
431
430
|
}
|
|
432
431
|
// ── A write succeeded and nothing on the client moved ───────────────────────────────────────
|
|
@@ -474,7 +473,7 @@ function findWindowContradictions(allEvents, options) {
|
|
|
474
473
|
// signal rule below had to earn. Two existing tests proved it: both describe a window with a
|
|
475
474
|
// failed call in it, and both were already answered by the rule that owns that fact.
|
|
476
475
|
if (options.actionSince !== undefined &&
|
|
477
|
-
events.some(
|
|
476
|
+
events.some(isMeaningfulStateChange) &&
|
|
478
477
|
!events.some((e) => e.type === EventType.NET_REQUEST || e.type === EventType.NET_PENDING) &&
|
|
479
478
|
!events.some((e) => e.type === EventType.DOM_ADDED ||
|
|
480
479
|
e.type === EventType.DOM_REMOVED ||
|
|
@@ -567,6 +566,9 @@ function findWindowContradictions(allEvents, options) {
|
|
|
567
566
|
const call = netCall(event);
|
|
568
567
|
if (!isMutating(call))
|
|
569
568
|
continue;
|
|
569
|
+
// Declared a read by the assertion itself (#1353): a repeat is the app reading twice.
|
|
570
|
+
if (isDeclaredRead(call, options.repeatableNetUrls))
|
|
571
|
+
continue;
|
|
570
572
|
const label = `${call.method} ${call.url}`;
|
|
571
573
|
const calls = writes.get(label) ?? [];
|
|
572
574
|
// `landed` is tracked per call rather than counted here, because the claim is about what
|
|
@@ -685,41 +687,6 @@ function findWindowContradictions(allEvents, options) {
|
|
|
685
687
|
* changing AND a GET to the same endpoint carrying the same page parameter the last one carried.
|
|
686
688
|
* Client-side paging that fetches nothing is legitimate and stays silent.
|
|
687
689
|
*/
|
|
688
|
-
/** Query parameters that say which page of a list is being asked for. */
|
|
689
|
-
const PAGE_PARAMS = ['page', 'offset', 'cursor', 'after', 'start', 'skip', 'from'];
|
|
690
|
-
/** "Page 2", "page 2 of 6", "2 / 6", "2 of 6". */
|
|
691
|
-
const PAGE_LABEL = /\bpage\s+(\d+)\b|\b(\d+)\s*(?:of|\/)\s*\d+\b/i;
|
|
692
|
-
function pageNumber(text) {
|
|
693
|
-
if ('string' !== typeof text)
|
|
694
|
-
return undefined;
|
|
695
|
-
const match = PAGE_LABEL.exec(text);
|
|
696
|
-
const raw = match?.[1] ?? match?.[2];
|
|
697
|
-
return raw === undefined ? undefined : Number(raw);
|
|
698
|
-
}
|
|
699
|
-
/** The endpoint and its page parameter, for a GET that carries one. */
|
|
700
|
-
function pageRequest(event) {
|
|
701
|
-
if (event.type !== EventType.NET_REQUEST)
|
|
702
|
-
return undefined;
|
|
703
|
-
const method = event.data['method'];
|
|
704
|
-
if ('string' !== typeof method || 'GET' !== method.toUpperCase())
|
|
705
|
-
return undefined;
|
|
706
|
-
const raw = event.data['url'];
|
|
707
|
-
if ('string' !== typeof raw)
|
|
708
|
-
return undefined;
|
|
709
|
-
let url;
|
|
710
|
-
try {
|
|
711
|
-
url = new URL(raw, 'http://app.invalid');
|
|
712
|
-
}
|
|
713
|
-
catch {
|
|
714
|
-
return undefined;
|
|
715
|
-
}
|
|
716
|
-
for (const param of PAGE_PARAMS) {
|
|
717
|
-
const value = url.searchParams.get(param);
|
|
718
|
-
if (value !== null)
|
|
719
|
-
return { path: url.pathname, param, value };
|
|
720
|
-
}
|
|
721
|
-
return undefined;
|
|
722
|
-
}
|
|
723
690
|
/**
|
|
724
691
|
* @param prior events before the window: where the last page request to each endpoint is learned.
|
|
725
692
|
*/
|
|
@@ -52,6 +52,8 @@ function differsOnlyByEnumeration(first, second) {
|
|
|
52
52
|
* (a tile grid's `?id=1` and `?id=2`), and neither answer can overwrite the other's view.
|
|
53
53
|
*/
|
|
54
54
|
const IDENTITY_PARAMS = new Set(['id', 'ids', 'uuid', 'slug', 'key']);
|
|
55
|
+
/** Different projections ask for differently shaped answers, both of which the app may need. */
|
|
56
|
+
const PROJECTION_PARAMS = new Set(['select', 'fields', 'columns', 'include', 'expand']);
|
|
55
57
|
/**
|
|
56
58
|
* Issued this close together, two requests came from one task (a `Promise.all`, two effects in one
|
|
57
59
|
* commit), so no later intent superseded the first: they are a fan-out, not a race (#1225).
|
|
@@ -61,8 +63,8 @@ const IDENTITY_PARAMS = new Set(['id', 'ids', 'uuid', 'slug', 'key']);
|
|
|
61
63
|
const SAME_TASK_MS = 2;
|
|
62
64
|
/**
|
|
63
65
|
* Whether the second read could have made the first obsolete. Not when they ask for differently
|
|
64
|
-
* shaped answers (
|
|
65
|
-
*
|
|
66
|
+
* shaped answers (different key sets or projections), not when they name different resources, and
|
|
67
|
+
* not when only enumeration changed.
|
|
66
68
|
*/
|
|
67
69
|
function couldSupersede(first, second) {
|
|
68
70
|
const a = new URLSearchParams(first);
|
|
@@ -74,6 +76,9 @@ function couldSupersede(first, second) {
|
|
|
74
76
|
for (const key of IDENTITY_PARAMS)
|
|
75
77
|
if (a.get(key) !== b.get(key))
|
|
76
78
|
return false;
|
|
79
|
+
for (const key of PROJECTION_PARAMS)
|
|
80
|
+
if (a.get(key) !== b.get(key))
|
|
81
|
+
return false;
|
|
77
82
|
return !differsOnlyByEnumeration(first, second);
|
|
78
83
|
}
|
|
79
84
|
/** Pair NET_PENDING with its NET_REQUEST by the id both carry. Unpaired events are still in flight. */
|
|
@@ -16,6 +16,11 @@ export declare function readsDomState(predicate: Predicate): boolean;
|
|
|
16
16
|
export declare function alreadyTrueHiddenMatch(predicate: Predicate, evidence: unknown): boolean;
|
|
17
17
|
/** What a green resting on hidden matches says instead of `yes`. See `hiddenMatchNote`. */
|
|
18
18
|
export declare const HIDDEN_MATCH_NOTE: string;
|
|
19
|
+
/**
|
|
20
|
+
* The same, for an element check, which asks by `state` and refuses `visible` ("element accepts:
|
|
21
|
+
* query, state, absent") — every hidden-match answer used to advise the field it refuses.
|
|
22
|
+
*/
|
|
23
|
+
export declare const HIDDEN_ELEMENT_MATCH_NOTE: string;
|
|
19
24
|
/**
|
|
20
25
|
* #1408: the post-action half of `alreadyTrueHiddenMatch`. A `text` clause beside a `net` clause is
|
|
21
26
|
* never already true, so a success template still hidden in the DOM passed with no caveat at all.
|
|
@@ -102,6 +102,13 @@ export function alreadyTrueHiddenMatch(predicate, evidence) {
|
|
|
102
102
|
export const HIDDEN_MATCH_NOTE = 'the declared consequence held only on a hidden element: a text or element check matches DOM ' +
|
|
103
103
|
'presence, not visibility, by default, so nothing here shows it is on screen. Add `visible: true` ' +
|
|
104
104
|
'if you meant "this is showing", not merely "this exists"';
|
|
105
|
+
/**
|
|
106
|
+
* The same, for an element check, which asks by `state` and refuses `visible` ("element accepts:
|
|
107
|
+
* query, state, absent") — every hidden-match answer used to advise the field it refuses.
|
|
108
|
+
*/
|
|
109
|
+
export const HIDDEN_ELEMENT_MATCH_NOTE = 'the declared consequence held only on a hidden element: an element check matches DOM presence, ' +
|
|
110
|
+
'not visibility, by default, so nothing here shows it is on screen. Add `state: "visible"` if you ' +
|
|
111
|
+
'meant "this is showing", not merely "this exists"';
|
|
105
112
|
/**
|
|
106
113
|
* #1408: the post-action half of `alreadyTrueHiddenMatch`. A `text` clause beside a `net` clause is
|
|
107
114
|
* never already true, so a success template still hidden in the DOM passed with no caveat at all.
|
|
@@ -111,17 +118,31 @@ export const HIDDEN_MATCH_NOTE = 'the declared consequence held only on a hidden
|
|
|
111
118
|
* `anyOf` carries only the branch that held, which is why each branch is tried against it.
|
|
112
119
|
*/
|
|
113
120
|
export function hiddenMatchNote(predicate, evidence) {
|
|
114
|
-
|
|
121
|
+
const kind = hiddenMatchKind(predicate, evidence);
|
|
122
|
+
if (kind === undefined)
|
|
123
|
+
return undefined;
|
|
124
|
+
return PredicateKind.ELEMENT === kind ? HIDDEN_ELEMENT_MATCH_NOTE : HIDDEN_MATCH_NOTE;
|
|
115
125
|
}
|
|
116
|
-
|
|
126
|
+
/** The kind of the first clause the green rests on that matched only hidden elements. */
|
|
127
|
+
function hiddenMatchKind(predicate, evidence) {
|
|
117
128
|
if (PredicateKind.ALL_OF === predicate.kind) {
|
|
118
129
|
if (!Array.isArray(evidence))
|
|
119
|
-
return
|
|
130
|
+
return undefined;
|
|
120
131
|
const each = evidence;
|
|
121
|
-
|
|
132
|
+
for (const [i, clause] of predicate.predicates.entries()) {
|
|
133
|
+
const kind = hiddenMatchKind(clause, each[i]);
|
|
134
|
+
if (kind !== undefined)
|
|
135
|
+
return kind;
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
122
138
|
}
|
|
123
139
|
if (PredicateKind.ANY_OF === predicate.kind) {
|
|
124
|
-
|
|
140
|
+
for (const clause of predicate.predicates) {
|
|
141
|
+
const kind = hiddenMatchKind(clause, evidence);
|
|
142
|
+
if (kind !== undefined)
|
|
143
|
+
return kind;
|
|
144
|
+
}
|
|
145
|
+
return undefined;
|
|
125
146
|
}
|
|
126
|
-
return alreadyTrueHiddenMatch(predicate, evidence);
|
|
147
|
+
return alreadyTrueHiddenMatch(predicate, evidence) ? predicate.kind : undefined;
|
|
127
148
|
}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* and has no evidence behind it.
|
|
15
15
|
*/
|
|
16
16
|
import { PredicateKind, ReticleCommand } from '@reticlehq/core';
|
|
17
|
+
import { textPredicateQuery } from '../question/predicate/predicate-element.js';
|
|
17
18
|
/** The properties that mean nothing without a before-reading. Mirrors `RELATIVE` in property.ts. */
|
|
18
19
|
const NEEDS_BASELINE = new Set([
|
|
19
20
|
'changed',
|
|
@@ -72,12 +73,7 @@ async function readStateValue(session, predicate) {
|
|
|
72
73
|
return 'boolean' === typeof reply.found ? { taken: true, value: reply.value } : undefined;
|
|
73
74
|
}
|
|
74
75
|
async function readText(session, predicate) {
|
|
75
|
-
const query =
|
|
76
|
-
...(predicate.contains === undefined ? {} : { text: predicate.contains }),
|
|
77
|
-
...(predicate.scope === undefined
|
|
78
|
-
? {}
|
|
79
|
-
: { scope: predicate.scope, ...(true === predicate.self ? { self: true } : {}) }),
|
|
80
|
-
};
|
|
76
|
+
const query = textPredicateQuery(predicate);
|
|
81
77
|
const match = await session.command(ReticleCommand.MATCH, { query });
|
|
82
78
|
if (!match.ok)
|
|
83
79
|
return undefined;
|
|
@@ -47,8 +47,15 @@ interface CoverageStatement {
|
|
|
47
47
|
* not depend on the evidence.
|
|
48
48
|
*/
|
|
49
49
|
export declare function impeachesCapture(kind: BlindSpotKind): boolean;
|
|
50
|
-
/**
|
|
51
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Compose the coverage statement. `full` (no note) when nothing was unobserved.
|
|
52
|
+
*
|
|
53
|
+
* `windowSpots`, when given, are the same spots counted over the judged window only. An impeaching
|
|
54
|
+
* kind is then labelled by what the WINDOW saw: its window count when it dropped events there, and
|
|
55
|
+
* as an earlier-in-the-session fact when it did not. Bounding kinds are standing facts of the page
|
|
56
|
+
* and keep their session-wide label.
|
|
57
|
+
*/
|
|
58
|
+
export declare function buildCoverageStatement(spots: readonly BlindSpot[], windowSpots?: readonly BlindSpot[]): CoverageStatement;
|
|
52
59
|
/**
|
|
53
60
|
* Reduce a window's BLIND_SPOT events to one spot per kind — the LATEST reported count wins (the sensor
|
|
54
61
|
* emits only on change, so the last value is the live count). This is how a result's coverage is derived
|
|
@@ -88,6 +95,9 @@ interface AbsencePredicate {
|
|
|
88
95
|
absent?: boolean;
|
|
89
96
|
query?: {
|
|
90
97
|
scope?: unknown;
|
|
98
|
+
role?: string | undefined;
|
|
99
|
+
by?: string | undefined;
|
|
100
|
+
value?: string | undefined;
|
|
91
101
|
};
|
|
92
102
|
predicate?: AbsencePredicate;
|
|
93
103
|
}
|
|
@@ -98,7 +108,8 @@ interface AbsencePredicate {
|
|
|
98
108
|
*
|
|
99
109
|
* Fires on three blind-spot kinds:
|
|
100
110
|
* - CROSS_ORIGIN_IFRAME (only when the predicate is scoped to a frame region)
|
|
101
|
-
* - VIRTUALIZED_UNMOUNTED — a row that was never rendered could hold the element
|
|
111
|
+
* - VIRTUALIZED_UNMOUNTED — a row that was never rendered could hold the element (scoped:
|
|
112
|
+
* skipped when the queried role is structurally page-level, like dialog or a landmark)
|
|
102
113
|
* - CLOSED_SHADOW_ROOT — a subtree Reticle cannot see into
|
|
103
114
|
*/
|
|
104
115
|
export declare function absenceBlindSpotNote(predicate: AbsencePredicate, spots: readonly BlindSpot[]): string | undefined;
|