Skip to content

fix: speed up short session links in large stores - #146803

Merged
steipete merged 5 commits into
mainfrom
codex/prefilter-short-session-resolution
Sep 13, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/prefilter-short-session-resolution

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Short session links spend unnecessary CPU projecting and sorting unrelated sessions as the session inventory grows.

User Impact

Short session links resolve with less synchronous work in large stores while preserving visibility, archived-session access, agent scoping, child-owner filtering, and collision handling.

Why This Change Was Made

The existing selector now filters by UUID prefix and visibility before projecting owner display data and sorting candidates. Slug narrowing and the stable ambiguity order remain with their existing owners. This optimization covers selection after session metadata loading.

The CI prerequisite moves all 30 managed-worktree test roots from agents-other into the existing agents-tools graph. This restores headroom at 672 and 416 roots while preserving all 18 graphs, the 700-root guard, the 720-root hard cap, stripe assignments, and compiler concurrency. The existing inventory regression still requires every canonical root exactly once. Two sidebar scope tests also switch directly to the canonical deferred helper after its former re-export was retired; their assertions are unchanged.

Evidence

  • Committed-test coverage: 85 canonical selector, store, and registered-handler tests passed for the selection change. The added handler case covers archived short-ID matches selected by spawnedBy with a stale slug.
  • Retained local benchmark/control, separate from the committed CI tests: eight synthetic cases and 24 selector/privacy comparisons passed. Substituting the original resolver fails the control with 1,000 owner projections where one matching candidate is expected; the fix passes.
  • Alternating local measurements with 10,000 synthetic in-memory rows reduced median resolution time from 20.15 ms to 4.35 ms. Owner projections and sort input dropped from 10,000 rows to one. Operation-count instrumentation was disabled during timed samples.
  • With 5,000 SQLite-backed sessions and 16 KiB of synthetic saved prompt per row, warm median resolution improved from 21.95 ms to 13.60 ms. Cold resolution remained around 100 ms. These measurements cover local synthetic selection work, not production latency.
  • The resolver delta remains byte-identical to its reviewed version; 46 focused resolver/RPC and type-owner routing checks passed after adopting main's fixture repair. On the combined allocation change, all 24 inventory/selection tests and both affected real compiler graphs passed. The two sidebar test files and their real UI compiler graph also passed on the integrated branch. Formatting and whitespace checks are clean. P2 reviews cover the unchanged combined resolver/allocation patch and the exact two-import correction.

Exact published-head CI run 34747326205 passed on ae35a43d18b5bf8227788eec4a1633824cdb21c0. The browser and real-Gateway E2E lanes were skipped by this change scope. Current main independently landed the identical two sidebar import migrations in #146862.

@clawsweeper

clawsweeper Bot commented Sep 13, 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 13, 2026
@steipete steipete self-assigned this Sep 13, 2026
@steipete
steipete marked this pull request as ready for review September 13, 2026 06:34
@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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 4:24 AM ET / 08:24 UTC (Revision 6).

ClawSweeper review

What this changes

The PR filters short session-link candidates before display projection and sorting, adds archived child-selection coverage, rebalances test compiler ownership, and repairs two sidebar test imports.

Merge readiness

✅ Ready for maintainer review

The optimization remains useful: current main and the latest release still process unrelated sessions before narrowing short-ID matches. No actionable introduced defect was found, and the shared CI prerequisites do not supersede the distinct resolver improvement.

Priority: P2
Reviewed head: ae35a43d18b5bf8227788eec4a1633824cdb21c0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with preserved selection semantics, useful compatibility coverage, and reported comparative measurements.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate; its synthetic resolver and SQLite measurements support the targeted optimization without claiming production latency.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate; its synthetic resolver and SQLite measurements support the targeted optimization without claiming production latency.
Evidence reviewed 7 items Production selection preserves existing semantics: The introduced predicate combines the UUID-prefix match with the existing sharing filter. Archived access, agent and child-owner filtering, deleted-agent rejection, slug narrowing, and the ten-candidate ambiguity bound remain with their existing owners.
Existing selector supports early filtering: The selector applies entryFilter before candidate processing and owner projection. Short-ID resolution supplies no profile-reference option, so supplying this predicate does not activate a different profile-selection contract. Sorting remains pairwise and deterministic.
Current main and release still need the optimization: Inspected the resolver on fetched main and v2026.9.4; both filter UUID prefixes and sharing visibility after filterAndSortSessionEntries. The release inspection used git show v2026.9.4:src/gateway/sessions-resolve.ts. No merged replacement is established by the supplied related context.
Findings None None.
Security None None.

How this fits together

The Gateway resolves short session links against stored session metadata and the caller’s visibility rules. It returns a matching conversation, a bounded list of ambiguous candidates, or a missing-session result to the client.

