Initialize repository snapshot
This commit is contained in:
50
ledger/schema/0001_init.sql
Normal file
50
ledger/schema/0001_init.sql
Normal file
@@ -0,0 +1,50 @@
|
||||
CREATE TABLE IF NOT EXISTS migrations (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL UNIQUE,
|
||||
applied_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tool_invocations (
|
||||
id TEXT PRIMARY KEY,
|
||||
ts TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
tool_name TEXT NOT NULL,
|
||||
action TEXT,
|
||||
status TEXT NOT NULL,
|
||||
duration_ms INTEGER,
|
||||
input_json TEXT,
|
||||
output_json TEXT,
|
||||
error_text TEXT,
|
||||
trace_id TEXT,
|
||||
actor TEXT,
|
||||
input_meta_json TEXT,
|
||||
output_meta_json TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS mcp_calls (
|
||||
id TEXT PRIMARY KEY,
|
||||
ts TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
server_name TEXT NOT NULL,
|
||||
method TEXT NOT NULL,
|
||||
tool_name TEXT,
|
||||
status TEXT NOT NULL,
|
||||
duration_ms INTEGER,
|
||||
request_json TEXT,
|
||||
response_json TEXT,
|
||||
error_text TEXT,
|
||||
trace_id TEXT,
|
||||
client_id TEXT,
|
||||
request_meta_json TEXT,
|
||||
response_meta_json TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS proof_artifacts (
|
||||
id TEXT PRIMARY KEY,
|
||||
ts TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
kind TEXT NOT NULL,
|
||||
path TEXT,
|
||||
sha256_hex TEXT,
|
||||
blake3_hex TEXT,
|
||||
size_bytes INTEGER,
|
||||
meta_json TEXT,
|
||||
trace_id TEXT
|
||||
);
|
||||
10
ledger/schema/0002_indexes.sql
Normal file
10
ledger/schema/0002_indexes.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_tool_invocations_ts ON tool_invocations(ts);
|
||||
CREATE INDEX IF NOT EXISTS idx_tool_invocations_tool_ts ON tool_invocations(tool_name, ts);
|
||||
CREATE INDEX IF NOT EXISTS idx_tool_invocations_trace_id ON tool_invocations(trace_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_mcp_calls_ts ON mcp_calls(ts);
|
||||
CREATE INDEX IF NOT EXISTS idx_mcp_calls_server_ts ON mcp_calls(server_name, ts);
|
||||
CREATE INDEX IF NOT EXISTS idx_mcp_calls_trace_id ON mcp_calls(trace_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_proof_artifacts_ts ON proof_artifacts(ts);
|
||||
CREATE INDEX IF NOT EXISTS idx_proof_artifacts_trace_id ON proof_artifacts(trace_id);
|
||||
18
ledger/schema/0003_shadow_receipts.sql
Normal file
18
ledger/schema/0003_shadow_receipts.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- 0003_shadow_receipts.sql
|
||||
CREATE TABLE IF NOT EXISTS shadow_receipts (
|
||||
id TEXT PRIMARY KEY, -- uuid
|
||||
ts TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
horizon_id TEXT NOT NULL, -- grouping key for “unrealized futures”
|
||||
counterfactual_hash TEXT NOT NULL, -- hash of normalized counterfactual payload
|
||||
entropy_delta REAL, -- optional numeric signal (can be NULL)
|
||||
reason_unrealized TEXT NOT NULL, -- short enum-like string (e.g. "blocked", "operator_abort")
|
||||
observer_signature TEXT, -- optional (future: Ed25519 signature)
|
||||
trace_id TEXT, -- correlate to invocation chain
|
||||
meta_json TEXT -- redacted metadata
|
||||
);
|
||||
|
||||
-- minimal safety constraints
|
||||
CREATE INDEX IF NOT EXISTS idx_shadow_receipts_ts ON shadow_receipts(ts);
|
||||
CREATE INDEX IF NOT EXISTS idx_shadow_receipts_horizon ON shadow_receipts(horizon_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_shadow_receipts_trace ON shadow_receipts(trace_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_shadow_receipts_reason ON shadow_receipts(reason_unrealized);
|
||||
Reference in New Issue
Block a user