@reticlehq/core 2.12.0 → 2.13.1

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.
@@ -244,6 +244,24 @@ export declare const ReticleDir: {
244
244
  readonly AMBIENT_FILE: "ambient.json";
245
245
  /** per-flow flake ledger — replay outcomes that decide intermittent-failure quarantine. */
246
246
  readonly FLAKE_FILE: "flake.json";
247
+ /**
248
+ * the project's cloud binding — .reticle/cloud.json, written by `reticle link`. Git-checked and
249
+ * non-secret: the project id, the API origin, and where its dashboard lives. The KEY lives in
250
+ * ~/.reticle/credentials.json instead, because that one must never reach a repository.
251
+ */
252
+ readonly CLOUD_LINK_FILE: "cloud.json";
253
+ /**
254
+ * local sync bookkeeping — .reticle/cloud-state.json. The pull cursor, when each half last ran,
255
+ * and the last error. NOT git-checked: it describes this machine's conversation with the server,
256
+ * and committing one machine's cursor would make every other machine skip what it had not seen.
257
+ */
258
+ readonly CLOUD_STATE_FILE: "cloud-state.json";
259
+ /**
260
+ * triage decisions pulled BACK from the dashboard — .reticle/issues.json. What a human said about
261
+ * a defect ("resolved", "not a bug"), so the HUD stops showing it and the next run does not
262
+ * re-report it as though nobody had looked.
263
+ */
264
+ readonly ISSUES_FILE: "issues.json";
247
265
  /** Per-flow assertion tiers recorded on each PASSING replay — the gate's anti-downgrade baseline. */
248
266
  readonly TIERS_FILE: "assertion-tiers.json";
249
267
  /**
package/dist/constants.js CHANGED
@@ -246,6 +246,24 @@ export const ReticleDir = {
246
246
  AMBIENT_FILE: 'ambient.json',
247
247
  /** per-flow flake ledger — replay outcomes that decide intermittent-failure quarantine. */
248
248
  FLAKE_FILE: 'flake.json',
249
+ /**
250
+ * the project's cloud binding — .reticle/cloud.json, written by `reticle link`. Git-checked and
251
+ * non-secret: the project id, the API origin, and where its dashboard lives. The KEY lives in
252
+ * ~/.reticle/credentials.json instead, because that one must never reach a repository.
253
+ */
254
+ CLOUD_LINK_FILE: 'cloud.json',
255
+ /**
256
+ * local sync bookkeeping — .reticle/cloud-state.json. The pull cursor, when each half last ran,
257
+ * and the last error. NOT git-checked: it describes this machine's conversation with the server,
258
+ * and committing one machine's cursor would make every other machine skip what it had not seen.
259
+ */
260
+ CLOUD_STATE_FILE: 'cloud-state.json',
261
+ /**
262
+ * triage decisions pulled BACK from the dashboard — .reticle/issues.json. What a human said about
263
+ * a defect ("resolved", "not a bug"), so the HUD stops showing it and the next run does not
264
+ * re-report it as though nobody had looked.
265
+ */
266
+ ISSUES_FILE: 'issues.json',
249
267
  /** Per-flow assertion tiers recorded on each PASSING replay — the gate's anti-downgrade baseline. */
250
268
  TIERS_FILE: 'assertion-tiers.json',
251
269
  /**
@@ -0,0 +1,85 @@
1
+ import { z } from 'zod';
2
+ /** The registry filename for a dev server listening on `port`. */
3
+ export declare function devServerRegistryFileName(port: number): string;
4
+ /**
5
+ * The port from a registry filename, or null when the name is not one.
6
+ *
7
+ * Strict about the whole shape, because the daemon's own `daemon-<port>.json` sits in the same
8
+ * directory: reading one of those as a dev server would report the daemon as an instrumented app,
9
+ * which is the precise false green this signal exists to prevent.
10
+ */
11
+ export declare function devServerRegistryPort(fileName: string): number | null;
12
+ /** One dev server's entry: enough to name it, reach it, and prove it is still alive. */
13
+ export declare const DevServerEntrySchema: z.ZodObject<{
14
+ port: z.ZodNumber;
15
+ pid: z.ZodNumber;
16
+ /** The project directory the dev server is serving — how a monorepo tells its apps apart. */
17
+ root: z.ZodString;
18
+ /** Where the app is actually served, as the dev server itself reports it. Never assembled here. */
19
+ url: z.ZodString;
20
+ /**
21
+ * The SDK version in the bundle, so a skew can be named rather than guessed at.
22
+ *
23
+ * Optional, and ABSENT rather than empty when it cannot be resolved. `""` reads as "the version is
24
+ * empty"; a missing field reads as "not known", which is the true statement — and the difference
25
+ * matters to the one reader who exists for this field, a skew diagnosis.
26
+ */
27
+ sdkVersion: z.ZodOptional<z.ZodString>;
28
+ startedAt: z.ZodNumber;
29
+ /**
30
+ * Optional because an app can be running before `init` has ever named it — which is exactly the
31
+ * state this signal has to be able to describe.
32
+ */
33
+ projectId: z.ZodOptional<z.ZodString>;
34
+ }, "strip", z.ZodTypeAny, {
35
+ url: string;
36
+ port: number;
37
+ pid: number;
38
+ startedAt: number;
39
+ root: string;
40
+ projectId?: string | undefined;
41
+ sdkVersion?: string | undefined;
42
+ }, {
43
+ url: string;
44
+ port: number;
45
+ pid: number;
46
+ startedAt: number;
47
+ root: string;
48
+ projectId?: string | undefined;
49
+ sdkVersion?: string | undefined;
50
+ }>;
51
+ export type DevServerEntry = z.infer<typeof DevServerEntrySchema>;
52
+ /**
53
+ * The entries whose process is still running, lowest port first.
54
+ *
55
+ * Liveness is checked rather than trusted for the same reason the daemon registry checks it: a dev
56
+ * server killed with SIGKILL runs no cleanup, so its file outlives it. A stale entry read as live is
57
+ * worse than no entry at all — it reports a running, instrumented app over a dead port, and sends
58
+ * the reader to look at their browser instead of at their terminal.
59
+ *
60
+ * Pure, so both the CLI and the plugins share one rule and it is testable without real processes.
61
+ */
62
+ /**
63
+ * The live entries that belong to THIS project.
64
+ *
65
+ * Scoping is not a refinement here, it is the difference between a diagnosis and a wrong answer. A
66
+ * dev server registry is machine-wide — one directory holds every app on the box — so "a dev server
67
+ * is running" is satisfied by somebody else's app, by another package in the same monorepo, by
68
+ * yesterday's terminal. Reported unscoped, `init` for app A told the user their dev server was wired
69
+ * and handed them app B's URL: confident, specific, and about a project they were not setting up.
70
+ *
71
+ * Two ways to belong, because both are true and neither covers the other:
72
+ *
73
+ * - the projectId matches, which is exact and survives a moved directory
74
+ * - the entry's root is the directory being set up, or inside it, which is what makes `init` at a
75
+ * monorepo root see the apps underneath it — they genuinely are its apps
76
+ *
77
+ * With neither known nothing matches, and the caller gets the same less specific answer it had
78
+ * before. That is the conservative direction on purpose: a missed match costs one vaguer sentence,
79
+ * a wrong match sends somebody to another team's app.
80
+ */
81
+ export declare function devServersForProject(entries: readonly DevServerEntry[], scope: {
82
+ projectId?: string | undefined;
83
+ root?: string | undefined;
84
+ }): DevServerEntry[];
85
+ export declare function liveDevServers(entries: readonly DevServerEntry[], isAlive: (pid: number) => boolean): DevServerEntry[];
@@ -0,0 +1,120 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The dev-server discovery registry — the return leg of `daemon-registry.ts`.
4
+ *
5
+ * A live daemon already drops `daemon-<port>.json` here so a build plugin can FIND it by projectId
6
+ * rather than being told a port in two places. Nothing went the other way: the daemon, and `init`,
7
+ * had no way to know a dev server existed at all.
8
+ *
9
+ * That gap is why setup fails silently. Ten things must be true before a tool call can see anything,
10
+ * and the commonest miss — a plugin added to a config the running dev server already read — is
11
+ * invisible from outside the dev server's own process. So `init` wrote files, printed instructions,
12
+ * and left; the person with an uninstrumented page was never told.
13
+ *
14
+ * The alternative was for `init` to run the dev command itself. It cannot: the command, the script
15
+ * name, the package manager, the port and the framework are all things the user or their agent may
16
+ * change, and a setup step that hardcodes any of them is a setup step that breaks on the project it
17
+ * was most needed for. So nothing here starts anything or names a command. The plugin ALREADY runs
18
+ * Node-side when the dev server boots; it announces there, and the reader waits.
19
+ *
20
+ * With both legs present the diagnosis is three-way and every branch is an observed fact:
21
+ *
22
+ * no entry, no session nothing with Reticle loaded is running — start or restart it
23
+ * entry, no session the bundle is wired and no page dialled — and `url` names where to look
24
+ * entry and session working
25
+ *
26
+ * A file rather than a request, deliberately: at `init` time there is frequently no daemon to POST
27
+ * to yet, and a signal that requires the thing it is diagnosing to already be up is no signal.
28
+ */
29
+ const DEV_SERVER_PREFIX = 'devserver-';
30
+ const DEV_SERVER_SUFFIX = '.json';
31
+ /** The registry filename for a dev server listening on `port`. */
32
+ export function devServerRegistryFileName(port) {
33
+ return `${DEV_SERVER_PREFIX}${String(port)}${DEV_SERVER_SUFFIX}`;
34
+ }
35
+ /**
36
+ * The port from a registry filename, or null when the name is not one.
37
+ *
38
+ * Strict about the whole shape, because the daemon's own `daemon-<port>.json` sits in the same
39
+ * directory: reading one of those as a dev server would report the daemon as an instrumented app,
40
+ * which is the precise false green this signal exists to prevent.
41
+ */
42
+ export function devServerRegistryPort(fileName) {
43
+ if (!fileName.startsWith(DEV_SERVER_PREFIX) || !fileName.endsWith(DEV_SERVER_SUFFIX))
44
+ return null;
45
+ const mid = fileName.slice(DEV_SERVER_PREFIX.length, -DEV_SERVER_SUFFIX.length);
46
+ return /^\d+$/.test(mid) ? Number(mid) : null;
47
+ }
48
+ /** One dev server's entry: enough to name it, reach it, and prove it is still alive. */
49
+ export const DevServerEntrySchema = z.object({
50
+ port: z.number(),
51
+ pid: z.number(),
52
+ /** The project directory the dev server is serving — how a monorepo tells its apps apart. */
53
+ root: z.string(),
54
+ /** Where the app is actually served, as the dev server itself reports it. Never assembled here. */
55
+ url: z.string(),
56
+ /**
57
+ * The SDK version in the bundle, so a skew can be named rather than guessed at.
58
+ *
59
+ * Optional, and ABSENT rather than empty when it cannot be resolved. `""` reads as "the version is
60
+ * empty"; a missing field reads as "not known", which is the true statement — and the difference
61
+ * matters to the one reader who exists for this field, a skew diagnosis.
62
+ */
63
+ sdkVersion: z.string().min(1).optional(),
64
+ startedAt: z.number(),
65
+ /**
66
+ * Optional because an app can be running before `init` has ever named it — which is exactly the
67
+ * state this signal has to be able to describe.
68
+ */
69
+ projectId: z.string().optional(),
70
+ });
71
+ /**
72
+ * The entries whose process is still running, lowest port first.
73
+ *
74
+ * Liveness is checked rather than trusted for the same reason the daemon registry checks it: a dev
75
+ * server killed with SIGKILL runs no cleanup, so its file outlives it. A stale entry read as live is
76
+ * worse than no entry at all — it reports a running, instrumented app over a dead port, and sends
77
+ * the reader to look at their browser instead of at their terminal.
78
+ *
79
+ * Pure, so both the CLI and the plugins share one rule and it is testable without real processes.
80
+ */
81
+ /**
82
+ * The live entries that belong to THIS project.
83
+ *
84
+ * Scoping is not a refinement here, it is the difference between a diagnosis and a wrong answer. A
85
+ * dev server registry is machine-wide — one directory holds every app on the box — so "a dev server
86
+ * is running" is satisfied by somebody else's app, by another package in the same monorepo, by
87
+ * yesterday's terminal. Reported unscoped, `init` for app A told the user their dev server was wired
88
+ * and handed them app B's URL: confident, specific, and about a project they were not setting up.
89
+ *
90
+ * Two ways to belong, because both are true and neither covers the other:
91
+ *
92
+ * - the projectId matches, which is exact and survives a moved directory
93
+ * - the entry's root is the directory being set up, or inside it, which is what makes `init` at a
94
+ * monorepo root see the apps underneath it — they genuinely are its apps
95
+ *
96
+ * With neither known nothing matches, and the caller gets the same less specific answer it had
97
+ * before. That is the conservative direction on purpose: a missed match costs one vaguer sentence,
98
+ * a wrong match sends somebody to another team's app.
99
+ */
100
+ export function devServersForProject(entries, scope) {
101
+ const { projectId, root } = scope;
102
+ if ((projectId === undefined || 0 === projectId.length) &&
103
+ (root === undefined || 0 === root.length)) {
104
+ return [];
105
+ }
106
+ return entries.filter((e) => (projectId !== undefined && 0 < projectId.length && e.projectId === projectId) ||
107
+ isWithin(e.root, root));
108
+ }
109
+ /** `path` is `base`, or sits under it. Separator-aware, so `/repo/app2` is not inside `/repo/app`. */
110
+ function isWithin(path, base) {
111
+ if (base === undefined || 0 === base.length)
112
+ return false;
113
+ const norm = (p) => p.split('\\').join('/').replace(/\/+$/, '');
114
+ const target = norm(path);
115
+ const parent = norm(base);
116
+ return target === parent || target.startsWith(`${parent}/`);
117
+ }
118
+ export function liveDevServers(entries, isAlive) {
119
+ return entries.filter((e) => isAlive(e.pid)).sort((a, b) => a.port - b.port);
120
+ }
@@ -115,6 +115,7 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
115
115
  ok: z.ZodBoolean;
116
116
  durationMs: z.ZodNumber;
117
117
  initiator: z.ZodString;
118
+ urlRaw: z.ZodOptional<z.ZodString>;
118
119
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
119
120
  id: z.ZodString;
120
121
  method: z.ZodString;
@@ -123,6 +124,7 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
123
124
  ok: z.ZodBoolean;
124
125
  durationMs: z.ZodNumber;
125
126
  initiator: z.ZodString;
127
+ urlRaw: z.ZodOptional<z.ZodString>;
126
128
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
127
129
  id: z.ZodString;
128
130
  method: z.ZodString;
@@ -131,22 +133,26 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
131
133
  ok: z.ZodBoolean;
132
134
  durationMs: z.ZodNumber;
133
135
  initiator: z.ZodString;
136
+ urlRaw: z.ZodOptional<z.ZodString>;
134
137
  }, z.ZodTypeAny, "passthrough">>;
135
138
  "net.pending": z.ZodObject<{
136
139
  id: z.ZodString;
137
140
  method: z.ZodString;
138
141
  url: z.ZodString;
139
142
  initiator: z.ZodString;
143
+ urlRaw: z.ZodOptional<z.ZodString>;
140
144
  }, "strip", z.ZodTypeAny, {
141
145
  url: string;
142
146
  id: string;
143
147
  method: string;
144
148
  initiator: string;
149
+ urlRaw?: string | undefined;
145
150
  }, {
146
151
  url: string;
147
152
  id: string;
148
153
  method: string;
149
154
  initiator: string;
155
+ urlRaw?: string | undefined;
150
156
  }>;
151
157
  "net.stream": z.ZodObject<{
152
158
  transport: z.ZodNativeEnum<{
@@ -73,6 +73,7 @@ const netRequestSchema = z
73
73
  ok: z.boolean(),
74
74
  durationMs: z.number(),
75
75
  initiator: z.string(),
76
+ urlRaw: z.string().optional(),
76
77
  })
77
78
  .passthrough();
78
79
  const consoleSchema = z.object({ message: z.string() }).passthrough();
@@ -93,6 +94,7 @@ export const EVENT_PAYLOAD_SCHEMAS = {
93
94
  method: z.string(),
94
95
  url: z.string(),
95
96
  initiator: z.string(),
97
+ urlRaw: z.string().optional(),
96
98
  }),