flowchart LR
 A[Short session link] --> B[Gateway resolver]
 C[Stored session metadata] --> B
 B --> D[Prefix and visibility filters]
 D --> E[Project and sort candidates]
 E --> F[Apply slug hint]
 F --> G[Matching session or ambiguity]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +3, Tests +30, Docs 0. Total +33 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 1 8 5 +3
Tests 5 38 8 +30
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 47 14 +33

Review metrics

Metric Value Why it matters
Compiler ownership 30 test roots reassigned; 18 graphs retained The prerequisite restores compiler headroom without relaxing inventory limits or expanding graph concurrency.

Technical review

Best possible solution:

Keep candidate narrowing inside the shared selector while preserving the existing visibility, ordering, and URL-resolution contracts.

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

Yes, from source: resolving one short-ID match in a large store currently projects and sorts unrelated eligible rows before narrowing. This review did not execute the benchmark.

Is this the best way to solve the issue?

Yes. The existing selector already supports early predicates, so moving candidate narrowing there avoids a second implementation or cache while retaining established behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2acbeee46147.

Labels

Label justifications:

  • P2: This is a bounded performance improvement for resolving short links 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 maintainer-authored PR is exempt from the external-contributor proof gate; its synthetic resolver and SQLite measurements support the targeted optimization without claiming production latency.

Evidence

What I checked:

  • Production selection preserves existing semantics: The introduced predicate combines the UUID-prefix match with the existing sharing filter. Archived access, agent and child-owner filtering, deleted-agent rejection, slug narrowing, and the ten-candidate ambiguity bound remain with their existing owners. (src/gateway/sessions-resolve.ts:149, ae35a43d18b5)
  • Existing selector supports early filtering: The selector applies entryFilter before candidate processing and owner projection. Short-ID resolution supplies no profile-reference option, so supplying this predicate does not activate a different profile-selection contract. Sorting remains pairwise and deterministic. (src/gateway/session-utils-list.ts:198, ae35a43d18b5)
  • Current main and release still need the optimization: Inspected the resolver on fetched main and v2026.9.4; both filter UUID prefixes and sharing visibility after filterAndSortSessionEntries. The release inspection used git show v2026.9.4:src/gateway/sessions-resolve.ts. No merged replacement is established by the supplied related context. (src/gateway/sessions-resolve.ts:138, 2acbeee46147)
  • Behavioral coverage and review continuity: The added registered-handler case checks two archived colliding IDs selected by spawnedBy despite a stale slug. Existing resolver tests cover scoping, deleted agents, ambiguity bounds, and slug ties. Comparing the prior reviewed SHA with HEAD showed no resolver or handler-test changes; the prior review listed no findings. (src/gateway/server-methods/sessions-read.test.ts:330, ae35a43d18b5)
  • Test ownership and helper migration: All 30 managed-worktree test files move from the agents-other exclusion boundary into agents-tools inclusion. The existing inventory test still enforces exactly-once ownership and the 700-root target; the 720-root hard cap and graph definitions are unchanged. Both sidebar imports resolve to the canonical deferred helper without changing assertions. (test/tsconfig/tsconfig.core.test.agents-tools.json:11, ae35a43d18b5)
  • Performance evidence and its scope: The captured PR body reports alternating synthetic in-memory measurements of 20.15 to 4.35 ms and SQLite-backed warm measurements of 21.95 to 13.60 ms, plus a failing original-resolver operation-count control. These are contributor-reported local measurements, not independently rerun production latency. Downloaded screenshots belong to fix(ui): stop repeated background metadata reads across chat panes #146685 and show its UI state, not this resolver’s timing. Tests were not executed during this read-only review. (ae35a43d18b5)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (5 earlier review cycles)
  • reviewed 2026-09-13T06:39:54.018Z sha 3c36aa6 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T07:07:47.395Z sha b1faa3a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T07:22:25.254Z sha b1faa3a :: blocked before merge. :: none
  • reviewed 2026-09-13T07:34:48.923Z sha a737db7 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T07:54:58.052Z sha a737db7 :: needs maintainer review before merge. :: none

Move the complete managed worktree test family into the existing agents-tools graph. Preserve all canonical roots, graph identities, stripe assignments, compiler concurrency, and the existing 700-root target and 720-root cap.
Use the canonical createDeferred helper in the two remaining sidebar scope tests after the shared helper export was retired. Preserve the existing scope-replacement assertions.
@steipete
steipete merged commit 2e0bfa1 into main Sep 13, 2026
192 of 193 checks passed
@steipete
steipete deleted the codex/prefilter-short-session-resolution branch September 13, 2026 08:34
@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 14, 2026
* perf(gateway): filter short session matches before projection

* fix(ci): restore agent test graph headroom

Move the complete managed worktree test family into the existing agents-tools graph. Preserve all canonical roots, graph identities, stripe assignments, compiler concurrency, and the existing 700-root target and 720-root cap.

* fix(test): complete sidebar deferred helper migration

Use the canonical createDeferred helper in the two remaining sidebar scope tests after the shared helper export was retired. Preserve the existing scope-replacement assertions.
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