Conversation
Add SVG-ready data layer for the HTML trends report: - TrendChartData frozen dataclass with dot_positions (SVG coords), zone_color (CSS color class), config_break_indices, and delta_badge - build_trends_template_data() converts MetricTrend → TrendChartData - _compute_dot_positions(): maps values to SVG pixel coordinates - _zone_color_for_trend(): CSS color based on current value + thresholds - _detect_config_breaks(): finds runs where config_hash changed - 18 tests covering SVG coords, zone colors, config-break detection, delta badges Ticket-280
New Jinja2 template for the HTML trends report: - Dark-themed, self-contained HTML (no external deps) - SVG dot charts with polyline trend lines per metric - Tier grouping: Operational → Knowledge → Analytical sections - Zone-colour coded dots (green/yellow/red/white) matching run report - Config-break dashed vertical lines at hash-change boundaries - Delta badge (positive/negative/neutral styling) - Direction badge (▲ improving / ▼ declining / = stable / — n/a) - Empty-state handling when no trend data is available - 5 template tests (SVG elements, tiers, zones, names, summary) Ticket-280
Add two new flags to the trends command: - --html FILE: write a self-contained HTML dot-chart trends report - -o / --output FILE: companion to --json, writes JSON to a file instead of stdout Also: - Path traversal guard on --html: rejects paths outside project root - Hint line: 'Tip: use --html FILE…' is printed after the table when --html is not given but trend data exists - 7 new CLI tests covering all flag combinations Ticket-280
Document the new --html and --json -o flags for 'raki trends': - HTML report generation with --html FILE - JSON file output with --json -o FILE - Chart anatomy: dot chart, zone colours, config-break markers, delta badge, direction indicator - Tier grouping table (Operational → Knowledge → Analytical) - Combined usage with --since / --last time filters Ticket-280
This was referenced May 20, 2026
17 tasks
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
Implements an HTML trend report for
raki trendswith interactive SVG dot-chart timelines, tier grouping, zone-colour coding, and config-break markers. Adds--html FILEand-o/--output FILEflags to thetrendssubcommand.What was built
Task 1 — Data layer (
TrendChartData+build_trends_template_data()):TrendChartDatafrozen dataclass withdot_positions,zone_color,config_break_indices,delta_badgebuild_trends_template_data()convertsMetricTrend → TrendChartDatawith SVG coordinates_compute_dot_positions(): maps values to SVG pixel space (y-axis inverted for SVG)_zone_color_for_trend(): reuses existinghtml_color_for_score()thresholds_detect_config_breaks(): compares adjacentconfig_hashvaluesTask 2 — HTML template (
trends.html.j2):Task 3 — HTML renderer (
write_trends_html_report()+build_summary_sentence()):build_summary_sentence()counts improving/declining/stable metricsTask 4 — CLI wiring:
--html FILE: writes HTML trends report, with path traversal guard-o/--output FILE: companion to--jsonfor file output"Tip: use --html FILE…"after the table when--htmlnot givenTask 5 —
changes/280.featuretowncrier fragmentTask 6 — New "Trends report" section in
docs/comparing-runs.mdAcceptance Criteria
TrendChartDatadataclass withdot_positions,zone_color,config_break_indices,delta_badgebuild_trends_template_data()converts MetricTrend to SVG coordinatestrends.html.j2dark-themed template with SVG dot charts and tier groupingwrite_trends_html_report()renderer with auto-directory creation--html FILECLI flag with path traversal guard-o/--output FILEcompanion flag for JSON file output--htmlnot givenchanges/280.feature)docs/comparing-runs.mdReview Results
Finding 1 — IMPORTANT (python-specialist, rag-specialist)
File:
src/raki/cli.py:1390Issue: Missing path traversal guard for
--json -o FILE. The--htmlpath has a traversal check (resolved_html.relative_to(project_root)), but the--json -ocode path at lines 1390–1394 writes to any user-supplied path without validation.raki trends --json -o /etc/cron.d/evilwould write outside the project.Suggestion: Add the same
Path(output_path).resolve().relative_to(Path.cwd().resolve())guard before the JSON file write, raisingclick.UsageErroron failure. Consider extracting a shared_validate_output_path(path: str) -> Pathhelper.Finding 2 — MINOR (python-specialist)
File:
docs/comparing-runs.md:249Issue: Documentation incorrectly claims the y-axis flips for
lower_is_bettermetrics. In reality,_compute_dot_positions()always maps higher values to higher visual positions regardless ofhigher_is_better.Suggestion: Simplify to: "Higher values always map to higher dot positions. Use the zone colour and direction indicator to determine whether a value is good or bad for a given metric."
Finding 3 — MINOR (python-specialist, rag-specialist)
File:
src/raki/cli.py:1324Issue:
-o FILEwithout--jsonsilently produces HTML output because line 1324 aliases-oto--htmlwhenjson_outputis False. A user runningraki trends -o report.txtmay not expect HTML content. Also, when both--html a.htmland-o b.htmlare given,-ois silently ignored.Suggestion: Either (a) require
--htmlor--jsonto be explicit when-ois used, or (b) clarify the help text to read "Alias for --html when --json is not given; companion to --json for file output".Finding 4 — MINOR (rag-specialist)
File:
src/raki/cli.py:1388Issue:
--json --html FILEsilently ignores the--htmlflag due to the earlyreturnon line 1397. The user gets no warning that their HTML report was skipped.Suggestion: Either emit a warning when both
--jsonand--html/effective_html_pathare set, or write both outputs (JSON first, then HTML).Refs #280
Assisted-by: Claude Opus 4.6 (1M context) noreply@anthropic.com
Assigned-by: decko