Skip to content

Stable run numbers across backfills and restarts; Reset clears the whole student tile - #97

Merged
Maharsh17 merged 1 commit into
mainfrom
session-scoped-runs
Sep 25, 2026
Merged

Maharsh17 merged 1 commit into
mainfrom
session-scoped-runs

Conversation

@Maharsh17

Copy link
Copy Markdown
Member

Fixes three bugs found in prod data (goal runs 0-5 of one student were overwritten and numbered newest-first).

1. Backfill fed events newest-first. backfill_student routed each event as prod paged it (newest-first), so run 0 was the newest run, and edit distances, episodes and goal profiles were computed over a reversed history. Backfill now only persists; the daemon evicts and rebuilds the worker from the log, which replays oldest-first.

2. Restarts overwrote runs. Run numbers are positions in a daemon session's replay and restart at 0 on every start (e.g. each deploy), but goal_profile was keyed by (studentID, run_index) and the alert dedupe by run index alone. So a new session's run 0 overwrote the old run 0, stale runs from the old session stayed mixed in, and alerts for reused run numbers never fired. Both are now keyed by session; the API shows the current session's goal evidence. Idempotent migration widens the key and keeps old rows (session '').

3. Reset only cleared notes and picks. The cards blanked, then runs, episodes, goal evidence and trigger history came back on the next fetch. Reset now records when it happened, and every read behind the student tile (states, detail, goal runs, alerts feed, trigger history, switches) shows only activity after it, for that board only. The confirm text now says what actually happens.

Tests: new tests/test_run_identity.py reproduces all three (failed before, pass now); full backend suite 256 passed, ruff clean; frontend 49 passed. Migration checked against an old-schema table (twice, idempotent). Docs updated.

Note for the perf/incremental-worker-state branch: small overlap in workers.py (session key on trigger detail, goal upsert and fired_indices; new session_key/start_session/evict).

🤖 Generated with Claude Code

…ar the whole student tile

- Backfill only persists prod's newest-first pages; the daemon then rebuilds the
  worker from the log so runs replay oldest-first (run 0 was the newest run, and
  edit distances and goal profiles were computed over a reversed history).
- goal_profile is keyed by (studentID, session, run_index) and the per-run alert
  dedupe by session, so a daemon restart no longer overwrites an earlier session's
  runs or silences alerts on a reused run number. Idempotent migration keeps old rows.
- Reset records when it happened; runs, episodes, goal evidence, alerts, trigger
  history and switches on that board then show only what came after it.
@Maharsh17
Maharsh17 merged commit 1961d53 into main Sep 25, 2026
2 checks passed
@Maharsh17
Maharsh17 deleted the session-scoped-runs branch September 25, 2026 06:33
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.

1 participant