@reticlehq/core 2.13.1 → 3.1.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 (147) hide show
  1. package/dist/artifacts/artifacts-entry.d.ts +20 -0
  2. package/dist/artifacts/artifacts-entry.js +20 -0
  3. package/dist/artifacts/flow-composition.d.ts +30 -0
  4. package/dist/artifacts/flow-composition.js +19 -0
  5. package/dist/{flow-constants.d.ts → artifacts/flow-constants.d.ts} +97 -3
  6. package/dist/{flow-constants.js → artifacts/flow-constants.js} +103 -4
  7. package/dist/artifacts/flow-mutation-target.d.ts +39 -0
  8. package/dist/artifacts/flow-mutation-target.js +89 -0
  9. package/dist/artifacts/flow-order.d.ts +30 -0
  10. package/dist/artifacts/flow-order.js +49 -0
  11. package/dist/artifacts/flow-select.d.ts +56 -0
  12. package/dist/artifacts/flow-select.js +56 -0
  13. package/dist/artifacts/flow-step-tool.d.ts +31 -0
  14. package/dist/artifacts/flow-step-tool.js +31 -0
  15. package/dist/artifacts/flow-types.d.ts +3736 -0
  16. package/dist/artifacts/flow-types.js +463 -0
  17. package/dist/artifacts/flow-unreached.d.ts +12 -0
  18. package/dist/artifacts/flow-unreached.js +24 -0
  19. package/dist/{impact-savings.d.ts → artifacts/impact-savings.d.ts} +7 -3
  20. package/dist/{impact-savings.js → artifacts/impact-savings.js} +27 -4
  21. package/dist/{impact.d.ts → artifacts/impact.d.ts} +122 -54
  22. package/dist/{impact.js → artifacts/impact.js} +30 -0
  23. package/dist/{journal.d.ts → artifacts/journal.d.ts} +50 -6
  24. package/dist/{journal.js → artifacts/journal.js} +38 -2
  25. package/dist/artifacts/step-effect.d.ts +29 -0
  26. package/dist/artifacts/step-effect.js +28 -0
  27. package/dist/hooks/hook-events.d.ts +311 -0
  28. package/dist/hooks/hook-events.js +127 -0
  29. package/dist/hooks/hooks-entry.d.ts +9 -0
  30. package/dist/hooks/hooks-entry.js +9 -0
  31. package/dist/{brand.d.ts → identity/brand.d.ts} +7 -0
  32. package/dist/{contract-fingerprint.d.ts → identity/contract-fingerprint.d.ts} +21 -3
  33. package/dist/{contract-fingerprint.js → identity/contract-fingerprint.js} +22 -4
  34. package/dist/{document-identity.d.ts → identity/document-identity.d.ts} +4 -5
  35. package/dist/{document-identity.js → identity/document-identity.js} +4 -5
  36. package/dist/{source-constants.d.ts → identity/source-constants.d.ts} +4 -4
  37. package/dist/{source-constants.js → identity/source-constants.js} +4 -4
  38. package/dist/index.d.ts +69 -42
  39. package/dist/index.js +78 -44
  40. package/dist/onboarding.d.ts +114 -0
  41. package/dist/onboarding.js +141 -0
  42. package/dist/realm/registry.d.ts +212 -0
  43. package/dist/realm/registry.js +302 -0
  44. package/dist/{dev-server-registry.d.ts → registry/dev-server-registry.d.ts} +4 -5
  45. package/dist/{dev-server-registry.js → registry/dev-server-registry.js} +28 -19
  46. package/dist/{project-registry.d.ts → registry/project-registry.d.ts} +5 -5
  47. package/dist/{project-registry.js → registry/project-registry.js} +5 -5
  48. package/dist/schema/command-name.json +31 -0
  49. package/dist/schema/event-message.json +1 -0
  50. package/dist/schema/event-payloads.json +791 -0
  51. package/dist/schema/event-type.json +1 -0
  52. package/dist/schema/hello-message.json +76 -2
  53. package/dist/schema/reticle-event.json +1 -0
  54. package/dist/schema/reticle-message.json +77 -2
  55. package/dist/telemetry-entry.d.ts +15 -0
  56. package/dist/telemetry-entry.js +15 -0
  57. package/dist/telemetry-feedback.d.ts +13 -14
  58. package/dist/telemetry-feedback.js +11 -12
  59. package/dist/telemetry-license.d.ts +1 -1
  60. package/dist/telemetry-license.js +1 -1
  61. package/dist/telemetry-refusal.d.ts +11 -11
  62. package/dist/telemetry-refusal.js +7 -8
  63. package/dist/telemetry-session.d.ts +49 -57
  64. package/dist/telemetry-session.js +47 -55
  65. package/dist/telemetry.d.ts +229 -198
  66. package/dist/telemetry.js +83 -98
  67. package/dist/tour-entry.d.ts +10 -0
  68. package/dist/tour-entry.js +10 -0
  69. package/dist/tour.d.ts +125 -0
  70. package/dist/tour.js +165 -0
  71. package/dist/{consequence.d.ts → verdict/consequence.d.ts} +35 -11
  72. package/dist/{consequence.js → verdict/consequence.js} +9 -22
  73. package/dist/{finding-fingerprint.js → verdict/finding-fingerprint.js} +1 -1
  74. package/dist/{findings.d.ts → verdict/findings.d.ts} +149 -41
  75. package/dist/{findings.js → verdict/findings.js} +169 -48
  76. package/dist/{instrumentation-gap.d.ts → verdict/instrumentation-gap.d.ts} +22 -14
  77. package/dist/{instrumentation-gap.js → verdict/instrumentation-gap.js} +23 -15
  78. package/dist/{intent.d.ts → verdict/intent.d.ts} +41 -52
  79. package/dist/{intent.js → verdict/intent.js} +11 -22
  80. package/dist/verdict/revision.d.ts +44 -0
  81. package/dist/verdict/revision.js +53 -0
  82. package/dist/{run-context.d.ts → verdict/run-context.d.ts} +13 -34
  83. package/dist/{run-context.js → verdict/run-context.js} +15 -36
  84. package/dist/{security.js → verdict/security.js} +12 -21
  85. package/dist/{verification-run.d.ts → verdict/verification-run.d.ts} +369 -93
  86. package/dist/{verification-run.js → verdict/verification-run.js} +157 -21
  87. package/dist/{verified-constants.d.ts → verdict/verified-constants.d.ts} +36 -13
  88. package/dist/{verified-constants.js → verdict/verified-constants.js} +36 -13
  89. package/dist/verdict/verify-progress.d.ts +129 -0
  90. package/dist/verdict/verify-progress.js +74 -0
  91. package/dist/wire/channel.d.ts +46 -0
  92. package/dist/wire/channel.js +95 -0
  93. package/dist/{constants.d.ts → wire/constants/constants.d.ts} +124 -28
  94. package/dist/{constants.js → wire/constants/constants.js} +137 -28
  95. package/dist/{session-constants.d.ts → wire/constants/session-constants.d.ts} +9 -2
  96. package/dist/{session-constants.js → wire/constants/session-constants.js} +9 -2
  97. package/dist/{desktop-contract.js → wire/desktop-contract.js} +1 -1
  98. package/dist/{event-classification.js → wire/event-classification.js} +1 -1
  99. package/dist/{event-payloads.d.ts → wire/event-payloads.d.ts} +229 -17
  100. package/dist/{event-payloads.js → wire/event-payloads.js} +61 -3
  101. package/dist/{event-priority.d.ts → wire/event-priority.d.ts} +1 -4
  102. package/dist/{event-priority.js → wire/event-priority.js} +2 -5
  103. package/dist/wire/global-press.d.ts +30 -0
  104. package/dist/wire/global-press.js +54 -0
  105. package/dist/{messages.d.ts → wire/messages.d.ts} +290 -38
  106. package/dist/{messages.js → wire/messages.js} +93 -5
  107. package/dist/wire/narrow.d.ts +39 -0
  108. package/dist/wire/narrow.js +45 -0
  109. package/dist/{net.d.ts → wire/net.d.ts} +49 -10
  110. package/dist/{net.js → wire/net.js} +49 -10
  111. package/dist/wire/platform.d.ts +37 -0
  112. package/dist/wire/platform.js +36 -0
  113. package/dist/{redaction.d.ts → wire/redaction.d.ts} +30 -0
  114. package/dist/wire/redaction.js +274 -0
  115. package/dist/wire/tool-names.d.ts +133 -0
  116. package/dist/wire/tool-names.js +142 -0
  117. package/dist/{toon.js → wire/toon.js} +1 -1
  118. package/dist/{types.d.ts → wire/types.d.ts} +106 -66
  119. package/dist/{types.js → wire/types.js} +24 -4
  120. package/dist/{no-session-reason.d.ts → words/no-session-reason.d.ts} +7 -3
  121. package/dist/{no-session-reason.js → words/no-session-reason.js} +7 -3
  122. package/dist/{notices.d.ts → words/notices.d.ts} +24 -12
  123. package/dist/{notices.js → words/notices.js} +27 -12
  124. package/package.json +22 -5
  125. package/dist/flow-types.d.ts +0 -1473
  126. package/dist/flow-types.js +0 -195
  127. package/dist/redaction.js +0 -149
  128. /package/dist/{brand.js → identity/brand.js} +0 -0
  129. /package/dist/{edit-epoch.d.ts → identity/edit-epoch.d.ts} +0 -0
  130. /package/dist/{edit-epoch.js → identity/edit-epoch.js} +0 -0
  131. /package/dist/{project-id.d.ts → identity/project-id.d.ts} +0 -0
  132. /package/dist/{project-id.js → identity/project-id.js} +0 -0
  133. /package/dist/{daemon-registry.d.ts → registry/daemon-registry.d.ts} +0 -0
  134. /package/dist/{daemon-registry.js → registry/daemon-registry.js} +0 -0
  135. /package/dist/{finding-fingerprint.d.ts → verdict/finding-fingerprint.d.ts} +0 -0
  136. /package/dist/{security.d.ts → verdict/security.d.ts} +0 -0
  137. /package/dist/{desktop-contract.d.ts → wire/desktop-contract.d.ts} +0 -0
  138. /package/dist/{event-classification.d.ts → wire/event-classification.d.ts} +0 -0
  139. /package/dist/{state-select.d.ts → wire/state-select.d.ts} +0 -0
  140. /package/dist/{state-select.js → wire/state-select.js} +0 -0
  141. /package/dist/{toon.d.ts → wire/toon.d.ts} +0 -0
  142. /package/dist/{browser-misdirect.d.ts → words/browser-misdirect.d.ts} +0 -0
  143. /package/dist/{browser-misdirect.js → words/browser-misdirect.js} +0 -0
  144. /package/dist/{unreachable-notice.d.ts → words/unreachable-notice.d.ts} +0 -0
  145. /package/dist/{unreachable-notice.js → words/unreachable-notice.js} +0 -0
  146. /package/dist/{upgrade.d.ts → words/upgrade.d.ts} +0 -0
  147. /package/dist/{upgrade.js → words/upgrade.js} +0 -0
@@ -10,8 +10,44 @@
10
10
  * logic), no `any` (opaque evidence is `z.unknown`), and every domain string is a named constant.
11
11
  */
12
12
  import { z } from 'zod';
13
+ import { SubjectRefSchema } from 'open-verification';
14
+ import { PredicateKind } from './consequence.js';
15
+ import { Verified } from './verified-constants.js';
13
16
  /** Schema version stamped into every run file so a reader can reject/upgrade old artifacts. */
14
- export const RUN_FILE_VERSION = 1;
17
+ export const RUN_FILE_VERSION = 3;
18
+ /**
19
+ * The version this artifact used before checks were recorded in the assertion vocabulary.
20
+ *
21
+ * Version 1 spelled a network check `network` where an assertion says `net`, and had a `layout` kind
22
+ * nothing could produce. Files already on disk are still read: the two old spellings are translated
23
+ * on the way in, so a stored run from before this change opens rather than reading as empty. Empty
24
+ * is the dangerous outcome -- it looks like a run that found nothing.
25
+ */
26
+ const RUN_FILE_VERSION_BEFORE_ONE_VOCABULARY = 1;
27
+ /**
28
+ * The version this artifact used before a check could say it was undetermined.
29
+ *
30
+ * Version 2 recorded a check as `pass` or `fail` and nothing else, so a check nobody could evaluate
31
+ * had no spelling and was dropped on the way in. That is the exact loss this whole system exists to
32
+ * prevent, committed by Reticle's own artifact: "I could not see" left the document silently, and a
33
+ * reader counting checks counted blind spots as the app's clean bill of health.
34
+ *
35
+ * Files already on disk are still read. `pass` and `fail` translate to `yes` and `no`, which is what
36
+ * they always meant.
37
+ */
38
+ const RUN_FILE_VERSION_BEFORE_UNDETERMINED_CHECKS = 2;
39
+ /** The old spelling of each check outcome, for reading a version 2 file. */
40
+ const OLD_CHECK_STATUS_SPELLING = {
41
+ pass: Verified.YES,
42
+ fail: Verified.NO,
43
+ };
44
+ /** The old spelling of each check kind, for reading a version 1 file. */
45
+ const OLD_CHECK_KIND_SPELLING = {
46
+ network: PredicateKind.NET,
47
+ // `layout` was never produced by anything, so a file cannot contain one. Mapped to the nearest
48
+ // truthful thing rather than dropped, so a hand-written file does not fail to open.
49
+ layout: PredicateKind.ELEMENT,
50
+ };
15
51
  /**
16
52
  * A run's identity, branded so it can't be confused with another id (e.g. a flow name) that also feeds
17
53
  * path helpers. The schema brands on parse; mint a fresh one with asRunId at a trusted/validated point.
@@ -36,6 +72,16 @@ export const VerdictStatus = {
36
72
  PASS: 'pass',
37
73
  FAIL: 'fail',
38
74
  PARTIAL: 'partial',
75
+ /**
76
+ * Nothing was proved either way -- no flow and no check produced an outcome, so there is nothing
77
+ * to pass and nothing to fail.
78
+ *
79
+ * This is deliberately NOT a pass. A run that checked nothing and a run that checked everything
80
+ * successfully are different facts, and flattening them into one word is how a green light comes
81
+ * to mean "we did not look". It matches how a single action is already judged, where "could not
82
+ * tell" has always been its own answer.
83
+ */
84
+ UNKNOWN: 'unknown',
39
85
  };
40
86
  /** Per-flow outcome inside a run. HEALED = a drifted anchor was consequence-verified and rebound. */
41
87
  export const RunFlowStatus = {
@@ -44,20 +90,22 @@ export const RunFlowStatus = {
44
90
  SKIPPED: 'skipped',
45
91
  HEALED: 'healed',
46
92
  };
47
- /** The kind of standalone assertion captured outside a flow (drives `evidence` narrowing downstream). */
48
- export const RunCheckKind = {
49
- SIGNAL: 'signal',
50
- NETWORK: 'network',
51
- ELEMENT: 'element',
52
- STATE: 'state',
53
- CONSOLE: 'console',
54
- LAYOUT: 'layout',
55
- };
56
- /** Binary status of a single check. */
57
- export const RunCheckStatus = {
58
- PASS: 'pass',
59
- FAIL: 'fail',
60
- };
93
+ /**
94
+ * The kind of standalone assertion captured outside a flow.
95
+ *
96
+ * This is `PredicateKind` -- the vocabulary assertions are written in -- and not a second list: two
97
+ * lists drift, and an artifact can only record what somebody can actually assert. Re-exported so
98
+ * the places that read it from this file still can.
99
+ */
100
+ export { PredicateKind };
101
+ /**
102
+ * What a check came out as.
103
+ *
104
+ * `Verified` and not a second list. A binary one here would lose `unknown` and `no-fault` -- the
105
+ * two the specification says make the other two mean anything -- at the moment the verdict is
106
+ * written down. Re-exported so the places that read it from this file still can.
107
+ */
108
+ export { Verified };
61
109
  /**
62
110
  * A risk surface a changed file / observed behaviour touches. The governance seed: a host can gate
63
111
  * a deploy when a high-severity surface is hit. Mirrors the surfaces real AI-app-builder incidents
@@ -154,10 +202,52 @@ export const RunFlowResultSchema = z.object({
154
202
  });
155
203
  /** A standalone assertion not tied to a flow. `evidence` is opaque (narrowed per kind by the caller). */
156
204
  export const RunCheckSchema = z.object({
157
- kind: z.nativeEnum(RunCheckKind),
205
+ kind: z.preprocess((given) => ('string' === typeof given ? (OLD_CHECK_KIND_SPELLING[given] ?? given) : given), z.nativeEnum(PredicateKind)),
158
206
  predicate: z.string(),
159
- status: z.nativeEnum(RunCheckStatus),
207
+ status: z.preprocess((given) => ('string' === typeof given ? (OLD_CHECK_STATUS_SPELLING[given] ?? given) : given), z.nativeEnum(Verified)),
160
208
  evidence: z.unknown().optional(),
209
+ /**
210
+ * Was this claim written down BEFORE the action, or after it?
211
+ *
212
+ * The difference between a check and a rationalisation. Afterwards, anything that happened can be
213
+ * described as what you meant; a claim made in advance can only be met or missed.
214
+ *
215
+ * Optional, and absence is not `false`. `false` says the claim came afterwards. Absent says nobody
216
+ * recorded which, and those are different facts about the evidence.
217
+ */
218
+ declaredBeforeActing: z.boolean().optional(),
219
+ /**
220
+ * What kind of evidence bought this answer.
221
+ *
222
+ * A green paid for with "something matching was on screen" is not the same green as one paid for
223
+ * with "the request went out", and a report that flattens them lets the cheap one pass for the
224
+ * dear one. Free-form because the grades belong to whoever produced the verdict.
225
+ */
226
+ grade: z.string().optional(),
227
+ /**
228
+ * What could not be seen while this was being checked.
229
+ *
230
+ * The property with no prior art: every other test report in existence is silent about its own
231
+ * blind spots. An empty list means nothing was hidden; absence means nobody looked.
232
+ */
233
+ couldNotSee: z.array(z.string()).optional(),
234
+ /**
235
+ * Why the verdict came out this way, in the engine's vocabulary.
236
+ *
237
+ * Carried so a reader -- and the fold that looks for late answers -- can tell an outcome that
238
+ * has not arrived from a capture that could not be read. Both are `unknown`, and only the
239
+ * first is a question that waiting can settle.
240
+ */
241
+ reason: z.string().optional(),
242
+ /** This check's own name, so a later verdict can cite it. See revision.ts. */
243
+ checkId: z.string().optional(),
244
+ /**
245
+ * The earlier check this one corrects, as `<runId>#<checkId>`.
246
+ *
247
+ * Present only on a correction, and the check it names is NOT edited: both stand, so a reader
248
+ * can see that the first answer was given, when it changed, and why.
249
+ */
250
+ supersedes: z.string().optional(),
161
251
  });
162
252
  /** A flagged risk. `gated` = a policy gate tripped on this surface. */
163
253
  export const RunRiskSchema = z.object({
@@ -214,6 +304,22 @@ export const RunVerdictSchema = z.object({
214
304
  reasons: z.array(z.string()).default([]),
215
305
  confidence: z.nativeEnum(RunConfidence),
216
306
  blockingRisks: z.number().default(0),
307
+ /**
308
+ * Which check this verdict is about, so a later one can say it corrects this.
309
+ *
310
+ * Optional because a run's overall verdict is not about one check. A verdict with no check named
311
+ * cannot be cited, and therefore cannot be corrected -- see revision.ts.
312
+ */
313
+ checkId: z.string().optional(),
314
+ /**
315
+ * The verdict this one replaces, written as `<runId>#<checkId>`.
316
+ *
317
+ * Present only on a correction. The verdict it names is NOT edited: it stays exactly as it was
318
+ * given, and this is a second, later answer that cites it. Rewriting the first in place would
319
+ * erase the fact that it was ever given, and "we always knew" is the shape of the problem this
320
+ * whole system exists to prevent.
321
+ */
322
+ supersedes: z.string().optional(),
217
323
  });
218
324
  /** Optional tamper-evidence signature over the run (for audit; populated later). */
219
325
  export const RunSignatureSchema = z.object({
@@ -222,12 +328,19 @@ export const RunSignatureSchema = z.object({
222
328
  signedAt: z.number(),
223
329
  });
224
330
  /**
225
- * The top-level verification-run artifact. Stable contract — additive changes only within
226
- * RUN_FILE_VERSION 1; a breaking change bumps the version. Arrays default to empty so a minimal
227
- * run (e.g. a single smoke flow) still validates.
331
+ * The top-level verification-run artifact. Stable contract — additive changes only within a
332
+ * RUN_FILE_VERSION; a breaking change bumps it. Arrays default to empty so a minimal run (e.g. a
333
+ * single smoke flow) still validates. Version 1 files are still read; see the note on the constant.
228
334
  */
229
335
  export const ReticleVerificationRunSchema = z.object({
230
- schemaVersion: z.literal(RUN_FILE_VERSION),
336
+ // All three versions are read; only the current one is written. Each older version differs from
337
+ // its successor in exactly one way -- how a check's kind is spelled, then how its outcome is --
338
+ // and both are translated above, so there is nothing else to migrate.
339
+ schemaVersion: z.union([
340
+ z.literal(RUN_FILE_VERSION),
341
+ z.literal(RUN_FILE_VERSION_BEFORE_UNDETERMINED_CHECKS),
342
+ z.literal(RUN_FILE_VERSION_BEFORE_ONE_VOCABULARY),
343
+ ]),
231
344
  runId: RunIdSchema,
232
345
  createdAt: z.number(), // epoch ms — INJECTED, never computed in pure logic
233
346
  durationMs: z.number(),
@@ -249,6 +362,29 @@ export const ReticleVerificationRunSchema = z.object({
249
362
  diffRef: z.string().optional(),
250
363
  note: z.string().optional(),
251
364
  }),
365
+ /**
366
+ * Which round of source edits this evidence belongs to.
367
+ *
368
+ * Evidence gathered before the change under test is true about the OLD code. Reporting it as true
369
+ * about the new code is a false pass, and it is the kind nobody notices because everything looks
370
+ * green. Absent when the run had no way to know.
371
+ */
372
+ editEpoch: z.number().optional(),
373
+ /**
374
+ * What was verified, in the protocol's own vocabulary.
375
+ *
376
+ * The artifact recorded the project, the agent, the trigger and the edit round, and never what
377
+ * KIND of thing was on the other end -- so a run against a Tauri desktop app and one against a
378
+ * web page were indistinguishable to every reader of this file. `surface` is the field that
379
+ * separates them, and `instance` is the one that says which document the evidence belongs to,
380
+ * which is the difference between evidence about this page and evidence that survived a
381
+ * navigation.
382
+ *
383
+ * `SubjectRef` is the specification's, imported rather than restated. Optional because a run
384
+ * assembled without a live session -- in CI, from flows alone -- genuinely does not know, and
385
+ * an invented subject is worse than an absent one.
386
+ */
387
+ subject: SubjectRefSchema.optional(),
252
388
  changedFiles: z.array(RunChangedFileSchema).default([]),
253
389
  flows: z.array(RunFlowResultSchema).default([]),
254
390
  checks: z.array(RunCheckSchema).default([]),
@@ -50,6 +50,18 @@ export type Verified = (typeof Verified)[keyof typeof Verified];
50
50
  * equal). Nothing anywhere re-lists these.
51
51
  */
52
52
  export declare const VerifiedReason: {
53
+ /**
54
+ * The claim needed to read something this implementation never said it could see.
55
+ *
56
+ * Not a failure and not a refusal shape of its own. It arrives through the verdict, because the
57
+ * verdict is the one channel an agent is told to gate on -- adding a ninth way to say "I cannot"
58
+ * would repeat the mistake that made this necessary.
59
+ *
60
+ * The distinction it draws is between "it did not happen" and "nothing was watching", which used
61
+ * to produce the same empty answer. Saying `no` to the second blames the app for a gap in the
62
+ * tooling, and is the confident wrong answer this whole mechanism exists to remove.
63
+ */
64
+ readonly CAPABILITY_ABSENT: "capability-absent";
53
65
  /** The assertion was never EVALUATED — under-specified call, or nothing instrumented to read. */
54
66
  readonly INCONCLUSIVE: "inconclusive";
55
67
  /**
@@ -68,6 +80,17 @@ export declare const VerifiedReason: {
68
80
  * RED, from the layer whose entire job is not to produce one.
69
81
  */
70
82
  readonly OBSERVATION_LOST: "observation_lost";
83
+ /**
84
+ * The request the assertion named was still in flight when the window closed, so a miss is not a
85
+ * failure — the consequence had not finished. NEVER `"no"`.
86
+ *
87
+ * Measured: `act_and_wait` returned `verified: "no"` / `assertion_failed` while the same result's
88
+ * contradictions named the matching POST as still in flight. The request completed 200 half a
89
+ * second after the window; a warm backend on the same assertion came back `yes`. A red that flips
90
+ * green when the backend warms up teaches the agent to loosen checks — the behaviour the docs
91
+ * forbid. See #669.
92
+ */
93
+ readonly WINDOW_CLOSED_EARLY: "window_closed_early";
71
94
  /** The declared consequence did not hold. */
72
95
  readonly ASSERTION_FAILED: "assertion_failed";
73
96
  /** Channels disagreed about the action — the false green this product exists to catch. */
@@ -93,11 +116,10 @@ export declare const VerifiedReason: {
93
116
  * The assertion held, but a channel's outcome had not been observed when the window closed — an
94
117
  * ABSENCE-derived finding (see ABSENCE_DERIVED_CONTRADICTIONS), not evidence against the action.
95
118
  *
96
- * Split out of UNSETTLED because that word is a claim about idle, and this clause fires
97
- * independently of whether the page went idle. One field report was, verbatim, "internally
98
- * contradictory": `verifiedReason: "unsettled"` beside `settled: true`, a passing nested verdict,
99
- * the requested POST at 200 and a clean console. Both halves came from this rule, and a verdict
100
- * whose own evidence block denies its stated reason is a verdict nobody can act on.
119
+ * DISTINCT FROM `UNSETTLED`, because that word is a claim about idle and this clause fires
120
+ * independently of whether the page went idle. Reporting it as `unsettled` produces a verdict
121
+ * whose own evidence block denies its stated reason — `verifiedReason: "unsettled"` beside
122
+ * `settled: true` — which nobody can act on.
101
123
  */
102
124
  readonly EVIDENCE_INCOMPLETE: "evidence_incomplete";
103
125
  /** Held at a real grade over a clean capture with no channel disagreeing. */
@@ -110,9 +132,9 @@ export type VerifiedReason = (typeof VerifiedReason)[keyof typeof VerifiedReason
110
132
  * WHAT made a capture unclean — the closed vocabulary behind `UNCLEAN_CAPTURE`.
111
133
  *
112
134
  * `unclean_capture` names three losses that belong to three different owners and need three
113
- * different fixes: our server buffer, our browser transport, and a boundary in the page that nobody
114
- * can see through. Until this existed they arrived as one value on a dashboard and as one sentence
115
- * of free prose in `integrity.issues`, which is not something a query can group by.
135
+ * different fixes: the server buffer, the browser transport, and a boundary in the page that nobody
136
+ * can see through. Without it they arrive as one value and one sentence of free prose in
137
+ * `integrity.issues`, which is not something a query can group by.
116
138
  *
117
139
  * That cost real time. `unclean_capture` became a large share of all `unknown` verdicts in the
118
140
  * field, and answering "which of the three?" took reading the eviction policy, because the data
@@ -180,11 +202,12 @@ export declare const BlindSpotKind: {
180
202
  readonly UNINSTRUMENTED_FRAME: "uninstrumented-frame";
181
203
  readonly VIRTUALIZED_UNMOUNTED: "virtualized-unmounted";
182
204
  /**
183
- * Something wrapped `fetch` before we did, so the request we record is not necessarily the request
184
- * that leaves. Wrappers chain outermost-first: anything installed EARLIER sits below us and mutates
185
- * after we have read `init.body`. An interceptor initialised before connect(), or a polyfill, does
186
- * exactly that. Unfixable from inside the page — there is no "patch last" primitive — so it is
187
- * declared instead, and a verdict over it reports partial coverage rather than implying we saw the wire.
205
+ * Something wrapped `fetch` first, so the recorded request is not necessarily the request that
206
+ * leaves. Wrappers chain outermost-first: anything installed EARLIER sits underneath and mutates
207
+ * the body after it has been read. An interceptor initialised before connect(), or a polyfill,
208
+ * does exactly that. Unfixable from inside the page — there is no "patch last" primitive — so it
209
+ * is declared instead, and a verdict over it reports partial coverage rather than implying the
210
+ * wire was seen.
188
211
  */
189
212
  readonly WRAPPED_NETWORK: "wrapped-network";
190
213
  /**
@@ -49,6 +49,18 @@ export const Verified = {
49
49
  * equal). Nothing anywhere re-lists these.
50
50
  */
51
51
  export const VerifiedReason = {
52
+ /**
53
+ * The claim needed to read something this implementation never said it could see.
54
+ *
55
+ * Not a failure and not a refusal shape of its own. It arrives through the verdict, because the
56
+ * verdict is the one channel an agent is told to gate on -- adding a ninth way to say "I cannot"
57
+ * would repeat the mistake that made this necessary.
58
+ *
59
+ * The distinction it draws is between "it did not happen" and "nothing was watching", which used
60
+ * to produce the same empty answer. Saying `no` to the second blames the app for a gap in the
61
+ * tooling, and is the confident wrong answer this whole mechanism exists to remove.
62
+ */
63
+ CAPABILITY_ABSENT: 'capability-absent',
52
64
  /** The assertion was never EVALUATED — under-specified call, or nothing instrumented to read. */
53
65
  INCONCLUSIVE: 'inconclusive',
54
66
  /**
@@ -67,6 +79,17 @@ export const VerifiedReason = {
67
79
  * RED, from the layer whose entire job is not to produce one.
68
80
  */
69
81
  OBSERVATION_LOST: 'observation_lost',
82
+ /**
83
+ * The request the assertion named was still in flight when the window closed, so a miss is not a
84
+ * failure — the consequence had not finished. NEVER `"no"`.
85
+ *
86
+ * Measured: `act_and_wait` returned `verified: "no"` / `assertion_failed` while the same result's
87
+ * contradictions named the matching POST as still in flight. The request completed 200 half a
88
+ * second after the window; a warm backend on the same assertion came back `yes`. A red that flips
89
+ * green when the backend warms up teaches the agent to loosen checks — the behaviour the docs
90
+ * forbid. See #669.
91
+ */
92
+ WINDOW_CLOSED_EARLY: 'window_closed_early',
70
93
  /** The declared consequence did not hold. */
71
94
  ASSERTION_FAILED: 'assertion_failed',
72
95
  /** Channels disagreed about the action — the false green this product exists to catch. */
@@ -92,11 +115,10 @@ export const VerifiedReason = {
92
115
  * The assertion held, but a channel's outcome had not been observed when the window closed — an
93
116
  * ABSENCE-derived finding (see ABSENCE_DERIVED_CONTRADICTIONS), not evidence against the action.
94
117
  *
95
- * Split out of UNSETTLED because that word is a claim about idle, and this clause fires
96
- * independently of whether the page went idle. One field report was, verbatim, "internally
97
- * contradictory": `verifiedReason: "unsettled"` beside `settled: true`, a passing nested verdict,
98
- * the requested POST at 200 and a clean console. Both halves came from this rule, and a verdict
99
- * whose own evidence block denies its stated reason is a verdict nobody can act on.
118
+ * DISTINCT FROM `UNSETTLED`, because that word is a claim about idle and this clause fires
119
+ * independently of whether the page went idle. Reporting it as `unsettled` produces a verdict
120
+ * whose own evidence block denies its stated reason — `verifiedReason: "unsettled"` beside
121
+ * `settled: true` — which nobody can act on.
100
122
  */
101
123
  EVIDENCE_INCOMPLETE: 'evidence_incomplete',
102
124
  /** Held at a real grade over a clean capture with no channel disagreeing. */
@@ -108,9 +130,9 @@ export const VerifiedReason = {
108
130
  * WHAT made a capture unclean — the closed vocabulary behind `UNCLEAN_CAPTURE`.
109
131
  *
110
132
  * `unclean_capture` names three losses that belong to three different owners and need three
111
- * different fixes: our server buffer, our browser transport, and a boundary in the page that nobody
112
- * can see through. Until this existed they arrived as one value on a dashboard and as one sentence
113
- * of free prose in `integrity.issues`, which is not something a query can group by.
133
+ * different fixes: the server buffer, the browser transport, and a boundary in the page that nobody
134
+ * can see through. Without it they arrive as one value and one sentence of free prose in
135
+ * `integrity.issues`, which is not something a query can group by.
114
136
  *
115
137
  * That cost real time. `unclean_capture` became a large share of all `unknown` verdicts in the
116
138
  * field, and answering "which of the three?" took reading the eviction policy, because the data
@@ -177,11 +199,12 @@ export const BlindSpotKind = {
177
199
  UNINSTRUMENTED_FRAME: 'uninstrumented-frame',
178
200
  VIRTUALIZED_UNMOUNTED: 'virtualized-unmounted',
179
201
  /**
180
- * Something wrapped `fetch` before we did, so the request we record is not necessarily the request
181
- * that leaves. Wrappers chain outermost-first: anything installed EARLIER sits below us and mutates
182
- * after we have read `init.body`. An interceptor initialised before connect(), or a polyfill, does
183
- * exactly that. Unfixable from inside the page — there is no "patch last" primitive — so it is
184
- * declared instead, and a verdict over it reports partial coverage rather than implying we saw the wire.
202
+ * Something wrapped `fetch` first, so the recorded request is not necessarily the request that
203
+ * leaves. Wrappers chain outermost-first: anything installed EARLIER sits underneath and mutates
204
+ * the body after it has been read. An interceptor initialised before connect(), or a polyfill,
205
+ * does exactly that. Unfixable from inside the page — there is no "patch last" primitive — so it
206
+ * is declared instead, and a verdict over it reports partial coverage rather than implying the
207
+ * wire was seen.
185
208
  */
186
209
  WRAPPED_NETWORK: 'wrapped-network',
187
210
  /**
@@ -0,0 +1,129 @@
1
+ /**
2
+ * What a verification run is DOING, while it is still doing it.
3
+ *
4
+ * A verification takes tens of seconds to minutes and the artifact only exists at the end, so
5
+ * without narration a run that is working and a run that has died look identical for the whole of
6
+ * its duration.
7
+ *
8
+ * These events are DERIVED from work that is already happening, never a second source of truth: the
9
+ * run artifact remains the only record of what was proved, and nothing here is ever graded, stored
10
+ * as evidence, or allowed to influence a verdict.
11
+ *
12
+ * ## The rules that keep it honest
13
+ *
14
+ * - **A reporter must never fail a run.** Emitting is best-effort at every layer; a listener that
15
+ * throws, or a network that is down, changes nothing about the verification or its exit code.
16
+ * - **Progress is not proof.** `flow_finished` carries `ok` so a watcher can colour a row, and
17
+ * that is a convenience for a human reading a list — the verdict is computed from the artifact,
18
+ * which is graded, and never from this.
19
+ * - **`total` is known before the loop starts**, because "step 3" without "of 12" tells a reader
20
+ * nothing about whether to keep waiting, which is the entire question they are asking.
21
+ */
22
+ import { z } from 'zod';
23
+ /** The phases a run passes through, in the order they occur. */
24
+ export declare const VerifyPhase: {
25
+ /** Opening the bridge connection. Fast, and the first thing that can fail. */
26
+ readonly CONNECTING: "connecting";
27
+ /** Connected, waiting for the app to attach a session. This is where a dead dev server shows up. */
28
+ readonly WAITING_FOR_APP: "waiting_for_app";
29
+ /** The suite is known. Carries `total`, which is what makes every later step legible. */
30
+ readonly FLOWS_FOUND: "flows_found";
31
+ /** One flow is replaying now. Carries its name and index. */
32
+ readonly FLOW_STARTED: "flow_started";
33
+ /** That flow is done. Carries `ok` — a convenience for a watcher, never a verdict. */
34
+ readonly FLOW_FINISHED: "flow_finished";
35
+ /** Every flow has run; the artifact is being assembled and graded. */
36
+ readonly GRADING: "grading";
37
+ /** The run reached the dashboard. The last thing anybody watching is waiting for. */
38
+ readonly PUSHED: "pushed";
39
+ };
40
+ export type VerifyPhase = (typeof VerifyPhase)[keyof typeof VerifyPhase];
41
+ /**
42
+ * A flow name is user-supplied and unbounded, and this string is rendered in somebody's dashboard.
43
+ * Bounded here rather than at the reader, so no consumer has to remember to truncate it.
44
+ */
45
+ export declare const VERIFY_PROGRESS_NAME_MAX = 120;
46
+ /** How many events a receiver keeps for one run. A walk nobody can scroll is not more honest. */
47
+ export declare const VERIFY_PROGRESS_MAX_EVENTS = 200;
48
+ export declare const verifyProgressEventSchema: z.ZodObject<{
49
+ phase: z.ZodEnum<["connecting", "waiting_for_app", "flows_found", "flow_started", "flow_finished", "grading", "pushed"]>;
50
+ /** 0-based position in the suite. Absent on phases that are not about one flow. */
51
+ index: z.ZodOptional<z.ZodNumber>;
52
+ /** How many flows the run will replay. Present from `flows_found` onwards. */
53
+ total: z.ZodOptional<z.ZodNumber>;
54
+ /** The flow being replayed. Absent on phases that are not about one flow. */
55
+ name: z.ZodOptional<z.ZodString>;
56
+ /** Did that flow replay cleanly? A convenience for rendering, never a verdict. */
57
+ ok: z.ZodOptional<z.ZodBoolean>;
58
+ /** When the emitter saw it, from the injected clock — never `Date.now()` in logic. */
59
+ at: z.ZodNumber;
60
+ }, "strip", z.ZodTypeAny, {
61
+ at: number;
62
+ phase: "connecting" | "waiting_for_app" | "flows_found" | "flow_started" | "flow_finished" | "grading" | "pushed";
63
+ ok?: boolean | undefined;
64
+ name?: string | undefined;
65
+ total?: number | undefined;
66
+ index?: number | undefined;
67
+ }, {
68
+ at: number;
69
+ phase: "connecting" | "waiting_for_app" | "flows_found" | "flow_started" | "flow_finished" | "grading" | "pushed";
70
+ ok?: boolean | undefined;
71
+ name?: string | undefined;
72
+ total?: number | undefined;
73
+ index?: number | undefined;
74
+ }>;
75
+ export type VerifyProgressEvent = z.infer<typeof verifyProgressEventSchema>;
76
+ /** The batch shape a run posts. Batched because one request per flow is a request per flow. */
77
+ export declare const verifyProgressBatchSchema: z.ZodObject<{
78
+ runId: z.ZodString;
79
+ events: z.ZodArray<z.ZodObject<{
80
+ phase: z.ZodEnum<["connecting", "waiting_for_app", "flows_found", "flow_started", "flow_finished", "grading", "pushed"]>;
81
+ /** 0-based position in the suite. Absent on phases that are not about one flow. */
82
+ index: z.ZodOptional<z.ZodNumber>;
83
+ /** How many flows the run will replay. Present from `flows_found` onwards. */
84
+ total: z.ZodOptional<z.ZodNumber>;
85
+ /** The flow being replayed. Absent on phases that are not about one flow. */
86
+ name: z.ZodOptional<z.ZodString>;
87
+ /** Did that flow replay cleanly? A convenience for rendering, never a verdict. */
88
+ ok: z.ZodOptional<z.ZodBoolean>;
89
+ /** When the emitter saw it, from the injected clock — never `Date.now()` in logic. */
90
+ at: z.ZodNumber;
91
+ }, "strip", z.ZodTypeAny, {
92
+ at: number;
93
+ phase: "connecting" | "waiting_for_app" | "flows_found" | "flow_started" | "flow_finished" | "grading" | "pushed";
94
+ ok?: boolean | undefined;
95
+ name?: string | undefined;
96
+ total?: number | undefined;
97
+ index?: number | undefined;
98
+ }, {
99
+ at: number;
100
+ phase: "connecting" | "waiting_for_app" | "flows_found" | "flow_started" | "flow_finished" | "grading" | "pushed";
101
+ ok?: boolean | undefined;
102
+ name?: string | undefined;
103
+ total?: number | undefined;
104
+ index?: number | undefined;
105
+ }>, "many">;
106
+ }, "strip", z.ZodTypeAny, {
107
+ runId: string;
108
+ events: {
109
+ at: number;
110
+ phase: "connecting" | "waiting_for_app" | "flows_found" | "flow_started" | "flow_finished" | "grading" | "pushed";
111
+ ok?: boolean | undefined;
112
+ name?: string | undefined;
113
+ total?: number | undefined;
114
+ index?: number | undefined;
115
+ }[];
116
+ }, {
117
+ runId: string;
118
+ events: {
119
+ at: number;
120
+ phase: "connecting" | "waiting_for_app" | "flows_found" | "flow_started" | "flow_finished" | "grading" | "pushed";
121
+ ok?: boolean | undefined;
122
+ name?: string | undefined;
123
+ total?: number | undefined;
124
+ index?: number | undefined;
125
+ }[];
126
+ }>;
127
+ export type VerifyProgressBatch = z.infer<typeof verifyProgressBatchSchema>;
128
+ /** Truncate a user-supplied flow name to the wire bound, so a caller cannot overflow the schema. */
129
+ export declare const boundFlowName: (name: string) => string;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * What a verification run is DOING, while it is still doing it.
3
+ *
4
+ * A verification takes tens of seconds to minutes and the artifact only exists at the end, so
5
+ * without narration a run that is working and a run that has died look identical for the whole of
6
+ * its duration.
7
+ *
8
+ * These events are DERIVED from work that is already happening, never a second source of truth: the
9
+ * run artifact remains the only record of what was proved, and nothing here is ever graded, stored
10
+ * as evidence, or allowed to influence a verdict.
11
+ *
12
+ * ## The rules that keep it honest
13
+ *
14
+ * - **A reporter must never fail a run.** Emitting is best-effort at every layer; a listener that
15
+ * throws, or a network that is down, changes nothing about the verification or its exit code.
16
+ * - **Progress is not proof.** `flow_finished` carries `ok` so a watcher can colour a row, and
17
+ * that is a convenience for a human reading a list — the verdict is computed from the artifact,
18
+ * which is graded, and never from this.
19
+ * - **`total` is known before the loop starts**, because "step 3" without "of 12" tells a reader
20
+ * nothing about whether to keep waiting, which is the entire question they are asking.
21
+ */
22
+ import { z } from 'zod';
23
+ /** The phases a run passes through, in the order they occur. */
24
+ export const VerifyPhase = {
25
+ /** Opening the bridge connection. Fast, and the first thing that can fail. */
26
+ CONNECTING: 'connecting',
27
+ /** Connected, waiting for the app to attach a session. This is where a dead dev server shows up. */
28
+ WAITING_FOR_APP: 'waiting_for_app',
29
+ /** The suite is known. Carries `total`, which is what makes every later step legible. */
30
+ FLOWS_FOUND: 'flows_found',
31
+ /** One flow is replaying now. Carries its name and index. */
32
+ FLOW_STARTED: 'flow_started',
33
+ /** That flow is done. Carries `ok` — a convenience for a watcher, never a verdict. */
34
+ FLOW_FINISHED: 'flow_finished',
35
+ /** Every flow has run; the artifact is being assembled and graded. */
36
+ GRADING: 'grading',
37
+ /** The run reached the dashboard. The last thing anybody watching is waiting for. */
38
+ PUSHED: 'pushed',
39
+ };
40
+ /**
41
+ * A flow name is user-supplied and unbounded, and this string is rendered in somebody's dashboard.
42
+ * Bounded here rather than at the reader, so no consumer has to remember to truncate it.
43
+ */
44
+ export const VERIFY_PROGRESS_NAME_MAX = 120;
45
+ /** How many events a receiver keeps for one run. A walk nobody can scroll is not more honest. */
46
+ export const VERIFY_PROGRESS_MAX_EVENTS = 200;
47
+ export const verifyProgressEventSchema = z.object({
48
+ phase: z.enum([
49
+ VerifyPhase.CONNECTING,
50
+ VerifyPhase.WAITING_FOR_APP,
51
+ VerifyPhase.FLOWS_FOUND,
52
+ VerifyPhase.FLOW_STARTED,
53
+ VerifyPhase.FLOW_FINISHED,
54
+ VerifyPhase.GRADING,
55
+ VerifyPhase.PUSHED,
56
+ ]),
57
+ /** 0-based position in the suite. Absent on phases that are not about one flow. */
58
+ index: z.number().int().nonnegative().optional(),
59
+ /** How many flows the run will replay. Present from `flows_found` onwards. */
60
+ total: z.number().int().nonnegative().optional(),
61
+ /** The flow being replayed. Absent on phases that are not about one flow. */
62
+ name: z.string().max(VERIFY_PROGRESS_NAME_MAX).optional(),
63
+ /** Did that flow replay cleanly? A convenience for rendering, never a verdict. */
64
+ ok: z.boolean().optional(),
65
+ /** When the emitter saw it, from the injected clock — never `Date.now()` in logic. */
66
+ at: z.number().int().nonnegative(),
67
+ });
68
+ /** The batch shape a run posts. Batched because one request per flow is a request per flow. */
69
+ export const verifyProgressBatchSchema = z.object({
70
+ runId: z.string().min(1).max(200),
71
+ events: z.array(verifyProgressEventSchema).max(VERIFY_PROGRESS_MAX_EVENTS),
72
+ });
73
+ /** Truncate a user-supplied flow name to the wire bound, so a caller cannot overflow the schema. */
74
+ export const boundFlowName = (name) => name.length <= VERIFY_PROGRESS_NAME_MAX ? name : name.slice(0, VERIFY_PROGRESS_NAME_MAX);
@@ -0,0 +1,46 @@
1
+ import { CHANNEL_DEFAULTS, ChannelId, Independence } from 'open-verification';
2
+ import { PredicateKind } from '../verdict/consequence.js';
3
+ /**
4
+ * The sources of truth a verdict can be built from.
5
+ *
6
+ * An implementation declares which of these it can observe. A claim reads one or more of them. Put
7
+ * those two facts together and you can tell, at the moment a connection opens, whether a claim is
8
+ * answerable at all -- rather than finding out after the action has been spent and the moment has
9
+ * passed.
10
+ *
11
+ * That ordering is the whole point. Reticle has a history of discovering a missing observation at
12
+ * assert time and reporting a result that looked like evidence: the assertion could not be answered
13
+ * because nothing was watching, and "nothing was watching" and "it did not happen" produced the same
14
+ * empty answer. Each time, the fix was one more flag on the handshake named for that one case. This
15
+ * is the mechanism those flags were each a hand-made instance of.
16
+ *
17
+ * Names are chosen for what the thing IS, not for what one surface calls it. A browser console, a
18
+ * phone's log stream and a server's stdout are one channel: `log`. A realm that has no console still
19
+ * has somewhere errors go.
20
+ */
21
+ export { ChannelId };
22
+ /** The channels a claim of this kind needs to look at. */
23
+ export declare function channelsRead(kind: PredicateKind): readonly ChannelId[];
24
+ /**
25
+ * The independence rule, and where it lives.
26
+ *
27
+ * It is not defined here. It is defined in `open-verification`, the specification this codebase
28
+ * implements, and re-exported here so the rest of the repository can reach it.
29
+ *
30
+ * That direction is the point. A rule this load-bearing, defined in the product and described in
31
+ * the spec, is two definitions of one contract -- and the two would drift the way every such pair
32
+ * drifts, silently and in the product's favour. Defining it in the protocol and importing it here
33
+ * means an implementation cannot quietly hold a more convenient version of the rule than the one
34
+ * it publishes.
35
+ */
36
+ export { Independence, CHANNEL_DEFAULTS };
37
+ /**
38
+ * May a disagreement between these two channels be reported as a fault?
39
+ *
40
+ * The protocol's rule, reached by channel id rather than by descriptor, because that is the shape
41
+ * every caller here already holds. The judgement itself is not re-implemented -- it is the
42
+ * specification's function, applied to this repository's defaults.
43
+ */
44
+ export declare function disagreementCanConvict(a: ChannelId, b: ChannelId): boolean;
45
+ /** How independent each channel is, in the shape this repository already reads it in. */
46
+ export declare const CHANNEL_INDEPENDENCE: Record<ChannelId, Independence>;