ktx/packages/context/src/tools/tool-session.ts

58 lines
1.8 KiB
TypeScript
Raw Normal View History

2026-05-10 23:51:24 +02:00
import type { GitService, KtxFileStorePort } from '../core/index.js';
2026-05-10 23:12:26 +02:00
import type { SemanticLayerService } from '../sl/index.js';
import type { KnowledgeWikiService } from '../wiki/index.js';
import type { TouchedSlSourceSet } from './touched-sl-sources.js';
export interface IngestToolMetadata {
runId: string;
jobId: string;
syncId: string;
sourceKey: string;
}
export interface MemoryAction {
target: 'wiki' | 'sl';
type: 'created' | 'updated' | 'removed';
key: string;
detail: string;
targetConnectionId?: string | null;
rawPaths?: string[];
2026-05-10 23:12:26 +02:00
}
interface EvictionDecisionRecord {
rawPath: string;
artifactKind: 'wiki' | 'sl';
artifactKey: string;
action: 'removed';
2026-05-10 23:12:26 +02:00
reason: string;
}
/**
* Per-WU (or per-memory-agent) state threaded through ToolContext. When present,
* SL/wiki tools read session-scoped services and emit touched-set entries / actions
* instead of hitting shared services. When absent, tools behave as they do for
* interactive research/workshop callers.
*/
export interface ToolSession {
/**
* Warehouse connection targeted by SL tools. `null` when the session has no
* warehouse connection (wiki-only memory-agent turns) SL tools must guard
* for this and return a structured error rather than execute against a
* blank connection.
*/
connectionId: string | null;
/** When true, worktree-scoped service writes bypass DB index updates. */
isWorktreeScoped: boolean;
preHead: string | null;
touchedSlSources: TouchedSlSourceSet;
actions: MemoryAction[];
allowedRawPaths?: ReadonlySet<string>;
feat(context): add warehouse verification tools (#46) * feat(context): add warehouse dialect dispatch * feat(context): read warehouse scan catalog * feat(context): add entity details verification tool * feat(context): add ingest SQL verification tool * feat(context): add raw warehouse discovery tool * feat(context): expose warehouse verification tools to ingest * docs(context): add ingest identifier verification protocol * test(context): guard ingest identifier verification prompts * chore(context): verify warehouse verification tools * docs: add warehouse verification tools plan and spec * fix(context): expose target warehouses to Notion ingest * fix(context): update ingest prompts for warehouse verification tools * fix(context): scope raw schema discovery to allowed connections * fix(context): verify warehouse column display targets * docs: add notion warehouse verification gap closure plan * fix(context): include raw discovery connection names * fix(context): expose warehouse targets for LookML and MetricFlow * fix(context): pass connection config to ingest query executors * fix(cli): enable read-only SQL probes for local ingest * docs: add warehouse verification final v1 closure plan * fix(context): align warehouse sql probe prompt shape * docs: add warehouse verification prompt shape closure plan * test(context): catch connectionless sql execution prompt examples * fix(context): include connection name in sl capture sql example * docs: add warehouse verification sql example closure plan * fix(context): report structured entity detail misses * docs: add warehouse verification structured target miss closure plan * fix: report untracked squash merge conflicts * feat: require ingest verification ledger * fix: stabilize ingest wiki references
2026-05-13 13:43:23 +02:00
allowedConnectionNames?: ReadonlySet<string>;
2026-05-10 23:12:26 +02:00
semanticLayerService: SemanticLayerService;
wikiService: KnowledgeWikiService;
2026-05-10 23:51:24 +02:00
configService: KtxFileStorePort;
2026-05-10 23:12:26 +02:00
gitService: GitService;
ingest?: IngestToolMetadata;
evictionDecisions?: EvictionDecisionRecord[];
}