feat(mcp,acp): Repository.WithTx + acp.Repository.InTx

Cross-module transactional support for spec §6.1: ACP CreateSession must
atomically insert acp_sessions row + mcp_tokens row (FK NOT NULL).

- mcp.Repository.WithTx(tx) -> Repository (tx-bound, no pool)
- acp.Repository.InTx(ctx, fn) -> error (pgx.BeginFunc wrapper)
- acp.Repository.WithTx(tx) -> Repository (tx-bound)
- Update fakeRepos in test files to satisfy new interface methods

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-08 12:40:54 +08:00
parent 62d9a91ca5
commit be8d5e3a1b
5 changed files with 53 additions and 0 deletions
+9
View File
@@ -18,6 +18,7 @@ import (
"time"
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -112,6 +113,14 @@ func (f *fakeEventRepo) PurgeEventsBefore(context.Context, time.Time) (int64, er
panic("n/a")
}
func (f *fakeEventRepo) InTx(context.Context, func(context.Context, pgx.Tx) error) error {
panic("n/a")
}
func (f *fakeEventRepo) WithTx(pgx.Tx) acp.Repository {
return f
}
// relayTestRig wires up a Relay with two io.Pipe pairs that simulate the agent
// subprocess. Returns:
// - r: the relay under test