Skip to content

feat(roadmap): one function decides when any draft pull request is ready #2916

Closed

Description

@dan-petty

What happened

The owner asked on 2026-10-31 for one issue workflow that is simple, clear, discrete, consistent and repeatable for the Service jobs, agentic coders and human developers. The plan and the owner's decisions are in the tracker issue. Decisions taken (the recommended defaults): add the label status/planned (amends ADR 0016); claim an item with labels owner/service, owner/agent and owner/human; a new runner image digest clears a stop once; any actor may claim an item, one at a time, a person's claim beats the Service's, and the Service never takes a claimed item.

Four kinds of pull request become ready by four rules: a stage plan pull request (the Service row of #2882), an implement pull request (the Job's mark_ready), an agent pull request (devops pr ready by hand) and a person's pull request. The owner decided on 2026-10-31 that a draft is marked ready when the work on the change is complete and all checks pass. The model evaluator (#2867) will later add alignment with the issue and the project rules. #2882 left one seam for it.

What should happen

  • One function, with one input (the pull request, its kind, its recorded item) and one answer (ready, wait, or refuse with a reason), is the only place that decides. The stage row, the implement Job and devops pr ready call it. The kinds differ only in what "complete" means: a plan is complete when opened, an implementation when every task group is ticked and the change is archived, an agent's or a person's pull request when its author says so.
  • devops pr check-readiness blocks a pull request of the implement job whose groups are not all ticked (the partial pull request merged as fix(config): config files and their copies keep the mode of the file,... #2801 on 2026-10-30 would be refused).
  • The evaluator feat(roadmap): Add a draft PR evaluator for issue and rules #2867 plugs into this function. This issue does not build it.

Evidence

Acceptance criteria

  • A test table covers the four kinds with complete and incomplete cases.
  • The implement Job and the stage row use the function.
  • A partial implement pull request is refused by check-readiness with the group named.
  • uv run devops ci passes.

Proposed design

Problem statement

Readiness of a draft pull request is decided in three separate places: the stage_ready row, the implement job, and the devops pr ready command. Each uses its own logic. This caused a partial implement pull request to merge as #2801. One function must be the single place that decides whether a draft pull request is ready, for all four kinds.

Acceptance criteria

Requirement: Single readiness function

The system SHALL provide one function that takes a pull request, its kind, and its recorded item, and returns ready, wait, or refuse with a reason.

Scenario: Function refuses an incomplete implement PR

  • WHEN A pull request of kind implement has one unticked task group
  • THEN The function returns refuse and the reason names the unticked group

Requirement: Stage row calls the function

The stage_ready row of the Service SHALL call the readiness function instead of its own inline logic.

Scenario: Stage row marks a plan PR ready

  • WHEN A stage plan PR is open and all its checks pass
  • THEN The stage_ready row calls the function and the function returns ready

Requirement: Implement job calls the function

The implement job SHALL call the readiness function before marking a pull request ready.

Scenario: Implement job refuses a partial PR

  • WHEN The implement job has an unticked task group
  • THEN The function returns refuse and the job does not mark the PR ready

Requirement: check-readiness command

The command devops pr check-readiness SHALL call the readiness function and report the result, naming the unticked group for a refused implement PR.

Scenario: check-readiness refuses a partial implement PR

  • WHEN A user runs devops pr check-readiness on an implement PR with an unticked group
  • THEN The command exits non-zero and prints the name of the unticked group

Requirement: Test table covers four kinds

The test suite SHALL include a table-driven test that covers all four kinds with both complete and incomplete cases.

Scenario: Test table has eight rows

  • WHEN The test suite runs the readiness function table test
  • THEN All eight rows (four kinds times two states) pass

Requirement: CI passes

The command uv run devops ci SHALL pass after the change.

Scenario: CI passes

  • WHEN A developer runs uv run devops ci
  • THEN All checks pass with exit code 0

Existing Tool Considered

No check has run. No open, maintained tool covers this need. The decision encodes project-specific rules: task group tick state, OpenSpec archive state, and author intent per kind. No library provides a readiness decision for these rules. The cost is building the function: about 200 tokens to write, about 50 tokens per fix cycle, and one development session of elapsed time.

Key questions

  • What is the input and output shape of the readiness function?: Input: the pull request object, its kind (stage_plan, implement, agent, person), and its recorded item. Output: a status of ready, wait, or refuse, and a reason string when the status is refuse. (best practice) [sources: openspec/changes/archive/2026-10-31-2865-service-marks-stage-pr-ready/design.md]
    • Chosen: One function with a kind parameter. The body states one function is the only place that decides. A kind parameter keeps the decision in one place and makes the test table simple.
    • Rejected: Separate functions per kind. Rejected because the body requires one function. Separate functions would split the decision and make the evaluator seam harder to add.
  • Where does the function live in the codebase?: In implement_pull.py, alongside the existing mark_ready function, so that both the Service and the CLI import it from one module. (best practice) [sources: openspec/changes/archive/2026-10-31-2865-service-marks-stage-pr-ready/design.md:19]
    • Chosen: implement_pull.py alongside mark_ready. The existing mark_ready is already in this module. The Service and the CLI both import from it. No new file is needed.
    • Rejected: A new pr_readiness.py module. Rejected because it adds a new file for one function and splits the PR readiness logic across two modules.
  • What does complete mean for each kind?: stage_plan: complete when the PR is opened. implement: complete when every task group is ticked and the change is archived. agent: complete when the author says so. person: complete when the author says so. [sources: openspec/changes/archive/2026-10-31-2865-service-marks-stage-pr-ready/proposal.md]
  • How does the evaluator feat(roadmap): Add a draft PR evaluator for issue and rules #2867 plug into the function?: The function accepts an optional list of additional check callables. The evaluator adds its alignment check to that list. The function runs all checks and returns refuse if any fails. (best practice) [sources: openspec/changes/archive/2026-10-31-2865-service-marks-stage-pr-ready/design.md]
    • Chosen: Optional list of check callables in the function signature. The body says the evaluator plugs into this function. An optional list is a clean seam that adds no coupling. The function stays the single decision point.
    • Rejected: The evaluator calls the function and adds its own check after. Rejected because it splits the decision into two places. The body requires one function as the only place that decides.
  • What does devops pr check-readiness print for a refused implement PR?: It prints the status refuse and the name of the unticked task group. It exits with a non-zero code. (best practice) [sources: openspec/changes/archive/2026-10-31-2865-service-marks-stage-pr-ready/proposal.md]
    • Chosen: Print the unticked group name and exit non-zero. The body says the partial PR would be refused with the group named. A non-zero exit lets a script or hook block the merge.
    • Rejected: Print a generic refuse message and exit non-zero. Rejected because the body requires the group to be named so the developer knows what to fix.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    status/new
    value/high
    effort/medium
    on Oct 31, 2026
  2. dan-petty commented on Oct 31, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It prevents a known incident (partial PR #2801 merged) but is not blocking other work.
    • Value: High. A single decision point stops partial pull requests from merging and makes readiness consistent for all four kinds.
    • Effort: Medium. One function with four cases, one CLI command, and a test table; the logic is specified but must be wired into three callers.
    • Related: feat(roadmap): Define one shared workflow for all roadmap actors #2908, which asks for a different change. Both are pieces of the one-issue-workflow; #2908 is the umbrella, the candidate is the readiness-decision function within it.
  3. added
    priority/p2-medium
    on Oct 31, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 1, 2026
  5. devops-cli-service commented on Nov 1, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 66ed3bf (see proposed design in issue body).

  6. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Staged: branch feat/2916-one-function-decides-when-any-draft, draft pull request #3170. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Add the readiness function and its table test: 6361 tokens
    2. Route the stage row through draft_readiness: 6316 tokens
    3. Route the implement job through draft_readiness: 6318 tokens
    4. Block check-readiness on a refused implement pull request: 6324 tokens

    The plan run made 15 model request(s), and used 439653 input tokens and 7272 output tokens. The tool calls, in order:

    1. search_code({"text":"mark_ready"})
    2. search_code({"text":"ready_to_mark"})
    3. list_files({"directory":"src/devops_cli/roadmap"})
    4. read_file({"path":"src/devops_cli/roadmap/implement_pull.py"})
    5. read_file({"path":"src/devops_cli/roadmap/stage_ready.py"})
    6. search_code({"text":"pr ready"})
    7. search_code({"text":"def mark_ready"})
    8. search_code({"text":"check-readiness"})
    9. search_code({"text":"def pr_ready"})
    10. list_files({"directory":"src/devops_cli/commands"})
    11. read_file({"path":"src/devops_cli/commands/pr.py"})
    12. read_file({"path":"src/devops_cli/roadmap/implement_pull.py","start_line":100,"end_line":200})
    13. search_code({"text":"check_readiness"})
    14. search_code({"text":"def ready"})
    15. search_code({"text":"plan_pr_ready"})
    16. read_file({"path":"src/devops_cli/commands/pr.py","start_line":1220,"end_line":1320})
    17. read_file({"path":"src/devops_cli/commands/pr.py","start_line":1440,"end_line":1560})
    18. read_file({"path":"src/devops_cli/github/pr_plans.py","start_line":180,"end_line":380})
    19. list_files({"directory":"src/devops_cli/roadmap"})
    20. list_files({"directory":"tests/roadmap"})
    21. read_file({"path":"src/devops_cli/roadmap/implement_pull.py"})
    22. read_file({"path":"src/devops_cli/roadmap/stage_ready.py"})
    23. search_code({"text":"mark_ready"})
    24. search_code({"text":"check-readiness"})
    25. search_code({"text":"check_readiness"})
    26. read_file({"path":"src/devops_cli/commands/pr.py","start_line":1440,"end_line":1560})
    27. read_file({"path":"src/devops_cli/github/merge_readiness.py"})
    28. search_code({"text":"mark_ready"})
    29. search_code({"text":"from devops_cli.roadmap.implement_pull import"})
    30. search_code({"text":"mark_ready("})
    31. read_file({"path":"src/devops_cli/roadmap/implement_run.py","start_line":1,"end_line":120})
  7. added 2 commits that reference this issue on Nov 2, 2026
  8. added
    status/planned
    and removed
    status/ready
    on Nov 2, 2026
  9. added
    status/in-review
    and removed
    status/planned
    on Nov 3, 2026
  10. removed
    status/in-review
    on Nov 3, 2026
  11. devops-cli-service commented on Nov 3, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-03 13:34 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/p2-mediumscope/roadmapsource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions