@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
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// The kind enum lives in core (it crosses the wire in a BLIND_SPOT event); re-exported here for the
|
|
8
8
|
// honesty-side callers.
|
|
9
9
|
export { BlindSpotKind } from '@reticlehq/core';
|
|
10
|
-
import { BlindSpotKind, EventType, PredicateKind, ReticleEnv, TRANSPORT_LIMITS, isDesktopBlindSpot, realmOf, } from '@reticlehq/core';
|
|
10
|
+
import { BlindSpotKind, EventType, PredicateKind, QueryBy, ReticleEnv, TRANSPORT_LIMITS, isDesktopBlindSpot, realmOf, } from '@reticlehq/core';
|
|
11
11
|
/**
|
|
12
12
|
* Whether the observation window saw everything it was asked about.
|
|
13
13
|
*
|
|
@@ -43,7 +43,7 @@ const LABEL = {
|
|
|
43
43
|
// Not a tally — a fact about the app's wiring, phrased as what the EMPTY state channel means. An
|
|
44
44
|
// agent reading `stateDiffs: []` otherwise reads "the app changed no state", which is a claim
|
|
45
45
|
// nothing here can support. Names the one-line fix, because the reader is the one who can apply it.
|
|
46
|
-
[BlindSpotKind.UNWATCHED_STATE]: () =>
|
|
46
|
+
[BlindSpotKind.UNWATCHED_STATE]: () => "no subscribable store is registered, so NO state change is observed — an empty stateDiffs here means unwatched, not unchanged (import { registerStore } from '@reticlehq/browser' and call registerStore(name, store) with a subscribable store; for component-local React state, import { useReticleStore } from '@reticlehq/react/store' and call useReticleStore(name, value), or inspect it with reticle_look { action: 'state', ref: '...' })",
|
|
47
47
|
[BlindSpotKind.WRAPPED_NETWORK]: () => 'fetch was already wrapped before Reticle, so recorded requests may differ from what was sent',
|
|
48
48
|
// A fact about the app's wiring, not a tally. Says what a network view WITHOUT ipc:// records
|
|
49
49
|
// MEANS, because that state here is indistinguishable from "this app made no backend calls" —
|
|
@@ -72,8 +72,21 @@ const LABEL = {
|
|
|
72
72
|
export function impeachesCapture(kind) {
|
|
73
73
|
return kind === BlindSpotKind.RATE_LIMITED;
|
|
74
74
|
}
|
|
75
|
-
/**
|
|
76
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Bridge sampling that happened in the session but not in the window being judged (#1414). The
|
|
77
|
+
* window's own label says "this window is SAMPLED" and asks for a re-run, which is false here: the
|
|
78
|
+
* verdict's capture is whole, and repeating the drive would only repeat a clean check.
|
|
79
|
+
*/
|
|
80
|
+
const RATE_LIMITED_ELSEWHERE = (n) => `${String(n)} event${1 === n ? '' : 's'} dropped by the bridge rate cap earlier in this session, none in this window, so this result's capture is complete`;
|
|
81
|
+
/**
|
|
82
|
+
* Compose the coverage statement. `full` (no note) when nothing was unobserved.
|
|
83
|
+
*
|
|
84
|
+
* `windowSpots`, when given, are the same spots counted over the judged window only. An impeaching
|
|
85
|
+
* kind is then labelled by what the WINDOW saw: its window count when it dropped events there, and
|
|
86
|
+
* as an earlier-in-the-session fact when it did not. Bounding kinds are standing facts of the page
|
|
87
|
+
* and keep their session-wide label.
|
|
88
|
+
*/
|
|
89
|
+
export function buildCoverageStatement(spots, windowSpots) {
|
|
77
90
|
const present = spots.filter((s) => s.count > 0);
|
|
78
91
|
if (0 === present.length)
|
|
79
92
|
return { coverage: Coverage.FULL, spots: [] };
|
|
@@ -85,7 +98,15 @@ export function buildCoverageStatement(spots) {
|
|
|
85
98
|
// daemon can report one, and `LABEL[kind](count)` threw a TypeError on the verdict path when it
|
|
86
99
|
// did — turning "there is something I could not see" into a crashed assert, which is worse than
|
|
87
100
|
// either the caveat or the silence. Unknown kinds degrade to their own name.
|
|
88
|
-
const
|
|
101
|
+
const known = (s) => 'function' === typeof LABEL[s.kind] ? LABEL[s.kind](s.count) : `${s.kind} (${String(s.count)})`;
|
|
102
|
+
const label = (s) => {
|
|
103
|
+
if (windowSpots === undefined || !impeachesCapture(s.kind))
|
|
104
|
+
return known(s);
|
|
105
|
+
const inWindow = windowSpots.find((w) => w.kind === s.kind)?.count ?? 0;
|
|
106
|
+
return 0 < inWindow
|
|
107
|
+
? known({ kind: s.kind, count: inWindow })
|
|
108
|
+
: RATE_LIMITED_ELSEWHERE(s.count);
|
|
109
|
+
};
|
|
89
110
|
const note = `${Coverage.PARTIAL} — ${present.map(label).join(', ')}`;
|
|
90
111
|
return { coverage: Coverage.PARTIAL, note, spots: present };
|
|
91
112
|
}
|
|
@@ -145,7 +166,8 @@ export function blindSpotsFromState(state, runtime) {
|
|
|
145
166
|
return spotsForRuntime(spots, runtime);
|
|
146
167
|
}
|
|
147
168
|
/**
|
|
148
|
-
* Events the BROWSER's own transport queue threw
|
|
169
|
+
* Events lost in transport inside this window, or 0: the BROWSER's own transport queue threw them
|
|
170
|
+
* away, or the daemon dropped a frame from a live session that it could not read (#1413).
|
|
149
171
|
*
|
|
150
172
|
* `RATE_LIMITED` — the BRIDGE sampling because events arrived faster than its per-second cap — is
|
|
151
173
|
* already the one blind spot that `impeachesCapture`, on the reasoning that a green over a window
|
|
@@ -170,6 +192,18 @@ function droppedByTransport(events) {
|
|
|
170
192
|
}
|
|
171
193
|
return dropped;
|
|
172
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Roles that are structurally page-level and can never be a virtualized list row. A dialog is
|
|
197
|
+
* always a top-level overlay; a landmark is a page-structural element. Absence of one of these
|
|
198
|
+
* is not threatened by rows a virtualizer unmounted off-screen (#1236).
|
|
199
|
+
*/
|
|
200
|
+
const NEVER_VIRTUALIZED_ROLES = new Set([
|
|
201
|
+
'dialog',
|
|
202
|
+
'alertdialog',
|
|
203
|
+
'banner',
|
|
204
|
+
'contentinfo',
|
|
205
|
+
'main',
|
|
206
|
+
]);
|
|
173
207
|
/**
|
|
174
208
|
* When an absence assertion targets a page with regions Reticle cannot observe, "the element is
|
|
175
209
|
* absent" means only "it is absent in what I CAN see". Returns a note when that distinction
|
|
@@ -177,7 +211,8 @@ function droppedByTransport(events) {
|
|
|
177
211
|
*
|
|
178
212
|
* Fires on three blind-spot kinds:
|
|
179
213
|
* - CROSS_ORIGIN_IFRAME (only when the predicate is scoped to a frame region)
|
|
180
|
-
* - VIRTUALIZED_UNMOUNTED — a row that was never rendered could hold the element
|
|
214
|
+
* - VIRTUALIZED_UNMOUNTED — a row that was never rendered could hold the element (scoped:
|
|
215
|
+
* skipped when the queried role is structurally page-level, like dialog or a landmark)
|
|
181
216
|
* - CLOSED_SHADOW_ROOT — a subtree Reticle cannot see into
|
|
182
217
|
*/
|
|
183
218
|
export function absenceBlindSpotNote(predicate, spots) {
|
|
@@ -195,11 +230,14 @@ export function absenceBlindSpotNote(predicate, spots) {
|
|
|
195
230
|
}
|
|
196
231
|
if (PredicateKind.ELEMENT !== predicate.kind || true !== predicate.absent)
|
|
197
232
|
return undefined;
|
|
233
|
+
const role = predicate.query?.role ??
|
|
234
|
+
(QueryBy.ROLE === predicate.query?.by ? predicate.query.value : undefined);
|
|
198
235
|
const relevant = spots.filter((spot) => spot.count > 0 &&
|
|
199
236
|
(spot.kind === BlindSpotKind.CROSS_ORIGIN_IFRAME
|
|
200
237
|
? undefined !== predicate.query?.scope
|
|
201
|
-
: spot.kind === BlindSpotKind.VIRTUALIZED_UNMOUNTED
|
|
202
|
-
|
|
238
|
+
: spot.kind === BlindSpotKind.VIRTUALIZED_UNMOUNTED
|
|
239
|
+
? undefined === role || !NEVER_VIRTUALIZED_ROLES.has(role)
|
|
240
|
+
: spot.kind === BlindSpotKind.CLOSED_SHADOW_ROOT));
|
|
203
241
|
if (0 === relevant.length)
|
|
204
242
|
return undefined;
|
|
205
243
|
const statement = buildCoverageStatement(relevant);
|
|
@@ -210,7 +248,7 @@ export function transportGapNote(events) {
|
|
|
210
248
|
const dropped = droppedByTransport(events);
|
|
211
249
|
return 0 === dropped
|
|
212
250
|
? undefined
|
|
213
|
-
:
|
|
251
|
+
: `${String(dropped)} event(s) in this window were lost in transport (a browser queue overflow, or a frame the daemon could not read), so events that would have contradicted this may never have arrived`;
|
|
214
252
|
}
|
|
215
253
|
/**
|
|
216
254
|
* Is the state channel dark?
|
|
@@ -14,7 +14,9 @@ export function gapsForAction(facts) {
|
|
|
14
14
|
const off = true === facts.sourceMappingDisabled;
|
|
15
15
|
gaps.push(instrumentationGap(off ? InstrumentationGapKind.SOURCE_MAPPING_OFF : InstrumentationGapKind.NO_SOURCE_MAPPING, off
|
|
16
16
|
? 'source mapping is turned off for this build, so no element carries data-reticle-source'
|
|
17
|
-
:
|
|
17
|
+
: facts.ref === undefined
|
|
18
|
+
? 'nothing this verdict located carries a source mapping'
|
|
19
|
+
: 'the control that was driven carries no source mapping', 'this verdict can name the control but not the file and line that render it, so finding the code is a separate search', { ...(facts.ref === undefined ? {} : { ref: facts.ref }) }));
|
|
18
20
|
}
|
|
19
21
|
// Asked about state, and there is no state channel to answer from. Deliberately UNLOCATED: a store
|
|
20
22
|
// is registered once at app setup, nowhere near the control that was driven, and nothing in this
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which checks read too early: the ONE rule every fold of a run's checks applies.
|
|
3
|
+
*
|
|
4
|
+
* A passive check (an assert, made after acting rather than declared before it) that came back `no`
|
|
5
|
+
* is superseded when the SAME claim holds later in the same run. Driven over MCP: the Harness
|
|
6
|
+
* asserted the text Generate produces before its POST answered, read `no`, and a working journey
|
|
7
|
+
* was failed while the same assert held a second later.
|
|
8
|
+
*
|
|
9
|
+
* It lived in four places — the Harness's tally, the run's verdict, the synced run's flow status and
|
|
10
|
+
* the session's result block — each keyed differently and one not at all, so one end-of-session
|
|
11
|
+
* answer could carry `claim: pass` beside "Reticle result: failed". Every fold calls this instead.
|
|
12
|
+
*
|
|
13
|
+
* A DECLARED check that failed is never excused: a first click that did nothing is a finding even if
|
|
14
|
+
* a second one works. A `no` AFTER a `yes` on the same claim is never excused either: that is a
|
|
15
|
+
* regression inside the run.
|
|
16
|
+
*/
|
|
17
|
+
/** One check, as a fold reads it. */
|
|
18
|
+
export interface CheckReading {
|
|
19
|
+
/** The claim: two readings with the same key are the same claim. */
|
|
20
|
+
readonly key: string;
|
|
21
|
+
/** Made after acting (an assert), rather than declared before the action it judges. */
|
|
22
|
+
readonly passive: boolean;
|
|
23
|
+
/** Came back `yes`. */
|
|
24
|
+
readonly held: boolean;
|
|
25
|
+
/** Came back `no`. Neither is undecided. */
|
|
26
|
+
readonly failed: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** The indexes, into `readings`, of the passive `no`s a later `yes` of the same claim supersedes. */
|
|
29
|
+
export declare function supersededChecks(readings: readonly CheckReading[]): ReadonlySet<number>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which checks read too early: the ONE rule every fold of a run's checks applies.
|
|
3
|
+
*
|
|
4
|
+
* A passive check (an assert, made after acting rather than declared before it) that came back `no`
|
|
5
|
+
* is superseded when the SAME claim holds later in the same run. Driven over MCP: the Harness
|
|
6
|
+
* asserted the text Generate produces before its POST answered, read `no`, and a working journey
|
|
7
|
+
* was failed while the same assert held a second later.
|
|
8
|
+
*
|
|
9
|
+
* It lived in four places — the Harness's tally, the run's verdict, the synced run's flow status and
|
|
10
|
+
* the session's result block — each keyed differently and one not at all, so one end-of-session
|
|
11
|
+
* answer could carry `claim: pass` beside "Reticle result: failed". Every fold calls this instead.
|
|
12
|
+
*
|
|
13
|
+
* A DECLARED check that failed is never excused: a first click that did nothing is a finding even if
|
|
14
|
+
* a second one works. A `no` AFTER a `yes` on the same claim is never excused either: that is a
|
|
15
|
+
* regression inside the run.
|
|
16
|
+
*/
|
|
17
|
+
/** The indexes, into `readings`, of the passive `no`s a later `yes` of the same claim supersedes. */
|
|
18
|
+
export function supersededChecks(readings) {
|
|
19
|
+
const superseded = new Set();
|
|
20
|
+
for (const [at, reading] of readings.entries()) {
|
|
21
|
+
if (!reading.passive || !reading.failed)
|
|
22
|
+
continue;
|
|
23
|
+
const heldLater = readings
|
|
24
|
+
.slice(at + 1)
|
|
25
|
+
.some((later) => later.key === reading.key && later.held);
|
|
26
|
+
if (heldLater)
|
|
27
|
+
superseded.add(at);
|
|
28
|
+
}
|
|
29
|
+
return superseded;
|
|
30
|
+
}
|
|
@@ -36,10 +36,12 @@ export function describeWaitTarget(predicate) {
|
|
|
36
36
|
return `a route change${predicate.pathname === undefined ? '' : ` to '${predicate.pathname}'`}${predicate.contains === undefined ? '' : ` containing '${predicate.contains}'`}`;
|
|
37
37
|
case PredicateKind.STATE:
|
|
38
38
|
return `state at '${predicate.path}'`;
|
|
39
|
+
// Every part that decides the claim stays in it: the label is the check's title downstream, and
|
|
40
|
+
// one that dropped `ignoreCase` or the wanted state read as a different check from its own result.
|
|
39
41
|
case PredicateKind.TEXT:
|
|
40
|
-
return `text containing '${predicate.contains}'`;
|
|
42
|
+
return `text containing '${predicate.contains}'${true === predicate.ignoreCase ? ', ignoring case' : ''}`;
|
|
41
43
|
case PredicateKind.ELEMENT:
|
|
42
|
-
return `an element matching ${JSON.stringify(predicate.query)}`;
|
|
44
|
+
return `an element matching ${JSON.stringify(predicate.query)}${predicate.state === undefined ? '' : ` in state '${predicate.state}'`}`;
|
|
43
45
|
case PredicateKind.CONSOLE:
|
|
44
46
|
return 'a console message';
|
|
45
47
|
case PredicateKind.ANIMATION:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChannelId, Verified, VerifiedReason } from '@reticlehq/core';
|
|
2
2
|
import { type HonestyBlock } from './honesty.js';
|
|
3
3
|
import { type UnsettledWindow } from './unsettled.js';
|
|
4
4
|
interface VerifiedInputs {
|
|
@@ -163,5 +163,10 @@ interface VerifiedVerdict {
|
|
|
163
163
|
/** One sentence naming the deciding evidence — never a restatement of the field. */
|
|
164
164
|
because: string;
|
|
165
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* The sentence a vacuous-grade `unknown` carries. Exported because it is the CALLER's unknown — it
|
|
168
|
+
* asserted nothing real — and the feedback invite has to tell it from "Reticle could not tell".
|
|
169
|
+
*/
|
|
170
|
+
export declare const VACUOUS_BECAUSE = "nothing was asserted at a real grade, so passing proves nothing \u2014 assert a signal, request, or state path";
|
|
166
171
|
export declare function decideVerified(inputs: VerifiedInputs): VerifiedVerdict;
|
|
167
172
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { bodyCaptureRemedy } from './body-capture-remedy.js';
|
|
2
|
-
import { ContradictionKind, MUTATING_METHODS, Verified, VerifiedReason, isAbsenceDerived, isAdvisory, } from '@reticlehq/core';
|
|
2
|
+
import { ChannelId, ContradictionKind, MUTATING_METHODS, Verified, VerifiedReason, isAbsenceDerived, isAdvisory, } from '@reticlehq/core';
|
|
3
3
|
import { HonestyGrade } from './honesty.js';
|
|
4
4
|
import { unsettledBecause } from './unsettled.js';
|
|
5
5
|
import { pageTornDownWhileOn } from './page-teardown.js';
|
|
@@ -29,6 +29,13 @@ function undeclaredChannels(inputs) {
|
|
|
29
29
|
const needed = inputs.channelsRead ?? [];
|
|
30
30
|
return needed.filter((channel) => !observable.includes(channel));
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* The sentence a vacuous-grade `unknown` carries. Exported because it is the CALLER's unknown — it
|
|
34
|
+
* asserted nothing real — and the feedback invite has to tell it from "Reticle could not tell".
|
|
35
|
+
*/
|
|
36
|
+
export const VACUOUS_BECAUSE = 'nothing was asserted at a real grade, so passing proves nothing — assert a signal, request, or state path';
|
|
37
|
+
/** A `"POST /api/x"` label: is it a write? */
|
|
38
|
+
const isWriteLabel = (label) => MUTATING_METHODS.includes((label.split(' ')[0] ?? '').toUpperCase());
|
|
32
39
|
export function decideVerified(inputs) {
|
|
33
40
|
const { pass, honesty, contradictions = [], settled, outcomePending, outcomeUnread } = inputs;
|
|
34
41
|
// Ahead of everything, with `capability-absent` below it and for the same reason: a skewed wire
|
|
@@ -123,6 +130,27 @@ export function decideVerified(inputs) {
|
|
|
123
130
|
'consequence was not disproved — it had not finished', inputs.unsettled),
|
|
124
131
|
};
|
|
125
132
|
}
|
|
133
|
+
// The same rule, for a claim that does not NAME the request. Driven over MCP: the Harness asserted
|
|
134
|
+
// "Generated script for" the moment Generate was pressed, while the POST that produces that text
|
|
135
|
+
// was still open; `no` failed the journey, and the same assert held a second later. A write that
|
|
136
|
+
// has not answered is an outcome not in yet, whatever the claim is about. It only ever turns a
|
|
137
|
+
// `no` into `unknown`, never into a `yes`.
|
|
138
|
+
//
|
|
139
|
+
// A claim about the network keeps the named-request rule above: its request not firing while an
|
|
140
|
+
// UNRELATED write is open is a real miss. Only a claim that reads the page waits on the write.
|
|
141
|
+
const readsThePageOnly = inputs.channelsRead !== undefined &&
|
|
142
|
+
0 < inputs.channelsRead.length &&
|
|
143
|
+
!inputs.channelsRead.includes(ChannelId.NET);
|
|
144
|
+
if (false === pass &&
|
|
145
|
+
readsThePageOnly &&
|
|
146
|
+
(inputs.unsettled?.stillInFlight ?? []).some(isWriteLabel)) {
|
|
147
|
+
return {
|
|
148
|
+
verified: Verified.UNKNOWN,
|
|
149
|
+
verifiedReason: VerifiedReason.WINDOW_CLOSED_EARLY,
|
|
150
|
+
because: unsettledBecause('a write this window started had not answered when the claim was read, so the ' +
|
|
151
|
+
'consequence was not disproved — it had not arrived yet', inputs.unsettled),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
126
154
|
// ABOVE the failure clause, and for the same reason `observationLost` is: a consequence that has
|
|
127
155
|
// not happened YET has not failed. `202 Accepted` is the only word HTTP has for "the outcome does
|
|
128
156
|
// not exist yet", and a not-yet-reconciled write is indistinguishable from a broken one at the
|
|
@@ -198,7 +226,7 @@ export function decideVerified(inputs) {
|
|
|
198
226
|
// catch, and its outcome genuinely does not exist yet. A poll or a prefetch left hanging says
|
|
199
227
|
// nothing about the action; an unfinished mutation says the answer is not in yet. Read off the
|
|
200
228
|
// labels the window already carries — and when there are no labels to read, nothing is softened.
|
|
201
|
-
const openWrite = (inputs.unsettled?.stillInFlight ?? []).some(
|
|
229
|
+
const openWrite = (inputs.unsettled?.stillInFlight ?? []).some(isWriteLabel);
|
|
202
230
|
const settlementOnly = declaredHeld &&
|
|
203
231
|
inputs.unsettled !== undefined &&
|
|
204
232
|
!openWrite &&
|
|
@@ -293,7 +321,7 @@ export function decideVerified(inputs) {
|
|
|
293
321
|
verifiedReason: VerifiedReason.ALREADY_TRUE,
|
|
294
322
|
because: 'the declared consequence was already true before this action, so it proves nothing about it — assert something the action CHANGES (a signal, a request, a route, or store state)' +
|
|
295
323
|
(true === inputs.alreadyTrueHiddenMatch
|
|
296
|
-
? '. That prior match was against a HIDDEN element — this predicate checks DOM presence, not visibility, by default; add `visible: true` if you meant "this is showing", not merely "this exists"'
|
|
324
|
+
? '. That prior match was against a HIDDEN element — this predicate checks DOM presence, not visibility, by default; add `visible: true` to a text check, or `state: "visible"` to an element check, if you meant "this is showing", not merely "this exists"'
|
|
297
325
|
: ''),
|
|
298
326
|
};
|
|
299
327
|
}
|
|
@@ -354,7 +382,7 @@ export function decideVerified(inputs) {
|
|
|
354
382
|
return {
|
|
355
383
|
verified: Verified.UNKNOWN,
|
|
356
384
|
verifiedReason: VerifiedReason.VACUOUS_GRADE,
|
|
357
|
-
because:
|
|
385
|
+
because: VACUOUS_BECAUSE,
|
|
358
386
|
};
|
|
359
387
|
}
|
|
360
388
|
// A write answered 2xx and its payload went unread, so the one channel that could contradict the
|
|
@@ -24,6 +24,11 @@ export interface DeclaredNetFailure {
|
|
|
24
24
|
urlContains?: string;
|
|
25
25
|
status?: number;
|
|
26
26
|
}
|
|
27
|
+
/** A `net { repeatable: true }` clause: the endpoint it declared a read, and its method if named. */
|
|
28
|
+
export interface DeclaredRead {
|
|
29
|
+
urlContains: string;
|
|
30
|
+
method?: string;
|
|
31
|
+
}
|
|
27
32
|
interface DeclaredExpectations {
|
|
28
33
|
/** Requests the caller declared would FAIL, so failing is the expected outcome, not a disagreement. */
|
|
29
34
|
netFailures: readonly DeclaredNetFailure[];
|
|
@@ -40,6 +45,11 @@ interface DeclaredExpectations {
|
|
|
40
45
|
* is why an empty-string entry is meaningful and is preserved rather than skipped.
|
|
41
46
|
*/
|
|
42
47
|
netUrls: readonly string[];
|
|
48
|
+
/**
|
|
49
|
+
* The net clauses that said `repeatable: true`: reads, not writes (#1353). One with no
|
|
50
|
+
* `urlContains` is never here: the schema refuses it, and it would excuse every request.
|
|
51
|
+
*/
|
|
52
|
+
repeatableNetUrls: readonly DeclaredRead[];
|
|
43
53
|
}
|
|
44
54
|
export declare function declaredExpectations(predicate: Predicate | undefined): DeclaredExpectations;
|
|
45
55
|
/**
|
|
@@ -71,4 +81,14 @@ export declare function matchesDeclaredFailure(call: {
|
|
|
71
81
|
matchUrl?: string;
|
|
72
82
|
status: number | undefined;
|
|
73
83
|
}, declared: readonly DeclaredNetFailure[]): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Was this call declared a read? Same matching as `matchesDeclaredFailure`: the URL must contain
|
|
86
|
+
* the clause's `urlContains`, and a method the clause named must agree, so a repeatable GET never
|
|
87
|
+
* excuses a POST to the same endpoint (#1353).
|
|
88
|
+
*/
|
|
89
|
+
export declare function isDeclaredRead(call: {
|
|
90
|
+
method: string;
|
|
91
|
+
url: string;
|
|
92
|
+
matchUrl?: string;
|
|
93
|
+
}, reads: readonly DeclaredRead[] | undefined): boolean;
|
|
74
94
|
export {};
|
|
@@ -68,6 +68,7 @@ function pushAuthDenialStatuses(into) {
|
|
|
68
68
|
export function declaredExpectations(predicate) {
|
|
69
69
|
const netFailures = [];
|
|
70
70
|
const netUrls = [];
|
|
71
|
+
const repeatableNetUrls = [];
|
|
71
72
|
let rendersContent = false;
|
|
72
73
|
const walk = (p) => {
|
|
73
74
|
switch (p.kind) {
|
|
@@ -81,6 +82,12 @@ export function declaredExpectations(predicate) {
|
|
|
81
82
|
return;
|
|
82
83
|
case PredicateKind.NET: {
|
|
83
84
|
netUrls.push(p.urlContains ?? '');
|
|
85
|
+
if (true === p.repeatable && p.urlContains !== undefined && p.urlContains.trim() !== '') {
|
|
86
|
+
repeatableNetUrls.push({
|
|
87
|
+
urlContains: p.urlContains,
|
|
88
|
+
...(p.method === undefined ? {} : { method: p.method }),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
84
91
|
const declaredFailure = false === p.ok || (p.status !== undefined && p.status >= FAILURE_STATUS_MIN);
|
|
85
92
|
if (!declaredFailure)
|
|
86
93
|
return;
|
|
@@ -112,7 +119,7 @@ export function declaredExpectations(predicate) {
|
|
|
112
119
|
};
|
|
113
120
|
if (predicate !== undefined)
|
|
114
121
|
walk(predicate);
|
|
115
|
-
return { netFailures, rendersContent, netUrls };
|
|
122
|
+
return { netFailures, rendersContent, netUrls, repeatableNetUrls };
|
|
116
123
|
}
|
|
117
124
|
/**
|
|
118
125
|
* Did the caller name a consequence that does not depend on the response body?
|
|
@@ -180,3 +187,15 @@ export function matchesDeclaredFailure(call, declared) {
|
|
|
180
187
|
return true;
|
|
181
188
|
});
|
|
182
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Was this call declared a read? Same matching as `matchesDeclaredFailure`: the URL must contain
|
|
192
|
+
* the clause's `urlContains`, and a method the clause named must agree, so a repeatable GET never
|
|
193
|
+
* excuses a POST to the same endpoint (#1353).
|
|
194
|
+
*/
|
|
195
|
+
export function isDeclaredRead(call, reads) {
|
|
196
|
+
if (reads === undefined)
|
|
197
|
+
return false;
|
|
198
|
+
const haystack = call.matchUrl ?? call.url;
|
|
199
|
+
return reads.some((r) => haystack.includes(r.urlContains) &&
|
|
200
|
+
(r.method === undefined || r.method.toUpperCase() === call.method.toUpperCase()));
|
|
201
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the `net` channel cannot see, and what a miss over it is allowed to claim.
|
|
3
|
+
*
|
|
4
|
+
* The network observer patches `fetch` and `XMLHttpRequest`; a document-initiated subresource, a
|
|
5
|
+
* native download and anything before the SDK attached never reach it. Each rule here exists so a
|
|
6
|
+
* zero-match `net` verdict says "not observable" or names its blind stretch, instead of "never
|
|
7
|
+
* happened". Split from `predicate-eval.ts`, which decides the verdict; this only knows the channel.
|
|
8
|
+
*
|
|
9
|
+
* Takes the filter's parts rather than the predicate, so it needs nothing from the contract.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Does this filter target a class of request the observer cannot see?
|
|
13
|
+
*
|
|
14
|
+
* Read off `urlContains` only, and only when the pattern ENDS in one of the suffixes — a filter of
|
|
15
|
+
* `/api/` that happens to contain `.css` somewhere in a query string is still an ordinary XHR
|
|
16
|
+
* target. Query strings and fragments are stripped first, since `favicon.ico?v=2` is the same asset.
|
|
17
|
+
*/
|
|
18
|
+
export declare function targetsUnobservedChannel(url: string | undefined): boolean;
|
|
19
|
+
export declare function targetsNativeDownload(url: string | undefined): boolean;
|
|
20
|
+
/** `filter` is the net clause as applied — `describeNetFilter` of it. */
|
|
21
|
+
export declare function nativeDownloadReason(filter: string): string;
|
|
22
|
+
/** The sentence both zero-match branches hand to `inconclusive`; `filter` as `nativeDownloadReason`. */
|
|
23
|
+
export declare function unobservedChannelReason(filter: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Appended to a zero-match `net` negative whose window starts at SDK attach.
|
|
26
|
+
*
|
|
27
|
+
* Every event's `t` is stamped `performance.now() - #start`, where `#start` is taken when the SDK
|
|
28
|
+
* is constructed, so `t` is never negative and a window with `since === 0` begins AT attach — never
|
|
29
|
+
* before it. Whatever the page did between navigation start and attach left no event at all, so
|
|
30
|
+
* "no matching call" over such a window cannot be told apart from "the call was made while nothing
|
|
31
|
+
* was watching yet".
|
|
32
|
+
*
|
|
33
|
+
* The gap is routine rather than exotic: a `fetch` from an effect in a root provider, or a classic
|
|
34
|
+
* `<script>` at the end of `<body>`, fires before a deferred module script has run. Read as proof
|
|
35
|
+
* the request was never made, that sends a reader looking for a defect in code that works —
|
|
36
|
+
* restarting dev servers and re-reading providers to establish that the request was invisible rather
|
|
37
|
+
* than absent.
|
|
38
|
+
*
|
|
39
|
+
* Same argument as DOCUMENT_ONLY_SUFFIXES one axis over: that one is a channel Reticle does not
|
|
40
|
+
* watch, this is a stretch of TIME it was not yet watching.
|
|
41
|
+
*
|
|
42
|
+
* The grade is deliberately NOT downgraded to `inconclusive`. A missing API call is the finding this
|
|
43
|
+
* oracle exists to make, and it is the strongest grade available for the startup class — session
|
|
44
|
+
* restore, feature flags, bootstrap config — which is exactly the class that silently breaks on
|
|
45
|
+
* reload. Every window an action opens carries `since > 0` and is untouched. What changes is only
|
|
46
|
+
* what the negative CLAIMS: it stops asserting the request never happened, and names the assertion
|
|
47
|
+
* that can settle it, because the state such a request produces IS observable after attach.
|
|
48
|
+
*/
|
|
49
|
+
export declare const PRE_ATTACH_CAVEAT: string;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the `net` channel cannot see, and what a miss over it is allowed to claim.
|
|
3
|
+
*
|
|
4
|
+
* The network observer patches `fetch` and `XMLHttpRequest`; a document-initiated subresource, a
|
|
5
|
+
* native download and anything before the SDK attached never reach it. Each rule here exists so a
|
|
6
|
+
* zero-match `net` verdict says "not observable" or names its blind stretch, instead of "never
|
|
7
|
+
* happened". Split from `predicate-eval.ts`, which decides the verdict; this only knows the channel.
|
|
8
|
+
*
|
|
9
|
+
* Takes the filter's parts rather than the predicate, so it needs nothing from the contract.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* URL suffixes only the DOCUMENT fetches, which the network observer therefore never records.
|
|
13
|
+
*
|
|
14
|
+
* `network.ts` patches `fetch` and `XMLHttpRequest` and nothing else, so `<link rel=icon>`,
|
|
15
|
+
* `<link rel=manifest>`, stylesheets, fonts and `<img src>` are invisible to it. "No matching call"
|
|
16
|
+
* and "that class of call is not observed" are then indistinguishable, and the miss graded
|
|
17
|
+
* `assertion_failed` — a false RED. Reported from the field: an assert over `/favicon.ico`,
|
|
18
|
+
* `/site.webmanifest` and `/apple-touch-icon.png` returned `verified:"no"` while curl showed all
|
|
19
|
+
* three answering 200. A false negative here is worse than an unknown, because an agent that trusts
|
|
20
|
+
* it goes and "fixes" working code.
|
|
21
|
+
*
|
|
22
|
+
* Deliberately NOT here: `.js` and `.json`. Both are routinely fetched via `fetch`/XHR — a module
|
|
23
|
+
* preload and an API call can share a suffix — so downgrading them would hide real misses. This list
|
|
24
|
+
* is only the suffixes for which the document is the sole plausible initiator.
|
|
25
|
+
*
|
|
26
|
+
* This began as the smaller half of #447: it did not make these requests observable, it stopped
|
|
27
|
+
* Reticle claiming they did not happen. The other half, observing them via resource timing, has
|
|
28
|
+
* since landed in the browser SDK, so the two halves are no longer independent and this downgrade is
|
|
29
|
+
* now GATED: when the event stream carries at least one document-initiated record, the observer is
|
|
30
|
+
* demonstrably live and a miss over these suffixes is real evidence, graded a plain failure. Only a
|
|
31
|
+
* page whose stream holds no resource entry at all keeps the honest "cannot tell apart" answer,
|
|
32
|
+
* because there the observer may simply not exist.
|
|
33
|
+
*/
|
|
34
|
+
const DOCUMENT_ONLY_SUFFIXES = [
|
|
35
|
+
'.ico',
|
|
36
|
+
'.png',
|
|
37
|
+
'.jpg',
|
|
38
|
+
'.jpeg',
|
|
39
|
+
'.gif',
|
|
40
|
+
'.svg',
|
|
41
|
+
'.webp',
|
|
42
|
+
'.avif',
|
|
43
|
+
'.bmp',
|
|
44
|
+
'.css',
|
|
45
|
+
'.woff',
|
|
46
|
+
'.woff2',
|
|
47
|
+
'.ttf',
|
|
48
|
+
'.otf',
|
|
49
|
+
'.eot',
|
|
50
|
+
'.webmanifest',
|
|
51
|
+
];
|
|
52
|
+
/**
|
|
53
|
+
* File suffixes a click typically downloads or navigates to as a document, never as fetch/XHR.
|
|
54
|
+
*
|
|
55
|
+
* Sibling of DOCUMENT_ONLY_SUFFIXES, not a member of it. Those are subresources: once resource
|
|
56
|
+
* timing is live, a miss is evidence. A click on `<a href="/export.pdf">` is a navigation (or a
|
|
57
|
+
* Content-Disposition attachment). Resource timing of stylesheets does not make it visible, so
|
|
58
|
+
* grading the miss as "0 network calls" / a 404 is the lie #805 exists to stop — even on a page
|
|
59
|
+
* whose observer is running. `.js` / `.json` stay off this list for the same reason they stay off
|
|
60
|
+
* the other: they are routinely fetched.
|
|
61
|
+
*/
|
|
62
|
+
const NATIVE_DOWNLOAD_SUFFIXES = [
|
|
63
|
+
'.pdf',
|
|
64
|
+
'.csv',
|
|
65
|
+
'.tsv',
|
|
66
|
+
'.zip',
|
|
67
|
+
'.gz',
|
|
68
|
+
'.tar',
|
|
69
|
+
'.xlsx',
|
|
70
|
+
'.xls',
|
|
71
|
+
'.docx',
|
|
72
|
+
'.doc',
|
|
73
|
+
'.pptx',
|
|
74
|
+
'.ppt',
|
|
75
|
+
'.ods',
|
|
76
|
+
'.odt',
|
|
77
|
+
'.rtf',
|
|
78
|
+
'.7z',
|
|
79
|
+
'.rar',
|
|
80
|
+
];
|
|
81
|
+
/**
|
|
82
|
+
* Does this filter target a class of request the observer cannot see?
|
|
83
|
+
*
|
|
84
|
+
* Read off `urlContains` only, and only when the pattern ENDS in one of the suffixes — a filter of
|
|
85
|
+
* `/api/` that happens to contain `.css` somewhere in a query string is still an ordinary XHR
|
|
86
|
+
* target. Query strings and fragments are stripped first, since `favicon.ico?v=2` is the same asset.
|
|
87
|
+
*/
|
|
88
|
+
function filterPath(urlContains) {
|
|
89
|
+
return (urlContains.split('#')[0] ?? '').split('?')[0]?.toLowerCase() ?? '';
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Does this filter target a class of request the observer cannot see?
|
|
93
|
+
*
|
|
94
|
+
* Read off `urlContains` only, and only when the pattern ENDS in one of the suffixes — a filter of
|
|
95
|
+
* `/api/` that happens to contain `.css` somewhere in a query string is still an ordinary XHR
|
|
96
|
+
* target. Query strings and fragments are stripped first, since `favicon.ico?v=2` is the same asset.
|
|
97
|
+
*/
|
|
98
|
+
export function targetsUnobservedChannel(url) {
|
|
99
|
+
if (undefined === url)
|
|
100
|
+
return false;
|
|
101
|
+
return DOCUMENT_ONLY_SUFFIXES.some((suffix) => filterPath(url).endsWith(suffix));
|
|
102
|
+
}
|
|
103
|
+
export function targetsNativeDownload(url) {
|
|
104
|
+
if (undefined === url)
|
|
105
|
+
return false;
|
|
106
|
+
return NATIVE_DOWNLOAD_SUFFIXES.some((suffix) => filterPath(url).endsWith(suffix));
|
|
107
|
+
}
|
|
108
|
+
/** `filter` is the net clause as applied — `describeNetFilter` of it. */
|
|
109
|
+
export function nativeDownloadReason(filter) {
|
|
110
|
+
return (`no fetch or XHR matched ${filter}. A native download or document navigation ` +
|
|
111
|
+
`(an <a href> to a file, a Content-Disposition attachment, <a download>) never goes through ` +
|
|
112
|
+
`fetch or XMLHttpRequest, so an empty net window is not a 404 and is not evidence the export ` +
|
|
113
|
+
`failed. This is unobservable on the net channel. Assert the link href, or check the file ` +
|
|
114
|
+
`outside the browser — Reticle cannot see the bytes land`);
|
|
115
|
+
}
|
|
116
|
+
/** The sentence both zero-match branches hand to `inconclusive`; `filter` as `nativeDownloadReason`. */
|
|
117
|
+
export function unobservedChannelReason(filter) {
|
|
118
|
+
return (`no call matched ${filter}, and no document-initiated load was recorded either, ` +
|
|
119
|
+
`so this page exposed no resource timing to read: Reticle observes fetch and XMLHttpRequest ` +
|
|
120
|
+
`directly, while a request the document initiates (<link rel=icon|manifest|preload>, a ` +
|
|
121
|
+
`stylesheet, a font, <img src>) leaves no record, and that state cannot be told apart from the ` +
|
|
122
|
+
`request having been made. ` +
|
|
123
|
+
`Nothing here says the app is wrong. Check it outside the browser, or assert something the ` +
|
|
124
|
+
`document does not fetch on its own`);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Appended to a zero-match `net` negative whose window starts at SDK attach.
|
|
128
|
+
*
|
|
129
|
+
* Every event's `t` is stamped `performance.now() - #start`, where `#start` is taken when the SDK
|
|
130
|
+
* is constructed, so `t` is never negative and a window with `since === 0` begins AT attach — never
|
|
131
|
+
* before it. Whatever the page did between navigation start and attach left no event at all, so
|
|
132
|
+
* "no matching call" over such a window cannot be told apart from "the call was made while nothing
|
|
133
|
+
* was watching yet".
|
|
134
|
+
*
|
|
135
|
+
* The gap is routine rather than exotic: a `fetch` from an effect in a root provider, or a classic
|
|
136
|
+
* `<script>` at the end of `<body>`, fires before a deferred module script has run. Read as proof
|
|
137
|
+
* the request was never made, that sends a reader looking for a defect in code that works —
|
|
138
|
+
* restarting dev servers and re-reading providers to establish that the request was invisible rather
|
|
139
|
+
* than absent.
|
|
140
|
+
*
|
|
141
|
+
* Same argument as DOCUMENT_ONLY_SUFFIXES one axis over: that one is a channel Reticle does not
|
|
142
|
+
* watch, this is a stretch of TIME it was not yet watching.
|
|
143
|
+
*
|
|
144
|
+
* The grade is deliberately NOT downgraded to `inconclusive`. A missing API call is the finding this
|
|
145
|
+
* oracle exists to make, and it is the strongest grade available for the startup class — session
|
|
146
|
+
* restore, feature flags, bootstrap config — which is exactly the class that silently breaks on
|
|
147
|
+
* reload. Every window an action opens carries `since > 0` and is untouched. What changes is only
|
|
148
|
+
* what the negative CLAIMS: it stops asserting the request never happened, and names the assertion
|
|
149
|
+
* that can settle it, because the state such a request produces IS observable after attach.
|
|
150
|
+
*/
|
|
151
|
+
export const PRE_ATTACH_CAVEAT = ' — note that this window starts where the SDK attached, and requests made before that are never ' +
|
|
152
|
+
'captured, so a miss here cannot tell a call that was never made apart from one made before the ' +
|
|
153
|
+
'page connected; if the call is expected during startup, assert on the state it produces instead';
|
|
@@ -14,3 +14,17 @@ export declare function evalElement(session: PredicateSession, query: ElementQue
|
|
|
14
14
|
/** The text of every element a passing match described, joined — what a reader sees there. */
|
|
15
15
|
export declare function joinedText(evidence: unknown): string;
|
|
16
16
|
export declare function withTextProperty(base: EvalResult, assertion: PropertyAssertion, subject: string, baseline?: Baseline): EvalResult;
|
|
17
|
+
/**
|
|
18
|
+
* The element query a text predicate is evaluated through — one builder for the verdict and its
|
|
19
|
+
* baseline, so the two cannot disagree about what text was asked for.
|
|
20
|
+
*
|
|
21
|
+
* `matchCase` unless the predicate opts out: a check that matched "Saved Priya" against "Saved
|
|
22
|
+
* priya" could never catch a capitalisation defect. An undefined `contains` must not reach the query
|
|
23
|
+
* as `text: undefined` — that is a locator asking for the empty string.
|
|
24
|
+
*/
|
|
25
|
+
export declare function textPredicateQuery(predicate: {
|
|
26
|
+
contains?: string | undefined;
|
|
27
|
+
ignoreCase?: boolean | undefined;
|
|
28
|
+
scope?: string | undefined;
|
|
29
|
+
self?: boolean | undefined;
|
|
30
|
+
}): ElementQuery;
|