97
99
  [EventType.NET_STREAM]: netStreamSchema,
98
100
  [EventType.DOWNLOAD]: downloadSchema,
@@ -439,6 +439,24 @@ export interface FlowReplayResult {
439
439
  * envelope, or a fall-back note below N=3 runs). Additive; present when segments were observed.
440
440
  */
441
441
  deviation?: unknown;
442
+ /**
443
+ * What the project already knows about this flow, fetched from shared memory on the agent's
444
+ * behalf.
445
+ *
446
+ * Present only when the project is linked, memory sync is on, and the team has actually captured
447
+ * something about this flow. Consulting shared memory used to be a separate act an agent had to
448
+ * remember to perform — measured across a real corpus, every subject showed zero reads, not
449
+ * because the knowledge was useless but because nothing ever asked for it. A verification that
450
+ * asks on the agent's behalf is the difference between memory the platform stores and memory the
451
+ * platform uses.
452
+ *
453
+ * Deliberately additive and deliberately small: a verdict whose own result has been pushed below
454
+ * a wall of statements is a worse verdict.
455
+ */
456
+ knows?: {
457
+ statement: string;
458
+ status: string;
459
+ }[];
442
460
  }
443
461
  /**
444
462
  * The on-disk flow file: diffable, git-tracked, anchor-resolved.
package/dist/impact.d.ts CHANGED
@@ -228,6 +228,42 @@ export declare const ImpactSavingsSchema: z.ZodObject<{
228
228
  };
229
229
  }>;
230
230
  export type ImpactSavings = z.infer<typeof ImpactSavingsSchema>;
231
+ /**
232
+ * How many recent defects a scope remembers.
233
+ *
234
+ * Small on purpose. `counts.failed` already says HOW MANY defects there have been; this list exists
235
+ * so the HUD can say WHICH ONES, and a panel in the corner of somebody's app is not a triage queue.
236
+ * Ten is enough to recognise what is currently broken and short enough that the record stays a
237
+ * counters file rather than becoming a log.
238
+ */
239
+ export declare const IMPACT_DEFECT_LIMIT = 10;
240
+ /**
241
+ * One defect, as the HUD shows it.
242
+ *
243
+ * Recorded at the moment a verdict comes back verified:"no" - so it is a thing that actually failed
244
+ * a declared consequence, never a heuristic read of the page afterwards.
245
+ */
246
+ export declare const ImpactDefectSchema: z.ZodObject<{
247
+ /** When it was caught (epoch ms). */
248
+ at: z.ZodNumber;
249
+ /** One line naming what failed, in the words the verdict used. */
250
+ title: z.ZodString;
251
+ /** Why it failed, when the verdict said. */
252
+ detail: z.ZodOptional<z.ZodString>;
253
+ /** `file:line` of the element that was acted on, so the reader can go straight there. */
254
+ source: z.ZodOptional<z.ZodString>;
255
+ }, "strip", z.ZodTypeAny, {
256
+ at: number;
257
+ title: string;
258
+ source?: string | undefined;
259
+ detail?: string | undefined;
260
+ }, {
261
+ at: number;
262
+ title: string;
263
+ source?: string | undefined;
264
+ detail?: string | undefined;
265
+ }>;
266
+ export type ImpactDefect = z.infer<typeof ImpactDefectSchema>;
231
267
  /** One scope of the record: this project, or everything on this machine. */
232
268
  export declare const ImpactScopeSchema: z.ZodObject<{
233
269
  counts: z.ZodObject<{
@@ -418,6 +454,30 @@ export declare const ImpactScopeSchema: z.ZodObject<{
418
454
  }>;
419
455
  /** When this scope first recorded anything (epoch ms). */
420
456
  since: z.ZodNumber;
457
+ /**
458
+ * The most recent defects, newest first. Defaulted rather than required: a record written by an
459
+ * older build has no such field, and a counters file that fails to parse loses the whole history.
460
+ */
461
+ defects: z.ZodDefault<z.ZodArray<z.ZodObject<{
462
+ /** When it was caught (epoch ms). */
463
+ at: z.ZodNumber;
464
+ /** One line naming what failed, in the words the verdict used. */
465
+ title: z.ZodString;
466
+ /** Why it failed, when the verdict said. */
467
+ detail: z.ZodOptional<z.ZodString>;
468
+ /** `file:line` of the element that was acted on, so the reader can go straight there. */
469
+ source: z.ZodOptional<z.ZodString>;
470
+ }, "strip", z.ZodTypeAny, {
471
+ at: number;
472
+ title: string;
473
+ source?: string | undefined;
474
+ detail?: string | undefined;
475
+ }, {
476
+ at: number;
477
+ title: string;
478
+ source?: string | undefined;
479
+ detail?: string | undefined;
480
+ }>, "many">>;
421
481
  }, "strip", z.ZodTypeAny, {
422
482
  counts: {
423
483
  sessions: number;
@@ -464,6 +524,12 @@ export declare const ImpactScopeSchema: z.ZodObject<{
464
524
  };
465
525
  };
466
526
  since: number;
527
+ defects: {
528
+ at: number;
529
+ title: string;
530
+ source?: string | undefined;
531
+ detail?: string | undefined;
532
+ }[];
467
533
  }, {
468
534
  counts: {
469
535
  sessions: number;
@@ -510,6 +576,12 @@ export declare const ImpactScopeSchema: z.ZodObject<{
510
576
  };
511
577
  };
512
578
  since: number;
579
+ defects?: {
580
+ at: number;
581
+ title: string;
582
+ source?: string | undefined;
583
+ detail?: string | undefined;
584
+ }[] | undefined;
513
585
  }>;
514
586
  export type ImpactScope = z.infer<typeof ImpactScopeSchema>;
515
587
  /** What the HUD receives: this project, and the machine-wide total. */
@@ -704,6 +776,30 @@ export declare const ImpactSnapshotSchema: z.ZodObject<{
704
776
  }>;
705
777
  /** When this scope first recorded anything (epoch ms). */
706
778
  since: z.ZodNumber;
779
+ /**
780
+ * The most recent defects, newest first. Defaulted rather than required: a record written by an
781
+ * older build has no such field, and a counters file that fails to parse loses the whole history.
782
+ */
783
+ defects: z.ZodDefault<z.ZodArray<z.ZodObject<{
784
+ /** When it was caught (epoch ms). */
785
+ at: z.ZodNumber;
786
+ /** One line naming what failed, in the words the verdict used. */
787
+ title: z.ZodString;
788
+ /** Why it failed, when the verdict said. */
789
+ detail: z.ZodOptional<z.ZodString>;
790
+ /** `file:line` of the element that was acted on, so the reader can go straight there. */
791
+ source: z.ZodOptional<z.ZodString>;
792
+ }, "strip", z.ZodTypeAny, {
793
+ at: number;
794
+ title: string;
795
+ source?: string | undefined;
796
+ detail?: string | undefined;
797
+ }, {
798
+ at: number;
799
+ title: string;
800
+ source?: string | undefined;
801
+ detail?: string | undefined;
802
+ }>, "many">>;
707
803
  }, "strip", z.ZodTypeAny, {
708
804
  counts: {
709
805
  sessions: number;
@@ -750,6 +846,12 @@ export declare const ImpactSnapshotSchema: z.ZodObject<{
750
846
  };
751
847
  };
752
848
  since: number;
849
+ defects: {
850
+ at: number;
851
+ title: string;
852
+ source?: string | undefined;
853
+ detail?: string | undefined;
854
+ }[];
753
855
  }, {
754
856
  counts: {
755
857
  sessions: number;
@@ -796,6 +898,12 @@ export declare const ImpactSnapshotSchema: z.ZodObject<{
796
898
  };
797
899
  };
798
900
  since: number;
901
+ defects?: {
902
+ at: number;
903
+ title: string;
904
+ source?: string | undefined;
905
+ detail?: string | undefined;
906
+ }[] | undefined;
799
907
  }>;
800
908
  global: z.ZodObject<{
801
909
  counts: z.ZodObject<{
@@ -986,6 +1094,30 @@ export declare const ImpactSnapshotSchema: z.ZodObject<{
986
1094
  }>;
987
1095
  /** When this scope first recorded anything (epoch ms). */
988
1096
  since: z.ZodNumber;
1097
+ /**
1098
+ * The most recent defects, newest first. Defaulted rather than required: a record written by an
1099
+ * older build has no such field, and a counters file that fails to parse loses the whole history.
1100
+ */
1101
+ defects: z.ZodDefault<z.ZodArray<z.ZodObject<{
1102
+ /** When it was caught (epoch ms). */
1103
+ at: z.ZodNumber;
1104
+ /** One line naming what failed, in the words the verdict used. */
1105
+ title: z.ZodString;
1106
+ /** Why it failed, when the verdict said. */
1107
+ detail: z.ZodOptional<z.ZodString>;
1108
+ /** `file:line` of the element that was acted on, so the reader can go straight there. */
1109
+ source: z.ZodOptional<z.ZodString>;
1110
+ }, "strip", z.ZodTypeAny, {
1111
+ at: number;
1112
+ title: string;
1113
+ source?: string | undefined;
1114
+ detail?: string | undefined;
1115
+ }, {
1116
+ at: number;
1117
+ title: string;
1118
+ source?: string | undefined;
1119
+ detail?: string | undefined;
1120
+ }>, "many">>;
989
1121
  }, "strip", z.ZodTypeAny, {
990
1122
  counts: {
991
1123
  sessions: number;
@@ -1032,6 +1164,12 @@ export declare const ImpactSnapshotSchema: z.ZodObject<{
1032
1164
  };
1033
1165
  };
1034
1166
  since: number;
1167
+ defects: {
1168
+ at: number;
1169
+ title: string;
1170
+ source?: string | undefined;
1171
+ detail?: string | undefined;
1172
+ }[];
1035
1173
  }, {
1036
1174
  counts: {
1037
1175
  sessions: number;
@@ -1078,9 +1216,21 @@ export declare const ImpactSnapshotSchema: z.ZodObject<{
1078
1216
  };
1079
1217
  };
1080
1218
  since: number;
1219
+ defects?: {
1220
+ at: number;
1221
+ title: string;
1222
+ source?: string | undefined;
1223
+ detail?: string | undefined;
1224
+ }[] | undefined;
1081
1225
  }>;
1082
1226
  /** Project name, for the report's title row. */
1083
1227
  projectName: z.ZodOptional<z.ZodString>;
1228
+ /**
1229
+ * Where the full, triageable list of these defects lives - present only when this project is
1230
+ * linked to a Reticle Cloud workspace. Absent is the normal case and the HUD simply shows its
1231
+ * short list without a link: the free tool is complete on its own.
1232
+ */
1233
+ dashboardUrl: z.ZodOptional<z.ZodString>;
1084
1234
  }, "strip", z.ZodTypeAny, {
1085
1235
  project: {
1086
1236
  counts: {
@@ -1128,6 +1278,12 @@ export declare const ImpactSnapshotSchema: z.ZodObject<{
1128
1278
  };
1129
1279
  };
1130
1280
  since: number;
1281
+ defects: {
1282
+ at: number;
1283
+ title: string;
1284
+ source?: string | undefined;
1285
+ detail?: string | undefined;
1286
+ }[];
1131
1287
  };
1132
1288
  schemaVersion: number;
1133
1289
  global: {
@@ -1176,8 +1332,15 @@ export declare const ImpactSnapshotSchema: z.ZodObject<{
1176
1332
  };
1177
1333
  };
1178
1334
  since: number;
1335
+ defects: {
1336
+ at: number;
1337
+ title: string;
1338
+ source?: string | undefined;
1339
+ detail?: string | undefined;
1340
+ }[];
1179
1341
  };
