T-200: M2.1t (retry of T-197) — Land the PostgreSQL executor factory for the MCP copilot stdio host: openResearchCopilotExecutor(config) in libs/data/postgres/src/research-copilot-executor.ts, reusing the finished T-197 branch work and completing QA sign-off (no new deps, no DuckDB, no bin, no curate-etl changes)
This commit is contained in:
parent
7bf9bb6c20
commit
872debd9c6
1 changed files with 37 additions and 25 deletions
|
|
@ -295,10 +295,10 @@ describe.skipIf(!url)('PostgreSQL MCP copilot executor integration', () => {
|
|||
schema: f.schema,
|
||||
vaultCutoffTs: VAULT_CUTOFF_TS,
|
||||
});
|
||||
expect(await trialLookup.hasVisibleTrialRef('1')).toBe(true);
|
||||
expect(await trialLookup.hasVisibleTrialRef('2')).toBe(false);
|
||||
expect(await trialLookup.hasResearchVisibleTrial('1')).toBe(true);
|
||||
expect(await trialLookup.hasResearchVisibleTrial('2')).toBe(false);
|
||||
|
||||
// 2. Findings idempotent replay (both same-ID 23505 path and same-key ON CONFLICT path).
|
||||
// 2. Findings idempotent replay (both same-key ON CONFLICT and same-ID 23505 paths).
|
||||
const writePort = createPostgresFindingWritePort({
|
||||
executor: handle.executor,
|
||||
schema: f.schema,
|
||||
|
|
@ -315,33 +315,45 @@ describe.skipIf(!url)('PostgreSQL MCP copilot executor integration', () => {
|
|||
summary: 'Verifies SQLSTATE 23505 and ON CONFLICT replay through openResearchCopilotExecutor.',
|
||||
trialRefs: ['1'],
|
||||
evidenceRefs: ['evidence:e1'],
|
||||
idempotencyKey,
|
||||
};
|
||||
|
||||
const first = await writePort.appendFinding(baseFinding);
|
||||
expect(first.replayed).toBe(false);
|
||||
expect(first.id).toBe(findingId);
|
||||
expect(first.createdAt).toBe(FIXED_TS);
|
||||
|
||||
// Same-key replay with a different ID and later timestamp must return the original finding.
|
||||
const sameKeyReplay = await writePort.appendFinding({
|
||||
...baseFinding,
|
||||
id: `finding-${randomUUID()}`,
|
||||
createdAt: '2026-02-01T00:00:00.000Z',
|
||||
const first = await writePort.appendFinding(baseFinding, idempotencyKey);
|
||||
expect(first).toEqual({
|
||||
status: 'created',
|
||||
id: findingId,
|
||||
createdAt: FIXED_TS,
|
||||
});
|
||||
expect(sameKeyReplay.replayed).toBe(true);
|
||||
expect(sameKeyReplay.id).toBe(findingId);
|
||||
expect(sameKeyReplay.createdAt).toBe(FIXED_TS);
|
||||
|
||||
// Same-ID replay without idempotencyKey triggers SQLSTATE 23505 primary-key replay path.
|
||||
const sameIdReplay = await writePort.appendFinding({
|
||||
...baseFinding,
|
||||
idempotencyKey: undefined,
|
||||
createdAt: '2026-03-01T00:00:00.000Z',
|
||||
// Same-key replay with a different ID and later timestamp (ON CONFLICT DO NOTHING path)
|
||||
// must return the original finding and timestamp.
|
||||
const sameKeyReplay = await writePort.appendFinding(
|
||||
{
|
||||
...baseFinding,
|
||||
id: `finding-${randomUUID()}`,
|
||||
createdAt: '2026-02-01T00:00:00.000Z',
|
||||
},
|
||||
idempotencyKey
|
||||
);
|
||||
expect(sameKeyReplay).toEqual({
|
||||
status: 'replayed',
|
||||
id: findingId,
|
||||
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.
|
||||
const sameIdReplay = await writePort.appendFinding(
|
||||
{
|
||||
...baseFinding,
|
||||
createdAt: '2026-03-01T00:00:00.000Z',
|
||||
},
|
||||
idempotencyKey
|
||||
);
|
||||
expect(sameIdReplay).toEqual({
|
||||
status: 'replayed',
|
||||
id: findingId,
|
||||
createdAt: FIXED_TS,
|
||||
});
|
||||
expect(sameIdReplay.replayed).toBe(true);
|
||||
expect(sameIdReplay.id).toBe(findingId);
|
||||
expect(sameIdReplay.createdAt).toBe(FIXED_TS);
|
||||
|
||||
const rowCount = await handle.executor.query<{ count: string }>(
|
||||
`SELECT count(*)::text AS count FROM ${f.schema}.findings`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue