Skip to content

refactor(ingestion): remove the superseded gold metric views - #2332

Merged
aleksdotbar merged 3 commits into
mainfrom
claude/legacy-metric-views-cleanup-c79bf5
Aug 7, 2026
Merged

refactor(ingestion): remove the superseded gold metric views#2332
aleksdotbar merged 3 commits into
mainfrom
claude/legacy-metric-views-cleanup-c79bf5

Conversation

@aleksdotbar

@aleksdotbar aleksdotbar commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

51 insight.* gold views left over from the pre-unified metric path. Nothing reads them.

Dead how

  • Query catalog that named 25 of them is write-only — runtime reader deleted in 523898d4; execute_metric_query gone.
  • No gold model selects from one. Runtime only accepts *_metric_observations / *_metric_evidence.
  • Frontend, charts, k8s, CI: zero refs.

Change

  • Delete 29 migrations that create them. Runner keeps no ledger and replays every file, so deleting is the removal — a drop migration would just add another permanent replay. 6 migrations remain: identity DDL, class heals, contract stamp.
  • Drop 3 data-quality tests + their gold source. Superseded by the observation-table checks, which cover the same measures at error severity instead of warn. focus_time_pct bound is structural (dev_time_h = GREATEST(0, working_hours - meetings)).
  • Remove the seed SYSTEM REFRESH (fed views nothing reads; task_issue_state / task_status_spans are rebuilt by the gold run), refresh-task-views.sh (no automated caller), fix-seed-aggregation.sql (targets a renamed table).
  • Regenerate the DDL snapshot. It applies before migrations with CREATE OR REPLACE VIEW, so without this every deploy recreates them.

Verified

dbt parse clean · ruff check/format clean · bootstrap 231 models PASS 0 ERROR · field parity 0 failures · snapshot diff pure deletion, 2 files, 0 additions · 16 gold tables intact.

Not run: e2e metrics suite and dbt build --selector data_quality (need a live stand).

Follow-ups

  • Presentation-layer specs contradict this: PRD.md:182 MUST keeps legacy gold in insight, §4.5 sequences relocation-then-drop. Needs amending + contract version bump.
  • Existing clusters keep the relations; applier never drops. Out-of-band sweep needed.
  • Write-only metrics / metric_catalog tables and their seed migrations still there.
  • AI observations lost their only non-negative check; that family has 1 of 5 sibling tests.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Changes
    • Retired the legacy analytics reporting layer and related data views across collaboration, AI, CRM, Git, task delivery, support, wiki, and individual-contributor metrics.
    • Removed associated task-view refresh automation and legacy data-quality checks.
    • Updated internal guidance to reflect the current data sources and reporting flow.
    • Existing reports or integrations that rely on retired analytics datasets may require migration to supported reporting sources.

The three data-quality tests are superseded by the observation-table
checks, which cover the same measures at error severity instead of warn:
git/collab/task nonnegative, plus the structural focus-hours bound in
class_focus_metrics. Their gold source declared only those three views,
so it goes with them.

The seed's SYSTEM REFRESH existed to surface seeded rows in views that
the unified path no longer reads; task_issue_state and task_status_spans
are rebuilt by the gold run. refresh-task-views.sh had no automated
caller, and fix-seed-aggregation.sql targeted a table since renamed.

Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
Metrics are served from the unified observation and evidence tables, so
none of these 51 views has a reader: no gold model selects from one, the
runtime only accepts relations ending in _metric_observations or
_metric_evidence, and the query catalog that named them is write-only.

The migration runner keeps no ledger and replays every file on each
invocation, so deleting the files that create the views is the removal
itself — a drop migration would only add another permanent replay.
Remaining migrations cover identity DDL, class contract heals and the
contract-version stamp; none references the insight database.

Existing clusters keep the relations until dropped out of band; the
applier never drops.

Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
The snapshot is applied before migrations with CREATE OR REPLACE VIEW,
so it would recreate every dropped view on each deploy until refreshed.
staging.sql collapses to its CREATE DATABASE because dump-ddl derives it
from the staging references in insight.sql, and the only one came from
email_daily.

Signed-off-by: Aleksandr Barkhatov <pm@aleks.bar>
@aleksdotbar
aleksdotbar requested a review from a team as a code owner August 7, 2026 10:05
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change removes legacy insight Gold views, migrations, source definitions, data-quality tests, and task refresh orchestration. Seed documentation now references current silver and Gold models.

Changes

Legacy Gold analytics removal

Layer / File(s) Summary
Insight schema and migration removal
src/ingestion/scripts/connectors-ddl/insight.sql, src/ingestion/scripts/migrations/*
Removes legacy analytical views, materialized views, tables, and their migration definitions across AI, collaboration, CRM, Git, Jira, support, wiki, people, and executive metrics.
Source and data-quality cleanup
src/ingestion/scripts/connectors-ddl/staging.sql, src/ingestion/silver/_shared/gold_sources.yml, src/ingestion/dbt/tests/gold/*
Removes the staging table, Gold source registrations, and three Gold-layer data-quality tests.
Seed flow cleanup
src/ingestion/tools/seed/insight_seed/generators/*.py, src/ingestion/tools/seed/insight_seed/silver.py, src/ingestion/scripts/post-deploy/refresh-task-views.sh
Removes task materialized-view refresh orchestration and updates seed documentation for the current model flow.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: mitasovr, cyberantonz, ktursunov

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: removing superseded legacy gold metric views and related definitions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/legacy-metric-views-cleanup-c79bf5

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@aleksdotbar
aleksdotbar enabled auto-merge August 7, 2026 10:07

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/ingestion/tools/seed/insight_seed/silver.py`:
- Around line 18-22: Remove the numbered apply-ch-migrations.sh workflow step
and its phase-ordering note from the module docstring in insight_seed; keep the
module header focused on the module’s purpose. Preserve the execution and
ordering contract in apply_ch_migrations()’s function docstring or a dedicated
runbook.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4714ce25-a8b8-42d8-828b-8daf600c6532

📥 Commits

Reviewing files that changed from the base of the PR and between f6a7e0b and ce97847.

📒 Files selected for processing (41)
  • src/backend/services/analytics/fix-seed-aggregation.sql
  • src/ingestion/dbt/tests/gold/assert_collab_messaging_bounds.sql
  • src/ingestion/dbt/tests/gold/assert_ic_chart_loc_nonneg.sql
  • src/ingestion/dbt/tests/gold/assert_ic_kpis_bounds.sql
  • src/ingestion/scripts/connectors-ddl/insight.sql
  • src/ingestion/scripts/connectors-ddl/staging.sql
  • src/ingestion/scripts/migrations/20260422000000_gold-views.sql
  • src/ingestion/scripts/migrations/20260422100000_ic-kpis-honest-nulls.sql
  • src/ingestion/scripts/migrations/20260422150000_team-member-honest-nulls.sql
  • src/ingestion/scripts/migrations/20260423120000_bullet-views-honest-nulls.sql
  • src/ingestion/scripts/migrations/20260427120000_views-from-silver.sql
  • src/ingestion/scripts/migrations/20260427180000_ai-bullet-rows-tool-filter.sql
  • src/ingestion/scripts/migrations/20260428000000_collab-metrics-update.sql
  • src/ingestion/scripts/migrations/20260429000000_task-delivery-silver-rewrite.sql
  • src/ingestion/scripts/migrations/20260430000000_git-bullet-expand.sql
  • src/ingestion/scripts/migrations/20260512000000_crm-gold-views.sql
  • src/ingestion/scripts/migrations/20260515000000_task-delivery-bullet-rewrite.sql
  • src/ingestion/scripts/migrations/20260518000000_collab-bullet-rewrite.sql
  • src/ingestion/scripts/migrations/20260519000000_ai-bullet-rewrite.sql
  • src/ingestion/scripts/migrations/20260520000000_code-quality-bullet-rewrite.sql
  • src/ingestion/scripts/migrations/20260521000000_git-bullet-rewrite.sql
  • src/ingestion/scripts/migrations/20260527000000_metrics-gold-views.sql
  • src/ingestion/scripts/migrations/20260601000000_ai-claude-team-metrics.sql
  • src/ingestion/scripts/migrations/20260604000001_drop-peer-cohort-stats.sql
  • src/ingestion/scripts/migrations/20260604000002_drop-ic-kpi-peer-median.sql
  • src/ingestion/scripts/migrations/20260605000001_ic-kpis-git-fanout-fix.sql
  • src/ingestion/scripts/migrations/20260609000000_ai-chatgpt-team-gold.sql
  • src/ingestion/scripts/migrations/20260610000000_ai-person-period-rollup-fix.sql
  • src/ingestion/scripts/migrations/20260611000000_support-bullet-rows.sql
  • src/ingestion/scripts/migrations/20260618000000_ai-claude-team-overage-gold.sql
  • src/ingestion/scripts/migrations/20260620000000_wiki-bullet-rows.sql
  • src/ingestion/scripts/migrations/20260623000000_ai_personal_gold_views.sql
  • src/ingestion/scripts/migrations/20260624000000_ic-chart-loc-git-breakdown.sql
  • src/ingestion/scripts/migrations/20260702000000_collab-person-counter-daily.sql
  • src/ingestion/scripts/migrations/20260708000000_task-delivery-status-category.sql
  • src/ingestion/scripts/post-deploy/refresh-task-views.sh
  • src/ingestion/silver/_shared/gold_sources.yml
  • src/ingestion/tools/seed/insight_seed/generators/hr.py
  • src/ingestion/tools/seed/insight_seed/generators/people.py
  • src/ingestion/tools/seed/insight_seed/generators/task.py
  • src/ingestion/tools/seed/insight_seed/silver.py
💤 Files with no reviewable changes (37)
  • src/ingestion/silver/_shared/gold_sources.yml
  • src/ingestion/scripts/migrations/20260604000001_drop-peer-cohort-stats.sql
  • src/ingestion/dbt/tests/gold/assert_ic_kpis_bounds.sql
  • src/ingestion/dbt/tests/gold/assert_collab_messaging_bounds.sql
  • src/ingestion/scripts/migrations/20260605000001_ic-kpis-git-fanout-fix.sql
  • src/ingestion/scripts/migrations/20260422150000_team-member-honest-nulls.sql
  • src/ingestion/scripts/migrations/20260624000000_ic-chart-loc-git-breakdown.sql
  • src/ingestion/scripts/migrations/20260604000002_drop-ic-kpi-peer-median.sql
  • src/ingestion/dbt/tests/gold/assert_ic_chart_loc_nonneg.sql
  • src/ingestion/scripts/migrations/20260527000000_metrics-gold-views.sql
  • src/ingestion/scripts/migrations/20260610000000_ai-person-period-rollup-fix.sql
  • src/ingestion/scripts/migrations/20260618000000_ai-claude-team-overage-gold.sql
  • src/ingestion/scripts/migrations/20260427120000_views-from-silver.sql
  • src/ingestion/scripts/migrations/20260519000000_ai-bullet-rewrite.sql
  • src/ingestion/scripts/connectors-ddl/staging.sql
  • src/ingestion/scripts/migrations/20260428000000_collab-metrics-update.sql
  • src/ingestion/scripts/migrations/20260620000000_wiki-bullet-rows.sql
  • src/ingestion/scripts/migrations/20260423120000_bullet-views-honest-nulls.sql
  • src/ingestion/scripts/migrations/20260515000000_task-delivery-bullet-rewrite.sql
  • src/ingestion/scripts/migrations/20260609000000_ai-chatgpt-team-gold.sql
  • src/ingestion/scripts/migrations/20260518000000_collab-bullet-rewrite.sql
  • src/ingestion/scripts/migrations/20260623000000_ai_personal_gold_views.sql
  • src/ingestion/scripts/migrations/20260702000000_collab-person-counter-daily.sql
  • src/ingestion/scripts/migrations/20260611000000_support-bullet-rows.sql
  • src/backend/services/analytics/fix-seed-aggregation.sql
  • src/ingestion/scripts/migrations/20260422000000_gold-views.sql
  • src/ingestion/scripts/migrations/20260429000000_task-delivery-silver-rewrite.sql
  • src/ingestion/scripts/migrations/20260422100000_ic-kpis-honest-nulls.sql
  • src/ingestion/scripts/migrations/20260520000000_code-quality-bullet-rewrite.sql
  • src/ingestion/scripts/post-deploy/refresh-task-views.sh
  • src/ingestion/scripts/migrations/20260430000000_git-bullet-expand.sql
  • src/ingestion/scripts/migrations/20260521000000_git-bullet-rewrite.sql
  • src/ingestion/scripts/migrations/20260601000000_ai-claude-team-metrics.sql
  • src/ingestion/scripts/migrations/20260512000000_crm-gold-views.sql
  • src/ingestion/scripts/migrations/20260427180000_ai-bullet-rows-tool-filter.sql
  • src/ingestion/scripts/migrations/20260708000000_task-delivery-status-category.sql
  • src/ingestion/scripts/connectors-ddl/insight.sql

Comment on lines +18 to +22
3. `apply-ch-migrations.sh` — applies migrations/*.sql (identity DDL, class
contract heals, the contract-version stamp), the staging label repair,
and `dbt run --select tag:gold` to build the dbt-owned gold models. Run
AFTER seeding so the materialized gold models are built over real seeded
silver instead of empty placeholders.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Remove the workflow step from the module docstring.

This numbered apply-ch-migrations.sh step repeats the execution documented by apply_ch_migrations() and adds an AFTER seeding phase note to the module header. Keep the module docstring focused on module purpose. Retain the operational contract in the function docstring or a dedicated runbook.

As per coding guidelines, “Do not add module docstring headers that restate code, issue numbers, or phase/scope notes.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/ingestion/tools/seed/insight_seed/silver.py` around lines 18 - 22, Remove
the numbered apply-ch-migrations.sh workflow step and its phase-ordering note
from the module docstring in insight_seed; keep the module header focused on the
module’s purpose. Preserve the execution and ordering contract in
apply_ch_migrations()’s function docstring or a dedicated runbook.

Source: Coding guidelines

@aleksdotbar
aleksdotbar added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit a89a41d Aug 7, 2026
59 checks passed
@aleksdotbar
aleksdotbar deleted the claude/legacy-metric-views-cleanup-c79bf5 branch August 7, 2026 10:55
Gregory91G added a commit that referenced this pull request Aug 12, 2026
Three items in these documents pointed at files that no longer exist, and one
argument rested on a surface that no longer does.

`#2443` took `docs/components/connectors/ai/README.md` with the spec tree, and
the parent metrics design with it, so the two late-phase items naming them are
gone rather than repointed — neither describes work anyone can now do.

`#2332` deleted the migrations that build the 51 legacy gold views, on the
reasoning that none has a reader. One of them served `cc_overage` from
`max(0, used − limit)`, which is the disagreement 18 was about. The section now
says what is true: the surface is no longer created, the catalog entries naming
it are inert, and the disagreement is latent — it returns only if something
starts reading those relations again. The same removal took the migration the
seat-dating convention was inherited from, so the decomposition states the
convention itself instead of citing a deleted file.

Signed-off-by: Gregory Gogin <grigoriy.gogin@constructor.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants