diff --git a/packages/context/src/ingest/isolated-diff/source-routing.test.ts b/packages/context/src/ingest/isolated-diff/source-routing.test.ts new file mode 100644 index 00000000..75e52a1c --- /dev/null +++ b/packages/context/src/ingest/isolated-diff/source-routing.test.ts @@ -0,0 +1,40 @@ +import { describe, expect, it } from 'vitest'; +import { + defaultIsolatedDiffSourceKeys, + isIsolatedDiffDirectWriteSourceKey, + ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS, +} from './source-routing.js'; + +describe('isolated-diff source routing', () => { + it('keeps the runner-owned direct-write connector list explicit', () => { + expect(ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS).toEqual([ + 'metabase', + 'notion', + 'lookml', + 'looker', + 'dbt', + 'metricflow', + ]); + }); + + it('returns a mutable copy for runtime settings', () => { + const keys = defaultIsolatedDiffSourceKeys(); + keys.push('fake'); + + expect(defaultIsolatedDiffSourceKeys()).toEqual([ + 'metabase', + 'notion', + 'lookml', + 'looker', + 'dbt', + 'metricflow', + ]); + }); + + it('recognizes migrated connector source keys only', () => { + expect(isIsolatedDiffDirectWriteSourceKey('notion')).toBe(true); + expect(isIsolatedDiffDirectWriteSourceKey('metricflow')).toBe(true); + expect(isIsolatedDiffDirectWriteSourceKey('historic-sql')).toBe(false); + expect(isIsolatedDiffDirectWriteSourceKey('live-database')).toBe(false); + }); +}); diff --git a/packages/context/src/ingest/isolated-diff/source-routing.ts b/packages/context/src/ingest/isolated-diff/source-routing.ts new file mode 100644 index 00000000..20d63b89 --- /dev/null +++ b/packages/context/src/ingest/isolated-diff/source-routing.ts @@ -0,0 +1,22 @@ +export const ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS = [ + 'metabase', + 'notion', + 'lookml', + 'looker', + 'dbt', + 'metricflow', +] as const; + +export type IsolatedDiffDirectWriteSourceKey = (typeof ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS)[number]; + +const ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEY_SET = new Set(ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS); + +export function defaultIsolatedDiffSourceKeys(): string[] { + return [...ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS]; +} + +export function isIsolatedDiffDirectWriteSourceKey( + sourceKey: string, +): sourceKey is IsolatedDiffDirectWriteSourceKey { + return ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEY_SET.has(sourceKey); +} diff --git a/packages/context/src/ingest/local-bundle-runtime.test.ts b/packages/context/src/ingest/local-bundle-runtime.test.ts index 8287df71..aa4c61e2 100644 --- a/packages/context/src/ingest/local-bundle-runtime.test.ts +++ b/packages/context/src/ingest/local-bundle-runtime.test.ts @@ -29,6 +29,14 @@ type RuntimeWithSlValidationDeps = { }; }; +type RuntimeWithSettingsDeps = { + deps: { + settings: { + isolatedDiffSourceKeys?: string[]; + }; + }; +}; + function testAgentRunner(): AgentRunnerPort { return { runLoop: vi.fn().mockResolvedValue({ stopReason: 'natural' as const }) }; } @@ -258,6 +266,25 @@ describe('createLocalBundleIngestRuntime', () => { }); }); + it('enables isolated-diff routing for direct durable-write connectors', () => { + const runtime = createLocalBundleIngestRuntime({ + project, + adapters: [new FakeSourceAdapter()], + agentRunner: testAgentRunner(), + }); + + const settings = (runtime.runner as unknown as RuntimeWithSettingsDeps).deps.settings; + + expect(settings.isolatedDiffSourceKeys).toEqual([ + 'metabase', + 'notion', + 'lookml', + 'looker', + 'dbt', + 'metricflow', + ]); + }); + it('accepts a debug LLM request file when constructing the default agent runner', async () => { await writeFile( join(project.projectDir, 'ktx.yaml'), diff --git a/packages/context/src/ingest/local-bundle-runtime.ts b/packages/context/src/ingest/local-bundle-runtime.ts index 74e3bd52..4fccf121 100644 --- a/packages/context/src/ingest/local-bundle-runtime.ts +++ b/packages/context/src/ingest/local-bundle-runtime.ts @@ -77,6 +77,7 @@ import { ContextEvidenceIndexService, SqliteContextEvidenceStore } from './conte import { DiffSetService } from './diff-set.service.js'; import { ingestTracePathForJob, type IngestTraceLevel } from './ingest-trace.js'; import { IngestBundleRunner } from './ingest-bundle.runner.js'; +import { defaultIsolatedDiffSourceKeys } from './isolated-diff/source-routing.js'; import { PageTriageService } from './page-triage/index.js'; import { createWarehouseVerificationTools } from './tools/warehouse-verification/index.js'; import type { @@ -722,7 +723,7 @@ export function createLocalBundleIngestRuntime( workUnitMaxConcurrency: options.project.config.ingest.workUnits.maxConcurrency, workUnitStepBudget: options.project.config.ingest.workUnits.stepBudget, workUnitFailureMode: options.project.config.ingest.workUnits.failureMode, - isolatedDiffSourceKeys: ['metabase'], + isolatedDiffSourceKeys: defaultIsolatedDiffSourceKeys(), ingestTraceLevel: ingestTraceLevelFromEnv(), }, skillsRegistry: new SkillsRegistryService({ skillsDir, logger }),