Skip to content

refactor(gateway): schedule auth pruning with the runtime owner - #159455

Merged
steipete merged 1 commit into
mainfrom
hostneutral/scheduler-auth-pruning-0926
Sep 27, 2026
Merged

steipete merged 1 commit into
mainfrom
hostneutral/scheduler-auth-pruning-0926

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Authentication rate-limit pruning previously owned separate periodic timers for each limiter.

Require an explicit scheduler and stable id for internal limiters. The Gateway supplies its kernel scheduler; the shipped public SDK factory borrows the bound host, or explicitly creates and closes a standalone scheduler through dispose. Preserve failed-attempt policy, penalties and request-scoped waits.

The invariant is one scheduler instance per Gateway process: kernel composition supplies it, and required internal scheduler dependencies prevent silently creating private owners. Shipped SDK facades resolve the bound host; standalone entry points visibly own creation and stop.

Deleted: Private pruning intervals and direct timer-based fixtures are removed.

User Impact and Update Behavior

Update behavior: Existing authentication, signatures, proxy attribution, ports, and configuration remain unchanged. No store or schema migration. Public SDK factory parameters remain source-compatible; internal construction requires the scheduler. Disposed resources close their pruning job with their existing dispose operation.

LOC: production +124/−36/net +88; tests +645/−519/net +126; docs +0/−0/net +0. These atomic constructor/caller closures include test migrations; growth is reported directly, without splitting off unused intermediate wiring.

Evidence

Historical focused proof: provider blacksmith-testbox, lease tbx_01m3fqja9r983kwbphpb3v3g5g, run 36270738491; 34 passing file executions / 682 case executions / 522.116 s wall. These source-pinned receipts cover the reviewed composition; they are not claims that the refreshed publication head ran remotely. Each row used pnpm test <file> --maxWorkers=1, after frozen install.

Focused test cost and source identity
File Passed Wall Proof tree
src/gateway/auth-rate-limit.test.ts 47 3.037 s 4989a9c05916
src/gateway/auth.test.ts 109 16.040 s 4989a9c05916
src/gateway/control-ui.http.test.ts 123 23.975 s 536c02d99c4f
src/gateway/node-reapproval-coordinator.test.ts 9 16.999 s 536c02d99c4f
src/gateway/rate-limit-attempt-serialization.test.ts 2 2.129 s 536c02d99c4f
src/gateway/server-http.device-pairing-ingress.test.ts 4 23.254 s 536c02d99c4f
src/gateway/server-http.hooks-delivery.test.ts 7 17.699 s 536c02d99c4f
src/gateway/server-http.node-workspace-transfer.test.ts 6 17.848 s 536c02d99c4f
src/gateway/server-runtime-state.tailscale.test.ts 7 20.570 s 536c02d99c4f
src/gateway/server.plugin-node-capability-auth.test.ts 13 17.925 s 536c02d99c4f
src/gateway/server.public-worker-ingress.test.ts 6 18.498 s 536c02d99c4f
src/gateway/server/hooks-request-handler.fanout.test.ts 21 23.368 s 536c02d99c4f
src/gateway/server/hooks.agent-trust.test.ts 30 15.780 s 536c02d99c4f
src/gateway/server/hooks.background-admission.test.ts 12 16.688 s 536c02d99c4f
src/gateway/server/hooks.early-failure.test.ts 34 18.401 s 536c02d99c4f
src/gateway/server/hooks.terminal-target.test.ts 4 17.726 s 536c02d99c4f
src/gateway/server/ws-connection.startup.test.ts 15 27.948 s 536c02d99c4f
src/gateway/server/ws-connection/auth-context.state.test.ts 5 15.130 s 536c02d99c4f
src/gateway/server/ws-connection/auth-context.test.ts 20 15.027 s 536c02d99c4f
src/gateway/user-profiles-http.auth.test.ts 18 19.917 s 536c02d99c4f
src/gateway/watch-node-http.test.ts 21 30.005 s 536c02d99c4f
src/gateway/worker-environments/worker-bootstrap-artifact-transfer.test.ts 17 16.410 s 536c02d99c4f
src/plugin-sdk/webhook-ingress.test.ts 4 2.224 s 536c02d99c4f
src/gateway/server-http.hooks-request-timeout.test.ts 8 17.936 s 536c02d99c4f
src/gateway/server.plugin-http-auth.test.ts 33 20.066 s 536c02d99c4f
src/gateway/server-close.test.ts 80 24.524 s 536c02d99c4f
src/gateway/server-close.cleanup-scope.test.ts 2 4.837 s 536c02d99c4f
src/gateway/test-helpers.listener.test.ts 3 2.274 s 536c02d99c4f
extensions/diffs/src/http.test.ts 3 20.807 s 536c02d99c4f
extensions/nextcloud-talk/src/monitor.limiter-lifecycle.test.ts 1 2.374 s 536c02d99c4f
extensions/nextcloud-talk/src/monitor.preauth-inflight.test.ts 2 3.872 s 536c02d99c4f
extensions/nextcloud-talk/src/monitor-runtime.abort.test.ts 2 24.126 s 536c02d99c4f
extensions/nextcloud-talk/src/monitor.durable-ack.test.ts 4 1.822 s 536c02d99c4f
extensions/nextcloud-talk/src/monitor.replay.test.ts 10 2.880 s 536c02d99c4f

