T-134: M2.1d — MCP copilot search_symbols tool: vault-safe security-master symbol lookup via an injected SymbolSearchPort in libs/research/src/mcp/tools/

This commit is contained in:
Studio 2026-12-01 06:11:53 -05:00
parent 857eedf379
commit 4c810cb249
2 changed files with 33 additions and 6 deletions

View file

@ -337,11 +337,35 @@ describe('MCP search_symbols tool', () => {
expect(resB.isError).toBe(false);
expect(resA.payload).toEqual(resB.payload);
// Exact ticker (2, 10) -> prefix (5, 25) -> name substring (15; note 100 has 'Apple' not 'aapl') -> other (30, 100)
expect(resA.payload?.rows.map(r => r.listingId)).toEqual([2, 10, 5, 25, 15, 30, 100]);
expect(resA.payload?.rowCount).toBe(7);
// Exact ticker (2, 10) -> prefix (5, 25) -> name substring (15); unrelated candidates (30, 100) are excluded
expect(resA.payload?.rows.map(r => r.listingId)).toEqual([2, 10, 5, 25, 15]);
expect(resA.payload?.rowCount).toBe(5);
expect(resA.payload?.truncated).toBe(false);
// Unrelated candidates must not trigger truncation when all actual matches fit within limit.
const exactFitRes = await callSearchSymbols(createFakePort({ rows: fixture }), {
query: 'AAPL',
limit: 5,
});
expect(exactFitRes.isError).toBe(false);
expect(exactFitRes.payload?.rows.map(r => r.listingId)).toEqual([2, 10, 5, 25, 15]);
expect(exactFitRes.payload?.rowCount).toBe(5);
expect(exactFitRes.payload?.truncated).toBe(false);
// When none of the port's returned candidates match, return an empty, non-truncated payload.
const noMatchRes = await callSearchSymbols(createFakePort({ rows: fixture }), {
query: 'UNMATCHED',
limit: 2,
});
expect(noMatchRes.isError).toBe(false);
expect(noMatchRes.payload).toEqual({
scope: 'vault_fenced',
vaultCutoffTs: VAULT_CUTOFF_TS,
rowCount: 0,
truncated: false,
rows: [],
});
// Verify trimmed query, default limit, includeDelisted: true, and vaultCutoffTs were passed to port.
expect(fakeA.calls).toHaveLength(1);
expect(fakeA.calls[0]).toEqual({