Skip to content

perf(nodes): checkpoint host telemetry in the Gateway - #184099

Merged
steipete merged 6 commits into
mainfrom
dbasync/heartbeatmem
Oct 26, 2026
Merged

steipete merged 6 commits into
mainfrom
dbasync/heartbeatmem

Conversation

@steipete

@steipete steipete commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

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 and devicePairing.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):

node --import ./scripts/tsx.mjs scripts/perf/pairing-live-measure.mts \
  --out <internal-synthetic-output> --observer <frozen-v3.1.5>/observer.cjs \
  --heartbeat-mode checkpoint --steady-seconds 900 --finish disconnect

Use --heartbeat-mode baseline on the baseline arm. Separate recovery uses --steady-seconds 130 --finish shutdown or --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 6ea1b8d5b5341d2eae5f1e7063113c7c73b82dea and candidate 0241631f93a5293fcb9a9a22da0f869045749617. 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.

Pair Steady heartbeat SQL / requests / MAIN First-sample SQL / requests / MAIN Whole-flow SQL / requests / MAIN
1 75/15/0 → 15/3/0 87/22/0 → 102/30/0 1251/263/69 → 1146/245/68
2 75/15/0 → 15/3/0 107/32/0 → 101/30/0 1263/271/68 → 1147/245/68
3 75/15/0 → 15/3/0 96/27/0 → 113/34/0 1257/266/68 → 1140/242/68

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.

Phase Metric Baseline median [min–max]; p95 Candidate median [min–max]; p95
boot sql 825 [819–828]; 828 822 [804–823]; 823
boot requests 135 [133–137]; 137 134 [126–134]; 134
boot main 63 [63–64]; 64 63 [63–63]; 63
first-sample sql 96 [87–107]; 107 102 [101–113]; 113
first-sample requests 27 [22–32]; 32 30 [30–34]; 34
first-sample main 0 [0–0]; 0 0 [0–0]; 0
steady sql 309 [309–310]; 310 195 [195–196]; 196
steady requests 97 [97–99]; 99 74 [74–75]; 75
steady main 0 [0–0]; 0 0 [0–0]; 0
disconnect sql 9 [9–9]; 9 9 [9–9]; 9
disconnect requests 2 [2–2]; 2 2 [2–2]; 2
disconnect main 0 [0–0]; 0 0 [0–0]; 0
shutdown sql 18 [18–18]; 18 18 [18–18]; 18
shutdown requests 5 [5–5]; 5 5 [5–5]; 5
shutdown main 5 [5–5]; 5 5 [5–5]; 5
whole-flow sql 1257 [1251–1263]; 1263 1146 [1140–1147]; 1147
whole-flow requests 266 [263–271]; 271 245 [242–245]; 245
whole-flow main 68 [68–69]; 69 68 [68–68]; 68
Unphased (retained) sql 0 [0–0]; 0 0 [0–1]; 1

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:

Whole owner Pair1 delta SQL / requests Pair2 Pair3 Source finding
UNKNOWN/task, readonly auth-profile issuer +3/+1 +3/+1 −3/−1 Extra task dispatched during boot before node launch; two runtime probes plus auth store/state UNION.
agentDatabaseDeletion.snapshot +4/+1 0/0 +5/+1 Extra readSnapshot work; pair3 difference is in boot before node launch.
devicePairing.list −44/−11 −52/−14 −40/−10 Committed pairing publication changes less often.
Passive WAL −10/0 −7/0 −10/0 Fewer writes; no additional saving claim beyond heartbeat.

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.

Operation Pair1 Pair2 Pair3
FUNCTION / readOpenClawAgentDatabase +1 / +1 / +0 +0 / +0 / +0 +0 / +0 / +0
FUNCTION / readStore +1 / +1 / +0 +0 / +0 / +0 +0 / +0 / +0
NO_REQUEST / runWithAsyncStore -10 / +0 / +0 -7 / +0 / +0 -10 / +0 / +0
NO_REQUEST / withEngineStoreAdmission -1 / +0 / -1 +0 / +0 / +0 +0 / +0 / +0
UNKNOWN / task +3 / +1 / +0 +3 / +1 / +0 -3 / -1 / +0
agentDatabaseDeletion.snapshot +4 / +1 / +0 +0 / +0 / +0 +5 / +1 / +0
channelIngress.health -2 / -1 / +0 +0 / +0 / +0 +2 / +1 / +0
cron.loadMutable +0 / +0 / +0 +0 / +0 / +0 +1 / +1 / +0
devicePairing.list -44 / -11 / +0 -52 / -14 / +0 -40 / -10 / +0
lifecycle-artifact-plan +0 / +0 / +0 +0 / +0 / +0 -4 / -1 / +0
node.recordHostStats -60 / -12 / +0 -60 / -12 / +0 -60 / -12 / +0
plugins.deferredMigrations.read +1 / +1 / +0 +0 / +0 / +0 +0 / +0 / +0
prewarm +0 / +0 / +0 +0 / +0 / +0 +0 / -1 / +0
scan +0 / +0 / +0 +0 / -1 / +0 +0 / +2 / +0
session-entry-list +0 / +0 / +0 +0 / +0 / +0 -7 / -4 / +0
session-pending-archives +0 / +0 / +0 +0 / +0 / +0 -1 / -1 / +0
session-target-inventory +0 / +0 / +0 +0 / +0 / +0 +0 / +1 / +0
usage-cost +2 / +1 / +0 +0 / +0 / +0 +0 / +0 / +0

Behavior and Review Evidence

Focused proof on runtime-identical 7d72b2724270 passed 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.

Separate recovery cell / phase SQL / requests / MAIN
shutdown / boot 775 / 115 / 64
shutdown / first-sample 149 / 49 / 0
shutdown / reload 308 / 113 / 39
shutdown / reload-shutdown 33 / 15 / 5
shutdown / shutdown 23 / 6 / 5
shutdown / steady 151 / 58 / 0
shutdown / whole-flow 1439 / 356 / 113
crash / boot 783 / 116 / 64
crash / crash 0 / 0 / 0
crash / first-sample 138 / 49 / 0
crash / reload 531 / 129 / 101
crash / reload-shutdown 51 / 17 / 5
crash / steady 151 / 58 / 0
crash / whole-flow 1654 / 369 / 170

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/2 and check-source-contracts gates 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. No src/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 f1839899dc7df4665bd67d56867439b50f055fe9 compared 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 lastHostStats is 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.

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XS labels Oct 26, 2026
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This 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.

  • Before: The workload observes a 130-second window and requires per-minute durable updates.
  • After: Checkpoint mode measures a 900-second window and expects three or four durable updates while checking live broadcasts and final offline statistics.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful approved preparation, but the acceptance oracle has a concrete correctness defect and the intended production optimization remains incomplete.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored workload-only draft is outside the ordinary contributor proof gate; its body explicitly leaves production implementation and baseline/candidate measurements pending.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Partial
User problem: Connected nodes cause a pairing-storage transaction every minute even though live statistics are already available in NodeRegistry memory.
Reason: The maintainer has approved the checkpoint direction and its durability tradeoffs; this head provides preparatory measurement tooling rather than the production optimization.

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
Reviewed head: 7ccd472ae3a809354512324b87129af82f93478b

Before merge

  • Enforce the checkpoint deadline between durable samples (P2) - With --heartbeat-mode checkpoint --steady-seconds 900, this assertion accepts three or four writes regardless of their spacing. A candidate persisting at steady seconds 60, 120, and 840 passes while continuing reports leave the durable sample more than five minutes behind; live broadcasts, revision counts, and the final disconnect flush can all still pass. maxDurableSampleLagMs is only recorded. Check successive durable sample receipt times and overdue samples during the run so the workload rejects that schedule instead of certifying the five-minute deadline.

Findings

  • [P2] Enforce the checkpoint deadline between durable samples — scripts/perf/pairing-live-measure.mts:389-393

Tests

  • Missing end-to-end proof: No executed baseline/checkpoint workload is supplied, and shutdown after completed disconnect persistence does not exercise shutdown with a pending telemetry write.
Agent review details

How this fits together

The 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
Loading

Technical review

Best 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:

  • [P2] Enforce the checkpoint deadline between durable samples — scripts/perf/pairing-live-measure.mts:389-393
    With --heartbeat-mode checkpoint --steady-seconds 900, this assertion accepts three or four writes regardless of their spacing. A candidate persisting at steady seconds 60, 120, and 840 passes while continuing reports leave the durable sample more than five minutes behind; live broadcasts, revision counts, and the final disconnect flush can all still pass. maxDurableSampleLagMs is only recorded. Check successive durable sample receipt times and overdue samples during the run so the workload rejects that schedule instead of certifying the five-minute deadline.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5bc90d07df85.

Provenance checked

  • Pairing workload cadence and acceptance changes intended behavior with a stated reason (542760b: The original workload retained per-minute heartbeat writes while measuring removal of discarded iMessage pairing reads.)
  • Fixture pairing approval keeps the original intent (542760b: The original fixture explicitly approved pending pairing requests; the revised fixture relies on the existing direct-loopback connection owner's silent approval contract.)

Testing

Proof path: none.

Security

None.

Evidence

Acceptance criteria:

  • Verify a 900-second schedule with durable updates at seconds 300, 600, and 900 satisfies the deadline oracle.
  • Verify a 900-second schedule with durable updates at seconds 60, 120, and 840 fails despite satisfying the aggregate count.
  • Run the existing baseline and checkpoint workload through the built Gateway with synthetic state and the frozen observer.
  • pnpm check:script-erasability
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 542760b adds scripts/perf/pairing-live-measure.mts:2 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 542760bddd36; files: scripts/perf/pairing-live-measure.mts)

PR surface

Docs +40, Other +193. Total +233 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 1 40 0 +40
Config 0 0 0 0
Generated 0 0 0 0
Other 1 222 29 +193
Total 2 262 29 +233

Review metrics

Metric Value Why it matters
Benchmark options 2 new CLI options --heartbeat-mode selects baseline/checkpoint acceptance and --steady-seconds controls the measurement window; neither changes Gateway configuration.

Labels

Label changes:

  • add P2: The defect can approve an invalid checkpoint cadence in an operator-run benchmark, with no production runtime change in this head.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The defect can approve an invalid checkpoint cadence in an operator-run benchmark, with no production runtime change in this head.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 25, 2026, 10:54 PM ET / October 26, 2026, 02:54 UTC.

@steipete steipete changed the title perf(gateway): checkpoint paired-node host telemetry in the registry improve(nodes): reduce durable writes for host telemetry Oct 26, 2026
@steipete
steipete marked this pull request as ready for review October 26, 2026 03:09
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T03:12:30.997927Z 7d72b27 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 0241631f93a5293fcb9a9a22da0f869045749617
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/infra/device-pairing-node.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-node.worker.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: XL and removed size: M labels Oct 26, 2026
@steipete steipete changed the title improve(nodes): reduce durable writes for host telemetry perf(nodes): checkpoint host telemetry in the Gateway Oct 26, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

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.

@steipete
steipete merged commit 7b82210 into main Oct 26, 2026
201 of 207 checks passed
@steipete
steipete deleted the dbasync/heartbeatmem branch October 26, 2026 07:05
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts security-sensitive-changed size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant