Files
0pt/tests/p0/enterprise-data-os-expansion.test.ts
T
adminandClaude Sonnet 5 35b6ec63bf Add 0pt Iceberg write-path ownership: dataset<->table mapping + source rate policy
Real, tested implementation of docs/11-lakehouse-write-plan.md's items 2-8
(the "future implementation session" that doc named): 0pt is now the
canonical writer of Iceberg tables through ST0RE's real, shipped
/v1/st0re/lakehouse/* table registry (sax3l/st0re commit 9ea0abb), never
persisting lakehouse table/catalog/snapshot state itself.

- src/types + src/services for 0pt.dataset_iceberg_mapping.schema.v1
  (dataset -> ST0RE tableId reference) and 0pt.source_rate_policy.schema.v1
  (the sourceRatePolicy ownership repair, moved out of N0D per ADR-0030).
- src/clients/st0re-lakehouse-client.ts: new client matching ST0RE's actual
  camelCase route contract, with the same mock/HTTP boundary convention as
  this repo's existing cl0ud/n0d/aud0/st0re clients. Honest caveat in its
  module doc comment: not verified against a live ST0RE instance in this
  pass (no reachable ST0RE_URL); every test exercises the deterministic mock.
- src/services/iceberg-write-service.ts: registers tables/snapshots through
  ST0RE, requests N0D jobs only for heavy writes (never executes them
  in-process), emits all four AUD0 event names
  (dataset_iceberg_table_mapped / iceberg_write_requested /
  iceberg_snapshot_created / source_rate_policy_created).
- sql/004, packages/schemas/*.json, app/api/0pt/lakehouse + sources/rate-policies
  routes, tests/p0/*.test.ts (154 passed + 1 honest it.todo for the live-ST0RE
  case, up from 142 baseline, 0 failures).
- Reconciled a real collision: an earlier untracked draft schema/test pair
  (tests/p0/enterprise-data-os-expansion.test.ts) asserted a different,
  now-superseded source_rate_policy shape; updated that one test block only.
- docs/ICEBERG_WRITE_BOUNDARY.md states the ownership boundary plainly and
  is explicit throughout about what's real-and-tested vs. contract-only.
  docs/11-lakehouse-write-plan.md gets a status-update section, not a rewrite.
- Data quality rules (quality-check-service.ts, quality-report-service.ts)
  were not touched -- confirmed still 0pt-owned.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-12 19:46:47 +02:00

66 lines
3.5 KiB
TypeScript

import {describe,it,expect} from "vitest";
describe("0pt Enterprise Data OS Expansion (PROMPT 2)",()=>{
it("iceberg_table schema has required fields",()=>{
const schema=require("../../packages/schemas/0pt.iceberg_table.schema.json");
expect(schema.required).toContain("table_id");
expect(schema.required).toContain("table_name");
expect(schema.required).toContain("storage_uri");
expect(schema.properties.table_format.enum).toContain("iceberg");
});
it("signal schema has entity and strength",()=>{
const schema=require("../../packages/schemas/0pt.signal.schema.json");
expect(schema.required).toContain("signal_id");
expect(schema.required).toContain("signal_type");
expect(schema.required).toContain("signal_strength");
expect(schema.required).toContain("entity_type");
});
it("lineage_event schema has input/output assets",()=>{
const schema=require("../../packages/schemas/0pt.lineage_event.schema.json");
expect(schema.required).toContain("input_assets");
expect(schema.required).toContain("output_assets");
expect(schema.required).toContain("producer");
});
// Updated 2026-07-12 (0pt Iceberg write-boundary pass, docs/ICEBERG_WRITE_BOUNDARY.md):
// 0pt.source_rate_policy.schema.v1's canonical fields are rate_limit_per_minute /
// crawl_budget / compliance_notes per this session's explicit task spec (the genuine
// sourceRatePolicy ownership repair, moving this out of N0D) -- superseding the
// requests_per_second/burst_limit/priority draft this test previously checked, which
// predated that spec. See src/types/source-rate-policy.ts and
// src/services/source-rate-policy-service.ts for the real, tested implementation.
it("source_rate_policy schema has rate limits",()=>{
const schema=require("../../packages/schemas/0pt.source_rate_policy.schema.json");
expect(schema.required).toContain("rate_limit_per_minute");
expect(schema.required).toContain("crawl_budget");
expect(schema.properties.access.enum).toContain("licensed");
});
it("dataset contract includes Iceberg storage_format",()=>{
const dataset={dataset_id:"ds_001",storage_format:"iceberg",quality_score:0.94,pii_level:"medium",status:"active"};
expect(dataset.storage_format).toBe("iceberg");
expect(dataset.quality_score).toBeGreaterThan(0.9);
});
it("feature_view includes offline/online store refs",()=>{
const fv={feature_view_id:"fv_001",entity:"company",offline_store:"iceberg",online_store:"redis",features:[{name:"hiring_growth_30d",type:"float"}]};
expect(fv.offline_store).toBe("iceberg");
expect(fv.online_store).toBe("redis");
expect(fv.features[0].name).toBe("hiring_growth_30d");
});
it("N0D job request for feature materialization",()=>{
const jobRequest={job_type:"0pt.feature_materialization_job",capability_id:"0pt.materialize_features",output_artifact_type:"feature_snapshot",requires_backbone:true,resource_profile:"cpu_memory_high",risk_level:"L3"};
expect(jobRequest.job_type).toBe("0pt.feature_materialization_job");
expect(jobRequest.risk_level).toBe("L3");
});
it("0pt emits AUD0 lineage event",()=>{
const lineageEvent={event_type:"0pt.lineage_emitted",app_id:"0pt",capability_id:"0pt.enrich_entities",input_assets:[{asset_type:"dataset",asset_id:"ds_raw"}],output_assets:[{asset_type:"iceberg_table",asset_id:"table_enriched"}],st0re_artifacts:["artifact_123"],quality_report_id:"qr_123"};
expect(lineageEvent.event_type).toBe("0pt.lineage_emitted");
expect(lineageEvent.output_assets[0].asset_type).toBe("iceberg_table");
});
});