This document details the relational schema, entity validation rules, deduplication strategy, snapshot architecture, and evidence provenance invariants implemented in TraceGraph.
erDiagram
INVESTIGATION {
string id PK
string name
string description
string target_scope
datetime created_at
json config_metadata
}
ENTITY {
string id PK
string entity_type
string raw_value
string canonical_value
datetime created_at
}
OBSERVATION {
string id PK
string entity_id FK
string investigation_id FK
string collector_name
string collector_version
string source_reference
datetime observed_at
datetime ingested_at
json data
string status
json error_details
}
RELATIONSHIP {
string id PK
string source_entity_id FK
string target_entity_id FK
string relationship_type
datetime created_at
}
RELATIONSHIP_EVIDENCE {
string id PK
string relationship_id FK
string observation_id FK
datetime created_at
string notes
}
SNAPSHOT {
string id PK
string investigation_id FK
string label
string schema_version
datetime created_at
string content_digest
integer entity_count
integer relationship_count
integer observation_count
json snapshot_data
}
METADATA {
string key PK
string value
datetime updated_at
}
INVESTIGATION ||--o{ OBSERVATION : "contains"
INVESTIGATION ||--o{ SNAPSHOT : "has snapshots"
ENTITY ||--o{ OBSERVATION : "is observed by"
ENTITY ||--o{ RELATIONSHIP : "is source of"
ENTITY ||--o{ RELATIONSHIP : "is target of"
RELATIONSHIP ||--o{ RELATIONSHIP_EVIDENCE : "is substantiated by"
OBSERVATION ||--o{ RELATIONSHIP_EVIDENCE : "substantiates"
Tracks discrete scoping boundaries and investigation parameters.
| Column | Type | Nullable | Description |
|---|---|---|---|
id |
VARCHAR(36) | NO | Primary Key (UUIDv4). |
name |
VARCHAR(255) | NO | Investigation title or reference code. |
description |
TEXT | YES | Objective, scope notes, or incident ticket. |
target_scope |
TEXT | NO | Declared target scope definition (e.g. example.com, 93.184.215.0/24). Default "" (unrestricted). |
created_at |
DATETIME | NO | UTC creation timestamp. |
config_metadata |
JSON | NO | Parameters, allowed target scopes, and tags. |
Represents infrastructure nodes.
| Column | Type | Nullable | Description |
|---|---|---|---|
id |
VARCHAR(36) | NO | Primary Key (UUIDv4). |
entity_type |
VARCHAR(50) | NO | Classification (DOMAIN, IPV4, IPV6, ASN, CIDR, NAMESERVER, etc.). |
raw_value |
VARCHAR(1024) | NO | Original input as provided by user or collector. |
canonical_value |
VARCHAR(1024) | NO | Canonicalized representation used for deduplication. |
created_at |
DATETIME | NO | UTC registration timestamp. |
Constraints & Indexes:
UNIQUE(entity_type, canonical_value): Prevents duplicate entity insertion across the workspace.INDEX(entity_type, canonical_value): Fast lookup during ingestion.
Discrete evidence collected from an identified source.
| Column | Type | Nullable | Description |
|---|---|---|---|
id |
VARCHAR(36) | NO | Primary Key (UUIDv4). |
entity_id |
VARCHAR(36) | NO | Foreign Key to entities.id (ON DELETE CASCADE). |
investigation_id |
VARCHAR(36) | YES | Foreign Key to investigations.id (ON DELETE CASCADE). Indexed. |
collector_name |
VARCHAR(100) | NO | Collector identity (e.g. live_dns, rdap, mock_dns). |
collector_version |
VARCHAR(50) | NO | Collector semver version. |
source_reference |
VARCHAR(1024) | NO | Provenance URI, resolver, or registry URL. |
observed_at |
DATETIME | NO | UTC timestamp when observed at source. |
ingested_at |
DATETIME | NO | UTC timestamp when stored locally. |
data |
JSON | NO | Raw structured telemetry payload. |
status |
VARCHAR(20) | NO | SUCCESS, EMPTY, FAILED, or TIMEOUT. |
error_details |
JSON | YES | Diagnostic information if status is not SUCCESS. |
Directional link between two infrastructure entities.
| Column | Type | Nullable | Description |
|---|---|---|---|
id |
VARCHAR(36) | NO | Primary Key (UUIDv4). |
source_entity_id |
VARCHAR(36) | NO | Foreign Key to entities.id (ON DELETE CASCADE). |
target_entity_id |
VARCHAR(36) | NO | Foreign Key to entities.id (ON DELETE CASCADE). |
relationship_type |
VARCHAR(50) | NO | Relationship verb (RESOLVES_TO, HOSTED_ON, etc.). |
created_at |
DATETIME | NO | UTC timestamp of relationship registration. |
Constraints & Indexes:
UNIQUE(source_entity_id, target_entity_id, relationship_type): Prevents duplicate edges.
Join table connecting a relationship to its supporting observation records.
| Column | Type | Nullable | Description |
|---|---|---|---|
id |
VARCHAR(36) | NO | Primary Key (UUIDv4). |
relationship_id |
VARCHAR(36) | NO | Foreign Key to relationships.id (ON DELETE CASCADE). |
observation_id |
VARCHAR(36) | NO | Foreign Key to observations.id (ON DELETE CASCADE). |
created_at |
DATETIME | NO | UTC timestamp of evidence association. |
notes |
TEXT | YES | Analyst extraction notes. |
Constraints:
UNIQUE(relationship_id, observation_id): Prevents redundant linking.
Point-in-time immutable capture of an investigation's evidence graph.
| Column | Type | Nullable | Description |
|---|---|---|---|
id |
VARCHAR(36) | NO | Primary Key (UUIDv4). |
investigation_id |
VARCHAR(36) | NO | Foreign Key to investigations.id (ON DELETE CASCADE). Indexed. |
label |
VARCHAR(255) | YES | Optional user label (e.g. Baseline Scan, Pre-cutover). |
schema_version |
VARCHAR(50) | NO | Schema format version (e.g. 3.0.0). |
created_at |
DATETIME | NO | UTC capture timestamp. Indexed. |
content_digest |
VARCHAR(64) | NO | SHA-256 hash of canonicalized JSON content. Indexed. |
entity_count |
INTEGER | NO | Total entities in snapshot graph. |
relationship_count |
INTEGER | NO | Total relationships in snapshot graph. |
observation_count |
INTEGER | NO | Total observations in snapshot graph. |
snapshot_data |
JSON | NO | Canonical snapshot payload including entities, rels, obs, and links. |
Key-value workspace configuration and schema state.
| Column | Type | Nullable | Description |
|---|---|---|---|
key |
VARCHAR(100) | NO | Primary Key (e.g. schema_version). |
value |
TEXT | NO | Associated configuration value. |
updated_at |
DATETIME | NO | UTC update timestamp. |
- Unsupported Edge Invariant: A relationship without at least one linked row in
relationship_evidenceevaluatesis_verified = False. The platform must never label an unlinked relationship as verified. - Snapshot Immutability Invariant: Snapshots store a self-contained, canonical serialization of the investigation's graph at capture time. Subsequent collections, entity mutations, or relationship additions never alter previously taken snapshots.
- Cryptographic Content Digest: Every snapshot computes a deterministic SHA-256 digest of canonicalized content (
entities,relationships,observations, andevidence_linkssorted by canonical domain keys with normalized UTC ISO timestamps). Tampering with any byte insidesnapshot_datainvalidatesverify_snapshot_integrity(). - Cascading Integrity: Deleting an entity cascades and deletes its dependent observations and relationships. Deleting an investigation cascades and removes all associated observations and snapshots.
- Temporal Distinction:
observed_atrepresents real-world timestamp of the artifact.ingested_atrepresents storage time in TraceGraph. This guarantees that historical replays and imported archives maintain truthful telemetry timelines.
| Entity Type | Input Example | Normalized Output | Strategy |
|---|---|---|---|
DOMAIN |
Example.COM. |
example.com |
Strip, lower, rstrip trailing dot, IDNA encoding. |
IPV4 |
093.184.215.014 |
93.184.215.14 |
Canonical dotted-decimal via ipaddress.IPv4Address. |
IPV6 |
2606:2800:0220:0001:0248:1893:25C8:1946 |
2606:2800:220:1:248:1893:25c8:1946 |
Canonical lowercase compressed via ipaddress.IPv6Address. |
ASN |
as15169 |
AS15169 |
Canonical uppercase AS prefix + integer. |
CIDR |
192.168.1.1/24 |
192.168.1.0/24 |
Network representation via ipaddress.ip_network(strict=False). |
NAMESERVER |
NS1.EXAMPLE.COM |
ns1.example.com |
Lowercase FQDN. |
CERTIFICATE |
aa:bb:cc:dd |
AABBCCDD |
Strip colons/spaces, uppercase hex fingerprint. |
TraceGraph uses explicit, versioned relational schema tracking via the metadata table.
- v1.0.0 (v0.1.0-alpha): Initial foundation with unassociated observations and implicit investigation boundaries.
- v2.0.0 (v0.2.0-alpha): Added
target_scopecolumn toinvestigationsandinvestigation_idcolumn toobservations. - v3.0.0 (v0.3.0-alpha): Added
snapshotstable with foreign key cascade toinvestigationsand indexes oninvestigation_id,created_at, andcontent_digest.
- Upgrades are executed sequentially in forward-only transactions:
1.0.0 -> 2.0.0: Addstarget_scopeandinvestigation_id, builds index, and backfills legacy observations tolegacy-v0.1-investigation.2.0.0 -> 3.0.0: Createssnapshotstable with foreign keys, checks, and performance indexes.- Updates
metadatarecordschema_versionto'3.0.0'.
- Migrations are automatically applied whenever
tracegraph initor workspace verification runs on an existing database. Zero data loss is guaranteed.