Skip to content

fix: preserve concurrent session creation across agents - #158380

Closed
steipete wants to merge 1 commit into
mainfrom
codex/session-create-store-admission
Closed

steipete wants to merge 1 commit into
mainfrom
codex/session-create-store-admission

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #158379

What Problem This Solves

Fixes session creation returning “session access facts unavailable” when another agent opens its first store concurrently.

User Impact

Users can create sessions for different agents concurrently without unrelated store registration discarding an in-progress creation's prepared access facts.

Why This Change Was Made

Committed store notifications now identify the affected agent and database paths. Prepared session facts can retain their existing reads when that publication is unrelated to every captured source. Same-agent changes, overlapping files or store families, unknown changes, and existing lifecycle and registry guards still invalidate those facts.

No schema, stored data, permissions, or update migration changes are required.

Evidence

  • The authenticated Gateway RPC regression fails on the unchanged base: the second agent's creation succeeds, then the pending first creation returns UNAVAILABLE.
  • All 45 focused tests pass on Node 24.19.0: session creation, prepared sharing facts, registration commit/rollback, recovery, and row publications.
  • Independent review completed with no actionable P0–P2 findings. Required changed-code checks and PR CI remain pending.
  • Test cost: two added cases reuse existing fixtures and take approximately 4.4 seconds and 0.3 seconds in the Linux run. The existing registry publication case now covers every removed store. The five-file run took 303 seconds including worker compilation and test transforms.

@clawsweeper

clawsweeper Bot commented Sep 25, 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: M labels Sep 25, 2026
@steipete
steipete marked this pull request as ready for review September 25, 2026 22:07
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Store-change notifications identify the affected agent and database files so creating another agent’s first session does not invalidate an unrelated pending creation.

Example: Create sessions for main and ops while main’s sharing read is paused.

  • Before: The ops creation succeeds, but main returns UNAVAILABLE.
  • After: Both creations succeed and persist their returned session IDs in separate canonical agent stores.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The repair has useful boundary coverage, but its custom-store behavior remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Verified repository administrator authorship exempts this PR from the external proof gate. The reported focused run exercises authenticated Gateway creation with real SQLite workers in an isolated harness for canonical stores; custom registry-backed creation remains uncovered. The diff changes runtime notifications and validation only, with no persisted format or migration change.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Creating sessions for two agents concurrently can reject one valid creation with an unavailable-storage error.
Reason: Preserving unrelated session creations restores an established behavior without adding configuration or permissions. The area owner proposed the repair, but custom registry-backed stores remain affected at the pinned head.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep open: the prior custom-store finding remains unresolved. Current main has a newer scoped registry implementation, but no formally linked replacement establishes grounds to close this maintainer-owned work.

Priority: P2
Reviewed head: 613636dd11bb282b214fd6c7e1c0b52f7a76c552

Before merge

  • Preserve registry-backed reads for unrelated custom stores (P2) - With a supported custom session.store template such as custom/{agentId}/sessions.json, discovery requests registry rows and retains current.assertCurrent. Another agent’s registration replaces the global registry memo. This new early return skips notification invalidation, but the later assertSource still calls the captured registry assertion and rejects the pending creation with UNAVAILABLE. Scope registry validation to the captured sources as well, and extend the authenticated held-read regression to this layout. This is the still-unfixed finding from the previous review.
  • Complete next step - Resolve the GitHub-reported conflict using current main’s shared registry and topology contracts.

Findings

  • [P2] Preserve registry-backed reads for unrelated custom stores — src/gateway/session-sharing-preparation.ts:140-141

Tests

  • Missing end-to-end proof: The authenticated held-read creation scenario with a custom session.store template still needs a base-failing and repaired-head-passing result; this review could not execute tests.
Agent review details

How this fits together

The Gateway prepares session storage and access facts before creating a session. Database registration notifications determine whether those prepared facts remain valid until the creation commits.

flowchart LR
A[Authenticated session creation] --> B[Discover agent stores]
B --> C[Prepare access facts]
D[Database registration] --> E[Check affected agent and files]
E --> C
C --> F[Validate captured sources]
F --> G[Create session or return unavailable]
Loading

Technical review

Best possible solution:

Reuse main’s shared registry witness and preserve focused concurrent-creation coverage for canonical and custom store layouts.

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

No current-main failing run was established. The supplied held-read Gateway regression defines the original failure, while inspected main now uses a source-scoped registry witness.

Is this the best way to solve the issue?

No, the pinned implementation is incomplete: filtering notifications leaves custom discovery’s global registry assertion unchanged. Main’s shared registry owner provides the narrower integration path.

Full review comments:

  • [P2] Preserve registry-backed reads for unrelated custom stores — src/gateway/session-sharing-preparation.ts:140-141
    With a supported custom session.store template such as custom/{agentId}/sessions.json, discovery requests registry rows and retains current.assertCurrent. Another agent’s registration replaces the global registry memo. This new early return skips notification invalidation, but the later assertSource still calls the captured registry assertion and rejects the pending creation with UNAVAILABLE. Scope registry validation to the captured sources as well, and extend the authenticated held-read regression to this layout. This is the still-unfixed finding from the previous review.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 24ca81d55bce.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduced change: The introduced diff adds scoped store notifications and skips unrelated notifications without changing registry snapshot validation. (src/gateway/session-sharing-preparation.ts:140, 613636dd11bb)
  • Unresolved registry-backed discovery: Custom-store discovery retains current.assertCurrent, and assertSource invokes that registry assertion when consuming the prepared facts. The registry assertion rejects any replacement of its captured process memo. (src/gateway/session-sharing-preparation.ts:359, 613636dd11bb)
  • Global registry generation: Registration changes the process-wide registry memo; snapshot assertions reject a different memo even when the changed database is unrelated to the captured custom-store family. (src/state/openclaw-agent-db-registry-listing.ts:327, 613636dd11bb)
  • Meaningful Gateway regression: The added test drives authenticated sessions.create requests through WebSockets, pauses an actual worker sharing read, and checks both persisted session IDs. Its store template uses agents/{agentId}/sessions, which bypasses the remaining custom-store registry dependency. (src/gateway/server.sessions.create.stores.test.ts:37, 613636dd11bb)
  • Re-review continuity: The previous completed review raised the same registry-backed custom-store finding. The pinned head remains 613636d, matching the earlier recorded review head. (613636dd11bb)
  • Current-main successor implementation: Current main validates registry publications through a shared source-scoped registry witness. Its mutation filter distinguishes unrelated sources from captured files, physical aliases, and discovered families; this addresses the branch’s missing registry integration at the source level. (src/config/sessions/session-store-target-inventory.ts:180, 24ca81d55bce)

Likely related people:

  • Shakker: Raw commit 65e49fa adds src/gateway/session-sharing-preparation.ts:88 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 65e49fa2008c; files: src/gateway/session-sharing-preparation.ts)

PR surface

Source +65, Tests +141. Total +206 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 75 10 +65
Tests 3 143 2 +141
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 218 12 +206

Review metrics

Metric Value Why it matters
Production and test growth production +65 net lines; tests +141 net lines The original fix scopes existing publication owners, with most growth devoted to behavioral regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #158379
Summary: This PR explicitly targets the canonical concurrent first-session creation report.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A specific concurrent multi-agent creation ordering fails on the branch’s base, and the proposed repair remains incomplete for custom stores.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-25T22:14:47.448Z sha 613636d :: needs changes before merge. :: [P2] Preserve registry-backed reads for unrelated custom stores
  • reviewed September 26, 2026, 9:46 PM ET / September 27, 2026, 01:46 UTC (Revision 2) sha unknown :: blocked before merge. :: [P2] Preserve registry-backed reads for unrelated custom stores

Reviewed October 9, 2026, 11:29 AM ET / 15:29 UTC (Revision 3).

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Superseded by #163030 (9fc095c) and #169249 (b1cadee). Current main scopes both registry notifications and retained discovery assertions to the captured sources, including physical aliases/custom-store families, rather than only filtering notifications. Existing preparation/creation tests cover unrelated agent creation/deletion through persisted session and transcript creation; retained-read tests cover unrelated registry changes. The exact overlapping WebSocket fixture remains useful optional coverage, but the production repair is already owned by main. This conclusion is source/test inspection, not a fresh runtime replay.

@RomneyDa
RomneyDa deleted the codex/session-create-store-admission branch October 22, 2026 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Concurrent first-session creation fails when another agent opens its store

2 participants