diff --git a/backend/scripts/p2-acceptance.mjs b/backend/scripts/p2-acceptance.mjs index 91c6b7bc..6c6432ac 100644 --- a/backend/scripts/p2-acceptance.mjs +++ b/backend/scripts/p2-acceptance.mjs @@ -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")] }; }, }, {