Skip to content

tui: ignore stale verification results from older edits #75

Description

@abhiksark

Motivation

Verification runs in background threads. A slower result for older text can arrive after a newer result and overwrite the visible state or incorrectly complete the exercise.

Current evidence

A controlled Textual pilot on dev at e1d4dae37234b75124bd6a53f06734296ebbbdee reproduced the race twice. The older run was held, a newer failing run was applied, and then the older passing run was released:

before older result: current='a1', completed=[]
after older result:  current='a2', completed=['a1']

Textual worker cancellation is advisory for a running thread. _apply_result() checks attachment and exercise name, but not which edit or run produced the result.

Exact scope

Associate each verification with the editor revision or run generation that started it. Only the newest applicable result may update output, failure counts, completion state, resume state, or exercise navigation.

Acceptance checklist

  • A slower old pass cannot replace a newer failure.
  • A slower old failure cannot replace a newer pass.
  • Stale results cannot mark completion, advance, or change persisted resume state.
  • Results for a screen that was popped remain ignored.
  • Normal single-run behavior and immediate advancement remain unchanged.
  • Deterministic pilot coverage controls both completion orders without timing-only sleeps.

Explicit exclusions

Do not remove subprocess isolation, make verification synchronous, change the five-second timeout, or redesign the output panel.

Likely files

  • pythonlings/screens/track.py
  • tests/tui/test_app_pilot.py

Verification

python -m pytest tests/tui -q
python -m pytest -q
pythonlings --root tests/fixtures/passing_curriculum verify

Run the controlled old-pass/new-fail and old-fail/new-pass cases repeatedly.

Sprint coordination

See Discussion #37 and tracker #52. This issue is intentionally unassigned. A coordination comment is welcome, but it does not reserve the issue. The first pull request that satisfies every acceptance criterion and verification requirement is considered for merge.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: tuiTextual terminal user interfacebugSomething isn't workingdev sprintPythonlings Community Dev Sprint August 2026help wantedExtra attention is neededsize: MMedium, self-contained contribution

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions