Skip to content

test(gateway): publish runtime config in users.self and users.prefs.get request tests - #170227

Merged
steipete merged 1 commit into
mainfrom
fix/users-preferences-runtime-config
Oct 12, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/users-preferences-runtime-config

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: seven users-preferences.test.ts cases (users.self keeps its original … authority ×6 and users.prefs.get retains its original scope) fail with Runtime config is not prepared whenever CI selects that file, for example the agentic-gateway-methods-hosted-2 shard on #170077 (run 38289790852, job 114947303634).

User Impact

No user-visible change. PRs that touch this file's imports (such as server-plugin-in-process-dispatch.ts) stop failing the gateway-methods-isolated shard.

Why This Change Was Made

#169714 turned getRuntimeConfig from config/io into readRuntimeConfig, which reads the published runtime snapshot and throws when nothing was prepared instead of cold-loading config. createOpenClawTestState resets runtime-config state when it applies its env, and these seven cases drive handleGatewayRequest through createDirectChatContext() defaults, so method authorization (authorizeGatewayMethod, assertCurrent in session-mutation-guards.ts) hit the throwing reader. The other nine cases pass because they use a context with its own getRuntimeConfig or call handlers directly.

The two tests now publish an empty runtime snapshot right after creating their state: the precondition a running Gateway always has, and the idiom push-authority-in-process.test.ts already uses in the same shard. Test-state cleanup resets the snapshot again, so nothing leaks between tests.

This was never intermittent. It has been deterministic on main since #169714, but it only shows up when changed-file selection schedules this file. The 16/16 local pass on the #170077 head ran pre-#169714 code, while PR CI tests the merge ref. The green main push run checked (32feb396e066) did not schedule the gateway-methods shard. No other gatewayMethodsIsolatedTestFiles entry uses default createDirectChatContext() without publishing config (users-role.worker.test.ts passes its own getRuntimeConfig).

Evidence

  • Before, on origin/main 24dec4d6c370: pnpm test src/gateway/server-methods/users-preferences.test.ts --maxWorkers=1 gives 7 failed / 9 passed, the same error and stacks as the CI job.
  • After, same command: 16 passed under the gateway-methods-isolated project (Vitest 67.7s, wall 80s on a loaded dev Mac).
  • Shard sibling pnpm test src/gateway/server-methods/push-authority-in-process.test.ts --maxWorkers=1: 3 passed under the gateway-methods project.
  • node scripts/run-tsgo-core-test-shards.mjs --changed-paths-json for the file: gateway-methods graph passed. oxfmt --check and oxlint are clean.
  • No timers, sleeps, or new fixtures; the added cost is one synchronous snapshot publish per test. The failing CI shard spent 14.4s on this file; expected unchanged.

…et request tests

#169714 made getRuntimeConfig from config/io throw when no runtime
snapshot is published. createOpenClawTestState resets that state, so the
users.self authority cases and the users.prefs.get scope case, which use
createDirectChatContext() defaults, failed method authorization with
"Runtime config is not prepared" whenever CI selected this file.

Publish an empty snapshot after creating test state, matching
push-authority-in-process.test.ts in the same shard.
@clawsweeper

clawsweeper Bot commented Oct 12, 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 gateway Gateway runtime size: XS labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR publishes an empty runtime-config snapshot before seven existing Gateway profile and preference request tests.

Example: The users.prefs.get test reads ui.theme=dark and revokes operator.sessions.read while the read is pending.

  • Before: Missing runtime config prevents the test from reaching its intended authority check.
  • After: The request reaches the pending read and must return FORBIDDEN after scope revocation.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A correct, narrowly scoped fixture repair supported by source and reported in-process validation; this review did not independently execute the tests.
Proof confidence 🦐 gold shrimp (3/6) This test-only maintainer PR changes fixture preparation rather than shipped behavior; its body reports the affected request harness failing before and passing after the change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Selected Gateway CI fails before existing profile and preference authority tests exercise their intended behavior.
Reason: The patch restores meaningful existing coverage using the established fixture pattern and preserves all security expectations.

Regression provenance

Regression provenance — verified: source commit 7e48efba1047 by Peter Steinberger; canonical PR #169714 (blame-to-merge-commit).

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a concrete test-fixture failure while preserving the existing authority checks. The focused patch has no actionable findings.

Priority: P3
Reviewed head: a9487da956a63fa0478ae63d9f47ca0679a1ad27

Before merge

None.

Findings

None.

Agent review details

How this fits together

The request-test fixture supplies runtime config to Gateway method admission; profile and preference handlers then read worker-backed state and recheck requester authority before responding.

flowchart TD
  A[Test state] --> B[Published runtime config]
  B --> C[Gateway request admission]
  C --> D[Profile and preference handlers]
  D --> E[Current authority check]
  E --> F[RPC response assertions]
Loading

Technical review

Best possible solution:

Retain the explicit fixture publications and merge through the normal required checks without changing production authorization or config-loading behavior.

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

Source establishes the failure path: test-state creation clears the snapshot, the default context uses the prepared-only reader, and request authorization reads it; the PR reports matching before-and-after test results.

Is this the best way to solve the issue?

Publishing the existing snapshot at fixture setup restores the required runtime precondition without mocking authorization, weakening assertions, or changing the shared reader.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 21f043cf86f5.

Provenance checked

  • Runtime-config preparation in request tests keeps the original intent (7e48efb: Consume asynchronously prepared runtime config instead of cold-loading storage during ordinary runtime reads.)
  • Profile and preference authority assertions keeps the original intent (282fc78: Support scoped session readers while preserving requester identity and current permission checks across asynchronous reads.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Shakker: Raw commit 282fc78 adds src/gateway/server-methods/users-preferences.test.ts:52 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 282fc78eaf64; files: src/gateway/server-methods/users-preferences.test.ts)

PR surface

Tests +3. Total +3 across 1 file. Added test files: 0.

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

Labels

Label changes:

  • add P3: This is a focused test-fixture repair with no user-facing runtime change.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a focused test-fixture repair with no user-facing runtime change.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed October 12, 2026, 4:45 PM ET / 20:45 UTC.

@steipete
steipete merged commit 7e596d5 into main Oct 12, 2026
106 checks passed
@steipete
steipete deleted the fix/users-preferences-runtime-config branch October 12, 2026 22:03
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…et request tests (openclaw#170227)

openclaw#169714 made getRuntimeConfig from config/io throw when no runtime
snapshot is published. createOpenClawTestState resets that state, so the
users.self authority cases and the users.prefs.get scope case, which use
createDirectChatContext() defaults, failed method authorization with
"Runtime config is not prepared" whenever CI selected this file.

Publish an empty snapshot after creating test state, matching
push-authority-in-process.test.ts in the same shard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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