Spaces:
Sleeping
Sleeping
Update SQL
Browse files
SQL
CHANGED
|
@@ -1,463 +1,221 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
4A — Imports (after line 35)
|
| 223 |
-
|
| 224 |
-
from models.opportunity_model import compute_opportunity_adjustment
|
| 225 |
-
from models.arsenal_drift_model import compute_arsenal_drift_adjustment
|
| 226 |
-
|
| 227 |
-
4B — Exact intermediate checkpoints for debug ladder
|
| 228 |
-
|
| 229 |
-
After each adjustment block, snapshot the current probability values. These become the debug ladder. Add after batter_baseline = dict(batter_baseline) at line
|
| 230 |
-
242:
|
| 231 |
-
_snap_baseline_hr = float(batter_baseline.get("hr_prob_base", 0.03) or 0.03)
|
| 232 |
-
_snap_baseline_hit = float(batter_baseline.get("hit_prob_base", 0.15) or 0.15)
|
| 233 |
-
_snap_baseline_tb2p = float(batter_baseline.get("tb2p_prob_base", 0.10) or 0.10)
|
| 234 |
-
|
| 235 |
-
Then add a snapshot immediately after each adjustment block writes back to batter_baseline:
|
| 236 |
-
- After zone block: _snap_after_zone_hr = float(batter_baseline["hr_prob_base"])
|
| 237 |
-
- After family zone: _snap_after_family_zone_hr = ...
|
| 238 |
-
- After arsenal matchup: _snap_after_arsenal_hr = ...
|
| 239 |
-
- After env: _snap_after_env_hr = ...
|
| 240 |
-
- After platoon: _snap_after_platoon_hr = ...
|
| 241 |
-
- After trajectory: _snap_after_traj_hr = ...
|
| 242 |
-
- After rolling: _snap_after_rolling_hr = ...
|
| 243 |
-
- After opportunity: _snap_after_opportunity_hr = ...
|
| 244 |
-
- After drift: _snap_after_drift_hr = ...
|
| 245 |
-
|
| 246 |
-
Same pattern for _hit and _tb2p variants (total ~27 new local variables, surfaced in output dict).
|
| 247 |
-
|
| 248 |
-
These are exact values — no reconstruction required. The debug ladder reads directly from these fields.
|
| 249 |
-
|
| 250 |
-
4C — Opportunity multiplier (AFTER rolling block, BEFORE simulate call ~line 538)
|
| 251 |
-
|
| 252 |
-
# Batch 13: Opportunity adjustment (multiplicative, upcoming-only)
|
| 253 |
-
try:
|
| 254 |
-
opp_adj = compute_opportunity_adjustment(
|
| 255 |
-
lineup_slot=None, # batting order not available in game_row currently
|
| 256 |
-
team_total=game_row.get("team_total"),
|
| 257 |
-
pitcher_row=pitcher_row,
|
| 258 |
-
)
|
| 259 |
-
except Exception:
|
| 260 |
-
opp_adj = {"expected_pa": 4.3, "pa_multiplier": 1.0,
|
| 261 |
-
"pitcher_quality_score": 0.0, "opportunity_reason": "error"}
|
| 262 |
-
|
| 263 |
-
pa_mult = float(opp_adj.get("pa_multiplier", 1.0) or 1.0)
|
| 264 |
-
batter_baseline["hit_prob_base"] = min(0.55, max(0.05,
|
| 265 |
-
float(batter_baseline.get("hit_prob_base", 0.15) or 0.15) * pa_mult))
|
| 266 |
-
batter_baseline["hr_prob_base"] = min(0.30, max(0.005,
|
| 267 |
-
float(batter_baseline.get("hr_prob_base", 0.03) or 0.03) * pa_mult))
|
| 268 |
-
batter_baseline["tb2p_prob_base"] = min(0.45, max(0.03,
|
| 269 |
-
float(batter_baseline.get("tb2p_prob_base", 0.10) or 0.10) * pa_mult))
|
| 270 |
-
|
| 271 |
-
4D — Arsenal drift (AFTER opportunity, BEFORE simulate)
|
| 272 |
-
|
| 273 |
-
# Batch 13: Arsenal drift adjustment (additive, upcoming-only)
|
| 274 |
-
try:
|
| 275 |
-
drift_adj = compute_arsenal_drift_adjustment(
|
| 276 |
-
pitcher_roll=pitcher_rolling_row,
|
| 277 |
-
pitcher_row=pitcher_row,
|
| 278 |
-
rolling_reason_tags=rolling_adj.get("rolling_adjustment_reason_tags", ""),
|
| 279 |
-
)
|
| 280 |
-
except Exception:
|
| 281 |
-
drift_adj = {"arsenal_hr_adjustment": 0.0, "arsenal_hit_adjustment": 0.0,
|
| 282 |
-
"arsenal_drift_score": 0.0, "arsenal_reason_tags": ""}
|
| 283 |
-
|
| 284 |
-
drift_hit = float(drift_adj.get("arsenal_hit_adjustment", 0.0) or 0.0)
|
| 285 |
-
drift_hr = float(drift_adj.get("arsenal_hr_adjustment", 0.0) or 0.0)
|
| 286 |
-
batter_baseline["hit_prob_base"] = min(0.55, max(0.05,
|
| 287 |
-
float(batter_baseline.get("hit_prob_base", 0.15) or 0.15) + drift_hit))
|
| 288 |
-
batter_baseline["hr_prob_base"] = min(0.30, max(0.005,
|
| 289 |
-
float(batter_baseline.get("hr_prob_base", 0.03) or 0.03) + drift_hr))
|
| 290 |
-
|
| 291 |
-
4E — New output dict fields (in the return row dict, Batch 13 section)
|
| 292 |
-
|
| 293 |
-
# Exact intermediate HR checkpoints for debug ladder (all logged in-place above)
|
| 294 |
-
"snap_baseline_hr": _snap_baseline_hr,
|
| 295 |
-
"snap_baseline_hit": _snap_baseline_hit,
|
| 296 |
-
"snap_baseline_tb2p": _snap_baseline_tb2p,
|
| 297 |
-
"snap_after_zone_hr": _snap_after_zone_hr,
|
| 298 |
-
"snap_after_arsenal_hr": _snap_after_arsenal_hr,
|
| 299 |
-
"snap_after_env_hr": _snap_after_env_hr,
|
| 300 |
-
"snap_after_platoon_hr": _snap_after_platoon_hr,
|
| 301 |
-
"snap_after_traj_hr": _snap_after_traj_hr,
|
| 302 |
-
"snap_after_rolling_hr": _snap_after_rolling_hr,
|
| 303 |
-
"snap_after_opportunity_hr": _snap_after_opportunity_hr,
|
| 304 |
-
"snap_after_drift_hr": _snap_after_drift_hr,
|
| 305 |
-
# Opportunity
|
| 306 |
-
"expected_pa": opp_adj.get("expected_pa"),
|
| 307 |
-
"pa_multiplier": opp_adj.get("pa_multiplier"),
|
| 308 |
-
"pitcher_quality_score": opp_adj.get("pitcher_quality_score"),
|
| 309 |
-
"opportunity_reason": opp_adj.get("opportunity_reason"),
|
| 310 |
-
"lineup_slot_used": opp_adj.get("lineup_slot_used"),
|
| 311 |
-
"team_total_used": opp_adj.get("team_total_used"),
|
| 312 |
-
"opportunity_mode": opp_adj.get("opportunity_mode"),
|
| 313 |
-
# Arsenal drift
|
| 314 |
-
"arsenal_hr_adjustment": drift_adj.get("arsenal_hr_adjustment"),
|
| 315 |
-
"arsenal_hit_adjustment": drift_adj.get("arsenal_hit_adjustment"),
|
| 316 |
-
"arsenal_drift_score": drift_adj.get("arsenal_drift_score"),
|
| 317 |
-
"arsenal_reason_tags": drift_adj.get("arsenal_reason_tags"),
|
| 318 |
-
|
| 319 |
-
---
|
| 320 |
-
TASK 5 — Full Debug Dashboard
|
| 321 |
-
|
| 322 |
-
5A — Create visualization/debug_page.py
|
| 323 |
-
|
| 324 |
-
def render_debug(statcast_df, odds_df, conn, live_games, scores_df) -> None:
|
| 325 |
-
|
| 326 |
-
The function renders a full debug page with these sections (use st.header + st.subheader):
|
| 327 |
-
|
| 328 |
-
Section 1 — Filters (sidebar or top-of-page)
|
| 329 |
-
- Game selector (multiselect from live/scheduled games)
|
| 330 |
-
- Player filter (text input)
|
| 331 |
-
- Team filter (multiselect)
|
| 332 |
-
- Edge threshold (slider 0–20%)
|
| 333 |
-
|
| 334 |
-
Section 2 — Model Snapshot Table
|
| 335 |
-
- Call build_upcoming_hitter_recommendations() for each selected game
|
| 336 |
-
- Display: Player, Game, Slot, hit_prob, hr_prob, tb2p_prob, fair_hr_odds, book_hr_odds, hr_edge, pa_multiplier, pitcher_quality_score
|
| 337 |
-
- Apply edge threshold filter
|
| 338 |
-
|
| 339 |
-
Section 3 — Adjustment Ladder (per batter, expandable)
|
| 340 |
-
- Read exact checkpoint fields from output row (all are exact values logged in-place by the simulator):
|
| 341 |
-
Layer | Cumulative HR prob field
|
| 342 |
-
─────────────────────────────────────────────
|
| 343 |
-
Baseline | snap_baseline_hr
|
| 344 |
-
After Zone | snap_after_zone_hr
|
| 345 |
-
After Arsenal | snap_after_arsenal_hr
|
| 346 |
-
After Env | snap_after_env_hr
|
| 347 |
-
After Platoon | snap_after_platoon_hr
|
| 348 |
-
After Trajectory | snap_after_traj_hr
|
| 349 |
-
After Rolling | snap_after_rolling_hr
|
| 350 |
-
After Opportunity | snap_after_opportunity_hr
|
| 351 |
-
After Drift | snap_after_drift_hr
|
| 352 |
-
Final (simulated) | hr_prob
|
| 353 |
-
- Derive Delta column = current - previous row
|
| 354 |
-
- Show as table: Layer | Delta | Cumulative
|
| 355 |
-
- Use st.dataframe inside st.expander(batter_name)
|
| 356 |
-
- Values are exact (no approximation) — each checkpoint logged immediately after its block in the simulator
|
| 357 |
-
|
| 358 |
-
Section 4 — Full Feature Snapshot
|
| 359 |
-
- Two columns: batter_features dict + pitcher_row dict
|
| 360 |
-
- Use st.json() inside expanders
|
| 361 |
-
|
| 362 |
-
Section 5 — Signal Attribution
|
| 363 |
-
- rolling_adjustment_reason_tags (pipe-split to rows)
|
| 364 |
-
- arsenal_reason_tags
|
| 365 |
-
- reason_tags (pitcher live state)
|
| 366 |
-
- Show as a flat tag-cloud table
|
| 367 |
-
|
| 368 |
-
Section 6 — Admin Tools (moved from debug expander)
|
| 369 |
-
- Grade outcomes button → grade_final_game_outcomes_from_scores(scores_df)
|
| 370 |
-
- Build prop outcome rows button
|
| 371 |
-
- Fill realized outcomes button
|
| 372 |
-
- Simulator raw rows table (existing code from lines 3156–3236)
|
| 373 |
-
- Phase 6 live-state debug table (existing code from lines 3330–3514)
|
| 374 |
-
- Audit metrics (existing code from lines 3516–3682)
|
| 375 |
-
|
| 376 |
-
Section 7 — Export
|
| 377 |
-
- st.download_button for CSV: sim_df.to_csv(index=False).encode()
|
| 378 |
-
- st.download_button for JSON: json.dumps(sim_rows, default=str).encode()
|
| 379 |
-
|
| 380 |
-
Section 8 — Audit Metadata (placeholder display)
|
| 381 |
-
st.json({
|
| 382 |
-
"model_version": "Batch 13",
|
| 383 |
-
"feature_version": "rolling_form+opportunity+drift",
|
| 384 |
-
"odds_snapshot_id": None,
|
| 385 |
-
"data_timestamp": str(pd.Timestamp.now()),
|
| 386 |
-
})
|
| 387 |
-
|
| 388 |
-
Section 9 — CLV / ERE (existing tables from lines 3617–3661 moved here)
|
| 389 |
-
|
| 390 |
-
5B — Remove debug expander from app.py
|
| 391 |
-
|
| 392 |
-
Delete lines 2657–3682 (the entire with st.expander("Debug: raw schedule, scores"): block).
|
| 393 |
-
|
| 394 |
-
5C — Add Debug to navigation in app.py
|
| 395 |
-
|
| 396 |
-
In main() at line 3964:
|
| 397 |
-
options=[
|
| 398 |
-
"Dashboard", "Props", "Matchups",
|
| 399 |
-
"Betting", "Bet Tracker", "Algorithm Breakdown", "Debug"
|
| 400 |
-
]
|
| 401 |
-
|
| 402 |
-
Add import at top of app.py:
|
| 403 |
-
from visualization.debug_page import render_debug
|
| 404 |
-
|
| 405 |
-
Add handler in page dispatch:
|
| 406 |
-
elif page == "Debug":
|
| 407 |
-
render_debug(
|
| 408 |
-
statcast_df=load_statcast_recent(),
|
| 409 |
-
odds_df=odds_df,
|
| 410 |
-
conn=conn,
|
| 411 |
-
live_games=live_games,
|
| 412 |
-
scores_df=scores_df,
|
| 413 |
-
)
|
| 414 |
-
|
| 415 |
-
Note: live_games, scores_df, and odds_df are already computed in main() via the shared cached loaders — verify scope or refactor as needed.
|
| 416 |
-
|
| 417 |
-
---
|
| 418 |
-
Integration Order (Final)
|
| 419 |
-
|
| 420 |
-
batter_baseline (compute_batter_baseline)
|
| 421 |
-
↓ [snapshot baseline_hit/hr/tb2p_prob]
|
| 422 |
-
↓ blended pitch outcome (additive)
|
| 423 |
-
↓ zone matchup (additive)
|
| 424 |
-
↓ family zone matchup (additive)
|
| 425 |
-
↓ arsenal matchup (additive)
|
| 426 |
-
↓ pulled contact (hr only, additive)
|
| 427 |
-
↓ environment (additive)
|
| 428 |
-
↓ platoon/handedness (additive)
|
| 429 |
-
↓ trajectory (additive)
|
| 430 |
-
↓ rolling form (additive) ← Batch 12E
|
| 431 |
-
↓ opportunity (MULTIPLICATIVE × pa_multiplier) ← NEW Batch 13
|
| 432 |
-
↓ arsenal drift (additive) ← NEW Batch 13
|
| 433 |
-
↓ simulate_upcoming_hitter()
|
| 434 |
-
|
| 435 |
-
---
|
| 436 |
-
Hard Constraints
|
| 437 |
-
|
| 438 |
-
- DO NOT modify engine/live_game_engine.py or simulation/pitch_simulator.py
|
| 439 |
-
- All new adjustments must be None-safe with try/except fallbacks
|
| 440 |
-
- Opportunity is MULTIPLICATIVE only
|
| 441 |
-
- Rolling + Drift are ADDITIVE only
|
| 442 |
-
- Drift max effect: ±0.003 HR, ±0.0025 hit (drift_score 0.5 × 0.006/0.005)
|
| 443 |
-
- Opportunity max effect: pa_multiplier range [0.85, 1.15]
|
| 444 |
-
- estimate_plate_appearance_probability() in opportunity_model.py remains UNCHANGED (used by recommendation_engine.py)
|
| 445 |
-
|
| 446 |
-
---
|
| 447 |
-
Verification
|
| 448 |
-
|
| 449 |
-
1. Opportunity: Run simulator with known pitcher (high SwStr) → pa_multiplier < 1.0; with walk-happy pitcher → > 1.0. Check output fields present in sim row.
|
| 450 |
-
2. Drift anti-double-count: Force a pitcher row with large EV spike AND set rolling_reason_tags = "pitcher_ev_allowed_spiking" → drift EV contribution halved.
|
| 451 |
-
3. Debug tab: Navigate to Debug page → loads without crash, all 9 sections render, CSV/JSON download works.
|
| 452 |
-
4. Ladder accuracy: Verify snap_after_drift_hr differs from hr_prob only by the simulation randomness adjustment (expected small delta). Verify snap_baseline_hr
|
| 453 |
-
matches compute_batter_baseline output for that player.
|
| 454 |
-
5. No crashes on None inputs: Pass lineup_slot=None, team_total=None, pitcher_row={} → returns pa_multiplier=1.0.
|
| 455 |
-
6. Live engine isolation: Confirm engine/live_game_engine.py and simulation/pitch_simulator.py have zero imports of new modules.
|
| 456 |
-
╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
|
| 457 |
-
|
| 458 |
-
Claude has written up a plan and is ready to execute. Would you like to proceed?
|
| 459 |
-
|
| 460 |
-
❯ 1. Yes, clear context (56% used) and auto-accept edits
|
| 461 |
-
2. Yes, auto-accept edits
|
| 462 |
-
3. Yes, manually approve edits
|
| 463 |
-
4. Type here to tell Claude what to change
|
|
|
|
| 1 |
+
Small Follow-Up Update — Feedback Tab + Batch 13 Debug/Traceability Refinements
|
| 2 |
+
|
| 3 |
+
Context
|
| 4 |
+
|
| 5 |
+
Batch 13 is already in progress / just completed:
|
| 6 |
+
- Opportunity Model
|
| 7 |
+
- Arsenal Drift Layer
|
| 8 |
+
- Full Debug Dashboard
|
| 9 |
+
|
| 10 |
+
This follow-up is intentionally small and surgical. It does TWO things:
|
| 11 |
+
|
| 12 |
+
1. Add a simple Feedback tab backed by CockroachDB
|
| 13 |
+
2. Add the remaining debug/traceability refinements we identified for Batch 13
|
| 14 |
+
|
| 15 |
+
Do NOT change live-engine logic.
|
| 16 |
+
Do NOT refactor unrelated systems.
|
| 17 |
+
Keep this focused and minimal.
|
| 18 |
+
|
| 19 |
+
------------------------------------------------------------
|
| 20 |
+
PART 1 — Feedback Tab (CockroachDB-backed)
|
| 21 |
+
------------------------------------------------------------
|
| 22 |
+
|
| 23 |
+
Goal
|
| 24 |
+
|
| 25 |
+
Add a very simple Feedback tab for early external users.
|
| 26 |
+
|
| 27 |
+
UI requirements:
|
| 28 |
+
- text box
|
| 29 |
+
- submit button
|
| 30 |
+
- display all submitted feedback below
|
| 31 |
+
- all submissions stored together in CockroachDB
|
| 32 |
+
|
| 33 |
+
Storage requirements:
|
| 34 |
+
- create a new table for feedback
|
| 35 |
+
- table can be created lazily on first submission OR created up front in schema init — choose whichever is simplest and most reliable
|
| 36 |
+
- CockroachDB only, no DuckDB/local files
|
| 37 |
+
|
| 38 |
+
Files to modify:
|
| 39 |
+
- database/db.py
|
| 40 |
+
- visualization/feedback_page.py (new)
|
| 41 |
+
- app.py
|
| 42 |
+
|
| 43 |
+
------------------------------------------------------------
|
| 44 |
+
1A — database/db.py
|
| 45 |
+
------------------------------------------------------------
|
| 46 |
+
|
| 47 |
+
Add a new table:
|
| 48 |
+
|
| 49 |
+
feedback_submissions
|
| 50 |
+
|
| 51 |
+
Recommended schema:
|
| 52 |
+
|
| 53 |
+
CREATE TABLE IF NOT EXISTS feedback_submissions (
|
| 54 |
+
created_at TEXT,
|
| 55 |
+
message TEXT
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
If you want to add an id column and it is easy/safe in CockroachDB, that is fine, but keep it simple.
|
| 59 |
+
Do NOT overengineer this.
|
| 60 |
+
|
| 61 |
+
Add helper functions:
|
| 62 |
+
|
| 63 |
+
ensure_feedback_submissions_table(conn) -> None
|
| 64 |
+
|
| 65 |
+
insert_feedback_submission(conn, message: str) -> None
|
| 66 |
+
|
| 67 |
+
read_feedback_submissions(conn) -> pd.DataFrame
|
| 68 |
+
|
| 69 |
+
Behavior:
|
| 70 |
+
- insert_feedback_submission() should call ensure_feedback_submissions_table() first
|
| 71 |
+
- read_feedback_submissions() should return rows ordered newest first
|
| 72 |
+
|
| 73 |
+
------------------------------------------------------------
|
| 74 |
+
1B — visualization/feedback_page.py
|
| 75 |
+
------------------------------------------------------------
|
| 76 |
+
|
| 77 |
+
Create new file:
|
| 78 |
+
visualization/feedback_page.py
|
| 79 |
+
|
| 80 |
+
Function:
|
| 81 |
+
|
| 82 |
+
render_feedback(conn) -> None
|
| 83 |
+
|
| 84 |
+
UI:
|
| 85 |
+
|
| 86 |
+
- st.header("Feedback")
|
| 87 |
+
- st.text_area(...) for feedback text
|
| 88 |
+
- st.button("Submit")
|
| 89 |
+
|
| 90 |
+
On submit:
|
| 91 |
+
- trim whitespace
|
| 92 |
+
- if empty, show warning
|
| 93 |
+
- otherwise insert into feedback_submissions table
|
| 94 |
+
- show success message
|
| 95 |
+
|
| 96 |
+
Below the form:
|
| 97 |
+
- load all submissions from DB
|
| 98 |
+
- display newest first
|
| 99 |
+
- simple display is fine:
|
| 100 |
+
- created_at in bold
|
| 101 |
+
- message beneath
|
| 102 |
+
- divider between entries
|
| 103 |
+
|
| 104 |
+
Keep it clean and minimal.
|
| 105 |
+
No sentiment analysis, no categories, no editing/deleting.
|
| 106 |
+
|
| 107 |
+
------------------------------------------------------------
|
| 108 |
+
1C — app.py
|
| 109 |
+
------------------------------------------------------------
|
| 110 |
+
|
| 111 |
+
Add import:
|
| 112 |
+
from visualization.feedback_page import render_feedback
|
| 113 |
+
|
| 114 |
+
Add Feedback to navigation options.
|
| 115 |
+
|
| 116 |
+
Route:
|
| 117 |
+
elif page == "Feedback":
|
| 118 |
+
render_feedback(conn)
|
| 119 |
+
|
| 120 |
+
Place it wherever makes sense in nav, but keep it visible.
|
| 121 |
+
|
| 122 |
+
------------------------------------------------------------
|
| 123 |
+
PART 2 — Batch 13 Debug/Traceability Refinements
|
| 124 |
+
------------------------------------------------------------
|
| 125 |
+
|
| 126 |
+
These are small follow-up improvements to the just-accepted Batch 13 work.
|
| 127 |
+
|
| 128 |
+
Files to modify:
|
| 129 |
+
- models/live_fair_simulator_v3.py
|
| 130 |
+
- models/arsenal_drift_model.py
|
| 131 |
+
- visualization/debug_page.py
|
| 132 |
+
|
| 133 |
+
------------------------------------------------------------
|
| 134 |
+
2A — Add missing exact debug checkpoints
|
| 135 |
+
------------------------------------------------------------
|
| 136 |
+
|
| 137 |
+
In models/live_fair_simulator_v3.py, add exact checkpoint snapshots for the layers that were still missing from the HR debug ladder:
|
| 138 |
+
|
| 139 |
+
Add:
|
| 140 |
+
- snap_after_family_zone_hr
|
| 141 |
+
- snap_after_pulled_contact_hr
|
| 142 |
+
|
| 143 |
+
Also add equivalent checkpoints for hit/tb2p where relevant.
|
| 144 |
+
|
| 145 |
+
Important:
|
| 146 |
+
- Use exact in-place snapshots immediately after each layer writes back to batter_baseline
|
| 147 |
+
- Do NOT reconstruct later
|
| 148 |
+
|
| 149 |
+
Updated ladder order should reflect all real HR-affecting layers:
|
| 150 |
+
|
| 151 |
+
Baseline
|
| 152 |
+
After Zone
|
| 153 |
+
After Family Zone
|
| 154 |
+
After Arsenal
|
| 155 |
+
After Pulled Contact
|
| 156 |
+
After Env
|
| 157 |
+
After Platoon
|
| 158 |
+
After Trajectory
|
| 159 |
+
After Rolling
|
| 160 |
+
After Opportunity
|
| 161 |
+
After Drift
|
| 162 |
+
Final (simulated hr_prob)
|
| 163 |
+
|
| 164 |
+
------------------------------------------------------------
|
| 165 |
+
2B — Log hit and tb2p checkpoint ladders too
|
| 166 |
+
------------------------------------------------------------
|
| 167 |
+
|
| 168 |
+
Even if the Debug UI only shows HR ladder by default, log the exact checkpoint fields for:
|
| 169 |
+
- HR
|
| 170 |
+
- hit
|
| 171 |
+
- tb2p
|
| 172 |
+
|
| 173 |
+
This is for future audit/admin use.
|
| 174 |
+
|
| 175 |
+
At minimum, ensure output row includes exact checkpoint fields for all three.
|
| 176 |
+
|
| 177 |
+
------------------------------------------------------------
|
| 178 |
+
2C — Fix / clarify pitcher drift applied scale
|
| 179 |
+
------------------------------------------------------------
|
| 180 |
+
|
| 181 |
+
In models/arsenal_drift_model.py, explicitly prevent accidental double sample dampening.
|
| 182 |
+
|
| 183 |
+
Current concern:
|
| 184 |
+
If pitcher_rolling_confidence already includes sample dampening, multiplying again by _sample_scale(n5) reintroduces double-dampening.
|
| 185 |
+
|
| 186 |
+
Requirement:
|
| 187 |
+
- verify what pitcher_rolling_confidence actually represents
|
| 188 |
+
- make drift scaling correct and explicit
|
| 189 |
+
|
| 190 |
+
Valid outcomes:
|
| 191 |
+
1. If pitcher_rolling_confidence is match-quality only:
|
| 192 |
+
scale = _sample_scale(n5) * confidence
|
| 193 |
+
2. If pitcher_rolling_confidence already includes sample dampening:
|
| 194 |
+
scale = confidence
|
| 195 |
+
|
| 196 |
+
Whichever is true, enforce it clearly in code/comments.
|
| 197 |
+
|
| 198 |
+
Also add this field to drift output:
|
| 199 |
+
- arsenal_drift_applied_scale
|
| 200 |
+
|
| 201 |
+
This must be surfaced in simulator output for traceability.
|
| 202 |
+
|
| 203 |
+
------------------------------------------------------------
|
| 204 |
+
2D — Keep live odds debug panel intentionally
|
| 205 |
+
------------------------------------------------------------
|
| 206 |
+
|
| 207 |
+
If render_live_prop_odds_debug_panel(live_games) remains on Dashboard, keep it intentionally and make sure it is not orphaned by the debug refactor.
|
| 208 |
+
|
| 209 |
+
Do NOT accidentally remove it unless clearly replacing it with an equivalent section in Debug page.
|
| 210 |
+
|
| 211 |
+
------------------------------------------------------------
|
| 212 |
+
2E — Update Debug page ladder
|
| 213 |
+
------------------------------------------------------------
|
| 214 |
+
|
| 215 |
+
In visualization/debug_page.py:
|
| 216 |
+
- update the Adjustment Ladder section to use the fuller exact checkpoint chain
|
| 217 |
+
- include Family Zone and Pulled Contact in the ladder
|
| 218 |
+
- continue using exact logged fields only
|
| 219 |
+
- no approximation / no reconstruction
|
| 220 |
+
|
| 221 |
+
If feasible without clutter, add a simple toggle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|