Skip to content

fix(gateway): session lists stall after identity-scope changes - #156339

Merged
steipete merged 2 commits into
mainfrom
codex/team-auth-reload-session-facts
Sep 23, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/team-auth-reload-session-facts

Conversation

@steipete

@steipete steipete commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: session lists repeat expensive database reads and row rebuilding when an operator changes identity scopes and clients reconnect.

User Impact

Identity-scope-only hot reloads retain already prepared session data while applying the current access policy. Changes that affect session data, model facts, or resolution provenance still refresh it. There are no schema changes, migrations, new settings, or required operator actions.

Why This Change Was Made

Config publication previously invalidated every resident row even when only identity scopes changed. During the ensuing model-runtime replacement, a temporarily unavailable catalog could cause another rebuild before the identical completed catalog returned.

The projection now advances its config without invalidating unchanged rows for that narrowly checked change. It also retains loaded catalog facts until the model owner's existing replacement promise settles, including failure and supersession. Permission revocation, current authorization, forced invalidation, same-object publications, and queued session writes keep their existing owners and behavior.

Evidence

  • The registered sessions.list regression failed before the fix by rereading unchanged live and archived rows. It now covers scope addition/change/removal, a concurrent committed session change, changed model facts and resolution provenance, forced invalidation, and same-object publication.

  • A synthetic managed reload exercised secrets publication, hot reload, prepared-model replacement, the resident projection, and 19 concurrent registered list calls. Before catalog retention it performed four row reads and three materializations for two sessions; afterward both counts are zero, with the same returned rows and model facts. Providers and service handles were synthetic; this did not boot real Gateway sockets or the installed plugin inventory.

  • A separate 4,000-session snapshot-publication reproduction went from 63 worker batches rereading and rebuilding all 4,000 rows to zero rereads and rebuilds. This establishes eliminated work, not a calibrated production latency claim.

  • 127 focused tests pass across session projection, connection-policy revocation, model lifecycle, auth reload, and catalog publication. Fresh independent review found no actionable P0–P2 defects. Production typechecking passed. Initial CI caught four scope-array inference errors in the new test fixture; the fixture now uses the canonical operator-scope type and explicit config types. Its exact gateway-methods typecheck and registered regression pass locally, and the test-only correction has a fresh clean review. The full changed-file gate now passes, including production and all 25 test type graphs, lint/format, dead exports, import cycles, and repository guards. Hosted CI run 35836666118 passes on head 4e7d100069437675ee0d1af0ba64e5e1d6b12147 (128 successful jobs, 16 intentional skips). The completed exact-head ClawSweeper review reports no correctness or security findings; its proof request is addressed below.

  • Integration with main e331b970664a4f8b923e136e348b0e47f98cbe81, which includes the registry-refresh fix in fix(gateway): stop session refresh loops and reuse run indexes #156268, passes all three selected regressions together: identity-scope reload, pending catalog replacement, and persisting an already-absent registry run. The integration used the exact reviewed PR diff and an independent frozen dependency installation; source fingerprints remained unchanged. Wall time was 43.19 seconds, including 12.317 seconds of compiler preparation.

Test cost, measured with pnpm test <file> --maxWorkers=1: the new registered-handler test takes 1.291 seconds in its body and 20.696 seconds wall including a 12.119-second compiler-cache miss; the new catalog test takes 26 ms in its body and 6.064 seconds wall. The modified existing lifecycle file passes 43 cases in 11.332 seconds wall; its changed failure-publication case takes 68 ms. Hosted CI test-body times are 983 ms for the registered-handler test, 16 ms for the catalog test, and 76 ms for the modified lifecycle case; all 43 lifecycle case bodies total 3.722 seconds (not suite wall time). The managed stress fixtures remain outside per-PR CI.

A later integration against main a1107a5217b67fbb2e4ecb27d7bc458cc3713a9c also passes: the same three Gateway regressions plus all seven auth-publication recovery cases from #156561, 10 cases across four files in 66.78 seconds. This used an independent frozen install and the exact reviewed diff, with unchanged source fingerprints.

Behavior proof and review disposition

The applicable proof is the executed Gateway boundary behavior, including the registered sessions.list handler, real SQLite workers, runtime config publication, and model-replacement lifecycle. The proof applies to the changed contract. The permanent regression fails on the original behavior and passes at this reviewed head; hosted CI independently runs these cases.

The managed-reload replay uses synthetic provider and service handles with the production publication/replacement owners and 19 concurrent registered requests. Selected fields from its recorded after-change output:

{"materializedAfterReload":0,"materialized":0,"readBatches":0,"rowKeysRead":0,"catalogEntriesEqual":true,"catalogRoutesEqual":true,"pluginRegistrySame":true,"pluginMetadataSame":true}

The corresponding before-change replay recorded four row reads and three materializations for two unchanged sessions. Current config adoption, scope revocation, changed session writes, model/provenance changes, replacement failure, and supersession have separate passing regression coverage. This demonstrates preserved output and eliminated redundant work at the affected boundary. It does not claim socket-level, installed-provider, or production latency proof.

Maintainer disposition of the generic proof request in the completed review: the recorded boundary proof applies to this internal caching change and is sufficient for its changed contract. No transport, provider protocol, or stored-data contract changes. The review identifies no missing specific behavior or code defect. Production performance verification remains a separate follow-up after an authorized deployment.

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 23, 2026 08:09
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M labels Sep 23, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 23, 2026, 6:03 AM ET / 10:03 UTC.

ClawSweeper review

What this changes

The Gateway reuses prepared session rows across identity-scope-only reloads and retains catalog facts while their replacement is pending.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this remains a distinct, useful fix absent from current main. The reviewed patch preserves the existing authorization and invalidation boundaries, and no actionable correctness defect was found.

Priority: P2
Reviewed head: 4e7d100069437675ee0d1af0ba64e5e1d6b12147

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Recorded reviewer rating: A focused repair with meaningful regression coverage and bounded before/after observations; no blocking defect was identified. Real behavior proof remains required by host policy.
Proof confidence 🌊 off-meta tidepool Recorded reviewer rating; Required by policy: the recorded not-applicable assessment does not satisfy the current PR proof policy. Put relevant after-change evidence in the main PR body, then request a fresh review with @clawsweeper re-review. Recorded reviewer context: GitHub verifies repository-admin authorship, so the external-contributor proof gate does not apply. The supplied synthetic reload observations exercise the changed production owners and registered list handler, with real sockets and installed inventory explicitly excluded. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Required by policy Required by policy: the recorded not-applicable assessment does not satisfy the current PR proof policy. Put relevant after-change evidence in the main PR body, then request a fresh review with @clawsweeper re-review. Recorded reviewer context: GitHub verifies repository-admin authorship, so the external-contributor proof gate does not apply. The supplied synthetic reload observations exercise the changed production owners and registered list handler, with real sockets and installed inventory explicitly excluded. No stored-data contract changes.
Evidence reviewed 10 items Pinned patch scope: Reviewed the introduced merge-base-to-head delta and original owner blobs. The catalog refresh extraction preserves its existing checks; the functional additions concern projection invalidation and replacement-promise observation. No Codex-specific dependency contract is involved.
Conservative config reuse: Reuse requires different config objects, changed identity scopes, equal remaining config, and equal serialized resolution provenance. Forced invalidation bypasses this path, and already queued session work remains intact.
Replacement lifetime: The catalog observes the model owner's actual replacement promise, ignores superseded settlement callbacks, resumes on success or rejection, and prevents disposed projections from being invalidated by later settlement.
Findings None None.
Security None None.

How this fits together

The Gateway’s session projection combines stored session records, configuration, and model catalog facts into rows for session-list requests. Request authorization remains separate from these cached display facts.

flowchart TD
  A[Configuration publication] --> B{Only identity scopes changed?}
  B -->|Yes| C[Retain prepared session rows]
  B -->|No| D[Refresh affected facts]
  E[Model replacement settles] --> D
  D --> C
  C --> F[Current request authorization]
  F --> G[Session list response]
Loading

Before merge

  • Add real behavior proof - Required by policy: the recorded not-applicable assessment does not satisfy the current PR proof policy. Put relevant after-change evidence in the main PR body, then request a fresh review with @clawsweeper re-review. Recorded reviewer context: GitHub verifies repository-admin authorship, so the external-contributor proof gate does not apply. The supplied synthetic reload observations exercise the changed production owners and registered list handler, with real sockets and installed inventory explicitly excluded. No stored-data contract changes.
Agent review details

Security

None.

PR surface

Source +66, Tests +275, Docs +2. Total +343 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 6 96 30 +66
Tests 3 277 2 +275
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 375 32 +343

Review metrics

Metric Value Why it matters
Reported reload work 4,000 sessions: 63 worker batches → 0 The supplied replay measures avoided database and materialization work without claiming calibrated production latency.

Technical review

Best possible solution:

Keep cache reuse confined to unchanged session facts, with current access policy and model-replacement settlement controlled by their existing owners.

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

Yes, from source: current main broadly invalidates resident rows on identity-scope publication and can adopt an unavailable catalog during replacement. The registered-handler regression targets that path; this review did not execute it.

Is this the best way to solve the issue?

Yes. The patch extends the existing projection and lifecycle owners with narrowly guarded reuse, without adding settings, persisted state, or a competing authorization path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6b4ebc043bc8.

Labels

Label changes:

  • add P2: This fixes bounded session-list stalls and redundant work after an operator changes identity scopes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit. This is the recorded reviewer rating; real behavior proof remains required by host policy.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Required by policy: the recorded not-applicable assessment does not satisfy the current PR proof policy. Put relevant after-change evidence in the main PR body, then request a fresh review with @clawsweeper re-review. Recorded reviewer context: GitHub verifies repository-admin authorship, so the external-contributor proof gate does not apply. The supplied synthetic reload observations exercise the changed production owners and registered list handler, with real sockets and installed inventory explicitly excluded. No stored-data contract changes.

Label justifications:

  • P2: This fixes bounded session-list stalls and redundant work after an operator changes identity scopes.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit. This is the recorded reviewer rating; real behavior proof remains required by host policy.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Required by policy: the recorded not-applicable assessment does not satisfy the current PR proof policy. Put relevant after-change evidence in the main PR body, then request a fresh review with @clawsweeper re-review. Recorded reviewer context: GitHub verifies repository-admin authorship, so the external-contributor proof gate does not apply. The supplied synthetic reload observations exercise the changed production owners and registered list handler, with real sockets and installed inventory explicitly excluded. No stored-data contract changes.

Evidence

What I checked:

  • Pinned patch scope: Reviewed the introduced merge-base-to-head delta and original owner blobs. The catalog refresh extraction preserves its existing checks; the functional additions concern projection invalidation and replacement-promise observation. No Codex-specific dependency contract is involved. (src/agents/prepared-model-runtime.ts:433, 4e7d10006943)
  • Conservative config reuse: Reuse requires different config objects, changed identity scopes, equal remaining config, and equal serialized resolution provenance. Forced invalidation bypasses this path, and already queued session work remains intact. (src/gateway/session-row-projection-config.ts:11, 4e7d10006943)
  • Replacement lifetime: The catalog observes the model owner's actual replacement promise, ignores superseded settlement callbacks, resumes on success or rejection, and prevents disposed projections from being invalidated by later settlement. (src/gateway/session-row-projection-catalog.ts:43, 4e7d10006943)
  • Authorization remains independent: Auth-policy generations still include identityScopes. Authenticated request dispatch checks current client authority before sending responses, independently of retained projection rows; the patch does not alter those checks. (src/gateway/server/ws-connection/authenticated-request-dispatch.ts:238, 4e7d10006943)
  • Meaningful regression coverage: The registered sessions.list test covers scope addition/change/removal, committed row updates, model changes, resolution provenance, forced invalidation, and same-object publication. Catalog coverage separately checks replacement supersession and failure. Tests were inspected, not executed in this read-only review. (src/gateway/server-methods/sessions-list-config.test.ts:30, 4e7d10006943)
  • Still necessary on main: Fetched main still broadly invalidates config changes and lacks replacement-promise retention in the catalog. The latest supplied release does not contain this projection-catalog path; no shipped equivalent fix was established. (src/gateway/session-row-projection-catalog.ts:66, 6b4ebc043bc8)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 merged commit 11867ab into main Sep 23, 2026
235 of 237 checks passed
@steipete
steipete deleted the codex/team-auth-reload-session-facts branch September 23, 2026 15:17
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 24, 2026
…law#156339)

* fix(gateway): retain session facts across identity-scope reloads

* test(gateway): preserve operator scope types in reload fixtures
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
@VACInc

VACInc commented Sep 27, 2026

Copy link
Copy Markdown
Member

Complementary follow-up: #159939 has merged. This PR retains prepared session rows and catalog facts during identity-scope reloads; the follow-up preserves verified WebSocket connections and accepted runs when another login's grants change. The fixes address different effects of the same reload, and neither replaces the other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants