Repository navigation
feat(diagnostics): show event loop, database and queue health - #535
Merged
Merged
Conversation
nixuuu
force-pushed
the
feat/diagnostics-2-gateway
branch
from
November 11, 2026 08:50
115b50b to
6d5b38c
Compare
nixuuu
added a commit
that referenced
this pull request
Nov 11, 2026
Use native scope-free pool borrows for ordinary statements, retain pinned transactions and streams, and charge cached wrappers to the existing collector budget. Remove timer and measurement-path allocations. Add opt-in JSC heap/profile evidence and stage-specific swap pressure gates. Related: #535
nixuuu
added a commit
that referenced
this pull request
Nov 11, 2026
Keep retries encoded within the existing 4 MiB and 60-minute limits, decode after the home lock, and report dropped minutes. Preserve incomplete rollups across retry and compaction. Remove dense percentile scans and successful row sets from diagnostic lease closure state. Related: #535
nixuuu
added a commit
that referenced
this pull request
Nov 11, 2026
Use native scope-free pool borrows for ordinary statements, retain pinned transactions and streams, and charge cached wrappers to the existing collector budget. Remove timer and measurement-path allocations. Add opt-in JSC heap/profile evidence and stage-specific swap pressure gates. Related: #535
nixuuu
added a commit
that referenced
this pull request
Nov 11, 2026
Keep retries encoded within the existing 4 MiB and 60-minute limits, decode after the home lock, and report dropped minutes. Preserve incomplete rollups across retry and compaction. Remove dense percentile scans and successful row sets from diagnostic lease closure state. Related: #535
nixuuu
force-pushed
the
feat/diagnostics-2-gateway
branch
from
November 11, 2026 14:07
c150a18 to
bb974ed
Compare
This was referenced Nov 11, 2026
nixuuu
force-pushed
the
feat/diagnostics-2-gateway
branch
2 times, most recently
from
November 12, 2026 01:51
cc64722 to
e77a606
Compare
This was referenced Nov 12, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 12, 2026
Use native scope-free pool borrows for ordinary statements, retain pinned transactions and streams, and charge cached wrappers to the existing collector budget. Remove timer and measurement-path allocations. Add opt-in JSC heap/profile evidence and stage-specific swap pressure gates. Related: #535
nixuuu
added a commit
that referenced
this pull request
Nov 12, 2026
Keep retries encoded within the existing 4 MiB and 60-minute limits, decode after the home lock, and report dropped minutes. Preserve incomplete rollups across retry and compaction. Remove dense percentile scans and successful row sets from diagnostic lease closure state. Related: #535
nixuuu
force-pushed
the
feat/diagnostics-2-gateway
branch
from
November 12, 2026 12:02
07b2536 to
190407c
Compare
nixuuu
force-pushed
the
feat/diagnostics-2-gateway
branch
3 times, most recently
from
November 12, 2026 14:42
c70ab27 to
9115559
Compare
nixuuu
force-pushed
the
feat/diagnostics-2-gateway
branch
2 times, most recently
from
November 12, 2026 23:45
76f1e1f to
ca4197a
Compare
nixuuu
marked this pull request as ready for review
November 12, 2026 23:59
nixuuu
force-pushed
the
feat/diagnostics-2-gateway
branch
from
November 13, 2026 00:04
ca4197a to
0852475
Compare
nixuuu
force-pushed
the
feat/diagnostics-2-gateway
branch
from
November 13, 2026 00:20
0852475 to
5119370
Compare
nixuuu
added a commit
that referenced
this pull request
Nov 13, 2026
…#505) **Draft — Stage 1 gate accepted by the maintainer; the six-stage stack remains draft.** The accepted decision uses CPU median deltas ≤0.33 pp, RPC p95 within ±0.5 ms and startup readiness +0.39 MiB. Remaining approximately +12 MiB RSS medians in pool-contention/post-restore were accepted within measured RSS noise (pair range −240…+18 MiB). Stage 2 must not increase those budgets. Historical runs/exclusions below remain evidence, not a newly repeated Stage 1 gate. ## Stage 1 Current stack base: dev `968757a4c`. Migrations 0124–0128 are already merged, so Stage 1 is **0129_diagnostics** (registry, schema and sync-upgrade references updated). Stages 2–3 add no migration; Stage 4 follows with 0130 and Stage 5 with 0131. Contracts stay additive and `update/v1` remains untouched. The stack reuses #574's shared `additional_capabilities` field and handshake implementation, replacing its independently implemented extension field; production legacy-peer integration passes. Stages 2–3 overhead gates are also accepted; their focused governor/series GC test is recorded in #535. All six stages are implemented; the entire stack stays draft while final current-head CI runs, then will be marked ready together as requested by the maintainer. Settings → General → Diagnostics shows this computer and every linked computer on web/desktop and mobile: freshness, offline saved data, unsupported/denied states, link and RPC findings, sortable/paged RPC rows and drill-down, and 1 min / 15 min / 1 h / 24 h windows. - Descriptor-allowlisted RPC lifecycle metrics use 128 fixed duration buckets, counts/rates, final codes, current/peak in-flight, stream lifetime/first-message/message classes, and existing encoded payload sizes where available. Public RPC payload sizes remain **Not measured**: no existing-byte hook exists, and messages are never re-encoded to count bytes. - Worker/computer heartbeat echoes measure monotonic RTT/jitter separately from heartbeat age/interval. Older versions remain usable and visibly unsupported. - Reads are owner-scoped. Direct and one-relay reads use capability/onward grants, revoke/cache invalidation, shared background gathering and bounded traffic/memory. Metrics never contain prompts, paths, payloads, free-form errors or request-derived method labels. - Lightweight aggregates, findings, session checkpoints and last-known peer overviews persist off the request path, with atomic retry/dedupe, restart gaps and existing retention leases. Stack: [#495](#495) → [#505](#505), [stack #506](Stack #506). No merge is performed by this handoff. ## Rebase and migration The full diagnostics stack was rebased onto `origin/dev` **`3d44197868b9c42eec317dcc3bf5903841e6e582`**, including incremental sync #538/#539/#541/#543. Documentation head: `7ef043e411b13d310111a90362b63de55175d2b7`; Stage 1 head: **`ed0dc6509914499ec3812df7a1f1341266809fcb`**. Branches were force-pushed with leases through `gh stack`. Bases remain #495 → `dev`, #505 → `docs/diagnostics`; #535 and #542 continue above this PR. Current-head full CI is green. Historical Stage 1 measurements below retain their original revisions. Dev includes migrations 0120–0124; concurrent PRs reserve 0125–0128. Diagnostics uses **`0129_diagnostics.sql`**, with index/schema expectations and the sync→diagnostics upgrade test updated. Stages 2–3 add no migration; Stage 4 follows with 0130. Draft numbers may still need renumbering if dev advances. Additive GitHub/sync/diagnostics contracts were regenerated; frozen `update/v1` is unchanged. The allowlist/page-offset ceiling remains **512** and fixed collector budgets remain unchanged. ## Memory and restore redesign The original dense design had a real regression: approximately +140–160 MiB startup VmHWM, 1.3–6 s wall restoration, and +50–100 MiB reconnect/write-failure RSS. Earlier CPU/p95 deltas changed sign under heavy host swapping and cannot establish acceptance. The previous resource-only run also had idle RSS +17.50 MiB and one post-restore peak +13.83 MiB; those findings motivated the current controlled rerun and are not erased. - Histograms contain sorted nonzero bucket indices/counts in memory and packed-varint protobuf fields on disk. Aggregate merges reuse buffers without protobuf copies per merge. - Keep the short live ring, current minute plus the last 60 minutes, and incremental 15 m / 1 h closed-minute aggregates. Restored/live rings remain separate for session dedupe. Cache admission failure uses direct merging. - The listener becomes ready before background restore; RPCs never await it. Only the last hour of minute rows is restored in eight-row pages. Incoming reports queue within a bound until persisted dedupe watermarks load. - The owner-scoped 24 h query uses hourly rows, a shared 5 s cache, and the current hour from memory. At most one completed hour falls back to at most 60 minute rows after a crash. View allocation is capped at 1 MiB. - Hourly downsampling/replacement shares the atomic minute/state batch, including retries and late minutes. Minute retention is **2 h** (quota 180 including maintenance grace); hourly retention **30 days** (quota 720). Collection has a 6 MiB method budget and 2 MiB link budget, 16 measured partners and 32 cached peer overviews. Dropped/limited coverage is explicit. `docs/diagnostics.md` and `docs/database-retention.md` document the final retention, limits and size estimates, replacing 72 h of dense in-memory minute history. No UI copy changed in this follow-up. ## Verification after rebase Passed: `bun install`, `bun run gen`, `bun run gen:check`, full `bun run typecheck`, root lint, format check and the web build. Ignored stale Expo route types were regenerated with an isolated local Metro process, then that process was stopped; no mobile source workaround was added. Focused files ran serially: | File | Tests | Assertions | | --- | ---: | ---: | | `packages/db/test/schema.test.ts` | 23 | 85 | | `tests/integration/diagnostics-hourly.test.ts` | 4 | 23 | | `tests/integration/diagnostics.test.ts` | 6 | 45 | | `tests/integration/diagnostics-history.test.ts` | 11 | 76 | Coverage includes bounded last-hour restore, owner-scoped hourly reads, atomic replacement/dedupe, rolling expiry, responsive RPCs during locked historical storage and reports arriving during restore. The integration suite also covers three real gateways/workers with a relay, owner denial/revoke, offline/older versions, no recursive gather, stream cleanup, histogram/count dedupe, RTT versus heartbeat, limits, restart continuity/gaps, failed-write retry, retention/downsampling and concurrent pruning. The requested **one fresh full `check:tmp` after all measurement/profile processes stopped passed on this exact head**: **2383 pass, 165 skip, 0 fail**, **29,261 assertions**, **2548 tests across 443 files**, **1372.23 s**. Command: `TMPDIR=/var/tmp/canopy-diagnostics-1/sparse/checktmp-4b86ae4d bun run check:tmp --max-concurrency 1`. Exit 0; `check:tmp: nothing left in the temp dir`. The runner noted tool-owned caches excluded by its policy, then removed its private tree; the parent scratch directory is empty. The checkout remains clean at the measured SHA. Log: `/var/tmp/canopy-diagnostics-1/sparse/checktmp-4b86ae4d.log`. No production/test source was changed during this run, and the full suite was not repeated. Historical GitHub snapshot (2026-11-11): **CI green on both layers**, including static checks/commitlint and the aggregate typecheck/tests/builds job. #505 passed all four test shards and web/Linux builds; docs-only #495 correctly skipped those matrix jobs. No submitted reviews or review decision. Both PRs remain draft until the complete stack is verified. Runs: [#495 CI](https://github.com/itsoltech/canopy/actions/runs/42943020455), [#505 CI](https://github.com/itsoltech/canopy/actions/runs/42943019335). ## Controlled overhead measurement **Historical recording: 3 of the requested 5 pairs completed. Stage 1's gate was subsequently accepted by the maintainer as stated at the top.** The unchanged runner stopped with exit 1 after all three attempts at pair 4 crossed the requested swap-out gates. Pair 5 never started. Results below preserve medians/ranges of only those three eligible whole pairs, rather than implying a five-pair run. Both PRs remain draft as part of the unfinished stack. Memory also remains open: steady RSS reached **+13.05 MiB** in accepted pair 2, despite a three-pair median of +7.08 MiB; post-restore restart VmHWM uplift reached **+14.26 MiB**. Pool-contention RSS median was +12.48 MiB. These observations are retained; favorable CPU/p95 observations do not override memory or the missing pairs. Protocol: five alternating off/on, on/off, off/on, on/off, off/on pairs (ABBA blocks), each process warmed with 300 reads plus 5 s. Every member has 10 min idle and 140 s each steady, reconnect, slow reader, write failure and pool contention. Four lanes offer 20 GetThread/s; the slow-reader fixture adds four update lanes and eight paused watches. Overview reads use 15 min; detail reads use 24 h every 10 s, exceeding the 5 s cache TTL. Each member starts with equivalent fresh private databases: 120 minute + 720 hourly sparse rows, 24 methods, four nonzero duration buckets and actual coverage timestamps; seeded payload **1,115,520 bytes**. Gateway, worker, PostgreSQL and driver are pinned to separate physical cores (2/3/4/1). `nice -n -5` is denied, so affinity-only fallback is used. Own ports 18191/18192; no existing stack or global caches were changed. No builds/tests or forced GC ran alongside accepted measurements. New processes reset their own runtime caches and warm their own data. Before every attempt: loadavg and 30 s preflight. Continuous `vmstat -w -S K 1` ignores the first since-boot row; `/proc/vmstat` and actual 4096-byte pages enforce cumulative output. Reject swap-out ≥128 KiB/s in any sample or ≥1 MiB cumulative; swap-in ≥1024 KiB/s or ≥128 KiB/s for three consecutive seconds; load above 12 logical CPUs. Small old-page reads are allowed and logged. Rejected whole attempts are excluded, with at most three attempts per pair; no thresholds were relaxed. Acceptance: paired CPU median delta <1 percentage point of one core; RPC p95 median delta <max(1 ms, 10% baseline); startup/steady RSS uplift ≤10 MiB. Also report synchronous startup diagnostics CPU (<100 ms), background restore separately, and full-history p95 (<50 ms). ### Host eligibility and exclusions | Pair / attempt | Accepted | Max load | Swap-in peak KiB/s | Swap-in bytes | Swap-out peak KiB/s / bytes | Reason | | --- | --- | ---: | ---: | ---: | ---: | --- | | 1 / 1 | No | 1.45 | 2476 | 3,760,128 | 0 / 0 | Input rate | | 1 / 2 | No | 0.20 | 4544 | 4,784,128 | 0 / 0 | Input rate | | 1 / 3 | **Yes** | 1.23 | 792 | 1,863,680 | 0 / 0 | Allowed old-page reads; longest ≥128 KiB/s streak 1 s | | 2 / 1 | No | 0.92 | 5668 | 6,828,032 | 0 / 0 | Input rate | | 2 / 2 | **Yes** | 0.80 | 160 | 655,360 | 0 / 0 | Allowed reads; streak 1 s | | 3 / 1 | **Yes** | 0.79 | 48 | 663,552 | 0 / 0 | Allowed reads; streak 0 s | | 4 / 1 | No | 0.68 | 244 | 385,024 | 792 / 811,008 | Output rate | | 4 / 2 | No | 0.66 | 60 | 262,144 | 2200 / 2,580,480 | Output rate and total | | 4 / 3 | No | 0.87 | 676 | 937,984 | 2172 / 2,682,880 | Output rate and total; retry limit reached | Each accepted pair contains both members and all six phases (18 verified complete phase/pair groups). Each has 2672 one-second host samples. Accepted keys are **1/3, 2/2, 3/1**; all rows from other attempts are excluded, including their completed on phases. No pair 4 data are spliced into pair 5 or the medians. Pair 4's output bursts occurred around the transition into the disabled member. The host counters do not identify which process owned those pages; this report does **not** attribute them to other agents or prove an external cause. ### Preliminary paired deltas, median [min, max], n=3 CPU is percentage points of one core; all differences are on minus off. RPC baselines were below 10 ms, so the requested p95 threshold is 1 ms in every measured phase. Idle issues no application reads. History p95 is the enabled 24 h view including database/transport, with 14 reads per loaded phase/member. | Phase | Gateway CPU pp | RPC p95 ms | RSS MiB | Enabled 24 h p95 ms | | --- | ---: | ---: | ---: | ---: | | Idle | +0.0127 [0.0077, 0.0170] | — | +5.74 [3.07, 8.78] | — | | Steady | +0.2676 [0.1319, 0.3261] | −0.030 [−0.467, 0.435] | +7.08 [−2.13, **13.05**] | 25.334 [22.614, 27.338] | | Reconnect | +0.2345 [0.2009, 0.3327] | +0.208 [−0.175, 0.301] | +6.35 [2.68, **11.68**] | 12.550 [11.853, 14.823] | | Slow reader | +0.1275 [0.1225, 0.1868] | +0.120 [−0.736, 0.184] | +3.82 [−25.05, 7.33] | 19.789 [12.405, 22.396] | | Write failure | +0.0471 [−0.1152, 0.0951] | +0.135 [−0.030, 0.331] | +9.21 [−240.37, **12.96**] | 11.319 [9.789, 12.455] | | Pool contention | +0.0545 [−0.1950, 0.0695] | +0.263 [−0.034, 0.287] | **+12.48** [4.25, **17.86**] | 18.999 [18.103, 23.030] | Large negative RSS deltas are preserved: in pair 1 the disabled process still held 422.67 MiB after the slow-reader phase at the write-failure sample, versus 182.30 MiB enabled. These are raw RSS endpoints with normal GC, not retained heap or proof of memory savings. No forced GC, trimming, outlier removal or favorable-pair selection enters this table. Offered GetThread traffic completed 2804 calls/member/loaded phase, except 2805 disabled slow-reader calls in pair 1; reconnect completed 27 reconnects/member/phase. Eight paused watches and about 2800 updates ran in each slow-reader phase. | Pair | Phase | Δ CPU pp | Δ RPC p95 ms | Δ RSS MiB | | --- | --- | ---: | ---: | ---: | | 1 | Idle | +0.0127 | — | +5.74 | | 2 | Idle | +0.0170 | — | +8.78 | | 3 | Idle | +0.0077 | — | +3.07 | | 1 | Steady | +0.2676 | −0.030 | +7.08 | | 2 | Steady | +0.1319 | +0.435 | **+13.05** | | 3 | Steady | +0.3261 | −0.467 | −2.13 | | 1 | Reconnect | +0.3327 | +0.208 | +2.68 | | 2 | Reconnect | +0.2009 | −0.175 | **+11.68** | | 3 | Reconnect | +0.2345 | +0.301 | +6.35 | | 1 | Slow reader | +0.1868 | +0.120 | −25.05 | | 2 | Slow reader | +0.1275 | +0.184 | +7.33 | | 3 | Slow reader | +0.1225 | −0.736 | +3.82 | | 1 | Write failure | +0.0471 | −0.030 | −240.37 | | 2 | Write failure | −0.1152 | +0.331 | **+12.96** | | 3 | Write failure | +0.0951 | +0.135 | +9.21 | | 1 | Pool contention | −0.1950 | +0.287 | +4.25 | | 2 | Pool contention | +0.0545 | −0.034 | **+12.48** | | 3 | Pool contention | +0.0695 | +0.263 | **+17.86** | Steady raw baselines (CPU %, RPC p95 ms, RSS MiB), off → on: pair 1 **2.4037 → 2.6713; 2.939 → 2.909; 163.68 → 170.77**; pair 2 **2.4275 → 2.5594; 2.973 → 3.407; 161.37 → 174.42**; pair 3 **2.2916 → 2.6177; 3.481 → 3.015; 164.35 → 162.23**. ### Startup and restart continuity VmHWM is the Linux process-image high-water mark. Startup is sampled at readiness; background restore is reported separately. Restart peaks compare to that pair's disabled startup baseline, not to an unrelated process. Each enabled member has three fresh-process restarts. | Pair | Startup VmHWM off / on MiB | Δ startup MiB | Initial post-restore Δ MiB | Max restart ready Δ MiB | Max restart post-restore Δ MiB | Sync startup CPU on ms | Restart background CPU ms (three) | | --- | ---: | ---: | ---: | ---: | ---: | ---: | --- | | 1 | 143.41 / 143.80 | +0.39 | +6.58 | +3.80 | **+14.26** | 0.929 | 86.451, 75.190, 76.820 | | 2 | 143.42 / 141.99 | −1.43 | +5.48 | +3.04 | **+11.73** | 1.547 | 50.276, 51.827, 72.785 | | 3 | 142.74 / 144.63 | +1.89 | +7.75 | +1.50 | **+12.75** | 0.938 | 58.646, 71.747, 82.577 | Initial readiness VmHWM paired delta median **+0.39 MiB [−1.43, +1.89]**; initial post-restore delta median **+6.58 MiB [+5.48, +7.75]**. Max restart post-restore paired uplift median **+12.75 MiB [+11.73, +14.26]**. Initial synchronous CPU median **0.938 ms [0.929, 1.547]**; maximum across initial starts and all nine restarts **2.439 ms**. Initial background inclusive CPU is **44.902 / 58.202 / 45.679 ms**; restart intervals are **50.276–86.451 ms**. These include concurrent work in the process and are not isolated restore-function CPU. Initial background wall intervals are **46.641 / 59.691 / 47.304 ms**; no 72 h startup scan occurs. Raw startup heap off/on MiB: **22.24/23.30**, **56.79/16.26**, **16.33/23.35**. Different GC phases make these unsuitable as retained-memory deltas. Ring/link accounting immediately after restore is **2,578,368 bytes** in each enabled member and **0** disabled; after steady it is **2,280,512–2,322,048 bytes**. This counter excludes rolling-window budgets, hourly-view/snapshot caches and runtime overhead; it is not total retained memory or RSS. ### Worker, PostgreSQL and event loop | Phase | Worker Δ CPU pp median [min,max] | PostgreSQL Δ CPU pp median [min,max] | Gateway Δ loop p99 ms median [min,max] | | --- | ---: | ---: | ---: | | Idle | +0.0091 [0.0038,0.0107] | +0.0073 [−0.0020,0.0118] | +0.0013 [−0.0018,0.0090] | | Steady | +0.0034 [0.0002,0.0101] | +0.0311 [−0.0446,0.0351] | +0.0041 [−0.0031,0.4337] | | Reconnect | +0.0038 [−0.0030,0.0118] | +0.0412 [0.0017,0.0663] | +0.0379 [−0.1326,0.4869] | | Slow reader | +0.0031 [−0.0000,0.0093] | +0.0012 [−0.1739,0.1358] | +0.1085 [0.0655,0.1884] | | Write failure | +0.0024 [0.0017,0.0141] | +0.0380 [0.0047,0.1191] | −0.0701 [−0.2673,0.1623] | | Pool contention | +0.0054 [0.0038,0.0083] | +0.0276 [−0.1164,0.0292] | −0.2550 [−0.2785,−0.0896] | Enabled gateway event-loop p99 ranges from 0.460 to 1.816 ms across measured phases. Worker RSS samples are 73.80–77.13 MiB. Write-failure fixtures held the diagnostics table for 70 s: enabled persistence changed `unavailable` → `saved` with zero pending minutes afterward in every accepted pair. Pool contention showed nine blocked gateway connections; recovered persistence remained `saved`, with zero pending minutes. ### Persisted writes and bytes/hour One mutation batch/minute means **60 scheduled batches/hour per process**, with more tuple changes inside the batch. Counts below are diagnostics table inserts/updates, **not batches**. Hour replacement/compacted flags, seeded compaction and retry recovery create bursts, so extrapolating a 140 s phase is not a normal long-run write count. Disabled timed tuple-change rates were zero. Bytes are paired deltas of **whole private PostgreSQL WAL/NVMe cgroup I/O**, including maintenance/checkpoints and application interactions; they are not isolated payload bytes. Negative deltas are preserved. Device 259:0 is NVMe; zram device 253:0 is excluded from disk-write columns. | Phase | On tuple changes/h median [min,max] | Δ WAL KiB/h median [min,max] | Δ NVMe KiB/h median [min,max] | | --- | ---: | ---: | ---: | | Idle | 120.0 [120.0,485.9] | +573.8 [314.3,895.1] | +5062.6 [4823.2,5087.1] | | Steady | 154.1 [102.7,385.1] | +896.1 [160.7,4472.4] | +5853.0 [5440.6,11500.4] | | Reconnect | 102.7 [102.7,462.1] | +883.4 [874.5,1250.8] | +6336.3 [5454.6,7889.4] | | Slow reader | 102.7 [102.7,153.9] | +1268.5 [−178.2,2817.8] | +379849.8 [177096.6,439206.6] | | Write failure | 77.0 [76.9,1665.4] | +1214.0 [−1048.8,2399.2] | −4087.3 [−5537.0,11009.2] | | Pool contention | 102.6 [102.5,153.8] | +1502.8 [−459.6,3442.3] | +13391.0 [10689.2,13893.7] | | Pair | Phase | On tuple changes/h | Δ WAL KiB/h | Δ NVMe KiB/h | | --- | --- | ---: | ---: | ---: | | 1 | Idle | 120.0 | +314.3 | +5062.6 | | 2 | Idle | 485.9 | +895.1 | +4823.2 | | 3 | Idle | 120.0 | +573.8 | +5087.1 | | 1 | Steady | 102.7 | +160.7 | +5440.6 | | 2 | Steady | 154.1 | +896.1 | +5853.0 | | 3 | Steady | 385.1 | +4472.4 | +11500.4 | | 1 | Reconnect | 462.1 | +1250.8 | +7889.4 | | 2 | Reconnect | 102.7 | +874.5 | +5454.6 | | 3 | Reconnect | 102.7 | +883.4 | +6336.3 | | 1 | Slow reader | 153.9 | +2817.8 | +379849.8 | | 2 | Slow reader | 102.7 | −178.2 | +177096.6 | | 3 | Slow reader | 102.7 | +1268.5 | +439206.6 | | 1 | Write failure | 77.0 | +2399.2 | −5537.0 | | 2 | Write failure | 1665.4 | +1214.0 | −4087.3 | | 3 | Write failure | 76.9 | −1048.8 | +11009.2 | | 1 | Pool contention | 102.5 | −459.6 | +10689.2 | | 2 | Pool contention | 102.6 | +3442.3 | +13391.0 | | 3 | Pool contention | 153.8 | +1502.8 | +13893.7 | `persistedBytesPerHour` in raw data is **net retained rollup payload growth**, sometimes negative under retention. It is not bytes written and is not substituted for WAL/I/O above. Seeded diagnostics table bytes at startup are 1,490,944–1,499,136 plus 139,264 index bytes; measured enabled phases reach 1,581,056 table bytes and 147,456 index bytes. Logical payload after loaded phases is about 1.10 MB (1.05 MiB; see raw counters), despite restoring only the last hour. ### Profile-backed remaining memory cost A separate **nonacceptance** off/on control used the same production revision with CPU/heap profiling enabled, 120 s idle +140 s steady, realistic history and uncached 24 h reads. Only the benchmark launcher/entry received temporary profiling hooks. They were restored exactly to HEAD before the fresh full test. Profiles add their own substantial memory overhead; their RSS/timing is not substituted into the accepted-pair table. GC was forced only at shutdown in this control, outside all accepted measurements. The complete enabled heap profile has **1509 `Aggregate` objects, 6039 `Histogram` objects, 3018 `BigUint64Array` counter arrays**, and **32,071 ordinary arrays versus 19,658 disabled**. `Aggregate` allocates two fixed counter arrays and four histogram objects; each histogram owns two sparse arrays. The 12,413 additional ordinary arrays and object fan-out remain a concrete retained cost of the last-hour ring and its views, even though dense histogram bins and 72 h restore are gone. Enabled `FunctionCodeBlock` count is **1931 versus 1707** disabled; their displayed self sizes are about 5.3 versus 4.7 MiB. These type retained sizes overlap, so they are not summed. | Qualitative profile control | Off | On | Difference | | --- | ---: | ---: | ---: | | Heap used after explicit full GC before shutdown, MiB | 79.21 | 84.61 | +5.40 | | RSS after that GC, MiB | 193.25 | 199.58 | +6.33 | | JSC reserved heap capacity after GC, MiB | 101.91 | 104.30 | +2.39 | | Complete heap at exit after cleanup, bytes | 53,031,380 | 55,844,643 | +2,813,263 | | Ring/link budget accounting, bytes | 0 | 2,584,816 | +2,584,816 | | Additional rolling-window accounting, bytes | 0 | 165,024 | +165,024 | | Historical view series / pending payload bytes | 0 / 0 | 24 / 0 | Bounded; no pending-write accumulation in this control | The CPU profile identifies rolling-window refresh (`windows.ts`), sparse count updates/aggregate merges and worker catalog work among added diagnostics frames. Profile percentages/wall-weighted times are qualitative; process CPU counters above determine the gate. The profiles support focusing further memory work on the aggregate/histogram/counter object layout and runtime/GC capacity. They **do not prove the cause of the entire +13.05 MiB steady or +14.26 MiB restart RSS uplift**, nor establish a leak or a memory pass. No further production change or favorable remeasurement is hidden in this report. Private profile evidence: `/var/tmp/canopy-diagnostics-1/sparse/profile-4b86ae4d/`, including `Heap.20261111.072510.2706275.0.003.md` (off), `Heap.20261111.072944.2709361.0.003.md` (on), corresponding CPU profiles, and `memory-2706275-7.json` / `memory-2709361-7.json`. `instrumentation.patch` records the temporary hooks; no profile artifact is committed. ### Row sizes and exact payload-write accounting A separate resource-only exercise (`acceptance:false`, no timed workload) records current-head row sizes and uses audit triggers only after sampled processes stop. Fixture minute payload/tuple sizes are **1184 /1253 bytes**; an uncompressed hourly fixture is **1352 /1421 bytes**. After compaction, hourly payloads range **1352–2100 bytes** while physical tuple sizes range **368–1421 bytes** due to compression; logical and physical sizes are separate measures. After the enabled close, retained rows were 121 minute rows /141,496 payload bytes and 719 hour rows /972,836 bytes. Table/index sizes above come from actual timed processes, not this audit. Sixty synthetic minute calls through the real store issue **60 actual mutation batches**. This deliberately exercises late minutes in one already-completed hour, replacing that hourly row 60 times; it is **not normal elapsed-hour timing or a 24-method production write-rate estimate**. | Mutation class | Tuple changes | Sum of NEW payload bytes written | | --- | ---: | ---: | | Minute rollups | 60 | 5700 | | Hourly replacements | 60 | 6480 | | State checkpoints | 60 | 2400 | | **Total** | **180** | **14,580** | This sum includes overwritten hourly payloads. The final retained payload is only **5700 minute +108 hourly bytes**; it is explicitly not reported as total bytes written. The byte sum excludes tuple/index/WAL overhead; whole-database WAL/I/O measurements are reported separately above. Evidence: `/var/tmp/canopy-diagnostics-1/sparse/resources-4b86ae4d.{jsonl,log}` and `profile-4b86ae4d/storage-instrumentation.patch`. The temporary row/trigger instrumentation was restored before the full test; private containers were removed. Evidence: `/var/tmp/canopy-diagnostics-1/sparse/measure-20261111T020059Z/` (`results.jsonl`, `stderr.log`, recorded head/runtime/topology). Repeatable wrapper: `/var/tmp/canopy-diagnostics-1/sparse/run-five-pairs.sh`; instructions: `/var/tmp/canopy-diagnostics-1/sparse/README.md`. Artifacts are not committed. ## Browser, mobile and copy audit Historical real-browser checks used three seeded computers (offline saved metrics and older/unsupported included), long computer/method names, many methods, sorting/pagination, unary/stream drill-down and quiet/empty states. Light/dark, desktop/narrow/390 px phone were inspected. No UI source changed in this follow-up; no new browser pass is claimed after this rebase. Screenshots remain uncommitted under `/var/tmp/canopy-diagnostics-1/`: `desktop-{light,dark}.png`, `narrow-{light,dark}.png`, `phone-{light,dark}.png`, `rpc-table-light.png`, `rpc-details-{desktop,phone}.png`, `rpc-stream-details-phone.png`, `quiet-desktop-light.png`, `quiet-phone-dark.png`, `empty-desktop-light.png`, `empty-phone-dark.png`, `rebased-desktop-{light,dark}.png`, `rebased-phone-{light,dark}.png`, **`final-desktop-{light,dark}.png` and `final-phone-{light,dark}.png`**. The last overview checks were 1440×1000 and 390×844 with no horizontal overflow; full drill-down was not repeated after those rebases. Copy audit (`docs/copy.md` §8): General → Diagnostics matches settings; actions View calls / Show details / Retry / Allow. Short text distinguishes loading, offline saved data, unsupported, denied, insufficient coverage and no calls. **Not permitted** and **Not measured** describe limits honestly; mobile gap text uses singular/plural forms. Details disclose histogram quantization, exact max and small p99 samples. Long names wrap/truncate without moving controls; statuses use text and color. No UI tests/copy artifacts added. The redesign leaves this copy unchanged. Original EAS CLI 27.4.1 production fingerprints were unchanged: iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`, Android `5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. Stage mobile changes are JS only; this follow-up adds no native source changes. Native visuals remain unverified because device support failed twice, including the advised refresh. No native diagnostics screenshot/parity pass is claimed. Earlier mobile verification: Expo Doctor 20/20, diagnostics modules' scoped ESLint, and Android/iOS JS/Hermes exports passed. App-wide Expo ESLint had 42 errors/5 warnings outside diagnostics. Disposable CNG prebuild failed during Android image generation (`Could not find MIME for Buffer <null>`); no native config/assets changed. No APK/IPA build or publication attempted. Logs remain at `/var/tmp/canopy-diagnostics-1/mobile-export-{android,ios-retry}.log` and `mobile-export-{android,ios}/`. ## Remaining scope **Keep #495 and #505 draft.** The maintainer accepted Stage 1's gate as stated at the top. Historical run limitations and memory findings above remain evidence; they are not pending gate failures. No `gh pr ready` or merge was performed. The remaining stages must be completed and verified before the stack can be made ready. Later stages cover process resources/event loop/SQL/pool/governor, broader worker/sync diagnostics, client aggregates/reports, log export and tracing. Multi-instance live merging is future work; persisted process/session identity is retained. Client FCP/TTI, independent wire-byte accounting and operation-isolated maintenance cost remain unmeasured. Public RPC payload sizes require an existing-byte hook. Native visual parity still needs working device support.
nixuuu
added a commit
that referenced
this pull request
Nov 13, 2026
Stage 3 adds worker and synchronization health to Settings → Diagnostics on web/desktop and mobile: journal backlog/redelivery, TTFT/turn/human-wait timings and outcomes, git admission/execution, process/storage resources, and linked mirror detection-to-commit lag, known pending revisions, confirmation age and resubscription reasons. Link findings preserve both observers' values, coverage and freshness without summing directional samples. **Stages 2–3 overhead gates accepted by the maintainer; the stack remains draft.** CPU medians are at most approximately +0.35 pp, p95 is nonpositive or within the A/A envelope, and all-pairs memory medians are at most +6.5 MiB RSS / +3.9 MiB heap. The n=2 governor sensitivity view is within the harness's pre-existing GC noise (#544). Parent #535 now includes the focused governor/series bounded-memory test: 175 assertions, twenty saturated many-family cycles after warmup, two GCs per sample, heap growth **+0.0763 MiB**, all collector/sub-budget caps preserved. No full benchmark was rerun for that condition. Stack #506: #495 → #505 → #535 → #542 → stage 4, rebased onto dev `f7ad51cc`. Concurrent PRs own/reserve 0124–0128; diagnostics Stage 1 now uses **0129_diagnostics**, with index/schema/upgrade references updated. This stage adds no migration and integrates thread-sync diagnostics without duplication. Historical measurements below retain the original measured heads; the rebase itself was not remeasured. ### Collection and bounds - Additive `worker_diagnostics_v1` negotiation and committed generated contracts; older peers continue working. The frozen update/v1 protocol is untouched. - Worker **512 KiB fixed budget**: 256 KiB sparse measurements and 256 KiB indices, active timings and report assembly. No worker history ring or durable metric queue. Maximum 256 delivery high-water entries and 64 active turn timings, with visible drops and unknown replay distinguished from known redelivery. - Reports use the existing 30 s WorkerLink cadence and stay within 32 KiB. Process sampling is every 5 s; filesystem/three known journal files every 60 s. Journal counters use transactional TEMP counts, one startup scan and an indexed oldest-event read. Durable append, ACK/sequence/prune semantics remain unchanged. No inference, provider requests or additional subprocess probes. - Gateway measurements share the existing **2 MiB link budget**, persistence and hourly cache; at most eight restore-pending reports consume that same budget. Closed numeric IDs and reconstruction remove unknown fields. No prompts/output/SQL/parameters/paths/argv/errors/stacks enter reports. Worker freshness accounts for sender-relative ages and cadence. - Mirror lag is emitted only after a real atomic commit; interrupted deltas do not emit lag or false zero backlog. Findings use growth/age, CPU and disk thresholds; hysteresis pauses in gaps. Parent instrumentation remains inside the existing collector budgets (1 MiB internal sub-budget, 512 KiB SQL sub-limit). No Stage 2 budget increased. Governor/error audit: callbacks retain enums/numbers, timing state and diagnostics only. No per-admission metric map, retained error/cause/stack or failed-promise list was found. Application scheduler limits remain 256 queue / 512 cache; settled keyed flights are deleted. Parent #535 removed the concrete retained `Exit.Failure`, statement/acquisition captures, and permits one pool sampler in flight. This audit is backed by the focused GC evidence below; it is not used alone to dismiss endpoint memory. ### Compact resource details and copy audit Worker resources use a shared **Metric | Last | Mean | Max** table on web and mobile. Gateway resources, DB pool, queue and sync gauges use the same pattern. Uptime has Last only; numeric cells are right-aligned/tabular and never wrap, while metric names ellipsize and retain accessible full names. CPU says “CPU”, with “% of one core” in tooltip/accessibility text. Precision is compact (`18%`, `96 MiB`, one decimal below 10). No dagger marker or Last-known footnote remains; offline cards say “Last known data”. Approximate/incomplete markers have one legend. The two worker explanations use shorter secondary text. Both clients use kit disclosures and matching chevron/motion behavior. Copy audit (`docs/copy.md` §8): English/sentence case, units defined once, evidence-based findings and explicit next steps; journal replay uncertainty, incomplete/history states, long-name truncation and current-only uptime checked. Desktop/narrow/phone, light/dark, short/typical/long labels reviewed. Final two-nit revision received phone and desktop checks. No UI changed in the measurement corrections. Screenshots remain private under `/var/tmp/canopy-diagnostics-3/compact/`: `desktop-{light,dark}-workers.png`, `narrow-{light,dark}-workers.png`, `phone-{light,dark}-workers.png`, `phone-light-gateway.png`, `phone-dark-database.png`, `phone-dark-sync.png`. Final nits: `/var/tmp/canopy-diagnostics-3/nits/{phone-dark,desktop-light}-workers.png`. Mobile is JS only. Pinned EAS 27.4.1 production fingerprints unchanged: iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`, Android `5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. No native simulator claim. ### Governor retention after the sync rebase Completed **`bash scripts/bench/diagnostics-retention.sh 3 governor`** with fresh A/B fixtures, stages 1–2 on both sides, real governor load and native JSC snapshots. Before governor, post-GC heap was **A 71.829 / B 71.935 MiB**, delta **+0.106 MiB**. End governor pre-GC: **A 93.028 / B 105.558 MiB**, delta **+12.529 MiB**. End governor after two forced GC calls: **A 73.433 / B 72.862 MiB**, delta **−0.571 MiB**. The earlier +28 MiB endpoint observation did not persist after GC in this focused fixture. Largest strings matched; no growing error/admission record collection appeared. Evidence: `/var/tmp/canopy-diagnostics-3/retention-governor-sync-20261112/`. Raw snapshots/counts are private (0700/0600); they can contain fixture credentials. Analyzer reports root-reachable self bytes and bounded root paths, not dominator-retained sizes. JSC does not classify weak edges, so paths alone do not prove strong retention. Parent #535 reports the write-failure parameter probe and original-workload control: after-GC delta **+1.542 MiB** in the control, versus **+2.720 MiB** after release with the synthetic 8 MiB parameter. The latter is above approximately 2 MiB and remains explicitly reported. Full-watch note: incremental sync removes full snapshots for the modern sequence protocol, while this benchmark preserves the old flags without `sequence` and still exercises compatibility snapshots. This stack does not rewrite that workload or fix compatibility watches to mask their collectible allocations. Original-spike causation is not conclusively attributed to the removed diagnostic Exit reference. ### Fresh-state method and controls — 2026-11-12 This measurement supersedes the earlier shared-driver/cluster recordings. Each A or B member now has a fresh Bun driver VM, PostgreSQL cluster/WAL/database, gateway state directory and worker state directory. The old member exits and its cluster/state is removed before the next starts. Initial fixture counts are logged and match: 500 threads, 1,000 turns, 7,099 items and 840 seeded rollups. The measured checkout remains committed and unchanged throughout recording. Two A/A controls precede each stage's four acceptance pairs. Current-stage diagnostics are off in every control member; lower stages remain on. Slot order is strictly AB / BA for controls and AB / BA / AB / BA for measured pairs. The p95 noise floor is the maximum absolute paired A/A delta for that phase, a descriptive n=2 envelope, not a confidence interval. We compare B−A with max(0.25 ms, that envelope), report percentages separately, and do not subtract noise from overhead. Every measured process runs in a user scope with `MemorySwapMax=0`; PostgreSQL has its own bound scope. Limits and current swap are checked at boundaries and every second. Nonzero/unreadable scope counters, load above 12 CPUs, or host swap-in >=4 MiB/s for three consecutive seconds reject the pair. Host swap-out is log-only and recorded per pair. Kernel affinity was denied (`Operation not permitted`), so kswapd ticks/last CPU and zram I/O remain logged. No host settings or foreign processes changed. Sensitivity flags a whole pair only when any process/phase delta differs by more than 2× MAD and host peak swap-out exceeds 4 MiB/s. Primary medians include every accepted pair; sensitivity medians exclude whole flagged pairs and state their n. This is not a reason to discard accepted data. Physical PostgreSQL I/O remains unavailable (`null`) because the I/O controller is not delegated. ### RPC path profile `diagnostics-rpc-path.ts` holds the Stage 1 interceptor constant and adds Stage 2 RPC correlation plus three SQL phase records per call. Four alternating pairs, 25,600 measured calls per member, show median per-call increments **+0.001701 / +0.001914 / +0.001749 / +0.001528 ms** (median **+0.001725 ms**). The paired p95 of batch-average call costs is **−0.015590 / +0.002867 / +0.002300 / −0.002806 ms**; this is explicitly a batch statistic, not network RPC p95. Fixed-buffer bounds held, with no drops. Native JSC sampling is dominated by transport abort/listener/generator/header operations, rather than a diagnostic allocation loop. A separate fresh-state 30 s real steady profile gave **A 4.037163 / B 4.128845 ms RPC p95**, delta **+0.091683 ms**, and CPU **+0.020855 pp**. This focused result meets 0.25 ms, but does not replace full-sequence controls or acceptance results. Private profiles: `/var/tmp/canopy-diagnostics-2/isolation-20261112/` and `isolation-profile-fixed-20261112/`. No profiling or explicit GC runs inside acceptance recordings. ### Independent pre-existing findings - **[#544](#544): legacy thread-watch allocations awaiting GC.** On pure dev, the second gateway's pre-GC heap is 166.82 MiB larger, but the after-GC difference is only 0.99 MiB. Fresh-state A/A controls also produce +172.15 MiB heap in one pair, this time on its first member, despite no current-stage diagnostic difference. Therefore shared PostgreSQL/driver state and running second are not necessary causes. Fresh isolation is implemented, but cannot honestly be claimed to eliminate all spikes. This stack does not fix legacy watches or force production GC. - **[#563](#563): blocked writes can starve SQL reads.** With nine blocked updates plus ingest, all ten gateway connections wait on row/transaction locks. Pure dev's SQL-backed view probe completes after 64,824.9 ms; both Stage 3 sides show ~59,820 ms history reads in the original fixture. These are successful delayed requests, not RPC timeouts. The acceptance fixture now blocks eight updates, leaving one read slot after ingest, and logs overview/history waits individually. The product scheduling issue is separate. Stage 2 control evidence: `/var/tmp/canopy-diagnostics-2/fresh-aa-20261112/`. All raw snapshots remain private; no SQL text, parameters, credentials or string contents are attached. ### Fresh-state results: Stage 3 Measured head: `d12c76ffdab2ce83787deba9b79bc2a3db6f3de5`. **4 accepted / 0 rejected**, strict AB / BA / AB / BA. Every member has a fresh driver, PG cluster/WAL, database and gateway/worker state. Stages 1–2 stay enabled; only Stage 3 changes. No profiler, explicit GC, snapshots, tests or builds run during acceptance recordings. All **6,221 per-second scope samples** and boundaries have zero swap with `memory.swap.max=0`. There are no load or sustained swap-in violations. **No pairs are MAD/swap-out flagged**, so all-pair and unflagged medians are identical (n=4). | Phase | Gateway CPU pp | p95 ms | p95 % | Gateway RSS MiB | Gateway heap MiB | | --- | ---: | ---: | ---: | ---: | ---: | | governor | -0.074 | 0.142 | 5.579 | -5.596 | -7.206 | | idle | 0.001 | — | — | -0.141 | 0.061 | | pool_contention | -0.011 | -0.047 | -1.298 | 1.348 | 2.428 | | reconnect | -0.082 | -0.387 | -11.844 | 1.869 | 0.536 | | slow_reader | -0.017 | -0.162 | -3.527 | 1.947 | 1.613 | | steady | -0.023 | 0.071 | 2.59 | 0.564 | 0.633 | | write_failure | 0.086 | 0.034 | 1.187 | 0.92 | 1.196 | CPU is percentage points of one core. RPC p95 is the median paired difference; percent is separately the median paired percent change. RSS/heap are ordinary endpoint values without explicit GC, not retained-memory sizes. | Phase | Worker CPU pp | Worker RSS MiB | Worker heap MiB | PG CPU pp | Total CPU pp | | --- | ---: | ---: | ---: | ---: | ---: | | governor | 0.023 | 1.242 | 0.661 | 0.008 | -0.043 | | idle | 0.001 | 1.078 | 0.174 | 0.002 | 0.006 | | pool_contention | 0.048 | 0.629 | 0.692 | 0.023 | 0.152 | | reconnect | 0.016 | 1.109 | 0.322 | -0.035 | -0.137 | | slow_reader | 0.009 | 1.094 | 0.334 | -0.107 | -0.131 | | steady | 0.055 | 1.285 | 0.059 | 0.076 | 0.065 | | write_failure | 0.013 | 0.551 | 0.101 | 0.012 | 0.111 | | Pair | Order | Host swap-out MiB | Peak MiB/s | Result | | --- | --- | ---: | ---: | --- | | 1 | AB | 0 | 0 | Accepted | | 2 | BA | 0 | 0 | Accepted | | 3 | AB | 0 | 0 | Accepted | | 4 | BA | 0 | 0 | Accepted | ### Own A/A controls Two full-sequence A/A pairs with Stage 3 disabled in all four fresh members, stages 1–2 enabled: **2 accepted / 0 rejected**, no flags, zero host swap-out, all **3,110 scope samples** zero swap. | Phase | A/A pair 1 ms | A/A pair 2 ms | Noise envelope ms | B−A ms | Within target/envelope | | --- | ---: | ---: | ---: | ---: | --- | | steady | 0.632 | -0.98 | 0.98 | 0.071 | true | | reconnect | 0.724 | -0.449 | 0.724 | -0.387 | true | | slow_reader | -0.994 | -0.457 | 0.994 | -0.162 | true | | write_failure | 0.174 | 0.094 | 0.174 | 0.034 | true | | pool_contention | 0.014 | -0.054 | 0.054 | -0.047 | true | | governor | 0.387 | -0.157 | 0.387 | 0.142 | true | The envelope is max absolute A/A delta, descriptive n=2, not a confidence interval. Acceptance compares with max(0.25 ms, envelope); no noise is subtracted. **Every phase median also meets +0.25 ms without the noise allowance.** The steady median is **+0.071 ms / +2.59%**. Combined gateway+worker+PostgreSQL median CPU peaks at **+0.152 pp**, below 0.5 pp. Individual p95 outliers remain visible: steady pair 1 is +1.121 ms and pool pair 4 +0.792 ms; neither is discarded. ### Every gateway pair | Phase | Pair | CPU pp | p95 ms | p95 % | RSS MiB | Heap MiB | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | governor | 1 | -0.263 | 0.465 | 18.408 | -23.695 | -18.333 | | governor | 2 | 0.115 | -0.432 | -12.418 | 3.391 | 2.795 | | governor | 3 | -0.399 | 0.47 | 15.97 | 3.59 | 4.254 | | governor | 4 | 0.236 | -0.181 | -4.812 | -14.582 | -17.208 | | idle | 1 | 0.003 | — | — | -0.113 | -0.044 | | idle | 2 | -0 | — | — | 1.008 | 0.082 | | idle | 3 | 0.002 | — | — | -0.977 | 0.04 | | idle | 4 | -0.038 | — | — | -0.168 | 0.256 | | pool_contention | 1 | -0.036 | 0.228 | 6.091 | 2.438 | 3.121 | | pool_contention | 2 | 0.014 | -0.323 | -8.687 | 0.258 | 1.736 | | pool_contention | 3 | -0.203 | -0.366 | -9.695 | 0.215 | -2.096 | | pool_contention | 4 | 0.251 | 0.792 | 27.31 | 16.523 | 10.176 | | reconnect | 1 | -0.08 | -0.644 | -18.971 | -0.266 | -2.958 | | reconnect | 2 | -0.153 | 0.057 | 2.059 | 0.047 | 3.923 | | reconnect | 3 | -0.083 | -0.939 | -26.427 | 10.477 | -2.233 | | reconnect | 4 | 0.037 | -0.13 | -4.717 | 3.691 | 3.305 | | slow_reader | 1 | -0.134 | 0.344 | 10.507 | 9.445 | 19.635 | | slow_reader | 2 | 0.1 | 0.789 | 26.106 | -5.137 | 3.014 | | slow_reader | 3 | -0.346 | -0.668 | -17.561 | 3.816 | -3.418 | | slow_reader | 4 | 0.153 | -1.257 | -32.879 | 0.078 | 0.211 | | steady | 1 | -0.06 | 1.121 | 42.556 | -1.973 | 0.831 | | steady | 2 | 0.013 | -0.608 | -15.523 | 1.988 | 0.435 | | steady | 3 | 0.136 | 0.496 | 15.439 | -0.859 | -1.141 | | steady | 4 | -0.251 | -0.354 | -10.258 | 5.492 | 1.02 | | write_failure | 1 | 0.2 | -0.03 | -1.045 | -243.77 | -168.184 | | write_failure | 2 | 0.094 | 0.028 | 0.965 | -6.164 | 2.739 | | write_failure | 3 | -0.098 | 0.039 | 1.409 | 8.004 | 4.755 | | write_failure | 4 | 0.077 | 0.208 | 7.903 | 11.281 | -0.346 | All worker/PostgreSQL/total CPU and worker memory pair values remain in `paired-report.json`. **Memory interpretation:** write-failure gateway median is **+0.920 MiB RSS / +1.196 MiB heap**; governor median is **−5.596 MiB RSS / −7.206 MiB heap** and worker governor heap **+0.661 MiB**. Negative endpoint deltas are not claimed as retained-memory savings. First-pair write-failure heap is A 252.816 / B 84.633 MiB, so a large spike also occurs on the first, disabled member after complete state isolation. The A/A control also has a slow-receiver heap difference of +178.312 MiB; modern data isolation alone cannot eliminate legacy-watch GC timing. The separate dev/GC evidence and #544 describe this pre-existing behavior. These facts do not turn endpoint medians into a proof of zero memory cost. **Pool starvation:** corrected acceptance fixture leaves one read slot after ingest. Across all eight measured members, maximum pool-contention history p95 is **32.512 ms**. Original ~59,820 ms reads existed on both Stage 3 sides; the pure-dev SQL-backed probe also stalled ~64,825 ms behind a fully occupied pool. They completed successfully, not via timeout. Product scheduling is tracked separately in #563. Evidence: `/var/tmp/canopy-diagnostics-3/fresh-gate-20261112/` and `/var/tmp/canopy-diagnostics-3/fresh-aa-20261112/`. No old/shared-state recordings are pooled into these results. Raw snapshots remain private. Owned scopes/listeners are cleaned up. Gate decision remains with the maintainer; every PR stays draft. ### Verification After rebase: install, gen:check, full typecheck, lint, format:check, web builds, diff/shell checks and shard-manifest validation passed. **109 focused tests in 19 files**, one file at a time through `check:tmp`, all controlled temp directories clean. Covers journal ACK/reconnect/restart, bounded churn/active timing, deterministic ACP/git privacy, worker reports/old peers/owner relay, mirrors and interrupted commits, durability, sync upgrade to 0124 and Stage 2 query/privacy/failure paths. Parent Stage 2 also ran its focused selection (**72 tests / 12 files**). Critical protocol tests: MAD 2, swap 4, scope 1; heap analyzer privacy 2, all passed. Shell-only postlude syntax/diff checks passed without another application run. Full current-head CI includes four green test shards, static checks and builds. An earlier duplicate run was cancelled by workflow concurrency; its synthetic matrix/aggregate failure is superseded by the later complete green run. Gate decisions remain with the maintainer. Results below distinguish ordinary endpoint heap/RSS from the focused post-GC evidence; negative endpoint deltas are not claimed as a retained-memory benefit.
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.
nixuuu
added a commit
that referenced
this pull request
Nov 13, 2026
Ordinary SQL family/RPC measurements exhausted a 512 KiB SQL allocation even while the 6 MiB process budget was mostly unused. The 192-correlation limit also counted global series, so startup metadata crowded out foreground RPC correlations. Reallocate internal measurements to 4 MiB, with SQL capped at 3 MiB, inside the unchanged 6 MiB total. Count only correlations toward a 256-series allowance: the composed workload with the new SQL families exceeded 192 despite substantial free budget. SQL completion still writes four numbers into the existing bounded queue; no new timer, query text or per-query object is added. Add a time-weighted `Dropped measurements per second` gauge alongside the existing cumulative drop count. Suspension and wall-clock jumps do not invent observation time. Under adversarial cardinality the existing caps still drop explicitly and mark incomplete distributions. Paired local workload: two linked desktop gateways with 12 threads each, desktop SSE plus mobile Connect simulation, diagnostics enabled; 5 s warmup then the same 30 s idle window. | Diagnostics counter | Before A / B | After A / B | |---|---:|---:| | Cumulative dropped measurements at end (includes fixture startup) | 6411 / 2075 | 0 / 0 | | Drops during 30 s idle window | 2679 / 0 | 0 / 0 | | Database queries during window | 2910 / 2623 | 2888 / 2613 | | Collector allocation at end | 869120 / 790800 B | 991760 / 809312 B | Composed verification with all seven independent PRs: 826/765 queries per 30 s, zero new GetComputers calls, zero mirror ACKs and zero collector drops during that steady window. Startup still explicitly drops optional correlations beyond the per-slot cardinality cap (1464/1526 cumulative before the window); the new rate distinguishes this bounded startup detail from ongoing loss. The 256-series cap and unchanged total memory budget remain enforced. The final adversarial memory run passes 175 assertions with 0.21 MiB retained heap growth after warmup. A deterministic 15-minute, 325-query/s workload records all 292500 queries: old collector drops 507395 measurements; new collector drops zero, with RPC correlations retained. This reproduces the failure without claiming a live device or a production 15-minute capture. Validation: SQL retention/overflow/expiry/history/drop-rate unit tests 7 passed, 309 assertions; real linked workload passed. Saturated rolling-memory test retains the 6 MiB process ceiling and independent GC/heap plateau checks, with revised internal limits and slot-rotation tolerance. Install and full typecheck passed. Focused lint and formatting passed; gen:check/web build already passed earlier in the task. Full local check:tmp deferred to CI due shared-host load; focused integration files use check:tmp. Native/mobile sources and fingerprint unchanged; device checks blocked by the device host. Copy audit (§8): absent rate label → `Dropped measurements per second`; explicit unit in a plain sentence-case diagnostic label, no action/error copy changed. No new colour or icon dependency. Fixes: #535
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 2 adds gateway health to Settings → Diagnostics: event-loop p50/p99/max, CPU/RSS/heap, pool pressure, named slow SQL families, ingest/outbox/watch queues and process-governor admissions/waits/drops. Web/desktop and mobile expose the same details; RPC drill-down correlates local SQL reserve, execute, release and transaction timings.
Whole-stack manual QA — 2026-11-12
Reviewed on top of stage 6 at desktop, narrow and phone widths in light/dark, with long computer/worker names and online/offline/unsupported data. Fixed the DB-family disclosure border to use the semantic
border-dividertoken; RPC details now use the same short histogram explanation as the main sections on web and mobile. Phone tables fit without horizontal overflow; p99 stays bounded by max, uptime has Last only, and the fixture had over 95% named-family coverage. Existing performance acceptance is unchanged.Copy audit (§8): removed the obsolete repeated quantization paragraph in RPC details in favour of the existing shared explanation; no new term or action. Numbers remain tabular, unavailable values explicit, and light/dark contrast follows kit tokens. Install, generation check, full typecheck, lint, format and web build passed after the fixes. Screenshots/check evidence:
/var/tmp/canopy-diagnostics-6/qa/(not committed).Overhead gate accepted by the maintainer; the stack remains draft. CPU medians are at most approximately +0.35 pp; p95 is nonpositive or within the A/A envelope in every phase. All-pairs memory medians are at most +6.5 MiB RSS / +3.9 MiB heap across stages 2–3. The governor sensitivity view is interpreted against the pre-existing A/A GC jumps in #544, with the deterministic bounds test below completing the maintainer's condition.
Stack #506: #495 → #505 → #535 → #542 → stage 4, rebased onto dev
f7ad51cc. Migrations 0124–0128 are reserved by concurrent work; Stage 1 now uses 0129_diagnostics, including index/schema/upgrade tests. Stages 2–3 add no migrations. Thread-sync diagnostics from #543 are integrated, not duplicated. Contracts are additive, generated code is committed and update/v1 remains untouched. Measurements below retain their original measured heads; this rebase was not remeasured.Deterministic governor/series memory bound
tests/integration/diagnostics-memory.test.tsruns the real governor and SQL-family collector in an isolated Bun child: 40 families × 4 SQL phases × 8 RPC correlations, saturated queues, admissions/cache/join/drop/cancel, five warmup cycles followed by twenty cycles of 72 fake minutes. Each sample follows two full GCs. 175 assertions passed: 6 MiB collector / 1 MiB internal measurements / 512 KiB SQL sub-limit, expired rolling slots, no queued/active work at checkpoints, and increasing explicit drops under pressure.Post-GC heap: 15,783,235 → 15,863,231 bytes (+0.0763 MiB). Retained Measure objects: 2649 → 2625; Histograms 1539 → 1545; total objects 22,392 → 22,374. The test checks a plateau across all samples, not just endpoints. No full bench was run for this condition.
Bounds and privacy
Exit.Failureand statement/acquisition captures from cleanup callbacks. Classification stores numeric reason/defect counts and a failure bit, preserving work/release error semantics. Pool sampling is single-flight; governor callbacks retain only the collector. Pending encoded writes are single-flight and capped at 60 minutes / 4 MiB, with explicit drops/gaps. No collector budget increased.Retention evidence after the sync rebase
bash scripts/bench/diagnostics-retention.sh 2 write_failurecompleted with seeded history, slow receivers, periodic views, the real 70 s lock and a failing INSERT carrying an 8 MiB synthetic parameter. Each checkpoint used a fresh A/B fixture, two forced GC calls and a native JSC snapshot; snapshots themselves collect garbage, so earlier checkpoints do not collect in later-checkpoint fixtures.The after-release probe residual exceeds approximately 2 MiB; it is not silently rounded into a pass. A control without the synthetic parameter, retaining the original lock/watches, gave pre-GC A 248.853 / B 248.706 MiB and post-GC A 73.618 / B 75.160 MiB, delta +1.542 MiB. Thus a roughly 170 MiB collectible heap also occurs with Stage 2 disabled.
Largest string self-size was 85,386 bytes in both sides, with no retained 8 MiB parameter string. Positive differences were primarily ArrayBuffer backing stores (~0.94/0.95/1.88 MiB across the checkpoints) and JIT code (~0.30/0.47/0.45 MiB). Example path:
ObservedConnection → DatabaseConnection → PgConnectionImpl → parser closure → store → ArrayBuffer; large writer/module buffers also existed on both sides. The original control had ~0.95 MiB extra ArrayBuffer and ~0.17 MiB JIT self bytes. Pending diagnostic data during the lock was only A 5,201 B / B 22,937 B, and after release A 5,146 B / B 12,700 B; no growing failed-write queue or parameter-bearing diagnostic record appeared.Pre-existing watch finding: the large collectible allocations were associated with full watch snapshots. The incremental-sync stack removed them for the modern sequence protocol; this benchmark deliberately preserves the older watch flags without
sequence, so the compatibility snapshot path remains exercised. This diagnostics stack does not change watch protocol/workload to hide those allocations and does not claim the original spike was conclusively caused by the removed Exit reference.Analyzer:
bun scripts/bench/diagnostics-heap-report.ts off.json on.json, run automatically by the retention launcher. It reports constructor counts, root-reachable self bytes and bounded shortest root paths, not dominator-retained sizes. Native JSC snapshots lack weak-edge classification; a root path alone does not establish strong retention. Unknown names are redacted/hashed and string contents are never printed. Bun 1.4.4's V8 export crashed in the discarded initial run, so completed evidence uses native JSC. Raw snapshots/type counts remain private (0700/0600); do not upload them.Private evidence:
retention-sync-jsc-20261112/,retention-control-20261112/under/var/tmp/canopy-diagnostics-2/.Fresh-state method and controls — 2026-11-12
This measurement supersedes the earlier shared-driver/cluster recordings. Each A or B member now has a fresh Bun driver VM, PostgreSQL cluster/WAL/database, gateway state directory and worker state directory. The old member exits and its cluster/state is removed before the next starts. Initial fixture counts are logged and match: 500 threads, 1,000 turns, 7,099 items and 840 seeded rollups. The measured checkout remains committed and unchanged throughout recording.
Two A/A controls precede each stage's four acceptance pairs. Current-stage diagnostics are off in every control member; lower stages remain on. Slot order is strictly AB / BA for controls and AB / BA / AB / BA for measured pairs. The p95 noise floor is the maximum absolute paired A/A delta for that phase, a descriptive n=2 envelope, not a confidence interval. We compare B−A with max(0.25 ms, that envelope), report percentages separately, and do not subtract noise from overhead.
Every measured process runs in a user scope with
MemorySwapMax=0; PostgreSQL has its own bound scope. Limits and current swap are checked at boundaries and every second. Nonzero/unreadable scope counters, load above 12 CPUs, or host swap-in >=4 MiB/s for three consecutive seconds reject the pair. Host swap-out is log-only and recorded per pair. Kernel affinity was denied (Operation not permitted), so kswapd ticks/last CPU and zram I/O remain logged. No host settings or foreign processes changed.Sensitivity flags a whole pair only when any process/phase delta differs by more than 2× MAD and host peak swap-out exceeds 4 MiB/s. Primary medians include every accepted pair; sensitivity medians exclude whole flagged pairs and state their n. This is not a reason to discard accepted data. Physical PostgreSQL I/O remains unavailable (
null) because the I/O controller is not delegated.RPC path profile
diagnostics-rpc-path.tsholds the Stage 1 interceptor constant and adds Stage 2 RPC correlation plus three SQL phase records per call. Four alternating pairs, 25,600 measured calls per member, show median per-call increments +0.001701 / +0.001914 / +0.001749 / +0.001528 ms (median +0.001725 ms). The paired p95 of batch-average call costs is −0.015590 / +0.002867 / +0.002300 / −0.002806 ms; this is explicitly a batch statistic, not network RPC p95. Fixed-buffer bounds held, with no drops. Native JSC sampling is dominated by transport abort/listener/generator/header operations, rather than a diagnostic allocation loop.A separate fresh-state 30 s real steady profile gave A 4.037163 / B 4.128845 ms RPC p95, delta +0.091683 ms, and CPU +0.020855 pp. This focused result meets 0.25 ms, but does not replace full-sequence controls or acceptance results. Private profiles:
/var/tmp/canopy-diagnostics-2/isolation-20261112/andisolation-profile-fixed-20261112/. No profiling or explicit GC runs inside acceptance recordings.Independent pre-existing findings
Stage 2 control evidence:
/var/tmp/canopy-diagnostics-2/fresh-aa-20261112/. All raw snapshots remain private; no SQL text, parameters, credentials or string contents are attached.Fresh-state results: Stage 2
Measured head:
07b25362c33346f5537cdbc324ba3561e33340e9. 4 accepted / 0 rejected, strict AB / BA / AB / BA. All scope swap checks passed. Pairs 2 and 3 meet the agreed joint MAD/swap-out sensitivity rule; they remain in primary results.Gateway medians above include all four accepted pairs. CPU is percentage points of one core; p95 is the median of paired deltas (and separately the median paired percent change). Endpoint RSS/heap are sampled without forced GC.
Worker/PostgreSQL CPU, total CPU and worker memory are retained for every phase/pair in
paired-report.json; no process cost is omitted from that report.Interpretation: RPC p95 meets the 0.25 ms / phase-specific A/A criterion in every phase; gateway median CPU stays below 0.5 pp. This is not a no-memory-growth claim: primary write-failure memory is +5.998 MiB RSS / +2.497 MiB heap, and sensitivity governor heap is +33.649 MiB with only n=2. Those endpoint effects and the independent A/A collectible watch spike remain visible. The maintainer decides the gate.
Evidence:
/var/tmp/canopy-diagnostics-2/fresh-gate-20261112/and/var/tmp/canopy-diagnostics-2/fresh-aa-20261112/, including immutable heads, JSONL, profiles references, paired deltas, rejected records (none), host swap counters and all MAD flags.Verification and UI
After the sync rebase: install, generated-code check, full typecheck, lint, format check, diff/shard-manifest checks and web builds passed. Stage 2 focused verification: 72 tests in 12 files, one file at a time via
check:tmp, clean controlled temp directories. Includes ACK/durability under ingest/slow receiver, owner SQL, reserve/execute/release errors, throwing error getters and large-parameter privacy, governor and restart continuity. Stage 3 repeats/extends coverage to 109 tests in 19 files. Protocol logic: paired/MAD 2, swap 4, scope 1 passing tests; heap analyzer security 2 passing tests. Shell postlude syntax/diff checks pass. Current-head full CI is green, including all four shards and builds; the full local suite was not redundantly repeated during recording.Shared web/mobile percentiles clamp to observed min/max. Disclosures use kit chevrons/motion; observation duration appears once per section, uptime has only its latest value and percentile explanation is one sentence. Prior seeded browser QA covered light/dark, desktop/narrow/390/320 px and long labels; no UI changed in this measurement update. Evidence under
/var/tmp/canopy-diagnostics-2/:desktop-{light,dark}-process.png,desktop-dark-database.png,desktop-light-query-family.png,narrow-dark-governor.png,phone-{light,dark}-process.png,phone-320-light-queues.png.Mobile JS only; pinned EAS 27.4.1 production fingerprints unchanged: iOS
6ddec9ef559ee0095ac33e94ff9418a942053b17, Android5f6eae3ab278f1cd543e9ed763f923a319b65ec9. Native device UI was not exercised.Copy audit (
docs/copy.md§8): English/sentence case, explicit units, evidence-led findings and next actions; observation once per group, latest-only uptime, one-sentence percentile explanation, coverage denominator, incomplete/historical states, and long-label wrapping verified. No new UI copy in the latest corrections.Other measured processes