principal_history_nodes Client SQLite table
One row per hash a scope's graph mentions. Child hashes are set once the node itself is stored: that untrusted proof material is checked against a locally restored private root. A row without them is a liveness placeholder for a referenced hash, such as a leaf or a root not stored yet. The count and managed flag are disposable liveness hints for reclamation.
Declared in packages/client-sdk/src/data/sqlite/schema/principalHistoryEvidenceSchema.ts
Columns
scope_idtext- not null
Evidence scope the node belongs to, as in
principal_history_prefixes.organization_idtext- not null
Organization of the evidence scope. Reference decrements and reclamation change only rows in the scope's organization.
hashtext- not null
Hex SHA-256 hash the row tracks: a stored index node, or a leaf or root referenced before it is stored.
reference_countinteger- not null
Live incoming edges: stored parent nodes, plus prefix and stage rows whose
rootHashnames this hash. Decrements stop at zero.managedinteger- not null
Set when this client stores the node's children. Reclamation deletes only managed rows whose count is zero; placeholders start unmanaged.
left_hashtext- nullable
Left child hash of a stored node; null for a placeholder.
right_hashtext- nullable
Right child hash of a stored node; null for a placeholder.
Keys and constraints
- Primary key
(scope_id, hash)
Indexes
principal_history_nodes_reclaim_idx(scope_id, organization_id, managed, reference_count, hash)principal_history_nodes_organization_idx(organization_id)
DDL
The statements the client runs to create this table and its indexes.
CREATE TABLE IF NOT EXISTS "principal_history_nodes" (
"scope_id" TEXT NOT NULL,
"organization_id" TEXT NOT NULL,
"hash" TEXT NOT NULL,
"reference_count" INTEGER NOT NULL,
"managed" INTEGER NOT NULL,
"left_hash" TEXT,
"right_hash" TEXT,
PRIMARY KEY ("scope_id", "hash")
);
CREATE INDEX IF NOT EXISTS "principal_history_nodes_reclaim_idx" ON "principal_history_nodes" ("scope_id", "organization_id", "managed", "reference_count", "hash");
CREATE INDEX IF NOT EXISTS "principal_history_nodes_organization_idx" ON "principal_history_nodes" ("organization_id");