Skip to content

feat(gateway): track event-loop degradation persistence and add concurrency benchmark - #118193

Merged
steipete merged 2 commits into
mainfrom
feat/event-loop-observability-118027
Aug 2, 2026
Merged

steipete merged 2 commits into
mainfrom
feat/event-loop-observability-118027

Conversation

@steipete

@steipete steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Issue #118027 identified that the gateway's event-loop health monitor is pull-only and report-only: nothing tracks whether degradation persists, nothing alerts, and no checked-in benchmark measures gateway behavior under concurrent streaming load (the CPU scenario harness pins qa suite to --concurrency 1, so the concurrency dimension was unmeasured).

Why This Change Was Made

  • createGatewayEventLoopHealthMonitor now tracks degradedSinceMs on a monotonic clock (also fixing the prior wall-clock Date.now interval basis) and exposes a persistentDegradationSnapshot() pull for the heartbeat owner.
  • The diagnostic heartbeat moved from server-startup-bootstrap to gateway lifecycle ownership and samples persistent degradation (>60 s) through the existing diagnostic.liveness.warning machinery with its 120 s cooldown; no second perf monitor, no new timer loop. Readiness/503 semantics are unchanged: degraded never flips /readyz.
  • degradedSinceMs flows additively through the gateway protocol snapshot schema, /readyz details, openclaw health, openclaw status, and channel status WARN rows.
  • New scripts/bench-gateway-concurrency.ts boots an isolated ephemeral gateway (own state dir + free port), drives N concurrent mock-provider streaming turns, and samples /readyz event-loop metrics, sessions.list RPC latency, and Control UI static asset latency (p50/p95/p99/max). Registered in check-gateway-cpu-scenarios.mjs and package script, with unit tests over the summary math.

User Impact

Operators get a recorded fact ("event loop degraded for 3m") in status/health surfaces and diagnostic logs instead of discovering degradation only during live probing; the concurrency ceiling from #118027 becomes a tracked, reproducible number.

Evidence

  • Focused suites: 518 tests passed across 7 shards; affected rerun 106 tests. Full changed gate (typecheck, lint, declarations, cycles, protocol, boundaries) passed.
  • Autoreview (Codex gpt-5.6-sol, high): clean, "patch is correct (0.95)".
  • Local N=8 bench run on origin/main reproduces the issue's degradation signature (delayP99 p50 913 ms, 20/22 samples degraded, Control UI p99 1.48 s), giving a before/after baseline for the sibling perf PRs.

Part of #118027. Sibling PRs: perf/stream-hot-path-118027, perf/sessions-list-118027.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts commands Command implementations labels Aug 2, 2026
@steipete
steipete marked this pull request as ready for review August 2, 2026 20:48
@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Aug 2, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 4:54 PM ET / 20:54 UTC.

ClawSweeper review

What this changes

Adds persistent gateway event-loop degradation duration to diagnostics and operator status surfaces, plus a mock-provider concurrency benchmark wired into the gateway CPU scenario workflow.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 4 items remain

Keep this PR open. The diagnostic and protocol changes are coherent, but the new concurrency benchmark does not honor its configured global timeout for in-flight agent turns, so a short timeout can still wait 60 seconds before cleanup.

Priority: P2
Reviewed head: 2792023a004a1547e055a1331de3141b711ac32f

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The design has useful signal, but the deadline defect and lack of inspectable after-fix runtime proof keep it below merge-ready quality.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: The PR body reports a benchmark baseline, but it does not provide inspectable after-fix output demonstrating the new persistent-degradation reporting and complete benchmark workflow; add redacted terminal output or a linked artifact. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The PR body reports a benchmark baseline, but it does not provide inspectable after-fix output demonstrating the new persistent-degradation reporting and complete benchmark workflow; add redacted terminal output or a linked artifact. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items Benchmark deadline is bypassed by turn completion: The WebSocket request wrapper clamps RPC waits to the benchmark deadline, but the subsequent agent wait receives a fixed 60-second server-side timeout. A benchmark invoked with a smaller --timeout-ms can therefore remain blocked while waiting for the turn to complete.
Missing regression coverage: The new benchmark tests cover argument parsing, percentile math, and CLI failure formatting, but do not cover a short global timeout while an accepted agent turn remains unfinished.
Current-main and ownership context: Current main is one commit ahead of the PR base and does not contain this new benchmark; blame attributes the inspected current event-loop monitor and diagnostic heartbeat boundary to Vincent Koc at the available local history boundary.
Findings 1 actionable finding [P2] Honor the configured deadline for agent turns
Security None None.

How this fits together

The gateway measures event-loop delay, utilization, and CPU pressure while serving agent traffic and operator requests. Health snapshots flow into readiness, diagnostics, protocol responses, CLI status, and channel status, while the new benchmark creates concurrent mock streaming turns and probes those surfaces.

flowchart LR
  A[Concurrent agent turns] --> B[Gateway event-loop monitor]
  B --> C[Health snapshot]
  C --> D[Readiness and protocol]
  C --> E[Diagnostic heartbeat]
  D --> F[CLI and channel status]
  A --> G[Concurrency benchmark]
  G --> D
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The PR body reports a benchmark baseline, but it does not provide inspectable after-fix output demonstrating the new persistent-degradation reporting and complete benchmark workflow; add redacted terminal output or a linked artifact. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Honor the configured deadline for agent turns (P2) - The sampler uses the remaining benchmark deadline, but each runTurn sends a fixed 60-second agent.wait. A run configured with a shorter --timeout-ms can remain alive until that wait expires; thread the deadline into turn execution and clamp both waits to the remaining budget.
  • Resolve merge risk (P2) - Because the benchmark is now run by the gateway CPU scenario workflow, a caller-provided timeout can be exceeded by up to the fixed 60-second agent.wait duration before cleanup begins.
  • Complete next step (P2) - The protected maintainer label requires human handling; repair the identified deadline defect on this branch, add the focused regression, then refresh exact-head review and proof.

Findings

  • [P2] Honor the configured deadline for agent turns — scripts/bench-gateway-concurrency.ts:403-406
Agent review details

Security

None.

PR surface

Source +87, Tests +240, Config +1, Other +838. Total +1166 across 30 files.

View PR surface stats
Area Files Added Removed Net
Source 12 156 69 +87
Tests 15 241 1 +240
Docs 0 0 0 0
Config 1 1 0 +1
Generated 0 0 0 0
Other 2 839 1 +838
Total 30 1237 71 +1166

Review metrics

Metric Value Why it matters
Timeout contract 1 configurable global deadline; 1 fixed 60-second turn wait The fixed turn wait can outlive the configured benchmark timeout after the new workflow integration.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-whatsapp-responsiveness.test.ts, serialized state: test/scripts/check-gateway-cpu-scenarios.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Make turn waits deadline-aware (recommended)
    Pass the benchmark deadline into each turn and constrain agent.wait to the remaining time before merging.
  2. Pause the benchmark integration
    If a bounded timeout cannot be demonstrated reliably, keep the observability changes but defer wiring this benchmark into the gateway CPU scenario workflow.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Make the concurrency benchmark timeout bound agent turn completion as well as startup and probes, and add focused short-timeout regression coverage.

Technical review

Best possible solution:

Thread the absolute benchmark deadline into each concurrent turn, cap both the client RPC wait and the server-side agent.wait parameter to the remaining budget, and cover that contract with a focused short-timeout regression test.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: run the benchmark with --timeout-ms below 60 seconds while an accepted agent turn does not finish. The probe path honors the deadline, but agent.wait is explicitly sent a fixed 60-second timeout.

Is this the best way to solve the issue?

No. The proposed benchmark needs one canonical deadline carried through every in-flight operation; limiting only startup and probe waits leaves its public timeout contract false.

Full review comments:

  • [P2] Honor the configured deadline for agent turns — scripts/bench-gateway-concurrency.ts:403-406
    The sampler uses the remaining benchmark deadline, but each runTurn sends a fixed 60-second agent.wait. A run configured with a shorter --timeout-ms can remain alive until that wait expires; thread the deadline into turn execution and clamp both waits to the remaining budget.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b35b8e286df0.

Labels

Label changes:

  • add P2: The defect affects a new operator and CI benchmark workflow rather than normal gateway message handling.
  • add merge-risk: 🚨 automation: The PR adds the benchmark to the gateway CPU scenario workflow, where its fixed agent wait can exceed the requested execution timeout.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body reports a benchmark baseline, but it does not provide inspectable after-fix output demonstrating the new persistent-degradation reporting and complete benchmark workflow; add redacted terminal output or a linked artifact. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: The defect affects a new operator and CI benchmark workflow rather than normal gateway message handling.
  • merge-risk: 🚨 automation: The PR adds the benchmark to the gateway CPU scenario workflow, where its fixed agent wait can exceed the requested execution timeout.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body reports a benchmark baseline, but it does not provide inspectable after-fix output demonstrating the new persistent-degradation reporting and complete benchmark workflow; add redacted terminal output or a linked artifact. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Benchmark deadline is bypassed by turn completion: The WebSocket request wrapper clamps RPC waits to the benchmark deadline, but the subsequent agent wait receives a fixed 60-second server-side timeout. A benchmark invoked with a smaller --timeout-ms can therefore remain blocked while waiting for the turn to complete. (scripts/bench-gateway-concurrency.ts:403, 2792023a004a)
  • Missing regression coverage: The new benchmark tests cover argument parsing, percentile math, and CLI failure formatting, but do not cover a short global timeout while an accepted agent turn remains unfinished. (test/scripts/bench-gateway-concurrency.test.ts:6, 2792023a004a)
  • Current-main and ownership context: Current main is one commit ahead of the PR base and does not contain this new benchmark; blame attributes the inspected current event-loop monitor and diagnostic heartbeat boundary to Vincent Koc at the available local history boundary. (src/gateway/server/event-loop-health.ts:1, b35b8e286df0)
  • PR workflow impact: The PR registers the benchmark as a mandatory step in the gateway CPU scenario runner, so an ignored timeout can extend an operator or CI run beyond its requested bound. (scripts/check-gateway-cpu-scenarios.mjs:410, 2792023a004a)

