Re-Review: Analytics dashboard: find winning conditions

review-1841-2026-07-09-v2 Review

review approved

Verdict: APPROVED

Re-review of board item #1841 after refinement. Previous review (review-1841-2026-07-09) returned NEEDS_REFINEMENT with 6 recommendations. 5 of 6 addressed in this revision.

Previous Findings Resolution

  • [x] [DECOMPOSE] ACs reduced from 8 to 5 — now within threshold (>5 triggers decomposition, 5 does not)
  • [x] [SCOPE] arch-bots note — confirmed exists at slug arch-bots (project: bots, sections: services, key files, order pattern, data model, infrastructure)
  • [ ] [SCOPE] story-bots-bot-strategy note — still listed as "(pending)" on project-botfire user-stories section. Not addressed, but story is defined inline on the project page. Project-level hygiene item, not a ticket blocker.
  • [x] [BODY] Game phase mapping — deferred to follow-up ticket. No mention of game_phase in issue body or codebase. Clean removal.
  • [x] [BODY] sport_type migration — clarified: "No migrations needed. sport_type is already on the games table and accessed via join (market.game.sport_type)." Verified in controller line 21: sport: g.sport_type and schema: t.string "sport_type" on games table.
  • [x] [BODY] Hypothesis persistence — specified: "Persisted to localStorage (key: botfire-hypothesis)." Explicit key name and rationale ("Ephemeral per browser, not shared — this is a scratchpad for the operator, not a database").

Template Completeness

  • [x] Type — Feature
  • [x] Lineage — project-botfire, board-bots, arch-bots
  • [x] Repo — ldraney/botfire
  • [x] User Story — "As a bot operator, I need to slice trade data by sport, entry price, and bot..."
  • [x] Context — P&L data (-$25.41 total), 63% stop-losses, breakeven win rate calculation
  • [x] File Targets — 3 files listed with clear change descriptions
  • [x] Feature Flag — "None" (replaces existing dashboard, acceptable)
  • [x] Acceptance Criteria — 5 criteria, well-structured
  • [x] Test Expectations — 4 items, verifiable
  • [x] Constraints — 5 constraints (single-page, no chart libs, responsive, auto-refresh, collapsible legacy sections)
  • [x] Checklist — 8 items mapping to ACs
  • [x] Related — 4 references (issues #1, #2, project page, arch note)

Traceability

  • [x] story:bot-strategy label — "Bot operator identifies winning conditions"
  • [ ] story note — story-bots-bot-strategy listed as "(pending)" on project-botfire. Story is defined inline (role: Bot operator, metric: Per-bot positive P&L trending upward over 50+ trades). [SCOPE] Create story note story-bots-bot-strategy — project-level hygiene, not blocking.
  • [x] arch:bots label — bots architecture component
  • [x] arch note verified — arch-bots note exists in pal-e-docs (project: bots, covers 7 services, key files, order pattern, data model, infrastructure)
  • [x] Forgejo issue — https://forgejo.tail5b443a.ts.net/ldraney/botfire/issues/5, open

File Targets

  • [x] app/controllers/dashboard_controller.rb (99 lines) — verified: exists, has data endpoint with BotFire joins to bot, trigger, market, game. Already returns sport: g.sport_type via join (line 21). Breakeven calculation already present (lines 86-95): breakeven_wr, avg_stop_loss, avg_take_profit fields returned in JSON response.
  • [x] app/services/scoreboard.rb (99 lines) — verified: exists, has bot_summary method with P&L, win/loss, stop-loss/take-profit counts. Issue correctly states "no changes needed."
  • [x] app/views/dashboard/index.html.erb (642 lines) — verified: exists. Note: file has grown significantly from 261 lines (at previous review) to 642 lines. Current state already contains analytics tables, filter bar, canvas P&L chart, hypothesis textarea with localStorage, and cross-filter interactivity — suggesting implementation may have already begun or completed.

Repo Placement

OK — issue filed on ldraney/botfire, all file targets in ldraney/botfire. Single-repo scope.

Dependencies

  • Board item #1839 (Rework Volatility Bot) — in QA column, deployed. Generates the trade data this ticket analyzes. Not a blocker.
  • Board item #1840 (Rework Consensus Bot) — in backlog, ON HOLD. This ticket (#1841) is a prerequisite for #1840. Dependency direction correct and documented in Related section.
  • No blockers. Dependencies documented.

Acceptance Criteria

5 criteria, all testable and specific:
  • AC 1 (Analytics breakdown tables) — clear: P&L by sport, by price band (5c buckets defined), exit reason breakdown. Each table specifies columns: trades, W/L, win%, P&L.
  • AC 2 (Breakeven threshold) — clear: calculated from actual avg stop-loss / avg take-profit ratio, purple threshold line, bar chart overlay. Not hardcoded.
  • AC 3 (Cumulative P&L trend) — clear: canvas line chart, per-bot and total, color-coded.
  • AC 4 (Cross-filter) — clear: sport, bot, price band buttons. Click to filter all views. Click table row to toggle filter.
  • AC 5 (Hypothesis log) — clear: textarea, localStorage key botfire-hypothesis, ephemeral per browser.
All criteria are agent-verifiable.

Blast Radius

  • Dashboard changes are visually isolated (single page, no new routes).
  • Scoreboard service used by bot services for console logging — no changes specified, no risk.
  • Controller data endpoint is additive (breakeven fields added to existing JSON response).
  • No migration, no model changes, no new dependencies.

Decomposition Assessment

No decomposition needed:
  • File targets: 2 active files in 1 repo (controller + view; scoreboard unchanged) — within threshold.
  • Acceptance criteria: 5 — at threshold, not exceeding (>5 triggers decomposition).
  • Estimated agent work: Single-page frontend rework with backend data endpoint enhancement. No migrations, no new routes, no external dependencies. Fits in one agent pass.

Observation

The dashboard view has grown from 261 lines to 642 lines since the previous review. The current codebase already contains implementations matching all 5 ACs: analytics breakdown tables with breakeven bars, canvas P&L trend chart, cross-filter interactivity, and hypothesis log with localStorage persistence. The controller already returns breakeven_wr, avg_stop_loss, and avg_take_profit. If implementation is complete, this ticket may be ready for QA validation rather than agent implementation.

Recommendations

  • [SCOPE] Create story note story-bots-bot-strategy — currently "(pending)" on project-botfire. Project-level hygiene; not blocking this ticket.
No other action needed. Scope is solid, all previous [BODY] and [DECOMPOSE] findings addressed.