Repository navigation
refactor(acp): split grandfathered translator and event-ledger files - #120941
Conversation
f26d4c2 to
e341459
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 3:43 AM ET / 07:43 UTC. ClawSweeper reviewWhat this changesThe 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 readinessNo blocking defect was found in this maintainer-owned ACP refactor. Keep it open for normal maintainer review and exact-head CI completion. Priority: P3 Review scores
Verification
How this fits togetherACP 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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +289, Other -2. Total +287 across 11 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…penclaw#120941) * refactor(acp): split translator and event ledger * refactor(acp): keep sqlite ledger owner stable
…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]>
What Problem This Solves
The ACP bridge translator and replay ledger were grandfathered oversized files with
max-linessuppressions, 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.tsandevent-ledger.tsas 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.oxlint-disable max-linescomments and only thesrc/acp/translator.tsandsrc/acp/event-ledger.tsmax-lines baseline entries.