修复(08-08-production-deployment-execution): 保留生产预检真实错误码
ci-e2e / e2e (push) Canceled after 0s
ci-minimal / check-minimal (push) Canceled after 0s

这个提交包含在:
2026-08-08 20:14:36 +08:00
父节点 8892ca9e38
当前提交 83af7544c4
共修改 4 个文件,包含 116 行新增和 9 行删除
@@ -130,6 +130,12 @@ describe("deployment safety contract", () => {
expect(preflight).toContain("PRISMA_STATUS_OUTPUT_UNREADABLE");
expect(preflight).toContain("redacted datasource line");
expect(preflight).toContain("PRODUCTION_PREFLIGHT_REPORT_NOT_FRESH");
expect(preflight.lastIndexOf("printStableRemoteSummary(stdout)")).toBeLessThan(
preflight.lastIndexOf("assertRemotePreflightResult({"),
);
expect(preflight.indexOf("reportRef=${reportRef(reportDir)}")).toBeLessThan(
preflight.lastIndexOf("assertRemotePreflightResult({"),
);
expect(remote).toContain("PRISMA_STATUS_BEGIN");
expect(remote).toContain("PROD_MIGRATION_STATUS_UNKNOWN_PENDING");
expect(remote).toContain("logged_failure");
@@ -227,6 +233,46 @@ describe("deployment safety contract", () => {
);
});
it.each([
{
name: "prefers a remote safety code when the marker is missing",
status: 1,
stdout: "",
stderr: "[production-preflight][PAUSED] code=PROD_DATABASE_IDENTITY_MISMATCH",
rawStatus: null,
expectedCode: "PROD_DATABASE_IDENTITY_MISMATCH",
},
{
name: "prefers a remote safety code when the marker exists",
status: 1,
stdout: "[production-preflight][PAUSED] code=PROD_MIGRATION_STATUS_FAILED",
stderr: "",
rawStatus: "Database schema is up to date!",
expectedCode: "PROD_MIGRATION_STATUS_FAILED",
},
{
name: "fails closed when a remote failure has no parseable code",
status: 1,
stdout: "remote command failed",
stderr: "ssh exited unexpectedly",
rawStatus: null,
expectedCode: "PRODUCTION_PREFLIGHT_REMOTE_FAILED",
},
{
name: "requires the Prisma marker after a successful remote exit",
status: 0,
stdout: "[production-preflight][PASS] target_identity",
stderr: "",
rawStatus: null,
expectedCode: "PRISMA_STATUS_OUTPUT_MISSING",
},
])("$name", async ({ status, stdout, stderr, rawStatus, expectedCode }) => {
const target = await import(pathToFileURL(PRODUCTION_PREFLIGHT).href);
expect(() => target.assertRemotePreflightResult({ status, stdout, stderr, rawStatus })).toThrowError(
expect.objectContaining({ code: expectedCode }),
);
});
it("captures a redacted pre-status evidence copy from a controlled SSH fixture", async () => {
const fakeBin = path.join(fixtureRoot, "bin");
const reportDir = path.join(fixtureRoot, "report");