Skip to content

refactor: dedupe session-catalog cursor paging and sleep helper clones - #124569

Merged
steipete merged 2 commits into
mainfrom
steipete/cleanup-dedupe-batch
Aug 16, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/cleanup-dedupe-batch

Conversation

@steipete

Copy link
Copy Markdown
Contributor
Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Two clusters of copy-pasted code were drifting hazards:

  1. extensions/acpx/src/pi-session-catalog.ts and extensions/opencode/session-catalog.ts each carried ~114 byte-identical lines of session-catalog cursor paging scaffolding (boundedLimit / encodeCursor / decodeCursor / optionalRawCursor / transcriptPage). Any future paging fix would have to be applied twice, and the copies could silently diverge.
  2. src/gateway/desktop/managed-linux.ts and src/agents/embedded-agent-runner/run/attempt-async-tasks.ts each had a private sleep() clone duplicating canonical helpers that already exist in the repo.

Why This Change Was Made

The cursor-paging scaffolding moves into the existing private-local SDK subpath src/plugin-sdk/session-catalog-runtime.ts (already listed in plugin-sdk-private-local-only-subpaths.json and already consumed by beam — no new public surface). Both plugins keep their plugin-named cursor guards as direct aliases, so error strings, cursor canonical form, and byte budgets are unchanged.

The managed-linux readiness poll now uses @openclaw/retry sleepWithAbort with ref: false (preserving the clone's timer.unref() behavior), and the embedded agent runner's async-task wait uses src/utils/sleep.ts. A third sleep copy in the update-managed-service handoff script is intentionally kept: it lives inside a serialized standalone script (String.raw template) that cannot import repo modules; noted in the commit body.

User Impact

No user-visible behavior change. Behavior-neutral refactor: one canonical owner for session-catalog cursor paging and sleep semantics, net -96 production LOC, zero test lines touched.

Evidence

  • node scripts/run-vitest.mjs extensions/acpx/src/pi-session-catalog extensions/opencode/session-catalog src/gateway/desktop/managed-linux.test.ts src/agents/embedded-agent-runner/run/attempt.async-tasks.test.ts — 4 shards passed post-rebase (7 + 20 + 18 tests plus managed-linux suite, all green).
  • plugin-sdk:surface:check (via node --import tsx scripts/plugin-sdk-surface-report.mts --check) — clean, package-exported forbidden subpaths: 0.
  • tsgo core + extensions typecheck lanes — clean.
  • Autoreview clean (0.99), no accepted/actionable findings.
  • git diff --numstat vs origin/main: production delta net -96 LOC (extensions -208/+34, core sleep sites -14/+5, +121 relocated canonical copy in src/plugin-sdk/session-catalog-runtime.ts); no test files changed.

…on-catalog-runtime

The acpx Pi and opencode session catalogs carried byte-identical
boundedLimit/encodeCursor/decodeCursor/optionalRawCursor/transcriptPage
scaffolding (~114 duplicated lines each). Move one canonical copy into the
private-local session-catalog-runtime SDK subpath both plugins already may
import, and keep the plugin-named cursor guards as direct aliases.

Net -87 production LOC; no behavior change (error strings, cursor canonical
form, and byte budgets are unchanged).
…elpers

managed-linux readiness polling now uses @openclaw/retry sleepWithAbort with
ref:false (preserving the clone's timer.unref behavior), and the embedded
agent runner's async-task wait uses src/utils/sleep.ts. Both clones matched
canonical semantics on real inputs (positive integer poll intervals).

The update-managed-service-handoff copy stays: it lives inside a serialized
standalone handoff script (String.raw template) that cannot import repo
modules.
@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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling extensions: acpx extensions: opencode size: M maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 12:35
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 8:41 AM ET / 12:41 UTC.

ClawSweeper review

What this changes

The PR centralizes duplicated session-catalog cursor paging in a private plugin SDK runtime module and replaces two local delay helpers with canonical sleep utilities.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for normal maintainer handling. Direct source review found no blocking correctness or security issue; current main has not absorbed this refactor, and the maintainer label prevents automated cleanup.

Priority: P3
Reviewed head: 81736911bdf5f396966512d475a7e629332959da

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The refactor is coherent, preserves the inspected contracts, and has focused existing coverage for the moved behavior.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, non-user-visible refactor is outside the external-contributor real-behavior-proof gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, non-user-visible refactor is outside the external-contributor real-behavior-proof gate.
Evidence reviewed 6 items Shared paging owner: The PR head retains the existing limit bounds, canonical cursor validation, UTF-8 truncation, and page-byte cap in one private runtime owner.
Private SDK boundary: The runtime subpath was already listed as private-local-only and package-exported, so this does not create a public third-party SDK contract.
Existing behavior coverage: The ACPX and OpenCode catalog tests exercise page ordering, cursor rejection, and transcript byte budgets through their provider-facing paths.
Findings None None.
Security None None.

How this fits together

ACPX and OpenCode session catalogs turn local session data into paged Gateway results. Managed desktop startup and embedded-agent task completion both use bounded waits while their runtime work progresses.

flowchart LR
  A[ACPX session catalog] --> C[Shared cursor paging]
  B[OpenCode session catalog] --> C
  C --> D[Gateway session results]
  E[Desktop readiness poll] --> F[Abortable shared delay]
  G[Embedded task polling] --> H[Canonical delay]
  F --> I[Runtime lifecycle]
  H --> I
Loading

Before merge

  • Complete next step (P2) - The maintainer label and normal exact-head review gates require human handling; no mechanical repair is indicated.
Agent review details

Security

None.

PR surface

Source -96. Total -96 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 5 160 256 -96
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 5 160 256 -96

Review metrics

Metric Value Why it matters
Production versus test delta production -96, tests 0 The refactor removes duplicate production logic without expanding test surface or public configuration.

Stored data model

Persistent data-model change detected: serialized state: extensions/acpx/src/pi-session-catalog.ts, serialized state: extensions/opencode/session-catalog.ts, serialized state: src/plugin-sdk/session-catalog-runtime.ts, unknown-data-model-change: extensions/opencode/session-catalog.ts, unknown-data-model-change: src/plugin-sdk/session-catalog-runtime.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep one private local runtime owner for shared paging and land once the exact-head maintainer review and checks are complete.

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

Not applicable: this PR is a behavior-neutral refactor; existing focused provider tests cover the moved paging behavior.

Is this the best way to solve the issue?

Yes: the pre-existing private SDK subpath is the narrow shared owner for two bundled callers, avoiding renewed provider-local copies.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a behavior-neutral maintenance refactor with no reported user-facing regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, non-user-visible refactor is outside the external-contributor real-behavior-proof gate.

Label justifications:

  • P3: This is a behavior-neutral maintenance refactor with no reported user-facing regression.
  • 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-authored, non-user-visible refactor is outside the external-contributor real-behavior-proof gate.

Evidence

What I checked:

Likely related people:

  • steipete: The pre-refactor ACPX/OpenCode paging and the two delay call sites are blamed to the recent session-catalog/gateway feature work. (role: recent feature contributor; confidence: high; commits: eae415b6213b, 0dffb8fa05d8, 81736911bdf5; files: extensions/acpx/src/pi-session-catalog.ts, extensions/opencode/session-catalog.ts, src/gateway/desktop/managed-linux.ts)

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.

@steipete
steipete merged commit 0d9a424 into main Aug 16, 2026
264 checks passed
@steipete
steipete deleted the steipete/cleanup-dedupe-batch branch August 16, 2026 12:57
@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 17, 2026
openclaw#124569)

* refactor(plugin-sdk): dedupe session-catalog cursor paging into session-catalog-runtime

The acpx Pi and opencode session catalogs carried byte-identical
boundedLimit/encodeCursor/decodeCursor/optionalRawCursor/transcriptPage
scaffolding (~114 duplicated lines each). Move one canonical copy into the
private-local session-catalog-runtime SDK subpath both plugins already may
import, and keep the plugin-named cursor guards as direct aliases.

Net -87 production LOC; no behavior change (error strings, cursor canonical
form, and byte budgets are unchanged).

* refactor(core): replace private sleep() clones with canonical sleep helpers

managed-linux readiness polling now uses @openclaw/retry sleepWithAbort with
ref:false (preserving the clone's timer.unref behavior), and the embedded
agent runner's async-task wait uses src/utils/sleep.ts. Both clones matched
canonical semantics on real inputs (positive integer poll intervals).

The update-managed-service-handoff copy stays: it lives inside a serialized
standalone handoff script (String.raw template) that cannot import repo
modules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: acpx extensions: opencode gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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