@reticlehq/engine 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +36 -0
- package/dist/disagreement/body-failures.d.ts +4 -0
- package/dist/disagreement/body-failures.js +113 -0
- package/dist/disagreement/contradiction-evidence.d.ts +122 -0
- package/dist/disagreement/contradiction-evidence.js +194 -0
- package/dist/disagreement/contradiction-folds.d.ts +61 -0
- package/dist/disagreement/contradiction-folds.js +71 -0
- package/dist/disagreement/contradiction-types.d.ts +164 -0
- package/dist/disagreement/contradiction-types.js +1 -0
- package/dist/disagreement/contradictions.d.ts +5 -0
- package/dist/disagreement/contradictions.js +613 -0
- package/dist/disagreement/echo-mismatch.d.ts +10 -0
- package/dist/disagreement/echo-mismatch.js +299 -0
- package/dist/disagreement/reconcile.d.ts +39 -0
- package/dist/disagreement/reconcile.js +211 -0
- package/dist/disagreement/stale-response.d.ts +3 -0
- package/dist/disagreement/stale-response.js +186 -0
- package/dist/disagreement/unit-mismatch.d.ts +16 -0
- package/dist/disagreement/unit-mismatch.js +167 -0
- package/dist/disagreement/witness-disagreement.d.ts +42 -0
- package/dist/disagreement/witness-disagreement.js +43 -0
- package/dist/evidence/accepted-write.d.ts +35 -0
- package/dist/evidence/accepted-write.js +54 -0
- package/dist/evidence/already-true.d.ts +16 -0
- package/dist/evidence/already-true.js +89 -0
- package/dist/evidence/blind-spots.d.ts +133 -0
- package/dist/evidence/blind-spots.js +253 -0
- package/dist/evidence/body-capture-remedy.d.ts +42 -0
- package/dist/evidence/body-capture-remedy.js +96 -0
- package/dist/evidence/gap-ledger.d.ts +52 -0
- package/dist/evidence/gap-ledger.js +63 -0
- package/dist/evidence/honesty.d.ts +113 -0
- package/dist/evidence/honesty.js +105 -0
- package/dist/evidence/instrumentation-gaps.d.ts +91 -0
- package/dist/evidence/instrumentation-gaps.js +102 -0
- package/dist/evidence/learned-guards.d.ts +75 -0
- package/dist/evidence/learned-guards.js +78 -0
- package/dist/evidence/observability.d.ts +38 -0
- package/dist/evidence/observability.js +40 -0
- package/dist/evidence/page-teardown.d.ts +15 -0
- package/dist/evidence/page-teardown.js +17 -0
- package/dist/evidence/step-effect.d.ts +41 -0
- package/dist/evidence/step-effect.js +27 -0
- package/dist/evidence/uncaptured-bodies.d.ts +23 -0
- package/dist/evidence/uncaptured-bodies.js +41 -0
- package/dist/evidence/undeclared-change.d.ts +51 -0
- package/dist/evidence/undeclared-change.js +56 -0
- package/dist/evidence/unread-outcome.d.ts +10 -0
- package/dist/evidence/unread-outcome.js +77 -0
- package/dist/evidence/unsettled.d.ts +58 -0
- package/dist/evidence/unsettled.js +127 -0
- package/dist/evidence/verdict-intent-gap.d.ts +30 -0
- package/dist/evidence/verdict-intent-gap.js +35 -0
- package/dist/evidence/verified.d.ts +158 -0
- package/dist/evidence/verified.js +378 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +25 -0
- package/dist/question/declared.d.ts +74 -0
- package/dist/question/declared.js +171 -0
- package/dist/question/lineage.d.ts +52 -0
- package/dist/question/lineage.js +122 -0
- package/dist/question/predicate/net-evidence.d.ts +21 -0
- package/dist/question/predicate/net-evidence.js +81 -0
- package/dist/question/predicate/observed-in-window.d.ts +24 -0
- package/dist/question/predicate/observed-in-window.js +38 -0
- package/dist/question/predicate/predicate-asks.d.ts +28 -0
- package/dist/question/predicate/predicate-asks.js +46 -0
- package/dist/question/predicate/predicate-console.d.ts +13 -0
- package/dist/question/predicate/predicate-console.js +138 -0
- package/dist/question/predicate/predicate-element.d.ts +13 -0
- package/dist/question/predicate/predicate-element.js +214 -0
- package/dist/question/predicate/predicate-eval-kit.d.ts +90 -0
- package/dist/question/predicate/predicate-eval-kit.js +126 -0
- package/dist/question/predicate/predicate-eval.d.ts +24 -0
- package/dist/question/predicate/predicate-eval.js +710 -0
- package/dist/question/predicate/predicate-parse.d.ts +15 -0
- package/dist/question/predicate/predicate-parse.js +173 -0
- package/dist/question/predicate/predicate-precheck.d.ts +8 -0
- package/dist/question/predicate/predicate-precheck.js +41 -0
- package/dist/question/predicate/predicate-request-body.d.ts +50 -0
- package/dist/question/predicate/predicate-request-body.js +120 -0
- package/dist/question/predicate/predicate-route.d.ts +66 -0
- package/dist/question/predicate/predicate-route.js +293 -0
- package/dist/question/predicate/predicate-schema.d.ts +170 -0
- package/dist/question/predicate/predicate-schema.js +509 -0
- package/dist/question/predicate/predicate-session.d.ts +72 -0
- package/dist/question/predicate/predicate-session.js +1 -0
- package/dist/question/predicate/predicate-to-links.d.ts +13 -0
- package/dist/question/predicate/predicate-to-links.js +38 -0
- package/dist/question/predicate/predicate.d.ts +26 -0
- package/dist/question/predicate/predicate.js +785 -0
- package/dist/question/predicate/property.d.ts +102 -0
- package/dist/question/predicate/property.js +135 -0
- package/dist/question/predicate/split-text-miss.d.ts +32 -0
- package/dist/question/predicate/split-text-miss.js +51 -0
- package/dist/question/predicate/testid-near-miss.d.ts +22 -0
- package/dist/question/predicate/testid-near-miss.js +33 -0
- package/dist/question/reaction.d.ts +17 -0
- package/dist/question/reaction.js +67 -0
- package/dist/window/adversary.d.ts +28 -0
- package/dist/window/adversary.js +90 -0
- package/dist/window/ambient.d.ts +63 -0
- package/dist/window/ambient.js +76 -0
- package/dist/window/appearance-budget.d.ts +41 -0
- package/dist/window/appearance-budget.js +47 -0
- package/dist/window/asset-noise.d.ts +42 -0
- package/dist/window/asset-noise.js +35 -0
- package/dist/window/body-relevance.d.ts +54 -0
- package/dist/window/body-relevance.js +78 -0
- package/dist/window/byte-size.d.ts +1 -0
- package/dist/window/byte-size.js +16 -0
- package/dist/window/engine-host.d.ts +35 -0
- package/dist/window/engine-host.js +20 -0
- package/dist/window/event-filters.d.ts +121 -0
- package/dist/window/event-filters.js +215 -0
- package/dist/window/json-salvage.d.ts +33 -0
- package/dist/window/json-salvage.js +96 -0
- package/dist/window/network-detail-merge.d.ts +8 -0
- package/dist/window/network-detail-merge.js +89 -0
- package/dist/window/ring-buffer.d.ts +41 -0
- package/dist/window/ring-buffer.js +152 -0
- package/package.json +71 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blind-spot register — the never-silent statement of what the layer CANNOT see. Closed shadow roots,
|
|
3
|
+
* cross-origin iframes, and virtualized-unmounted rows are documented limits; a result that touched one
|
|
4
|
+
* says so (`coverage: partial — 2 cross-origin frames unobserved`) instead of implying it saw everything.
|
|
5
|
+
* Pure formatting over the counted blind spots the observers report.
|
|
6
|
+
*/
|
|
7
|
+
export { BlindSpotKind } from '@reticlehq/core';
|
|
8
|
+
import { BlindSpotKind, type ReticleEvent } from '@reticlehq/core';
|
|
9
|
+
interface BlindSpot {
|
|
10
|
+
kind: BlindSpotKind;
|
|
11
|
+
count: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Whether the observation window saw everything it was asked about.
|
|
15
|
+
*
|
|
16
|
+
* NOT core's VerdictStatus, which happens to spell one of its values 'partial' too: that one grades
|
|
17
|
+
* a verification RUN (some flows passed, some failed), this one grades what could be OBSERVED. Two
|
|
18
|
+
* meanings behind one string is exactly how a comparison ends up reading the wrong field, so they
|
|
19
|
+
* stay separate vocabularies.
|
|
20
|
+
*/
|
|
21
|
+
export declare const Coverage: {
|
|
22
|
+
readonly FULL: "full";
|
|
23
|
+
readonly PARTIAL: "partial";
|
|
24
|
+
};
|
|
25
|
+
export type Coverage = (typeof Coverage)[keyof typeof Coverage];
|
|
26
|
+
interface CoverageStatement {
|
|
27
|
+
coverage: Coverage;
|
|
28
|
+
/** Present only when partial — the human/agent-legible list of what went unobserved. */
|
|
29
|
+
note?: string;
|
|
30
|
+
spots: BlindSpot[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Blind spots that IMPEACH the capture, as opposed to bounding what it covers.
|
|
34
|
+
*
|
|
35
|
+
* The distinction decides whether a verdict is downgraded to UNKNOWN or merely carries a caveat, and
|
|
36
|
+
* conflating them breaks the tool in one direction or the other:
|
|
37
|
+
*
|
|
38
|
+
* - **Impeaching**: events were DROPPED, so the window itself is a sample and any claim over it may
|
|
39
|
+
* be a false negative. Nothing observed can be trusted to be complete.
|
|
40
|
+
* - **Bounding**: a region is structurally unobservable — a cross-origin frame, a closed shadow
|
|
41
|
+
* root, the 9,970 virtualized rows that were never rendered. What WAS observed is completely and
|
|
42
|
+
* correctly observed; there is simply a boundary, and it is usually permanent.
|
|
43
|
+
*
|
|
44
|
+
* Treating the second kind as impeaching made every verdict on any virtualized list UNKNOWN — which
|
|
45
|
+
* is most data-heavy software, permanently. A tool that answers "unknown" to everything is as
|
|
46
|
+
* useless as one that answers "yes" to everything, and it is the same failure: a verdict that does
|
|
47
|
+
* not depend on the evidence.
|
|
48
|
+
*/
|
|
49
|
+
export declare function impeachesCapture(kind: BlindSpotKind): boolean;
|
|
50
|
+
/** Compose the coverage statement. `full` (no note) when nothing was unobserved. */
|
|
51
|
+
export declare function buildCoverageStatement(spots: readonly BlindSpot[]): CoverageStatement;
|
|
52
|
+
/**
|
|
53
|
+
* Reduce a window's BLIND_SPOT events to one spot per kind — the LATEST reported count wins (the sensor
|
|
54
|
+
* emits only on change, so the last value is the live count). This is how a result's coverage is derived
|
|
55
|
+
* from what the SDK observed during the action, with no extra round-trip.
|
|
56
|
+
*/
|
|
57
|
+
export declare function blindSpotsFromEvents(events: readonly ReticleEvent[]): BlindSpot[];
|
|
58
|
+
/**
|
|
59
|
+
* Drop Electron-only coverage rows unless this session is actually an Electron renderer.
|
|
60
|
+
*
|
|
61
|
+
* The kinds live in the same vocabulary as "no store registered", so listing whatever is present
|
|
62
|
+
* reported a Vite + React tab as an un-instrumented Electron renderer. The session already knows
|
|
63
|
+
* the runtime (PAGE_HEALTH). Unknown runtime (older SDK) keeps the rows — dropping them would hide
|
|
64
|
+
* a real missing-preload warning.
|
|
65
|
+
*/
|
|
66
|
+
export declare function spotsForRuntime(spots: readonly BlindSpot[], runtime: string | undefined): BlindSpot[];
|
|
67
|
+
/**
|
|
68
|
+
* Blind spots from the session's remembered LEVEL state rather than from a window of events.
|
|
69
|
+
*
|
|
70
|
+
* The SDK emits BLIND_SPOT only when the count changes, so a page that mounted cross-origin frames at
|
|
71
|
+
* load announces them once and is silent thereafter. Deriving coverage from one act's window then
|
|
72
|
+
* reports "full" for a page a third of which is unobservable — and the act tool's own description
|
|
73
|
+
* tells harnesses to gate on that block. Ask the session what is true now instead of inferring it
|
|
74
|
+
* from what happened to be said recently.
|
|
75
|
+
*
|
|
76
|
+
* `runtime` gates Electron-only kinds (see `spotsForRuntime`) so a web session cannot inherit them
|
|
77
|
+
* from the coverage vocabulary.
|
|
78
|
+
*/
|
|
79
|
+
export declare function blindSpotsFromState(state: Readonly<Record<string, number>>, runtime?: string): BlindSpot[];
|
|
80
|
+
/**
|
|
81
|
+
* The narrow slice of a predicate the absence-blind-spot check needs.
|
|
82
|
+
*
|
|
83
|
+
* Kept minimal to avoid pulling the full Predicate type (and its transitive deps) into the
|
|
84
|
+
* honesty module. Anything that quacks like this works.
|
|
85
|
+
*/
|
|
86
|
+
interface AbsencePredicate {
|
|
87
|
+
kind: string;
|
|
88
|
+
absent?: boolean;
|
|
89
|
+
query?: {
|
|
90
|
+
scope?: unknown;
|
|
91
|
+
};
|
|
92
|
+
predicate?: AbsencePredicate;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* When an absence assertion targets a page with regions Reticle cannot observe, "the element is
|
|
96
|
+
* absent" means only "it is absent in what I CAN see". Returns a note when that distinction
|
|
97
|
+
* matters, undefined otherwise.
|
|
98
|
+
*
|
|
99
|
+
* Fires on three blind-spot kinds:
|
|
100
|
+
* - 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
|
|
102
|
+
* - CLOSED_SHADOW_ROOT — a subtree Reticle cannot see into
|
|
103
|
+
*/
|
|
104
|
+
export declare function absenceBlindSpotNote(predicate: AbsencePredicate, spots: readonly BlindSpot[]): string | undefined;
|
|
105
|
+
/** The impeaching note for a transport gap, or undefined when the window was intact. */
|
|
106
|
+
export declare function transportGapNote(events: readonly ReticleEvent[]): string | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Is the state channel dark?
|
|
109
|
+
*
|
|
110
|
+
* Nothing subscribed means NO state change is observed, so an empty `stateDiffs` is a statement
|
|
111
|
+
* about Reticle rather than about the app. Derived here, once, because two callers now need it —
|
|
112
|
+
* the act path's causal summary and the instrumentation-gap surface — and a second spelling of this
|
|
113
|
+
* predicate would eventually disagree with the first about what "unwatched" means.
|
|
114
|
+
*/
|
|
115
|
+
export declare function isStateUnwatched(spots: readonly BlindSpot[]): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Does a passing verdict on this predicate REST on the window being complete?
|
|
118
|
+
*
|
|
119
|
+
* Only an absence claim does. A positive assertion that passed found its evidence, and events aged
|
|
120
|
+
* out elsewhere in the buffer do not unmake it. An absence claim concluded "nothing is there" — and
|
|
121
|
+
* the thing the buffer dropped is precisely the disproof, so "absent" degrades to "absent in what I
|
|
122
|
+
* still hold".
|
|
123
|
+
*
|
|
124
|
+
* The distinction is not optional. Scarce-loss is recorded for AGE eviction too, so `lostSince(0)`
|
|
125
|
+
* is true on any session older than the 60s cutoff; impeaching every verdict over a caller-chosen
|
|
126
|
+
* window would make `unknown` the answer to everything, which this repo has already paid for once.
|
|
127
|
+
*/
|
|
128
|
+
export declare function restsOnCompleteWindow(predicate: {
|
|
129
|
+
kind: string;
|
|
130
|
+
absent?: boolean;
|
|
131
|
+
count?: number;
|
|
132
|
+
predicate?: unknown;
|
|
133
|
+
}): boolean;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blind-spot register — the never-silent statement of what the layer CANNOT see. Closed shadow roots,
|
|
3
|
+
* cross-origin iframes, and virtualized-unmounted rows are documented limits; a result that touched one
|
|
4
|
+
* says so (`coverage: partial — 2 cross-origin frames unobserved`) instead of implying it saw everything.
|
|
5
|
+
* Pure formatting over the counted blind spots the observers report.
|
|
6
|
+
*/
|
|
7
|
+
// The kind enum lives in core (it crosses the wire in a BLIND_SPOT event); re-exported here for the
|
|
8
|
+
// honesty-side callers.
|
|
9
|
+
export { BlindSpotKind } from '@reticlehq/core';
|
|
10
|
+
import { BlindSpotKind, EventType, PredicateKind, ReticleEnv, TRANSPORT_LIMITS, isDesktopBlindSpot, realmOf, } from '@reticlehq/core';
|
|
11
|
+
/**
|
|
12
|
+
* Whether the observation window saw everything it was asked about.
|
|
13
|
+
*
|
|
14
|
+
* NOT core's VerdictStatus, which happens to spell one of its values 'partial' too: that one grades
|
|
15
|
+
* a verification RUN (some flows passed, some failed), this one grades what could be OBSERVED. Two
|
|
16
|
+
* meanings behind one string is exactly how a comparison ends up reading the wrong field, so they
|
|
17
|
+
* stay separate vocabularies.
|
|
18
|
+
*/
|
|
19
|
+
export const Coverage = {
|
|
20
|
+
FULL: 'full',
|
|
21
|
+
PARTIAL: 'partial',
|
|
22
|
+
};
|
|
23
|
+
const LABEL = {
|
|
24
|
+
[BlindSpotKind.CLOSED_SHADOW_ROOT]: (n) => `${String(n)} closed shadow root${1 === n ? '' : 's'} unobserved`,
|
|
25
|
+
[BlindSpotKind.CROSS_ORIGIN_IFRAME]: (n) => `${String(n)} cross-origin frame${1 === n ? '' : 's'} unobserved`,
|
|
26
|
+
// The DOM of these frames IS observed; only their network is not. Saying so precisely matters — a
|
|
27
|
+
// flat "unobserved" would discard a real capability and push agents back to guessing.
|
|
28
|
+
[BlindSpotKind.UNINSTRUMENTED_FRAME]: (n) => `${String(n)} same-origin frame${1 === n ? '' : 's'} observed for DOM but not network — requests they make are invisible`,
|
|
29
|
+
[BlindSpotKind.VIRTUALIZED_UNMOUNTED]: (n) => `${String(n)} virtualized unmounted row${1 === n ? '' : 's'} unobserved`,
|
|
30
|
+
// Not "some rows we could not see" — the events never reached the observer, so this window is a
|
|
31
|
+
// SAMPLE of what the app did. Phrased as a caveat on what the whole result MEANS.
|
|
32
|
+
// Names a NUMBER, not a variable. "Raise it for a busy app" leaves the reader to invent a value,
|
|
33
|
+
// and the one who reported this had to guess before finding one that worked. The default was
|
|
34
|
+
// raised in the same change, so a page still hitting the cap after that is genuinely unusual and
|
|
35
|
+
// deserves a concrete next value rather than an adjective.
|
|
36
|
+
[BlindSpotKind.RATE_LIMITED]: (n) => `${String(n)} event${1 === n ? '' : 's'} dropped by the bridge rate cap, so this window is SAMPLED. Set ${ReticleEnv.MAX_MESSAGES_PER_SECOND}=${String(TRANSPORT_LIMITS.MAX_MESSAGES_PER_SECOND * 5)} and restart the daemon, then re-run this drive`,
|
|
37
|
+
// Not a count of things — a single fact about the page. Phrased so the coverage line reads as a
|
|
38
|
+
// caveat on what the network view MEANS, not as a tally.
|
|
39
|
+
// A count of unverifiable ACTIONS, not of things we failed to look at. The distinction matters:
|
|
40
|
+
// nothing here was missed, there was simply never a verdict to observe, and no amount of extra
|
|
41
|
+
// instrumentation would produce one.
|
|
42
|
+
[BlindSpotKind.VERDICTLESS_SEND]: (n) => `${String(n)} one-way IPC send${1 === n ? '' : 's'} dispatched with NO verdict — the renderer never learns whether the main process handled ${1 === n ? 'it' : 'them'}, so this cannot be confirmed from the page`,
|
|
43
|
+
// Not a tally — a fact about the app's wiring, phrased as what the EMPTY state channel means. An
|
|
44
|
+
// agent reading `stateDiffs: []` otherwise reads "the app changed no state", which is a claim
|
|
45
|
+
// nothing here can support. Names the one-line fix, because the reader is the one who can apply it.
|
|
46
|
+
[BlindSpotKind.UNWATCHED_STATE]: () => 'no subscribable store is registered, so NO state change is observed — an empty stateDiffs here means unwatched, not unchanged (register the store itself in your reticle-dev module: registerStore(name, store), not a getter)',
|
|
47
|
+
[BlindSpotKind.WRAPPED_NETWORK]: () => 'fetch was already wrapped before Reticle, so recorded requests may differ from what was sent',
|
|
48
|
+
// A fact about the app's wiring, not a tally. Says what a network view WITHOUT ipc:// records
|
|
49
|
+
// MEANS, because that state here is indistinguishable from "this app made no backend calls" —
|
|
50
|
+
// and that reading is the false green: every IPC call went unseen and every `assert { net }` over
|
|
51
|
+
// them is vacuous. Document-initiated loads ARE seen since subresource observation (#447), so
|
|
52
|
+
// the note names the missing half instead of claiming the whole view is blind.
|
|
53
|
+
[BlindSpotKind.UNOBSERVED_IPC]: () => "this Electron renderer has no Reticle preload, so NO ipcRenderer.invoke is observed; document-initiated loads may still appear, so a view with no ipc:// records means unseen IPC, not none (add require('@reticlehq/electron/preload') to your preload)",
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Blind spots that IMPEACH the capture, as opposed to bounding what it covers.
|
|
57
|
+
*
|
|
58
|
+
* The distinction decides whether a verdict is downgraded to UNKNOWN or merely carries a caveat, and
|
|
59
|
+
* conflating them breaks the tool in one direction or the other:
|
|
60
|
+
*
|
|
61
|
+
* - **Impeaching**: events were DROPPED, so the window itself is a sample and any claim over it may
|
|
62
|
+
* be a false negative. Nothing observed can be trusted to be complete.
|
|
63
|
+
* - **Bounding**: a region is structurally unobservable — a cross-origin frame, a closed shadow
|
|
64
|
+
* root, the 9,970 virtualized rows that were never rendered. What WAS observed is completely and
|
|
65
|
+
* correctly observed; there is simply a boundary, and it is usually permanent.
|
|
66
|
+
*
|
|
67
|
+
* Treating the second kind as impeaching made every verdict on any virtualized list UNKNOWN — which
|
|
68
|
+
* is most data-heavy software, permanently. A tool that answers "unknown" to everything is as
|
|
69
|
+
* useless as one that answers "yes" to everything, and it is the same failure: a verdict that does
|
|
70
|
+
* not depend on the evidence.
|
|
71
|
+
*/
|
|
72
|
+
export function impeachesCapture(kind) {
|
|
73
|
+
return kind === BlindSpotKind.RATE_LIMITED;
|
|
74
|
+
}
|
|
75
|
+
/** Compose the coverage statement. `full` (no note) when nothing was unobserved. */
|
|
76
|
+
export function buildCoverageStatement(spots) {
|
|
77
|
+
const present = spots.filter((s) => s.count > 0);
|
|
78
|
+
if (0 === present.length)
|
|
79
|
+
return { coverage: Coverage.FULL, spots: [] };
|
|
80
|
+
// Each label carries its own ending. Appending a blanket " unobserved" here produced
|
|
81
|
+
// "...may differ from what was sent unobserved" for the wrapped-network caveat, which is a
|
|
82
|
+
// sentence rather than a count — and the same dangle appeared the moment a second prose-shaped
|
|
83
|
+
// spot (rate-limited sampling) was added.
|
|
84
|
+
// A kind this daemon does not know about still has to READ as a blind spot. An SDK newer than the
|
|
85
|
+
// daemon can report one, and `LABEL[kind](count)` threw a TypeError on the verdict path when it
|
|
86
|
+
// did — turning "there is something I could not see" into a crashed assert, which is worse than
|
|
87
|
+
// either the caveat or the silence. Unknown kinds degrade to their own name.
|
|
88
|
+
const label = (s) => 'function' === typeof LABEL[s.kind] ? LABEL[s.kind](s.count) : `${s.kind} (${String(s.count)})`;
|
|
89
|
+
const note = `${Coverage.PARTIAL} — ${present.map(label).join(', ')}`;
|
|
90
|
+
return { coverage: Coverage.PARTIAL, note, spots: present };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Reduce a window's BLIND_SPOT events to one spot per kind — the LATEST reported count wins (the sensor
|
|
94
|
+
* emits only on change, so the last value is the live count). This is how a result's coverage is derived
|
|
95
|
+
* from what the SDK observed during the action, with no extra round-trip.
|
|
96
|
+
*/
|
|
97
|
+
export function blindSpotsFromEvents(events) {
|
|
98
|
+
const latest = new Map();
|
|
99
|
+
for (const e of events) {
|
|
100
|
+
if (e.type !== EventType.BLIND_SPOT)
|
|
101
|
+
continue;
|
|
102
|
+
const kind = e.data['kind'];
|
|
103
|
+
const count = e.data['count'];
|
|
104
|
+
if ('string' === typeof kind && 'number' === typeof count) {
|
|
105
|
+
latest.set(kind, count);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return [...latest].map(([kind, count]) => ({ kind, count }));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Drop Electron-only coverage rows unless this session is actually an Electron renderer.
|
|
112
|
+
*
|
|
113
|
+
* The kinds live in the same vocabulary as "no store registered", so listing whatever is present
|
|
114
|
+
* reported a Vite + React tab as an un-instrumented Electron renderer. The session already knows
|
|
115
|
+
* the runtime (PAGE_HEALTH). Unknown runtime (older SDK) keeps the rows — dropping them would hide
|
|
116
|
+
* a real missing-preload warning.
|
|
117
|
+
*/
|
|
118
|
+
export function spotsForRuntime(spots, runtime) {
|
|
119
|
+
// Unknown runtime keeps the rows, deliberately and separately from the table below: an older SDK
|
|
120
|
+
// sends none, and dropping a real missing-preload warning is worse than showing one that does not
|
|
121
|
+
// apply. The table answers "does this realm raise these", not "should silence be treated as no".
|
|
122
|
+
if (runtime === undefined)
|
|
123
|
+
return [...spots];
|
|
124
|
+
if (realmOf(runtime).ownsCoverageKinds)
|
|
125
|
+
return [...spots];
|
|
126
|
+
return spots.filter((spot) => !isDesktopBlindSpot(spot.kind));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Blind spots from the session's remembered LEVEL state rather than from a window of events.
|
|
130
|
+
*
|
|
131
|
+
* The SDK emits BLIND_SPOT only when the count changes, so a page that mounted cross-origin frames at
|
|
132
|
+
* load announces them once and is silent thereafter. Deriving coverage from one act's window then
|
|
133
|
+
* reports "full" for a page a third of which is unobservable — and the act tool's own description
|
|
134
|
+
* tells harnesses to gate on that block. Ask the session what is true now instead of inferring it
|
|
135
|
+
* from what happened to be said recently.
|
|
136
|
+
*
|
|
137
|
+
* `runtime` gates Electron-only kinds (see `spotsForRuntime`) so a web session cannot inherit them
|
|
138
|
+
* from the coverage vocabulary.
|
|
139
|
+
*/
|
|
140
|
+
export function blindSpotsFromState(state, runtime) {
|
|
141
|
+
const spots = Object.entries(state).map(([kind, count]) => ({
|
|
142
|
+
kind: kind,
|
|
143
|
+
count,
|
|
144
|
+
}));
|
|
145
|
+
return spotsForRuntime(spots, runtime);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Events the BROWSER's own transport queue threw away inside this window, or 0.
|
|
149
|
+
*
|
|
150
|
+
* `RATE_LIMITED` — the BRIDGE sampling because events arrived faster than its per-second cap — is
|
|
151
|
+
* already the one blind spot that `impeachesCapture`, on the reasoning that a green over a window
|
|
152
|
+
* you did not fully see "would only describe what was observed". `TRANSPORT_OVERFLOW` is the exact
|
|
153
|
+
* same loss on the other side of the wire, and it was read in journal rollups and NOWHERE on the
|
|
154
|
+
* verdict path. So the identical condition downgraded a verdict from one side of the socket and was
|
|
155
|
+
* invisible from the other: a window that dropped 34 events graded `proved`, in a sentence whose own
|
|
156
|
+
* words were "over a clean capture".
|
|
157
|
+
*
|
|
158
|
+
* `TRUNCATED` is deliberately NOT counted. It names the channel it capped (a DOM-mutation flood on
|
|
159
|
+
* any busy page) and is routine churn; treating it as lost evidence would caveat every verdict on
|
|
160
|
+
* every real app, and a caveat that is always present is one nobody reads. TRANSPORT_OVERFLOW is the
|
|
161
|
+
* honest "arbitrary events are gone" marker — it cannot say which.
|
|
162
|
+
*/
|
|
163
|
+
function droppedByTransport(events) {
|
|
164
|
+
let dropped = 0;
|
|
165
|
+
for (const e of events) {
|
|
166
|
+
if (e.type !== EventType.TRANSPORT_OVERFLOW)
|
|
167
|
+
continue;
|
|
168
|
+
const n = e.data['dropped'];
|
|
169
|
+
dropped += 'number' === typeof n ? n : 0;
|
|
170
|
+
}
|
|
171
|
+
return dropped;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* When an absence assertion targets a page with regions Reticle cannot observe, "the element is
|
|
175
|
+
* absent" means only "it is absent in what I CAN see". Returns a note when that distinction
|
|
176
|
+
* matters, undefined otherwise.
|
|
177
|
+
*
|
|
178
|
+
* Fires on three blind-spot kinds:
|
|
179
|
+
* - 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
|
|
181
|
+
* - CLOSED_SHADOW_ROOT — a subtree Reticle cannot see into
|
|
182
|
+
*/
|
|
183
|
+
export function absenceBlindSpotNote(predicate, spots) {
|
|
184
|
+
// `not(element)` is the third spelling of an absence assertion — the `not` wrapper IS the
|
|
185
|
+
// negation, so the inner predicate will not carry `absent: true`. Unwrap and synthesize it.
|
|
186
|
+
// `not(element { absent: true })` is a double negative — presence — and a positive match is
|
|
187
|
+
// not threatened by an unobservable region.
|
|
188
|
+
if (PredicateKind.NOT === predicate.kind && predicate.predicate !== undefined) {
|
|
189
|
+
if (PredicateKind.ELEMENT === predicate.predicate.kind) {
|
|
190
|
+
if (true === predicate.predicate.absent)
|
|
191
|
+
return undefined;
|
|
192
|
+
return absenceBlindSpotNote({ ...predicate.predicate, absent: true }, spots);
|
|
193
|
+
}
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
if (PredicateKind.ELEMENT !== predicate.kind || true !== predicate.absent)
|
|
197
|
+
return undefined;
|
|
198
|
+
const relevant = spots.filter((spot) => spot.count > 0 &&
|
|
199
|
+
(spot.kind === BlindSpotKind.CROSS_ORIGIN_IFRAME
|
|
200
|
+
? undefined !== predicate.query?.scope
|
|
201
|
+
: spot.kind === BlindSpotKind.VIRTUALIZED_UNMOUNTED ||
|
|
202
|
+
spot.kind === BlindSpotKind.CLOSED_SHADOW_ROOT));
|
|
203
|
+
if (0 === relevant.length)
|
|
204
|
+
return undefined;
|
|
205
|
+
const statement = buildCoverageStatement(relevant);
|
|
206
|
+
return `the absence assertion targeted a region Reticle could not observe (${statement.note ?? 'partial coverage'}), so a passing DOM check cannot prove absence`;
|
|
207
|
+
}
|
|
208
|
+
/** The impeaching note for a transport gap, or undefined when the window was intact. */
|
|
209
|
+
export function transportGapNote(events) {
|
|
210
|
+
const dropped = droppedByTransport(events);
|
|
211
|
+
return 0 === dropped
|
|
212
|
+
? undefined
|
|
213
|
+
: `the browser dropped ${String(dropped)} event(s) in this window (transport queue overflow), so events that would have contradicted this may never have arrived`;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Is the state channel dark?
|
|
217
|
+
*
|
|
218
|
+
* Nothing subscribed means NO state change is observed, so an empty `stateDiffs` is a statement
|
|
219
|
+
* about Reticle rather than about the app. Derived here, once, because two callers now need it —
|
|
220
|
+
* the act path's causal summary and the instrumentation-gap surface — and a second spelling of this
|
|
221
|
+
* predicate would eventually disagree with the first about what "unwatched" means.
|
|
222
|
+
*/
|
|
223
|
+
export function isStateUnwatched(spots) {
|
|
224
|
+
return spots.some((spot) => spot.kind === BlindSpotKind.UNWATCHED_STATE && spot.count > 0);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Does a passing verdict on this predicate REST on the window being complete?
|
|
228
|
+
*
|
|
229
|
+
* Only an absence claim does. A positive assertion that passed found its evidence, and events aged
|
|
230
|
+
* out elsewhere in the buffer do not unmake it. An absence claim concluded "nothing is there" — and
|
|
231
|
+
* the thing the buffer dropped is precisely the disproof, so "absent" degrades to "absent in what I
|
|
232
|
+
* still hold".
|
|
233
|
+
*
|
|
234
|
+
* The distinction is not optional. Scarce-loss is recorded for AGE eviction too, so `lostSince(0)`
|
|
235
|
+
* is true on any session older than the 60s cutoff; impeaching every verdict over a caller-chosen
|
|
236
|
+
* window would make `unknown` the answer to everything, which this repo has already paid for once.
|
|
237
|
+
*/
|
|
238
|
+
export function restsOnCompleteWindow(predicate) {
|
|
239
|
+
if (PredicateKind.NOT === predicate.kind)
|
|
240
|
+
return true;
|
|
241
|
+
// An exact cardinality of ZERO is the third spelling of an absence claim, and reading only
|
|
242
|
+
// `absent` missed it: `{ kind: "net", urlContains: "/api/auth/sign-in", count: 0 }` says "this
|
|
243
|
+
// request was never made", and the call the buffer evicted is precisely the disproof. It was
|
|
244
|
+
// graded `yes` over a window known to have lost scarce evidence — the exact false green the two
|
|
245
|
+
// clauses above exist to prevent, reached by the one spelling they did not cover (#668).
|
|
246
|
+
//
|
|
247
|
+
// Only zero. `count: 2` asserts calls were MADE and found them; events aged out elsewhere in the
|
|
248
|
+
// buffer do not unmake a positive finding, which is the same reason a plain presence assertion is
|
|
249
|
+
// left alone here.
|
|
250
|
+
if (0 === predicate.count)
|
|
251
|
+
return true;
|
|
252
|
+
return true === predicate.absent;
|
|
253
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
/** The earliest SDK release whose observer can capture network bodies at all. */
|
|
16
|
+
export declare const BODY_CAPTURE_MIN_VERSION = "2.4.0";
|
|
17
|
+
/**
|
|
18
|
+
* The remedy for this session, or the honest statement that there is none.
|
|
19
|
+
*
|
|
20
|
+
* An UNKNOWN version is treated as capable. A hand-wired connect reports none, and guessing "too
|
|
21
|
+
* old" there would hide a working fix from someone who could have used it; the opposite guess costs
|
|
22
|
+
* one wasted read. The asymmetry decides it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function bodyCaptureRemedy(sdkVersion: string | undefined): string;
|
|
25
|
+
/**
|
|
26
|
+
* Refuse a body clause the session cannot answer, BEFORE the action is spent.
|
|
27
|
+
*
|
|
28
|
+
* Reported: an `act_and_wait` matched the right call and returned `verified: "no"` with "a matching
|
|
29
|
+
* call with no recorded body", because that project's `connect()` does not pass
|
|
30
|
+
* `captureNetworkBodies` — and the reporter could not change it, since it was not their project's
|
|
31
|
+
* config to edit for an unrelated verification task. The action bought nothing that was not knowable
|
|
32
|
+
* in advance, and on a drive that mutates state an action is not always repeatable. That is what
|
|
33
|
+
* makes this a pre-flight rather than a better failure message.
|
|
34
|
+
*
|
|
35
|
+
* Refuses ONLY on a DECLARED `captureBodies: false`. An SDK too old to announce the setting sends
|
|
36
|
+
* nothing, and refusing on silence would break every session predating the announcement for a clause
|
|
37
|
+
* many of them satisfy — the same asymmetry that makes an unknown VERSION count as capable.
|
|
38
|
+
*/
|
|
39
|
+
export declare function bodyClauseRefusal(predicate: unknown, session: {
|
|
40
|
+
captureBodies?: boolean | undefined;
|
|
41
|
+
sdkVersion?: string | undefined;
|
|
42
|
+
}): string | undefined;
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
/** The earliest SDK release whose observer can capture network bodies at all. */
|
|
16
|
+
export const BODY_CAPTURE_MIN_VERSION = '2.4.0';
|
|
17
|
+
/**
|
|
18
|
+
* Compare two dotted versions numerically.
|
|
19
|
+
*
|
|
20
|
+
* String comparison inverts exactly where it hurts: a two-digit minor sorts BEFORE a one-digit one
|
|
21
|
+
* as text, so a NEWER SDK would be told it is too old and the working remedy withheld. A prerelease
|
|
22
|
+
* suffix is dropped rather than parsed — an `-rc` build counts as its own minor, and nothing here
|
|
23
|
+
* needs finer.
|
|
24
|
+
*/
|
|
25
|
+
function isAtLeast(version, minimum) {
|
|
26
|
+
const parts = (v) => v
|
|
27
|
+
.split('-')[0]
|
|
28
|
+
?.split('.')
|
|
29
|
+
.map((n) => Number.parseInt(n, 10) || 0) ?? [];
|
|
30
|
+
const have = parts(version);
|
|
31
|
+
const want = parts(minimum);
|
|
32
|
+
for (let i = 0; i < Math.max(have.length, want.length); i += 1) {
|
|
33
|
+
const a = have[i] ?? 0;
|
|
34
|
+
const b = want[i] ?? 0;
|
|
35
|
+
if (a !== b)
|
|
36
|
+
return a > b;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
/** The sentence naming the setting — only ever produced for an SDK that HAS it. */
|
|
41
|
+
const ENABLE_IT = 'Turn it on where your app calls connect(): `reticle.connect({ captureNetworkBodies: true })`, ' +
|
|
42
|
+
'or for the Vite plugin `reticle({ captureNetworkBodies: true })` / VITE_RETICLE_CAPTURE_BODIES=1. ' +
|
|
43
|
+
'Then re-run the action.';
|
|
44
|
+
/**
|
|
45
|
+
* The remedy for this session, or the honest statement that there is none.
|
|
46
|
+
*
|
|
47
|
+
* An UNKNOWN version is treated as capable. A hand-wired connect reports none, and guessing "too
|
|
48
|
+
* old" there would hide a working fix from someone who could have used it; the opposite guess costs
|
|
49
|
+
* one wasted read. The asymmetry decides it.
|
|
50
|
+
*/
|
|
51
|
+
export function bodyCaptureRemedy(sdkVersion) {
|
|
52
|
+
if (sdkVersion !== undefined && !isAtLeast(sdkVersion, BODY_CAPTURE_MIN_VERSION)) {
|
|
53
|
+
return (`this page's SDK is ${sdkVersion}, and body capture needs ${BODY_CAPTURE_MIN_VERSION} or ` +
|
|
54
|
+
'newer — the setting does not exist in your version, so there is nothing to switch on. ' +
|
|
55
|
+
'Upgrade the SDK, or assert on something else this session can see.');
|
|
56
|
+
}
|
|
57
|
+
return ENABLE_IT;
|
|
58
|
+
}
|
|
59
|
+
/** Clause names that can only be answered from a recorded body. */
|
|
60
|
+
const BODY_CLAUSE_FIELDS = ['bodyContains', 'requestBodyContains'];
|
|
61
|
+
/** Does this predicate, or anything nested in it, ask about a body? */
|
|
62
|
+
function asksAboutBody(predicate) {
|
|
63
|
+
if (null === predicate || 'object' !== typeof predicate)
|
|
64
|
+
return false;
|
|
65
|
+
const node = predicate;
|
|
66
|
+
if (BODY_CLAUSE_FIELDS.some((f) => node[f] !== undefined))
|
|
67
|
+
return true;
|
|
68
|
+
// The reported shape is an `allOf` carrying route + console + the net clause that needs bodies.
|
|
69
|
+
// Checking only the top level would miss every realistic call.
|
|
70
|
+
const nested = node['predicates'] ?? node['predicate'];
|
|
71
|
+
if (Array.isArray(nested))
|
|
72
|
+
return nested.some(asksAboutBody);
|
|
73
|
+
return asksAboutBody(nested);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Refuse a body clause the session cannot answer, BEFORE the action is spent.
|
|
77
|
+
*
|
|
78
|
+
* Reported: an `act_and_wait` matched the right call and returned `verified: "no"` with "a matching
|
|
79
|
+
* call with no recorded body", because that project's `connect()` does not pass
|
|
80
|
+
* `captureNetworkBodies` — and the reporter could not change it, since it was not their project's
|
|
81
|
+
* config to edit for an unrelated verification task. The action bought nothing that was not knowable
|
|
82
|
+
* in advance, and on a drive that mutates state an action is not always repeatable. That is what
|
|
83
|
+
* makes this a pre-flight rather than a better failure message.
|
|
84
|
+
*
|
|
85
|
+
* Refuses ONLY on a DECLARED `captureBodies: false`. An SDK too old to announce the setting sends
|
|
86
|
+
* nothing, and refusing on silence would break every session predating the announcement for a clause
|
|
87
|
+
* many of them satisfy — the same asymmetry that makes an unknown VERSION count as capable.
|
|
88
|
+
*/
|
|
89
|
+
export function bodyClauseRefusal(predicate, session) {
|
|
90
|
+
if (false !== session.captureBodies)
|
|
91
|
+
return undefined;
|
|
92
|
+
if (!asksAboutBody(predicate))
|
|
93
|
+
return undefined;
|
|
94
|
+
return ('this assertion reads a request/response BODY, and this session is not recording them — it ' +
|
|
95
|
+
`would fail whatever the app did. Nothing ran, so no action was spent. ${bodyCaptureRemedy(session.sdkVersion)}`);
|
|
96
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type InstrumentationGap } from '@reticlehq/core/artifacts';
|
|
2
|
+
/**
|
|
3
|
+
* What this session still cannot see, accumulated across its verdicts.
|
|
4
|
+
*
|
|
5
|
+
* A gap reported on one verdict and then forgotten is a note. A gap that is still standing when the
|
|
6
|
+
* agent asks "am I done?" is a piece of work — and that difference is the entire discipline
|
|
7
|
+
* mechanism, because an agent finishing a task is the one moment it will act on a cost it can close.
|
|
8
|
+
*
|
|
9
|
+
* ## Why the LAST verdict decides, not the whole history
|
|
10
|
+
*
|
|
11
|
+
* The honest question is "is this app still unverifiable in this way", not "was it ever". An agent
|
|
12
|
+
* that hits a gap, adds the build plugin and re-verifies has CLOSED it — the later verdict simply
|
|
13
|
+
* stops emitting that kind — and a ledger that still reported it would punish exactly the behaviour
|
|
14
|
+
* this exists to cause. Nobody instruments an app twice for a tool that never notices the first time.
|
|
15
|
+
*
|
|
16
|
+
* So `open()` reflects the most recent verdict, and `everSeen` is kept separately for the summary,
|
|
17
|
+
* where "you hit this and fixed it" is worth saying and is not a reason to withhold done.
|
|
18
|
+
*/
|
|
19
|
+
export declare class GapLedger {
|
|
20
|
+
#private;
|
|
21
|
+
/**
|
|
22
|
+
* Record what the verdict just reported. An empty list is a real observation — it is how a gap
|
|
23
|
+
* gets closed — so it must not be ignored as "nothing to record".
|
|
24
|
+
*/
|
|
25
|
+
note(gaps: readonly InstrumentationGap[]): void;
|
|
26
|
+
/** Gaps the most recent verdict still reported. The ones that are work right now. */
|
|
27
|
+
open(): readonly InstrumentationGap[];
|
|
28
|
+
/** Every kind seen in this session, including ones since closed. */
|
|
29
|
+
get everSeen(): readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* Did this session leave the app less verifiable than it could be?
|
|
32
|
+
*
|
|
33
|
+
* The one question a "have I finished" call needs answered, and the one a session summary turns
|
|
34
|
+
* into `unproven` rather than `verified`.
|
|
35
|
+
*/
|
|
36
|
+
get hasOpen(): boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Record a verdict's gaps against the session that produced it.
|
|
40
|
+
*
|
|
41
|
+
* Tolerates a session with no ledger, and that is a statement about the seam rather than a hedge:
|
|
42
|
+
* `Session` is satisfied structurally, and dozens of specs — plus any consumer embedding this engine
|
|
43
|
+
* — build one as an object literal rather than through the constructor. Such a session is a real
|
|
44
|
+
* caller, it simply keeps no ledger, and recording is a side effect that must never be the reason a
|
|
45
|
+
* verdict fails to return.
|
|
46
|
+
*
|
|
47
|
+
* One helper rather than an optional-chain at each call site: the tolerance is a decision, and a
|
|
48
|
+
* decision spelled `?.` in two places is one nobody can find later.
|
|
49
|
+
*/
|
|
50
|
+
export declare function noteSessionGaps(session: {
|
|
51
|
+
gaps?: GapLedger;
|
|
52
|
+
}, gaps: readonly InstrumentationGap[]): void;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { dedupeGaps } from '@reticlehq/core/artifacts';
|
|
2
|
+
/**
|
|
3
|
+
* What this session still cannot see, accumulated across its verdicts.
|
|
4
|
+
*
|
|
5
|
+
* A gap reported on one verdict and then forgotten is a note. A gap that is still standing when the
|
|
6
|
+
* agent asks "am I done?" is a piece of work — and that difference is the entire discipline
|
|
7
|
+
* mechanism, because an agent finishing a task is the one moment it will act on a cost it can close.
|
|
8
|
+
*
|
|
9
|
+
* ## Why the LAST verdict decides, not the whole history
|
|
10
|
+
*
|
|
11
|
+
* The honest question is "is this app still unverifiable in this way", not "was it ever". An agent
|
|
12
|
+
* that hits a gap, adds the build plugin and re-verifies has CLOSED it — the later verdict simply
|
|
13
|
+
* stops emitting that kind — and a ledger that still reported it would punish exactly the behaviour
|
|
14
|
+
* this exists to cause. Nobody instruments an app twice for a tool that never notices the first time.
|
|
15
|
+
*
|
|
16
|
+
* So `open()` reflects the most recent verdict, and `everSeen` is kept separately for the summary,
|
|
17
|
+
* where "you hit this and fixed it" is worth saying and is not a reason to withhold done.
|
|
18
|
+
*/
|
|
19
|
+
export class GapLedger {
|
|
20
|
+
#open = [];
|
|
21
|
+
#everSeen = new Set();
|
|
22
|
+
/**
|
|
23
|
+
* Record what the verdict just reported. An empty list is a real observation — it is how a gap
|
|
24
|
+
* gets closed — so it must not be ignored as "nothing to record".
|
|
25
|
+
*/
|
|
26
|
+
note(gaps) {
|
|
27
|
+
this.#open = dedupeGaps(gaps);
|
|
28
|
+
for (const gap of gaps)
|
|
29
|
+
this.#everSeen.add(gap.kind);
|
|
30
|
+
}
|
|
31
|
+
/** Gaps the most recent verdict still reported. The ones that are work right now. */
|
|
32
|
+
open() {
|
|
33
|
+
return this.#open;
|
|
34
|
+
}
|
|
35
|
+
/** Every kind seen in this session, including ones since closed. */
|
|
36
|
+
get everSeen() {
|
|
37
|
+
return [...this.#everSeen];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Did this session leave the app less verifiable than it could be?
|
|
41
|
+
*
|
|
42
|
+
* The one question a "have I finished" call needs answered, and the one a session summary turns
|
|
43
|
+
* into `unproven` rather than `verified`.
|
|
44
|
+
*/
|
|
45
|
+
get hasOpen() {
|
|
46
|
+
return this.#open.length > 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Record a verdict's gaps against the session that produced it.
|
|
51
|
+
*
|
|
52
|
+
* Tolerates a session with no ledger, and that is a statement about the seam rather than a hedge:
|
|
53
|
+
* `Session` is satisfied structurally, and dozens of specs — plus any consumer embedding this engine
|
|
54
|
+
* — build one as an object literal rather than through the constructor. Such a session is a real
|
|
55
|
+
* caller, it simply keeps no ledger, and recording is a side effect that must never be the reason a
|
|
56
|
+
* verdict fails to return.
|
|
57
|
+
*
|
|
58
|
+
* One helper rather than an optional-chain at each call site: the tolerance is a decision, and a
|
|
59
|
+
* decision spelled `?.` in two places is one nobody can find later.
|
|
60
|
+
*/
|
|
61
|
+
export function noteSessionGaps(session, gaps) {
|
|
62
|
+
session.gaps?.note(gaps);
|
|
63
|
+
}
|