fix: route closed-issue imports through pm close for pm-cli 2026.8.3

Merged
UN
4mo ago
+412-56

Summary

pm-cli 2026.8.3 enforces governance.require_close_reason: pm create --status closed and pm update --status closed are now hard close_reason_required errors. The old 2026.7.29 bypass that silently auto-routed these and defaulted a close reason is gone. This package relied on that bypass in one path.

Root cause

runImport (non-atomic create path) created new closed GitHub issues with pm create --status closed, so importing a not-yet-known closed issue failed under the enforced policy. The atomic path and the re-import reconciliation path were already correct (they route closure through pm close --reason); only the plain create path used the now-broken invocation.

Changes

  • index.ts — the create path now creates a closed upstream issue as open, then closes it via pm close --reason "GitHub issue #N closed", mirroring the atomic and reconciliation paths.
  • Provenance timestamps — thread GitHub closed_at through GhIssue → PreparedGithubImport → every close site (create path, reconciliation, and the atomic close mutation) as --completed-at / completedAt, so imported items keep their real completion time instead of the import time. The reason stays factual provenance; no outcome is fabricated.
  • test/handler-failures.test.ts — the createLinkedItem fixture used the same pm create --status closed pattern to build a closed linked item; switched to create-then-close so the fixture is still a genuinely closed item under the enforced policy, without changing what the tests assert.
  • Pins @unbrained/pm-cli at ^2026.8.3 (peer >=2026.8.3).

pm item

Gates

gateresult
npm run typecheckpass
npm run buildpass
npm test239/239 pass (incl. the two previously-failing tests)
npm run coveragepass — index.ts 88.83% lines / 80.15% branches / 89.94% functions (thresholds 88/79/89)
npm run changelog:checkup to date

No governance policy, lint rule, or coverage threshold was weakened.

Summary by Sourcery

Route imports of closed GitHub issues through explicit pm close operations and preserve source completion timestamps under the updated pm-cli governance policy.

Bug Fixes:

  • Fix non-atomic GitHub issue imports that previously tried to create items born closed, which now violate pm-cli close-reason governance constraints.

Enhancements:

  • Thread GitHub closed_at into PreparedGithubImport and pm close mutations so imported items retain their original completion time instead of the import time.

Build:

  • Update peer and dev dependency pins to require pm-cli 2026.8.3 in line with the new close-reason enforcement.

Tests:

  • Adjust linked-item test fixtures to create items open and then close them via pm close so closed-status tests remain valid under the new governance rules.

Chores:

  • Record the pm governance item history and spec files related to this change in the repository.

Summary by cubic

Fixes imports of closed GitHub issues and project items under @unbrained/pm-cli 2026.8.3 by creating items open, then closing via pm close --reason with --completed-at. Also fixes id parsing so create‑then‑close reliably closes the new item.

  • Bug Fixes

    • Route all closures through pm close --reason; pass GitHub closed_at as --completed-at.
    • Project import: omit --status closed on create/update; close after with a provenance reason.
    • parseCreatedItemId now reads the flat { id } from pm create --json (drops the unused { item.id } shape).
    • Create path: if the new id can’t be parsed, count as skipped and don’t report a successful import; share a single close-argv builder to keep reason and timestamp consistent.
    • Tests: switch fixtures to create‑then‑close; add a contract test for the real pm create --json envelope and an end‑to‑end closed‑issue import that asserts the item lands closed.
  • Dependencies

    • Pin @unbrained/pm-cli to ^2026.8.3 (peer >=2026.8.3).