Repository navigation
feat(diagnostics): add client timings and investigation reports - #569
Merged
Merged
Conversation
nixuuu
force-pushed
the
feat/diagnostics-4-clients
branch
5 times, most recently
from
November 12, 2026 14:36
906880f to
903a86b
Compare
nixuuu
force-pushed
the
feat/diagnostics-4-clients
branch
from
November 12, 2026 14:42
903a86b to
9f3d2ad
Compare
nixuuu
force-pushed
the
feat/diagnostics-4-clients
branch
3 times, most recently
from
November 12, 2026 23:45
be8bfae to
545c7d7
Compare
nixuuu
marked this pull request as ready for review
November 12, 2026 23:59
nixuuu
force-pushed
the
feat/diagnostics-4-clients
branch
from
November 13, 2026 00:04
545c7d7 to
d728b28
Compare
nixuuu
force-pushed
the
feat/diagnostics-4-clients
branch
from
November 13, 2026 00:20
d728b28 to
7bdcb7a
Compare
nixuuu
added a commit
that referenced
this pull request
Nov 13, 2026
Collect logs now creates a bounded, redacted ZIP from the selected computers and their workers. Web and desktop download it through an authenticated, no-store route; mobile exports it using the existing native modules. This is diagnostics stage 5, stacked on #569. Keep the entire stack draft. ### Behavior and bounds - Shared `@canopy/logs` writer replaces the desktop-only writer and supports standalone gateway/worker/BFF logs. Fixed source aliases, 16 KiB lines, strict 5 MiB × 4 rotation and seven-day retention; periodic pruning during continuous writes. External PostgreSQL logs require an explicitly configured local adapter; no SQL logging is enabled. - Redaction runs at each source before 32 KiB sequenced/checksummed chunks. The export uses closed event templates: arbitrary messages, unknown JSON, SQL/parameters, paths, hosts, names, stacks and causes are omitted, with coverage counts. The coordinator verifies the closed format again. This intentionally exports less context than raw logs. - One owner job, two home readers, one exporter/home, sixteen selected computers and sixteen workers/home. Post-redaction caps: 2 MiB/source, 12 MiB/home, 96 MiB/action and 100 MiB ZIP. Sources are pull-driven, rate-limited and CPU-throttled; ZIP uses store mode and streams to private disk. No raw spool, whole-ZIP heap buffer, durable worker commands or retry queues. Per-chunk authorization checks do not clone the job/coverage tree. - Linked requests are source-only and nonrecursive. Onward log access has a separate owner-scoped grant (migration 0131); read grants do not imply log access. Revoke/cancel/expiry disconnect transfers and delete spools. Private source registration rejects paired phones, desktop renderers and linked callers. Partial sources remain explicit in a valid partial ZIP; retry creates a new action. Optional attachment uses ordinary owner-scoped placement, permissions and attachment limits, with a coverage-manifest note and no automatic unpacking. - Stack rebased onto dev `968757a4c`; diagnostics migrations remain 0129 (stage 1), 0130 (stage 4), 0131 (stage 5). It now reuses #574's shared `additional_capabilities` field and handshake implementation instead of the stack's duplicate extension field. Production legacy-peer integration passes (3 tests / 34 assertions); log security and gRPC export pass (3 / 16 and 4 / 138), with clean temporary directories. Generated contracts are committed; update/v1 is untouched. Final current-head CI is running; the maintainer authorized marking all seven PRs ready together once green. ### Mobile: JS-only No native dependency was added. **iOS uses Share logs; Android uses Save logs and the existing Storage Access Framework directory picker.** The successful Android save names the file and destination directory, and offers Open folder when the OS reports it can open the URI. Otherwise the destination confirmation remains visible. Share cancellation does not report a successful share. Private cache files are bounded, streamed, checksummed and removed after export, TTL or unpair. **A native Android share sheet is a possible follow-up when we next ship a native build anyway.** It is outside this stack. Pinned `bunx [email protected] fingerprint:generate --platform <ios|android> --build-profile production --json --non-interactive` matches stage 4 exactly: - iOS: `6ddec9ef559ee0095ac33e94ff9418a942053b17` - Android: `5f6eae3ab278f1cd543e9ed763f923a319b65ec9` ### Verification and remaining work Passed locally, one test file at a time: - `packages/logs/test/export.test.ts`: 8 tests, 46 assertions. Split secrets/UTF-8, oversized records, SQL/host/path/unknown payload omission, range/tail/legacy budgets, rotation/TTL, symlink refusal, pull checksums/cancel cleanup, coordinator verification and partial ZIP integrity/traversal. - `apps/gateway/test/diagnostics-logs-security.test.ts`: 3 tests, 18 assertions. Private source channel denial, bounded old-peer capability compatibility, verified-byte accounting, partial-source cleanup and absence of raw error/parameter bytes in ZIP. - `bun install`, `bun run gen:check`, full typecheck (Svelte zero errors/warnings), lint, format:check and `bash -n scripts/bench/diagnostics-stage5.sh` passed. The final transfer-only change also passed the focused gateway typecheck/security tests, lint and format check. After explicit permission, `tests/integration/diagnostics-logs.test.ts` passed: **4 tests, 138 assertions**, using three real gateways, relay read/log grant separation/revoke, worker source, auth, cancel and partial ZIP. `packages/db/test/schema.test.ts` passed: **23 tests, 85 assertions**; `thread-sync-upgrade.test.ts`: **1 test, 19 assertions**. Its rebase ordering error was corrected in stage 1 and cascaded through the stack; 0126 is now applied after the upgrade fixture is seeded. Files were run separately. Full gen:check/typecheck/lint/format checks passed again before measurement. Full `check:tmp` and a fresh web build are not claimed. Native manual QA is **blocked**: device discovery returned `Device list failed: Could not communicate with device support. Try refreshing devices.` twice, including the requested refresh. Android SAF/iOS share behavior is implemented but not confirmed on a device. No new browser/screenshots or native QA pass is claimed for stage 5. ### Copy audit — docs/copy.md §8 1. No log export → **Collect logs**, **Time range**, computer selection and concise secondary privacy/omission notes. English sentence case; each description has one idea, no new glossary terms or humor. Redaction is stated once, with missing/truncated coverage explained separately. 2. No export actions → **Download logs** on web/desktop, **Share logs** on iOS, **Save logs** on Android. The common collection/error text is shared in meaning. Android destination confirmation and conditional **Open folder** complete the save flow; user-requested platform terminology is preserved. 3. Generic failure → “Could not collect logs. Check the selection and retry.” Refresh/export/cancel errors each have a concrete retry or recollection action; no SQL, driver errors or implementation jargon appears on the surface. Retry also works when initial collection failed before a job existed. 4. No partial outcome → explicit per-computer progress, **Retry failed**, downloadable partial archive and a 15-minute availability note. Meaning does not depend on color; progress/status use live announcements. Optional agent attachment is unchecked and explicit. 5. Layout uses the existing kit Dialog/Sheet, controls and density. Short/typical/long-name desktop/phone visual verification remains open; it is not represented as a completed audit item. Run `bash scripts/bench/diagnostics-stage5.sh` only in a maintainer-confirmed quiet window. The launcher is reusable (about 140 minutes before retries). Its default is four pairs; the completed recording below is the current evidence. ### Measurement results — 2026-11-12 Measured head: `711b2b29b29ad8998c1d95b2e3d063a882a6cb8a`. Four accepted pairs, all attempt 1; no host-gate rejections. Strict **AB / BA / AB / BA**, fresh driver VM, PG cluster/database/WAL and gateway/worker state per member; idle 180 s, other phases 90 s. Stages 1–4 stay enabled on both sides. No tests or builds ran during recording. Every sampled scope had `MemorySwapMax=0` and `memory.swap.current=0` (stage 5: 7,649 samples, maximum load 2.74). Load and sustained swap-in gates passed. Host swap-out remains log-only. Pinning kernel kswapd away from the measured CPUs failed with **Operation not permitted**; kernel ticks/CPU and zram IO were recorded instead. **Each cell is all four pairs / sensitivity without flagged pair 4 (n=3).** Pair 4 is flagged by the agreed joint rule: a delta beyond 2×MAD coinciding with host swap-out >4 MiB/s. It stays accepted and included in the primary median. CPU is summed gateway + worker + PostgreSQL + driver/BFF, in percentage points of one core. RSS/heap here are gateway phase-end values, without forced GC; other processes are below. No fresh A/A control was run in this window, and no new A/A noise floor is claimed. | Phase | CPU pp | RPC p95 ms | RPC p95 % | Gateway RSS MiB | Gateway heap MiB | |---|---:|---:|---:|---:|---:| | idle | +0.019 / -0.025 | — | — | +0.848 / +0.223 | +0.148 / +0.133 | | steady | -0.116 / -0.221 | -0.146 / -0.293 | -4.021 / -8.070 | +0.285 / -0.629 | -0.208 / -0.144 | | reconnect | +0.074 / +0.103 | +0.232 / -0.052 | +9.225 / -1.948 | +0.607 / +1.383 | +0.597 / +0.336 | | slow_reader | +0.232 / +0.141 | -0.625 / -0.895 | -13.750 / -19.343 | +1.619 / +4.973 | +6.898 / +3.316 | | write_failure | +0.311 / +0.322 | +0.164 / +0.153 | +5.765 / +5.466 | -0.729 / +2.094 | +0.777 / +0.905 | | pool_contention | +0.044 / +0.187 | -0.253 / -0.202 | -7.108 / -5.232 | -0.154 / +0.297 | -2.999 / -4.728 | | governor | -0.092 / -0.220 | +0.231 / +0.301 | +7.768 / +11.164 | +9.666 / +12.328 | +6.104 / +8.395 | | report | +0.078 / +0.103 | -0.058 / +0.019 | -2.008 / +0.729 | +5.633 / +6.633 | +2.795 / +4.687 | | log_export | +0.860 / +0.906 | -0.233 / -0.080 | -8.666 / -3.156 | +3.059 / +1.934 | +2.150 / +2.073 | | Pair | Order | Accepted / attempt | Host swap-out MiB total | Peak MiB/s | Joint MAD flag | |---|---|---|---:|---:|---| | 1 | AB | yes / 1 | 0.000 | 0.000 | no | | 2 | BA | yes / 1 | 0.000 | 0.000 | no | | 3 | AB | yes / 1 | 0.000 | 0.000 | no | | 4 | BA | yes / 1 | 26.492 | 24.172 | yes | <details><summary>Worker and driver/BFF resource medians (all / sensitivity)</summary> | Phase | Worker CPU pp | Worker RSS MiB | Worker heap MiB | Driver/BFF CPU pp | Driver/BFF RSS MiB | Driver/BFF heap MiB | |---|---:|---:|---:|---:|---:|---:| | idle | -0.006 / -0.019 | -0.066 / -0.047 | +0.001 / +0.003 | +0.001 / -0.003 | +0.182 / -0.441 | -0.256 / -0.246 | | steady | +0.024 / +0.023 | +0.609 / +0.152 | +0.199 / +0.160 | -0.036 / -0.064 | -0.193 / -0.234 | -0.122 / -0.153 | | reconnect | +0.028 / +0.042 | -0.008 / -1.789 | +0.867 / +0.362 | +0.065 / +0.035 | +2.547 / +1.898 | +0.102 / -0.421 | | slow_reader | +0.033 / +0.054 | -0.543 / -1.629 | -2.135 / -2.589 | +0.176 / +0.115 | -1.117 / -0.738 | -0.330 / -0.324 | | write_failure | -0.012 / +0.002 | +1.699 / +0.465 | +4.755 / +4.209 | +0.149 / +0.052 | -2.094 / -0.227 | -1.003 / -0.220 | | pool_contention | +0.007 / +0.003 | +2.262 / +4.164 | +2.194 / +5.397 | +0.006 / +0.035 | +0.160 / -0.027 | +0.131 / -0.203 | | governor | -0.015 / -0.018 | +2.377 / +4.508 | +2.590 / +5.567 | +0.022 / +0.055 | +0.727 / +0.465 | +0.134 / -0.238 | | report | -0.011 / -0.016 | -0.070 / -0.219 | +0.333 / +1.286 | -0.035 / -0.019 | -0.668 / -0.133 | +0.445 / +0.760 | | log_export | +0.013 / +0.006 | +0.059 / +0.004 | +1.252 / +1.547 | +0.108 / +0.107 | +4.568 / +3.586 | +4.106 / +4.007 | </details> <details><summary>Per-pair deltas, every reported process and metric</summary> | Phase | Metric | Pair 1 AB | Pair 2 BA | Pair 3 AB | Pair 4 BA (flagged) | |---|---|---:|---:|---:|---:| | idle | gateway.cpuPp | +0.041 | -0.003 | -0.029 | +0.054 | | idle | worker.cpuPp | +0.007 | -0.019 | -0.035 | +0.016 | | idle | postgres.cpuPp | +0.004 | +0.002 | +0.002 | -0.001 | | idle | driverBff.cpuPp | +0.012 | -0.005 | -0.003 | +0.004 | | idle | driverBff.rssMiB | -0.914 | +0.805 | -0.441 | +0.848 | | idle | driverBff.heapMiB | -0.266 | -0.149 | -0.246 | -0.357 | | idle | total.cpuPp | +0.063 | -0.025 | -0.064 | +0.073 | | idle | gateway.rssMiB | +0.078 | +0.223 | +1.473 | +1.820 | | idle | worker.rssMiB | -0.039 | -0.047 | -0.086 | -0.207 | | idle | gateway.heapMiB | -0.107 | +0.162 | +0.133 | +0.408 | | idle | worker.heapMiB | +0.003 | +0.003 | -0.002 | -0.000 | | steady | gateway.cpuPp | +0.153 | -0.188 | +0.016 | +0.103 | | steady | worker.cpuPp | +0.023 | +0.068 | -0.035 | +0.025 | | steady | postgres.cpuPp | -0.051 | -0.012 | -0.170 | -0.133 | | steady | driverBff.cpuPp | +0.278 | -0.089 | -0.064 | -0.007 | | steady | driverBff.rssMiB | -1.316 | -0.152 | -0.234 | +0.883 | | steady | driverBff.heapMiB | -0.348 | -0.077 | -0.153 | -0.092 | | steady | total.cpuPp | +0.404 | -0.221 | -0.252 | -0.012 | | steady | gateway.rssMiB | -12.125 | -0.629 | +1.688 | +1.199 | | steady | worker.rssMiB | +0.152 | -1.660 | +1.066 | +1.398 | | steady | gateway.heapMiB | -0.865 | +0.662 | -0.144 | -0.271 | | steady | worker.heapMiB | +0.160 | -0.305 | +0.914 | +0.238 | | steady | rpc.p95Ms | -0.438 | -0.293 | +0.001 | +0.674 | | steady | rpc.p95Percent | -13.310 | -8.070 | +0.029 | +24.274 | | steady | history.p95Ms | -2.277 | -0.472 | +4.313 | +3.000 | | reconnect | gateway.cpuPp | -0.027 | -0.242 | +0.073 | -0.022 | | reconnect | worker.cpuPp | +0.053 | +0.042 | +0.013 | -0.137 | | reconnect | postgres.cpuPp | +0.125 | +0.059 | -0.018 | +0.108 | | reconnect | driverBff.cpuPp | +0.142 | -0.020 | +0.035 | +0.095 | | reconnect | driverBff.rssMiB | -0.508 | +1.898 | +3.195 | +3.352 | | reconnect | driverBff.heapMiB | -0.421 | +0.625 | -1.013 | +0.769 | | reconnect | total.cpuPp | +0.293 | -0.161 | +0.103 | +0.045 | | reconnect | gateway.rssMiB | -0.168 | +2.512 | +1.383 | -9.902 | | reconnect | worker.rssMiB | +1.773 | -7.203 | -1.789 | +8.039 | | reconnect | gateway.heapMiB | +0.336 | +0.857 | -0.217 | +0.992 | | reconnect | worker.heapMiB | +1.373 | -9.732 | +0.362 | +10.010 | | reconnect | rpc.p95Ms | -0.291 | -0.052 | +0.516 | +0.671 | | reconnect | rpc.p95Percent | -10.784 | -1.948 | +20.398 | +24.062 | | reconnect | history.p95Ms | +3.040 | +0.200 | -2.134 | -2.085 | | slow_reader | gateway.cpuPp | +0.183 | +0.118 | -0.025 | +0.217 | | slow_reader | worker.cpuPp | +0.086 | +0.001 | +0.054 | +0.012 | | slow_reader | postgres.cpuPp | -0.033 | -0.083 | -0.409 | -0.144 | | slow_reader | driverBff.cpuPp | +0.242 | +0.106 | +0.115 | +0.237 | | slow_reader | driverBff.rssMiB | -0.738 | +0.707 | -3.344 | -1.496 | | slow_reader | driverBff.heapMiB | -0.445 | -0.018 | -0.324 | -0.336 | | slow_reader | total.cpuPp | +0.478 | +0.141 | -0.265 | +0.322 | | slow_reader | gateway.rssMiB | +4.973 | +21.238 | -11.492 | -1.734 | | slow_reader | worker.rssMiB | -1.629 | +0.543 | -3.004 | +1.605 | | slow_reader | gateway.heapMiB | +3.316 | +11.428 | -9.515 | +10.479 | | slow_reader | worker.heapMiB | -2.589 | +4.198 | -6.769 | -1.681 | | slow_reader | rpc.p95Ms | -1.766 | -0.355 | -0.895 | +0.385 | | slow_reader | rpc.p95Percent | -42.127 | -8.158 | -19.343 | +9.860 | | slow_reader | history.p95Ms | -2.356 | -8.044 | +0.413 | -5.779 | | write_failure | gateway.cpuPp | +0.115 | +0.235 | -0.088 | +0.133 | | write_failure | worker.cpuPp | +0.095 | +0.002 | -0.026 | -0.069 | | write_failure | postgres.cpuPp | +0.061 | +0.059 | -0.046 | -0.011 | | write_failure | driverBff.cpuPp | +0.052 | +0.029 | +0.343 | +0.247 | | write_failure | driverBff.rssMiB | -0.227 | -0.223 | -5.363 | -3.961 | | write_failure | driverBff.heapMiB | -0.220 | -0.127 | -1.786 | -1.906 | | write_failure | total.cpuPp | +0.322 | +0.325 | +0.183 | +0.300 | | write_failure | gateway.rssMiB | -3.551 | +14.039 | +2.094 | -6.078 | | write_failure | worker.rssMiB | -2.848 | +0.465 | +8.070 | +2.934 | | write_failure | gateway.heapMiB | +0.905 | +4.019 | +0.649 | -0.768 | | write_failure | worker.heapMiB | -8.781 | +4.209 | +10.713 | +5.301 | | write_failure | rpc.p95Ms | +0.153 | -0.076 | +0.175 | +0.275 | | write_failure | rpc.p95Percent | +6.064 | -2.411 | +5.466 | +9.490 | | write_failure | history.p95Ms | +2.001 | +5.788 | -4.282 | +2.557 | | pool_contention | gateway.cpuPp | -0.095 | +0.364 | +0.061 | +0.009 | | pool_contention | worker.cpuPp | -0.035 | +0.010 | +0.003 | +0.013 | | pool_contention | postgres.cpuPp | -0.188 | +0.025 | +0.026 | -0.097 | | pool_contention | driverBff.cpuPp | +0.035 | -0.071 | +0.096 | -0.024 | | pool_contention | driverBff.rssMiB | +0.492 | -0.027 | -0.398 | +0.348 | | pool_contention | driverBff.heapMiB | -0.294 | -0.203 | +0.585 | +0.466 | | pool_contention | total.cpuPp | -0.283 | +0.328 | +0.187 | -0.099 | | pool_contention | gateway.rssMiB | +2.266 | -12.020 | +0.297 | -0.605 | | pool_contention | worker.rssMiB | +4.578 | +4.164 | -3.941 | +0.359 | | pool_contention | gateway.heapMiB | -4.728 | -15.253 | -1.269 | +1.475 | | pool_contention | worker.heapMiB | +14.064 | +5.397 | -6.205 | -1.009 | | pool_contention | rpc.p95Ms | -0.202 | -0.304 | +0.072 | -1.128 | | pool_contention | rpc.p95Percent | -5.232 | -8.985 | +1.890 | -30.891 | | pool_contention | history.p95Ms | -6.037 | +6.568 | +1.054 | -14.428 | | governor | gateway.cpuPp | -0.322 | -0.041 | -0.023 | +0.011 | | governor | worker.cpuPp | -0.023 | +0.000 | -0.018 | -0.012 | | governor | postgres.cpuPp | -0.010 | +0.021 | -0.094 | +0.087 | | governor | driverBff.cpuPp | +0.055 | +0.056 | -0.084 | -0.011 | | governor | driverBff.rssMiB | +0.465 | +1.035 | -1.727 | +0.988 | | governor | driverBff.heapMiB | -0.481 | -0.238 | +0.572 | +0.506 | | governor | total.cpuPp | -0.300 | +0.036 | -0.220 | +0.074 | | governor | gateway.rssMiB | +31.313 | +7.004 | +12.328 | -12.113 | | governor | worker.rssMiB | +0.246 | +4.508 | +8.816 | -1.438 | | governor | gateway.heapMiB | +31.634 | +8.395 | +3.813 | -8.002 | | governor | worker.heapMiB | -3.118 | +5.567 | +13.482 | -0.387 | | governor | rpc.p95Ms | +0.641 | +0.048 | +0.301 | +0.160 | | governor | rpc.p95Percent | +27.310 | +1.755 | +11.164 | +4.372 | | governor | history.p95Ms | -7.450 | -18.052 | +0.713 | -0.204 | | report | gateway.cpuPp | +0.248 | +0.040 | +0.105 | -0.456 | | report | worker.cpuPp | -0.016 | -0.006 | -0.018 | +0.015 | | report | postgres.cpuPp | +0.018 | +0.087 | +0.068 | +0.115 | | report | driverBff.cpuPp | +0.159 | -0.019 | -0.102 | -0.052 | | report | driverBff.rssMiB | -0.133 | +3.406 | -1.203 | -1.742 | | report | driverBff.heapMiB | +0.129 | +1.506 | +0.760 | -1.316 | | report | total.cpuPp | +0.409 | +0.103 | +0.054 | -0.378 | | report | gateway.rssMiB | +6.633 | +10.074 | +4.633 | -9.980 | | report | worker.rssMiB | +8.137 | -7.145 | -0.219 | +0.078 | | report | gateway.heapMiB | +4.687 | +10.820 | +0.903 | -7.223 | | report | worker.heapMiB | +12.229 | -13.792 | +1.286 | -0.620 | | report | rpc.p95Ms | +0.206 | -0.741 | +0.019 | -0.136 | | report | rpc.p95Percent | +7.681 | -26.205 | +0.729 | -4.746 | | report | history.p95Ms | -1.606 | -0.153 | +2.184 | +0.344 | | log_export | gateway.cpuPp | +0.843 | +0.786 | +0.971 | +0.491 | | log_export | worker.cpuPp | +0.006 | -0.023 | +0.020 | +0.046 | | log_export | postgres.cpuPp | +0.053 | -0.057 | -0.083 | -0.016 | | log_export | driverBff.cpuPp | +0.004 | +0.107 | +0.109 | +0.110 | | log_export | driverBff.rssMiB | +3.586 | +5.551 | +1.031 | +6.266 | | log_export | driverBff.heapMiB | +4.205 | +4.007 | +2.770 | +5.354 | | log_export | total.cpuPp | +0.906 | +0.814 | +1.016 | +0.631 | | log_export | gateway.rssMiB | +1.934 | +1.234 | +7.273 | +4.184 | | log_export | worker.rssMiB | -2.262 | +0.113 | +0.004 | +3.574 | | log_export | gateway.heapMiB | +2.228 | -1.995 | +2.073 | +7.766 | | log_export | worker.heapMiB | -3.744 | +1.547 | +2.134 | +0.957 | | log_export | rpc.p95Ms | -0.080 | -0.424 | +0.262 | -0.386 | | log_export | rpc.p95Percent | -3.156 | -14.177 | +10.368 | -14.516 | | log_export | history.p95Ms | -0.290 | -3.568 | +1.943 | -3.835 | </details> Four B log actions downloaded checksum-verified **partial** archives, 3,961,767–3,961,926 bytes each, in 14.822–15.410 s; median duration **14.925 s**. All A actions returned disabled. The explicit export phase averages CPU across 90 s; it is separate from ordinary background collection. A short export-only A/B smoke passed before the full run. Preserved excluded recordings: the first attempt aborted because the driver read a child-only diagnostics flag when validating B; the harness now reads its own member flag. The next attempt completed two accepted pairs, then received SIGTERM during pair 3 (no scope-swap or host-gate violations). After confirmation that nobody intentionally stopped it, the entire stage was rerun through **setsid + nohup**, PID file and controller log, because the launcher has no resume mode. Only the four complete pairs from that detached recording enter the medians above; the earlier two are kept as additional evidence, not pooled. Evidence (uncommitted): `/var/tmp/canopy-diagnostics-5/window-20261112-detached/{head.txt,results.jsonl,paired-report.json,stderr.log,controller.log,controller.pid}`. Raw deltas and every joint-rule flag remain in paired-report.json. Measurements are complete; **CPU, p95 and memory accepted by the maintainer on 2026-11-12**, as recorded above. All PRs remain drafts. The driver-flag harness fix passed scripts typecheck, repository lint and format checks; the export-only A/B smoke then verified disabled A and checksum-verified partial B before the detached full recording. Product code and native fingerprints did not change. ## Whole-stack QA correction — 2026-11-12 The live log collector emitted versioned gateway and UUID-shaped worker startup/link lines which the template allowlist omitted. Recognize those closed runtime templates, then emit only primitive timestamp/source/event/legacy fields. The original line, version, worker ID, address, path, SQL and parameters still never enter the exported records. The existing security test now includes actual runtime-shaped startup/link messages: **8 tests / 50 assertions passed**, with a clean temporary directory. Downloading through the browser then produced a valid partial ZIP containing five sanitized gateway events and explicit unavailable/omitted source coverage. Manual QA covered collection progress, partial/offline/unsupported sources, retry and ZIP download at desktop/narrow/phone widths in light/dark, including long names. Install, gen:check, full typecheck, lint, format:check and web build passed. Copy audit: no new UI copy; the existing privacy and missing-source notices remain accurate. Evidence is in `/var/tmp/canopy-diagnostics-6/qa/` (uncommitted). Native mobile Share/SAF interactions were not exercised by this browser run. ## Maintainer acceptance — 2026-11-12 Stages 4 (#569) and 5 (#572) are accepted for CPU, RPC p95 and memory. The maintainer accepted the measured cumulative stages 2–5 memory difference: about **+5 MiB idle**, **+5–12 MiB under typical load**, and about **+15 MiB worst case during governor load**. Existing A/B results are preserved. No further memory investigation, bounded-memory re-tests, A/A controls or full A/B runs are required for this acceptance. The entire diagnostics stack remains draft and will merge together after stage 6 is accepted.
nixuuu
added a commit
that referenced
this pull request
Nov 13, 2026
One diagnostics session can now collect short, explicitly requested traces on one computer's gateway or one connected worker. Owners can start a 1/5/10-minute session, stop it and export its samples from web, desktop and mobile. The default is five minutes; tracing never starts through overview polling or log collection. **Stage 6 slow-reader cost occurs while explicitly requested tracing is active.** In B, `benchTracing()` starts gateway tracing before every phase, including `slow_reader`, exports its samples and stops it afterward. A leaves tracing inactive; stages 1–5 are enabled on both sides. All four B slow-reader runs exported 616 samples each with zero drops. The maintainer accepts the measured cost for this opt-in mode (at most 10 minutes): **+0.562 ms p95 (+15.242%), +21.322 MiB RSS / +18.900 MiB heap**; without flagged pair 4, **+0.581 ms, +20.668 / +19.489 MiB**. These are active-session working-set observations, not the tracing-off cost. Four accepted / zero rejected pairs, zero scope swap throughout; CPU medians are at most +0.148 pp. Full results remain below. ### Stop, GC and export-retention evidence — 2026-11-13 Ran only the requested focused slow-reader A/B: `bash scripts/bench/diagnostics-retention.sh 6 slow_reader end`, immutable head `0d058ff70d1dec3791c2c697c155de56d9bb2c5a`. It reuses fresh state, seeded history, periodic detail views and the 90-second workload. B exported 615 samples with zero drops and stopped before the heap checkpoint. Both scope swap values remained zero; the focused pair passed load/swap-in gates. No full overhead recording was repeated. After stop and two full GCs, gateway heap was **A 75.267 MiB / B 76.722 MiB, B−A +1.455 MiB**. Before GC it was A 94.439 / B 84.507 MiB. The earlier roughly +19 MiB endpoint difference is therefore not retained after collection in this focused workload. Persistence had zero pending minutes/bytes on both sides. The snapshot diff shows one extra `Float64Array` (**144,048 bytes**, the bounded 2,000-span ring), +0.938 MiB `ArrayBuffer` self bytes with unchanged object count, and +0.440 MiB function-code self bytes. These are root-reachable self-size deltas, not dominator retained sizes; snapshot graphs and sanitized retainer paths are private evidence. Stop immediately disables recording; it deliberately preserves the **141 KiB numeric ring for up to ten minutes** so the owner can still export the finished trace. Temporary export DTOs are not cached. The purge timer then clears the ring and session state; worker stop also detaches its governor observer, and close/disconnect clears everything. This is bounded post-stop export retention, not an immediate-zero-memory claim. Added an isolated lifecycle regression: 12 consecutive saturated rings and protobuf exports, two full GCs after every stop and TTL expiry. Heap after GC: warm baseline **6.906 MiB**, final stopped **6.986 MiB (+0.079 MiB)**, final purged **6.848 MiB (−0.058 MiB)**. Every sample stayed within 2 MiB of baseline; no accumulation across cycles, and the old lease becomes unexportable after expiry. The existing gRPC/WorkerLink tests also verify explicit stop, expiry, detached worker observation and restart. No production tracing/instrumentation change was needed. Evidence: `/var/tmp/canopy-diagnostics-6/retention-stop/run/end/` (`post-gc.json`, A/B snapshots, `retention-diff.json`, raw events), and `/var/tmp/canopy-diagnostics-6/final-trace-memory-test.log`; not committed. - One ephemeral lease per computer, fenced stop/export, monotonic expiry and no restoration after restart. Worker disconnect clears its ring and observer. Direct linked homes support explicit actions; onward tracing is denied. Existing owner authentication and direct-peer export permission apply. - Sample less than 1% of fixed RPC/DB/pool/ingest/governor operations, at most 100 samples/s and 2,000 spans. The numeric ring allocates **141 KiB on explicit start**, within the separate **4 MiB tracing ceiling**, and is purged within ten minutes after stop/expiry. Inactive recording uses no clocks or allocations. Export DTOs are temporary and never cached. Ordinary snapshots contain session metadata only; peer persistence omits it. - No payload, SQL, parameters, error objects/messages/stacks or arbitrary labels enter the ring. Names are projected from local descriptors/family definitions at export. Remote unknown protobuf fields and supplied names are discarded. Start, stop, expiry, cancellation and export have separate scalar audit events; coordinator/home actions share the lease ID. - Additive protobuf messages, WorkerLink frame 852 and `diagnostics_trace_v1`; generated contracts included. No migration, protocol bump, frozen `update/v1` edit or native dependency. Parent stages 4 (#569) and 5 (#572) were accepted for CPU, p95 and memory by the maintainer on **2026-11-12**. Their existing four-pair A/B results are preserved. Additional governor memory investigation/tests and A/A recordings were stopped as requested. Stack #506 will be marked ready after all seven current-head CI runs are green; the maintainer merges the entire stack together. ### Verification Focused tracing integration covers actual gRPC + WorkerLink start/stop/export, independent homes, authentication, foreign workers, stale leases, expiry and gateway restart. It verifies the sample/rate/ring caps, real failed parameterised SQL, malicious worker names/unknown fields and scalar audit records. Run one file at a time. Existing diagnostics and log integrations also protect the shared collectors, snapshots, capability negotiation and log pipeline. Passed: `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check`, the web production build, `git diff --check` and shell syntax validation of the stage-6 bench script. Focused `check:tmp` runs, one file at a time: tracing (4 tests, 64 assertions), diagnostics (7 tests, 50 assertions) and logs (4 tests, 138 assertions); all passed with clean temporary directories. Local evidence is under `/var/tmp/canopy-diagnostics-6/` (not committed). A full local integration suite was not run; focused `check:tmp` runs verify cleanup, and CI runs the repository suite. After the QA fixes and restack, repeated install, gen:check, full typecheck, lint, format:check and web build successfully. Focused files ran individually: report adapter **3 tests / 9 assertions**, log export security **8 / 50**, and the previously authorized gRPC log integration **4 / 138**. All passed with clean temporary directories. Both pinned mobile fingerprint commands were rerun and preserved the hashes below. The final stack rebase uses dev `968757a4c`, including #579's avatar-cache fix and the newly merged citation contracts. It reuses #574's `additional_capabilities` field/shared handshake implementation rather than duplicating field 8. Migrations remain 0129/0130/0131. Post-rebase local checks passed: gen:check, full typecheck (including mobile and Svelte), lint, format:check, shard manifest, web production build and diff checks. Focused files passed individually through `check:tmp`: tracing **4 / 64**, trace memory **1 / 27**, logs **4 / 138**, client diagnostics **8 / 66**, diagnostics **7 / 50**, production legacy capability compatibility **3 / 34**, log-source/archive security **3 / 16**, and GitHub avatar cache **9 / 39**. Controlled temporary directories are clean; forensic scopes/listeners have stopped. The final current-head CI workflows are running; PRs stay draft until all seven are green, then will be marked ready together as requested. Mobile stays JS-only. Pinned `bunx [email protected] fingerprint:generate --platform <ios|android> --build-profile production --json --non-interactive` preserves iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17` and Android `5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. Trace export uses the existing iOS Share and Android directory picker. Browser QA is complete below; native device interactions were not exercised by that run. ### Measurement protocol — completed `bash scripts/bench/diagnostics-stage6.sh` — about **100–110 minutes**, longer after rejected pairs. Four fresh AB/BA/AB/BA pairs on the same revision, with stages 1–5 enabled on both sides. A leaves tracing inactive; B explicitly starts tracing on the gateway, then on the worker in its own phase. Idle (3 min), steady, slow receiver, governor, gateway tracing with log export, and worker tracing with log export (90 s each); existing synthetic sync, journal/ACK, deterministic harness/git and RPC traffic continue. Each B phase exports and checks samples, then stops its lease. The recording used swap-disabled user scopes for gateway, worker and bench PostgreSQL. Every sample had zero scope swap; load and sustained swap-in gates passed. Host swap-out was recorded without rejecting solely for it. Pair 4 met the joint 2×MAD/high-swap-out rule and remains in primary medians; sensitivity excludes it. `updatedb` ran for 40 s during A's governor phase (PID 2103822); the pair's host swap-out was 214.195 MiB, peak 111.262 MiB/s. No tests or builds ran on the measured server during recording; manual QA/checks ran on the second machine. No additional A/A controls were recorded, as instructed. Recording and all owned processes are finished; the benchmark ports are free. ### Copy audit — docs/copy.md §8 Before: no tracing action or feedback. After: “Start deeper tracing”, “Stop tracing”, “Export samples”, one short privacy sentence, explicit expiry/off/unsupported states and an error with a retry action. The longer Start label is the accepted spec wording. Controls reuse the settings kit, compact density, semantic colours, reduced-motion support and minimum touch targets; no new custom animation or native control. Numbers/times and off/unsupported status are textual. Long worker names use the existing Select/SettingChoice truncation. No new metaphor or glossary synonym. Desktop/narrow/phone light/dark interactions and long-name layouts were checked without page-wide horizontal overflow. ### Whole-stack browser QA Reviewed linked overview, gateway/DB/governor, worker resources and queues, client delivery, Markdown/JSON report preview and placement selection, log collection/download and deeper tracing on a disposable seeded stack. Light/dark at 1440×1000, 768×1024 and 390×844; long names, offline/unsupported homes and empty/loading/read-error/Retry states. Gateway start/stop worked for 1/5/10 minutes; actual one-minute automatic expiry exported 91 samples. Worker start/stop/export worked through the fixture WorkerLink; that brief idle UI session had no worker samples, while integration and the acceptance bench exercise active work. Trace action failure recovered on retry. No uncaught errors in valid flows. Fixed two findings in their owning stages: semantic DB disclosure borders and shared short RPC histogram copy (#535), plus actual startup/link log template recognition with a security regression test (#572). Interrupted final screenshots/static checks were repeated after the QA machine reboot. Browser, fixture processes and its named container were stopped; allocated ports were verified free and the disposable checkout cleaned. Evidence: `/var/tmp/canopy-diagnostics-6/qa/qa-report.md` and adjacent screenshots/check logs, not committed. Limitations: synthetic linked/worker data, no native device interaction, and no real investigation thread was created because the fixture advertised no available model. Project/workspace selection and the disabled unavailable-model state were checked. Focused integration provides ownership, tracing-capability and cross-home protocol evidence. # Stage 6 measurement — 2026-11-12/13 Measured immutable head: `3182e35547152f36d42a75fc918ed40e60df0d69`. Four accepted / zero rejected pairs, first attempt each, strict AB / BA / AB / BA. A=tracing inactive, B=explicit tracing; stages 1–5 enabled on both. Every member used a fresh driver, PostgreSQL cluster/database/WAL and gateway/worker state. Initial counts matched (500 threads, 1,000 turns, 7,099 items, 840 rollups). Every scope sample had MemorySwapMax=0 and memory.swap.current=0. Load and sustained swap-in gates passed. No foreign tests/builds were observed. Host swap-out is log-only under the agreed protocol. Pair 4 is flagged by the joint >2×MAD and >4 MiB/s host swap-out rule, and remains in the primary medians. `updatedb` PID 2103822 (`/usr/bin/updatedb --prune-bind-mounts=no --add-prunepaths=/.snapshots`) ran 00:14:56–00:15:36 CET during A's governor phase. Pair 4 peak host swap-out was 111.262 MiB/s, total 214.195 MiB. Scope swap remained zero and load peaked at 2.03 in that member. The job finished before the recording ended; no pair was retried. Kernel kswapd/zram counters were logged; kernel affinity could not be changed. Gateway/worker/PostgreSQL were pinned to CPUs 2/3/4. CPU values are percentage points of one core. RSS/heap are endpoint MiB without forced GC. Percent deltas are paired percent changes, not a ratio of medians. These results are reported for maintainer acceptance; the repeatable slow-receiver memory increase is not attributed solely to updatedb or labelled as accepted noise. ## Gateway — primary n=4 | Phase | CPU pp | p95 ms | p95 % | RSS MiB | Heap MiB | | --- | ---: | ---: | ---: | ---: | ---: | | idle | -0.006 | — | — | 0.713 | 0.106 | | steady | 0.148 | 0.108 | 3.248 | 0.213 | 0.976 | | slow_reader | -0.07 | 0.562 | 15.242 | 21.322 | 18.9 | | governor | -0.006 | 0.147 | 5.519 | -7.998 | -11.524 | | log_export | 0.067 | 0.055 | 3.744 | 8.502 | 8.282 | | trace_worker | -0.032 | 0.154 | 5.415 | 3.58 | 1.564 | ## Gateway — sensitivity excluding flagged pair 4, n=3 | Phase | CPU pp | p95 ms | p95 % | RSS MiB | Heap MiB | | --- | ---: | ---: | ---: | ---: | ---: | | idle | 0 | — | — | 0.742 | 0.059 | | steady | 0.107 | 0.273 | 8.148 | -0.133 | 0.716 | | slow_reader | 0.011 | 0.581 | 16.144 | 20.668 | 19.489 | | governor | 0.044 | 0.236 | 8.947 | -13.77 | -14.327 | | log_export | 0.135 | 0.389 | 15.517 | 14.098 | 10.387 | | trace_worker | 0.012 | 0.335 | 11.765 | 2.586 | 0.437 | ## Worker and process totals Total CPU sums the measured gateway, worker and PostgreSQL processes; it excludes the driver. | Phase | Worker CPU pp n4 / n3 | Worker RSS MiB n4 / n3 | Worker heap MiB n4 / n3 | PostgreSQL CPU pp n4 / n3 | Total CPU pp n4 / n3 | | --- | ---: | ---: | ---: | ---: | ---: | | idle | -0.004 / -0.009 | 0.115 / 0.113 | -0.003 / -0.003 | -0.004 / -0.008 | -0.014 / -0.017 | | steady | -0.002 / -0.003 | 0.426 / 0 | 0.258 / 0.204 | 0.052 / 0.02 | 0.195 / 0.119 | | slow_reader | -0.001 / 0.003 | -0.041 / 0.301 | -0.405 / -0.499 | 0.055 / -0.008 | -0.023 / -0.008 | | governor | -0.013 / -0.009 | 0.064 / 0.168 | -0.244 / -0.187 | -0.081 / -0.066 | -0.034 / 0.082 | | log_export | -0.024 / -0.012 | -0.043 / 0.066 | -1.354 / -0.859 | -0.064 / -0.058 | 0.033 / 0.111 | | trace_worker | -0.052 / -0.032 | -1.33 / -0.078 | -0.858 / -0.06 | -0.083 / -0.073 | -0.139 / -0.056 | ## Host results | Pair | Order | Result | Host swap-out MiB | Peak MiB/s | | --- | --- | --- | ---: | ---: | | 1 | AB | Accepted | 0 | 0 | | 2 | BA | Accepted | 0 | 0 | | 3 | AB | Accepted | 0 | 0 | | 4 | BA | Accepted, sensitivity flag | 214.195 | 111.262 | ## Per-pair deltas Each cell lists pairs 1 / 2 / 3 / 4, including the flagged pair. Full raw deltas and every flag are in paired-report.json. | Phase | Metric | Pair 1 | Pair 2 | Pair 3 | Pair 4 | | --- | --- | ---: | ---: | ---: | ---: | | idle | gateway.cpuPp | 0 | -0.044 | 0.016 | -0.012 | | idle | worker.cpuPp | -0.009 | -0.04 | 0.007 | 0.001 | | idle | postgres.cpuPp | -0.008 | 0.01 | -0.013 | 0 | | idle | total.cpuPp | -0.017 | -0.074 | 0.01 | -0.012 | | idle | gateway.rssMiB | 1.742 | 0.742 | 0.453 | 0.684 | | idle | gateway.heapMiB | 0.059 | 0.433 | -0.134 | 0.154 | | idle | worker.rssMiB | -0.246 | 0.117 | 0.113 | 0.391 | | idle | worker.heapMiB | -0.004 | -0.003 | 0.001 | -0.008 | | steady | gateway.cpuPp | 0.107 | 0.361 | -0.164 | 0.189 | | steady | worker.cpuPp | -0.009 | -0.003 | -0.001 | -0.002 | | steady | postgres.cpuPp | 0.02 | 0.015 | 0.085 | 0.084 | | steady | total.cpuPp | 0.119 | 0.373 | -0.08 | 0.271 | | steady | gateway.rssMiB | -0.133 | 1.047 | -18.813 | 0.559 | | steady | gateway.heapMiB | 1.411 | 0.443 | 0.716 | 1.236 | | steady | worker.rssMiB | -0.02 | 0.852 | 0 | 0.949 | | steady | worker.heapMiB | 0.204 | -0.196 | 0.312 | 0.729 | | steady | rpc.p95Ms | 0.294 | 0.273 | -0.596 | -0.058 | | steady | rpc.p95Percent | 9.376 | 8.148 | -16.475 | -1.653 | | steady | history.p95Ms | 8.931 | -3.046 | -6.787 | -3.789 | | slow_reader | gateway.cpuPp | 0.011 | 0.504 | -0.331 | -0.15 | | slow_reader | worker.cpuPp | 0.003 | 0.029 | -0.016 | -0.006 | | slow_reader | postgres.cpuPp | -0.324 | -0.008 | 0.339 | 0.118 | | slow_reader | total.cpuPp | -0.31 | 0.525 | -0.008 | -0.037 | | slow_reader | gateway.rssMiB | 21.977 | -13.918 | 20.668 | 22.203 | | slow_reader | gateway.heapMiB | 23.389 | -13.107 | 19.489 | 18.311 | | slow_reader | worker.rssMiB | -0.625 | 1.395 | 0.301 | -0.383 | | slow_reader | worker.heapMiB | 0.631 | -0.603 | -0.499 | -0.311 | | slow_reader | rpc.p95Ms | -0.25 | 0.581 | 0.643 | 0.544 | | slow_reader | rpc.p95Percent | -5.625 | 16.144 | 17.859 | 14.341 | | slow_reader | history.p95Ms | -4.318 | -3.259 | -5.754 | 4.18 | | governor | gateway.cpuPp | 0.261 | -0.056 | 0.044 | -0.267 | | governor | worker.cpuPp | -0.017 | 0.003 | -0.009 | -0.02 | | governor | postgres.cpuPp | -0.066 | -0.096 | 0.048 | -0.107 | | governor | total.cpuPp | 0.178 | -0.149 | 0.082 | -0.394 | | governor | gateway.rssMiB | -2.227 | -23.598 | -13.77 | 27.488 | | governor | gateway.heapMiB | -8.722 | -31.28 | -14.327 | 49.258 | | governor | worker.rssMiB | 0.168 | -0.777 | 0.84 | -0.039 | | governor | worker.heapMiB | -0.3 | -0.187 | 0.963 | -4.956 | | governor | rpc.p95Ms | 0.855 | 0.236 | 0.058 | -0.074 | | governor | rpc.p95Percent | 34.976 | 8.947 | 2.092 | -2.188 | | governor | history.p95Ms | 1.449 | 2.052 | -2.135 | -3.485 | | log_export | gateway.cpuPp | -0.002 | 0.258 | 0.135 | -0.16 | | log_export | worker.cpuPp | 0.016 | -0.012 | -0.035 | -0.06 | | log_export | postgres.cpuPp | -0.058 | -0.07 | 0.011 | -0.204 | | log_export | total.cpuPp | -0.045 | 0.176 | 0.111 | -0.423 | | log_export | gateway.rssMiB | 2.906 | 14.844 | 14.098 | -6.305 | | log_export | gateway.heapMiB | 3.504 | 10.406 | 10.387 | 6.177 | | log_export | worker.rssMiB | -0.152 | 0.066 | 8.836 | -0.156 | | log_export | worker.heapMiB | -0.859 | -1.849 | 14.348 | -2.912 | | log_export | rpc.p95Ms | 0.532 | 0.389 | -0.278 | -0.963 | | log_export | rpc.p95Percent | 20.023 | 15.517 | -8.03 | -25.016 | | log_export | history.p95Ms | -1.88 | 5.93 | -10.343 | -19.754 | | trace_worker | gateway.cpuPp | 0.012 | -0.076 | 0.392 | -0.436 | | trace_worker | worker.cpuPp | 0.025 | -0.073 | -0.032 | -0.078 | | trace_worker | postgres.cpuPp | -0.093 | -0.073 | 0.098 | -0.221 | | trace_worker | total.cpuPp | -0.056 | -0.222 | 0.458 | -0.735 | | trace_worker | gateway.rssMiB | 4.574 | 2.586 | 1.527 | 6.938 | | trace_worker | gateway.heapMiB | 0.236 | 3.499 | 0.437 | 2.691 | | trace_worker | worker.rssMiB | -0.078 | 10.621 | -3.441 | -2.582 | | trace_worker | worker.heapMiB | -0.06 | 19.303 | -1.657 | -2.397 | | trace_worker | rpc.p95Ms | 0.346 | 0.335 | -0.028 | -1.725 | | trace_worker | rpc.p95Percent | 12.327 | 11.765 | -0.936 | -40.849 | | trace_worker | history.p95Ms | 0.708 | -2.349 | 2.665 | -140.633 | ## Sampling, controls and postprocessing All four B runs exported gateway trace samples in every gateway phase and worker samples in the worker phase, with zero trace drops. No new A/A controls were run, following the maintainer's instruction to stop extra A/A work. Earlier stages' steady A/A envelope (about 0.58–0.98 ms) is historical context only, not a new control or a noise adjustment for this run. Slow-receiver p95 is +0.562 ms (+15.242%) primary / +0.581 ms (+16.144%) sensitivity; its gateway RSS/heap increase persists without pair 4. The first launcher invocation aborted before measurements because the short-phase guard omitted stage 6. That guard was fixed and committed before this immutable recording. All four completed pairs above come from the clean restart. The final postlude then exposed a report-only assumption that every stage records every known phase; it was corrected to use the recorded phase subset, with focused adapter tests covering earlier stages, complete pairs and strict order. The corrected report was regenerated from unchanged raw results; no recordings were repeated for that fix. Subsequent QA fixes are isolated to stage-2 UI tokens/copy, stage-5 startup/link log template recognition and the report adapter. No tracing instrumentation changed after this measured head. Their final restacked heads are reported in the PRs. No collector budget or native fingerprint changed. Evidence directory: `/var/tmp/canopy-diagnostics-6/window-20261112-stage6-retry/` (not committed): head.txt, results.jsonl, paired-report.json, controller.log, controller.pid, stderr.log, maintenance.txt. Raw heap snapshots were not collected in this gate. All measured processes/scopes ended and benchmark ports were verified free.
nixuuu
added a commit
that referenced
this pull request
Nov 15, 2026
Retired client sessions were never pruned, and the sender lease never expired while the client kept submitting every minute. After the third reload, every batch from that sender got ResourceExhausted (HTTP 429) until it stopped submitting for five minutes. Retirements now carry a timestamp and expire after a sliding five-minute window. A retired session stays ignored until its window ends. Fixes: #569 Co-Authored-By: Claude Opus 5.5 <[email protected]>
nixuuu
added a commit
that referenced
this pull request
Nov 15, 2026
## Cause
`ClientDiagnostics.submit()` (`apps/gateway/src/diagnostics/clients.ts`)
keeps the retired sessions of each sender+source channel so it can
ignore replays. A third new session raised
`ResourceExhausted("Diagnostics session limit reached")`. The comment
said "twice within its five-minute lease", but:
- the lease never expired while the client kept submitting, because
`state.last` is refreshed on every batch and channels are only evicted
after 300 s with no batches;
- `retired` was never trimmed.
So after the third page reload (each reload starts a new session;
desktop uses `crypto.randomUUID()`), every batch from that sender got
HTTP 429 (`gateway-errors.ts` maps `ResourceExhausted` to 429). This
lasted until the client stopped submitting for five minutes, and that
client's diagnostics were lost. In the desktop renderer it shows up as
`POST /api/diagnostics/submit 429` once a minute.
## Fix
- Retired sessions now carry their retirement time, and entries older
than five minutes are dropped, giving a real sliding window. At most two
new sessions are accepted per channel in any five minutes; a third still
gets `ResourceExhausted`.
- A retired session stays ignored until its window ends. After that,
replays are still blocked: the window (300 s) is longer than the batch
freshness tolerance in both directions (±120 s, so 240 s in total). Any
batch accepted before the retirement is already rejected as stale by
then.
- Memory accounting is unchanged: the fixed 1 KiB per-channel
reservation already covers at most two retired entries. `#restored`
checkpoints don't use `retired`.
- The client is unchanged. It already swallows submit errors (`.catch(()
=> {})`). The console line is the browser's own network log. With this
fix a 429 is only a short, rate-limited condition, so a client backoff
isn't clearly needed.
- `docs/diagnostics.md` now describes the restart window (in Polish).
Fixes: #569 (the PR that added the session limit)
## Verification
Ran locally:
- `bun run check:tmp ./tests/integration/diagnostics-clients.test.ts`:
11 pass. The new test fails on the old code with `Diagnostics session
limit reached` and passes with the fix. It covers:
- a reload every three minutes over 24 minutes keeps being accepted;
- a third restart within five minutes is still limited;
- a retired session is still ignored inside its window;
- a stale replay after the window is rejected.
- `apps/gateway` typecheck, plus oxlint and oxfmt on the edited files.
Left to CI: the full gate (gen:check, repo-wide typecheck/lint/format,
all test shards, builds).
Copy audit: not applicable, no UI text changes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <[email protected]>
nixuuu
added a commit
that referenced
this pull request
Nov 15, 2026
## Change Running many threads made each renderer fetch background history and repeatedly reload panels and PR lists. The BFF now materializes overview, thread metadata and settings from one owner/target-scoped `WatchOverview`, shares loaded read models and pushes complete projections over SSE. Ready-key lookup is O(1); response encoding and list traversal still scale with response size. - Move bounded history warming to the BFF and remove renderer `/warm` requests and panel/PR polling. Visible history and older pages remain on demand. - Share and reactively refresh panels, PR lists, proxies, model catalogs, bots and updates. Bound caches/queues and fence old results across reconnects, sharing resets and target changes. - Allow independent diagnostics sessions with browser/BFF submission cooldown, accept GitHub avatar version hashes, and keep infinite decorative animations out of composer transition controls. - Update the affected Polish architecture, API, performance, diagnostics, connector and GitHub docs. ## Verification - After rebasing onto current `dev`: 17 real-gRPC BFF integration tests / 100 assertions passed through `check:tmp`; temporary directory clean. Web and integration-package typechecks and test-shard ownership check passed. - Earlier focused checks passed for diagnostics, avatars/panels, shared-query invalidation/projection races, gateway/mobile/domain typechecks, and edited-file lint/formatting. - Inspected light/dark at desktop and phone widths. Reconnect recovery and rapid thread navigation worked without page errors. - Isolated browser probe with 12 synthetic thread submissions: the observed renderer issued 3 HTTP requests over 12.1 seconds, with no `/warm`, panel or PR-list requests. This is a synthetic sample, not a production percentile. - No user-facing copy changed. Full generated-code checks, repository-wide checks, remaining test shards and builds are left to CI. Fixes: #623 Fixes: #569 Fixes: #756
nixuuu
added a commit
that referenced
this pull request
Nov 18, 2026
…gs (#986) ## Nightly.75 console report - Reproduced the `actorAvatars` exception and `derived_inert` warnings by invalidating avatar reads just before a PR snapshot reset. Scheduled refreshes now use a mounted subscriber, and a later explicit read uses its own fetch function. - Preserve the saved timeline anchor through a slow initial snapshot. Start the positioning deadline once data arrives and compare watch liveness against loaded history. Routine history paging still contributes to the diagnostics counter. Actionable recovery warnings keep their reason. - Open a cold thread through the owner-scoped GetThread RPC while the overview stream is rebuilding. Skip Git scans for unavailable placements. Report busy, missing, oversized and timed-out checkouts in the panel, retain the last successful counts on a transient scan failure, and cancel an abandoned shared HTTP request when its last reader leaves. - Skip idle web, desktop and BFF diagnostics submissions. Reserve admission and checkpoint space for active sessions within the existing 6 MiB budget. A frozen minute carries its checkpoints even if RPC load exhausted the space for its metric series. The screenshots omit response bodies and the expanded recovery objects. The tests cover concrete paths to the reported statuses. Genuine connectivity and rate limits still surface. ## Local verification - Focused shared-query, overview invalidation, BFF state and reads, Git status, thread history/watch, client diagnostics and persistence tests. Gateway, domain and web typechecks passed. Lint and formatting checked on edited files. Full gate runs in CI. - Chromium at 1280 and 390 px, light and dark. PR reset and avatar reload produced no exception or Svelte warning after the fix. In a 1000-turn thread, a 2.25 s initial snapshot delay restored an 8 px scroll offset. A real checkout reported its changed file, and a removed worktree issued no Git request. Desktop rapid navigation cancelled the in-flight request. At phone width in both themes, closing thread details and navigating to the removed worktree started one Git read, cancelled it once and issued no further Git request. ## Copy audit Reviewed all ten items in docs/copy.md §8. Generic Git refresh failures now identify the missing directory, busy checkout, size limit or timeout and give a recovery action. Directory terminology matches the glossary. Short, typical and long names were checked at desktop and phone widths. All items pass or are inapplicable. Fixes: #456 Fixes: #569 Fixes: #672 Fixes: #799 Fixes: #847 Fixes: #900
nixuuu
added a commit
that referenced
this pull request
Nov 18, 2026
) ## Changes - Commit consecutive buffered text deltas for the same worker thread and turn together, up to 32 events and 256 KiB of text and raw JSON. The first delta following a control message proceeds immediately. Publish individual events in order and acknowledge committed journal prefixes. Retry failed groups per event. - Start PR file-page and Viewed reads concurrently through the existing GitHub request scheduler. Verify mutable REST data before caching it and verify head, base and account mapping before returning the result. - Reserve capacity for process, queue and ACK measurements within existing collector and snapshot memory limits. Export window boundaries, sanitized loss reasons and per-link losses. Omit inapplicable statistics and exclude events without a receipt timestamp from ACK latency. - Give each PostgreSQL test server an IPC-linked helper that can remove its own container and volume after the runner exits. Removal targets the full Docker ID. Existing containers are outside its scope. ## Local verification - In three runs per mode against a local PostgreSQL/gRPC fixture, the median 160-event burst required 9 transcript transactions and ACKs with batching versus 160 before. Median run p95 for burst send to ACK fell from 638 ms to 186 ms. Time to first gateway publication was 18.1 ms before and 17.4 ms after. These timings describe the fixture. - With a cached PR summary, the 300-file GitHub fixture required one upstream summary request on a warm file-page read, down from three. The cold read issued one REST page request, three Viewed requests and two summary checks. Tests cover head/base changes and account remapping mid-read. - Targeted tests covered bounded event batches, mixed frames, retry and quarantine, journal replay, live thread updates, durable threads, owner-scoped PR reads, cache behavior, collector pressure, memory bounds, export, durable diagnostics history and schema setup. Temp-directory checks passed. - Verified interruption during PostgreSQL setup with two concurrent fixtures. Killing the first runner removed only its database container. Terminating the second removed its container too. - Gateway, transport and database package typechecks passed, as did lint and formatting for the edited TypeScript. Repository-wide static checks, test shards and platform builds run in GitHub CI. Fixes: #523 Fixes: #535 Fixes: #569
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage 4 adds sampled client and BFF timings to Settings → Diagnostics, a redacted JSON/Markdown report, explicit placement for an ordinary investigation thread, and a durable reset baseline. Web/desktop and mobile expose the same actions and source groups. This is a draft on top of #542 in
gh stack#506; stages 5–6 remain separate work.Behavior and bounds
diagnostics_v1capability because the whole stack ships together; another hello entry exceeded older peers' 32-capability limit. The separate direct-only allowlist remains enforced.579a81a413252418a70d5eabc291a1e1bd09a4fb. Reserved migrations 0124–0128 are left to concurrent PRs: Stage 1 is 0129_diagnostics, stages 2–3 add none, and Stage 4 is 0130_diagnostics_actions. Receipts live with their thread (cascade deletion), with no independent TTL. Registry/schema/upgrade expectations are updated. Contracts are additive and generated;update/v1is untouched.Verification
Focused coverage includes authenticated schema/rate/size limits, unknown-field redaction, owner placement denial, exact concurrent idempotency, attachment delivery, receipt/checkpoint restart continuity, stale sequence/epoch fences, rollback and error redaction, selected worker reset without losing gateway history, direct-home/onward denial, real paired TLS mobile ingestion and immediate revoke. BFF integration uses real gRPC and actual SSE cancellation, keeping local/remote observations separate and excluding self-submission.
Parent #535 contains the maintainer's requested deterministic governor/series bound: 175 assertions, 40 families × four SQL phases × eight RPC correlations, twenty 72-minute cycles after warmup, two full GCs per sample. Heap +0.0763 MiB, stable object counts, all fixed collector/sub-budget caps held. Stages 2–3 gates are accepted; no full bench was rerun for this condition.
Final focused checks passed one file at a time via
check:tmp: gateway SQL/governor 10 tests / 97 assertions, linked diagnostics/direct reset 7 / 50, client auth/report/reset/restart 8 / 66, and BFF unary/SSE 2 / 8 — 27 tests, 221 assertions, with no temp leftovers. The direct reset accepts the transport's empty route envelope while rejecting every actual relay envelope. The driver-error security fixture replaces JSC's lazy stack before installing private message getters. The five-second shared-view cache has an explicit ten-second observation deadline in the ingestion test.On the earlier Stage 4 revision,
bun install,gen:check, repository typecheck, lint, format check, web build, script typecheck/shell syntax and the shard manifest check passed. Before the latest rebase, fullcheck:tmp --max-concurrency 1passed: 2504 pass, 166 skips, 0 failures, 33,232 assertions across 470 files, with no temp leftovers (27 minutes). Its isolated governor/series child again plateaued after GC: 15,924,808 → 16,001,722 bytes (+0.0734 MiB), objects 22,620 → 22,605, with all caps held. Native CNG prebuild and Android/iOS JS/Hermes exports passed. Pinned EAS CLI 27.4.1 production fingerprints remain identical to Stage 3: iOS6ddec9ef559ee0095ac33e94ff9418a942053b17, Android5f6eae3ab278f1cd543e9ed763f923a319b65ec9. No native configuration/dependency changes or publication.Additional mobile checks: Expo Doctor 19/20, with 13 existing SDK patch-version mismatches; app-wide Expo ESLint reports existing React-hook/import findings outside the diagnostics modules. Diagnostics-scoped ESLint is clean. Native visual QA remains unverified: device discovery failed twice with “Could not communicate with device support. Try refreshing devices.” Local Android SDK/iOS simulator are unavailable. No device session was reused or native parity claimed.
Browser and copy audit
Manual browser QA used the disposable seeded stack on private ports, at 1440×1000, 768×1000 and 390×844, light/dark. Long computer/worker names, offline/unsupported sources, client source disclosures, report selection/preview/copy, placement fields and reset confirmation/cancel were inspected; no browser errors. Integration tests cover actual creation/reset, rather than triggering inference during visual review. No committed UI test suite.
Uncommitted screenshots:
/var/tmp/canopy-diagnostics-4/{desktop,narrow,phone}-{light,dark}-{clients,selection,report,reset}.png(24 files).Copy audit (
docs/copy.md§8):After the latest rebase, install/gen:check/full typecheck/lint/format checks passed before recording. Focused Stage 5 gRPC and migration files passed separately on the top of the stack; a fresh local full-suite or web-build pass is not claimed for the rebased Stage 4 head. The deliberate-lock harness deadline fix also passed script typecheck, lint and formatting before recording.
Run
bash scripts/bench/diagnostics-stage4.shonly in a maintainer-confirmed quiet window. The launcher is reusable (about 125 minutes before retries, plus JS probes). Its default is four pairs; the completed recording below is the current evidence.Measurement results — 2026-11-12
Measured head:
00aba6121f285db55ea5cd49f9ca809d6b6d2673. Four accepted pairs, all attempt 1; no host-gate rejections. Strict AB / BA / AB / BA, fresh driver VM, PG cluster/database/WAL and gateway/worker state per member; idle 180 s, other phases 90 s. Stages 1–3 stay enabled on both sides. No tests or builds ran during recording.Every sampled scope had
MemorySwapMax=0andmemory.swap.current=0(stage 4: 6,923 samples, maximum load 1.94). Load and sustained swap-in gates passed. Host swap-out remains log-only. Pinning kernel kswapd away from the measured CPUs failed with Operation not permitted; kernel ticks/CPU and zram IO were recorded instead.Each cell is all four pairs / sensitivity without flagged pair 4 (n=3). Pair 4 is flagged by the agreed joint rule: a delta beyond 2×MAD coinciding with host swap-out >4 MiB/s. It stays accepted and included in the primary median. CPU is summed gateway + worker + PostgreSQL + driver/BFF, in percentage points of one core. RSS/heap here are gateway phase-end values, without forced GC; other processes are below. No fresh A/A control was run in this window, and no new A/A noise floor is claimed.
Worker and driver/BFF resource medians (all / sensitivity)
Per-pair deltas, every reported process and metric
An earlier run aborted before completing a pair: the fixture's intentional 70 s lock exceeded the BFF's ordinary 35 s update deadline. The harness now grants only that deliberately blocked fixture call 100 s; product deadlines are unchanged. The complete recording above uses the corrected immutable revision. This was a harness abort, not a host-gate rejection. The client JS probes also completed; these are JS-only probes, not native rendering evidence.
Evidence (uncommitted):
/var/tmp/canopy-diagnostics-4/window-20261112-retry/{head.txt,results.jsonl,paired-report.json,stderr.log,client-js.jsonl}. Raw deltas and every joint-rule flag remain in paired-report.json. Measurements are complete; CPU, p95 and memory accepted by the maintainer on 2026-11-12, as recorded above. All PRs remain drafts.Client JS probes — separate ABBA micro-benchmark
Bun 1.4.4, 1,000 turns / 7,099 items / 14,085,915 encoded bytes; 10–30 repetitions per member. A1/B1/B2/A2; the table averages the two member medians/p95s per side, not a pooled p95. Cache probes exclude disk. These JS-only measurements do not establish device/native paint performance.
Maintainer acceptance — 2026-11-12
Stages 4 (#569) and 5 (#572) are accepted for CPU, RPC p95 and memory. The maintainer accepted the measured cumulative stages 2–5 memory difference: about +5 MiB idle, +5–12 MiB under typical load, and about +15 MiB worst case during governor load. Existing A/B results are preserved. No further memory investigation, bounded-memory re-tests, A/A controls or full A/B runs are required for this acceptance. The entire diagnostics stack remains draft and will merge together after stage 6 is accepted.