Skip to content

fix(memory): restore indexing during fresh agent startup - #170220

Merged
steipete merged 1 commit into
mainfrom
dbasync/memstartup
Oct 12, 2026
Merged

steipete merged 1 commit into
mainfrom
dbasync/memstartup

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes memory indexing startup on a fresh agent when session creation already holds the absent agent database's creating reference. The memory service previously logged Originally observed agent target requires its captured creating reference and failed to start its index.

User Impact

Fresh agents can initialize memory indexing and make subsequent session turns searchable. No configuration change or migration is required.

Why This Change Was Made

Explicit worker preparation now borrows the creation reference already held by the canonical execution owner. Ordinary execution captures and absent-store reads keep their existing semantics. The old unqualified preparation capture is removed; no extra SQL, filesystem observation, owner, generation, or SDK export is introduced.

No checks are removed. The captured-target and live-authority guards protect real database replacement and revoked writes, so they remain at their existing boundaries. Gateway main-thread SQLite call sites in the touched owners remain 0 → 0.

Historical source attribution: a17bd679979e1dc69bba795222c5dce5da750815 introduced V2 worker storage; 91eff279daa0d6dbf9cd44a9440355ffad9564f1 adopted it for memory publication. The same deterministic overlapping-creator probe fails on both current base 910a2c1b30857b3b96a456da86a1e72d69d3ebba and supplied good revision 42042df1da5d8924b0343a43e972375004b5a5a0. The supplied bisect window therefore cannot identify the latent owner defect; the later scheduling trigger remains unproven.

Evidence

  • Baseline V2 regression: 1 failed, 2 passed, with the exact captured-creating-reference error only in the overlapping-creator case (Vitest 99.07 s; cold worker compilation 216.98 s).
  • Regression coverage: fresh memory manager startup followed by transcript indexing and search; V2 absent-store behavior, explicit preparation with/without a captured creator, writes, close, and revoked-authority rejection.
  • Final committed-head CI: 31 changed-suite tests passed (22 worker-store, 3 V2, 6 memory admission). The fresh-agent index/search regression passed in 4.964 s; summed case time was 18.662 s, 1.850 s, and 8.822 s respectively. Earlier local candidate attempts were invalidated by source changes and are not counted as proof.
  • CI production/test types, type-aware lint, source/export contracts, Madge (0 cycles), T1 and dialect ratchets passed. Whole-repository T1 remains 471 → 471; touched-owner T1 is 0 → 0. Knip production, full-tree, and script export scans passed with zero findings on the exact committed head in Testbox.
  • Three CI shards have independently proven inherited runtime-config fixture failures: incognito completion lineage and replacement receipts reproduce in main run 38292584060; plugin registry reproduces in a controlled main replay at 8f7bac24b5fe6de7a511c6b372669cdf6324cc4d (same test/error/stack, 1 failed/1 passed, 35.92 s). All three test files are unchanged here and recorded for the red-main owner. Candidate CI.
  • Codex autoreview: scoped clean, no actionable P0–P2 findings. Changed-file type-aware oxlint, oxfmt, and diff checks passed.
  • Live candidate: all 13 turns, native child, control-plane RPCs, cron, compaction, and clean shutdown passed in 46.6 s; no fixture children remained. The original startup warning is absent, and memory index/cache/retrieval SQL appears in warmed worker stacks. Testbox run, exact source 9658984afe1a8e9909bc756f61e8b5de8abcb15f; harness and Knip both exited 0.
  • Diff: 6 files, +171/−61 lines; production change +19/−3, with the existing V2 tests moved into a dedicated database-worker fixture.
  • No update/Doctor/schema/plugin-loading/service-lifecycle behavior or public SDK surface changes; published-driver update cell is not applicable.

One baseline/candidate pair under relaxed testing v6; each has ten warmed turns. Baseline used macOS / Node 24.21.0 / SQLite 3.53.4; candidate used an isolated Testbox checkout / Node 24.19.0 / SQLite 3.53.3. Both use shared harness v2 causal accounting. The local copy only adjusted fixture location and startup readiness; the candidate used the unchanged shared harness. Host/runtime differences limit wall-clock and background-window comparisons; no speedup is claimed.

Warmed measurement, median [min–max] Base Candidate
Turn-caused all-thread statements 210 [210–218] 210 [205–215]
Turn-caused requests 47 [47–51] 47 [46–49]
Turn-caused MAIN statements 0 [0–0] 0 [0–0]
All statements in turn window, including background 244 [235–266] 234 [230–285]
All requests in turn window, including background 59.5 [55–69] 56.5 [54–68]
Memory worker statements per window-turn, mean 0 10.9
Memory-attributed requests per window-turn, mean 0 1.2

Restored memory work is background-attributed by the harness. Its mean SQL per warmed window-turn is: publication 2.4, source-index maintenance 2.4, embedding cache 1.7, chunk writes 1.6, vector writes 1.0, search/retrieval 1.5, and source-state reads 0.3. Each was zero on the failing baseline. Restoring this work is the intended product correction, not a query regression. Turn-caused mean statements/requests are 211.7/47.9 → 210.6/47.6; all-window means are 245.5/59.6 → 246.5/59.0.

Shared read family, statements per turn Base Candidate
Exact-entry facts 4.4 4.3
Actor hydration 3.3 3.3
Entry-cache snapshots 0 0
Row facts 0 0
Watermark reads 2.0 2.0

Proof-tool recovery: local candidate connection failed before turns at the existing 15-second handshake deadline; its startup already showed restored memory publication. Two local Knip scans timed out under host load. An initial Testbox expired during local source staging before executing code. Native Testbox provisioning, an isolated checkout of the pushed SHA, and frozen-lockfile installation completed the missing live proof and all Knip scans. No product timeout, guard, or baseline was changed to obtain a pass.

Landing uses the authorized head-pinned squash route and the independently evidenced inherited-test exception. The three inherited failures have been handed to the red-main repair owner.

Let explicit worker preparation borrow the creation reference already held by the canonical agent execution owner. Keep ordinary captures and absent-store reads unchanged. Cover overlapping creators, memory indexing and search, and existing V2 authority behavior.
@clawsweeper

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

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Explicit worker preparation borrows the execution owner’s captured creation target so memory indexing can initialize alongside fresh-agent session creation.

Example: Agent main starts while another creator holds its absent database target, then records a turn about a cobalt telescope.

  • Before: Memory initialization fails with “Originally observed agent target requires its captured creating reference,” preventing indexing.
  • After: Preparation shares the captured target, allowing the transcript to be indexed and found by searching “cobalt telescope.”

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The repair is focused and source-supported, but clean candidate behavior evidence remains thin.
Proof confidence 🦪 silver shellfish (2/6) The supplied MEMBER association exempts this maintainer-authored PR from the ordinary contributor proof gate; its body still reports invalidated candidate tests and pending live startup/index/search verification.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Fresh agents can fail to initialize memory indexing when session creation already holds the absent database’s creation reference.
Reason: This restores an existing capability with a small shared-owner repair, and the maintainer-authored direction requires no additional product decision.

Merge readiness

✅ Ready for maintainer review

Keep this PR: it repairs a current fresh-agent indexing failure through the existing execution owner, and no actionable introduced defect was found.

Priority: P2
Reviewed head: 9658984afe1a8e9909bc756f61e8b5de8abcb15f

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A clean candidate run and shipped-entry-point demonstration of fresh-agent startup followed by transcript indexing and successful search remain unverified.
Agent review details

How this fits together

Memory initialization calls the shared agent worker store, whose execution owner admits database creation and worker operations while preserving physical identity, live authority, and settlement.

flowchart TD
  A[Fresh agent session creation] --> C[Canonical execution owner]
  B[Memory manager startup] --> D[Worker store preparation]
  D --> C
  C --> E[SQLite worker]
  E --> F[Agent database and memory index]
  F --> G[Memory search]
Loading

Technical review

Best possible solution:

Keep preparation on the canonical execution owner and land this focused repair once its normal validation gates are satisfied.

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

The current source exposes a deterministic overlapping-creator failure, supported by the reported baseline regression; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The repair fixes the creation-reference mismatch at the shared execution owner without weakening ordinary absence, replacement, or authorization semantics.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 7abc1b2 adds src/state/openclaw-agent-worker-store.ts:200 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7abc1b2e4a77; files: src/state/openclaw-agent-worker-store.ts)

PR surface

Source +16, Tests +94. Total +110 across 6 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 19 3 +16
Tests 4 152 58 +94
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 171 61 +110

Review metrics

Metric Value Why it matters
Production versus test changes Production +19/-3; tests and test routing +152/-58 The small runtime repair is supported by consumer-level indexing/search coverage and shared worker-store contracts, with existing V2 tests moved rather than discarded.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Overlapping fresh-agent creation prevents memory indexing and retrieval, with no demonstrated loss of stored transcripts or failure of the entire agent workflow.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Complete a clean run of the added memory and V2 regressions on the reviewed head.

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 (1 earlier review cycle)
  • reviewed 2026-10-12T20:42:17.135Z sha 9658984 :: needs maintainer review before merge. :: none

Reviewed October 12, 2026, 4:50 PM ET / 20:50 UTC (Revision 2).

@steipete
steipete merged commit 647ef88 into main Oct 12, 2026
150 of 157 checks passed
@steipete
steipete deleted the dbasync/memstartup branch October 12, 2026 21:24
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…0220)

Let explicit worker preparation borrow the creation reference already held by the canonical agent database execution owner. Preserve ordinary absent-store reads and target/authority checks.

Regression coverage proves overlapping creation, fresh-agent memory startup, transcript indexing and search. Live harness confirms the startup warning is gone and memory worker SQL returns; warmed turn-caused SQL/requests remain 210/47, with zero MAIN statements.

Validation: 31 changed-suite tests, type-aware lint, types, source/export contracts, Madge, database ratchets, three Knip export scans, and Codex review. Landed under the approved exception for three independently proven inherited test failures, recorded in PR openclaw#170220.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-core Extension: memory-core P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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