Skip to content

refactor(anthropic): split session catalog into concept modules - #124342

Merged
steipete merged 2 commits into
mainfrom
steipete/split-anthropic-session-catalog
Aug 16, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/split-anthropic-session-catalog

Conversation

@steipete

@steipete steipete commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Anthropic session catalog remained a 2,075-line grandfathered max-lines file, which made its distinct responsibilities harder to review and kept the last suppression in this neighborhood outside the repository's current file-size standard.

Why This Change Was Made

This splits the catalog along the same concept-module seam pattern established for the Codex sibling in #124178: filesystem scan and bounded caches, CLI/Desktop discovery, parameter and cursor parsing, catalog/transcript listing, and adoption continuation. session-catalog.ts remains a 210-line runtime assembly and grep-stable export facade, while the continuation path stays separate from adoption because folding it there would create an import cycle through the runtime.

The change is behavior-neutral and leaves all existing importers untouched. It also removes the trailing max-lines suppression and its baseline entry, lowering the ratchet to 912.

User Impact

There is no user-visible behavior change. Maintainers get smaller concept-owned modules without importer churn, while the existing session catalog exports and adoption-continuation semantics remain intact.

Evidence

  • Line-multiset fidelity comparison between the original file and the six resulting modules found only oxfmt signature rewraps caused by added export keywords; all 92 top-level declarations are token-identical.
  • The adoption-continuation path retains the single module-level createSessionCatalogAdoptionCoordinator instance, memo key ${agentId}\0${sourceKey}, and narrowed loadedHistory local with its explanatory comment.
  • Existing importers remain unchanged: session-catalog.test.ts, session-catalog-node-commands.ts, and the lazy-import boundary in session-catalog-registration.ts.
  • node scripts/run-vitest.mjs over extensions/anthropic/{session-catalog,lazy-import,session-catalog-history,index,openclaw.plugin}.test.ts: 5 files, 118 tests passed.
  • CI=1 node scripts/check-changed.mjs: clean; max-lines ratchet 912, import cycles 0, oxfmt clean.
  • Targeted oxlint across all six session-catalog modules: clean.
  • Follow-up commit 8cbb88d489758844ccae2db6e296e27deca93df5 moved the record-shaped caches into discovery, removing the scan-to-discovery type edge while keeping cache ownership with record discovery.
  • Exact-head re-verification is clean: Madge reports 0 cycles, runtime topology reports 0 cycles, the focused session-catalog and lazy-import suites pass, and a fresh whole-branch Codex autoreview found no accepted/actionable findings.
  • Raw diff is +113 lines, entirely module/import/re-export formatting overhead; net production logic growth is at most zero and tests are +0/-0.

AI-assisted change. No agent transcript included.

Follow the #124178 sibling seam pattern while preserving behavior. Remove the max-lines suppression and baseline entry after the split.
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 16, 2026 01:56
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 15, 2026, 10:02 PM ET / August 16, 2026, 02:02 UTC.

ClawSweeper review

What this changes

The PR splits Anthropic’s local Claude session catalog into scan, discovery, parsing, listing, and continuation modules while preserving its facade.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open: the refactor remains necessary, but the extracted modules introduce a static import cycle that blocks the required architecture check.

Priority: P3
Reviewed head: e8ad96f4dcd5d4082bb79ea8c403b7b5c64f7c57

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The extraction is coherent, but the introduced static cycle blocks required architecture validation.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored behavior-neutral refactor does not require contributor real-behavior proof; the architecture guard must still pass.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored behavior-neutral refactor does not require contributor real-behavior proof; the architecture guard must still pass.
Evidence reviewed 4 items Static dependency cycle: Scan type-imports CatalogRecord from discovery, while discovery value-imports scan helpers. The Madge guard includes all static imports, including type imports, so this creates a cycle.
Current-main behavior: Current main still has a 2,075-line Anthropic session-catalog facade with its grandfathered max-lines suppression, so the cleanup is not already implemented.
Entry point and coverage: Registration lazily loads the facade, which delegates list, read, continuation, and terminal operations to the extracted modules; the existing catalog tests exercise provider registration and these operations.
Findings 1 actionable finding [P2] Move the catalog record type out of the static import cycle
Security None None.

How this fits together

The Anthropic plugin discovers local Claude sessions and exposes catalog listing, transcript reading, and session continuation through OpenClaw’s shared session-catalog API. Gateway requests enter via the registered provider and are delegated by the facade to these modules.

flowchart LR
  A[Claude session files] --> B[Discovery and scan]
  C[Gateway catalog request] --> D[Anthropic catalog facade]
  D --> E[Listing and transcript read]
  E --> F[Session catalog response]
  D --> G[Session continuation]
  G --> H[OpenClaw session]
Loading

Before merge

  • Move the catalog record type out of the static import cycle (P2) - Discovery value-imports scan helpers while this new type import points scan back at discovery. The required Madge guard includes type imports, so it reports a circular dependency and the architecture job cannot pass. Put the shared record type in the leaf types module and import it from both modules.

Findings

  • [P2] Move the catalog record type out of the static import cycle — extensions/anthropic/session-catalog-scan.ts:5
Agent review details

Security

None.

PR surface

Source +113, Other -1. Total +112 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 6 1998 1885 +113
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 7 1998 1886 +112

Review metrics

