fix: connect 10 unconnected backend modules to real code paths (context_builder→agent_runner, agent_permissions→agent_runner, agent_tools→agent_runner, data_policy→agent_runner, oversight→agent_runner+migration 0128, transparency→agent_runner, agent_stream→agent_routes SSE endpoint, agent_memory AI-module deleted, decision_guard→engine, require_approval→agent_runner), 11 integration tests passing
2026-08-19 16:25:20 +02:00
|
|
|
"""Create ai_decision_records table for oversight.
|
|
|
|
|
|
|
|
|
|
Revision ID: 0128
|
|
|
|
|
Revises: 0127
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from alembic import op
|
|
|
|
|
import sqlalchemy as sa
|
|
|
|
|
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
|
|
|
|
|
|
|
|
|
revision = "0128"
|
|
|
|
|
down_revision = "0127"
|
|
|
|
|
branch_labels = None
|
|
|
|
|
depends_on = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def upgrade() -> None:
|
2026-08-19 16:30:27 +02:00
|
|
|
# Use IF NOT EXISTS to avoid DuplicateTableError if table was already
|
|
|
|
|
# created by Base.metadata.create_all() in prestart.sh
|
|
|
|
|
op.execute("""
|
|
|
|
|
CREATE TABLE IF NOT EXISTS ai_decision_records (
|
|
|
|
|
id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,
|
|
|
|
|
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
|
|
|
owner_id UUID,
|
|
|
|
|
agent_run_id UUID NOT NULL,
|
|
|
|
|
recommendation TEXT NOT NULL,
|
|
|
|
|
evidence JSONB NOT NULL DEFAULT '{}',
|
|
|
|
|
reviewer_id UUID,
|
|
|
|
|
decision VARCHAR(20),
|
|
|
|
|
decision_timestamp VARCHAR(40),
|
|
|
|
|
deviation_note TEXT,
|
|
|
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
|
|
|
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL,
|
|
|
|
|
deleted_at TIMESTAMP WITH TIME ZONE
|
|
|
|
|
)
|
|
|
|
|
""")
|
|
|
|
|
op.execute("CREATE INDEX IF NOT EXISTS ix_ai_decision_records_tenant_id ON ai_decision_records(tenant_id)")
|
|
|
|
|
op.execute("CREATE INDEX IF NOT EXISTS ix_ai_decision_records_agent_run_id ON ai_decision_records(agent_run_id)")
|
fix: connect 10 unconnected backend modules to real code paths (context_builder→agent_runner, agent_permissions→agent_runner, agent_tools→agent_runner, data_policy→agent_runner, oversight→agent_runner+migration 0128, transparency→agent_runner, agent_stream→agent_routes SSE endpoint, agent_memory AI-module deleted, decision_guard→engine, require_approval→agent_runner), 11 integration tests passing
2026-08-19 16:25:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def downgrade() -> None:
|
|
|
|
|
op.drop_table("ai_decision_records")
|