Skip to content

Commit e333d52

Browse files
committed
add tasks
1 parent e449d4a commit e333d52

File tree

1 file changed

+392
-0
lines changed

1 file changed

+392
-0
lines changed
Lines changed: 392 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,392 @@
1+
# Tasks: Grafana PostgreSQL Explain Visualizer Panel Plugin
2+
3+
**Input**: Design documents from `/specs/001-grafana-explain-panel/`
4+
**Prerequisites**: plan.md, spec.md, research.md, data-model.md, contracts/
5+
**Feature Branch**: `001-grafana-explain-panel`
6+
**Generated**: 2025-11-24
7+
8+
**Tests**: Not included - tests are optional and not explicitly requested in the specification.
9+
10+
**Organization**: Tasks are grouped by user story to enable independent implementation and testing of each story.
11+
12+
---
13+
14+
## Phase 1: Setup (Project Initialization)
15+
16+
**Purpose**: Bootstrap Grafana panel plugin with official tooling and configure build system inside Docker
17+
18+
- [ ] T001 Bootstrap plugin using @grafana/create-plugin or verify existing plugin.json and package.json structure
19+
- [ ] T002 Install dependencies: npm install (includes @grafana/data, @grafana/ui, @grafana/runtime, React 18.x, TypeScript 5.x)
20+
- [ ] T003 [P] Install Vue 3 runtime and PEV2 library: npm install vue@^3.4.0 pev2@latest
21+
- [ ] T004 [P] Install development dependencies: npm install --save-dev @types/node vue-loader@^17.4.0 @vue/compiler-sfc@^3.4.0
22+
- [ ] T005 Configure webpack for Vue bundling in .config/webpack/webpack.config.ts (add Vue loader, resolve alias, DefinePlugin for Vue feature flags)
23+
- [ ] T006 Update plugin.json metadata (name: "Postgres Explain Visualizer", id: "cybertec-pev-panel", type: "panel")
24+
- [ ] T007 [P] Create directory structure: src/components/, src/services/, src/types/, src/utils/, src/styles/
25+
- [ ] T008 Verify build process: npm run build produces dist/module.js with bundled Vue and PEV2
26+
27+
**Checkpoint**: Project structure initialized, dependencies installed, webpack configured, build successful
28+
29+
---
30+
31+
## Phase 2: Foundational (Type Definitions & Core Infrastructure)
32+
33+
**Purpose**: Establish type safety and shared utilities that ALL user stories depend on
34+
35+
**⚠️ CRITICAL**: No user story work can begin until this phase is complete
36+
37+
- [ ] T009 [P] Create src/types/plan-types.ts with ExecutionPlan, PlanNode, NodeType, JoinType, ParentRelationship interfaces (copy from contracts/plan-types.ts)
38+
- [ ] T010 [P] Create src/types/panel-options.ts with PanelOptions interface and DEFAULT_PANEL_OPTIONS (copy from contracts/panel-options.ts)
39+
- [ ] T011 [P] Create src/types/error-types.ts with ErrorType enum, ErrorState interface, PlanError class (copy from contracts/error-types.ts)
40+
- [ ] T012 [P] Create src/utils/constants.ts with default field names, font size ranges, performance thresholds
41+
- [ ] T013 [P] Create src/utils/logger.ts with console logging utilities (error, warn, info methods with context)
42+
- [ ] T014 [P] Create src/components/ErrorBoundary.tsx (React Error Boundary component with componentDidCatch)
43+
- [ ] T015 [P] Create src/components/ErrorDisplay.tsx (displays ErrorState using @grafana/ui Alert component)
44+
- [ ] T016 [P] Create src/components/LoadingSpinner.tsx (loading state component using @grafana/ui LoadingPlaceholder)
45+
- [ ] T017 Update src/module.ts to register panel plugin with PanelPlugin constructor
46+
47+
**Checkpoint**: Foundation ready - all types defined, error handling infrastructure in place, user story implementation can now begin in parallel
48+
49+
---
50+
51+
## Phase 3: User Story 1 - Visualize JSON EXPLAIN Output (Priority: P1) 🎯 MVP
52+
53+
**Goal**: Enable users to see PostgreSQL EXPLAIN (FORMAT JSON) output as an interactive tree visualization
54+
55+
**Independent Test**: Configure panel with TestData data source providing JSON EXPLAIN output, verify PEV2 visualization renders with node details, hover tooltips, and expand/collapse functionality
56+
57+
### Implementation for User Story 1
58+
59+
- [ ] T018 [P] [US1] Create src/services/dataExtractor.ts (extract plan string from Grafana DataFrame by field name)
60+
- [ ] T019 [P] [US1] Create src/services/planValidator.ts (validate JSON structure matches ExecutionPlan interface using isValidExecutionPlan)
61+
- [ ] T020 [US1] Create src/services/vueBootstrap.ts (mountVueApp and unmountVueApp functions using Vue createApp)
62+
- [ ] T021 [US1] Create src/components/VueMount.tsx (React component managing Vue app lifecycle with useRef and useEffect)
63+
- [ ] T022 [US1] Integrate PEV2 Plan component in src/components/VueMount.tsx (import pev2 library, create Vue app with Plan component)
64+
- [ ] T023 [US1] Import PEV2 styles in src/components/VueMount.tsx (import 'pev2/dist/style.css')
65+
- [ ] T024 [US1] Create src/components/ExplainPanel.tsx (main panel component receiving PanelProps, managing data extraction and Vue mounting)
66+
- [ ] T025 [US1] Wire dataExtractor in ExplainPanel.tsx (call extractPlanData with data and options.planFieldName)
67+
- [ ] T026 [US1] Wire planValidator in ExplainPanel.tsx (validate extracted JSON before passing to Vue)
68+
- [ ] T027 [US1] Wire VueMount component in ExplainPanel.tsx (render VueMount with plan data when valid)
69+
- [ ] T028 [US1] Add error handling in ExplainPanel.tsx (try-catch blocks, render ErrorDisplay on failures)
70+
- [ ] T029 [US1] Wrap VueMount in ErrorBoundary in ExplainPanel.tsx
71+
- [ ] T030 [US1] Add loading state handling in ExplainPanel.tsx (display LoadingSpinner while processing)
72+
- [ ] T031 [US1] Update src/module.ts to export ExplainPanel as default panel component
73+
74+
**Checkpoint**: User Story 1 complete - JSON EXPLAIN output renders as PEV2 visualization with full interactivity
75+
76+
---
77+
78+
## Phase 4: User Story 4 - Handle Data Source Flexibility (Priority: P1)
79+
80+
**Goal**: Ensure plugin works with any Grafana data source (PostgreSQL, JSON API, TestData, Prometheus) without requiring specific data source types
81+
82+
**Independent Test**: Create panels with multiple data sources (PostgreSQL with "QUERY PLAN" field, JSON API with "execution_plan" field, TestData with "plan" field), verify all render correctly
83+
84+
**Dependencies**: Builds on User Story 1's data extraction and validation
85+
86+
### Implementation for User Story 4
87+
88+
- [ ] T032 [US4] Enhance src/services/dataExtractor.ts to handle empty data (return null if data.series is empty)
89+
- [ ] T033 [US4] Enhance src/services/dataExtractor.ts to handle field not found (throw PlanError with FIELD_NOT_FOUND and available field names)
90+
- [ ] T034 [US4] Enhance src/services/dataExtractor.ts to handle multiple rows (log warning, use first row)
91+
- [ ] T035 [US4] Enhance src/services/dataExtractor.ts to handle both string and object field values (stringify objects, pass strings directly)
92+
- [ ] T036 [US4] Add comprehensive error messages in dataExtractor.ts with available field names for debugging
93+
- [ ] T037 [US4] Update ExplainPanel.tsx to handle NO_DATA error gracefully (display info message, not error)
94+
- [ ] T038 [US4] Update ExplainPanel.tsx to handle FIELD_NOT_FOUND error with resolution hint showing available fields
95+
96+
**Checkpoint**: Plugin works with any data source - field extraction is robust and provides helpful error messages
97+
98+
---
99+
100+
## Phase 5: User Story 2 - Visualize Plain Text EXPLAIN Output (Priority: P2)
101+
102+
**Goal**: Automatically detect plain text EXPLAIN format and convert to JSON for visualization without manual intervention
103+
104+
**Independent Test**: Provide plain text EXPLAIN output to panel, verify automatic format detection and conversion to visualization matching JSON output
105+
106+
**Dependencies**: Builds on User Story 1's validation and visualization
107+
108+
### Implementation for User Story 2
109+
110+
- [ ] T039 [P] [US2] Create src/services/formatDetector.ts (detectFormat function returning 'json' | 'text' | 'unknown')
111+
- [ ] T040 [P] [US2] Implement JSON detection in formatDetector.ts (check for { or [ start, validate with JSON.parse)
112+
- [ ] T041 [P] [US2] Implement text detection in formatDetector.ts (regex patterns for Seq Scan, Index Scan, cost=, etc.)
113+
- [ ] T042 [US2] Create src/services/textParser.ts (convertTextToJson function using PEV2's parsePlan utility)
114+
- [ ] T043 [US2] Add error handling in textParser.ts (wrap parse failures with PlanError PARSE_ERROR)
115+
- [ ] T044 [US2] Add validation after parsing in textParser.ts (ensure parsed result has Plan field)
116+
- [ ] T045 [US2] Integrate formatDetector in ExplainPanel.tsx (detect format after extraction, before validation)
117+
- [ ] T046 [US2] Integrate textParser in ExplainPanel.tsx (convert text to JSON when format is 'text')
118+
- [ ] T047 [US2] Skip format detection when forceJsonMode is true in ExplainPanel.tsx
119+
- [ ] T048 [US2] Handle INVALID_FORMAT error in ExplainPanel.tsx (display when format is 'unknown')
120+
- [ ] T049 [US2] Handle PARSE_ERROR error in ExplainPanel.tsx (display with hint to use FORMAT JSON)
121+
122+
**Checkpoint**: Plain text EXPLAIN automatically converts and visualizes - users can use either format seamlessly
123+
124+
---
125+
126+
## Phase 6: User Story 3 - Configure Panel Display Options (Priority: P3)
127+
128+
**Goal**: Allow users to customize visualization appearance (font size, dark mode, field name) for better readability and theme matching
129+
130+
**Independent Test**: Adjust panel options (fontSize slider, darkMode toggle, planFieldName input), verify changes apply immediately without data re-fetch
131+
132+
**Dependencies**: Builds on User Story 1's panel and visualization
133+
134+
### Implementation for User Story 3
135+
136+
- [ ] T050 [US3] Add panel options builder in src/module.ts using setPanelOptions method
137+
- [ ] T051 [US3] Add planFieldName text input to options builder (name: "Plan Field Name", default: "plan")
138+
- [ ] T052 [US3] Add forceJsonMode boolean switch to options builder (name: "Force JSON Mode", default: false)
139+
- [ ] T053 [US3] Add fontSize slider to options builder (name: "Font Size", range: 10-24, step: 1, default: 14)
140+
- [ ] T054 [US3] Add darkMode boolean switch to options builder (name: "Dark Mode", default: false)
141+
- [ ] T055 [US3] Pass fontSize option to VueMount.tsx component props
142+
- [ ] T056 [US3] Pass darkMode option to VueMount.tsx component props
143+
- [ ] T057 [US3] Apply fontSize to PEV2 component in VueMount.tsx (via Vue props or CSS variable)
144+
- [ ] T058 [US3] Apply darkMode to PEV2 component in VueMount.tsx (via Vue props or CSS class)
145+
- [ ] T059 [US3] Create src/styles/pev2-overrides.css for theme-aware PEV2 styling
146+
- [ ] T060 [US3] Import pev2-overrides.css in VueMount.tsx
147+
- [ ] T061 [US3] Use Grafana theme variables in pev2-overrides.css (--grafana-font-family, --grafana-text-primary)
148+
- [ ] T062 [US3] Verify options persist when dashboard is saved and reloaded
149+
150+
**Checkpoint**: Panel options work - users can customize appearance and changes apply immediately
151+
152+
---
153+
154+
## Phase 7: User Story 5 - Automatic Panel Resizing (Priority: P3)
155+
156+
**Goal**: Gracefully handle browser and panel dimension changes without truncation or scroll issues
157+
158+
**Independent Test**: Resize browser window and panel dimensions, verify visualization scales appropriately with smooth transitions
159+
160+
**Dependencies**: Builds on User Story 1's visualization rendering
161+
162+
### Implementation for User Story 5
163+
164+
- [ ] T063 [US5] Add width and height props tracking in ExplainPanel.tsx
165+
- [ ] T064 [US5] Pass width and height to VueMount.tsx component
166+
- [ ] T065 [US5] Implement resize handler in VueMount.tsx using useEffect with [width, height] dependencies
167+
- [ ] T066 [US5] Update container div dimensions in VueMount.tsx when width/height change
168+
- [ ] T067 [US5] Trigger PEV2 layout recalculation on resize (if PEV2 exposes resize API)
169+
- [ ] T068 [US5] Add CSS overflow: auto to container div in VueMount.tsx for scrolling when needed
170+
- [ ] T069 [US5] Add debouncing to resize handler for performance (optional, if needed)
171+
- [ ] T070 [US5] Verify resize performance meets < 500ms requirement
172+
173+
**Checkpoint**: Panel resizing works smoothly - visualization adapts to container dimensions
174+
175+
---
176+
177+
## Phase 8: Polish & Cross-Cutting Concerns
178+
179+
**Purpose**: Finalize plugin with documentation, testing, and production readiness
180+
181+
- [ ] T071 [P] Update README.md with plugin description, installation, configuration, usage examples
182+
- [ ] T072 [P] Update README.md with sample PostgreSQL queries (JSON and text EXPLAIN formats)
183+
- [ ] T073 [P] Create CHANGELOG.md with initial version entry
184+
- [ ] T074 [P] Add plugin logo to src/img/logo.svg
185+
- [ ] T075 [P] Add plugin screenshots to src/img/ directory
186+
- [ ] T076 [P] Create provisioning/dashboards/explain-example.json with sample dashboard
187+
- [ ] T077 Add example queries to explain-example.json (simple scan, join, aggregation, CTE)
188+
- [ ] T078 Verify bundle size is under 2MB requirement (npm run build, check dist/module.js)
189+
- [ ] T079 Verify no external CDN references in bundle (inspect dist/module.js source)
190+
- [ ] T080 Test plugin in local Grafana instance following quickstart.md
191+
- [ ] T081 Test plugin with PostgreSQL data source and real EXPLAIN queries
192+
- [ ] T082 Test plugin with TestData data source using CSV and JSON scenarios
193+
- [ ] T083 Test error states: NO_DATA, FIELD_NOT_FOUND, INVALID_FORMAT, PARSE_ERROR
194+
- [ ] T084 Verify CSP compliance (test in Grafana Cloud or with strict CSP settings)
195+
- [ ] T085 Run linter: npm run lint and fix any issues
196+
- [ ] T086 Run formatter: npm run format
197+
- [ ] T087 Build production bundle: npm run build
198+
- [ ] T088 Generate plugin signing manifest if needed: npm run sign
199+
- [ ] T089 Create distribution package: zip -r dist.zip dist/ or npm run package
200+
201+
**Checkpoint**: Plugin complete, tested, documented, and ready for distribution
202+
203+
---
204+
205+
## Dependencies & Execution Order
206+
207+
### Phase Dependencies
208+
209+
- **Setup (Phase 1)**: No dependencies - can start immediately
210+
- **Foundational (Phase 2)**: Depends on Setup completion - BLOCKS all user stories
211+
- **User Story 1 (Phase 3)**: Depends on Foundational phase - Core visualization capability
212+
- **User Story 4 (Phase 4)**: Depends on User Story 1 - Enhances data extraction
213+
- **User Story 2 (Phase 5)**: Depends on User Story 1 - Adds format conversion
214+
- **User Story 3 (Phase 6)**: Depends on User Story 1 - Adds customization
215+
- **User Story 5 (Phase 7)**: Depends on User Story 1 - Adds responsive behavior
216+
- **Polish (Phase 8)**: Depends on all user stories being complete
217+
218+
### User Story Dependencies
219+
220+
```
221+
Foundation (Phase 2) ──┬──> User Story 1 (Phase 3) ──┬──> User Story 4 (Phase 4)
222+
│ ├──> User Story 2 (Phase 5)
223+
│ ├──> User Story 3 (Phase 6)
224+
│ └──> User Story 5 (Phase 7)
225+
226+
└──> Polish (Phase 8) [after all stories]
227+
```
228+
229+
### Recommended Implementation Order
230+
231+
**MVP First** (User Story 1 only):
232+
1. Complete Phase 1: Setup (T001-T008)
233+
2. Complete Phase 2: Foundational (T009-T017) ⚠️ CRITICAL BLOCKER
234+
3. Complete Phase 3: User Story 1 (T018-T031)
235+
4. **STOP and VALIDATE**: Test with JSON EXPLAIN output
236+
5. Deploy/demo if ready
237+
238+
**Full Feature Delivery**:
239+
1. Complete Setup + Foundational (T001-T017)
240+
2. Complete User Story 1 (T018-T031) → MVP ready
241+
3. Complete User Story 4 (T032-T038) → Data source flexibility
242+
4. Complete User Story 2 (T039-T049) → Text format support
243+
5. Complete User Story 3 (T050-T062) → Customization options
244+
6. Complete User Story 5 (T063-T070) → Responsive design
245+
7. Complete Polish (T071-T089) → Production ready
246+
247+
### Within Each User Story
248+
249+
- Tasks marked [P] can run in parallel (different files, no dependencies)
250+
- Tasks without [P] must run sequentially (dependencies on previous tasks)
251+
- Always complete foundational tasks before story-specific tasks
252+
- Test story independently before moving to next priority
253+
254+
### Parallel Opportunities
255+
256+
**Phase 1 (Setup)**: T003 + T004 can run parallel to T002 completion
257+
258+
**Phase 2 (Foundational)**: T009, T010, T011, T012, T013, T014, T015, T016 can all run in parallel
259+
260+
**User Story 1**: T018 + T019 can run in parallel
261+
262+
**User Story 2**: T039, T040, T041 can run in parallel, then T042
263+
264+
**Phase 8 (Polish)**: T071, T072, T073, T074, T075, T076 can all run in parallel
265+
266+
---
267+
268+
## Parallel Example: User Story 1
269+
270+
```bash
271+
# Launch all parallel foundation tasks together:
272+
Task T009: "Create src/types/plan-types.ts"
273+
Task T010: "Create src/types/panel-options.ts"
274+
Task T011: "Create src/types/error-types.ts"
275+
Task T012: "Create src/utils/constants.ts"
276+
Task T013: "Create src/utils/logger.ts"
277+
Task T014: "Create src/components/ErrorBoundary.tsx"
278+
Task T015: "Create src/components/ErrorDisplay.tsx"
279+
Task T016: "Create src/components/LoadingSpinner.tsx"
280+
281+
# Then launch User Story 1 parallel tasks:
282+
Task T018: "Create src/services/dataExtractor.ts"
283+
Task T019: "Create src/services/planValidator.ts"
284+
285+
# Then sequential implementation tasks...
286+
```
287+
288+
---
289+
290+
## Implementation Strategy
291+
292+
### MVP First (Recommended for Single Developer)
293+
294+
**Deliverable**: Basic JSON EXPLAIN visualization
295+
296+
1. ✅ Phase 1: Setup (T001-T008) - ~2 hours
297+
2. ✅ Phase 2: Foundational (T009-T017) - ~3 hours ⚠️ BLOCKS ALL STORIES
298+
3. ✅ Phase 3: User Story 1 (T018-T031) - ~6 hours
299+
4. **VALIDATE**: Test with sample JSON EXPLAIN data
300+
5. **DEMO**: Show working visualization to stakeholders
301+
6. Total MVP time: ~11 hours
302+
303+
### Incremental Delivery (Recommended for Team)
304+
305+
**Iteration 1 - MVP** (User Story 1):
306+
- Setup + Foundational + US1
307+
- Deliverable: JSON visualization working
308+
- Demo: Show PEV2 rendering PostgreSQL plans
309+
310+
**Iteration 2** (User Story 4):
311+
- Add data source flexibility
312+
- Deliverable: Works with any Grafana data source
313+
- Demo: PostgreSQL, JSON API, TestData all work
314+
315+
**Iteration 3** (User Story 2):
316+
- Add text format auto-conversion
317+
- Deliverable: No format restrictions
318+
- Demo: Plain EXPLAIN queries work seamlessly
319+
320+
**Iteration 4** (User Story 3):
321+
- Add customization options
322+
- Deliverable: User-configurable appearance
323+
- Demo: Dark mode, font size, field name options
324+
325+
**Iteration 5** (User Story 5):
326+
- Add responsive design
327+
- Deliverable: Professional panel behavior
328+
- Demo: Resize window, panel scales smoothly
329+
330+
**Iteration 6** (Polish):
331+
- Documentation and distribution
332+
- Deliverable: Production-ready plugin
333+
- Demo: Install from zip, works in Grafana Cloud
334+
335+
### Parallel Team Strategy
336+
337+
With 3 developers after Foundational phase:
338+
339+
**Developer A**: User Stories 1 + 4 (core visualization + data sources)
340+
**Developer B**: User Story 2 (text format conversion)
341+
**Developer C**: User Stories 3 + 5 (options + resize)
342+
343+
All stories integrate independently without conflicts.
344+
345+
---
346+
347+
## Task Summary
348+
349+
- **Total Tasks**: 89
350+
- **Phase 1 (Setup)**: 8 tasks
351+
- **Phase 2 (Foundational)**: 9 tasks ⚠️ CRITICAL BLOCKER
352+
- **Phase 3 (User Story 1 - P1)**: 14 tasks
353+
- **Phase 4 (User Story 4 - P1)**: 7 tasks
354+
- **Phase 5 (User Story 2 - P2)**: 11 tasks
355+
- **Phase 6 (User Story 3 - P3)**: 13 tasks
356+
- **Phase 7 (User Story 5 - P3)**: 8 tasks
357+
- **Phase 8 (Polish)**: 19 tasks
358+
359+
**Parallelizable Tasks**: 26 tasks marked [P]
360+
361+
**MVP Scope** (Setup + Foundational + US1): 31 tasks (~11 hours estimated)
362+
363+
**Full Feature** (All phases): 89 tasks (~40 hours estimated)
364+
365+
---
366+
367+
## Format Validation ✅
368+
369+
All tasks follow the required checklist format:
370+
- ✅ Checkbox: `- [ ]` prefix on all tasks
371+
- ✅ Task ID: Sequential T001-T089
372+
-[P] marker: Present on parallelizable tasks only
373+
-[Story] label: Present on user story phase tasks (US1, US2, US3, US4, US5)
374+
- ✅ Description: Clear action with exact file path
375+
- ✅ Organization: Grouped by user story for independent implementation
376+
- ✅ Dependencies: Clearly documented with phase structure
377+
- ✅ MVP defined: User Story 1 (Phase 3) is the minimum viable product
378+
379+
---
380+
381+
## Notes
382+
383+
- All type definition files in contracts/ should be copied to src/types/ in Phase 2
384+
- Vue 3 and PEV2 must be bundled (no CDN usage) per Principle III
385+
- Error handling is comprehensive per Principle IX
386+
- Each user story is independently testable per specification requirements
387+
- Format detection supports both JSON and text EXPLAIN per User Story 2
388+
- Panel options provide customization per User Story 3
389+
- Foundational phase (Phase 2) BLOCKS all user story work - complete it first
390+
- Tests are not included as they were not explicitly requested in specification
391+
- Stop at any checkpoint to validate independently before proceeding
392+
- Commit frequently, test thoroughly, follow constitution principles

0 commit comments

Comments
 (0)