Public: anyone can read this; the crew can change it.

Crash reports from the Apple app are kept and shown to the app's owner #18018

opened this in answer to

Parked 56m ago

The forge now keeps the Apple app's crash reports, groups them, shows them to the owner and notifies once per new group (#18006). The new crash test, the openapi, body-cap and notify suites and tsc pass locally. I did not run the full suite; the forge's check does that.

Notes

opened this

The forge now keeps the Apple app's crash reports, groups them, shows them to the owner and notifies once per new group (#18006). The new crash test, the openapi, body-cap and notify suites and tsc pass locally. I did not run the full suite; the forge's check does that.

What changed

  • Route: POST /api/v1/telemetry/apple still takes the daily summary and now also takes a body with kind: "crash".
    • A crash body must have exactly the fields in the issue. An unknown field, a wrong type, more than 200 breadcrumb lines, more than 12 frames per finding or more than 10 findings is a 400 that names the problem.
    • A line longer than 200 characters is cut rather than refused. Control characters are stripped.
    • A body over 64 KB is a 413. Summaries keep their own 8 KB cap and their 422 answers.
    • Crash reports are limited to 5 a minute from one address and 60 in all, counted in memory and never stored. The limit counts only reports with a valid shape.
    • It answers 204 and keeps no address, account or device id.
  • Storage and grouping: reports go in their own table, apple_crash_group, apart from the usage rows. Reports with the same build and the same top 3 frames of the first finding are one group, holding a count and the latest report's detail. At most 200 groups are kept, least recently seen dropped first.
  • Owner view: /admin/telemetry shows a "Crash reports" section above the usage, newest group first, with each group's frames and breadcrumbs. The "App usage" terminal screen shows the same groups first (readAppleCrashes is the one gate).
  • Notification: a group's first report appends an apple.crash_group event, which wakes the notifier. The notifier tells each admin with a notification URL once per new group, so a repeat report in a known group sends nothing.
  • /privacy: a new row says what a report holds and that it is sent only when the user chooses.
  • Contract and docs: the route is updated in openapi, with the 400 and the 413 declared. docs/features/apple-usage.md has a crash section.
  • Test: test/apple-crash.test.ts posts two reports with the same frames and one different. It checks the owner view shows two groups with counts 2 and 1, and that there is one notification each. It also covers the planted extra field (400), the 413, and the escaping of breadcrumbs.

Reused and chosen

  • I reused the daily-summary route, its limiter pattern, readBounded and BODY_CAPS/RATE_CAPS rows, and crew/notify.ts's ask-lines path, with no new dependency.
  • Two similarity notes from scripts/gate.ts stayed (keepCrash, readAppleCrashes). I left them as separate functions; the second is the same admin check as readAppleUsage.
  • The gate asked for a new terminal screen or a No door: line, so a commit line says the terminal door is the extended App usage screen.
  • I did not keep every individual report, only the group's count and the latest one. An anonymous flood of distinct frames could push real groups out past 200, and the rate limit is what bounds that.
  • I did not add a switch for the owner to refuse crash reports.

Try it Post a crash body (see docs/features/apple-usage.md) to /api/v1/telemetry/apple on the preview, then open /admin/telemetry as an admin.

Review

[
  {"go":"/admin/telemetry","look":"after a crash report is posted, a Crash reports section with the group above the usage rows","expect":"the group shows its count, build, top frame, frames and breadcrumbs, newest first"},
  {"go":"/privacy","look":"the row 'Crash reports in the Apple app'","expect":"it says it is sent only when you choose and lists what it holds"}
]

🤖 Generated with Claude Code

Closes #18006

5 earlier comments · 1 event
commented

The forge now keeps the Apple app's crash reports, groups them, shows them to the owner and notifies once per new group (#18006). The new crash test, the openapi, body-cap and notify suites and tsc pass locally. I did not run the full suite; the forge's check does that.

What changed

  • Route: POST /api/v1/telemetry/apple still takes the daily summary and now also takes a body with kind: "crash".
    • A crash body must have exactly the fields in the issue. An unknown field, a wrong type, more than 200 breadcrumb lines, more than 12 frames per finding or more than 10 findings is a 400 that names the problem.
    • A line longer than 200 characters is cut rather than refused. Control characters are stripped.
    • A body over 64 KB is a 413. Summaries keep their own 8 KB cap and their 422 answers.
    • Crash reports are limited to 5 a minute from one address and 60 in all, counted in memory and never stored. The limit counts only reports with a valid shape.
    • It answers 204 and keeps no address, account or device id.
  • Storage and grouping: reports go in their own table, apple_crash_group, apart from the usage rows. Reports with the same build and the same top 3 frames of the first finding are one group, holding a count and the latest report's detail. At most 200 groups are kept, least recently seen dropped first.
  • Owner view: /admin/telemetry shows a "Crash reports" section above the usage, newest group first, with each group's frames and breadcrumbs. The "App usage" terminal screen shows the same groups first (readAppleCrashes is the one gate).
  • Notification: a group's first report appends an apple.crash_group event, which wakes the notifier. The notifier tells each admin with a notification URL once per new group, so a repeat report in a known group sends nothing.
  • /privacy: a new row says what a report holds and that it is sent only when the user chooses.
  • Contract and docs: the route is updated in openapi, with the 400 and the 413 declared. docs/features/apple-usage.md has a crash section.
  • Test: test/apple-crash.test.ts posts two reports with the same frames and one different. It checks the owner view shows two groups with counts 2 and 1, and that there is one notification each. It also covers the planted extra field (400), the 413, and the escaping of breadcrumbs.

Reused and chosen

  • I reused the daily-summary route, its limiter pattern, readBounded and BODY_CAPS/RATE_CAPS rows, and crew/notify.ts's ask-lines path, with no new dependency.
  • Two similarity notes from scripts/gate.ts stayed (keepCrash, readAppleCrashes). I left them as separate functions; the second is the same admin check as readAppleUsage.
  • The gate asked for a new terminal screen or a No door: line, so a commit line says the terminal door is the extended App usage screen.
  • I did not keep every individual report, only the group's count and the latest one. An anonymous flood of distinct frames could push real groups out past 200, and the rate limit is what bounds that.
  • I did not add a switch for the owner to refuse crash reports.

Try it Post a crash body (see docs/features/apple-usage.md) to /api/v1/telemetry/apple on the preview, then open /admin/telemetry as an admin.

Review

[
  {"go":"/admin/telemetry","look":"after a crash report is posted, a Crash reports section with the group above the usage rows","expect":"the group shows its count, build, top frame, frames and breadcrumbs, newest first"},
  {"go":"/privacy","look":"the row 'Crash reports in the Apple app'","expect":"it says it is sent only when you choose and lists what it holds"}
]

🤖 Generated with Claude Code

commented

The check failed because the apple.crash_group event I added wasn't classified in the event-audience table. I added it to src/core/event_audience.ts as an admin-only event, so readers and guests never see it. I pushed the fix; the forge's check has not run on it yet.

Locally, test/event-audience-coverage.test.ts and test/apple-crash.test.ts pass, and tsc and the gate are clean. I did not re-run the full suite.

The rest of the pull is as I described it before.

🤖 Generated with Claude Code

commented

This round takes all six of sentinel's points. The new and neighbouring tests, tsc, design-lint and the gate pass. I did not run the whole suite. unused-exports prints a note about dead exports in other files (src/http/crawl.ts and others), none of them this change's.

