@aarwitz/tapp 0.17.24 → 0.17.26

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tapp",
3
3
  "description": "Give Claude hands and eyes on iOS, Android, and web apps, with exploration, replayable flows, evidence, and deterministic CI gates.",
4
- "version": "0.17.24",
4
+ "version": "0.17.26",
5
5
  "author": {
6
6
  "name": "Aaron Horowitz",
7
7
  "url": "https://github.com/aarwitz"
@@ -24,7 +24,7 @@
24
24
  "command": "npx",
25
25
  "args": [
26
26
  "-y",
27
- "@aarwitz/tapp@0.17.24",
27
+ "@aarwitz/tapp@0.17.26",
28
28
  "mcp"
29
29
  ],
30
30
  "cwd": "${CLAUDE_PROJECT_DIR}"
package/AGENTS.md CHANGED
@@ -210,5 +210,31 @@ without a coding agent, model, subscription, or API key. AI generation and `asse
210
210
  of retrying variations.
211
211
  - When you show a screenshot as proof, say what it proves and what it doesn't ("login works;
212
212
  I haven't verified checkout").
213
+ - The capture a command returns is the evidence; `~/.tapp/captures/` holds every project's history.
214
+ Every capture carries `provenance.json` (kind, platform, target, project) and every result that
215
+ hands back a capture path hands back that record. `tapp_list_captures` and `tapp report latest`
216
+ are scoped to the current project; pass `allProjects:true` only when the user asks for history,
217
+ and never present another project's capture as this project's evidence or borrow it as a fixture.
213
218
  - A clean `tapp_audit` means the page is served without structural defects. It says nothing about
214
219
  behaviour, because nothing was clicked; never report it as "the site works".
220
+
221
+ ## File feedback on tapp itself — don't just work around it
222
+
223
+ Tapp is still being hardened, and a rough edge in Tapp is not the same thing as a defect in the
224
+ app under test. File it with `tapp_feedback` (or `npx -y @aarwitz/tapp@latest feedback "title"`)
225
+ as soon as you notice, not after you've already found a workaround and moved on — draft only;
226
+ `submit:true` needs the user's OK first, since filing posts a public GitHub issue. File when you
227
+ see any of:
228
+
229
+ - A command's documented or expected behavior doesn't match what happened (a flag silently
230
+ ignored, a field `null`/missing when it should be populated).
231
+ - A crash, hang, or unexplained failure from the underlying platform tooling (simulator, emulator,
232
+ browser) rather than the app under test.
233
+ - You had to invent a workaround to get a straightforward task done.
234
+ - A result that technically succeeded but didn't do what it clearly should have (`ok` with no
235
+ actual state change, `inconclusive` for a reason that doesn't match the documented causes).
236
+ - You're not sure whether something is a real app finding or a Tapp bug — file it rather than
237
+ silently deciding either way.
238
+
239
+ One file per distinct issue. Lean toward filing when unsure: a closed non-issue costs nothing, a
240
+ bug nobody ever reported stays a bug.
package/bin/tapp.js CHANGED
@@ -1233,6 +1233,10 @@ switch (command) {
1233
1233
  const flowLog = path.join(tappHome, "flows", `${token}.log`);
1234
1234
  const evidenceDir = path.join(tappHome, "captures", `flow-${platform}-${token}`);
1235
1235
  fs.mkdirSync(path.dirname(flowLog), { recursive: true });
1236
+ {
1237
+ const { writeCaptureProvenance } = await import(path.join(packageRoot, "mcp-server", "src", "capture-provenance.js"));
1238
+ writeCaptureProvenance(evidenceDir, { kind: "flow", platform, target: path.relative(process.cwd(), absolute) || absolute });
1239
+ }
1236
1240
  const env = { ...process.env, FLOW_LOG: flowLog, TAPP_FLOW_EVIDENCE_DIR: evidenceDir };
1237
1241
  if (platform === "ios") {
1238
1242
  const launch = iosLaunchOptions(flags, rest);
@@ -1445,6 +1449,10 @@ switch (command) {
1445
1449
  const evidenceDir = path.join(tappHome, "captures", `scenario-web-${token}`);
1446
1450
  const env = { ...process.env, FLOW_LOG: flowLog, TAPP_FLOW_EVIDENCE_DIR: evidenceDir };
1447
1451
  const url = typeof flags.url === "string" ? flags.url : scenario.url || scenario.app || "";
1452
+ {
1453
+ const { writeCaptureProvenance } = await import(path.join(packageRoot, "mcp-server", "src", "capture-provenance.js"));
1454
+ writeCaptureProvenance(evidenceDir, { kind: "scenario", platform: "web", target: url || (path.relative(process.cwd(), absolute) || absolute) });
1455
+ }
1448
1456
  const result = spawnSync(process.execPath, [path.join(packageRoot, "scripts", "run-web-scenario.js"), absolute, url], { stdio: "inherit", env });
1449
1457
  if (fs.existsSync(flowLog)) spawnSync("python3", [path.join(packageRoot, "scripts", "flow_lib.py"), "report", flowLog], { stdio: "inherit" });
1450
1458
  console.log(`\nEvidence: ${evidenceDir}`);
@@ -1993,7 +2001,13 @@ switch (command) {
1993
2001
  // of those made `tapp report` fail even though valid exploration captures existed. An explicitly
1994
2002
  // named capture is honored as-is so a non-exploration capture still gets a clear "no markers".
1995
2003
  const explicit = rest[0] && rest[0] !== "latest";
1996
- const wanted = explicit ? runs.find((r) => path.basename(r) === rest[0]) : runs.find(hasMarkers);
2004
+ // `latest` means this project's latest: the directory holds every project's captures, and
2005
+ // opening another project's evidence from here is exactly the mix-up issue #29 describes.
2006
+ // Falls back to any exploration capture only when none carries this project's provenance.
2007
+ const { readCaptureProvenance, captureBelongsToProject } = await import(path.join(packageRoot, "mcp-server", "src", "capture-provenance.js"));
2008
+ const ours = (dir) => captureBelongsToProject(readCaptureProvenance(dir), process.cwd());
2009
+ const wanted = explicit ? runs.find((r) => path.basename(r) === rest[0]) : (runs.find((r) => hasMarkers(r) && ours(r)) || runs.find(hasMarkers));
2010
+ if (!explicit && wanted && !ours(wanted)) console.log("ℹ️ No exploration capture carries this project's provenance; showing the newest capture on this machine — it may belong to another project.");
1997
2011
  if (!wanted) {
1998
2012
  bad("No captures found", explicit ? `no capture named "${rest[0]}"` : "run an exploration first (no capture with exploration markers was found)");
1999
2013
  process.exit(1);
@@ -0,0 +1,77 @@
1
+ // Which project a capture belongs to.
2
+ //
3
+ // Every capture lands in the shared ~/.tapp/captures/, so an agent working in project A can
4
+ // see project B's history and, without anything telling it otherwise, present it as evidence
5
+ // (public issue #29: a Copilot session borrowed an unrelated capture as a "fixture"). Each
6
+ // capture now records who made it and from where, every result that hands back a capture path
7
+ // hands back this record with it, and listings default to the current project.
8
+ import fs from "fs";
9
+ import path from "path";
10
+ import { execFileSync } from "child_process";
11
+ import { createRequire } from "module";
12
+
13
+ const require = createRequire(import.meta.url);
14
+ const VERSION = (() => { try { return require("../../package.json").version; } catch { return "0.0.0"; } })();
15
+
16
+ export const PROVENANCE_FILE = "provenance.json";
17
+
18
+ function realpath(dir) {
19
+ try { return fs.realpathSync(dir); } catch { return path.resolve(dir); }
20
+ }
21
+
22
+ // The git remote is the most stable project identity there is: it survives clones in different
23
+ // directories and is what a human means by "the project". Absent → the directory alone.
24
+ function gitRemote(dir) {
25
+ try {
26
+ return execFileSync("git", ["-C", dir, "config", "--get", "remote.origin.url"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 2_000 }).trim() || null;
27
+ } catch {
28
+ return null;
29
+ }
30
+ }
31
+
32
+ export function describeProject(projectDir = process.cwd()) {
33
+ const dir = realpath(projectDir);
34
+ return { dir, name: path.basename(dir), remote: gitRemote(dir) };
35
+ }
36
+
37
+ // kind: explore | audit | flow | scenario | session. target: bundle id / app id / url / flow file.
38
+ export function writeCaptureProvenance(captureDir, { kind, platform, target = "", projectDir = process.cwd(), extra = {} } = {}) {
39
+ const record = {
40
+ schemaVersion: 1,
41
+ kind: String(kind || "capture"),
42
+ platform: String(platform || ""),
43
+ target: String(target || ""),
44
+ project: describeProject(projectDir),
45
+ tool: { name: "tapp", version: VERSION },
46
+ createdAt: new Date().toISOString(),
47
+ ...extra,
48
+ };
49
+ fs.mkdirSync(captureDir, { recursive: true });
50
+ fs.writeFileSync(path.join(captureDir, PROVENANCE_FILE), JSON.stringify(record, null, 2));
51
+ return record;
52
+ }
53
+
54
+ export function readCaptureProvenance(captureDir) {
55
+ try {
56
+ const parsed = JSON.parse(fs.readFileSync(path.join(captureDir, PROVENANCE_FILE), "utf8"));
57
+ return parsed && typeof parsed === "object" ? parsed : null;
58
+ } catch {
59
+ return null;
60
+ }
61
+ }
62
+
63
+ // Same remote, or same real directory. A capture with no record predates provenance and cannot
64
+ // be claimed by any project — callers show those separately rather than guessing.
65
+ export function captureBelongsToProject(provenance, projectDir = process.cwd()) {
66
+ if (!provenance?.project) return false;
67
+ const here = describeProject(projectDir);
68
+ if (provenance.project.remote && here.remote) return provenance.project.remote === here.remote;
69
+ return provenance.project.dir === here.dir;
70
+ }
71
+
72
+ // One line an agent can echo when it cites a capture, so the reader sees whose evidence it is.
73
+ export function provenanceLabel(provenance) {
74
+ if (!provenance) return "provenance unknown (capture predates tapp 0.17.25)";
75
+ const who = provenance.project?.remote || provenance.project?.dir || "unknown project";
76
+ return `${provenance.kind || "capture"} · ${provenance.platform || "?"} · ${provenance.target || "(no target)"} · from ${who}`;
77
+ }
@@ -82,6 +82,8 @@ export function writeHtmlReport(captureDir, { report, label = "", recordingWarni
82
82
  (f) => `<li>
83
83
  <span class="sev" style="background:${SEV_COLOR[f.severity] || "#57606a"}">${esc(f.severity)}</span>
84
84
  ${esc(f.title)}${f.screen ? ` <span class="dim">— on ${esc(f.screen)}</span>` : ""}${f.url ? ` <span class="dim">— ${esc(f.url)}</span>` : ""}
85
+ ${f.crashReport ? `<div class="dim">crash report: ${esc(f.crashReport)}</div>` : ""}
86
+ ${f.attributionNote ? `<div class="dim">${esc(f.attributionNote)}</div>` : ""}
85
87
  ${f.aiAnalysis ? `<div class="ai">why: ${esc(f.aiAnalysis)}</div>` : ""}
86
88
  ${f.suggestedFix ? `<div class="ai">fix: ${esc(f.suggestedFix)}</div>` : ""}
87
89
  ${f.evidence && fs.existsSync(path.join(captureDir, f.evidence))
@@ -29,6 +29,7 @@ const workspaceRoot = (() => {
29
29
  catch { return path.resolve(process.cwd()); }
30
30
  })();
31
31
  const scriptsDir = path.join(repoRoot, "scripts");
32
+ import { writeCaptureProvenance, readCaptureProvenance, captureBelongsToProject, provenanceLabel } from "./capture-provenance.js";
32
33
  // TAPP_HOME (set by the `tapp` CLI when installed) redirects writable output to a user directory.
33
34
  // The old alias remains a read-only fallback; unset repository development stays local.
34
35
  const tappHome = (process.env.TAPP_HOME || "").trim();
@@ -168,11 +169,14 @@ function listCaptureRuns(limit = 10) {
168
169
  .map((d) => {
169
170
  const full = path.join(capturesDir, d.name);
170
171
  const stat = fs.statSync(full);
172
+ const provenance = readCaptureProvenance(full);
171
173
  return {
172
174
  id: d.name,
173
175
  path: full,
174
176
  relativePath: path.relative(repoRoot, full),
175
177
  modifiedAt: stat.mtime.toISOString(),
178
+ provenance,
179
+ thisProject: captureBelongsToProject(provenance, workspaceRoot),
176
180
  };
177
181
  })
178
182
  .sort((a, b) => (a.modifiedAt < b.modifiedAt ? 1 : -1));
@@ -180,6 +184,19 @@ function listCaptureRuns(limit = 10) {
180
184
  return entries.slice(0, Math.max(1, limit));
181
185
  }
182
186
 
187
+ // The captures directory is shared by every project on the machine. The agent-facing listing
188
+ // shows this project's captures only; other projects' captures and captures made before
189
+ // provenance existed are counted, not shown, so an agent never mistakes another project's
190
+ // history for evidence of this one (issue #29). Internal callers that diff "before/after" to find
191
+ // a capture a command just created keep the unfiltered list above.
192
+ function listProjectCaptures(limit = 10, { allProjects = false } = {}) {
193
+ const all = listCaptureRuns(1000);
194
+ const hiddenUnknown = allProjects ? 0 : all.filter((e) => !e.provenance).length;
195
+ const hiddenOtherProjects = allProjects ? 0 : all.filter((e) => e.provenance && !e.thisProject).length;
196
+ const visible = allProjects ? all : all.filter((e) => e.thisProject);
197
+ return { captures: visible.slice(0, Math.max(1, limit)), hiddenOtherProjects, hiddenUnknown };
198
+ }
199
+
183
200
  function summarizeCapture(runPath) {
184
201
  if (!fs.existsSync(runPath)) {
185
202
  return null;
@@ -191,9 +208,12 @@ function summarizeCapture(runPath) {
191
208
  ? fs.readdirSync(screenshotsDir).filter((f) => f.endsWith(".png") || f.endsWith(".jpg") || f.endsWith(".jpeg")).length
192
209
  : 0;
193
210
 
211
+ const provenance = readCaptureProvenance(runPath);
194
212
  return {
195
213
  path: runPath,
196
214
  relativePath: path.relative(repoRoot, runPath),
215
+ provenance,
216
+ thisProject: captureBelongsToProject(provenance, workspaceRoot),
197
217
  hasMarkers: files.includes("ocqa-markers.txt"),
198
218
  hasFullOutput: files.includes("full-output.txt"),
199
219
  hasUITree: files.includes("uitree.json"),
@@ -1903,6 +1923,7 @@ export async function runQaWeb({ url, maxActions, timeout, testEmail, testPasswo
1903
1923
  const timeoutSec = Math.max(30, Math.min(3600, asInteger(timeout, 600)));
1904
1924
  const id = "web-" + new Date().toISOString().replace(/[-:T]/g, "").slice(0, 14).replace(/^(\d{8})/, "$1-");
1905
1925
  const outDir = path.join(capturesDir, id);
1926
+ const provenance = writeCaptureProvenance(outDir, { kind: "explore", platform: "web", target: url.trim(), projectDir: workspaceRoot });
1906
1927
  let webResult;
1907
1928
  try {
1908
1929
  const { exploreWeb } = await import("./web-explorer.js");
@@ -1937,7 +1958,7 @@ export async function runQaWeb({ url, maxActions, timeout, testEmail, testPasswo
1937
1958
  const { writeHtmlReport } = await import("./html-report.js");
1938
1959
  reportHtml = writeHtmlReport(outDir, { report, label: url.trim() });
1939
1960
  } catch { /* evidence page is best-effort */ }
1940
- const structured = { ...report, regression, platform: "web", uiMap, reportHtml, exploration: { seedRoutes: webResult.seedRoutes || [], targets: webResult.seedTargets || [] }, capture: { id, path: outDir, relativePath: path.relative(repoRoot, outDir) } };
1961
+ const structured = { ...report, regression, platform: "web", uiMap, reportHtml, exploration: { seedRoutes: webResult.seedRoutes || [], targets: webResult.seedTargets || [] }, capture: { id, path: outDir, relativePath: path.relative(repoRoot, outDir), provenance } };
1941
1962
  const text = formatQaReport(report, { regression, bundleId: url.trim(), aiConfigured: !!backend, reportHtml, uiMap: uiMap.error ? null : uiMap, surface });
1942
1963
  return { structured, text };
1943
1964
  }
@@ -1950,6 +1971,7 @@ export async function runQaAndroid({ appId, apkPath, serial, maxActions, timeout
1950
1971
  const timeoutSec = Math.max(30, Math.min(3600, asInteger(timeout, 600)));
1951
1972
  const id = "android-" + new Date().toISOString().replace(/[-:T]/g, "").slice(0, 14).replace(/^(\d{8})/, "$1-");
1952
1973
  const outDir = path.join(capturesDir, id);
1974
+ const provenance = writeCaptureProvenance(outDir, { kind: "explore", platform: "android", target: appId.trim(), projectDir: workspaceRoot });
1953
1975
  let androidResult;
1954
1976
  try {
1955
1977
  const { exploreAndroid } = await import("./android-explorer.js");
@@ -1983,7 +2005,7 @@ export async function runQaAndroid({ appId, apkPath, serial, maxActions, timeout
1983
2005
  const { writeHtmlReport } = await import("./html-report.js");
1984
2006
  reportHtml = writeHtmlReport(outDir, { report, label: appId.trim() });
1985
2007
  } catch {}
1986
- const structured = { ...report, regression, platform: "android", uiMap, reportHtml, exploration: { targets: androidResult.seedTargets || [] }, capture: { id, path: outDir, relativePath: path.relative(repoRoot, outDir) } };
2008
+ const structured = { ...report, regression, platform: "android", uiMap, reportHtml, exploration: { targets: androidResult.seedTargets || [] }, capture: { id, path: outDir, relativePath: path.relative(repoRoot, outDir), provenance } };
1987
2009
  const text = formatQaReport(report, { regression, bundleId: appId.trim(), aiConfigured: !!backend, reportHtml, uiMap: uiMap.error ? null : uiMap, surface });
1988
2010
  return { structured, text };
1989
2011
  }
@@ -2006,6 +2028,7 @@ export async function runQaIos({ bundleId, maxActions, timeout, args = {}, surfa
2006
2028
 
2007
2029
  const { created, timedOut, captureStderr } = await runExploreStreaming(bundleId, actions, timeoutSec, env, onProgress);
2008
2030
  if (!created) return { error: "Exploration produced no capture run", details: { timedOut } };
2031
+ const provenance = writeCaptureProvenance(created.path, { kind: "explore", platform: "ios", target: bundleId, projectDir: workspaceRoot });
2009
2032
 
2010
2033
  const report = buildQaReport(path.join(created.path, "ocqa-markers.txt"), { platform: "ios", target: bundleId });
2011
2034
  if (!report) {
@@ -2053,7 +2076,7 @@ export async function runQaIos({ bundleId, maxActions, timeout, args = {}, surfa
2053
2076
  reportHtml,
2054
2077
  recording,
2055
2078
  recordingWarning,
2056
- capture: { id: created.id, path: created.path, relativePath: created.relativePath },
2079
+ capture: { id: created.id, path: created.path, relativePath: created.relativePath, provenance },
2057
2080
  timedOut,
2058
2081
  autoBooted: sim.autoBooted || false,
2059
2082
  };
@@ -2714,7 +2737,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
2714
2737
  {
2715
2738
  name: "tapp_list_captures",
2716
2739
  title: "List captures",
2717
- description: "List recent capture runs from captures/",
2740
+ description: "List recent capture runs for THIS project (the workspace the server runs in). The captures directory is shared by every project on the machine; other projects' captures and pre-provenance captures are counted but hidden unless allProjects is true. Each entry carries provenance {kind, platform, target, project}. Use the capture a command just returned as evidence; never cite a capture from another project as if it were this one.",
2718
2741
  inputSchema: {
2719
2742
  type: "object",
2720
2743
  properties: {
@@ -2724,6 +2747,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
2724
2747
  maximum: 100,
2725
2748
  default: 10,
2726
2749
  },
2750
+ allProjects: { type: "boolean", default: false, description: "Include captures from other projects and captures without provenance — only when the user explicitly asks for historical evidence" },
2727
2751
  },
2728
2752
  },
2729
2753
  },
@@ -3620,16 +3644,20 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
3620
3644
  if (limit < 1 || limit > 100) {
3621
3645
  return errorResult("limit must be between 1 and 100", { received: limit });
3622
3646
  }
3623
- const captures = listCaptureRuns(limit);
3624
- const L = [`🗂️ Found **${captures.length}** capture run${captures.length === 1 ? "" : "s"}`];
3647
+ const allProjects = args.allProjects === true;
3648
+ const { captures, hiddenOtherProjects, hiddenUnknown } = listProjectCaptures(limit, { allProjects });
3649
+ const L = [`🗂️ Found **${captures.length}** capture run${captures.length === 1 ? "" : "s"}${allProjects ? " across all projects" : ` for this project (${path.basename(workspaceRoot)})`}`];
3625
3650
  if (captures.length) {
3626
3651
  L.push("");
3627
3652
  for (const c of captures.slice(0, 12)) {
3628
- L.push(`- \`${c.id}\` · ${c.relativePath}`);
3653
+ L.push(`- \`${c.id}\` · ${provenanceLabel(c.provenance)}`);
3629
3654
  }
3630
3655
  if (captures.length > 12) L.push(`- …and ${captures.length - 12} more`);
3631
3656
  }
3632
- return richResult(L.join("\n"), { captures });
3657
+ if (hiddenOtherProjects || hiddenUnknown) {
3658
+ L.push("", `Not shown: ${hiddenOtherProjects} capture(s) from other projects${hiddenUnknown ? ` and ${hiddenUnknown} with no provenance (made before tapp 0.17.25)` : ""}. They are not evidence of this project; pass allProjects:true only when the user asks for historical captures.`);
3659
+ }
3660
+ return richResult(L.join("\n"), { captures, hiddenOtherProjects, hiddenUnknown, project: path.basename(workspaceRoot) });
3633
3661
  }
3634
3662
 
3635
3663
  if (name === "tapp_capture_summary") {
@@ -0,0 +1,133 @@
1
+ // Who actually crashed.
2
+ //
3
+ // The iOS harness reports `crash` when the app under test stops running mid-run. That is the
4
+ // right observation and the wrong attribution whenever a *simulator system process* died —
5
+ // SpringBoard respawning takes every foreground app with it — and xcodebuild prints the full
6
+ // system crash trace for any simulator-hosted process that dies, not just the app (public
7
+ // issue #30). The desktop app has had a cross-check against the real crash reports in
8
+ // ~/Library/Logs/DiagnosticReports since a false-CRITICAL incident in the field
9
+ // (ExplorationService.findRealCrashReport); this is that check for the CLI/MCP path.
10
+ //
11
+ // The rules are the ones verified against real reports there:
12
+ // - bundleID lives in the header for genuine app crashes, in the body for EXC_GUARD/XPC faults,
13
+ // and in bundleInfo.CFBundleIdentifier sometimes — check all three;
14
+ // - launch-throttle crash variants omit the bundle id entirely; a report whose procPath is in
15
+ // THIS simulator's user-app container is the app, unless it is the XCUITest runner, whose own
16
+ // death is instrumentation failure and never an app crash;
17
+ // - EXC_GUARD is not an app crash.
18
+ import fs from "fs";
19
+ import os from "os";
20
+ import path from "path";
21
+
22
+ export const DEFAULT_REPORTS_DIR = path.join(os.homedir(), "Library", "Logs", "DiagnosticReports");
23
+ export const ATTRIBUTION_FILE = "crash-attribution.json";
24
+
25
+ function parseIps(raw) {
26
+ const nl = raw.indexOf("\n");
27
+ if (nl < 0) return null;
28
+ let header; let body;
29
+ try { header = JSON.parse(raw.slice(0, nl)); } catch { return null; }
30
+ try { body = JSON.parse(raw.slice(nl + 1)); } catch { body = {}; }
31
+ if (!header || typeof header !== "object") return null;
32
+ return { header, body: body && typeof body === "object" ? body : {} };
33
+ }
34
+
35
+ export function classifyCrashReport({ header, body }, { bundleId, simulatorUdid } = {}) {
36
+ const matchedBundle = (typeof body.bundleID === "string" && body.bundleID)
37
+ || (typeof header.bundleID === "string" && header.bundleID)
38
+ || (body.bundleInfo && typeof body.bundleInfo.CFBundleIdentifier === "string" ? body.bundleInfo.CFBundleIdentifier : null)
39
+ || null;
40
+ const procPath = typeof body.procPath === "string" ? body.procPath : "";
41
+ const procName = String(body.procName || header.name || header.app_name || "").trim();
42
+ const lower = procName.toLowerCase();
43
+ const isTestRunner = lower.endsWith("-runner") || procPath.includes("-Runner.app") || procPath.includes(".xctrunner");
44
+ const inOurSimulator = simulatorUdid ? procPath.includes(`/Devices/${simulatorUdid}/`) : false;
45
+ const inOurAppContainer = inOurSimulator && procPath.includes("/data/Containers/Bundle/Application/") && !isTestRunner;
46
+ const exceptionType = body.exception && typeof body.exception.type === "string" ? body.exception.type : null;
47
+ const isApp = bundleId ? (matchedBundle === bundleId || (matchedBundle == null && inOurAppContainer)) : inOurAppContainer;
48
+ return {
49
+ procName: procName || "(unknown process)",
50
+ bundleId: matchedBundle,
51
+ exceptionType,
52
+ isTestRunner,
53
+ inOurSimulator,
54
+ kind: isTestRunner ? "test-runner" : exceptionType === "EXC_GUARD" ? "guard-fault" : isApp ? "app" : inOurSimulator ? "simulator-system" : "other",
55
+ };
56
+ }
57
+
58
+ // Reports written at or after `since` (ms epoch), classified. ExcUserFault_* files are user-fault
59
+ // notices, not crashes.
60
+ export function findCrashReports({ since, bundleId, simulatorUdid, dir = DEFAULT_REPORTS_DIR } = {}) {
61
+ let names;
62
+ try { names = fs.readdirSync(dir); } catch { return { app: [], simulatorSystem: [], other: [] }; }
63
+ const out = { app: [], simulatorSystem: [], other: [] };
64
+ for (const name of names) {
65
+ if (!name.endsWith(".ips") || name.startsWith("ExcUserFault_")) continue;
66
+ const full = path.join(dir, name);
67
+ let stat;
68
+ try { stat = fs.statSync(full); } catch { continue; }
69
+ if (Number.isFinite(since) && stat.mtimeMs < since) continue;
70
+ let parsed;
71
+ try { parsed = parseIps(fs.readFileSync(full, "utf8")); } catch { continue; }
72
+ if (!parsed) continue;
73
+ const c = classifyCrashReport(parsed, { bundleId, simulatorUdid });
74
+ const entry = { path: full, modifiedAt: new Date(stat.mtimeMs).toISOString(), procName: c.procName, bundleId: c.bundleId, exceptionType: c.exceptionType };
75
+ if (c.kind === "app") out.app.push(entry);
76
+ else if (c.kind === "simulator-system") out.simulatorSystem.push(entry);
77
+ else if (c.kind === "other" || c.kind === "test-runner") out.other.push({ ...entry, kind: c.kind });
78
+ // guard faults are dropped: not a crash of anything
79
+ }
80
+ for (const list of Object.values(out)) list.sort((a, b) => a.modifiedAt.localeCompare(b.modifiedAt));
81
+ return out;
82
+ }
83
+
84
+ // Replace a raw crash trace in captured tool output with one line that says whose it was, so a
85
+ // SpringBoard trace does not read as the app under test blowing up. The full text stays in
86
+ // full-output.txt; this is for anything shown to a person or an agent.
87
+ const TRACE_START = /^(?:Crash Report|Process:\s+\S+\s+\[\d+\]|Incident Identifier:|-{10,}\s*$|Thread \d+ (?:Crashed|name):)/;
88
+ const TRACE_END = /^(?:Binary Images:|EOF|-{10,}\s*$)/;
89
+ export function summarizeCrashTraces(text = "") {
90
+ const lines = String(text).split(/\r?\n/);
91
+ const out = [];
92
+ let i = 0;
93
+ while (i < lines.length) {
94
+ const line = lines[i];
95
+ const looksLikeTrace = /^Process:\s+(\S+)\s+\[\d+\]/.test(line) || /^Crash Report/.test(line) || /quit unexpectedly/i.test(line);
96
+ if (!looksLikeTrace) { out.push(line); i += 1; continue; }
97
+ let proc = (line.match(/^Process:\s+(\S+)/) || line.match(/^(\S+) quit unexpectedly/i) || [])[1] || "";
98
+ let exc = "";
99
+ let j = i;
100
+ let consumed = 0;
101
+ for (; j < lines.length && consumed < 400; j += 1, consumed += 1) {
102
+ const l = lines[j];
103
+ if (!proc) proc = (l.match(/^Process:\s+(\S+)/) || [])[1] || proc;
104
+ if (!exc) exc = (l.match(/^Exception Type:\s+(.+)$/) || [])[1] || exc;
105
+ if (consumed > 2 && TRACE_END.test(l)) { j += 1; break; }
106
+ }
107
+ out.push(`[crash trace of ${proc || "a simulator process"}${exc ? ` — ${exc.trim()}` : ""} omitted here; full text in full-output.txt]`);
108
+ i = j;
109
+ }
110
+ return out.join("\n");
111
+ }
112
+
113
+ // What a report consumer needs to decide: did the app crash, or did something else take it down?
114
+ export function attributeRunCrash({ since, bundleId, simulatorUdid, dir } = {}) {
115
+ const reports = findCrashReports({ since, bundleId, simulatorUdid, dir });
116
+ const verdict = reports.app.length
117
+ ? "app"
118
+ : reports.simulatorSystem.length
119
+ ? "simulator-system"
120
+ : reports.other.some((r) => r.kind === "test-runner")
121
+ ? "test-runner"
122
+ : "no-report";
123
+ return { schemaVersion: 1, since: Number.isFinite(since) ? new Date(since).toISOString() : null, bundleId: bundleId || null, simulatorUdid: simulatorUdid || null, verdict, reports };
124
+ }
125
+
126
+ export function writeAttribution(captureDir, attribution) {
127
+ fs.writeFileSync(path.join(captureDir, ATTRIBUTION_FILE), JSON.stringify(attribution, null, 2));
128
+ return path.join(captureDir, ATTRIBUTION_FILE);
129
+ }
130
+
131
+ export function readAttribution(captureDir) {
132
+ try { return JSON.parse(fs.readFileSync(path.join(captureDir, ATTRIBUTION_FILE), "utf8")); } catch { return null; }
133
+ }
@@ -150,9 +150,55 @@ export function observationSummary(report) {
150
150
 
151
151
  // Turn a capture's OCQA markers into a scoreless observation with deduped findings and an
152
152
  // explicit coverage floor. Release judgment is applied later by evaluateGate.
153
+ function readCrashAttribution(captureDir) {
154
+ try {
155
+ const parsed = JSON.parse(fs.readFileSync(path.join(captureDir, "crash-attribution.json"), "utf8"));
156
+ return parsed && typeof parsed === "object" && typeof parsed.verdict === "string" ? parsed : null;
157
+ } catch {
158
+ return null;
159
+ }
160
+ }
161
+
162
+ // The harness observes that the app stopped running; the crash reports say whose fault it was.
163
+ // A simulator system process (SpringBoard) dying takes the app with it, and the XCUITest runner
164
+ // dying is instrumentation failure — neither is a defect in the app under test, and reporting
165
+ // either as a critical app crash is the false CRITICAL the desktop app fixed in 0.16 (issue #30).
166
+ // With no report in the run window the harness observation stands, unverified and said so.
167
+ export function reattributeCrashes(findings, attribution) {
168
+ for (const f of findings) {
169
+ if (f.type !== "crash") continue;
170
+ const r = attribution.reports || {};
171
+ if (attribution.verdict === "app") {
172
+ const report = r.app?.[0];
173
+ if (report) {
174
+ f.crashReport = report.path;
175
+ if (report.exceptionType) f.title = `${f.title} (${report.exceptionType})`;
176
+ }
177
+ } else if (attribution.verdict === "simulator-system") {
178
+ const report = r.simulatorSystem?.[0] || {};
179
+ f.type = "simulator_system_crash";
180
+ f.category = "environment";
181
+ f.severity = "medium";
182
+ f.authority = "advisory";
183
+ f.crashReport = report.path || null;
184
+ f.title = `Simulator system process ${report.procName || "(unknown)"} crashed${report.exceptionType ? ` (${report.exceptionType})` : ""} and took the app with it — not attributed to the app under test`;
185
+ } else if (attribution.verdict === "test-runner") {
186
+ f.type = "test_runner_crash";
187
+ f.category = "environment";
188
+ f.severity = "medium";
189
+ f.authority = "advisory";
190
+ f.title = "The XCUITest runner died mid-run (instrumentation failure) — the app under test is not known to have crashed";
191
+ } else {
192
+ f.attributionNote = "no crash report was found for this run window; the harness observation stands unverified";
193
+ }
194
+ }
195
+ return findings;
196
+ }
197
+
153
198
  export function buildQaReport(markersFilePath, { platform = "ios", target = null } = {}) {
154
199
  const base = parseOcqaMarkers(markersFilePath);
155
200
  if (!base) return null;
201
+ const crashAttribution = platform === "ios" ? readCrashAttribution(path.dirname(markersFilePath)) : null;
156
202
 
157
203
  const raw = fs.readFileSync(markersFilePath, "utf8");
158
204
  const rawIssues = [];
@@ -264,6 +310,7 @@ export function buildQaReport(markersFilePath, { platform = "ios", target = null
264
310
  ...(platform === "web" ? { evaluationTier: findingEvaluationTier(i, platform) } : {}),
265
311
  });
266
312
  }
313
+ if (crashAttribution) reattributeCrashes(findings, crashAttribution);
267
314
  findings.sort((a, b) => severityRank(a.severity) - severityRank(b.severity));
268
315
 
269
316
  const screensExplored = screens.size || base.uniqueScreens.length;
@@ -278,9 +325,9 @@ export function buildQaReport(markersFilePath, { platform = "ios", target = null
278
325
  const high = findings.filter((f) => f.severity === "high").length;
279
326
  const med = findings.filter((f) => f.severity === "medium").length;
280
327
  const low = findings.filter((f) => f.severity === "low").length;
281
- const verdictFindings = platform === "web"
282
- ? findings.filter((finding) => finding.evaluationTier !== "sampled")
283
- : findings;
328
+ // Advisory-authority findings (an environment event re-attributed away from the app) are
329
+ // reported but never counted toward the gate's deterministic tally.
330
+ const verdictFindings = findings.filter((finding) => finding.authority !== "advisory" && (platform !== "web" || finding.evaluationTier !== "sampled"));
284
331
  const verdictCrit = verdictFindings.filter((f) => f.severity === "critical").length;
285
332
  const verdictHigh = verdictFindings.filter((f) => f.severity === "high").length;
286
333
  const verdictMed = verdictFindings.filter((f) => f.severity === "medium").length;
@@ -512,14 +559,20 @@ export function computeContentCollapse(currentCounts, baselineCounts) {
512
559
  // vanishing from the same-budget exploration usually means navigation regressed (a dead
513
560
  // back button trapping the explorer, a broken link, a crash short-circuiting a flow).
514
561
  // Found via subtle-bug seeding: a dead back button stranded the run on one screen and
515
- // SHIP-READY passed with 3 of 6 baseline screens missing. Guarded: only fires when the
516
- // current run had a comparable action budget (≥60% of baseline actions), so a legit
517
- // short run doesn't spray false losses.
562
+ // SHIP-READY passed with 3 of 6 baseline screens missing. Two guards keep it honest:
563
+ // - a comparable action budget (≥60% of baseline actions), so a legit short run doesn't spray
564
+ // false losses;
565
+ // - a real collapse (fewer than 60% of the baseline's screens reached). Exploration order is not
566
+ // deterministic, and at a small budget a run routinely reaches 6 of 7 screens one time and a
567
+ // different 6 the next; that is variance, not a regression. The hosted iOS gate went red on
568
+ // exactly that (one of seven DemoApp screens unreached at 16 actions) on 2026-10-08.
518
569
  export function computeReachabilityLoss(current, baseline) {
519
- if (!current?.screens || !baseline?.screens) return [];
570
+ if (!current?.screens || !baseline?.screens || !baseline.screens.length) return [];
520
571
  const baseActions = baseline.actionsPerformed || 0;
521
572
  if (baseActions > 0 && (current.actionsPerformed || 0) < baseActions * 0.6) return [];
522
573
  const reached = new Set(current.screens);
574
+ const reachedBaseline = baseline.screens.filter((s) => reached.has(s)).length;
575
+ if (reachedBaseline >= baseline.screens.length * 0.6) return [];
523
576
  return baseline.screens
524
577
  .filter((s) => !reached.has(s))
525
578
  .map((screen) => ({
@@ -20,6 +20,7 @@ import {
20
20
  import { buildQaReport } from "./report.js";
21
21
  import { writeHtmlReport } from "./html-report.js";
22
22
  import { buildUiMapFromMarkers, writeUiMap } from "./ui-map.js";
23
+ import { writeCaptureProvenance } from "./capture-provenance.js";
23
24
 
24
25
  const require = createRequire(import.meta.url);
25
26
  const VERSION = (() => { try { return require("../../package.json").version; } catch { return "0.0.0"; } })();
@@ -322,6 +323,7 @@ export async function auditWebSite({
322
323
  const { chromium, devices } = await loadPlaywright();
323
324
  const browser = await chromium.launch(webBrowserLaunchOptions(process.env, {}));
324
325
  const capture = capturesDir ? openCapture(capturesDir, captureId || auditCaptureId()) : null;
326
+ const provenance = capture ? writeCaptureProvenance(capture.dir, { kind: "audit", platform: "web", target: start.href }) : null;
325
327
  try {
326
328
  const contextOptions = webContextOptions({ device, viewport, devices });
327
329
  // Identify ourselves to sites we do not own; the default UA is kept so rendering is unchanged.
@@ -396,7 +398,7 @@ export async function auditWebSite({
396
398
  };
397
399
  if (capture) {
398
400
  finalizeCapture(capture, { startUrl: start.href, pages: results, findings, robotsBlocked, linksChecked: { total: linksTotal, checked: linksChecked } });
399
- summary.capture = { id: capture.id, path: capture.dir, report: path.join(capture.dir, "report.html") };
401
+ summary.capture = { id: capture.id, path: capture.dir, report: path.join(capture.dir, "report.html"), provenance };
400
402
  fs.writeFileSync(path.join(capture.dir, "audit.json"), JSON.stringify(summary, null, 2));
401
403
  }
402
404
  return summary;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aarwitz/tapp",
3
- "version": "0.17.24",
3
+ "version": "0.17.26",
4
4
  "mcpName": "io.github.aarwitz/tapp",
5
5
  "description": "Let coding agents verify UI changes on real iOS, Android, and web surfaces, then enforce reviewed proof in deterministic CI.",
6
6
  "license": "MIT",
@@ -24,6 +24,7 @@
24
24
  "docs/application-model.md",
25
25
  "docs/scenarios.md",
26
26
  "mcp-server/src/",
27
+ "scripts/attribute-ios-crash.js",
27
28
  "scripts/ci-gate.sh",
28
29
  "scripts/compile-contract.js",
29
30
  "scripts/compile-flow.js",
@@ -89,7 +90,7 @@
89
90
  "mobile"
90
91
  ],
91
92
  "scripts": {
92
- "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/focused-navigation.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-link-audit.test.js tests/web-audit.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/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
93
+ "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/focused-navigation.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-link-audit.test.js tests/web-audit.test.js tests/capture-provenance.test.js tests/ios-crash-attribution.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/mcp-workspace.test.js tests/action.test.js tests/package-surface.test.js tests/agent-surface.test.js tests/presentation-contract.test.js tests/landing-brand.test.js tests/ci-gate.test.js tests/ci-report.test.js tests/desktop-protocol.test.js tests/ios-flow-protocol.test.js tests/feedback-triage-0919.test.js vscode-extension/test/bridge.test.js",
93
94
  "test:browser-journey": "node --test tests/browser-journey.test.js",
94
95
  "test:browser-native": "TAPP_RUN_NATIVE_BROWSER=1 node --test tests/browser-native-journey.test.js"
95
96
  }
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ // Called by quick-capture.sh after an iOS run whose markers contain a crash: decide from the real
3
+ // crash reports whether the app under test crashed or a simulator system process took it down,
4
+ // write crash-attribution.json into the capture, and print one line for the terminal.
5
+ //
6
+ // node scripts/attribute-ios-crash.js <capture-dir> <bundle-id> <simulator-udid> <run-start-epoch-seconds>
7
+ import path from "path";
8
+ import { fileURLToPath } from "url";
9
+ import { attributeRunCrash, writeAttribution } from "../mcp-server/src/ios-crash-attribution.js";
10
+
11
+ const [captureDir, bundleId, simulatorUdid, startSeconds] = process.argv.slice(2);
12
+ if (!captureDir || !bundleId) {
13
+ console.error(`usage: ${path.basename(fileURLToPath(import.meta.url))} <capture-dir> <bundle-id> [simulator-udid] [run-start-epoch-seconds]`);
14
+ process.exit(2);
15
+ }
16
+ // Reports can be written a few seconds after the process dies; look back a little before the run
17
+ // started so a crash at launch is not missed, and never miss one written after we checked.
18
+ const since = Number(startSeconds) > 0 ? Number(startSeconds) * 1000 - 15_000 : Date.now() - 3_600_000;
19
+ const attribution = attributeRunCrash({ since, bundleId, simulatorUdid: simulatorUdid || undefined });
20
+ writeAttribution(path.resolve(captureDir), attribution);
21
+ const r = attribution.reports;
22
+ const line = attribution.verdict === "app"
23
+ ? `Crash attribution: ${bundleId} crashed (${r.app[0].exceptionType || "see report"}) — ${r.app[0].path}`
24
+ : attribution.verdict === "simulator-system"
25
+ ? `Crash attribution: simulator system process ${r.simulatorSystem[0].procName} crashed (${r.simulatorSystem[0].exceptionType || "see report"}) and took the app with it — NOT attributed to ${bundleId}; ${r.simulatorSystem[0].path}`
26
+ : attribution.verdict === "test-runner"
27
+ ? `Crash attribution: the XCUITest runner died (instrumentation failure, not ${bundleId})`
28
+ : `Crash attribution: no crash report found for this run window; the harness observation stands unverified`;
29
+ console.log(line);
@@ -241,6 +241,7 @@ while [[ $# -gt 0 ]]; do
241
241
  done
242
242
 
243
243
  UDID=$(get_booted_sim)
244
+ RUN_START_TS=$(date +%s)
244
245
  SIM_NAME=$(get_sim_name)
245
246
 
246
247
  if [[ -z "$UDID" ]]; then
@@ -401,6 +402,12 @@ OCQA_COMPLETE:{\"actions\":0,\"states\":0,\"issues\":1,\"screens\":\"\",\"outcom
401
402
  fi
402
403
  echo "$OUTPUT" > "$CAPTURE_DIR/full-output.txt"
403
404
 
405
+ # A harness "crash" means the app stopped running; it does not say why. Cross-check the real
406
+ # crash reports so a SpringBoard death is not written up as the app's bug (issue #30).
407
+ if grep -q '"type":"crash"' "$CAPTURE_DIR/ocqa-markers.txt" 2>/dev/null; then
408
+ node "$PROJECT_ROOT/scripts/attribute-ios-crash.js" "$CAPTURE_DIR" "$APP_BUNDLE" "$UDID" "$RUN_START_TS" || true
409
+ fi
410
+
404
411
  COMPLETE_LINE=$(grep "OCQA_COMPLETE" "$CAPTURE_DIR/ocqa-markers.txt" | tail -1 || true)
405
412
  if [[ -n "$COMPLETE_LINE" ]]; then
406
413
  echo ""
@@ -77,6 +77,10 @@ ship verdict. Report:
77
77
  - each important finding and its evidence/report path;
78
78
  - what Tapp explicitly did not check.
79
79
 
80
+ Evidence is the capture the command just returned. `~/.tapp/captures/` is shared by every project on
81
+ the machine; `tapp_list_captures` shows only this project's and labels each with its provenance. Never
82
+ cite or reuse another project's capture, and never borrow one as a fixture — make a fresh one.
83
+
80
84
  If `inconclusive: true`, explain the blocker. A login wall or missing test data is not a pass. Ask for
81
85
  credentials or launch configuration instead of rerunning blindly. Do not infer content accuracy,
82
86
  privacy, brand consistency, or business guarantees from a generic crawl; those require a reviewed
@@ -93,6 +97,16 @@ ids or visible labels, check `hittable`, tap a field before typing, and wait for
93
97
  content. Use coordinates only as a last resort. End the session when finished.
94
98
 
95
99
  Do not edit the app merely because testing found a defect unless the user also asked for a fix. State what the evidence proves and what remains untested.
96
- If tapp itself misbehaves, draft feedback with `npx -y @aarwitz/tapp@latest feedback "title"` or `tapp_feedback`; it is public — draft first, `--submit` only with the user's OK.
100
+
101
+ ## File feedback on tapp itself — don't just work around it
102
+
103
+ A rough edge in Tapp (not the app under test) deserves its own report, filed the moment you
104
+ notice — not after you've already found a workaround and moved on. Draft with `tapp_feedback` or
105
+ `npx -y @aarwitz/tapp@latest feedback "title"` (draft only; `submit:true` needs the user's OK, it's
106
+ public) whenever: documented/expected behavior doesn't match reality; the underlying platform
107
+ tooling (simulator/emulator/browser) crashes or hangs, not the app under test; you had to invent a
108
+ workaround to finish a straightforward task; a result reported `ok`/`inconclusive` but clearly
109
+ shouldn't have; or you're unsure whether something is a real app finding or a Tapp bug. One report
110
+ per issue; when unsure, file — a closed non-issue costs nothing, an unreported bug stays a bug.
97
111
 
98
112
  Read [references/commands.md](references/commands.md) only for exact CLI/MCP syntax, Flow replay, credentials, or platform prerequisites.