fix(f4): harden schema-columns enrichment + ValidationError guard + staged-helper note

This commit is contained in:
2026-07-06 23:25:00 +02:00
committed by Marco Pancotti
parent 3ed570ee60
commit d942635085
4 changed files with 71 additions and 6 deletions
@@ -120,3 +120,51 @@ test("reviewer_schema_linking records table/column decisions and syncs schema_li
cp.execFileSync = origExecFileSync;
}
});
test("reviewer_schema_linking returns a textResult (not a throw) when a proposed table is not in the catalog", async () => {
const origExecFileSync = cp.execFileSync;
cp.execFileSync = (file, args) => {
if (args[0] === "phase" && args[1] === "meta")
return JSON.stringify({ phases: [{ num: 4, id: "F4" }] });
if (args[0] === "phase" && args[1] === "show") return "Fase corrente: 4\n";
if (args[0] === "schema" && args[1] === "columns" && args[2] === "badtable") {
const err = new Error("Command failed");
err.stderr = "ERRORE: tabella 'badtable' non trovata nel catalogo";
throw err;
}
return "";
};
try {
const gate = require(GATE);
const { createFakePi } = require("./fake_pi_runtime.js");
const { pi, ctx, tools } = createFakePi();
ctx.cwd = "/nonexistent-thothii-test-cwd";
gate.default(pi);
const tool = tools.get("reviewer_schema_linking");
assert.ok(tool, "reviewer_schema_linking must be registered");
const result = await tool.def.execute(
"call-1",
{
session: "s1",
title: "Schema linking",
tables: [
{
id: "t-bad",
name: "badtable",
kind: "promote",
},
],
},
null,
null,
ctx,
);
assert.match(result.content[0].text, /badtable/);
} finally {
cp.execFileSync = origExecFileSync;
}
});