Skip to content

refactor(active-memory): split runtime modules - #106285

Merged
steipete merged 8 commits into
mainfrom
codex/refactor-active-memory-modules
Jul 13, 2026
Merged

steipete merged 8 commits into
mainfrom
codex/refactor-active-memory-modules

Conversation

@steipete

@steipete steipete commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #106280

What Problem This Solves

The Active Memory plugin runtime had grown to 4,182 lines in one entrypoint, combining configuration, session eligibility, prompt/query shaping, transcript evidence, recall execution, and plugin registration. That made reviews slower and made ownership boundaries harder to see.

After refreshing the branch onto current main, the repository-wide type gates also exposed a pre-existing strict-indexing error in the new worker bundle manifest pruning code. That baseline error blocked exact-head validation for this refactor.

Why This Change Was Made

This keeps index.ts as the thin plugin registration surface and moves the existing runtime into focused sibling modules for types/constants, configuration, sessions, prompts/queries, transcript evidence, and recall execution. Runtime behavior, plugin exports, config/storage contracts, and the existing test helper surface remain unchanged. Every changed Active Memory production module is below the repository's 500-line LOC ratchet; the largest is 445 lines.

The worker bundle fix is one type-only annotation: the pruned JSON manifest remains a string-keyed record while dynamically named fields are deleted. Runtime bytes and behavior are unchanged.

User Impact

No user-visible behavior change. Maintainers get smaller review surfaces and explicit one-way module dependencies for future Active Memory fixes.

Evidence

  • corepack pnpm test extensions/active-memory — 179 tests passed on Blacksmith Testbox tbx_01kxe08p2t4208d1hdse6cct5t (Actions run).
  • corepack pnpm check:loc --base origin/main -- extensions/active-memory — all 13 changed Active Memory production files passed the 500-line ratchet on the same Testbox.
  • corepack pnpm check:test-types and corepack pnpm build — full test-type and build gates passed on the same Testbox.
  • Final Active Memory import cleanup rerun on Testbox tbx_01kxe17bwfqfvdwkatdyybenbz (Actions run): extension lint, 179 focused tests, and test types passed.
  • Fresh autoreview: Active Memory merge cleanup clean at 0.98 confidence; worker manifest annotation clean at 0.99 confidence.

AI-assisted: yes. The implementation and generated diff were reviewed against the complete Active Memory test surface.

@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Jul 13, 2026
@steipete
steipete force-pushed the codex/refactor-active-memory-modules branch 2 times, most recently from da2953a to 40e966a Compare July 13, 2026 11:06
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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. labels Jul 13, 2026
@clawsweeper

clawsweeper Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 13, 2026, 12:13 PM ET / 16:13 UTC.

Summary
The PR decomposes the Active Memory runtime into configuration, query, recall, session, transcript, and shared-type modules while retaining index.ts as the registration entrypoint.

PR surface: Source +489. Total +489 across 13 files.

Reproducibility: not applicable. This PR is a behavior-preserving refactor rather than a reported runtime defect. The packaging-surface problem is directly source-verifiable from the new top-level module placement and bundled entry discovery.

Review metrics: 1 noteworthy metric.

  • Packaged surface expansion: 12 top-level runtime modules added. Bundled discovery treats root-level plugin modules as build entries, so this structural split currently creates twelve unintended distributable surfaces.

Stored data model
Persistent data-model change detected: persistent cache schema: extensions/active-memory/recall.ts, serialized state: extensions/active-memory/session-policy.ts, serialized state: extensions/active-memory/session.ts, unknown-data-model-change: extensions/active-memory/session-policy.ts, unknown-data-model-change: extensions/active-memory/session.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #106280
Summary: This PR is the direct candidate implementation for the linked Active Memory module-splitting issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦐 gold shrimp
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Move the new implementation modules below the bundled top-level public-surface boundary and verify the packaged artifact list.
  • [P1] Add redacted after-fix output from a real configured Active Memory recall run.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR has extensive tests and CI but no after-fix evidence from a real Active Memory setup; add a redacted terminal transcript, live output, or runtime logs to the PR body, which should trigger re-review, or ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Merging the current layout would publish twelve implementation modules as independently importable bundled artifacts, unintentionally expanding and potentially freezing the Active Memory package surface.
  • [P1] Automated tests provide strong regression coverage, but they do not demonstrate that a real configured Active Memory recall still behaves identically after the module split.

Maintainer options:

  1. Keep runtime modules private (recommended)
    Move the split implementation files below a private subdirectory or narrowly exclude them from bundled public-surface discovery, verify packaged artifacts, and add real runtime proof before merge.

Next step before merge

  • [P1] A maintainer should require the concrete package-surface correction and contributor-supplied live runtime proof, then complete protected-label review; automation cannot supply proof from the contributor's setup.

Security
Cleared: The diff does not add dependencies, workflows, permissions, secret handling, downloads, or other concrete security or supply-chain exposure beyond the separately identified package-surface compatibility issue.

Review findings

  • [P2] Keep the split modules out of the packaged public surface — extensions/active-memory/config.ts:1
Review details

Best possible solution:

Move the implementation modules beneath a private directory such as runtime-internals/, update imports and package-artifact coverage so only intended entrypoints ship, then attach a redacted live Active Memory recall transcript or runtime log.

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

Not applicable: this PR is a behavior-preserving refactor rather than a reported runtime defect. The packaging-surface problem is directly source-verifiable from the new top-level module placement and bundled entry discovery.

Is this the best way to solve the issue?

No, not in its current layout. Splitting the monolith is appropriate, but private implementation modules should live below the top-level packaged entrypoint boundary rather than expanding the plugin's importable surface.

Full review comments:

  • [P2] Keep the split modules out of the packaged public surface — extensions/active-memory/config.ts:1
    Move these runtime implementation files beneath a private subdirectory, or narrowly exclude them from bundled entry discovery. Top-level plugin .ts files become independent packaged build entries, so the current layout exposes twelve internals under dist/extensions/active-memory/ and risks turning this refactor into an accidental compatibility contract.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add merge-risk: 🚨 compatibility: The current file placement makes private implementation modules importable packaged artifacts and could accidentally establish new plugin contracts.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P3: The PR is a maintainability refactor with no intended user-visible behavior change, despite requiring a packaging-boundary correction before merge.
  • merge-risk: 🚨 compatibility: The current file placement makes private implementation modules importable packaged artifacts and could accidentally establish new plugin contracts.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR has extensive tests and CI but no after-fix evidence from a real Active Memory setup; add a redacted terminal transcript, live output, or runtime logs to the PR body, which should trigger re-review, or ask a maintainer to comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +489. Total +489 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 13 4327 3838 +489
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 4327 3838 +489

What I checked:

  • Private modules remain top-level: At head a10dbc3, twelve runtime implementation modules are added directly under extensions/active-memory/, including config.ts, recall.ts, session.ts, and transcript.ts. (extensions/active-memory/config.ts:1, a10dbc346615)
  • Bundled packaging consumes discovered entries: The bundled build configuration consumes entries returned by the top-level plugin surface collector; the review discussion identifies that these new root-level files consequently appear under dist/extensions/active-memory/ as independently importable artifacts. (scripts/lib/bundled-plugin-build-entries.ts, ec2f0c6861fe)
  • Packaging finding remains unresolved: The actionable review at refactor(active-memory): split runtime modules #106285 (comment) asks that split implementation modules move into a private subdirectory or be excluded from public-surface collection; the latest file list still uses the top-level layout. (extensions/active-memory/index.ts:1, a10dbc346615)
  • Strong supplemental validation: The PR body reports 179 Active Memory tests, the LOC ratchet, test-type checks, and a build passing on Blacksmith Testbox tbx_01kxe08p2t4208d1hdse6cct5t. (extensions/active-memory/index.ts:1, a10dbc346615)
  • Real behavior proof is absent: The PR evidence contains automated tests, checks, and build output, but no redacted live Active Memory run, runtime logs, or terminal transcript showing unchanged recall behavior after the split. (a10dbc346615)

Likely related people:

  • steipete: The current Active Memory implementation history, linked refactor issue, and latest work on the runtime make this the strongest routing candidate for the module and packaging boundary. (role: feature owner and recent area contributor; confidence: high; commits: 7bbb9395400a, 68ff5315ab86, 2ce1804b10be; files: extensions/active-memory/index.ts, extensions/active-memory/config.ts, extensions/active-memory/recall.ts)
  • aaronmurdock: Recent merged Active Memory work connects this contributor to the existing runtime behavior and makes them a useful secondary reviewer for behavior-preservation concerns. (role: recent adjacent contributor; confidence: medium; files: extensions/active-memory/index.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • 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.
Review history (2 earlier review cycles)
  • reviewed 2026-07-13T11:20:43.152Z sha 40e966a :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-13T11:36:24.388Z sha 40e966a :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 13, 2026
@steipete
steipete force-pushed the codex/refactor-active-memory-modules branch from 40e966a to 15f9fcb Compare July 13, 2026 14:57
@steipete steipete self-assigned this Jul 13, 2026
@steipete
steipete force-pushed the codex/refactor-active-memory-modules branch from 7e3bb57 to f4dff5b Compare July 13, 2026 15:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4dff5b296

ℹ️ 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".

@@ -0,0 +1,397 @@
import path from "node:path";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep split modules out of packaged plugin surface

In packaged builds, bundled plugin discovery treats every top-level .ts file as a public build entry (collectTopLevelPublicSurfaceEntries), and listBundledPluginPackArtifacts() now includes dist/extensions/active-memory/config.js plus the other new sibling modules. That makes these private refactor modules shipped/importable artifacts instead of keeping index.ts/doctor-contract-api.ts as the only Active Memory surfaces, effectively freezing internals that this split was meant to keep local; move the runtime modules under a private subdirectory (or exclude them from the bundled public-surface collector) before release.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the codex/refactor-active-memory-modules branch from f4dff5b to a10dbc3 Compare July 13, 2026 15:41
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 13, 2026
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Jul 13, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification:

Known proof gap: no live provider recall run. This is a behavior-preserving module split; the full focused test surface and exact-head gates cover the moved branches.

@steipete
steipete merged commit 409d13f into main Jul 13, 2026
116 of 120 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the codex/refactor-active-memory-modules branch July 13, 2026 17:45
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 14, 2026
* refactor(active-memory): split runtime modules

* fix(active-memory): annotate hook deadline result

* refactor(active-memory): keep runtime modules bounded

* fix(active-memory): use type-only recall imports

* refactor(active-memory): supersede partial split

* fix(gateway): type pruned worker manifest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Split Active Memory runtime into focused modules

1 participant