Fix linked issue comment mirrors and reserved-ID guidance
Fixes #286
Scope
Both halves of this PR are the issue's own requirements: the reserved-ID refusal and its repair are the issue body, and the non-convergent comment mirror on a linked item is the issue's first comment, reproduced below.
Reproduction
On clean pm-rl main at 273a687, the locked PM CLI and pm-github 2026.11.25 imported the same GitHub comment twice. The linked item went from 17 to 18 to 19 comments. The SDK read shortened the stored 1,221-character comment to 253 characters and omitted its trailing GitHub ID marker. On pm-ado main at ce4b8c1, the SDK returned the complete comment and marker. The linked item went from 5 to 6 to 6.
Changes
- Read complete native comments for GitHub issue mirroring and blocker revalidation. Write new mirrors through the native comment operation with the GitHub author and creation time. Recognize existing rows by the trailing GitHub comment ID.
- Add a copyable
pm update … --field github_url=…example for an unowned reserved creation destination. Both import command forms use the same ownership guard. Add targeted-import and repair guidance to CLI help and the issue intake guide.
Verification
- On the released failing pm-rl fixture, the packed fix went from 17 to 18 to 18 and stored
2026-11-24T18:15:04Z. The second import reported zero imports and updates. The item and its history were byte-identical. The packed npm and Bun consumers repeated the same result against the captured public responses. - Six focused regressions and the packed minimum SDK test passed. Rebuilding the reverted behavior in a disposable checkout reproduced the duplicate comment, missing repair and missing help. Reverting only the timestamp factory or the blocker comment read failed the corresponding regression.
- Targeted Node run passed 1,445 tests across 57 files with zero skips. The final comment-path recheck passed 26 tests. Typecheck, test compilation, lint, changelog, docstrings, duplication, ownership inventory and privacy passed. Privacy audited 10,600 Git objects.
Round 1 fixes (re-review findings)
- The reserved-ID repair command now replays the failing invocation's typed tracker selector (
pm --pm-path <selector> update …), so a copy made in another directory cannot link a same-ID item in that directory's tracker. The same rule was applied to the comment mirror's release guidance and the webhook reconcile recovery hint, the two other commands this package renders from a failing tracker-scoped invocation. - The link offer is kept only when the refused item's claims after the link are exactly the target issue (evaluated with the shared ownership-claims machinery the next import uses). A reserved item whose
github_numberorgithub_repocontradicts the link keeps the plain refusal, so the offered repair can never create contradictory ownership. - The mirror validates each source comment timestamp before writing; a missing or unparseable time is counted failed and retried on the next sync, never stored and skipped by comment id.
Each finding has a regression that fails on a behavioral revert of only its fix (revert proofs are recorded in the tracker item), including a two-tracker adversarial test that copies the offered command into a second workspace holding a same-ID decoy item and proves only the failed import's tracker is updated.
Round 2 fixes (non-blocking findings)
- A new strict RFC 3339 parser (
source-time.ts) admits only real calendar moments: impossible dates (2026-02-30), non-leap February 29 and free-form rollovers (February 31, 2026) are refused before any write by both persistence paths that store provider times — the native comment mirror and the importer's source-lifetime gate — while real leap days stay importable. Reverting either guard fails its regression. - The repair guidance now states its own copy-safety limits: a typed selector repeats and stays relative to its directory, an implicit selection keeps the copy bound to the same shell, and only an absolute selector is safe from any directory. The docs test pins the qualified wording.
- The atomic rethrow finding was re-verified rather than changed: the SDK's expected-error factory mirrors
context.codeonto a top-levelcode(pinned SDK and the declared 2026.10.23 floor), so the wrapped repair refusal keeps its typed code through both atomic rethrow guards. A new deterministic mid-transaction regression (the reserved item appearing inside the injected atomic commit) proves the surfaced refusal keeps the repair — and fails if that code is ever stripped, which was the finding's premise.
Tracker item pm-github-github-ee4d59c27b67-286.
Summary by Sourcery
Make linked GitHub imports converge reliably while providing safe, tracker-scoped guidance for reserved-ID ownership conflicts.
New Features:
- Add safe, copyable repair guidance for reserved GitHub IDs and targeted issue imports, including tracker-scoped recovery commands.
- Preserve GitHub comment authors and creation timestamps when mirroring comments to linked items.
Bug Fixes:
- Prevent duplicate or truncated mirrored comments by reading complete native comment data and deduplicating on trailing GitHub comment ID markers.
- Reject malformed or impossible GitHub timestamps instead of persisting invalid dates or treating failed comment writes as synchronized.
- Withhold reserved-ID link suggestions when existing provenance contradicts the target issue.
Enhancements:
- Propagate the failing invocation's tracker selector into rendered repair, release, and webhook recovery commands.
Documentation:
- Document how to start work on a GitHub issue, repair reserved-ID refusals, and safely mirror comments on linked items.
Tests:
- Add regression coverage for idempotent linked imports, reserved-ID repairs, tracker isolation, timestamp validation, comment deduplication, and recovery guidance.
Chores:
- Update the ownership inventory for the new reserved-ID repair path.
Summary by cubic
Fixes #286. GitHub issue imports on linked items now mirror comments completely and idempotently, and reserved-ID ownership refusals name an executable repair.
Bug Fixes
- Comment mirrors read the native annotation store instead of the SDK projection, preserving full text and trailing GitHub ID markers; new mirrors write through the native comment operation and keep the GitHub author and creation time.
- Source timestamps must parse as a real RFC 3339 moment before any write; impossible or rolled-over dates fail retryably instead of persisting, and sub-second fractions are trimmed to milliseconds to match the engine's read.
New Features
- Reserved-ID refusals now include a copyable
pm update … --field github_url=…command when the destination is unowned and post-link claims are exactly the target issue; rendered commands replay the failing invocation's tracker selector. - CLI help and the issue intake guide document targeted single-issue imports (
pm github import <owner>/<repo> --issue <N>).