

-- Intelligence adjustments log
CREATE TABLE IF NOT EXISTS intelligence_adjustments (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  adjustment_type VARCHAR(50) NOT NULL, -- 'threshold', 'prompt', 'pattern'
  changes JSONB NOT NULL DEFAULT '[]',
  reason TEXT,
  applied_by VARCHAR(100) DEFAULT 'system',
  created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

-- Index for efficient queries
CREATE INDEX IF NOT EXISTS idx_intelligence_adjustments_type
ON intelligence_adjustments(adjustment_type);

CREATE INDEX IF NOT EXISTS idx_intelligence_adjustments_created
ON intelligence_adjustments(created_at);
COMMENT ON TABLE intelligence_adjustments IS 'Logs automatic threshold adjustments made by the self-improvement system';
