SDK context integrity and merge truth

Merged
UN
3mo ago
+1222-236

Summary

  • expose notes_count in token-bounded get/show projections while keeping deep/full note payloads backward compatible
  • promote alias-aware relationship edge validation into the public SDK and enforce self-edge policy before CLI create/update persistence
  • classify merge reconciliation by net outcome so append unions and reorderings preserve context without false data-loss warnings
  • document the new SDK and merge-safety contracts, generate the changelog through pm-changelog, and record rich tracker lineage

Why

Project management is context management. Agents need compact reads that disclose omitted context, mutation primitives that prevent invalid graph state, and merge diagnostics that stay loud only when context is genuinely lost.

Tracked work

  • pm-3esl28 — truthful omitted-note counts
  • pm-k9t17l — SDK relationship mutation integrity
  • pm-mmm9o5 — loss-aware merge reconciliation
  • pm-ds3b — rolling SDK reference

Validation

  • pnpm test:coverage — 6,101 tests; 100% statements, branches, functions, and lines
  • pnpm typecheck
  • pnpm lint — ESLint, zero-clone jscpd, static quality, 100% docstrings, package boundaries, and token budgets
  • docs skills and link validation
  • generated changelog check, secrets/version gates, packed npm smoke, and 88-command dogfood
  • isolated packed-consumer acceptance for CLI and public SDK behavior
  • real two-branch Git merge acceptance retaining both agents' notes with strict history validation

The consolidated release gate is otherwise green; its live Sentry check intentionally remains red on historical issue PM-CLI-2J from release 2026.7.22. This PR fixes that exact pre-persistence self-edge failure. The issue will remain open until the merged release is installed and verified with no recurrence.


Summary by cubic

Adds truthful SDK reads and safer writes: standard-depth get/show now reports omitted note counts, relationship mutations reject self-edges before persistence, and merge reconciliation only warns on real data loss.

  • New Features

    • Standard-depth pm get/show --json returns item.notes_count when notes are omitted; deep/full payloads unchanged. (GH-645)
    • SDK enforces relationship self-edge rules before persistence; CLI create/update reject self blocked_by and alias forms, honoring custom allow-self kinds. (GH-649)
    • Merge reconciliation classifies discards as net-lossless vs net-lossy; unions/reorders keep attribution and avoid false loss warnings; docs updated. (GH-646)
  • Migration

    • Remove any automation that writes self blocked_by edges; these now error before write with a clear message.
    • No changes needed for readers; notes_count is additive.