Skip to content

fix(discord): annotate deploy request duration across clock changes - #189161

Closed
chengzhichao-xydt wants to merge 1 commit into
openclaw:mainfrom
chengzhichao-xydt:fix/discord-deploy-request-clock
Closed

chengzhichao-xydt wants to merge 1 commit into
openclaw:mainfrom
chengzhichao-xydt:fix/discord-deploy-request-clock

Conversation

@chengzhichao-xydt

@chengzhichao-xydt chengzhichao-xydt commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: a failed discord slash-command deploy reports a bogus request duration in its error text when the system clock steps mid-request (NTP correction, manual change, VM snapshot restore). requestCommandDeploy annotates abort failures with deployRequestMs computed from Date.now(), so a forward step reports a one-second timeout as an hour (observed=3600s), and a backward step zeroes the duration and even flips the diagnostic from "timed out" to "was aborted".

User Impact

Deploy failure diagnostics report the real elapsed request time and classify timeout-vs-abort correctly regardless of clock corrections. No configuration, public API, schema, or migration changes; annotation field names and message shape are unchanged.

Why This Change Was Made

The annotation is a duration measurement, so it now reads performance.now(), which is monotonic and immune to system-clock steps. A new regression pins an abort landing after a backward wall-clock step (duration stays 45ms on the monotonic clock instead of negative by an hour).

Evidence

node scripts/run-vitest.mjs run extensions/discord/src/internal/command-deploy.test.ts: 4/4 pass (the new wall-clock regression is red against the base implementation). oxlint and oxfmt --check clean on changed files. Local tsgo lane unavailable on this host (glibc 2.28 vs binary requirement 2.33+); type gates run in hosted CI. Net test growth +26 lines is recorded in config/test-lines-allocations/chengzhichao-discord-deploy-clock-20261031.txt.

Real behavior proof

Behavior addressed: Deploy failure annotations must report real elapsed request time across wall-clock steps.
Real environment tested: This branch at HEAD ac1bafb493a0ac997d498a68b5c789e99f296836, Node v24.13.1, Linux x64. A real subprocess constructs the real internal Client with its REST base URL pointed at a real loopback HTTP server that hangs, so the request aborts at the configured real 1s timeout; Date.now is stepped one hour when the request arrives (mid-flight) while performance.now stays native. The observable is the shipped formatDiscordDeployErrorMessage output text.
Exact steps or command run after this patch: WT=$PWD STEP_MS=3600000 OUT=/tmp/clock-proof/deploy-head-fwd.json node --import tsx /tmp/clock-proof/discord-deploy.mts and STEP_MS=-3600000, then the same two commands with extensions/discord/src/internal/client.ts restored to the base revision.
Evidence after fix: HEAD (both directions): Discord REST GET /applications/proof-app/commands timed out (timeout=1s, observed=1s). BASE: forward — ... timed out (timeout=1s, observed=3600s) (a 1s timeout reported as an hour); backward — ... was aborted (timeout=1s, observed=0s) (duration zeroed and timeout misclassified as abort). Receipts: /tmp/clock-proof/deploy-{head,base}-{fwd,bwd}.json.
Observed result after fix: The shipped error text reports the real 1s duration and the correct timeout classification under ±1h wall-clock steps; base reports an hour (or zero) and flips the classification.
What was not tested: The live Discord REST API, real command registration outcomes, and OS/NTP clock adjustment. Timeout length and annotation field names are unchanged.

Intentionally out of scope

  • Other Discord REST paths' timing (this annotation owner is the command-deploy path).
  • Any change to timeout policy, retry, or the deploy reconciliation flow.

@clawsweeper

clawsweeper Bot commented Oct 31, 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 channel: discord Channel integration: discord size: XS labels Oct 31, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Measures Discord command-deployment request duration with a monotonic clock so clock corrections do not distort failure diagnostics.

Example: A Discord command-list request times out after one second while the wall clock moves backward one hour.

  • Before: Reports "was aborted (timeout=1s, observed=0s)".
  • After: Reports "timed out (timeout=1s, observed=1s)".

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused patch and repaired consumer fixture are supported by real-HTTP fault evidence and successful exact-head gates; proof reaches the production request owner rather than a full Gateway deployment.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Exact-head contributor output exercises Client command deployment through the real REST transport against a hanging loopback server on Node 24/Linux: native one-second timeouts retain correct duration and classification across ±1-hour wall-clock steps, with failing base comparisons; live Discord registration and OS clock adjustment were explicitly outside the scenario.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Discord deployment failures report incorrect elapsed time and can misclassify a timeout after a system-clock correction.
Reason: A small owner-local repair restores the intended diagnostic contract without changing deployment policy, configuration, public APIs, or stored data.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current-main diagnostic bug with a focused change; the previous fixture finding is resolved and no correctness blockers remain.

Priority: P2
Reviewed head: ac1bafb493a0ac997d498a68b5c789e99f296836

Before merge

None.

Findings

None.

Agent review details

How this fits together

Discord startup invokes Client command reconciliation, whose REST failures carry timing annotations into the deployment warning formatter.

flowchart LR
  A[Discord startup] --> B[Client command reconciliation]
  B --> C[REST request owner]
  C --> D[Discord REST transport]
  D --> E[Annotated failure]
  E --> F[Deployment warning formatter]
Loading

Technical review

Best possible solution:

Keep monotonic duration measurement in Client.requestCommandDeploy while preserving the existing annotation and formatter contracts.

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

Current-main source establishes the faulty wall-clock subtraction and its classification consumer; contributor output demonstrates the failure against base without this review executing target code.

Is this the best way to solve the issue?

The two clock replacements repair elapsed-time measurement at its existing owner, and the regression plus migrated consumer fixture cover the affected contract without introducing another timing layer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3bc6c4c43fc4.

Provenance checked

  • Discord deployment-request timing and diagnostics keeps the original intent (d23c8a8: Explain aborted command-deployment requests with method, path, elapsed duration, and timeout budget; subsequent refactors preserved that behavior at the request owner.)
  • Deployment regression and provider fixtures keeps the original intent (refactor: deslop Discord, QA Lab and plugin fixtures #182302: Preserve warning formatting, original error identity, all five HTTP methods, and separation from unrelated concurrent REST traffic.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 0cf5e00 adds extensions/discord/src/internal/client.ts:468 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0cf5e00fbe57; files: extensions/discord/src/internal/client.ts)

PR surface

Source +2, Tests +26, Other +2. Total +30 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 4 2 +2
Tests 2 28 2 +26
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 4 34 4 +30

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Clock corrections can produce misleading deployment-failure durations and timeout classifications, with limited impact confined to diagnostics.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-31T07:15:22.847Z sha e0facbc7b2dd0d5947cf326879ead25f5edf58ea :: needs changes before merge. :: [P2] [P2] Migrate the existing deployment-diagnostic test clock

Reviewed October 31, 2026, 6:36 AM ET / 10:36 UTC (Revision 2).

@chengzhichao-xydt
chengzhichao-xydt force-pushed the fix/discord-deploy-request-clock branch from e0facbc to ac1bafb Compare October 31, 2026 07:19
@chengzhichao-xydt

Copy link
Copy Markdown
Contributor Author

Fixed the missed consumer fixture: provider.deploy.test.ts's deploy-diagnostic cases now drive performance.now (the 25s timeout annotation assertions unchanged). Both provider.deploy.test.ts and command-deploy.test.ts suites pass (11/11). @clawsweeper re-review

@chengzhichao-xydt

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 31, 2026
obviyus added a commit that referenced this pull request Nov 2, 2026
…ions (#190894)

fix: measure durations, timeouts and cache ages with the monotonic clock

Several timeouts, cache TTLs and retry backoffs measured elapsed time with the wall clock. When the system clock jumped (NTP correction, sleep and resume, manual change), they fired too early, never fired, or ignored server backoff. These callers now use the monotonic clock (`src/shared/monotonic-time.ts` in core, `performance.now()` in extensions). Stored and displayed timestamps stay on the wall clock, and SDK signatures and public epochs are unchanged.

This sweep includes #190846, #190852, #190853, #187703, #187689, #187782, #187765, #189161, #189160 and #190098, with the contributors' commits kept for credit.

Evidence: built Gateway, CLI and real Chromium, main twice and candidate twice, stepping only the process wall clock (`Date.now`); no system clock change. On main, a Discord deployment timeout aborted or overran after a 60-second step, the Chromium context popover retried after about 100 ms despite server backoff, and the `sessions.usage`, Pi session catalog and GitHub project caches refreshed too early or too late. With this change, each followed real elapsed time. Ordinary controls passed, and epoch timestamps were unchanged. Details: #190894 (comment).

Thanks @Alix-007, @chengzhichao-xydt, @huwei-xydt.

Co-authored-by: Alix-007 <[email protected]>
Co-authored-by: chengzhichao-xydt <[email protected]>
Co-authored-by: Claude Code <[email protected]>
Co-authored-by: 胡伟0668000622 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
@obviyus

obviyus commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Thank you! Your fix is included in #190894, landed in fca1c6e with your commit kept for credit.

@obviyus obviyus closed this Nov 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
…ions (openclaw#190894)

fix: measure durations, timeouts and cache ages with the monotonic clock

Several timeouts, cache TTLs and retry backoffs measured elapsed time with the wall clock. When the system clock jumped (NTP correction, sleep and resume, manual change), they fired too early, never fired, or ignored server backoff. These callers now use the monotonic clock (`src/shared/monotonic-time.ts` in core, `performance.now()` in extensions). Stored and displayed timestamps stay on the wall clock, and SDK signatures and public epochs are unchanged.

This sweep includes openclaw#190846, openclaw#190852, openclaw#190853, openclaw#187703, openclaw#187689, openclaw#187782, openclaw#187765, openclaw#189161, openclaw#189160 and openclaw#190098, with the contributors' commits kept for credit.

Evidence: built Gateway, CLI and real Chromium, main twice and candidate twice, stepping only the process wall clock (`Date.now`); no system clock change. On main, a Discord deployment timeout aborted or overran after a 60-second step, the Chromium context popover retried after about 100 ms despite server backoff, and the `sessions.usage`, Pi session catalog and GitHub project caches refreshed too early or too late. With this change, each followed real elapsed time. Ordinary controls passed, and epoch timestamps were unchanged. Details: openclaw#190894 (comment).

Thanks @Alix-007, @chengzhichao-xydt, @huwei-xydt.

Co-authored-by: Alix-007 <[email protected]>
Co-authored-by: chengzhichao-xydt <[email protected]>
Co-authored-by: Claude Code <[email protected]>
Co-authored-by: 胡伟0668000622 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants