Skip to content

forward and reverse inherited characteristics#46

Merged
matt-beanland merged 1 commit into
devfrom
10-shelf-on-path
May 21, 2026
Merged

forward and reverse inherited characteristics#46
matt-beanland merged 1 commit into
devfrom
10-shelf-on-path

Conversation

@matt-beanland
Copy link
Copy Markdown
Collaborator

No description provided.

@matt-beanland matt-beanland linked an issue May 21, 2026 that may be closed by this pull request
@matt-beanland
Copy link
Copy Markdown
Collaborator Author

Summary

What landed

Calc modules

  • DiffoExample.Calculations.InheritedCharacteristic — mirrors Diffo.Provider.Calculations.InheritedPlace; traverses incoming AssignmentRelationship by alias, then reads the typed characteristic value from each source instance.
  • DiffoExample.Calculations.ReverseInheritedCharacteristic — dual; traverses outgoing AssignmentRelationship (optionally alias-filtered), reads the typed characteristic on each assignee.
  • DiffoExample.Access.Calculations.ShelfTotalPorts — domain-specific calc summing AssignableCharacteristic.(last - first + 1) across each card a shelf has assigned a slot to.

Resource shape

  • Card — new :shelf calc (brings up shelf characteristic via via: [:slot]) and :slot calc (assigned slot value).
  • Path — new :card calc (via: [:port]), :shelf calc (via: [:port, :slot], two-hop), :port calc (assigned port value).
  • Shelf — new :cards calc (brings up assigned cards in slot order) and :total_ports calc (aggregate).

Tests

  • path_test updated to set aliases on slot and port assignments in create_dslam_with_line_card; new assertions verify path.card, path.shelf, path.port resolve through the two-hop chain.
  • shelf_test adds new "shelf brings up its cards and total_ports" test asserting two cards (48 ports + 24 ports = 72 total) resolve through the outgoing traversal.

Test plan

  • mix test — 49 tests, 0 failures
  • mix format — clean
  • reuse lint — 96/96 files compliant
  • Manual: Ash.load(path, [:card, :shelf, :port]) returns the expected brought-up values through the assignment chain
  • Manual: Ash.load(shelf, [:cards, :total_ports]) returns cards in slot order and the correct port-capacity sum

Notes for reviewers

  • JSON rendering of inherited values isn't included in this PR — that's the diffo#173 yarn. The calcs work at the Ash API level (Ash.load + Ash.read); TMF JSON surfacing waits for the upstream DSL+JSON enhancement so we don't add per-resource customize that becomes dead code.
  • Alias discipline: the assignee names its own slot. Existing tests with multiple unaliased assignments to the same target (e.g. two pairs to one service) work as before; the new path-test scenarios set aliases explicitly because the calcs need them to traverse by name.

@matt-beanland matt-beanland merged commit 806613f into dev May 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

path shelf characteristic

1 participant