Skip to content

refactor(memory-core): split CLI runtime - #114013

Merged
steipete merged 3 commits into
mainfrom
codex/bench10-memory-core-cli-runtime-split
Jul 26, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/bench10-memory-core-cli-runtime-split

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The memory-core CLI runtime combined status diagnostics, source scanning, indexing, search, promotion, REM preview, and REM backfill in one 2,053-line lazy runtime module with a grandfathered max-lines suppression.

Why This Change Was Made

This maintainer-requested refactor keeps the existing cli.ts -> import("./cli.runtime.js") lazy boundary unchanged. The runtime barrel now delegates to focused status, index/search/promotion, REM, and shared-support modules; every production module is below 700 lines, the max-lines suppression and baseline entry are removed, and total source LOC decreases by five.

Accepted tradeoff: index/search and promotion remain together because they share the manager lifecycle and output primitives; splitting them again would add module contracts without reducing ownership complexity. The index progress formatter was folded to one duration helper while retaining the same elapsed and ETA output.

User Impact

No user-visible behavior changes. Memory status, indexing, search, promotion, REM preview/backfill, JSON output, diagnostics, and the lazy loading contract remain unchanged.

AI-assisted refactor, reviewed and understood by the maintainer agent.

Evidence

  • node scripts/run-vitest.mjs extensions/memory-core/src/cli.test.ts extensions/memory-core/cli-metadata.test.ts — 2 files, 76 tests passed.
  • Blacksmith Testbox tbx_01kye9f2drdadmvb8210xf4aq8: pnpm check:changed && pnpm build passed, including extension production/test types, lint, max-lines ratchet, plugin boundaries, import-cycle checks, and the built lazy runtime graph. Actions run: https://github.com/openclaw/openclaw/actions/runs/30187161169
  • Repository Autoreview --mode uncommitted — clean, no accepted/actionable findings. The older global helper crashed in its JavaScript sanitizer before engine invocation; the current repository helper completed with the same Codex engine and bundle contract.
  • git diff --check — passed.

@steipete
steipete marked this pull request as ready for review July 26, 2026 04:13
@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: XL maintainer Maintainer-authored PR labels Jul 26, 2026
@clawsweeper clawsweeper Bot added 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 26, 2026
@clawsweeper

clawsweeper Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 26, 2026, 12:33 AM ET / 04:33 UTC.

ClawSweeper review

What this changes

This PR decomposes Memory Core’s lazy CLI implementation into separate status, index/search, REM, and shared-support modules while keeping the existing lazy CLI entry boundary.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep this PR open for maintainer review. It is a scoped internal refactor with no concrete patch defect identified from the supplied diff and validation evidence, but the protected maintainer label requires explicit maintainer handling; likely related people: steipete (current Memory Core CLI contributor, medium confidence).

Priority: P3
Reviewed head: dc7bb1472a0621067bdecb8f42e8dd1fedaf95e9
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch presents a coherent behavior-preserving runtime split with focused coverage and reported build validation; final acceptance is appropriately owner-led because it changes internal module boundaries broadly.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-labeled internal refactor is outside the external-contributor real-behavior-proof gate; the reported focused tests and build remain useful supplemental validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-labeled internal refactor is outside the external-contributor real-behavior-proof gate; the reported focused tests and build remain useful supplemental validation.
Evidence reviewed 6 items Scoped runtime split: The proposed branch reduces extensions/memory-core/src/cli.runtime.ts to an eight-line delegating barrel and moves its command implementations into focused runtime modules for status, index/search/promotion, REM, and shared support.
Lazy-boundary preservation: The PR body states that the existing cli.ts lazy import of ./cli.runtime.js is intentionally retained; the split remains behind that public CLI loading boundary.
Focused regression coverage follows moved secret resolution: The branch updates the command-secret-resolution coverage test to point from the former monolithic runtime to cli-runtime-common.ts, where command secret resolution now resides.
Findings None None.
Security None None.

How this fits together

Memory Core’s CLI accepts operator commands for status, indexing, search, promotion, and REM workflows. The lazy runtime loads command handlers, resolves configuration and secrets, acquires the memory manager, and emits command output or diagnostics.

flowchart LR
  A[Memory CLI commands] --> B[Lazy CLI entry]
  B --> C[Runtime barrel]
  C --> D[Status and repair handlers]
  C --> E[Index search and promotion]
  C --> F[REM handlers]
  D --> G[Memory manager]
  E --> G
  F --> G
  G --> H[CLI output and JSON diagnostics]
Loading

Decision needed

Question Recommendation
Does the Memory Core owner approve this full CLI-runtime decomposition as the preferred long-term module boundary after confirming command routing and output remain unchanged? Approve the split: Accept the current status, index/search, REM, and shared-support boundaries once required checks complete and the owner is satisfied that no command contract moved.

Why: The patch intentionally chooses ownership boundaries for a large internal runtime; tests support the refactor, but the protected maintainer label reserves acceptance of that structural direction for a human owner.

Before merge

  • Add real behavior proof - Not applicable: This maintainer-labeled internal refactor is outside the external-contributor real-behavior-proof gate; the reported focused tests and build remain useful supplemental validation.
  • Resolve merge risk (P1) - The split relocates every Memory Core CLI command path, so a final maintainer pass should preserve command output, JSON behavior, diagnostics, and the lazy import contract across status, indexing, search, promotion, and REM commands.
  • Resolve merge risk (P1) - Some broader GitHub matrix lanes were still running at the captured review state; completion is normal merge gating rather than evidence of a patch defect.
  • Complete next step (P2) - The protected maintainer label and intentional module-boundary choice require owner approval rather than an automated repair or cleanup action.
Agent review details

Security

None.

PR surface

Source -4, Tests 0, Other -1. Total -5 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 5 2049 2053 -4
Tests 1 1 1 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 7 2050 2055 -5

Review metrics

Metric Value Why it matters
Runtime decomposition 1 monolithic lazy runtime replaced by 1 barrel plus 4 focused runtime modules This is a large ownership-boundary refactor, so preserving the existing CLI entry and command contracts matters more than line-count reduction alone.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/memory-core/src/cli-status.runtime.ts, migration/backfill/repair: extensions/memory-core/src/cli.runtime.ts, unknown-data-model-change: extensions/memory-core/src/cli-index-search.runtime.ts, unknown-data-model-change: extensions/memory-core/src/cli-rem.runtime.ts, unknown-data-model-change: extensions/memory-core/src/cli-runtime-common.ts, unknown-data-model-change: extensions/memory-core/src/cli-status.runtime.ts, and 6 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm command-contract preservation (recommended)
    Before merge, review the exported barrel delegation and exact-head checks to ensure existing CLI output, JSON diagnostics, and lazy loading remain unchanged.
  2. Accept the structural risk
    Merge after the owner accepts that the reported focused tests and build are sufficient for this behavior-neutral CLI reorganization.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Wait for required checks, then verify the runtime barrel retains all previous command exports and the lazy import boundary.

Technical review

Best possible solution:

Land the focused refactor only after maintainer review confirms the barrel exports preserve the lazy CLI contract and the exact head completes its required checks; retain the focused command coverage as the regression guard.

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

Not applicable: this PR refactors an existing CLI implementation rather than fixing a reported failing user workflow. The review question is contract preservation across existing commands.

Is this the best way to solve the issue?

Yes, conditionally: keeping the existing lazy entry and using a small delegating barrel is a maintainable way to divide the oversized runtime, provided the owner approves these module boundaries and command contracts remain unchanged.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fc3476b116b9.

Labels

Label justifications:

  • P3: The PR is an internal maintainability refactor with no reported user-facing behavior change or confirmed regression.
  • merge-risk: 🚨 compatibility: Moving all Memory Core CLI handlers can accidentally alter existing command routing, output, JSON diagnostics, or lazy-load behavior despite the intended behavior-neutral scope.
  • 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: This maintainer-labeled internal refactor is outside the external-contributor real-behavior-proof gate; the reported focused tests and build remain useful supplemental validation.

Evidence

