Repository navigation
feat(diagnostics): collect bounded redacted computer logs - #572
Merged
Merged
Conversation
nixuuu
force-pushed
the
feat/diagnostics-5-logs
branch
2 times, most recently
from
November 12, 2026 14:54
b6675d3 to
1b7b947
Compare
This was referenced Nov 12, 2026
nixuuu
force-pushed
the
feat/diagnostics-5-logs
branch
3 times, most recently
from
November 12, 2026 23:45
fe40628 to
09738a2
Compare
nixuuu
marked this pull request as ready for review
November 12, 2026 23:59
nixuuu
force-pushed
the
feat/diagnostics-5-logs
branch
from
November 13, 2026 00:04
09738a2 to
c547a5b
Compare
nixuuu
force-pushed
the
feat/diagnostics-5-logs
branch
from
November 13, 2026 00:20
c547a5b to
f768d91
Compare
nixuuu
added a commit
that referenced
this pull request
Nov 13, 2026
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 - BFF unary observations use the existing local/remote routing decision. SSE observes first message and lifetime, then publishes scalar message/byte totals on close using the existing encoded bytes. No per-frame clock or histogram work was added. Web/desktop sample thread-open-to-two-frames, first parse/decode/reducer, Paint Timing FCP and supported long tasks. Mobile samples feed layout-to-two-JS-frames, first snapshot reducer and JS frame delay; Connect decoder/native paint are explicitly unmeasured. - Clients sample **10% of openings, at most 20/min**, with at most twelve numeric histograms, no thread IDs/URLs/payloads, one in-flight upload, no disk buffer/retry queue, and drop-on-failure. Client uploads are bounded at 16 KiB/minute, BFF at 32 KiB/30 s, authenticated sender total at 60 KiB/minute. Suspend clears observations; stale batches cannot be re-dated. Gateway limits 30 sender/source channels, 30 rate entries and bounded session/checkpoint metadata inside the existing **6 MiB** collector. Client observations remain separate and untrusted. Overflow is rejected or recorded as incomplete/dropped. - Reports project registered metrics/methods/families/rules, alias computer/worker names, omit IDs/paths/versions/sessions and unknown fields, and cap JSON/Markdown at **256 KiB** with explicit omissions. A ten-minute HMAC binds the exact preview. Creating an investigation requires project/workspace/worker/provider/model selection and a separate action. It creates a normal **ASK** thread with an attachment, ordinary turn/outbox and audit. Owner-scoped placement locks, attachment, thread and idempotency receipt share one transaction; an exact retry survives restart, while conflicting content/placement is rejected. No elevated permissions or hidden instruction injection. - Reset persists epoch and the selected process baseline before ACK, clears only its diagnostic history/findings, fences pre-reset worker batches and cached/in-flight client responses, and preserves runtime work, live gauges and governor limits. There are at most 17 durable process baselines; a new identity beyond that cap is rejected rather than growing retained state. History is processed in eight-row cursor pages instead of materializing all retained rollups. A failed reset rolls back without advancing the baseline. Only directly connected homes can be controlled; the target rechecks owner/link/target and rejects relay/onward requests. Reset uses the existing `diagnostics_v1` capability because the whole stack ships together; another hello entry exceeded older peers' 32-capability limit. The separate direct-only allowlist remains enforced. - The stack is rebased onto dev `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/v1` is 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, full `check:tmp --max-concurrency 1` passed: **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: iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`, Android `5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. 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): 1. No client section → **Clients and delivery** with source disclosures and short secondary notes. Sampling and proxy limits are stated once; absent support is not represented as zero. English sentence case, active voice and existing glossary terms; no new glossary term or humor. 2. No export → **Prepare report → Preview report → Copy report**. Preview explains aliases, measurements and coverage; omissions are explicit. Buttons start with verbs, and failures state what happened plus a retry/copy action. 3. No investigation action → **Ask an agent to investigate / Create investigation**, with explicit project/workspace/agent-model choices and a short notice that the report may go to the selected provider and normal approvals apply. No automatic AI action. 4. No reset action → **Reset counters? / Reset counters**. Confirmation repeats the verb and explains the selected diagnostic baseline and preserved running work. Success uses a live status; meaning never depends only on color or an icon. 5. Short/typical/long names were checked at desktop/narrow/phone widths in both themes. Preview scrolls within a bounded region; action placement, focus labels and wrapping stay usable. Mobile shares the copy and domain labels, with native visual verification explicitly outstanding. 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.sh` only 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=0` and `memory.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. | Phase | CPU pp | RPC p95 ms | RPC p95 % | Gateway RSS MiB | Gateway heap MiB | |---|---:|---:|---:|---:|---:| | idle | +0.005 / +0.009 | — | — | +0.213 / -0.227 | +0.069 / +0.049 | | steady | +0.016 / +0.185 | +0.448 / +0.369 | +15.987 / +12.475 | +0.672 / +0.242 | +0.014 / -0.432 | | reconnect | -0.161 / -0.203 | -0.034 / -0.171 | -1.031 / -5.688 | +2.363 / +2.254 | +0.709 / +0.393 | | slow_reader | -0.027 / -0.088 | -0.387 / -0.435 | -9.140 / -10.091 | +3.846 / +2.172 | +2.328 / -1.166 | | write_failure | +0.044 / -0.016 | +0.334 / +0.195 | +12.333 / +6.687 | -1.393 / -1.922 | -1.009 / -1.648 | | pool_contention | -0.008 / +0.014 | +0.445 / +0.574 | +13.241 / +17.343 | -2.514 / -10.516 | -4.934 / -11.550 | | governor | +0.075 / +0.172 | -0.011 / -0.298 | +0.218 / -9.560 | +9.172 / +10.699 | +7.368 / +10.102 | | report | +0.058 / +0.090 | -0.035 / +0.049 | -1.303 / +1.922 | -4.313 / -9.492 | -3.067 / -5.102 | | Pair | Order | Accepted / attempt | Host swap-out MiB total | Peak MiB/s | Joint MAD flag | |---|---|---|---:|---:|---| | 1 | AB | yes / 1 | 13.523 | 2.227 | no | | 2 | BA | yes / 1 | 1.887 | 1.125 | no | | 3 | AB | yes / 1 | 2.488 | 1.570 | no | | 4 | BA | yes / 1 | 94.945 | 28.754 | 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.003 / -0.002 | -0.090 / -0.102 | +0.007 / +0.012 | +0.008 / +0.009 | +0.016 / +0.633 | -0.094 / -0.334 | | steady | +0.004 / +0.007 | -0.605 / -0.918 | -0.054 / +0.078 | -0.096 / +0.008 | +0.453 / +1.125 | -0.021 / -0.042 | | reconnect | +0.008 / -0.007 | +0.143 / -0.176 | +0.126 / +0.044 | -0.063 / -0.038 | -0.025 / -0.055 | -0.176 / -0.266 | | slow_reader | +0.012 / +0.011 | -1.348 / -1.582 | -2.524 / -3.680 | +0.042 / +0.047 | +0.561 / +0.637 | +0.222 / +0.255 | | write_failure | +0.029 / +0.025 | -0.846 / -0.277 | -0.838 / +3.231 | +0.017 / +0.037 | +0.412 / +1.074 | +0.367 / +0.543 | | pool_contention | -0.000 / +0.022 | -2.945 / -2.227 | -2.707 / -0.594 | +0.041 / +0.049 | +0.326 / -0.109 | +0.019 / -0.026 | | governor | -0.011 / -0.024 | -0.893 / -0.230 | -0.268 / +0.044 | +0.086 / +0.157 | +0.711 / +0.613 | -0.080 / -0.081 | | report | -0.016 / -0.012 | +1.682 / +0.742 | +4.492 / +0.223 | -0.012 / -0.007 | +1.416 / +1.879 | +0.801 / +1.370 | </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.051 | -0.028 | -0.002 | +0.004 | | idle | worker.cpuPp | +0.020 | -0.013 | -0.002 | -0.003 | | idle | postgres.cpuPp | +0.008 | -0.001 | -0.005 | +0.008 | | idle | driverBff.cpuPp | +0.009 | +0.007 | +0.019 | -0.008 | | idle | driverBff.rssMiB | +0.633 | -0.602 | +0.660 | -0.730 | | idle | driverBff.heapMiB | +0.146 | -0.376 | -0.334 | +0.405 | | idle | total.cpuPp | +0.088 | -0.035 | +0.009 | +0.001 | | idle | gateway.rssMiB | +0.652 | -0.227 | -0.496 | +0.676 | | idle | worker.rssMiB | -0.117 | -0.102 | -0.078 | +0.457 | | idle | gateway.heapMiB | +0.089 | +0.049 | +0.046 | +0.218 | | idle | worker.heapMiB | +0.003 | +0.016 | +0.012 | -0.016 | | steady | gateway.cpuPp | +0.007 | +0.166 | -0.334 | +0.022 | | steady | worker.cpuPp | +0.017 | +0.007 | -0.017 | +0.001 | | steady | postgres.cpuPp | +0.064 | +0.084 | -0.045 | +0.080 | | steady | driverBff.cpuPp | +0.098 | +0.008 | -0.200 | -0.255 | | steady | driverBff.rssMiB | -0.645 | +1.520 | +1.125 | -0.219 | | steady | driverBff.heapMiB | -0.042 | -0.271 | -0.001 | +0.401 | | steady | total.cpuPp | +0.185 | +0.265 | -0.596 | -0.153 | | steady | gateway.rssMiB | -2.781 | +1.102 | +0.242 | +5.359 | | steady | worker.rssMiB | -1.324 | -0.918 | +0.184 | -0.293 | | steady | gateway.heapMiB | -1.665 | +1.038 | -0.432 | +0.461 | | steady | worker.heapMiB | +0.301 | -0.187 | +0.078 | -0.263 | | steady | rpc.p95Ms | +0.362 | +0.369 | +0.528 | +0.641 | | steady | rpc.p95Percent | +11.701 | +12.475 | +19.500 | +21.603 | | steady | history.p95Ms | -4.118 | +4.944 | +5.173 | -2.981 | | reconnect | gateway.cpuPp | -0.049 | -0.142 | -0.238 | +0.176 | | reconnect | worker.cpuPp | -0.007 | +0.022 | -0.017 | +0.039 | | reconnect | postgres.cpuPp | -0.179 | -0.045 | +0.052 | +0.066 | | reconnect | driverBff.cpuPp | -0.088 | -0.038 | +0.084 | -0.118 | | reconnect | driverBff.rssMiB | +0.746 | -0.055 | -2.051 | +0.004 | | reconnect | driverBff.heapMiB | -0.266 | -0.085 | -0.807 | +0.347 | | reconnect | total.cpuPp | -0.322 | -0.203 | -0.119 | +0.164 | | reconnect | gateway.rssMiB | -2.258 | +2.254 | +2.473 | +2.930 | | reconnect | worker.rssMiB | +0.461 | -0.176 | -0.250 | +0.660 | | reconnect | gateway.heapMiB | +0.393 | +0.360 | +1.106 | +1.024 | | reconnect | worker.heapMiB | +0.208 | +0.044 | -0.504 | +1.906 | | reconnect | rpc.p95Ms | -0.640 | -0.171 | +0.133 | +0.103 | | reconnect | rpc.p95Percent | -16.973 | -5.688 | +4.222 | +3.626 | | reconnect | history.p95Ms | -1.459 | -3.281 | +5.758 | +1.081 | | slow_reader | gateway.cpuPp | -0.183 | -0.105 | +0.559 | +0.108 | | slow_reader | worker.cpuPp | -0.000 | +0.012 | +0.011 | +0.022 | | slow_reader | postgres.cpuPp | +0.072 | -0.154 | +0.094 | -0.132 | | slow_reader | driverBff.cpuPp | +0.023 | +0.047 | +0.446 | +0.036 | | slow_reader | driverBff.rssMiB | +1.555 | +0.637 | +0.484 | -1.672 | | slow_reader | driverBff.heapMiB | +0.718 | +0.190 | +0.255 | -1.164 | | slow_reader | total.cpuPp | -0.088 | -0.200 | +1.110 | +0.034 | | slow_reader | gateway.rssMiB | +18.566 | +2.172 | -12.086 | +5.520 | | slow_reader | worker.rssMiB | -1.582 | -5.238 | +1.355 | -1.113 | | slow_reader | gateway.heapMiB | +17.881 | -1.166 | -4.817 | +5.822 | | slow_reader | worker.heapMiB | -3.680 | -6.159 | +2.606 | -1.368 | | slow_reader | rpc.p95Ms | +0.282 | -0.435 | -1.115 | -0.340 | | slow_reader | rpc.p95Percent | +7.929 | -10.091 | -25.916 | -8.189 | | slow_reader | history.p95Ms | -1.430 | -0.240 | -5.477 | -6.992 | | write_failure | gateway.cpuPp | +0.012 | +0.014 | +0.022 | +0.096 | | write_failure | worker.cpuPp | +0.025 | +0.054 | -0.007 | +0.034 | | write_failure | postgres.cpuPp | -0.017 | -0.006 | -0.068 | -0.013 | | write_failure | driverBff.cpuPp | -0.297 | +0.041 | +0.037 | -0.002 | | write_failure | driverBff.rssMiB | +4.008 | -10.199 | +1.074 | -0.250 | | write_failure | driverBff.heapMiB | +2.473 | +0.543 | +0.191 | +0.064 | | write_failure | total.cpuPp | -0.278 | +0.104 | -0.016 | +0.115 | | write_failure | gateway.rssMiB | -1.922 | +1.867 | -26.934 | -0.863 | | write_failure | worker.rssMiB | -0.277 | +1.859 | -1.414 | -2.563 | | write_failure | gateway.heapMiB | -2.929 | -0.370 | -1.648 | +0.892 | | write_failure | worker.heapMiB | -4.907 | +3.231 | +4.026 | -5.902 | | write_failure | rpc.p95Ms | +0.195 | +0.473 | +0.104 | +0.894 | | write_failure | rpc.p95Percent | +6.687 | +17.979 | +3.657 | +35.820 | | write_failure | history.p95Ms | +17.498 | -1.727 | +2.178 | +7.787 | | pool_contention | gateway.cpuPp | +0.053 | -0.037 | +0.305 | -0.073 | | pool_contention | worker.cpuPp | -0.022 | +0.062 | +0.022 | -0.101 | | pool_contention | postgres.cpuPp | -0.164 | -0.060 | +0.192 | +0.111 | | pool_contention | driverBff.cpuPp | -0.018 | +0.049 | +0.081 | +0.033 | | pool_contention | driverBff.rssMiB | -0.109 | -1.969 | +0.762 | +10.629 | | pool_contention | driverBff.heapMiB | -0.700 | +0.182 | -0.026 | +0.063 | | pool_contention | total.cpuPp | -0.150 | +0.014 | +0.600 | -0.030 | | pool_contention | gateway.rssMiB | -10.516 | +5.488 | -22.352 | +10.398 | | pool_contention | worker.rssMiB | -2.227 | -4.785 | -0.695 | -3.664 | | pool_contention | gateway.heapMiB | -11.550 | +1.683 | -12.630 | +7.156 | | pool_contention | worker.heapMiB | -0.324 | -6.704 | -0.594 | -4.819 | | pool_contention | rpc.p95Ms | +0.317 | +0.574 | +1.143 | +0.136 | | pool_contention | rpc.p95Percent | +9.139 | +17.343 | +34.364 | +3.602 | | pool_contention | history.p95Ms | +10.504 | +0.336 | +4.872 | +1.366 | | governor | gateway.cpuPp | +0.329 | -0.008 | -0.002 | -0.046 | | governor | worker.cpuPp | -0.024 | -0.079 | +0.002 | +0.018 | | governor | postgres.cpuPp | +0.095 | +0.049 | -0.001 | -0.070 | | governor | driverBff.cpuPp | +0.157 | +0.016 | +0.173 | -0.082 | | governor | driverBff.rssMiB | +0.809 | -1.316 | +0.613 | +1.090 | | governor | driverBff.heapMiB | -0.764 | -0.081 | +0.234 | -0.080 | | governor | total.cpuPp | +0.557 | -0.023 | +0.172 | -0.180 | | governor | gateway.rssMiB | +14.270 | +10.699 | -7.098 | +7.645 | | governor | worker.rssMiB | -3.125 | +2.176 | -0.230 | -1.555 | | governor | gateway.heapMiB | +10.102 | +15.042 | -1.626 | +4.633 | | governor | worker.heapMiB | +0.044 | +9.615 | -0.580 | -4.492 | | governor | rpc.p95Ms | +0.275 | -1.337 | -0.298 | +0.457 | | governor | rpc.p95Percent | +9.997 | -37.585 | -9.560 | +17.504 | | governor | history.p95Ms | -3.804 | -0.383 | -4.224 | +2.643 | | report | gateway.cpuPp | +0.056 | +0.185 | -0.021 | -0.276 | | report | worker.cpuPp | -0.012 | -0.001 | -0.020 | -0.052 | | report | postgres.cpuPp | +0.053 | +0.024 | +0.150 | +0.068 | | report | driverBff.cpuPp | -0.007 | -0.182 | +0.073 | -0.017 | | report | driverBff.rssMiB | +2.555 | +1.879 | +0.953 | -1.578 | | report | driverBff.heapMiB | +1.370 | +2.243 | +0.233 | -0.132 | | report | total.cpuPp | +0.090 | +0.027 | +0.183 | -0.277 | | report | gateway.rssMiB | -11.809 | +0.867 | -9.492 | +3.684 | | report | worker.rssMiB | -0.848 | +2.621 | +0.742 | +8.023 | | report | gateway.heapMiB | -12.282 | -1.031 | -5.102 | +3.471 | | report | worker.heapMiB | +0.090 | +8.761 | +0.223 | +14.529 | | report | rpc.p95Ms | -0.222 | +0.049 | +1.169 | -0.119 | | report | rpc.p95Percent | -8.115 | +1.922 | +51.429 | -4.529 | | report | history.p95Ms | +2.303 | -2.209 | -1.581 | -2.967 | </details> 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. <details><summary>Client JS probes — separate ABBA micro-benchmark</summary> 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. | Work | A median ms | B median ms | Δ median ms | A p95 ms | B p95 ms | |---|---:|---:|---:|---:|---:| | markdown lex / long answer | 5.6102 | 6.6358 | 1.0256 | 8.8928 | 9.3972 | | mobile cache cold load / decode, no disk | 24.0731 | 24.2935 | 0.2203 | 47.3732 | 45.6164 | | mobile cache save / new immutable snapshot, no disk | 24.1221 | 25.2893 | 1.1672 | 49.2225 | 48.1091 | | mobile cache save / same immutable snapshot, no disk | 0.0005 | 0.0006 | 0.0002 | 0.0032 | 0.0231 | | mobile turn body / 5000 sibling items | 1.9512 | 2.3702 | 0.4189 | 4.2618 | 5.6908 | | mobile turn body / typical turn | 0.0101 | 0.0101 | -0.0000 | 0.1737 | 0.4013 | | mobile turn grouping / streaming item | 1.0549 | 1.1368 | 0.0819 | 5.3557 | 3.4281 | | mobile visible turns | 1.7980 | 2.4185 | 0.6205 | 5.8787 | 6.9739 | | protobuf JSON decode + reducer / 200 deltas | 6.8445 | 6.5577 | -0.2868 | 11.6863 | 11.1171 | | web feed / unchanged history | 0.3235 | 0.3689 | 0.0454 | 2.4641 | 2.3855 | </details> ## 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.
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.
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
@canopy/logswriter 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.968757a4c; diagnostics migrations remain 0129 (stage 1), 0130 (stage 4), 0131 (stage 5). It now reuses fix(computers): preserve legacy capability handshakes #574's sharedadditional_capabilitiesfield 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-interactivematches stage 4 exactly:6ddec9ef559ee0095ac33e94ff9418a942053b175f6eae3ab278f1cd543e9ed763f923a319b65ec9Verification 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 andbash -n scripts/bench/diagnostics-stage5.shpassed. 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.tspassed: 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.tspassed: 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. Fullcheck:tmpand 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
Run
bash scripts/bench/diagnostics-stage5.shonly 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=0andmemory.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.
Worker and driver/BFF resource medians (all / sensitivity)
Per-pair deltas, every reported process and metric
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.