@reticlehq/core 2.14.0 → 3.2.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/{artifacts-entry.d.ts → artifacts/artifacts-entry.d.ts} +7 -7
- package/dist/{artifacts-entry.js → artifacts/artifacts-entry.js} +7 -7
- package/dist/artifacts/flow-composition.d.ts +30 -0
- package/dist/artifacts/flow-composition.js +19 -0
- package/dist/{flow-constants.d.ts → artifacts/flow-constants.d.ts} +99 -3
- package/dist/{flow-constants.js → artifacts/flow-constants.js} +108 -4
- package/dist/artifacts/flow-mutation-target.d.ts +39 -0
- package/dist/artifacts/flow-mutation-target.js +89 -0
- package/dist/artifacts/flow-order.d.ts +30 -0
- package/dist/artifacts/flow-order.js +49 -0
- package/dist/artifacts/flow-select.d.ts +56 -0
- package/dist/artifacts/flow-select.js +56 -0
- package/dist/artifacts/flow-step-tool.d.ts +31 -0
- package/dist/artifacts/flow-step-tool.js +31 -0
- package/dist/artifacts/flow-types.d.ts +3736 -0
- package/dist/artifacts/flow-types.js +463 -0
- package/dist/artifacts/flow-unreached.d.ts +12 -0
- package/dist/artifacts/flow-unreached.js +24 -0
- package/dist/{impact.d.ts → artifacts/impact.d.ts} +271 -103
- package/dist/{impact.js → artifacts/impact.js} +75 -5
- package/dist/artifacts/journal.d.ts +218 -0
- package/dist/artifacts/journal.js +130 -0
- package/dist/artifacts/step-effect.d.ts +29 -0
- package/dist/artifacts/step-effect.js +28 -0
- package/dist/hooks/hook-events.d.ts +311 -0
- package/dist/hooks/hook-events.js +127 -0
- package/dist/hooks/hooks-entry.d.ts +9 -0
- package/dist/hooks/hooks-entry.js +9 -0
- package/dist/identity/brand.d.ts +102 -0
- package/dist/{brand.js → identity/brand.js} +7 -0
- package/dist/{contract-fingerprint.d.ts → identity/contract-fingerprint.d.ts} +21 -3
- package/dist/{contract-fingerprint.js → identity/contract-fingerprint.js} +22 -4
- package/dist/{document-identity.d.ts → identity/document-identity.d.ts} +4 -5
- package/dist/{document-identity.js → identity/document-identity.js} +4 -5
- package/dist/{source-constants.d.ts → identity/source-constants.d.ts} +4 -4
- package/dist/{source-constants.js → identity/source-constants.js} +4 -4
- package/dist/index.d.ts +57 -43
- package/dist/index.js +66 -45
- package/dist/onboarding.d.ts +114 -0
- package/dist/onboarding.js +141 -0
- package/dist/realm/registry.d.ts +212 -0
- package/dist/realm/registry.js +302 -0
- package/dist/{dev-server-registry.d.ts → registry/dev-server-registry.d.ts} +6 -7
- package/dist/{dev-server-registry.js → registry/dev-server-registry.js} +28 -19
- package/dist/{project-registry.d.ts → registry/project-registry.d.ts} +5 -5
- package/dist/{project-registry.js → registry/project-registry.js} +5 -5
- package/dist/schema/command-name.json +31 -0
- package/dist/schema/event-payloads.json +795 -0
- package/dist/schema/hello-message.json +70 -2
- package/dist/schema/reticle-message.json +70 -2
- package/dist/telemetry-entry.d.ts +1 -1
- package/dist/telemetry-entry.js +1 -1
- package/dist/telemetry-feedback.d.ts +15 -16
- package/dist/telemetry-feedback.js +11 -12
- package/dist/telemetry-license.d.ts +1 -1
- package/dist/telemetry-license.js +1 -1
- package/dist/telemetry-refusal.d.ts +11 -11
- package/dist/telemetry-refusal.js +7 -8
- package/dist/telemetry-session.d.ts +51 -59
- package/dist/telemetry-session.js +47 -55
- package/dist/telemetry.d.ts +306 -222
- package/dist/telemetry.js +112 -99
- package/dist/tour-entry.d.ts +10 -0
- package/dist/tour-entry.js +10 -0
- package/dist/tour.d.ts +125 -0
- package/dist/tour.js +165 -0
- package/dist/{consequence.d.ts → verdict/consequence.d.ts} +32 -15
- package/dist/{consequence.js → verdict/consequence.js} +9 -31
- package/dist/{finding-fingerprint.js → verdict/finding-fingerprint.js} +1 -1
- package/dist/{findings.d.ts → verdict/findings.d.ts} +86 -39
- package/dist/{findings.js → verdict/findings.js} +103 -49
- package/dist/{instrumentation-gap.d.ts → verdict/instrumentation-gap.d.ts} +7 -14
- package/dist/{instrumentation-gap.js → verdict/instrumentation-gap.js} +7 -15
- package/dist/{intent.d.ts → verdict/intent.d.ts} +35 -46
- package/dist/{intent.js → verdict/intent.js} +11 -22
- package/dist/verdict/revision.d.ts +44 -0
- package/dist/verdict/revision.js +53 -0
- package/dist/{run-context.d.ts → verdict/run-context.d.ts} +13 -34
- package/dist/{run-context.js → verdict/run-context.js} +15 -36
- package/dist/{security.js → verdict/security.js} +12 -21
- package/dist/{verification-run.d.ts → verdict/verification-run.d.ts} +381 -105
- package/dist/{verification-run.js → verdict/verification-run.js} +157 -21
- package/dist/{verified-constants.d.ts → verdict/verified-constants.d.ts} +34 -13
- package/dist/{verified-constants.js → verdict/verified-constants.js} +34 -13
- package/dist/{verify-progress.d.ts → verdict/verify-progress.d.ts} +18 -22
- package/dist/{verify-progress.js → verdict/verify-progress.js} +6 -10
- package/dist/wire/channel.d.ts +46 -0
- package/dist/wire/channel.js +95 -0
- package/dist/{constants.d.ts → wire/constants/constants.d.ts} +179 -28
- package/dist/{constants.js → wire/constants/constants.js} +199 -28
- package/dist/{session-constants.d.ts → wire/constants/session-constants.d.ts} +23 -2
- package/dist/{session-constants.js → wire/constants/session-constants.js} +23 -2
- package/dist/{desktop-contract.js → wire/desktop-contract.js} +1 -1
- package/dist/{event-classification.js → wire/event-classification.js} +1 -1
- package/dist/{event-payloads.d.ts → wire/event-payloads.d.ts} +72 -13
- package/dist/{event-payloads.js → wire/event-payloads.js} +23 -3
- package/dist/{event-priority.d.ts → wire/event-priority.d.ts} +1 -4
- package/dist/{event-priority.js → wire/event-priority.js} +2 -5
- package/dist/{global-press.js → wire/global-press.js} +1 -1
- package/dist/{messages.d.ts → wire/messages.d.ts} +240 -48
- package/dist/{messages.js → wire/messages.js} +68 -5
- package/dist/wire/narrow.d.ts +39 -0
- package/dist/wire/narrow.js +45 -0
- package/dist/{net.d.ts → wire/net.d.ts} +36 -13
- package/dist/{net.js → wire/net.js} +36 -13
- package/dist/wire/platform.d.ts +37 -0
- package/dist/wire/platform.js +36 -0
- package/dist/{redaction.js → wire/redaction.js} +12 -12
- package/dist/wire/snapshot-tree.d.ts +33 -0
- package/dist/wire/snapshot-tree.js +43 -0
- package/dist/wire/tool-names.d.ts +133 -0
- package/dist/wire/tool-names.js +142 -0
- package/dist/{toon.js → wire/toon.js} +1 -1
- package/dist/{types.d.ts → wire/types.d.ts} +77 -76
- package/dist/{types.js → wire/types.js} +4 -3
- package/dist/{no-session-reason.d.ts → words/no-session-reason.d.ts} +7 -3
- package/dist/{no-session-reason.js → words/no-session-reason.js} +7 -3
- package/dist/{notices.d.ts → words/notices.d.ts} +8 -12
- package/dist/{notices.js → words/notices.js} +8 -12
- package/package.json +16 -7
- package/dist/brand.d.ts +0 -49
- package/dist/flow-types.d.ts +0 -1711
- package/dist/flow-types.js +0 -247
- package/dist/journal.d.ts +0 -122
- package/dist/journal.js +0 -57
- package/dist/{impact-savings.d.ts → artifacts/impact-savings.d.ts} +0 -0
- package/dist/{impact-savings.js → artifacts/impact-savings.js} +0 -0
- package/dist/{edit-epoch.d.ts → identity/edit-epoch.d.ts} +0 -0
- package/dist/{edit-epoch.js → identity/edit-epoch.js} +0 -0
- package/dist/{project-id.d.ts → identity/project-id.d.ts} +0 -0
- package/dist/{project-id.js → identity/project-id.js} +0 -0
- package/dist/{daemon-registry.d.ts → registry/daemon-registry.d.ts} +0 -0
- package/dist/{daemon-registry.js → registry/daemon-registry.js} +0 -0
- package/dist/{finding-fingerprint.d.ts → verdict/finding-fingerprint.d.ts} +0 -0
- package/dist/{security.d.ts → verdict/security.d.ts} +0 -0
- package/dist/{desktop-contract.d.ts → wire/desktop-contract.d.ts} +0 -0
- package/dist/{event-classification.d.ts → wire/event-classification.d.ts} +0 -0
- package/dist/{global-press.d.ts → wire/global-press.d.ts} +0 -0
- package/dist/{redaction.d.ts → wire/redaction.d.ts} +0 -0
- package/dist/{state-select.d.ts → wire/state-select.d.ts} +0 -0
- package/dist/{state-select.js → wire/state-select.js} +0 -0
- package/dist/{toon.d.ts → wire/toon.d.ts} +0 -0
- package/dist/{browser-misdirect.d.ts → words/browser-misdirect.d.ts} +0 -0
- package/dist/{browser-misdirect.js → words/browser-misdirect.js} +0 -0
- package/dist/{unreachable-notice.d.ts → words/unreachable-notice.d.ts} +0 -0
- package/dist/{unreachable-notice.js → words/unreachable-notice.js} +0 -0
- package/dist/{upgrade.d.ts → words/upgrade.d.ts} +2 -2
- /package/dist/{upgrade.js → words/upgrade.js} +0 -0
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CROSS_STEP_ADDRESS, FlowStepTool } from './flow-step-tool.js';
|
|
3
|
+
import { StepEffect } from './step-effect.js';
|
|
4
|
+
export { CROSS_STEP_ADDRESS, FlowStepTool } from './flow-step-tool.js';
|
|
5
|
+
import { ActionType } from '../wire/constants/constants.js';
|
|
6
|
+
import { CONSEQUENCE_KINDS } from '../verdict/consequence.js';
|
|
7
|
+
// Its own directory's constants, which this file had been reaching through `wire/constants/constants.js`
|
|
8
|
+
// to get -- the clearest cost of that re-export: artifacts went out to wire to fetch a symbol
|
|
9
|
+
// that had been sitting next door the whole time.
|
|
10
|
+
import { AnchorKind, FLOW_FILE_VERSION, FlowStatus, } from './flow-constants.js';
|
|
11
|
+
/**
|
|
12
|
+
* A semantic anchor: how a step re-finds its element/event at replay
|
|
13
|
+
* time. Never a volatile eXX ref. testid/role+name bind a DOM element; signal binds an event.
|
|
14
|
+
*/
|
|
15
|
+
export const FlowAnchorSchema = z.discriminatedUnion('kind', [
|
|
16
|
+
// `source` is provenance, not part of how the step re-finds its element — the testid does that.
|
|
17
|
+
// It rides along so a failure can say which file to open; optional, so existing flow files parse
|
|
18
|
+
// unchanged and FLOW_FILE_VERSION does not move.
|
|
19
|
+
z.object({
|
|
20
|
+
kind: z.literal(AnchorKind.TESTID),
|
|
21
|
+
value: z.string().min(1),
|
|
22
|
+
source: z
|
|
23
|
+
.object({ file: z.string(), line: z.number(), column: z.number().optional() })
|
|
24
|
+
.optional(),
|
|
25
|
+
}),
|
|
26
|
+
z.object({
|
|
27
|
+
kind: z.literal(AnchorKind.ROLE),
|
|
28
|
+
role: z.string().min(1),
|
|
29
|
+
name: z.string().optional(),
|
|
30
|
+
}),
|
|
31
|
+
z.object({ kind: z.literal(AnchorKind.SIGNAL), name: z.string().min(1) }),
|
|
32
|
+
// Auto-anchor: re-find an element by component identity / source location when it has no testid.
|
|
33
|
+
// component or source carries the durable signal; role/name are disambiguating extras.
|
|
34
|
+
z.object({
|
|
35
|
+
kind: z.literal(AnchorKind.COMPONENT),
|
|
36
|
+
component: z.string().optional(),
|
|
37
|
+
source: z
|
|
38
|
+
.object({ file: z.string(), line: z.number(), column: z.number().optional() })
|
|
39
|
+
.optional(),
|
|
40
|
+
role: z.string().optional(),
|
|
41
|
+
name: z.string().optional(),
|
|
42
|
+
}),
|
|
43
|
+
]);
|
|
44
|
+
/**
|
|
45
|
+
* A post-condition a step asserts (compiled from a structured annotation; optional).
|
|
46
|
+
*
|
|
47
|
+
* Strict, at every nesting level: an unrecognized key (a typo, or a predicate kind this schema
|
|
48
|
+
* doesn't model, e.g. `allOf`, or a typo'd `net`/`console`/`element`/`state` sub-field) must fail
|
|
49
|
+
* to parse instead of being silently dropped. A loose z.object() here would quietly discard the
|
|
50
|
+
* extra key and leave the step with a weaker (or empty) assertion than its author wrote — the
|
|
51
|
+
* flow then replays green against nothing, having proved no real regression.
|
|
52
|
+
*/
|
|
53
|
+
export const FlowExpectSchema = z
|
|
54
|
+
.object({
|
|
55
|
+
/**
|
|
56
|
+
* The route the step must have reached — the consequence of a NAVIGATION.
|
|
57
|
+
*
|
|
58
|
+
* Absent until now, and its absence was not a corner case: navigation is one of the commonest
|
|
59
|
+
* journeys there is, and every route-asserted drive saved a flow that could never go red. Found
|
|
60
|
+
* by driving a real app, where `act_and_wait { until: { kind: "route" } }` returned
|
|
61
|
+
* `verified: "yes"` and the flow saved from that same drive graded `assertion-free`.
|
|
62
|
+
*
|
|
63
|
+
* Additive and optional, so a flow file written before it still parses and FLOW_FILE_VERSION
|
|
64
|
+
* stays 1 — the same treatment `signalData` and `signalCount` had.
|
|
65
|
+
*/
|
|
66
|
+
route: z
|
|
67
|
+
.object({ pathname: z.string().optional(), contains: z.string().optional() })
|
|
68
|
+
.optional(),
|
|
69
|
+
signal: z.string().optional(),
|
|
70
|
+
/**
|
|
71
|
+
* Optional payload shape an `assert-signal` annotation requires the signal
|
|
72
|
+
* to match (the predicate DSL's signal.dataMatches). Additive/optional — a flow file with a
|
|
73
|
+
* bare `signal` still parses, and the on-disk version stays FLOW_FILE_VERSION 1.
|
|
74
|
+
*/
|
|
75
|
+
signalData: z.record(z.unknown()).optional(),
|
|
76
|
+
/**
|
|
77
|
+
* Exact number of times the signal must have fired — the signal-side twin of `net.count`, and the
|
|
78
|
+
* only way a saved flow can keep a cardinality the agent actually asserted. Without it a
|
|
79
|
+
* `count: 1` drive would be recorded as bare presence, which is a strictly WEAKER claim than the
|
|
80
|
+
* one made: the replayed flow then goes green on the double-fire it was recorded to catch.
|
|
81
|
+
* Additive/optional — a flow file with a bare `signal` still parses, and FLOW_FILE_VERSION stays 1.
|
|
82
|
+
*/
|
|
83
|
+
signalCount: z.number().int().nonnegative().optional(),
|
|
84
|
+
net: z
|
|
85
|
+
.object({
|
|
86
|
+
method: z.string().optional(),
|
|
87
|
+
urlContains: z.string().optional(),
|
|
88
|
+
status: z.number().optional(),
|
|
89
|
+
/**
|
|
90
|
+
* Exact number of matching requests since the action — turns presence into a cardinality
|
|
91
|
+
* assertion. Catches the double-submit / useEffect-double-fire / retry-storm regression class:
|
|
92
|
+
* the request fired (presence passes) but fired the WRONG number of times. Omit = presence (≥1).
|
|
93
|
+
*/
|
|
94
|
+
count: z.number().int().nonnegative().optional(),
|
|
95
|
+
})
|
|
96
|
+
.strict()
|
|
97
|
+
.optional(),
|
|
98
|
+
/**
|
|
99
|
+
* Console golden end-condition: assert the action logged (or, with absent:true, did NOT log) a
|
|
100
|
+
* console message at `level` (default 'error'). `absent:true` is the common case — "the action
|
|
101
|
+
* completed with a clean console" — catching the regression where an action throws a caught error
|
|
102
|
+
* / logs an uncaught rejection while the UI still renders fine (a presence check passes it).
|
|
103
|
+
*/
|
|
104
|
+
console: z
|
|
105
|
+
.object({
|
|
106
|
+
level: z.string().optional(),
|
|
107
|
+
absent: z.boolean().optional(),
|
|
108
|
+
})
|
|
109
|
+
.strict()
|
|
110
|
+
.optional(),
|
|
111
|
+
element: z
|
|
112
|
+
.object({
|
|
113
|
+
testid: z.string().optional(),
|
|
114
|
+
role: z.string().optional(),
|
|
115
|
+
name: z.string().optional(),
|
|
116
|
+
})
|
|
117
|
+
.strict()
|
|
118
|
+
.optional(),
|
|
119
|
+
/**
|
|
120
|
+
* Rendered text as an end-condition, using the shapes the assert surface already accepts.
|
|
121
|
+
*
|
|
122
|
+
* The gap this closes: an app with no testids, no `reticle.signal`, no registrable store and no
|
|
123
|
+
* network call on the interaction under test -- a discount price computed and rendered, a
|
|
124
|
+
* formatted total, a derived label -- could not produce an asserted flow AT ALL. Everything the
|
|
125
|
+
* vocabulary offered needed a channel that app does not have, so the only honest outcome was
|
|
126
|
+
* `assertion-free`, which is a permanent green (#811).
|
|
127
|
+
*
|
|
128
|
+
* Derived-DOM rendering is a large share of what actually breaks in a UI, and it was the share
|
|
129
|
+
* that could not be pinned.
|
|
130
|
+
*
|
|
131
|
+
* Classified PRESENCE, not consequence, and that is not a technicality: text is read from the
|
|
132
|
+
* DOM, so a locator healed to the wrong element can still satisfy it. It earns `presence-only`,
|
|
133
|
+
* which is a real grade above `assertion-free` and honestly below `signal`/`net`/`state`.
|
|
134
|
+
*/
|
|
135
|
+
text: z
|
|
136
|
+
.object({
|
|
137
|
+
contains: z.string().min(1),
|
|
138
|
+
/** Narrow the search to a container, exactly as the `text` predicate's `scope` does. */
|
|
139
|
+
scope: z.string().optional(),
|
|
140
|
+
/** Assert the text is GONE — the regression check for a cleared error or a dismissed toast. */
|
|
141
|
+
absent: z.boolean().optional(),
|
|
142
|
+
/** Require the match to be visible, not merely present in the DOM. */
|
|
143
|
+
visible: z.boolean().optional(),
|
|
144
|
+
})
|
|
145
|
+
.strict()
|
|
146
|
+
.optional(),
|
|
147
|
+
/**
|
|
148
|
+
* Assert a registered store's value — the source of truth no DOM/network read can reach. Compiles
|
|
149
|
+
* to the predicate engine's `state` predicate. Additive/optional — a flow without it still parses
|
|
150
|
+
* and the on-disk version stays FLOW_FILE_VERSION 1. `equals` accepts a literal, omitted = presence,
|
|
151
|
+
* or a `{ $gte | $contains | $length }` operator pattern.
|
|
152
|
+
*/
|
|
153
|
+
state: z
|
|
154
|
+
.object({
|
|
155
|
+
store: z.string().optional(),
|
|
156
|
+
path: z.string(),
|
|
157
|
+
equals: z.unknown().optional(),
|
|
158
|
+
/**
|
|
159
|
+
* Treat this as an INVARIANT that must still hold AFTER the action settles, rather than a
|
|
160
|
+
* condition to wait for. Set it for a blast-radius check ("this unrelated path must NOT have
|
|
161
|
+
* moved") — without it a wait-until-true read passes before an over-reaching side-effect lands.
|
|
162
|
+
*/
|
|
163
|
+
hold: z.boolean().optional(),
|
|
164
|
+
})
|
|
165
|
+
.strict()
|
|
166
|
+
.optional(),
|
|
167
|
+
})
|
|
168
|
+
.strict();
|
|
169
|
+
const baseFlowStep = z.object({
|
|
170
|
+
tool: z.string(),
|
|
171
|
+
anchor: FlowAnchorSchema,
|
|
172
|
+
/**
|
|
173
|
+
* Where this step's element came from in the source, when the build stamped one.
|
|
174
|
+
*
|
|
175
|
+
* Written alongside the anchor rather than inside it, because only a COMPONENT anchor had a place
|
|
176
|
+
* for a source and a recorder prefers a TESTID anchor whenever the element has one — so the most
|
|
177
|
+
* common flow in existence could never say which files it covers. `reticle_verify { action:
|
|
178
|
+
* "change" }` then had nothing to scope by and re-ran the whole suite: measured on this repo's own
|
|
179
|
+
* flows, 52 replayed, 46 seconds, verdict `unknown`.
|
|
180
|
+
*
|
|
181
|
+
* Optional, and its absence still means unknown provenance, which is still re-run by default. The
|
|
182
|
+
* fail-safe must keep failing safe.
|
|
183
|
+
*/
|
|
184
|
+
source: z
|
|
185
|
+
.object({ file: z.string().min(1), line: z.number().int().positive().optional() })
|
|
186
|
+
.optional(),
|
|
187
|
+
/**
|
|
188
|
+
* A name for this step that survives editing the flow.
|
|
189
|
+
*
|
|
190
|
+
* Resume targets a step, and targeting it by POSITION breaks the moment one is inserted, removed
|
|
191
|
+
* or healed: "resume from 4" quietly means a different step than it did yesterday and nothing
|
|
192
|
+
* reports the shift. Optional and back-compat — a flow without ids resumes by index exactly as
|
|
193
|
+
* before, which is every flow recorded before this shipped.
|
|
194
|
+
*/
|
|
195
|
+
id: z.string().min(1).optional(),
|
|
196
|
+
/** What this step does to the subject; absent means unknown. See StepEffect. */
|
|
197
|
+
effect: z.nativeEnum(StepEffect).optional(),
|
|
198
|
+
action: z.nativeEnum(ActionType).optional(),
|
|
199
|
+
args: z.record(z.unknown()).optional(),
|
|
200
|
+
expect: FlowExpectSchema.optional(),
|
|
201
|
+
degraded: z.boolean().optional(),
|
|
202
|
+
timeoutMs: z.number().int().positive().optional(),
|
|
203
|
+
invoke: z.string().min(1).optional(),
|
|
204
|
+
});
|
|
205
|
+
export const FlowStepSchema = baseFlowStep.extend({
|
|
206
|
+
steps: z.lazy(() => z.array(FlowStepSchema).optional()),
|
|
207
|
+
});
|
|
208
|
+
/**
|
|
209
|
+
* The on-disk flow file: diffable, git-tracked, anchor-resolved.
|
|
210
|
+
* The optional `dynamic` field (both `dynamic` + `success` are optional, so a
|
|
211
|
+
* file with neither still parses — back-compat is locked by a test).
|
|
212
|
+
*/
|
|
213
|
+
export const FlowFileSchema = z.object({
|
|
214
|
+
version: z.literal(FLOW_FILE_VERSION),
|
|
215
|
+
name: z.string(),
|
|
216
|
+
/**
|
|
217
|
+
* The business goal this flow exists to verify, one line (e.g. "ship a deploy to production").
|
|
218
|
+
* Optional + back-compat (a flow without it still parses). Set via an `intent` annotation. The
|
|
219
|
+
* point of "intent + outcome oracle": a flow that declares an intent should also assert an
|
|
220
|
+
* observable business OUTCOME (a consequence success-state), or it claims to verify a goal it
|
|
221
|
+
* cannot actually check — flow-classify flags that gap.
|
|
222
|
+
*/
|
|
223
|
+
intent: z.string().optional(),
|
|
224
|
+
/**
|
|
225
|
+
* The intent-ledger row this flow discharges — the id in `.reticle/intent.json`.
|
|
226
|
+
*
|
|
227
|
+
* `intent` above is the prose a recorder captured; this is the LINK to the ledger that already
|
|
228
|
+
* models declared → bound → proved and records which verdict discharged what. Without it there
|
|
229
|
+
* would be two ways to say what a change is for, which is the defect this codebase keeps paying
|
|
230
|
+
* for: a flow's goal and an intent's statement would drift apart with nothing to reconcile them.
|
|
231
|
+
*
|
|
232
|
+
* Set at save time from the flow's own prose, or written by hand to point a flow at an intent
|
|
233
|
+
* declared earlier via `reticle_intent` — a flow can prove something somebody else declared.
|
|
234
|
+
* Optional + back-compat: a flow without it replays exactly as before, and the on-disk version
|
|
235
|
+
* stays FLOW_FILE_VERSION 1.
|
|
236
|
+
*/
|
|
237
|
+
intentId: z.string().optional(),
|
|
238
|
+
/**
|
|
239
|
+
* The project the flow was recorded against (the connecting session's HELLO `projectId`), stamped at
|
|
240
|
+
* save time. Scopes a flow to its app so a shared daemon's HUD lists only the current project's flows
|
|
241
|
+
* instead of every project that ever saved to that daemon. Optional + back-compat: a flow with no
|
|
242
|
+
* projectId is treated as global (visible everywhere), so pre-existing files parse and still show.
|
|
243
|
+
*/
|
|
244
|
+
projectId: z.string().optional(),
|
|
245
|
+
/**
|
|
246
|
+
* The route (pathname) the journey started on, captured at record time. Replay navigates here
|
|
247
|
+
* before step 1 so a flow whose first anchor lives on another page doesn't drift on step 1 ("a
|
|
248
|
+
* step no longer matches") just because replay began on the wrong page. Optional + back-compat: a
|
|
249
|
+
* flow without it (or recorded before this shipped) replays from the current page as before, and
|
|
250
|
+
* the on-disk version stays FLOW_FILE_VERSION 1.
|
|
251
|
+
*/
|
|
252
|
+
startPath: z.string().optional(),
|
|
253
|
+
// FUTURE: fixtures/preconditions — schema slot reserved, unpopulated this cut. The recorder
|
|
254
|
+
// never writes it and no fixture runner exists.
|
|
255
|
+
fixture: z.string().optional(),
|
|
256
|
+
/**
|
|
257
|
+
* What must already be true for this flow to mean anything, and what it leaves true.
|
|
258
|
+
*
|
|
259
|
+
* These are the two halves of composition. Replaying flows back to back only works when the state
|
|
260
|
+
* one leaves is the state the next expects, and nothing said so — so a suite either got lucky or
|
|
261
|
+
* produced a failure that looked like a regression and was a missing precondition. `requires` lets
|
|
262
|
+
* a replay report THAT instead: not met is `unknown` (nothing ran, nothing proved), never a
|
|
263
|
+
* failure, which is the same honesty rule an uncovered change already follows.
|
|
264
|
+
*
|
|
265
|
+
* `ensures` is the other side, and is what makes A-then-B checkable before either runs.
|
|
266
|
+
*
|
|
267
|
+
* Both optional and both absent from every flow recorded before this shipped, where absent means
|
|
268
|
+
* what it has always meant: replay from wherever the app already is, and let the steps speak.
|
|
269
|
+
* Same predicate shape as a step's `expect`, deliberately — a precondition is just a consequence
|
|
270
|
+
* somebody else's flow was responsible for.
|
|
271
|
+
*/
|
|
272
|
+
requires: z.array(FlowExpectSchema).optional(),
|
|
273
|
+
ensures: z.array(FlowExpectSchema).optional(),
|
|
274
|
+
/** From the injected clock (ms) — deterministic in tests, byte-stable on disk. */
|
|
275
|
+
createdAt: z.number(),
|
|
276
|
+
steps: z.array(FlowStepSchema),
|
|
277
|
+
/**
|
|
278
|
+
* How long every step of this flow waits for its declared consequence, in ms. A step's own
|
|
279
|
+
* `timeoutMs` wins over it; absent both, FLOW_SIGNAL_TIMEOUT_MS applies.
|
|
280
|
+
*
|
|
281
|
+
* Flow-level because slowness is usually a property of the APP, not of one control — a remote
|
|
282
|
+
* database, a model-backed endpoint, a cold container. Optional + back-compat: a flow without it
|
|
283
|
+
* replays exactly as before and the on-disk version stays FLOW_FILE_VERSION 1.
|
|
284
|
+
*/
|
|
285
|
+
signalTimeoutMs: z.number().int().positive().optional(),
|
|
286
|
+
success: FlowExpectSchema.optional(),
|
|
287
|
+
/**
|
|
288
|
+
* Anchors whose CONTENT must not be asserted (e.g. LLM output). Replay asserts
|
|
289
|
+
* presence, not words. Compiled from a `mark-dynamic` annotation.
|
|
290
|
+
*/
|
|
291
|
+
dynamic: z.array(FlowAnchorSchema).optional(),
|
|
292
|
+
/**
|
|
293
|
+
* Free-form labels a suite selects on — `smoke`, `checkout`, `slow`.
|
|
294
|
+
*
|
|
295
|
+
* Not an enum: the useful sets are the ones a team invents for its own product, and a closed list
|
|
296
|
+
* would mean shipping somebody's release process in the contract. Optional and back-compat, so
|
|
297
|
+
* every flow already on disk keeps loading.
|
|
298
|
+
*/
|
|
299
|
+
labels: z.array(z.string().min(1)).optional(),
|
|
300
|
+
/**
|
|
301
|
+
* Flows that must run, and pass, before this one.
|
|
302
|
+
*
|
|
303
|
+
* By name, because a name is what every other caller addresses a flow by. A prerequisite that is
|
|
304
|
+
* not in the run is reported rather than assumed satisfied: a checkout flow whose login was
|
|
305
|
+
* filtered out by a label would otherwise fail for a reason that has nothing to do with checkout.
|
|
306
|
+
*/
|
|
307
|
+
needs: z.array(z.string().min(1)).optional(),
|
|
308
|
+
/** Whether a suite runs this flow. Absent means active — see FlowStatus. */
|
|
309
|
+
status: z.enum([FlowStatus.ACTIVE, FlowStatus.QUARANTINED, FlowStatus.DRAFT]).optional(),
|
|
310
|
+
/**
|
|
311
|
+
* What this flow has learned from being run, as opposed to what a person wrote on it.
|
|
312
|
+
*
|
|
313
|
+
* Distinct from `knownBugs` above, and the difference is who is speaking. A known bug is a HUMAN
|
|
314
|
+
* excusing a failing assertion with a traceable id. A learned guard is the SYSTEM remembering a
|
|
315
|
+
* defect it observed: `open` while the defect is still happening, `guarded` once a run stopped
|
|
316
|
+
* showing it. Only the second state asserts anything, and its return is a regression.
|
|
317
|
+
*
|
|
318
|
+
* The ordering is the safety property. A contradiction seen right now is not an assertion:
|
|
319
|
+
* asserting "must not happen" while it happens makes the flow red over an accepted defect and
|
|
320
|
+
* trains the reader to ignore it, and asserting "does happen" pins broken behaviour so the check
|
|
321
|
+
* fires when somebody FIXES the bug. See `learnFromRun` in the engine for the rule.
|
|
322
|
+
*/
|
|
323
|
+
learned: z
|
|
324
|
+
.array(z.object({
|
|
325
|
+
kind: z.string().min(1),
|
|
326
|
+
/*
|
|
327
|
+
* A step index, or -1 for a finding that belongs to no single step.
|
|
328
|
+
*
|
|
329
|
+
* `-1` is the address this repo already uses for a whole-span contradiction (see
|
|
330
|
+
* `decision.ts`), and declaring it `nonnegative()` here made the first cross-step finding
|
|
331
|
+
* write a flow file that could never be loaded again — the narrow writer does not validate,
|
|
332
|
+
* `load` does, and the flow was lost permanently to what read like user corruption.
|
|
333
|
+
*
|
|
334
|
+
* `min(-1)` rather than any negative number: -1 is a convention somebody chose, and -2 is a
|
|
335
|
+
* bug arriving as data.
|
|
336
|
+
*/
|
|
337
|
+
step: z.number().int().min(CROSS_STEP_ADDRESS),
|
|
338
|
+
state: z.enum(['open', 'guarded']),
|
|
339
|
+
/** Consecutive runs that did not show it. One quiet run is not a fix; see learnFromRun. */
|
|
340
|
+
cleanRuns: z.number().int().nonnegative().optional(),
|
|
341
|
+
}))
|
|
342
|
+
.optional(),
|
|
343
|
+
/**
|
|
344
|
+
* Bugs this flow is KNOWN to expose, so a red for a filed reason is not re-investigated.
|
|
345
|
+
*
|
|
346
|
+
* Without it, a suite red for a known cause is indistinguishable from one that just broke: either
|
|
347
|
+
* somebody re-opens an investigation into a bug already filed, or the flow gets quarantined and
|
|
348
|
+
* stops watching the rest of the journey it covers.
|
|
349
|
+
*
|
|
350
|
+
* `assertions` is what keeps the note honest. A known-bug note is a claim about code, and code
|
|
351
|
+
* moves; a note recorded against assertions that have since changed explains away a NEW failure
|
|
352
|
+
* with an OLD excuse, which is a false green in a different costume. `staleKnownBugs` reports any
|
|
353
|
+
* note whose assertions no longer all exist, rather than trusting it.
|
|
354
|
+
*/
|
|
355
|
+
knownBugs: z
|
|
356
|
+
.array(z.object({
|
|
357
|
+
/** Required: an unattributable excuse is worse than none. An issue key, a URL, anything traceable. */
|
|
358
|
+
id: z.string().min(1),
|
|
359
|
+
summary: z.string().min(1),
|
|
360
|
+
/** Which of this flow's assertions the note was written against. */
|
|
361
|
+
assertions: z.array(z.string()),
|
|
362
|
+
}))
|
|
363
|
+
.optional(),
|
|
364
|
+
/**
|
|
365
|
+
* Why this flow is out of the suite, who owns getting it back, and since when.
|
|
366
|
+
*
|
|
367
|
+
* Required in full when quarantined, because a quarantine without a reason and an owner is a
|
|
368
|
+
* silent skip wearing a label: it removes the failure from the verdict AND the reason to ever fix
|
|
369
|
+
* it. `until` is the optional half — a date somebody has to look at it again.
|
|
370
|
+
*/
|
|
371
|
+
quarantine: z
|
|
372
|
+
.object({
|
|
373
|
+
reason: z.string().min(1),
|
|
374
|
+
since: z.string().min(1),
|
|
375
|
+
owner: z.string().min(1),
|
|
376
|
+
until: z.string().optional(),
|
|
377
|
+
})
|
|
378
|
+
.optional(),
|
|
379
|
+
});
|
|
380
|
+
/**
|
|
381
|
+
* Is this flow excluded from the suite's verdict?
|
|
382
|
+
*
|
|
383
|
+
* Quarantine takes a flow out of the verdict, which is a real power, and the failure mode is not a
|
|
384
|
+
* malformed file — it is a flow quietly leaving the suite and nobody noticing it went. So this fails
|
|
385
|
+
* TOWARD running it: an incomplete quarantine is treated as no quarantine at all. Whoever wants a
|
|
386
|
+
* flow out has to say why, who owns getting it back, and since when.
|
|
387
|
+
*
|
|
388
|
+
* A function rather than a schema rule, deliberately. The conditional form would be a zod
|
|
389
|
+
* `.refine()` — this package has none, and a refinement does not survive into the generated JSON
|
|
390
|
+
* Schema, so an implementation reading the contract from `schema/` would never see it. "Does this
|
|
391
|
+
* file parse" and "is this flow actually excluded" are two different questions; this is the second.
|
|
392
|
+
*
|
|
393
|
+
* The status is the decision and the block is the paperwork: a leftover note without the status
|
|
394
|
+
* excludes nothing, so tidying a flow back into the suite is one field.
|
|
395
|
+
*/
|
|
396
|
+
export function isQuarantined(flow) {
|
|
397
|
+
if (flow.status !== FlowStatus.QUARANTINED)
|
|
398
|
+
return false;
|
|
399
|
+
const q = flow.quarantine;
|
|
400
|
+
return (q !== undefined &&
|
|
401
|
+
'string' === typeof q.reason &&
|
|
402
|
+
q.reason.length > 0 &&
|
|
403
|
+
'string' === typeof q.owner &&
|
|
404
|
+
q.owner.length > 0 &&
|
|
405
|
+
'string' === typeof q.since &&
|
|
406
|
+
q.since.length > 0);
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* The in-page → wire payload for a finished human recording. The browser
|
|
410
|
+
* compiles captured interactions into a FlowFile-shaped object (resolving semantic anchors at
|
|
411
|
+
* capture time) and emits it as ONE EventType.FLOW_RECORDED event; the server persists it.
|
|
412
|
+
*/
|
|
413
|
+
export const RecordedFlowSchema = z.object({
|
|
414
|
+
name: z.string(),
|
|
415
|
+
flow: FlowFileSchema,
|
|
416
|
+
});
|
|
417
|
+
/**
|
|
418
|
+
* Known-bug notes that can no longer be believed.
|
|
419
|
+
*
|
|
420
|
+
* A note survives only while EVERY assertion it named is still present. Anything else — an
|
|
421
|
+
* assertion renamed, removed, or a note that named none at all — is reported rather than trusted,
|
|
422
|
+
* because the failure mode is silent and expensive: an old excuse attached to a new break reads as
|
|
423
|
+
* "known issue" and nobody looks again.
|
|
424
|
+
*
|
|
425
|
+
* A note naming no assertions is always stale. It cannot be checked against anything, so it cannot
|
|
426
|
+
* be relied on to explain anything.
|
|
427
|
+
*/
|
|
428
|
+
export function staleKnownBugs(notes, currentAssertions) {
|
|
429
|
+
const present = new Set(currentAssertions);
|
|
430
|
+
return (notes ?? []).filter((note) => 0 === note.assertions.length || !note.assertions.every((a) => present.has(a)));
|
|
431
|
+
}
|
|
432
|
+
/** True when a FlowExpect asserts at least one consequence (any of the ConsequenceKind fields set). */
|
|
433
|
+
export function flowExpectHasConsequence(expect) {
|
|
434
|
+
if (expect === undefined)
|
|
435
|
+
return false;
|
|
436
|
+
const fields = expect;
|
|
437
|
+
for (const kind of CONSEQUENCE_KINDS) {
|
|
438
|
+
if (fields[kind] !== undefined)
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* True when a FlowExpect checks ONLY presence — an element, rendered text or a route, no consequence.
|
|
445
|
+
*
|
|
446
|
+
* `text` counts here for the same reason `element` does, and leaving it out would have been the
|
|
447
|
+
* expensive kind of omission: a text-only expect would have been neither a consequence nor
|
|
448
|
+
* presence-only, so it would have fallen through to `assertion-free` — a permanent green wearing
|
|
449
|
+
* an assertion (#811). `route` is here for exactly that reason and no other.
|
|
450
|
+
*
|
|
451
|
+
* PRESENCE rather than a consequence, deliberately, and it is a close call. A route change is
|
|
452
|
+
* observed on a channel rather than queried from the DOM, so unlike `element` it cannot be
|
|
453
|
+
* satisfied by a healed-but-wrong locator — an argument for promoting it. What settles it the other
|
|
454
|
+
* way is that the LIVE verdict already grades a route assertion `presence`, and one of the two had
|
|
455
|
+
* to follow the other: a flow that graded stronger on disk than the drive that produced it would be
|
|
456
|
+
* a saved claim nobody made. Promoting both is a defensible change and a separate one, with the
|
|
457
|
+
* false-green question — can the route commit while the view does not render? — answered first.
|
|
458
|
+
*/
|
|
459
|
+
export function flowExpectIsPresenceOnly(expect) {
|
|
460
|
+
if (expect === undefined || flowExpectHasConsequence(expect))
|
|
461
|
+
return false;
|
|
462
|
+
return expect.element !== undefined || expect.text !== undefined || expect.route !== undefined;
|
|
463
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The coverage number that counts what a run never touched.
|
|
3
|
+
*
|
|
4
|
+
* `steps`/`declared` measure how much of what a run DROVE it actually proved — both go up when the
|
|
5
|
+
* suite gets more rigorous about the routes it already visits, and neither ever notices a route no
|
|
6
|
+
* flow goes near. A perfect score on two of eleven routes is not a green app, and nothing else here
|
|
7
|
+
* says so.
|
|
8
|
+
*
|
|
9
|
+
* Known routes are what the app has been SEEN to have, accumulated across runs, so this is the one
|
|
10
|
+
* figure that grows by exploring rather than by writing more assertions.
|
|
11
|
+
*/
|
|
12
|
+
export declare function unreachedRoutes(known: readonly string[], visited: readonly string[]): string[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The coverage number that counts what a run never touched.
|
|
3
|
+
*
|
|
4
|
+
* `steps`/`declared` measure how much of what a run DROVE it actually proved — both go up when the
|
|
5
|
+
* suite gets more rigorous about the routes it already visits, and neither ever notices a route no
|
|
6
|
+
* flow goes near. A perfect score on two of eleven routes is not a green app, and nothing else here
|
|
7
|
+
* says so.
|
|
8
|
+
*
|
|
9
|
+
* Known routes are what the app has been SEEN to have, accumulated across runs, so this is the one
|
|
10
|
+
* figure that grows by exploring rather than by writing more assertions.
|
|
11
|
+
*/
|
|
12
|
+
export function unreachedRoutes(known, visited) {
|
|
13
|
+
const seen = new Set(visited);
|
|
14
|
+
const out = [];
|
|
15
|
+
for (const route of known) {
|
|
16
|
+
// A route visited but never learned is not a gap — it is the opposite, so only `known` is walked.
|
|
17
|
+
if (seen.has(route))
|
|
18
|
+
continue;
|
|
19
|
+
if (out.includes(route))
|
|
20
|
+
continue;
|
|
21
|
+
out.push(route);
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|