@reticlehq/core 3.3.0 → 3.4.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.
Files changed (47) hide show
  1. package/README.md +1 -1
  2. package/dist/artifacts/flow-constants.d.ts +19 -0
  3. package/dist/artifacts/flow-constants.js +36 -1
  4. package/dist/artifacts/flow-expect-flat.d.ts +16 -16
  5. package/dist/artifacts/flow-expect-flat.js +2 -2
  6. package/dist/artifacts/flow-mutation-target.js +4 -0
  7. package/dist/artifacts/flow-types.d.ts +393 -297
  8. package/dist/artifacts/flow-types.js +17 -2
  9. package/dist/artifacts/journal.d.ts +3 -2
  10. package/dist/hooks/hook-events.d.ts +4 -4
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.js +1 -0
  13. package/dist/registry/daemon-registry.d.ts +14 -4
  14. package/dist/registry/daemon-registry.js +20 -4
  15. package/dist/schema/event-payloads.json +3 -0
  16. package/dist/telemetry-refusal.d.ts +3 -2
  17. package/dist/telemetry.d.ts +11 -10
  18. package/dist/verdict/compare-source.d.ts +80 -0
  19. package/dist/verdict/compare-source.js +93 -0
  20. package/dist/verdict/consequence.d.ts +2 -0
  21. package/dist/verdict/consequence.js +2 -0
  22. package/dist/verdict/instrumentation-gap.js +1 -1
  23. package/dist/verdict/intent.d.ts +12 -12
  24. package/dist/verdict/predicate-tree.d.ts +35 -0
  25. package/dist/verdict/predicate-tree.js +40 -0
  26. package/dist/verdict/predicate.d.ts +11 -2
  27. package/dist/verdict/predicate.js +38 -2
  28. package/dist/verdict/verification-run.d.ts +261 -28
  29. package/dist/verdict/verification-run.js +36 -0
  30. package/dist/wire/channel.d.ts +10 -0
  31. package/dist/wire/channel.js +25 -0
  32. package/dist/wire/constants/constants.d.ts +45 -4
  33. package/dist/wire/constants/constants.js +57 -4
  34. package/dist/wire/event-payloads.d.ts +12 -9
  35. package/dist/wire/event-payloads.js +8 -3
  36. package/dist/wire/messages.d.ts +24 -24
  37. package/dist/wire/net.d.ts +17 -0
  38. package/dist/wire/net.js +17 -0
  39. package/dist/wire/redaction.js +17 -0
  40. package/dist/wire/toon.d.ts +1 -1
  41. package/dist/wire/toon.js +2 -1
  42. package/dist/wire/types.d.ts +44 -44
  43. package/dist/words/no-session-reason.d.ts +7 -0
  44. package/dist/words/no-session-reason.js +7 -0
  45. package/dist/words/notices.d.ts +7 -0
  46. package/dist/words/notices.js +9 -2
  47. package/package.json +3 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @reticlehq/core
2
2
 
