T-200: edits made in the worktree

This commit is contained in:
Studio 2026-12-03 15:19:01 -05:00
parent 872debd9c6
commit e720c879df
4 changed files with 158 additions and 179 deletions

View file

@ -340,8 +340,7 @@ describe.skipIf(!url)('PostgreSQL MCP copilot executor integration', () => {
createdAt: FIXED_TS,
});
// Same-ID replay with the same idempotencyKey triggers PostgreSQL PK SQLSTATE 23505;
// executor must preserve SQLSTATE 23505 so the adapter resolves the original finding.
// Same-ID, same-key replay must also return the original receipt and keep 1 stored row.
const sameIdReplay = await writePort.appendFinding(
{
...baseFinding,
@ -355,6 +354,23 @@ describe.skipIf(!url)('PostgreSQL MCP copilot executor integration', () => {
createdAt: FIXED_TS,
});
// Unkeyed duplicate-PK insert hits PostgreSQL's primary-key constraint directly;
// verify the executor observes and preserves real SQLSTATE 23505 without leaking driver fields.
let pkCollisionErr: unknown;
try {
await writePort.appendFinding({
...baseFinding,
createdAt: '2026-04-01T00:00:00.000Z',
});
} catch (error) {
pkCollisionErr = error;
}
expect(pkCollisionErr).toBeInstanceOf(Error);
expect((pkCollisionErr as { code?: string }).code).toBe('23505');
expect((pkCollisionErr as Error).message).toBe('PostgreSQL research copilot query failed.');
expect('cause' in (pkCollisionErr as Error)).toBe(false);
expect('detail' in (pkCollisionErr as Error)).toBe(false);
const rowCount = await handle.executor.query<{ count: string }>(
`SELECT count(*)::text AS count FROM ${f.schema}.findings`
);