Skip to content

fix(github): a rerun that reverts a stall change counts its own Status write as a person's activity, so a stall descope is quietly undone #1085

Closed as not planned

Description

@dan-petty

Problem

Found by the final verifier of #740 (PR #1084). Lines cited at be2b8b4 (feat/roadmap-reprioritize), in src/devops_cli/roadmap/reprioritize.py.

It needs two stopped runs plus a person's action between them. When a rerun drops or re-judges an unfinished stall change, the revert writes the Status back (_apply_revert, line 2121: store.set_field(revert.item, item_field, value)). That is the job's own write, and a later run reads it as a person's activity.

The documented rule is 'the job's own write being no activity' (module docstring, lines 123-124). Breaking it means a stall descope that the rerun decides again is quietly undone. The item stays In Progress in the current release with no comment. Its stall clock restarts at the job's own revert write, so it is not descoped for another 14 days. The run left alone would have descoped it, with its comment.

Scenario:

  1. An admitted In Progress feature in started v1.0.0 is idle for 15 days.
  2. Run A (stall descope, READY_TO_NEXT) moves it to v1.0.1 and sets it Ready. Both writes are confirmed. Then its comment POST fails, and the CLI says to run it again.
  3. A person moves the item back to v1.0.0. A P1 bug that a person makes P0 instead behaves the same way.
  4. Run B drops the change, because the Release is now the person's, or re-judges it as FIX_STALLED/READY. The revert sets the Status back to In Progress. Run B then judges the item with the change's old clock (_prepare, line 1253), still finds it stalled, and starts a new descope.
  5. Left alone, run B ends with the item in v1.0.1, Ready, with 1 comment.
  6. If run B stops at any of 8 of its 11 gh writes, between the revert's Status write and the new comment, run C ends with the item in v1.0.0, In Progress, Admitted kept, and 0 comments.

Three code paths misread the revert's write:

  • (a) The new change's Pending takes status_at=store.status_changed_at(...) (line 2041), which is the time of the revert's own write. _resumed hands that to the re-judge as the clock (line 1163), so the item looks active and run C reverts the descope.
  • (b) If run B stops after the revert's Status write but before the new Pending, run C reads the old Pending. Its written Status now holds In Progress, so _owner returns PERSON (line 1079). The clock override is then skipped (line 1252), and the revert's write counts as activity.
  • (c) If the revert's Status write and the new change's Status write share a timestamp, run C's re-judge leaves the job's Ready on the item with no comment. This always happens in the in-memory store, which uses one clock per run. On GitHub it needs both writes in the same second of updatedAt. The cause: the begun Status shows no clock change, so _owner returns NO_ONE (line 1084) even though the field holds the change's value. In this variant the existing machine fails its own invariant: 'Reprioritization: a change the job begins is finished, with its reason comment, by the run that begins it or by the next one.'

Evidence

Method: I wrote a stateful fake gh behind the real GitHubRoadmapStore. It is backed by the in-memory state and answers every REST, GraphQL and gh project call the job makes. Faults are injected per gh write, either before the write applies or after it applies and still reports a 502. Each write advances the clock by 1 s, like GitHub's updatedAt.

Double-fault sweeps on the current code (diverged means the final state differs from the run left alone):

  • stall-written-then-put-back: 104 of 176 cases diverged.
  • stall-then-made-critical (P1 bug, stall descope stopped at its comment, person sets P0): 88 of 180.
  • the same with the bug also put back: 56 of 100.

In every diverged case the item ends In Progress in v1.0.0 with no comment, instead of v1.0.1 Ready with 1 comment (or, for the fix, Ready in place with 1 comment). Single faults in run B alone diverge at writes 2a, 3, 3a, 4, 4a, 5, 6a, 7, 7a, 8, 9a and 10. Write 10 is the new comment POST failing before it applies.

Replay on the in-memory machine. It is red on HEAD 77df02e for all 7 cases: [3], [4], [5], [7], [8] and [10] end (None, 'v1.0.0', 'In Progress', 'v1.0.0', 0), and [9] raises the machine's finished invariant. It is green on the fix, 0.01 s each:

@pytest.mark.parametrize("at", [3, 4, 5, 7, 8, 9, 10])
def test_a_stall_descope_a_person_undid_is_descoped_again_wherever_its_rerun_stops(at: int) -> None:
    state = RoadmapLifecycle()
    held, _ = state.start(held=["In Progress", "Ready"], waiting=[]).values
    replay(
        state,
        lambda: state.next_run_stops(at=8, later=True),
        lambda: state.days_pass(days=STALL_DAYS + 1),
        lambda: state.next_run_stops(at=at, later=True),
        lambda: state.person_places(item=held, place="current"),
        lambda: state.days_pass(days=1),
    )
    found = state.view[held]
    assert (state.outstanding, found.release, found.status,
            state.titled(found.job_record.get(JobMark.ADMITTED)),
            len(state.store.comments_on(held))) == (None, "v1.0.1", "Ready", None, 1)

No other scenario diverged:

  • All 16 SWEPT scenarios through the GitHub store: 7,632 cases, 0 diverged, 1,856 unclaimed. Each settles to the same state as the in-memory adapter.
  • Single faults counting reads too: 1,398 cases, 0 diverged.
  • The 15 round-12 scenarios (cut at start, a shipped-since close, pull-ins then shipped or cut, stays, written fields put back, a start with items placed by a person): 0 diverged.
  • With ticking clocks, SWEPT diverges only through Nudged timestamps. That is an artifact of the ticks, and 0 diverge with that mark masked.
  • The machine run through the GitHub adapter passed 120 seeds at 300x40 (41000-41119, median 34.1 s) and 40 seeds at 200x70 (42000-42039, median 51.4 s). Control: with the cut-lock row removed, it fails seeds 31000 and 31001.

Acceptance criteria

  • A revert's own writes count as no activity and no person's, as a change's own writes do. The module, _Pending, _Resumed, _owner and _apply_revert docstrings say so.
  • The replay test_a_stall_descope_a_person_undid_is_descoped_again_wherever_its_rerun_stops[3,4,5,7,8,9,10] (below) is red on the current code and green after the fix, 0.01 s each.
  • The double-fault sweeps through the GitHub store for the three stall scenarios (stall written then put back; stall then made critical; the same with the bug also put back) show 0 diverged. Every other GitHub-backed scenario is unchanged: 0 diverged, same unclaimed counts.
  • The deep profile's double-fault sweep stays at 7,580 cases, 0 diverged, and the cut-lock search still shrinks to the same three rules.
  • ruff check (C901 at 10), ruff format and mypy --strict are clean, no noqa is added, and uv run devops ci passes.

Key questions

  • Which fix? Proposed: the one below, validated against the replay and the sweeps above.

Validated fix in reprioritize.py, in four parts.

(a) Record the clock the rules judged the item by:

  • Decision gains clock: datetime | None = None, set in _Run.decision from self.status_times.get(item.number).
  • _Pending gains judged_at: datetime | None = None, set in _pending as judged_at=decision.clock if sets_status else None.
  • In _resumed, replace line 1163 with status_at=_judged_clock(pending, owners.get(ItemField.STATUS)), where:
def _judged_clock(pending, status):
    if ItemField.STATUS in pending.begun:
        return pending.judged_at or pending.status_at
    return pending.judged_at if status is _Owner.NO_ONE else None

(b) Mark each revert undo in the Pending mark, in the undo's own record call:

  • _Pending gains undone: tuple[ItemField, ...] = ().
  • Revert gains begun: _Pending | None, passed from _Resumed.revert().
  • _apply_revert adds the field to pending.undone and calls store.set_field(revert.item, item_field, value, marks={JobMark.PENDING: pending.model_dump_json()}).
  • _owner gains a first branch: if item_field in pending.undone and _same_place(item.field_value(item_field), was): return _Owner.NO_ONE.
  • _Resumed gains reverting=bool(pending.undone).
  • _prepare drops a reverting change: dropped = (resumed.person and not resumed.done and not resumed.unproven) or resumed.reverting.

(c) In _owner's begun branch, a field whose clock is unchanged but which holds the change's value (not was) is UNPROVEN, not NO_ONE: landed = holds and not _same_place(value, was); return _Owner.UNPROVEN if landed else _Owner.NO_ONE.

(d) Pin the replay above.

Validation of the fix, loaded under the module's real name:

  • The replay goes from 7 failed to 7 passed.
  • The three stall scenarios: 0 of 268, 0 of 228 and 0 of 148 diverged.
  • Every other GitHub-backed scenario is unchanged: 0 diverged, same unclaimed counts.
  • test_roadmap_reprioritize, test_roadmap_lifecycle_properties and test_roadmap_store_contract: 286 passed.
  • The deep profile passes 86 tests. Its double-fault sweep is unchanged at 7,580 cases, 7,212 with the rerun failing too, 0 diverged and 1,856 unclaimed, and the cut-lock search still shrinks to the same three rules.
  • 60 seeds (43000-43059, 300x40, not derandomized) all pass.
  • ruff check with C901 at 10 and ruff format are clean, and MYPYPATH=src mypy --strict reports no issues.

Also update the _Pending, _Resumed, _owner and _apply_revert docstrings and the module docstring: a revert's own writes, like a change's, are no activity and no person's.

Strategic alignment

Update 2026-10-08: refinement

Re-checked after #1294, #1349 and #1360: the replay ends the same way ((None, 'v1.0.1', 'Ready', None, 1) with no stop), and the stall rule applies whoever placed the item (roadmap/reprioritize.py:1432-1436). Lines moved from be2b8b4: :126-127, :2236, :2156, :1218, :1133-1138, :1293, :1307-1308.

Activity

  1. added
    type/bug
    scope/github
    priority/p2-medium
    on Oct 3, 2026
  2. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Linked: #1086. Both test resume paths of the reprioritize job with tests/test_roadmap_lifecycle_properties.py; the fixes are independent, and the second rebases. Found by the 2026-10-08 backlog review.

  3. dan-petty commented on Oct 23, 2026

    @dan-petty
    OwnerAuthor

    Not planned: the fix is in roadmap/reprioritize.py, which #1952 deletes with the planner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2-mediumscope/githubtype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions