@reticlehq/core 3.3.0 → 3.5.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 (48) 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 +17 -16
  18. package/dist/telemetry.js +3 -3
  19. package/dist/verdict/compare-source.d.ts +80 -0
  20. package/dist/verdict/compare-source.js +93 -0
  21. package/dist/verdict/consequence.d.ts +2 -0
  22. package/dist/verdict/consequence.js +2 -0
  23. package/dist/verdict/instrumentation-gap.js +1 -1
  24. package/dist/verdict/intent.d.ts +12 -12
  25. package/dist/verdict/predicate-tree.d.ts +35 -0
  26. package/dist/verdict/predicate-tree.js +40 -0
  27. package/dist/verdict/predicate.d.ts +11 -2
  28. package/dist/verdict/predicate.js +38 -2
  29. package/dist/verdict/verification-run.d.ts +261 -28
  30. package/dist/verdict/verification-run.js +36 -0
  31. package/dist/wire/channel.d.ts +10 -0
  32. package/dist/wire/channel.js +25 -0
  33. package/dist/wire/constants/constants.d.ts +45 -5
  34. package/dist/wire/constants/constants.js +57 -5
  35. package/dist/wire/event-payloads.d.ts +12 -9
  36. package/dist/wire/event-payloads.js +8 -3
  37. package/dist/wire/messages.d.ts +24 -24
  38. package/dist/wire/net.d.ts +17 -0
  39. package/dist/wire/net.js +17 -0
  40. package/dist/wire/redaction.js +17 -0
  41. package/dist/wire/toon.d.ts +1 -1
  42. package/dist/wire/toon.js +2 -1
  43. package/dist/wire/types.d.ts +44 -44
  44. package/dist/words/no-session-reason.d.ts +7 -0
  45. package/dist/words/no-session-reason.js +7 -0
  46. package/dist/words/notices.d.ts +7 -0
  47. package/dist/words/notices.js +9 -2
  48. package/package.json +3 -2
@@ -7,6 +7,7 @@ import { CONSEQUENCE_KINDS, PRESENCE_GRADED } from '../verdict/consequence.js';
7
7
  import { PredicateKind } from '../verdict/consequence.js';
8
8
  import { PredicateSchema } from '../verdict/predicate.js';
9
9
  import { sessionBoundField, sessionRefRefusal } from '../verdict/predicate-tree.js';
10
+ import { isConsequenceSource } from '../verdict/compare-source.js';
10
11
  import { FlowExpectSchema, flowExpectToPredicate } from './flow-expect-flat.js';
11
12
  // The older flat shape and its reader live together; both are re-exported so the one public name
12
13
  // for "a flow's types" still answers for them.
@@ -140,6 +141,9 @@ const baseFlowStep = z.object({
140
141
  degraded: z.boolean().optional(),
141
142
  timeoutMs: z.number().int().positive().optional(),
142
143
  invoke: z.string().min(1).optional(),
144
+ /** See FlowStep.page / FlowStep.endPage. */
145
+ page: z.string().optional(),
146
+ endPage: z.string().optional(),
143
147
  });
144
148
  export const FlowStepSchema = baseFlowStep.extend({
145
149
  steps: z.lazy(() => z.array(FlowStepSchema).optional()),
@@ -217,6 +221,14 @@ export const FlowFileSchema = z.object({
217
221
  */
218
222
  requires: ExpectListSchema.optional(),
219
223
  ensures: ExpectListSchema.optional(),
224
+ /**
225
+ * Who made this flow, stamped at save: the agent that drove it (its MCP client name) and the
226
+ * person signed in to the cloud key on that machine. Either is absent when it was not known —
227
+ * never guessed.
228
+ */
229
+ author: z
230
+ .object({ agent: z.string().min(1).optional(), person: z.string().min(1).optional() })
231
+ .optional(),
220
232
  /** From the injected clock (ms) — deterministic in tests, byte-stable on disk. */
221
233
  createdAt: z.number(),
222
234
  steps: z.array(FlowStepSchema),
@@ -377,7 +389,9 @@ export function staleKnownBugs(notes, currentAssertions) {
377
389
  }
378
390
  /** True when a FlowExpect asserts at least one consequence (any of the ConsequenceKind fields set). */
379
391
  export function flowExpectHasConsequence(expect) {
380
- return expectClauses(expect).some((clause) => CONSEQUENCE_KINDS.has(clause.kind));
392
+ return expectClauses(expect).some((clause) => CONSEQUENCE_KINDS.has(clause.kind) ||
393
+ (PredicateKind.COMPARE === clause.kind &&
394
+ (isConsequenceSource(clause.left) || isConsequenceSource(clause.right))));
381
395
  }
382
396
  /**
383
397
  * True when a FlowExpect checks ONLY presence — an element, rendered text or a route, no consequence.
@@ -398,7 +412,8 @@ export function flowExpectHasConsequence(expect) {
398
412
  export function flowExpectIsPresenceOnly(expect) {
399
413
  if (expect === undefined || flowExpectHasConsequence(expect))
400
414
  return false;
401
- return expectClauses(expect).some((clause) => PRESENCE_GRADED.has(clause.kind));
415
+ // A `compare` reaching here reads text on both sides, which is two readings of the same DOM.
416
+ return expectClauses(expect).some((clause) => PRESENCE_GRADED.has(clause.kind) || PredicateKind.COMPARE === clause.kind);
402
417
  }
403
418
  /**
404
419
  * Every clause an expectation contains, composites flattened.
@@ -183,6 +183,7 @@ export declare const JournalVerdictEffectSchema: z.ZodObject<{
183
183
  readonly CONSOLE: "console";
184
184
  readonly ANIMATION: "animation";
185
185
  readonly SETTLED: "settled";
186
+ readonly COMPARE: "compare";
186
187
  readonly ALL_OF: "allOf";
187
188
  readonly ANY_OF: "anyOf";
188
189
  readonly NOT: "not";
@@ -226,7 +227,7 @@ export declare const JournalVerdictEffectSchema: z.ZodObject<{
226
227
  }, "strip", z.ZodTypeAny, {
227
228
  claim: string;
228
229
  verified: "yes" | "no" | "unknown" | "no-fault";
229
- kind?: "signal" | "text" | "net" | "state" | "element" | "route" | "console" | "animation" | "settled" | "allOf" | "anyOf" | "not" | undefined;
230
+ kind?: "signal" | "net" | "state" | "element" | "text" | "route" | "console" | "animation" | "settled" | "compare" | "allOf" | "anyOf" | "not" | undefined;
230
231
  declaredBeforeActing?: boolean | undefined;
231
232
  grade?: string | undefined;
232
233
  couldNotSee?: string[] | undefined;
@@ -235,7 +236,7 @@ export declare const JournalVerdictEffectSchema: z.ZodObject<{
235
236
  }, {
236
237
  claim: string;
237
238
  verified: "yes" | "no" | "unknown" | "no-fault";
238
- kind?: "signal" | "text" | "net" | "state" | "element" | "route" | "console" | "animation" | "settled" | "allOf" | "anyOf" | "not" | undefined;
239
+ kind?: "signal" | "net" | "state" | "element" | "text" | "route" | "console" | "animation" | "settled" | "compare" | "allOf" | "anyOf" | "not" | undefined;
239
240
  declaredBeforeActing?: boolean | undefined;
240
241
  grade?: string | undefined;
241
242
  couldNotSee?: string[] | undefined;
@@ -98,9 +98,9 @@ export declare const BugFoundHookPayloadSchema: z.ZodObject<{
98
98
  tool: z.ZodString;
99
99
  sessionId: z.ZodOptional<z.ZodString>;
100
100
  }, "strip", z.ZodTypeAny, {
101
+ kind: string;
101
102
  event: "bug_found";
102
103
  at: string;
103
- kind: string;
104
104
  tool: string;
105
105
  repeat: boolean;
106
106
  route?: string | undefined;
@@ -109,9 +109,9 @@ export declare const BugFoundHookPayloadSchema: z.ZodObject<{
109
109
  sessionId?: string | undefined;
110
110
  fingerprint?: string | undefined;
111
111
  }, {
112
+ kind: string;
112
113
  event: "bug_found";
113
114
  at: string;
114
- kind: string;
115
115
  tool: string;
116
116
  repeat: boolean;
117
117
  route?: string | undefined;
@@ -211,9 +211,9 @@ export declare const HookPayloadSchema: z.ZodDiscriminatedUnion<"event", [z.ZodO
211
211
  tool: z.ZodString;
212
212
  sessionId: z.ZodOptional<z.ZodString>;
213
213
  }, "strip", z.ZodTypeAny, {
214
+ kind: string;
214
215
  event: "bug_found";
215
216
  at: string;
216
- kind: string;
217
217
  tool: string;
218
218
  repeat: boolean;
219
219
  route?: string | undefined;
@@ -222,9 +222,9 @@ export declare const HookPayloadSchema: z.ZodDiscriminatedUnion<"event", [z.ZodO
222
222
  sessionId?: string | undefined;
223
223
  fingerprint?: string | undefined;
224
224
  }, {
225
+ kind: string;
225
226
  event: "bug_found";
226
227
  at: string;
227
- kind: string;
228
228
  tool: string;
229
229
  repeat: boolean;
230
230
  route?: string | undefined;
package/dist/index.d.ts CHANGED
@@ -51,6 +51,7 @@ export * from './verdict/findings.js';
51
51
  export * from './wire/desktop-contract.js';
52
52
  export * from './verdict/consequence.js';
53
53
  export * from './verdict/property-assertion.js';
54
+ export * from './verdict/compare-source.js';
54
55
  export * from './verdict/predicate.js';
55
56
  export * from './verdict/predicate-tree.js';
56
57
  export * from './artifacts/flow-expect-flat.js';
package/dist/index.js CHANGED
@@ -66,6 +66,7 @@ export * from './verdict/consequence.js';
66
66
  // The predicate CONTRACT: what a caller may declare, and what a saved flow may carry. The engine
67
67
  // owns the reasoning over it and re-exports both halves as one surface.
68
68
  export * from './verdict/property-assertion.js';
69
+ export * from './verdict/compare-source.js';
69
70
  export * from './verdict/predicate.js';
70
71
  export * from './verdict/predicate-tree.js';
71
72
  // The version 1 reader: a flat expect lifted to the predicate a v2 file stores directly.
@@ -27,9 +27,19 @@ export type DaemonRegistryEntry = z.infer<typeof DaemonRegistryEntrySchema>;
27
27
  /**
28
28
  * Pick the daemon port an app should connect to, given the registry entries, the app's projectId, and
29
29
  * a liveness probe. Pure so both the vite and next plugins share one rule and it's unit-testable:
30
- * 1. drop dead daemons (crashed, stale entry);
31
- * 2. among the living, prefer the one whose projectId matches the app's — lowest port wins on a tie;
32
- * 3. return null when nothing matches, so the caller falls back to the default port (never guesses a
30
+ * 1. the port the project CONFIGURED wins whenever a live daemon is registered on it that is not
31
+ * another project's (a daemon naming no project counts; one naming a different project never does);
32
+ * 2. otherwise drop dead daemons (crashed, stale entry);
33
+ * 3. among the living, prefer the one whose projectId matches the app's — lowest port wins on a tie;
34
+ * 4. return null when nothing matches, so the caller falls back to the default port (never guesses a
33
35
  * mismatched daemon — a wrong auto-connect is worse than the honest default).
36
+ *
37
+ * The first rule exists because `init --port <new>` starts a daemon on the new port while the old one
38
+ * for the same project is still alive. Discovery by projectId then found both, took the lower, and
39
+ * the page dialled the OLD daemon: init waited on the new one and exited with "connected to a
40
+ * DIFFERENT Reticle daemon". `.reticle.json` is what the daemon and the CLI follow, so when a daemon
41
+ * answers there it is the answer; the registry only speaks when nothing does. Another project's
42
+ * daemon squatting that port is not an answer: the pairing token is per machine, so taking it would
43
+ * pair this page with that project's bridge while this project's own daemon sat live elsewhere.
34
44
  */
35
- export declare function pickDaemonPort(entries: readonly DaemonRegistryEntry[], projectId: string | undefined, isAlive: (pid: number) => boolean): number | null;
45
+ export declare function pickDaemonPort(entries: readonly DaemonRegistryEntry[], projectId: string | undefined, isAlive: (pid: number) => boolean, configuredPort?: number): number | null;
@@ -31,12 +31,28 @@ export const DaemonRegistryEntrySchema = z.object({
31
31
  /**
32
32
  * Pick the daemon port an app should connect to, given the registry entries, the app's projectId, and
33
33
  * a liveness probe. Pure so both the vite and next plugins share one rule and it's unit-testable:
34
- * 1. drop dead daemons (crashed, stale entry);
35
- * 2. among the living, prefer the one whose projectId matches the app's — lowest port wins on a tie;
36
- * 3. return null when nothing matches, so the caller falls back to the default port (never guesses a
34
+ * 1. the port the project CONFIGURED wins whenever a live daemon is registered on it that is not
35
+ * another project's (a daemon naming no project counts; one naming a different project never does);
36
+ * 2. otherwise drop dead daemons (crashed, stale entry);
37
+ * 3. among the living, prefer the one whose projectId matches the app's — lowest port wins on a tie;
38
+ * 4. return null when nothing matches, so the caller falls back to the default port (never guesses a
37
39
  * mismatched daemon — a wrong auto-connect is worse than the honest default).
40
+ *
41
+ * The first rule exists because `init --port <new>` starts a daemon on the new port while the old one
42
+ * for the same project is still alive. Discovery by projectId then found both, took the lower, and
43
+ * the page dialled the OLD daemon: init waited on the new one and exited with "connected to a
44
+ * DIFFERENT Reticle daemon". `.reticle.json` is what the daemon and the CLI follow, so when a daemon
45
+ * answers there it is the answer; the registry only speaks when nothing does. Another project's
46
+ * daemon squatting that port is not an answer: the pairing token is per machine, so taking it would
47
+ * pair this page with that project's bridge while this project's own daemon sat live elsewhere.
38
48
  */
39
- export function pickDaemonPort(entries, projectId, isAlive) {
49
+ export function pickDaemonPort(entries, projectId, isAlive, configuredPort) {
50
+ if (undefined !== configuredPort &&
51
+ entries.some((e) => e.port === configuredPort &&
52
+ isAlive(e.pid) &&
53
+ (e.projectId === undefined || projectId === undefined || e.projectId === projectId))) {
54
+ return configuredPort;
55
+ }
40
56
  if (projectId === undefined || 0 === projectId.length)
41
57
  return null;
42
58
  const matches = entries
@@ -92,6 +92,9 @@
92
92
  "urlRaw": {
93
93
  "type": "string"
94
94
  },
95
+ "nextAction": {
96
+ "type": "string"
97
+ },
95
98
  "requestShape": {
96
99
  "type": "string"
97
100
  }
@@ -63,6 +63,7 @@ export declare const ToolRefusalSchema: z.ZodObject<{
63
63
  readonly AUTH_REFUSED: "auth_refused";
64
64
  readonly LEASE_EXPIRED: "lease_expired";
65
65
  readonly TAB_GONE: "tab_gone";
66
+ readonly ROUTE_SERVER_ERROR: "route_server_error";
66
67
  readonly APP_NOT_REOPENED: "app_not_reopened";
67
68
  readonly CONFIG_ELSEWHERE: "config_elsewhere";
68
69
  readonly NO_LISTENER_NO_CONFIG: "no_listener_no_config";
@@ -84,11 +85,11 @@ export declare const ToolRefusalSchema: z.ZodObject<{
84
85
  reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
85
86
  tool: string;
86
87
  retried: boolean;
87
- noSessionReason?: "auth_refused" | "lease_expired" | "tab_gone" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
88
+ noSessionReason?: "auth_refused" | "lease_expired" | "tab_gone" | "route_server_error" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
88
89
  }, {
89
90
  reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
90
91
  tool: string;
91
92
  retried: boolean;
92
- noSessionReason?: "auth_refused" | "lease_expired" | "tab_gone" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
93
+ noSessionReason?: "auth_refused" | "lease_expired" | "tab_gone" | "route_server_error" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
93
94
  }>;
94
95
  export type ToolRefusal = z.infer<typeof ToolRefusalSchema>;
@@ -699,7 +699,7 @@ export declare const BugFoundSchema: z.ZodObject<{
699
699
  }, "strip", z.ZodTypeAny, {
700
700
  kind: string;
701
701
  source: "replay" | "contradiction" | "crawl" | "assertion";
702
- attribution: "reticle" | "app" | "request" | "unclassified";
702
+ attribution: "reticle" | "request" | "app" | "unclassified";
703
703
  falseGreen: boolean;
704
704
  repeat: boolean;
705
705
  tool?: string | undefined;
@@ -707,7 +707,7 @@ export declare const BugFoundSchema: z.ZodObject<{
707
707
  }, {
708
708
  kind: string;
709
709
  source: "replay" | "contradiction" | "crawl" | "assertion";
710
- attribution: "reticle" | "app" | "request" | "unclassified";
710
+ attribution: "reticle" | "request" | "app" | "unclassified";
711
711
  falseGreen: boolean;
712
712
  repeat: boolean;
713
713
  tool?: string | undefined;
@@ -998,9 +998,9 @@ export declare const InitOutcomeSchema: z.ZodObject<{
998
998
  /**
999
999
  * What `init` saw when it waited for an app to connect.
1000
1000
  *
1001
- * ABSENT means it never looked, which is the honest answer for every scripted run: `init` only
1002
- * waits when a human is at the terminal. Read an absent value as "not measured", never as a
1003
- * failure to connect, or the funnel reads scripted installs as losses.
1001
+ * Default init reports CONNECTED after runtime success. Runtime failures carry a classified
1002
+ * reason without guessing the watcher's daemon/page classification. Files-only init watches
1003
+ * only in an interactive terminal. Absence alone is not evidence of a failed connection.
1004
1004
  */
1005
1005
  confirmation: z.ZodOptional<z.ZodNativeEnum<{
1006
1006
  /** An app carrying the SDK reached the daemon while `init` watched. This is what installed means. */
@@ -2053,9 +2053,9 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2053
2053
  /**
2054
2054
  * What `init` saw when it waited for an app to connect.
2055
2055
  *
2056
- * ABSENT means it never looked, which is the honest answer for every scripted run: `init` only
2057
- * waits when a human is at the terminal. Read an absent value as "not measured", never as a
2058
- * failure to connect, or the funnel reads scripted installs as losses.
2056
+ * Default init reports CONNECTED after runtime success. Runtime failures carry a classified
2057
+ * reason without guessing the watcher's daemon/page classification. Files-only init watches
2058
+ * only in an interactive terminal. Absence alone is not evidence of a failed connection.
2059
2059
  */
2060
2060
  confirmation: z.ZodOptional<z.ZodNativeEnum<{
2061
2061
  /** An app carrying the SDK reached the daemon while `init` watched. This is what installed means. */
@@ -2214,7 +2214,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2214
2214
  }, "strip", z.ZodTypeAny, {
2215
2215
  kind: string;
2216
2216
  source: "replay" | "contradiction" | "crawl" | "assertion";
2217
- attribution: "reticle" | "app" | "request" | "unclassified";
2217
+ attribution: "reticle" | "request" | "app" | "unclassified";
2218
2218
  falseGreen: boolean;
2219
2219
  repeat: boolean;
2220
2220
  tool?: string | undefined;
@@ -2222,7 +2222,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2222
2222
  }, {
2223
2223
  kind: string;
2224
2224
  source: "replay" | "contradiction" | "crawl" | "assertion";
2225
- attribution: "reticle" | "app" | "request" | "unclassified";
2225
+ attribution: "reticle" | "request" | "app" | "unclassified";
2226
2226
  falseGreen: boolean;
2227
2227
  repeat: boolean;
2228
2228
  tool?: string | undefined;
@@ -2243,6 +2243,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2243
2243
  readonly AUTH_REFUSED: "auth_refused";
2244
2244
  readonly LEASE_EXPIRED: "lease_expired";
2245
2245
  readonly TAB_GONE: "tab_gone";
2246
+ readonly ROUTE_SERVER_ERROR: "route_server_error";
2246
2247
  readonly APP_NOT_REOPENED: "app_not_reopened";
2247
2248
  readonly CONFIG_ELSEWHERE: "config_elsewhere";
2248
2249
  readonly NO_LISTENER_NO_CONFIG: "no_listener_no_config";
@@ -2255,12 +2256,12 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2255
2256
  reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
2256
2257
  tool: string;
2257
2258
  retried: boolean;
2258
- noSessionReason?: "auth_refused" | "lease_expired" | "tab_gone" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
2259
+ noSessionReason?: "auth_refused" | "lease_expired" | "tab_gone" | "route_server_error" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
2259
2260
  }, {
2260
2261
  reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
2261
2262
  tool: string;
2262
2263
  retried: boolean;
2263
- noSessionReason?: "auth_refused" | "lease_expired" | "tab_gone" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
2264
+ noSessionReason?: "auth_refused" | "lease_expired" | "tab_gone" | "route_server_error" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
2264
2265
  }>>;
2265
2266
  /** Only on `mcp_connection_lost`: which stage of the outage, why, and after how many retries. */
2266
2267
  outage: z.ZodOptional<z.ZodObject<{
@@ -2455,7 +2456,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2455
2456
  bug?: {
2456
2457
  kind: string;
2457
2458
  source: "replay" | "contradiction" | "crawl" | "assertion";
2458
- attribution: "reticle" | "app" | "request" | "unclassified";
2459
+ attribution: "reticle" | "request" | "app" | "unclassified";
2459
2460
  falseGreen: boolean;
2460
2461
  repeat: boolean;
2461
2462
  tool?: string | undefined;
@@ -2611,7 +2612,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2611
2612
  reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
2612
2613
  tool: string;
2613
2614
  retried: boolean;
2614
- noSessionReason?: "auth_refused" | "lease_expired" | "tab_gone" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
2615
+ noSessionReason?: "auth_refused" | "lease_expired" | "tab_gone" | "route_server_error" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
2615
2616
  } | undefined;
2616
2617
  outage?: {
2617
2618
  reason: "other" | "sse_ended" | "daemon_shutdown" | "sse_error" | "sse_aborted" | "sse_closed" | "connect_error";
@@ -2681,7 +2682,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2681
2682
  bug?: {
2682
2683
  kind: string;
2683
2684
  source: "replay" | "contradiction" | "crawl" | "assertion";
2684
- attribution: "reticle" | "app" | "request" | "unclassified";
2685
+ attribution: "reticle" | "request" | "app" | "unclassified";
2685
2686
  falseGreen: boolean;
2686
2687
  repeat: boolean;
2687
2688
  tool?: string | undefined;
@@ -2837,7 +2838,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2837
2838
  reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
2838
2839
  tool: string;
2839
2840
  retried: boolean;
2840
- noSessionReason?: "auth_refused" | "lease_expired" | "tab_gone" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
2841
+ noSessionReason?: "auth_refused" | "lease_expired" | "tab_gone" | "route_server_error" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
2841
2842
  } | undefined;
2842
2843
  outage?: {
2843
2844
  reason: "other" | "sse_ended" | "daemon_shutdown" | "sse_error" | "sse_aborted" | "sse_closed" | "connect_error";
package/dist/telemetry.js CHANGED
@@ -770,9 +770,9 @@ export const InitOutcomeSchema = z.object({
770
770
  /**
771
771
  * What `init` saw when it waited for an app to connect.
772
772
  *
773
- * ABSENT means it never looked, which is the honest answer for every scripted run: `init` only
774
- * waits when a human is at the terminal. Read an absent value as "not measured", never as a
775
- * failure to connect, or the funnel reads scripted installs as losses.
773
+ * Default init reports CONNECTED after runtime success. Runtime failures carry a classified
774
+ * reason without guessing the watcher's daemon/page classification. Files-only init watches
775
+ * only in an interactive terminal. Absence alone is not evidence of a failed connection.
776
776
  */
777
777
  confirmation: z.nativeEnum(InitConfirmation).optional(),
778
778
  });
@@ -0,0 +1,80 @@
1
+ /**
2
+ * The `compare` predicate's contract: where each side's value is read from, and how the two are
3
+ * compared.
4
+ *
5
+ * Every other predicate checks one observation against a value the CALLER supplies. That leaves one
6
+ * claim unsayable: "the page shows what the server answered". The refund case is the one that
7
+ * shipped — the server read `1187.01` as paise and answered `{"refunded":11.87}`, the page displayed
8
+ * the number the user had typed, and every channel was green. `bodyContains` catches it only when
9
+ * the agent already knows the right number, and an agent verifying a fix usually does not.
10
+ *
11
+ * `compare` reads two observed values and relates them, so the claim needs no expected value at all.
12
+ * The sources are the four channels that carry a VALUE (a request or response field, a signal
13
+ * payload field, a store path, an element's text). Route, console and animation carry events, not
14
+ * values, so they are not sources.
15
+ */
16
+ import { z } from 'zod';
17
+ import { PredicateKind } from './consequence.js';
18
+ /** Which half of an exchange a `net` source reads. */
19
+ export declare const NetBodySide: {
20
+ readonly RESPONSE: "response";
21
+ readonly REQUEST: "request";
22
+ };
23
+ export type NetBodySide = (typeof NetBodySide)[keyof typeof NetBodySide];
24
+ /**
25
+ * How the two readings are compared.
26
+ *
27
+ * `value` is strict equality of two scalars: `"11.87"` and `11.87` differ, because text and a JSON
28
+ * number are different things and saying they agree would be a guess. `number` reads ONE number out
29
+ * of each side (a JSON number as is, a string by its only numeric token, so `"₹1,187.01"` reads as
30
+ * 1187.01) and compares those, within `tolerance`. A string with no number, or with two, is
31
+ * unreadable rather than unequal: picking one would be a guess about which the caller meant.
32
+ */
33
+ export declare const CompareAs: {
34
+ readonly VALUE: "value";
35
+ readonly NUMBER: "number";
36
+ };
37
+ export type CompareAs = (typeof CompareAs)[keyof typeof CompareAs];
38
+ export type CompareSource = {
39
+ from: typeof PredicateKind.NET;
40
+ urlContains: string;
41
+ method?: string;
42
+ /** Which body the path reads. Defaults to the response, the half a UI cannot fake. */
43
+ body?: NetBodySide;
44
+ path: string;
45
+ } | {
46
+ from: typeof PredicateKind.SIGNAL;
47
+ name: string;
48
+ path: string;
49
+ } | {
50
+ from: typeof PredicateKind.STATE;
51
+ store?: string;
52
+ path: string;
53
+ }
54
+ /** The whole text of the element `scope` names (a CSS selector), itself included. */
55
+ | {
56
+ from: typeof PredicateKind.TEXT;
57
+ scope: string;
58
+ };
59
+ /**
60
+ * Cast rather than annotated for the reason `PredicateSchema` is: zod infers optional fields as
61
+ * `| undefined`, which `exactOptionalPropertyTypes` will not assign to the hand-written type.
62
+ */
63
+ export declare const CompareSourceSchema: z.ZodType<CompareSource>;
64
+ /**
65
+ * Does this source read a value the APP produced — a request, a payload, a store — rather than
66
+ * rendered text?
67
+ *
68
+ * Decides how a `compare` grades. With at least one such side, a pass means the page agrees with the
69
+ * app's own record of what happened, which a healed-but-wrong locator cannot fake. Text against text
70
+ * is a presence-grade claim, because both sides are readings of the same DOM.
71
+ */
72
+ export declare function isConsequenceSource(source: CompareSource): boolean;
73
+ /**
74
+ * Do two sources read the same value, for refusing a comparison with itself?
75
+ *
76
+ * Spelled-out defaults are filled in first. Otherwise `{ body: "response" }` against a source that
77
+ * left `body` out would read as two different sources, and a comparison that cannot fail would get
78
+ * past the refusal just by being written two ways.
79
+ */
80
+ export declare function sameCompareSource(a: CompareSource, b: CompareSource): boolean;
@@ -0,0 +1,93 @@
1
+ /**
2
+ * The `compare` predicate's contract: where each side's value is read from, and how the two are
3
+ * compared.
4
+ *
5
+ * Every other predicate checks one observation against a value the CALLER supplies. That leaves one
6
+ * claim unsayable: "the page shows what the server answered". The refund case is the one that
7
+ * shipped — the server read `1187.01` as paise and answered `{"refunded":11.87}`, the page displayed
8
+ * the number the user had typed, and every channel was green. `bodyContains` catches it only when
9
+ * the agent already knows the right number, and an agent verifying a fix usually does not.
10
+ *
11
+ * `compare` reads two observed values and relates them, so the claim needs no expected value at all.
12
+ * The sources are the four channels that carry a VALUE (a request or response field, a signal
13
+ * payload field, a store path, an element's text). Route, console and animation carry events, not
14
+ * values, so they are not sources.
15
+ */
16
+ import { z } from 'zod';
17
+ import { PredicateKind } from './consequence.js';
18
+ /** Which half of an exchange a `net` source reads. */
19
+ export const NetBodySide = {
20
+ RESPONSE: 'response',
21
+ REQUEST: 'request',
22
+ };
23
+ /**
24
+ * How the two readings are compared.
25
+ *
26
+ * `value` is strict equality of two scalars: `"11.87"` and `11.87` differ, because text and a JSON
27
+ * number are different things and saying they agree would be a guess. `number` reads ONE number out
28
+ * of each side (a JSON number as is, a string by its only numeric token, so `"₹1,187.01"` reads as
29
+ * 1187.01) and compares those, within `tolerance`. A string with no number, or with two, is
30
+ * unreadable rather than unequal: picking one would be a guess about which the caller meant.
31
+ */
32
+ export const CompareAs = {
33
+ VALUE: 'value',
34
+ NUMBER: 'number',
35
+ };
36
+ /** A path into a JSON value: `data.total`, `items.0.id` — the grammar `state.path` speaks. */
37
+ const pathField = z.string().min(1);
38
+ /**
39
+ * Cast rather than annotated for the reason `PredicateSchema` is: zod infers optional fields as
40
+ * `| undefined`, which `exactOptionalPropertyTypes` will not assign to the hand-written type.
41
+ */
42
+ export const CompareSourceSchema = z.discriminatedUnion('from', [
43
+ z
44
+ .object({
45
+ from: z.literal(PredicateKind.NET),
46
+ urlContains: z.string().min(1),
47
+ method: z.string().optional(),
48
+ body: z.enum([NetBodySide.RESPONSE, NetBodySide.REQUEST]).optional(),
49
+ path: pathField,
50
+ })
51
+ .strict(),
52
+ z
53
+ .object({ from: z.literal(PredicateKind.SIGNAL), name: z.string().min(1), path: pathField })
54
+ .strict(),
55
+ z
56
+ .object({ from: z.literal(PredicateKind.STATE), store: z.string().optional(), path: pathField })
57
+ .strict(),
58
+ z.object({ from: z.literal(PredicateKind.TEXT), scope: z.string().min(1) }).strict(),
59
+ ]);
60
+ /**
61
+ * Does this source read a value the APP produced — a request, a payload, a store — rather than
62
+ * rendered text?
63
+ *
64
+ * Decides how a `compare` grades. With at least one such side, a pass means the page agrees with the
65
+ * app's own record of what happened, which a healed-but-wrong locator cannot fake. Text against text
66
+ * is a presence-grade claim, because both sides are readings of the same DOM.
67
+ */
68
+ export function isConsequenceSource(source) {
69
+ return PredicateKind.TEXT !== source.from;
70
+ }
71
+ /**
72
+ * Do two sources read the same value, for refusing a comparison with itself?
73
+ *
74
+ * Spelled-out defaults are filled in first. Otherwise `{ body: "response" }` against a source that
75
+ * left `body` out would read as two different sources, and a comparison that cannot fail would get
76
+ * past the refusal just by being written two ways.
77
+ */
78
+ export function sameCompareSource(a, b) {
79
+ const left = withDefaults(a);
80
+ const right = withDefaults(b);
81
+ const keys = new Set([...Object.keys(left), ...Object.keys(right)]);
82
+ return [...keys].every((key) => left[key] === right[key]);
83
+ }
84
+ function withDefaults(source) {
85
+ // The network reader matches methods case-blind, so `GET` and `get` pick the same call.
86
+ if (PredicateKind.NET === source.from)
87
+ return {
88
+ ...source,
89
+ body: source.body ?? NetBodySide.RESPONSE,
90
+ method: source.method?.toUpperCase(),
91
+ };
92
+ return { ...source };
93
+ }
@@ -43,6 +43,8 @@ export declare const PredicateKind: {
43
43
  readonly CONSOLE: "console";
44
44
  readonly ANIMATION: "animation";
45
45
  readonly SETTLED: "settled";
46
+ /** Two observed values, related to each other — see compare-source.ts. */
47
+ readonly COMPARE: "compare";
46
48
  readonly ALL_OF: "allOf";
47
49
  readonly ANY_OF: "anyOf";
48
50
  readonly NOT: "not";
@@ -41,6 +41,8 @@ export const PredicateKind = {
41
41
  CONSOLE: 'console',
42
42
  ANIMATION: 'animation',
43
43
  SETTLED: 'settled',
44
+ /** Two observed values, related to each other — see compare-source.ts. */
45
+ COMPARE: 'compare',
44
46
  ALL_OF: 'allOf',
45
47
  ANY_OF: 'anyOf',
46
48
  NOT: 'not',
@@ -119,7 +119,7 @@ export const InstrumentationGapKind = {
119
119
  */
120
120
  const GAP_FIX = {
121
121
  [InstrumentationGapKind.NO_SOURCE_MAPPING]: 'add the Reticle build plugin (@reticlehq/vite-plugin, @reticlehq/next, or the babel plugin) so elements carry data-reticle-source',
122
- [InstrumentationGapKind.NO_STORE_REGISTERED]: 'register the store with reticle.registerStore(name, getState) so state can be read directly instead of inferred from the DOM',
122
+ [InstrumentationGapKind.NO_STORE_REGISTERED]: 'register the store itself with reticle.registerStore(name, store), or registerStore(name, getState, subscribe), so its changes are observed — a bare getter can be read but never reports a change',
123
123
  [InstrumentationGapKind.NO_SIGNAL_ON_MUTATION]: 'fire reticle.signal(name, data) where this state is committed — commitAndSignal binds the two so they cannot drift',
124
124
  [InstrumentationGapKind.UNDECLARED_CONTROL]: 'add this control to reticle.describe() so the capability contract matches what the app actually exposes',
125
125
  [InstrumentationGapKind.MISSING_TESTID]: 'add data-testid="..." on this control so the flow can name it after a refactor',