beads/internal/ado
Vishnu J f3cd47dd90
fix(ado): map parent-child deps to hierarchy links (not Related) (#5129)
* fix(ado): map parent-child deps to hierarchy links (not Related)

beads stores hierarchy as dependency type "parent-child", but the ADO
adapter only matched the unreachable alias "parent". Push therefore
emitted System.LinkTypes.Related and never set System.Parent; pull
wrote the non-canonical "parent" type back into beads.

Map both directions to parent-child (canonical) and keep "parent" as a
push-side alias for safety.

Fixes #4961

* fix(ado): correct hierarchy link direction for parent-child push/pull

The GH#4961 fix renamed the mapped literal to "parent-child" but kept
the old link-type/swap wiring, which pointed the wrong direction on
both sides (review by maphew, PR #5129):

- Push (beadsDepToADORel): the desired set is built from the child's
  own outgoing dependency row (IssueID=child, DependsOnID=parent), so
  PushLinks always runs with workItemID as the child and the target as
  the parent. Emitting RelChild (Hierarchy-Forward) from the child
  asserted the child is the parent's parent, reparenting the target
  backwards on push. Now emits RelParent (Hierarchy-Reverse).

- Pull (adoRelToBeadsDep): the swap flags for RelChild/RelParent were
  inverted relative to beads' child-to-parent storage convention.
  Flipped both so the resulting dep always points child -> parent.

- removableRelTypes now tracks RelParent instead of RelChild, since
  beads owns the Hierarchy-Reverse link on the child after this fix.

Added TestPushLinks_HierarchyDirection and
TestPullLinks_HierarchyChildDirection to pin the emitted/parsed
relation type in each direction; updated existing tests whose fixtures
and assertions encoded the old (backwards) direction.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015AfaSMkMRF5BTzuPNFnqHY

* fix(ado): stop mapping the legacy "parent" dep type to a hierarchy link

DependencyType.IsValid accepts any non-empty string, so "parent"-typed
rows written by the pre-fix pull path really do persist. Both old pull
branches stored them parent -> child, backwards relative to the
convention this PR standardises on, so mapping the alias to RelParent
would assert the child is the parent's parent and reparent real
hierarchies -- the exact corruption this PR fixes, arriving via the
legacy path.

Drop the alias so those rows fall through to RelRelated (inert), where
they have effectively been all along. Retyping and reversing them needs
a migration with its own tests, tracked separately.

Reported by maphew on PR #5129.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 01:45:16 -07:00
..
bootstrap.go feat(ado): add Azure DevOps work item tracker package 2026-03-19 14:34:28 -07:00
bootstrap_test.go feat(ado): add Azure DevOps work item tracker package 2026-03-19 14:34:28 -07:00
client.go fix(ado): use date-only format for WIQL ChangedDate queries (#3345) 2026-04-20 13:05:34 -07:00
client_test.go fix(ado): use date-only format for WIQL ChangedDate queries (#3345) 2026-04-20 13:05:34 -07:00
fieldmapper.go fix: set ADO Severity field for Bug work items during sync 2026-03-30 12:22:26 -07:00
links.go fix(ado): map parent-child deps to hierarchy links (not Related) (#5129) 2026-07-31 01:45:16 -07:00
links_test.go fix(ado): map parent-child deps to hierarchy links (not Related) (#5129) 2026-07-31 01:45:16 -07:00
mapping.go fix: set ADO Severity field for Bug work items during sync 2026-03-30 12:22:26 -07:00
mapping_test.go fix: set ADO Severity field for Bug work items during sync 2026-03-30 12:22:26 -07:00
reconcile.go fix: replace fragile string matching with typed APIError for HTTP status checks 2026-03-30 20:28:13 -07:00
reconcile_test.go feat(ado): add Azure DevOps work item tracker package 2026-03-19 14:34:28 -07:00
richtext.go feat(ado): add Azure DevOps work item tracker package 2026-03-19 14:34:28 -07:00
richtext_test.go feat(ado): add Azure DevOps work item tracker package 2026-03-19 14:34:28 -07:00
statetransition.go fix: replace fragile string matching with typed APIError for HTTP status checks 2026-03-30 20:28:13 -07:00
statetransition_test.go fix(ado): create work items in initial state then transition to target 2026-03-30 12:25:32 -07:00
tracker.go fix(trackers): route secret keys through config.yaml in all tracker getConfig methods 2026-05-15 09:07:12 -07:00
tracker_test.go fix(trackers): route secret keys through config.yaml in all tracker getConfig methods 2026-05-15 09:07:12 -07:00
types.go fix: set ADO Severity field for Bug work items during sync 2026-03-30 12:22:26 -07:00
types_test.go feat(ado): add Azure DevOps work item tracker package 2026-03-19 14:34:28 -07:00