feat(ingest): make isolated diff routing the private default

This commit is contained in:
Andrey Avtomonov 2026-05-18 02:47:49 +02:00
parent 1dd1151a08
commit 8cf63b2248
3 changed files with 19 additions and 47 deletions

View file

@ -1,40 +1,22 @@
import { describe, expect, it } from 'vitest';
import {
defaultIsolatedDiffSourceKeys,
isIsolatedDiffDirectWriteSourceKey,
ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS,
} from './source-routing.js';
import { defaultSharedWorktreeSourceKeys, isSharedWorktreeFallbackSourceKey } 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('defaults every non-override source to isolated diffs', () => {
expect(defaultSharedWorktreeSourceKeys()).toEqual([]);
});
it('returns a mutable copy for runtime settings', () => {
const keys = defaultIsolatedDiffSourceKeys();
keys.push('fake');
const keys = defaultSharedWorktreeSourceKeys();
keys.push('legacy-source');
expect(defaultIsolatedDiffSourceKeys()).toEqual([
'metabase',
'notion',
'lookml',
'looker',
'dbt',
'metricflow',
]);
expect(defaultSharedWorktreeSourceKeys()).toEqual([]);
});
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);
it('recognizes only explicitly configured shared-worktree fallback sources', () => {
expect(isSharedWorktreeFallbackSourceKey('notion', [])).toBe(false);
expect(isSharedWorktreeFallbackSourceKey('metricflow', [])).toBe(false);
expect(isSharedWorktreeFallbackSourceKey('legacy-source', ['legacy-source'])).toBe(true);
expect(isSharedWorktreeFallbackSourceKey('other-source', ['legacy-source'])).toBe(false);
});
});

View file

@ -1,22 +1,12 @@
export const ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEYS = [
'metabase',
'notion',
'lookml',
'looker',
'dbt',
'metricflow',
] as const;
const DEFAULT_SHARED_WORKTREE_SOURCE_KEYS: readonly string[] = [];
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 defaultSharedWorktreeSourceKeys(): string[] {
return [...DEFAULT_SHARED_WORKTREE_SOURCE_KEYS];
}
export function isIsolatedDiffDirectWriteSourceKey(
export function isSharedWorktreeFallbackSourceKey(
sourceKey: string,
): sourceKey is IsolatedDiffDirectWriteSourceKey {
return ISOLATED_DIFF_DIRECT_WRITE_SOURCE_KEY_SET.has(sourceKey);
sharedWorktreeSourceKeys: readonly string[] = DEFAULT_SHARED_WORKTREE_SOURCE_KEYS,
): boolean {
return sharedWorktreeSourceKeys.includes(sourceKey);
}

View file

@ -143,7 +143,7 @@ export interface IngestSettingsPort {
workUnitMaxConcurrency?: number;
workUnitStepBudget?: number;
workUnitFailureMode?: 'abort' | 'continue';
isolatedDiffSourceKeys?: string[];
sharedWorktreeSourceKeys?: string[];
ingestTraceLevel?: IngestTraceLevel;
}