Repository navigation
fix(memory): Knowledge calls fail mid-turn after unrelated session activity - #166419
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed October 7, 2026, 5:26 AM ET / 09:26 UTC (Revision 6). ClawSweeper reviewWhat this changesThe PR keeps memory tools available during unrelated session activity by narrowing registry invalidation and waiting for relevant session publications before checking authority. Merge readiness⛔ Blocked before merge - 1 item remains This PR remains necessary: pinned main still invalidates memory authority after unrelated activity. No blocking patch defect remains, and the previous migration concern does not apply because no stored-data contract changes. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw’s memory host grants access from trusted session lineage and supplies it to memory providers and tools. Session publications update those grants, allowing unchanged sessions to continue while rejecting reset or released sessions. flowchart TD
A[Agent memory request] --> B[Host session audience]
C[Session and registry publications] --> D[Relevant publication readiness]
B --> D
D --> E[Current authority check]
E -->|Valid| F[Memory provider or tool]
E -->|Revoked| G[Access denied]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +167, Tests +652. Total +819 across 13 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep publication readiness in the existing session authority owner while preserving synchronous revocation checks at every memory effect boundary. Do we have a high-confidence way to reproduce the issue? Yes, source establishes a focused path: mint a memory audience, publish unrelated registry topology, then invoke its memory tool on pinned main. Contributor live evidence and failing baseline regressions corroborate it; this review did not execute the path. Is this the best way to solve the issue? Yes. Reusing the existing publication and registry owners repairs transient unavailability without weakening incarnation revocation or creating another authority mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5077ad4f99aa. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
60da0ed to
a57551b
Compare
|
On the remaining proof item (parent reset during the publication wait, "before real memory I/O"):
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Scope registry topology invalidation to witnessed candidate sources and keep catalog-only changes out of session authority invalidation. Join admitted session publications at memory host boundaries while retaining synchronous final guards and cancellation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Memory-slot readiness no longer throws an already-aborted signal before the tool runs. Plugin tools still receive an aborted signal and own cancellation, and a retired plugin runtime still reports that it is no longer active before any abort reason. Only the memory-slot owner waits for audience publications. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Exercise the real SQLite session owner and memory provider adapter with a delegated child audience while its parent's admitted publication is held. A parent metadata write lets the read reach the provider after it settles; a parent reset rejects the read before any provider I/O. Co-Authored-By: Claude Opus 5.5 <[email protected]>
a57551b to
5539873
Compare
|
Merged via squash.
|
…tivity (openclaw#166419) * fix(memory): preserve audience authority across unrelated publications Scope registry topology invalidation to witnessed candidate sources and keep catalog-only changes out of session authority invalidation. Join admitted session publications at memory host boundaries while retaining synchronous final guards and cancellation. * fix(plugins): keep plugin tool cancellation and liveness order Memory-slot readiness no longer throws an already-aborted signal before the tool runs. Plugin tools still receive an aborted signal and own cancellation, and a retired plugin runtime still reports that it is no longer active before any abort reason. Only the memory-slot owner waits for audience publications. * test(memory): prove retained child audiences wait on parent publications Exercise the real SQLite session owner and memory provider adapter with a delegated child audience while its parent's admitted publication is held. A parent metadata write lets the read reach the provider after it settles; a parent reset rejects the read before any provider I/O.
What Problem This Solves
Fixes: memory-slot tools (for example Knowledge) fail mid-turn with
memory audience currency is unavailable; retry the operation/SESSION_DELIVERY_GENERATION_UNAVAILABLEwhen unrelated session or registry activity happens during the turn.User Impact
User impact: long agent turns that read or write memory no longer lose access partway through because another session, agent database, or session group changed. Retrying within the same turn could never recover, so long ingestion and research runs stalled.
Why This Change Was Made
Since the memory audience moved into the host (#162176), each memory call checks a session generation lease. Three unrelated events left that lease permanently unavailable for the rest of the turn:
sessions.groups.*), which were announced as full session changes;This change limits registry invalidation to the candidate sources the lease actually witnessed, marks group edits catalog-only, and has the memory host wait for admitted publications of the audience's sessions (and its delegating parents) before the synchronous final currency check. A real incarnation change (new session id or lifecycle revision) still revokes the audience, and cancellation still aborts the wait.
Evidence
Live failure: a Granola-to-Knowledge ingestion session on a
mainGateway hit the error repeatedly while reads and writes in the same session succeeded moments earlier and later.Live after-fix proof (fsn1 Gateway,
dd619529b24plus this PR and #166417, systemd user service, Knowledge as the memory slot), in a fresh dashboard session on agentmain:knowledge_statusconversation:<session>sleep 75; meanwhilesessions.groups.putwith the unchanged catalog,sessions.patchrelabeling this same session, andsessions.createof a sibling sessionknowledge_statusagainknowledge_records(limit: 1)The session's lifecycle revision was unchanged across the turn. Revocation still applies: after
sessions.reseton the parent, its existing subagent's nextknowledge_statusfailed withKnowledge access unavailable: trusted agent/session authority is required.session-accessor.sqlite-generation-readiness.test.ts): a delegated child audience is minted through the real lineage walk, then its parent's publication is held mid-flight. While held, the child's read is pending (not failed, provider not called). A parent metadata write lets the read reach the provider afterwards; a parent reset (same session id, new lifecycle revision) rejects it with no provider I/O and the audience stays revoked. Both cases fail againstmainproduction code and pass here; the file runs in 29 s wall with--maxWorkers=1(23 s Vitest).tools.optional.test.ts, 76/76).main(16 failures acrosssession-delivery-generation.registry.test.ts,session-accessor.sqlite-generation-readiness.test.ts,memory-audience.test.ts,memory-provider-runtime.test.ts,sessions-groups.test.ts) and pass with this change (94/94 across those files).pnpm test src/config/sessions/session-delivery-generation.registry.test.ts --maxWorkers=1: 64 s wall, about 19 s of test time on a loaded laptop; each case exercises real SQLite registry publications, which is the boundary under test.src/plugins/memory-audience.test.ts --maxWorkers=1: 72 s wall on the same host.memory-audience.test.tscovers a child revoked after a parent reset or removal, parent reset/release/abort while a publication wait is pending, and a child publication when the parent rejects preparation;memory-provider-runtime.test.tsrejects an audience presented by a different session. Registry tests use real SQLite publications for removal, reassignment, ABA, rollback, and changes during preparation.WeakMaps keyed by host-minted audience objects) and are rebuilt on every turn; nothing is persisted, migrated, or read back across upgrades.node scripts/check-changed.mjs --base dd619529b24: passed (format, core typecheck graphs, lint, dead-export scans, guards).🤖 Generated with Claude Code