Repository navigation
perf(nodes): checkpoint host telemetry in the Gateway - #184099
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. What this changesThis PR extends the paired-node benchmark with checkpoint modes, resource measurements, live catalog checks, and disconnect verification. Example: Benchmark one node reporting host statistics every 60 seconds for 900 seconds.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Needs changes before merge - 1 item remains Keep this maintainer-authored draft open: it prepares a useful measurement workload, but its checkpoint acceptance assertion can pass an incorrect persistence cadence. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe benchmark launches an isolated Gateway and real node host, observes host-stat broadcasts and node.list responses, reads synthetic pairing storage, and records measurement artifacts. flowchart LR
A[Benchmark controller] --> B[Isolated Gateway]
C[Real node host] --> B
B --> D[NodeRegistry live statistics]
B --> E[Pairing worker storage]
D --> F[Broadcast and catalog checks]
E --> G[Durable sample checks]
F --> H[Measurement artifacts]
G --> H
Technical reviewBest possible solution: Retain the existing benchmark and runtime owners, enforce checkpoint spacing from durable sample receipt times, and complete the approved optimization with its declared acceptance evidence. Do we have a high-confidence way to reproduce the issue? Source inspection establishes that the 900-second checkpoint assertion accepts any three or four durable changes, including schedules with gaps exceeding five minutes; no target code was executed. Is this the best way to solve the issue? Extending the existing real-Gateway workload is appropriate, but total write counts cannot establish the sample-age deadline; use the durable timestamps already observed rather than adding another owner or timing mechanism. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5bc90d07df85. Provenance checked
TestingProof path: none. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceDocs +40, Other +193. Total +233 across 2 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 25, 2026, 10:54 PM ET / October 26, 2026, 02:54 UTC. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
The checkpoint-spacing P2 remains a workload follow-up: the steady cell records sample lag but does not automatically assert its maximum, so its write-count ceiling alone is not proof of checkpoint spacing. The three candidate runs observed maximum durable sample lags of 299947, 240002 and 240004 ms. Existing owner tests cover saved-sample deadlines and reports arriving during an outstanding checkpoint; the separate crash/reload cell checks both saved-sample age and discarded sample span against five minutes. No steady-spacing assertion was added in this PR, and the finding is not marked fixed. The accepted production behavior and this proof limitation are recorded in the PR body. |
Keep live node host statistics in the existing registry and checkpoint only lastHostStats. Persist the first sample immediately, use a five-minute sample-age deadline, fold the final sample into disconnect, and drain checkpoints before shutdown retires workers. Pairing identity, authorization, revocation, tokens, names and consent retain immediate durability and committed revision ownership. Three synthetic count-only A/B pairs reduce steady heartbeat SQL from 75 to 15 and worker requests from 15 to 3 per node per 15 minutes, with runtime MAIN zero. A crash can lose roughly five minutes of telemetry; the offline catalog may briefly show the previous checkpoint while disconnect persistence settles.
What Problem This Solves
Connected nodes write host telemetry to durable paired-device state every minute even though live views already use the Gateway's in-memory registry. This change reduces steady heartbeat work by 80%: 75 → 15 SQL statements and 15 → 3 worker requests per node per 15 minutes, identically in three baseline/candidate pairs. Runtime MAIN stays zero.
Design and User Impact
The existing NodeRegistry coalesces only
lastHostStats. The pairing writer and committed publication remain the sole owners of durable paired state, authorization anddevicePairing.revision. The first accepted sample persists immediately; later checkpoints use a five-minute deadline anchored to the last saved sample's receipt timestamp. The latest sample joins the existing disconnect mutation, and shutdown drains checkpoints before workers and database handles retire. Live catalog and broadcast visibility remain immediate. No schema or second pairing store is introduced.The accepted durability tradeoff is explicit: a crash can lose roughly five minutes of host telemetry, and the offline catalog can briefly show the previous durable sample while disconnect persistence settles. The sample-age bound assumes continuing reports and successful scheduling/storage; scheduler/commit delay and sensor silence remain visible through the original
updatedAtMs. Identity, approval, revocation, token, name and consent writes stay immediately durable. Actual writes keep their current-generation check at the durable effect, FIFO/admission checks, atomic row/revision transaction and committed receipt. Intermediate heartbeats no longer re-read or rewrite paired state. Revision consumers need committed-state invalidation, not a bump for every telemetry report.Production is +289/−131 lines, net +158, within the explicitly approved +100–160 allowance. The required checkpoint scheduling, final-sample handoff and shutdown drain account for the growth. Unrelated auth-profile and generic config reads are excluded from the saving.
Final Count Evidence
Reproduction entry point (built arm, Node 26.12.1; controller sets internal TMPDIR, pinned Bun caches and NODE_DISABLE_COMPILE_CACHE=1):
Use
--heartbeat-mode baselineon the baseline arm. Separate recovery uses--steady-seconds 130 --finish shutdownor--finish crash. All three count pairs and both recovery cells retain input/artifact/frozen hashes and controller cleanup receipts.Same-platform, real isolated Gateway and paired-node transport, synthetic state only, frozen v3.1.5 observer/causality/background roots verified. Identical committed workload on baseline
6ea1b8d5b5341d2eae5f1e7063113c7c73b82deaand candidate0241631f93a5293fcb9a9a22da0f869045749617. Three alternating 900-second A/B pairs completed under the preregistered amendment below. Count-only admission on a loaded host: no latency, CPU-speed or memory-improvement claim. Per-thread CPU profiles and diagnostics were collected descriptively. Baseline qaRuntime and candidate sourcePerformance builds use matching runtime phases plus a final candidate metadata write; the original baseline environment was not captured, so exact build-environment parity is not asserted.Counts below use n=3 per arm; p95 is nearest rank (the maximum with three samples). Cold, first-sample, steady and terminal phases stay separate. Whole flow includes the unphased statement. Shutdown's inherited five MAIN statements are retained; runtime MAIN zero is not a whole-flow MAIN-zero claim.
Steady total SQL rates (base → candidate, per minute) were 20.594 → 12.999, 20.666 → 13.065 and 20.597 → 13.000. Steady request rates were 6.465 → 4.933, 6.600 → 4.933 and 6.466 → 5.000. Rates use the full observed phase duration including settlement. Boundary delays were base 250/45/108 ms and candidate 85/103/16 ms, all inside the predeclared 5000 ms limit. Each arm observed 15 steady reports, 16 total broadcasts matched to live catalog, final-sample disconnect persistence and offline catalog parity. All six runners exited 0 and drained; no SQL execution errors. Per-node heartbeat saving is 60 SQL / 12 requests per 15 min, approximately 4 SQL / 0.8 requests per minute; the owner operation itself is 75/15 → 15/3 in every pair.
Original STOP and Amended Attribution
The original first pair stopped on first-sample requests 22 → 30 (+36.36%); SQL 87 → 102 (+17.24%). It was not waived as within spread. Raw STOP arrays remain pair1[
first-sample.requests], pair2[], pair3[.sql,first-sample.requests]. Pair3 first-sample requests 27 → 34 (+25.93%); SQL 96 → 113 (+17.71%). Pair2 boot rose 819 → 823 SQL and 133 → 134 requests. Those observations remain in the reported counts.The maintainer explicitly replaced five pairs with three and accepted an owner-attribution rule: another owner rising in at least two pairs is a STOP when it has a call path from the changed node-registry, connection, nodes.event or device-pairing-node code. The repeated whole-owner rises were:
Auth-profile dispatch loses its upstream initiator at the detached readonly pool; deletion snapshot origins end at
readSnapshot. The exact upstream callers are not claimed. Source inspection found no call/data-publication path from this diff to either repeated issuer: checkpoint construction creates only owner state and an async-context snapshot; it does not read auth or persist. Node catalog invalidation is a local revision. Host-stat/disconnect receipts contain no worker-environment, approval or token facts that could emit session topology/model refresh. The unchanged prepared-model publication → usage backfill → agent-list → deletion snapshot chain is a possible independent route, not attribution of a specific captured request. Indirect startup scheduling effects cannot be excluded. Under the explicit amended rule, these non-reachable owners do not block; this is not a claim that every positive count was merely moved between phases.Pair3's extra unphased 1 SQL is a COMMIT from a boot-dispatched session-entry-list request (its BEGIN and two SELECTs are in boot), issued by
listSqliteSessionEntriesFromDatabase/readSessionEntryList. It is retained as unphased and in whole flow, not reassigned or dropped. Phase-file truncate/write transition is a possible explanation, not a proven scheduling cause. Other positive owners rise only once across the three pairs; full per-operation deltas and immutable raw STOP evidence are retained in the local proof packet.All whole-owner operation deltas (candidate minus baseline)
SQL / requests / MAIN, per pair. Owners equal in every pair are omitted. No positive cell is discarded.
FUNCTION / readOpenClawAgentDatabaseFUNCTION / readStoreNO_REQUEST / runWithAsyncStoreNO_REQUEST / withEngineStoreAdmissionUNKNOWN / taskagentDatabaseDeletion.snapshotchannelIngress.healthcron.loadMutabledevicePairing.listlifecycle-artifact-plannode.recordHostStatsplugins.deferredMigrations.readprewarmscansession-entry-listsession-pending-archivessession-target-inventoryusage-costBehavior and Review Evidence
Focused proof on runtime-identical
7d72b2724270passed 328 tests across 15 files, covering checkpoint deadlines, a report arriving during an outstanding checkpoint, durable-immediate revocation/identity changes, pairing, transport/catalog, lifecycle, revision consumers and prompt-prefix stability. Native PostgreSQL proof passed both cases for approval rollback/committed publication and final-sample disconnect/revision/catalog parity. The initial native setup selected system Bun before assertions; the corrected runner resolved and checksum-verified the pinned Bun before changing HOME.Both separate 130-second recovery cells passed with dirty accepted telemetry, real Gateway restart, offline catalog parity, exit 0 and all child groups drained. Shutdown persisted the latest sample before workers retired; restart without a node preserved that exact sample and timestamp. Crash preserved exactly the prior durable checkpoint: discarded accepted-sample span 119958ms and durable sample age at kill 130368ms, both below 300000 ms. Capture-to-exit was 252 ms and restart took 64612 ms; downtime is recorded separately and never subtracted from sample age. These are behavior observations, not timing comparisons.
Dirty shutdown counts include the final flush: 23 SQL / 6 requests / MAIN 5 in the shutdown phase, versus 18/5/5 after normal disconnect had already persisted the sample in the A/B arms. The extra 5 SQL / 1 request is counted, not hidden or claimed as a saving. The separate cells' counts below include restart and shutdown work; they are candidate behavior cells, not additional A/B samples.
ClawSweeper's P2 observation is retained as a workload follow-up: a total write-count ceiling alone does not automatically assert steady checkpoint spacing. Manual candidate maximum durable sample lags were 299947/240002/240004 ms; owner deadline/in-flight tests and the separate crash cell cover the behavior. The steady workload's automatic spacing assertion has not been added, and this is not reported as a fixed finding. No production defect was demonstrated. Two isolated full Codex reviews completed; the second had no actionable P0–P2 findings. A later runtime-identical +7/−7 private-type correction received a scoped-clean isolated delta review, with explicit carry approval for the full reviews. The first delta attempt ended before reviewer execution during snapshot preparation; its stable-input retry completed.
Exact candidate CI 40266887924 passed 65 jobs, 27 planned skips and ci-gate, including all three PostgreSQL shards 121391524982,121391525041,121391525032. Exact-head PostgreSQL semantic review approved the change and shutdown ordering. Local typed lint/check:changed hit the mandated dependency-store containment boundary before analysis; corresponding clean-checkout
check-prod-types,check-test-types*,check-lint-core-1/2andcheck-source-contractsgates passed. All seven reliable Knip baseline comparisons have identical findings (exports 6/25/6, dependency rows 6/20, unused files 0/40); no new findings, not an absolute-zero claim. These scans carry across the runtime-identical private-type correction. Nosrc/plugin-sdk/**files change. The coordinator marked SDK API-diff not applicable; the transitively reachable NodeRegistry optional persistence callback is disclosed, and no generated API comparison pass is claimed.The published-driver upgrade cell remains pending and coordinator-owned. Because immediate Testbox capacity was unavailable, the maintainer consolidated latest-stable → current-main coverage for this and the related startup/state/lifecycle changes after they land. Individual lane retries are stopped. A failed consolidated upgrade or next production update requires an attributed fix-forward or revert. No upgrade pass is claimed here.
Open-PR overlap: candidate tree
f1839899dc7df4665bd67d56867439b50f055fe9compared base-only vs base+candidate against #179959, #170160, #157860, #153907, #148770, #144766, #142957, #142349 and #127982: zero new conflict paths or changed conflict regions. All current indexed peer heads match the recorded comparisons; #183535 was also compared cleanly before it left the current overlap set. Final shared-index refresh is recorded before READY.The following preregistration sections are retained as history. The final count amendment supersedes the original five-pair requirement; the reported completed sample count is three pairs. The later consolidated upgrade-cell disposition above supersedes the earlier individual post-land plan.
Preregistered acceptance — before the first run
The heartbeat checkpoint change uses this real Gateway and paired-node flow with
the frozen v3.1.5 observer, causality observer, and background roots. Reproduce the
current-main heartbeat writes before changing production code. Count cold startup,
the first accepted sample, a 15-minute steady phase, disconnect, and shutdown
separately. Keep all fixture state synthetic. The earlier requirement for at least
two persisted samples in 130 seconds describes the old cadence; the checkpoint
workload replaces it with the following contract.
Run five alternating baseline/candidate pairs on the same platform. For one node
reporting every minute, steady heartbeat work must fall from approximately 75 SQL
statements and 15 execute requests to at most 20 statements and four requests per
15 minutes. Runtime main-thread SQL must remain zero. Report per-operation counts
and rates, median, p95, and min–max separately for each phase. Count whole-process
and main-thread work, including final persistence, to expose relocated cost.
Record per-thread CPU profiles, CPU totals, RSS/heap, event-response and catalog
latency, and broadcast counts. Every accepted report must remain immediately
visible in the live catalog and broadcast stream. User-facing metrics must hold
or improve; an adverse 20% cell stops the change, and smaller adverse movement
needs explicit disposition. Wall-clock/CPU A/B runs require the campaign timing
lock and load below 24. After 60 minutes without timing admission, report only
counts/profile evidence and the unmeasured timing limitation.
Behavioral acceptance also requires durable-immediate revocation and identity
changes, a report arriving during an outstanding checkpoint, final-sample
disconnect persistence, shutdown drain before worker retirement, crash/reload
staleness bounded by the checkpoint interval, offline catalog parity, and passing
revision-consumer suites. Keep security and all other paired-state writes
immediate; only
lastHostStatsis coalesced in the existing NodeRegistry.The approved tradeoffs are explicit: a crash can lose roughly five minutes of
host telemetry, and the offline catalog can briefly display the previous durable
sample while disconnect persistence settles. The five-minute deadline is anchored
to the last persisted sample's receipt time and assumes continuing reports and
successful scheduling/storage; completion delay and sensor silence remain visible
in the original
updatedAtMs. First-sample persistence is immediate. No schema,second pairing store, or memory-only authorization revision is introduced.
Observation-boundary clarification (before the next run)
Each rate sample retains a nominal 900-second steady window and must observe 15 real minute reports after the first persisted sample and its broadcast. A fixed maximum of 5,000 ms after the nominal deadline settles the final report and required durable observation; exceeding it fails the fixture. SQL, requests, MAIN, CPU, memory, and diagnostics remain collected through settlement, with all boundary work retained in the steady phase. Report nominal duration, boundary settlement duration, added boundary delay, and full measured phase duration separately; compute rates from the full measured duration. Baseline minimum 75 SQL/15 heartbeat requests and candidate maximum 20 SQL/four requests remain unchanged. Boundary delay participates in admitted timing comparisons under the existing regression rule. The separate 130-second recovery cells retain their nominal duration and two-report requirement with the same fixed five-second settlement bound.
The correction closes an observation gap: a minute timer can drift beyond the nominal final loop iteration, and a durable write can settle after that iteration's read. The workload now observes the first sample's broadcast before entering steady and evaluates completion after each durable-state read. It never substitutes the shared pairing revision for heartbeat SQL/request attribution, discards boundary work, or extends the wait beyond the fixed bound to obtain a passing count.
Count-only admission disposition before acceptance execution
The coordinator authorized these preregistered heartbeat pairs as count-based acceptance on the loaded host. All five alternating 900-second baseline/candidate pairs and both 130-second recovery cells remain required, with unchanged SQL/request/MAIN, visibility, durability, and cleanup limits. The controller selects its existing counts/profile-only mode from the start; it records CPU, memory, latency and per-thread profiles descriptively, with no speed or controlled timing claim. Any later timing comparison still requires the timing lock and load below 24. The original acceptance and observation-boundary clarification above remain unchanged.
Count acceptance amendment after the first-pair STOP
The maintainer directs two additional count-only A/B pairs on the same exact heads and platform, for three pairs total. The completed first pair and its original STOP remain immutable evidence. Each new arm retains the committed 900-second steady workload and fixed five-second settlement bound. All three pairs must reproduce deterministic steady heartbeat counts of 75 SQL / 15 requests on baseline and 15 SQL / 3 requests on candidate, with runtime MAIN zero.
Every phase and whole-workload SQL/request/MAIN count, raw adverse cell, and per-operation delta remains reported. Apply the following attribution rule across the three pairs: any other owner that rises in the same direction in at least two pairs and has a call path from the changed node-registry, connection, nodes.event, or device-pairing-node paths is a STOP requiring attribution. Owners with no call path from this change do not block under this explicit disposition. A whole-owner increase is not relabeled as a mere phase shift. Runtime MAIN, visibility, durability, boundary settlement, and cleanup checks remain mandatory.
The separate 130-second shutdown-drain and crash/reload cells remain required and will run after the additional pairs. This amendment replaces the original five-pair sample count with three; it does not claim that five pairs passed or erase the first-pair STOP. Report count medians, p95, and min–max for the three pairs, with cold and warm cells separate. CPU profiles and diagnostics remain descriptive: no latency, CPU-speed, or memory-improvement claim is admitted on this loaded host. The published-driver update cell remains post-land at the first immediately granted box.