feat(ingest): route direct-write connectors through isolated diffs

This commit is contained in:
Andrey Avtomonov 2026-05-18 02:37:26 +02:00
parent a00285fd42
commit 449db1d42a
4 changed files with 91 additions and 1 deletions

View file

@ -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);
});
});

View file

@ -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<string>(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);
}

View file

@ -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'),

View file

@ -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 }),