feat(P-001, P-002): 0pt→N0D quality delegation + internal OpenAPI
CI (SIAX Cloud) / security (pull_request) Successful in 16s
CI (SIAX Cloud) / security (push) Successful in 16s
Security Scan (SIAX Cloud) / security (push) Successful in 17s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 23s
CI (SIAX Cloud) / integration (push) Failing after 27s
CI (SIAX Cloud) / integration (pull_request) Failing after 31s
CI (SIAX Cloud) / quality (pull_request) Successful in 42s
CI (SIAX Cloud) / quality (push) Successful in 42s

This commit is contained in:
2026-09-08 22:38:47 +02:00
parent 4514d97e13
commit 2d34cb1629
5 changed files with 252 additions and 21 deletions
+60 -4
View File
@@ -3,14 +3,18 @@
* contract (sax3l/n0d main `src/api/schemas.ts` createJobSchema +
* `src/api/mappers.ts` + job-lifecycle routes, verified 2026-08-31):
*
* POST /v1/n0d/jobs (202) — required: job_type, capability_id, tenant_id,
* required_role (enum), resource_requirements {cpu, memory_gb, disk_gb};
* idempotency is BODY-ONLY (idempotency_key); callback_url = CloudEvents.
* GET /v1/n0d/jobs/:id, GET /v1/n0d/jobs/:id/result
* POST /v1/n0d/jobs (202) — generic job creation (n0dCreateJob)
* POST /v1/n0d/quality/run (202) — data-quality delegation (n0dRunDataQuality)
* GET /v1/n0d/jobs/:id
* GET /v1/n0d/jobs/:id/result
*
* The pre-2026-08-31 client sent required_node_roles[]/resource_profile/
* output_artifact_type/risk_level — fields N0D's createJobSchema does not
* accept. This test pins the mapped wire shape.
*
* P-001 (owner-seam): 0pt delegates quality to N0D via n0dRunDataQuality
* (POST /v1/n0d/quality/run), NOT the generic createJob. N0D OWNS quality
* execution; 0pt only requests it.
*/
import { describe, it, expect, afterEach } from "vitest";
import {
@@ -18,6 +22,7 @@ import {
resolveRequiredRole,
resolveResourceRequirements,
type N0dCreateJobInput,
type RunDataQualityInput,
} from "@/src/clients/n0d-client";
import { SiaxError } from "@/src/platform/errors";
import { startContractServer, type ContractServer } from "./contract-test-server";
@@ -150,4 +155,55 @@ describe("N0dClient wire contract", () => {
expect((err as SiaxError).code).toBe("NOT_FOUND");
}
});
it("P-001: runDataQuality POSTs to /v1/n0d/quality/run with dataset_id + quality_rule_set_id", async () => {
server = await startContractServer([
{ method: "POST", path: "/v1/n0d/quality/run", status: 202, respond: () => WIRE_JOB },
]);
const client = createN0dClient(server.baseUrl);
const runInput: RunDataQualityInput = {
tenant_id: "t_test",
dataset_id: "ds_1",
quality_rule_set_id: "rs_1",
project_id: "p_test",
run_inline: { dataset_csv: "a,b\n1,2", rules: [{ expectation: "expect_column_to_exist", column: "a" }] },
idempotency_key: "dq:ds_1:latest:dqrun_",
};
const job = await client.runDataQuality(runInput);
const req = server.requests[0];
expect(req.method).toBe("POST");
expect(req.path).toBe("/v1/n0d/quality/run");
expect(req.headers["x-tenant-id"]).toBe("t_test");
const body = req.body as Record<string, unknown>;
expect(body.tenant_id).toBe("t_test");
expect(body.dataset_id).toBe("ds_1");
expect(body.quality_rule_set_id).toBe("rs_1");
expect(body.run_inline).toBeDefined();
expect(body.job_type).toBeUndefined();
expect(body.capability_id).toBeUndefined();
expect(body.required_role).toBeUndefined();
expect(body.resource_requirements).toBeUndefined();
expect(body.idempotency_key).toBe("dq:ds_1:latest:dqrun_");
expect(job.job_id).toBe("job_r3al");
});
it("P-001: runDataQuality without run_inline is enqueue-only (no fabricated result)", async () => {
server = await startContractServer([
{ method: "POST", path: "/v1/n0d/quality/run", status: 202, respond: () => WIRE_JOB },
]);
const client = createN0dClient(server.baseUrl);
const job = await client.runDataQuality({
tenant_id: "t_test",
dataset_id: "ds_2",
quality_rule_set_id: "rs_2",
});
expect(job.status).toBe("queued");
expect(job.job_id).toBe("job_r3al");
// The wire body must NOT carry createJob-only fields and must NOT fabricate results.
const body = server.requests[0].body as Record<string, unknown>;
expect(body.run_inline).toBeUndefined();
expect(body.job_type).toBeUndefined();
expect(body.capability_id).toBeUndefined();
});
});
+18
View File
@@ -4,6 +4,9 @@
* GE delegation (never faked), cross-tenant isolation.
*/
import { describe, it, expect } from "vitest";
import { readFileSync } from "node:fs";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { QualityService } from "@/src/quality/quality-service";
import { ExpectationEngine } from "@/src/quality/expectation-engine";
import { SiaxError } from "@/src/platform/errors";
@@ -226,4 +229,19 @@ describe("QualityService — GE delegation (§11 DQ, never faked)", () => {
expect(finished.results[0].executed_by).toBe("great_expectations");
await expect(q.recordDelegatedResults(run.run_id, "t_a", [])).rejects.toMatchObject({ code: "CONFLICT" });
});
it("P-002: n0dGetJobResult is registered in the 0pt OpenAPI catalog (0pt.n0dGetJobResult)", () => {
// Verify that the n0dGetJobResult operationId is present in the 0pt internal
// OpenAPI contract (contracts/openapi.yaml) — it is the P-001 owner-seam
// retrieval endpoint for delegated quality jobs.
const catalog = readFileSync(
resolve(dirname(fileURLToPath(import.meta.url)), "../../contracts/openapi.yaml"),
"utf8"
);
expect(catalog).toContain("operationId: 0pt.n0dGetJobResult");
expect(catalog).toContain("/api/0pt/n0d/results/{jobId}");
expect(catalog).toContain("operationId: 0pt.quality.run");
expect(catalog).toContain("operationId: 0pt.quality.checks");
expect(catalog).toContain("operationId: 0pt.quality.reports");
});
});