Metric Value Why it matters
Production versus test delta production +113 net (1,998 added, 1,885 removed); tests +0/-0 The intended behavior-neutral extraction adds module/export overhead without test churn; the remaining blocker is the static cycle.

Stored data model

Persistent data-model change detected: serialized state: extensions/anthropic/session-catalog-continue.ts, serialized state: extensions/anthropic/session-catalog-discovery.ts, serialized state: extensions/anthropic/session-catalog-listing.ts, serialized state: extensions/anthropic/session-catalog-parsing.ts, serialized state: extensions/anthropic/session-catalog-scan.ts, serialized state: extensions/anthropic/session-catalog.ts, and 6 more. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Move CatalogRecord into the existing leaf types module, import it from scan and discovery, and rerun the architecture guard.

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

Yes. The architecture guard statically collects every import, and the scan/discovery pair forms a deterministic cycle from the proposed source.

Is this the best way to solve the issue?

No. The concept split is appropriate, but the shared record type must be a leaf contract rather than creating a scan/discovery dependency cycle.

Full review comments:

  • [P2] Move the catalog record type out of the static import cycle — extensions/anthropic/session-catalog-scan.ts:5
    Discovery value-imports scan helpers while this new type import points scan back at discovery. The required Madge guard includes type imports, so it reports a circular dependency and the architecture job cannot pass. Put the shared record type in the leaf types module and import it from both modules.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is internal maintainability work with no intended user-visible behavior change.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored behavior-neutral refactor does not require contributor real-behavior proof; the architecture guard must still pass.

Label justifications:

  • P3: This is internal maintainability work with no intended user-visible behavior change.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored behavior-neutral refactor does not require contributor real-behavior proof; the architecture guard must still pass.

Evidence

What I checked:

Likely related people:

  • steipete: Recent main history attributes the central catalog continuation path to this contributor, who also authored the merged related catalog refactor. (role: recent area contributor; confidence: high; commits: 394648c7021a, 7862a5da1592; files: extensions/anthropic/session-catalog.ts, extensions/anthropic/session-catalog-registration.ts)

Rank-up moves

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

  • Move CatalogRecord to a leaf contract shared by scan and discovery.
  • Rerun the exact-head architecture check after removing the cycle.

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.

The record-shaped caches (catalogDiscoveryCache, claudeSessionScanCache,
their entry types, bounds, and TTLs) are consumed only by discovery; moving
them out of scan removes the scan->discovery type-import edge flagged by the
madge topology gate and leaves scan as record-agnostic fs primitives.
@steipete steipete self-assigned this Aug 16, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

ClawSweeper rank-up move handling for exact head 8cbb88d489758844ccae2db6e296e27deca93df5:

  • “Move CatalogRecord to a leaf contract”: skipped in its literal form. Commit 8cbb88d489758844ccae2db6e296e27deca93df5 instead moves the record-shaped caches into session-catalog-discovery.ts, their owning module, which deletes the scan-to-discovery type edge entirely without adding another shared contract.
  • “Rerun the exact-head architecture check”: applied. Madge reports 0 cycles and runtime topology reports 0 cycles; the focused session-catalog and lazy-import suites are green. A fresh whole-branch Codex autoreview also found no accepted/actionable findings.

No behavior-changing edits were made after that reviewed head.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification for exact head 8cbb88d489758844ccae2db6e296e27deca93df5:

  • Focused proof: node scripts/run-vitest.mjs extensions/anthropic/session-catalog.test.ts extensions/anthropic/lazy-import.test.ts passed.
  • Architecture/static proof: CI=1 node scripts/check-changed.mjs passed, including Madge 0 cycles, runtime topology 0 cycles, max-lines, formatting, and targeted static checks.
  • Independent review: fresh whole-branch Codex autoreview versus origin/main found no accepted/actionable findings; it was intentionally not rerun after the unchanged reviewed head.
  • Exact-head CI: node scripts/watch-pr-ci.mjs 124342 8cbb88d489758844ccae2db6e296e27deca93df5 reported GREEN for https://github.com/openclaw/openclaw/actions/runs/31921247665.
  • Native review artifacts validated with READY FOR /prepare-pr, issueValidation.status=valid, zero findings, and behavioral sweep pass.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 124342 completed in hosted_exact_or_recent_parent mode, made no rebase or head change, and verified the remote PR tree matches the prepared head. No separate Testbox lease/run was created because the exact-head hosted gate was reusable.

Known proof gap: no live behavior proof was run; this is a behavior-neutral module extraction with unchanged importers, so focused regression suites plus exact-head CI are the appropriate proof surface.

@steipete
steipete merged commit df2b83f into main Aug 16, 2026
182 checks passed
@steipete
steipete deleted the steipete/split-anthropic-session-catalog branch August 16, 2026 02:18
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 16, 2026
…claw#124342)

* refactor(anthropic): split session-catalog into concept modules

Follow the openclaw#124178 sibling seam pattern while preserving behavior. Remove the max-lines suppression and baseline entry after the split.

* refactor(anthropic): own record caches in session-catalog-discovery

The record-shaped caches (catalogDiscoveryCache, claudeSessionScanCache,
their entry types, bounds, and TTLs) are consumed only by discovery; moving
them out of scan removes the scan->discovery type-import edge flagged by the
madge topology gate and leaves scan as record-agnostic fs primitives.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: anthropic maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant