Repository navigation
test: guard numeric ACP initialize protocol version - #318
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughThe change adds an ACP startup contract test. The test decodes the initialize request and verifies that ChangesACP initialize contract
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| internal/acp/client_start_contract_test.go | Adds a focused contract test that reliably rejects missing, quoted, non-integral, or incorrect ACP protocol-version values without changing production behavior. |
Reviews (1): Last reviewed commit: "test: guard ACP initialize protocol vers..." | Re-trigger Greptile
Context
Issue #306 reported that a clean Windows installation of Compozy
v0.3.0-beta.3disconnected while starting@agentclientprotocol/[email protected]. The report attributed the disconnect to Compozy sendinginitialize.params.protocolVersionas a JSON string after the adapter allegedly changed the field to a number.That attribution does not reproduce against the released Compozy code or either adapter version named in the report. This PR therefore does not claim a production serialization fix that did not occur. It closes the actual coverage gap: Compozy had no raw-wire assertion preventing a future regression from a numeric ACP version to a quoted value.
Fixes #306.
Reproduction and root-cause investigation
The dependent ACP API requires an integer
The current ACP contract models
protocolVersionas an integer. Compozy usesgithub.com/coder/acp-go-sdk v0.13.5, where:ProtocolVersionNumberis the numeric constant1;ProtocolVersionis an integer type;InitializeRequest.ProtocolVersionis serialized directly in the JSON-RPC params.Direct requests to the exact reported adapter confirm that behavior:
[email protected]"protocolVersion":"1"-32602 Invalid params: expected number, received string[email protected]"protocolVersion":1agentInfo.version = "0.64.2"[email protected]"protocolVersion":"1"-32602 Invalid params[email protected]"protocolVersion":1agentInfo.version = "0.63.0"Both npm releases declare
@agentclientprotocol/sdk 1.3.0. The adapter's changelog between 0.63.0 and 0.64.2 contains no initialize schema transition. The claimed 0.64-only breaking change, and the explanation that pinning 0.63 restored a legacy string contract, are therefore disproven.The released Compozy binary already sends the number
The
v0.3.0-beta.3tag and currentmainboth construct:The official
compozy_windows_x86_64.zipbeta.3 artifact was also inspected with Go build metadata. Itscompozy.exeembedsgithub.com/coder/acp-go-sdk v0.13.5, the same SDK whose request field is numeric.There is no prior Compozy commit that converted this field from string to number between beta.3 and current
main: both ends already use the same numeric SDK contract.The real current client completes the reported handshake
A temporary live probe exercised the real
internal/acp.Driver.Startpath with the exact command:It completed the production launch,
initialize,session/new, and session mode negotiation:The probe stopped the driver, observed the ACP connection close, and confirmed that child PID
66217no longer existed. The temporary probe source was removed after the run; it is not a network-dependent test added to the canonical unit suite.Why the original disconnect cannot be assigned to the schema
A quoted version produces a normal JSON-RPC invalid-params response. The reported
peer disconnected before responseinstead means the child process closed the transport before replying. Those are distinct failure modes.The original crash evidence did not retain the child exit code, signal, or stderr tail, so the reason that the Windows
npxprocess exited cannot be reconstructed from #306. The fact that a later run happened to work after installing 0.63.0 changed the installed process/cache state, but does not prove a protocol difference; 0.63.0 enforces the same numeric schema.Issue #315 owns the general
process_exit/peer disconnecteddiagnostic work, including exit code, signal, and stderr preservation. This PR deliberately avoids conflicting production changes in that area.Solution design
The canonical ACP Start contract suite now captures the actual JSON-RPC request written by the real Compozy client to a subprocess and inspects the raw
initialize.paramsobject.The new invariant is:
The assertion unmarshals the raw field into a Go
int. A future change to"1"fails at the wire boundary independently of the SDK's Go type. It also compares the value to the SDK's supported version so a stale hard-coded assertion cannot pass after a protocol update.The existing subprocess capture harness and lifecycle helpers are reused. No duplicate mock, compatibility DTO, fallback, or adapter pin was added.
Changes by surface
@latest; no temporary 0.63 pin.Test placement and invariants
1, not a string.internal/acp/client_start_contract_test.go.internal/acp/client_test_support_test.go.No duplicate assertion was added to HTTP, CLI, UDS, web, config, generated output, or the ACP mock-agent implementation because none of those layers owns serialization of the client's initialize request.
Verification and QA evidence
Focused and package verification
CGO_ENABLED=1 go test -race ./internal/acp -run '^TestStartInitializeContract$' -count=1— passCGO_ENABLED=1 go test -race ./internal/acp/... -count=1— passmake gate— pass; scoped Go lint reported 0 issues and the ACP race suite passedgit diff --check— passWindows evidence
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go test -c ./internal/acp— passPE32+ executable (console) x86-64, for MS Windowsmake cross-build-windows— passReal adapter probe
Driver.Startagainst[email protected]— pass through initialize, session creation, and mode negotiationFull repository gate
make gate-fullpassed for fingerprintf856af8997bc750b8bf742e2679ee4880971b1b9.The recorded full gate includes codegen and installer checks, Bun lint/typecheck/tests, web build, Go format/lint/race tests, Go and Windows builds, and package boundaries. The Go suite completed 20,689 tests with 2 expected platform/helper skips.
QA tracker
This diff changes only internal automated coverage. It does not change a UI, CLI verb, API route, configuration key, public copy, or runtime behavior, so no living QA scenario was added or reset. The live adapter probe is the scenario evidence for the reported handshake, and it was torn down cleanly.
Compozy Impact Audit
compozy__*tool IDs, toolsets, descriptors, schemas, digests, risk flags, diagnostics, capability gates, and CLI/API fallbacks; none serialize ACP initialize requests or change in this test-only diff.workspace_idpropagation, store, cache, SSE, or event path changes.skills/compozy/; no tool ID, CLI path, hook event, capability, extension resource, memory/network/task semantic, or operator workflow changes.Compatibility, risks, and decisions
claude-agent-acp@latest; no temporary dependency pin or downgrade.main, the beta.3 source, the released Windows binary, and the live 0.64.2 probe all demonstrate correct production behavior.Summary by CodeRabbit