bitcain docs

Agent System

Agent System

Autonomous agent events, actions, metrics, cost tracking, and infrastructure management.

12 tables in this group.

agent_events

Inter-agent communication bus backed by Supabase Realtime

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
source_agent_idtextNo
source_agent_typetextNo
event_typetextNo
payloadjsonbNo'{}'::jsonb
target_agent_ids_textYes'{}'::text[]
correlation_iduuidYes
created_attimestamptzNonow()

RLS Policies:

  • All authenticated users can read agent events — SELECT for {public}
  • Service role full access to agent events — ALL for {public}

Indexes:

  • agent_events_pkey
  • idx_agent_events_correlation
  • idx_agent_events_created
  • idx_agent_events_created_at
  • idx_agent_events_event_type
  • idx_agent_events_source
  • idx_agent_events_source_agent
  • idx_agent_events_targets
  • idx_agent_events_type

agent_actions

Complete audit trail of all actions taken by agents in the swarm

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
agent_nametextNo
agent_versiontextYes'1.0.0'::text
action_typetextNo
action_categorytextYes
incident_iduuidYes
helpdesk_ticket_iduuidYes
coding_request_iduuidYes
input_contextjsonbNo'{}'::jsonb
output_resultjsonbNo'{}'::jsonb
successboolNo
error_messagetextYes
execution_time_msint4Yes
workflow_run_idtextYes
workflow_job_idtextYes
requires_approvalboolYesfalse
approval_statustextYes
approved_bytextYes
approved_attimestamptzYes
created_attimestamptzNonow()

RLS Policies:

  • Service role full access on agent_actions — ALL for {service_role}

Indexes:

  • agent_actions_agent_idx
  • agent_actions_incident_idx
  • agent_actions_pkey

agent_metrics

Performance metrics aggregated by hour for the swarm

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
bucket_starttimestamptzNo
bucket_endtimestamptzNo
agent_nametextNo
actions_totalint4No0
actions_successfulint4No0
actions_failedint4No0
avg_execution_time_msint4Yes
p50_execution_time_msint4Yes
p95_execution_time_msint4Yes
p99_execution_time_msint4Yes
incidents_detectedint4Yes0
incidents_auto_resolvedint4Yes0
incidents_escalatedint4Yes0
mttr_msint4Yes
created_attimestamptzNonow()

RLS Policies:

  • Service role full access on agent_metrics — ALL for {service_role}

Indexes:

  • agent_metrics_bucket_start_agent_name_key
  • agent_metrics_pkey
  • agent_metrics_time_idx

agent_costs

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
agent_idtextNo
cost_typetextNo
amount_usdnumericNo
descriptiontextYes
metadatajsonbYes'{}'::jsonb
created_attimestamptzYesnow()

RLS Policies:

  • authenticated_read — SELECT for {public}
  • service_role_all — ALL for {public}

Indexes:

  • agent_costs_pkey
  • idx_agent_costs_agent
  • idx_agent_costs_type

agent_swarm_config

Runtime configuration for agent behavior

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
config_keytextNo
config_valuejsonbNo
descriptiontextYes
value_schemajsonbYes
updated_bytextYes
created_attimestamptzNonow()
updated_attimestamptzNonow()

RLS Policies:

  • Service role full access on agent_swarm_config — ALL for {service_role}

Indexes:

  • agent_swarm_config_config_key_key
  • agent_swarm_config_pkey

infrastructure_incidents

Tracks all infrastructure incidents detected and handled by the agent swarm

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
incident_numberint4Nonextval('infrastructure_incidents_incident_number_seq'::r...
severitytextNo
statustextNo'detected'::text
incident_typetextNo
sourcetextNo
source_idtextYes
affected_services_textNo'{}'::text[]
titletextNo
error_messagetextYes
error_detailsjsonbYes'{}'::jsonb
sentry_issue_idtextYes
linear_issue_idtextYes
slack_channel_idtextYes
slack_thread_tstextYes
github_workflow_run_idtextYes
embeddingvectorYes
resolution_stepsjsonbYes'[]'::jsonb
resolution_summarytextYes
resolved_bytextYes
resolved_attimestamptzYes
time_to_detect_msint4Yes
time_to_mitigate_msint4Yes
time_to_resolve_msint4Yes
created_attimestamptzNonow()
updated_attimestamptzNonow()

RLS Policies:

  • Service role full access on infrastructure_incidents — ALL for {service_role}

Indexes:

  • infrastructure_incidents_embedding_idx
  • infrastructure_incidents_incident_number_key
  • infrastructure_incidents_pkey
  • infrastructure_incidents_services_idx
  • infrastructure_incidents_status_idx

runbook_patterns

Learned patterns from resolved incidents for future automation

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
pattern_nametextNo
pattern_typetextNo
trigger_conditionsjsonbNo'{}'::jsonb
automated_stepsjsonbNo'[]'::jsonb
requires_approvalboolNofalse
auto_execute_thresholdint4Yes3
usage_countint4No0
success_countint4No0
failure_countint4No0
avg_resolution_time_msint4Yes
descriptiontextYes
embeddingvectorYes
versionint4No1
previous_version_iduuidYes
created_attimestamptzNonow()
updated_attimestamptzNonow()
last_used_attimestamptzYes

RLS Policies:

  • Service role full access on runbook_patterns — ALL for {service_role}

Indexes:

  • runbook_patterns_embedding_idx
  • runbook_patterns_pattern_name_key
  • runbook_patterns_pkey
  • runbook_patterns_type_idx

sentry_error_mappings

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
sentry_issue_idtextNo
linear_issue_idtextNo
error_typetextNo
team_keytextNo
statustextNo'open'::text
event_countint4No1
first_seen_attimestamptzNonow()
last_seen_attimestamptzNonow()
created_attimestamptzNonow()
updated_attimestamptzNonow()

RLS Policies:

  • authenticated_read_sentry_mappings — SELECT for {authenticated}
  • service_role_full_access_sentry_mappings — ALL for {service_role}

Indexes:

  • idx_sentry_mappings_error_type
  • idx_sentry_mappings_linear_issue
  • idx_sentry_mappings_status
  • idx_sentry_mappings_team
  • sentry_error_mappings_pkey
  • sentry_error_mappings_sentry_issue_id_key

fix_metrics

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
error_typetextNo
linear_issue_idtextYes
sentry_issue_idtextYes
github_pr_urltextYes
sourcetextNo'unknown'::text
team_keytextYes
severitytextYes
detected_attimestamptzNonow()
acknowledged_attimestamptzYes
fix_started_attimestamptzYes
fix_completed_attimestamptzYes
time_to_acknowledgeintervalYes
time_to_fix_startintervalYes
time_to_resolutionintervalYes
fix_successfulboolYes
fix_methodtextYes
regression_occurredboolYesfalse
commit_shatextYes
notestextYes
metadatajsonbYes'{}'::jsonb
created_attimestamptzNonow()
updated_attimestamptzNonow()

RLS Policies:

  • authenticated_read_fix_metrics — SELECT for {authenticated}
  • service_role_full_access_fix_metrics — ALL for {service_role}

Indexes:

  • fix_metrics_pkey
  • idx_fix_metrics_detected
  • idx_fix_metrics_error_type
  • idx_fix_metrics_source
  • idx_fix_metrics_successful
  • idx_fix_metrics_team

automation_analytics

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
period_starttimestamptzNo
period_daysint4No7
prs_totalint4No0
prs_mergedint4No0
claude_reviewsint4No0
claude_issues_foundint4No0
claude_critical_issuesint4No0
ci_runsint4No0
ci_failuresint4No0
linear_issuesint4No0
linear_completedint4No0
linear_ci_failure_issuesint4No0
linear_sentry_issuesint4No0
pr_merge_ratenumericYes
ci_success_ratenumericYes
review_coveragenumericYes
created_attimestamptzNonow()

RLS Policies:

  • authenticated_read_analytics — SELECT for {authenticated}
  • service_role_full_access_analytics — ALL for {service_role}

Indexes:

  • automation_analytics_pkey
  • idx_automation_analytics_period
  • idx_automation_analytics_unique_period

coding_requests

Feature requests and bug fixes from Slack/Linear handled by the coding agent

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
request_numberint4Nonextval('coding_requests_request_number_seq'::regclass)
sourcetextNo
source_idtextNo
source_urltextYes
titletextNo
descriptiontextYes
request_typetextNo'feature'::text
prioritytextNo'medium'::text
estimated_complexitytextYes
statustextNo'pending'::text
implementation_planjsonbYes'{}'::jsonb
files_to_create_textYes'{}'::text[]
files_to_modify_textYes'{}'::text[]
test_files_textYes'{}'::text[]
branch_nametextYes
pr_numberint4Yes
pr_urltextYes
pr_statustextYes
assigned_agenttextYes'coding-agent'::text
requested_by_idtextYes
requested_by_nametextYes
requested_by_emailtextYes
created_attimestamptzNonow()
updated_attimestamptzNonow()
started_attimestamptzYes
completed_attimestamptzYes

RLS Policies:

  • Service role full access on coding_requests — ALL for {service_role}

Indexes:

  • coding_requests_pkey
  • coding_requests_request_number_key
  • coding_requests_source_idx
  • coding_requests_status_idx

approval_requests

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
agent_namevarchar(100)No
action_typevarchar(100)No
action_detailsjsonbNo
risk_levelvarchar(20)No'medium'::character varying
statusvarchar(50)No'pending'::character varying
slack_channel_idvarchar(50)Yes
slack_message_tsvarchar(50)Yes
slack_thread_tsvarchar(50)Yes
resolved_byvarchar(255)Yes
resolved_attimestamptzYes
rejection_reasontextYes
continuation_event_typevarchar(100)Yes
continuation_payloadjsonbYes
expires_attimestamptzNo(now() + '24:00:00'::interval)
created_attimestamptzNonow()
updated_attimestamptzNonow()

RLS Policies:

  • Service role full access on approval_requests — ALL for {public}

Indexes:

  • approval_requests_pkey
  • idx_approval_requests_slack
  • idx_approval_requests_status

On this page