@reticlehq/core 2.8.0 → 2.10.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/telemetry.js CHANGED
@@ -20,6 +20,7 @@ import { MachineSnapshotSchema, ProjectProfileSchema, SessionSummarySchema, } fr
20
20
  import { BrowserBrand, FeedbackSchema } from './telemetry-feedback.js';
21
21
  import { CaptureLoss, VerifiedReason } from './verified-constants.js';
22
22
  import { IdentitySchema } from './telemetry-feedback.js';
23
+ import { LicenseActivation } from './telemetry-license.js';
23
24
  /** Bump when the event shape changes so the analytics side can segment old senders. */
24
25
  export const TELEMETRY_EVENT_VERSION = 3;
25
26
  /**
@@ -128,6 +129,24 @@ export const TelemetryEventKind = {
128
129
  * is a real rate rather than an inference, and a reconnecting page cannot inflate it.
129
130
  */
130
131
  APP_INSTRUMENTED: 'app_instrumented',
132
+ /**
133
+ * A daemon has been up long enough that no app is going to arrive on its own.
134
+ *
135
+ * The exact counterpart of `app_instrumented`, and the reason it has to exist: that event only
136
+ * fires on SUCCESS, so the far larger population — daemons that never get an app at all — is
137
+ * measurable today only by the ABSENCE of an event, and an absence cannot distinguish "nothing
138
+ * was wired" from "the process died before it could tell us" from "we never sent it".
139
+ *
140
+ * The funnel breaks here and nowhere else, so this is the one silence worth turning into a signal.
141
+ * Fired ONCE per daemon run, and never after an app has connected, so a daemon that starts slowly
142
+ * and then works reports nothing.
143
+ *
144
+ * Read it against `agentAttached`: a stalled daemon with no agent is a person who installed and
145
+ * walked away, which is not a defect. A stalled daemon WITH an agent attached is the failure this
146
+ * product currently has — the tools are there, something is asking for them, and there is no app
147
+ * on the other end.
148
+ */
149
+ INSTRUMENTATION_STALLED: 'instrumentation_stalled',
131
150
  /**
132
151
  * The agent LOST its Reticle tools — the worst thing this product does to anyone, and until now
133
152
  * completely invisible in the field.
@@ -194,6 +213,7 @@ const SESSION_SCOPED = new Set([
194
213
  TelemetryEventKind.SESSION_PROGRESS,
195
214
  TelemetryEventKind.MCP_CLIENT_CONNECTED,
196
215
  TelemetryEventKind.APP_INSTRUMENTED,
216
+ TelemetryEventKind.INSTRUMENTATION_STALLED,
197
217
  TelemetryEventKind.PROJECT_PROFILED,
198
218
  TelemetryEventKind.VERIFICATION_COMPLETED,
199
219
  TelemetryEventKind.BUG_FOUND,
@@ -527,6 +547,19 @@ export const BugFoundSchema = z.object({
527
547
  * `BugAttribution` for why `app` needs positive evidence.
528
548
  */
529
549
  attribution: z.nativeEnum(BugAttribution),
550
+ /**
551
+ * A stable hash identifying THIS defect across sessions — same kind at the same route = same
552
+ * fingerprint, regardless of when or where it was found.
553
+ *
554
+ * The inputs (route, selector) never travel raw — only the 8-char hex hash does, following the
555
+ * same privacy pattern as `projectId`. The analytics side groups on it to answer "was this bug
556
+ * fixed?" (the fingerprint stops appearing) and to deduplicate the same defect found by parallel
557
+ * agents in one run.
558
+ *
559
+ * OPTIONAL because old senders and the `reticle verify` CLI path do not yet compute it. Absent
560
+ * means "not fingerprinted", never "a different defect from one that has a fingerprint".
561
+ */
562
+ fingerprint: z.string().max(16).optional(),
530
563
  });
531
564
  /**
532
565
  * WHY a tool could not do what was asked.
@@ -600,6 +633,26 @@ export const AppInstrumentationSchema = z.object({
600
633
  /** How long the daemon had been up. Large values mean Reticle sat there with nothing wired. */
601
634
  msToFirstApp: z.number().int().nonnegative(),
602
635
  });
636
+ /**
637
+ * The shape of a daemon that waited and got nothing.
638
+ *
639
+ * Deliberately the same three facts as `AppInstrumentation` rather than a richer payload, so the
640
+ * success and failure cases are directly comparable: the only difference between them should be
641
+ * which event carries them. `msWaited` is the counterpart of `msToFirstApp`.
642
+ *
643
+ * What it does NOT carry is any attempt to say WHY, because at this point the daemon does not know.
644
+ * Whether a dev server is listening is a live probe, and running one on a timer to enrich a metric
645
+ * would be collecting for the metric's sake. The diagnosis belongs where a human or an agent asks
646
+ * for it, not here.
647
+ */
648
+ export const InstrumentationStallSchema = z.object({
649
+ /** Whether `reticle init` had been run in this directory (a projectId is stamped). */
650
+ initialized: z.boolean(),
651
+ /** Whether an MCP client is attached. The difference between an idle install and a broken one. */
652
+ agentAttached: z.boolean(),
653
+ /** How long the daemon has been up with no app on the other end. */
654
+ msWaited: z.number().int().nonnegative(),
655
+ });
603
656
  /**
604
657
  * WHICH stage of an MCP outage this is. Reported at most twice per proxy process, and the two are
605
658
  * different facts: `first` says the session lost its tools at all, `budget_spent` says the proxy
@@ -608,6 +661,18 @@ export const AppInstrumentationSchema = z.object({
608
661
  export const OutageStage = {
609
662
  FIRST: 'first',
610
663
  BUDGET_SPENT: 'budget_spent',
664
+ /**
665
+ * The link came back on its own, and `attempts` says what it cost.
666
+ *
667
+ * Without it `first` is unfalsifiable. It is emitted at the moment of the drop, when the attempt
668
+ * counter is 1 by construction and the cap keeps any later drop from ever replacing it — so every
669
+ * event in the field carried the same stage and the same attempt count, and neither could carry
670
+ * another. That reads as "reconnection never advances past the first attempt" and it is really
671
+ * "this event is emitted before there is anything to say". `recovered` is the counterpart that
672
+ * makes the pair mean something: `first` with no `recovered` and no `budget_spent` is a session
673
+ * whose tools never came back.
674
+ */
675
+ RECOVERED: 'recovered',
611
676
  };
612
677
  /**
613
678
  * WHY the stream went away, as far as the proxy can tell. A closed vocabulary because the proxy's
@@ -615,8 +680,17 @@ export const OutageStage = {
615
680
  * without a raw string reaching the wire, per the classifier rule.
616
681
  */
617
682
  export const OutageReason = {
618
- /** The SSE stream ended cleanly — usually the daemon exiting. */
683
+ /** The SSE stream ended cleanly and nothing said why. */
619
684
  SSE_ENDED: 'sse_ended',
685
+ /**
686
+ * The daemon ANNOUNCED that it was retiring before it closed the stream.
687
+ *
688
+ * Not an outage the agent suffered, and separating it is the whole point: a scheduled shutdown and
689
+ * a daemon dying under a live client are the same clean stream end on this side of the socket, so
690
+ * the metric meant to say "the agent lost its tools" spent most of its volume counting the daemon
691
+ * going to sleep exactly as designed. Split out, `sse_ended` finally means what it says.
692
+ */
693
+ DAEMON_SHUTDOWN: 'daemon_shutdown',
620
694
  /** The stream errored. */
621
695
  SSE_ERROR: 'sse_error',
622
696
  /** The socket died under us with neither `end` nor `error` — daemon killed, network reset. */
@@ -834,6 +908,8 @@ export const TelemetryEventSchema = z.object({
834
908
  outage: McpOutageSchema.optional(),
835
909
  /** Only on `app_instrumented`: the install's second half finally happening. */
836
910
  instrumentation: AppInstrumentationSchema.optional(),
911
+ /** Only on `instrumentation_stalled`: the install's second half not happening. */
912
+ stall: InstrumentationStallSchema.optional(),
837
913
  /**
838
914
  * Only on `reticle_installed` / `init_completed`: which published route brought this install in.
839
915
  *
@@ -841,4 +917,22 @@ export const TelemetryEventSchema = z.object({
841
917
  * common, and because there is exactly one fact to carry. Absent on every other kind.
842
918
  */
843
919
  installSource: z.nativeEnum(InstallSource).optional(),
920
+ /**
921
+ * Enterprise activation, on EVERY event. Two scalars rather than a block, for the same reason
922
+ * `installSource` is one: they describe the install, not any single event, and they have to be
923
+ * present on the events that show whether a licensed customer got anywhere.
924
+ *
925
+ * `licenseId` is the signed license id — an opaque uuid that resolves to a company only against the
926
+ * issuance ledger we hold locally, so the analytics backend never learns a customer list. The
927
+ * organisation NAME is deliberately absent: it is free text somebody typed at signing time, and
928
+ * rule 3 is names-never-values.
929
+ *
930
+ * `licenseId` is present only when activation is `active`; `licenseStatus` rides whenever an issuer
931
+ * key is baked, including the failure states, which is what makes a lapse distinguishable from a
932
+ * churn. The PLAN is deliberately not here: the issuance ledger already holds it against this same
933
+ * id, so it would be a per-event cost for something the join that resolves the id resolves anyway.
934
+ */
935
+ licenseId: z.string().min(1).max(64).optional(),
936
+ /** How activation resolved. Absent on a build with no issuer key baked, i.e. every OSS install. */
937
+ licenseStatus: z.nativeEnum(LicenseActivation).optional(),
844
938
  });
package/dist/types.d.ts CHANGED
@@ -2,7 +2,16 @@ import type { Ref } from './brand.js';
2
2
  import { z } from 'zod';
3
3
  import { type AnnotationErrorCode, type AnnotationTarget, ElementState } from './constants.js';
4
4
  import type { FlowExpect } from './flow-types.js';
5
- /** A query describing which element(s) to find, Testing-Library style. */
5
+ /**
6
+ * A query describing which element(s) to find, Testing-Library style.
7
+ *
8
+ * Strict, for the same reason the predicate union that wraps it is: a key nobody spells is a schema
9
+ * error naming the key, never a stripped field. Reported from the field —
10
+ * `{ kind: 'element', query: { css: "a[href='…']" } }` parsed, `css` was dropped, the empty query
11
+ * that survived matched nothing, and the verdict read "no element matched {}" about an element that
12
+ * was on the page. A stripped locator here is a false RED, and an agent that believes it goes and
13
+ * "fixes" correct code.
14
+ */
6
15
  export declare const ElementQuerySchema: z.ZodObject<{
7
16
  by: z.ZodOptional<z.ZodNativeEnum<{
8
17
  readonly ROLE: "role";
@@ -33,7 +42,7 @@ export declare const ElementQuerySchema: z.ZodObject<{
33
42
  file: z.ZodString;
34
43
  line: z.ZodNumber;
35
44
  column: z.ZodOptional<z.ZodNumber>;
36
- }, "strip", z.ZodTypeAny, {
45
+ }, "strict", z.ZodTypeAny, {
37
46
  file: string;
38
47
  line: number;
39
48
  column?: number | undefined;
@@ -54,7 +63,7 @@ export declare const ElementQuerySchema: z.ZodObject<{
54
63
  * verification was handed back to the human. Requires `scope`.
55
64
  */
56
65
  self: z.ZodOptional<z.ZodBoolean>;
57
- }, "strip", z.ZodTypeAny, {
66
+ }, "strict", z.ZodTypeAny, {
58
67
  testid?: string | undefined;
59
68
  role?: string | undefined;
60
69
  component?: string | undefined;
package/dist/types.js CHANGED
@@ -2,8 +2,18 @@ import { z } from 'zod';
2
2
  import { AnnotationKind, CONTRACT_FILE_VERSION, ElementState, QueryBy, RunKind, RunStatus, } from './constants.js';
3
3
  import { PROJECT_FILE_VERSION } from './flow-constants.js';
4
4
  import { RiskSurface } from './verification-run.js';
5
- /** A query describing which element(s) to find, Testing-Library style. */
6
- export const ElementQuerySchema = z.object({
5
+ /**
6
+ * A query describing which element(s) to find, Testing-Library style.
7
+ *
8
+ * Strict, for the same reason the predicate union that wraps it is: a key nobody spells is a schema
9
+ * error naming the key, never a stripped field. Reported from the field —
10
+ * `{ kind: 'element', query: { css: "a[href='…']" } }` parsed, `css` was dropped, the empty query
11
+ * that survived matched nothing, and the verdict read "no element matched {}" about an element that
12
+ * was on the page. A stripped locator here is a false RED, and an agent that believes it goes and
13
+ * "fixes" correct code.
14
+ */
15
+ export const ElementQuerySchema = z
16
+ .object({
7
17
  by: z.nativeEnum(QueryBy).optional(),
8
18
  value: z.string().optional(),
9
19
  role: z.string().optional(),
@@ -23,6 +33,7 @@ export const ElementQuerySchema = z.object({
23
33
  /** Source location of the target element (auto-anchor resolution) — the precise, granular match. */
24
34
  source: z
25
35
  .object({ file: z.string(), line: z.number(), column: z.number().optional() })
36
+ .strict()
26
37
  .optional(),
27
38
  /** CSS selector or ref to scope the search. */
28
39
  scope: z.string().optional(),
@@ -36,7 +47,8 @@ export const ElementQuerySchema = z.object({
36
47
  * verification was handed back to the human. Requires `scope`.
37
48
  */
38
49
  self: z.boolean().optional(),
39
- });
50
+ })
51
+ .strict();
40
52
  /** One named flow advertised by the app (mirrors the browser CapabilityFlow). */
41
53
  export const CapabilityFlowSchema = z.object({
42
54
  name: z.string(),
@@ -19,6 +19,20 @@ export declare const Verified: {
19
19
  readonly NO: "no";
20
20
  /** Not determinable from this evidence — vacuous grade, dirty capture, or never settled. */
21
21
  readonly UNKNOWN: "unknown";
22
+ /**
23
+ * The engine saw the whole window, ran every oracle, and found nothing wrong — but nothing was
24
+ * declared to prove, so this is not verification.
25
+ *
26
+ * Distinct from `unknown`, which used to carry both this and "I could not see". The two need
27
+ * opposite responses: this one says ASSERT SOMETHING, the other says LOOK AGAIN WITH BETTER
28
+ * COVERAGE, and collapsing them into one word sent people to fix the wrong thing.
29
+ *
30
+ * Two properties keep it honest, and both are enforced rather than documented: it requires a
31
+ * SETTLED window, so it cannot be earned by returning early, and it is never `yes`, so it cannot be
32
+ * mistaken for proof. Without the first it would be the green-forever button that an
33
+ * always-available "nothing was wrong" always becomes.
34
+ */
35
+ readonly NO_FAULT: "no-fault";
22
36
  };
23
37
  export type Verified = (typeof Verified)[keyof typeof Verified];
24
38
  /**
@@ -62,16 +76,34 @@ export declare const VerifiedReason: {
62
76
  readonly ALREADY_TRUE: "already_true";
63
77
  /** The capture was not clean, so a green would only describe what happened to be observed. */
64
78
  readonly UNCLEAN_CAPTURE: "unclean_capture";
65
- /** Nothing was asserted at a real grade — the assertion could not have failed. */
79
+ /**
80
+ * Nothing was asserted at a real grade — the assertion could not have failed — AND the window did
81
+ * not settle, so the engine cannot even say it looked at the whole thing.
82
+ */
66
83
  readonly VACUOUS_GRADE: "vacuous_grade";
84
+ /** Nothing was asserted at a real grade, but the window settled and no channel reported a problem. */
85
+ readonly NOTHING_DECLARED: "nothing_declared";
67
86
  /** A write answered 202 Accepted: the outcome does not exist yet. */
68
87
  readonly OUTCOME_PENDING: "outcome_pending";
69
88
  /** A 2xx whose body was never recorded, so the one channel that could disagree was closed. */
70
89
  readonly OUTCOME_UNREAD: "outcome_unread";
71
90
  /** The page never settled, so the reaction window may have closed early. */
72
91
  readonly UNSETTLED: "unsettled";
92
+ /**
93
+ * The assertion held, but a channel's outcome had not been observed when the window closed — an
94
+ * ABSENCE-derived finding (see ABSENCE_DERIVED_CONTRADICTIONS), not evidence against the action.
95
+ *
96
+ * Split out of UNSETTLED because that word is a claim about idle, and this clause fires
97
+ * independently of whether the page went idle. One field report was, verbatim, "internally
98
+ * contradictory": `verifiedReason: "unsettled"` beside `settled: true`, a passing nested verdict,
99
+ * the requested POST at 200 and a clean console. Both halves came from this rule, and a verdict
100
+ * whose own evidence block denies its stated reason is a verdict nobody can act on.
101
+ */
102
+ readonly EVIDENCE_INCOMPLETE: "evidence_incomplete";
73
103
  /** Held at a real grade over a clean capture with no channel disagreeing. */
74
104
  readonly PROVED: "proved";
105
+ /** A passing absence assertion targeted a region Reticle could not observe. */
106
+ readonly ABSENCE_BLIND_SPOT: "absence_blind_spot";
75
107
  };
76
108
  export type VerifiedReason = (typeof VerifiedReason)[keyof typeof VerifiedReason];
77
109
  /**
@@ -176,5 +208,19 @@ export declare const BlindSpotKind: {
176
208
  * is declared, and the verdict over it reports partial coverage.
177
209
  */
178
210
  readonly VERDICTLESS_SEND: "verdictless-send";
211
+ /**
212
+ * No SUBSCRIBABLE store is registered, so the app's own state is unobservable.
213
+ *
214
+ * Without it, "the store did not change" and "nothing was watching the store" are the same empty
215
+ * `stateDiffs` — and the first reading is a confident wrong answer. It is the common case, not an
216
+ * exotic one: `init` writes a capabilities file that registers nothing until someone edits it, and
217
+ * a store passed as a bare getter is readable but silent, so an app can hold state, change it on
218
+ * every click, and report an empty state channel forever with no error anywhere.
219
+ *
220
+ * BOUNDING, never impeaching (see `impeachesCapture`): what WAS observed — DOM, network, console,
221
+ * storage — is observed completely. Only the state channel is dark, and it lights up the moment a
222
+ * subscribable store registers, which is when the SDK emits this kind with count 0.
223
+ */
224
+ readonly UNWATCHED_STATE: "unwatched-state";
179
225
  };
180
226
  export type BlindSpotKind = (typeof BlindSpotKind)[keyof typeof BlindSpotKind];
@@ -19,6 +19,20 @@ export const Verified = {
19
19
  NO: 'no',
20
20
  /** Not determinable from this evidence — vacuous grade, dirty capture, or never settled. */
21
21
  UNKNOWN: 'unknown',
22
+ /**
23
+ * The engine saw the whole window, ran every oracle, and found nothing wrong — but nothing was
24
+ * declared to prove, so this is not verification.
25
+ *
26
+ * Distinct from `unknown`, which used to carry both this and "I could not see". The two need
27
+ * opposite responses: this one says ASSERT SOMETHING, the other says LOOK AGAIN WITH BETTER
28
+ * COVERAGE, and collapsing them into one word sent people to fix the wrong thing.
29
+ *
30
+ * Two properties keep it honest, and both are enforced rather than documented: it requires a
31
+ * SETTLED window, so it cannot be earned by returning early, and it is never `yes`, so it cannot be
32
+ * mistaken for proof. Without the first it would be the green-forever button that an
33
+ * always-available "nothing was wrong" always becomes.
34
+ */
35
+ NO_FAULT: 'no-fault',
22
36
  };
23
37
  /**
24
38
  * WHY a verdict came out the way it did — the deciding clause of the rule, named.
@@ -61,16 +75,34 @@ export const VerifiedReason = {
61
75
  ALREADY_TRUE: 'already_true',
62
76
  /** The capture was not clean, so a green would only describe what happened to be observed. */
63
77
  UNCLEAN_CAPTURE: 'unclean_capture',
64
- /** Nothing was asserted at a real grade — the assertion could not have failed. */
78
+ /**
79
+ * Nothing was asserted at a real grade — the assertion could not have failed — AND the window did
80
+ * not settle, so the engine cannot even say it looked at the whole thing.
81
+ */
65
82
  VACUOUS_GRADE: 'vacuous_grade',
83
+ /** Nothing was asserted at a real grade, but the window settled and no channel reported a problem. */
84
+ NOTHING_DECLARED: 'nothing_declared',
66
85
  /** A write answered 202 Accepted: the outcome does not exist yet. */
67
86
  OUTCOME_PENDING: 'outcome_pending',
68
87
  /** A 2xx whose body was never recorded, so the one channel that could disagree was closed. */
69
88
  OUTCOME_UNREAD: 'outcome_unread',
70
89
  /** The page never settled, so the reaction window may have closed early. */
71
90
  UNSETTLED: 'unsettled',
91
+ /**
92
+ * The assertion held, but a channel's outcome had not been observed when the window closed — an
93
+ * ABSENCE-derived finding (see ABSENCE_DERIVED_CONTRADICTIONS), not evidence against the action.
94
+ *
95
+ * Split out of UNSETTLED because that word is a claim about idle, and this clause fires
96
+ * independently of whether the page went idle. One field report was, verbatim, "internally
97
+ * contradictory": `verifiedReason: "unsettled"` beside `settled: true`, a passing nested verdict,
98
+ * the requested POST at 200 and a clean console. Both halves came from this rule, and a verdict
99
+ * whose own evidence block denies its stated reason is a verdict nobody can act on.
100
+ */
101
+ EVIDENCE_INCOMPLETE: 'evidence_incomplete',
72
102
  /** Held at a real grade over a clean capture with no channel disagreeing. */
73
103
  PROVED: 'proved',
104
+ /** A passing absence assertion targeted a region Reticle could not observe. */
105
+ ABSENCE_BLIND_SPOT: 'absence_blind_spot',
74
106
  };
75
107
  /**
76
108
  * WHAT made a capture unclean — the closed vocabulary behind `UNCLEAN_CAPTURE`.
@@ -173,4 +205,18 @@ export const BlindSpotKind = {
173
205
  * is declared, and the verdict over it reports partial coverage.
174
206
  */
175
207
  VERDICTLESS_SEND: 'verdictless-send',
208
+ /**
209
+ * No SUBSCRIBABLE store is registered, so the app's own state is unobservable.
210
+ *
211
+ * Without it, "the store did not change" and "nothing was watching the store" are the same empty
212
+ * `stateDiffs` — and the first reading is a confident wrong answer. It is the common case, not an
213
+ * exotic one: `init` writes a capabilities file that registers nothing until someone edits it, and
214
+ * a store passed as a bare getter is readable but silent, so an app can hold state, change it on
215
+ * every click, and report an empty state channel forever with no error anywhere.
216
+ *
217
+ * BOUNDING, never impeaching (see `impeachesCapture`): what WAS observed — DOM, network, console,
218
+ * storage — is observed completely. Only the state channel is dark, and it lights up the moment a
219
+ * subscribable store registers, which is when the SDK emits this kind with count 0.
220
+ */
221
+ UNWATCHED_STATE: 'unwatched-state',
176
222
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reticlehq/core",
3
- "version": "2.8.0",
3
+ "version": "2.10.0",
4
4
  "description": "The Reticle foundation: the shared wire contract — types, zod schemas, constants, messages, and the isomorphic kernel that every Reticle package (browser SDK, server, kits, test harness) imports. Depends only on zod.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",