Skip to content

feat(github): pr readiness requires an issue-linked, completed task file #704

Closed

Description

@dan-petty

Context & Rationale

AGENTS.md says every change must be grounded in an issue and recorded in a task file. Nothing checks either rule:

  • AGENTS.md:167-172 grounds every change in an issue. AGENTS.md:121 and :174-175 give each item a task file, docs/agent/tasks/task-<issue>-<slug>.md.
  • AGENTS.md:72 and :185 require two things in the delivering commit: every box in that file ticked (- [x]) and "verification results recorded".
  • tests/test_agent_task_files.py:31-35 checks only three things: the issue link, that there is no **PR** field, and the status value.
  • _evaluate_pr_blockers (commands/pr.py:1422-1466) checks mergeability, draft state, check runs and review threads. It never reads the PR body's issue link, and it never checks whether the PR carries a task file. The changed-file read (_fetch_pr_changed_files, :1392) only feeds a warning (:1404), and it returns [] on any failure.
  • GitHub acts on a closing keyword only when a PR targets the default branch (github/issue_closure.py:1-11). Item PRs target release/*, so the body's Closes #N is the only link. extract_linked_issues (:100) parses it exactly as gh issues close-merged acts on it (:241-299). It strips code and quoted lines (strip_non_prose, :88-97), but not HTML comments.
  • devops pr check-readiness is what agents run before they merge. No workflow runs it, and GitHub does not require it.
  • run_gh pages a --paginate request itself (github/rate_limiter.py:1580-1624). It stops at the first page shorter than the endpoint's per_page, and assumes 100 when the URL sets none (:1499-1506, :1575). pulls/{n}/files returns 30 per page by default, so without ?per_page=100 the read ends after 30 files. PR fix(k8s): restore kubernetes cpu metrics and align monitoring dashboards to homelab-k3s (#737) #738 changed 51.

Measured over the 41 PRs merged into release/v0.2.24. Method: gh pr list --state merged --base release/v0.2.24 --limit 100 --json number,body,files,mergeCommit, with bodies scored by extract_linked_issues and task files read at each merge commit.

At ef21785, 16 task files hold - [ ] outside code fences:

Most of these lines are stale process steps (for example "Open Draft Pull Request targeting release/v0.2.17") or criteria nobody ticked. Fixing them means editing other items' files. AGENTS.md:175 and docs/agent/tasks/README.md:9 let a topic branch edit only its own task file. AGENTS.md:177 allows task-file edits only in the PR that delivers that item.

The PR template asks authors to tick things they cannot verify:

The release PR body does the same: _build_quality_checklist (commands/release.py:922-934) ticks all seven of its boxes on every non-draft release PR without reading anything.

Scope & Deliverables

Deliverable:

  • Readiness blocker. _evaluate_pr_blockers gains one grounding check, on by default. It runs in this order:
    1. The release PR is exempt: head release/vX.Y.Z from the same repository, base the repository's default branch. All three come from the REST payload readiness already fetches (_fetch_pr_details, commands/pr.py:212). There is no --allow-ungrounded flag.
    2. One run_gh read of repos/{owner}/{repo}/contents/docs/agent/tasks at the base SHA:
      • A 404 means the repository does not use task files, and the check reports nothing.
      • Any other error is a blocker that names it.
    3. The PR body names exactly one issue, as parsed by extract_linked_issues(body, "<owner>/<repo>").
    4. The PR's changed files include docs/agent/tasks/task-<N>-*.md for that issue. The file must be added, modified or renamed, not removed. The number is parsed as an integer, so task-089-*.md matches feat(k8s): centralized kubernetes logging stack and LogQL integration #89.
    • Each failure is one blocker that says what is missing.
    • The check-readiness docstring names the new blocker. The generated docs are refreshed with devops docs generate.
  • Changed-file reader. One fail-closed reader:
    • It calls gh api --paginate repos/{owner}/{repo}/pulls/{n}/files?per_page=100 through run_gh, and returns each filename with its status. The per_page=100 is required: without it run_gh's pager stops after 30 files.
    • When the grounding check applies, a failed read is a blocker that names the failure. When it does not (the release PR, or a base without docs/agent/tasks/), a failed read prints a warning and does not block.
    • It replaces _fetch_pr_changed_files. The perimeter warning uses the same list, so readiness reads the files once per run.
  • Completed task file.
    • tests/test_agent_task_files.py also asserts that a task file holds no unchecked box (- [ ] or * [ ], at any indent) outside fenced code blocks. The test owns this rule. It does not import the task parser in github/projects.py.
    • Work that was not done is a plain bullet naming its follow-up issue.
    • A check only a person can run is a plain bullet starting "Pending a person:", followed by the exact commands.
    • Fix every task file the new assertion fails on at the PR's base: the 16 listed above at ef21785, plus any merged since.
  • Rule text. AGENTS.md:72, :175 and :185, and docs/agent/tasks/README.md:9 and :49-55, all say the same thing:
    • A box is ticked only for work that is done.
    • Unfinished work and person-run checks are plain bullets.
    • Verification is the PR's passing checks, which readiness reads. Typed pass counts and coverage figures are not required.
    • A PR that changes a rule every task file follows brings the existing files into line. This is the one exception to editing only your own task file.
  • PR template. Cut .github/pull_request_template.md down to what no check decides: summary, type of change, base branch, a Closes #<issue> placeholder and the task-file path. Remove the whole quality-gate checklist (:23-39) and the :44 example. No example issue number appears anywhere in the template, comments included.
  • Release PR body. Remove _build_quality_checklist and its call (commands/release.py:949).
  • Write this item's task file in its final form. Today task-704-*.md is a stale Backlog stub that names v0.2.24. If feat(github): github-sourced roadmap, migration and generated roadmap view (devops roadmap migrate, render) #739's task-file split-off has already deleted it, create it.

Acceptance criteria:

  • Grounding blocker tests live in tests/test_pr_cmd.py, stub run_gh, and are verified by uv run pytest tests/test_pr_cmd.py -k grounding:
    • A PR into release/v0.2.25 whose body says Closes #704, and whose files include a modified docs/agent/tasks/task-704-x.md, gets no grounding blocker.
    • Each of these cases gets exactly one grounding blocker that names the cause:
    • task-089-x.md satisfies Closes #89.
    • These get no grounding blocker:
      • head release/v0.2.25 into main, the default branch;
      • the same with a failing file read, which prints one warning.
    • These are blocked:
      • head feat/x into main;
      • head release/foo into main;
      • head release/v0.2.25 from another repository into main.
    • A base branch without docs/agent/tasks/ (a stubbed 404) gets no grounding blocker, even when the file read also fails. Any other error from that lookup blocks.
    • The reader's argv is exactly gh api --paginate repos/<owner>/<repo>/pulls/<n>/files?per_page=100.
  • A pager test drives run_gh's own pagination, with run_subprocess stubbed as at tests/test_github_rate_limiter.py:611:
    • Page 1 returns 100 files, and page 2 returns docs/agent/tasks/task-704-x.md.
    • The reader returns all 101 entries, and the PR gets no grounding blocker.
  • The existing readiness tests (the _blockers helper at tests/test_pr_cmd.py:1655 and the CLI cases from :940) stub the new reads and still pass.
  • tests/test_agent_task_files.py passes over every task file. Cases built from literal text show:
    • - [ ], an indented - [ ] and * [ ] outside a fence each fail;
    • a - [ ] inside a fence passes.
  • Template tests:
    • The checkbox lines of .github/pull_request_template.md are pinned to the six type-of-change lines.
    • The template contains Closes # and docs/agent/tasks/task-.
    • extract_linked_issues over the template text returns nothing.
    • rg -n -i 'complexity|coverage|quality gate|10/10' .github/pull_request_template.md returns nothing.
  • tests/test_release.py (:882-890, :918-920) asserts that the release PR body has no checkbox line.
  • rg -n 'verification results recorded' AGENTS.md docs/agent/tasks/README.md returns nothing.
  • uv run devops ci passes. The new and changed tests run offline and add at most 1 s in total, shown by uv run pytest tests/test_pr_cmd.py tests/test_agent_task_files.py tests/test_release.py tests/test_github_rate_limiter.py --durations=0.
  • Person-run check, read-only against live GitHub, once the PR is open:
    • uv run devops pr check-readiness <this PR> shows no grounding blocker.
    • uv run devops pr check-readiness <an open PR that closes no issue> shows exactly one.

Key questions:

Constraint:

Strategic Alignment

Activity

  1. added this to the v0.2.24 milestone on Sep 28, 2026
  2. added
    type/feature
    scope/github
    priority/p2-medium
    on Sep 28, 2026
  3. modified the milestones: v0.2.24, v0.2.25 on Sep 30, 2026
  4. dan-petty commented on Sep 30, 2026

    @dan-petty
    OwnerAuthor

    Revised for the roadmap design (#739-#746): the only --allow-ungrounded exemption is the release PR; the completed-file check reads unchecked boxes instead of a Done status, because #739 removes the **Status** line; the roadmap_sync clause and the #699 coordination note are gone. #740 extends this blocker so a PR's item must belong to the release its base branch names.

  5. dan-petty commented on Oct 2, 2026

    @dan-petty
    OwnerAuthor

    Closed by #929, merged into release/v0.2.25.

    GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by devops gh issues close-merged.

  6. added a commit that references this issue on Oct 3, 2026
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/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions