@reticlehq/core 2.11.0 → 2.13.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 (58) hide show
  1. package/dist/constants.d.ts +40 -0
  2. package/dist/constants.js +41 -1
  3. package/dist/dev-server-registry.d.ts +85 -0
  4. package/dist/dev-server-registry.js +120 -0
  5. package/dist/document-identity.d.ts +39 -0
  6. package/dist/document-identity.js +53 -0
  7. package/dist/edit-epoch.d.ts +36 -0
  8. package/dist/edit-epoch.js +40 -0
  9. package/dist/event-payloads.d.ts +24 -4
  10. package/dist/event-payloads.js +13 -1
  11. package/dist/findings.d.ts +62 -0
  12. package/dist/findings.js +75 -0
  13. package/dist/flow-types.d.ts +88 -0
  14. package/dist/flow-types.js +22 -0
  15. package/dist/impact.d.ts +176 -0
  16. package/dist/impact.js +36 -0
  17. package/dist/index.d.ts +8 -0
  18. package/dist/index.js +9 -0
  19. package/dist/instrumentation-gap.d.ts +59 -1
  20. package/dist/instrumentation-gap.js +0 -0
  21. package/dist/intent.d.ts +332 -0
  22. package/dist/intent.js +133 -0
  23. package/dist/journal.d.ts +33 -0
  24. package/dist/journal.js +20 -0
  25. package/dist/messages.d.ts +84 -10
  26. package/dist/messages.js +20 -0
  27. package/dist/net.d.ts +34 -0
  28. package/dist/net.js +86 -0
  29. package/dist/no-session-reason.d.ts +35 -0
  30. package/dist/no-session-reason.js +34 -0
  31. package/dist/notices.d.ts +79 -6
  32. package/dist/notices.js +83 -6
  33. package/dist/run-context.d.ts +122 -0
  34. package/dist/run-context.js +118 -0
  35. package/dist/schema/event-message.json +10 -0
  36. package/dist/schema/event-type.json +1 -0
  37. package/dist/schema/reticle-event.json +10 -0
  38. package/dist/schema/reticle-message.json +10 -0
  39. package/dist/security.d.ts +8 -2
  40. package/dist/security.js +37 -3
  41. package/dist/session-constants.d.ts +8 -0
  42. package/dist/session-constants.js +8 -0
  43. package/dist/source-constants.cjs +9 -0
  44. package/dist/source-constants.d.cts +4 -0
  45. package/dist/telemetry-license.d.ts +12 -0
  46. package/dist/telemetry-license.js +12 -0
  47. package/dist/telemetry-refusal.d.ts +94 -0
  48. package/dist/telemetry-refusal.js +61 -0
  49. package/dist/telemetry-session.d.ts +151 -2
  50. package/dist/telemetry-session.js +114 -0
  51. package/dist/telemetry.d.ts +167 -95
  52. package/dist/telemetry.js +46 -44
  53. package/dist/types.d.ts +9 -0
  54. package/dist/unreachable-notice.d.ts +19 -0
  55. package/dist/unreachable-notice.js +26 -0
  56. package/dist/verified-constants.d.ts +8 -0
  57. package/dist/verified-constants.js +10 -0
  58. package/package.json +6 -2
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Refusals — why a tool could not do what was asked, and the row that reports one.
3
+ *
4
+ * Split out of telemetry.ts at the 1000-line cap, alongside telemetry-feedback.ts which was split
5
+ * for the same reason. The seam is real: telemetry.ts is the session wire, and this is the refusal
6
+ * vocabulary that `error-recovery.ts` is graded against. `NoSessionReason` lives in its own module
7
+ * again, because it refines exactly one member of the enum below.
8
+ */
9
+ import { z } from 'zod';
10
+ /**
11
+ * WHY a tool could not do what was asked.
12
+ *
13
+ * Derived from the refusal paths that actually exist rather than invented: every member below is a
14
+ * bucket over `error-recovery.ts`'s recovery table, which is the single place a thrown message is
15
+ * turned into a next action. That table is the vocabulary; this is its coarse grouping, and a new
16
+ * entry there cannot compile without being classified here.
17
+ *
18
+ * The five that matter belong to four different owners, which is the whole reason for splitting
19
+ * them: `no_session` is the install's second half never happening, `bad_args` is the agent's own
20
+ * call, `not_ready` is the environment, and `no_match` / `unsupported` are the app and our own
21
+ * capability surface. One undifferentiated "the agent stopped" number cannot be acted on by anyone.
22
+ */
23
+ export declare const RefusalReason: {
24
+ /** There was no app to reach: nothing connected, no session by that id, or several with none named. */
25
+ readonly NO_SESSION: "no_session";
26
+ /** The target did not exist: a stale ref, a missing baseline, an option value the select has not got. */
27
+ readonly NO_MATCH: "no_match";
28
+ /** Reticle refuses to pretend: a rich-text surface, a disabled field, a destructive control. */
29
+ readonly UNSUPPORTED: "unsupported";
30
+ /** The call did not match the schema, or named a value our own validators reject. */
31
+ readonly BAD_ARGS: "bad_args";
32
+ /** Nothing is wrong with the call; the world is not ready — a throttled tab, a timeout, no browser. */
33
+ readonly NOT_READY: "not_ready";
34
+ /** A refusal this list does not name. A classifier that cannot say "I don't know" lies instead. */
35
+ readonly OTHER: "other";
36
+ };
37
+ export type RefusalReason = (typeof RefusalReason)[keyof typeof RefusalReason];
38
+ /** One tool call that could not be served. */
39
+ export declare const ToolRefusalSchema: z.ZodObject<{
40
+ /** Which tool. A name from our own fixed namespace, never app data. */
41
+ tool: z.ZodString;
42
+ reason: z.ZodNativeEnum<{
43
+ /** There was no app to reach: nothing connected, no session by that id, or several with none named. */
44
+ readonly NO_SESSION: "no_session";
45
+ /** The target did not exist: a stale ref, a missing baseline, an option value the select has not got. */
46
+ readonly NO_MATCH: "no_match";
47
+ /** Reticle refuses to pretend: a rich-text surface, a disabled field, a destructive control. */
48
+ readonly UNSUPPORTED: "unsupported";
49
+ /** The call did not match the schema, or named a value our own validators reject. */
50
+ readonly BAD_ARGS: "bad_args";
51
+ /** Nothing is wrong with the call; the world is not ready — a throttled tab, a timeout, no browser. */
52
+ readonly NOT_READY: "not_ready";
53
+ /** A refusal this list does not name. A classifier that cannot say "I don't know" lies instead. */
54
+ readonly OTHER: "other";
55
+ }>;
56
+ /**
57
+ * For `no_session` only: WHICH no-session situation, from core's closed `NoSessionReason`.
58
+ *
59
+ * Rides the refusal rather than the profile because this is where the diagnosis is actually
60
+ * COMPUTED - `project_profiled` fires once at daemon start, before any tool call has failed, so
61
+ * it cannot carry a reason that does not exist yet. Absent on every other refusal reason.
62
+ */
63
+ noSessionReason: z.ZodOptional<z.ZodNativeEnum<{
64
+ readonly LEASE_EXPIRED: "lease_expired";
65
+ readonly TAB_GONE: "tab_gone";
66
+ readonly APP_NOT_REOPENED: "app_not_reopened";
67
+ readonly CONFIG_ELSEWHERE: "config_elsewhere";
68
+ readonly NO_LISTENER_NO_CONFIG: "no_listener_no_config";
69
+ readonly NO_LISTENER: "no_listener";
70
+ readonly NO_CONFIG: "no_config";
71
+ readonly SDK_NOT_REACHING_DAEMON: "sdk_not_reaching_daemon";
72
+ }>>;
73
+ /**
74
+ * TRUE when the call immediately before this one was the SAME tool, also refused.
75
+ *
76
+ * Reported on the RETRY rather than on the first refusal, because the first refusal has to be sent
77
+ * at the moment it happens: deferring it until the next call is known would lose it entirely for
78
+ * the agent that gives up, and that agent is the whole population this event exists to describe.
79
+ * So count `retried: true` for retries; the ratio against all refusals is whether our diagnosis
80
+ * gets anybody unstuck.
81
+ */
82
+ retried: z.ZodBoolean;
83
+ }, "strip", z.ZodTypeAny, {
84
+ reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
85
+ tool: string;
86
+ retried: boolean;
87
+ noSessionReason?: "lease_expired" | "tab_gone" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
88
+ }, {
89
+ reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
90
+ tool: string;
91
+ retried: boolean;
92
+ noSessionReason?: "lease_expired" | "tab_gone" | "app_not_reopened" | "config_elsewhere" | "no_listener_no_config" | "no_listener" | "no_config" | "sdk_not_reaching_daemon" | undefined;
93
+ }>;
94
+ export type ToolRefusal = z.infer<typeof ToolRefusalSchema>;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Refusals — why a tool could not do what was asked, and the row that reports one.
3
+ *
4
+ * Split out of telemetry.ts at the 1000-line cap, alongside telemetry-feedback.ts which was split
5
+ * for the same reason. The seam is real: telemetry.ts is the session wire, and this is the refusal
6
+ * vocabulary that `error-recovery.ts` is graded against. `NoSessionReason` lives in its own module
7
+ * again, because it refines exactly one member of the enum below.
8
+ */
9
+ import { z } from 'zod';
10
+ import { NoSessionReason } from './no-session-reason.js';
11
+ /**
12
+ * WHY a tool could not do what was asked.
13
+ *
14
+ * Derived from the refusal paths that actually exist rather than invented: every member below is a
15
+ * bucket over `error-recovery.ts`'s recovery table, which is the single place a thrown message is
16
+ * turned into a next action. That table is the vocabulary; this is its coarse grouping, and a new
17
+ * entry there cannot compile without being classified here.
18
+ *
19
+ * The five that matter belong to four different owners, which is the whole reason for splitting
20
+ * them: `no_session` is the install's second half never happening, `bad_args` is the agent's own
21
+ * call, `not_ready` is the environment, and `no_match` / `unsupported` are the app and our own
22
+ * capability surface. One undifferentiated "the agent stopped" number cannot be acted on by anyone.
23
+ */
24
+ export const RefusalReason = {
25
+ /** There was no app to reach: nothing connected, no session by that id, or several with none named. */
26
+ NO_SESSION: 'no_session',
27
+ /** The target did not exist: a stale ref, a missing baseline, an option value the select has not got. */
28
+ NO_MATCH: 'no_match',
29
+ /** Reticle refuses to pretend: a rich-text surface, a disabled field, a destructive control. */
30
+ UNSUPPORTED: 'unsupported',
31
+ /** The call did not match the schema, or named a value our own validators reject. */
32
+ BAD_ARGS: 'bad_args',
33
+ /** Nothing is wrong with the call; the world is not ready — a throttled tab, a timeout, no browser. */
34
+ NOT_READY: 'not_ready',
35
+ /** A refusal this list does not name. A classifier that cannot say "I don't know" lies instead. */
36
+ OTHER: 'other',
37
+ };
38
+ /** One tool call that could not be served. */
39
+ export const ToolRefusalSchema = z.object({
40
+ /** Which tool. A name from our own fixed namespace, never app data. */
41
+ tool: z.string().min(1).max(64),
42
+ reason: z.nativeEnum(RefusalReason),
43
+ /**
44
+ * For `no_session` only: WHICH no-session situation, from core's closed `NoSessionReason`.
45
+ *
46
+ * Rides the refusal rather than the profile because this is where the diagnosis is actually
47
+ * COMPUTED - `project_profiled` fires once at daemon start, before any tool call has failed, so
48
+ * it cannot carry a reason that does not exist yet. Absent on every other refusal reason.
49
+ */
50
+ noSessionReason: z.nativeEnum(NoSessionReason).optional(),
51
+ /**
52
+ * TRUE when the call immediately before this one was the SAME tool, also refused.
53
+ *
54
+ * Reported on the RETRY rather than on the first refusal, because the first refusal has to be sent
55
+ * at the moment it happens: deferring it until the next call is known would lose it entirely for
56
+ * the agent that gives up, and that agent is the whole population this event exists to describe.
57
+ * So count `retried: true` for retries; the ratio against all refusals is whether our diagnosis
58
+ * gets anybody unstuck.
59
+ */
60
+ retried: z.boolean(),
61
+ });
@@ -309,6 +309,22 @@ export declare const SessionSummarySchema: z.ZodObject<{
309
309
  * PRESENCE is the signal.
310
310
  */
311
311
  noSessionErrors: z.ZodOptional<z.ZodNumber>;
312
+ /**
313
+ * Connection-level POST failures on the MCP proxy (`ENOBUFS`, `EMFILE`, `EADDRNOTAVAIL`,
314
+ * `ECONNREFUSED` before any bytes were sent).
315
+ *
316
+ * These never produce `tool_refused` (the call never reached a handler) and never produce
317
+ * `mcp_connection_lost` (the SSE stream is fine). Without this count, a keep-alive retry that
318
+ * saves the call is indistinguishable from one that never fired. Absent when none happened.
319
+ */
320
+ postSocketFailures: z.ZodOptional<z.ZodNumber>;
321
+ /**
322
+ * Of those POST failures, how many a bounded retry then delivered.
323
+ *
324
+ * The numerator against `postSocketFailures`: a retry that quietly saves a call is a different
325
+ * fact from a retry that never runs. Absent when none were saved.
326
+ */
327
+ postRetriesSaved: z.ZodOptional<z.ZodNumber>;
312
328
  /**
313
329
  * Longest back-to-back run per tool name — the shape of a retry loop.
314
330
  *
@@ -444,6 +460,33 @@ export declare const SessionSummarySchema: z.ZodObject<{
444
460
  * asked whether it worked is the finding, so absence and `false` must not look alike.
445
461
  */
446
462
  endedWithVerdict: z.ZodOptional<z.ZodBoolean>;
463
+ /**
464
+ * Was the update nudge actually delivered to an agent during this daemon run.
465
+ *
466
+ * The nudge is the entire adoption mechanism for a published fix — it rides the tool-result
467
+ * envelope once per daemon process — and it emitted NOTHING, so the one question it exists to
468
+ * answer could not be asked. `versionChange.nudged` is the other half and only reaches us from
469
+ * machines that DID update; the cohort pinned three releases back never fires `version_changed` at
470
+ * all, which is exactly the cohort worth understanding.
471
+ *
472
+ * Crossed against this same installId's `version` on a later day it separates the two causes,
473
+ * which need opposite fixes: `false` for run after run means the nudge is not firing for them (a
474
+ * cache that never warms, a check that never returns, an offline machine); `true` for run after
475
+ * run with a version that never moves means the agent is receiving it and dropping it out of the
476
+ * envelope, or telling a human who says no.
477
+ *
478
+ * Reads the delivery flag, not a counter: the nudge is one-shot per process by design, so `true`
479
+ * means "an agent was told", never "how often".
480
+ */
481
+ updateNudged: z.ZodOptional<z.ZodBoolean>;
482
+ /**
483
+ * The newer version this daemon knew about, when it knew about one.
484
+ *
485
+ * OUR OWN published version number, so it is low-cardinality and carries nothing about the
486
+ * machine. Without it `updateNudged: false` is two facts at once — nothing was available, or
487
+ * something was and the nudge did not fire — and only the second is a defect.
488
+ */
489
+ updateOffered: z.ZodOptional<z.ZodString>;
447
490
  /** Was this a clean shutdown, or a periodic flush of a still-running session? */
448
491
  final: z.ZodBoolean;
449
492
  /**
@@ -499,6 +542,8 @@ export declare const SessionSummarySchema: z.ZodObject<{
499
542
  unknownToolCalls?: number | undefined;
500
543
  unknownTools?: Record<string, number> | undefined;
501
544
  noSessionErrors?: number | undefined;
545
+ postSocketFailures?: number | undefined;
546
+ postRetriesSaved?: number | undefined;
502
547
  consecutiveRepeats?: Record<string, number> | undefined;
503
548
  abandonedActions?: number | undefined;
504
549
  machine?: {
@@ -513,12 +558,14 @@ export declare const SessionSummarySchema: z.ZodObject<{
513
558
  clientVersions?: Record<string, string> | undefined;
514
559
  appConnects?: number | undefined;
515
560
  msToFirstApp?: number | undefined;
516
- endReason?: "never_used" | "explored" | "abandoned" | "verified" | "client_left" | undefined;
561
+ endReason?: "verified" | "never_used" | "explored" | "abandoned" | "client_left" | undefined;
517
562
  feedbackPrompted?: number | undefined;
518
563
  errorClasses?: Record<string, number> | undefined;
519
564
  errorsRecovered?: number | undefined;
520
565
  errorsRepeated?: number | undefined;
521
566
  endedWithVerdict?: boolean | undefined;
567
+ updateNudged?: boolean | undefined;
568
+ updateOffered?: string | undefined;
522
569
  exit?: "signal" | "idle" | "unknown" | undefined;
523
570
  }, {
524
571
  durationMs: number;
@@ -560,6 +607,8 @@ export declare const SessionSummarySchema: z.ZodObject<{
560
607
  unknownToolCalls?: number | undefined;
561
608
  unknownTools?: Record<string, number> | undefined;
562
609
  noSessionErrors?: number | undefined;
610
+ postSocketFailures?: number | undefined;
611
+ postRetriesSaved?: number | undefined;
563
612
  consecutiveRepeats?: Record<string, number> | undefined;
564
613
  abandonedActions?: number | undefined;
565
614
  machine?: {
@@ -574,12 +623,14 @@ export declare const SessionSummarySchema: z.ZodObject<{
574
623
  clientVersions?: Record<string, string> | undefined;
575
624
  appConnects?: number | undefined;
576
625
  msToFirstApp?: number | undefined;
577
- endReason?: "never_used" | "explored" | "abandoned" | "verified" | "client_left" | undefined;
626
+ endReason?: "verified" | "never_used" | "explored" | "abandoned" | "client_left" | undefined;
578
627
  feedbackPrompted?: number | undefined;
579
628
  errorClasses?: Record<string, number> | undefined;
580
629
  errorsRecovered?: number | undefined;
581
630
  errorsRepeated?: number | undefined;
582
631
  endedWithVerdict?: boolean | undefined;
632
+ updateNudged?: boolean | undefined;
633
+ updateOffered?: string | undefined;
583
634
  exit?: "signal" | "idle" | "unknown" | undefined;
584
635
  }>;
585
636
  export type SessionSummary = z.infer<typeof SessionSummarySchema>;
@@ -596,6 +647,40 @@ export declare const ProjectSize: {
596
647
  readonly HUGE: "huge";
597
648
  };
598
649
  export type ProjectSize = (typeof ProjectSize)[keyof typeof ProjectSize];
650
+ /**
651
+ * Why a profile carries no `stack`, when it carries none.
652
+ *
653
+ * `stack` unknown is one of the largest buckets on the profile, and an empty field is not a cause:
654
+ * it collapses "the daemon was started somewhere that is not a project" with "we read this app's
655
+ * manifest and did not recognise what it uses", which need opposite fixes — the first is a
656
+ * discovery problem, the second is a one-line addition to the dependency table.
657
+ *
658
+ * Derived from the branches of `detectStack` rather than computed beside them. A reason assembled
659
+ * separately from the code that failed drifts from it, and then the dimension is worse than absent
660
+ * because it is confidently wrong.
661
+ */
662
+ export declare const StackUnknownReason: {
663
+ /** No manifest here, and discovery found no app anywhere below. Usually a daemon started outside the project. */
664
+ readonly NO_APP_FOUND: "no_app_found";
665
+ /** A `package.json` HERE, read fine, naming no dependency in the table. The app is a stack we do not know. */
666
+ readonly MANIFEST_UNRECOGNISED: "manifest_unrecognised";
667
+ /** Discovery found workspace apps and every one of their manifests was unrecognised. */
668
+ readonly WORKSPACE_APPS_UNRECOGNISED: "workspace_apps_unrecognised";
669
+ /**
670
+ * The cwd manifest DECLARES workspaces and discovery surfaced no app in any of them.
671
+ *
672
+ * Separated from `NO_APP_FOUND` because it is a different failure with a different fix, and
673
+ * likely the dominant one: `findWorkspaceApps` admits a directory only when it holds a Vite or
674
+ * Next config file, or names `next`/`vite` outright. A workspace app on Angular, Nuxt, SvelteKit
675
+ * or Remix is therefore never surfaced, so its manifest is never read and no addition to the
676
+ * stack table could ever reach it. Folded into `NO_APP_FOUND` this reads as "no project here",
677
+ * which points at discovery scope when the gap is in what discovery will admit.
678
+ */
679
+ readonly WORKSPACE_ROOT_NO_APPS: "workspace_root_no_apps";
680
+ /** Workspace discovery threw — a permission error, most likely. Distinguished so it cannot masquerade as absence. */
681
+ readonly DISCOVERY_FAILED: "discovery_failed";
682
+ };
683
+ export type StackUnknownReason = (typeof StackUnknownReason)[keyof typeof StackUnknownReason];
599
684
  /**
600
685
  * The shape of the project and how much of Reticle it actually uses.
601
686
  *
@@ -619,6 +704,34 @@ export declare const ProjectProfileSchema: z.ZodObject<{
619
704
  * that reads one directory reports nothing precisely where the real repos are.
620
705
  */
621
706
  stackSource: z.ZodOptional<z.ZodEnum<["cwd", "workspace"]>>;
707
+ /**
708
+ * Why there is no `stack`, when there is none. Present ONLY when `stack` is absent.
709
+ *
710
+ * Omitted rather than sent as a "resolved" member, so the field's presence is itself the signal —
711
+ * the same rule the session counters follow. A member meaning "nothing went wrong" would be sent
712
+ * on every successful profile and would have to be filtered out of every query that uses this.
713
+ */
714
+ stackUnknownReason: z.ZodOptional<z.ZodNativeEnum<{
715
+ /** No manifest here, and discovery found no app anywhere below. Usually a daemon started outside the project. */
716
+ readonly NO_APP_FOUND: "no_app_found";
717
+ /** A `package.json` HERE, read fine, naming no dependency in the table. The app is a stack we do not know. */
718
+ readonly MANIFEST_UNRECOGNISED: "manifest_unrecognised";
719
+ /** Discovery found workspace apps and every one of their manifests was unrecognised. */
720
+ readonly WORKSPACE_APPS_UNRECOGNISED: "workspace_apps_unrecognised";
721
+ /**
722
+ * The cwd manifest DECLARES workspaces and discovery surfaced no app in any of them.
723
+ *
724
+ * Separated from `NO_APP_FOUND` because it is a different failure with a different fix, and
725
+ * likely the dominant one: `findWorkspaceApps` admits a directory only when it holds a Vite or
726
+ * Next config file, or names `next`/`vite` outright. A workspace app on Angular, Nuxt, SvelteKit
727
+ * or Remix is therefore never surfaced, so its manifest is never read and no addition to the
728
+ * stack table could ever reach it. Folded into `NO_APP_FOUND` this reads as "no project here",
729
+ * which points at discovery scope when the gap is in what discovery will admit.
730
+ */
731
+ readonly WORKSPACE_ROOT_NO_APPS: "workspace_root_no_apps";
732
+ /** Workspace discovery threw — a permission error, most likely. Distinguished so it cannot masquerade as absence. */
733
+ readonly DISCOVERY_FAILED: "discovery_failed";
734
+ }>>;
622
735
  /** Its MAJOR version only — "breaks on React 19" is a work item, a full semver is a fingerprint. */
623
736
  stackMajor: z.ZodOptional<z.ZodNumber>;
624
737
  size: z.ZodOptional<z.ZodNativeEnum<{
@@ -665,6 +778,36 @@ export declare const ProjectProfileSchema: z.ZodObject<{
665
778
  runCount: z.ZodNumber;
666
779
  /** A git-checked `.reticle/contract.json` — the team declared a testable surface on purpose. */
667
780
  hasContract: z.ZodBoolean;
781
+ /**
782
+ * Has `reticle init` run in this project — a `.reticle.json` is present.
783
+ *
784
+ * The install has two halves and the failure side of the second one is a SET DIFFERENCE:
785
+ * `daemon_started` minus `app_instrumented`, joined on `sessionId`. That difference says a daemon
786
+ * ran with nothing wired and cannot say WHY, so the whole non-instrumented majority arrives as one
787
+ * silence covering four different situations with four different owners.
788
+ *
789
+ * This is the first of the two bits that split it, and it is on `project_profiled` deliberately:
790
+ * that event fires once per daemon start whatever happens afterwards, so it is the only place a
791
+ * fact about a project reaches us for the users who never instrument anything. `app_instrumented`
792
+ * carries the same field and cannot answer this, because it only exists when the answer is moot.
793
+ */
794
+ initialized: z.ZodOptional<z.ZodBoolean>;
795
+ /**
796
+ * Has an app for this project EVER connected to Reticle — read from durable state, not from this
797
+ * process.
798
+ *
799
+ * The second bit. `initialized: false` is "never ran init"; `initialized: true` with this `false`
800
+ * is the cohort the funnel loses — the config was written and no page has ever reached the daemon,
801
+ * which is the dev server that was never restarted, a plugin that never loaded, or a handshake
802
+ * refused at the origin gate. `true` here with no `app_instrumented` this run is a working install
803
+ * whose app simply is not up right now, and reading that as a loss is how the drop-off gets
804
+ * over-stated.
805
+ *
806
+ * Scoped to project + port, like every other reader of this state, so it cannot borrow another
807
+ * project's success on a shared daemon. OPTIONAL because an older sender has none; absent means
808
+ * not measured, never `false`.
809
+ */
810
+ appConnectedBefore: z.ZodOptional<z.ZodBoolean>;
668
811
  /** Fail-to-pass bug capsules — the deepest feature in the product. */
669
812
  capsuleCount: z.ZodNumber;
670
813
  /** Which of Reticle's feature FAMILIES this project has ever touched. The activation metric. */
@@ -684,10 +827,13 @@ export declare const ProjectProfileSchema: z.ZodObject<{
684
827
  stack?: string | undefined;
685
828
  stackMajor?: number | undefined;
686
829
  stackSource?: "cwd" | "workspace" | undefined;
830
+ stackUnknownReason?: "no_app_found" | "manifest_unrecognised" | "workspace_apps_unrecognised" | "workspace_root_no_apps" | "discovery_failed" | undefined;
687
831
  size?: "medium" | "tiny" | "small" | "large" | "huge" | undefined;
688
832
  monorepo?: boolean | undefined;
689
833
  forge?: "github" | "gitlab" | "bitbucket" | "azure" | "sourcehut" | "codeberg" | "self_hosted" | undefined;
690
834
  ageWeeks?: number | undefined;
835
+ initialized?: boolean | undefined;
836
+ appConnectedBefore?: boolean | undefined;
691
837
  }, {
692
838
  git: "none" | "local_only" | "remote";
693
839
  flowCount: number;
@@ -701,9 +847,12 @@ export declare const ProjectProfileSchema: z.ZodObject<{
701
847
  stack?: string | undefined;
702
848
  stackMajor?: number | undefined;
703
849
  stackSource?: "cwd" | "workspace" | undefined;
850
+ stackUnknownReason?: "no_app_found" | "manifest_unrecognised" | "workspace_apps_unrecognised" | "workspace_root_no_apps" | "discovery_failed" | undefined;
704
851
  size?: "medium" | "tiny" | "small" | "large" | "huge" | undefined;
705
852
  monorepo?: boolean | undefined;
706
853
  forge?: "github" | "gitlab" | "bitbucket" | "azure" | "sourcehut" | "codeberg" | "self_hosted" | undefined;
707
854
  ageWeeks?: number | undefined;
855
+ initialized?: boolean | undefined;
856
+ appConnectedBefore?: boolean | undefined;
708
857
  }>;
709
858
  export type ProjectProfile = z.infer<typeof ProjectProfileSchema>;
@@ -202,6 +202,22 @@ export const SessionSummarySchema = z.object({
202
202
  * PRESENCE is the signal.
203
203
  */
204
204
  noSessionErrors: z.number().int().nonnegative().optional(),
205
+ /**
206
+ * Connection-level POST failures on the MCP proxy (`ENOBUFS`, `EMFILE`, `EADDRNOTAVAIL`,
207
+ * `ECONNREFUSED` before any bytes were sent).
208
+ *
209
+ * These never produce `tool_refused` (the call never reached a handler) and never produce
210
+ * `mcp_connection_lost` (the SSE stream is fine). Without this count, a keep-alive retry that
211
+ * saves the call is indistinguishable from one that never fired. Absent when none happened.
212
+ */
213
+ postSocketFailures: z.number().int().nonnegative().optional(),
214
+ /**
215
+ * Of those POST failures, how many a bounded retry then delivered.
216
+ *
217
+ * The numerator against `postSocketFailures`: a retry that quietly saves a call is a different
218
+ * fact from a retry that never runs. Absent when none were saved.
219
+ */
220
+ postRetriesSaved: z.number().int().nonnegative().optional(),
205
221
  /**
206
222
  * Longest back-to-back run per tool name — the shape of a retry loop.
207
223
  *
@@ -313,6 +329,33 @@ export const SessionSummarySchema = z.object({
313
329
  * asked whether it worked is the finding, so absence and `false` must not look alike.
314
330
  */
315
331
  endedWithVerdict: z.boolean().optional(),
332
+ /**
333
+ * Was the update nudge actually delivered to an agent during this daemon run.
334
+ *
335
+ * The nudge is the entire adoption mechanism for a published fix — it rides the tool-result
336
+ * envelope once per daemon process — and it emitted NOTHING, so the one question it exists to
337
+ * answer could not be asked. `versionChange.nudged` is the other half and only reaches us from
338
+ * machines that DID update; the cohort pinned three releases back never fires `version_changed` at
339
+ * all, which is exactly the cohort worth understanding.
340
+ *
341
+ * Crossed against this same installId's `version` on a later day it separates the two causes,
342
+ * which need opposite fixes: `false` for run after run means the nudge is not firing for them (a
343
+ * cache that never warms, a check that never returns, an offline machine); `true` for run after
344
+ * run with a version that never moves means the agent is receiving it and dropping it out of the
345
+ * envelope, or telling a human who says no.
346
+ *
347
+ * Reads the delivery flag, not a counter: the nudge is one-shot per process by design, so `true`
348
+ * means "an agent was told", never "how often".
349
+ */
350
+ updateNudged: z.boolean().optional(),
351
+ /**
352
+ * The newer version this daemon knew about, when it knew about one.
353
+ *
354
+ * OUR OWN published version number, so it is low-cardinality and carries nothing about the
355
+ * machine. Without it `updateNudged: false` is two facts at once — nothing was available, or
356
+ * something was and the nudge did not fire — and only the second is a defect.
357
+ */
358
+ updateOffered: z.string().max(32).optional(),
316
359
  /** Was this a clean shutdown, or a periodic flush of a still-running session? */
317
360
  final: z.boolean(),
318
361
  /**
@@ -341,6 +384,39 @@ export const ProjectSize = {
341
384
  LARGE: 'large', // < 5000
342
385
  HUGE: 'huge', // 5000+ — a monorepo or a mature product
343
386
  };
387
+ /**
388
+ * Why a profile carries no `stack`, when it carries none.
389
+ *
390
+ * `stack` unknown is one of the largest buckets on the profile, and an empty field is not a cause:
391
+ * it collapses "the daemon was started somewhere that is not a project" with "we read this app's
392
+ * manifest and did not recognise what it uses", which need opposite fixes — the first is a
393
+ * discovery problem, the second is a one-line addition to the dependency table.
394
+ *
395
+ * Derived from the branches of `detectStack` rather than computed beside them. A reason assembled
396
+ * separately from the code that failed drifts from it, and then the dimension is worse than absent
397
+ * because it is confidently wrong.
398
+ */
399
+ export const StackUnknownReason = {
400
+ /** No manifest here, and discovery found no app anywhere below. Usually a daemon started outside the project. */
401
+ NO_APP_FOUND: 'no_app_found',
402
+ /** A `package.json` HERE, read fine, naming no dependency in the table. The app is a stack we do not know. */
403
+ MANIFEST_UNRECOGNISED: 'manifest_unrecognised',
404
+ /** Discovery found workspace apps and every one of their manifests was unrecognised. */
405
+ WORKSPACE_APPS_UNRECOGNISED: 'workspace_apps_unrecognised',
406
+ /**
407
+ * The cwd manifest DECLARES workspaces and discovery surfaced no app in any of them.
408
+ *
409
+ * Separated from `NO_APP_FOUND` because it is a different failure with a different fix, and
410
+ * likely the dominant one: `findWorkspaceApps` admits a directory only when it holds a Vite or
411
+ * Next config file, or names `next`/`vite` outright. A workspace app on Angular, Nuxt, SvelteKit
412
+ * or Remix is therefore never surfaced, so its manifest is never read and no addition to the
413
+ * stack table could ever reach it. Folded into `NO_APP_FOUND` this reads as "no project here",
414
+ * which points at discovery scope when the gap is in what discovery will admit.
415
+ */
416
+ WORKSPACE_ROOT_NO_APPS: 'workspace_root_no_apps',
417
+ /** Workspace discovery threw — a permission error, most likely. Distinguished so it cannot masquerade as absence. */
418
+ DISCOVERY_FAILED: 'discovery_failed',
419
+ };
344
420
  /**
345
421
  * The shape of the project and how much of Reticle it actually uses.
346
422
  *
@@ -364,6 +440,14 @@ export const ProjectProfileSchema = z.object({
364
440
  * that reads one directory reports nothing precisely where the real repos are.
365
441
  */
366
442
  stackSource: z.enum(['cwd', 'workspace']).optional(),
443
+ /**
444
+ * Why there is no `stack`, when there is none. Present ONLY when `stack` is absent.
445
+ *
446
+ * Omitted rather than sent as a "resolved" member, so the field's presence is itself the signal —
447
+ * the same rule the session counters follow. A member meaning "nothing went wrong" would be sent
448
+ * on every successful profile and would have to be filtered out of every query that uses this.
449
+ */
450
+ stackUnknownReason: z.nativeEnum(StackUnknownReason).optional(),
367
451
  /** Its MAJOR version only — "breaks on React 19" is a work item, a full semver is a fingerprint. */
368
452
  stackMajor: z.number().int().nonnegative().optional(),
369
453
  size: z.nativeEnum(ProjectSize).optional(),
@@ -389,6 +473,36 @@ export const ProjectProfileSchema = z.object({
389
473
  runCount: z.number().int().nonnegative(),
390
474
  /** A git-checked `.reticle/contract.json` — the team declared a testable surface on purpose. */
391
475
  hasContract: z.boolean(),
476
+ /**
477
+ * Has `reticle init` run in this project — a `.reticle.json` is present.
478
+ *
479
+ * The install has two halves and the failure side of the second one is a SET DIFFERENCE:
480
+ * `daemon_started` minus `app_instrumented`, joined on `sessionId`. That difference says a daemon
481
+ * ran with nothing wired and cannot say WHY, so the whole non-instrumented majority arrives as one
482
+ * silence covering four different situations with four different owners.
483
+ *
484
+ * This is the first of the two bits that split it, and it is on `project_profiled` deliberately:
485
+ * that event fires once per daemon start whatever happens afterwards, so it is the only place a
486
+ * fact about a project reaches us for the users who never instrument anything. `app_instrumented`
487
+ * carries the same field and cannot answer this, because it only exists when the answer is moot.
488
+ */
489
+ initialized: z.boolean().optional(),
490
+ /**
491
+ * Has an app for this project EVER connected to Reticle — read from durable state, not from this
492
+ * process.
493
+ *
494
+ * The second bit. `initialized: false` is "never ran init"; `initialized: true` with this `false`
495
+ * is the cohort the funnel loses — the config was written and no page has ever reached the daemon,
496
+ * which is the dev server that was never restarted, a plugin that never loaded, or a handshake
497
+ * refused at the origin gate. `true` here with no `app_instrumented` this run is a working install
498
+ * whose app simply is not up right now, and reading that as a loss is how the drop-off gets
499
+ * over-stated.
500
+ *
501
+ * Scoped to project + port, like every other reader of this state, so it cannot borrow another
502
+ * project's success on a shared daemon. OPTIONAL because an older sender has none; absent means
503
+ * not measured, never `false`.
504
+ */
505
+ appConnectedBefore: z.boolean().optional(),
392
506
  /** Fail-to-pass bug capsules — the deepest feature in the product. */
393
507
  capsuleCount: z.number().int().nonnegative(),
394
508
  /** Which of Reticle's feature FAMILIES this project has ever touched. The activation metric. */