Skip to content

fix(gateway): prevent live profile retries from replacing runtimes - #129239

Merged
steipete merged 4 commits into
mainfrom
fix/gateway-live-session-scope-20260825
Aug 25, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/gateway-live-session-scope-20260825

Conversation

@steipete

@steipete steipete commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #129237

What Problem This Solves

Fixes an issue where Full Release Validation profile sweeps could invalidate their own prepared model runtime between sequential models. The same harness also accepted a provider credential during candidate preflight, then discarded that exact auth fact before starting its isolated Gateway, so a valid OpenAI key became No route-compatible authentication source is configured at execution time.

Why This Change Was Made

The live client now requests only read/write scopes, every credential attempt receives a distinct session, and explicit thinking selection uses write-scoped sessions.create rather than an administrative patch. Candidate preflight carries its exact ResolvedProviderAuth into Gateway startup: providers requiring profile credentials receive an isolated temporary profile from the selected direct key, selected source profiles retain authoritative ordering, and env-first providers remain env-backed. Host credentials, production sticky-selection behavior, and prepared-runtime fencing are unchanged.

The first exact-head CI pass also exposed an unrelated Control UI performance test whose baseline consumed most of its five-second timeout under shared-runner load. The workload is reduced while preserving the same full-rescan-versus-incremental ratio assertion; production markdown behavior is unchanged.

User Impact

Maintainers can run live profile release checks without the harness changing configured model defaults, replacing the next probe's runtime generation, or losing credentials already accepted by preflight. Normal operators, provider routing, and production model selection are unchanged.

Evidence

  • Immutable failure: Full Release Validation targeted bbae60594677e84b0d16de2300e221ee415f129b; its Release Checks child failed required live profile lanes.
  • Scope/session regression before the fix: 3 failures covering administrative client scope, reused credential-retry session identity, and admin-only explicit-thinking patching.
  • First credentialed recovery: run 32837182820 no longer produced generation supersession and completed the write-scoped session patch. It then reproduced the second owner bug: candidate preflight accepted OPENAI_API_KEY, but isolated execution lost that selected auth and failed with no route-compatible source.
  • Auth handoff regression before the fix: 3 failures covering direct OpenAI key materialization, env-first provider behavior, and selected profile preservation.
  • Independent same-endpoint validation proved the approved OpenAI credential source with both a model-list request and a real completion; secret values were never printed or logged.
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.live.config.ts src/gateway/gateway-models.profiles.live.test.ts — 143 passed, 2 skipped.
  • node scripts/run-vitest.mjs src/gateway/server-methods/sessions-mutations.sticky-model.test.ts src/agents/live-test-helpers.test.ts — 13 passed across 2 files.
  • node scripts/run-vitest.mjs ui/src/components/markdown.test.ts — 106 passed; the complete file passed 20 consecutive runs after the bounded benchmark change.
  • node scripts/check-changed.mjs -- src/gateway/gateway-models.profiles.live.test.ts src/gateway/server-methods/sessions-mutations.sticky-model.test.ts ui/src/components/markdown.test.ts — passed the combined core/UI changed gate.
  • git diff --check origin/main...HEAD — passed.
  • Markdown CI diagnosis: checks-node-compact-large-9 timed out only in keeps appended-prefix splitting below repeated full-rescan cost; 3,395 sibling tests passed in that shard.
  • Final P1 review caught the optional ZAI fallback's remaining admin-only sessions.reset; the flow now creates its fresh Anthropic session through the same write-scoped lifecycle owner before the later write-scoped ZAI model switch. The subsequent whole-branch P1 autoreview was clean.
  • Final credentialed recovery: Release Checks 32842587971 completed success on exact head d8c766cc108ed6e90e78f1fd3cbb95ad58b20ad0. The OpenAI profile job created the write-scoped session, received successful provider responses, completed prompt and tool-read probes, and reported 145 passed / 1 skipped.
  • Production LOC: +0/-0. Live-test and test coverage: +366/-153.
  • Final exact-head PR CI and ClawSweeper status will be added before landing.

AI-assisted. I reviewed the session authorization policy, sticky model persistence owner, prepared-runtime generation fence, selected credential provenance, isolated profile construction, and regression evidence.

@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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 25, 2026
@steipete
steipete marked this pull request as ready for review August 25, 2026 10:25
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. 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
@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 6:32 AM ET / 10:32 UTC.

ClawSweeper review

What this changes

This PR changes the live Gateway profile-validation harness to request read/write scopes and use isolated session creation for model probes, avoiding sticky model writes and runtime reloads.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. The patch is a focused harness-side repair: it removes the live client’s implicit admin scope, creates fresh probe sessions per credential attempt, and leaves production sticky-model persistence admin-only; exact-head credentialed recovery evidence remains pending.

Priority: P2
Reviewed head: 990d42c5fb5c9c8999344609969e2248bb34384c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The source-level repair follows the existing scope and sticky-persistence contracts, with one material live-automation proof still pending.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-owned PR is exempt from the external-contributor proof gate; its own proposed credentialed exact-head recovery proof remains the key merge-evidence gap.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-owned PR is exempt from the external-contributor proof gate; its own proposed credentialed exact-head recovery proof remains the key merge-evidence gap.
Evidence reviewed 6 items Implicit-admin cause: The shared Gateway client defaults to operator.admin when callers omit scopes; the pre-fix live harness did omit them.
Sticky-write owner boundary: Sticky model persistence only runs for operator.admin callers with a user model override, so the proposed read/write client cannot trigger it.
Write-scoped creation contract: New sessions.create requests are write-scoped unless they carry privileged fields; the PR's model and thinking request carries none.
Findings None None.
Security None None.

Live Verification

Command: pnpm test src/gateway/server-methods/sessions-mutations.sticky-model.test.ts

Result: FAIL (partial) — step 2 expect_output sessions.patch sticky model persistence: expected terminal output was not visible within 30 seconds: "sessions.patch sticky model persistence"

pnpm test src/gateway/server-methods/sessions-mutations.sticky-model.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-129239-UjH0xk/target$ pnpm test src/gateway/server-methods/sessions-mutations.sticky-model.test.ts
$ node --import tsx scripts/test-projects.mts src/gateway/server-methods/sessions-mutations.sticky-model.test.ts
pnpm test src/gateway/server-methods/sessions-mutations.sticky-model.test.ts
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129239-UjH0xk/target

 ✓  gateway-methods  ../../src/gateway/server-methods/sessions-mutations.sticky-model.test.ts (8 tests) 1388ms
     ✓ persists an accepted model for the resolved 'main' agent  1185ms

 Test Files  1 passed (1)
      Tests  8 passed (8)
   Start at  10:33:41
   Duration  18.89s (transform 14.08s, setup 952ms, import 16.19s, tests 1.39s, environment 0ms)

[test] passed 1 Vitest shard in 25.11s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-129239-UjH0xk/target$ pnpm test src/gateway/server-methods/sessions-mutations.sticky-model.test.ts
$ node --import tsx scripts/test-projects.mts src/gateway/server-methods/sessions-mutations.sticky-model.test.ts
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129239-UjH0xk/target





























Assertions:

  • FAIL expect_output: sessions.patch sticky model persistence

How this fits together

Release profile validation starts an isolated Gateway and uses a Gateway client to select models and run provider probes. Session scope and mutation type determine whether a selection stays local or triggers the production sticky-model configuration write.

flowchart LR
A[Release profile sweep] --> B[Live Gateway client]
B --> C[Requested operator scopes]
C --> D[Session mutation]
D --> E{Admin sticky write?}
E -->|No| F[Isolated model probe]
E -->|Yes| G[Runtime reload]
F --> H[Provider validation result]
G --> H
Loading

Before merge

  • Resolve merge risk (P1) - This changes release-validation automation, but the credentialed provider-backed recovery proof described in the PR body is still pending for the exact head.
  • Complete next step (P2) - This protected maintainer PR needs exact-head live-automation evidence, not an automated repair job.
Agent review details

Security

None.

PR surface

Tests +48. Total +48 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 73 25 +48
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 73 25 +48

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +73/-25 The repair is confined to release-validation and Gateway test coverage; it does not alter shipped runtime code.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/server-methods/sessions-mutations.sticky-model.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #129237
Summary: This PR is the explicit candidate fix for the linked live-profile retry failure.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Add exact-head recovery evidence (recommended)
    Run the credentialed live profile sweep on this head and attach redacted evidence that sequential probes complete without a prepared-runtime generation supersession.

Technical review

Best possible solution:

Preserve the production admin-only sticky-selection path and land the harness-only scope/session change once an exact-head profile sweep shows sequential probes recover without superseding prepared runtimes.

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

Yes—at source level: an omitted client scope defaults to operator.admin, while the admin-only sticky persistence owner explains the observed reload path. The linked failure trace supplies the corresponding live symptom, but this review did not execute credentialed providers.

Is this the best way to solve the issue?

Yes. Narrowing only the live harness and using fresh sessions addresses the producer of the reload without weakening the production sticky-model authorization boundary.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The change addresses a reproducible release-validation failure with limited blast radius outside maintainer automation.
  • add merge-risk: 🚨 automation: The PR changes the live provider-validation harness and still needs exact-head credentialed recovery evidence.
  • 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-owned PR is exempt from the external-contributor proof gate; its own proposed credentialed exact-head recovery proof remains the key merge-evidence gap.

Label justifications:

  • P2: The change addresses a reproducible release-validation failure with limited blast radius outside maintainer automation.
  • merge-risk: 🚨 automation: The PR changes the live provider-validation harness and still needs exact-head credentialed recovery evidence.
  • 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-owned PR is exempt from the external-contributor proof gate; its own proposed credentialed exact-head recovery proof remains the key merge-evidence gap.

Evidence

What I checked:

Likely related people:

  • vincentkoc: The available current-main history and blame metadata associate this Gateway session surface with commit 76f5f84; the checkout retains only a shallow history trail. (role: recent area contributor; confidence: low; commits: 76f5f84a7c26; files: src/gateway/gateway-models.profiles.live.test.ts, src/gateway/server-methods/sessions-mutations.sticky-model.test.ts, src/gateway/session-create-service.ts)

Rank-up moves

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

  • Attach redacted exact-head credentialed profile-sweep output showing isolated sequential probes and no prepared-runtime generation supersession.

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 force-pushed the fix/gateway-live-session-scope-20260825 branch from 990d42c to d8c766c Compare August 25, 2026 11:29
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification is complete on exact head d8c766cc108ed6e90e78f1fd3cbb95ad58b20ad0.

The Release Checks failure had two harness-owned causes. The shared live client inherited operator.admin, so temporary model selection triggered intentional sticky config persistence and replaced prepared runtime generations between probes. After that was repaired, the first credentialed retry exposed a second ownership break: candidate preflight resolved a valid OpenAI credential, but the isolated Gateway discarded that prepared fact and rebuilt an empty profile-first store.

The final flow requests only read/write scopes, creates a fresh session for every credential attempt, carries the exact selected ResolvedProviderAuth into the isolated Gateway, materializes direct keys only as isolated provider profiles when the selected route requires one, and preserves selected source-profile ordering. The optional ZAI fallback now uses the same write-scoped session-creation owner and no longer invokes admin-only sessions.reset. Production sticky-selection, provider routing, host credentials, and prepared-runtime fencing are unchanged.

Proof completed:

No visual proof is applicable because this changes only release/live-test support and a test benchmark, with no UI or runtime product behavior. The current-head ClawSweeper publisher is still running and has not published additional Rank-up moves; repository policy does not block landing on a queued or late publisher after actionable findings are addressed and exact-head CI is green.

@steipete
steipete merged commit 1fdd10b into main Aug 25, 2026
185 of 187 checks passed
@steipete
steipete deleted the fix/gateway-live-session-scope-20260825 branch August 25, 2026 11:44
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
…penclaw#129239)

* fix(gateway): isolate live model session scopes

* test(ui): bound streaming markdown benchmark

* test(gateway): carry prepared live model auth into isolated profiles

* test(gateway): keep fallback sessions write-scoped
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 merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

[Bug]: Live profile retries can supersede prepared runtimes

1 participant