Skip to content

test(memory): own the fenced late manager's successor provider - #168300

Merged
RomneyDa merged 1 commit into
mainfrom
fix/memory-runtime-late-manager-successor
Oct 10, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/memory-runtime-late-manager-successor

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: src/plugins/memory-runtime.owners.test.ts intermittently fails with expected "vi.fn()" to be called 1 times, but got 2 times on successorClose under CI load. Seen on the 2026.10.1 stable release validation in plugin prerelease job 114117019527.

User Impact

No user-visible change. Removes a timing-dependent failure from the plugin prerelease and node test lanes; production memory runtime code is unchanged.

Why This Change Was Made

The reload-owner test acquires a default-purpose manager for agent late while the reload fence is up, then leaves it cached and live.

  • Its file watcher reports a reconcile change on start.
  • After the 1.5 s watch debounce (extensions/memory-core/src/memory/manager-watch-ops.ts), the background sync runs. It has been owned by the plugin lifecycle since eaf60b0, so it resumes on the successor adapter and creates a second successor provider (manager-provider-lifecycle.ts).
  • closeAll then correctly closes both.
  • When that debounce lands between reload.commit() and closeAll, the count is 2.

Production is correct: one provider per live manager, each closed exactly once. The test now probes the late manager explicitly after commit, so it deterministically owns its successor provider. It also expects one successor close per live replacement-era manager. No sleeps, retries or loosened matchers.

Evidence

  • Instrumented repro: logging the successor creates showed the extra provider comes from agent late.
  • Deterministic control: with the late probe added and the old === 1 assertions kept, 8 of 17 modes fail every time with the CI error.
  • On release (31eb71f): a bounded loop of node scripts/run-vitest.mjs src/plugins/memory-runtime.owners.test.ts passed 30/30 with load average 40–50.
  • On this branch (main): the same file passed 17/17 in 5 consecutive runs. oxfmt and scoped oxlint are clean.
  • Not covered: main's separate late-probe and memory-background-reload.test.ts failures. In late-probe mode the successor create returns null, so this race cannot cause them; they need their own investigation.

The reload owner test acquires a default-purpose manager for agent "late"
while the reload fence is active and leaves it cached and live. Its file
watcher emits a reconcile invalidation on start, and after the 1.5s watch
debounce the background sync (now owned by the plugin lifecycle since
eaf60b0) resumes on the successor adapter and creates a second
successor provider, which closeAll correctly closes. Under CPU load that
debounce lands between commit and closeAll, so successorClose counted 2.

Acquire the late manager's successor provider explicitly after commit and
expect one successor close per live replacement-era manager.
@clawsweeper

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

@RomneyDa
RomneyDa marked this pull request as ready for review October 10, 2026 07:06
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The test explicitly initializes the fenced late manager’s successor provider and expects cleanup once per live replacement-era manager.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The source supports a correct, narrowly scoped fixture repair; supplied validation is harness-based, and CI remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored test-only correction changes no shipped behavior; reported validation exercises real memory lifecycle owners with synthetic embedding providers.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Plugin validation intermittently fails because cleanup correctly closes a provider the test did not deterministically initialize.
Reason: The focused fixture correction preserves lifecycle coverage without production changes, sleeps, retries, or relaxed matchers.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR makes a useful, focused correction to a timing-dependent test expectation. No introduced correctness or security defect was found.

Priority: P2
Reviewed head: 0f42f8266cdb6c759989ab308794cb8e434f8228

Before merge

None.

Findings

None.

Agent review details

How this fits together

The plugin reload test exercises Memory Core manager acquisition, embedding-provider replacement, and final cleanup through the real lifecycle owners with synthetic providers.

flowchart TD
  A[Reload ownership test] --> B[Memory runtime]
  B --> C[Manager registry]
  C --> D[Main and late managers]
  D --> E[Successor providers]
  C --> F[Final cleanup]
  F --> E
Loading

Technical review

Best possible solution:

Retain the explicit post-commit probe and exact per-manager cleanup expectations.

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

Current source supports the race: a cached late manager can initialize its own provider after reload resumes; the author reports deterministic reproduction, but this read-only review ran no tests.

Is this the best way to solve the issue?

The change fixes the fixture’s incomplete setup while preserving exact cleanup assertions, the legacy single-provider case, and the null-provider case.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Reload ownership and cleanup expectations keeps the original intent (05a2844: Keep admitted memory work and its exact embedding-provider dependencies owned through replacement and cleanup.)
  • Background sync after registry replacement keeps the original intent (ee5dea9: Run background memory work through its exact plugin instance and currently adopted registry.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Tests +13. Total +13 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 15 2 +13
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 15 2 +13

Labels

Label changes:

  • add P2: A bounded test-fixture race disrupts plugin validation without changing production behavior.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A bounded test-fixture race disrupts plugin validation without changing production behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 10, 2026, 3:11 AM ET / 07:11 UTC.

@RomneyDa
RomneyDa merged commit ad2d602 into main Oct 10, 2026
173 checks passed
@RomneyDa
RomneyDa deleted the fix/memory-runtime-late-manager-successor branch October 10, 2026 21:06
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
…law#168300)

The reload owner test acquires a default-purpose manager for agent "late"
while the reload fence is active and leaves it cached and live. Its file
watcher emits a reconcile invalidation on start, and after the 1.5s watch
debounce the background sync (now owned by the plugin lifecycle since
eaf60b0) resumes on the successor adapter and creates a second
successor provider, which closeAll correctly closes. Under CPU load that
debounce lands between commit and closeAll, so successorClose counted 2.

Acquire the late manager's successor provider explicitly after commit and
expect one successor close per live replacement-era manager.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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