Skip to main content
Version: Next

Data Models Reference

This page documents the core data structures used across DecisionBox.

DiscoveryResult

A complete discovery run output. Stored in the discoveries MongoDB collection.

FieldTypeDescription
idstringMongoDB ObjectID
project_idstringProject that owns this discovery
domainstringDomain (e.g., gaming, social)
categorystringCategory (e.g., match3, idle, casual, content_sharing)
run_typestringfull (all areas), partial (some areas or some failed), failed (all areas failed)
areas_requestedstring[]Area IDs requested (empty for full run)
discovery_datetimestampWhen the discovery ran
total_stepsintNumber of exploration steps executed
durationint64Duration in nanoseconds
insightsInsight[]Discovered patterns
recommendationsRecommendation[]Actionable advice
summarySummaryAggregate stats
created_attimestampWhen result was saved
updated_attimestampLast write timestamp

Discovery logs are stored in split collections rather than embedded on the document: discovery_exploration_steps, discovery_analysis_steps, discovery_validation_results, and discovery_recommendation_log. See Discovery log collections for the rationale and the document shapes.

Insight

A discovered pattern or finding. Generated by the analysis phase.

FieldTypeDescription
idstringDeterministic ID: {area}-{index} (e.g., churn-1, monetization-3). Auto-generated if LLM omits it.
analysis_areastringWhich area found this (e.g., churn, levels)
namestringSpecific descriptive name (e.g., "Day 0-to-Day 1 Drop: 67% Never Return")
descriptionstringDetailed description with exact numbers and percentages
severitystringcritical, high, medium, or low
affected_countintNumber of affected users (COUNT DISTINCT user_id)
risk_scorefloat640.0 to 1.0 risk assessment
confidencefloat640.0 to 1.0 confidence level
metricsmapFlexible key-value metrics (e.g., {"churn_rate": 0.67, "avg_sessions": 3.2})
indicatorsstring[]Specific metric indicators (e.g., "Session drop: 12min → 4min")
target_segmentstringDescription of affected user segment
source_stepsint[]Exploration step numbers that support this insight
validationInsightValidationWarehouse verification result (if validated)
discovered_attimestampWhen this insight was generated

InsightValidation

Attached to an insight after validation by the verifier + refuter pair.

FieldTypeDescription
verifierStructuredVerdictDefender-frame agent verdict with per-claim evidence rows
refuterStructuredVerdictSkeptic-frame agent verdict (omitted when refuter is disabled or the refuter run failed)
combinedstringCombined verdict: confirmed, supported, rejected, partial, unverifiable, validation_disabled, or skipped_budget_cap
refuter_disabledboolTrue when the refuter was intentionally skipped for this document
validated_attimestampWhen validation was performed
input_tokensintLLM input tokens consumed during validation
output_tokensintLLM output tokens produced during validation

Legacy fields (status, original_count, verified_count, query, reasoning) remain populated on documents written before the verifier+refuter pipeline shipped; the dashboard renders the new fields when present and falls back to the legacy fields otherwise.

Recommendation

An actionable suggestion based on discovered insights.

FieldTypeDescription
idstringRecommendation ID
categorystringCategory: churn, engagement, monetization, difficulty
titlestringSpecific action title
descriptionstringDetailed explanation with numbers
priorityint1 (critical) to 5 (optional). P1 = highest priority.
target_segmentstringExact segment criteria
segment_sizeintNumber of users in the segment
expected_impactImpactExpected improvement
actionsstring[]Numbered implementation steps
related_insight_idsstring[]UUIDs of insights this recommendation addresses, verbatim from the same discovery's insights[].id (e.g., ["6e9261f5-c4ec-404b-bdf0-760a4644f384"]). Recommendations whose related_insight_ids cannot be resolved to an eligible insight are dropped server-side before persistence; see the RecommendationStep recommendations_dropped* counters
confidencefloat640.0 to 1.0 confidence

Impact

Expected impact of a recommendation.

FieldTypeDescription
metricstringWhat metric improves (e.g., retention_rate, revenue)
estimated_improvementstringExpected improvement (e.g., "+15-20%", "+$4,975/month")
reasoningstringWhy this improvement is expected

Summary

Aggregate stats for a discovery run.

