AI & Machine Learning
AI & Machine Learning
AI predictions, model training, reinforcement learning, and RAG knowledge base.
12 tables in this group.
predictions
AI model predictions for validation and live monitoring
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | No | gen_random_uuid() |
user_id | uuid | Yes | |
model_id | uuid | Yes | |
strategy_id | uuid | Yes | |
symbol | text | No | |
timeframe | text | No | |
prediction_type | text | No | |
predicted_value | float8 | Yes | |
predicted_label | text | Yes | |
predicted_probabilities | jsonb | Yes | |
confidence | float8 | Yes | |
input_features | jsonb | Yes | '{}'::jsonb |
market_state | jsonb | Yes | '{}'::jsonb |
current_price | numeric | Yes | |
actual_value | float8 | Yes | |
actual_label | text | Yes | |
is_correct | bool | Yes | |
error_magnitude | float8 | Yes | |
profit_impact | numeric | Yes | |
prediction_horizon_minutes | int4 | Yes | |
prediction_made_at | timestamptz | No | now() |
prediction_expires_at | timestamptz | Yes | |
outcome_recorded_at | timestamptz | Yes | |
embedding | vector | Yes | |
metadata | jsonb | Yes | '{}'::jsonb |
created_at | timestamptz | No | now() |
agent_id | text | Yes | |
prompt_version | text | Yes |
RLS Policies:
Service role full access predictions— ALL for {public}Users can insert own predictions— INSERT for {public}Users can view own predictions— SELECT for {public}
Indexes:
idx_predictions_agent_ididx_predictions_confidenceidx_predictions_createdidx_predictions_modelidx_predictions_outcomeidx_predictions_pending_is_correctidx_predictions_pending_outcomeidx_predictions_symbolidx_predictions_typeidx_predictions_useridx_predictions_user_idpredictions_pkey
model_training_jobs
ML model training runs (LSTM, transformers, RL agents)
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | No | gen_random_uuid() |
user_id | uuid | Yes | |
model_name | text | No | |
model_type | text | No | |
model_version | text | Yes | |
status | text | No | 'queued'::text |
hyperparameters | jsonb | Yes | '{}'::jsonb |
training_data_config | jsonb | Yes | '{}'::jsonb |
symbols | _text | Yes | '{}'::text[] |
timeframes | _text | Yes | '{}'::text[] |
training_data_start | timestamptz | Yes | |
training_data_end | timestamptz | Yes | |
epochs_total | int4 | Yes | |
epochs_completed | int4 | Yes | 0 |
batch_size | int4 | Yes | |
learning_rate | float8 | Yes | |
training_metrics | jsonb | Yes | '{}'::jsonb |
validation_metrics | jsonb | Yes | '{}'::jsonb |
best_metrics | jsonb | Yes | '{}'::jsonb |
loss_history | jsonb | Yes | '[]'::jsonb |
model_artifact_path | text | Yes | |
model_size_bytes | int8 | Yes | |
checkpoint_paths | jsonb | Yes | '[]'::jsonb |
gpu_hours | float8 | Yes | 0 |
estimated_cost_usd | numeric | Yes | |
tokens_used | int4 | Yes | |
created_at | timestamptz | No | now() |
updated_at | timestamptz | No | now() |
started_at | timestamptz | Yes | |
completed_at | timestamptz | Yes | |
error_message | text | Yes | |
error_details | jsonb | Yes | |
retry_count | int4 | Yes | 0 |
max_retries | int4 | Yes | 3 |
RLS Policies:
Service role full access model_training_jobs— ALL for {public}Users can insert own training jobs— INSERT for {public}Users can update own training jobs— UPDATE for {public}Users can view own training jobs— SELECT for {public}
Indexes:
idx_model_training_jobs_createdidx_model_training_jobs_model_nameidx_model_training_jobs_model_typeidx_model_training_jobs_statusidx_model_training_jobs_usermodel_training_jobs_pkey
rl_training_episodes
Reinforcement learning episode data (Q-Learning, DT, PPO)
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | No | gen_random_uuid() |
agent_id | text | No | |
algorithm | text | No | |
episode_number | int4 | No | |
states | jsonb | No | '[]'::jsonb |
actions | jsonb | No | '[]'::jsonb |
rewards | jsonb | No | '[]'::jsonb |
total_reward | float8 | No | 0 |
episode_length | int4 | No | 0 |
cumulative_pnl | numeric | Yes | |
max_drawdown | float8 | Yes | |
sharpe_ratio | float8 | Yes | |
win_rate | float8 | Yes | |
epsilon | float8 | Yes | |
learning_rate | float8 | Yes | |
q_values_summary | jsonb | Yes | |
loss | float8 | Yes | |
symbol | text | No | |
timeframe | text | No | |
market_regime | text | Yes | |
env_config | jsonb | Yes | '{}'::jsonb |
started_at | timestamptz | No | now() |
completed_at | timestamptz | Yes | |
created_at | timestamptz | No | now() |
metadata | jsonb | Yes | '{}'::jsonb |
RLS Policies:
Service role full access rl_training_episodes— ALL for {public}
Indexes:
idx_rl_episodes_agentidx_rl_episodes_algorithmidx_rl_episodes_createdidx_rl_episodes_numberidx_rl_episodes_rewardidx_rl_episodes_symbolidx_rl_training_episodes_agent_idrl_training_episodes_pkey
agent_learning_episodes
Agent self-improvement learning episodes
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | No | gen_random_uuid() |
agent_id | text | No | |
agent_type | text | No | |
episode_type | text | No | |
context | jsonb | No | '{}'::jsonb |
action_taken | text | No | |
outcome | text | No | |
reward | float8 | No | 0 |
lessons_learned | _text | Yes | |
pattern_id | uuid | Yes | |
confidence_before | float8 | Yes | |
confidence_after | float8 | Yes | |
strategy_id | uuid | Yes | |
signal_id | uuid | Yes | |
order_id | uuid | Yes | |
prediction_id | uuid | Yes | |
embedding | vector | Yes | |
episode_start | timestamptz | No | now() |
episode_end | timestamptz | Yes | |
created_at | timestamptz | No | now() |
metadata | jsonb | Yes | '{}'::jsonb |
RLS Policies:
Service role full access agent_learning_episodes— ALL for {public}
Indexes:
agent_learning_episodes_pkeyidx_agent_learning_agentidx_agent_learning_createdidx_agent_learning_episodes_agent_ididx_agent_learning_outcomeidx_agent_learning_rewardidx_agent_learning_type
collective_memory
Universal shared memory for cross-agent knowledge transfer and collective learning
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | No | gen_random_uuid() |
agent_id | text | No | |
agent_type | text | No | |
memory_type | text | No | |
content_json | jsonb | No | |
content_embedding | vector | Yes | |
confidence | numeric | No | 0.5 |
access_count | int4 | No | 0 |
decay_factor | numeric | No | 1.0 |
symbol | varchar(20) | Yes | |
tags | _text | Yes | '{}'::text[] |
expires_at | timestamptz | Yes | |
created_at | timestamptz | No | now() |
updated_at | timestamptz | No | now() |
RLS Policies:
All authenticated users can read collective memory— SELECT for {public}Service role full access to collective memory— ALL for {public}
Indexes:
collective_memory_pkeyidx_collective_memory_agentidx_collective_memory_agent_ididx_collective_memory_agent_symbol_typeidx_collective_memory_confidenceidx_collective_memory_createdidx_collective_memory_embeddingidx_collective_memory_expiresidx_collective_memory_memory_typeidx_collective_memory_symbolidx_collective_memory_tagsidx_collective_memory_type
q_table_snapshots
Persisted Q-value snapshots from RL agents for cross-agent aggregation
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | No | gen_random_uuid() |
agent_id | text | No | |
symbol | varchar(20) | No | |
state_key | text | No | |
action | text | No | |
q_value | numeric | No | |
update_count | int4 | No | 0 |
epsilon | numeric | Yes | |
episode_number | int4 | Yes | |
created_at | timestamptz | No | now() |
RLS Policies:
All authenticated users can read Q-table snapshots— SELECT for {public}Service role full access to Q-table snapshots— ALL for {public}
Indexes:
idx_q_snapshots_agentidx_q_snapshots_createdidx_q_snapshots_stateidx_q_snapshots_symbolidx_q_snapshots_symbol_state_actionidx_q_table_snapshots_upsertq_table_snapshots_pkey
trading_experiences
RL experiences for Decision Transformer and Q-Learning training
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | No | gen_random_uuid() |
agent_id | text | No | |
state | jsonb | No | |
action | text | No | |
reward | float8 | No | |
next_state | jsonb | Yes | |
done | bool | Yes | false |
embedding | vector | Yes | |
confidence | float8 | Yes | 0.5 |
metadata | jsonb | Yes | '{}'::jsonb |
created_at | timestamptz | Yes | now() |
RLS Policies:
Authenticated users can view experience statistics— SELECT for {public}Service role can manage all experiences— ALL for {public}
Indexes:
trading_experiences_action_idxtrading_experiences_agent_id_idxtrading_experiences_agent_reward_idxtrading_experiences_created_at_idxtrading_experiences_embedding_idxtrading_experiences_pkeytrading_experiences_reward_idx
trading_documents
RAG knowledge base for trading content with semantic embeddings for similarity search
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | No | gen_random_uuid() |
content | text | No | |
content_hash | varchar(64) | No | |
doc_type | document_type | No | |
source | content_source | No | |
embedding | vector | No | |
metadata | jsonb | Yes | '{}'::jsonb |
created_at | timestamptz | No | now() |
content_created_at | timestamptz | No | now() |
user_id | uuid | Yes | |
expires_at | timestamptz | Yes |
RLS Policies:
trading_documents_delete_policy— DELETE for {authenticated}trading_documents_insert_policy— INSERT for {authenticated}trading_documents_read_policy— SELECT for {authenticated}trading_documents_service_role_policy— ALL for {service_role}trading_documents_update_policy— UPDATE for {authenticated}
Indexes:
trading_documents_content_created_at_idxtrading_documents_content_hash_keytrading_documents_created_at_idxtrading_documents_doc_type_idxtrading_documents_embedding_hnsw_idxtrading_documents_expires_at_idxtrading_documents_metadata_gin_idxtrading_documents_pkeytrading_documents_source_idxtrading_documents_user_id_idx
rag_settings
Admin-configurable settings for RAG data collection pipeline. Should contain only one row (singleton pattern).
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | No | gen_random_uuid() |
enabled_sources | jsonb | No | jsonb_build_object('x_twitter', true, 'reddit', true, 'co... |
collection_limits | jsonb | No | jsonb_build_object('x_twitter', 100, 'reddit', 50, 'coing... |
collection_interval_minutes | int4 | No | 30 |
auto_expiration_days | int4 | No | 30 |
max_posts_per_run | int4 | No | 1000 |
created_at | timestamptz | No | now() |
updated_at | timestamptz | No | now() |
updated_by | uuid | Yes | |
version | int4 | No | 1 |
RLS Policies:
Admins can create RAG settings— INSERT for {authenticated}Admins can delete RAG settings— DELETE for {authenticated}Admins can update RAG settings— UPDATE for {authenticated}Authenticated users can view RAG settings— SELECT for {authenticated}
Indexes:
rag_settings_pkeyrag_settings_updated_at_idx
ai_batch_jobs
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | No | gen_random_uuid() |
user_id | uuid | Yes | |
job_type | text | No | |
custom_id | text | No | |
payload_json | jsonb | No | |
priority | int4 | Yes | 50 |
run_after | timestamptz | Yes | |
status | text | No | 'pending'::text |
batch_id | text | Yes | |
batch_position | int4 | Yes | |
result_json | jsonb | Yes | |
error_message | text | Yes | |
tokens_used | int4 | Yes | |
created_at | timestamptz | No | now() |
updated_at | timestamptz | No | now() |
batched_at | timestamptz | Yes | |
sent_at | timestamptz | Yes | |
completed_at | timestamptz | Yes | |
idempotency_key | text | Yes | |
expires_at | timestamptz | Yes | (now() + '7 days'::interval) |
RLS Policies:
Service role full access to batch jobs— ALL for {public}Users can cancel own pending batch jobs— UPDATE for {public}Users can insert own batch jobs— INSERT for {public}Users can view own batch jobs— SELECT for {public}
Indexes:
ai_batch_jobs_custom_id_keyai_batch_jobs_idempotency_key_keyai_batch_jobs_pkeyidx_ai_batch_jobs_batch_ididx_ai_batch_jobs_job_typeidx_ai_batch_jobs_pendingidx_ai_batch_jobs_statusidx_ai_batch_jobs_user_id
ai_batch_executions
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | No | gen_random_uuid() |
anthropic_batch_id | text | No | |
jobs_count | int4 | No | |
total_tokens_estimated | int4 | Yes | |
total_tokens_used | int4 | Yes | |
status | text | No | 'created'::text |
succeeded_count | int4 | Yes | 0 |
failed_count | int4 | Yes | 0 |
estimated_cost_usd | numeric | Yes | |
actual_cost_usd | numeric | Yes | |
savings_usd | numeric | Yes | |
created_at | timestamptz | No | now() |
submitted_at | timestamptz | Yes | |
completed_at | timestamptz | Yes | |
error_details | jsonb | Yes |
RLS Policies:
Service role full access to batch executions— ALL for {public}
Indexes:
ai_batch_executions_anthropic_batch_id_keyai_batch_executions_pkeyidx_ai_batch_executions_status
attribution_analyses
| Column | Type | Nullable | Default |
|---|---|---|---|
id | uuid | No | |
portfolio_id | uuid | No | |
benchmark_id | uuid | No | |
start_date | date | No | |
end_date | date | No | |
period | varchar(20) | Yes | |
total_excess_return | numeric | No | |
asset_allocation_effect | numeric | Yes | |
security_selection_effect | numeric | Yes | |
interaction_effect | numeric | Yes | |
currency_effect | numeric | Yes | |
timing_effect | numeric | Yes | |
t_statistic | numeric | Yes | |
p_value | numeric | Yes | |
confidence_level | numeric | Yes | |
created_at | timestamp | No | |
attribution_breakdown | json | Yes |
RLS Policies:
attribution_analyses_service_all— ALL for {public}
Indexes:
attribution_analyses_pkeyidx_attribution_analyses_benchmark_ididx_attribution_analyses_portfolio_id