Design and Implement an Attack-Path Graph Domain
Model infrastructure assets and typed relationships, then validate and construct traversable attack paths.
For this exercise, model an infrastructure graph containing generic assets, virtual machines, databases, and typed directed relationships. Each asset and relationship carries a declared criticality, and each returned attack path carries a severity derived only from the ordered path and those declared values.
The severity rule must be able to evolve without changing graph validation or traversal. A path is an ordered list of asset identities.
Support registering assets and relationships, validating whether a proposed path follows existing directed relationships without repeated assets, and finding one valid path between two assets when it exists. Reject unknown identities, duplicate identities, self-relationships, and malformed relationships explicitly.
Return immutable path results and keep graph state consistent after every rejected mutation. Design the objects and interfaces, walk through validation, then implement the core with tests.
Preserve criticality and severity as explicit domain values, but exclude inventing a vulnerability-risk formula, authorization, distributed storage, and exhaustive enumeration of every path.