Repository navigation
fix(gateway): expose live load and preserve public reads - #166387
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 maintainer review before merge. Reviewed October 7, 2026, 10:32 AM ET / 14:32 UTC (Revision 9). ClawSweeper reviewWhat this changesThe PR adds live Gateway load gauges, narrows active-session selection, synchronizes anonymous publication reads before delivery, and updates a channel-status fixture. Merge readiness✅ Ready for maintainer review The PR remains useful and has no identified blocking patch defect. Current main still lacks the live gauges and retains the public-reader race; the earlier migration-proof blocker does not apply to this narrowed diff. Priority: P2 Review scores
Verification
How this fits togetherGateway run and session owners feed current activity into the Prometheus exporter for operator monitoring. Anonymous conversation requests use the session projection to check publication authority before returning transcript content. flowchart TD
A[Run and session owners] --> B[Live activity projection]
B --> C[Prometheus exporter]
D[Anonymous conversation request] --> E[Prepared sharing facts]
E --> F[Current publication and cache checks]
F --> G[Transcript response or refusal]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +450, Tests +520, Docs +46. Total +1016 across 40 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one owner-projected live-load view and consume current publication authority synchronously through final HTTP delivery while preserving existing counters and public URLs. Do we have a high-confidence way to reproduce the issue? Yes: current-main source can mistake pending sharing facts for an absent publication after awaited history, and the added regression targets that exact invalidation. No local runtime reproduction was executed in this read-only review. Is this the best way to solve the issue? Yes: the patch reuses the existing activity, selection, prepared-read, and authorization owners without adding a competing registry or persistent format. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cb04039f21de. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
ecd730e to
356c749
Compare
356c749 to
4fcd558
Compare
8189998 to
84e959a
Compare
84e959a to
e02f3af
Compare
…6387) * fix(diagnostics): expose live session and run gauges * fix(gateway): reconcile public reads before delivery * test(gateway): align channel status fixture with inspection
Problem and change
openclaw_session_state_total{state="processing"}is cumulative and can remain at 60 after every run finishes. Add five fixed-cardinality live series: running/queued sessions inopenclaw_sessions_active, and admitted agent runs, active chat runs, and queued chat turns inopenclaw_gateway_active_work. Preserve the existing counter name; its HELP text and Gateway metrics reference now explicitly describe cumulative observations, including repeated observations of a session.Existing owners publish absolute counts after changes, using coalescing and lifecycle-bound subscriptions. Session counts match the full operator
sessions.listactive-only roster, including global/unknown sessions and default archive/cron-history exclusions. Work counts matchcreateGatewayActiveWorkSnapshot(). Unavailable or retired sources remove samples, and projection stops without exporter demand. No polling timers, per-session labels, new configuration options, or schema changes. Categories overlap and are not the complete suspension-blocker inventory; zero alone does not establish suspend readiness.The PR also fixes an anonymous public-reader race exposed by integration testing: pending sharing facts were treated as absent publications. Initial authorization and final HTTP authorization/response emission now consume the existing prepared-read owner synchronously. Revocation and representation-cache invalidation remain enforced.
Update the channel-status fixture to the current no-probe contract: inspection metadata supplies configuration/source fields, and recorded runtime supplies
lastProbeAt. Remove its unused live summary hook and strengthen the WhatsApp configuration assertion to exactlyfalse.Rebased onto
96ccec4a1385. Upstream now supplies the complete commit-receipt and continuation-authority repairs and the CI fixture fixes encountered during validation. The redundant lane repair commits were dropped. Only the live metrics, public-reader readiness, and channel fixture changes remain; no upstream fixes were copied or cherry-picked.Measurement
Synthetic persisted-state/API/exporter rig: 10,000 idle rows, 2 active rows, 20 transitions.
These are bounded-work and freshness measurements, not a claimed wall-time speedup or production memory reduction.
Production/tooling delta with
git diff --stat origin/main...HEAD -- ':!*.test.ts' ':!*test-support*' ':!docs/*': +452 (669 additions, 217 deletions). Growth implements the new live-metrics contract: owner notifications, replayable projection, exporter delivery, and indexed selection for session-list parity without idle-history scans. The public-reader fix adds 15 net lines to retain prepared authorization through response emission. Existing code moves to focused modules; there is no second activity registry or alternate fast path. The cumulative metric name and legacy public token URLs are retained public contracts.Proof
All heavy validation ran remotely; Testbox provider
blacksmith-testbox, profileopenclaw-check. No local tests, builds, or typechecks.git range-diffto the previously reviewed and validated patches. Ontbx_01m4avp5j96fxdkmsag4jvdx0r, the original ten-file CI shard passed 51/51 in 173.48s and eight focused files passed 163/163 in 342.87s.node scripts/check-changed.mjs --staged --timedpassed all core/test/extension types, dead exports, lint, and schema/database/media guards. The lease ended with exit 255 after 1h1m38s, before the last runtime guards finished; all five unfinished guards passed against the same tree ontbx_01m4azkxkkgabnjh9jga593kbein 1m56s. Runtime import cycles: 0. No gate was waived.tbx_01m4adfrhhkektfvdxcktjnb1c: original reader 7 pass / 1 fail, corrected reader 8/8. Another 27 HTTP/admission cases passed, covering concurrent readers, revocation, and cache staleness. The original predecessor-plus-X sequence reproduced the false 404; the corrected sequence passed 12/12 across five files.tbx_01m4a0kcvc1358z30v4jv4k2zh. Fullpnpm buildpassed on the authorized Linux rig in 26m24.5s while sharing the host with a gate; this is build proof, not an idle-host timing.tbx_01m4b3rnjz44x5yxz2g097tp09. After the upstream UI fixture correction,tbx_01m4b74xvhgp65agjbkate657fpassed 17/17 cases across five files, UI component types (62.80s), extension test types (107.52s), and core/extension lint. An initial extension-lint command used an incorrect tsconfig path; the corrected command passed with zero warnings/errors.Test cost: cold
pnpm test src/gateway/server-work-metrics.test.ts --maxWorkers=1measured 60.55s wall / 5.978s test time on the rig; a later Testbox run measured 3.893s test time. The public-reader suite measured 32.62s wall, including its new 513ms regression; database-backed authorization across awaited history requires this boundary. The original exporter regression took 9ms.Current-base proof on
tbx_01m4bahafg5pgp5nz63gffqgwwverified candidate treed015da92479c1ead3fc1390753c502fb151f05a5before execution. The original CI group passed 71/71 tests across 21 files in 263.66s; the repaired channel-status case passed in 33ms.node scripts/run-vitest.mjspassed 68/68 integration tests across eight files (217.94s + 16.39s + 4.41s), including metrics, active selection, public reads, continuation authority, and committed facts.node scripts/check-changed.mjs --base HEAD --timed -- src/gateway/server.channels.test.tspassed every planned check: Gateway server types 70.50s, dead exports 97.54s with zero entries, and lint 16.18s with zero warnings/errors. Combined remote command: 15m12s, exit 0. Fresh full-candidate review is clean at P0–P2. All task-owned leases are stopped.CI is green on
e02f3af37687: run 37636360689 completed successfully. Final PR check rollup: 106 passing, 48 skipped, zero failed or pending. The automated merge watcher subsequently merged the PR; no manual merge or auto-merge command was issued.One unresolved observation remains: an initial
sessions-read-active.test.tsinvocation returned totalCount 3 instead of 4. Isolated candidate/original probes, original-order replay, and subsequent rebased runs pass. No cause was established; passing replays are not claimed as a fix.