Skip to content

fix(gateway): skip registered agent stores no configured agent owns - #164929

Merged
steipete merged 2 commits into
mainfrom
upd/upd-post-version-serial-admission-system-agent
Oct 4, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/upd-post-version-serial-admission-system-agent

Conversation

@steipete

@steipete steipete commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Refs #164799

What Problem This Solves

A registered database left behind by an unconfigured agent can be inspected and opened during Gateway startup, causing a startup refusal or failed readiness even though configured agents can serve requests.

Why This Change Was Made

Preflight, startup-owned session projection, and startup maintenance use one configured-store predicate. Standalone session readers retain their existing behavior. Registered configured owners and explicit configured store locators remain admitted; other registered stores are skipped before runtime reads. Startup records one warning naming the database basename and Doctor guidance. Configured database inspection and Doctor/restart diagnostics retain their normal behavior.

Startup maintenance applies the skip inside its existing deletion-fenced operation, immediately before database access. Deleted-store cleanup logging runs first, and stores missing registry entries retain the existing recovery path, including durable lineage child re-registration. No reconciliation logic is duplicated.

The existing two-slot background opening bound from #164670 is preserved and covered by the HTTP fixture. No configuration, schema, dependency, worker, or cache is added.

User Impact

A corrupt unconfigured system-agent leftover no longer prevents the tested Gateway from returning /readyz 200. Its source bytes remain untouched.

Deferred lineage-probe follow-up: conversations stored only under a retired physical owner with no registry/config reference are not surfaced until re-registered. This PR deliberately does not probe session lineage. Version-bound clean-close receipts still require normal admission after a version change; the reporter's multi-GB systemd deployment and packaged 9.7↔9.8 update path have not been reproduced end to end.

Reported by @Oldrich333.

Evidence

  • The original HTTP negative control fails with AgentDatabaseAdmissionError / file is not a database. The corrected fixture returns /readyz 200, records one skip warning, preserves the corrupt bytes, and observes peak parallel opening of two configured stores after version-bound receipts are invalidated. The preflight regression covers both startup passes and keeps Doctor strict.
  • CI at b3e633835f5770ee05fc6e8f933bb17e5acc9093 exposed three registry-recovery failures in the runtime-config job. The unchanged suite reproduced all three locally (3 failed / 11 passed, 41.27s command wall time). The early configured-owner return was the regression; it bypassed retained-deletion logging and unregistered lineage recovery.
  • After moving the skip, the unchanged startup-migration.registry-recovery.test.ts, server-agent-database-startup.test.ts, and openclaw-database-preflight.startup-prepared.test.ts each passed three times: 36 tests per pass. Combined command wall times: 168.78s, 151.73s, 156.94s. The HTTP regression itself took 4.19s, 4.30s, 4.13s; the lineage recovery case took 2.83s, 2.55s, 2.85s. No tests were edited for this CI repair.
  • Fresh P1 Codex review of the staged candidate: scoped-clean, no actionable P0/P1 findings.
  • node scripts/check-changed.mjs passed in 582.59s, including all 27 test-type graphs, changed-file lint, dead-export scans, guards, and zero runtime import cycles. Final formatting and git diff --check passed.
  • All 21 direct importers are covered: registry recovery passed three times above; the remaining 20 files / 365 tests passed once through the repository wrapper. Total importer-command wall time was 1284.80s, including a fresh 13m25.8s package build. The packaged MCP seed smoke passed (3.61s test time; 15.05s file wall time).
  • Earlier importer evidence at the original PR head: the Gateway group passed 177 files / 3,563 tests (one file / three tests skipped); the complete 372-file selection did not finish. Publication proceeded under the explicit hostnote waiver.
  • Named performance follow-up (pre-existing fixtures; slow-test gate explicitly waived): src/agents/main-session-recovery/main-session-restart-recovery.test.ts took 188.888s for 150 cases; src/auto-reply/reply/session.test.ts took 128.337s for 105 cases. Both files are unchanged and passed. A CLI-auth case reported 38.766s including setup/cleanup; callback-only time was not measured.
  • Proof runs locally under the existing hostnote waiver. The earlier stopped Testbox lease produced no useful results. Local correction evidence applies to 2ebfd7fa84495cf5c35bb9852ca96a1d431ad518; hosted CI for this new head is not claimed as passed.
  • Production: +74/−30 (net +44); tests: +138/−36. This CI repair changes only production code, +13/−9. No timeout increases, retries, new skips, configuration options, schema changes, or dependencies. No rebase or force-push.

@clawsweeper

clawsweeper Bot commented Oct 4, 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.

@steipete
steipete marked this pull request as ready for review October 4, 2026 13:39
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M labels Oct 4, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 Oct 4, 2026
@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 4, 2026, 10:34 AM ET / 14:34 UTC (Revision 2).

ClawSweeper review

What this changes

Gateway startup skips registered databases without a configured owner or explicit configured store path, preserves deletion and registry recovery, and adds readiness regressions.

Regression provenance

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

Merge readiness

⛔ Blocked before merge - 4 items remain

The correction preserves registry recovery, but the Gateway projection still excludes healthy stores containing configured agents’ descendant sessions. This useful PR remains necessary and needs a focused compatibility repair.

Priority: P1
Reviewed head: 2ebfd7fa84495cf5c35bb9852ca96a1d431ad518

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused recovery correction and boundary evidence are useful, but a supported conversation-discovery path still regresses.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate. Reported real HTTP readiness and native database evidence supports leftover isolation, but does not cover retained lineage in the resident projection or the packaged update path. No stored-data model changes are introduced.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate. Reported real HTTP readiness and native database evidence supports leftover isolation, but does not cover retained lineage in the resident projection or the packaged update path. No stored-data model changes are introduced.
Evidence reviewed 11 items Pinned introduction and clean checkout: Reviewed the supplied merge-base-to-head introduced diff. Origin identifies openclaw/openclaw, and final git status remains clean. The stale test merge was not used to infer removal of main-branch work.
Registry-recovery correction: The current maintenance guard checks retained deletion first, skips only registered unconfigured stores, and retains the operation for missing registry entries. This addresses the earlier early-return mechanism described in the captured PR body.
Projection exclusion survives recovery: The introduced projection guard rejects an unconfigured physical owner without considering registration, successful recovery, or descendant lineage. The real projection requests physical-owner preservation, so this guard applies before its store reader runs.
Findings 1 actionable finding [P1] Preserve recovered lineage stores in the Gateway projection
Security None None.

How this fits together

Gateway startup inspects agent databases and prepares their sessions before serving requests. The session projection turns admitted physical stores into the conversation inventory used by Gateway clients.

flowchart TD
  A[Configured agents and store paths] --> C[Startup database selection]
  B[Registered and discovered databases] --> C
  C --> D[Configured store eligibility]
  D --> E[Database admission and maintenance]
  D --> F[Skipped store warning]
  E --> G[Gateway conversation inventory]
  E --> H[HTTP readiness]
Loading

Before merge

  • Preserve recovered lineage stores in the Gateway projection (P1) - With only ops configured, a healthy codex store can contain a child whose spawnedBy references agent:ops:main, as the existing registry-recovery test demonstrates. This guard excludes that physical store even after maintenance re-registers it. The real projection uses preserveSentinelOwners: "physical", captures the startup context, and retains it while admission is adopted by the Gateway, so the conversation remains absent after startup. The passing standalone-reader test bypasses this guard. Preserve admitted lineage stores while skipping unrelated corrupt leftovers. This is a late discovery: the projection hunk is unchanged from the earlier reviewed head.
  • Resolve merge risk (P1) - The reported packaged 9.7↔9.8 update path remains unverified; changing receipt versions in the HTTP fixture does not establish published-driver upgrade and rollback behavior.
  • Complete next step (P2) - Repair lineage-store eligibility in the real Gateway projection and establish the reported version-change compatibility before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P1] Preserve recovered lineage stores in the Gateway projection — src/config/sessions/combined-store-gateway.ts:487-492
Agent review details

Security

None.

PR surface

Source +44, Tests +102. Total +146 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 5 74 30 +44
Tests 2 138 36 +102
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 212 66 +146

Review metrics

Metric Value Why it matters
Production versus test LOC production +74/−30, tests +138/−36 Production growth is explained by a shared eligibility predicate and its startup consumers; the remaining compatibility defect is in projection consumption.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/config/sessions/startup-migration.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Preserve lineage and verify cutover (recommended)
    Repair the projection eligibility boundary, then demonstrate retained conversation inventory and readiness across the reported version-change path.

Technical review

Best possible solution:

Exclude unrelated corrupt leftovers from readiness while retaining healthy descendant conversations through the existing store-admission and projection owners.

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

Yes, from source: use the existing ops/codex lineage fixture through the real Gateway projection under startup admission; the new physical-owner predicate excludes the child store. This read-only review did not execute that failure.

Is this the best way to solve the issue?

No, the shared eligibility predicate is useful, but applying it before projection reads discards supported lineage regardless of successful registry recovery.

Full review comments:

  • [P1] Preserve recovered lineage stores in the Gateway projection — src/config/sessions/combined-store-gateway.ts:487-492
    With only ops configured, a healthy codex store can contain a child whose spawnedBy references agent:ops:main, as the existing registry-recovery test demonstrates. This guard excludes that physical store even after maintenance re-registers it. The real projection uses preserveSentinelOwners: "physical", captures the startup context, and retains it while admission is adopted by the Gateway, so the conversation remains absent after startup. The passing standalone-reader test bypasses this guard. Preserve admitted lineage stores while skipping unrelated corrupt leftovers. This is a late discovery: the projection hunk is unchanged from the earlier reviewed head.
    Confidence: 0.94
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 session-state: The new physical-owner filter excludes healthy descendant-session stores from the resident Gateway inventory.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate. Reported real HTTP readiness and native database evidence supports leftover isolation, but does not cover retained lineage in the resident projection or the packaged update path. No stored-data model changes are introduced.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: The PR addresses failed Gateway readiness affecting real users, while its projection filter can hide existing conversations.
  • merge-risk: 🚨 compatibility: Existing retained-store installations can lose previously supported discovery behavior, and packaged version-change proof remains incomplete.
  • merge-risk: 🚨 session-state: The new physical-owner filter excludes healthy descendant-session stores from the resident Gateway inventory.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate. Reported real HTTP readiness and native database evidence supports leftover isolation, but does not cover retained lineage in the resident projection or the packaged update path. No stored-data model changes are introduced.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/config/sessions/startup-migration.registry-recovery.test.ts src/gateway/server-agent-database-startup.test.ts src/state/openclaw-database-preflight.startup-prepared.test.ts --maxWorkers=1.
  • [P1] node scripts/run-vitest.mjs src/gateway/session-row-projection.registry-refresh.test.ts --maxWorkers=1.
  • [P1] node scripts/check-changed.mjs.
  • [P1] git diff --check.

What I checked:

  • Pinned introduction and clean checkout: Reviewed the supplied merge-base-to-head introduced diff. Origin identifies openclaw/openclaw, and final git status remains clean. The stale test merge was not used to infer removal of main-branch work. (2ebfd7fa8449)
  • Registry-recovery correction: The current maintenance guard checks retained deletion first, skips only registered unconfigured stores, and retains the operation for missing registry entries. This addresses the earlier early-return mechanism described in the captured PR body. (src/config/sessions/startup-migration.ts:275, 2ebfd7fa8449)
  • Projection exclusion survives recovery: The introduced projection guard rejects an unconfigured physical owner without considering registration, successful recovery, or descendant lineage. The real projection requests physical-owner preservation, so this guard applies before its store reader runs. (src/config/sessions/combined-store-gateway.ts:487, 2ebfd7fa8449)
  • Gateway projection entrypoint: The projection's store reader passes preserveSentinelOwners: physical. Projection creation captures its async context, and Gateway startup adopts database admission until shutdown; completing startup does not remove the eligibility filter. (src/gateway/session-row-membership-read.ts:297, 2ebfd7fa8449)
  • Existing lineage contract: The existing recovery test configures only ops, stores a codex child with spawnedBy pointing to ops, re-registers that physical store, and expects the child to remain visible. Its standalone combined-reader call does not enable the new physical projection guard. (src/config/sessions/startup-migration.registry-recovery.test.ts:382, bb5656bf89e2)
  • Re-review continuity: The projection file has no changes between the earlier reviewed head and this head. The remaining projection finding was equally visible in the earlier cycle and is explicitly marked late. (src/config/sessions/combined-store-gateway.ts:487, 2ebfd7fa8449)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Preserve healthy lineage stores and extend the existing recovery scenario through the actual Gateway projection.
  • Record readiness and complete retained-session inventory across the reported packaged version-change path.

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-10-04T13:49:17.854Z sha b3e6338 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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. and removed 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 Oct 4, 2026
@steipete
steipete merged commit 9074545 into main Oct 4, 2026
153 of 154 checks passed
@steipete
steipete deleted the upd/upd-post-version-serial-admission-system-agent branch October 4, 2026 14:39
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
…penclaw#164929)

* fix(gateway): skip registered agent stores no configured agent owns

* fix(gateway): preserve agent store registry recovery
obviyus added a commit that referenced this pull request Oct 5, 2026
…ent stores (#165408)

chat.history and chat.startup for a session in an agent store skipped by startup admission (#164929) now return the existing non-retryable not-found refusal instead of a retryable "reload the conversation" error that clients retried forever. A row created mid-read still gets the retryable reload.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
…ent stores (openclaw#165408)

chat.history and chat.startup for a session in an agent store skipped by startup admission (openclaw#164929) now return the existing non-retryable not-found refusal instead of a retryable "reload the conversation" error that clients retried forever. A row created mid-read still gets the retryable reload.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime 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. 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.

1 participant