feat(runtime): sync experience bus and learner stack into main
This commit is contained in:
38
migrations/054_agent_experience_events.sql
Normal file
38
migrations/054_agent_experience_events.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
-- Phase-1: Router Experience Bus event store (append-only)
|
||||
|
||||
CREATE TABLE IF NOT EXISTS agent_experience_events (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
event_id UUID NOT NULL UNIQUE,
|
||||
ts TIMESTAMPTZ NOT NULL,
|
||||
node_id TEXT NOT NULL,
|
||||
source TEXT NOT NULL,
|
||||
agent_id TEXT NOT NULL,
|
||||
task_type TEXT NOT NULL,
|
||||
request_id TEXT NULL,
|
||||
channel TEXT NOT NULL DEFAULT 'unknown',
|
||||
inputs_hash TEXT NOT NULL,
|
||||
provider TEXT NOT NULL,
|
||||
model TEXT NOT NULL,
|
||||
profile TEXT NULL,
|
||||
latency_ms INT NOT NULL,
|
||||
tokens_in INT NULL,
|
||||
tokens_out INT NULL,
|
||||
ok BOOLEAN NOT NULL,
|
||||
error_class TEXT NULL,
|
||||
error_msg_redacted TEXT NULL,
|
||||
http_status INT NOT NULL,
|
||||
raw JSONB NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_agent_experience_events_agent_ts
|
||||
ON agent_experience_events (agent_id, ts DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_agent_experience_events_task_ts
|
||||
ON agent_experience_events (task_type, ts DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_agent_experience_events_hash_ts
|
||||
ON agent_experience_events (inputs_hash, ts DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_agent_experience_events_ok_ts
|
||||
ON agent_experience_events (ok, ts DESC);
|
||||
27
migrations/055_agent_lessons.sql
Normal file
27
migrations/055_agent_lessons.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
-- Phase-2: Experience Learner lessons store (append-only)
|
||||
|
||||
CREATE TABLE IF NOT EXISTS agent_lessons (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
lesson_id UUID NOT NULL UNIQUE,
|
||||
lesson_key TEXT NOT NULL UNIQUE,
|
||||
ts TIMESTAMPTZ NOT NULL,
|
||||
scope TEXT NOT NULL,
|
||||
agent_id TEXT NULL,
|
||||
task_type TEXT NOT NULL,
|
||||
trigger TEXT NOT NULL,
|
||||
action TEXT NOT NULL,
|
||||
avoid TEXT NOT NULL,
|
||||
signals JSONB NOT NULL,
|
||||
evidence JSONB NOT NULL,
|
||||
raw JSONB NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_agent_lessons_scope_ts
|
||||
ON agent_lessons (scope, ts DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_agent_lessons_agent_ts
|
||||
ON agent_lessons (agent_id, ts DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_agent_lessons_task_ts
|
||||
ON agent_lessons (task_type, ts DESC);
|
||||
Reference in New Issue
Block a user