Close pm items delivered by merged pull requests with verifiable GitHub evidence
After a pull request merges, delivered pm items remain open until an agent performs manual tracker cleanup. This adds pm github closeout: a dry-run plan by default, with explicit SDK writes through --apply.
Select repeatable --pr numbers or an inclusive ISO --since cutoff, using the existing repository/token resolution. Canonical same-repository tracker links select items, including encoded names and nested SDK folders. Foreign links, unknown ids, terminal items and repeatable --skip exclusions produce explicit skip rows. All API planning finishes before writes, and overlapping PR references close an item once.
Head evidence combines readable requirements from classic protection and active rulesets, preserving app bindings and legacy statuses across complete pagination. Every known required context must succeed. Permission/not-found gaps add an explicitly labeled fallback requiring completed success/neutral/skipped head runs and successful latest statuses; fallback never discards a readable requirement. Missing or malformed evidence and other authorization failures skip closure. Close reasons contain only PR number/URL, merge SHA, head SHA, merge time and successful check names; PR prose never enters the tracker.
Before: an agent had to maintain private cleanup scripts. After: pm github closeout --repo owner/repo --pr 42 --json previews the stable plan that --apply executes. Repeating the completed selection makes no tracker writes. The README documents the output, policies and agent flow; pm-changelog generates the entry. The reusable sync workflow and its inputs are unchanged. Optional bot-branch automation remains follow-up item pm-github-0x3y.
Validation:
- Focused HTTP/real-tracker acceptance: 64/64 passed, including packed CLI TOON/JSON output, SDK custom folders, exclusions, privacy and byte-identical dry-run/repeat behavior. Exact 100/100/100/100 coverage of
closeout.ts. - Behavioral guard reverts: removing only the required-success rejection in
checkCloseoutHeadfailed its regression 1/1; removing only the terminal-item branch inrunCloseoutfailed the repeat regression 1/1. Restoring the source passed both 2/2. These regressions import source directly. pm test pm-github-t4i2 --run --progress: 1/1 linked commands passed. Native Bun registration and custom-folder SDK acceptance: 2/2 passed.env HOME=$(mktemp -d) GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 npm run release:checkand the equivalentbun run release:check: both passed 654/654 tests, zero failed/skipped/canceled/TODO, exact 100/100/100/100 coverage across all 13 authored modules, zero production vulnerabilities, and all release checks passed.- Both full gates use isolated Git identity and bounded file-worker concurrency; every test, deadline, source inventory and threshold is unchanged. The existing synthetic watchdog startup flake is tracked separately as
pm-github-sah1. npm run changelog:fullandnpm run changelog:check: passed.
Delivered item: https://github.com/unbraind/pm-github/blob/main/.agents/pm/features/pm-github-t4i2.toon
Summary by Sourcery
Add verified merged-pull-request closeout for pm items, with dry-run planning by default and explicit tracker writes through --apply.
New Features:
- Add
pm github closeoutto identify tracker items delivered by merged pull requests and produce a stable dry-run plan or apply verified closures.
Bug Fixes:
- Prevent unsafe or unsupported closures by rejecting incomplete merge data, failed or ambiguous head evidence, terminal items, open-child items, epics, and non-delivery mentions.
Enhancements:
- Support pull-request and inclusive merge-time selection, repository and token resolution, canonical same-repository links, exclusions, idempotent reruns, explicit skip reasons, and privacy-safe close reasons based only on verified GitHub facts.
- Combine classic protection, ruleset, check-run, and legacy status evidence with conservative labeled fallback handling and complete pagination.
Documentation:
- Document the closeout command, selection and evidence policies, output format, and agent workflow in the README.
Tests:
- Add comprehensive HTTP-boundary, SDK mutation, CLI packaging, pagination, evidence-validation, privacy, idempotency, and custom-folder acceptance coverage.
Chores:
- Record the delivered feature and related follow-up/watchdog items in the project-management history and changelog.
Summary by cubic
Adds pm github closeout so delivered pm items close using verifiable merged-PR evidence instead of manual tracker cleanup.
Behavior
- Dry-run by default;
--applywrites through the existing SDK, and re-running a completed selection writes nothing. - Items are selected by same-repository tracker links from repeatable
--prnumbers or an inclusive--sincecutoff, which stops paging once a row predates the cutoff; foreign links, unknown ids, terminal items, and repeatable--skipids produce explicit skip rows. - Only claimed items (
in_progress) or links preceded by a closing keyword (Closes, Fixes, Resolves, Delivers) close. The keyword binds to its link by scanning backward with only earlier links, commas, or "and" in between, so "Not fixed here; see <link>" cannot close a follow-up. Epics and items with open children never close, and every refusal gets a skip row naming the rule. - Failures map to
CommandError(usage exit 2 for selector/repository errors, exit 1 otherwise) so the host never re-runs the handler.
Evidence
- Head checks combine classic protection and active rulesets, with a labeled fallback only when permission gaps hide required context; the fallback never discards a readable requirement.
- Close reasons record PR number/URL, merge SHA, head SHA, merge time, and successful check names only; PR prose never enters the tracker.