3
- The **foundation** of [Reticle](https://github.com/reticlehq/reticle) — the shared wire contract that every Reticle package imports: types, [zod](https://zod.dev) schemas, constants, and the messages that cross the browser ↔ bridge ↔ agent boundary. It is isomorphic (runs in a browser or in Node), depends only on `zod`, and re-exports nothing.
3
+ The **foundation** of [Reticle](https://github.com/reticlehq/reticle) — the shared wire contract that every Reticle package imports: types, [zod](https://zod.dev) schemas, constants, and the messages that cross the browser ↔ bridge ↔ agent boundary. It is isomorphic (runs in a browser or in Node), depends only on `zod` and [`open-verification`](https://www.npmjs.com/package/open-verification) (the protocol whose vocabulary it is written in), and re-exports nothing.
4
4
 
5
5
  Most people never install this directly. Install the package for your audience instead:
6
6
 
@@ -60,6 +60,8 @@ export declare const PROJECT_ROUTE_CAP = 200;
60
60
  * one of the two arms and the other was gone with nothing said.
61
61
  */
62
62
  export declare const FLOW_FILE_VERSION = 2;
63
+ /** Stamped instead of FLOW_FILE_VERSION on a flow that holds a `compare` — see flowFileVersionFor. */
64
+ export declare const COMPARE_FLOW_FILE_VERSION = 3;
63
65
  /**
64
66
  * Every version this Reticle can READ, which is not the same question as what it writes.
65
67
  *
@@ -71,6 +73,22 @@ export declare const FLOW_FILE_VERSION = 2;
71
73
  * A number outside this set is the wrong READER, not a damaged file, and says so.
72
74
  */
73
75
  export declare const READABLE_FLOW_VERSIONS: ReadonlySet<number>;
76
+ /**
77
+ * The version a flow file must carry for a reader to be able to replay it.
78
+ *
79
+ * A reader from before `compare` knew versions 1 and 2, so a v2 file holding one failed there as a
80
+ * generic PARSE_FAILED on the unknown kind. Stamping only the flows that USE it keeps every other
81
+ * flow readable by that older reader, and turns the rest into "the reader is the wrong one".
82
+ * Every save routes through it, so a v1 file without one keeps its version byte for byte.
83
+ *
84
+ * The walk is over the whole value rather than the four fields a predicate lives in today (step
85
+ * `expect`, `success`, `requires`, `ensures`), so a predicate slot added later cannot be missed.
86
+ * ponytail: a literal `{ kind: "compare" }` inside an `equals` value also bumps it; that only costs
87
+ * the older reader a file it could have read.
88
+ */
89
+ export declare function flowFileVersionFor(flow: {
90
+ readonly version: number;
91
+ }): number;
74
92
  /** How a flow step is anchored to the live DOM at replay time (semantic, never a volatile ref). */
75
93
  export declare const AnchorKind: {
76
94
  readonly TESTID: "testid";
@@ -105,6 +123,7 @@ export declare const FlowErrorCode: {
105
123
  */
106
124
  readonly WRONG_VERSION: "flow_wrong_version";
107
125
  readonly NO_RECORDING: "flow_no_recording";
126
+ readonly STEP_NOT_FOUND: "flow_step_not_found";
108
127
  };
109
128
  export type FlowErrorCode = (typeof FlowErrorCode)[keyof typeof FlowErrorCode];
110
129
  /** A flow name must be a single safe path segment (no '/', '\\', '..', leading dot). */
@@ -1,3 +1,4 @@
1
+ import { PredicateKind } from '../verdict/consequence.js';
1
2
  /**
2
3
  * On-disk artifact constants: the project history, flow files, replay/drift status, the recorder
3
4
  * lifecycle, heal outcomes, and the structured-annotation vocabulary.
@@ -57,6 +58,8 @@ export const PROJECT_ROUTE_CAP = 200;
57
58
  * one of the two arms and the other was gone with nothing said.
58
59
  */
59
60
  export const FLOW_FILE_VERSION = 2;
61
+ /** Stamped instead of FLOW_FILE_VERSION on a flow that holds a `compare` — see flowFileVersionFor. */
62
+ export const COMPARE_FLOW_FILE_VERSION = 3;
60
63
  /**
61
64
  * Every version this Reticle can READ, which is not the same question as what it writes.
62
65
  *
@@ -67,7 +70,38 @@ export const FLOW_FILE_VERSION = 2;
67
70
  *
68
71
  * A number outside this set is the wrong READER, not a damaged file, and says so.
69
72
  */
70
- export const READABLE_FLOW_VERSIONS = new Set([1, FLOW_FILE_VERSION]);
73
+ export const READABLE_FLOW_VERSIONS = new Set([
74
+ 1,
75
+ FLOW_FILE_VERSION,
76
+ COMPARE_FLOW_FILE_VERSION,
77
+ ]);
78
+ /**
79
+ * The version a flow file must carry for a reader to be able to replay it.
80
+ *
81
+ * A reader from before `compare` knew versions 1 and 2, so a v2 file holding one failed there as a
82
+ * generic PARSE_FAILED on the unknown kind. Stamping only the flows that USE it keeps every other
83
+ * flow readable by that older reader, and turns the rest into "the reader is the wrong one".
84
+ * Every save routes through it, so a v1 file without one keeps its version byte for byte.
85
+ *
86
+ * The walk is over the whole value rather than the four fields a predicate lives in today (step
87
+ * `expect`, `success`, `requires`, `ensures`), so a predicate slot added later cannot be missed.
88
+ * ponytail: a literal `{ kind: "compare" }` inside an `equals` value also bumps it; that only costs
89
+ * the older reader a file it could have read.
90
+ */
91
+ export function flowFileVersionFor(flow) {
92
+ if (usesCompare(flow))
93
+ return COMPARE_FLOW_FILE_VERSION;
94
+ // A file whose compare was edited away drops back; any other version is left as it was written.
95
+ return COMPARE_FLOW_FILE_VERSION === flow.version ? FLOW_FILE_VERSION : flow.version;
96
+ }
97
+ function usesCompare(value) {
98
+ if (null === value || 'object' !== typeof value)
99
+ return false;
100
+ if (Array.isArray(value))
101
+ return value.some(usesCompare);
102
+ const record = value;
103
+ return PredicateKind.COMPARE === record['kind'] || Object.values(record).some(usesCompare);
104
+ }
71
105
  /** How a flow step is anchored to the live DOM at replay time (semantic, never a volatile ref). */
72
106
  export const AnchorKind = {
73
107
  TESTID: 'testid', // { kind:'testid', value }
@@ -101,6 +135,7 @@ export const FlowErrorCode = {
101
135
  */
102
136
  WRONG_VERSION: 'flow_wrong_version',
103
137
  NO_RECORDING: 'flow_no_recording', // save with no compiled program by that name
138
+ STEP_NOT_FOUND: 'flow_step_not_found', // resume `from` names no step of the flow
104
139
  };
105
140
  /** A flow name must be a single safe path segment (no '/', '\\', '..', leading dot). */
106
141
  /**
@@ -161,23 +161,17 @@ export declare const FlowExpectSchema: z.ZodObject<{
161
161
  hold: z.ZodOptional<z.ZodBoolean>;
162
162
  }, "strict", z.ZodTypeAny, {
163
163
  path: string;
164
+ hold?: boolean | undefined;
164
165
  store?: string | undefined;
165
166
  equals?: unknown;
166
- hold?: boolean | undefined;
167
167
  }, {
168
168
  path: string;
169
+ hold?: boolean | undefined;
169
170
  store?: string | undefined;
170
171
  equals?: unknown;
171
- hold?: boolean | undefined;
172
172
  }>>;
173
173
  }, "strict", z.ZodTypeAny, {
174
174
  signal?: string | undefined;
175
- text?: {
176
- contains: string;
177
- visible?: boolean | undefined;
178
- scope?: string | undefined;
179
- absent?: boolean | undefined;
180
- } | undefined;
181
175
  net?: {
182
176
  status?: number | undefined;
183
177
  method?: string | undefined;
@@ -186,15 +180,21 @@ export declare const FlowExpectSchema: z.ZodObject<{
186
180
  } | undefined;
187
181
  state?: {
188
182
  path: string;
183
+ hold?: boolean | undefined;
189
184
  store?: string | undefined;
190
185
  equals?: unknown;
191
- hold?: boolean | undefined;
192
186
  } | undefined;
193
187
  element?: {
194
188
  testid?: string | undefined;
195
189
  role?: string | undefined;
196
190
  name?: string | undefined;
197
191
  } | undefined;
192
+ text?: {
193
+ contains: string;
194
+ visible?: boolean | undefined;
195
+ scope?: string | undefined;
196
+ absent?: boolean | undefined;
197
+ } | undefined;
198
198
  route?: {
199
199
  contains?: string | undefined;
200
200
  pathname?: string | undefined;
@@ -207,12 +207,6 @@ export declare const FlowExpectSchema: z.ZodObject<{
207
207
  signalCount?: number | undefined;
208
208
  }, {
209
209
  signal?: string | undefined;
210
- text?: {
211
- contains: string;
212
- visible?: boolean | undefined;
213
- scope?: string | undefined;
214
- absent?: boolean | undefined;
215
- } | undefined;
216
210
  net?: {
217
211
  status?: number | undefined;
218
212
  method?: string | undefined;
@@ -221,15 +215,21 @@ export declare const FlowExpectSchema: z.ZodObject<{
221
215
  } | undefined;
222
216
  state?: {
223
217
  path: string;
218
+ hold?: boolean | undefined;
224
219
  store?: string | undefined;
225
220
  equals?: unknown;
226
- hold?: boolean | undefined;
227
221
  } | undefined;
228
222
  element?: {
229
223
  testid?: string | undefined;
230
224
  role?: string | undefined;
231
225
  name?: string | undefined;
232
226
  } | undefined;
227
+ text?: {
228
+ contains: string;
229
+ visible?: boolean | undefined;
230
+ scope?: string | undefined;
231
+ absent?: boolean | undefined;
232
+ } | undefined;
233
233
  route?: {
234
234
  contains?: string | undefined;
235
235
  pathname?: string | undefined;
@@ -172,8 +172,8 @@ export function flowExpectToPredicate(success) {
172
172
  parts.push(signal);
173
173
  }
174
174
  if (success.route !== undefined) {
175
- // The mirror of `predicateToExpect`'s ROUTE case. Replay evaluates predicates, so carrying the
176
- // route back here is the whole of what makes a recorded navigation able to fail.
175
+ // Replay evaluates predicates, so carrying the route back here is the whole of what makes a
176
+ // recorded navigation able to fail.
177
177
  const route = {
178
178
  kind: PredicateKind.ROUTE,
179
179
  };
@@ -19,6 +19,7 @@
19
19
  * Guessing a target would manufacture the demotion instead of measuring it.
20
20
  */
21
21
  import { PredicateKind } from '../verdict/consequence.js';
22
+ import { compareSourceClauses } from '../verdict/predicate-tree.js';
22
23
  /** Every endpoint this flow's own declarations name, in order, once each. */
23
24
  /**
24
25
  * Every `net` URL a predicate names, composites included.
@@ -39,6 +40,9 @@ function netUrlsIn(predicate) {
39
40
  }
40
41
  if (PredicateKind.NOT === predicate.kind)
41
42
  return netUrlsIn(predicate.predicate);
43
+ if (PredicateKind.COMPARE === predicate.kind) {
44
+ return compareSourceClauses(predicate).flatMap(netUrlsIn);
45
+ }
42
46
  return [];
43
47
  }
44
48
  export function mutationTargetsFor(flow) {