fix: mine FK candidates from approved SQL joins in the acceptance
This commit is contained in:
@@ -1163,9 +1163,12 @@ async function realChecks(ctx) {
|
||||
{
|
||||
id: "schema_review",
|
||||
async run() {
|
||||
// FK suggestion consumes the workspace's own introspected physical schema.
|
||||
// FK suggestion consumes the workspace's own introspected physical schema and mines
|
||||
// approved SQL joins for candidates.
|
||||
await runThothctlJson(ctx, "preprocess-dwh-filesystem", ["workspace", "preprocess", "dwh", "--workspace", "p2-filesystem"], 0);
|
||||
const suggest = await runThothctlJson(ctx, "schema-suggest-filesystem", ["workspace", "schema", "suggest-fks", "--workspace", "p2-filesystem"], 3);
|
||||
const sqlPath = join(ctx.run.root, "fixtures", "p2-filesystem.sql");
|
||||
await atomicWrite(sqlPath, "SELECT v.id FROM dw.visits v JOIN dw.patients p ON v.patient_id = p.id\n");
|
||||
const suggest = await runThothctlJson(ctx, "schema-suggest-filesystem", ["workspace", "schema", "suggest-fks", "--workspace", "p2-filesystem", "--from-sql", sqlPath], 3);
|
||||
assert(suggest.payload.code === "manual_review_required", "suggest did not block");
|
||||
assert(typeof suggest.payload.suggestedFksYaml === "string" && suggest.payload.suggestedFksYaml.length > 0, "suggested FK YAML missing");
|
||||
const digest = suggest.payload.artifactIdentities?.[0]?.digest;
|
||||
@@ -1182,7 +1185,7 @@ async function realChecks(ctx) {
|
||||
], 0);
|
||||
assert(checked.payload.status === "succeeded", "schema check failed");
|
||||
state.filesystemCandidateDigest = digest;
|
||||
return { commands: ["thothctl"], artifacts: [...suggest.artifacts, ...checked.artifacts, await fileArtifact(ctx.run.root, "fixtures/p2-filesystem.candidates.yaml"), await fileArtifact(ctx.run.root, "fixtures/p2-filesystem.annotations.yaml")] };
|
||||
return { commands: ["thothctl"], artifacts: [...suggest.artifacts, ...checked.artifacts, await fileArtifact(ctx.run.root, "fixtures/p2-filesystem.candidates.yaml"), await fileArtifact(ctx.run.root, "fixtures/p2-filesystem.annotations.yaml"), await fileArtifact(ctx.run.root, "fixtures/p2-filesystem.sql")] };
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user