@descryy/mcp 0.1.2 → 0.3.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 (207) hide show
  1. package/dist/bin/descry-mcp.js +30 -2
  2. package/dist/bin/descry-mcp.js.map +1 -1
  3. package/dist/browser/driver.d.ts +236 -0
  4. package/dist/browser/driver.d.ts.map +1 -0
  5. package/dist/browser/driver.js +70 -0
  6. package/dist/browser/driver.js.map +1 -0
  7. package/dist/browser/evidence.d.ts +47 -0
  8. package/dist/browser/evidence.d.ts.map +1 -0
  9. package/dist/browser/evidence.js +55 -0
  10. package/dist/browser/evidence.js.map +1 -0
  11. package/dist/browser/fake-driver.d.ts +58 -0
  12. package/dist/browser/fake-driver.d.ts.map +1 -0
  13. package/dist/browser/fake-driver.js +161 -0
  14. package/dist/browser/fake-driver.js.map +1 -0
  15. package/dist/browser/graph-write.d.ts +86 -0
  16. package/dist/browser/graph-write.d.ts.map +1 -0
  17. package/dist/browser/graph-write.js +135 -0
  18. package/dist/browser/graph-write.js.map +1 -0
  19. package/dist/browser/playwright-driver.d.ts +65 -0
  20. package/dist/browser/playwright-driver.d.ts.map +1 -0
  21. package/dist/browser/playwright-driver.js +359 -0
  22. package/dist/browser/playwright-driver.js.map +1 -0
  23. package/dist/browser/provider.d.ts +49 -0
  24. package/dist/browser/provider.d.ts.map +1 -0
  25. package/dist/browser/provider.js +28 -0
  26. package/dist/browser/provider.js.map +1 -0
  27. package/dist/browser/registry.d.ts +182 -0
  28. package/dist/browser/registry.d.ts.map +1 -0
  29. package/dist/browser/registry.js +215 -0
  30. package/dist/browser/registry.js.map +1 -0
  31. package/dist/browser/scenario-resolve.d.ts +62 -0
  32. package/dist/browser/scenario-resolve.d.ts.map +1 -0
  33. package/dist/browser/scenario-resolve.js +127 -0
  34. package/dist/browser/scenario-resolve.js.map +1 -0
  35. package/dist/browser/scenario-runner.d.ts +113 -0
  36. package/dist/browser/scenario-runner.d.ts.map +1 -0
  37. package/dist/browser/scenario-runner.js +315 -0
  38. package/dist/browser/scenario-runner.js.map +1 -0
  39. package/dist/browser/stack-parser.d.ts +43 -0
  40. package/dist/browser/stack-parser.d.ts.map +1 -0
  41. package/dist/browser/stack-parser.js +112 -0
  42. package/dist/browser/stack-parser.js.map +1 -0
  43. package/dist/browser/tool-support.d.ts +113 -0
  44. package/dist/browser/tool-support.d.ts.map +1 -0
  45. package/dist/browser/tool-support.js +181 -0
  46. package/dist/browser/tool-support.js.map +1 -0
  47. package/dist/disclosure-ledger.d.ts +38 -0
  48. package/dist/disclosure-ledger.d.ts.map +1 -0
  49. package/dist/disclosure-ledger.js +40 -0
  50. package/dist/disclosure-ledger.js.map +1 -0
  51. package/dist/index.d.ts +12 -1
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +10 -0
  54. package/dist/index.js.map +1 -1
  55. package/dist/protocol.d.ts +12 -3
  56. package/dist/protocol.d.ts.map +1 -1
  57. package/dist/protocol.js +12 -3
  58. package/dist/protocol.js.map +1 -1
  59. package/dist/render.d.ts +121 -10
  60. package/dist/render.d.ts.map +1 -1
  61. package/dist/render.js +96 -15
  62. package/dist/render.js.map +1 -1
  63. package/dist/runtime-registry.d.ts +63 -0
  64. package/dist/runtime-registry.d.ts.map +1 -0
  65. package/dist/runtime-registry.js +131 -0
  66. package/dist/runtime-registry.js.map +1 -0
  67. package/dist/scenarios/index.d.ts +4 -0
  68. package/dist/scenarios/index.d.ts.map +1 -0
  69. package/dist/scenarios/index.js +4 -0
  70. package/dist/scenarios/index.js.map +1 -0
  71. package/dist/scenarios/parse.d.ts +32 -0
  72. package/dist/scenarios/parse.d.ts.map +1 -0
  73. package/dist/scenarios/parse.js +199 -0
  74. package/dist/scenarios/parse.js.map +1 -0
  75. package/dist/scenarios/scenario.d.ts +115 -0
  76. package/dist/scenarios/scenario.d.ts.map +1 -0
  77. package/dist/scenarios/scenario.js +41 -0
  78. package/dist/scenarios/scenario.js.map +1 -0
  79. package/dist/scenarios/storage.d.ts +51 -0
  80. package/dist/scenarios/storage.d.ts.map +1 -0
  81. package/dist/scenarios/storage.js +93 -0
  82. package/dist/scenarios/storage.js.map +1 -0
  83. package/dist/server.d.ts.map +1 -1
  84. package/dist/server.js +11 -3
  85. package/dist/server.js.map +1 -1
  86. package/dist/session.d.ts +142 -2
  87. package/dist/session.d.ts.map +1 -1
  88. package/dist/session.js +266 -4
  89. package/dist/session.js.map +1 -1
  90. package/dist/tools/analyze.d.ts +41 -1
  91. package/dist/tools/analyze.d.ts.map +1 -1
  92. package/dist/tools/analyze.js +111 -9
  93. package/dist/tools/analyze.js.map +1 -1
  94. package/dist/tools/browser-click.d.ts +36 -0
  95. package/dist/tools/browser-click.d.ts.map +1 -0
  96. package/dist/tools/browser-click.js +117 -0
  97. package/dist/tools/browser-click.js.map +1 -0
  98. package/dist/tools/browser-close-session.d.ts +24 -0
  99. package/dist/tools/browser-close-session.d.ts.map +1 -0
  100. package/dist/tools/browser-close-session.js +63 -0
  101. package/dist/tools/browser-close-session.js.map +1 -0
  102. package/dist/tools/browser-fill.d.ts +49 -0
  103. package/dist/tools/browser-fill.d.ts.map +1 -0
  104. package/dist/tools/browser-fill.js +138 -0
  105. package/dist/tools/browser-fill.js.map +1 -0
  106. package/dist/tools/browser-navigate.d.ts +32 -0
  107. package/dist/tools/browser-navigate.d.ts.map +1 -0
  108. package/dist/tools/browser-navigate.js +103 -0
  109. package/dist/tools/browser-navigate.js.map +1 -0
  110. package/dist/tools/browser-run-scenario.d.ts +54 -0
  111. package/dist/tools/browser-run-scenario.d.ts.map +1 -0
  112. package/dist/tools/browser-run-scenario.js +228 -0
  113. package/dist/tools/browser-run-scenario.js.map +1 -0
  114. package/dist/tools/browser-save-scenario.d.ts +44 -0
  115. package/dist/tools/browser-save-scenario.d.ts.map +1 -0
  116. package/dist/tools/browser-save-scenario.js +298 -0
  117. package/dist/tools/browser-save-scenario.js.map +1 -0
  118. package/dist/tools/browser-snapshot.d.ts +60 -0
  119. package/dist/tools/browser-snapshot.d.ts.map +1 -0
  120. package/dist/tools/browser-snapshot.js +139 -0
  121. package/dist/tools/browser-snapshot.js.map +1 -0
  122. package/dist/tools/browser-start-session.d.ts +43 -0
  123. package/dist/tools/browser-start-session.d.ts.map +1 -0
  124. package/dist/tools/browser-start-session.js +272 -0
  125. package/dist/tools/browser-start-session.js.map +1 -0
  126. package/dist/tools/browser-type.d.ts +48 -0
  127. package/dist/tools/browser-type.d.ts.map +1 -0
  128. package/dist/tools/browser-type.js +136 -0
  129. package/dist/tools/browser-type.js.map +1 -0
  130. package/dist/tools/contracts.d.ts +15 -0
  131. package/dist/tools/contracts.d.ts.map +1 -1
  132. package/dist/tools/contracts.js +14 -3
  133. package/dist/tools/contracts.js.map +1 -1
  134. package/dist/tools/cross-pr.d.ts.map +1 -1
  135. package/dist/tools/cross-pr.js +1 -0
  136. package/dist/tools/cross-pr.js.map +1 -1
  137. package/dist/tools/git-diff.d.ts.map +1 -1
  138. package/dist/tools/git-diff.js +104 -4
  139. package/dist/tools/git-diff.js.map +1 -1
  140. package/dist/tools/git-history.d.ts.map +1 -1
  141. package/dist/tools/git-history.js +1 -0
  142. package/dist/tools/git-history.js.map +1 -1
  143. package/dist/tools/history.js +1 -1
  144. package/dist/tools/history.js.map +1 -1
  145. package/dist/tools/impact.d.ts +9 -0
  146. package/dist/tools/impact.d.ts.map +1 -1
  147. package/dist/tools/impact.js +4 -4
  148. package/dist/tools/impact.js.map +1 -1
  149. package/dist/tools/index.d.ts +12 -1
  150. package/dist/tools/index.d.ts.map +1 -1
  151. package/dist/tools/index.js +31 -0
  152. package/dist/tools/index.js.map +1 -1
  153. package/dist/tools/kit.d.ts +11 -1
  154. package/dist/tools/kit.d.ts.map +1 -1
  155. package/dist/tools/kit.js +3 -0
  156. package/dist/tools/kit.js.map +1 -1
  157. package/dist/tools/link-workspace.d.ts.map +1 -1
  158. package/dist/tools/link-workspace.js +13 -1
  159. package/dist/tools/link-workspace.js.map +1 -1
  160. package/dist/tools/mark-incident.d.ts +69 -0
  161. package/dist/tools/mark-incident.d.ts.map +1 -0
  162. package/dist/tools/mark-incident.js +212 -0
  163. package/dist/tools/mark-incident.js.map +1 -0
  164. package/dist/tools/observe-runtime.d.ts +292 -0
  165. package/dist/tools/observe-runtime.d.ts.map +1 -0
  166. package/dist/tools/observe-runtime.js +1192 -0
  167. package/dist/tools/observe-runtime.js.map +1 -0
  168. package/dist/tools/observe-tests.d.ts +125 -0
  169. package/dist/tools/observe-tests.d.ts.map +1 -0
  170. package/dist/tools/observe-tests.js +313 -0
  171. package/dist/tools/observe-tests.js.map +1 -0
  172. package/dist/tools/pr-analysis.d.ts +71 -13
  173. package/dist/tools/pr-analysis.d.ts.map +1 -1
  174. package/dist/tools/pr-analysis.js +55 -12
  175. package/dist/tools/pr-analysis.js.map +1 -1
  176. package/dist/tools/pre-push.d.ts +77 -0
  177. package/dist/tools/pre-push.d.ts.map +1 -0
  178. package/dist/tools/pre-push.js +250 -0
  179. package/dist/tools/pre-push.js.map +1 -0
  180. package/dist/tools/propagation.d.ts.map +1 -1
  181. package/dist/tools/propagation.js +1 -0
  182. package/dist/tools/propagation.js.map +1 -1
  183. package/dist/tools/questions.d.ts.map +1 -1
  184. package/dist/tools/questions.js +101 -14
  185. package/dist/tools/questions.js.map +1 -1
  186. package/dist/tools/refusal-fetch.d.ts.map +1 -1
  187. package/dist/tools/refusal-fetch.js +1 -0
  188. package/dist/tools/refusal-fetch.js.map +1 -1
  189. package/dist/tools/runtime-incident.d.ts +92 -0
  190. package/dist/tools/runtime-incident.d.ts.map +1 -0
  191. package/dist/tools/runtime-incident.js +144 -0
  192. package/dist/tools/runtime-incident.js.map +1 -0
  193. package/dist/tools/scope.d.ts.map +1 -1
  194. package/dist/tools/scope.js +1 -0
  195. package/dist/tools/scope.js.map +1 -1
  196. package/dist/tools/similar-incidents.d.ts +13 -0
  197. package/dist/tools/similar-incidents.d.ts.map +1 -1
  198. package/dist/tools/similar-incidents.js +22 -8
  199. package/dist/tools/similar-incidents.js.map +1 -1
  200. package/dist/tools/verification-status.d.ts +22 -0
  201. package/dist/tools/verification-status.d.ts.map +1 -1
  202. package/dist/tools/verification-status.js +52 -5
  203. package/dist/tools/verification-status.js.map +1 -1
  204. package/dist/tools/verify-claim.d.ts.map +1 -1
  205. package/dist/tools/verify-claim.js +5 -0
  206. package/dist/tools/verify-claim.js.map +1 -1
  207. package/package.json +16 -4
@@ -0,0 +1,315 @@
1
+ /**
2
+ * Replaying a stored scenario — §7's runner half.
3
+ *
4
+ * ## What this composes, and the four things it must not get wrong
5
+ *
6
+ * Everything below is composition: the port drives, `scenarios/` is the
7
+ * artifact, `scenario-resolve.ts` re-resolves a descriptor, `tool-support.ts`
8
+ * drains and correlates. What the runner adds is *order*, and four ordering
9
+ * mistakes each fail as flakiness or as a false pass rather than as an error,
10
+ * which is why each is named here rather than left to be rediscovered.
11
+ *
12
+ * 1. **`registry.use()` is called once per step.** It is not a lookup: it is
13
+ * asynchronous, it is the crash detector, and it touches the idle clock. A
14
+ * runner that resolved the session once and held the entry across N steps
15
+ * would be reaped mid-scenario at the five-minute idle timeout, and would
16
+ * read as a flaky test rather than as a design error.
17
+ * 2. **`drainEvidence()` drains, it does not peek.** Once per step, aggregated
18
+ * into the summary. A single read at the end loses every earlier step's
19
+ * observations — and would silently pass an assertion anchored at step 0,
20
+ * which is the false green this whole feature exists to prevent.
21
+ * 3. **A stored step carries no `ref`.** Every step re-resolves against a
22
+ * fresh snapshot, exact-or-refuse, with no fallback chain. See
23
+ * `scenario-resolve.ts`.
24
+ * 4. **Assertions evaluate here, at replay.** An empty assertion list replays
25
+ * as `unverified`, never `passed`.
26
+ *
27
+ * ## The outcome rule
28
+ *
29
+ * `DEC-384`, implemented rather than restated. A
30
+ * failed assertion is the scenario's own claim about the application, written
31
+ * down by a person, and it blocks. A console error or a failed request is
32
+ * reported and does not block — frequently true of a working page, and a check
33
+ * people disable protects nothing. No assertions is `unverified`. An
34
+ * unresolvable step is **neither pass nor fail**: Descry cannot tell a
35
+ * deliberate rename from a vanished button, and both produce a byte-identical
36
+ * unresolvable step, so it claims neither while still stopping the run.
37
+ *
38
+ * Three counts, **never summed** — `failed`, `unresolved`, `unverified` — and
39
+ * only failed assertions join `blockingTotal`, because folding `unresolved`
40
+ * into it would re-assert through arithmetic the defect claim the ruling
41
+ * refused to make in prose.
42
+ */
43
+ import { NO_GRAPH_WRITE } from "./graph-write.js";
44
+ import { resolveTarget } from "./scenario-resolve.js";
45
+ import { observeAndCorrelate, useSession, withinConsent } from "./tool-support.js";
46
+ const MUTATING = ["click", "type", "fill"];
47
+ /** True when replaying this scenario would change the running application. A navigate-only scenario would not. */
48
+ export function mutates(scenario) {
49
+ return scenario.steps.some((step) => MUTATING.includes(step.action));
50
+ }
51
+ function mergeGraph(into, next) {
52
+ const reached = [...into.reached];
53
+ for (const node of next.reached)
54
+ if (!reached.some((seen) => seen.nodeId === node.nodeId))
55
+ reached.push(node);
56
+ return {
57
+ reached,
58
+ promoted: [...new Set([...into.promoted, ...next.promoted])],
59
+ created: [...new Set([...into.created, ...next.created])],
60
+ refused: [...new Set([...into.refused, ...next.refused])],
61
+ contradictions: [...new Set([...into.contradictions, ...next.contradictions])],
62
+ };
63
+ }
64
+ export async function replayScenario(ctx, registry, sessionId, scenario) {
65
+ const steps = scenario.steps.map((step, index) => ({
66
+ index,
67
+ action: step.action,
68
+ status: "skipped",
69
+ url: "",
70
+ resolution: null,
71
+ }));
72
+ const assertionResults = scenario.assertions.map(() => null);
73
+ const acc = { consoleErrors: [], failedRequests: [], actions: [], totalRequests: 0 };
74
+ let graph = NO_GRAPH_WRITE;
75
+ const notes = [];
76
+ let sessionEnded = null;
77
+ let stopped = false;
78
+ function absorb(evidence) {
79
+ acc.consoleErrors.push(...evidence.consoleErrors);
80
+ acc.failedRequests.push(...evidence.failedRequests);
81
+ acc.actions.push(...evidence.actions);
82
+ acc.totalRequests += evidence.totalRequests;
83
+ }
84
+ function cumulative() {
85
+ return {
86
+ consoleErrors: [...acc.consoleErrors],
87
+ failedRequests: [...acc.failedRequests],
88
+ actions: [...acc.actions],
89
+ totalRequests: acc.totalRequests,
90
+ };
91
+ }
92
+ function anchoredAt(anchor) {
93
+ return scenario.assertions.some((assertion, index) => assertion.afterStep === anchor && assertionResults[index] === null);
94
+ }
95
+ /**
96
+ * A snapshot is taken only when something is anchored here.
97
+ *
98
+ * Not a micro-optimisation: a snapshot is a real round trip to a real page,
99
+ * and taking one after every step of a twenty-step scenario that asserts
100
+ * once at the end would triple the cost of the common case.
101
+ */
102
+ async function evaluateAnchored(anchor, entry) {
103
+ if (!anchoredAt(anchor))
104
+ return;
105
+ const snapshot = await entry.page.snapshot();
106
+ scenario.assertions.forEach((assertion, index) => {
107
+ if (assertion.afterStep !== anchor || assertionResults[index] !== null)
108
+ return;
109
+ assertionResults[index] = evaluateAssertion(assertion, index, entry, snapshot, cumulative());
110
+ });
111
+ }
112
+ for (const [index, step] of scenario.steps.entries()) {
113
+ // Trap 1. Per step, always: `use` is the crash detector and the idle
114
+ // clock, and a five-minute scenario that resolved the session once would
115
+ // be reaped out from under itself halfway through.
116
+ const found = await useSession(registry, sessionId);
117
+ if (!found.ok) {
118
+ sessionEnded = found.dead;
119
+ absorb(found.dead.evidence);
120
+ stopped = true;
121
+ break;
122
+ }
123
+ const { entry } = found;
124
+ ctx.progress(`Replaying step ${index + 1} of ${scenario.steps.length}`, index + 1, scenario.steps.length);
125
+ if (step.action === "navigate") {
126
+ const url = step.url ?? "";
127
+ if (!withinConsent(entry, url)) {
128
+ steps[index] = {
129
+ index,
130
+ action: step.action,
131
+ status: "unresolved",
132
+ url: entry.page.currentUrl(),
133
+ resolution: {
134
+ kind: "zero",
135
+ disagreed: [],
136
+ message: `step ${index}: navigating to ${url} would leave ${entry.consentedOrigin}, the origin this ` +
137
+ "session was consented for. The step is not run and the replay stops — consent is bound to one " +
138
+ "origin, and a stored step cannot widen it.",
139
+ },
140
+ };
141
+ stopped = true;
142
+ break;
143
+ }
144
+ await entry.page.navigate(url);
145
+ }
146
+ else {
147
+ // Trap 3. A fresh snapshot every time, and exact-or-refuse against it.
148
+ const snapshot = await entry.page.snapshot();
149
+ const target = step.target;
150
+ if (target === null) {
151
+ steps[index] = {
152
+ index,
153
+ action: step.action,
154
+ status: "unresolved",
155
+ url: snapshot.url,
156
+ resolution: {
157
+ kind: "zero",
158
+ disagreed: [],
159
+ message: `step ${index}: a ${step.action} step carries no target to resolve. Fix the scenario file and re-save it.`,
160
+ },
161
+ };
162
+ stopped = true;
163
+ break;
164
+ }
165
+ const resolved = resolveTarget(`step ${index}`, target, snapshot);
166
+ if (!resolved.resolved) {
167
+ steps[index] = { index, action: step.action, status: "unresolved", url: snapshot.url, resolution: resolved.failure };
168
+ // Trap 2 again, on the failure path. Stopping without draining would
169
+ // discard whatever the page said before the descriptor stopped
170
+ // matching, which is exactly the evidence a person needs to tell a
171
+ // rename from a breakage.
172
+ const observed = await observeAndCorrelate(ctx, entry);
173
+ absorb(observed.evidence);
174
+ graph = mergeGraph(graph, observed.graph);
175
+ notes.push(...observed.notes);
176
+ stopped = true;
177
+ break;
178
+ }
179
+ const ref = resolved.element.ref;
180
+ if (step.action === "click")
181
+ await entry.page.click(ref);
182
+ else if (step.action === "type")
183
+ await entry.page.type(ref, step.text ?? "");
184
+ else
185
+ await entry.page.fill(ref, step.text ?? "");
186
+ }
187
+ // Trap 2. Once per step, aggregated. A final read would lose everything
188
+ // the earlier steps saw; a peeking read would report each observation
189
+ // again on the teardown flush.
190
+ const observed = await observeAndCorrelate(ctx, entry);
191
+ absorb(observed.evidence);
192
+ graph = mergeGraph(graph, observed.graph);
193
+ notes.push(...observed.notes);
194
+ steps[index] = { index, action: step.action, status: "ran", url: entry.page.currentUrl(), resolution: null };
195
+ await evaluateAnchored(index, entry);
196
+ }
197
+ // End-of-scenario assertions, and only when there are some. A `use` call is
198
+ // not free — it is the crash detector and it touches the idle clock — so a
199
+ // scenario with nothing anchored at the end does not make one.
200
+ if (!stopped && anchoredAt(null)) {
201
+ const found = await useSession(registry, sessionId);
202
+ if (found.ok) {
203
+ await evaluateAnchored(null, found.entry);
204
+ }
205
+ else {
206
+ sessionEnded = found.dead;
207
+ absorb(found.dead.evidence);
208
+ }
209
+ }
210
+ const assertions = scenario.assertions.map((assertion, index) => assertionResults[index] ?? {
211
+ index,
212
+ kind: assertion.kind,
213
+ afterStep: assertion.afterStep,
214
+ status: "notReached",
215
+ detail: `The replay stopped before this assertion's anchor, so it never ran. That is not a pass and not a ` +
216
+ "failure — it is already accounted for by the step that stopped the run.",
217
+ });
218
+ const failed = assertions.filter((a) => a.status === "failed").length;
219
+ const unevaluable = assertions.filter((a) => a.status === "unevaluable").length;
220
+ const unresolvedSteps = steps.filter((s) => s.status === "unresolved").length;
221
+ const unresolved = unresolvedSteps + unevaluable;
222
+ // A scenario that claimed nothing verified nothing. One scenario, so this is
223
+ // 1 or 0 — the count is a count so the CLI can add scenarios together, never
224
+ // so it can add it to the other two.
225
+ const unverified = scenario.assertions.length === 0 ? 1 : 0;
226
+ const passed = assertions.filter((a) => a.status === "passed").length;
227
+ const outcome = failed > 0 ? "failed" : unresolved > 0 || sessionEnded !== null ? "unresolved" : unverified > 0 ? "unverified" : "passed";
228
+ return {
229
+ scenario: scenario.name,
230
+ sessionId,
231
+ outcome,
232
+ counts: { passed, failed, unresolved, unverified },
233
+ // Only failed assertions. See the header.
234
+ blockingTotal: failed,
235
+ exitCode: outcome === "failed" ? 1 : outcome === "unresolved" ? 2 : 0,
236
+ steps,
237
+ assertions,
238
+ evidence: cumulative(),
239
+ graph,
240
+ sessionEnded,
241
+ notes,
242
+ };
243
+ }
244
+ /**
245
+ * Evaluate one assertion against the page as it stands and the evidence
246
+ * gathered so far.
247
+ *
248
+ * The two evidence assertions read *cumulatively* — everything observed since
249
+ * the replay began, not only the step just taken. An author anchoring
250
+ * `noConsoleErrors` after step 3 is claiming the page got that far cleanly,
251
+ * not that step 3 in isolation was quiet.
252
+ */
253
+ function evaluateAssertion(assertion, index, entry, snapshot, evidence) {
254
+ const base = { index, kind: assertion.kind, afterStep: assertion.afterStep };
255
+ const unevaluable = (detail) => ({ ...base, status: "unevaluable", detail });
256
+ const passed = (detail) => ({ ...base, status: "passed", detail });
257
+ const failed = (detail) => ({ ...base, status: "failed", detail });
258
+ switch (assertion.kind) {
259
+ case "elementVisible": {
260
+ if (assertion.target === null) {
261
+ return unevaluable(`assertion ${index}: elementVisible names no element. Fix the scenario file and re-save it.`);
262
+ }
263
+ const found = resolveTarget(`assertion ${index}`, assertion.target, snapshot);
264
+ if (found.resolved)
265
+ return passed(`assertion ${index}: the element is on ${snapshot.url}.`);
266
+ // Ambiguity is the page being unreadable, not the claim being wrong —
267
+ // "which of these two did you mean" is a question, not a defect. Zero
268
+ // and partial are the claim failing: the author wrote down that this
269
+ // element would be here, and it is not.
270
+ if (found.failure.kind === "ambiguous")
271
+ return unevaluable(found.failure.message);
272
+ return failed(found.failure.message);
273
+ }
274
+ case "textEquals": {
275
+ if (assertion.target === null || assertion.expected === null) {
276
+ return unevaluable(`assertion ${index}: textEquals needs both an element and an expected value, and the scenario file ` +
277
+ "stores only one of them. Fix the scenario and re-save it.");
278
+ }
279
+ const found = resolveTarget(`assertion ${index}`, assertion.target, snapshot);
280
+ if (!found.resolved) {
281
+ return found.failure.kind === "ambiguous" ? unevaluable(found.failure.message) : failed(found.failure.message);
282
+ }
283
+ // The snapshot carries an accessible name, which is what the port
284
+ // exposes; there is no text-content field to compare against and
285
+ // inventing one would be a promise the format cannot keep.
286
+ return found.element.name === assertion.expected
287
+ ? passed(`assertion ${index}: the element's accessible name is "${assertion.expected}".`)
288
+ : failed(`assertion ${index}: expected the element's accessible name to be "${assertion.expected}", and it ` +
289
+ `is "${found.element.name}".`);
290
+ }
291
+ case "urlEquals": {
292
+ if (assertion.expected === null) {
293
+ return unevaluable(`assertion ${index}: urlEquals stores no expected URL. Fix the scenario file and re-save it.`);
294
+ }
295
+ const actual = entry.page.currentUrl();
296
+ return actual === assertion.expected
297
+ ? passed(`assertion ${index}: the page is at ${actual}.`)
298
+ : failed(`assertion ${index}: expected the page to be at ${assertion.expected}, and it is at ${actual}.`);
299
+ }
300
+ case "noConsoleErrors":
301
+ return evidence.consoleErrors.length === 0
302
+ ? passed(`assertion ${index}: no console errors were observed.`)
303
+ : failed(`assertion ${index}: ${evidence.consoleErrors.length} console error(s) were observed, the first ` +
304
+ `being "${evidence.consoleErrors[0]?.text ?? ""}". An observed console error does not block a ` +
305
+ "push on its own; this one does, because the scenario's author claimed there would be none.");
306
+ case "noFailedRequests":
307
+ return evidence.failedRequests.length === 0
308
+ ? passed(`assertion ${index}: no failed requests were observed.`)
309
+ : failed(`assertion ${index}: ${evidence.failedRequests.length} request(s) failed, the first being ` +
310
+ `${evidence.failedRequests[0]?.method ?? ""} ${evidence.failedRequests[0]?.url ?? ""}. A failed ` +
311
+ "request does not block a push on its own; this one does, because the author claimed there " +
312
+ "would be none.");
313
+ }
314
+ }
315
+ //# sourceMappingURL=scenario-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenario-runner.js","sourceRoot":"","sources":["../../src/browser/scenario-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAMH,OAAO,EAAE,cAAc,EAA0B,MAAM,kBAAkB,CAAC;AAE1E,OAAO,EAAE,aAAa,EAA0B,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,aAAa,EAAoB,MAAM,mBAAmB,CAAC;AAkErG,MAAM,QAAQ,GAAkC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE1E,kHAAkH;AAClH,MAAM,UAAU,OAAO,CAAC,QAAkB;IACxC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CA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
+ * language.
4
+ *
5
+ * `runtime-registry.ts`'s argument, applied to the browser lane. A raw
6
+ * `fetch()` call-site stack is a string in some runtime's own format, and
7
+ * turning it into resolved frames is per-language work that lives in
8
+ * `descry-runtime`'s adapters. An `import { createV8StackTraceParser } from
9
+ * "@descryy/runtime-adapter-typescript"` in a tool file would put the word
10
+ * "typescript" above the IR boundary in the one process that runs everything
11
+ * — rule 1, which this repository calls a design bug rather than a style
12
+ * preference.
13
+ *
14
+ * So the parser is **named by the caller as a module specifier** and imported
15
+ * at run time, exactly as every static source and runtime adapter already is.
16
+ *
17
+ * ## Without one, the arrow does not exist, and the reply says so
18
+ *
19
+ * This is not a degradation that can be hidden. `confirmObservedFrontendCaller`
20
+ * takes a parsed `StackTrace`; with no parser, every request is still observed
21
+ * and every endpoint it reached can still be named, but **no caller edge is
22
+ * written at all**. That is a real, honest, partial answer — "this route was
23
+ * hit, we cannot tell you from where" — and it is disclosed rather than
24
+ * presented as a run that found nothing.
25
+ */
26
+ import type { StackTraceParser } from "@descryy/runtime-backend-observation";
27
+ /** A stack-trace parser named the way `RuntimeAdapterSpec` names a runtime adapter. */
28
+ export interface StackParserSpec {
29
+ readonly module: string;
30
+ /** Named export to call. Defaults to the `create*StackTraceParser` convention. */
31
+ readonly export?: string;
32
+ }
33
+ /**
34
+ * Distinct from a generic `Error` so a tool can tell "the parser would not
35
+ * load" — a refusal it must disclose — from "the run itself broke". Both are
36
+ * honest; they are not the same statement.
37
+ */
38
+ export declare class StackParserLoadError extends Error {
39
+ readonly specifier: string;
40
+ constructor(specifier: string, reason: string);
41
+ }
42
+ export declare function loadStackParser(spec: StackParserSpec): Promise<StackTraceParser>;
43
+ //# sourceMappingURL=stack-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack-parser.d.ts","sourceRoot":"","sources":["../../src/browser/stack-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,uFAAuF;AACvF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,kFAAkF;IAClF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAQ9C;AAKD,wBAAsB,eAAe,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkDtF"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * How a browser session reaches a stack-trace parser without naming a
3
+ * language.
4
+ *
5
+ * `runtime-registry.ts`'s argument, applied to the browser lane. A raw
6
+ * `fetch()` call-site stack is a string in some runtime's own format, and
7
+ * turning it into resolved frames is per-language work that lives in
8
+ * `descry-runtime`'s adapters. An `import { createV8StackTraceParser } from
9
+ * "@descryy/runtime-adapter-typescript"` in a tool file would put the word
10
+ * "typescript" above the IR boundary in the one process that runs everything
11
+ * — rule 1, which this repository calls a design bug rather than a style
12
+ * preference.
13
+ *
14
+ * So the parser is **named by the caller as a module specifier** and imported
15
+ * at run time, exactly as every static source and runtime adapter already is.
16
+ *
17
+ * ## Without one, the arrow does not exist, and the reply says so
18
+ *
19
+ * This is not a degradation that can be hidden. `confirmObservedFrontendCaller`
20
+ * takes a parsed `StackTrace`; with no parser, every request is still observed
21
+ * and every endpoint it reached can still be named, but **no caller edge is
22
+ * written at all**. That is a real, honest, partial answer — "this route was
23
+ * hit, we cannot tell you from where" — and it is disclosed rather than
24
+ * presented as a run that found nothing.
25
+ */
26
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
27
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
28
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
29
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
30
+ });
31
+ }
32
+ return path;
33
+ };
34
+ /**
35
+ * Distinct from a generic `Error` so a tool can tell "the parser would not
36
+ * load" — a refusal it must disclose — from "the run itself broke". Both are
37
+ * honest; they are not the same statement.
38
+ */
39
+ export class StackParserLoadError extends Error {
40
+ specifier;
41
+ constructor(specifier, reason) {
42
+ super(`Could not load a stack-trace parser from "${specifier}": ${reason}. Requests will still be observed ` +
43
+ "and endpoints still named, but no frontend→backend caller edge can be written without one.");
44
+ this.name = "StackParserLoadError";
45
+ this.specifier = specifier;
46
+ }
47
+ }
48
+ const FACTORY_PATTERN = /^create[A-Za-z0-9]*StackTraceParser$/;
49
+ const RESOLVER_PATTERN = /^create[A-Za-z0-9]*SourceLocationResolver$/;
50
+ export async function loadStackParser(spec) {
51
+ let module;
52
+ try {
53
+ module = (await import(__rewriteRelativeImportExtension(spec.module)));
54
+ }
55
+ catch (error) {
56
+ throw new StackParserLoadError(spec.module, error instanceof Error ? error.message : String(error));
57
+ }
58
+ const name = spec.export ?? soleFactory(module, spec.module);
59
+ const factory = module[name];
60
+ if (typeof factory !== "function") {
61
+ throw new StackParserLoadError(spec.module, `"${name}" is not a function`);
62
+ }
63
+ // A parser factory that takes an argument takes a `SourceLocationResolver`
64
+ // — resolving a script URL to a real file on disk is the half of the job
65
+ // that is filesystem-shaped rather than text-shaped, and every adapter that
66
+ // needs one exports a `create*SourceLocationResolver` beside its parser.
67
+ //
68
+ // This is checked rather than assumed because the failure is silent. Called
69
+ // with no resolver, `createV8StackTraceParser` returns a parser that throws
70
+ // nothing and produces `null` for every stack — so a run would observe
71
+ // every request, write no edge, report no error, and look exactly like an
72
+ // application with no frontend callers. Measured, not hypothesised: it is
73
+ // what this loader did before this branch existed.
74
+ const needsResolver = factory.length >= 1;
75
+ let resolver;
76
+ if (needsResolver) {
77
+ const resolverName = soleMatch(module, RESOLVER_PATTERN);
78
+ if (resolverName === null) {
79
+ throw new StackParserLoadError(spec.module, `${name}() expects a source-location resolver and the module exports no create*SourceLocationResolver ` +
80
+ "to build one from. Without it every stack parses to null and no caller edge could ever be written");
81
+ }
82
+ try {
83
+ resolver = module[resolverName]();
84
+ }
85
+ catch (error) {
86
+ throw new StackParserLoadError(spec.module, `${resolverName}() threw: ${error instanceof Error ? error.message : String(error)}`);
87
+ }
88
+ }
89
+ try {
90
+ return needsResolver
91
+ ? factory(resolver)
92
+ : factory();
93
+ }
94
+ catch (error) {
95
+ throw new StackParserLoadError(spec.module, `${name}() threw: ${error instanceof Error ? error.message : String(error)}`);
96
+ }
97
+ }
98
+ function soleMatch(module, pattern) {
99
+ const matches = Object.keys(module).filter((key) => pattern.test(key) && typeof module[key] === "function");
100
+ return matches.length === 1 ? matches[0] : null;
101
+ }
102
+ /** Two matches is an error, not a coin toss — `runtime-registry.ts`'s rule, for the same reason. */
103
+ function soleFactory(module, specifier) {
104
+ const matches = Object.keys(module).filter((key) => FACTORY_PATTERN.test(key) && typeof module[key] === "function");
105
+ if (matches.length === 1)
106
+ return matches[0];
107
+ if (matches.length === 0) {
108
+ throw new StackParserLoadError(specifier, "it exports no create*StackTraceParser factory; name one explicitly with \"export\"");
109
+ }
110
+ throw new StackParserLoadError(specifier, `it exports ${matches.length} create*StackTraceParser factories (${matches.join(", ")}) — name one explicitly with "export"`);
111
+ }
112
+ //# sourceMappingURL=stack-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack-parser.js","sourceRoot":"","sources":["../../src/browser/stack-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;;;;;;AAWH;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,SAAS,CAAS;IAE3B,YAAY,SAAiB,EAAE,MAAc;QAC3C,KAAK,CACH,6CAA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AC,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACnD,CAAC;AAED,oGAAoG;AACpG,SAAS,WAAW,CAAC,MAA+B,EAAE,SAAiB;IACrE,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,UAAU,CAAC,CAAC;IACpH,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC,CAAC,CAAE,CAAC;IAC7C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,oBAAoB,CAAC,SAAS,EAAE,oFAAoF,CAAC,CAAC;IAClI,CAAC;IACD,MAAM,IAAI,oBAAoB,CAC5B,SAAS,EACT,cAAc,OAAO,CAAC,MAAM,uCAAuC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,uCAAuC,CAC7H,CAAC;AACJ,CAAC"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * What the seven browser tools share.
3
+ *
4
+ * Kept in one place because the parts that repeat are the parts that must not
5
+ * drift: how a dead session is reported, how consent is checked, and how a
6
+ * reply is stamped. Seven copies of a refusal is seven chances for one of
7
+ * them to say something slightly different about the same state.
8
+ */
9
+ import { type ToolContext } from "../tools/kit.ts";
10
+ import type { ToolAnswer } from "../render.ts";
11
+ import type { BrowserSessionEntry, BrowserSessionRegistry } from "./registry.ts";
12
+ import { type BrowserEvidenceReport } from "./evidence.ts";
13
+ import type { BrowserObservation } from "./driver.ts";
14
+ import { type BrowserGraphWrite } from "./graph-write.ts";
15
+ /**
16
+ * The staleness stamp for a reply that observed a browser.
17
+ *
18
+ * A browser tool does not read the graph, and on a repository that has never
19
+ * been analysed there is no graph to read. Refusing to open a browser because
20
+ * of that would be refusing for a reason that has nothing to do with the
21
+ * request, so the stamp degrades instead — and says it degraded.
22
+ */
23
+ export interface BrowserStamp {
24
+ readonly commitSha: string | null;
25
+ readonly graphBuiltAt: number | null;
26
+ readonly irSchemaVersion: number;
27
+ readonly commitSpread: number;
28
+ readonly note: string | null;
29
+ }
30
+ export declare function browserStamp(ctx: ToolContext): BrowserStamp;
31
+ export interface BrowserReplyOptions<T> {
32
+ readonly headline: string;
33
+ readonly data: T;
34
+ readonly notes: readonly string[];
35
+ readonly state?: "ok" | "refused" | "failed" | "empty";
36
+ readonly ctx: ToolContext;
37
+ readonly fitToBudget?: (budgetBytes: number) => import("../render.ts").ReplyFit<T>;
38
+ }
39
+ /**
40
+ * Every browser reply, stamped identically.
41
+ *
42
+ * `resolutionFloor: 4` on a successful observation, and that is not
43
+ * generosity: R4 is "observed at runtime", and a page element this call
44
+ * actually saw is the definition of it. A refusal or a failure observed
45
+ * nothing, so it stamps R0 — the floor has to describe the evidence behind
46
+ * *this* reply, not the tool's best case.
47
+ */
48
+ export declare function browserAnswer<T>(options: BrowserReplyOptions<T>): ToolAnswer<T>;
49
+ export interface DeadSession {
50
+ readonly state: "refused" | "failed";
51
+ readonly headline: string;
52
+ readonly notes: readonly string[];
53
+ readonly evidence: BrowserEvidenceReport;
54
+ }
55
+ /**
56
+ * Look a session up, or describe exactly why it cannot be used.
57
+ *
58
+ * The three dead states are deliberately not collapsed into one. "You never
59
+ * had this session", "it timed out five minutes ago, here is what it saw" and
60
+ * "the browser crashed" are three different things for a caller to do next,
61
+ * and only the last of them is a `failed`.
62
+ */
63
+ export declare function useSession(registry: BrowserSessionRegistry, sessionId: string): Promise<{
64
+ readonly ok: true;
65
+ readonly entry: BrowserSessionEntry;
66
+ } | {
67
+ readonly ok: false;
68
+ readonly dead: DeadSession;
69
+ }>;
70
+ /**
71
+ * Drain what the page has said, relate it to the graph, and produce both the
72
+ * payload and the disclosures in one place.
73
+ *
74
+ * Every evidence-bearing browser tool goes through this rather than draining
75
+ * for itself. Two reasons, and the second is the one that matters: a tool
76
+ * that drained without correlating would be a tool through which the R4 write
77
+ * silently does not happen, and nothing about its reply would look different.
78
+ *
79
+ * A repository with no graph correlates nothing and says so. That is a real
80
+ * state — a developer can drive a browser against an app they have never
81
+ * analysed — and it must not look like "we looked and found no connection".
82
+ */
83
+ export declare function observeAndCorrelate(ctx: ToolContext, entry: BrowserSessionEntry): Promise<{
84
+ readonly evidence: BrowserEvidenceReport;
85
+ readonly graph: BrowserGraphWrite;
86
+ readonly notes: readonly string[];
87
+ }>;
88
+ export declare function emptyEvidence(): BrowserEvidenceReport;
89
+ export declare function reportOf(observation: BrowserObservation): BrowserEvidenceReport;
90
+ /**
91
+ * Is `url` inside the origin this session was consented for?
92
+ *
93
+ * The consent ruling's one hard bound. Checked here rather than in each verb
94
+ * so that a future eighth tool cannot forget it.
95
+ */
96
+ /**
97
+ * Does this session's environment profile permit changing the application?
98
+ *
99
+ * Read off the profile the session was opened under — DEC-270's
100
+ * `safetyLevel`, the same field `observe_runtime` consults. Deliberately not
101
+ * a per-tool flag: two independent notions of "safe" is how a runtime run and
102
+ * a browser run end up disagreeing about the same environment.
103
+ *
104
+ * A session opened with no profile returns null here, and the session's own
105
+ * consent is then the only authorization — which is a real authorization,
106
+ * granted explicitly at `browser_start_session` against a named origin. The
107
+ * two are independent and both must pass: consent answers *may Descry drive a
108
+ * browser against this target at all*, the profile answers *may it mutate*,
109
+ * and neither excuses the other.
110
+ */
111
+ export declare function mutationRefusal(entry: BrowserSessionEntry): string | null;
112
+ export declare function withinConsent(entry: BrowserSessionEntry, url: string): boolean;
113
+ //# sourceMappingURL=tool-support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-support.d.ts","sourceRoot":"","sources":["../../src/browser/tool-support.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KA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