@kaelio/ktx 0.1.0-rc.5 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/python/kaelio_ktx-0.1.0-py3-none-any.whl +0 -0
- package/assets/python/manifest.json +2 -2
- package/dist/clack.d.ts +6 -0
- package/dist/clack.js +23 -0
- package/dist/cli-program.js +5 -2
- package/dist/cli-program.test.js +7 -1
- package/dist/cli-runtime.d.ts +4 -0
- package/dist/cli-runtime.js +8 -1
- package/dist/command-schemas.d.ts +1 -1
- package/dist/commands/ingest-commands.js +1 -0
- package/dist/commands/knowledge-commands.js +5 -0
- package/dist/commands/mcp-commands.js +11 -3
- package/dist/commands/mcp-commands.test.js +30 -1
- package/dist/commands/sql-commands.d.ts +3 -0
- package/dist/commands/sql-commands.js +43 -0
- package/dist/commands/sql-commands.test.d.ts +1 -0
- package/dist/commands/sql-commands.test.js +68 -0
- package/dist/context-build-view.js +5 -1
- package/dist/dev.test.js +27 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.test.js +56 -21
- package/dist/ingest.js +123 -18
- package/dist/ingest.test.js +206 -0
- package/dist/io/print-list.d.ts +2 -1
- package/dist/io/print-list.js +7 -0
- package/dist/io/print-list.test.js +13 -11
- package/dist/io/symbols.d.ts +2 -2
- package/dist/knowledge.d.ts +1 -0
- package/dist/knowledge.js +34 -16
- package/dist/knowledge.test.js +27 -0
- package/dist/managed-python-command.d.ts +2 -0
- package/dist/managed-python-command.js +17 -9
- package/dist/managed-python-command.test.js +59 -4
- package/dist/next-steps.js +1 -1
- package/dist/next-steps.test.js +2 -0
- package/dist/print-command-tree.js +7 -1
- package/dist/public-ingest.d.ts +9 -1
- package/dist/public-ingest.js +50 -7
- package/dist/public-ingest.test.js +69 -2
- package/dist/release-version.d.ts +5 -0
- package/dist/release-version.js +44 -0
- package/dist/runtime-requirements.d.ts +23 -0
- package/dist/runtime-requirements.js +99 -0
- package/dist/runtime-requirements.test.d.ts +1 -0
- package/dist/runtime-requirements.test.js +63 -0
- package/dist/setup-agents.d.ts +11 -3
- package/dist/setup-agents.js +397 -134
- package/dist/setup-agents.test.js +359 -61
- package/dist/setup-embeddings.js +3 -6
- package/dist/setup-embeddings.test.js +18 -2
- package/dist/setup-models.js +2 -2
- package/dist/setup-models.test.js +5 -3
- package/dist/setup-ready-menu.d.ts +1 -1
- package/dist/setup-ready-menu.js +2 -0
- package/dist/setup-ready-menu.test.js +3 -0
- package/dist/setup-runtime.d.ts +45 -0
- package/dist/setup-runtime.js +47 -0
- package/dist/setup-runtime.test.d.ts +1 -0
- package/dist/setup-runtime.test.js +110 -0
- package/dist/setup-sources-notion.test.d.ts +1 -0
- package/dist/setup-sources-notion.test.js +107 -0
- package/dist/setup-sources.js +5 -2
- package/dist/setup.d.ts +19 -1
- package/dist/setup.js +104 -29
- package/dist/setup.test.js +221 -57
- package/dist/sl.js +2 -2
- package/dist/sl.test.js +10 -0
- package/dist/source-mapping.js +9 -1
- package/dist/source-mapping.test.d.ts +1 -0
- package/dist/source-mapping.test.js +65 -0
- package/dist/sql.d.ts +22 -0
- package/dist/sql.js +125 -0
- package/dist/sql.test.d.ts +1 -0
- package/dist/sql.test.js +226 -0
- package/node_modules/@ktx/connector-clickhouse/dist/package-exports.test.js +1 -1
- package/node_modules/@ktx/context/dist/connections/connection-type.d.ts +4 -4
- package/node_modules/@ktx/context/dist/core/git.service.d.ts +3 -0
- package/node_modules/@ktx/context/dist/core/git.service.js +47 -1
- package/node_modules/@ktx/context/dist/core/git.service.patch.test.d.ts +1 -0
- package/node_modules/@ktx/context/dist/core/git.service.patch.test.js +40 -0
- package/node_modules/@ktx/context/dist/ingest/adapters/historic-sql/types.d.ts +5 -5
- package/node_modules/@ktx/context/dist/ingest/adapters/looker/looker.adapter.d.ts +2 -2
- package/node_modules/@ktx/context/dist/ingest/adapters/looker/tools/looker-query-to-sl.tool.d.ts +2 -2
- package/node_modules/@ktx/context/dist/ingest/adapters/looker/types.d.ts +16 -16
- package/node_modules/@ktx/context/dist/ingest/adapters/lookml/pull-config.d.ts +1 -1
- package/node_modules/@ktx/context/dist/ingest/adapters/metabase/fetch.js +16 -0
- package/node_modules/@ktx/context/dist/ingest/adapters/metabase/fetch.test.js +41 -0
- package/node_modules/@ktx/context/dist/ingest/adapters/metricflow/metricflow.adapter.d.ts +2 -1
- package/node_modules/@ktx/context/dist/ingest/adapters/metricflow/metricflow.adapter.js +40 -0
- package/node_modules/@ktx/context/dist/ingest/adapters/metricflow/metricflow.adapter.test.js +116 -1
- package/node_modules/@ktx/context/dist/ingest/adapters/metricflow/projection-config.d.ts +29 -0
- package/node_modules/@ktx/context/dist/ingest/adapters/metricflow/projection-config.js +40 -0
- package/node_modules/@ktx/context/dist/ingest/adapters/metricflow/pull-config.d.ts +1 -1
- package/node_modules/@ktx/context/dist/ingest/artifact-gates.d.ts +25 -0
- package/node_modules/@ktx/context/dist/ingest/artifact-gates.js +149 -0
- package/node_modules/@ktx/context/dist/ingest/artifact-gates.test.d.ts +1 -0
- package/node_modules/@ktx/context/dist/ingest/artifact-gates.test.js +167 -0
- package/node_modules/@ktx/context/dist/ingest/final-gate-repair.d.ts +29 -0
- package/node_modules/@ktx/context/dist/ingest/final-gate-repair.js +178 -0
- package/node_modules/@ktx/context/dist/ingest/final-gate-repair.test.d.ts +1 -0
- package/node_modules/@ktx/context/dist/ingest/final-gate-repair.test.js +109 -0
- package/node_modules/@ktx/context/dist/ingest/index.d.ts +8 -1
- package/node_modules/@ktx/context/dist/ingest/index.js +7 -0
- package/node_modules/@ktx/context/dist/ingest/ingest-bundle.runner.d.ts +18 -2
- package/node_modules/@ktx/context/dist/ingest/ingest-bundle.runner.isolated-diff.test.d.ts +1 -0
- package/node_modules/@ktx/context/dist/ingest/ingest-bundle.runner.isolated-diff.test.js +1761 -0
- package/node_modules/@ktx/context/dist/ingest/ingest-bundle.runner.js +1695 -901
- package/node_modules/@ktx/context/dist/ingest/ingest-bundle.runner.test.js +135 -118
- package/node_modules/@ktx/context/dist/ingest/ingest-trace.d.ts +50 -0
- package/node_modules/@ktx/context/dist/ingest/ingest-trace.js +88 -0
- package/node_modules/@ktx/context/dist/ingest/ingest-trace.test.d.ts +1 -0
- package/node_modules/@ktx/context/dist/ingest/ingest-trace.test.js +76 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/git-patch.d.ts +16 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/git-patch.js +78 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/git-patch.test.d.ts +1 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/git-patch.test.js +76 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/patch-integrator.d.ts +58 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/patch-integrator.js +223 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/patch-integrator.test.d.ts +1 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/patch-integrator.test.js +369 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/textual-conflict-resolver.d.ts +23 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/textual-conflict-resolver.js +190 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/textual-conflict-resolver.test.d.ts +1 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/textual-conflict-resolver.test.js +101 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/work-unit-executor.d.ts +15 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/work-unit-executor.js +61 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/work-unit-executor.test.d.ts +1 -0
- package/node_modules/@ktx/context/dist/ingest/isolated-diff/work-unit-executor.test.js +137 -0
- package/node_modules/@ktx/context/dist/ingest/local-bundle-ingest.test.js +7 -0
- package/node_modules/@ktx/context/dist/ingest/local-bundle-runtime.js +54 -10
- package/node_modules/@ktx/context/dist/ingest/local-bundle-runtime.test.js +65 -0
- package/node_modules/@ktx/context/dist/ingest/memory-flow/schema.d.ts +23 -5
- package/node_modules/@ktx/context/dist/ingest/memory-flow/schema.js +17 -0
- package/node_modules/@ktx/context/dist/ingest/memory-flow/schema.test.js +1 -0
- package/node_modules/@ktx/context/dist/ingest/memory-flow/types.d.ts +6 -0
- package/node_modules/@ktx/context/dist/ingest/parsed-target-table.d.ts +1 -1
- package/node_modules/@ktx/context/dist/ingest/ports.d.ts +3 -0
- package/node_modules/@ktx/context/dist/ingest/report-snapshot.d.ts +32 -7
- package/node_modules/@ktx/context/dist/ingest/report-snapshot.js +25 -0
- package/node_modules/@ktx/context/dist/ingest/report-snapshot.test.js +124 -0
- package/node_modules/@ktx/context/dist/ingest/reports.d.ts +23 -0
- package/node_modules/@ktx/context/dist/ingest/semantic-layer-target-policy.d.ts +11 -0
- package/node_modules/@ktx/context/dist/ingest/semantic-layer-target-policy.js +26 -0
- package/node_modules/@ktx/context/dist/ingest/semantic-layer-target-policy.test.d.ts +1 -0
- package/node_modules/@ktx/context/dist/ingest/semantic-layer-target-policy.test.js +25 -0
- package/node_modules/@ktx/context/dist/ingest/stages/stage-3-work-units.d.ts +4 -0
- package/node_modules/@ktx/context/dist/ingest/stages/stage-3-work-units.js +4 -0
- package/node_modules/@ktx/context/dist/ingest/stages/stage-3-work-units.test.js +29 -0
- package/node_modules/@ktx/context/dist/ingest/tools/emit-unmapped-fallback.tool.d.ts +1 -1
- package/node_modules/@ktx/context/dist/ingest/types.d.ts +24 -0
- package/node_modules/@ktx/context/dist/ingest/wiki-body-refs.d.ts +24 -0
- package/node_modules/@ktx/context/dist/ingest/wiki-body-refs.js +111 -0
- package/node_modules/@ktx/context/dist/ingest/wiki-body-refs.test.d.ts +1 -0
- package/node_modules/@ktx/context/dist/ingest/wiki-body-refs.test.js +138 -0
- package/node_modules/@ktx/context/dist/llm/claude-code-runtime.js +19 -2
- package/node_modules/@ktx/context/dist/llm/claude-code-runtime.test.js +33 -0
- package/node_modules/@ktx/context/dist/project/setup-config.d.ts +1 -1
- package/node_modules/@ktx/context/dist/project/setup-config.js +10 -1
- package/node_modules/@ktx/context/dist/project/setup-config.test.js +3 -2
- package/node_modules/@ktx/context/dist/sl/tools/sl-edit-source.tool.js +5 -1
- package/node_modules/@ktx/context/dist/sl/tools/sl-edit-source.tool.test.js +15 -0
- package/node_modules/@ktx/context/dist/sl/tools/sl-write-source.tool.js +5 -1
- package/node_modules/@ktx/context/dist/sl/tools/sl-write-source.tool.test.js +22 -0
- package/node_modules/@ktx/context/dist/tools/action-target-connection.d.ts +9 -0
- package/node_modules/@ktx/context/dist/tools/action-target-connection.js +14 -0
- package/node_modules/@ktx/context/dist/tools/context-candidate-write.tool.d.ts +4 -4
- package/node_modules/@ktx/context/dist/tools/index.d.ts +1 -0
- package/node_modules/@ktx/context/dist/tools/index.js +1 -0
- package/node_modules/@ktx/context/dist/wiki/local-knowledge.js +4 -1
- package/node_modules/@ktx/context/dist/wiki/local-knowledge.test.js +44 -0
- package/node_modules/@ktx/context/dist/wiki/tools/wiki-write.tool.js +3 -48
- package/node_modules/@ktx/context/dist/wiki/tools/wiki-write.tool.test.js +28 -0
- package/node_modules/@ktx/context/dist/wiki/wiki-ref-validation.d.ts +17 -0
- package/node_modules/@ktx/context/dist/wiki/wiki-ref-validation.js +79 -0
- package/node_modules/@ktx/context/dist/wiki/wiki-ref-validation.test.d.ts +1 -0
- package/node_modules/@ktx/context/dist/wiki/wiki-ref-validation.test.js +64 -0
- package/node_modules/@ktx/context/prompts/memory_agent_bundle_ingest_work_unit.md +23 -4
- package/node_modules/@ktx/context/skills/ingest_triage/SKILL.md +7 -3
- package/package.json +4 -4
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MemoryAction } from '../tools/index.js';
|
|
2
|
+
import type { KnowledgeWikiService } from './knowledge-wiki.service.js';
|
|
3
|
+
import type { WikiScope } from './types.js';
|
|
4
|
+
export declare function findMissingWikiRefs(input: {
|
|
5
|
+
wikiService: KnowledgeWikiService;
|
|
6
|
+
scope: WikiScope;
|
|
7
|
+
scopeId: string | null;
|
|
8
|
+
pageKey: string;
|
|
9
|
+
refs?: string[];
|
|
10
|
+
content: string;
|
|
11
|
+
}): Promise<string[]>;
|
|
12
|
+
export declare function findDanglingWikiRefsForActions(input: {
|
|
13
|
+
wikiService: KnowledgeWikiService;
|
|
14
|
+
scope: WikiScope;
|
|
15
|
+
scopeId: string | null;
|
|
16
|
+
actions: MemoryAction[];
|
|
17
|
+
}): Promise<string[]>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { isFlatWikiKey } from './keys.js';
|
|
2
|
+
function isWikiPageKeyRef(ref) {
|
|
3
|
+
return /^[a-z0-9][a-z0-9_-]*(?:-[a-z0-9_]+)*$/.test(ref);
|
|
4
|
+
}
|
|
5
|
+
function extractInlineWikiRefs(content) {
|
|
6
|
+
const refs = new Set();
|
|
7
|
+
const re = /\[\[([^\]\n]+)\]\]/g;
|
|
8
|
+
for (const match of content.matchAll(re)) {
|
|
9
|
+
const target = match[1]?.split('|', 1)[0]?.trim();
|
|
10
|
+
if (target && isWikiPageKeyRef(target)) {
|
|
11
|
+
refs.add(target);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return [...refs].sort();
|
|
15
|
+
}
|
|
16
|
+
async function visibleWikiPageKeys(wikiService, scope, scopeId) {
|
|
17
|
+
const keys = new Set();
|
|
18
|
+
if (scope === 'USER') {
|
|
19
|
+
for (const key of await wikiService.listPageKeys('GLOBAL', null)) {
|
|
20
|
+
keys.add(key);
|
|
21
|
+
}
|
|
22
|
+
for (const key of await wikiService.listPageKeys('USER', scopeId)) {
|
|
23
|
+
keys.add(key);
|
|
24
|
+
}
|
|
25
|
+
return keys;
|
|
26
|
+
}
|
|
27
|
+
for (const key of await wikiService.listPageKeys('GLOBAL', null)) {
|
|
28
|
+
keys.add(key);
|
|
29
|
+
}
|
|
30
|
+
return keys;
|
|
31
|
+
}
|
|
32
|
+
export async function findMissingWikiRefs(input) {
|
|
33
|
+
const candidates = new Set();
|
|
34
|
+
for (const ref of input.refs ?? []) {
|
|
35
|
+
if (isWikiPageKeyRef(ref)) {
|
|
36
|
+
candidates.add(ref);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (const ref of extractInlineWikiRefs(input.content)) {
|
|
40
|
+
candidates.add(ref);
|
|
41
|
+
}
|
|
42
|
+
if (candidates.size === 0) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
const available = await visibleWikiPageKeys(input.wikiService, input.scope, input.scopeId);
|
|
46
|
+
available.add(input.pageKey);
|
|
47
|
+
return [...candidates].filter((ref) => !available.has(ref)).sort();
|
|
48
|
+
}
|
|
49
|
+
export async function findDanglingWikiRefsForActions(input) {
|
|
50
|
+
const latestWikiActionByKey = new Map();
|
|
51
|
+
for (const action of input.actions) {
|
|
52
|
+
if (action.target === 'wiki' && isFlatWikiKey(action.key)) {
|
|
53
|
+
latestWikiActionByKey.set(action.key, action.type);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const dangling = [];
|
|
57
|
+
for (const [pageKey, actionType] of [...latestWikiActionByKey.entries()].sort(([left], [right]) => left.localeCompare(right))) {
|
|
58
|
+
if (actionType === 'removed') {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const page = await input.wikiService.readPage(input.scope, input.scopeId, pageKey);
|
|
62
|
+
if (!page) {
|
|
63
|
+
dangling.push(`${pageKey} -> (missing page)`);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const missingRefs = await findMissingWikiRefs({
|
|
67
|
+
wikiService: input.wikiService,
|
|
68
|
+
scope: input.scope,
|
|
69
|
+
scopeId: input.scopeId,
|
|
70
|
+
pageKey,
|
|
71
|
+
refs: page.frontmatter.refs,
|
|
72
|
+
content: page.content,
|
|
73
|
+
});
|
|
74
|
+
for (const missingRef of missingRefs) {
|
|
75
|
+
dangling.push(`${pageKey} -> ${missingRef}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return dangling;
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { findDanglingWikiRefsForActions } from './wiki-ref-validation.js';
|
|
3
|
+
function makeWikiService(pages) {
|
|
4
|
+
return {
|
|
5
|
+
listPageKeys: vi.fn().mockResolvedValue(Object.keys(pages)),
|
|
6
|
+
readPage: vi.fn().mockImplementation((_scope, _scopeId, pageKey) => {
|
|
7
|
+
const page = pages[pageKey];
|
|
8
|
+
if (!page) {
|
|
9
|
+
return Promise.resolve(null);
|
|
10
|
+
}
|
|
11
|
+
return Promise.resolve({
|
|
12
|
+
pageKey,
|
|
13
|
+
frontmatter: { summary: pageKey, usage_mode: 'auto', refs: page.refs },
|
|
14
|
+
content: page.content ?? '',
|
|
15
|
+
});
|
|
16
|
+
}),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
describe('wiki ref validation', () => {
|
|
20
|
+
it('allows circular refs once both touched pages exist', async () => {
|
|
21
|
+
const wikiService = makeWikiService({
|
|
22
|
+
'page-a': { refs: ['page-b'], content: 'See [[page-b]].' },
|
|
23
|
+
'page-b': { refs: ['page-a'], content: 'See [[page-a]].' },
|
|
24
|
+
});
|
|
25
|
+
const dangling = await findDanglingWikiRefsForActions({
|
|
26
|
+
wikiService: wikiService,
|
|
27
|
+
scope: 'GLOBAL',
|
|
28
|
+
scopeId: null,
|
|
29
|
+
actions: [
|
|
30
|
+
{ target: 'wiki', type: 'created', key: 'page-a', detail: 'Page A' },
|
|
31
|
+
{ target: 'wiki', type: 'created', key: 'page-b', detail: 'Page B' },
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
expect(dangling).toEqual([]);
|
|
35
|
+
});
|
|
36
|
+
it('treats removed pages as unavailable ref targets', async () => {
|
|
37
|
+
const wikiService = makeWikiService({
|
|
38
|
+
'page-a': { refs: ['page-b'], content: 'See [[page-b]].' },
|
|
39
|
+
});
|
|
40
|
+
const dangling = await findDanglingWikiRefsForActions({
|
|
41
|
+
wikiService: wikiService,
|
|
42
|
+
scope: 'GLOBAL',
|
|
43
|
+
scopeId: null,
|
|
44
|
+
actions: [
|
|
45
|
+
{ target: 'wiki', type: 'updated', key: 'page-a', detail: 'Page A' },
|
|
46
|
+
{ target: 'wiki', type: 'removed', key: 'page-b', detail: 'Page B' },
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
expect(dangling).toEqual(['page-a -> page-b']);
|
|
50
|
+
});
|
|
51
|
+
it('does not validate existing dangling refs on untouched pages', async () => {
|
|
52
|
+
const wikiService = makeWikiService({
|
|
53
|
+
'page-a': { refs: [], content: '' },
|
|
54
|
+
'old-page': { refs: ['missing-page'], content: 'See [[missing-page]].' },
|
|
55
|
+
});
|
|
56
|
+
const dangling = await findDanglingWikiRefsForActions({
|
|
57
|
+
wikiService: wikiService,
|
|
58
|
+
scope: 'GLOBAL',
|
|
59
|
+
scopeId: null,
|
|
60
|
+
actions: [{ target: 'wiki', type: 'updated', key: 'page-a', detail: 'Page A' }],
|
|
61
|
+
});
|
|
62
|
+
expect(dangling).toEqual([]);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
<role>
|
|
2
|
-
You are processing ONE WorkUnit of a multi-file ingest bundle. The WorkUnit
|
|
2
|
+
You are processing ONE WorkUnit of a multi-file ingest bundle. The WorkUnit
|
|
3
|
+
gives you a slice of raw source files (LookML views, dbt/MetricFlow YAMLs,
|
|
4
|
+
Metabase card JSONs, Notion pages, or similar) and you must translate that
|
|
5
|
+
slice into KTX semantic-layer sources and/or knowledge wiki pages, in one pass.
|
|
6
|
+
You run in an isolated WorkUnit worktree. Deterministic projection output,
|
|
7
|
+
existing project memory, and listed dependency paths are visible; sibling
|
|
8
|
+
WorkUnit edits from this same job are not visible until the runner integrates
|
|
9
|
+
accepted patches.
|
|
3
10
|
</role>
|
|
4
11
|
|
|
5
12
|
<stance>
|
|
@@ -8,9 +15,19 @@ Assertive. The bundle was explicitly submitted for ingest. Default to capturing
|
|
|
8
15
|
|
|
9
16
|
<workflow>
|
|
10
17
|
1. Read this WorkUnit's section at the end of the user prompt. It lists your `rawFiles`, any unchanged `dependencyPaths` you may need to resolve references, the `peerFileIndex` (paths only; you CANNOT read them), the source's `skillNames`, and any `priorProvenance` rows telling you what earlier syncs produced from these files.
|
|
11
|
-
2. Load the per-source review skill first (
|
|
18
|
+
2. Load the per-source review skill first (for example `lookml_ingest`,
|
|
19
|
+
`metricflow_ingest`, or `dbt_ingest`), then `sl_capture` and
|
|
20
|
+
`wiki_capture`, and `ingest_triage` last. The triage skill tells you how to
|
|
21
|
+
react when existing project memory, deterministic projection output, or
|
|
22
|
+
prior provenance overlaps with what this WorkUnit is about to write.
|
|
12
23
|
3. If the system prompt includes `<canonical_pins>`, read those pins before choosing artifact keys. A pin's `canonicalArtifactKey` is the preferred artifact for its `contestedKey`: prefer editing the pinned canonical artifact when it already exists or when this raw file clearly updates it. Do not create a duplicate contested artifact when a pin says another artifact is canonical; use a specific disambiguated key only when the raw file describes a genuinely different domain.
|
|
13
|
-
4. For each raw file: call `read_raw_file` (or `read_raw_span` for slicing large
|
|
24
|
+
4. For each raw file: call `read_raw_file` (or `read_raw_span` for slicing large
|
|
25
|
+
files) to load content. Before writing a new SL source or wiki page, call
|
|
26
|
+
`discover_data` for each candidate source, table, metric, or topic name to
|
|
27
|
+
find existing wiki pages, SL sources, deterministic projection output, prior
|
|
28
|
+
sync artifacts, and raw warehouse matches; apply `ingest_triage` when you hit
|
|
29
|
+
one, and apply any matching canonical pin before deciding whether to edit,
|
|
30
|
+
rename, or skip.
|
|
14
31
|
5. For every `wiki_write`, `wiki_remove`, `sl_write_source`, or `sl_edit_source` call, include `rawPaths` with only the raw file paths that directly support that action. If one artifact synthesizes several files, list each contributing raw file. Do not include unrelated files from the same WorkUnit.
|
|
15
32
|
6. When `priorProvenance` names an existing artifact for one of your raw files, prefer `sl_edit` over `sl_write` for that artifact: the re-ingest change rule says expression-only changes replace silently, grain/column/filter changes replace and flag.
|
|
16
33
|
7. When a raw file cannot map to normal SL and you use a fallback path, call `emit_unmapped_fallback` exactly once for that raw file and reason. Use `fallback: "sql_standalone"` for a standalone SQL source, `fallback: "wiki_only"` for documentation-only capture, and `fallback: "flagged"` when no reliable artifact can be written.
|
|
@@ -28,5 +45,7 @@ Wiki keys must be flat slugs like `paid-order-lifecycle`, not directory paths li
|
|
|
28
45
|
- Do not invent physical column names or grain keys. For table-backed SL sources, every `columns:`, `grain:`, `joins:`, `segments:`, and `measures[].expr` column must come from raw-file column declarations or warehouse-backed discovery (`discover_data`, `sl_discover`, `entity_details`). If column names are not confirmed, capture the business context in wiki instead of writing a full SL source.
|
|
29
46
|
- Do not write context-source overlays into the context source connection just because that is the current WorkUnit connection. Use `sl_discover` across data sources and write the SL artifact to the warehouse/data-source connection that owns the matching manifest. If there is no confirmed target connection, use `emit_unmapped_fallback` and wiki capture.
|
|
30
47
|
- Do not duplicate an artifact that prior provenance says you already produced; update it.
|
|
31
|
-
- Do not silently accept a name collision with
|
|
48
|
+
- Do not silently accept a name collision with visible existing memory,
|
|
49
|
+
deterministic projection output, or prior provenance when the formula differs.
|
|
50
|
+
Trigger `ingest_triage`.
|
|
32
51
|
</do_not>
|
|
@@ -7,8 +7,11 @@ callers: [memory_agent]
|
|
|
7
7
|
# Ingest Triage - conflict classification and resolution
|
|
8
8
|
|
|
9
9
|
This skill is loaded in two contexts:
|
|
10
|
-
- By a Stage 3 WorkUnit agent when `sl_discover
|
|
11
|
-
|
|
10
|
+
- By a Stage 3 WorkUnit agent when `sl_discover`, deterministic projection
|
|
11
|
+
output, existing project memory, or prior provenance overlaps with what the
|
|
12
|
+
current WorkUnit is about to write.
|
|
13
|
+
- By the Stage 4 reconciliation agent for cross-WorkUnit sweeps, accepted patch
|
|
14
|
+
overlap, and eviction decisions.
|
|
12
15
|
|
|
13
16
|
Apply the rules below before every write that could collide with an existing artifact.
|
|
14
17
|
|
|
@@ -23,7 +26,8 @@ Apply the rules below before every write that could collide with an existing art
|
|
|
23
26
|
3. **If the difference is structural - grain, columns, filter, join shape - is the current bundle the re-ingest of a previously-ingested bundle (i.e. `priorProvenance` has a row for this raw file and artifact)?**
|
|
24
27
|
Re-ingest change (semantic break): replace + flag. Record in the IngestReport's `conflicts_resolved` list with `flagged_for_human: true`.
|
|
25
28
|
|
|
26
|
-
4. **If
|
|
29
|
+
4. **If reconciliation sees accepted patches from this same job with no
|
|
30
|
+
prior-sync row, check for same-ingest contradictions:**
|
|
27
31
|
|
|
28
32
|
| Kind | Detection | Resolution |
|
|
29
33
|
|---|---|---|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaelio/ktx",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Standalone KTX context layer for database agents",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -71,10 +71,10 @@
|
|
|
71
71
|
"license": "Apache-2.0",
|
|
72
72
|
"repository": {
|
|
73
73
|
"type": "git",
|
|
74
|
-
"url": "
|
|
74
|
+
"url": "https://github.com/Kaelio/ktx"
|
|
75
75
|
},
|
|
76
76
|
"bugs": {
|
|
77
|
-
"url": "https://github.com/
|
|
77
|
+
"url": "https://github.com/Kaelio/ktx/issues"
|
|
78
78
|
},
|
|
79
|
-
"homepage": "https://github.com/
|
|
79
|
+
"homepage": "https://github.com/Kaelio/ktx#readme"
|
|
80
80
|
}
|