Skip to content

mac Phase 4 Batch X: consented crash report with redaction (R5) - #1254

Draft
iamfatness wants to merge 11 commits into
mainfrom
mac-control-phase4-crash
Draft

iamfatness wants to merge 11 commits into
mainfrom
mac-control-phase4-crash

Conversation

@iamfatness

@iamfatness iamfatness commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Phase 4 control lane, Batch X (R5): consented crash report, with redaction, per docs/superpowers/plans/2026-11-22-mac-control-telemetry-leftovers-phase4.md Tasks 10-13. Draft, stacked on #1249 (base mac-control-phase4-telemetry). In progress. Do not merge without the owner's OK.

Privacy (D-X2): stricter than Windows on purpose

  • .ips reports are sanitized by an allow-list. crashReporterKey, bootSessionUUID, userID, incident ids, vmSummary, trialInfo, image paths and any /Users/<name> never leave the machine.
  • Log tails are redacted with the shell's redactor. When a tail starts mid-file, its partial first line is dropped, so a secret cut at the seek point can't slip past the line patterns.
  • Manifest skip lines name files, never local paths.
  • Red first: the privacy test ran against a builder that copied tails raw, as Windows does, and failed on exactly the planted stream key before redaction went in. It runs in the shell harness on CI's mac-shell-tests job, so a redactor that becomes a no-op again fails CI.
  • Windows' raw tails, and the local paths in its skip lines, are listed as candidate issues, not filed.

Security-review fixes (each red first, then green)

  • f41bf20: every kept .ips string goes through the full redactor and the known literals (crash/sanitize-redacts-kept-free-text). CrashArchiveRequest.knownSecretLiterals (stream key, meeting passcode, SRT passphrase) scrubs tails, and a final check withholds any entry that still carries a literal (crash/archive-known-literal-scrubbed, crash/archive-withholds-entry-with-literal). Strings and lines over 8 KiB are omitted, never scanned, because the redactor was quadratic and hung (crash/long-text-omitted-not-scanned).
  • 6ebd6c6: .ips keys get the same redaction, and colliding keys are both kept (crash/sanitize-redacts-keys-without-collisions). The literal check reads unescaped keys and strings before serialization (reports), parsed JSON (bundle), text (tails) and the scrubbed manifest (crash/literal-check-sees-through-json-escaping, with /, " and \).
  • Force-pushed 2026-11-26 on top of the rebased mac Phase 4 Batch T: opt-in telemetry (R4) #1249.

So far

  • Tasks 10-11: scanner (exact process names; macOS's .000 suffix handled), offer-once watermark, sanitizer, archive builder, uploader (POST /v1/crashes, X-CoreVideo-* headers with reason ips: <processes>, redirects refused, 120 s total timeout) and coordinator (none without a key). crash/* 93/93. Every named mutation turned red.

  • Task 12: the crash bar, in Windows' copy and states. Once per process, only with a key.

  • Not in this release (feature freeze): Task 13 (release symbols / dSYMs).

🤖 Generated with Claude Code

John Wallace and others added 6 commits November 26, 2026 16:03
… machine class

Task 7 of docs/superpowers/plans/2026-11-22-mac-control-telemetry-leftovers-phase4.md.

- contracts/telemetry.fixtures.json, written by the new MCT
  TelemetryFixtureExportTests from the REAL Windows telemetry code
  (COREVIDEO_REWRITE_TELEMETRY_FIXTURES=1). It holds payloads, ram bands,
  half-to-even RAM rounding, consent files and config resolution.
  - The payload inputs are core sync responses parsed on the LIVE path:
    CoreProtocolParser.TryParseWireState + MapNativeWireStateToSnapshot, as
    MediaCoreSupervisor does on a real core (confirmed). The direct
    TryParseSyncSnapshot branch is the stub path.
  - Participants come from the core's own participants node there; no Zoom
    merger on that path.
  - Three inputs: the secret-laden snapshot re-expressed as core JSON
    (stream key, guest name, recording folder, meeting URL, passphrase);
    engine off; NDI-only.
- TelemetryConfig: endpoint https://telemetry.corevideo.io, overridden by a
  non-blank COREVIDEO_TELEMETRY_ENDPOINT. The key comes ONLY from
  COREVIDEO_TELEMETRY_API_KEY (D-T1); nothing is embedded. Enabled = a key
  plus an absolute http(s) URL. The description never prints the key.
- MachineClassProbe (D-T2): mac-arm64-cpu<N>-ram<N>gb, RAM rounded half to
  even, Windows bands, gpuTier apple-m<gen>[-pro|-max|-ultra] from
  machdep.cpu.brand_string. No model code, serial or name.
- TelemetryPayloadBuilder: counts and on/off from the core snapshot, keys in
  Windows' order, a nil gpuTier omitted. Builder returns an ordered
  TelemetryPayload struct instead of a JSONObject, because a dictionary cannot
  keep the wire order.
- TelemetryConsentStore: the Windows JSON (DateTimeOffset "+00:00"),
  temp-file + rename, bounded 20 x 25 ms retry with the sleep injected.
  Absent, empty, corrupt, locked or unreadable files, and a directory at the
  path, all read OFF. A revoke lands on an unreadable file; a grant and
  markSent throw instead.
- TelemetryCrashCount and CrashReportRecord (Task 10 reuses it).

Tests (telemetry/*, 111 checks): payload-matches-windows (object-equal AND
key order at every level, all three inputs, no secret in the wire),
ram-bands, ram-rounding-half-even, machine-label, config-matches-windows,
consent-defaults-off (including the same store reading a file that turns
corrupt or locked), consent-file-shape (object- and text-equal),
revoke-lands-when-unreadable, marksent-never-revokes, crash-count. The MCT
exporter: 2/2.

Mutations (all red): RAM rounded half away from zero (8.5 GiB); gpuTier
always emitted (engine-off); streaming read from activeSenderCount instead
of sender status (ndi-only); a corrupt or locked file returning the last
in-memory value (same-store case); two payload keys swapped (order).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Task 8 of the Phase 4 control plan. Ports of Windows TelemetryEventClient
and TelemetryEventService.

- TelemetryEventClient: POST {endpoint}/v1/events (the absolute path
  replaces a base path, as Windows new Uri(endpoint, "/v1/events")),
  Authorization: Bearer, Content-Type: application/json. Outcomes: 2xx
  Accepted (reportId read); 429 or >= 500 RetryLater (Retry-After as delta
  seconds or an HTTP date relative to the injected now); anything else
  Rejected; a network error is RetryLater. Error bodies are cut to 300
  characters.
- TelemetryService: the heartbeat every 24 h (first after 24 h) is scheduled
  ONLY when configured at start, and sends only with consent at fire time,
  15 s timeout. Only a heartbeat RetryLater with Retry-After moves the next
  fire. Session-end is sent once per process with a 2 s timeout and never
  honours Retry-After. The exact wire JSON is logged before every POST, then
  "accepted (reportId=...)" or "not accepted (<Status>, http=<n|n/a>): ...".
  An accepted send records markSent(now). Every interval and timeout runs on
  an injected TelemetryClock (RealTelemetryClock = main-queue scheduling,
  which fires during .terminateLater).
- AppModel (D-T4): with consent and a key, an idle quit returns
  .terminateLater and replies when session-end finishes or 2 s pass,
  whichever is first, exactly once. Without either, the quit is .terminateNow
  as before. confirmQuit fires session-end first so it runs alongside output
  teardown. startTelemetry() reads the key only from
  COREVIDEO_TELEMETRY_API_KEY, logs only the endpoint host and whether a key
  is present, and never runs in the test harness.

Tests (telemetry/* 152, quit/* 105, all pass): client-classify,
client-request-shape (a URLProtocol stub, no network), no-send-without-
consent, no-send-without-key (no timer scheduled), session-end-once,
heartbeat-cadence (manual clock: 24 h, consent off at 30 h, Retry-After
600 s), audit-log-precedes-send, marks-sent-only-on-accept,
quit/idle-waits-for-session-end (run against a transport that honours its
timeout AND one that ignores it, rule 9; the reply comes at exactly 2 s),
quit/idle-unchanged-without-consent, quit/idle-replies-when-send-finishes
(0.3 s).

Mutations (all red): session-end honours Retry-After (a timer moved);
heartbeat scheduled without a key; quit replies only when the send finishes
(the never-returning transport never replies); log written after the POST.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Task 9 of the Phase 4 control plan (placement D-T3: the bottom of the Zoom
pane, after "Zoom status").

- TelemetryCard, in Windows' order and words (SettingsPage.xaml:187-221,
  SettingsViewModel.cs:140-152):
  - title "Diagnostics & telemetry";
  - toggle "Share anonymous health data" (Off/On);
  - the what-is-sent copy, verbatim;
  - a 12 pt accent status line: "Telemetry endpoint and API key configured."
    or Windows' missing-key sentence;
  - a ghost "Preview what's sent" button;
  - a bordered, monospaced, selectable, scrolling (max 320) preview of the
    indented session-end payload.
- The toggle loads the stored consent WITHOUT re-persisting it, persists only
  on the operator's change, and logs "telemetry: consent ENABLED/disabled by
  operator". The preview works with consent off and sends nothing.
- Diagnostics.swift header: "nothing in this file sends a byte off the
  machine; uploads live in Telemetry*.swift and CrashReport*.swift and need
  consent".
- Tab snapshot: COREVIDEO_SHELL_TAB_SNAPSHOT_TELEMETRY=1 seeds an open
  preview. It is opt-in, so other lanes' Zoom snapshots are unchanged. The
  capture was reviewed against the XAML order.

Tests: telemetry/card-copy (every string verbatim),
telemetry/toggle-persists-not-on-load (load writes nothing, a flip writes
once and logs, a repeat writes nothing), telemetry/preview-without-consent.
telemetry/* 167/167.

Mutations (all red): persist during the initial load; preview gated on
consent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n replies once

Rebasing Batch T onto main brought in #1236, which also defers an idle quit
(the Comms release-all in a meeting). Both holds now run side by side, and
finishIdleQuit replies exactly once, when the release has finished (its own
bound) AND session-end has finished or hit its 2 s cap. With neither hold
the quit is .terminateNow, as before.

quit/idle-waits-for-comms-and-session-end: released but session-end in
flight -> no reply; session-end done at 0.3 s -> one reply; never a second.
Mutation (red): mark telemetry done up front, so the reply comes after the
release alone. telemetry/* 167, quit/* 110, comms 268, all passing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ank key, heartbeat pin, quit window, transport hardening

The independent Batch T review found no blocking defect, and all 11 plan
mutations went red. Its gaps, each now fixed with a test that is red without
the fix:

1. The harness uses a distinctive API key, and the audit test asserts it is
   in NO log line (adding log(apiKey) used to stay green).
2. The fake transport's POST body equals the logged wire, byte for byte.
3. A blank or whitespace key is NO key (TelemetryConfig.resolve returns nil).
   New Windows exporter row (null, " ") in contracts/telemetry.fixtures.json:
   Windows reports enabled=false for it too.
4. Heartbeat pinned: after a RetryLater retry exactly one timer is armed, and
   the next 25 h hold exactly one more fire (a stale, uncancelled timer is
   red). New telemetry/heartbeat-no-drift: a send that takes 10 s does not
   push the next fire (cadence runs from the fire, as Windows' Timer period).
5. A held idle quit (session-end and/or the Comms release-all) sets the quit
   gate to .finishing (QuitGate.beginDeferredQuit) and quitFinishing, so a
   second quit is ignored (.terminateCancel) and no output can start in the
   window (canSetOutputs). The test first proves outputs COULD start, so the
   check cannot pass vacuously (a first version did, and was caught by its
   own mutation).
6. Transport:
   - redirects are refused by a session delegate, so the Bearer key never
     reaches another host and the 3xx is Rejected;
   - a HARD total timeout (timeoutIntervalForResource, one ephemeral session
     per send, no cookies or cache), as Windows' HttpClient.Timeout;
   - a neutral User-Agent "CoreVideoPro-Telemetry/1" with no OS build.
   Tested with the URLProtocol stub: one host contacted on a 302, the UA, a
   hung server ending at 0.5 s, and the resource timeout.

Mutations (all red): log the key; POST a body different from the log; keep a
blank key; leave the old heartbeat timer armed; reschedule after the send
(drift); no quit-gate phase; leave outputs open in the window; follow the
redirect; the default User-Agent; idle-only timeout.
telemetry/* 190, quit/* 116, comms 268, MCT exporter 2/2, all passing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…matches on Windows

System.Text.Json's indented output uses Environment.NewLine (\r\n on
Windows), so FixtureIsCurrent failed on the Windows CI job. The fixture is
unchanged (it was written with \n on macOS).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iamfatness
iamfatness force-pushed the mac-control-phase4-telemetry branch from 596cb02 to b225eb4 Compare November 26, 2026 21:06
John Wallace and others added 4 commits November 26, 2026 16:07
…ed crash archive, uploader, coordinator

Tasks 10 and 11 of the Phase 4 control plan, in one commit because their
tests share ShellTestsCrash.swift.

Task 10 (D-X1, D-X2):
- CrashReportScanner: .ips reports for CoreVideoProShell, corevideo-native,
  corevideo-zoom-engine, corevideo-plugin-host and corevideo-browser-host in
  ~/Library/Logs/DiagnosticReports (+ Retired). Exact process names
  (corevideo-native-tests-* never matches); the optional suffix is any digit
  run, because macOS writes ".000". Newer than the watermark, oldest first,
  each once; an unreadable folder does not hide the others.
- CrashReportWatermarkStore: Windows' JSON (camelCase, DateTimeOffset
  "+00:00"), 3-day first-run lookback, a corrupt file is the fresh default.
  CrashReportOffer.scanAndAdvance moves the watermark at scan time, so a
  report is offered once, sent or not.
- IpsSanitizer: an ALLOW-LIST copy. The header and body keys are the plan's;
  usedImages keep only uuid/base/size/arch/name/source (no path); threads keep
  triggered/id/threadState/queue/frames; any "/Users/<name>" in a kept string
  or key becomes "/Users/USER". Slashes are written unescaped, so text checks
  see real paths (a first version escaped them and a path check passed
  vacuously; caught and fixed with a parsed-value check). Unparsable input is
  nil and never sent raw.
- Fixture mac-shell/Tests/Fixtures/crash/CoreVideoProShell-fixture.ips is a
  trimmed real report: identity values are SENTINEL-*, with a planted
  /Users/jdoe in asi and one unredacted image path. It contains no real
  user name (the generator refused to write the file otherwise).

Task 11:
- CrashReportArchiveBuilder: manifest.txt, dumps/<name>.ips (SANITIZED),
  logs/<name> (REDACTED tails, last 2 MiB), support-bundle.json; Windows'
  manifest lines. Largest-first fit within the 24 MiB budget after logs,
  bundle and 64 KiB slack; reports oldest first; zipped with
  `ditto -c -k` from a staging folder (entries at the root).
  - Privacy beyond Windows: every tail line goes through Redactor.redactLines,
    and when a tail starts mid-file its partial first line is DROPPED, so a
    secret cut at the seek point (no rtmp:// prefix, too short for the
    entropy rule) cannot slip through. Skip lines name files, never local
    paths, and exception text is path-scrubbed.
- CrashReportUploader: POST /v1/crashes, Bearer, application/zip, the
  X-CoreVideo-Version / -Machine-Class / -Reason headers (reason "ips: <procs>";
  wer-dump is a Windows word), 120 s total timeout, redirects refused, the
  neutral User-Agent (the telemetry session), Windows' outcome classes and
  crash wording.
- CrashReportCoordinator: nil without a key (or with a blank one). The zip
  stays in ~/Library/Application Support/CoreVideoPro/support-bundles after
  upload. An accepted report id is recorded in the watermark, and nothing on
  RetryLater. Windows' thanks, saved-copy and assemble-error sentences.

Red first (owner instruction): crash/archive-log-tail-redacted was run
against a builder that copied the tail raw, as Windows does, and failed on
exactly the planted stream key before redaction went in.
crash/archive-log-tail-cut-mid-secret pins the partial-line drop. Both run in
the shell harness, which CI's mac-shell-tests job executes and which exits 1
on any failure, so a redactor that becomes a no-op again fails CI.

crash/* 93/93. Mutations (all red): no-op redactor; keep the partial first
line; smallest-first fit; --keepParent; record a report on RetryLater; keep
usedImages.path (caught by "no image path survives"; the path scrub alone
already defeats the identity check, defence in depth); drop
usedImages.uuid; prefix-match process names; advance the watermark only
after Send.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… final check) and the crash bar (3/3)

Two MEDIUM findings from the security review of 94254b0, each fixed red
first, plus Task 12.

1. Redact every kept .ips string (CrashReports.swift, IpsSanitizer.scrub).
   The allow-list kept free text (asi, exception, termination, ktriageinfo,
   legacyInfo, thread queue names) but only path-scrubbed it. Every kept
   string value now goes through Redactor.scrub with the known literals,
   after the /Users/<name> rewrite.
   Test crash/sanitize-redacts-kept-free-text plants a stream key and a
   token= value in the fixture's asi message. It was RED against the
   path-scrub-only sanitizer and is green now.
   Bound: a kept string over 8 KiB is replaced by "[omitted: N characters]",
   never scanned. The redactor's high-entropy rule is quadratic on one long
   run, and a 700 KiB string hung the harness for hours (sampled:
   NSRegularExpression under IpsSanitizer.scrub). Log-tail lines over 8 KiB
   are omitted the same way, so a crash upload can never hang on a huge
   string, and nothing that long is sent raw. Pinned by
   crash/long-text-omitted-not-scanned (600 KB in well under 5 s).
2. Known secret literals plus the final literal check (CrashReportArchive.swift).
   CrashArchiveRequest.knownSecretLiterals is filled by the coordinator at
   send time from the support bundle's source (stream key, meeting passcode)
   plus the SRT passphrase. Log tails use redactLines(text, literals:), and
   reports are sanitized with the literals. Before staging, as the support
   bundle's final check does, any entry (report, tail, bundle) that still
   carries a literal is WITHHELD; the manifest says "withheld: a known secret
   survived redaction" without quoting it.
   Tests: crash/archive-known-literal-scrubbed (a short lowercase passcode the
   regex rules provably miss is in no entry) and
   crash/archive-withholds-entry-with-literal (a raw bundle carrying the
   literal is withheld). Both were RED before the fix.

Task 12, the crash bar (CrashBar.swift; Windows StudioWorkspace.xaml:1337-1356,
.xaml.cs:137-226): a closable bar over the top of the content area, title
"CoreVideo Pro crashed last session", message with "crash report" for
"crash dump", "Send report", then sending, sent, not sent (with "Try again"
only when retryable) and failed. The launch scan runs once per process, off
the main actor, only with a key. The uploaded zip omits the Mac support
bundle, because it keeps local file paths; the manifest says why.

Mutations (all red): path scrub only (S1); tails redacted without the
literals (S2: the final check then withholds the tail, so the secret still
does not leave, but the case is red); no final check (S3); keep "Try again"
after a 413; scan on every call. Dropping the 8 KiB bound brings back the
hang itself rather than a clean red.

crash/* 129/129 (-j 3 build, run under a 600 s timeout).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… lint

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ck on unescaped text

A MEDIUM finding from the security review of f41bf20, fixed red first.

1. Keys (CrashReports.swift, IpsSanitizer.scrub): dictionary KEYS now get the
   same Redactor.scrub, known literals and 8 KiB bound as values (they were
   only path-scrubbed). Two keys that redact to the same text are both kept
   as "<key> (2)", ... (keys visited in sorted order, so the output is
   stable), never silently overwritten.
   Test crash/sanitize-redacts-keys-without-collisions: a stream key and two
   token= secrets inside asi KEYS. RED before (the secrets survived); the
   three keys must stay three, with all three values.
2. The final literal check now reads entries as the receiver will, not only
   as serialized bytes, because JSON escaping of '"' and '\' hid a literal
   from a byte search:
   - reports: IpsSanitizer.sanitizeChecked checks every unescaped key and
     string BEFORE serialization and withholds the report when a literal
     survives;
   - support bundle and any JSON entry: parsed, and every unescaped key and
     string checked (CrashReportArchiveBuilder.carriesLiteral);
   - log tails: checked as text;
   - manifest: scrubbed with the literals (it can quote a file name), and
     any line that still carries one is withheld (scrubManifest).
   Test crash/literal-check-sees-through-json-escaping: a literal with '/',
   '"' and '\' in a report KEY and escaped inside the bundle JSON, a log
   tail, and a second literal in a manifest skip line (a log file's name).
   RED before (both literals escaped detection).

Mutations (all red): keys path-scrubbed only; a colliding key overwrites;
a byte-only final check (with every JSON path off; a first mutant left the
line-by-line JSON path on and stayed green, so it was redone); the manifest
unscrubbed.

crash/* 136/136.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iamfatness
iamfatness force-pushed the mac-control-phase4-crash branch from ea4de50 to 6ebd6c6 Compare November 26, 2026 21:26
@iamfatness
iamfatness changed the base branch from mac-control-phase4-telemetry to main November 26, 2026 21:33
…undle; scrub JSON-escaped forms

Two findings from review of 6ebd6c6, fixed red first.

1. One source for the live secret literals (AppModel.liveSecretLiterals()).
   The crash report used [streamKey, srtPassphrase, joinPasscode] and the
   support bundle used [streamKey, joinPasscode] + the social credentials, so
   a crash report did not scrub the YouTube API key or the Twitch tokens by
   identity, and the support bundle (on main) did not scrub the SRT
   passphrase. Both now call liveSecretLiterals(): stream key, SRT
   passphrase, meeting passcode, YouTube API key, Twitch access and refresh
   tokens. The crash coordinator's construction is now
   AppModel.makeCrashCoordinator (production defaults; tests pass harness
   folders and keep the rest of the real wiring).
   Diagnostics.swift:641 is the headless self-check, which seeds its own
   synthetic secrets and has no model, so it keeps its own list (it passes).
   Test crash/live-secrets-reach-crash-zip-and-bundle plants all six as short
   values the patterns provably miss, through the REAL seams (model
   properties, and the harness's in-memory Keychain for SocialCredentials;
   the real Keychain is never touched), then checks the zip built by
   makeCrashCoordinator and the bundle from supportBundleInput(). RED before:
   ytk/twa/twr leaked from the crash zip and srtp from the bundle.

2. JSON-escaped forms of a literal (Redactor.literalForms: as typed, and
   JSON-escaped with and without "\/"). A log line that EMBEDS a JSON string
   after a text prefix carried the escaped form past both the redactor's
   literal replace and the final check. The shared redactor (Redactor.scrub)
   now replaces every form, longest first, so the support bundle gets it
   too; the bundle's verification pass, and the crash report's final checks
   (carriesLiteral on bytes and on unescaped JSON, scrubManifest, the .ips
   pre-serialization walk), search for every form.
   Test crash/escaped-literal-inside-a-text-line: `info: payload={"passcode":"pa\/ss\"w\\rd99"}`
   and the no-slash-escape form, for a literal with '/', '"' and '\'. RED
   before.

Mutations (both red): the shared list without the social credentials (the
crash-zip assertions fail); literalForms returning the raw form only.
crash/* 162, health/* 37, redaction/* 6, self-check PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant