@reticlehq/engine 3.6.0 → 3.8.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 +134 -2
- package/dist/disagreement/contradiction-evidence.js +291 -3
- package/dist/disagreement/contradiction-types.d.ts +16 -1
- package/dist/disagreement/contradictions.d.ts +12 -0
- package/dist/disagreement/contradictions.js +56 -84
- package/dist/disagreement/stale-response.js +56 -17
- 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/body-capture-remedy.d.ts +1 -15
- package/dist/evidence/body-capture-remedy.js +6 -1
- 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/step-effect.d.ts +20 -1
- package/dist/evidence/step-effect.js +30 -2
- package/dist/evidence/superseded-checks.d.ts +29 -0
- package/dist/evidence/superseded-checks.js +30 -0
- package/dist/evidence/uncaptured-bodies.d.ts +18 -1
- package/dist/evidence/uncaptured-bodies.js +22 -1
- package/dist/evidence/unread-outcome.d.ts +7 -0
- package/dist/evidence/unread-outcome.js +22 -0
- package/dist/evidence/unsettled.js +29 -2
- package/dist/evidence/verified.d.ts +8 -1
- package/dist/evidence/verified.js +33 -5
- 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-compare.js +7 -1
- package/dist/question/predicate/predicate-console.js +23 -10
- package/dist/question/predicate/predicate-element.d.ts +23 -0
- package/dist/question/predicate/predicate-element.js +208 -16
- package/dist/question/predicate/predicate-eval-kit.d.ts +28 -3
- package/dist/question/predicate/predicate-eval-kit.js +34 -7
- package/dist/question/predicate/predicate-eval.d.ts +11 -1
- package/dist/question/predicate/predicate-eval.js +138 -177
- package/dist/question/predicate/predicate-parse.js +34 -0
- package/dist/question/predicate/predicate-request-body.d.ts +15 -1
- package/dist/question/predicate/predicate-request-body.js +23 -3
- 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 +58 -18
- package/dist/question/predicate/split-text-miss.d.ts +7 -0
- package/dist/question/predicate/split-text-miss.js +18 -1
- package/dist/state-bookkeeping.d.ts +27 -0
- package/dist/state-bookkeeping.js +74 -0
- package/dist/window/adversary.js +5 -1
- package/package.json +2 -2
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What to tell a caller whose assertion needs response bodies, given what the connected SDK can do.
|
|
3
|
-
*
|
|
4
|
-
* The remedy used to be one fixed sentence naming `captureNetworkBodies`. Reported from the field:
|
|
5
|
-
* six verdicts came back `unknown`/`outcome_unread` advising that setting against a pinned
|
|
6
|
-
* `@reticlehq/react` from before it existed. The reporter set the env var, restarted, got the
|
|
7
|
-
* identical message, and worked it out by elimination.
|
|
8
|
-
*
|
|
9
|
-
* The daemon is TOLD the page's SDK version at HELLO and threw it away after computing skew. Nothing
|
|
10
|
-
* new has to be observed to say the true thing — it only has to be kept.
|
|
11
|
-
*
|
|
12
|
-
* Same class as the version-skew remedy that named a React package on Vue projects: remedy text that
|
|
13
|
-
* does not check whether it applies. A wrong remedy is worse than none, because it is followed.
|
|
14
|
-
*/
|
|
15
1
|
/** The earliest SDK release whose observer can capture network bodies at all. */
|
|
16
2
|
export declare const BODY_CAPTURE_MIN_VERSION = "2.4.0";
|
|
17
3
|
/**
|
|
@@ -21,7 +7,7 @@ export declare const BODY_CAPTURE_MIN_VERSION = "2.4.0";
|
|
|
21
7
|
* old" there would hide a working fix from someone who could have used it; the opposite guess costs
|
|
22
8
|
* one wasted read. The asymmetry decides it.
|
|
23
9
|
*/
|
|
24
|
-
export declare function bodyCaptureRemedy(sdkVersion: string | undefined): string;
|
|
10
|
+
export declare function bodyCaptureRemedy(sdkVersion: string | undefined, skipReason?: unknown): string;
|
|
25
11
|
/**
|
|
26
12
|
* The invariant opening of the refusal below, named so the error envelope can recognise it.
|
|
27
13
|
*
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* Same class as the version-skew remedy that named a React package on Vue projects: remedy text that
|
|
13
13
|
* does not check whether it applies. A wrong remedy is worse than none, because it is followed.
|
|
14
14
|
*/
|
|
15
|
+
import { skippedBodyRemedy } from '../question/predicate/predicate-eval.js';
|
|
15
16
|
/** The earliest SDK release whose observer can capture network bodies at all. */
|
|
16
17
|
export const BODY_CAPTURE_MIN_VERSION = '2.4.0';
|
|
17
18
|
/**
|
|
@@ -51,7 +52,11 @@ const ENABLE_IT = 'Turn it on where your app calls connect(): `reticle.connect({
|
|
|
51
52
|
* old" there would hide a working fix from someone who could have used it; the opposite guess costs
|
|
52
53
|
* one wasted read. The asymmetry decides it.
|
|
53
54
|
*/
|
|
54
|
-
export function bodyCaptureRemedy(sdkVersion) {
|
|
55
|
+
export function bodyCaptureRemedy(sdkVersion, skipReason) {
|
|
56
|
+
// Capture is ON and the SDK skipped this body on purpose: switching it on changes nothing (#1520).
|
|
57
|
+
const skipped = skippedBodyRemedy(skipReason);
|
|
58
|
+
if (skipped !== undefined)
|
|
59
|
+
return skipped;
|
|
55
60
|
if (sdkVersion !== undefined && !isAtLeast(sdkVersion, BODY_CAPTURE_MIN_VERSION)) {
|
|
56
61
|
return (`this page's SDK is ${sdkVersion}, and body capture needs ${BODY_CAPTURE_MIN_VERSION} or ` +
|
|
57
62
|
'newer — the setting does not exist in your version, so there is nothing to switch on. ' +
|
|
@@ -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
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* live path and the replay path share it instead of agreeing by coincidence.
|
|
12
12
|
*/
|
|
13
13
|
import type { Contradiction, ReactionDigest, ReticleEvent } from '@reticlehq/core';
|
|
14
|
+
import type { Predicate } from '../question/predicate/predicate-eval.js';
|
|
14
15
|
/** The cursor pair an observer can re-read this step's evidence with. */
|
|
15
16
|
export interface StepWindow {
|
|
16
17
|
since: number;
|
|
@@ -38,4 +39,22 @@ export interface StepEffect {
|
|
|
38
39
|
*/
|
|
39
40
|
contradictions?: Contradiction[];
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
/** The page origin and declared background, omitted when the caller cannot say. Absence fails open. */
|
|
43
|
+
export declare function appScope(session: {
|
|
44
|
+
url?: string;
|
|
45
|
+
background?: readonly string[];
|
|
46
|
+
}): {
|
|
47
|
+
appOrigin?: string;
|
|
48
|
+
background?: readonly string[];
|
|
49
|
+
};
|
|
50
|
+
export declare function stepEffect(events: readonly ReticleEvent[], window: StepWindow,
|
|
51
|
+
/** The page under test, so a third-party write is not graded as the app ignoring a response. */
|
|
52
|
+
scope?: {
|
|
53
|
+
appOrigin?: string;
|
|
54
|
+
background?: readonly string[];
|
|
55
|
+
/**
|
|
56
|
+
* What the step said it would cause. A failure it declared is not a contradiction, the same
|
|
57
|
+
* rule `act_and_wait` applies to its `until`. Omitted when the step declared nothing.
|
|
58
|
+
*/
|
|
59
|
+
declared?: readonly Predicate[];
|
|
60
|
+
}): StepEffect;
|
|
@@ -12,7 +12,17 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { buildReactionReport, summarizeReaction } from '../question/reaction.js';
|
|
14
14
|
import { findContradictions } from '../disagreement/contradictions.js';
|
|
15
|
-
|
|
15
|
+
import { declaredExpectations } from '../question/declared.js';
|
|
16
|
+
/** The page origin and declared background, omitted when the caller cannot say. Absence fails open. */
|
|
17
|
+
export function appScope(session) {
|
|
18
|
+
return {
|
|
19
|
+
...(session.url === undefined ? {} : { appOrigin: session.url }),
|
|
20
|
+
...(session.background === undefined ? {} : { background: session.background }),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function stepEffect(events, window,
|
|
24
|
+
/** The page under test, so a third-party write is not graded as the app ignoring a response. */
|
|
25
|
+
scope = {}) {
|
|
16
26
|
const effect = {};
|
|
17
27
|
if (window.until > window.since)
|
|
18
28
|
effect.window = { since: window.since, until: window.until };
|
|
@@ -20,8 +30,26 @@ export function stepEffect(events, window) {
|
|
|
20
30
|
// `actionSince` is what tells the detectors which window belongs to THIS action. Without it the
|
|
21
31
|
// headline rule cannot attribute a failed request to the click that moved the screen, and the
|
|
22
32
|
// whole family goes quiet while looking perfectly wired.
|
|
23
|
-
const contradictions = findContradictions(events, {
|
|
33
|
+
const contradictions = findContradictions(events, {
|
|
34
|
+
actionSince: window.since,
|
|
35
|
+
...(scope.appOrigin === undefined ? {} : { appOrigin: scope.appOrigin }),
|
|
36
|
+
...(scope.background === undefined ? {} : { background: scope.background }),
|
|
37
|
+
...declaredOptions(scope.declared),
|
|
38
|
+
});
|
|
24
39
|
if (contradictions.length > 0)
|
|
25
40
|
effect.contradictions = contradictions;
|
|
26
41
|
return effect;
|
|
27
42
|
}
|
|
43
|
+
/** The contradiction options a step's own expectations give, merged over every one it declared. */
|
|
44
|
+
function declaredOptions(declared) {
|
|
45
|
+
// Nothing declared names no traffic: an empty `namedNetUrls` would hide every duplicate request.
|
|
46
|
+
if (declared === undefined || 0 === declared.length) {
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
const each = declared.map(declaredExpectations);
|
|
50
|
+
return {
|
|
51
|
+
expectedFailures: each.flatMap((d) => d.netFailures),
|
|
52
|
+
namedNetUrls: each.flatMap((d) => d.netUrls),
|
|
53
|
+
repeatableNetUrls: each.flatMap((d) => d.repeatableNetUrls),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Does any of these events prove body capture is ON (#1520)?
|
|
3
|
+
*
|
|
4
|
+
* The SDK stamps a skip reason on a response body (a stream, a binary type, a failed read), or a
|
|
5
|
+
* `requestBodyType` on a request body it cannot stringify, only when capture is on. The
|
|
6
|
+
* `error-status` reason is the exception: it marks a body recorded with capture OFF, and it has no
|
|
7
|
+
* skip remedy, so it does not count here.
|
|
8
|
+
*/
|
|
9
|
+
export declare function captureProvedOn(events: readonly {
|
|
10
|
+
data: Record<string, unknown>;
|
|
11
|
+
}[]): boolean;
|
|
1
12
|
/**
|
|
2
13
|
* Say so when a payload exists but was not recorded.
|
|
3
14
|
*
|
|
@@ -18,6 +29,12 @@ export declare function bodiesNotCaptured(calls: {
|
|
|
18
29
|
responseBody?: string;
|
|
19
30
|
}[],
|
|
20
31
|
/** The page SDK's version, so the remedy can check whether it applies. See body-capture-remedy. */
|
|
21
|
-
sdkVersion?: string
|
|
32
|
+
sdkVersion?: string,
|
|
33
|
+
/**
|
|
34
|
+
* A call in the window carries a body-skip reason or a request body type, which the SDK stamps
|
|
35
|
+
* only with capture ON (#1520). Then the bodies are absent for that reason, not because nothing
|
|
36
|
+
* is recorded, and the note would say the opposite of the truth.
|
|
37
|
+
*/
|
|
38
|
+
captureProvedOn?: boolean): {
|
|
22
39
|
bodiesNotCaptured?: string;
|
|
23
40
|
};
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { bodyCaptureRemedy } from './body-capture-remedy.js';
|
|
2
|
+
import { skippedBodyRemedy } from '../question/predicate/predicate-eval.js';
|
|
3
|
+
/**
|
|
4
|
+
* Does any of these events prove body capture is ON (#1520)?
|
|
5
|
+
*
|
|
6
|
+
* The SDK stamps a skip reason on a response body (a stream, a binary type, a failed read), or a
|
|
7
|
+
* `requestBodyType` on a request body it cannot stringify, only when capture is on. The
|
|
8
|
+
* `error-status` reason is the exception: it marks a body recorded with capture OFF, and it has no
|
|
9
|
+
* skip remedy, so it does not count here.
|
|
10
|
+
*/
|
|
11
|
+
export function captureProvedOn(events) {
|
|
12
|
+
return events.some((e) => skippedBodyRemedy(e.data['responseBodyReason']) !== undefined ||
|
|
13
|
+
('string' === typeof e.data['requestBodyType'] && 0 < e.data['requestBodyType'].length));
|
|
14
|
+
}
|
|
2
15
|
/** Methods that normally carry a payload — the ones where a missing body is worth explaining. */
|
|
3
16
|
const BODY_BEARING_METHODS = new Set(['POST', 'PUT', 'PATCH']);
|
|
4
17
|
/**
|
|
@@ -17,7 +30,13 @@ const BODY_BEARING_METHODS = new Set(['POST', 'PUT', 'PATCH']);
|
|
|
17
30
|
*/
|
|
18
31
|
export function bodiesNotCaptured(calls,
|
|
19
32
|
/** The page SDK's version, so the remedy can check whether it applies. See body-capture-remedy. */
|
|
20
|
-
sdkVersion
|
|
33
|
+
sdkVersion,
|
|
34
|
+
/**
|
|
35
|
+
* A call in the window carries a body-skip reason or a request body type, which the SDK stamps
|
|
36
|
+
* only with capture ON (#1520). Then the bodies are absent for that reason, not because nothing
|
|
37
|
+
* is recorded, and the note would say the opposite of the truth.
|
|
38
|
+
*/
|
|
39
|
+
captureProvedOn = false) {
|
|
21
40
|
const bodyBearing = calls.filter((c) => BODY_BEARING_METHODS.has((c.method ?? '').toUpperCase()));
|
|
22
41
|
if (0 === bodyBearing.length)
|
|
23
42
|
return {};
|
|
@@ -27,6 +46,8 @@ sdkVersion) {
|
|
|
27
46
|
// result, exactly on the question the note exists to answer. (#394)
|
|
28
47
|
if (calls.some((c) => c.responseBody !== undefined))
|
|
29
48
|
return {};
|
|
49
|
+
if (captureProvedOn)
|
|
50
|
+
return {};
|
|
30
51
|
if (bodyBearing.some((c) => c.requestBody !== undefined))
|
|
31
52
|
return {};
|
|
32
53
|
return {
|
|
@@ -7,4 +7,11 @@ import { type ReticleEvent } from '@reticlehq/core';
|
|
|
7
7
|
* name no write, which is unactionable on any page that makes more than one call.
|
|
8
8
|
*/
|
|
9
9
|
export declare function unreadWriteLabels(events: readonly ReticleEvent[]): string[];
|
|
10
|
+
/**
|
|
11
|
+
* The reason the SDK stamped on every unread write in the window, when they all share one (#1520).
|
|
12
|
+
*
|
|
13
|
+
* Read beside `unreadWriteLabels`, with the same filter, so the remedy for an unread outcome can
|
|
14
|
+
* say "capture is on, this was a stream" instead of "enable capture".
|
|
15
|
+
*/
|
|
16
|
+
export declare function unreadWriteReason(events: readonly ReticleEvent[]): unknown;
|
|
10
17
|
export declare function hasUnreadWriteOutcome(events: readonly ReticleEvent[]): boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventType, MUTATING_METHODS, NetInitiator, isDevToolingUrl, } from '@reticlehq/core';
|
|
2
2
|
import { asString } from '@reticlehq/core';
|
|
3
|
+
import { sharedSkipReason } from '../question/predicate/predicate-eval.js';
|
|
3
4
|
const IPC_METHOD = NetInitiator.IPC.toUpperCase();
|
|
4
5
|
/**
|
|
5
6
|
* A write whose outcome is sitting in a payload nobody read.
|
|
@@ -72,6 +73,27 @@ export function unreadWriteLabels(events) {
|
|
|
72
73
|
}
|
|
73
74
|
return labels;
|
|
74
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The reason the SDK stamped on every unread write in the window, when they all share one (#1520).
|
|
78
|
+
*
|
|
79
|
+
* Read beside `unreadWriteLabels`, with the same filter, so the remedy for an unread outcome can
|
|
80
|
+
* say "capture is on, this was a stream" instead of "enable capture".
|
|
81
|
+
*/
|
|
82
|
+
export function unreadWriteReason(events) {
|
|
83
|
+
const labels = new Set(unreadWriteLabels(events));
|
|
84
|
+
if (0 === labels.size)
|
|
85
|
+
return undefined;
|
|
86
|
+
const reasons = [];
|
|
87
|
+
for (const event of events) {
|
|
88
|
+
if (event.type !== EventType.NET_REQUEST || event.data['responseBody'] !== undefined)
|
|
89
|
+
continue;
|
|
90
|
+
const method = ('string' === typeof event.data['method'] ? event.data['method'] : '').toUpperCase();
|
|
91
|
+
if (!labels.has(`${method} ${asString(event.data['url']) ?? ''}`.trim()))
|
|
92
|
+
continue;
|
|
93
|
+
reasons.push(event.data['responseBodyReason']);
|
|
94
|
+
}
|
|
95
|
+
return sharedSkipReason(reasons);
|
|
96
|
+
}
|
|
75
97
|
export function hasUnreadWriteOutcome(events) {
|
|
76
98
|
return unreadWriteLabels(events).length > 0;
|
|
77
99
|
}
|
|
@@ -25,6 +25,31 @@ const MAX_LISTED_REQUESTS = 3;
|
|
|
25
25
|
* agent that never chose that wait cannot be expected to recognise it in a timeout about it.
|
|
26
26
|
*/
|
|
27
27
|
export function describeWaitTarget(predicate) {
|
|
28
|
+
return `${waitPhrase(predicate)}${otherConditions(predicate)}`;
|
|
29
|
+
}
|
|
30
|
+
/** The fields a phrase already words, per kind; `since` is a cursor, never a condition. */
|
|
31
|
+
const WORDED = {
|
|
32
|
+
[PredicateKind.SIGNAL]: ['name'],
|
|
33
|
+
[PredicateKind.NET]: ['method', 'urlContains'],
|
|
34
|
+
[PredicateKind.ROUTE]: ['pathname', 'contains'],
|
|
35
|
+
[PredicateKind.STATE]: ['path'],
|
|
36
|
+
[PredicateKind.TEXT]: ['contains', 'ignoreCase'],
|
|
37
|
+
[PredicateKind.ELEMENT]: ['query', 'state'],
|
|
38
|
+
[PredicateKind.ANIMATION]: ['name'],
|
|
39
|
+
};
|
|
40
|
+
const NEVER_WORDED = new Set(['kind', 'since']);
|
|
41
|
+
/**
|
|
42
|
+
* Every other condition the claim checks, as JSON. The label is the check's title and its issue
|
|
43
|
+
* key downstream, so a condition left out made a weaker check share a stricter one's issue.
|
|
44
|
+
*/
|
|
45
|
+
function otherConditions(predicate) {
|
|
46
|
+
const worded = WORDED[predicate.kind];
|
|
47
|
+
if (worded === undefined)
|
|
48
|
+
return '';
|
|
49
|
+
const rest = Object.entries(predicate).filter(([key, value]) => value !== undefined && !NEVER_WORDED.has(key) && !worded.includes(key));
|
|
50
|
+
return 0 === rest.length ? '' : ` where ${JSON.stringify(Object.fromEntries(rest))}`;
|
|
51
|
+
}
|
|
52
|
+
function waitPhrase(predicate) {
|
|
28
53
|
switch (predicate.kind) {
|
|
29
54
|
case PredicateKind.SETTLED:
|
|
30
55
|
return 'the page to go idle';
|
|
@@ -36,10 +61,12 @@ export function describeWaitTarget(predicate) {
|
|
|
36
61
|
return `a route change${predicate.pathname === undefined ? '' : ` to '${predicate.pathname}'`}${predicate.contains === undefined ? '' : ` containing '${predicate.contains}'`}`;
|
|
37
62
|
case PredicateKind.STATE:
|
|
38
63
|
return `state at '${predicate.path}'`;
|
|
64
|
+
// Every part that decides the claim stays in it: the label is the check's title downstream, and
|
|
65
|
+
// one that dropped `ignoreCase` or the wanted state read as a different check from its own result.
|
|
39
66
|
case PredicateKind.TEXT:
|
|
40
|
-
return `text containing '${predicate.contains}'`;
|
|
67
|
+
return `text containing '${predicate.contains}'${true === predicate.ignoreCase ? ', ignoring case' : ''}`;
|
|
41
68
|
case PredicateKind.ELEMENT:
|
|
42
|
-
return `an element matching ${JSON.stringify(predicate.query)}`;
|
|
69
|
+
return `an element matching ${JSON.stringify(predicate.query)}${predicate.state === undefined ? '' : ` in state '${predicate.state}'`}`;
|
|
43
70
|
case PredicateKind.CONSOLE:
|
|
44
71
|
return 'a console message';
|
|
45
72
|
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 {
|
|
@@ -116,6 +116,8 @@ interface VerifiedInputs {
|
|
|
116
116
|
* Empty means nothing went unread.
|
|
117
117
|
*/
|
|
118
118
|
outcomeUnread?: readonly string[];
|
|
119
|
+
/** The skip reason every unread write carries, if any (`unreadWriteReason`), so the remedy fits it. */
|
|
120
|
+
outcomeUnreadReason?: unknown;
|
|
119
121
|
/**
|
|
120
122
|
* The page SDK's version, so the unread-body remedy can check whether it applies.
|
|
121
123
|
*
|
|
@@ -163,5 +165,10 @@ interface VerifiedVerdict {
|
|
|
163
165
|
/** One sentence naming the deciding evidence — never a restatement of the field. */
|
|
164
166
|
because: string;
|
|
165
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* The sentence a vacuous-grade `unknown` carries. Exported because it is the CALLER's unknown — it
|
|
170
|
+
* asserted nothing real — and the feedback invite has to tell it from "Reticle could not tell".
|
|
171
|
+
*/
|
|
172
|
+
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
173
|
export declare function decideVerified(inputs: VerifiedInputs): VerifiedVerdict;
|
|
167
174
|
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
|
|
@@ -378,7 +406,7 @@ export function decideVerified(inputs) {
|
|
|
378
406
|
verifiedReason: VerifiedReason.OUTCOME_UNREAD,
|
|
379
407
|
because: `a write returned 2xx with a response body that was never recorded (${outcomeUnread.join('; ')}), so its outcome is unread` +
|
|
380
408
|
' — a 200 describes the transport, not the result (a batch reports per-item failures in the body, and every GraphQL error is a 200). ' +
|
|
381
|
-
bodyCaptureRemedy(inputs.sdkVersion),
|
|
409
|
+
bodyCaptureRemedy(inputs.sdkVersion, inputs.outcomeUnreadReason),
|
|
382
410
|
};
|
|
383
411
|
}
|
|
384
412
|
// Never settled: the page may still be moving, so the observation window may have closed early.
|
|
@@ -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;
|