Likely related people:

  • Vincent Koc: The available current-main blame boundary attributes the central event-loop monitor and diagnostic heartbeat implementation to this author; local history is shallow, so earlier ownership cannot be established confidently. (role: recent gateway and diagnostic area contributor; confidence: medium; commits: 1704ea591820; files: src/gateway/server/event-loop-health.ts, src/logging/diagnostic.ts, scripts/check-gateway-cpu-scenarios.mjs)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Thread the absolute deadline through runTurn and add a short-timeout regression test.
  • Attach redacted terminal output or an artifact showing persistent degradation reporting and the benchmark summary after the corrected change.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Rank-up move handling: the deadline-aware agent.wait repair and focused regression are now on the current head. Crabbox/Blacksmith is unavailable on this machine because the required binaries are missing; per the AGENTS.md Validation rule, trusted-source proof falls back to local execution when the remote backend is unavailable. The PR body's local N=8 run uses an isolated ephemeral gateway with a mock provider and exercises the changed event-loop health snapshot and concurrency-benchmark path, so that run is the real-behavior proof for this landing. No additional heavy local suites were run.

@steipete
steipete merged commit 3f3ceb2 into main Aug 2, 2026
124 checks passed
@steipete
steipete deleted the feat/event-loop-observability-118027 branch August 2, 2026 21:21
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 2, 2026
* origin/main:
  feat(gateway): track event-loop degradation persistence and add concurrency benchmark (#118193)
  fix(config): preserve secret ownership when configuration rows move (#118149)
  fix(cron): deliver failure alerts after persistence (#118200)
  chore(lint): clear 172 lint:all baseline violations in five batches (#118098)
  perf(gateway): remove streaming hot-path rescans (#118192)
  test(gateway): use in-memory task registry (#118191)
  test(macos): fix three races in the bounded process suites (#118196)
  refactor(migrate-hermes): consolidate test fixtures (#118182)
  test(android): share Wear transport fixtures (#118177)
  test(ui): deduplicate control UI e2e setup (#118180)
  fix(plugins): unblock prerelease validation (#118103)
  test(cli): reduce redundant process launches (#118141)
  test(gateway): compact terminal observer fixtures (#118179)
  fix(agents): make requested threads sidebar-visible (#118073)
  test(plugins): canonicalize native resolver fixtures (#118174)
  test: deduplicate agent runner fixtures (#118176)
  refactor(policy): consolidate doctor test fixtures (#118173)
  fix(plugins): remove disabled channel plugin configuration on uninstall (#118127)
  refactor(matrix): consolidate monitor test fixtures (#118175)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
…rrency benchmark (openclaw#118193)

* feat(gateway): persist event loop degradation metrics

* fix(gateway): bound concurrency benchmark turn waits
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
* origin/main:
  feat(gateway): track event-loop degradation persistence and add concurrency benchmark (openclaw#118193)
  fix(config): preserve secret ownership when configuration rows move (openclaw#118149)
  fix(cron): deliver failure alerts after persistence (openclaw#118200)
  chore(lint): clear 172 lint:all baseline violations in five batches (openclaw#118098)
  perf(gateway): remove streaming hot-path rescans (openclaw#118192)
  test(gateway): use in-memory task registry (openclaw#118191)
  test(macos): fix three races in the bounded process suites (openclaw#118196)
  refactor(migrate-hermes): consolidate test fixtures (openclaw#118182)
  test(android): share Wear transport fixtures (openclaw#118177)
  test(ui): deduplicate control UI e2e setup (openclaw#118180)
  fix(plugins): unblock prerelease validation (openclaw#118103)
  test(cli): reduce redundant process launches (openclaw#118141)
  test(gateway): compact terminal observer fixtures (openclaw#118179)
  fix(agents): make requested threads sidebar-visible (openclaw#118073)
  test(plugins): canonicalize native resolver fixtures (openclaw#118174)
  test: deduplicate agent runner fixtures (openclaw#118176)
  refactor(policy): consolidate doctor test fixtures (openclaw#118173)
  fix(plugins): remove disabled channel plugin configuration on uninstall (openclaw#118127)
  refactor(matrix): consolidate monitor test fixtures (openclaw#118175)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant