Skip to content

fix(gateway): first chats fail during cold storage startup - #199565

Merged
roboclaw-bot merged 12 commits into
mainfrom
openclaw/vivid-shell
Nov 15, 2026
Merged

roboclaw-bot merged 12 commits into
mainfrom
openclaw/vivid-shell

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #197510

What Problem This Solves

First chat requests can fail with storage-unavailable errors while an agent database is starting. Permissive fixture umasks also prevent Gateway tests from reaching that behavior.

User Impact

Cold chat requests retain the existing database preparation instead of rejecting its first registration. Filesystem permission, routing, lifetime and source-identity guards remain enforced. No migration or configuration change is required.

Why This Change Was Made

Wait only for an already-running first-use creator before capturing the registry witness, and classify existing-file registrations against physically qualified identities. Readiness stays in the existing fact-acquisition owner; the caller retains its lifetime and routing checks. This adds no retry or timeout increase.

Create fixture-owned .openclaw with mode 0700 before publishing its selectors. The native writable-ancestor guard is unchanged; no chmod, skip, quarantine or permission override is added.

Evidence

  • Current-head integration: PR CI 43754726962 and Security Review 43754726935 completed successfully for d8b5dc1572f7f53a0169de4a2d30cd9aabc9c4ef.
  • Real first-chat flow: fresh isolated Gateway run passed the additional selected case in 19.355s. A real first-use creator was paused before opening the absent target database; the same real WebSocket chat request observed a canonical startup refusal before handler work. After releasing the real creator, authorization acquired the target, agent.wait returned ok, history contained exactly one expected assistant answer, and the tracked local HTTP provider received one request. The native run ended with no suite or unhandled errors, and one-release AWS cleanup completed.

The first-chat test issues one SDK chat intent, not one wire attempt: the unmodified SDK made five wire attempts (four normal startup refusals, one handler start). No test retry wrapper, database prewarm or request-timeout change was added. This qualifies the current user flow with an explicit observation overlay; it is not an original-versus-fixed Gateway RPC RED/GREEN comparison. The owner-level causal regressions below provide that separate evidence. The provider is local and deterministic, not a live external model.

Selected first-chat native receipts and source scope

Projected from the actual selected-case and native run-end receipts; the immutable pre-release snapshot is the pause witness:

published parent: d8b5dc1572f7f53a0169de4a2d30cd9aabc9c4ef
clean observation commit: 67ff49e8d5f7a748f2b180a73e0a3333e9dff550
observation tree: 319129caca8f11801330a816a249f2519f325ed9
store absent before first use: true
before release: matching target opens=1, creator paused=true
before release: canonical startup refusals=1, handler starts=0
post-release native factory increment: 1
post-release matching target increment: 3
SDK intents=1; wire attempts=5; total startup refusals=4
handler starts=1; agent.wait=ok
persisted expected answers=1; provider requests=1
selected case=passed; suite errors=0; unhandled errors=0

The clean native observation commit is a child of this PR head, with four explicit observation/test-path changes. The production preparer is byte-identical to the PR; the fact-reader algorithm is unchanged apart from scalar publications. It is not claimed to be the unmodified published tree. Pinned Node 24.22.1 and pinned Bun 1.4.4-canary.1+191755ec1 both passed the tiny native-channel/correlation control before product work. The selected first-chat case passed; the five existing recovery cases were intentionally not selected in this additional run and are covered by the 70-case qualification below.

Only the immutable pre-release snapshot establishes the held creator. Later open counters include a normal second open; the auxiliary post-open pause flag is not a liveness observation and is excluded from qualification. Earlier probes that timed out before the required observation were rejected, not counted as causal RED.

Owner regressions, fixture isolation and scoped checks
  • Current normalized-source qualification: maintained Gateway-root compiler leaf passed with all five changed files in the actual compiler program; exact five-file type-aware lint and normal qaRuntime build passed; all 49 owner, 16 creation/settlement and five original recovered-output cases passed (70 total, zero pending).
  • Exact first-use causal RED and original repair GREEN: baseline executed the first-use regression and failed with actual registry-error provenance; the initial repair passed. The normalized run requalified the later owner/readiness simplification rather than borrowing that earlier GREEN. The separate existing-store cold-registration regression also has retained original RED/fix GREEN evidence.
  • Fixture-isolation proof: permissive-umask regression failed on 0775 versus 0700, then helper 3 + recovered-output 5 + encrypted 1 cases passed. Both fixture files remain byte-identical to that qualified source.
  • Repository-configured formatting and fresh complete five-file independent review passed. All task-owned runtime leases completed one-release cleanup.

The normalized proof used failed CI merge 3449e444e4a8733541d828e894d86ce74f83705d, with all five changed-file bytes matching this revision. Its 97dd78cc2cbd4f9dff1add734a2b316ac8d8bf31 main integration was a different whole tree; the subsequent successful current-head PR CI above, not file-byte equality, supplies integration validation.

Full-main qualification, release packaging and manual Windows/live-external-model proof are not claimed. Current-head ClawSweeper satisfaction and the native landing workflow remain required; nothing has been merged by this update.

Contributor credit

Co-authored-by: obviyus [email protected]
Co-authored-by: steipete [email protected]

Work sessions

Linked for team reference; these sessions aren’t public.

Worked on by

roboclaw-bot and others added 2 commits November 15, 2026 08:21
Create the owned state root before publishing fixture selectors so recursive
agent setup keeps it private under a permissive creation policy.

Add a real-filesystem child regression using the existing managed runner.
Runtime red/green is UNRUN; this local candidate is not publication-ready.
Original continuation and supported shared-state logging issues remain open.

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
Worked on by:
- @obviyus
- @steipete

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 2394395c-2cca-8e71-b107-d1782704b86e
@clawsweeper

clawsweeper Bot commented Nov 15, 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: XS labels Nov 15, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 15, 2026
@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Waits for existing first-use database preparation before capturing session registry facts and creates private Gateway test state.

Example: A chat targets agent:main:sharing while sessions.sqlite is being created.

  • Before: The creator's registration can invalidate the captured registry witness and reject session authorization.
  • After: Authorization joins the existing creator and validates the physically qualified database generation.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with distinct regressions, supplied Gateway behavior receipts and successful exact-head integration; the end-to-end observation uses an explicitly disclosed overlay and deterministic provider.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Self-contained receipts exercise isolated Gateway first-chat authorization across held database creation through WebSocket chat, agent completion and persisted history using a deterministic local HTTP provider; the disclosed observation overlay preserves the preparer and adds scalar fact-reader observations, with causal owner regressions supplied separately.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A first chat can be refused while its agent database opens.
Reason: The maintainer-authored direction repairs a concrete authorization-read failure while preserving existing storage and permission contracts.

Merge readiness

✅ Ready for maintainer review

This PR repairs a current cold-start ordering bug with a focused change; no actionable correctness or security defects were found.

Priority: P2
Reviewed head: d8b5dc1572f7f53a0169de4a2d30cd9aabc9c4ef

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway session authorization acquires database identity, registry and sharing facts before allowing chat or session operations.

flowchart TD
  A[WebSocket chat request] --> B[Session authorization]
  B --> C[Sharing fact acquisition]
  C --> D[Existing database preparation]
  D --> E[Registry and physical identity validation]
  E --> F[Authorized chat execution]
Loading

Technical review

Best possible solution:

Join existing first-use creation and qualify source identities before registry validation through the existing fact-acquisition owner.

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

Current main exposes both ordering failures, and the supplied causal regressions record registry-error RED/GREEN results; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The repair preserves the invariant that registration is classified against the acquired physical generation, using existing owners without retries, new state or relaxed access checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 284f555a2588.

Provenance checked

  • Session fact acquisition and registry validation keeps the original intent (2c4413a: Move necessary filesystem work through existing async owners and carry prepared facts forward without weakening physical identity or authority checks.)
  • Cold preparation ordering and replacement protection keeps the original intent (12bb616: Prevent an opener's registration from invalidating sharing acquisition while still rejecting physical database replacement.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 2c4413a adds src/gateway/session-sharing-preparation.ts:305 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2c4413a6abbf; files: src/gateway/session-sharing-preparation.ts)

PR surface

Source +24, Tests +155. Total +179 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 40 16 +24
Tests 3 155 0 +155
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 195 16 +179

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +40/-16; tests and fixtures +155/-0 The production growth orders existing preparation and validation; the added coverage protects two distinct registration timings and fixture permissions.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: Cold storage preparation can transiently refuse chat authorization; the supplied SDK flow recovers through existing startup retries.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-15T10:25:51.857Z sha 6a63973 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-15T16:02:06.065Z sha a795329 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-15T19:58:23.029Z sha d8b5dc1 :: needs maintainer review before merge. :: none

Reviewed November 15, 2026, 5:47 PM ET / 22:47 UTC (Revision 4).

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 15, 2026 10:35
roboclaw-bot and others added 4 commits November 15, 2026 12:43
Retain the existing published PR head without changing the reviewed source tree.

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
Worked on by:
- @obviyus
- @steipete

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: fa092d79-9524-8fc8-ba79-f014cd2840d0
roboclaw-bot and others added 3 commits November 15, 2026 15:56
Drop the competing skill projection delta after PR #197510 repaired that owner on main. Keep the original independently proven private fixture change only; merge retains main's skill assertions.

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
Worked on by:
- @obviyus
- @steipete

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: e8b6fdb3-8609-85b8-8d5e-d1db281a091f
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 15, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 15, 2026
@roboclaw-bot
roboclaw-bot merged commit e45fb2a into main Nov 15, 2026
179 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/vivid-shell branch November 15, 2026 22:55
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 16, 2026
…199565)

* test(gateway): create fixture state privately

Create the owned state root before publishing fixture selectors so recursive
agent setup keeps it private under a permissive creation policy.

Add a real-filesystem child regression using the existing managed runner.
Runtime red/green is UNRUN; this local candidate is not publication-ready.
Original continuation and supported shared-state logging issues remain open.

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>

* fix(gateway): keep fixture state private under permissive umasks

Worked on by:
- @obviyus
- @steipete

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 2394395c-2cca-8e71-b107-d1782704b86e

* fix(gateway): preserve retained context in skill refresh proof

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>

* fix(gateway): keep fixture state private under permissive umasks

Worked on by:
- @obviyus
- @steipete

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: fa092d79-9524-8fc8-ba79-f014cd2840d0

* fix(gateway): retain landed skill refresh coverage

Drop the competing skill projection delta after PR openclaw#197510 repaired that owner on main. Keep the original independently proven private fixture change only; merge retains main's skill assertions.

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>

* fix(gateway): keep fixture state private under permissive umasks

Worked on by:
- @obviyus
- @steipete

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: e8b6fdb3-8609-85b8-8d5e-d1db281a091f

* fix(gateway): first chats fail during cold storage startup

Worked on by:
- @obviyus
- @steipete

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
OpenClaw-Publication: 7ac9760f-b182-89d8-ba33-0e083183f2ff

---------

Co-authored-by: obviyus <[email protected]>
Co-authored-by: steipete <[email protected]>
steipete added a commit that referenced this pull request Nov 18, 2026
Preserve first-chat authorization when catalog persistence opens the selected absent database. Keep session-row, lifecycle, routing, and source-revocation guards intact. The focused bisect identifies #197510 as the first failing first-chat authorization boundary; #199565 had repaired other cold-registration orderings.

The deterministic regression is red before this fix. All 66 owning tests and three complete real Gateway reload trials pass; Codex review is clean through P2. check:changed passes every check except nine unused exports reproduced identically on exact main parent 97b03f7 and attributed to #200533, #198455, and #200817. Preserve peer cleanup scope in #201019.
steipete added a commit that referenced this pull request Nov 18, 2026
…200966)

* perf(agents): materialize selected rows for simple completions

* style: satisfy selected completion lint checks

* test: bind isolated registry measurement to concrete instances

* test: align participant custody with requester ownership

Follow #200952: Alice owns sessions she requests even when Bob supplies execution authority. Preserve autonomous agent ownership expectations. All 174 spawn-boundary, child-custody, and provenance tests pass; Codex scoped review is clean.

* fix: retain missing-session facts across database creation

Preserve first-chat authorization when catalog persistence opens the selected absent database. Keep session-row, lifecycle, routing, and source-revocation guards intact. The focused bisect identifies #197510 as the first failing first-chat authorization boundary; #199565 had repaired other cold-registration orderings.

The deterministic regression is red before this fix. All 66 owning tests and three complete real Gateway reload trials pass; Codex review is clean through P2. check:changed passes every check except nine unused exports reproduced identically on exact main parent 97b03f7 and attributed to #200533, #198455, and #200817. Preserve peer cleanup scope in #201019.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 19, 2026
…penclaw#200966)

* perf(agents): materialize selected rows for simple completions

* style: satisfy selected completion lint checks

* test: bind isolated registry measurement to concrete instances

* test: align participant custody with requester ownership

Follow openclaw#200952: Alice owns sessions she requests even when Bob supplies execution authority. Preserve autonomous agent ownership expectations. All 174 spawn-boundary, child-custody, and provenance tests pass; Codex scoped review is clean.

* fix: retain missing-session facts across database creation

Preserve first-chat authorization when catalog persistence opens the selected absent database. Keep session-row, lifecycle, routing, and source-revocation guards intact. The focused bisect identifies openclaw#197510 as the first failing first-chat authorization boundary; openclaw#199565 had repaired other cold-registration orderings.

The deterministic regression is red before this fix. All 66 owning tests and three complete real Gateway reload trials pass; Codex review is clean through P2. check:changed passes every check except nine unused exports reproduced identically on exact main parent 4dca39a and attributed to openclaw#200533, openclaw#198455, and openclaw#200817. Preserve peer cleanup scope in openclaw#201019.
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…200966)

* perf(agents): materialize selected rows for simple completions

* style: satisfy selected completion lint checks

* test: bind isolated registry measurement to concrete instances

* test: align participant custody with requester ownership

Follow #200952: Alice owns sessions she requests even when Bob supplies execution authority. Preserve autonomous agent ownership expectations. All 174 spawn-boundary, child-custody, and provenance tests pass; Codex scoped review is clean.

* fix: retain missing-session facts across database creation

Preserve first-chat authorization when catalog persistence opens the selected absent database. Keep session-row, lifecycle, routing, and source-revocation guards intact. The focused bisect identifies #197510 as the first failing first-chat authorization boundary; #199565 had repaired other cold-registration orderings.

The deterministic regression is red before this fix. All 66 owning tests and three complete real Gateway reload trials pass; Codex review is clean through P2. check:changed passes every check except nine unused exports reproduced identically on exact main parent 97b03f7 and attributed to #200533, #198455, and #200817. Preserve peer cleanup scope in #201019.

(cherry picked from commit 8610cd6)

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…penclaw#200966)

* perf(agents): materialize selected rows for simple completions

* style: satisfy selected completion lint checks

* test: bind isolated registry measurement to concrete instances

* test: align participant custody with requester ownership

Follow openclaw#200952: Alice owns sessions she requests even when Bob supplies execution authority. Preserve autonomous agent ownership expectations. All 174 spawn-boundary, child-custody, and provenance tests pass; Codex scoped review is clean.

* fix: retain missing-session facts across database creation

Preserve first-chat authorization when catalog persistence opens the selected absent database. Keep session-row, lifecycle, routing, and source-revocation guards intact. The focused bisect identifies openclaw#197510 as the first failing first-chat authorization boundary; openclaw#199565 had repaired other cold-registration orderings.

The deterministic regression is red before this fix. All 66 owning tests and three complete real Gateway reload trials pass; Codex review is clean through P2. check:changed passes every check except nine unused exports reproduced identically on exact main parent 97b03f7 and attributed to openclaw#200533, openclaw#198455, and openclaw#200817. Preserve peer cleanup scope in openclaw#201019.

(cherry picked from commit 8610cd6)
Release adaptation: approved 2026.11.7 models replay; see models-hook-safe-v2/REPORT.md.
Co-authored-by: RomneyDa <[email protected]>
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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