Skip to content

fix(gateway): avoid repeated session root scans in configured lists - #124384

Merged
steipete merged 4 commits into
mainfrom
fix/configured-list-registry
Aug 16, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/configured-list-registry

Conversation

@steipete

@steipete steipete commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Control UI clients requesting configured-only all-agent session lists repeatedly enumerated configured, retired, and manual session roots. The repeated discovery happened on a request-time hot path after 88d6a2c8d63 stopped forwarding the configured-only scope into combined-store loading.

A simple switch to configured targets would be incorrect: it would regress the configured-parent child visibility shipped in 8483d0337530, where an unconfigured child remains visible when its spawnedBy or parentSessionKey belongs to a configured agent.

Why This Change Was Made

The combined Gateway store now builds configured-only candidates from configured direct targets, the startup/runtime-seeded durable database registry, and currently open incognito databases. It deduplicates physical targets with the existing ownership rules, canonicalizes and merges rows before applying the lineage-aware configured filter, and returns authoritative prepared durable targets for sharing resolution.

Sharing enrichment seeds every logical result agent from those prepared targets. This includes a child whose logical agent differs from the configured physical database owner, preventing a fallback to request-time filesystem discovery while preserving configured-parent lineage. The prepared discovery-cache constructor lives in the existing store-lookup owner because the CI max-lines rule correctly rejects further growth in sessions-read.ts. Broad non-configured all-agent lists retain their existing directory discovery behavior. No configuration, schema, protocol, compatibility fallback, or process cache was added.

Production LOC: +133/-116 (net +17). Tests: +263/-98 (net +165). The positive production growth is the explicit prepared-target owner boundary plus the extracted cache constructor required to preserve all child-lineage cases without request-time discovery while keeping sessions-read.ts below its hard line limit.

User Impact

Operators with multiple configured agents and connected Control UI clients avoid repeated session-root scans during configured-only refreshes. Configured main and ACP sessions, configured-parent durable and incognito children, parent-owned physical-store children, and existing ownership/collision behavior remain visible as before. Retired or manual stores unrelated to configured lineage stay hidden from configured-only results and remain available in broad lists.

Evidence

  • Original pre-fix regression: 1 of 7 tests failed because one configured-only request performed four directory enumerations.
  • Original post-fix Gateway RPC regression: 7 of 7 passed with zero configured-only enumeration; the broad request still enumerated and included the unrelated local store.
  • Combined lineage coverage: 31 of 31 passed.
  • Consolidated initial validation: 117 tests passed across 10 files and 3 Vitest shards.
  • Follow-up pre-fix regression: a parent-owned physical-store child triggered one directory enumeration during sharing enrichment; the fixed request performs zero.
  • Prepared-target focused validation: 77 tests passed across 5 files; targeted core oxlint passed and final autoreview was clean.
  • Upgrade-boundary proof removes only an existing durable child database's registry row, leaves the DB intact, and runs the real startup migration discovery/open loop. Startup restores the exact registry row; the post-start configured-only read retains the configured-parent child with zero directory discovery and excludes an unrelated registered row.
  • Startup and configured-list siblings pass across 6 files and 74 tests; the new migration contract also passes independently.
  • The prior ClawSweeper P1 is addressed by explicit proof of the existing startup owner that backfills durable registry state before runtime reads.
  • Full changed gate, targeted lint, formatting, diff checks, and fresh autoreview are clean.

New exact-head CI, a fresh current-head ClawSweeper review, and the post-landing live multi-client soak are pending.

@clawsweeper

clawsweeper Bot commented Aug 16, 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: M maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 03:31
@steipete steipete self-assigned this Aug 16, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 12:40 AM ET / 04:40 UTC.

ClawSweeper review

What this changes

The PR makes configured-only Gateway session lists use prepared configured, registered, and open session-store targets instead of request-time root discovery, while preserving parent-linked child sessions.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

The PR remains necessary: current main still loads configured-only lists without forwarding that scope, then resolves sharing from an empty discovery cache. The proposed prepared-target path is a coherent owner-boundary repair, and the follow-up startup-registry test addresses the prior upgrade-visibility blocker; exact-head CI and normal maintainer review remain before merge.

Priority: P1
Reviewed head: 60823d1bdd1470611b5746fbbca548e3023b8705

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a coherent owner-boundary fix with focused regression coverage, pending routine exact-head CI completion.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-owned Gateway PR is exempt from the external-contributor proof gate; its body nevertheless records focused before/after Gateway and startup-recovery validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-owned Gateway PR is exempt from the external-contributor proof gate; its body nevertheless records focused before/after Gateway and startup-recovery validation.
Evidence reviewed 6 items Current-main bug path: Current main invokes combined-store loading without the configured-only scope and filters only afterward, so the loader cannot select prepared configured-only candidates.
Current-main discovery fallback: The current sharing lookup resolves absent cache entries through existing-store discovery, the path that can enumerate session roots for configured-list results.
Prepared-target repair: The PR forwards configured-only scope, builds candidates from the durable registry and configured targets, applies lineage filtering after canonical merge, and seeds sharing discovery from those targets.
Findings None None.
Security None None.

How this fits together

Control UI session refreshes call the Gateway’s session-list RPC, which combines durable and incognito agent stores before resolving sharing visibility. Configured-only lists must hide unrelated stores while retaining children linked to configured parents.

flowchart LR
A[Control UI refresh] --> B[Gateway session list]
B --> C{Configured-only request}
C --> D[Prepared configured and registered stores]
D --> E[Combined session rows]
E --> F[Parent and spawned-child filter]
F --> G[Sharing resolution]
G --> H[Visible session list]
Loading

Before merge

  • Resolve merge risk (P1) - Configured-only visibility now depends on durable registry recovery before runtime reads; the new startup migration regression covers the identified missing-row upgrade case, but exact-head CI should confirm the full Gateway suite.
  • Resolve merge risk (P1) - Production code grows by 17 net lines in a bug fix. The added prepared-target cache is justified by moving discovery ownership out of the request-time sharing loop; no smaller absorbing refactor was evident without restoring duplicate discovery.
  • Complete next step (P2) - This maintainer-labelled implementation PR has no mechanical review finding; complete normal exact-head CI and maintainer merge review rather than dispatching a repair lane.
Agent review details

Security

None.

PR surface

Source +17, Tests +165. Total +182 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 4 133 116 +17
Tests 9 263 98 +165
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 396 214 +182

Review metrics

Metric Value Why it matters
Production versus regression-test delta production +133/-116 (net +17); tests +263/-98 (net +165) The added production boundary moves target preparation out of request-time sharing, while the tests cover RPC visibility, parent-owned stores, incognito lineage, and startup recovery.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/config/sessions/startup-migration.registry-recovery.test.ts, persistent cache schema: src/gateway/session-utils-store-lookup.ts, serialized state: src/config/sessions/combined-store-gateway.ts, serialized state: src/config/sessions/startup-migration.registry-recovery.test.ts, serialized state: src/gateway/server-methods/sessions-read.ts, serialized state: src/gateway/server-methods/sessions-shared.ts, and 8 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge-risk options

Maintainer options:

  1. Validate the prepared-target upgrade path (recommended)
    Complete exact-head Gateway checks covering startup registry recovery, configured-parent children, and broad-list discovery before merge.
  2. Accept the scoped session-list behavior
    Merge with the documented compatibility tradeoff that configured-only lists use the startup-maintained registry rather than request-time root discovery.

Technical review

Best possible solution:

Keep one prepared-target flow shared by configured-list loading and sharing resolution, retain the startup registry-recovery regression, and merge after exact-head Gateway validation is green.

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

Yes—source shows current main loads the unscoped combined store before filtering, and the focused Gateway handler tests construct configured, child, and unrelated stores while observing directory discovery.

Is this the best way to solve the issue?

Yes—the repair moves configured-only selection to the combined-store owner and supplies those exact targets to sharing resolution; filtering only at the consumer would retain the discovery path and a direct-config-only shortcut would lose parent-linked children.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7563682c3fc3.

Labels

Label justifications:

  • P1: This changes the Gateway session-list path used by Control UI refreshes and can affect active users’ visible session set.
  • merge-risk: 🚨 compatibility: Existing durable agent stores are selected through a different configured-only target path after startup.
  • merge-risk: 🚨 session-state: The modified target set and lineage filter determine whether persisted parent and child session rows appear in the list.
  • 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 maintainer-owned Gateway PR is exempt from the external-contributor proof gate; its body nevertheless records focused before/after Gateway and startup-recovery validation.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the prior configured-child preservation and session-list performance work, and the current PR follows the same session-store ownership path. (role: session-list feature owner and recent area contributor; confidence: high; commits: 8483d0337530, 88d6a2c8d635, 60823d1bdd14; files: src/config/sessions/combined-store-gateway.ts, src/gateway/server-methods/sessions-read.ts, src/gateway/session-utils-store-lookup.ts)
  • Jason (Json): Current-main blame attributes the extracted combined-store path carrying the unforwarded configured-only scope to this recent merged change. (role: recent current-main contributor; confidence: high; commits: 5f1bbed42d4d; files: src/config/sessions/combined-store-gateway.ts, src/gateway/server-methods/sessions-read.ts)

Rank-up moves

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

  • Complete the exact-head Gateway checks before merge.

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 (2 earlier review cycles)
  • reviewed 2026-08-16T03:39:25.908Z sha 689c8ce :: found issues before merge. :: [P1] Preserve unregistered durable children on upgrade
  • reviewed 2026-08-16T04:13:15.694Z sha df5178c :: needs maintainer review before merge. :: none

@steipete steipete closed this Aug 16, 2026
@steipete steipete reopened this Aug 16, 2026
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready evidence for exact head 60823d1bdd1470611b5746fbbca548e3023b8705.

The configured-only sessions.list regression is repaired at the combined-store owner boundary: configured direct targets, the startup/runtime durable registry, and open incognito candidates are canonicalized and merged before lineage filtering, then the authoritative durable targets are reused for sharing resolution. This preserves configured-parent children without request-time root discovery. Broad lists retain their existing discovery behavior.

Local proof on this patch:

  • node scripts/run-vitest.mjs src/config/sessions/startup-migration.registry-recovery.test.ts — 1/1 passed.
  • node scripts/run-vitest.mjs src/config/sessions/startup-migration.registry-recovery.test.ts src/config/sessions/legacy-main-session-migration.startup.test.ts src/gateway/server-startup-secret-owner-isolation.test.ts src/gateway/server.sessions.store-rpc.test.ts src/gateway/server.sessions.store-paths.test.ts src/gateway/session-utils.subagent.test.ts — 74 tests passed across 6 files.
  • node scripts/run-vitest.mjs src/gateway/server.sessions.store-paths.test.ts src/gateway/server.sessions.store-rpc.test.ts src/gateway/session-utils.subagent.test.ts src/gateway/session-utils-creators.test.ts src/gateway/server-methods/sessions-read.test.ts src/gateway/server-methods/sessions-read-cache.test.ts src/gateway/session-sharing-store-cache.test.ts — 93 tests passed in the parent-owned-store follow-up; the prepared-target focused set passed 77 tests across 5 files.
  • Combined lineage coverage: 31/31 passed. Focused RPC coverage: 7/7 passed after reproducing the pre-fix configured-only enumeration failure.
  • OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 node scripts/check-changed.mjs -- <changed paths> — changed gates passed, including type, lint, max-lines, database, cycle, and architecture checks.
  • node_modules/.bin/oxfmt <changed paths> and git diff --check — clean.
  • .agents/skills/autoreview/scripts/autoreview --mode uncommitted — clean with no actionable findings; the final test-only autoreview was clean at 0.99.

Exact-head CI is completed success: https://github.com/openclaw/openclaw/actions/runs/31926923650

The current-head ClawSweeper review reports no findings. Its prior upgrade concern is addressed by the real startup recovery test: it deletes only a durable child's registry row, preserves the database, runs the existing startup discovery/open owner, verifies the exact registry row is restored before runtime reads, then confirms the configured-parent child remains visible with zero directory discovery while an unrelated row stays excluded. Its only optional rank-up move was exact-head CI, now complete.

Production LOC: +133/-116 (net +17). Tests: +263/-98 (net +165). The production growth is the prepared-target owner boundary and store-lookup extraction; the change also removes the duplicate late configured filter and duplicate fixed/template merge policy. There is no config, protocol, SQLite schema/version, or migration-format change.

Known proof gap: the live multi-client soak remains intentionally post-merge because the live environment is currently degraded. No live-soak success is claimed.

@steipete
steipete merged commit 0c7b560 into main Aug 16, 2026
194 checks passed
@steipete
steipete deleted the fix/configured-list-registry branch August 16, 2026 04:45
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

SemonCat pushed a commit to SemonCat/openclaw that referenced this pull request Aug 16, 2026
…penclaw#124384)

* fix(gateway): stop configured session rediscovery

* fix(gateway): reuse prepared child store targets

* refactor(gateway): own prepared session targets

* test(gateway): prove session registry recovery
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 17, 2026
…penclaw#124384)

* fix(gateway): stop configured session rediscovery

* fix(gateway): reuse prepared child store targets

* refactor(gateway): own prepared session targets

* test(gateway): prove session registry recovery
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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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