What I checked:

  • Scoped runtime split: The proposed branch reduces extensions/memory-core/src/cli.runtime.ts to an eight-line delegating barrel and moves its command implementations into focused runtime modules for status, index/search/promotion, REM, and shared support. (extensions/memory-core/src/cli.runtime.ts:1, dc7bb1472a06)
  • Lazy-boundary preservation: The PR body states that the existing cli.ts lazy import of ./cli.runtime.js is intentionally retained; the split remains behind that public CLI loading boundary. (extensions/memory-core/src/cli.runtime.ts:1, dc7bb1472a06)
  • Focused regression coverage follows moved secret resolution: The branch updates the command-secret-resolution coverage test to point from the former monolithic runtime to cli-runtime-common.ts, where command secret resolution now resides. (src/cli/command-secret-resolution.coverage.test.ts:7, dc7bb1472a06)
  • Reported validation: The PR reports 76 focused Memory Core CLI tests, a successful changed-check/build Testbox run, a clean repository autoreview, and a clean diff check; GitHub checks also show the relevant fast guards succeeding while part of the broader matrix remains in progress. (dc7bb1472a06)
  • Protected review routing: The supplied PR context includes the protected maintainer label, so this cleanup workflow must not close or autonomously resolve the PR.
  • Review continuity: The preceding ClawSweeper review at 5c321638930cc21eccb0b5c35c594eaee6791078 reported no patch findings; subsequent branch commits narrowed helper exports and updated the secret-resolver coverage reference. (extensions/memory-core/src/cli-runtime-common.ts:1, dc7bb1472a06)

Likely related people:

  • steipete: Authored all three commits in the proposed Memory Core CLI-runtime split, including the narrowed helper exports and moved secret-resolution coverage. (role: current area contributor; confidence: medium; commits: 756fbfd872aa, b517ce0735d6, dc7bb1472a06; files: extensions/memory-core/src/cli.runtime.ts, extensions/memory-core/src/cli-runtime-common.ts, src/cli/command-secret-resolution.coverage.test.ts)

Rank-up moves

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

  • Complete the in-progress required checks on the exact head.
  • Have the Memory Core owner confirm the delegated barrel preserves all prior command exports and lazy loading.

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 (1 earlier review cycle)
  • reviewed 2026-07-26T04:17:01.301Z sha 5c321638930cc21eccb0b5c35c594eaee6791078 :: needs real behavior proof before merge. :: none

@steipete
steipete force-pushed the codex/bench10-memory-core-cli-runtime-split branch from 13ea9b2 to b517ce0 Compare July 26, 2026 04:21
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 26, 2026
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Jul 26, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for head dc7bb1472a0621067bdecb8f42e8dd1fedaf95e9:

  • node scripts/run-vitest.mjs extensions/memory-core/src/cli.test.ts extensions/memory-core/cli-metadata.test.ts src/cli/command-secret-resolution.coverage.test.ts — 3 files, 94 tests passed.
  • Blacksmith Testbox tbx_01kye9f2drdadmvb8210xf4aq8 / Actions run https://github.com/openclaw/openclaw/actions/runs/30187161169 — pnpm check:changed && pnpm build passed, including extension production/test types, lint, max-lines, plugin boundaries, import cycles, and the built lazy-runtime graph.
  • Exact-head CI https://github.com/openclaw/openclaw/actions/runs/30187846131 — required checks green. The earlier check-dependencies unused-export failure and command-secret coverage failure were fixed by narrowing extracted helpers and moving the coverage target to their canonical owner.
  • Repository Autoreview --mode branch --base origin/main — clean, no accepted/actionable findings.
  • scripts/pr review-validate-artifacts 114013 — passed with READY FOR /prepare-pr, zero findings, and valid issue validation.
  • Source surface is net −4 lines; total diff is net −5. The original cli.ts -> import("./cli.runtime.js") lazy seam is unchanged and every production module is below 700 lines.

Known gaps: none for this behavior-neutral refactor. No config, API, persistence format, or schema changes are present.

@steipete
steipete merged commit 99d8d90 into main Jul 26, 2026
121 of 123 checks passed
@steipete
steipete deleted the codex/bench10-memory-core-cli-runtime-split branch July 26, 2026 04:38
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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