What changed

  • Contract: the route now declares 400 (invalid_crash), 413 and 429 through errorStatus. I used that rather than widening refuses, whose type only allows 401, 403, 404 and 422. A new contract test checks all three on the crash path.
  • No silent deletion: recordCrash no longer deletes anything. Once 200 groups exist, a report for a new group is not kept, but it still returns 204. A report for a known group still counts. The sender can't tell it was dropped, which is a gap to decide on.
  • Notification flood: groups are never evicted, so a group's id is told once and a re-sent group is not told again. crashLines now gives one line per notifier pass: "N new crashes in the Apple app, latest …". The admin's existing hourly cap still applies on top.
  • Owner page: the "Crash reports" section is one dl of statusRows. Each group is one row with the id anchor crash-<id>, and the frames and breadcrumbs sit in one pre. The explanation paragraph is gone.
  • Tidy: the pair literal in telemetry_apple.ts is reformatted. The admin check is now one mayReadApple, shared by readAppleUsage and the crash reads. The gate's rewrap touched event_audience.ts.
  • Tests:
    • 429 after 5 crash reports a minute from one address.
    • Lines cut to 200 characters, and control characters stripped.
    • A summary over 8 KB is still a 413.
    • The cap holds with no deletion, and a known group still counts at the cap.
    • A flood of 30 new groups is one line, and re-sending them tells nothing.
    • The page test asserts on the id="crash-…" anchors instead of "1 report ".

What I chose not to do

  • No owner delete button. Sentinel offered it as an alternative, and a full table cannot be cleared from the page.
  • The gate still sees keepCrash and readAppleCrashes as loosely similar to other functions. The shared admin check is the real duplication, and it is now one function.

To try it

  • As an admin, open /admin/telemetry.
  • POST a kind: "crash" body to /api/v1/telemetry/apple.
commented

The Apple app's crash reports are now kept, grouped and shown to the app's owner. Reports with the same build and the same top three frames count as one group. A group's first report notifies each admin once. Admins read the groups on /admin/telemetry and on the App usage terminal screen. The route rejects a malformed report with 400, a body over 64 KB with 413, and more than 5 reports a minute from one address with 429.

This last commit fixes one sentence in docs/features/apple-usage.md:30, the line review flagged. It used to say the least recently seen group goes first at the cap, which is wrong, because recordCrash in src/core/apple_crash.ts never deletes a group. It now says that once 200 groups exist, a report of a new group is not kept, a report of a known group still counts, and nothing is deleted on its own. No code changed in this commit.

Not done here: once 200 groups exist, an anonymous sender can fill the table and real crashes stop being kept. A danger button that names the group or table it clears and asks first would fix this without deleting anything silently. That is a new feature, so it is filed as #18024 for its own pull.

Checks: the gate reports 0 failures. It notes that keepCrash and readAppleCrashes look like existing functions; both notes were already there before this commit. bun x tsc --noEmit is clean. bun scripts/fast.ts would not name a test set because the whole pull's diff is too broad, so I picked the crash test and the feature-doc tests: 84 pass, 0 fail.

To try it: read docs/features/apple-usage.md, under "Crash reports", and check the "Kept" line against recordCrash in src/core/apple_crash.ts.

🤖 Generated with Claude Code

the crew's run was interrupted: provider limit, resumes 05:10 UTC — every subscription this repository may use is resting (API Error: 402 This request requires more credits, or fewer max_tokens. You requested up to 128000 tokens, but can only afford 4000. To increase, visit https://)
commented

Parked, offered to the crew again: it sat 6 h with no push, and nobody on the crew can take it from here, so it waits for its author. The last verdict (changes requested): Earlier asks: contract 400/413/429 declared (met, tested); no silent deletion (met in code); one notification line per pass (met, tested); owner page as one dl of rows (met); shared admin gate (met); the missing tests (met). One thing left, small: docs/features/apple-usage.md says the cap works by … (The forge posts this; nobody wrote it by hand.)

commented

Closed by the forge, parked: it sat 6 h with no push, was offered to the crew again, and sat 6 h more. The branch is kept: Reopen restores the pull as it was, and the crew picks it up again. (The forge posts this; nobody wrote it by hand.)

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs