Skip to content

refactor(acp): split grandfathered translator and event-ledger files - #120941

Merged
steipete merged 2 commits into
mainfrom
steipete/acp-split-translator-ledger
Aug 9, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/acp-split-translator-ledger

Conversation

@steipete

@steipete steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The ACP bridge translator and replay ledger were grandfathered oversized files with max-lines suppressions, which made their distinct lifecycle, streaming, approval, replay, and persistence responsibilities harder to review and maintain.

Why This Change Was Made

This maintainer-requested refactor mechanically extracts those responsibilities into concept-named ACP modules while retaining translator.ts and event-ledger.ts as the stable public entry points. Shared mutable state and operation ordering remain owned by the same translator and ledger flows; no public exports or runtime behavior change.

AI-assisted: yes. The complete diff was reviewed with the repository autoreview workflow and all findings were addressed.

User Impact

There is no user-visible behavior change. ACP bridge sessions, prompt streaming, approval relays, replay, and SQLite/in-memory ledger behavior remain the same, while each production module is now below the repository's file-size threshold.

Evidence

  • pnpm format config/max-lines-baseline.txt src/acp/event-ledger.ts src/acp/event-ledger.types.ts src/acp/event-ledger.memory.ts src/acp/event-ledger.sqlite.ts src/acp/translator.ts src/acp/translator.agent-events.ts src/acp/translator.disconnects.ts src/acp/translator.prompt-state.ts src/acp/translator.prompt-stream.ts src/acp/translator.session-lifecycle.ts src/acp/translator.session-state.ts — passed.
  • node scripts/run-vitest.mjs src/acp — 172 test files passed, 1,369 tests passed.
  • node scripts/check-changed.mjs — passed all selected ratchets, typechecks, lint, dead-export, import-cycle, and boundary guards on Blacksmith Testbox.
  • pnpm build — passed; no [INEFFECTIVE_DYNAMIC_IMPORT] warning.
  • .agents/skills/autoreview/scripts/autoreview --mode local --stream-engine-output — clean, no accepted/actionable findings.
  • The behavioral diff is move-only extraction. Existing tests are unchanged; the only policy changes remove the two oxlint-disable max-lines comments and only the src/acp/translator.ts and src/acp/event-ledger.ts max-lines baseline entries.

@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Aug 9, 2026
@steipete
steipete marked this pull request as ready for review August 9, 2026 06:12
@steipete
steipete force-pushed the steipete/acp-split-translator-ledger branch from f26d4c2 to e341459 Compare August 9, 2026 07:37
@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 Aug 9, 2026
@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 3:43 AM ET / 07:43 UTC.

ClawSweeper review

What this changes

The PR splits ACP translation, session lifecycle, prompt streaming, and replay-ledger responsibilities into focused modules while retaining the existing translator and ledger entry points.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking defect was found in this maintainer-owned ACP refactor. Keep it open for normal maintainer review and exact-head CI completion.

Priority: P3
Reviewed head: e34145907eee4556a05c7168c3a112f3df84419a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The source review found preserved public and persistence boundaries with substantial stated focused validation; exact-head CI remains the merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-owned internal refactor has no new user-visible interaction; focused ACP regression and build evidence is the relevant proof path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-owned internal refactor has no new user-visible interaction; focused ACP regression and build evidence is the relevant proof path.
Evidence reviewed 6 items Stable ACP façade: The public agent entry point keeps shared session-update, session-state, approval, and prompt collaborators, then delegates the same public operations to extracted owners.
Caller and public ledger contract: Gateway callbacks still target the translator façade, and the ledger façade continues to export the in-memory factory and public ledger types used by server and tests.
Persistence and lifecycle preservation: SQLite remains the ledger owner; writes still use the synchronous state transaction, while new, load, and resume paths retain ledger creation and replay ordering.
Findings None None.
Security None None.

How this fits together

ACP converts Agent Client Protocol session and prompt requests into Gateway chat operations and returns updates to the client. A replay ledger records those operations in memory or SQLite so sessions can be rehydrated.

flowchart LR
  A[ACP client] --> B[ACP bridge]
  B --> C[Session and prompt coordination]
  C --> D[Gateway chat]
  C --> E[Replay ledger]
  E --> F[Memory or SQLite state]
  D --> G[ACP updates]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head CI is still in progress; merge only after required checks complete successfully.
Agent review details

Security

None.

PR surface

Source +289, Other -2. Total +287 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 10 2342 2053 +289
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 2 -2
Total 11 2342 2055 +287

Review metrics

Metric Value Why it matters
Production versus test delta production +2,342/-2,055 (net +287); tests +0/-0 The net production growth is justified by separating two grandfathered oversized ownership boundaries while preserving the existing test suite.
Max-lines exemptions 2 removed The refactor achieves its stated maintainability goal by removing the two baseline exemptions rather than adding a new suppression.

Stored data model

Persistent data-model change detected: serialized state: src/acp/event-ledger.memory.ts, vector/embedding metadata: src/acp/translator.session-state.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the stable translator and ledger façades while letting the extracted modules own the existing lifecycle, streaming, approval, replay, and persistence responsibilities.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the stable translator and ledger façades while letting the extracted modules own the existing lifecycle, streaming, approval, replay, and persistence responsibilities.

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

Not applicable: the PR is intended to preserve existing ACP behavior while reorganizing its internal implementation.

Is this the best way to solve the issue?

Yes: keeping the established façades and extracting coherent lifecycle and ledger owners is the narrowest maintainable approach; moving the public boundary would add compatibility risk without benefit.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a non-user-visible internal maintainability refactor.
  • 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-owned internal refactor has no new user-visible interaction; focused ACP regression and build evidence is the relevant proof path.

Label justifications:

  • P3: This is a non-user-visible internal maintainability refactor.
  • 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-owned internal refactor has no new user-visible interaction; focused ACP regression and build evidence is the relevant proof path.

Evidence

What I checked:

  • Stable ACP façade: The public agent entry point keeps shared session-update, session-state, approval, and prompt collaborators, then delegates the same public operations to extracted owners. (src/acp/translator.ts:75, e34145907eee)
  • Caller and public ledger contract: Gateway callbacks still target the translator façade, and the ledger façade continues to export the in-memory factory and public ledger types used by server and tests. (src/acp/event-ledger.ts:22, e34145907eee)
  • Persistence and lifecycle preservation: SQLite remains the ledger owner; writes still use the synchronous state transaction, while new, load, and resume paths retain ledger creation and replay ordering. (src/acp/translator.session-lifecycle.ts:130, e34145907eee)
  • Existing regression coverage: Current ACP tests cover memory and SQLite replay/retention, rejected sends, ledger write failures, and the SQLite-only migration path; this extraction leaves those tests unchanged. (src/acp/event-ledger.test.ts:14, 499d81cdbdad)
  • Current-main comparison and provenance: Current main has no ACP-path changes beyond the PR base, so the behind-base state does not conceal an ACP overlap; available history attributes the current ACP wrapper ancestry to Peter Steinberger. (src/acp/translator.ts:61, 7b076155)
  • Security and diff hygiene: The patch changes ACP source and the max-lines baseline only; it introduces no workflow, dependency, lockfile, package, publishing, or credential surface, and has no whitespace errors. (config/max-lines-baseline.txt:322, e34145907eee)

Likely related people:

  • steipete: Authored both refactor commits and the available ACP wrapper history attributes the current surface to Peter Steinberger. (role: current and recent ACP contributor; confidence: high; commits: 1c66a889a5be, e34145907eee, 7b076155; files: src/acp/translator.ts, src/acp/event-ledger.ts)
  • obviyus: Available ACP history associates this contributor with the reconnect/disconnect behavior extracted into the translator collaborators. (role: adjacent reconnect-path contributor; confidence: medium; commits: 3106ad3; files: src/acp/translator.disconnects.ts)
  • Alex Knight: Available ACP history associates this contributor with the original lifecycle and ledger work now being separated. (role: earlier lifecycle and ledger contributor; confidence: medium; commits: 6a8b4e4, b1eedb2; files: src/acp/translator.session-lifecycle.ts, src/acp/event-ledger.ts)

Rank-up moves

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

  • Wait for the in-progress exact-head checks to finish green before merge.

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 7cf4f9a into main Aug 9, 2026
126 checks passed
@steipete
steipete deleted the steipete/acp-split-translator-ledger branch August 9, 2026 08:23
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 10, 2026
…penclaw#120941)

* refactor(acp): split translator and event ledger

* refactor(acp): keep sqlite ledger owner stable
xydt-tanshanshan added a commit to xydt-tanshanshan/openclaw that referenced this pull request Aug 15, 2026
…boundary

newSession and resumeSession now defer session_info_update and
available_commands_update wire delivery past the JSON-RPC response so
ACP clients receive the session/new or session/resume result before any
session/update notification. The ledger write is still awaited before
the lifecycle handler returns, so follow-up reads see the snapshot
immediately.

Available commands are pre-fetched via prepareAvailableCommands() BEFORE
arming the snapshot delivery timer, so the lazy command-module dynamic
import yield cannot let the snapshot timer fire while the handler is
still pending. This resolves the P1 ordering defect where the snapshot
timer could fire during the command-discovery yield, delivering
session_info_update before the RPC response.

The deferred callback is fenced by the captured session instance rather
than hasSession: after closeSession removes the session, a resumeSession
with the same ID creates a new instance, so the stale callback's
deliveryGuard fails and suppresses the notification instead of leaking
into the replacement lifecycle.

Command discovery failures propagate to the RPC client:
prepareAvailableCommands awaits getAvailableCommands before any timer is
armed, so a discovery error rejects the newSession/resumeSession promise
rather than being swallowed.

Boundary-level transport proof uses real ACP SDK transport
(AgentSideConnection + ClientSideConnection + ndJsonStream over
PassThrough streams) with a mock Gateway to verify the response arrives
before any notification over the real wire.

Reimplements PR openclaw#109973 on the refactored session lifecycle owner
(PR openclaw#120941 split translator.ts into session-lifecycle/session-state/
session-updates modules).

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: 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