CI (SIAX Cloud) / integration (push) Successful in 42s
CI (SIAX Cloud) / quality (push) Successful in 1m17s
CI (SIAX Cloud) / security (push) Successful in 46s
Security Scan (SIAX Cloud) / security (push) Successful in 31s
CI (SIAX Cloud) / security (pull_request) Successful in 24s
CI (SIAX Cloud) / integration (pull_request) Successful in 36s
CI (SIAX Cloud) / quality (pull_request) Successful in 1m4s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 27s
BEFORE_STATE (verified, with evidence):
* P060 PARTIAL/BROKEN. The registry persisted rights/provenance/health/
freshness to Postgres, but carried no authorization, no schedule, no
checkpoint, no schema and no owner distinct from created_by — and the
activation DoD was inverted: postgres-source-repository.ts wrote
`${input.status ?? "active"}`, so a source with no rights, no provenance
and no authorization was ACTIVE the instant it was registered. No
activation operation existed at all.
* P061 MISSING. services/api/sources/connectors.py had per-source fetch_*()
functions only — no lifecycle, no cursor, no resume, no health, no
conformance suite.
* P062 MISSING, already documented as such in
services/api/tests/test_known_gaps.py:10-19 (no CDC pipeline anywhere;
workers/pipeline.py has no persistence at all).
* P063 MISSING. schema_version existed as a free string; no comparison,
no policy, no versioned source schema.
* P064 PARTIAL. Rules/runs/issues/scores existed, but a failing rule only
opened an issue and the data flowed on. No quarantine anywhere.
* P065 DUPLICATE (confirmed). Two ER engines: src/er/entity-resolution-
service.ts (canonical) and services/api/workers/resolve.py (simplified,
still called by pipeline.py:110).
* P067 PARTIAL. Lineage was emitted to AUD0 but nothing here could ANSWER a
lineage question — no store, no query, no route.
* P068 MISSING, documented in test_known_gaps.py:44-52 ("no delivery-store
persistence layer exists to dedupe a backfill against").
BUILT (only what was PARTIAL/BROKEN/MISSING):
* P060 sql/007_ingestion_plane.sql adds authorization/schedule/schemas/
checkpoints/ledger/quarantine/lineage tables, owner_id, and flips the
opt_sources status DEFAULT to 'pending' so even a raw psql INSERT cannot
produce an unclassified-but-active source. SourceRegistryService gains
classifySource/activateSource/deactivateSource + authorization/schedule
accessors; registration NEVER activates (asking for status:"active" goes
through the gate, not around it); a service identity cannot authorize a
source. Routes: activate (GET classification / POST activate),
authorization, schedule.
* P061 src/connectors/connector.ts — all nine operations on one interface.
src/connectors/conformance.ts — a runnable suite (15 checks, no "skip"
verdict). HttpJsonConnector (real HTTP, opaque cursor) and
JsonlFileConnector (real file, line offsets, CDC deletes) both pass it.
The suite caught a real defect while being written: an API that drops
next_cursor at the end left the connector unable to resume, which is why
HttpJsonConnectorConfig has cursor_field.
* P062 src/types/ingestion.ts + src/ingestion/{envelope,ingestion-runner}.ts.
One envelope for batch/stream/cdc; durable per-(source,partition)
checkpoints; resume proven by killing a run inside the sink.
* P063 src/schema/{record-schema,compatibility,schema-registry}.ts. Two
enforcement points, both upstream of any consumer write: a discovery gate
before the first read, and per-record conformance before the page reaches
the sink. A producer cannot widen its own policy retroactively.
* P064 src/quality/quality-policy.ts composes the EXISTING ExpectationEngine
(not a second engine) and adds the missing consequence: block /
quarantine / warn, with quarantine durable and recoverable. No policy is
reported as "none_declared", never as a pass; an unexecutable expectation
counts as a violation, never a silent pass.
* P067 src/lineage/{lineage-edge,lineage-store}.ts + GET /api/0pt/lineage.
AUD0 stays the system of record; this is 0pt's own queryable projection.
* P068 opt_ingestion_ledger + IngestionRunner.backfill: bounded, idempotent
on repeat, leaves the live checkpoint alone, still re-emits real changes.
A BUG THIS PASS WROTE AND CAUGHT: the first IngestionRepository draft
combined the idempotency check and its recording into one atomic call
BEFORE the sink. The crash/resume test then delivered 7 of 10 records — the
page in flight when the sink died was already marked delivered, so the
resumed run skipped it as a duplicate. Permanent, silent data loss. Fixed by
splitting peekDeliveries/commitDeliveries and committing both the ledger and
the checkpoint only after the sink resolves.
NOT DONE, stated rather than deferred quietly:
* P065 is NOT met. resolve.py is still a second simplified production
engine. Closing it means rewriting it as an adapter over the canonical
service, which cannot be verified from this repo today: services/api is
not built by this repo's Dockerfile, api.0pt.app answers 404, and NO CI
workflow runs its pytest suite. The duplication is now stated at both
sites in code and the removal plan is in STATUS.md. The new ingestion
plane performs no ER, so it adds no third engine.
* P066 (Iceberg) untouched — ST0RE is owned by another workflow. Contract
read only.
* Delivery is AT-LEAST-ONCE, not exactly-once (no per-partition run lock).
* No CDC *source* exists; the contract is met, a CDC connector is not built.
* 0pt does not schedule itself — the schedule row is a declaration ACT0
would read.
VERIFIED: pnpm typecheck clean; pnpm test 365 passed / 25 skipped (was
311/18); pnpm build clean with all four new routes in the route table; lint
unchanged at 12 pre-existing errors. Real Postgres 16
(tests/p0/ingestion-plane-postgres.realinfra.test.ts, 7 passed) plus a real
`docker restart` of that container with an identical read-back through the
production code path — that is P060's "a restart preserves all sources",
measured.
DEPLOYMENT REALITY (curl, 2026-09-04): 0pt.app/api/health returns 200 from
Vercel with db:not_configured; 0pt.app/api/0pt/sources returns 404;
api.0pt.app/health returns 404; cd.yml still guards on a placeholder Coolify
app id. None of the capability layer runs in production. Nothing here is
LIVE_VERIFIED and STATUS.md says so.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
166 lines
7.2 KiB
TypeScript
166 lines
7.2 KiB
TypeScript
/**
|
|
* P061 DoD: "two heterogeneous connectors pass the same conformance suite."
|
|
*
|
|
* This file is that proof. It runs the SAME function
|
|
* (src/connectors/conformance.ts::runConnectorConformance) against two
|
|
* connectors that share nothing but the contract:
|
|
*
|
|
* HttpJsonConnector — a real node:http server on a real socket, opaque
|
|
* cursor paging, network health check, timestamp
|
|
* backfill bounds.
|
|
* JsonlFileConnector — a real file on disk, line-offset cursor, filesystem
|
|
* health check, line-number backfill bounds, and CDC
|
|
* delete records the HTTP connector cannot produce.
|
|
*
|
|
* Neither connector is mocked. The HTTP fixture is a genuine server that
|
|
* implements paging server-side; the file fixture is a genuine file written
|
|
* to a temp dir. A connector that only "passed" against a stub would prove
|
|
* nothing about the contract.
|
|
*/
|
|
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
import http from "node:http";
|
|
import type { AddressInfo } from "node:net";
|
|
import { promises as fs } from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { runConnectorConformance, type ConformanceFixture } from "@/src/connectors/conformance";
|
|
import { HttpJsonConnector } from "@/src/connectors/http-json-connector";
|
|
import { JsonlFileConnector } from "@/src/connectors/jsonl-file-connector";
|
|
import type { RecordSchemaFields } from "@/src/schema/record-schema";
|
|
|
|
const SCHEMA: RecordSchemaFields = {
|
|
org_number: { type: "string", required: true },
|
|
name: { type: "string", required: true },
|
|
employees: { type: "number", required: false },
|
|
};
|
|
|
|
/** 5 records, shared by both fixtures so the suite's counts are comparable. */
|
|
const ROWS = [
|
|
{ org_number: "556001-0001", name: "Alfa AB", employees: 10, seq: 1 },
|
|
{ org_number: "556002-0002", name: "Beta AB", employees: 20, seq: 2 },
|
|
{ org_number: "556003-0003", name: "Gamma AB", employees: 30, seq: 3 },
|
|
{ org_number: "556004-0004", name: "Delta AB", employees: 40, seq: 4 },
|
|
{ org_number: "556005-0005", name: "Epsilon AB", employees: 50, seq: 5 },
|
|
];
|
|
|
|
// --- fixture 1: a real paged HTTP API ---------------------------------------
|
|
|
|
let server: http.Server;
|
|
let baseUrl = "";
|
|
|
|
beforeAll(async () => {
|
|
server = http.createServer((req, res) => {
|
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
if (url.pathname !== "/v1/records") {
|
|
res.writeHead(404).end("{}");
|
|
return;
|
|
}
|
|
const limit = Number(url.searchParams.get("limit") ?? "100");
|
|
const from = url.searchParams.get("from");
|
|
const to = url.searchParams.get("to");
|
|
if (from !== null && to !== null) {
|
|
// Backfill: bounds are `seq` values, from inclusive, to exclusive.
|
|
const slice = ROWS.filter((r) => r.seq >= Number(from) && r.seq < Number(to)).slice(0, limit);
|
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
res.end(JSON.stringify({ records: slice, next_cursor: null }));
|
|
return;
|
|
}
|
|
// Cursor is the `seq` of the last record already delivered.
|
|
const after = Number(url.searchParams.get("cursor") ?? "0");
|
|
const slice = ROWS.filter((r) => r.seq > after).slice(0, limit);
|
|
const next = slice.length > 0 ? String(slice[slice.length - 1].seq) : null;
|
|
const more = slice.length > 0 && slice[slice.length - 1].seq < ROWS[ROWS.length - 1].seq;
|
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
res.end(JSON.stringify({ records: slice, next_cursor: more ? next : null }));
|
|
});
|
|
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
|
|
baseUrl = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await new Promise<void>((resolve) => server.close(() => resolve()));
|
|
await fs.rm(tmpDir, { recursive: true, force: true }).catch(() => undefined);
|
|
});
|
|
|
|
// --- fixture 2: a real JSONL file -------------------------------------------
|
|
|
|
const tmpDir = path.join(os.tmpdir(), `opt-conformance-${process.pid}`);
|
|
const jsonlPath = path.join(tmpDir, "companies.jsonl");
|
|
|
|
beforeAll(async () => {
|
|
await fs.mkdir(tmpDir, { recursive: true });
|
|
await fs.writeFile(
|
|
jsonlPath,
|
|
ROWS.map((r) => JSON.stringify({ org_number: r.org_number, name: r.name, employees: r.employees })).join("\n") + "\n",
|
|
"utf8",
|
|
);
|
|
});
|
|
|
|
const ctx = { tenant_id: "t_test", project_id: "p_test", source_id: "src_conf", run_id: "run_conf" };
|
|
|
|
describe("P061 connector contract — the same conformance suite, two heterogeneous connectors", () => {
|
|
it("HttpJsonConnector passes every check", async () => {
|
|
const fixture: ConformanceFixture = {
|
|
validConfig: {
|
|
base_url: baseUrl,
|
|
records_path: "/v1/records",
|
|
partition_key: "companies",
|
|
schema: SCHEMA,
|
|
record_key_field: "org_number",
|
|
cursor_field: "seq",
|
|
},
|
|
// Not an absolute URL and no schema — must be rejected without any IO.
|
|
invalidConfig: { base_url: "not-a-url", records_path: "v1/records", partition_key: "", record_key_field: "" },
|
|
ctx,
|
|
backfill: { from: "2", to: "4" },
|
|
expectedRecordCount: ROWS.length,
|
|
};
|
|
const report = await runConnectorConformance(new HttpJsonConnector(), fixture);
|
|
const failed = report.checks.filter((c) => !c.passed);
|
|
expect(failed.map((c) => `${c.name}: ${c.detail}`)).toEqual([]);
|
|
expect(report.passed).toBe(true);
|
|
expect(report.checks.length).toBeGreaterThanOrEqual(14);
|
|
});
|
|
|
|
it("JsonlFileConnector passes every check — the identical suite", async () => {
|
|
const fixture: ConformanceFixture = {
|
|
validConfig: {
|
|
file_path: jsonlPath,
|
|
partition_key: "companies",
|
|
schema: SCHEMA,
|
|
record_key_field: "org_number",
|
|
},
|
|
// Relative path, wrong extension, no schema.
|
|
invalidConfig: { file_path: "companies.csv", partition_key: "", record_key_field: "" },
|
|
ctx,
|
|
// File-connector bounds are LINE NUMBERS — deliberately a different
|
|
// vocabulary from the HTTP fixture's timestamps/sequence values, which
|
|
// is exactly the heterogeneity the shared contract has to survive.
|
|
backfill: { from: "1", to: "3" },
|
|
expectedRecordCount: ROWS.length,
|
|
};
|
|
const report = await runConnectorConformance(new JsonlFileConnector(), fixture);
|
|
const failed = report.checks.filter((c) => !c.passed);
|
|
expect(failed.map((c) => `${c.name}: ${c.detail}`)).toEqual([]);
|
|
expect(report.passed).toBe(true);
|
|
});
|
|
|
|
it("the suite actually FAILS a connector that breaks the contract (it is not decoration)", async () => {
|
|
// A connector that accepts any config at all — the classic fail-open bug.
|
|
class FailOpenConnector extends JsonlFileConnector {
|
|
override validate() {
|
|
return { valid: true, errors: [] };
|
|
}
|
|
}
|
|
const report = await runConnectorConformance(new FailOpenConnector(), {
|
|
validConfig: { file_path: jsonlPath, partition_key: "companies", schema: SCHEMA, record_key_field: "org_number" },
|
|
invalidConfig: { file_path: "nope.csv", partition_key: "", record_key_field: "" },
|
|
ctx,
|
|
backfill: { from: "1", to: "3" },
|
|
expectedRecordCount: ROWS.length,
|
|
});
|
|
expect(report.passed).toBe(false);
|
|
expect(report.checks.find((c) => c.name.startsWith("validate: rejects"))?.passed).toBe(false);
|
|
});
|
|
});
|