FieldTypeDescription
total_insightsintNumber of insights generated
total_recommendationsintNumber of recommendations generated
queries_executedintNumber of SQL queries executed
errorsstring[]Error messages from failed analysis areas (if any)

ExplorationStep

One step in the autonomous exploration phase. Drives one user-visible exploration turn — usually one LLM call, but a turn whose response can't be parsed is retried (up to a small retry budget) and every retry's token usage is summed onto the same step.

FieldTypeDescription
stepintStep number (1-based)
timestamptimestampWhen this step ran
actionstringOne of query_data, lookup_schema, search_tables, complete, complete_rejected
thinkingstringAI's reasoning for this query
query_purposestringShort description of query intent
querystringThe SQL query executed
row_countintNumber of rows returned
execution_time_msint64Query execution time in milliseconds
errorstringError message if query failed
fix_attemptsintNumber of applied LLM repairs for this step's query (0 if it ran cleanly on the first try or if every fix call failed). fix_attempts <= len(fix_history).
fixedboolTrue if the query was auto-fixed after a SQL error
fix_historyFixAttempt[]Per-attempt fix log; omitted (or empty) when no fix was needed. Includes failed attempts (LLM error, unparseable response, filter rejection) — those carry fixer_error set. See FixAttempt.
tokens_inintInput tokens consumed (sum across any parse-retry rounds on this step)
tokens_outintOutput tokens generated (sum across any parse-retry rounds on this step)

FixAttempt

One entry per LLM call the self-healing SQL fix loop made for a single exploration step. Stored as elements of ExplorationStep.fix_history in chronological order. Every entry — including failed attempts whose proposed SQL was never applied — is recorded so downstream tooling has visibility into the full repair trajectory, not just the last call.

FieldTypeDescription
stepintThe parent ExplorationStep.step number, duplicated for self-contained export.
attemptintZero-based retry index inside the step. Matches the attempt argument the executor passes to the SQL fixer.
prompt_instringFully rendered prompt the fixer sent to the LLM (system instruction + user message).
response_outstringRaw LLM response text — before SQL extraction. Populated even when extraction failed.
sql_beforestringThe broken SQL handed to the fixer.
sql_afterstringThe SQL the fixer proposed. Empty when the fixer failed to extract any parseable SQL (in that case fixer_error is set).
error_instringThe warehouse error message that triggered this fix call.
fixer_errorstringWhen non-empty, the reason the proposal was NOT applied: LLM transport error, unparseable response, or post-fix security-filter rejection. When empty, the proposal was applied and the warehouse was retried with sql_after.
input_tokensintInput tokens consumed by this fix call.
output_tokensintOutput tokens generated by this fix call.
duration_msint64LLM call duration in milliseconds.
timestamptimestampWhen this fix attempt was recorded.

The parent ExplorationStep.fix_attempts counter is the number of applied repairs (fixer_error empty), so fix_attempts <= len(fix_history) with the gap being failed-fixer rows.

AnalysisStep

Full LLM dialog for one analysis area. Captures the complete prompt and response.

FieldTypeDescription
area_idstringAnalysis area ID (e.g., churn)
area_namestringDisplay name (e.g., Churn Risks)
run_attimestampWhen this analysis ran
relevant_queriesintNumber of exploration queries used as context
tokens_inintInput tokens consumed
tokens_outintOutput tokens generated
duration_msint64LLM call duration in milliseconds
insight_countintNumber of insights extracted
errorstringError message if analysis failed

RecommendationStep

Full LLM dialog for the recommendation-generation phase, stored in the discovery_recommendation_log collection. One row per discovery run.

FieldTypeDescription
run_attimestampWhen the recommendation phase ran
promptstringFully rendered recommendation prompt sent to the LLM
insight_countintNumber of eligible insights handed to the recommender
responsestringRaw LLM response text — before JSON cleanup
tokens_inintInput tokens consumed by the LLM call
tokens_outintOutput tokens generated by the LLM call
duration_msint64LLM call duration in milliseconds
recommendationsRecommendation[]The parsed recommendations actually persisted to the discovery (after the related_insight_ids validity check below has dropped any unresolvable ones)
statusstringOptional observability marker. Empty on the happy path; set to skipped_no_eligible_insights when every upstream insight was rejected by the validator so the recommender was never invoked
recommendations_droppedintNumber of recommendations the LLM emitted but the orchestrator discarded before persistence because their related_insight_ids could not be resolved to an eligible insight (sum of the two reason-specific counters). Omitted on a clean run.
recommendations_dropped_missing_idsintSubset of recommendations_dropped that arrived with an empty or absent related_insight_ids array. Omitted on a clean run.
recommendations_dropped_unknown_idintSubset of recommendations_dropped that cited at least one id not present in the eligible insight set — typically slug-style identifiers (category:severity:theme) hallucinated by the LLM in place of a real UUID. Use this counter to measure regression rates per LLM provider. Omitted on a clean run.
errorstringError message if recommendation generation failed (LLM transport error or unparseable response)

ValidationResult

Warehouse verification of an insight's claims.

FieldTypeDescription
insight_idstringID of the validated insight
analysis_areastringArea this insight belongs to
claimed_countintCount claimed by the AI
verified_countintCount verified from the warehouse
statusstringconfirmed, adjusted, rejected, error
reasoningstringExplanation of the result
querystringThe verification SQL query
validated_attimestampWhen validation was performed
input_tokensintInput tokens summed across every verifier LLM call for this insight (initial verification, lookup-loop rounds, forced final round). Omitted on legacy rows.
output_tokensintOutput tokens summed across the same set. Omitted on legacy rows.

DiscoveryRun

Live status of a running discovery. Stored in discovery_runs collection, updated in real-time.

FieldTypeDescription
idstringRun ID
project_idstringProject being discovered
statusstringpending, running, completed, failed, cancelled
phasestringCurrent phase: init, schema_discovery, exploration, analysis, validation, recommendations, saving, complete
phase_detailstringHuman-readable phase description
progressint0 to 100 percentage
started_attimestampWhen the run started
updated_attimestampLast status update
completed_attimestampWhen the run finished (null if running)
errorstringError message (if failed)
stepsRunStep[]Live step feed
total_queriesintTotal SQL queries executed
successful_queriesintQueries that returned results
failed_queriesintQueries that errored
insights_foundintInsights generated so far

RunStep

One step in the live progress feed.

FieldTypeDescription
phasestringWhich phase this step belongs to
step_numintStep number
timestamptimestampWhen this step occurred
typestringquery, insight, analysis, validation, recommendation, error
messagestringStep description
llm_thinkingstringAI's reasoning text
querystringSQL query (if type=query)
query_resultstringQuery result summary
row_countintRows returned
query_time_msintQuery execution time
query_fixedboolWhether query was auto-fixed
insight_namestringInsight name (if type=insight)
insight_severitystringInsight severity (if type=insight)
errorstringError message (if type=error)

Feedback

User feedback on insights, recommendations, or exploration steps.

FieldTypeDescription
idstringFeedback ID
project_idstringProject ID
discovery_idstringDiscovery run ID
target_typestringinsight, recommendation, exploration_step
target_idstringID of the rated item
ratingstringlike or dislike
commentstringOptional comment (typically with dislikes)
created_attimestampWhen feedback was submitted

Project

Project configuration. Stored in projects collection.

FieldTypeDescription
idstringMongoDB ObjectID
namestringProject name
descriptionstringProject description
domainstringDomain (e.g., gaming, social)
categorystringCategory (e.g., match3, idle, casual, content_sharing)
warehouseWarehouseConfigData warehouse configuration
llmLLMConfigLLM provider configuration
profilemapDomain-specific profile (from JSON Schema form)
promptsProjectPromptsPer-project prompt overrides
statusstringProject status
last_run_attimestampWhen the last discovery ran
last_run_statusstringLast run result
created_attimestampWhen the project was created
updated_attimestampLast update

WarehouseConfig

FieldTypeDescription
providerstringProvider ID: bigquery, redshift
project_idstringGCP project ID (BigQuery)
datasetsstring[]Dataset/schema names
locationstringData location
filter_fieldstringMulti-tenant filter column
filter_valuestringMulti-tenant filter value
configmapProvider-specific key-value config

LLMConfig

FieldTypeDescription
providerstringProvider ID: claude, openai, ollama, vertex-ai, bedrock
modelstringModel identifier (free text)
configmapProvider-specific key-value config (e.g., project_id, location for Vertex AI)

Next Steps