feat(platform): canonical SIAX context/errors + real-contract clients, no prod mock fallback
- src/platform/: SiaxRequestContext + propagation headers + 12 canonical
error codes (documented mirror of cl0ud packages/contract), SiaxError,
resource refs (st0re:artifact:...), and the §3/§10 dependency-mode guard:
production runtime + unconfigured dependency/store => hard
DEPENDENCY_UNAVAILABLE at construction, never silent mock/in-memory.
- src/clients/: all four platform clients rewritten against the REAL wire
contracts verified on sibling main branches this session:
* cl0ud: POST /api/policy/evaluate ({data} envelope, allow+requiresApproval)
- the old /v1/cl0ud/policies/evaluate path never existed on CL0UD
* st0re: camelCase ArtifactInput on /v1/st0re/artifacts/register incl.
X-Tenant-Id/X-Actor-Id + X-Idempotency-Key - the old snake_case body
would have been a 400 against the live registry
* n0d: required_role + resource_requirements + body idempotency_key +
CloudEvents callback_url per n0d createJobSchema; adds getJob/getJobResult
* aud0: /v1/aud0/openlineage is AUD0's only lineage ingest -
/v1/aud0/lineage/events never existed; legacy shape converts to a
spec-shaped OpenLineage RunEvent (deterministic runId dedup)
- src/lineage/: OpenLineage subset types + LineageEmitter (never-throw,
§16 evidence semantics)
- shared SiaxHttp transport: timeouts, typed SiaxError mapping, context
propagation, no raw upstream bodies in errors
Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5
parent
00a1b3997d
commit
b7038d7675
@@ -63,7 +63,7 @@ describe("DocumentCaptureService.captureFromMailbox", () => {
|
||||
],
|
||||
});
|
||||
}
|
||||
if (url.includes("/v1/aud0/events") || url.includes("/v1/aud0/lineage/events")) {
|
||||
if (url.includes("/v1/aud0/events") || url.includes("/v1/aud0/openlineage")) {
|
||||
aud0Calls.push({ url, body: init?.body ? JSON.parse(init.body as string) : null });
|
||||
return jsonResponse({});
|
||||
}
|
||||
@@ -97,9 +97,11 @@ describe("DocumentCaptureService.captureFromMailbox", () => {
|
||||
expect(captured).toBeTruthy();
|
||||
expect(captured!.body.payload.filename).toBe("doc.pdf");
|
||||
expect(captured!.body.capability_id).toBe("0pt.capture_document");
|
||||
const lineage = aud0Calls.find((c) => c.url.includes("lineage"));
|
||||
// Lineage now goes to AUD0's REAL ingest contract: an OpenLineage
|
||||
// RunEvent on /v1/aud0/openlineage.
|
||||
const lineage = aud0Calls.find((c) => c.url.includes("openlineage"));
|
||||
expect(lineage).toBeTruthy();
|
||||
expect(lineage!.body.target_id).toBe(doc.document_id);
|
||||
expect(lineage!.body.outputs[0].name).toContain(doc.document_id);
|
||||
});
|
||||
|
||||
it("skips non-PDF attachments and records per-message errors without aborting the whole run", async () => {
|
||||
|
||||
@@ -97,7 +97,7 @@ describe("DocumentExtractionService — evidence-based extraction", () => {
|
||||
},
|
||||
});
|
||||
}
|
||||
if (url.includes("/v1/aud0/events") || url.includes("/v1/aud0/lineage/events")) {
|
||||
if (url.includes("/v1/aud0/events") || url.includes("/v1/aud0/openlineage")) {
|
||||
aud0Calls.push({ url, body: init?.body ? JSON.parse(init.body as string) : null });
|
||||
return jsonResponse({});
|
||||
}
|
||||
|
||||
@@ -61,14 +61,26 @@ function baseRequest(overrides: Partial<ExternalWriteRequest> = {}): ExternalWri
|
||||
function stubCl0udAllowAndAud0(opts: { decision?: "allow" | "deny" | "approval_required" } = {}) {
|
||||
const aud0Calls: { url: string; body: any }[] = [];
|
||||
const fetchMock = vi.fn(async (url: string, init?: RequestInit) => {
|
||||
if (url.includes("/v1/cl0ud/policies/evaluate")) {
|
||||
// REAL CL0UD wire contract (cl0ud main): POST /api/policy/evaluate with a
|
||||
// `{ data: { decision, requiresApproval, ... } }` envelope; there is no
|
||||
// "approval_required" decision value on the wire — it is allow +
|
||||
// requiresApproval, which 0pt's client maps back onto the historical
|
||||
// three-value vocabulary.
|
||||
if (url.includes("/api/policy/evaluate")) {
|
||||
const wanted = opts.decision ?? "allow";
|
||||
return jsonResponse({
|
||||
decision_id: "pdec_test",
|
||||
decision: opts.decision ?? "allow",
|
||||
reason: opts.decision === "deny" ? "test_deny" : opts.decision === "approval_required" ? "test_approval_required" : undefined,
|
||||
data: {
|
||||
decision: wanted === "deny" ? "deny" : "allow",
|
||||
requiresApproval: wanted === "approval_required",
|
||||
decisionId: "pdec_test",
|
||||
reason: wanted === "deny" ? "test_deny" : wanted === "approval_required" ? "test_approval_required" : undefined,
|
||||
},
|
||||
meta: {},
|
||||
});
|
||||
}
|
||||
if (url.includes("/v1/aud0/events") || url.includes("/v1/aud0/lineage/events")) {
|
||||
// REAL AUD0 lineage ingest is the OpenLineage endpoint (/v1/aud0/openlineage);
|
||||
// /v1/aud0/lineage/events never existed on AUD0.
|
||||
if (url.includes("/v1/aud0/events") || url.includes("/v1/aud0/openlineage")) {
|
||||
aud0Calls.push({ url, body: init?.body ? JSON.parse(init.body as string) : null });
|
||||
return jsonResponse({});
|
||||
}
|
||||
@@ -145,11 +157,15 @@ describe("ExternalWritebackService — successful write", () => {
|
||||
expect(writtenEvent!.body.risk_level).toBe("L4");
|
||||
expect(writtenEvent!.body.payload.external_id).toBe("ext_1");
|
||||
|
||||
const lineageEvent = aud0Calls.find((c) => c.url.includes("/lineage/"));
|
||||
// Lineage now goes to AUD0's REAL ingest contract: an OpenLineage
|
||||
// RunEvent on /v1/aud0/openlineage (the legacy source/target shape is
|
||||
// converted by aud0-client's legacyLineageToOpenLineage).
|
||||
const lineageEvent = aud0Calls.find((c) => c.url.includes("/openlineage"));
|
||||
expect(lineageEvent).toBeTruthy();
|
||||
expect(lineageEvent!.body.source_id).toBe("idem-1");
|
||||
expect(lineageEvent!.body.target_id).toBe("ext_1");
|
||||
expect(lineageEvent!.body.lineage_type).toBe("produced");
|
||||
expect(lineageEvent!.body.eventType).toBe("COMPLETE");
|
||||
expect(lineageEvent!.body.inputs[0].name).toContain("idem-1");
|
||||
expect(lineageEvent!.body.outputs[0].name).toContain("ext_1");
|
||||
expect(lineageEvent!.body.run.facets.siaxLegacyLineage.lineage_type).toBe("produced");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user