1180
1342
  projectName?: string | undefined;
1343
+ dashboardUrl?: string | undefined;
1181
1344
  }, {
1182
1345
  project: {
1183
1346
  counts: {
@@ -1225,6 +1388,12 @@ export declare const ImpactSnapshotSchema: z.ZodObject<{
1225
1388
  };
1226
1389
  };
1227
1390
  since: number;
1391
+ defects?: {
1392
+ at: number;
1393
+ title: string;
1394
+ source?: string | undefined;
1395
+ detail?: string | undefined;
1396
+ }[] | undefined;
1228
1397
  };
1229
1398
  schemaVersion: number;
1230
1399
  global: {
@@ -1273,8 +1442,15 @@ export declare const ImpactSnapshotSchema: z.ZodObject<{
1273
1442
  };
1274
1443
  };
1275
1444
  since: number;
1445
+ defects?: {
1446
+ at: number;
1447
+ title: string;
1448
+ source?: string | undefined;
1449
+ detail?: string | undefined;
1450
+ }[] | undefined;
1276
1451
  };
1277
1452
  projectName?: string | undefined;
1453
+ dashboardUrl?: string | undefined;
1278
1454
  }>;
1279
1455
  export type ImpactSnapshot = z.infer<typeof ImpactSnapshotSchema>;
1280
1456
  /** Empty counters - the starting point for a fresh store and the identity for merges. */
package/dist/impact.js CHANGED
@@ -76,6 +76,31 @@ export const ImpactSavingsSchema = z.object({
76
76
  /** Minutes not spent, vs the re-prompt cycle a false green costs. */
77
77
  minutes: ImpactEstimateSchema,
78
78
  });
79
+ /**
80
+ * How many recent defects a scope remembers.
81
+ *
82
+ * Small on purpose. `counts.failed` already says HOW MANY defects there have been; this list exists
83
+ * so the HUD can say WHICH ONES, and a panel in the corner of somebody's app is not a triage queue.
84
+ * Ten is enough to recognise what is currently broken and short enough that the record stays a
85
+ * counters file rather than becoming a log.
86
+ */
87
+ export const IMPACT_DEFECT_LIMIT = 10;
88
+ /**
89
+ * One defect, as the HUD shows it.
90
+ *
91
+ * Recorded at the moment a verdict comes back verified:"no" - so it is a thing that actually failed
92
+ * a declared consequence, never a heuristic read of the page afterwards.
93
+ */
94
+ export const ImpactDefectSchema = z.object({
95
+ /** When it was caught (epoch ms). */
96
+ at: z.number().int().nonnegative(),
97
+ /** One line naming what failed, in the words the verdict used. */
98
+ title: z.string(),
99
+ /** Why it failed, when the verdict said. */
100
+ detail: z.string().optional(),
101
+ /** `file:line` of the element that was acted on, so the reader can go straight there. */
102
+ source: z.string().optional(),
103
+ });
79
104
  /** One scope of the record: this project, or everything on this machine. */
80
105
  export const ImpactScopeSchema = z.object({
81
106
  counts: ImpactCountsSchema,
@@ -84,6 +109,11 @@ export const ImpactScopeSchema = z.object({
84
109
  savings: ImpactSavingsSchema,
85
110
  /** When this scope first recorded anything (epoch ms). */
86
111
  since: z.number().int().nonnegative(),
112
+ /**
113
+ * The most recent defects, newest first. Defaulted rather than required: a record written by an
114
+ * older build has no such field, and a counters file that fails to parse loses the whole history.
115
+ */
116
+ defects: z.array(ImpactDefectSchema).default([]),
87
117
  });
88
118
  /** What the HUD receives: this project, and the machine-wide total. */
89
119
  export const ImpactSnapshotSchema = z.object({
@@ -92,6 +122,12 @@ export const ImpactSnapshotSchema = z.object({
92
122
  global: ImpactScopeSchema,
93
123
  /** Project name, for the report's title row. */
94
124
  projectName: z.string().optional(),
125
+ /**
126
+ * Where the full, triageable list of these defects lives - present only when this project is
127
+ * linked to a Reticle Cloud workspace. Absent is the normal case and the HUD simply shows its
128
+ * short list without a link: the free tool is complete on its own.
129
+ */
130
+ dashboardUrl: z.string().optional(),
95
131
  });
96
132
  /** Empty counters - the starting point for a fresh store and the identity for merges. */
97
133
  export function emptyImpactCounts() {