Skip to content

fix: avoid slow incognito key checks in large session stores - #139528

Merged
steipete merged 1 commit into
mainfrom
codex/incognito-existence-metadata-20260905
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/incognito-existence-metadata-20260905

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where checking an explicit incognito session key performs unnecessary synchronous work as the durable session store grows.

Why This Change Was Made

Use the existing metadata listing for the durable collision check and consume its keys synchronously without cloning entries. Keep the same durable-store scope, canonical validation, malformed-row handling, and separate process-local existence check.

User Impact

Incognito key checks avoid decoding unrelated saved prompts. Collision rejection and incognito session lifecycle behavior stay unchanged. Listing still visits session metadata; this change adds no cache, schema, configuration, or public API.

Evidence

A synthetic source-service probe with 100 and 1,000 unrelated saved prompts reduced prompt decodes from 100/1,000 to zero. All eight actual service response cases, including normalized aliases and durable/process-local collisions, matched the baseline. Both readers retained the same fresh-handle malformed-row error.

The existing incognito create/list/spawn/reset/delete test now also checks that collision detection does not parse an unrelated saved prompt. It failed for that assertion on the baseline and passes with this change. All 162 tests in the complete creation suite passed. Exact-head CI succeeded, and the supplemental deprecated-API, database-first, media-helper, and runtime-sidecar audits passed. Independent review found no actionable issues.

A compiled Linux Node 26.7 Gateway using the reviewed source tree passed nine real RPC operations: normalized explicit creation, three process-local reuse aliases, another creation, listing, reset, deletion, and confirmation that the sessions were gone. All 1,000 unrelated durable prompts remained intact; no incognito session nodes or windows were written to disk. Source/build/process bindings, unchanged file hashes, and graceful process closure were independently verified.

The reader probe is not a whole-Gateway latency benchmark and does not use a live model provider. Warm legacy durable-collision and malformed-row cases are covered separately by the source-service proof. A duplicate local changed-check run was cancelled after exact-head CI coverage was verified; it is not reported as a passing local full run.

@clawsweeper

clawsweeper Bot commented Sep 5, 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 maintainer Maintainer-authored PR labels Sep 5, 2026
@steipete
steipete marked this pull request as ready for review September 5, 2026 23:54
@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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 8:33 PM ET / September 6, 2026, 00:33 UTC.

ClawSweeper review

What this changes

Use existing session metadata to check explicit incognito keys without decoding unrelated saved prompts, and extend the session lifecycle regression test.

Merge readiness

✅ Ready for maintainer review

The optimization remains useful on current main, and no actionable correctness or security defect was found. The maintainer-authored PR has a focused implementation and relevant reported validation.

Priority: P2
Reviewed head: d5c0b8abd23999ba5e07fe2adaa6fbbdbfcdec79

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair using an established reader contract, with meaningful regression coverage and relevant reported runtime validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. Supplemental evidence reports the changed creation service preserving eight response cases and nine real Gateway RPC operations with 1,000 durable prompts; these observations were not independently rerun.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. Supplemental evidence reports the changed creation service preserving eight response cases and nine real Gateway RPC operations with 1,000 durable prompts; these observations were not independently rerun.
Evidence reviewed 8 items Verified introduced change: The merge-base-to-head diff adds only the existing list projection and borrowing options to the collision reader, plus regression coverage; unrelated base-branch changes are excluded.
Current main still needs this optimization: Fetched main still calls the collision reader without a projection, selecting the full-read default. The nearby creation optimization associated with #139529 adds selective full-entry reads elsewhere but does not change this call. Release inclusion of this PR was not established.
Existing projection preserves the key-check contract: The metadata selector removes saved prompt fields while retaining malformed JSON for normal parsing. Both projections use canonical validation, and the listing filters and validates the same session keys. Borrowed entries are consumed synchronously without mutation.
Findings None None.
Security None None.

How this fits together

The Gateway creates incognito conversations in process memory. Before creating an explicitly named conversation, it checks durable and process-local sessions to prevent key reuse.

flowchart TD
  A[Session creation request] --> B[Normalize and validate key]
  B --> C[Read durable session metadata]
  C --> D[Check durable and process-local collisions]
  D --> E[Reject existing key]
  D --> F[Continue authorized incognito creation]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +2, Tests +14. Total +16 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 0 +2
Tests 1 27 13 +14
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 29 13 +16

Review metrics

None.

Technical review

Best possible solution:

Keep collision detection on the existing metadata reader while preserving canonical validation, process-local checks, and saved prompt contents.

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

Yes, from source: explicit incognito creation on current main requests full durable entries, causing unrelated saved prompts to be decoded. This review did not execute the reported probes.

Is this the best way to solve the issue?

Yes. Reusing the existing metadata projection is a narrow repair; the simpler keys-only reader would bypass validation behavior retained by this approach.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 652738ca86cc.

Labels

Label justifications:

  • P2: This is a bounded Gateway performance improvement for explicit incognito creation in large session stores.
  • 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: The external-contributor proof gate does not apply to this MEMBER-authored PR. Supplemental evidence reports the changed creation service preserving eight response cases and nine real Gateway RPC operations with 1,000 durable prompts; these observations were not independently rerun.

Evidence

What I checked:

  • Verified introduced change: The merge-base-to-head diff adds only the existing list projection and borrowing options to the collision reader, plus regression coverage; unrelated base-branch changes are excluded. (src/gateway/session-create-service.ts:506, d5c0b8abd239)
  • Current main still needs this optimization: Fetched main still calls the collision reader without a projection, selecting the full-read default. The nearby creation optimization associated with fix(sessions): avoid pauses decoding unrelated prompts during creation #139529 adds selective full-entry reads elsewhere but does not change this call. Release inclusion of this PR was not established. (src/gateway/session-create-service.ts:506, 652738ca86cc)
  • Existing projection preserves the key-check contract: The metadata selector removes saved prompt fields while retaining malformed JSON for normal parsing. Both projections use canonical validation, and the listing filters and validates the same session keys. Borrowed entries are consumed synchronously without mutation. (src/config/sessions/session-accessor.sqlite-status.ts:25, d5c0b8abd239)
  • Regression coverage retains lifecycle and collision assertions: The complete affected test retains process-local storage, parent restrictions, list/reset/delete behavior, and durable collision rejection. The added assertion detects decoding an unrelated persisted prompt and restores the JSON parser spy in finally. (src/gateway/server.sessions.create.test.ts:1279, d5c0b8abd239)
  • Storage review checkpoint does not require a new design: The documented checkpoint exempts read-only queries preserving existing semantics. This patch uses an existing projection without changing schemas, persisted data, authorization, or public APIs. Public docs: docs/reference/database-schemas.md. (docs/reference/database-schemas.md:386, d5c0b8abd239)
  • Captured validation and review continuity: The supplied body reports zero unrelated prompt decodes at 100 and 1,000 rows, eight matching service responses, unchanged malformed-row errors, a baseline-failing regression assertion, and nine compiled Linux Gateway RPC operations preserving all durable prompts. These are contributor-reported results, not reviewer executions. The previous review at the same head retained no findings or published rank-up moves. (d5c0b8abd239)

Likely related people:

  • steipete: 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-06T00:00:29.670Z sha d5c0b8a :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 7ac43e8 into main Sep 6, 2026
254 of 255 checks passed
@steipete
steipete deleted the codex/incognito-existence-metadata-20260905 branch September 6, 2026 00:44
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 6, 2026
* origin/main: (302 commits)
  test(gateway): preserve held-work close failures (#139593)
  refactor(exec): share package argument scanning (#139560)
  fix(audit): preserve sequence range validation before numeric decoding (#139587)
  fix(transcripts): retain capture ownership through failed cleanup (#139572)
  refactor(models): share selector reference traversal (#139571)
  perf(agents): classify allowlists without intermediate sets (#138392)
  chore(release): update appcast for 2026.9.2 (#139575)
  fix(ci): synchronize cloud retries and board widget input (#139506)
  fix(plugins): explain SDK incompatibilities after core updates (#139458)
  fix(voice-call): retain installed WebSocket behavior under Bun (#139567)
  test(text): consolidate literal sanitizer cases (#139579)
  test(gateway): observe native drain without a lint exception (#139576)
  test(memory): consolidate visibility fixtures without policy defaults (#139569)
  fix(ui): show shimmer skeletons while loading Control UI (#139525)
  test(qa): make cleanup child logging deterministic (#139566)
  test(cli): keep Unix socket fixtures within path limits (#139565)
  fix: avoid slow incognito key checks in large session stores (#139528)
  feat(macos): open Gateway windows from the Gateways menu (#139522)
  test(workshop): isolate marker casing fixture identities (#139554)
  fix(process): require cleanup evidence before releasing owned work (#139517)
  ...

# Conflicts:
#	scripts/release-check.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
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 P2 Normal backlog priority with limited blast radius. 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