Skip to content

fix(gateway): use secure telemetry jitter - #128998

Merged
vincentkoc merged 1 commit into
mainfrom
fix/native-telemetry-jitter
Aug 25, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/native-telemetry-jitter

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

Resolves a problem where release preparation could reject the gateway telemetry maintenance source because its jitter combined Date.now() with Math.random(), even though the value was scheduling jitter rather than a temporary-path identifier.

Why This Change Was Made

The gateway now uses the canonical generateSecureInt() helper for both telemetry jitter calculations. Its [0, maxExclusive) contract preserves the existing initial [0, 5m) and repeat [5m, 10m) cadence while satisfying the repository random-ID guardrail. No telemetry behavior, configuration, or temp-path logic changes.

User Impact

Maintainers can prepare releases without this false-positive guard failure. Gateway telemetry checks retain the same randomized cadence.

Evidence

  • AWS Crabbox cbx_0870260b8ec8, exact source base 935c555c98d6b38af76faa6a0b1370353d1828df
  • node scripts/run-vitest.mjs src/gateway/server-maintenance.telemetry.test.ts — 2/2 passed
  • pnpm run check:temp-path-guardrails — passed
  • pnpm format:check src/gateway/server-maintenance.ts src/gateway/server-maintenance.telemetry.test.ts — passed
  • node scripts/run-oxlint.mjs src/gateway/server-maintenance.ts src/gateway/server-maintenance.telemetry.test.ts — 0 warnings, 0 errors
  • git diff --check — passed
  • signed commit: 308c01645650b3268af2f3a2675e3005db4e71be

Use the canonical bounded secure-random helper so maintenance jitter keeps its existing cadence without tripping temporary-path guardrails.
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc vincentkoc self-assigned this Aug 25, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

Exact head: 308c01645650b3268af2f3a2675e3005db4e71be.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS maintainer Maintainer-authored PR labels Aug 25, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 25, 2026 04:08
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 12:49 AM ET / 04:49 UTC.

ClawSweeper review

What this changes

The PR replaces gateway telemetry jitter based on Math.random() with the shared bounded secure-random helper and updates the timer test.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open: no blocking correctness or security finding; current main still matches the release guard’s Date.now()/Math.random() pattern, while this branch preserves both timer ranges through the canonical helper. Likely related people: Miorbnli (current code introducer; high confidence).

Priority: P3
Reviewed head: 308c01645650b3268af2f3a2675e3005db4e71be

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused, net-neutral patch and timer coverage match the helper contract and preserve the scheduler invariant.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored internal scheduler repair is exempt from the external-contributor real-behavior-proof gate; its body also reports focused Crabbox test and guard results.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored internal scheduler repair is exempt from the external-contributor real-behavior-proof gate; its body also reports focused Crabbox test and guard results.
Evidence reviewed 6 items Current-main behavior: Current main still calculates the initial telemetry offset with Date.now() and Math.random() on one line, so the central release-guard problem remains unresolved there.
Guard mechanism: The release guard flags runtime files containing Date.now() and Math.random() on the same line, which directly matches the former scheduler expression.
Helper contract: The shared helper documents its one-argument form as producing an integer in [0, maxExclusive), preserving the former jitter bounds.
Findings None None.
Security None None.

Live Verification

Command: pnpm test src/gateway/server-maintenance.telemetry.test.ts

Result: FAIL (partial) — step 2 expect_output gateway telemetry maintenance: expected terminal output was not visible within 30 seconds: "gateway telemetry maintenance"

pnpm test src/gateway/server-maintenance.telemetry.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128998-AtblFK/target$ pnpm test src/gateway/server-maintenance.telemetry.test.ts
$ node --import tsx scripts/test-projects.mts src/gateway/server-maintenance.telemetry.test.ts
pnpm test src/gateway/server-maintenance.telemetry.test.ts
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128998-AtblFK/target

 ✓  gateway-server  ../../src/gateway/server-maintenance.telemetry.test.ts (2 tests) 13203ms
     ✓ uses one jittered maintenance schedule and silently retries failed checks  13196ms

 Test Files  1 passed (1)
      Tests  2 passed (2)
   Start at  04:50:38
   Duration  14.70s (transform 11.72s, setup 949ms, import 177ms, tests 13.20s, environment 0ms)

[test] passed 1 Vitest shard in 21.04s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128998-AtblFK/target$ pnpm test src/gateway/server-maintenance.telemetry.test.ts
$ node --import tsx scripts/test-projects.mts src/gateway/server-maintenance.telemetry.test.ts
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128998-AtblFK/target

 ✓  gateway-server  ../../src/gateway/server-maintenance.telemetry.test.ts (2 tests) 5477ms
     ✓ uses one jittered maintenance schedule and silently retries failed checks  5471ms

 Test Files  1 passed (1)
      Tests  2 passed (2)
   Start at  04:51:00
   Duration  6.25s (transform 3.41s, setup 433ms, import 114ms, tests 5.48s, environment 0ms)

[test] passed 1 Vitest shard in 12.47s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128998-AtblFK/target$


















Assertions:

  • FAIL expect_output: gateway telemetry maintenance

How this fits together

Gateway startup creates periodic maintenance timers. One timer schedules telemetry update checks using a randomized initial offset and randomized five-to-ten-minute repeat interval.

flowchart LR
  A[Gateway startup] --> B[Maintenance timer]
  B --> C[Secure bounded jitter]
  C --> D[Telemetry check schedule]
  D --> E[Telemetry update service]
  E --> F[Gateway health flow]
Loading

Before merge

  • Complete next step (P2) - This protected member-authored PR has no discrete repair finding; normal exact-head maintainer review and merge gating are the remaining actions.
Agent review details

Security

None.

PR surface

Source 0, Tests +9. Total +9 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 3 0
Tests 1 12 3 +9
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 15 6 +9

Review metrics

Metric Value Why it matters
Production vs test LOC production +3/-3 (net 0); tests +12/-3 (net +9) The runtime change is net-neutral, while the added test assertions protect both initial and repeat jitter bounds.

Technical review

Best possible solution:

Keep the net-neutral scheduler change: use the shared exclusive-upper-bound helper while retaining the existing initial and repeat telemetry cadence.

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

Yes: the guard’s source rule deterministically matches the current-main scheduler expression, and the focused fake-timer test exercises both scheduling decisions; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes: direct use of the shared bounded helper removes the guard-triggering expression without adding scheduler-specific logic or changing either timing range.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a focused internal scheduling and release-guard bug fix with limited user-facing blast radius.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored internal scheduler repair is exempt from the external-contributor real-behavior-proof gate; its body also reports focused Crabbox test and guard results.

Label justifications:

  • P3: This is a focused internal scheduling and release-guard bug fix with limited user-facing blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored internal scheduler repair is exempt from the external-contributor real-behavior-proof gate; its body also reports focused Crabbox test and guard results.

Evidence

What I checked:

Likely related people:

  • Miorbnli: Available history shows this author introduced the telemetry scheduler, its focused test, and the shared secure-random helper together. (role: introduced current maintenance and helper surface; confidence: high; commits: 3a17d5993ad3; files: src/gateway/server-maintenance.ts, src/gateway/server-maintenance.telemetry.test.ts, src/infra/secure-random.ts)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-25T04:07:52.868Z sha 308c016 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Aug 25, 2026
@vincentkoc
vincentkoc merged commit 81c0ba0 into main Aug 25, 2026
307 checks passed
@vincentkoc
vincentkoc deleted the fix/native-telemetry-jitter branch August 25, 2026 06:07
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
Use the canonical bounded secure-random helper so maintenance jitter keeps its existing cadence without tripping temporary-path guardrails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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.

1 participant