@reticlehq/core 2.10.0 → 2.12.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 (43) hide show
  1. package/dist/constants.d.ts +22 -0
  2. package/dist/constants.js +23 -1
  3. package/dist/document-identity.d.ts +39 -0
  4. package/dist/document-identity.js +53 -0
  5. package/dist/edit-epoch.d.ts +36 -0
  6. package/dist/edit-epoch.js +40 -0
  7. package/dist/event-payloads.d.ts +18 -4
  8. package/dist/event-payloads.js +11 -1
  9. package/dist/findings.d.ts +62 -0
  10. package/dist/findings.js +75 -0
  11. package/dist/flow-types.d.ts +70 -0
  12. package/dist/flow-types.js +22 -0
  13. package/dist/index.d.ts +7 -0
  14. package/dist/index.js +7 -0
  15. package/dist/instrumentation-gap.d.ts +141 -0
  16. package/dist/instrumentation-gap.js +164 -0
  17. package/dist/intent.d.ts +332 -0
  18. package/dist/intent.js +133 -0
  19. package/dist/journal.d.ts +33 -0
  20. package/dist/journal.js +20 -0
  21. package/dist/messages.d.ts +84 -10
  22. package/dist/messages.js +20 -0
  23. package/dist/notices.d.ts +5 -3
  24. package/dist/notices.js +5 -3
  25. package/dist/project-registry.d.ts +86 -0
  26. package/dist/project-registry.js +66 -0
  27. package/dist/run-context.d.ts +122 -0
  28. package/dist/run-context.js +118 -0
  29. package/dist/schema/event-message.json +10 -0
  30. package/dist/schema/event-type.json +1 -0
  31. package/dist/schema/reticle-event.json +10 -0
  32. package/dist/schema/reticle-message.json +10 -0
  33. package/dist/security.js +17 -1
  34. package/dist/source-constants.cjs +9 -0
  35. package/dist/source-constants.d.cts +4 -0
  36. package/dist/telemetry-session.d.ts +2 -2
  37. package/dist/telemetry.d.ts +6 -98
  38. package/dist/telemetry.js +0 -41
  39. package/dist/types.d.ts +70 -0
  40. package/dist/types.js +14 -0
  41. package/dist/unreachable-notice.d.ts +19 -0
  42. package/dist/unreachable-notice.js +26 -0
  43. package/package.json +6 -2
@@ -120,6 +120,14 @@ export declare const FlowExpectSchema: z.ZodObject<{
120
120
  * bare `signal` still parses, and the on-disk version stays FLOW_FILE_VERSION 1.
121
121
  */
122
122
  signalData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
123
+ /**
124
+ * Exact number of times the signal must have fired — the signal-side twin of `net.count`, and the
125
+ * only way a saved flow can keep a cardinality the agent actually asserted. Without it a
126
+ * `count: 1` drive would be recorded as bare presence, which is a strictly WEAKER claim than the
127
+ * one made: the replayed flow then goes green on the double-fire it was recorded to catch.
128
+ * Additive/optional — a flow file with a bare `signal` still parses, and FLOW_FILE_VERSION stays 1.
129
+ */
130
+ signalCount: z.ZodOptional<z.ZodNumber>;
123
131
  net: z.ZodOptional<z.ZodObject<{
124
132
  method: z.ZodOptional<z.ZodString>;
125
133
  urlContains: z.ZodOptional<z.ZodString>;
@@ -200,6 +208,7 @@ export declare const FlowExpectSchema: z.ZodObject<{
200
208
  }, "strip", z.ZodTypeAny, {
201
209
  signal?: string | undefined;
202
210
  signalData?: Record<string, unknown> | undefined;
211
+ signalCount?: number | undefined;
203
212
  net?: {
204
213
  status?: number | undefined;
205
214
  method?: string | undefined;
@@ -224,6 +233,7 @@ export declare const FlowExpectSchema: z.ZodObject<{
224
233
  }, {
225
234
  signal?: string | undefined;
226
235
  signalData?: Record<string, unknown> | undefined;
236
+ signalCount?: number | undefined;
227
237
  net?: {
228
238
  status?: number | undefined;
229
239
  method?: string | undefined;
@@ -446,6 +456,20 @@ export declare const FlowFileSchema: z.ZodObject<{
446
456
  * cannot actually check — flow-classify flags that gap.
447
457
  */
448
458
  intent: z.ZodOptional<z.ZodString>;
459
+ /**
460
+ * The intent-ledger row this flow discharges — the id in `.reticle/intent.json`.
461
+ *
462
+ * `intent` above is the prose a recorder captured; this is the LINK to the ledger that already
463
+ * models declared → bound → proved and records which verdict discharged what. Without it there
464
+ * would be two ways to say what a change is for, which is the defect this codebase keeps paying
465
+ * for: a flow's goal and an intent's statement would drift apart with nothing to reconcile them.
466
+ *
467
+ * Set at save time from the flow's own prose, or written by hand to point a flow at an intent
468
+ * declared earlier via `reticle_intent` — a flow can prove something somebody else declared.
469
+ * Optional + back-compat: a flow without it replays exactly as before, and the on-disk version
470
+ * stays FLOW_FILE_VERSION 1.
471
+ */
472
+ intentId: z.ZodOptional<z.ZodString>;
449
473
  /**
450
474
  * The project the flow was recorded against (the connecting session's HELLO `projectId`), stamped at
451
475
  * save time. Scopes a flow to its app so a shared daemon's HUD lists only the current project's flows
@@ -473,6 +497,14 @@ export declare const FlowFileSchema: z.ZodObject<{
473
497
  * bare `signal` still parses, and the on-disk version stays FLOW_FILE_VERSION 1.
474
498
  */
475
499
  signalData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
500
+ /**
501
+ * Exact number of times the signal must have fired — the signal-side twin of `net.count`, and the
502
+ * only way a saved flow can keep a cardinality the agent actually asserted. Without it a
503
+ * `count: 1` drive would be recorded as bare presence, which is a strictly WEAKER claim than the
504
+ * one made: the replayed flow then goes green on the double-fire it was recorded to catch.
505
+ * Additive/optional — a flow file with a bare `signal` still parses, and FLOW_FILE_VERSION stays 1.
506
+ */
507
+ signalCount: z.ZodOptional<z.ZodNumber>;
476
508
  net: z.ZodOptional<z.ZodObject<{
477
509
  method: z.ZodOptional<z.ZodString>;
478
510
  urlContains: z.ZodOptional<z.ZodString>;
@@ -553,6 +585,7 @@ export declare const FlowFileSchema: z.ZodObject<{
553
585
  }, "strip", z.ZodTypeAny, {
554
586
  signal?: string | undefined;
555
587
  signalData?: Record<string, unknown> | undefined;
588
+ signalCount?: number | undefined;
556
589
  net?: {
557
590
  status?: number | undefined;
558
591
  method?: string | undefined;
@@ -577,6 +610,7 @@ export declare const FlowFileSchema: z.ZodObject<{
577
610
  }, {
578
611
  signal?: string | undefined;
579
612
  signalData?: Record<string, unknown> | undefined;
613
+ signalCount?: number | undefined;
580
614
  net?: {
581
615
  status?: number | undefined;
582
616
  method?: string | undefined;
@@ -702,11 +736,13 @@ export declare const FlowFileSchema: z.ZodObject<{
702
736
  createdAt: number;
703
737
  intent?: string | undefined;
704
738
  projectId?: string | undefined;
739
+ intentId?: string | undefined;
705
740
  startPath?: string | undefined;
706
741
  fixture?: string | undefined;
707
742
  success?: {
708
743
  signal?: string | undefined;
709
744
  signalData?: Record<string, unknown> | undefined;
745
+ signalCount?: number | undefined;
710
746
  net?: {
711
747
  status?: number | undefined;
712
748
  method?: string | undefined;
@@ -762,11 +798,13 @@ export declare const FlowFileSchema: z.ZodObject<{
762
798
  createdAt: number;
763
799
  intent?: string | undefined;
764
800
  projectId?: string | undefined;
801
+ intentId?: string | undefined;
765
802
  startPath?: string | undefined;
766
803
  fixture?: string | undefined;
767
804
  success?: {
768
805
  signal?: string | undefined;
769
806
  signalData?: Record<string, unknown> | undefined;
807
+ signalCount?: number | undefined;
770
808
  net?: {
771
809
  status?: number | undefined;
772
810
  method?: string | undefined;
@@ -835,6 +873,20 @@ export declare const RecordedFlowSchema: z.ZodObject<{
835
873
  * cannot actually check — flow-classify flags that gap.
836
874
  */
837
875
  intent: z.ZodOptional<z.ZodString>;
876
+ /**
877
+ * The intent-ledger row this flow discharges — the id in `.reticle/intent.json`.
878
+ *
879
+ * `intent` above is the prose a recorder captured; this is the LINK to the ledger that already
880
+ * models declared → bound → proved and records which verdict discharged what. Without it there
881
+ * would be two ways to say what a change is for, which is the defect this codebase keeps paying
882
+ * for: a flow's goal and an intent's statement would drift apart with nothing to reconcile them.
883
+ *
884
+ * Set at save time from the flow's own prose, or written by hand to point a flow at an intent
885
+ * declared earlier via `reticle_intent` — a flow can prove something somebody else declared.
886
+ * Optional + back-compat: a flow without it replays exactly as before, and the on-disk version
887
+ * stays FLOW_FILE_VERSION 1.
888
+ */
889
+ intentId: z.ZodOptional<z.ZodString>;
838
890
  /**
839
891
  * The project the flow was recorded against (the connecting session's HELLO `projectId`), stamped at
840
892
  * save time. Scopes a flow to its app so a shared daemon's HUD lists only the current project's flows
@@ -862,6 +914,14 @@ export declare const RecordedFlowSchema: z.ZodObject<{
862
914
  * bare `signal` still parses, and the on-disk version stays FLOW_FILE_VERSION 1.
863
915
  */
864
916
  signalData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
917
+ /**
918
+ * Exact number of times the signal must have fired — the signal-side twin of `net.count`, and the
919
+ * only way a saved flow can keep a cardinality the agent actually asserted. Without it a
920
+ * `count: 1` drive would be recorded as bare presence, which is a strictly WEAKER claim than the
921
+ * one made: the replayed flow then goes green on the double-fire it was recorded to catch.
922
+ * Additive/optional — a flow file with a bare `signal` still parses, and FLOW_FILE_VERSION stays 1.
923
+ */
924
+ signalCount: z.ZodOptional<z.ZodNumber>;
865
925
  net: z.ZodOptional<z.ZodObject<{
866
926
  method: z.ZodOptional<z.ZodString>;
867
927
  urlContains: z.ZodOptional<z.ZodString>;
@@ -942,6 +1002,7 @@ export declare const RecordedFlowSchema: z.ZodObject<{
942
1002
  }, "strip", z.ZodTypeAny, {
943
1003
  signal?: string | undefined;
944
1004
  signalData?: Record<string, unknown> | undefined;
1005
+ signalCount?: number | undefined;
945
1006
  net?: {
946
1007
  status?: number | undefined;
947
1008
  method?: string | undefined;
@@ -966,6 +1027,7 @@ export declare const RecordedFlowSchema: z.ZodObject<{
966
1027
  }, {
967
1028
  signal?: string | undefined;
968
1029
  signalData?: Record<string, unknown> | undefined;
1030
+ signalCount?: number | undefined;
969
1031
  net?: {
970
1032
  status?: number | undefined;
971
1033
  method?: string | undefined;
@@ -1091,11 +1153,13 @@ export declare const RecordedFlowSchema: z.ZodObject<{
1091
1153
  createdAt: number;
1092
1154
  intent?: string | undefined;
1093
1155
  projectId?: string | undefined;
1156
+ intentId?: string | undefined;
1094
1157
  startPath?: string | undefined;
1095
1158
  fixture?: string | undefined;
1096
1159
  success?: {
1097
1160
  signal?: string | undefined;
1098
1161
  signalData?: Record<string, unknown> | undefined;
1162
+ signalCount?: number | undefined;
1099
1163
  net?: {
1100
1164
  status?: number | undefined;
1101
1165
  method?: string | undefined;
@@ -1151,11 +1215,13 @@ export declare const RecordedFlowSchema: z.ZodObject<{
1151
1215
  createdAt: number;
1152
1216
  intent?: string | undefined;
1153
1217
  projectId?: string | undefined;
1218
+ intentId?: string | undefined;
1154
1219
  startPath?: string | undefined;
1155
1220
  fixture?: string | undefined;
1156
1221
  success?: {
1157
1222
  signal?: string | undefined;
1158
1223
  signalData?: Record<string, unknown> | undefined;
1224
+ signalCount?: number | undefined;
1159
1225
  net?: {
1160
1226
  status?: number | undefined;
1161
1227
  method?: string | undefined;
@@ -1213,11 +1279,13 @@ export declare const RecordedFlowSchema: z.ZodObject<{
1213
1279
  createdAt: number;
1214
1280
  intent?: string | undefined;
1215
1281
  projectId?: string | undefined;
1282
+ intentId?: string | undefined;
1216
1283
  startPath?: string | undefined;
1217
1284
  fixture?: string | undefined;
1218
1285
  success?: {
1219
1286
  signal?: string | undefined;
1220
1287
  signalData?: Record<string, unknown> | undefined;
1288
+ signalCount?: number | undefined;
1221
1289
  net?: {
1222
1290
  status?: number | undefined;
1223
1291
  method?: string | undefined;
@@ -1276,11 +1344,13 @@ export declare const RecordedFlowSchema: z.ZodObject<{
1276
1344
  createdAt: number;
1277
1345
  intent?: string | undefined;
1278
1346
  projectId?: string | undefined;
1347
+ intentId?: string | undefined;
1279
1348
  startPath?: string | undefined;
1280
1349
  fixture?: string | undefined;
1281
1350
  success?: {
1282
1351
  signal?: string | undefined;
1283
1352
  signalData?: Record<string, unknown> | undefined;
1353
+ signalCount?: number | undefined;
1284
1354
  net?: {
1285
1355
  status?: number | undefined;
1286
1356
  method?: string | undefined;
@@ -55,6 +55,14 @@ export const FlowExpectSchema = z.object({
55
55
  * bare `signal` still parses, and the on-disk version stays FLOW_FILE_VERSION 1.
56
56
  */
57
57
  signalData: z.record(z.unknown()).optional(),
58
+ /**
59
+ * Exact number of times the signal must have fired — the signal-side twin of `net.count`, and the
60
+ * only way a saved flow can keep a cardinality the agent actually asserted. Without it a
61
+ * `count: 1` drive would be recorded as bare presence, which is a strictly WEAKER claim than the
62
+ * one made: the replayed flow then goes green on the double-fire it was recorded to catch.
63
+ * Additive/optional — a flow file with a bare `signal` still parses, and FLOW_FILE_VERSION stays 1.
64
+ */
65
+ signalCount: z.number().int().nonnegative().optional(),
58
66
  net: z
59
67
  .object({
60
68
  method: z.string().optional(),
@@ -134,6 +142,20 @@ export const FlowFileSchema = z.object({
134
142
  * cannot actually check — flow-classify flags that gap.
135
143
  */
136
144
  intent: z.string().optional(),
145
+ /**
146
+ * The intent-ledger row this flow discharges — the id in `.reticle/intent.json`.
147
+ *
148
+ * `intent` above is the prose a recorder captured; this is the LINK to the ledger that already
149
+ * models declared → bound → proved and records which verdict discharged what. Without it there
150
+ * would be two ways to say what a change is for, which is the defect this codebase keeps paying
151
+ * for: a flow's goal and an intent's statement would drift apart with nothing to reconcile them.
152
+ *
153
+ * Set at save time from the flow's own prose, or written by hand to point a flow at an intent
154
+ * declared earlier via `reticle_intent` — a flow can prove something somebody else declared.
155
+ * Optional + back-compat: a flow without it replays exactly as before, and the on-disk version
156
+ * stays FLOW_FILE_VERSION 1.
157
+ */
158
+ intentId: z.string().optional(),
137
159
  /**
138
160
  * The project the flow was recorded against (the connecting session's HELLO `projectId`), stamped at
139
161
  * save time. Scopes a flow to its app so a shared daemon's HUD lists only the current project's flows
package/dist/index.d.ts CHANGED
@@ -12,6 +12,8 @@ export * from './source-constants.js';
12
12
  export * from './event-classification.js';
13
13
  export * from './verified-constants.js';
14
14
  export * from './session-constants.js';
15
+ export * from './document-identity.js';
16
+ export * from './edit-epoch.js';
15
17
  export * from './messages.js';
16
18
  export * from './event-payloads.js';
17
19
  export * from './event-priority.js';
@@ -28,6 +30,10 @@ export * from './notices.js';
28
30
  export * from './journal.js';
29
31
  export * from './browser-misdirect.js';
30
32
  export * from './daemon-registry.js';
33
+ export * from './project-registry.js';
34
+ export * from './intent.js';
35
+ export * from './run-context.js';
36
+ export * from './instrumentation-gap.js';
31
37
  export * from './security.js';
32
38
  export * from './redaction.js';
33
39
  export * from './state-select.js';
@@ -41,3 +47,4 @@ export * from './impact.js';
41
47
  export * from './impact-savings.js';
42
48
  export { CONTRACT_FINGERPRINT, fnv1a, fingerprintOf } from './contract-fingerprint.js';
43
49
  export { fingerprintFinding, type FindingIdentity } from './finding-fingerprint.js';
50
+ export * from './unreachable-notice.js';
package/dist/index.js CHANGED
@@ -13,6 +13,8 @@ export * from './source-constants.js'; // DATA_RETICLE_SOURCE_ATTR, RETICLE_ROOT
13
13
  export * from './event-classification.js'; // CHURN_TYPES — shared eviction priority for buffer/queue
14
14
  export * from './verified-constants.js'; // Verified — the one field an agent gates on
15
15
  export * from './session-constants.js';
16
+ export * from './document-identity.js'; // which document an observation belongs to
17
+ export * from './edit-epoch.js'; // which round of source edits an observation belongs to
16
18
  export * from './messages.js'; // ReticleEvent + the message schemas
17
19
  export * from './event-payloads.js'; // per-event payload schemas + wire vocab
18
20
  export * from './event-priority.js'; // which events survive the bridge rate cap
@@ -32,6 +34,10 @@ export * from './journal.js';
32
34
  export * from './browser-misdirect.js';
33
35
  // ── INTERNAL cross-package plumbing (shared impl; not a stable outside API — may change in a minor) ─
34
36
  export * from './daemon-registry.js'; // daemon discovery, used by the vite plugin + server
37
+ export * from './project-registry.js'; // projectId -> directory, so a cross-repo daemon can still resolve
38
+ export * from './intent.js'; // what a change was supposed to make true, captured while somebody knows
39
+ export * from './run-context.js'; // what a run established, folded and capped, for the agent to pull back
40
+ export * from './instrumentation-gap.js'; // what Reticle could not see, and the change that would let it
35
41
  export * from './security.js'; // sanitize/serialize helpers shared by browser + server
36
42
  export * from './redaction.js'; // isSensitiveKey / scrubKnownSecrets — the shared redaction rules
37
43
  export * from './state-select.js'; // selectPath / capDepth — shared by browser SDK + server fallback
@@ -45,3 +51,4 @@ export * from './impact.js'; // the user's own record of what Reticle has done f
45
51
  export * from './impact-savings.js'; // the savings model - one file, so every claim is derivable there
46
52
  export { CONTRACT_FINGERPRINT, fnv1a, fingerprintOf } from './contract-fingerprint.js';
47
53
  export { fingerprintFinding } from './finding-fingerprint.js';
54
+ export * from './unreachable-notice.js'; // the page's unreachable warning, as a contract the daemon parses
@@ -0,0 +1,141 @@
1
+ /**
2
+ * What Reticle could not see, and the one change that would let it.
3
+ *
4
+ * Reticle answers "could I see it?" — and answers it honestly: an unobservable channel downgrades a
5
+ * verdict rather than passing it. That is a safety property and it is why a green verdict here means
6
+ * something. What it has never answered is the other half: **what would I need in order to see it?**
7
+ *
8
+ * The difference matters because of who is driving. The decision-maker is an agent, and an agent
9
+ * cannot be relied on to remember to instrument an app — nobody can. But an agent WILL act on a cost
10
+ * it is paying right now, if it is handed the file, the line, and the change. So an absence in the
11
+ * app stops being a silent weakness in the verdict and becomes a piece of work, at the moment the
12
+ * agent is trying to finish.
13
+ *
14
+ * ## The rule that keeps this from becoming noise
15
+ *
16
+ * A gap is reported ONLY when a verdict came back weaker than it would otherwise have been, BECAUSE
17
+ * of an absence in the app. Never as a survey of everything uninstrumented on the page.
18
+ *
19
+ * A gap nobody hit is a backlog, not a finding, and this product does not need another surface
20
+ * producing findings nobody reads. The test for whether a gap belongs here is: *did this absence
21
+ * change the answer the agent just got?* If not, it does not fire.
22
+ */
23
+ /**
24
+ * The kinds of absence that can weaken a verdict. Most name a capability the app did not provide;
25
+ * `UNDECLARED_CHANGE` names one the agent did not, and is here because it costs a verdict the same.
26
+ */
27
+ export declare const InstrumentationGapKind: {
28
+ /**
29
+ * An element was driven and carries no source mapping, so no `file:line` can be reported for it.
30
+ *
31
+ * The cheapest gap to close and the one with the widest blast radius: source mapping is what turns
32
+ * "a control did not react" into "this control, at this line, did not react".
33
+ */
34
+ readonly NO_SOURCE_MAPPING: "no-source-mapping";
35
+ /** A `state` predicate ran and the app registers no store, so the deterministic channel is absent. */
36
+ readonly NO_STORE_REGISTERED: "no-store-registered";
37
+ /**
38
+ * An action changed the DOM and no signal fired for it.
39
+ *
40
+ * The app moved and did not say so, which means the strongest evidence class Reticle has — the app
41
+ * asserting its own success — is unavailable for this action, and every verdict about it has to
42
+ * fall back to inference from the DOM.
43
+ */
44
+ readonly NO_SIGNAL_ON_MUTATION: "no-signal-on-mutation";
45
+ /** The route changed and no route signal fired, so route consequences cannot be asserted. */
46
+ readonly NO_ROUTE_SIGNAL: "no-route-signal";
47
+ /** A control was driven that the declared capability contract does not mention. */
48
+ readonly UNDECLARED_CONTROL: "undeclared-control";
49
+ /**
50
+ * A flow cannot name a control with a stable testid, so the proposal is to add one.
51
+ *
52
+ * Honesty does not emit this on a verdict today — a missing testid is not itself a weaker
53
+ * channel the way a missing signal is. Oracles do, when they can locate the control. It
54
+ * belongs in this vocabulary so `reticle_domain` and a later honesty emit cannot disagree
55
+ * about the name of the same absence.
56
+ */
57
+ readonly MISSING_TESTID: "missing-testid";
58
+ /**
59
+ * Code changed, and this verdict is the first one taken since — with nothing declaring what the
60
+ * change was supposed to make true.
61
+ *
62
+ * The odd one out here, and deliberately so: every other kind names something the APP did not
63
+ * provide, and this one names something the AGENT did not say. It belongs beside them because it
64
+ * has the same effect on a verdict. A change with no declared intent can only be checked against
65
+ * itself, so a green means "nothing visibly broke" and gets read as "the change worked" — which is
66
+ * the definition of a false green, and the one absence no amount of instrumentation can close.
67
+ *
68
+ * It is never derived from the diff, the file name or the test name. A guessed intent reads as the
69
+ * developer's own words and an agent will act on it, which is strictly worse than honest absence.
70
+ */
71
+ readonly UNDECLARED_CHANGE: "undeclared-change";
72
+ /**
73
+ * A verdict PASSED and the ledger still holds intents nothing has proved.
74
+ *
75
+ * The mirror of `UNDECLARED_CHANGE`, and the more expensive half. That one fires when NOTHING was
76
+ * declared; this fires when something was and no verdict ever settled it — which reads identically
77
+ * to done from inside the run, because every verdict the agent drew came back green.
78
+ *
79
+ * Measured on the bench fixture: an agent fixed a form guard, drove the app, and drew SEVEN green
80
+ * verdicts, then reported FIXED. The form still accepted a whitespace-only service. Its closing
81
+ * words quoted its own patch as the evidence — seven verdicts about other things, and a conclusion
82
+ * read off the diff. No rule could see it: the change WAS declared, so `UNDECLARED_CHANGE` stayed
83
+ * silent, and each individual verdict was honestly green.
84
+ *
85
+ * A green does not settle what the run still owes, and only the ledger knows the difference. This
86
+ * is not a failure — the assertion held — so it downgrades nothing; it names the debt on the
87
+ * result the agent is already reading, at the moment it is deciding whether it is finished.
88
+ */
89
+ readonly INTENT_UNDISCHARGED: "intent-undischarged";
90
+ /**
91
+ * A flow was saved and nothing says what it is for.
92
+ *
93
+ * The second kind here that names something the AGENT did not say rather than something the app
94
+ * did not provide, and it costs the same. A saved flow is a regression test that runs for months:
95
+ * when it eventually goes red, the report can name the step that broke and nothing else, so the
96
+ * reader has to reconstruct the goal from the steps before they can judge whether the failure
97
+ * matters. An intent turns that report into a sentence about what stopped being true.
98
+ *
99
+ * Never derived from the flow name, the step names or the assertions, for the reason
100
+ * `UNDECLARED_CHANGE` gives: a guessed goal reads as the author's own words and somebody will act
101
+ * on it. Absence stays honest.
102
+ */
103
+ readonly NO_FLOW_INTENT: "no-flow-intent";
104
+ };
105
+ export type InstrumentationGapKind = (typeof InstrumentationGapKind)[keyof typeof InstrumentationGapKind];
106
+ export interface InstrumentationGap {
107
+ kind: InstrumentationGapKind;
108
+ /** What could not be seen, in the agent's terms. */
109
+ missing: string;
110
+ /** Why it weakened THIS verdict — the cost being paid right now, not a general principle. */
111
+ cost: string;
112
+ /** The single change that would close it. */
113
+ fix: string;
114
+ /** `file:line` when source mapping is present. Absent is itself usually the gap. */
115
+ source?: string;
116
+ /** The control the gap is about, when it is about one. */
117
+ ref?: string;
118
+ }
119
+ /** The one-line remedy for a gap kind. */
120
+ export declare function fixForGap(kind: InstrumentationGapKind): string;
121
+ /**
122
+ * Build a gap, with its remedy attached.
123
+ *
124
+ * `missing` and `cost` are the caller's — only the emit site knows which control, which store, and
125
+ * what the verdict would otherwise have said. `fix` never is.
126
+ */
127
+ export declare function instrumentationGap(kind: InstrumentationGapKind, missing: string, cost: string, detail?: {
128
+ source?: string;
129
+ ref?: string;
130
+ }): InstrumentationGap;
131
+ /**
132
+ * Collapse gaps that say the same thing.
133
+ *
134
+ * An `act_sequence` over eight unmapped controls is ONE missing build plugin, not eight findings. A
135
+ * list that scales with the page rather than with the number of distinct things to fix is the exact
136
+ * shape that trains an agent to stop reading these.
137
+ *
138
+ * Deduped on kind plus the specific thing named, so two different unregistered stores stay two gaps
139
+ * while one store hit twice stays one.
140
+ */
141
+ export declare function dedupeGaps(gaps: readonly InstrumentationGap[]): InstrumentationGap[];
@@ -0,0 +1,164 @@
1
+ /**
2
+ * What Reticle could not see, and the one change that would let it.
3
+ *
4
+ * Reticle answers "could I see it?" — and answers it honestly: an unobservable channel downgrades a
5
+ * verdict rather than passing it. That is a safety property and it is why a green verdict here means
6
+ * something. What it has never answered is the other half: **what would I need in order to see it?**
7
+ *
8
+ * The difference matters because of who is driving. The decision-maker is an agent, and an agent
9
+ * cannot be relied on to remember to instrument an app — nobody can. But an agent WILL act on a cost
10
+ * it is paying right now, if it is handed the file, the line, and the change. So an absence in the
11
+ * app stops being a silent weakness in the verdict and becomes a piece of work, at the moment the
12
+ * agent is trying to finish.
13
+ *
14
+ * ## The rule that keeps this from becoming noise
15
+ *
16
+ * A gap is reported ONLY when a verdict came back weaker than it would otherwise have been, BECAUSE
17
+ * of an absence in the app. Never as a survey of everything uninstrumented on the page.
18
+ *
19
+ * A gap nobody hit is a backlog, not a finding, and this product does not need another surface
20
+ * producing findings nobody reads. The test for whether a gap belongs here is: *did this absence
21
+ * change the answer the agent just got?* If not, it does not fire.
22
+ */
23
+ /**
24
+ * The kinds of absence that can weaken a verdict. Most name a capability the app did not provide;
25
+ * `UNDECLARED_CHANGE` names one the agent did not, and is here because it costs a verdict the same.
26
+ */
27
+ export const InstrumentationGapKind = {
28
+ /**
29
+ * An element was driven and carries no source mapping, so no `file:line` can be reported for it.
30
+ *
31
+ * The cheapest gap to close and the one with the widest blast radius: source mapping is what turns
32
+ * "a control did not react" into "this control, at this line, did not react".
33
+ */
34
+ NO_SOURCE_MAPPING: 'no-source-mapping',
35
+ /** A `state` predicate ran and the app registers no store, so the deterministic channel is absent. */
36
+ NO_STORE_REGISTERED: 'no-store-registered',
37
+ /**
38
+ * An action changed the DOM and no signal fired for it.
39
+ *
40
+ * The app moved and did not say so, which means the strongest evidence class Reticle has — the app
41
+ * asserting its own success — is unavailable for this action, and every verdict about it has to
42
+ * fall back to inference from the DOM.
43
+ */
44
+ NO_SIGNAL_ON_MUTATION: 'no-signal-on-mutation',
45
+ /** The route changed and no route signal fired, so route consequences cannot be asserted. */
46
+ NO_ROUTE_SIGNAL: 'no-route-signal',
47
+ /** A control was driven that the declared capability contract does not mention. */
48
+ UNDECLARED_CONTROL: 'undeclared-control',
49
+ /**
50
+ * A flow cannot name a control with a stable testid, so the proposal is to add one.
51
+ *
52
+ * Honesty does not emit this on a verdict today — a missing testid is not itself a weaker
53
+ * channel the way a missing signal is. Oracles do, when they can locate the control. It
54
+ * belongs in this vocabulary so `reticle_domain` and a later honesty emit cannot disagree
55
+ * about the name of the same absence.
56
+ */
57
+ MISSING_TESTID: 'missing-testid',
58
+ /**
59
+ * Code changed, and this verdict is the first one taken since — with nothing declaring what the
60
+ * change was supposed to make true.
61
+ *
62
+ * The odd one out here, and deliberately so: every other kind names something the APP did not
63
+ * provide, and this one names something the AGENT did not say. It belongs beside them because it
64
+ * has the same effect on a verdict. A change with no declared intent can only be checked against
65
+ * itself, so a green means "nothing visibly broke" and gets read as "the change worked" — which is
66
+ * the definition of a false green, and the one absence no amount of instrumentation can close.
67
+ *
68
+ * It is never derived from the diff, the file name or the test name. A guessed intent reads as the
69
+ * developer's own words and an agent will act on it, which is strictly worse than honest absence.
70
+ */
71
+ UNDECLARED_CHANGE: 'undeclared-change',
72
+ /**
73
+ * A verdict PASSED and the ledger still holds intents nothing has proved.
74
+ *
75
+ * The mirror of `UNDECLARED_CHANGE`, and the more expensive half. That one fires when NOTHING was
76
+ * declared; this fires when something was and no verdict ever settled it — which reads identically
77
+ * to done from inside the run, because every verdict the agent drew came back green.
78
+ *
79
+ * Measured on the bench fixture: an agent fixed a form guard, drove the app, and drew SEVEN green
80
+ * verdicts, then reported FIXED. The form still accepted a whitespace-only service. Its closing
81
+ * words quoted its own patch as the evidence — seven verdicts about other things, and a conclusion
82
+ * read off the diff. No rule could see it: the change WAS declared, so `UNDECLARED_CHANGE` stayed
83
+ * silent, and each individual verdict was honestly green.
84
+ *
85
+ * A green does not settle what the run still owes, and only the ledger knows the difference. This
86
+ * is not a failure — the assertion held — so it downgrades nothing; it names the debt on the
87
+ * result the agent is already reading, at the moment it is deciding whether it is finished.
88
+ */
89
+ INTENT_UNDISCHARGED: 'intent-undischarged',
90
+ /**
91
+ * A flow was saved and nothing says what it is for.
92
+ *
93
+ * The second kind here that names something the AGENT did not say rather than something the app
94
+ * did not provide, and it costs the same. A saved flow is a regression test that runs for months:
95
+ * when it eventually goes red, the report can name the step that broke and nothing else, so the
96
+ * reader has to reconstruct the goal from the steps before they can judge whether the failure
97
+ * matters. An intent turns that report into a sentence about what stopped being true.
98
+ *
99
+ * Never derived from the flow name, the step names or the assertions, for the reason
100
+ * `UNDECLARED_CHANGE` gives: a guessed goal reads as the author's own words and somebody will act
101
+ * on it. Absence stays honest.
102
+ */
103
+ NO_FLOW_INTENT: 'no-flow-intent',
104
+ };
105
+ /**
106
+ * The remedy for a kind, as one line an agent can act on without reading a doc.
107
+ *
108
+ * Held here rather than at each emit site so that a kind cannot be reported with a fix that has
109
+ * drifted from it — the same reason `tierOfFinding` derives from the kind in one place. An emit site
110
+ * supplies the specifics (which ref, which store); the vocabulary supplies the remedy.
111
+ */
112
+ const GAP_FIX = {
113
+ [InstrumentationGapKind.NO_SOURCE_MAPPING]: 'add the Reticle build plugin (@reticlehq/vite-plugin, @reticlehq/next, or the babel plugin) so elements carry data-reticle-source',
114
+ [InstrumentationGapKind.NO_STORE_REGISTERED]: 'register the store with reticle.registerStore(name, getState) so state can be read directly instead of inferred from the DOM',
115
+ [InstrumentationGapKind.NO_SIGNAL_ON_MUTATION]: 'fire reticle.signal(name, data) where this state is committed — commitAndSignal binds the two so they cannot drift',
116
+ [InstrumentationGapKind.NO_ROUTE_SIGNAL]: 'let the Reticle router adapter observe navigation, or fire reticle.signal on route commit',
117
+ [InstrumentationGapKind.UNDECLARED_CONTROL]: 'add this control to reticle.describe() so the capability contract matches what the app actually exposes',
118
+ [InstrumentationGapKind.MISSING_TESTID]: 'add data-testid="..." on this control so the flow can name it after a refactor',
119
+ [InstrumentationGapKind.UNDECLARED_CHANGE]: 'declare it with reticle_intent { action: "declare", intents: [{ id, statement }] } — the statement is prose, in your own words: which user does what, and what should become true',
120
+ [InstrumentationGapKind.INTENT_UNDISCHARGED]: 'draw a verdict whose `until` asserts the intent itself, then it discharges — or call reticle_run({ tool: "reticle_context" }) to see exactly what is still owed',
121
+ [InstrumentationGapKind.NO_FLOW_INTENT]: 'save it again with intent: "<which user does what, and what should become true>" — prose, in your own words — or set intentId to an intent already in the ledger',
122
+ };
123
+ /** The one-line remedy for a gap kind. */
124
+ export function fixForGap(kind) {
125
+ return GAP_FIX[kind];
126
+ }
127
+ /**
128
+ * Build a gap, with its remedy attached.
129
+ *
130
+ * `missing` and `cost` are the caller's — only the emit site knows which control, which store, and
131
+ * what the verdict would otherwise have said. `fix` never is.
132
+ */
133
+ export function instrumentationGap(kind, missing, cost, detail) {
134
+ return {
135
+ kind,
136
+ missing,
137
+ cost,
138
+ fix: fixForGap(kind),
139
+ ...(detail?.source === undefined ? {} : { source: detail.source }),
140
+ ...(detail?.ref === undefined ? {} : { ref: detail.ref }),
141
+ };
142
+ }
143
+ /**
144
+ * Collapse gaps that say the same thing.
145
+ *
146
+ * An `act_sequence` over eight unmapped controls is ONE missing build plugin, not eight findings. A
147
+ * list that scales with the page rather than with the number of distinct things to fix is the exact
148
+ * shape that trains an agent to stop reading these.
149
+ *
150
+ * Deduped on kind plus the specific thing named, so two different unregistered stores stay two gaps
151
+ * while one store hit twice stays one.
152
+ */
153
+ export function dedupeGaps(gaps) {
154
+ const seen = new Set();
155
+ const out = [];
156
+ for (const gap of gaps) {
157
+ const key = `${gap.kind}${gap.missing}`;
158
+ if (seen.has(key))
159
+ continue;
160
+ seen.add(key);
161
+ out.push(gap);
162
+ }
163
+ return out;
164
+ }