Skip to content

Restrict comparison to pathways sharing a sector #953

Description

@jacobvjk

From Alex's review on #936:

Hard restriction: cannot compare one sector to another

A comparison needs at least one sector in common; without one there is no shared sector axis for the page to scope by.

Where it belongs

Enforcement is at selection time, in PathwayCard — the only place a pathway is added to the tray — plus a guard on ComparisonPage for a hand-edited or stale ?ids=, which is read straight from the query string and validated only for existence.

Not in ComparisonContext.addToComparison: that context is deliberately data-free, and ComparisonContext.test.tsx adds ids "a"–"d" that exist in no metadata, so a guard there would need pathwayMetadata plus an unknown-id tolerance clause purely to keep the existing tests green.

loadFromSession does need to clear a restored selection that is provably incompatible, or a set stored before the rule existed comes back with Compare enabled.

Two things to get right

  • Intersect the whole running set, not pairwise against the first. With three pathways, A∩B ≠ ∅ and A∩C ≠ ∅ does not imply A∩B∩C ≠ ∅.
  • Missing sector data is not a clash. sectors is schema-required but carries no minItems, so sectors: [] is valid data. It must read as unknown, never as incompatible — a data gap must not look like a rule. Same for an id that resolves to no pathway.

Unverifiable against current data

All seven loadable pathways declare Power, so every pair shares at least three sectors and the restriction cannot fire in the running app today. It becomes reachable as the 49 v1 pathways migrate (#858). Until then it is provable only by fixture, and the code should say so or someone will read the branch as dead.

Note this touches PathwayCard and ComparisonContext rather than the comparison page itself.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions