Skip to content

WS4: missing-index CREATE statements as copy-paste on Recommendations cards#1084

Merged
erikdarlingdata merged 1 commit into
devfrom
feature/ws4-missing-index-copypaste
Jun 8, 2026
Merged

WS4: missing-index CREATE statements as copy-paste on Recommendations cards#1084
erikdarlingdata merged 1 commit into
devfrom
feature/ws4-missing-index-copypaste

Conversation

@erikdarlingdata

Copy link
Copy Markdown
Owner

What

Surfaces the SQL Server-suggested CREATE INDEX statement(s) on a MISSING_INDEX Recommendations card as "Copy fix". Previously the card showed advice + Ask-AI but no way to copy the suggested index.

Why it needed shared-library work (not just a reader tweak)

The missing_indexes drill-down (where create_statement lives) is ephemeralconfig.analysis_findings has no drill-down column and ReadFinding only rehydrates the built RemediationAction. So the reader never saw the CREATE text. This carries it on the persisted action (FactKey MISSING_INDEX) through the round-trip — exactly the pattern the autogrowth / server-config-memory advisories already use.

Copy-only by design

There is deliberately no handler for MISSING_INDEX — creating an index is a judgement call (over-indexing, write + storage cost), matching the rebuild plan's "advise, over-indexing caveats" stance. So:

  • Copy fix ✅ (the CREATE statement)
  • Apply ❌ (the reader leaves the card's Remediation null → ShowApply stays false)
  • Stays an incident — keeps Open-in-Active-Queries / Ask-AI. A new IsMissingIndexAdvisory flag gates only ShowCopyFix, so the card isn't reclassified.

Changes

Shared (PerformanceMonitor.Analysis / .Notifications)

  • RemediationAction: + MissingIndexTarget record + MissingIndexTargets field
  • FactRemediation: + BuildMissingIndexAction / ExtractMissingIndexTargets (reads missing_indexes: table / impact / create_statement)
  • AlertContext: + MissingIndexTargetDto + ToDto/FromDto round-trip (trailing-optional → backward-compatible)

Dashboard

  • AnalysisService: + BuildMissingIndexAction in the build chain
  • RecommendationsReader: render the CREATEs as CopyPasteSql, leave Remediation null
  • RecommendationItem / RecommendationsViewModel: IsMissingIndexAdvisoryShowCopyFix

Tests

MissingIndexAdvisoryTests (builder, extractor skip/cap, serializer round-trip, reader copy-only mapping, card affordances) + a MISSING_INDEX copy-only case in RemediationGoldenSampleTests (drill-down → builder drift guard: non-null + targets + not registry-dispatchable). Dashboard.Tests 476 / 0, Lite.Tests 406 / 0.

Scope notes

  • Lite + read-only surfaces (email/webhook/MCP) render copy-paste via the shared FactRemediation.GenerateForFinding, which doesn't yet handle MISSING_INDEX — Lite parity is a one-switch-case follow-up, out of scope for this Dashboard-card PR.
  • Live verification: the dev servers are well-indexed (no MISSING_INDEX finding fires), so the card won't appear naturally — covered by the round-trip + golden-sample tests instead. Happy to seed a missing-index scenario to demo it end-to-end.

🤖 Generated with Claude Code

…ndations cards

A MISSING_INDEX finding's drill-down carries the SQL Server-suggested CREATE INDEX
statement(s), but the drill-down is ephemeral (not persisted / not read back), so the
Recommendations reader never saw them -- the card showed advice + Ask-AI but no way to copy
the suggested index. This carries the CREATE statements on the persisted RemediationAction
(FactKey MISSING_INDEX) through the read-back, exactly like the autogrowth / server-config
advisories already do, so the reader can render them.

COPY-ONLY by design: there is deliberately no handler for MISSING_INDEX (creating an index is
a judgement call -- over-indexing, write + storage cost), so the card shows 'Copy fix' but no
Apply button. It stays an incident, keeping Open-in-Active-Queries / Ask-AI; a new
IsMissingIndexAdvisory flag gates only ShowCopyFix.

Shared:
- RemediationAction: + MissingIndexTarget record + MissingIndexTargets field
- FactRemediation: + BuildMissingIndexAction / ExtractMissingIndexTargets (reads the
  missing_indexes drill-down: table / impact / create_statement)
- AlertContext: + MissingIndexTargetDto + ToDto/FromDto round-trip (backward-compatible)
Dashboard:
- AnalysisService: + BuildMissingIndexAction in the build chain
- RecommendationsReader: render the CREATEs as CopyPasteSql, leave Remediation null (no Apply)
- RecommendationItem / RecommendationsViewModel: IsMissingIndexAdvisory -> ShowCopyFix

Tests: + MissingIndexAdvisoryTests (builder / extractor / serializer round-trip / reader
copy-only mapping / card affordances) and a MISSING_INDEX copy-only case in the golden-sample
(drill-down -> builder drift guard: non-null + targets + NOT registry-dispatchable).
Dashboard.Tests 476/0, Lite.Tests 406/0.

Lite + the read-only surfaces (email/webhook/MCP) render copy-paste via the shared
FactRemediation.GenerateForFinding, which does not yet handle MISSING_INDEX -- Lite parity is a
follow-up (one switch case), out of scope for this Dashboard-card PR.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 355d011 into dev Jun 8, 2026
2 checks passed
@erikdarlingdata erikdarlingdata deleted the feature/ws4-missing-index-copypaste branch June 8, 2026 21:23
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.

1 participant