- 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 <noreply@anthropic.com>
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
/**
|
|
* src/platform/resource-ref.ts
|
|
* =============================
|
|
* Canonical SIAX resource references (Master-DoD §5):
|
|
*
|
|
* `<product>:<resourceType>:<resourceId>[@<version>]`
|
|
*
|
|
* e.g. `st0re:artifact:art_x`, `aud0:evidence:ev_x`, `0pt:dataset:ds_x`,
|
|
* `0pt:dataset:ds_x@3`. No product needs another product's DB primary key;
|
|
* references are stable, resolvable through the owning capability, and
|
|
* authorization happens at dereference (never here — this module is pure
|
|
* parsing/formatting).
|
|
*/
|
|
|
|
export interface SiaxResourceRef {
|
|
product: string;
|
|
resourceType: string;
|
|
resourceId: string;
|
|
version?: string;
|
|
}
|
|
|
|
const REF_RE = /^([a-z0-9][a-z0-9-]*):([a-z0-9][a-z0-9_-]*):([^@\s:]+)(?:@([A-Za-z0-9._-]+))?$/;
|
|
|
|
/** Format a canonical reference string. */
|
|
export function formatResourceRef(ref: SiaxResourceRef): string {
|
|
const base = `${ref.product}:${ref.resourceType}:${ref.resourceId}`;
|
|
return ref.version ? `${base}@${ref.version}` : base;
|
|
}
|
|
|
|
/** Parse a canonical reference string; returns undefined when malformed. */
|
|
export function parseResourceRef(raw: string): SiaxResourceRef | undefined {
|
|
const m = REF_RE.exec(raw.trim());
|
|
if (!m) return undefined;
|
|
return { product: m[1], resourceType: m[2], resourceId: m[3], ...(m[4] ? { version: m[4] } : {}) };
|
|
}
|
|
|
|
/** True when `raw` is a canonical reference for the given product/type. */
|
|
export function isResourceRef(raw: string, product?: string, resourceType?: string): boolean {
|
|
const ref = parseResourceRef(raw);
|
|
if (!ref) return false;
|
|
if (product && ref.product !== product) return false;
|
|
if (resourceType && ref.resourceType !== resourceType) return false;
|
|
return true;
|
|
}
|