Database Schema
Sentinel uses Cloudflare D1 (SQLite) as its system of record. The schema is defined in src/db/schema.sql.
Tables
Section titled “Tables”incidents
Section titled “incidents”The core table tracking every detected error.
| Column | Type | Description |
|---|---|---|
id | TEXT PK | ULID |
fingerprint | TEXT NOT NULL | SHA-256 error fingerprint |
service_name | TEXT NOT NULL | Worker service name |
trigger_route | TEXT | HTTP route that triggered the error |
error_class | TEXT NOT NULL | client_4xx, server_5xx, or unhandled_exception |
error_message | TEXT | First error message seen |
status | TEXT NOT NULL | Current lifecycle status |
occurrence_count | INTEGER DEFAULT 1 | Total times this fingerprint has been seen |
first_seen | TEXT NOT NULL | ISO 8601 timestamp |
last_seen | TEXT NOT NULL | ISO 8601 timestamp |
repo_url | TEXT | Repository URL for the service |
commit_sha | TEXT | Commit SHA at time of detection |
created_at | TEXT DEFAULT now | Record creation |
updated_at | TEXT DEFAULT now | Last update |
Indexes: fingerprint, status, service_name
agent_runs
Section titled “agent_runs”Audit trail for every agent execution.
| Column | Type | Description |
|---|---|---|
id | TEXT PK | ULID |
incident_id | TEXT FK | References incidents(id) |
agent_type | TEXT NOT NULL | log_tailer, test_gen, triage, fix, tracing |
workflow_id | TEXT | Associated workflow instance ID |
status | TEXT DEFAULT ‘running’ | running, success, failure, timeout |
started_at | TEXT DEFAULT now | Execution start |
completed_at | TEXT | Execution end |
duration_ms | INTEGER | Computed duration |
error_message | TEXT | Error details on failure |
metadata | TEXT | JSON blob for agent-specific data |
Indexes: incident_id
llm_calls
Section titled “llm_calls”Cost tracking and audit for every LLM invocation.
| Column | Type | Description |
|---|---|---|
id | TEXT PK | ULID |
agent_run_id | TEXT FK | References agent_runs(id) |
model | TEXT NOT NULL | Model identifier |
provider | TEXT NOT NULL | workers_ai, anthropic, openai |
prompt_tokens | INTEGER | Input token count |
completion_tokens | INTEGER | Output token count |
total_tokens | INTEGER | Total token count |
latency_ms | INTEGER | Response latency |
cache_hit | BOOLEAN DEFAULT false | AI Gateway cache hit |
input_hash | TEXT | Hash for cache dedup |
Indexes: agent_run_id
artifacts
Section titled “artifacts”References to R2-stored binary artifacts.
| Column | Type | Description |
|---|---|---|
id | TEXT PK | ULID |
incident_id | TEXT FK | References incidents(id) |
artifact_type | TEXT NOT NULL | test_case, test_result, sample_event, patch, pr_body, etc. |
r2_key | TEXT NOT NULL | Full R2 object key |
content_type | TEXT | MIME type |
size_bytes | INTEGER | Artifact size |
Indexes: incident_id
service_configs
Section titled “service_configs”Hot-reloadable configuration for monitored services.
| Column | Type | Description |
|---|---|---|
service_name | TEXT PK | Worker service name |
repo_url | TEXT NOT NULL | GitHub repository URL |
repo_branch | TEXT DEFAULT ‘main’ | Default branch |
poll_interval_ms | INTEGER DEFAULT 30000 | Polling interval |
enabled | BOOLEAN DEFAULT true | Whether to monitor |
error_class_filter | TEXT DEFAULT ’[“server_5xx”,“unhandled_exception”]‘ | JSON array of error classes |
min_occurrences | INTEGER DEFAULT 1 | Threshold before creating incident |
github_artifacts
Section titled “github_artifacts”References to GitHub issues and PRs created by Sentinel.
| Column | Type | Description |
|---|---|---|
id | TEXT PK | ULID |
incident_id | TEXT FK | References incidents(id) |
artifact_type | TEXT NOT NULL | issue, pr, or branch |
github_repo | TEXT NOT NULL | owner/repo format |
github_number | INTEGER | Issue or PR number |
github_url | TEXT | Full GitHub URL |
Indexes: incident_id
external_services
Section titled “external_services”Phase 2 — configuration for non-Cloudflare origins monitored via Tracing Agent.
| Column | Type | Description |
|---|---|---|
origin_host | TEXT PK | Origin hostname |
repo_url | TEXT | Repository URL |
repo_branch | TEXT DEFAULT ‘main’ | Branch |
source_language | TEXT DEFAULT ‘typescript’ | Language |
route_mapping | TEXT | JSON route mapping |
enabled | BOOLEAN DEFAULT true | Active flag |
github_token_ref | TEXT | Secret reference for this origin’s token |