Skip to content

feat(daily-spending-forecast): replace ASCII charts with matplotlib and clarify P10/P50/P90 terminology - #49978

Merged
pelikhan merged 2 commits into
mainfrom
copilot/improve-daily-spending-forecast
Aug 3, 2026
Merged

pelikhan merged 2 commits into
mainfrom
copilot/improve-daily-spending-forecast

Conversation

Copilot AI commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Daily spending forecast reports used ASCII art charts and bare P10/P50/P90 labels with no explanation, making them hard to read and the percentile semantics opaque.

Changes

Python charting via shared/trending-charts-simple.md import

  • Adds NumPy/Pandas/Matplotlib/Seaborn/SciPy environment with cache-memory and upload-asset safe-output
  • Agent now generates two PNG charts embedded inline in every report:
    • Spending Trend — per-workflow line chart over 30 days with 7-day rolling-average overlay
    • Forecast Distribution — horizontal bar chart showing P10/P50/P90 weekly projections per workflow (green/blue/red)
  • Falls back to ASCII charts if chart generation fails

Self-explanatory percentile terminology

  • New ## Terminology section defines each term once with a plain-English label the agent must echo at first use per section:
    • P10 → 10th percentile — optimistic (9/10 months cost at least this much)
    • P50 → 50th percentile — median/expected
    • P90 → 90th percentile — conservative (only 1/10 months exceeds this)

Report structure update

  • Section order: overview → charts → metrics → collapsible detail → next actions
  • Chart images embedded via returned upload_asset URLs; workflow table retains P50/P90 per-run AIC columns

…P90 terminology

- Import shared/trending-charts-simple.md to provide Python environment
  (NumPy, Pandas, Matplotlib, Seaborn, SciPy) with cache-memory support
  and upload-asset safe-output capability
- Replace ASCII chart requirement with two matplotlib PNG charts:
  1. Spending Trend (line chart, last 30 days, per-workflow series + rolling avg)
  2. Forecast Distribution (horizontal bar, P10/P50/P90 per workflow)
- Add Terminology section defining P10/P50/P90 with plain-English explanations
  (optimistic/median/conservative) to appear in every report section
- Update Report section to embed charts inline and use self-explanatory
  percentile labels throughout
- Recompile: daily-spending-forecast.lock.yml updated

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update daily spending forecast with improved charts and terminology feat(daily-spending-forecast): replace ASCII charts with matplotlib and clarify P10/P50/P90 terminology Aug 3, 2026
Copilot AI requested a review from pelikhan August 3, 2026 12:46
@pelikhan
pelikhan marked this pull request as ready for review August 3, 2026 12:46
Copilot AI review requested due to automatic review settings August 3, 2026 12:46
@pelikhan
pelikhan merged commit 9daa89b into main Aug 3, 2026
1 check passed
@pelikhan
pelikhan deleted the copilot/improve-daily-spending-forecast branch August 3, 2026 12:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds rendered forecast charts and clearer percentile terminology to daily spending reports.

Changes:

  • Adds Python chart generation and asset uploads.
  • Defines P10/P50/P90 terminology and restructures reports.
  • Regenerates the compiled workflow.
Show a summary per file
File Description
.github/workflows/daily-spending-forecast.md Adds charting and reporting instructions.
.github/workflows/daily-spending-forecast.lock.yml Compiles the imported Python and asset-upload infrastructure.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Suppressed comments (1)

.github/workflows/daily-spending-forecast.md:239

  • The forecast JSON has no projection.weekly_aic_p* fields. Weekly percentiles are in weekly_monte_carlo.p10_projected_aic, p50_projected_aic, and p90_projected_aic (pkg/cli/forecast_types.go:60-64 and forecast_montecarlo.go:69-76). The current code therefore renders every bar as zero even when valid forecast data exists.
for wf in forecast.get("workflows", []):
    proj = wf.get("projection", {})
    rows.append({
        "workflow": wf.get("workflow_id", "unknown")[-30:],
        "p10": proj.get("weekly_aic_p10", 0),
  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment on lines +178 to +189
data_file = "/tmp/gh-aw/python/data/run_samples.json"
chart_file = "/tmp/gh-aw/python/charts/spending_trend.png"

# Load data written from forecast.json (run_samples list)
with open(data_file) as f:
samples = json.load(f)

df = pd.DataFrame(samples)
df["run_started_at"] = pd.to_datetime(df["run_started_at"])
df["date"] = df["run_started_at"].dt.date

top5 = df.groupby("workflow_id")["aic"].sum().nlargest(5).index
daily = grp.groupby("date")["aic"].mean()
ax.plot(daily.index, daily.values, marker="o", linewidth=1.5,
label=name, color=palette[idx], alpha=0.8)
rolling = daily.rolling(7, min_periods=1).mean()
P90 (90th percentile — conservative) forecast totals;
- the two rendered chart images embedded inline using the asset URLs from the
`upload_asset` calls above — include a descriptive alt-text for each;
- a workflow table showing sample count, observed AIC, P50/P90 per-run AIC, projected
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.84.4

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.

[q] Improve daily-spending-forecast: charts + clearer P10/P90 terminology

3 participants