@aarwitz/tapp 0.35.6 → 0.35.7

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.
@@ -13,6 +13,8 @@
13
13
  <body>
14
14
  <svg hidden aria-hidden="true" xmlns="http://www.w3.org/2000/svg">
15
15
  <symbol id="i-grid" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="2" width="5" height="5" rx="1"/><rect x="9" y="2" width="5" height="5" rx="1"/><rect x="2" y="9" width="5" height="5" rx="1"/><rect x="9" y="9" width="5" height="5" rx="1"/></symbol>
16
+ <symbol id="i-alert" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M8 2.2 14.3 13H1.7z" stroke-linejoin="round"/><path d="M8 6.3v3"/><circle cx="8" cy="11.3" r=".55" fill="currentColor" stroke="none"/></symbol>
17
+ <symbol id="i-map" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1.6" y="4" width="4.3" height="4.3" rx="1"/><rect x="10.1" y="2.3" width="4.3" height="4.3" rx="1"/><rect x="10.1" y="9.4" width="4.3" height="4.3" rx="1"/><path d="M5.9 6.15h1.9a1 1 0 0 1 1 1v4.4a1 1 0 0 0 1 1h.3M8.8 6.15h1.3"/></symbol>
16
18
  <symbol id="i-play" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="8" cy="8" r="6.25"/><path d="M6.5 5.5v5l4-2.5z" fill="currentColor" stroke="none"/></symbol>
17
19
  <symbol id="i-folder" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M2 4.5A1.5 1.5 0 0 1 3.5 3h3l1.5 1.5h4.5A1.5 1.5 0 0 1 14 6v5.5A1.5 1.5 0 0 1 12.5 13h-9A1.5 1.5 0 0 1 2 11.5z"/></symbol>
18
20
  <symbol id="i-branch" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="4" cy="3.5" r="1.5"/><circle cx="4" cy="12.5" r="1.5"/><circle cx="12" cy="5" r="1.5"/><path d="M4 5v6M12 6.5c0 3-8 2-8 4.5"/></symbol>
@@ -90,6 +92,8 @@
90
92
  <nav class="primary-nav" aria-label="Product navigation">
91
93
  <button data-view="overview" class="active"><span><svg><use href="#i-grid"/></svg></span>Overview</button>
92
94
  <button data-view="runs"><span><svg><use href="#i-play"/></svg></span>Runs <i id="run-count" class="zero">0</i></button>
95
+ <button data-view="findings"><span><svg><use href="#i-alert"/></svg></span>Findings <i id="findings-count" class="zero">0</i></button>
96
+ <button data-view="coverage"><span><svg><use href="#i-map"/></svg></span>Coverage</button>
93
97
  <button data-view="platforms"><span><svg><use href="#i-grid"/></svg></span>Platforms</button>
94
98
  <button data-view="admin" id="admin-nav" class="hidden"><span><svg><use href="#i-grid"/></svg></span>Admin</button>
95
99
  </nav>
@@ -168,6 +172,21 @@
168
172
  </section>
169
173
  </section>
170
174
 
175
+ <section class="workspace-view" data-view-panel="findings">
176
+ <div class="view-heading simple">
177
+ <div><p class="eyebrow">Findings</p><h1 id="findings-title">What the last run noticed</h1><p id="findings-note">Grouped by kind, worst first. Every finding is inside a group — nothing is dropped, and nothing here is a verdict.</p></div>
178
+ <select id="findings-run" class="run-picker" aria-label="Which run"></select>
179
+ </div>
180
+ <div id="findings-body"><div class="empty">No run yet.</div></div>
181
+ </section>
182
+ <section class="workspace-view" data-view-panel="coverage">
183
+ <div class="view-heading simple">
184
+ <div><p class="eyebrow">Coverage</p><h1>Where the run went</h1><p>Each screen tapp reached, and the action that led to the next one. Drawn from the map the engine wrote during the run.</p></div>
185
+ <select id="coverage-run" class="run-picker" aria-label="Which run"></select>
186
+ </div>
187
+ <div class="coverage-counts" id="coverage-counts"></div>
188
+ <div id="coverage-body"><div class="empty">No run yet.</div></div>
189
+ </section>
171
190
  <section class="workspace-view" data-view-panel="platforms">
172
191
  <div class="view-heading simple"><div><p class="eyebrow">Platforms</p><h1>What tapp can drive</h1><p>tapp is one engine with a driver per platform. This page says what this Studio can start right now, and where the rest runs.</p></div></div>
173
192
  <div id="platform-list"><div class="empty">Checking this machine…</div></div>
@@ -16,6 +16,15 @@ export const customerProductContract = Object.freeze({
16
16
  views: [
17
17
  { id: "overview", label: "Overview", capabilities: ["target-selection", "release-check", "live-feed", "progress-transcript", "live-session", "flow-recording", "latest-evidence"] },
18
18
  { id: "runs", label: "Runs", capabilities: ["run-history", "run-detail", "evidence-page", "website-audit"] },
19
+ // Findings and Coverage are how a run is READ. The engine keeps every finding distinct, by
20
+ // type|screen|target, so a regression stays visible; that same identity makes one site-wide
21
+ // problem arrive as thirty-four lines. Findings groups them for reading and drops none of
22
+ // them. Coverage draws the screens the run reached, and the action between each pair, from
23
+ // the map the engine already wrote beside the run. Neither measures anything, and neither
24
+ // judges: they show what a run recorded (TM-794, restoring what ADR-0006 moved out on
25
+ // 2026-10-15 — the report page kept the findings but never had the map).
26
+ { id: "findings", label: "Findings", capabilities: ["finding-groups", "finding-detail", "run-selection"] },
27
+ { id: "coverage", label: "Coverage", capabilities: ["screen-map", "transition-labels", "run-selection"] },
19
28
  // Only an owner of this deployment ever sees this one (TAPP_ADMIN_EMAILS); to anybody else
20
29
  // the nav item is absent and the route is a 404.
21
30
  // Says what tapp drives, what THIS Studio can start, and what to do about the difference.
@@ -30,6 +39,8 @@ export const customerProductContract = Object.freeze({
30
39
  "Repositories are opened from the machine the Studio runs on; nothing is uploaded or cloned by the Studio.",
31
40
  "Deterministic replay and ordinary merge decisions are keyless.",
32
41
  "The admin view reports counts about this deployment; credentials are encrypted and are never decrypted to be shown.",
42
+ "Findings groups for reading only: every finding the engine reported is inside exactly one group, and grouping never changes what was found or how a finding is identified.",
43
+ "Coverage draws only transitions the engine recorded. A screen it reached with no recorded way in is shown as such, never implied to follow from the screen drawn beside it.",
33
44
  "The Platforms view states what this machine can start, computed from the machine; a platform with no driver says so in those words and is never described as needing different hardware.",
34
45
  ],
35
46
  });
@@ -108,3 +108,188 @@ export function summarize(name, result = {}, { access = "" } = {}) {
108
108
  if (report?.headline) return { tone: "neutral", pill: `${report.screensExplored || 0} screens · ${report.actionsPerformed || 0} actions · ${(report.findings || []).length} findings`, text: /not a release decision/i.test(report.headline) ? report.headline : `${report.headline} An observation, not a release decision.` };
109
109
  return { tone: "neutral", pill: "Done", text: `${name} completed.` };
110
110
  }
111
+
112
+ // ---------------------------------------------------------------------------
113
+ // Findings, grouped so a run can be read (TM-794)
114
+ // ---------------------------------------------------------------------------
115
+ // The engine keeps every finding distinct — its signature is type|screen|target, so two dead
116
+ // buttons on one screen stay two findings and fixing one while breaking the other still reads as
117
+ // a change. That identity is right for regressions and wrong for reading: one site-wide contrast
118
+ // problem arrives as thirty-four lines and buries the two things worth fixing. Grouping is
119
+ // therefore a view concern only. Nothing here drops a finding; every one of them is inside a group.
120
+
121
+ const SEVERITY_ORDER = ["critical", "high", "medium", "low", "info"];
122
+ const severityRank = (value) => {
123
+ const index = SEVERITY_ORDER.indexOf(String(value || "info").toLowerCase());
124
+ return index === -1 ? SEVERITY_ORDER.length : index;
125
+ };
126
+
127
+ function prettyType(value) {
128
+ const text = String(value || "finding").replace(/[_-]+/g, " ").trim();
129
+ return text ? text[0].toUpperCase() + text.slice(1) : "Finding";
130
+ }
131
+
132
+ // The group's name is the engine's own words where the group agrees on them: the longest prefix
133
+ // every title shares, cut back to a word boundary. Thirty-four titles starting `Hard to read: "…`
134
+ // name themselves "Hard to read". When they share too little to be a name, fall back to the type.
135
+ function groupLabel(items, type) {
136
+ const titles = items.map((item) => String(item?.title || "")).filter(Boolean);
137
+ if (!titles.length) return prettyType(type);
138
+ if (titles.length === 1) return titles[0];
139
+ let prefix = titles[0];
140
+ for (const title of titles.slice(1)) {
141
+ let index = 0;
142
+ while (index < prefix.length && index < title.length && prefix[index] === title[index]) index += 1;
143
+ prefix = prefix.slice(0, index);
144
+ if (!prefix) break;
145
+ }
146
+ // The shared prefix usually stops inside a word — `Hard to read: "S` for "Services" and
147
+ // "Scope…". Drop that partial word, unless the prefix is a whole title (identical titles on
148
+ // different screens), where the last word really is the engine's and keeping it is right.
149
+ const cut = titles.includes(prefix) ? prefix : prefix.replace(/\S+$/u, "");
150
+ const trimmed = cut.replace(/[\s"'‘’“”:;,.\-—(\[]+$/u, "").trim();
151
+ return trimmed.length >= 8 ? trimmed : prettyType(type);
152
+ }
153
+
154
+ export function groupFindings(findings = []) {
155
+ const groups = new Map();
156
+ for (const finding of findings) {
157
+ if (!finding) continue;
158
+ const type = String(finding.type || finding.category || "finding");
159
+ if (!groups.has(type)) groups.set(type, []);
160
+ groups.get(type).push(finding);
161
+ }
162
+ return [...groups.entries()]
163
+ .map(([type, items]) => {
164
+ const severity = [...items].sort((a, b) => severityRank(a.severity) - severityRank(b.severity))[0]?.severity || "info";
165
+ const screens = [...new Set(items.map((item) => item.screen).filter(Boolean))];
166
+ return {
167
+ type,
168
+ label: groupLabel(items, type),
169
+ severity: String(severity).toLowerCase(),
170
+ count: items.length,
171
+ screens,
172
+ // Worst first inside the group too, so opening it does not start on a trailing low.
173
+ items: [...items].sort((a, b) => severityRank(a.severity) - severityRank(b.severity)),
174
+ };
175
+ })
176
+ .sort((a, b) => severityRank(a.severity) - severityRank(b.severity) || b.count - a.count || a.label.localeCompare(b.label));
177
+ }
178
+
179
+ // The row of counts above the list, worst kind first. It is counted from the findings
180
+ // themselves, so it can never claim a severity the list below it does not show.
181
+ export function severityTally(items = []) {
182
+ const counts = new Map();
183
+ for (const item of items) {
184
+ if (!item) continue;
185
+ const severity = String(item.severity || "info").toLowerCase();
186
+ counts.set(severity, (counts.get(severity) || 0) + 1);
187
+ }
188
+ return [...counts.entries()]
189
+ .sort(([a], [b]) => severityRank(a) - severityRank(b))
190
+ .map(([severity, count]) => ({ severity, count }));
191
+ }
192
+
193
+ // ---------------------------------------------------------------------------
194
+ // Coverage: the shape of what a run walked through (TM-794)
195
+ // ---------------------------------------------------------------------------
196
+ // Every capture already holds the map the engine built from its own markers: screens it reached,
197
+ // and the action that led from one to the next. Nothing here measures anything — it arranges what
198
+ // the engine recorded into columns by distance from the screen the run started on, and joins each
199
+ // screen to the stills written beside it. A screen the engine saw but never recorded a way into
200
+ // is listed as such rather than quietly placed next to the others.
201
+
202
+ const screenKey = (value) => String(value || "").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
203
+
204
+ // `tap "Pricing"`, `open /solutions`, `back` — the engine's own action, not a sentence about it.
205
+ export function transitionLabel(action = {}) {
206
+ const type = String(action?.type || "").trim() || "goes to";
207
+ const target = String(action?.target || "").trim();
208
+ return target ? `${type} “${target}”` : type;
209
+ }
210
+
211
+ export function coverageGraph(uiMap, shots = [], { platform = "" } = {}) {
212
+ const nodes = Array.isArray(uiMap?.nodes) ? uiMap.nodes : [];
213
+ const edges = Array.isArray(uiMap?.edges) ? uiMap.edges : [];
214
+ if (!nodes.length) return { screens: [], columns: [], counts: { screens: 0, transitions: 0 }, entryId: "", unreachable: [] };
215
+
216
+ // The stills are named for the screen they are of (`state_3_pricing.png`), which is the node's
217
+ // own key with its separators spelled differently. Match on that and nothing cleverer: a screen
218
+ // with no still shows as a named card, never as a guess at someone else's picture.
219
+ const byKey = new Map();
220
+ for (const shot of shots) {
221
+ const key = screenKey(shot?.caption);
222
+ if (!key) continue;
223
+ if (!byKey.has(key)) byKey.set(key, []);
224
+ byKey.get(key).push(shot.src);
225
+ }
226
+
227
+ const entryId = uiMap?.app?.entryNodes?.[platform] || Object.values(uiMap?.app?.entryNodes || {})[0] || nodes[0].id;
228
+ const outgoing = new Map(nodes.map((node) => [node.id, []]));
229
+ for (const edge of edges) {
230
+ if (!outgoing.has(edge?.from)) continue;
231
+ outgoing.get(edge.from).push(edge);
232
+ }
233
+
234
+ const depth = new Map([[entryId, 0]]);
235
+ let frontier = [entryId];
236
+ while (frontier.length) {
237
+ const next = [];
238
+ for (const id of frontier) {
239
+ for (const edge of outgoing.get(id) || []) {
240
+ if (!edge?.to || depth.has(edge.to) || !outgoing.has(edge.to)) continue;
241
+ depth.set(edge.to, depth.get(id) + 1);
242
+ next.push(edge.to);
243
+ }
244
+ }
245
+ frontier = next;
246
+ }
247
+
248
+ const reachedDepth = Math.max(0, ...[...depth.values()]);
249
+ const unreachable = nodes.filter((node) => !depth.has(node.id)).map((node) => node.id);
250
+ const nameById = new Map(nodes.map((node) => [node.id, node.name || node.semanticKey || node.id]));
251
+
252
+ const screens = nodes.map((node) => {
253
+ const key = screenKey(node.semanticKey || node.name);
254
+ // The engine marks a screen it met in a second structural state (`variant`, with the screen it
255
+ // is a state of in `baseSemanticKey`). The stills are captioned by title, so they cannot tell
256
+ // those apart. Fall back to the base screen's still for a variant and say that is what it is,
257
+ // rather than either showing nothing or implying the picture is of this exact state.
258
+ const base = node.variant ? screenKey(node.baseSemanticKey) : "";
259
+ const matched = byKey.get(key) || (base ? byKey.get(base) || [] : []);
260
+ const borrowed = !(byKey.get(key) || []).length && matched.length > 0;
261
+ return {
262
+ id: node.id,
263
+ name: node.stateLabel || node.name || node.semanticKey || "Screen",
264
+ key: node.semanticKey || key,
265
+ variantOf: node.variant ? (node.name || node.baseSemanticKey || "") : "",
266
+ // A screen the run never found a recorded way into sits in a column of its own, after the
267
+ // ones it did — never implied to follow from the last screen simply by being drawn there.
268
+ column: depth.has(node.id) ? depth.get(node.id) : reachedDepth + 1,
269
+ reached: depth.has(node.id),
270
+ shot: matched[0] || null,
271
+ shotCount: matched.length,
272
+ // True when the picture is of this screen in a different state than the one recorded here.
273
+ shotIsOfBaseScreen: borrowed,
274
+ controls: (node.controls || []).length,
275
+ outgoing: (outgoing.get(node.id) || []).map((edge) => ({
276
+ label: transitionLabel(edge.action),
277
+ to: edge.to,
278
+ toName: nameById.get(edge.to) || "",
279
+ })),
280
+ };
281
+ });
282
+
283
+ const columns = [];
284
+ for (const screen of screens) {
285
+ (columns[screen.column] ||= []).push(screen.id);
286
+ }
287
+
288
+ return {
289
+ screens,
290
+ columns: columns.map((column) => column || []),
291
+ counts: { screens: nodes.length, transitions: edges.length },
292
+ entryId,
293
+ unreachable,
294
+ };
295
+ }
@@ -1,6 +1,7 @@
1
1
  # Browser Studio
2
2
 
3
- Status: current product contract as of 2026-10-19 (ADR-0006, owner decision, amended). Supersedes
3
+ Status: current product contract as of 2026-11-15 (ADR-0006, owner decision, amended twice:
4
+ 2026-10-19, and TM-794 on 2026-11-15 bringing Findings and Coverage back). Supersedes
4
5
  the "desktop-parity Command Center" framing of 2026-10-14.
5
6
 
6
7
  The Studio in `browser/` is the one browser surface. It is a **run viewer**: point Tapp at a
@@ -44,6 +45,8 @@ refuses what the mode cannot do: a hosted Studio cannot open a path or a build o
44
45
  |---|---|---|
45
46
  | Overview | The **stage**: the device as large as the window allows, in its platform's aspect ratio (phone portrait for iOS and Android, browser landscape for web), showing the live frame or the newest screenshot the run wrote. The **chat** floats over its corner on a translucent ground, collapses to a pill, and narrates the engine's own progress log one emoji-led line at a time (👆 Tapped, ⌨️ Typed, 🔐 Signed in, 📍 Opened, 🧭 Reached, 📸 screenshots inline), then attaches the recording and `report.html` and ends with a pill — `✓ Ready to merge`, `× Do not merge`, `◐ Inconclusive`, or for an exploration its counts — and the headline. Nothing is generated after the fact and nothing is a score. Below the stage: the detected targets (an explicit choice when there are several), the live-session controls, and the current decision from the last gate. | `open`, `initialize` (inspect, then build + explore), `explore-build`, live session `start / act / save-flow / end`, release check |
46
47
  | Runs | Every run on this repository, every exploration started from the prompt, and every read-only website audit, newest first; each opens its evidence page. A URL field runs an audit from here. | `gate`, `audit` |
48
+ | Findings | What the selected run reported, **grouped by kind** and worst first: one row per kind with the count of places it covers (`Hard to read · 34 · 4 screens`), opening onto every individual place. The engine's identity for a finding is `type|screen|target`, so one site-wide problem arrives as dozens of lines and buries the two worth fixing; grouping is a reading aid in the view and drops nothing — every finding is inside exactly one group. A read-only audit's two kinds stay apart, as the engine draws them: **Broken** (structural defects) and **Worth a look** (not broken; what a person would notice). Never a verdict. | — |
49
+ | Coverage | The screens the selected run reached, in columns by distance from the screen it started on, each a card with the still the run wrote and the actions that led on from it (`tap "Pricing" → Pricing`). Built from the `ui-map.json` the engine writes into every capture: `nodes` are screens, `edges` the recorded transitions. Only recorded transitions are drawn — a screen reached with no recorded way in gets its own column and says so, and a run with no transitions at all (a read-only audit clicks nothing) is a plain grid of what it opened, with the reason stated. | — |
47
50
 
48
51
  A **website audit** is `explore --read-only`: up to twenty same-origin pages (twelve by default) are rendered and read —
49
52
  dead controls, broken images/assets/links, failed requests, JS exceptions, mixed content,
@@ -54,12 +57,20 @@ real small-business sites in October 2026; the remaining findings were verified
54
57
 
55
58
  ## What was removed, and where it lives instead
56
59
 
57
- The Contracts, Coverage and Settings views, the six-step journey stepper, and the folder-upload,
60
+ The Contracts and Settings views, the six-step journey stepper, and the folder-upload,
58
61
  GitHub-clone and remote-runner onboarding were removed on 2026-10-15. Reviewing and promoting
59
- contracts is `tapp plan` / `tapp validate` in the repository; coverage is on every run's
60
- `report.html`; actors and credentials live in `.tapp/project.json`; CI installation is `tapp ci`.
61
- The Studio keeps only what a browser does better than a terminal: watching a real device while a
62
- run happens, driving it by hand, and reading evidence.
62
+ contracts is `tapp plan` / `tapp validate` in the repository; actors and credentials live in
63
+ `.tapp/project.json`; CI installation is `tapp ci`. The Studio keeps only what a browser does
64
+ better than a terminal: watching a real device while a run happens, driving it by hand, and
65
+ reading evidence.
66
+
67
+ **Findings and Coverage came back on 2026-11-15** (TM-794, owner decision). They were removed in
68
+ the same pass on the argument that `report.html` already carried them. It carries the findings —
69
+ as the same flat list, which is the problem — and it never carried the map at all: the engine has
70
+ written `ui-map.json` into every capture throughout, and nothing drew it. Reading a run is a thing
71
+ a browser does better than a terminal, so it belongs to the same rule as the rest of the Studio.
72
+ Neither view computes anything: Findings groups what the engine reported, Coverage arranges the
73
+ map it wrote. Neither judges — only the gate does.
63
74
 
64
75
  ## Verified reference journey
65
76
 
@@ -68,7 +79,9 @@ target choice, exploration, a live session that records a Flow, the gate, and th
68
79
  `tests/browser-onboarding.test.js` covers the no-repository start and a read-only website audit;
69
80
  `tests/browser-product.test.js` covers authentication, CSRF, the audit operation and the removed
70
81
  endpoints answering 404. `tests/browser-chat-narration.test.js` covers prompt classification and
71
- the chat's narration and summary without a browser.
82
+ the chat's narration and summary without a browser, and
83
+ `tests/browser-run-reading.test.js` covers finding groups and the coverage graph the same way —
84
+ the browser journey then drives both views against a real run.
72
85
 
73
86
  ## Hosted relationship
74
87
 
@@ -25,6 +25,24 @@ export function parseFlowSteps(logText) {
25
25
  return steps;
26
26
  }
27
27
 
28
+ /**
29
+ * When the flow's steps actually began, on the wall clock, or null.
30
+ *
31
+ * The CLI cannot use its own "now": on iOS it spawns xcodebuild, which builds and launches the
32
+ * harness before a single step runs — most of a minute in which the recorder is already rolling.
33
+ * The runner says when it really started, and this reads it back.
34
+ */
35
+ export function flowStartedAtEpochMs(logText) {
36
+ for (const line of String(logText || "").split("\n")) {
37
+ if (!line.startsWith("OCQA_FLOW_CLOCK:")) continue;
38
+ try {
39
+ const value = Number(JSON.parse(line.slice("OCQA_FLOW_CLOCK:".length)).startedAtEpochMs);
40
+ if (Number.isFinite(value) && value > 0) return value;
41
+ } catch { /* a truncated line */ }
42
+ }
43
+ return null;
44
+ }
45
+
28
46
  /**
29
47
  * The same steps expressed in the recording's seconds.
30
48
  *
@@ -55,13 +73,19 @@ export function sidecarPath(videoPath) {
55
73
  return path.join(parsed.dir, `${parsed.name}.steps.json`);
56
74
  }
57
75
 
58
- export function writeStepsSidecar(videoPath, steps, { flowStartedAtMs, recordingStartedAtMs, holdMs = 0, name = "" } = {}) {
76
+ export function writeStepsSidecar(videoPath, steps, { flowStartedAtMs, recordingStartedAtMs, holdMs = 0, name = "", videoDurationMs = null } = {}) {
59
77
  const inVideoTime = stepsInVideoTime(steps, { flowStartedAtMs, recordingStartedAtMs });
78
+ // What a cut must not run past. Prefer the finished file's own duration: the tail is produced by
79
+ // re-encoding, which lands within about a second of what was asked for, and a sidecar that
80
+ // claims more than the file holds sends an editor past the end.
81
+ const computedEnd = inVideoTime.length ? inVideoTime[inVideoTime.length - 1].end + holdMs / 1000 : 0;
82
+ const endsAt = Number.isFinite(videoDurationMs) && videoDurationMs > 0
83
+ ? Math.min(computedEnd, videoDurationMs / 1000)
84
+ : computedEnd;
60
85
  const out = {
61
86
  video: path.basename(String(videoPath)),
62
87
  name,
63
- // What a cut should not run past: the last step's end plus whatever hold was asked for.
64
- endsAt: inVideoTime.length ? Number((inVideoTime[inVideoTime.length - 1].end + holdMs / 1000).toFixed(3)) : 0,
88
+ endsAt: Number(endsAt.toFixed(3)),
65
89
  holdSeconds: holdMs / 1000,
66
90
  steps: inVideoTime,
67
91
  };
@@ -44,7 +44,10 @@ export const FLOW_ACTIONS = Object.freeze([
44
44
  { action: "tap", target: "a visible label / accessibility id", passes: "the control was found and tapped; coordinates are not accepted — use the session's tap-by-point to learn the label" },
45
45
  { action: "type", target: "{field, value}", passes: "the field was found and now holds the value ($TEST_EMAIL/$TEST_PASSWORD substitute)" },
46
46
  { action: "login", target: "{email, password} (defaults to $TEST_EMAIL/$TEST_PASSWORD)", passes: "credentials were entered and submitted and the login form went away" },
47
- { action: "swipe", target: "up | down | left | right", passes: "the gesture was performed" },
47
+ { action: "swipe", target: "up | down | left | right (web: + {within} to scroll a drawer or modal)", passes: "the gesture was performed, and on web the thing actually moved" },
48
+ { action: "press", target: "a key (`press: ArrowRight`), or {key, target} to focus a control first (+ {times}); not `on:`, which YAML reads as true", passes: "the key was pressed; web only — this is what drives a slider or a shortcut" },
49
+ { action: "drag", target: "{from, by: [dx, dy]} or {from, to}", passes: "the control was dragged in steps, so listeners watching movement fire; web only — typing into a range input sets its value without the handle moving. This says the gesture was made, not that the page reacted: assert after it" },
50
+ { action: "screenshot", target: "a name for the picture", passes: "a viewport-sized picture was saved beside the run's evidence; web only" },
48
51
  { action: "back", target: "(none)", passes: "the platform back navigation was performed" },
49
52
  { action: "wait", target: "milliseconds (fixed pause; prefer wait_for)", passes: "always" },
50
53
  { action: "wait_for", target: "label / text (+ per-step timeoutMs/timeout; flow-level timeoutMs sets the default)", passes: "the element appeared before the timeout" },
@@ -75,8 +78,18 @@ export function isOptionalStep(step) {
75
78
  return Boolean(step?.params?.optional === true || step?.params?.optional === "true");
76
79
  }
77
80
 
81
+ /** What `alerts:` may say. Anything else is a typo that would silently do nothing (TM-497). */
82
+ export const ALERT_MODES = Object.freeze(["allow", "dismiss"]);
83
+
78
84
  export function validateFlowSteps(flow, platform = inferFlowPlatform(flow)) {
79
85
  const errors = [];
86
+ const alerts = String(flow?.alerts ?? "").trim();
87
+ if (alerts && !ALERT_MODES.includes(alerts.toLowerCase())) {
88
+ errors.push(`alerts: '${alerts}' is not a setting — use ${ALERT_MODES.map((m) => `alerts: ${m}`).join(" or ")}`);
89
+ }
90
+ if (alerts && platform !== "ios") {
91
+ errors.push(`alerts: applies to iOS flows, where a system alert belongs to the operating system rather than the app (this flow is ${platform})`);
92
+ }
80
93
  const steps = Array.isArray(flow?.steps) ? flow.steps : [];
81
94
  steps.forEach((raw, i) => {
82
95
  const step = normalizeFlowStep(raw);
@@ -182,6 +195,10 @@ export class FlowLog {
182
195
  this.criticality = flow.releaseContract?.criticality || "";
183
196
  this.kind = this.contract ? "release-contract" : flow.kind || "flow";
184
197
  this.emit(`OCQA_FLOW_RESULT:started total=${flow.steps.length} name=${flow.name || "flow"} kind=${this.kind}${this.contract ? ` contract=${this.contract}` : ""}`);
198
+ // When the steps actually began, on the wall clock (TM-497). Step times are relative to this,
199
+ // and a recorder started by the CLI knows nothing else about it: on iOS the CLI's own "now" is
200
+ // most of a minute earlier, because building and launching the harness happens in between.
201
+ this.emit(`OCQA_FLOW_CLOCK:${JSON.stringify({ startedAtEpochMs: Date.now() })}`);
185
202
  }
186
203
 
187
204
  emit(line) {