@reticlehq/core 3.7.0 → 3.8.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.
Files changed (138) hide show
  1. package/dist/activation-entry.d.ts +9 -0
  2. package/dist/activation-entry.js +9 -0
  3. package/dist/artifacts/drive-script.d.ts +84 -1217
  4. package/dist/artifacts/drive-script.js +1 -1
  5. package/dist/artifacts/flow-constants.d.ts +15 -0
  6. package/dist/artifacts/flow-constants.js +15 -0
  7. package/dist/artifacts/flow-expect-flat.d.ts +8 -192
  8. package/dist/artifacts/flow-expect-flat.js +2 -2
  9. package/dist/artifacts/flow-results.d.ts +26 -0
  10. package/dist/artifacts/flow-types.d.ts +212 -2295
  11. package/dist/artifacts/flow-types.js +14 -2
  12. package/dist/artifacts/harness-credits.d.ts +6 -3
  13. package/dist/artifacts/harness-credits.js +9 -6
  14. package/dist/artifacts/harness-map.d.ts +8 -69
  15. package/dist/artifacts/harness-map.js +1 -1
  16. package/dist/artifacts/hud-notices.d.ts +8 -82
  17. package/dist/artifacts/hud-notices.js +1 -1
  18. package/dist/artifacts/impact.d.ts +104 -1665
  19. package/dist/artifacts/impact.js +38 -21
  20. package/dist/artifacts/journal.d.ts +15 -231
  21. package/dist/artifacts/journal.js +15 -2
  22. package/dist/artifacts/prompt-context.d.ts +7 -33
  23. package/dist/artifacts/prompt-context.js +15 -4
  24. package/dist/artifacts/screenshot-upload.d.ts +3 -26
  25. package/dist/artifacts/screenshot-upload.js +1 -1
  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 +15 -171
  29. package/dist/hooks/hook-events.js +1 -1
  30. package/dist/hud-entry.js +1 -1
  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 +10 -0
  36. package/dist/index.js +10 -0
  37. package/dist/onboarding.d.ts +23 -52
  38. package/dist/onboarding.js +20 -1
  39. package/dist/registry/daemon-registry.d.ts +2 -14
  40. package/dist/registry/daemon-registry.js +1 -1
  41. package/dist/registry/dev-server-registry.d.ts +2 -31
  42. package/dist/registry/dev-server-registry.js +1 -1
  43. package/dist/registry/project-registry.d.ts +4 -32
  44. package/dist/registry/project-registry.js +1 -1
  45. package/dist/schema/command-message.json +65 -68
  46. package/dist/schema/command-name.json +29 -33
  47. package/dist/schema/command-result.json +25 -30
  48. package/dist/schema/event-message.json +104 -101
  49. package/dist/schema/event-payloads.json +246 -108
  50. package/dist/schema/event-type.json +47 -48
  51. package/dist/schema/hello-message.json +150 -133
  52. package/dist/schema/reticle-event.json +98 -94
  53. package/dist/schema/reticle-message.json +338 -310
  54. package/dist/telemetry-bug.d.ts +4 -75
  55. package/dist/telemetry-bug.js +1 -1
  56. package/dist/telemetry-entry.d.ts +1 -1
  57. package/dist/telemetry-entry.js +1 -1
  58. package/dist/telemetry-feedback.d.ts +17 -91
  59. package/dist/telemetry-feedback.js +20 -1
  60. package/dist/telemetry-refusal.d.ts +4 -31
  61. package/dist/telemetry-refusal.js +1 -1
  62. package/dist/telemetry-session.d.ts +45 -624
  63. package/dist/telemetry-session.js +25 -12
  64. package/dist/telemetry-signals.d.ts +211 -86
  65. package/dist/telemetry-signals.js +100 -2
  66. package/dist/telemetry.d.ts +321 -1691
  67. package/dist/telemetry.js +72 -6
  68. package/dist/verdict/check-sentence.d.ts +34 -0
  69. package/dist/verdict/check-sentence.js +228 -0
  70. package/dist/verdict/compare-source.d.ts +1 -1
  71. package/dist/verdict/compare-source.js +1 -1
  72. package/dist/verdict/consequence.d.ts +15 -0
  73. package/dist/verdict/consequence.js +11 -0
  74. package/dist/verdict/disparity.d.ts +8 -56
  75. package/dist/verdict/disparity.js +1 -1
  76. package/dist/verdict/findings.d.ts +10 -0
  77. package/dist/verdict/findings.js +13 -0
  78. package/dist/verdict/instrumentation-coverage.d.ts +6 -37
  79. package/dist/verdict/instrumentation-coverage.js +15 -59
  80. package/dist/verdict/instrumentation-gap.d.ts +72 -0
  81. package/dist/verdict/instrumentation-gap.js +64 -0
  82. package/dist/verdict/intent.d.ts +25 -224
  83. package/dist/verdict/intent.js +1 -1
  84. package/dist/verdict/predicate-tree.d.ts +2 -0
  85. package/dist/verdict/predicate-tree.js +16 -0
  86. package/dist/verdict/predicate.d.ts +3 -2
  87. package/dist/verdict/predicate.js +107 -16
  88. package/dist/verdict/property-assertion.d.ts +23 -101
  89. package/dist/verdict/property-assertion.js +1 -1
  90. package/dist/verdict/run-report.d.ts +71 -0
  91. package/dist/verdict/run-report.js +53 -0
  92. package/dist/verdict/security.d.ts +48 -2
  93. package/dist/verdict/security.js +185 -18
  94. package/dist/verdict/verification-run.d.ts +124 -1623
  95. package/dist/verdict/verification-run.js +37 -6
  96. package/dist/verdict/verify-progress.d.ts +22 -64
  97. package/dist/verdict/verify-progress.js +1 -1
  98. package/dist/wire/constants/constants.d.ts +56 -141
  99. package/dist/wire/constants/constants.js +64 -144
  100. package/dist/wire/constants/discovery.d.ts +4 -4
  101. package/dist/wire/constants/discovery.js +4 -4
  102. package/dist/wire/constants/event-types.d.ts +37 -1
  103. package/dist/wire/constants/event-types.js +35 -1
  104. package/dist/wire/constants/hud-controls.js +0 -2
  105. package/dist/wire/constants/hud-use.d.ts +4 -0
  106. package/dist/wire/constants/hud-use.js +4 -0
  107. package/dist/wire/constants/mcp-wire.d.ts +16 -0
  108. package/dist/wire/constants/mcp-wire.js +16 -0
  109. package/dist/wire/constants/response-body-reason.d.ts +19 -0
  110. package/dist/wire/constants/response-body-reason.js +18 -0
  111. package/dist/wire/constants/reticle-env.d.ts +140 -0
  112. package/dist/wire/constants/reticle-env.js +140 -0
  113. package/dist/wire/constants/session-constants.d.ts +11 -0
  114. package/dist/wire/constants/session-constants.js +11 -0
  115. package/dist/wire/event-payloads.d.ts +173 -629
  116. package/dist/wire/event-payloads.js +107 -23
  117. package/dist/wire/event-priority.js +1 -0
  118. package/dist/wire/messages.d.ts +90 -713
  119. package/dist/wire/messages.js +19 -3
  120. package/dist/wire/narrow.d.ts +6 -0
  121. package/dist/wire/narrow.js +26 -0
  122. package/dist/wire/next-step.d.ts +50 -0
  123. package/dist/wire/next-step.js +37 -0
  124. package/dist/wire/platform-link.d.ts +7 -0
  125. package/dist/wire/platform-link.js +14 -8
  126. package/dist/wire/production/activation-ticket.d.ts +64 -0
  127. package/dist/wire/production/activation-ticket.js +148 -0
  128. package/dist/wire/production/hello-mode.d.ts +35 -0
  129. package/dist/wire/production/hello-mode.js +32 -0
  130. package/dist/wire/production/production-policy.d.ts +92 -0
  131. package/dist/wire/production/production-policy.js +133 -0
  132. package/dist/wire/tool-names.d.ts +2 -0
  133. package/dist/wire/tool-names.js +2 -0
  134. package/dist/wire/types.d.ts +102 -700
  135. package/dist/wire/types.js +5 -5
  136. package/dist/words/upgrade.d.ts +3 -13
  137. package/dist/words/upgrade.js +1 -1
  138. package/package.json +7 -4
@@ -11,7 +11,7 @@
11
11
  * seen its channel or marker was announced
12
12
  * not seen yet neither — never counted as covered
13
13
  */
14
- import { z } from 'zod';
14
+ import * as z from 'zod';
15
15
  /** The eight things that decide how strong a verdict on this app can be. */
16
16
  export declare const CoverageCapability: {
17
17
  readonly PAGE_CONNECTED: "page connected";
@@ -53,13 +53,8 @@ export declare function coverageOf(input: {
53
53
  channels: readonly string[];
54
54
  gaps: readonly CoverageGap[];
55
55
  }): Coverage;
56
- /**
57
- * The gaps that would close these capabilities: the ones verdicts recorded (they name the control
58
- * and file), else the capability's own fix, so a capability never checked is still named. Pure.
59
- */
60
- export declare function gapsToClose(gaps: readonly CoverageGap[], capabilities: readonly CoverageCapability[]): CoverageGap[];
61
56
  /** The first line of every coverage prompt. */
62
- export declare const AGENT_PROMPT_LEAD = "Read https://reticle.sh/SKILL.md, then improve Reticle's coverage in this repo:";
57
+ export declare const AGENT_PROMPT_LEAD = "Read https://docs.reticle.sh/skill.md, then improve Reticle's coverage in this repo:";
63
58
  /** The last line: what the agent hands back. */
64
59
  export declare const AGENT_PROMPT_TAIL = "Report the coverage line it prints.";
65
60
  /**
@@ -73,7 +68,7 @@ export declare function agentPromptFor(input: {
73
68
  url: string;
74
69
  }): string;
75
70
  /** The capabilities an app reports as not applying to it, on the wire. Closed: core's eight only. */
76
- export declare const NotApplicableSchema: z.ZodArray<z.ZodNativeEnum<{
71
+ export declare const NotApplicableSchema: z.ZodArray<z.ZodEnum<{
77
72
  readonly PAGE_CONNECTED: "page connected";
78
73
  readonly DOM_ACTIONS: "DOM actions";
79
74
  readonly NETWORK: "network";
@@ -82,34 +77,8 @@ export declare const NotApplicableSchema: z.ZodArray<z.ZodNativeEnum<{
82
77
  readonly SIGNALS: "signals on mutation";
83
78
  readonly SOURCE_MAPPING: "file:line source mapping";
84
79
  readonly TEST_IDS: "stable test ids";
85
- }>, "many">;
86
- /** The score at which the Harness unlocks. */
87
- export declare const HARNESS_UNLOCK_COVERAGE = 0.8;
80
+ }>>;
88
81
  /** Seen ÷ applicable over the eight capabilities. See the header for the exact rule. */
89
82
  export declare function coverageScore(coverage: Pick<Coverage, 'seen'>, notApplicable?: readonly CoverageCapability[]): number;
90
- export interface HarnessGate {
91
- /** seen ÷ applicable, 0..1. */
92
- score: number;
93
- /** floor(score × 100). */
94
- percent: number;
95
- unlocked: boolean;
96
- /** The applicable capabilities not seen, in the order a reader climbs them. */
97
- unseen: CoverageCapability[];
98
- /** The one sentence a refusal says. Absent when unlocked. */
99
- reason?: string;
100
- }
101
- /** The one sentence a locked Harness answers with. */
102
- export declare const harnessLockedReason: (percent: number, unseen: readonly string[]) => string;
103
- /** Whether the Harness may drive an app with this coverage, and the sentence when it may not. */
104
- export declare function harnessGateOf(coverage: Pick<Coverage, 'seen'>, notApplicable?: readonly CoverageCapability[]): HarnessGate;
105
- /**
106
- * The prompt for the coding agent that closes the gate: each unseen capability with how to close it
107
- * (the control and file when a verdict named one), then the one flow that proves it. Pure.
108
- */
109
- export declare function harnessUnlockPrompt(input: {
110
- coverage: Pick<Coverage, 'seen'>;
111
- gaps: readonly CoverageGap[];
112
- appName: string;
113
- url: string;
114
- notApplicable?: readonly CoverageCapability[];
115
- }): string;
83
+ /** floor(coverageScore × 100): the setup score a person reads. */
84
+ export declare function coveragePercent(coverage: Pick<Coverage, 'seen'>, notApplicable?: readonly CoverageCapability[]): number;
@@ -11,7 +11,7 @@
11
11
  * seen its channel or marker was announced
12
12
  * not seen yet neither — never counted as covered
13
13
  */
14
- import { z } from 'zod';
14
+ import * as z from 'zod';
15
15
  import { ChannelId } from 'open-verification';
16
16
  import { InstrumentationGapKind, fixForGap } from './instrumentation-gap.js';
17
17
  import { CoverageMarker, SOURCE_MAPPING_CAPABILITY } from '../wire/platform-link.js';
@@ -117,24 +117,15 @@ export function coverageOf(input) {
117
117
  }
118
118
  return { seen, missing, notSeenYet, total: RULES.length, covered: seen.length };
119
119
  }
120
- /**
121
- * The gaps that would close these capabilities: the ones verdicts recorded (they name the control
122
- * and file), else the capability's own fix, so a capability never checked is still named. Pure.
123
- */
124
- export function gapsToClose(gaps, capabilities) {
125
- return RULES.filter((rule) => capabilities.includes(rule.capability)).flatMap((rule) => {
126
- const recorded = gaps.filter((gap) => rule.gaps.some((kind) => kind === gap.kind));
127
- return 0 < recorded.length
128
- ? recorded
129
- : [{ kind: rule.capability, missing: rule.capability, fix: rule.fix }];
130
- });
131
- }
132
120
  /** The first line of every coverage prompt. */
133
- export const AGENT_PROMPT_LEAD = "Read https://reticle.sh/SKILL.md, then improve Reticle's coverage in this repo:";
121
+ export const AGENT_PROMPT_LEAD = "Read https://docs.reticle.sh/skill.md, then improve Reticle's coverage in this repo:";
134
122
  /** The last line: what the agent hands back. */
135
123
  export const AGENT_PROMPT_TAIL = 'Report the coverage line it prints.';
136
- /** The placeholder the person replaces with the journey their change touched. */
137
- const JOURNEY_PLACEHOLDER = '<one journey you changed>';
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>';
138
129
  /**
139
130
  * The copy-paste prompt for a coding agent: only the gaps verdicts recorded, each with its fix and
140
131
  * what it is missing (and the control or file, when the gap names one), then the verify that proves
@@ -153,7 +144,7 @@ export function agentPromptFor(input) {
153
144
  AGENT_PROMPT_LEAD,
154
145
  `App: ${input.appName} at ${input.url}`,
155
146
  ...new Set(items),
156
- `Then run: reticle verify ${input.url} --expect "${JOURNEY_PLACEHOLDER}"`,
147
+ `Then run: npx @reticlehq/server verify ${input.url} --expect '${JOURNEY_PLACEHOLDER}'`,
157
148
  AGENT_PROMPT_TAIL,
158
149
  ].join('\n');
159
150
  }
@@ -162,30 +153,20 @@ function fixForKind(kind) {
162
153
  const known = Object.values(InstrumentationGapKind).find((k) => k === kind);
163
154
  return known === undefined ? kind : fixForGap(known);
164
155
  }
165
- // ── The Harness coverage gate ─────────────────────────────────────────────────────────────────
156
+ // ── The setup score ───────────────────────────────────────────────────────────────────────────
166
157
  /*
167
- * When the Reticle Harness may drive an app: only once Reticle can see enough of it.
168
- *
169
- * A Harness drive decides on the platform and spends credits; on an app Reticle half sees, it pays
170
- * for verdicts that can only infer from the DOM. So the Harness unlocks at a coverage score, and the
171
- * coding agent (which can use every other tool at any coverage) is how an app gets there.
172
- *
173
- * THE RULE, one definition; the platform mirrors it exactly:
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.
174
160
  *
175
161
  * capabilities the eight `CoverageCapability` entries, as `coverageOf` reads them
176
162
  * applicable capabilities minus those that do not apply to this app (excluded from both sides;
177
163
  * the daemon reports them as `notApplicable` on each local-apps app)
178
164
  * seen applicable capabilities `coverageOf` lists as seen; "not seen yet" is NOT seen
179
165
  * score seen ÷ applicable, 0 when nothing applies
180
- * percent floor(score × 100), so a shown percent is below 80 exactly when the gate is shut
181
- * unlocked score ≥ HARNESS_UNLOCK_COVERAGE (0.8)
182
- *
183
- * The gate is the Harness's alone. Pure: coverage in, a decision and its sentence out.
166
+ * percent floor(score × 100)
184
167
  */
185
168
  /** The capabilities an app reports as not applying to it, on the wire. Closed: core's eight only. */
186
169
  export const NotApplicableSchema = z.array(z.nativeEnum(CoverageCapability)).max(8);
187
- /** The score at which the Harness unlocks. */
188
- export const HARNESS_UNLOCK_COVERAGE = 0.8;
189
170
  /** Floating-point slack, so 0.29 × 100 floors to 29 and not 28. */
190
171
  const PERCENT_EPSILON = 1e-9;
191
172
  /** Seen ÷ applicable over the eight capabilities. See the header for the exact rule. */
@@ -195,32 +176,7 @@ export function coverageScore(coverage, notApplicable = []) {
195
176
  return 0;
196
177
  return applicable.filter((c) => coverage.seen.includes(c)).length / applicable.length;
197
178
  }
198
- /** The one sentence a locked Harness answers with. */
199
- export const harnessLockedReason = (percent, unseen) => `Harness unlocks at ${String(Math.round(HARNESS_UNLOCK_COVERAGE * 100))}% instrumentation. ` +
200
- `This app is at ${String(percent)}%: missing ${unseen.join(', ')}.`;
201
- /** Whether the Harness may drive an app with this coverage, and the sentence when it may not. */
202
- export function harnessGateOf(coverage, notApplicable = []) {
203
- const score = coverageScore(coverage, notApplicable);
204
- const percent = Math.floor(score * 100 + PERCENT_EPSILON);
205
- const unseen = Object.values(CoverageCapability).filter((c) => !notApplicable.includes(c) && !coverage.seen.includes(c));
206
- const unlocked = HARNESS_UNLOCK_COVERAGE <= score;
207
- return {
208
- score,
209
- percent,
210
- unlocked,
211
- unseen,
212
- ...(unlocked ? {} : { reason: harnessLockedReason(percent, unseen) }),
213
- };
214
- }
215
- /**
216
- * The prompt for the coding agent that closes the gate: each unseen capability with how to close it
217
- * (the control and file when a verdict named one), then the one flow that proves it. Pure.
218
- */
219
- export function harnessUnlockPrompt(input) {
220
- const { unseen } = harnessGateOf(input.coverage, input.notApplicable);
221
- return agentPromptFor({
222
- gaps: gapsToClose(input.gaps, unseen),
223
- appName: input.appName,
224
- url: input.url,
225
- });
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);
226
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 * as 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,74 @@ 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.ZodEnum<{
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
+ detail: z.ZodString;
201
+ }, z.core.$strip>;
202
+ export type EngineBlindSpot = z.infer<typeof EngineBlindSpotSchema>;
203
+ /** The verdict-result field that carries a session's `EngineBlindSpot[]`. */
204
+ export declare const ENGINE_BLIND_SPOTS_FIELD = "engineBlindSpots";
205
+ /** True when a claim states an amount: a digit, a percent sign, or a number word. */
206
+ export declare function namesArithmetic(claim: string): boolean;
207
+ /** What a session's run has shown so far, for `engineBlindSpots`. */
208
+ export interface EngineBlindSpotFacts {
209
+ /** An action in this session ran while a `<canvas>` was visible. */
210
+ canvasSeen: boolean;
211
+ /** A verdict in this session ran a computed comparison. */
212
+ compared: boolean;
213
+ /** The claims under test: inline intents and this run's declared intents. */
214
+ claims: readonly (string | undefined)[];
215
+ }
216
+ /**
217
+ * What this engine could not observe in a session, cumulative. See `EngineBlindSpotKind`.
218
+ *
219
+ * Pixels: this engine records no canvas digest, so a visible canvas is always unobserved.
220
+ */
221
+ export declare function engineBlindSpots(facts: EngineBlindSpotFacts): EngineBlindSpot[];
@@ -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 * as 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.
@@ -170,3 +171,66 @@ export function dedupeGaps(gaps) {
170
171
  }
171
172
  return out;
172
173
  }
174
+ /**
175
+ * What the ENGINE could not observe in a run, so a host can refuse to call that run clean.
176
+ *
177
+ * Not an instrumentation gap: nothing the app adds closes these, because this engine has no reader
178
+ * for them. Each verdict result (`reticle_act_and_wait`, `reticle_assert`) carries the list under
179
+ * `ENGINE_BLIND_SPOTS_FIELD`, CUMULATIVE for its session: everything seen since the session began,
180
+ * and `[]` when there is nothing. So the LAST verdict result of a run is the run's list. A host that
181
+ * predates the field ignores it; nothing else in the result changes.
182
+ */
183
+ export const EngineBlindSpotKind = {
184
+ /**
185
+ * An action ran while a `<canvas>` was visible, and this engine records no canvas digest.
186
+ *
187
+ * The pixels are the output there. A colour picker that no longer reaches the renderer leaves the
188
+ * DOM, the network and the store exactly as they were on the build that works, so "nothing
189
+ * disagreed" is not evidence that the canvas is right.
190
+ */
191
+ PIXELS_UNOBSERVED: 'pixels-unobserved',
192
+ /**
193
+ * A claim under test names a number or a total, and no verdict ran a computed comparison
194
+ * (`compare`).
195
+ *
196
+ * "Each hit adds one point" is broken by a handler that adds two. The store, the screen and the
197
+ * wire all agree with each other on that build, so only the arithmetic the claim states can catch
198
+ * it, and nothing checked it.
199
+ */
200
+ CLAIM_ARITHMETIC_UNCHECKED: 'claim-arithmetic-unchecked',
201
+ };
202
+ export const EngineBlindSpotSchema = z.object({
203
+ kind: z.nativeEnum(EngineBlindSpotKind),
204
+ /** What could not be seen, in words. */
205
+ detail: z.string().min(1),
206
+ });
207
+ /** The verdict-result field that carries a session's `EngineBlindSpot[]`. */
208
+ export const ENGINE_BLIND_SPOTS_FIELD = 'engineBlindSpots';
209
+ /** Number words and arithmetic nouns a claim uses to state an amount. Whole words only. */
210
+ const ARITHMETIC_WORDS = /\b(?:one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|hundred|thousand|once|twice|double|triple|half|total|sum|subtotal|count|score|points?|balance|average|percent)\b/i;
211
+ /** True when a claim states an amount: a digit, a percent sign, or a number word. */
212
+ export function namesArithmetic(claim) {
213
+ return /\d|%/.test(claim) || ARITHMETIC_WORDS.test(claim);
214
+ }
215
+ /**
216
+ * What this engine could not observe in a session, cumulative. See `EngineBlindSpotKind`.
217
+ *
218
+ * Pixels: this engine records no canvas digest, so a visible canvas is always unobserved.
219
+ */
220
+ export function engineBlindSpots(facts) {
221
+ const spots = [];
222
+ if (facts.canvasSeen) {
223
+ spots.push({
224
+ kind: EngineBlindSpotKind.PIXELS_UNOBSERVED,
225
+ detail: 'an action ran while a canvas was visible, and no canvas digest was recorded, so what it draws was not compared',
226
+ });
227
+ }
228
+ const numeric = facts.claims.find((claim) => claim !== undefined && namesArithmetic(claim));
229
+ if (numeric !== undefined && !facts.compared) {
230
+ spots.push({
231
+ kind: EngineBlindSpotKind.CLAIM_ARITHMETIC_UNCHECKED,
232
+ detail: `the claim "${numeric}" states an amount, and no verdict ran a computed comparison against it`,
233
+ });
234
+ }
235
+ return spots;
236
+ }
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import * as z from 'zod';
2
2
  /**
3
3
  * What a change was supposed to make true, captured while somebody still knows.
4
4
  *
@@ -37,271 +37,72 @@ export type IntentState = (typeof IntentState)[keyof typeof IntentState];
37
37
  export declare const IntentSurfaceSchema: z.ZodObject<{
38
38
  route: z.ZodOptional<z.ZodString>;
39
39
  flow: z.ZodOptional<z.ZodString>;
40
- files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
41
- }, "strip", z.ZodTypeAny, {
42
- route?: string | undefined;
43
- flow?: string | undefined;
44
- files?: string[] | undefined;
45
- }, {
46
- route?: string | undefined;
47
- flow?: string | undefined;
48
- files?: string[] | undefined;
49
- }>;
40
+ files: z.ZodOptional<z.ZodArray<z.ZodString>>;
41
+ }, z.core.$strip>;
50
42
  export type IntentSurface = z.infer<typeof IntentSurfaceSchema>;
51
43
  /** Which verdict discharged it, and how strongly. The grade is what makes a later weakening visible. */
52
44
  export declare const IntentProofSchema: z.ZodObject<{
53
45
  verdictId: z.ZodString;
54
46
  grade: z.ZodString;
55
47
  at: z.ZodNumber;
56
- /** The run the proving check landed in, so a reader links proof and run by id, not by time. */
57
48
  runId: z.ZodOptional<z.ZodString>;
58
- }, "strip", z.ZodTypeAny, {
59
- at: number;
60
- grade: string;
61
- verdictId: string;
62
- runId?: string | undefined;
63
- }, {
64
- at: number;
65
- grade: string;
66
- verdictId: string;
67
- runId?: string | undefined;
68
- }>;
49
+ }, z.core.$strip>;
69
50
  export declare const IntentSchema: z.ZodObject<{
70
51
  id: z.ZodString;
71
- /** The prose. Survives even when the binding rots, which is most of the point. */
72
52
  statement: z.ZodString;
73
- state: z.ZodEnum<["declared", "bound", "proved"]>;
53
+ state: z.ZodEnum<{
54
+ proved: "proved";
55
+ declared: "declared";
56
+ bound: "bound";
57
+ }>;
74
58
  declaredAt: z.ZodNumber;
75
- /** Left as `unknown`: core must not depend on the server's predicate vocabulary. */
76
59
  binding: z.ZodOptional<z.ZodUnknown>;
77
60
  surface: z.ZodOptional<z.ZodObject<{
78
61
  route: z.ZodOptional<z.ZodString>;
79
62
  flow: z.ZodOptional<z.ZodString>;
80
- files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
81
- }, "strip", z.ZodTypeAny, {
82
- route?: string | undefined;
83
- flow?: string | undefined;
84
- files?: string[] | undefined;
85
- }, {
86
- route?: string | undefined;
87
- flow?: string | undefined;
88
- files?: string[] | undefined;
89
- }>>;
63
+ files: z.ZodOptional<z.ZodArray<z.ZodString>>;
64
+ }, z.core.$strip>>;
90
65
  provenBy: z.ZodOptional<z.ZodObject<{
91
66
  verdictId: z.ZodString;
92
67
  grade: z.ZodString;
93
68
  at: z.ZodNumber;
94
- /** The run the proving check landed in, so a reader links proof and run by id, not by time. */
95
69
  runId: z.ZodOptional<z.ZodString>;
96
- }, "strip", z.ZodTypeAny, {
97
- at: number;
98
- grade: string;
99
- verdictId: string;
100
- runId?: string | undefined;
101
- }, {
102
- at: number;
103
- grade: string;
104
- verdictId: string;
105
- runId?: string | undefined;
106
- }>>;
107
- /** Every statement this intent previously carried, oldest first. Append-only, never rewritten. */
70
+ }, z.core.$strip>>;
108
71
  amended: z.ZodOptional<z.ZodArray<z.ZodObject<{
109
72
  statement: z.ZodString;
110
73
  at: z.ZodNumber;
111
- }, "strip", z.ZodTypeAny, {
112
- at: number;
113
- statement: string;
114
- }, {
115
- at: number;
116
- statement: string;
117
- }>, "many">>;
118
- }, "strip", z.ZodTypeAny, {
119
- state: "proved" | "declared" | "bound";
120
- id: string;
121
- statement: string;
122
- declaredAt: number;
123
- surface?: {
124
- route?: string | undefined;
125
- flow?: string | undefined;
126
- files?: string[] | undefined;
127
- } | undefined;
128
- binding?: unknown;
129
- provenBy?: {
130
- at: number;
131
- grade: string;
132
- verdictId: string;
133
- runId?: string | undefined;
134
- } | undefined;
135
- amended?: {
136
- at: number;
137
- statement: string;
138
- }[] | undefined;
139
- }, {
140
- state: "proved" | "declared" | "bound";
141
- id: string;
142
- statement: string;
143
- declaredAt: number;
144
- surface?: {
145
- route?: string | undefined;
146
- flow?: string | undefined;
147
- files?: string[] | undefined;
148
- } | undefined;
149
- binding?: unknown;
150
- provenBy?: {
151
- at: number;
152
- grade: string;
153
- verdictId: string;
154
- runId?: string | undefined;
155
- } | undefined;
156
- amended?: {
157
- at: number;
158
- statement: string;
159
- }[] | undefined;
160
- }>;
74
+ }, z.core.$strip>>>;
75
+ }, z.core.$strip>;
161
76
  export type Intent = z.infer<typeof IntentSchema>;
162
77
  export declare const IntentFileSchema: z.ZodObject<{
163
78
  version: z.ZodLiteral<1>;
164
79
  intents: z.ZodRecord<z.ZodString, z.ZodObject<{
165
80
  id: z.ZodString;
166
- /** The prose. Survives even when the binding rots, which is most of the point. */
167
81
  statement: z.ZodString;
168
- state: z.ZodEnum<["declared", "bound", "proved"]>;
82
+ state: z.ZodEnum<{
83
+ proved: "proved";
84
+ declared: "declared";
85
+ bound: "bound";
86
+ }>;
169
87
  declaredAt: z.ZodNumber;
170
- /** Left as `unknown`: core must not depend on the server's predicate vocabulary. */
171
88
  binding: z.ZodOptional<z.ZodUnknown>;
172
89
  surface: z.ZodOptional<z.ZodObject<{
173
90
  route: z.ZodOptional<z.ZodString>;
174
91
  flow: z.ZodOptional<z.ZodString>;
175
- files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
176
- }, "strip", z.ZodTypeAny, {
177
- route?: string | undefined;
178
- flow?: string | undefined;
179
- files?: string[] | undefined;
180
- }, {
181
- route?: string | undefined;
182
- flow?: string | undefined;
183
- files?: string[] | undefined;
184
- }>>;
92
+ files: z.ZodOptional<z.ZodArray<z.ZodString>>;
93
+ }, z.core.$strip>>;
185
94
  provenBy: z.ZodOptional<z.ZodObject<{
186
95
  verdictId: z.ZodString;
187
96
  grade: z.ZodString;
188
97
  at: z.ZodNumber;
189
- /** The run the proving check landed in, so a reader links proof and run by id, not by time. */
190
98
  runId: z.ZodOptional<z.ZodString>;
191
- }, "strip", z.ZodTypeAny, {
192
- at: number;
193
- grade: string;
194
- verdictId: string;
195
- runId?: string | undefined;
196
- }, {
197
- at: number;
198
- grade: string;
199
- verdictId: string;
200
- runId?: string | undefined;
201
- }>>;
202
- /** Every statement this intent previously carried, oldest first. Append-only, never rewritten. */
99
+ }, z.core.$strip>>;
203
100
  amended: z.ZodOptional<z.ZodArray<z.ZodObject<{
204
101
  statement: z.ZodString;
205
102
  at: z.ZodNumber;
206
- }, "strip", z.ZodTypeAny, {
207
- at: number;
208
- statement: string;
209
- }, {
210
- at: number;
211
- statement: string;
212
- }>, "many">>;
213
- }, "strip", z.ZodTypeAny, {
214
- state: "proved" | "declared" | "bound";
215
- id: string;
216
- statement: string;
217
- declaredAt: number;
218
- surface?: {
219
- route?: string | undefined;
220
- flow?: string | undefined;
221
- files?: string[] | undefined;
222
- } | undefined;
223
- binding?: unknown;
224
- provenBy?: {
225
- at: number;
226
- grade: string;
227
- verdictId: string;
228
- runId?: string | undefined;
229
- } | undefined;
230
- amended?: {
231
- at: number;
232
- statement: string;
233
- }[] | undefined;
234
- }, {
235
- state: "proved" | "declared" | "bound";
236
- id: string;
237
- statement: string;
238
- declaredAt: number;
239
- surface?: {
240
- route?: string | undefined;
241
- flow?: string | undefined;
242
- files?: string[] | undefined;
243
- } | undefined;
244
- binding?: unknown;
245
- provenBy?: {
246
- at: number;
247
- grade: string;
248
- verdictId: string;
249
- runId?: string | undefined;
250
- } | undefined;
251
- amended?: {
252
- at: number;
253
- statement: string;
254
- }[] | undefined;
255
- }>>;
256
- }, "strip", z.ZodTypeAny, {
257
- version: 1;
258
- intents: Record<string, {
259
- state: "proved" | "declared" | "bound";
260
- id: string;
261
- statement: string;
262
- declaredAt: number;
263
- surface?: {
264
- route?: string | undefined;
265
- flow?: string | undefined;
266
- files?: string[] | undefined;
267
- } | undefined;
268
- binding?: unknown;
269
- provenBy?: {
270
- at: number;
271
- grade: string;
272
- verdictId: string;
273
- runId?: string | undefined;
274
- } | undefined;
275
- amended?: {
276
- at: number;
277
- statement: string;
278
- }[] | undefined;
279
- }>;
280
- }, {
281
- version: 1;
282
- intents: Record<string, {
283
- state: "proved" | "declared" | "bound";
284
- id: string;
285
- statement: string;
286
- declaredAt: number;
287
- surface?: {
288
- route?: string | undefined;
289
- flow?: string | undefined;
290
- files?: string[] | undefined;
291
- } | undefined;
292
- binding?: unknown;
293
- provenBy?: {
294
- at: number;
295
- grade: string;
296
- verdictId: string;
297
- runId?: string | undefined;
298
- } | undefined;
299
- amended?: {
300
- at: number;
301
- statement: string;
302
- }[] | undefined;
303
- }>;
304
- }>;
103
+ }, z.core.$strip>>>;
104
+ }, z.core.$strip>>;
105
+ }, z.core.$strip>;
305
106
  export type IntentFile = z.infer<typeof IntentFileSchema>;
306
107
  export declare function emptyIntentFile(): IntentFile;
307
108
  export declare function declareIntent(input: {
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import * as z from 'zod';
2
2
  /**
3
3
  * What a change was supposed to make true, captured while somebody still knows.
4
4
  *
@@ -95,3 +95,5 @@ export declare function sessionRefRefusal(field: string): string;
95
95
  * another session. A ref under a `not` is exactly as meaningless as one at the top.
96
96
  */
97
97
  export declare function sessionBoundField(predicate: Predicate): string | undefined;
98
+ /** True when any clause of this predicate, at any depth, is a computed `compare`. */
99
+ export declare function computesComparison(predicate: Predicate | undefined): boolean;