@reticlehq/engine 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.
- package/LICENSE +202 -0
- package/README.md +36 -0
- package/dist/disagreement/body-failures.d.ts +4 -0
- package/dist/disagreement/body-failures.js +113 -0
- package/dist/disagreement/contradiction-evidence.d.ts +122 -0
- package/dist/disagreement/contradiction-evidence.js +194 -0
- package/dist/disagreement/contradiction-folds.d.ts +61 -0
- package/dist/disagreement/contradiction-folds.js +71 -0
- package/dist/disagreement/contradiction-types.d.ts +164 -0
- package/dist/disagreement/contradiction-types.js +1 -0
- package/dist/disagreement/contradictions.d.ts +5 -0
- package/dist/disagreement/contradictions.js +613 -0
- package/dist/disagreement/echo-mismatch.d.ts +10 -0
- package/dist/disagreement/echo-mismatch.js +299 -0
- package/dist/disagreement/reconcile.d.ts +39 -0
- package/dist/disagreement/reconcile.js +211 -0
- package/dist/disagreement/stale-response.d.ts +3 -0
- package/dist/disagreement/stale-response.js +186 -0
- package/dist/disagreement/unit-mismatch.d.ts +16 -0
- package/dist/disagreement/unit-mismatch.js +167 -0
- package/dist/disagreement/witness-disagreement.d.ts +42 -0
- package/dist/disagreement/witness-disagreement.js +43 -0
- package/dist/evidence/accepted-write.d.ts +35 -0
- package/dist/evidence/accepted-write.js +54 -0
- package/dist/evidence/already-true.d.ts +16 -0
- package/dist/evidence/already-true.js +89 -0
- package/dist/evidence/blind-spots.d.ts +133 -0
- package/dist/evidence/blind-spots.js +253 -0
- package/dist/evidence/body-capture-remedy.d.ts +42 -0
- package/dist/evidence/body-capture-remedy.js +96 -0
- package/dist/evidence/gap-ledger.d.ts +52 -0
- package/dist/evidence/gap-ledger.js +63 -0
- package/dist/evidence/honesty.d.ts +113 -0
- package/dist/evidence/honesty.js +105 -0
- package/dist/evidence/instrumentation-gaps.d.ts +91 -0
- package/dist/evidence/instrumentation-gaps.js +102 -0
- package/dist/evidence/learned-guards.d.ts +75 -0
- package/dist/evidence/learned-guards.js +78 -0
- package/dist/evidence/observability.d.ts +38 -0
- package/dist/evidence/observability.js +40 -0
- package/dist/evidence/page-teardown.d.ts +15 -0
- package/dist/evidence/page-teardown.js +17 -0
- package/dist/evidence/step-effect.d.ts +41 -0
- package/dist/evidence/step-effect.js +27 -0
- package/dist/evidence/uncaptured-bodies.d.ts +23 -0
- package/dist/evidence/uncaptured-bodies.js +41 -0
- package/dist/evidence/undeclared-change.d.ts +51 -0
- package/dist/evidence/undeclared-change.js +56 -0
- package/dist/evidence/unread-outcome.d.ts +10 -0
- package/dist/evidence/unread-outcome.js +77 -0
- package/dist/evidence/unsettled.d.ts +58 -0
- package/dist/evidence/unsettled.js +127 -0
- package/dist/evidence/verdict-intent-gap.d.ts +30 -0
- package/dist/evidence/verdict-intent-gap.js +35 -0
- package/dist/evidence/verified.d.ts +158 -0
- package/dist/evidence/verified.js +378 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +25 -0
- package/dist/question/declared.d.ts +74 -0
- package/dist/question/declared.js +171 -0
- package/dist/question/lineage.d.ts +52 -0
- package/dist/question/lineage.js +122 -0
- package/dist/question/predicate/net-evidence.d.ts +21 -0
- package/dist/question/predicate/net-evidence.js +81 -0
- package/dist/question/predicate/observed-in-window.d.ts +24 -0
- package/dist/question/predicate/observed-in-window.js +38 -0
- package/dist/question/predicate/predicate-asks.d.ts +28 -0
- package/dist/question/predicate/predicate-asks.js +46 -0
- package/dist/question/predicate/predicate-console.d.ts +13 -0
- package/dist/question/predicate/predicate-console.js +138 -0
- package/dist/question/predicate/predicate-element.d.ts +13 -0
- package/dist/question/predicate/predicate-element.js +214 -0
- package/dist/question/predicate/predicate-eval-kit.d.ts +90 -0
- package/dist/question/predicate/predicate-eval-kit.js +126 -0
- package/dist/question/predicate/predicate-eval.d.ts +24 -0
- package/dist/question/predicate/predicate-eval.js +710 -0
- package/dist/question/predicate/predicate-parse.d.ts +15 -0
- package/dist/question/predicate/predicate-parse.js +173 -0
- package/dist/question/predicate/predicate-precheck.d.ts +8 -0
- package/dist/question/predicate/predicate-precheck.js +41 -0
- package/dist/question/predicate/predicate-request-body.d.ts +50 -0
- package/dist/question/predicate/predicate-request-body.js +120 -0
- package/dist/question/predicate/predicate-route.d.ts +66 -0
- package/dist/question/predicate/predicate-route.js +293 -0
- package/dist/question/predicate/predicate-schema.d.ts +170 -0
- package/dist/question/predicate/predicate-schema.js +509 -0
- package/dist/question/predicate/predicate-session.d.ts +72 -0
- package/dist/question/predicate/predicate-session.js +1 -0
- package/dist/question/predicate/predicate-to-links.d.ts +13 -0
- package/dist/question/predicate/predicate-to-links.js +38 -0
- package/dist/question/predicate/predicate.d.ts +26 -0
- package/dist/question/predicate/predicate.js +785 -0
- package/dist/question/predicate/property.d.ts +102 -0
- package/dist/question/predicate/property.js +135 -0
- package/dist/question/predicate/split-text-miss.d.ts +32 -0
- package/dist/question/predicate/split-text-miss.js +51 -0
- package/dist/question/predicate/testid-near-miss.d.ts +22 -0
- package/dist/question/predicate/testid-near-miss.js +33 -0
- package/dist/question/reaction.d.ts +17 -0
- package/dist/question/reaction.js +67 -0
- package/dist/window/adversary.d.ts +28 -0
- package/dist/window/adversary.js +90 -0
- package/dist/window/ambient.d.ts +63 -0
- package/dist/window/ambient.js +76 -0
- package/dist/window/appearance-budget.d.ts +41 -0
- package/dist/window/appearance-budget.js +47 -0
- package/dist/window/asset-noise.d.ts +42 -0
- package/dist/window/asset-noise.js +35 -0
- package/dist/window/body-relevance.d.ts +54 -0
- package/dist/window/body-relevance.js +78 -0
- package/dist/window/byte-size.d.ts +1 -0
- package/dist/window/byte-size.js +16 -0
- package/dist/window/engine-host.d.ts +35 -0
- package/dist/window/engine-host.js +20 -0
- package/dist/window/event-filters.d.ts +121 -0
- package/dist/window/event-filters.js +215 -0
- package/dist/window/json-salvage.d.ts +33 -0
- package/dist/window/json-salvage.js +96 -0
- package/dist/window/network-detail-merge.d.ts +8 -0
- package/dist/window/network-detail-merge.js +89 -0
- package/dist/window/ring-buffer.d.ts +41 -0
- package/dist/window/ring-buffer.js +152 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Reticle Labs
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @reticlehq/engine
|
|
2
|
+
|
|
3
|
+
The rules that decide a verdict.
|
|
4
|
+
|
|
5
|
+
Give it what happened in a running app — the clicks, the network calls, the state changes, the console — and a statement about what should have followed, and it answers whether that statement held. That is all it does. There is no browser here, no server, no command line and no storage.
|
|
6
|
+
|
|
7
|
+
## Why it is on its own
|
|
8
|
+
|
|
9
|
+
Reticle's whole claim is that a verdict means something. The part that makes that claim is small and depends on almost nothing, so it should be possible to take it without taking a daemon you did not ask for. Somebody implementing the [OpenVerification](../open-verification) specification for a different kind of environment — a phone, a game, a terminal — needs these rules and none of the machinery around them.
|
|
10
|
+
|
|
11
|
+
## What is inside
|
|
12
|
+
|
|
13
|
+
- **`events/`** — reading a window of what happened and answering a question about it. Did the request go out? Did the page settle? Did anything contradict anything else?
|
|
14
|
+
- **`honesty/`** — the checks on the answer itself. Was the evidence good enough to say yes? Did we watch the same channel we acted on, which would prove nothing? Is "unknown" the honest answer?
|
|
15
|
+
|
|
16
|
+
## The four answers
|
|
17
|
+
|
|
18
|
+
A verdict is one of four things, and the last two matter as much as the first two:
|
|
19
|
+
|
|
20
|
+
| Answer | What it means |
|
|
21
|
+
| ---------- | --------------------------------------------------------------------------------- |
|
|
22
|
+
| `yes` | The declared consequence happened, and the evidence is independent of the action. |
|
|
23
|
+
| `no` | It did not happen. |
|
|
24
|
+
| `unknown` | Nobody could tell. The evidence was missing, stale, or came from the wrong place. |
|
|
25
|
+
| `no-fault` | Nothing was declared, so there was nothing to prove. |
|
|
26
|
+
|
|
27
|
+
`unknown` is a real answer, not a rounding error. A tool that turns "I could not see" into "yes" is worse than no tool, because it costs you the one thing you came for.
|
|
28
|
+
|
|
29
|
+
## What it needs from you
|
|
30
|
+
|
|
31
|
+
Two things, and both are optional:
|
|
32
|
+
|
|
33
|
+
- somewhere to **write down** a rule that could not be run at all
|
|
34
|
+
- a way to **keep a re-check attached** to the call that asked for it
|
|
35
|
+
|
|
36
|
+
Leave them out and the rules still work — you lose a log line, never a verdict. You hand them in on the object you pass; the rules never go looking. See `window/engine-host.ts`.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ReticleEvent } from '@reticlehq/core';
|
|
2
|
+
import type { OwnContradiction } from './contradiction-types.js';
|
|
3
|
+
/** Contradictions for 2xx responses whose bodies report failure. One per offending call. */
|
|
4
|
+
export declare function findBodyFailures(events: readonly ReticleEvent[]): OwnContradiction[];
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { ContradictionKind, EventType } from '@reticlehq/core';
|
|
2
|
+
/**
|
|
3
|
+
* A request that returned 2xx and reported failure INSIDE its body.
|
|
4
|
+
*
|
|
5
|
+
* The status line is not the outcome. Three shapes make this routine rather than exotic:
|
|
6
|
+
*
|
|
7
|
+
* - **GraphQL** answers HTTP 200 for every error it has ever produced. `errors: [...]` in a 200 body
|
|
8
|
+
* is the normal way a GraphQL request fails, so any verdict that reads only the status is blind to
|
|
9
|
+
* the entire error surface of an entire ecosystem.
|
|
10
|
+
* - **Bulk endpoints** answer 200 for the batch and put per-item results in the body. Measured on a
|
|
11
|
+
* shipments console: `POST /api/bulk-hold` → 200, banner reads "9 shipments held", and three of
|
|
12
|
+
* the nine carry `{"ok": false, "error": "carrier_locked"}`. Reticle had that body in hand and
|
|
13
|
+
* reported `verified: "yes"`.
|
|
14
|
+
* - **Envelope APIs** answer 200 with `{"success": false}` — common wherever a gateway normalises
|
|
15
|
+
* status codes.
|
|
16
|
+
*
|
|
17
|
+
* Every channel above the body agrees with the lie: the request succeeded, the UI advanced, the page
|
|
18
|
+
* settled, nothing 5xx'd. Only the payload disagrees, which is why this needs body capture — and why
|
|
19
|
+
* an agent reading a status column can never catch it.
|
|
20
|
+
*/
|
|
21
|
+
/** Keys whose truthiness means "this failed". Checked at the top level and per item. */
|
|
22
|
+
const FAILURE_FLAGS = ['ok', 'success', 'succeeded'];
|
|
23
|
+
/** Keys that, when carrying content, name a failure. */
|
|
24
|
+
const ERROR_KEYS = ['error', 'errors', 'errorMessage', 'failureReason'];
|
|
25
|
+
/** Arrays worth walking for per-item outcomes. Bulk APIs converge on a handful of names. */
|
|
26
|
+
const ITEM_KEYS = ['results', 'items', 'data', 'records', 'responses'];
|
|
27
|
+
function isRecord(value) {
|
|
28
|
+
return 'object' === typeof value && value !== null && !Array.isArray(value);
|
|
29
|
+
}
|
|
30
|
+
/** Whether one object reports a failure of its own. */
|
|
31
|
+
function reportsFailure(item) {
|
|
32
|
+
if (!isRecord(item))
|
|
33
|
+
return false;
|
|
34
|
+
for (const flag of FAILURE_FLAGS) {
|
|
35
|
+
if (false === item[flag])
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
for (const key of ERROR_KEYS) {
|
|
39
|
+
const value = item[key];
|
|
40
|
+
if (value === undefined || null === value)
|
|
41
|
+
continue;
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
if (value.length > 0)
|
|
44
|
+
return true;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
// An empty string or an explicit null is an API saying "no error", not an error.
|
|
48
|
+
if ('string' === typeof value && 0 === value.length)
|
|
49
|
+
continue;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
/** Failed / total across the first item array found. Zero total when the body is not a batch. */
|
|
55
|
+
function itemOutcomes(body) {
|
|
56
|
+
for (const key of ITEM_KEYS) {
|
|
57
|
+
const list = body[key];
|
|
58
|
+
if (!Array.isArray(list) || 0 === list.length)
|
|
59
|
+
continue;
|
|
60
|
+
const failed = list.filter(reportsFailure).length;
|
|
61
|
+
return { failed, total: list.length };
|
|
62
|
+
}
|
|
63
|
+
return { failed: 0, total: 0 };
|
|
64
|
+
}
|
|
65
|
+
function parse(raw) {
|
|
66
|
+
if (typeof raw !== 'string' || 0 === raw.length)
|
|
67
|
+
return undefined;
|
|
68
|
+
try {
|
|
69
|
+
const parsed = JSON.parse(raw);
|
|
70
|
+
return isRecord(parsed) ? parsed : undefined;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return undefined; // not JSON — nothing to read, and guessing at prose would invent findings
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const OK_MIN = 200;
|
|
77
|
+
const OK_MAX = 300;
|
|
78
|
+
/** Contradictions for 2xx responses whose bodies report failure. One per offending call. */
|
|
79
|
+
export function findBodyFailures(events) {
|
|
80
|
+
const found = [];
|
|
81
|
+
for (const event of events) {
|
|
82
|
+
if (event.type !== EventType.NET_REQUEST)
|
|
83
|
+
continue;
|
|
84
|
+
const status = event.data['status'];
|
|
85
|
+
if (typeof status !== 'number' || status < OK_MIN || status >= OK_MAX)
|
|
86
|
+
continue;
|
|
87
|
+
const body = parse(event.data['responseBody']);
|
|
88
|
+
if (body === undefined)
|
|
89
|
+
continue;
|
|
90
|
+
const url = 'string' === typeof event.data['url'] ? event.data['url'] : '';
|
|
91
|
+
const method = 'string' === typeof event.data['method'] ? event.data['method'] : '';
|
|
92
|
+
const where = `${method} ${url} → ${String(status)}`;
|
|
93
|
+
const { failed, total } = itemOutcomes(body);
|
|
94
|
+
if (failed > 0) {
|
|
95
|
+
found.push({
|
|
96
|
+
kind: ContradictionKind.PARTIAL_FAILURE_IN_OK_RESPONSE,
|
|
97
|
+
claim: `the request returned ${String(status)} and the page treated it as done`,
|
|
98
|
+
counter: `its body reports ${String(failed)} of ${String(total)} items FAILED`,
|
|
99
|
+
detail: `${where} — a batch endpoint's status describes the BATCH, not the items; whatever the UI says it did, ${String(failed)} of them did not happen`,
|
|
100
|
+
});
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (reportsFailure(body)) {
|
|
104
|
+
found.push({
|
|
105
|
+
kind: ContradictionKind.PARTIAL_FAILURE_IN_OK_RESPONSE,
|
|
106
|
+
claim: `the request returned ${String(status)} and the page treated it as done`,
|
|
107
|
+
counter: 'its body reports the operation FAILED',
|
|
108
|
+
detail: `${where} — the status line and the payload disagree; the payload is the outcome (a GraphQL error is always a 200)`,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return found;
|
|
113
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a request IS, which requests are OURS, and how to say one out loud.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `contradictions.ts` when that file crossed the line cap — and the seam was already
|
|
5
|
+
* there rather than invented for the occasion. Everything here answers a question ABOUT NETWORK
|
|
6
|
+
* EVIDENCE: what did this event mean, was it a write, did a retry rescue it, is it the toolchain's
|
|
7
|
+
* own traffic rather than the app's, is this cadence a poll. Nothing here knows what a
|
|
8
|
+
* contradiction is.
|
|
9
|
+
*
|
|
10
|
+
* The rules next door read this vocabulary and decide what disagrees. Keeping the two apart means a
|
|
11
|
+
* new rule cannot quietly redefine what "in flight" or "ours" means for itself, which is how two
|
|
12
|
+
* rules end up disagreeing about the same window.
|
|
13
|
+
*/
|
|
14
|
+
import { EventType, type ReticleEvent } from '@reticlehq/core';
|
|
15
|
+
export interface NetCall {
|
|
16
|
+
method: string;
|
|
17
|
+
url: string;
|
|
18
|
+
/** Grader haystack — the raw request when redaction rewrote `url`. */
|
|
19
|
+
matchUrl: string;
|
|
20
|
+
status: number | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* `undefined` means NO VERDICT — not failure.
|
|
23
|
+
*
|
|
24
|
+
* A one-way IPC `send` hands the message to the main process and returns; the renderer never learns
|
|
25
|
+
* whether it was handled. The observer deliberately omits both `ok` and `status` rather than
|
|
26
|
+
* manufacture a success nobody reported. Collapsing that to `false` here manufactured a FAILURE
|
|
27
|
+
* nobody reported instead, which is the same sin pointing the other way: every fire-and-forget send
|
|
28
|
+
* raised `ui-advanced-request-failed` against a UI that had done nothing wrong.
|
|
29
|
+
*/
|
|
30
|
+
ok: boolean | undefined;
|
|
31
|
+
}
|
|
32
|
+
export declare function netCall(e: ReticleEvent): NetCall;
|
|
33
|
+
/**
|
|
34
|
+
* The failed calls that a LATER successful call to the same endpoint replaced.
|
|
35
|
+
*
|
|
36
|
+
* Identity, not index: each `netCall` is a fresh object held by `settled`, and `settled` is built
|
|
37
|
+
* from events in sequence order, so "later" is simply "further along the array". Compared on
|
|
38
|
+
* `matchUrl` so a cache-buster or a changing query token cannot make a retry look like a different
|
|
39
|
+
* call — the same normalisation every other url comparison here uses.
|
|
40
|
+
*/
|
|
41
|
+
export declare function recoveredByRetry(settled: readonly NetCall[]): ReadonlySet<NetCall>;
|
|
42
|
+
/**
|
|
43
|
+
* Did the user-visible application state move forward? DOM, store and route only — deliberately NOT
|
|
44
|
+
* network, animation or signal. The question every rule below asks is "did the app act as if it
|
|
45
|
+
* succeeded", and a request firing is not the app acting as if anything.
|
|
46
|
+
*/
|
|
47
|
+
export declare function isMutating(call: NetCall): boolean;
|
|
48
|
+
export declare function describe(call: NetCall): string;
|
|
49
|
+
/**
|
|
50
|
+
* Actions that are SUPPOSED to make something happen, so producing nothing is a finding.
|
|
51
|
+
*
|
|
52
|
+
* Deliberately narrow. `hover`, `focus` and `scrollIntoView` can legitimately move nothing, and
|
|
53
|
+
* `fill`/`type` change an input's value without necessarily mutating the DOM tree — flagging those
|
|
54
|
+
* would manufacture noise, which is the failure mode opposite to a false green and just as bad.
|
|
55
|
+
*/
|
|
56
|
+
export declare const NET_TYPES: ReadonlySet<EventType>;
|
|
57
|
+
/**
|
|
58
|
+
* Hash-router paths put the route in the fragment (`#/settings`, `#!/home`). An in-page skip link
|
|
59
|
+
* does not (`#main-content`, `#`, empty). The blank-destination rule must still see the former.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isInPageFragment(hash: string): boolean;
|
|
62
|
+
export declare function hrefAsUrl(value: string | undefined): URL | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Same origin + pathname + search, different in-page fragment — a skip link, not a new view.
|
|
65
|
+
*
|
|
66
|
+
* Returns false when `from`/`to` are missing, so older events without hrefs keep the existing rule.
|
|
67
|
+
*/
|
|
68
|
+
export declare function isSameDocumentHashAnchor(event: ReticleEvent): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Split the window into the app's traffic and the dev toolchain's own (see `DevToolingChannel`).
|
|
71
|
+
*
|
|
72
|
+
* NOTHING below may judge the toolchain. Reported from a real drive: a correct Next.js navigation
|
|
73
|
+
* graded `verified: "no"` because the dev overlay was resolving a source map for an unrelated React
|
|
74
|
+
* key warning, and that in-flight `POST /__nextjs_original-stack-frames` read as "the UI advanced
|
|
75
|
+
* over a request that never settled". Every app that logs one dev warning got a false negative on
|
|
76
|
+
* every action. The overlay's own 404s and duplicate fetches are the same story on other checks,
|
|
77
|
+
* which is why the split happens ONCE here rather than in the one check that reported it.
|
|
78
|
+
*/
|
|
79
|
+
export declare function splitForeignTraffic(events: readonly ReticleEvent[], appOrigin: string | undefined): {
|
|
80
|
+
app: readonly ReticleEvent[];
|
|
81
|
+
ignored: string[];
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Cross-channel contradictions in this window, with the edit-epoch caveat attached when it applies.
|
|
85
|
+
*
|
|
86
|
+
* Cross-epoch evidence is LABELLED rather than excluded, which is the opposite of what the document
|
|
87
|
+
* scoping does, and the difference is the point. A navigation is total — it throws away the page,
|
|
88
|
+
* the refs, the in-flight requests and the state — so nothing recorded before it is still about the
|
|
89
|
+
* world, and dropping it is the only honest option. A hot update is not: most modules, most of the
|
|
90
|
+
* DOM, the whole network log and every console line survive one, so most of what was observed a
|
|
91
|
+
* second before an edit is still true a second after. Excluding it would empty windows that hold
|
|
92
|
+
* real findings, and an emptied window reads as "nothing happened" — which is the more expensive of
|
|
93
|
+
* the two wrong answers and the one this whole family of checks exists to prevent.
|
|
94
|
+
*
|
|
95
|
+
* So the findings stand and the caveat is said out loud, and only when it is unambiguous: EVERY
|
|
96
|
+
* observation in the window predates the edit. One post-edit observation and the agent is already
|
|
97
|
+
* looking at the code it wrote, so the label would be noise.
|
|
98
|
+
*/
|
|
99
|
+
/**
|
|
100
|
+
* Below this, repeated writes are a BURST, whatever their spacing.
|
|
101
|
+
*
|
|
102
|
+
* A double submit is two clicks, or one click and a re-render: milliseconds apart. Nothing a human
|
|
103
|
+
* or a StrictMode remount does lands on a quarter-second grid, so this is the floor under which
|
|
104
|
+
* regularity means nothing.
|
|
105
|
+
*/
|
|
106
|
+
export declare const POLL_MIN_INTERVAL_MS = 250;
|
|
107
|
+
/**
|
|
108
|
+
* How far a gap may sit from the median and still count as the same cadence.
|
|
109
|
+
*
|
|
110
|
+
* Loose on purpose: a real poll drifts under load, and a `setInterval` competing with a busy main
|
|
111
|
+
* thread is not metronomic. Tight enough that a burst followed by a late retry — the shape a double
|
|
112
|
+
* submit plus a user's second attempt makes — is not read as a rhythm.
|
|
113
|
+
*/
|
|
114
|
+
export declare const POLL_JITTER_RATIO = 0.4;
|
|
115
|
+
/**
|
|
116
|
+
* Is this the same write on a steady interval, rather than the same write twice?
|
|
117
|
+
*
|
|
118
|
+
* THREE samples minimum, and that is the load-bearing part: two writes give one gap, and a single
|
|
119
|
+
* gap cannot distinguish a cadence from a coincidence. Two writes stay a duplicate however far
|
|
120
|
+
* apart they are, which is the classic double submit and every case this rule was written for.
|
|
121
|
+
*/
|
|
122
|
+
export declare function isSteadyCadence(times: readonly number[]): boolean;
|