Current-composition refresh: provider blacksmith-testbox, lease tbx_01m3fz4ar9ygxxkxh5y2qjc40x, run 36278033418. Changed source remains byte-identical except preservation of main’s proxy-capture finalizer. Refreshed focused results:

File Passed Wall
src/gateway/control-ui.http.test.ts 123 28.802 s
src/plugin-sdk/webhook-ingress.test.ts 4 2.170 s

The same current composition passed full pnpm build (326.589 s), pnpm plugin-sdk:api:diff --base 0e27650f8e89afa47a839182e8018e5fb9382ce3 --head e06a34e17bceaaca9f04c5af68f4a52f7f84defe (130.200 s), export/surface/import guards, scoped docs sanity, and the existing MCP UI fixture (2 cases, 64.325 s). The isolated import profiler covered 19 packaged SDK consumers (6.229 s) plus three source-only QA consumers (0.918 s). The initial profiler command incorrectly selected private, non-packaged qa-lab and was rejected before import; the corrected routes preserve coverage. All source was verified, and no suite/build ran locally.

SDK API acknowledgement: digest 5e457d84 reports 125 affected exports (124 reachable, one signature-text change), with no added or removed entrypoints. startDiagnosticHeartbeat keeps the same optional config/options types through Parameters<...>[1]/[2]; its internal scheduler parameter is not part of the public call. Public createAuthRateLimiter retains its name, parameters and return contract; its declaration now belongs to the wrapper instead of the aliased internal constructor. The remaining reachable diff adds readonly to three synthesized reason?: undefined fields in recovery unions whose source is byte-identical. This is a nonempty declaration/reachability diff, with no public contract migration required.

Deslop and independent Codex review completed with no accepted/actionable findings. Rejected hypothetical findings retain source-backed dispositions. Required GitHub openclaw/ci-gate validates the exact published head; final Gateway/cron/SIGSTOP/SIGCONT/restart/SIGTERM proof follows the final stack slice.

Stack

Earlier slices include kernel scheduler #158423, session delivery #159275, update watcher #159291, and update campaign #159306. This slice follows diagnostic/CLI/SDK lifetime #159389. MCP fixtures #159372 and CLI settlement #159421 landed independently. Next: MCP scheduler cutover, then final timer census and docs. Earlier full stack links appear in predecessor PRs.

Merged scheduler slices

Publication head 28b8ad301754382beb3392756de6d12a07d656bd, based on fresh main 3b9ca80b7309b40117a9d95abcbc8ccd4c1ac3c3 after diagnostics merged. The exact reviewed/proved patch ID is unchanged. Complete-tree signature searches found no new internal callers requiring adaptation; newer main cleanup context is preserved.

@clawsweeper

clawsweeper Bot commented Sep 27, 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.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 28b8ad301754382beb3392756de6d12a07d656bd
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/auth-rate-limit.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 gateway Gateway runtime size: XL labels Sep 27, 2026
@steipete
steipete enabled auto-merge (squash) September 27, 2026 05:44
@steipete
steipete merged commit 5e1a2cf into main Sep 27, 2026
197 checks passed
@steipete
steipete deleted the hostneutral/scheduler-auth-pruning-0926 branch September 27, 2026 05:56
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant