Repository navigation
refactor(memory-wiki): move compiled cache to plugin state - #110167
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 13f55faa60
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| export function createWikiPromptSectionBuilder(): MemoryPromptSectionBuilder { | ||
| return ({ availableTools }) => buildWikiToolGuidance(availableTools); |
There was a problem hiding this comment.
Preserve compiled wiki digest in CLI prompts
When context.includeCompiledDigestPrompt is enabled, moving the digest out of this synchronous builder means prompts built through synchronous production callers no longer get the compiled wiki snapshot. src/agents/cli-runner/prepare.ts:1070 still calls buildCliAgentSystemPrompt()/buildConfiguredAgentSystemPrompt() without a preparedMemoryPrompt, so CLI-backed agent runs now receive only the wiki tool guidance from this builder, whereas the previous builder synchronously read agent-digest.json and appended the snapshot. Please add an async preparation handoff for the CLI prompt path (and similar synchronous prompt-inspection callers) before removing the digest from the builder.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 10:00 PM ET / July 18, 2026, 02:00 UTC. Summary PR surface: Source +1128, Tests +996, Docs +28, Generated 0, Other 0. Total +2152 across 56 files. Reproducibility: yes. source-reproducible: enable the compiled digest prompt for a large vault and trace the preparer’s Review metrics: 2 noteworthy metrics.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Split Memory Wiki’s prompt digest into a digest-only persisted/read path, retain the full claims payload for query operations, and add redacted real-run evidence covering compile, gateway restart, prompt output, and owner removal before merge. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: enable the compiled digest prompt for a large vault and trace the preparer’s Is this the best way to solve the issue? No: moving rebuildable state to plugin-owned SQLite is directionally sound, but using one combined cache payload for both prompt and query paths is not the narrowest solution because prompt construction requires only the compact digest. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3d1b77103511. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +1128, Tests +996, Docs +28, Generated 0, Other 0. Total +2152 across 56 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (5 earlier review cycles)
|
6c27397 to
6a1348c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a1348ca05
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| { | ||
| availableTools: new Set(params.availableTools), | ||
| citationsMode: params.citationsMode, | ||
| agentId: resolveAgentIdFromSessionKey(params.sessionKey), |
There was a problem hiding this comment.
Pass the resolved agent into memory preparation
When a non-legacy context engine runs for an agent whose session key is unscoped or legacy (for example the global queue used by global-scope agent runs), deriving the owner from params.sessionKey resolves to main, so agent-scoped memory-wiki preparation will load the wrong vault or throw Unknown memory-wiki agentId: main. The embedded caller already has the resolved sessionAgentId, so this helper should accept/use that value rather than reparsing the session key for the prepared memory context.
Useful? React with 👍 / 👎.
8654cc9 to
99093c3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 99093c338c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return []; | ||
| } | ||
| return [...toolGuidance, ...digestLines]; | ||
| const snapshot = await loadMemoryWikiCompiledCache(config); |
There was a problem hiding this comment.
Avoid parsing the full claims cache for prompt digests
When includeCompiledDigestPrompt is enabled, this prompt preparer only needs snapshot.digest, but loadMemoryWikiCompiledCache() reads the single compiled-cache blob that also contains the full claims array and synchronously gunzips/JSON-parses it. For large wiki vaults, every prompt preparation now pays to parse the entire query cache even though the prompt renders only the top digest pages; previously this path read just the small agent-digest.json. Please split the digest into a digest-only blob/read path or otherwise avoid loading all claims during prompt assembly.
Useful? React with 👍 / 👎.
| const active = resolveActiveVault(config); | ||
| if (!active) { | ||
| return null; |
There was a problem hiding this comment.
Activate cache owners from durable metadata on read
If a running gateway starts before the configured vault exists, the startup service skips activating that owner; a later documented openclaw wiki compile in another process can create the vault and write the shared SQLite compiled cache, but this read path still returns null because activeVaults was never populated in this process. That leaves the compiled prompt digest unavailable until a gateway restart or some same-process wiki operation initializes the vault, so the read path should be able to validate the stored metadata against the current vault generation instead of requiring prior process-local activation.
Useful? React with 👍 / 👎.
4c9101a to
345946a
Compare
a39199d to
e289b0a
Compare
|
Merged via squash.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e289b0a880
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (isMetadata(metadata) && ownerIds.has(metadata.ownerId)) { | ||
| continue; |
There was a problem hiding this comment.
Delete stale cache rows when vault identity changes
When an existing owner keeps the same owner id but changes or recreates its vault path/generation, the startup cleanup in extensions/memory-wiki/index.ts passes only owner ids, and this branch preserves every blob for that owner. The read path rejects those old rows via vaultPath/vaultGeneration, but they are never deleted, so stale compiled snapshots from a no-longer-configured vault remain in shared SQLite and continue counting against the blob namespace. Please key cleanup on the active owner identity plus vault path/generation/publication, or delete rows for the owner before activating the replacement vault.
Useful? React with 👍 / 👎.
…110167) * feat(plugin-sdk): prepare memory prompts asynchronously * refactor(memory-wiki): move compiled cache to plugin state * fix(plugin-sdk): export memory prompt preparer type * refactor(plugin-sdk): keep prompt preparer type private * test(memory-wiki): isolate compiled cache state * chore(memory-wiki): satisfy changed gates * fix(memory): preserve prepared prompts across context engines * docs(plugin-sdk): refresh API baseline * fix(memory): revalidate prepared prompt ownership * fix(codex): propagate sandboxed memory context * test(memory-wiki): seed durable vault identity * refactor(memory-wiki): keep cache lifecycle internal * fix(memory-wiki): harden compiled cache publication * style(memory-wiki): format cache lifecycle changes * test(memory-wiki): support extension test lib target * style(memory-wiki): remove redundant catch * refactor(memory-wiki): keep vault generation helper private
Share Google SSE startup, OpenAI voice configuration preparation and MiniMax request credentials. Reuse the SDK FIFO permit pool for Session Share and return Logbook's committed standup receipt instead of rereading its write. Remove repeated ONNX validation after the existing schema boundary and unused response/header copies. Preserve public surfaces, auth, resource bounds, snapshot limits, user-data durability and shutdown settlement. Phase E stays untouched. Simplify ordinary Memory Core sync-error bookkeeping and remove late-probe cache fencing and synthetic multi-process LanceDB startup retries. Remove redundant Bonjour sentinel/cleanup/listener defenses while retaining network-error handling and stop settlement. Net production reduction: 217 lines; test reduction: 204 lines. Best-effort tradeoffs accepted: - Active Memory's synthetic maximum-Date clock no longer bypasses caching; d649548 introduced the forced-clock fixture, not a human-use report. - Voice Call's synthetic maximum-Date clock uses numeric expiry and always admits the cache entry before native Promise rejection cleanup; 55d4456 introduced the forced-clock fixture, not a human-use report. - Future mutation of an internal webhook response is not isolated by copies; #118754 records synthetic HTTP proof, and no current consumer mutates it. - A publication racing compiled-cache reconciliation is picked up on the next lifecycle refresh; #110167 pins a synthetic lookup interleaving, not an incident. - A later parallel standup may overwrite the stored day, while each caller gets its own committed receipt; #99930/#144982 add the self-reread without an incident. - Deliberate mutation of Fal's internal image array during credential lookup may reach provider validation; migration 0f54ca2 already had a guarded caller. - Future mutation of Comfy's internal GET headers is not isolated by extra copies; #167205 retained these copies, but the current consumers are read-only. - An embedding probe finishing during adapter replacement can cache old availability for the existing 30-second TTL or until invalidation; #144252 and related #135599/#141280 describe architecture/synthetic lifecycle proof, not a human incident. Provider authority and shutdown drainage stay intact. - A competing LanceDB initializer exposing a table before its first readable version may fail startup and need the next invocation/restart. #105896's retry proof coordinates six processes; #105680 describes source inference, and its review explicitly notes that no actual failure log was supplied. Atomic existOk creation, schema/agent checks and user-data durability stay. - Internal handled-sync failure calls no longer re-check a tracked-active flag; #133239 introduced the bookkeeping, but every production caller is already inside tracked sync. A future untracked internal caller records its advisory failure directly. Deferred work and real overlapping failure identity stay. - Nonfinite ONNX logits still fail at the TypeBox IPC schema boundary; #153476 redundantly scanned the same validated vector a second time. No malformed network/worker input is newly admitted. - Bonjour's fixed-path existsSync no longer catches impossible filesystem exceptions; direct 989cfd1 cites no incident and Node already returns false. A throwing monkey-patch now fails startup visibly. - Bonjour cleanup no longer repeats stopPromise's once-only bookkeeping; ddc2036 added the flag for smoke stabilization without a user incident. Failed startup cannot expose a stop handle; SDK unsubscribe is idempotent. - Bonjour's fixed EventEmitter listeners no longer swallow attachment errors; direct 7389fc0 cites no incident, and pinned Ciao inherits ordinary on(). A future dependency-contract violation follows existing startup cleanup. Proof: targeted production/test types, syntax lint, formatting, zero runtime and Madge cycles, SDK source boundaries, lint-suppressions and focused plugin owner/sibling suites. Fresh independent review's sole ONNX finding is disproved by actual parseWorkerReply rejecting NaN and both infinities, as the installed TypeBox validator calls Number.isFinite. No accepted finding remains. One kept Memory Core generation-lease case hits its unchanged five-second embedding-start deadline on both candidate and unchanged task base 9e3e16c. It bypasses changed outcome/probe bookkeeping. It is not claimed passing or fixed. Typed-lint declaration preparation and full Active Memory suite startup also exceeded unchanged deadlines. Broad build/check-changed and PR CI unrun. Below-500 branch-only packet for bundling; Phase E remains untouched.
* refactor(plugins): consolidate provider and feature paths Share Google SSE startup, OpenAI voice configuration preparation and MiniMax request credentials. Reuse the SDK FIFO permit pool for Session Share and return Logbook's committed standup receipt instead of rereading its write. Remove repeated ONNX validation after the existing schema boundary and unused response/header copies. Preserve public surfaces, auth, resource bounds, snapshot limits, user-data durability and shutdown settlement. Phase E stays untouched. Simplify ordinary Memory Core sync-error bookkeeping and remove late-probe cache fencing and synthetic multi-process LanceDB startup retries. Remove redundant Bonjour sentinel/cleanup/listener defenses while retaining network-error handling and stop settlement. Net production reduction: 217 lines; test reduction: 204 lines. Best-effort tradeoffs accepted: - Active Memory's synthetic maximum-Date clock no longer bypasses caching; d649548 introduced the forced-clock fixture, not a human-use report. - Voice Call's synthetic maximum-Date clock uses numeric expiry and always admits the cache entry before native Promise rejection cleanup; 55d4456 introduced the forced-clock fixture, not a human-use report. - Future mutation of an internal webhook response is not isolated by copies; #118754 records synthetic HTTP proof, and no current consumer mutates it. - A publication racing compiled-cache reconciliation is picked up on the next lifecycle refresh; #110167 pins a synthetic lookup interleaving, not an incident. - A later parallel standup may overwrite the stored day, while each caller gets its own committed receipt; #99930/#144982 add the self-reread without an incident. - Deliberate mutation of Fal's internal image array during credential lookup may reach provider validation; migration 0f54ca2 already had a guarded caller. - Future mutation of Comfy's internal GET headers is not isolated by extra copies; #167205 retained these copies, but the current consumers are read-only. - An embedding probe finishing during adapter replacement can cache old availability for the existing 30-second TTL or until invalidation; #144252 and related #135599/#141280 describe architecture/synthetic lifecycle proof, not a human incident. Provider authority and shutdown drainage stay intact. - A competing LanceDB initializer exposing a table before its first readable version may fail startup and need the next invocation/restart. #105896's retry proof coordinates six processes; #105680 describes source inference, and its review explicitly notes that no actual failure log was supplied. Atomic existOk creation, schema/agent checks and user-data durability stay. - Internal handled-sync failure calls no longer re-check a tracked-active flag; #133239 introduced the bookkeeping, but every production caller is already inside tracked sync. A future untracked internal caller records its advisory failure directly. Deferred work and real overlapping failure identity stay. - Nonfinite ONNX logits still fail at the TypeBox IPC schema boundary; #153476 redundantly scanned the same validated vector a second time. No malformed network/worker input is newly admitted. - Bonjour's fixed-path existsSync no longer catches impossible filesystem exceptions; direct 989cfd1 cites no incident and Node already returns false. A throwing monkey-patch now fails startup visibly. - Bonjour cleanup no longer repeats stopPromise's once-only bookkeeping; ddc2036 added the flag for smoke stabilization without a user incident. Failed startup cannot expose a stop handle; SDK unsubscribe is idempotent. - Bonjour's fixed EventEmitter listeners no longer swallow attachment errors; direct 7389fc0 cites no incident, and pinned Ciao inherits ordinary on(). A future dependency-contract violation follows existing startup cleanup. Proof: targeted production/test types, syntax lint, formatting, zero runtime and Madge cycles, SDK source boundaries, lint-suppressions and focused plugin owner/sibling suites. Fresh independent review's sole ONNX finding is disproved by actual parseWorkerReply rejecting NaN and both infinities, as the installed TypeBox validator calls Number.isFinite. No accepted finding remains. One kept Memory Core generation-lease case hits its unchanged five-second embedding-start deadline on both candidate and unchanged task base 9e3e16c. It bypasses changed outcome/probe bookkeeping. It is not claimed passing or fixed. Typed-lint declaration preparation and full Active Memory suite startup also exceeded unchanged deadlines. Broad build/check-changed and PR CI unrun. Below-500 branch-only packet for bundling; Phase E remains untouched. * refactor(plugins): consolidate remaining feature and provider owners Replace ACPX trust scanning with the existing TOML parser, consolidate Logbook operation dispatch, reuse SDK FIFO playback admission, and prepare wiki claims once. Remove repeated internal validation and redundant copies while retaining external validation, live authority, resource bounds, durability and Phase E. Shrink only the assertion allowances eliminated by these removals. The complete branch removes 750 net production lines. Accepted timing and internal-mutation tradeoffs, provenance, review decisions and proof are recorded in the PR body and requested local ledger. * test(plugins): align checks with simplified owners
…aw#173064) * refactor(plugins): consolidate provider and feature paths Share Google SSE startup, OpenAI voice configuration preparation and MiniMax request credentials. Reuse the SDK FIFO permit pool for Session Share and return Logbook's committed standup receipt instead of rereading its write. Remove repeated ONNX validation after the existing schema boundary and unused response/header copies. Preserve public surfaces, auth, resource bounds, snapshot limits, user-data durability and shutdown settlement. Phase E stays untouched. Simplify ordinary Memory Core sync-error bookkeeping and remove late-probe cache fencing and synthetic multi-process LanceDB startup retries. Remove redundant Bonjour sentinel/cleanup/listener defenses while retaining network-error handling and stop settlement. Net production reduction: 217 lines; test reduction: 204 lines. Best-effort tradeoffs accepted: - Active Memory's synthetic maximum-Date clock no longer bypasses caching; 1802f6b introduced the forced-clock fixture, not a human-use report. - Voice Call's synthetic maximum-Date clock uses numeric expiry and always admits the cache entry before native Promise rejection cleanup; c7b888b introduced the forced-clock fixture, not a human-use report. - Future mutation of an internal webhook response is not isolated by copies; openclaw#118754 records synthetic HTTP proof, and no current consumer mutates it. - A publication racing compiled-cache reconciliation is picked up on the next lifecycle refresh; openclaw#110167 pins a synthetic lookup interleaving, not an incident. - A later parallel standup may overwrite the stored day, while each caller gets its own committed receipt; openclaw#99930/openclaw#144982 add the self-reread without an incident. - Deliberate mutation of Fal's internal image array during credential lookup may reach provider validation; migration d365cd8 already had a guarded caller. - Future mutation of Comfy's internal GET headers is not isolated by extra copies; openclaw#167205 retained these copies, but the current consumers are read-only. - An embedding probe finishing during adapter replacement can cache old availability for the existing 30-second TTL or until invalidation; openclaw#144252 and related openclaw#135599/openclaw#141280 describe architecture/synthetic lifecycle proof, not a human incident. Provider authority and shutdown drainage stay intact. - A competing LanceDB initializer exposing a table before its first readable version may fail startup and need the next invocation/restart. openclaw#105896's retry proof coordinates six processes; openclaw#105680 describes source inference, and its review explicitly notes that no actual failure log was supplied. Atomic existOk creation, schema/agent checks and user-data durability stay. - Internal handled-sync failure calls no longer re-check a tracked-active flag; openclaw#133239 introduced the bookkeeping, but every production caller is already inside tracked sync. A future untracked internal caller records its advisory failure directly. Deferred work and real overlapping failure identity stay. - Nonfinite ONNX logits still fail at the TypeBox IPC schema boundary; openclaw#153476 redundantly scanned the same validated vector a second time. No malformed network/worker input is newly admitted. - Bonjour's fixed-path existsSync no longer catches impossible filesystem exceptions; direct 1fa8665 cites no incident and Node already returns false. A throwing monkey-patch now fails startup visibly. - Bonjour cleanup no longer repeats stopPromise's once-only bookkeeping; 2ef6daa added the flag for smoke stabilization without a user incident. Failed startup cannot expose a stop handle; SDK unsubscribe is idempotent. - Bonjour's fixed EventEmitter listeners no longer swallow attachment errors; direct 836f011 cites no incident, and pinned Ciao inherits ordinary on(). A future dependency-contract violation follows existing startup cleanup. Proof: targeted production/test types, syntax lint, formatting, zero runtime and Madge cycles, SDK source boundaries, lint-suppressions and focused plugin owner/sibling suites. Fresh independent review's sole ONNX finding is disproved by actual parseWorkerReply rejecting NaN and both infinities, as the installed TypeBox validator calls Number.isFinite. No accepted finding remains. One kept Memory Core generation-lease case hits its unchanged five-second embedding-start deadline on both candidate and unchanged task base d6898f3. It bypasses changed outcome/probe bookkeeping. It is not claimed passing or fixed. Typed-lint declaration preparation and full Active Memory suite startup also exceeded unchanged deadlines. Broad build/check-changed and PR CI unrun. Below-500 branch-only packet for bundling; Phase E remains untouched. * refactor(plugins): consolidate remaining feature and provider owners Replace ACPX trust scanning with the existing TOML parser, consolidate Logbook operation dispatch, reuse SDK FIFO playback admission, and prepare wiki claims once. Remove repeated internal validation and redundant copies while retaining external validation, live authority, resource bounds, durability and Phase E. Shrink only the assertion allowances eliminated by these removals. The complete branch removes 750 net production lines. Accepted timing and internal-mutation tradeoffs, provenance, review decisions and proof are recorded in the PR body and requested local ledger. * test(plugins): align checks with simplified owners
What Problem This Solves
Memory plugins could only contribute synchronous system-prompt text. Memory Wiki therefore persisted its compiled agent digest and claim index in legacy state files, then read those files during prompt assembly. That created a prompt-path filesystem dependency, stale-owner risk, and cache lifecycle behavior outside the plugin state owner.
Why This Change Was Made
This adds one narrow async memory prompt-preparation registration. The agent run validates stable owner and vault-instance identity, loads prepared state before prompt assembly, and hands an immutable snapshot to synchronous prompt builders. Recompilation atomically replaces the snapshot; owner removal deletes its state.
Memory Wiki now stores its rebuildable compiled snapshot as a plugin blob in shared SQLite. Compile publishes one atomic replacement, prompt preparation and queries load the same snapshot, inactive owners are removed at plugin start, and stale legacy files are cleanup-only doctor debt. There is no file migration, polling, watcher, process decoded cache, or prompt-path filesystem I/O.
Context-engine assembly executes inside the same prepared-memory scope, including sandbox context, so custom engines preserve the async supplements without changing the synchronous context-engine contract.
AI-assisted implementation. Maintainer-requested architecture and migration.
User Impact
Memory Wiki prompts and queries use one lifecycle-owned compiled snapshot. Restarts reload the SQLite blob, recompiles replace it atomically, removed vault owners lose their cached state, and old cache files are safely deleted by doctor instead of being read or migrated.
Evidence
node scripts/run-vitest.mjs extensions/memory-wiki/src/compiled-cache.integration.test.ts extensions/memory-wiki/src/prompt-section.test.ts extensions/memory-wiki/src/compile.test.ts extensions/memory-wiki/index.test.ts extensions/memory-wiki/src/vault.test.ts extensions/memory-wiki/doctor-contract-api.test.ts extensions/memory-wiki/src/bridge.test.ts test/scripts/check-database-first-legacy-stores.test.ts— 550 tests passed.node scripts/run-vitest.mjs src/plugins/memory-state.test.ts src/context-engine/context-engine.test.ts extensions/memory-wiki/index.test.ts extensions/memory-wiki/src/compiled-cache.integration.test.ts— 81 tests passed.node scripts/run-vitest.mjs src/agents/harness/context-engine-lifecycle.test.ts src/agents/embedded-agent-runner/run/attempt-stream-runtime-prepare.test.ts extensions/memory-wiki/index.test.ts extensions/memory-wiki/src/compiled-cache.integration.test.ts— 31 tests passed.pnpm check:changedpassed all API, SDK surface, typecheck, lint, database-first, cycle, sidecar, and security lanes.pnpm test extensions/memory-wikipassed 37 files / 321 tests.pnpm buildpassed.