@aarwitz/tapp 0.17.0-rc.1 → 0.17.0-rc.3

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.
@@ -984,7 +984,10 @@ async function runExploreStreaming(bundleId, actions, timeout, env, onProgress)
984
984
  const before = new Set(listCaptureRuns(80).map((r) => r.id));
985
985
  const proc = spawn("bash", cmdArgs, { cwd: repoRoot, env: { ...process.env, ...env } });
986
986
  proc.stdout.on("data", () => {});
987
- proc.stderr.on("data", () => {});
987
+ let captureStderr = "";
988
+ proc.stderr.on("data", (chunk) => {
989
+ captureStderr = (captureStderr + chunk.toString("utf8")).slice(-8_000);
990
+ });
988
991
  const closed = new Promise((res) => proc.on("close", (code) => res(code ?? 1)));
989
992
 
990
993
  let captureDir = null;
@@ -1037,7 +1040,18 @@ async function runExploreStreaming(bundleId, actions, timeout, env, onProgress)
1037
1040
  await closed;
1038
1041
  const created = listCaptureRuns(80).find((r) => !before.has(r.id))
1039
1042
  || (captureDir ? { id: path.basename(captureDir), path: captureDir, relativePath: path.relative(repoRoot, captureDir) } : null);
1040
- return { created, timedOut };
1043
+ return { created, timedOut, captureStderr };
1044
+ }
1045
+
1046
+ export function recordingUnavailableReason(stderr = "") {
1047
+ const text = String(stderr);
1048
+ if (/resource busy|host recording is already in progress/i.test(text)) {
1049
+ return "the simulator recorder is busy with another host recording";
1050
+ }
1051
+ if (/could not start simulator video recording/i.test(text)) {
1052
+ return "the simulator could not start video recording";
1053
+ }
1054
+ return "the simulator did not produce a recording";
1041
1055
  }
1042
1056
 
1043
1057
  // Grab the booted simulator's current screen and return it downscaled + JPEG-compressed so the
@@ -1318,7 +1332,7 @@ export function qaNextSteps(report, surface = "mcp") {
1318
1332
  return next;
1319
1333
  }
1320
1334
 
1321
- function formatQaReport(report, { regression, inputHint, timedOut, bundleId, aiConfigured, reportHtml, recording, uiMap, surface = "mcp" } = {}) {
1335
+ function formatQaReport(report, { regression, inputHint, timedOut, bundleId, aiConfigured, reportHtml, recording, recordingWarning, uiMap, surface = "mcp" } = {}) {
1322
1336
  const c = report.findingCounts || {};
1323
1337
  const badge = observationBadge(report);
1324
1338
  const sevBits = ["critical", "high", "medium", "low"]
@@ -1338,6 +1352,7 @@ function formatQaReport(report, { regression, inputHint, timedOut, bundleId, aiC
1338
1352
  if (uiMap) L.push(`**UI Map** — ${uiMap.nodeCount} states · ${uiMap.edgeCount} transitions · ${uiMap.controlCount} semantic controls · ${uiMap.path}`);
1339
1353
  if (reportHtml) L.push(`**Evidence** — 📄 ${reportHtml} (screenshots of every screen + findings, shareable)`);
1340
1354
  if (recording) L.push(`**Recording** — 🎬 ${recording} (full exploration, embedded in the evidence page)`);
1355
+ else if (recordingWarning) L.push(`**Recording** — ⚠️ unavailable: ${recordingWarning}; screenshots were still captured`);
1341
1356
  L.push(`**Issues** — ${c.total ? `${c.total}${sevBits ? ` (${sevBits})` : ""}` : "none found ✨"}`);
1342
1357
  if (Array.isArray(report.findings) && report.findings.length) {
1343
1358
  L.push("");
@@ -1367,7 +1382,7 @@ function formatQaReport(report, { regression, inputHint, timedOut, bundleId, aiC
1367
1382
  L.push("");
1368
1383
  L.push(`> ℹ️ ${inputHint}`);
1369
1384
  }
1370
- // The honesty label: a "ready" is a claim about exactly these classes, nothing more.
1385
+ // The observation's scope: enumerate exactly what ran and what remains unchecked.
1371
1386
  if (Array.isArray(report.checkedFor) && report.checkedFor.length) {
1372
1387
  L.push("");
1373
1388
  L.push(`> ✅ Checked: ${report.checkedFor.join(" · ")}`);
@@ -1381,11 +1396,10 @@ function formatQaReport(report, { regression, inputHint, timedOut, bundleId, aiC
1381
1396
  const next = qaNextSteps(report, surface);
1382
1397
  L.push("");
1383
1398
  L.push(`**Next** — ${next.join(" · ")}`);
1384
- // The gate hook belongs at the moment the user thinks "I want this on every PR" —
1385
- // i.e. right after a verdict that found something, or after they hand-diffed a baseline.
1399
+ // The gate hook belongs at the moment the user thinks "I want these checks on every PR".
1386
1400
  if ((report.findings && report.findings.length) || regression) {
1387
1401
  L.push("");
1388
- L.push("> 🚦 Teams: get this verdict on every PR automatically (evidence + regression gate) — https://github.com/aarwitz/tapp#ci-gate");
1402
+ L.push("> 🚦 Teams: run these checks plus reviewed release contracts as a merge gate on every PR — https://github.com/aarwitz/tapp#ci-gate");
1389
1403
  }
1390
1404
  return L.join("\n");
1391
1405
  }
@@ -1466,7 +1480,7 @@ export async function runQaWeb({ url, maxActions, timeout, testEmail, testPasswo
1466
1480
  } catch (err) {
1467
1481
  return { error: String(err.message || err) };
1468
1482
  }
1469
- const report = buildQaReport(webResult.markersPath, { platform: "web" });
1483
+ const report = buildQaReport(webResult.markersPath, { platform: "web", target: url.trim() });
1470
1484
  if (!report) return { error: "Web exploration produced no markers", details: { capture: { id, path: outDir } } };
1471
1485
  const backend = remoteAiOptedIn() ? resolveModelBackend() : null;
1472
1486
  if (backend && report.findings.length) {
@@ -1509,7 +1523,7 @@ export async function runQaAndroid({ appId, apkPath, serial, maxActions, timeout
1509
1523
  } catch (error) {
1510
1524
  return { error: error.message || String(error), details: { capture: { id, path: outDir } } };
1511
1525
  }
1512
- const report = buildQaReport(androidResult.markersPath, { platform: "android" });
1526
+ const report = buildQaReport(androidResult.markersPath, { platform: "android", target: appId.trim() });
1513
1527
  if (!report) return { error: "Android exploration produced no markers", details: { capture: { id, path: outDir } } };
1514
1528
  const backend = remoteAiOptedIn() ? resolveModelBackend() : null;
1515
1529
  if (backend && report.findings.length) {
@@ -1541,10 +1555,10 @@ export async function runQaIos({ bundleId, maxActions, timeout, args = {}, surfa
1541
1555
  const timeoutSec = Math.max(30, Math.min(3600, asInteger(timeout, 600)));
1542
1556
  const env = explorationEnvFromArgs(args);
1543
1557
 
1544
- const { created, timedOut } = await runExploreStreaming(bundleId, actions, timeoutSec, env, onProgress);
1558
+ const { created, timedOut, captureStderr } = await runExploreStreaming(bundleId, actions, timeoutSec, env, onProgress);
1545
1559
  if (!created) return { error: "Exploration produced no capture run", details: { timedOut } };
1546
1560
 
1547
- const report = buildQaReport(path.join(created.path, "ocqa-markers.txt"));
1561
+ const report = buildQaReport(path.join(created.path, "ocqa-markers.txt"), { platform: "ios", target: bundleId });
1548
1562
  if (!report) {
1549
1563
  return {
1550
1564
  error: "No markers parsed from exploration (the app may not have launched)",
@@ -1574,13 +1588,14 @@ export async function runQaIos({ bundleId, maxActions, timeout, args = {}, surfa
1574
1588
  // Cross-run regression vs. a caller-supplied baseline (the CI gate).
1575
1589
  const regression = computeRegression(report.findings, args.baselineFindings);
1576
1590
  const uiMap = await writeRunUiMap({ markersPath: path.join(created.path, "ocqa-markers.txt"), platform: "ios", target: bundleId, runId: created.id, outDir: created.path });
1591
+ const recording =
1592
+ ["exploration.webm", "exploration.mov"].map((f) => path.join(created.path, f)).find((p) => fs.existsSync(p)) || null;
1593
+ const recordingWarning = recording ? null : recordingUnavailableReason(captureStderr);
1577
1594
  let reportHtml = null;
1578
1595
  try {
1579
1596
  const { writeHtmlReport } = await import("./html-report.js");
1580
- reportHtml = writeHtmlReport(created.path, { report, label: bundleId });
1597
+ reportHtml = writeHtmlReport(created.path, { report, label: bundleId, recordingWarning });
1581
1598
  } catch { /* evidence page is best-effort */ }
1582
- const recording =
1583
- ["exploration.webm", "exploration.mov"].map((f) => path.join(created.path, f)).find((p) => fs.existsSync(p)) || null;
1584
1599
  const structured = {
1585
1600
  ...report,
1586
1601
  regression,
@@ -1588,11 +1603,12 @@ export async function runQaIos({ bundleId, maxActions, timeout, args = {}, surfa
1588
1603
  inputHint,
1589
1604
  reportHtml,
1590
1605
  recording,
1606
+ recordingWarning,
1591
1607
  capture: { id: created.id, path: created.path, relativePath: created.relativePath },
1592
1608
  timedOut,
1593
1609
  autoBooted: sim.autoBooted || false,
1594
1610
  };
1595
- const text = formatQaReport(report, { regression, inputHint, timedOut, bundleId, aiConfigured: !!backend, reportHtml, recording, uiMap: uiMap.error ? null : uiMap, surface });
1611
+ const text = formatQaReport(report, { regression, inputHint, timedOut, bundleId, aiConfigured: !!backend, reportHtml, recording, recordingWarning, uiMap: uiMap.error ? null : uiMap, surface });
1596
1612
  return { structured, text };
1597
1613
  }
1598
1614
 
@@ -1753,6 +1769,8 @@ export async function runExploreTarget({
1753
1769
  timeout,
1754
1770
  testEmail,
1755
1771
  testPassword,
1772
+ appLaunchArgs,
1773
+ appLaunchEnv,
1756
1774
  baselineFindings,
1757
1775
  surface = "cli",
1758
1776
  onProgress = () => {},
@@ -1776,6 +1794,10 @@ export async function runExploreTarget({
1776
1794
  catch (error) { return { error: error.message || String(error) }; }
1777
1795
  const selectedPlatform = selected.platform;
1778
1796
 
1797
+ if (selectedPlatform !== "ios" && ((Array.isArray(appLaunchArgs) && appLaunchArgs.length) || (appLaunchEnv && Object.keys(appLaunchEnv).length))) {
1798
+ return { error: "appLaunchArgs/appLaunchEnv apply only to iOS targets." };
1799
+ }
1800
+
1779
1801
  if (selectedPlatform === "web") {
1780
1802
  const ownedUrl = String(selected.runtime?.ownedUrl || "").trim();
1781
1803
  if (/^https?:\/\//i.test(ownedUrl)) {
@@ -1818,7 +1840,7 @@ export async function runExploreTarget({
1818
1840
  const resolved = await resolveAppTarget(root, { cwd: root, onStatus, scheme, configuration });
1819
1841
  if (resolved.error) return resolved;
1820
1842
  if (resolved.via) onStatus(`Target ${resolved.bundleId} — ${resolved.via}`);
1821
- return runQaIos({ bundleId: resolved.bundleId, maxActions, timeout, args: { testEmail, testPassword, baselineFindings }, surface, onProgress });
1843
+ return runQaIos({ bundleId: resolved.bundleId, maxActions, timeout, args: { testEmail, testPassword, baselineFindings, appLaunchArgs, appLaunchEnv }, surface, onProgress });
1822
1844
  }
1823
1845
 
1824
1846
  function openLocalPort() {
@@ -2949,12 +2971,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
2949
2971
  // MCP concerns: auth, arg validation, and progress notifications.
2950
2972
  const progressToken = request.params && request.params._meta ? request.params._meta.progressToken : undefined;
2951
2973
  const budget = Math.max(1, Math.min(1000, asInteger(args.maxActions, 60)));
2952
- const notifyProgress = (unit) => (p) => {
2974
+ const notifyProgress = (metric) => (p) => {
2953
2975
  if (progressToken === undefined) return;
2954
2976
  const total = p.max || budget;
2955
2977
  server.notification({
2956
2978
  method: "notifications/progress",
2957
- params: { progressToken, progress: p.action || 0, total, message: `🔍 Exploring… ${p.action}/${total} actions · ${p.states} ${unit} reached` },
2979
+ params: { progressToken, progress: p.action || 0, total, message: `🔍 Exploring… ${p.action}/${total} actions · ${p.states} ${metric}` },
2958
2980
  }).catch(() => {});
2959
2981
  };
2960
2982
  if (wantsWeb) {
@@ -2965,7 +2987,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
2965
2987
  testEmail: args.testEmail,
2966
2988
  testPassword: args.testPassword,
2967
2989
  baselineFindings: args.baselineFindings,
2968
- onProgress: notifyProgress("pages"),
2990
+ onProgress: notifyProgress("pages reached"),
2969
2991
  });
2970
2992
  if (r.error) return errorResult(r.error, r.details || {});
2971
2993
  return richResult(r.text, r.structured);
@@ -2982,14 +3004,14 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
2982
3004
  testPassword: args.testPassword,
2983
3005
  baselineFindings: args.baselineFindings,
2984
3006
  clearData: args.clearData !== false,
2985
- onProgress: notifyProgress("screens"),
3007
+ onProgress: notifyProgress("screens reached"),
2986
3008
  });
2987
3009
  if (r.error) return errorResult(r.error, r.details || {});
2988
3010
  return richResult(r.text, r.structured);
2989
3011
  }
2990
3012
 
2991
3013
  let lastProgress = null;
2992
- const iosProgress = notifyProgress("screens");
3014
+ const iosProgress = notifyProgress("structural states observed");
2993
3015
  const r = await runQaIos({
2994
3016
  bundleId: String(args.appBundleId).trim(),
2995
3017
  maxActions: args.maxActions,
@@ -3686,7 +3708,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
3686
3708
  if (isNonEmptyString(args.apkPath)) await driver.install(path.resolve(args.apkPath));
3687
3709
  const snap = await driver.launch({ clearData: args.clearData === true });
3688
3710
  const data = await driver.screenshot();
3689
- await driver.forceStop().catch(() => {});
3690
3711
  return {
3691
3712
  content: [
3692
3713
  { type: "text", text: `🚀 Launched \`${appId}\` (Android)\n\n` + formatScreen(snap.screenTitle, snap.elements) },
@@ -428,16 +428,17 @@ export function adoptPrCoverageProposal({ projectDir, prPlanPath, item, releaseP
428
428
  if (!ground || !fs.existsSync(mapPath)) throw new Error("Coverage proposal requires the repository's persistent UI Map");
429
429
  const map = JSON.parse(fs.readFileSync(mapPath, "utf8"));
430
430
  const node = (map.nodes || []).find((candidate) => candidate.id === ground.id && candidate.status !== "proposed");
431
- if (!node) throw new Error(`Coverage proposal UI Map node is stale or missing: ${ground.id}`);
431
+ const refreshAdvice = "refresh the persistent UI Map with `tapp init --explore --refresh`, rerun `tapp pr gate`, then retry `tapp pr adopt`";
432
+ if (!node) throw new Error(`Coverage proposal UI Map node is stale or missing: ${ground.id}; ${refreshAdvice}`);
432
433
  if (target.navigation?.route && !(node.routes || []).some((route) => route.platform === target.platform && route.path === target.navigation.route && route.replayable === true)) {
433
- throw new Error(`Coverage proposal route is stale in the persistent UI Map: ${target.navigation.route}`);
434
+ throw new Error(`Coverage proposal route is stale in the persistent UI Map: ${target.navigation.route}; ${refreshAdvice}`);
434
435
  }
435
436
  if (target.navigation?.mode === "ui-map-path") {
436
437
  const currentNavigation = replayableUiMapNavigation(map, node.id, target.platform);
437
438
  const expectedEdges = (target.navigation.steps || []).map((step) => step.edgeId);
438
439
  const currentEdges = (currentNavigation.steps || []).map((step) => step.edgeId);
439
440
  if (currentNavigation.status !== "replayable" || JSON.stringify(expectedEdges) !== JSON.stringify(currentEdges)) {
440
- throw new Error(`Coverage proposal UI Map path is stale for ${node.name}`);
441
+ throw new Error(`Coverage proposal UI Map path is stale for ${node.name}; ${refreshAdvice}`);
441
442
  }
442
443
  }
443
444
  const releasePlan = JSON.parse(fs.readFileSync(targetPath, "utf8"));
@@ -1,6 +1,6 @@
1
1
  // Pure report/gate logic shared by the MCP server (index.js) and the CI gate CLI
2
- // (ci-report.js). Turns a capture's OCQA markers into the same ship/no-ship report the Tapp
3
- // app produces, and diffs two runs' findings into the CI regression gate. No shell, no server —
2
+ // (ci-report.js). Turns a capture's OCQA markers into a scoreless exploration observation,
3
+ // and applies explicit policy separately in the CI gate. No shell, no server —
4
4
  // keep it dependency-free so the CI path stays importable and testable.
5
5
  import fs from "fs";
6
6
  import path from "path";
@@ -133,9 +133,9 @@ export function observationSummary(report) {
133
133
  return `${report?.screensExplored || 0} screens · ${report?.actionsPerformed || 0} actions · ${n} finding(s) · observation only`;
134
134
  }
135
135
 
136
- // Turn a capture's OCQA markers into the same ship/no-ship report Tapp produces:
137
- // deduped findings + a trustworthy verdict with a coverage floor (mirrors OrchestratorService).
138
- export function buildQaReport(markersFilePath, { platform = "ios" } = {}) {
136
+ // Turn a capture's OCQA markers into a scoreless observation with deduped findings and an
137
+ // explicit coverage floor. Release judgment is applied later by evaluateGate.
138
+ export function buildQaReport(markersFilePath, { platform = "ios", target = null } = {}) {
139
139
  const base = parseOcqaMarkers(markersFilePath);
140
140
  if (!base) return null;
141
141
 
@@ -145,6 +145,7 @@ export function buildQaReport(markersFilePath, { platform = "ios" } = {}) {
145
145
  const inputsByScreen = new Map();
146
146
  const screenElementCounts = {}; // screen -> max elements observed (content-collapse detection)
147
147
  let anySecure = false;
148
+ let loginAttempted = false;
148
149
  let actions = 0;
149
150
 
150
151
  for (const line of raw.split(/\r?\n/)) {
@@ -163,6 +164,17 @@ export function buildQaReport(markersFilePath, { platform = "ios" } = {}) {
163
164
  }
164
165
  } else if (t.startsWith("OCQA_ACTION:")) {
165
166
  actions += 1;
167
+ try {
168
+ const action = JSON.parse(t.slice("OCQA_ACTION:".length));
169
+ if (action?.type === "login" || String(action?.type || "").startsWith("login_")) loginAttempted = true;
170
+ } catch {
171
+ /* ignore malformed */
172
+ }
173
+ } else if (
174
+ t === "OCQA_STATE:login_preamble_submitted" ||
175
+ t === "OCQA_STATE:login_preamble_two_step_submitted"
176
+ ) {
177
+ loginAttempted = true;
166
178
  } else if (t.startsWith("OCQA_STATE:{")) {
167
179
  try {
168
180
  const s = JSON.parse(t.slice("OCQA_STATE:".length));
@@ -202,7 +214,12 @@ export function buildQaReport(markersFilePath, { platform = "ios" } = {}) {
202
214
  const missingResources = new Set(normalizedIssues
203
215
  .filter((issue) => issue.type === "missing_asset" && issue.target)
204
216
  .map((issue) => issue.target));
217
+ // Older native captures represented the caller's wall-clock budget as a high-severity app
218
+ // finding. A timeout makes the evidence partial/inconclusive; it does not prove an app
219
+ // performance defect (the harness has a separate app_hang detector for that).
220
+ const timeBudgetExhausted = base.complete?.timedOut === true || normalizedIssues.some((issue) => issue.type === "explore_timeout");
205
221
  const reportIssues = normalizedIssues.filter((issue) =>
222
+ issue.type !== "explore_timeout" &&
206
223
  !(issue.type === "network_error" && issue.target && missingResources.has(issue.target) && /^Request failed:/i.test(String(issue.title || ""))));
207
224
 
208
225
  // Dedup by stable signature (type|screen|target) so repeated detections count once —
@@ -226,8 +243,13 @@ export function buildQaReport(markersFilePath, { platform = "ios" } = {}) {
226
243
  findings.sort((a, b) => severityRank(a.severity) - severityRank(b.severity));
227
244
 
228
245
  const screensExplored = screens.size || base.uniqueScreens.length;
229
- const actionsPerformed =
230
- actions || (base.complete && typeof base.complete === "object" ? base.complete.actions || 0 : 0);
246
+ // Some native recovery operations are counted by the harness budget but intentionally do not
247
+ // emit a public action narrative. Preserve the larger authoritative completion count instead of
248
+ // understating coverage whenever at least one narrated action exists.
249
+ const actionsPerformed = Math.max(
250
+ actions,
251
+ base.complete && typeof base.complete === "object" ? base.complete.actions || 0 : 0,
252
+ );
231
253
  const crit = findings.filter((f) => f.severity === "critical").length;
232
254
  const high = findings.filter((f) => f.severity === "high").length;
233
255
  const med = findings.filter((f) => f.severity === "medium").length;
@@ -244,9 +266,22 @@ export function buildQaReport(markersFilePath, { platform = "ios" } = {}) {
244
266
  // Coverage floor: exploration is inconclusive if the app wasn't actually exercised. Exploration
245
267
  // OBSERVES — it does not render a ship verdict or score (ADR-0005). Judgment (pass/fail/
246
268
  // inconclusive) is the gate's job (evaluateGate), computed from these findings + coverage + policy.
247
- const inconclusive = screensExplored < 2 || actionsPerformed < 3;
248
-
249
- const headline = inconclusive
269
+ // A one-page web target can still be swept exhaustively: page errors, requests, links, assets,
270
+ // placeholder anchors, and visible controls do not require a second route. Native exploration
271
+ // retains the stronger multi-screen/action floor. A credentialless single-screen login remains
272
+ // inconclusive so a login wall can never turn into a clean pass.
273
+ const coverageFloorMet = platform === "web"
274
+ ? screensExplored >= 1 && actionsPerformed >= 1
275
+ : screensExplored >= 2 && actionsPerformed >= 3;
276
+ const credentiallessLoginWall = anySecure && !loginAttempted && screensExplored <= 1;
277
+ const inconclusive = !coverageFloorMet || credentiallessLoginWall || timeBudgetExhausted;
278
+ const stopReason = credentiallessLoginWall ? "login-wall-no-credentials"
279
+ : timeBudgetExhausted ? "time-budget-exhausted"
280
+ : coverageFloorMet ? "completed" : "coverage-floor-not-met";
281
+
282
+ const headline = timeBudgetExhausted
283
+ ? `Inconclusive — exploration reached its ${base.complete?.timeoutSeconds || "configured"}s time budget after ${actionsPerformed} action(s) across ${screensExplored} screen(s). Findings are partial; this is not an app performance finding. Increase --timeout or request fewer actions.`
284
+ : inconclusive
250
285
  ? `Inconclusive — only ${screensExplored} screen(s) / ${actionsPerformed} action(s) explored. The app may have crashed on launch, be stuck behind a sign-in wall, or otherwise prevent exploration. Absence of issues is NOT a pass.`
251
286
  : findings.length === 0
252
287
  ? platform === "web"
@@ -254,7 +289,7 @@ export function buildQaReport(markersFilePath, { platform = "ios" } = {}) {
254
289
  : "No issues surfaced in the exercised surfaces. An observation, not a release decision."
255
290
  : `${findings.length} issue(s) surfaced for review (${crit} critical, ${high} high, ${med} medium, ${low} low). An observation, not a release decision.`;
256
291
 
257
- // The verdict's own honesty label: exactly which defect classes this run checked, which
292
+ // The observation's honesty label: exactly which defect classes this run checked, which
258
293
  // it structurally could NOT check, and which conditions never came up — so "checked" is
259
294
  // never claimed for a state the run didn't reach. Platform-aware: a web run doesn't
260
295
  // inherit iOS keyboard assertions and vice versa.
@@ -300,9 +335,12 @@ export function buildQaReport(markersFilePath, { platform = "ios" } = {}) {
300
335
  "content & reachability regressions require a baseline" ,
301
336
  ];
302
337
  }
303
- // "Failed sign-ins" is only a claim when a sign-in surface was actually encountered.
304
- if (anySecure) checkedFor.splice(2, 0, "failed sign-ins");
338
+ // "Failed sign-ins" is only a claim when credentials were actually submitted. Merely seeing a
339
+ // password field proves that a login surface was reached, not that authentication was exercised.
340
+ if (loginAttempted) checkedFor.splice(2, 0, "failed sign-ins");
341
+ else if (anySecure) notChecked.push("sign-in behavior (login form reached, no test credentials supplied)");
305
342
  else conditionsNotReached.push("sign-in (no login form encountered this run)");
343
+ if (timeBudgetExhausted) notChecked.push("the full requested action budget (run reached its wall-clock timeout)");
306
344
 
307
345
  return {
308
346
  // An ExplorationRun observation: findings + coverage + evidence, NO ship verdict or score
@@ -313,7 +351,7 @@ export function buildQaReport(markersFilePath, { platform = "ios" } = {}) {
313
351
  // ended; coverage/evidence/uiMap/comparison are the structured observation. uiMap and comparison
314
352
  // are populated by consumers that build the map / diff a baseline (null in the bare observation).
315
353
  runStatus: inconclusive ? "limited" : "completed",
316
- stopReason: inconclusive ? "coverage-floor-not-met" : "completed",
354
+ stopReason,
317
355
  headline,
318
356
  inconclusive,
319
357
  coverage: { screensExplored, actionsPerformed, screens: Array.from(screens) },
@@ -324,6 +362,7 @@ export function buildQaReport(markersFilePath, { platform = "ios" } = {}) {
324
362
  notChecked,
325
363
  conditionsNotReached,
326
364
  platform,
365
+ target: typeof target === "string" && target.trim() ? target.trim() : null,
327
366
  screensExplored,
328
367
  actionsPerformed,
329
368
  findingCounts: { critical: crit, high, medium: med, low, total: findings.length },
@@ -453,7 +492,7 @@ export function computeRegression(current, baseline) {
453
492
  // the evidence." Exit codes are the CI contract; precedence is fail > inconclusive > pass.
454
493
  export const GATE_EXIT = { pass: 0, fail: 1, error: 2, inconclusive: 3 };
455
494
  // Bump when the gate's decision semantics change (NOT the npm version). Recorded on every GateRun.
456
- export const GATE_POLICY_VERSION = "1";
495
+ export const GATE_POLICY_VERSION = "2";
457
496
 
458
497
  // Pure gate evaluator: frozen evidence + policy → a GateRun decision. Extracted verbatim from the
459
498
  // former inline logic in ci-report.js so the `[char]` characterization tests keep passing — the
@@ -484,6 +523,16 @@ export function evaluateGate({ report, regression = null, flows = [], scenarios
484
523
  const needsReview = suites.filter((s) => classify(s) === "needs-review");
485
524
  if (needsReview.length) inconclusive(`${needsReview.length} ${label}(s) contain assert_ai (model-observed); the deterministic gate cannot decide them — review, or add an explicit probabilistic policy`);
486
525
  }
526
+ // A submitted sign-in that remains on the login surface is an explicit exercised guarantee,
527
+ // not ordinary pre-existing UI debt. Letting it pass without a baseline would produce the
528
+ // contradictory public result "failed sign-in detected" + gate PASS. Keep sampled probes out,
529
+ // but fail every deterministic auth failure under every gate policy (including with a baseline).
530
+ const authFailures = (report.findings || []).filter((finding) =>
531
+ finding?.type === "auth_failed" &&
532
+ finding?.authority !== "model-observed" &&
533
+ finding?.evaluationTier !== "sampled"
534
+ );
535
+ if (authFailures.length) fail(`${authFailures.length} deterministic sign-in attempt(s) failed`);
487
536
  // Selected-but-unexecuted work is missing evidence, not an observed violation → inconclusive.
488
537
  if (prPlan?.execution?.notRun) inconclusive(`${prPlan.execution.notRun} selected release contract(s) did not run`);
489
538
  if (prPlan?.execution?.explorationFailed) inconclusive(`${prPlan.execution.explorationFailed} planned PR exploration target(s) failed or were not reached`);
@@ -45,7 +45,7 @@ export function webPlaceholderLinkFindings(links = []) {
45
45
  const seen = new Set();
46
46
  for (const link of links || []) {
47
47
  const rawHref = String(link?.rawHref || "").trim().toLowerCase();
48
- const placeholder = rawHref === "#" || /^javascript:(?:void\(0\);?|;?)$/.test(rawHref);
48
+ const placeholder = rawHref === "" || rawHref === "#" || /^javascript:(?:void\(0\);?|;?)$/.test(rawHref);
49
49
  if (!placeholder || link?.handlerHint) continue;
50
50
  const label = String(link?.label || "").replace(/\s+/g, " ").trim().slice(0, 100);
51
51
  const fingerprint = String(link?.fingerprint || "link").replace(/\s+/g, " ").trim().slice(0, 100) || "link";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarwitz/tapp",
3
- "version": "0.17.0-rc.1",
3
+ "version": "0.17.0-rc.3",
4
4
  "mcpName": "io.github.aarwitz/tapp",
5
5
  "description": "Release contracts, autonomous QA, and evidence-backed CI gates for iOS, Android, and web.",
6
6
  "license": "MIT",
@@ -87,7 +87,7 @@
87
87
  "mobile"
88
88
  ],
89
89
  "scripts": {
90
- "test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-flow.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/android-flow.test.js tests/managed-web.test.js tests/product-operations.test.js tests/browser-product.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/cloud-runner.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/action.test.js tests/package-surface.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js",
90
+ "test": "node --test tests/report.test.js tests/regression.test.js tests/engine.test.js tests/project-config.test.js tests/application-model.test.js tests/ui-map.test.js tests/task-runtime.test.js tests/release-contract.test.js tests/pr-selection.test.js tests/flow-runtime.test.js tests/web-explorer.test.js tests/web-session.test.js tests/web-flow.test.js tests/scenario-runtime.test.js tests/android-driver.test.js tests/android-explorer.test.js tests/android-flow.test.js tests/android-primitives-protocol.test.js tests/managed-web.test.js tests/product-operations.test.js tests/browser-product.test.js tests/browser-onboarding.test.js tests/managed-operation.test.js tests/cloud-runner.test.js tests/ci-setup.test.js tests/ci-install.test.js tests/cli.test.js tests/action.test.js tests/package-surface.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js",
91
91
  "test:browser-journey": "node --test tests/browser-journey.test.js",
92
92
  "test:browser-native": "TAPP_RUN_NATIVE_BROWSER=1 node --test tests/browser-native-journey.test.js"
93
93
  }
@@ -3,13 +3,15 @@
3
3
  #
4
4
  # Boots a simulator if needed, installs the app build under test, runs the autonomous exploration
5
5
  # harness, replays every committed Flow (deterministic E2E tests), diffs the findings against a
6
- # stored baseline, writes a GitHub Actions step summary, and exits non-zero when the gate fails
7
- # (new high/critical findings vs. baseline, or any failed Flow). Wrapped by ../action.yml for
8
- # GitHub Actions; equally usable from any other CI or locally.
6
+ # stored baseline, writes a GitHub Actions step summary, and exits with the public outcome contract:
7
+ # pass 0, deterministic fail 1, infrastructure/usage error 2, inconclusive evidence 3. Absolute
8
+ # blockers and reviewed Flow/Scenario/Contract failures are enforced even without a baseline;
9
+ # baseline comparisons additionally catch new high/critical regressions. Wrapped by ../action.yml
10
+ # for GitHub Actions; equally usable from any other CI or locally.
9
11
  #
10
12
  # Usage:
11
13
  # scripts/ci-gate.sh [--platform ios] --app <path/to/App.app> [--bundle-id <com.example.app>]
12
- # scripts/ci-gate.sh --platform android --apk <path/to/app.apk> --app-id <com.example.app>
14
+ # scripts/ci-gate.sh --platform android --apk <path/to/app.apk> --app-id <com.example.app> [--serial <adb-serial>]
13
15
  # scripts/ci-gate.sh --platform web [--url <http(s)://owned-app>]
14
16
  # # omit --url with --project-dir to detect/build/start/stop one owned web target
15
17
  # # bundle id is detected from the .app when omitted
@@ -29,13 +31,14 @@
29
31
  # [--json-out <file.json>] # write the full report (use as the next baseline)
30
32
  # [--md-out <file.md>] # write the rendered markdown report (for a PR comment)
31
33
  # [--device <name>] # simulator device to boot if none is (default "iPhone 16 Pro")
34
+ # [--serial <adb-serial>] # Android emulator/device (default: first connected device)
32
35
  #
33
36
  # The app must be a SIMULATOR build (xcodebuild ... -destination 'generic/platform=iOS Simulator').
34
37
  set -uo pipefail
35
38
  ROOT="$(cd "$(dirname "$0")/.." && pwd)"
36
39
 
37
40
  usage() {
38
- sed -n '2,30p' "$0" | sed 's/^# \{0,1\}//'
41
+ sed -n '2,/^set -uo pipefail$/p' "$0" | sed '$d; s/^# \{0,1\}//'
39
42
  }
40
43
 
41
44
  PLATFORM="ios" APP_PATH="" BUNDLE_ID="" APK_PATH="" APP_ID="" URL="" WEB_TARGET="" TARGET_KEY="" SERIAL="" ACTIONS=40 TIMEOUT=600 FLOWS="" SCENARIOS="" CONTRACTS="" PROJECT_DIR="" BASELINE="" FAIL_ON="gate" JSON_OUT="" MD_OUT="" DEVICE="iPhone 16 Pro" PR_BASE="" PR_HEAD="HEAD" CHANGED_FILES_FILE="" PR_PLAN_OUT=""
@@ -82,7 +85,6 @@ fi
82
85
  TAPP_PROJECT_ARTIFACTS=""
83
86
  if [[ -n "$PROJECT_DIR" ]]; then
84
87
  [[ -d "$PROJECT_DIR/.tapp" ]] && TAPP_PROJECT_ARTIFACTS="$PROJECT_DIR/.tapp"
85
- [[ -z "$TAPP_PROJECT_ARTIFACTS" && -d "$PROJECT_DIR/.autotap" ]] && TAPP_PROJECT_ARTIFACTS="$PROJECT_DIR/.autotap"
86
88
  fi
87
89
  [[ -z "$FLOWS" && -n "$TAPP_PROJECT_ARTIFACTS" && -d "$TAPP_PROJECT_ARTIFACTS/flows" ]] && FLOWS="$TAPP_PROJECT_ARTIFACTS/flows/*.yml"
88
90
  [[ "$PLATFORM" == "web" && -z "$SCENARIOS" && -n "$TAPP_PROJECT_ARTIFACTS" && -d "$TAPP_PROJECT_ARTIFACTS/scenarios" ]] && SCENARIOS="$TAPP_PROJECT_ARTIFACTS/scenarios/*.yml"
@@ -37,7 +37,10 @@ for (let i = 2; i < process.argv.length; i += 1) {
37
37
  else if (key === "--json-out") args.jsonOut = value;
38
38
  else if (key === "--md-out") args.mdOut = value;
39
39
  else if (key === "--pr-plan") args.prPlan = value;
40
- else throw new Error(`Unknown argument: ${key}`);
40
+ else {
41
+ console.error(`Unknown argument: ${key}`);
42
+ process.exit(2);
43
+ }
41
44
  }
42
45
  if (!["web", "android"].includes(args.platform)) throw new Error("--platform must be web|android");
43
46
  if (args.platform === "web" && !args.url && !args.projectDir) throw new Error("Web gate requires --url or --project-dir for managed build/start");
@@ -94,7 +97,7 @@ if (args.prPlan) {
94
97
  }
95
98
 
96
99
  let managedRuntime = null;
97
- let exitCode = 1;
100
+ let exitCode = 2;
98
101
  try {
99
102
  if (args.platform === "web" && !args.url) {
100
103
  const started = await startManagedWebTarget({
@@ -106,7 +109,7 @@ try {
106
109
  if (started.error) {
107
110
  console.error(`❌ ${started.error}`);
108
111
  if (started.details?.remediation) console.error(` ${started.details.remediation}`);
109
- process.exitCode = 1;
112
+ exitCode = 2;
110
113
  } else {
111
114
  managedRuntime = started;
112
115
  args.url = started.url;
@@ -114,7 +117,7 @@ try {
114
117
  }
115
118
  }
116
119
  if (args.platform === "web" && !args.url) {
117
- exitCode = 1;
120
+ exitCode = 2;
118
121
  } else {
119
122
  const qa = args.platform === "web"
120
123
  ? await runQaWeb({ url: args.url, maxActions: args.actions, timeout: args.timeout, testEmail: process.env.OCQA_TEST_EMAIL, testPassword: process.env.OCQA_TEST_PASSWORD, seedTargets: prExplorationTargets })
@@ -122,7 +125,7 @@ try {
122
125
  testEmail: process.env.OCQA_TEST_EMAIL, testPassword: process.env.OCQA_TEST_PASSWORD, seedTargets: prExplorationTargets });
123
126
  if (qa.error) {
124
127
  console.error(`❌ ${qa.error}`);
125
- exitCode = 1;
128
+ exitCode = 2;
126
129
  } else {
127
130
  const captureDir = qa.structured.capture.path;
128
131
  const markers = path.join(captureDir, "ocqa-markers.txt");
@@ -177,6 +180,9 @@ try {
177
180
  exitCode = report.status ?? 1;
178
181
  }
179
182
  }
183
+ } catch (error) {
184
+ console.error(`❌ ${error?.message || String(error)}`);
185
+ exitCode = 2;
180
186
  } finally {
181
187
  if (managedRuntime) {
182
188
  await stopManagedWebTarget(managedRuntime);