test(optimize): pin per-session MCP schema charging without connectors

The rewritten cost pass charges each session only for the schemas that
session loaded, which changes local-only estimates too (on a real corpus
the mcp-low-coverage estimate roughly halves). Pin it so the change is
deliberate rather than a side effect of the connector split.
This commit is contained in:
iamtoruk 2026-08-18 08:27:22 -07:00
parent 117aa833cc
commit cddf5d5a53

View file

@ -970,6 +970,25 @@ describe('connector findings and finding class', () => {
expect(classTotals([finding!], 0.00002).fix.tokensSaved).toBe(finding!.tokensSaved)
})
it('charges each session only for the local schemas it actually loaded', () => {
// Same per-session scoping the connector split relies on, with no
// connector in play: two flagged local servers in disjoint sessions are
// charged one schema each, not both schemas everywhere.
const sessions = ['filesystem', 'playwright'].flatMap(server =>
['a', 'b'].map(suffix => makeSession({
sessionId: `${server}-${suffix}`,
inventory: inventoryFor([server]),
turns: [makeTurn([makeCall({ cacheCreation: 50_000 })])],
})),
)
const finding = detectMcpToolCoverage([project(sessions)])
expect(finding).toMatchObject({ tokensSaved: 40_000 })
expect(finding!.applyTokensSaved).toBeUndefined()
expect(classTotals([finding!], 0.00002).fix.tokensSaved).toBe(40_000)
})
it('treats a local server named like a connector namespace as manual only', () => {
// Known limitation: the namespace prefix is the only connector signal in
// the transcript, so a local server literally named claude_ai_* gets the