View of rewrites

This commit is contained in:
2026-04-20 16:16:46 +02:00
parent 8ff73d32ae
commit 2f8880d785
4 changed files with 233 additions and 1 deletions
+30
View File
@@ -81,3 +81,33 @@ CREATE TABLE IF NOT EXISTS resolution_queue (
CREATE INDEX IF NOT EXISTS rq_status_idx ON resolution_queue (status);
CREATE INDEX IF NOT EXISTS rq_concept_idx ON resolution_queue (concept_id);
-- ---------------------------------------------------------------------------
-- kg_write_log — immutable audit log of every knowledge graph write
-- ---------------------------------------------------------------------------
-- op values:
-- 'insert' — new URD edge written for the first time
-- 'rewrite' — existing edge replaced (ispart_ispart update)
-- 'decompose' — isa_isa collision resolved by splitting into two dimensions
-- 'reclassify' — concept re-inserted in the correct dimension
CREATE TABLE IF NOT EXISTS kg_write_log (
id SERIAL PRIMARY KEY,
op VARCHAR(16) NOT NULL,
concept_id INT NOT NULL REFERENCES soas(id),
concept_token TEXT NOT NULL,
parent_id INT NOT NULL REFERENCES soas(id),
parent_token TEXT NOT NULL,
prev_parent_id INT REFERENCES soas(id),
prev_parent_token TEXT,
dim_id INT NOT NULL REFERENCES soas(id),
dim_token TEXT NOT NULL,
is_isa BOOLEAN NOT NULL DEFAULT false,
confidence FLOAT NOT NULL DEFAULT 1.0,
source VARCHAR(32) NOT NULL DEFAULT 'cloud_llm',
resolution_queue_id INT REFERENCES resolution_queue(id),
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS kwl_created_idx ON kg_write_log (created_at DESC);
CREATE INDEX IF NOT EXISTS kwl_concept_idx ON kg_write_log (concept_id);
CREATE INDEX IF NOT EXISTS kwl_op_idx ON kg_write_log (op);