Skip to content

fix(memory): admit shared index writes through the agent owner - #146760

Merged
steipete merged 1 commit into
mainfrom
codex/swarm-memory-write-admission
Sep 13, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/swarm-memory-write-admission

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Related: #130741. Builds on #146491 and #146563.

What Problem This Solves

Memory indexing could enter synchronous database writes while session cleanup owned the writer, delaying Gateway work. Queued syncs could also outlive manager shutdown or reopen a retired source connection.

Why This Change Was Made

Route published memory writes through the existing per-agent admission owner, retaining the selected state root and exact borrowed connection. Prepare embeddings and source data before admission, then recheck source, generation, and revision predicates before writing. Shadow publication keeps ATTACH, transaction, and DETACH in one synchronous admitted operation. Registry ownership remains in its existing module and public facade.

User Impact

Conflicting memory writes wait asynchronously, accepted syncs settle before manager shutdown, and stale borrowed handles fail without reopening a replacement. Existing schemas, retention, FIFO ordering, and integrity checks remain intact.

Evidence

Regressions reproduced premature cache writes, lost shutdown ownership, state-root retargeting, and retired-source reopening. Focused memory, transaction, lifecycle, and real reclamation-worker overlap tests pass, along with the component build and independent review.

Every production file in this repair is unchanged from the previous reviewed head. The refreshed integration preserves main's timing assertions for both push and pull-request modes, using synthetic costs matched to current group membership. Seven selected timing/prerequisite cases and all 63 memory-search cases passed, along with scoped types, lint, documentation checks, and a fresh independent P1 review.

The prior full canonical gate, 99 integration cases, 119 fixture cases, and normal build remain separately bound evidence; that full build and those suites were not rerun for this refresh. Exact-head CI follows publication. The real-OpenAI Swarm campaign remains outstanding, and this component proof does not establish the overall 500 ms target.

@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 docs Improvements or additions to documentation extensions: memory-core Extension: memory-core scripts Repository scripts plugin: file-transfer size: XL maintainer Maintainer-authored PR labels Sep 13, 2026
@steipete
steipete marked this pull request as ready for review September 13, 2026 05:15
@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: blocked before merge. Reviewed September 13, 2026, 6:45 AM ET / 10:45 UTC (Revision 4).

ClawSweeper review

What this changes

Memory Core routes shared index writes through the existing agent database queue and retains accepted synchronization work through shutdown, with regression coverage and documentation.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful repair absent from inspected main. No blocking correctness findings remain; the previous migration-proof warning does not apply because the patch preserves existing storage contracts.

Priority: P2
Reviewed head: f7dbcad57d404c62dbb929c2a183e9f1f66318ab

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this maintainer-authored repair. Inspected coverage connects the public memory runtime to real SQLite reclamation and verifies completion; the broader real-provider Swarm performance campaign remains separately outstanding.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this maintainer-authored repair. Inspected coverage connects the public memory runtime to real SQLite reclamation and verifies completion; the broader real-provider Swarm performance campaign remains separately outstanding.
Evidence reviewed 9 items Current main still lacks memory write admission: Current main calls the transaction helper directly during embedding-cache pruning, without the agent admission callback; its database-context class also lacks withDatabaseWrite. The merged prerequisite supplies the queue, but does not complete this Memory Core integration.
Exact borrowed owner checked before writes: The new wrapper passes the exact borrowed connection to the existing admission owner, then checks manager closure, database closure, context identity, and read-only status before mutation. The underlying owner rechecks agent admission and deletion/maintenance access.
Storage contract preserved: Shadow publication retains the existing tables, columns, revision predicate, and replacement transaction; preparation is separated from synchronous admitted publication. No schema version, persisted format, retention rule, or migration is introduced. The storage policy explicitly distinguishes internal admission mechanics from persistent-contract changes.
Findings None None.
Security None None.

How this fits together

Memory Core indexes workspace files and session transcripts for memory search. Its published index shares the agent SQLite database with session writers and cleanup workers, so write admission coordinates their access.

flowchart TD
  A[Workspace files and transcripts] --> B[Prepare chunks and embeddings]
  B --> C[Agent write queue]
  D[Session writes and cleanup] --> C
  C --> E[Recheck owner and revision]
  E --> F[Publish memory index]
  F --> G[Memory search]
  H[Manager shutdown] --> B
  H --> C
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +116, Tests +763, Docs +16, Other +6. Total +901 across 24 files.

View PR surface stats
Area Files Added Removed Net
Source 10 362 246 +116
Tests 11 788 25 +763
Docs 2 16 0 +16
Config 0 0 0 0
Generated 0 0 0 0
Other 1 6 0 +6
Total 24 1172 271 +901

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +116 lines; tests +763; test tooling +6 Production growth implements admission and lifecycle checks; most growth covers contention, retirement, and recovery regressions.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/memory-core/src/memory/manager-db.ts, serialized state: extensions/memory-core/src/memory/manager-search-orchestration.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-database-context.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-db.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-embedding-ops.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager.ts, and 6 more. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep memory mutations under the existing agent admission owner, with synchronous publication and lifecycle checks immediately before writes.

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

Yes, source establishes memory writes bypassing the shared admission queue during reclamation, and the new integration test exercises that overlap. Runtime reproduction was not executed in this read-only review.

Is this the best way to solve the issue?

Yes. Reusing the existing admission owner addresses the contention without introducing another queue or changing persistent formats; the previous generic migration-proof requirement is unwarranted.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded memory-index concurrency repair with no demonstrated emergency or release-wide outage.
  • 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 external-contributor proof gate does not apply to this maintainer-authored repair. Inspected coverage connects the public memory runtime to real SQLite reclamation and verifies completion; the broader real-provider Swarm performance campaign remains separately outstanding.

Evidence

What I checked:

  • Current main still lacks memory write admission: Current main calls the transaction helper directly during embedding-cache pruning, without the agent admission callback; its database-context class also lacks withDatabaseWrite. The merged prerequisite supplies the queue, but does not complete this Memory Core integration. (extensions/memory-core/src/memory/manager-embedding-ops.ts:382, 13ffb8a5cda4)
  • Exact borrowed owner checked before writes: The new wrapper passes the exact borrowed connection to the existing admission owner, then checks manager closure, database closure, context identity, and read-only status before mutation. The underlying owner rechecks agent admission and deletion/maintenance access. (extensions/memory-core/src/memory/manager-database-context.ts:62, f7dbcad57d40)
  • Storage contract preserved: Shadow publication retains the existing tables, columns, revision predicate, and replacement transaction; preparation is separated from synchronous admitted publication. No schema version, persisted format, retention rule, or migration is introduced. The storage policy explicitly distinguishes internal admission mechanics from persistent-contract changes. Public docs: docs/reference/database-schemas/storage-changes.md. (docs/reference/database-schemas/storage-changes.md:268, f7dbcad57d40)
  • Private facade and existing callers preserved: The SQLite facade is explicitly internal to bundled and official plugins. Its new transaction admission argument is optional with the original direct-execution default; the public Memory Core manager-runtime facade retains its exports after the internal move. Public docs: docs/plugins/sdk-runtime/state-and-system.md. (docs/plugins/sdk-runtime/state-and-system.md:197, f7dbcad57d40)
  • Regression coverage reaches production owners: The reclamation integration test loads the public memory runtime and uses the actual archive worker, injecting delayed parent authorization. It asserts deletion completion, cache pruning, and retained memory chunks. Additional inspected tests cover revoked state ownership, replacement handles, revision invalidation, and shutdown draining. These tests were inspected, not executed during this read-only review. (src/config/sessions/session-accessor.sqlite-reclamation-memory.test.ts:98, f7dbcad57d40)
  • Re-review continuity: GitHub contents metadata for the nine changed Memory Core production modules matches their current local blob IDs at the previously reviewed d308471 revision. The transaction helper also matches, at blob 26f6a99da31f2f4d12946bf647376cc001daf528. The prior projection contains no findings or published rank-up moves; its migration warning was reassessed against the actual storage delta. (src/infra/sqlite-transaction.ts:404, f7dbcad57d40)

Likely related people:

  • Peter Steinberger: Raw commit ee679bb adds src/state/openclaw-agent-db-write.ts:17 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ee679bb785be; files: src/state/openclaw-agent-db-write.ts)

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 (3 earlier review cycles)
  • reviewed 2026-09-13T05:21:52.591Z sha 9351c70 :: blocked before merge. :: none
  • reviewed 2026-09-13T06:55:11.498Z sha 6808ab9e4b83a8a0b3e9371146b62369e53dfb3b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T09:53:27.849Z sha d308471 :: blocked before merge. :: none

@steipete
steipete force-pushed the codex/swarm-memory-write-admission branch from d308471 to f7dbcad Compare September 13, 2026 10:38
@steipete
steipete merged commit e05d8b6 into main Sep 13, 2026
187 of 188 checks passed
@steipete
steipete deleted the codex/swarm-memory-write-admission branch September 13, 2026 11:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to zachisfine/openclaw that referenced this pull request Sep 13, 2026
* temp/pr-146799: (70 commits)
  test: reuse explicit fallback config fixtures (openclaw#146948)
  fix(computer): return fresh window observations after actions (openclaw#146822)
  refactor(feishu): remove unreachable requester topic selection (openclaw#146904)
  improve(gateway): reduce CPU spent listing agent-owned sessions (openclaw#137745)
  fix(ui): avoid recapturing chat drafts during UI updates (openclaw#146884)
  fix(ui): show system uptime in the debug overlay (openclaw#146960)
  fix(retry): honor waits beyond the native timer limit (openclaw#145718)
  fix(ui): keep chat history idle when run status changes (openclaw#146802)
  fix(ui): reuse persisted text during chat streaming (openclaw#146831)
  refactor(qa): share harness drift result construction (openclaw#146903)
  test(agents): coordinate settings lock contention (openclaw#146949)
  fix(worker): avoid repeatedly serializing screenshot history (openclaw#146907)
  fix(secrets): stop buffered upload writes after cancellation (openclaw#146840)
  perf(doctor): avoid unnecessary state runtime imports (openclaw#146926)
  improve: reduce compaction request estimation work (openclaw#146961)
  fix(ci): wait for forwarded avatar imports before assertions (openclaw#146729)
  perf(workers): skip configured Git author lookups (openclaw#146833)
  fix: admit borrowed memory writes through the agent database owner (openclaw#146760)
  fix(discord): prevent voice playback gaps and stale turn controls (openclaw#146798)
  improve: reduce worktree filesystem stalls and archive syncs (openclaw#146906)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit 'ccfd2377cd07d1ad3a583ba64d08e29a065f7061': (1587 commits)
  fix(ui): avoid recapturing chat drafts during UI updates (#146884)
  fix(ui): show system uptime in the debug overlay (#146960)
  fix(retry): honor waits beyond the native timer limit (#145718)
  fix(ui): keep chat history idle when run status changes (#146802)
  fix(ui): reuse persisted text during chat streaming (#146831)
  refactor(qa): share harness drift result construction (#146903)
  test(agents): coordinate settings lock contention (#146949)
  fix(worker): avoid repeatedly serializing screenshot history (#146907)
  fix(secrets): stop buffered upload writes after cancellation (#146840)
  perf(doctor): avoid unnecessary state runtime imports (#146926)
  improve: reduce compaction request estimation work (#146961)
  fix(ci): wait for forwarded avatar imports before assertions (#146729)
  perf(workers): skip configured Git author lookups (#146833)
  fix: admit borrowed memory writes through the agent database owner (#146760)
  fix(discord): prevent voice playback gaps and stale turn controls (#146798)
  improve: reduce worktree filesystem stalls and archive syncs (#146906)
  fix(ui): avoid extra chat rail work while replies stream (#146883)
  improve(ui): speed up populated Usage timelines (#146947)
  test(gateway): retain auth recovery failure diagnostics (#146925)
  fix(tests): create private temporary home directories (#146931)
  ...

# Conflicts:
#	test/tsconfig/tsconfig.core.test.agents-other.json
#	test/tsconfig/tsconfig.core.test.agents-root.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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