CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (pull_request) Successful in 4s
masterplan-lock / check (push) Successful in 4s
CI (SIAX Cloud) / security (pull_request) Successful in 21s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 28s
CI (SIAX Cloud) / integration (pull_request) Successful in 1m0s
CI (SIAX Cloud) / quality (pull_request) Successful in 10m42s
103 lines
2.8 KiB
TypeScript
103 lines
2.8 KiB
TypeScript
/**
|
|
* src/types/canonical-facts.ts — 0pt canonical structured observations.
|
|
*
|
|
* 0pt owns OBSERVED facts (source said X at time T, from artifact A). L0RE
|
|
* owns epistemic propositions/assertions and projections derived from these.
|
|
* This contract is the single write path into the canonical observation store;
|
|
* downstream products consume it through the same API instead of their own DB.
|
|
*/
|
|
|
|
export interface CanonicalEntityInput {
|
|
entity_type: string;
|
|
identity_namespace: string;
|
|
identity_value: string;
|
|
}
|
|
|
|
export interface CanonicalEntity extends CanonicalEntityInput {
|
|
entity_id: string;
|
|
tenant_id: string;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export type FactValueType = "string" | "number" | "boolean" | "date" | "json";
|
|
export type QualityStatus = "passed" | "warned" | "failed" | "unvalidated";
|
|
export type FactStatus = "observed" | "supported" | "disputed" | "retracted";
|
|
|
|
export interface CanonicalFactInput {
|
|
entity: CanonicalEntityInput;
|
|
predicate: string;
|
|
value: unknown;
|
|
value_type?: FactValueType;
|
|
value_unit?: string;
|
|
source_ref: string;
|
|
source_record_id?: string;
|
|
st0re_artifact_id?: string;
|
|
aud0_evidence_ref?: string;
|
|
run_ref?: string;
|
|
extractor_version: string;
|
|
observed_at: string;
|
|
valid_from?: string;
|
|
valid_to?: string;
|
|
confidence?: number;
|
|
quality_status?: QualityStatus;
|
|
status?: FactStatus;
|
|
}
|
|
|
|
export interface CanonicalRelationInput {
|
|
subject: CanonicalEntityInput;
|
|
predicate: string;
|
|
object: CanonicalEntityInput;
|
|
attributes?: Record<string, unknown>;
|
|
source_ref: string;
|
|
st0re_artifact_id?: string;
|
|
aud0_evidence_ref?: string;
|
|
run_ref?: string;
|
|
extractor_version: string;
|
|
observed_at: string;
|
|
valid_from?: string;
|
|
valid_to?: string;
|
|
confidence?: number;
|
|
}
|
|
|
|
export interface CanonicalFact extends CanonicalFactInput {
|
|
fact_id: string;
|
|
tenant_id: string;
|
|
entity_id: string;
|
|
created_at: string;
|
|
}
|
|
|
|
export interface CanonicalRelation extends CanonicalRelationInput {
|
|
relation_id: string;
|
|
tenant_id: string;
|
|
subject_id: string;
|
|
object_id: string;
|
|
created_at: string;
|
|
}
|
|
|
|
export interface CanonicalWriteRequest {
|
|
tenant_id: string;
|
|
project_id?: string;
|
|
entities?: CanonicalEntityInput[];
|
|
facts?: CanonicalFactInput[];
|
|
relations?: CanonicalRelationInput[];
|
|
}
|
|
|
|
export interface CanonicalWriteResult {
|
|
entities: CanonicalEntity[];
|
|
facts: { fact_id: string; entity_id: string; predicate: string }[];
|
|
relations: { relation_id: string; subject_id: string; predicate: string; object_id: string }[];
|
|
/** Identical re-inserts skipped by the unique key (idempotent replay). */
|
|
duplicates: number;
|
|
}
|
|
|
|
export interface CanonicalQuery {
|
|
tenant_id: string;
|
|
entity_id?: string;
|
|
entity_type?: string;
|
|
identity_namespace?: string;
|
|
identity_value?: string;
|
|
predicate?: string;
|
|
limit?: number;
|
|
}
|