Developer Reference
Database Models
All Prisma schema models with field descriptions.
The database is PostgreSQL (Neon recommended). All models are defined in prisma/schema.prisma.
Verdict
One record per agent per debate run.
| Field | Type | Description |
|---|---|---|
id | UUID | Primary key |
persona | string | Agent key: bull, bear, quant, macro_regime, narrative, contrarian |
token | string | Token symbol (uppercase) |
timestamp | DateTime | When this verdict was produced |
market_regime_context | string? | Macro regime at analysis time |
stance | string | long, short, or neutral |
conviction | float | 0–100 |
position_direction | string | long, short, or none |
position_size_pct | float | % of portfolio |
entry_ref | float | Reference entry price |
invalidation | float | Invalidation price level |
target | float? | Target price |
reasoning_trail | string | JSON array of reasoning steps |
summary | string | Plain-language summary |
consensusId | string? | FK → Consensus.id |
Consensus
Aggregated council result — one per debate run.
| Field | Type | Description |
|---|---|---|
id | UUID | Primary key |
token | string | Token symbol |
timestamp | DateTime | When the consensus was generated |
conviction_score | float | Weighted average conviction |
agreement | string | unanimous, majority, or split |
majority_stance | string | long, short, or neutral |
outlier_persona | string? | The dissenting agent (if any) |
outlier_reason | string? | Why the outlier dissented |
final_call | string | long, short, or neutral |
Relations: verdicts[] (Verdict), divergenceEvents[] (DivergenceEvent)
DivergenceEvent
Detected shift between two consecutive consensus snapshots.
| Field | Type | Description |
|---|---|---|
id | UUID | Primary key |
token | string | Token symbol |
timestamp | DateTime | When detected |
triggered | boolean | Whether the shift crossed a notification threshold |
shift_type | string | convergence, divergence, flip, or none |
previous_agreement | string | Prior agreement level |
current_agreement | string | New agreement level |
previous_call | string | Prior final call |
current_call | string | New final call |
note | string | Human-readable description |
consensusId | string | FK → Consensus.id |
Reputation
Running accuracy stats per agent per market regime.
| Field | Type | Description |
|---|---|---|
id | UUID | Primary key |
persona | string | Agent key |
regime | string | risk_on, risk_off, neutral, unclassified |
debates_scored | int | Total resolved positions |
correct_calls | int | Correctly resolved positions |
accuracy_pct | float | correct_calls / debates_scored × 100 |
avg_conviction_when_correct | float | Mean conviction on winning calls |
avg_conviction_when_wrong | float | Mean conviction on losing calls |
last_updated | DateTime | Auto-updated |
Unique constraint: (persona, regime) — one record per agent per regime.
AlertTrigger
User-configured alert with schedule and conditions.
| Field | Type | Description |
|---|---|---|
id | UUID | Primary key |
userId | string | Clerk user ID |
token | string | Token to monitor |
gapMinutes | int | Check frequency: 15, 30, 60, 120, 240, 720, or 1440 |
windowStartMin | int? | Daily window start (minutes from UTC midnight) |
windowEndMin | int? | Daily window end (minutes from UTC midnight) |
activeDaysMask | int | Bitmask: bit 0=Mon … bit 6=Sun. 127 = all days |
conditions | string | JSON array of AlertCondition[] |
conditionLogic | string | AND or OR |
notifyInApp | boolean | Record TriggerEvent on fire |
notifyEmail | boolean | Send email on fire |
emailAddress | string? | Resolved from Clerk at save time |
notifyMode | string | immediate or daily_summary |
enabled | boolean | Whether the trigger is active |
scheduleVersion | int | Increments on every schedule change (used to cancel stale Inngest jobs) |
nextRunAt | DateTime | When the next check is scheduled |
lockedUntil | DateTime? | Optimistic lock — set during active job |
lastCheckedAt | DateTime? | When the last check ran |
lastEmailSentAt | DateTime? | For 1-hour email cooldown enforcement |
TriggerCheck
One record per scheduled check run.
| Field | Type | Description |
|---|---|---|
id | UUID | Primary key |
triggerId | string | FK → AlertTrigger.id (cascade delete) |
token | string | Token that was checked |
checkedAt | DateTime | When the check ran |
fired | boolean | true if ≥1 condition was met |
consensusId | string? | The Consensus produced by this check |
TriggerEvent
One record per condition that fired within a check.
| Field | Type | Description |
|---|---|---|
id | UUID | Primary key |
triggerId | string | FK → AlertTrigger.id (cascade delete) |
checkId | string | The TriggerCheck this belongs to |
token | string | Token symbol |
firedAt | DateTime | When the condition fired |
conditionType | string | consensus_change, council_stance, agreement_below, conviction_threshold, agent_stance, divergence, market_regime |
previousState | string | JSON snapshot of prior state |
newState | string | JSON snapshot of new state |
note | string | Human-readable description |
RecheckSchedule
Legacy recurring token recheck schedule (per user/token, independent of AlertTrigger).
| Field | Type | Description |
|---|---|---|
id | UUID | Primary key |
userId | string | Clerk user ID |
token | string | Token to recheck |
gapMinutes | int | Check frequency in minutes |
scheduleVersion | int | Increments on change |
enabled | boolean | Active flag |
nextRunAt | DateTime | Next scheduled run |
lockedUntil | DateTime? | Optimistic lock |
Unique constraint: (userId, token)