Add phase 2 of the insight chart color registry (slug threading + resolver) - #773
Open
yellowcap wants to merge 4 commits into
Open
Add phase 2 of the insight chart color registry (slug threading + resolver)#773yellowcap wants to merge 4 commits into
yellowcap wants to merge 4 commits into
Conversation
…olver) Threads dataset_id and a stable category slug column through the analyst code-executor prompt, resolves colors deterministically against the phase 1 registry onto InsightChart (color_map/series_color/divergent_colors), and persists/serves the result end to end so charts stay color-consistent across languages instead of relying on translated-string matches.
2 tasks
Avoids colliding with main's current version so the bump-calver pre-commit hook (and CI lint check) passes.
2 tasks
The merge commit dropped uv.lock entirely, breaking CI (`uv sync --frozen` couldn't find a lockfile). Regenerated to match pyproject.toml 2026.7.24.3.
Collaborator
|
Conceptually this looks good to me @yellowcap - colors are resolved deterministically and persisted with One thing to check: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 2 of the insight chart color plan (see
docs/insight-chart-colors-plan.md, follows phase 1 in #771). Today the code-executor LLM writes already-translated category labels straight intochart_data, with no stable key surviving translation. This threads a stable category slug through the pipeline and resolves colors deterministically (never LLM-generated) against the phase-1 registry, so chart colors stay consistent across languages and match the map legend.Changes
EXECUTOR_WORKFLOW(src/agent/subagents/analyst/prompts.py): instructs the code executor to emit a{column}__slugsibling column next to any categorical color column, using canonical slugs from the dataset's registry when available.Analyst._resolve_charts/build_analysis_prompt(src/agent/subagents/analyst/tool.py): passescategory_slug_hints(fromget_dataset_palette(dataset_id)) into the prompt and threadsdataset_idthrough.resolve_chart_colors()(src/agent/subagents/analyst/charts/color_resolver.py): deterministic, hash-based fallback color for slugs with no registry entry; attachescolor_map/series_color/divergent_colorsontoInsightChart.update_insight_display(src/agent/tools/update_insight_display.py): re-runs the resolver on revision, using thedataset_idpersisted on the original chart (revisions can re-mapcolor_fieldto a different column).insight_chartsvia migrationd4f7b1e9a3c2_add_chart_color_registry_fields:dataset_id,color_map,series_color,divergent_colors.InsightChartmodel/schema/API surface carries the new fields through both acquisition paths (chat stream + analysis LRO).Compatibility
Additive: new nullable/defaulted DB columns, new optional model fields, new prompt section. Existing charts without a
dataset_idresolve to empty/Nonecolors (falls back to current frontend behavior) until the companionproject-zeno-nextPR consumescolorMap/seriesColor/divergentColors.Test plan
uv run pytest tests/agent/test_update_insight_display.py tests/tools/test_generate_insights_tiered.py tests/unit/agent/tools/test_color_resolver.py tests/unit/agent/tools/test_insight_chart_model.py tests/api/test_insights.py