Skip to content

fix(roadmap): a late premise return drops passed groups #5881

Closed

Description

@dan-petty

Problem

The implement job returns an item to New after some groups of the item have passed. The return takes the passed work off the item branch, closes the pull request, and reports the wrong facts.

On 2026-11-15, runner Job devops-cli-implement-devops-cli-3453-b8f208 (item #3453, v0.158.0) ran from 18:40Z to 19:33Z. It opened pull request #5873 at 18:49Z, and pushed 3 commits (+260 -24 in 12 files). At group 4, _check_premise (src/devops_cli/roadmap/implement/implement_run.py:902, called in the group loop at line 1155) returned the item to New. _withdraw then pushed the branch back to the plan commit and closed #5873. The commits are now only on refs/pull/5873/head (fe7a22e).

Four defects:

  1. The check runs late. It runs before each behavior group, not once before the first step. So a false premise of group 4 costs the tokens and the time of groups 1 to 3 (53 min here), and the docstring ("a false premise costs no model request") is false. The check also reads wip_base, so a guard that an earlier group of the same run added counts as "already defined".
  2. The comment is false. It says "the job ran no step and wrote no code" (implement_comment_premise_defined), but 3 groups ran and feat(roadmap): Record the identifiers that a group adds #5873 was open.
  3. The result line is false. roadmap job result: job=implement item=#3453 result=returned ... tokens=0 seconds=3198. The run used tokens, so the token cost of returns is lost in the grades.
  4. The rule matches test text. added_guard (src/devops_cli/roadmap/premise.py:142) took _delivery_title from task 4.1, which describes a test fixture: "gives a task that says to add a check beside the guard _delivery_title". _delivery_title is a real function at implement_run.py:1521, so the rule fired. feat(roadmap): a plan states the identifiers that a behavior group adds #3453 replaces this prose rule with an Adds: line, but the job cannot build feat(roadmap): a plan states the identifiers that a behavior group adds #3453 while the prose rule is live.

Expected behavior

  • A false premise stops the run before the first step, so it costs no model request and loses no work.
  • The comment and the result line state what the run did: the groups that ran, the tokens, and the pull request.
  • A task that only describes a test input does not return the item.

Fix options (the plan decides)

  • Check every behavior group against the base commit once, before the first step.
  • When a return happens after a group passed, keep the pushed groups (or stop with a class) and do not close the pull request.
  • Write the real token count in the result line of a return.
  • Skip a task that names a test function, or wait for feat(roadmap): a plan states the identifiers that a behavior group adds #3453 and build it by hand.

Test first: a plan whose group 4 holds a task that adds a guard which the base defines returns the item before the step of group 1.

Related

Source: #5873

Proposed design

Problem statement

A false premise in a later group returns the item to New after the earlier groups passed. The return pushes the branch back to the base commit, closes the pull request, and writes a comment and a result line that state false facts. The premise check also reads the work-in-progress tip, and the prose rule matches a guard name in a test description. The fix checks every behavior group against the base commit before the first step, stops a late premise as Blocked while keeping the passed work and the pull request, writes the real facts, and stops the prose rule from matching a test description.

Acceptance criteria

Requirement: Premise check before the first step

The implement job SHALL check the premise of every behavior group against the base commit before it runs the first step of a run.

Scenario: A false premise in group 4

  • WHEN A plan holds four behavior groups, and the task of group 4 adds a guard that the base commit defines.
  • THEN The job returns the item to New before the step of group 1 and makes no model request.

Requirement: Premise check reads the base commit

The premise check SHALL read the definitions of the base commit and MUST NOT count a definition that an earlier group of the run added.

Scenario: A guard that an earlier group adds

  • WHEN The task of group 1 adds _new_guard, the task of group 2 names _new_guard as an added guard, and the base commit does not define it.
  • THEN The job runs the step of group 1 and does not return the item to New.

Requirement: A late premise stops and keeps the passed groups

When the branch already holds commits past the base, a false premise SHALL stop the item as Blocked with the class premise_false, keep the commits, and leave the pull request open.

Scenario: A later run holds the commits of groups 1 to 3

  • WHEN An earlier Job kept the commits of groups 1 to 3 on the branch with an open pull request, and the check of a later Job finds a false premise.
  • THEN The item is Blocked with the class premise_false, the branch keeps the commits of groups 1 to 3, and the pull request stays open.

Requirement: The return comment states the run's facts

The comment of a return SHALL state the groups that ran, the tokens that the run used and the pull request of the run.

Scenario: A return after one step and no commit

  • WHEN An agent asks to return a Planned item at group 1 after one step used 40000 tokens and committed nothing.
  • THEN The comment says that one group ran, gives 40000 tokens and names no pull request.

Requirement: The result line holds the tokens of a return

The result line of a return SHALL give the tokens that the run used and MUST NOT give zero when the run used tokens.

Scenario: A return after model requests

  • WHEN The run used 120000 tokens before it returned the item to New.
  • THEN The result line holds tokens=120000.

Requirement: A guard named as a neighbor is not added

The premise rule SHALL require an add verb to introduce the guard word that the identifier follows and MUST NOT match an identifier named as a neighbor.

Scenario: A task that describes a test fixture

  • WHEN A task says to add a check beside the guard _delivery_title, and the base commit defines _delivery_title.
  • THEN The job runs the group and does not return the item to New.

Existing Tool Considered

No alternatives check has run. The web search found no open, maintained tool or library that reads an OpenSpec tasks.md or checks a task group's premise against a base commit; the project's own parse_task_groups and false_premises are the only code that reads the task text. The durable-workflow engines are rejected by ADR 0008 and ADR 0021, so the change builds on the project's code: 3 source modules and 5 test modules. The written cost is about 60k tokens to build, 15k tokens to keep and fix, and 3 hours elapsed.

Key questions

  • When does the implement job check the premise of a behavior group?: Once for every behavior group, against the base commit, before the first step of the run. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py:902, src/devops_cli/roadmap/implement/implement_run.py:1155, openspec/changes/archive/2026-11-08-3677-checkpoint-each-passed-group/design.md:6, openspec/changes/3453-a-plan-states-the-identifiers-that/tasks.md:38]
    • Rejected: Before each behavior group at the boundary. It spends the tokens and the time of the groups before the false one, and the docstring claim of no model request is false.
    • Chosen: Once before the first step of the run. It spends no model request and loses no group work when a later group holds a false premise.
  • Which commit does the premise check read?: The commit that implement.base names for a Staged item, and origin/<default> after the sync for a Planned item whose base is new; never wip_base, so a guard that an earlier group added does not count. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py:785, src/devops_cli/roadmap/implement/implement_run.py:804, src/devops_cli/roadmap/implement/implement_run.py:910, openspec/changes/archive/2026-11-08-3677-checkpoint-each-passed-group/design.md:10]
    • Rejected: The work-in-progress tip (wip_base). A guard that group 1 adds counts as already defined for group 2, and the check returns the item for no defect.
    • Chosen: The base commit of the run (implement.base, or origin/<default> for a Planned item). Every group sees the same tree, so the check answers the same question for each group.
  • What does a return do when the branch already holds the commits of a passed group?: Stop the item as Blocked with the class premise_false and the action left wait, keep the branch and the pull request, discard nothing, and pass kept_branch=True so the stop comment names the branch and the last commit it kept. A return to New happens only when the branch holds no commit past the base. (best practice) [sources: CONTEXT.md:52, CONTEXT.md:146, openspec/changes/archive/2026-11-08-3677-checkpoint-each-passed-group/design.md:5, docs/ROADMAP_WORKFLOW.md:100, src/devops_cli/roadmap/failure.py:67, src/devops_cli/roadmap/implement/implement_run.py:1255]
    • Rejected: Withdraw to the base commit and close the pull request. It discards the commits of the passed groups and loses the tokens of their steps.
    • Rejected: Return the item to New and keep the branch and the pull request. The stage selection leaves out an item whose branch is on origin (docs/ROADMAP_WORKFLOW.md:100), so the item waits in New with no named cause and no retry path.
    • Chosen: Stop the item as Blocked with the class premise_false and the action left wait. The stop keeps the work, names the cause, and waits for implement: retry as the other stops of the job do (CONTEXT.md:52).
  • What does the comment of a return state?: The groups that ran, the tokens that the run used and the pull request of the run, from the run's own record; a return before the first step says that no group ran. (best practice) [sources: src/devops_cli/lang/en/messages.py:3928, src/devops_cli/roadmap/implement/implement_run.py:916, src/devops_cli/roadmap/implement/implement_run.py:1215, src/devops_cli/roadmap/implement/implement_run.py:1724]
    • Rejected: Keep the text "the job ran no step and wrote no code". It is false when a step ran or the job opened a pull request.
    • Chosen: State the counts of the run. The comment then matches the run, whatever the run did.
  • Where does the result line of a return get its token count?: The Service's _report computes it as implement.spend minus implement.spend_counted and passes it to log_job_result as tokens; a return must therefore write the run's spend to implement.spend and leave implement.spend_counted for the Service to advance, as a stop does, instead of clearing both. (best practice) [sources: src/devops_cli/roadmap/implement/implement_submit.py:343, src/devops_cli/roadmap/implement/implement_submit.py:347, src/devops_cli/roadmap/implement/implement_submit.py:380, src/devops_cli/roadmap/implement/implement_run.py:931, src/devops_cli/roadmap/implement/implement_run.py:2024]
    • Rejected: Write tokens=0 for a return. It hides the token cost of returns from the job grade.
    • Chosen: Write the run's token count from implement.spend. The grade then reads the cost of a return as it reads the cost of a stop.
  • How does the premise rule stop matching a task that only describes a test input?: Require an add verb to introduce the guard word that the identifier follows, so an identifier after "beside the guard" is no added guard. After the first add verb that introduces a guard, every guard span is a candidate, so a task that names two guards still returns none. (best practice) [sources: src/devops_cli/roadmap/premise.py:142, tests/roadmap/test_premise.py:48, openspec/changes/3453-a-plan-states-the-identifiers-that/design.md:15, openspec/changes/3453-a-plan-states-the-identifiers-that/tasks.md:38, openspec/changes/archive/2026-11-06-3417-the-implement-job-re-checks-a/tasks.md:18]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/high
    effort/medium
    on Nov 15, 2026
  2. dan-petty commented on Nov 15, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p1-high
    owner/agent
    on Nov 15, 2026
  4. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  5. added
    status/in-review
    and removed
    status/new
    on Nov 15, 2026
  6. removed
    status/in-review
    owner/agent
    on Nov 15, 2026
  7. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-15 23:51 UTC

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

    effort/mediumpriority/p1-highscope/roadmapsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions