@reticlehq/core 3.6.0 → 3.8.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 (133) hide show
  1. package/dist/activation-entry.d.ts +9 -0
  2. package/dist/activation-entry.js +9 -0
  3. package/dist/artifacts/artifacts-entry.d.ts +2 -0
  4. package/dist/artifacts/artifacts-entry.js +2 -0
  5. package/dist/artifacts/drive-script.d.ts +222 -116
  6. package/dist/artifacts/drive-script.js +24 -1
  7. package/dist/artifacts/flow-constants.d.ts +33 -0
  8. package/dist/artifacts/flow-constants.js +35 -0
  9. package/dist/artifacts/flow-expect-flat.d.ts +8 -8
  10. package/dist/artifacts/flow-results.d.ts +461 -0
  11. package/dist/artifacts/flow-results.js +1 -0
  12. package/dist/artifacts/flow-types.d.ts +177 -543
  13. package/dist/artifacts/flow-types.js +17 -2
  14. package/dist/artifacts/harness-credits.d.ts +42 -0
  15. package/dist/artifacts/harness-credits.js +72 -0
  16. package/dist/artifacts/harness-map.d.ts +98 -0
  17. package/dist/artifacts/harness-map.js +36 -0
  18. package/dist/artifacts/impact.d.ts +355 -149
  19. package/dist/artifacts/impact.js +84 -49
  20. package/dist/artifacts/journal.d.ts +81 -11
  21. package/dist/artifacts/journal.js +39 -0
  22. package/dist/artifacts/prompt-context.d.ts +12 -0
  23. package/dist/artifacts/prompt-context.js +14 -3
  24. package/dist/artifacts/screenshot-upload.d.ts +51 -0
  25. package/dist/artifacts/screenshot-upload.js +26 -0
  26. package/dist/graph/app-graph.d.ts +137 -0
  27. package/dist/graph/app-graph.js +498 -0
  28. package/dist/hooks/hook-events.d.ts +26 -26
  29. package/dist/hud-entry.d.ts +1 -0
  30. package/dist/hud-entry.js +2 -0
  31. package/dist/identity/checkout.d.ts +41 -0
  32. package/dist/identity/checkout.js +118 -0
  33. package/dist/identity/state-dir.d.ts +23 -0
  34. package/dist/identity/state-dir.js +43 -0
  35. package/dist/index.d.ts +15 -0
  36. package/dist/index.js +15 -0
  37. package/dist/onboarding.d.ts +30 -1
  38. package/dist/onboarding.js +25 -0
  39. package/dist/realm/registry.js +19 -1
  40. package/dist/registry/dev-server-registry.d.ts +2 -2
  41. package/dist/schema/command-message.json +30 -0
  42. package/dist/schema/command-name.json +3 -1
  43. package/dist/schema/event-message.json +3 -1
  44. package/dist/schema/event-payloads.json +156 -3
  45. package/dist/schema/event-type.json +3 -1
  46. package/dist/schema/hello-message.json +21 -0
  47. package/dist/schema/reticle-event.json +3 -1
  48. package/dist/schema/reticle-message.json +54 -1
  49. package/dist/telemetry-bug.d.ts +169 -0
  50. package/dist/telemetry-bug.js +123 -0
  51. package/dist/telemetry-entry.d.ts +2 -1
  52. package/dist/telemetry-entry.js +2 -1
  53. package/dist/telemetry-feedback.d.ts +16 -2
  54. package/dist/telemetry-feedback.js +19 -0
  55. package/dist/telemetry-session.d.ts +91 -2
  56. package/dist/telemetry-session.js +65 -0
  57. package/dist/telemetry-signals.d.ts +557 -0
  58. package/dist/telemetry-signals.js +225 -0
  59. package/dist/telemetry.d.ts +649 -296
  60. package/dist/telemetry.js +110 -119
  61. package/dist/verdict/check-sentence.d.ts +34 -0
  62. package/dist/verdict/check-sentence.js +228 -0
  63. package/dist/verdict/consequence.d.ts +15 -0
  64. package/dist/verdict/consequence.js +11 -0
  65. package/dist/verdict/disparity.d.ts +105 -0
  66. package/dist/verdict/disparity.js +40 -0
  67. package/dist/verdict/findings.d.ts +16 -0
  68. package/dist/verdict/findings.js +22 -0
  69. package/dist/verdict/instrumentation-coverage.d.ts +84 -0
  70. package/dist/verdict/instrumentation-coverage.js +182 -0
  71. package/dist/verdict/instrumentation-gap.d.ts +79 -0
  72. package/dist/verdict/instrumentation-gap.js +65 -1
  73. package/dist/verdict/intent.d.ts +19 -5
  74. package/dist/verdict/intent.js +13 -1
  75. package/dist/verdict/predicate-tree.d.ts +17 -0
  76. package/dist/verdict/predicate-tree.js +37 -0
  77. package/dist/verdict/predicate.d.ts +16 -1
  78. package/dist/verdict/predicate.js +188 -13
  79. package/dist/verdict/property-assertion.d.ts +2 -2
  80. package/dist/verdict/run-report.d.ts +166 -0
  81. package/dist/verdict/run-report.js +53 -0
  82. package/dist/verdict/security.d.ts +60 -1
  83. package/dist/verdict/security.js +174 -12
  84. package/dist/verdict/verification-run.d.ts +713 -68
  85. package/dist/verdict/verification-run.js +113 -0
  86. package/dist/verdict/verify-progress.d.ts +6 -6
  87. package/dist/wire/constants/constants.d.ts +69 -155
  88. package/dist/wire/constants/constants.js +78 -159
  89. package/dist/wire/constants/discovery.d.ts +4 -4
  90. package/dist/wire/constants/discovery.js +4 -4
  91. package/dist/wire/constants/event-types.d.ts +35 -1
  92. package/dist/wire/constants/event-types.js +33 -1
  93. package/dist/wire/constants/hud-controls.js +15 -5
  94. package/dist/wire/constants/hud-use.d.ts +33 -4
  95. package/dist/wire/constants/hud-use.js +30 -4
  96. package/dist/wire/constants/mcp-wire.d.ts +26 -0
  97. package/dist/wire/constants/mcp-wire.js +26 -0
  98. package/dist/wire/constants/response-body-reason.d.ts +19 -0
  99. package/dist/wire/constants/response-body-reason.js +18 -0
  100. package/dist/wire/constants/reticle-chrome.d.ts +19 -0
  101. package/dist/wire/constants/reticle-chrome.js +19 -0
  102. package/dist/wire/constants/reticle-env.d.ts +138 -0
  103. package/dist/wire/constants/reticle-env.js +138 -0
  104. package/dist/wire/constants/session-constants.d.ts +26 -2
  105. package/dist/wire/constants/session-constants.js +26 -2
  106. package/dist/wire/desktop-contract.d.ts +8 -0
  107. package/dist/wire/desktop-contract.js +11 -0
  108. package/dist/wire/event-payloads.d.ts +202 -36
  109. package/dist/wire/event-payloads.js +100 -16
  110. package/dist/wire/messages.d.ts +193 -54
  111. package/dist/wire/messages.js +25 -1
  112. package/dist/wire/narrow.d.ts +6 -0
  113. package/dist/wire/narrow.js +26 -0
  114. package/dist/wire/next-step.d.ts +90 -0
  115. package/dist/wire/next-step.js +37 -0
  116. package/dist/wire/platform-link.d.ts +84 -0
  117. package/dist/wire/platform-link.js +57 -6
  118. package/dist/wire/production/activation-ticket.d.ts +64 -0
  119. package/dist/wire/production/activation-ticket.js +148 -0
  120. package/dist/wire/production/hello-mode.d.ts +35 -0
  121. package/dist/wire/production/hello-mode.js +32 -0
  122. package/dist/wire/production/production-policy.d.ts +138 -0
  123. package/dist/wire/production/production-policy.js +133 -0
  124. package/dist/wire/tool-names.d.ts +4 -0
  125. package/dist/wire/tool-names.js +4 -0
  126. package/dist/wire/types.d.ts +90 -52
  127. package/dist/wire/types.js +5 -0
  128. package/dist/words/notices.d.ts +1 -1
  129. package/dist/words/notices.js +1 -1
  130. package/dist/words/upgrade.js +1 -1
  131. package/dist/words/writing-rule.d.ts +14 -0
  132. package/dist/words/writing-rule.js +17 -0
  133. package/package.json +5 -1
@@ -31,6 +31,17 @@ export const PresenceKind = {
31
31
  * The remaining kinds are neither consequence nor presence: they observe context (route, console),
32
32
  * timing (animation, settled), or combine other predicates (allOf/anyOf/not).
33
33
  */
34
+ /**
35
+ * What a `settled` check waits on. Absent: the whole page (requests and DOM). `network`: requests
36
+ * only, for a check about requests — a counted `net` claim waits for a late duplicate, and DOM churn
37
+ * from an animation must not hold it open.
38
+ */
39
+ /**
40
+ * What a `settled` waits out. NETWORK: completed requests only. APP: the default's activity plus every
41
+ * framework render commit, for an app whose commits are its work (the default leaves them out: on many
42
+ * pages they are ambient, a clock re-rendering every second, and would never go quiet).
43
+ */
44
+ export const SettledChannel = { NETWORK: 'network', APP: 'app' };
34
45
  export const PredicateKind = {
35
46
  ELEMENT: PresenceKind.ELEMENT,
36
47
  TEXT: PresenceKind.TEXT,
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Two-way testing: one goal, judged by the coding agent and by the Harness, compared.
3
+ *
4
+ * The agent pass answers "does it work?"; the Harness, starting with one sentence and no context,
5
+ * answers "can someone who has never seen it find out how?". The comparison is the product: an agent
6
+ * that proved a goal the Harness could not find is a discoverability finding, not noise and not a
7
+ * defect. Carried on a Harness run's artifact and on the explore tool's answer.
8
+ */
9
+ import { z } from 'zod';
10
+ /** How the two verdicts on one goal compare. */
11
+ export declare const DisparityKind: {
12
+ /** Both proved it: it works, and someone new can find it. */
13
+ readonly FINDABLE: "findable";
14
+ /** The agent proved it; the Harness searched and could not find it. */
15
+ readonly DISCOVERABILITY: "discoverability";
16
+ /** The Harness proved what the agent saw fail: look at the agent's assumption. */
17
+ readonly AGENT_ASSUMPTION: "agent_assumption";
18
+ /** The agent saw it fail and the Harness did not prove it: a defect. */
19
+ readonly DEFECT: "defect";
20
+ };
21
+ export type DisparityKind = (typeof DisparityKind)[keyof typeof DisparityKind];
22
+ /** Where the Harness looked, at most this many places. */
23
+ export declare const MAX_DISPARITY_SEARCHED = 20;
24
+ export declare const RunDisparitySchema: z.ZodObject<{
25
+ /** The goal's text, as the journey quoted it. */
26
+ goal: z.ZodString;
27
+ kind: z.ZodNativeEnum<{
28
+ /** Both proved it: it works, and someone new can find it. */
29
+ readonly FINDABLE: "findable";
30
+ /** The agent proved it; the Harness searched and could not find it. */
31
+ readonly DISCOVERABILITY: "discoverability";
32
+ /** The Harness proved what the agent saw fail: look at the agent's assumption. */
33
+ readonly AGENT_ASSUMPTION: "agent_assumption";
34
+ /** The agent saw it fail and the Harness did not prove it: a defect. */
35
+ readonly DEFECT: "defect";
36
+ }>;
37
+ /** The coding agent's verdict on a claim naming the goal, in the same app. */
38
+ agent: z.ZodObject<{
39
+ verified: z.ZodNativeEnum<{
40
+ readonly YES: "yes";
41
+ readonly NO: "no";
42
+ readonly UNKNOWN: "unknown";
43
+ readonly NO_FAULT: "no-fault";
44
+ }>;
45
+ claim: z.ZodString;
46
+ }, "strip", z.ZodTypeAny, {
47
+ verified: "yes" | "no" | "unknown" | "no-fault";
48
+ claim: string;
49
+ }, {
50
+ verified: "yes" | "no" | "unknown" | "no-fault";
51
+ claim: string;
52
+ }>;
53
+ /** The Harness's verdict, and the hunt behind it. */
54
+ harness: z.ZodObject<{
55
+ verified: z.ZodNativeEnum<{
56
+ readonly YES: "yes";
57
+ readonly NO: "no";
58
+ readonly UNKNOWN: "unknown";
59
+ readonly NO_FAULT: "no-fault";
60
+ }>;
61
+ /** Whether its search found the goal on a page at all. */
62
+ found: z.ZodBoolean;
63
+ /** The places it searched, in order: the path a newcomer would take. */
64
+ searched: z.ZodArray<z.ZodString, "many">;
65
+ /** The last place it looked before giving up, when it did. */
66
+ gaveUpAt: z.ZodOptional<z.ZodString>;
67
+ }, "strip", z.ZodTypeAny, {
68
+ verified: "yes" | "no" | "unknown" | "no-fault";
69
+ found: boolean;
70
+ searched: string[];
71
+ gaveUpAt?: string | undefined;
72
+ }, {
73
+ verified: "yes" | "no" | "unknown" | "no-fault";
74
+ found: boolean;
75
+ searched: string[];
76
+ gaveUpAt?: string | undefined;
77
+ }>;
78
+ }, "strip", z.ZodTypeAny, {
79
+ kind: "findable" | "discoverability" | "agent_assumption" | "defect";
80
+ goal: string;
81
+ agent: {
82
+ verified: "yes" | "no" | "unknown" | "no-fault";
83
+ claim: string;
84
+ };
85
+ harness: {
86
+ verified: "yes" | "no" | "unknown" | "no-fault";
87
+ found: boolean;
88
+ searched: string[];
89
+ gaveUpAt?: string | undefined;
90
+ };
91
+ }, {
92
+ kind: "findable" | "discoverability" | "agent_assumption" | "defect";
93
+ goal: string;
94
+ agent: {
95
+ verified: "yes" | "no" | "unknown" | "no-fault";
96
+ claim: string;
97
+ };
98
+ harness: {
99
+ verified: "yes" | "no" | "unknown" | "no-fault";
100
+ found: boolean;
101
+ searched: string[];
102
+ gaveUpAt?: string | undefined;
103
+ };
104
+ }>;
105
+ export type RunDisparity = z.infer<typeof RunDisparitySchema>;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Two-way testing: one goal, judged by the coding agent and by the Harness, compared.
3
+ *
4
+ * The agent pass answers "does it work?"; the Harness, starting with one sentence and no context,
5
+ * answers "can someone who has never seen it find out how?". The comparison is the product: an agent
6
+ * that proved a goal the Harness could not find is a discoverability finding, not noise and not a
7
+ * defect. Carried on a Harness run's artifact and on the explore tool's answer.
8
+ */
9
+ import { z } from 'zod';
10
+ import { Verified } from './verified-constants.js';
11
+ /** How the two verdicts on one goal compare. */
12
+ export const DisparityKind = {
13
+ /** Both proved it: it works, and someone new can find it. */
14
+ FINDABLE: 'findable',
15
+ /** The agent proved it; the Harness searched and could not find it. */
16
+ DISCOVERABILITY: 'discoverability',
17
+ /** The Harness proved what the agent saw fail: look at the agent's assumption. */
18
+ AGENT_ASSUMPTION: 'agent_assumption',
19
+ /** The agent saw it fail and the Harness did not prove it: a defect. */
20
+ DEFECT: 'defect',
21
+ };
22
+ /** Where the Harness looked, at most this many places. */
23
+ export const MAX_DISPARITY_SEARCHED = 20;
24
+ export const RunDisparitySchema = z.object({
25
+ /** The goal's text, as the journey quoted it. */
26
+ goal: z.string().min(1).max(500),
27
+ kind: z.nativeEnum(DisparityKind),
28
+ /** The coding agent's verdict on a claim naming the goal, in the same app. */
29
+ agent: z.object({ verified: z.nativeEnum(Verified), claim: z.string().max(2000) }),
30
+ /** The Harness's verdict, and the hunt behind it. */
31
+ harness: z.object({
32
+ verified: z.nativeEnum(Verified),
33
+ /** Whether its search found the goal on a page at all. */
34
+ found: z.boolean(),
35
+ /** The places it searched, in order: the path a newcomer would take. */
36
+ searched: z.array(z.string().max(500)).max(MAX_DISPARITY_SEARCHED),
37
+ /** The last place it looked before giving up, when it did. */
38
+ gaveUpAt: z.string().max(500).optional(),
39
+ }),
40
+ });
@@ -37,6 +37,16 @@ export interface Contradiction {
37
37
  export declare const ContradictionKind: {
38
38
  /** The screen moved forward while a request in the same window failed — the swallowed rejection. */
39
39
  readonly UI_ADVANCED_REQUEST_FAILED: "ui-advanced-request-failed";
40
+ /**
41
+ * The UI moved while a write failed, and the app publishes no signal and no store change.
42
+ *
43
+ * The same window as `ui-advanced-request-failed`, but nothing could decide whether the app
44
+ * handled the failure: no acted control to follow, and no voice of the app's own. Measured on a
45
+ * zero-install live feed: the correct build and the broken one both produced the strong finding,
46
+ * because a feed that appends rows on its own is a UI that moves. Absence-derived, so it makes a
47
+ * verdict unknown, never no.
48
+ */
49
+ readonly UI_ADVANCED_UNSIGNALLED: "ui-advanced-unsignalled";
40
50
  /** The app fired its own success signal while a request in the same window failed. Strongest form:
41
51
  * the app did not merely look right, it explicitly ASSERTED success against its own evidence. */
42
52
  readonly SIGNAL_CONTRADICTED: "signal-contradicted";
@@ -93,6 +103,12 @@ export declare const ContradictionKind: {
93
103
  * -- a burst on an endpoint the assertion DID name -- keeps its downgrade.
94
104
  */
95
105
  readonly DUPLICATE_REQUEST_UNRELATED: "duplicate-request-unrelated";
106
+ /**
107
+ * A request carried a value for a field whose control on screen shows a different chosen value
108
+ * (UI "Workspace default", request `projectId: "bench-app"`). ADVISORY and opt-in: a fact worth a
109
+ * look, never a verdict on its own.
110
+ */
111
+ readonly SCREEN_REQUEST_MISMATCH: "screen-request-mismatch";
96
112
  /**
97
113
  * Two reads of the same endpoint were in flight together and settled OUT OF ORDER, so the one the
98
114
  * user asked for first is the one that landed last — and the screen is showing it.
@@ -6,6 +6,16 @@ import { ChannelId, disagreementCanConvict } from '../wire/channel.js';
6
6
  export const ContradictionKind = {
7
7
  /** The screen moved forward while a request in the same window failed — the swallowed rejection. */
8
8
  UI_ADVANCED_REQUEST_FAILED: 'ui-advanced-request-failed',
9
+ /**
10
+ * The UI moved while a write failed, and the app publishes no signal and no store change.
11
+ *
12
+ * The same window as `ui-advanced-request-failed`, but nothing could decide whether the app
13
+ * handled the failure: no acted control to follow, and no voice of the app's own. Measured on a
14
+ * zero-install live feed: the correct build and the broken one both produced the strong finding,
15
+ * because a feed that appends rows on its own is a UI that moves. Absence-derived, so it makes a
16
+ * verdict unknown, never no.
17
+ */
18
+ UI_ADVANCED_UNSIGNALLED: 'ui-advanced-unsignalled',
9
19
  /** The app fired its own success signal while a request in the same window failed. Strongest form:
10
20
  * the app did not merely look right, it explicitly ASSERTED success against its own evidence. */
11
21
  SIGNAL_CONTRADICTED: 'signal-contradicted',
@@ -62,6 +72,12 @@ export const ContradictionKind = {
62
72
  * -- a burst on an endpoint the assertion DID name -- keeps its downgrade.
63
73
  */
64
74
  DUPLICATE_REQUEST_UNRELATED: 'duplicate-request-unrelated',
75
+ /**
76
+ * A request carried a value for a field whose control on screen shows a different chosen value
77
+ * (UI "Workspace default", request `projectId: "bench-app"`). ADVISORY and opt-in: a fact worth a
78
+ * look, never a verdict on its own.
79
+ */
80
+ SCREEN_REQUEST_MISMATCH: 'screen-request-mismatch',
65
81
  /**
66
82
  * Two reads of the same endpoint were in flight together and settled OUT OF ORDER, so the one the
67
83
  * user asked for first is the one that landed last — and the screen is showing it.
@@ -233,6 +249,8 @@ export const ContradictionKind = {
233
249
  */
234
250
  export const ABSENCE_DERIVED_CONTRADICTIONS = new Set([
235
251
  ContradictionKind.REQUEST_NEVER_SETTLED,
252
+ // The app has no voice to say it handled the failure, and no acted control showed it either way.
253
+ ContradictionKind.UI_ADVANCED_UNSIGNALLED,
236
254
  ContradictionKind.RESPONSE_IGNORED,
237
255
  // The app said something happened and nothing corroborated it. That is an absence of agreement,
238
256
  // never proof the app is wrong — a signal about non-visual state has nothing to corroborate it by
@@ -278,6 +296,7 @@ export function isAbsenceDerived(kind) {
278
296
  */
279
297
  export const ADVISORY_CONTRADICTIONS = new Set([
280
298
  ContradictionKind.DUPLICATE_REQUEST_UNRELATED,
299
+ ContradictionKind.SCREEN_REQUEST_MISMATCH,
281
300
  ]);
282
301
  /** True when this kind is reported alongside a verdict without changing it. */
283
302
  export function isAdvisory(kind) {
@@ -350,6 +369,7 @@ export const MUTATING_METHODS = ['POST', 'PUT', 'PATCH', 'DELETE', 'IPC'];
350
369
  */
351
370
  export const CONTRADICTION_CHANNELS = {
352
371
  [ContradictionKind.UI_ADVANCED_REQUEST_FAILED]: [ChannelId.UI, ChannelId.NET],
372
+ [ContradictionKind.UI_ADVANCED_UNSIGNALLED]: [ChannelId.UI, ChannelId.NET],
353
373
  [ContradictionKind.SIGNAL_CONTRADICTED]: [ChannelId.SIGNAL, ChannelId.NET],
354
374
  [ContradictionKind.RESPONSE_IGNORED]: [ChannelId.NET, ChannelId.UI],
355
375
  [ContradictionKind.SIGNAL_WITHOUT_CONSEQUENCE]: [ChannelId.SIGNAL, ChannelId.NET],
@@ -358,6 +378,8 @@ export const CONTRADICTION_CHANNELS = {
358
378
  [ContradictionKind.CONSEQUENCE_ELSEWHERE]: [ChannelId.NET, ChannelId.UI],
359
379
  [ContradictionKind.DUPLICATE_REQUEST]: [ChannelId.NET, ChannelId.NET],
360
380
  [ContradictionKind.DUPLICATE_REQUEST_UNRELATED]: [ChannelId.NET, ChannelId.NET],
381
+ // The value a control shows against the value the request carried for the same field.
382
+ [ContradictionKind.SCREEN_REQUEST_MISMATCH]: [ChannelId.UI, ChannelId.NET],
361
383
  // The evidence is the interleaving of two responses, read against what the screen ended up showing.
362
384
  [ContradictionKind.STALE_RESPONSE_APPLIED]: [ChannelId.NET, ChannelId.UI],
363
385
  // Both sides are the server's own answer: the status line and the payload under it.
@@ -0,0 +1,84 @@
1
+ /**
2
+ * How much of an app Reticle can see, and the prompt that asks a coding agent to close the rest.
3
+ *
4
+ * Built only from what a page announced (its HELLO channels, plus the `source` / `testid` markers in
5
+ * the same list) and the gaps its verdicts actually recorded, never from a survey of the page: the
6
+ * rule `instrumentation-gap.ts` keeps. The platform derives the same three states from the same
7
+ * report, so the HUD, `doctor` and the dashboard agree:
8
+ *
9
+ * missing a verdict recorded the gap that names it (or a channel every SDK has is absent);
10
+ * a gap about one control does not outrank its channel seen elsewhere
11
+ * seen its channel or marker was announced
12
+ * not seen yet neither — never counted as covered
13
+ */
14
+ import { z } from 'zod';
15
+ /** The eight things that decide how strong a verdict on this app can be. */
16
+ export declare const CoverageCapability: {
17
+ readonly PAGE_CONNECTED: "page connected";
18
+ readonly DOM_ACTIONS: "DOM actions";
19
+ readonly NETWORK: "network";
20
+ readonly CONSOLE: "console";
21
+ readonly APP_STATE: "app state (store registered)";
22
+ readonly SIGNALS: "signals on mutation";
23
+ readonly SOURCE_MAPPING: "file:line source mapping";
24
+ readonly TEST_IDS: "stable test ids";
25
+ };
26
+ export type CoverageCapability = (typeof CoverageCapability)[keyof typeof CoverageCapability];
27
+ /** A recorded gap, as loosely as the daemon and the platform report carry it. */
28
+ export interface CoverageGap {
29
+ kind: string;
30
+ missing?: string;
31
+ cost?: string;
32
+ fix?: string;
33
+ /** The control the gap is about, when it names one. */
34
+ ref?: string;
35
+ /** `file:line`, when the gap carries one. */
36
+ source?: string;
37
+ }
38
+ export interface MissingCapability {
39
+ capability: CoverageCapability;
40
+ cost: string;
41
+ fix: string;
42
+ }
43
+ export interface Coverage {
44
+ seen: CoverageCapability[];
45
+ missing: MissingCapability[];
46
+ /** Neither seen nor reported missing: never counted as covered. */
47
+ notSeenYet: CoverageCapability[];
48
+ total: number;
49
+ covered: number;
50
+ }
51
+ /** What a page with these channels and these recorded gaps lets Reticle see. Pure. */
52
+ export declare function coverageOf(input: {
53
+ channels: readonly string[];
54
+ gaps: readonly CoverageGap[];
55
+ }): Coverage;
56
+ /** The first line of every coverage prompt. */
57
+ export declare const AGENT_PROMPT_LEAD = "Read https://docs.reticle.sh/skill.md, then improve Reticle's coverage in this repo:";
58
+ /** The last line: what the agent hands back. */
59
+ export declare const AGENT_PROMPT_TAIL = "Report the coverage line it prints.";
60
+ /**
61
+ * The copy-paste prompt for a coding agent: only the gaps verdicts recorded, each with its fix and
62
+ * what it is missing (and the control or file, when the gap names one), then the verify that proves
63
+ * the change. The same text the platform builds from the same report. Pure.
64
+ */
65
+ export declare function agentPromptFor(input: {
66
+ gaps: readonly CoverageGap[];
67
+ appName: string;
68
+ url: string;
69
+ }): string;
70
+ /** The capabilities an app reports as not applying to it, on the wire. Closed: core's eight only. */
71
+ export declare const NotApplicableSchema: z.ZodArray<z.ZodNativeEnum<{
72
+ readonly PAGE_CONNECTED: "page connected";
73
+ readonly DOM_ACTIONS: "DOM actions";
74
+ readonly NETWORK: "network";
75
+ readonly CONSOLE: "console";
76
+ readonly APP_STATE: "app state (store registered)";
77
+ readonly SIGNALS: "signals on mutation";
78
+ readonly SOURCE_MAPPING: "file:line source mapping";
79
+ readonly TEST_IDS: "stable test ids";
80
+ }>, "many">;
81
+ /** Seen ÷ applicable over the eight capabilities. See the header for the exact rule. */
82
+ export declare function coverageScore(coverage: Pick<Coverage, 'seen'>, notApplicable?: readonly CoverageCapability[]): number;
83
+ /** floor(coverageScore × 100): the setup score a person reads. */
84
+ export declare function coveragePercent(coverage: Pick<Coverage, 'seen'>, notApplicable?: readonly CoverageCapability[]): number;
@@ -0,0 +1,182 @@
1
+ /**
2
+ * How much of an app Reticle can see, and the prompt that asks a coding agent to close the rest.
3
+ *
4
+ * Built only from what a page announced (its HELLO channels, plus the `source` / `testid` markers in
5
+ * the same list) and the gaps its verdicts actually recorded, never from a survey of the page: the
6
+ * rule `instrumentation-gap.ts` keeps. The platform derives the same three states from the same
7
+ * report, so the HUD, `doctor` and the dashboard agree:
8
+ *
9
+ * missing a verdict recorded the gap that names it (or a channel every SDK has is absent);
10
+ * a gap about one control does not outrank its channel seen elsewhere
11
+ * seen its channel or marker was announced
12
+ * not seen yet neither — never counted as covered
13
+ */
14
+ import { z } from 'zod';
15
+ import { ChannelId } from 'open-verification';
16
+ import { InstrumentationGapKind, fixForGap } from './instrumentation-gap.js';
17
+ import { CoverageMarker, SOURCE_MAPPING_CAPABILITY } from '../wire/platform-link.js';
18
+ /** The eight things that decide how strong a verdict on this app can be. */
19
+ export const CoverageCapability = {
20
+ PAGE_CONNECTED: 'page connected',
21
+ DOM_ACTIONS: 'DOM actions',
22
+ NETWORK: 'network',
23
+ CONSOLE: 'console',
24
+ APP_STATE: 'app state (store registered)',
25
+ SIGNALS: 'signals on mutation',
26
+ SOURCE_MAPPING: SOURCE_MAPPING_CAPABILITY,
27
+ TEST_IDS: 'stable test ids',
28
+ };
29
+ const CONNECT_FIX = 'run `npx @reticlehq/server init` in the app so its pages connect to Reticle in development';
30
+ /** Ordered as a reader climbs them: nothing works without the first, everything sharpens with the last. */
31
+ const RULES = [
32
+ {
33
+ capability: CoverageCapability.PAGE_CONNECTED,
34
+ gaps: [],
35
+ cost: 'no page has connected, so nothing can be verified',
36
+ fix: CONNECT_FIX,
37
+ },
38
+ {
39
+ capability: CoverageCapability.DOM_ACTIONS,
40
+ channel: ChannelId.UI,
41
+ always: true,
42
+ gaps: [],
43
+ cost: 'controls cannot be driven or read',
44
+ fix: CONNECT_FIX,
45
+ },
46
+ {
47
+ capability: CoverageCapability.NETWORK,
48
+ channel: ChannelId.NET,
49
+ always: true,
50
+ gaps: [],
51
+ cost: 'requests cannot be asserted, so a save that never reached the server can pass',
52
+ fix: 'update @reticlehq/browser so the page reports its network channel',
53
+ },
54
+ {
55
+ capability: CoverageCapability.CONSOLE,
56
+ channel: ChannelId.LOG,
57
+ always: true,
58
+ gaps: [],
59
+ cost: 'errors thrown in the page are invisible to a verdict',
60
+ fix: 'update @reticlehq/browser so the page reports its console channel',
61
+ },
62
+ {
63
+ capability: CoverageCapability.APP_STATE,
64
+ channel: ChannelId.STATE,
65
+ gaps: [InstrumentationGapKind.NO_STORE_REGISTERED],
66
+ cost: 'state predicates fall back to reading the DOM',
67
+ fix: fixForGap(InstrumentationGapKind.NO_STORE_REGISTERED),
68
+ },
69
+ {
70
+ capability: CoverageCapability.SIGNALS,
71
+ channel: ChannelId.SIGNAL,
72
+ gaps: [InstrumentationGapKind.NO_SIGNAL_ON_MUTATION],
73
+ cost: 'the app never says it succeeded, so every verdict infers success from the DOM',
74
+ fix: fixForGap(InstrumentationGapKind.NO_SIGNAL_ON_MUTATION),
75
+ },
76
+ {
77
+ capability: CoverageCapability.SOURCE_MAPPING,
78
+ channel: CoverageMarker.SOURCE,
79
+ gaps: [InstrumentationGapKind.NO_SOURCE_MAPPING, InstrumentationGapKind.SOURCE_MAPPING_OFF],
80
+ perControl: [InstrumentationGapKind.NO_SOURCE_MAPPING],
81
+ cost: 'a broken control is named, never the line that renders it',
82
+ fix: fixForGap(InstrumentationGapKind.NO_SOURCE_MAPPING),
83
+ },
84
+ {
85
+ capability: CoverageCapability.TEST_IDS,
86
+ channel: CoverageMarker.TESTID,
87
+ gaps: [InstrumentationGapKind.MISSING_TESTID],
88
+ cost: 'a saved flow loses its controls after a refactor',
89
+ fix: fixForGap(InstrumentationGapKind.MISSING_TESTID),
90
+ },
91
+ ];
92
+ /** What a page with these channels and these recorded gaps lets Reticle see. Pure. */
93
+ export function coverageOf(input) {
94
+ const channels = new Set(input.channels);
95
+ const connected = 0 < channels.size;
96
+ const seen = [];
97
+ const missing = [];
98
+ const notSeenYet = [];
99
+ for (const rule of RULES) {
100
+ const announced = rule.channel === undefined ? connected : channels.has(rule.channel);
101
+ const recorded = input.gaps.find((gap) => rule.gaps.some((kind) => kind === gap.kind) &&
102
+ !(announced && true === rule.perControl?.some((kind) => kind === gap.kind)));
103
+ if (recorded !== undefined) {
104
+ missing.push({
105
+ capability: rule.capability,
106
+ cost: recorded.cost ?? rule.cost,
107
+ fix: recorded.fix ?? rule.fix,
108
+ });
109
+ continue;
110
+ }
111
+ if (announced)
112
+ seen.push(rule.capability);
113
+ else if (!connected || true === rule.always)
114
+ missing.push({ capability: rule.capability, cost: rule.cost, fix: rule.fix });
115
+ else
116
+ notSeenYet.push(rule.capability);
117
+ }
118
+ return { seen, missing, notSeenYet, total: RULES.length, covered: seen.length };
119
+ }
120
+ /** The first line of every coverage prompt. */
121
+ export const AGENT_PROMPT_LEAD = "Read https://docs.reticle.sh/skill.md, then improve Reticle's coverage in this repo:";
122
+ /** The last line: what the agent hands back. */
123
+ export const AGENT_PROMPT_TAIL = 'Report the coverage line it prints.';
124
+ /**
125
+ * The placeholder the agent replaces with the end state of the journey its change touched. It names
126
+ * a JSON predicate, because `--expect` parses JSON and refuses prose.
127
+ */
128
+ const JOURNEY_PLACEHOLDER = '<JSON predicate for the end state of one journey you changed>';
129
+ /**
130
+ * The copy-paste prompt for a coding agent: only the gaps verdicts recorded, each with its fix and
131
+ * what it is missing (and the control or file, when the gap names one), then the verify that proves
132
+ * the change. The same text the platform builds from the same report. Pure.
133
+ */
134
+ export function agentPromptFor(input) {
135
+ const items = input.gaps.map((gap) => {
136
+ const where = [
137
+ gap.missing === undefined ? undefined : `missing: ${gap.missing}`,
138
+ gap.ref === undefined ? undefined : `control ${gap.ref}`,
139
+ gap.source === undefined ? undefined : `at ${gap.source}`,
140
+ ].filter((part) => part !== undefined);
141
+ return `- ${gap.fix ?? fixForKind(gap.kind)}${0 === where.length ? '' : ` (${where.join(', ')})`}`;
142
+ });
143
+ return [
144
+ AGENT_PROMPT_LEAD,
145
+ `App: ${input.appName} at ${input.url}`,
146
+ ...new Set(items),
147
+ `Then run: npx @reticlehq/server verify ${input.url} --expect '${JOURNEY_PLACEHOLDER}'`,
148
+ AGENT_PROMPT_TAIL,
149
+ ].join('\n');
150
+ }
151
+ /** The vocabulary's fix for a kind this build knows, else nothing invented. */
152
+ function fixForKind(kind) {
153
+ const known = Object.values(InstrumentationGapKind).find((k) => k === kind);
154
+ return known === undefined ? kind : fixForGap(known);
155
+ }
156
+ // ── The setup score ───────────────────────────────────────────────────────────────────────────
157
+ /*
158
+ * How much of an app Reticle sees, as one number. It is information, never a gate: the Harness and
159
+ * every tool run at any score. Doctor and the HUD show it so a person knows what more wiring adds.
160
+ *
161
+ * capabilities the eight `CoverageCapability` entries, as `coverageOf` reads them
162
+ * applicable capabilities minus those that do not apply to this app (excluded from both sides;
163
+ * the daemon reports them as `notApplicable` on each local-apps app)
164
+ * seen applicable capabilities `coverageOf` lists as seen; "not seen yet" is NOT seen
165
+ * score seen ÷ applicable, 0 when nothing applies
166
+ * percent floor(score × 100)
167
+ */
168
+ /** The capabilities an app reports as not applying to it, on the wire. Closed: core's eight only. */
169
+ export const NotApplicableSchema = z.array(z.nativeEnum(CoverageCapability)).max(8);
170
+ /** Floating-point slack, so 0.29 × 100 floors to 29 and not 28. */
171
+ const PERCENT_EPSILON = 1e-9;
172
+ /** Seen ÷ applicable over the eight capabilities. See the header for the exact rule. */
173
+ export function coverageScore(coverage, notApplicable = []) {
174
+ const applicable = Object.values(CoverageCapability).filter((c) => !notApplicable.includes(c));
175
+ if (0 === applicable.length)
176
+ return 0;
177
+ return applicable.filter((c) => coverage.seen.includes(c)).length / applicable.length;
178
+ }
179
+ /** floor(coverageScore × 100): the setup score a person reads. */
180
+ export function coveragePercent(coverage, notApplicable = []) {
181
+ return Math.floor(coverageScore(coverage, notApplicable) * 100 + PERCENT_EPSILON);
182
+ }
@@ -14,6 +14,7 @@
14
14
  * everything uninstrumented on the page. The test is *did this absence change the answer the agent
15
15
  * just got?* — if not, it does not fire.
16
16
  */
17
+ import { z } from 'zod';
17
18
  /**
18
19
  * The kinds of absence that can weaken a verdict. Most name a capability the app did not provide;
19
20
  * `UNDECLARED_CHANGE` names one the agent did not, and is here because it costs a verdict the same.
@@ -147,3 +148,81 @@ export declare function instrumentationGap(kind: InstrumentationGapKind, missing
147
148
  * while one store hit twice stays one.
148
149
  */
149
150
  export declare function dedupeGaps(gaps: readonly InstrumentationGap[]): InstrumentationGap[];
151
+ /**
152
+ * What the ENGINE could not observe in a run, so a host can refuse to call that run clean.
153
+ *
154
+ * Not an instrumentation gap: nothing the app adds closes these, because this engine has no reader
155
+ * for them. Each verdict result (`reticle_act_and_wait`, `reticle_assert`) carries the list under
156
+ * `ENGINE_BLIND_SPOTS_FIELD`, CUMULATIVE for its session: everything seen since the session began,
157
+ * and `[]` when there is nothing. So the LAST verdict result of a run is the run's list. A host that
158
+ * predates the field ignores it; nothing else in the result changes.
159
+ */
160
+ export declare const EngineBlindSpotKind: {
161
+ /**
162
+ * An action ran while a `<canvas>` was visible, and this engine records no canvas digest.
163
+ *
164
+ * The pixels are the output there. A colour picker that no longer reaches the renderer leaves the
165
+ * DOM, the network and the store exactly as they were on the build that works, so "nothing
166
+ * disagreed" is not evidence that the canvas is right.
167
+ */
168
+ readonly PIXELS_UNOBSERVED: "pixels-unobserved";
169
+ /**
170
+ * A claim under test names a number or a total, and no verdict ran a computed comparison
171
+ * (`compare`).
172
+ *
173
+ * "Each hit adds one point" is broken by a handler that adds two. The store, the screen and the
174
+ * wire all agree with each other on that build, so only the arithmetic the claim states can catch
175
+ * it, and nothing checked it.
176
+ */
177
+ readonly CLAIM_ARITHMETIC_UNCHECKED: "claim-arithmetic-unchecked";
178
+ };
179
+ export type EngineBlindSpotKind = (typeof EngineBlindSpotKind)[keyof typeof EngineBlindSpotKind];
180
+ export declare const EngineBlindSpotSchema: z.ZodObject<{
181
+ kind: z.ZodNativeEnum<{
182
+ /**
183
+ * An action ran while a `<canvas>` was visible, and this engine records no canvas digest.
184
+ *
185
+ * The pixels are the output there. A colour picker that no longer reaches the renderer leaves the
186
+ * DOM, the network and the store exactly as they were on the build that works, so "nothing
187
+ * disagreed" is not evidence that the canvas is right.
188
+ */
189
+ readonly PIXELS_UNOBSERVED: "pixels-unobserved";
190
+ /**
191
+ * A claim under test names a number or a total, and no verdict ran a computed comparison
192
+ * (`compare`).
193
+ *
194
+ * "Each hit adds one point" is broken by a handler that adds two. The store, the screen and the
195
+ * wire all agree with each other on that build, so only the arithmetic the claim states can catch
196
+ * it, and nothing checked it.
197
+ */
198
+ readonly CLAIM_ARITHMETIC_UNCHECKED: "claim-arithmetic-unchecked";
199
+ }>;
200
+ /** What could not be seen, in words. */
201
+ detail: z.ZodString;
202
+ }, "strip", z.ZodTypeAny, {
203
+ kind: "pixels-unobserved" | "claim-arithmetic-unchecked";
204
+ detail: string;
205
+ }, {
206
+ kind: "pixels-unobserved" | "claim-arithmetic-unchecked";
207
+ detail: string;
208
+ }>;
209
+ export type EngineBlindSpot = z.infer<typeof EngineBlindSpotSchema>;
210
+ /** The verdict-result field that carries a session's `EngineBlindSpot[]`. */
211
+ export declare const ENGINE_BLIND_SPOTS_FIELD = "engineBlindSpots";
212
+ /** True when a claim states an amount: a digit, a percent sign, or a number word. */
213
+ export declare function namesArithmetic(claim: string): boolean;
214
+ /** What a session's run has shown so far, for `engineBlindSpots`. */
215
+ export interface EngineBlindSpotFacts {
216
+ /** An action in this session ran while a `<canvas>` was visible. */
217
+ canvasSeen: boolean;
218
+ /** A verdict in this session ran a computed comparison. */
219
+ compared: boolean;
220
+ /** The claims under test: inline intents and this run's declared intents. */
221
+ claims: readonly (string | undefined)[];
222
+ }
223
+ /**
224
+ * What this engine could not observe in a session, cumulative. See `EngineBlindSpotKind`.
225
+ *
226
+ * Pixels: this engine records no canvas digest, so a visible canvas is always unobserved.
227
+ */
228
+ export declare function engineBlindSpots(facts: EngineBlindSpotFacts): EngineBlindSpot[];