lacuna-tech / mds-core

Repo for LADOT MDS implementation for contribution to the Open Mobility Foundation
Apache License 2.0
13 stars 9 forks source link

API: How to retrieve the current active policies #939

Open mrsimpson opened 2 years ago

mrsimpson commented 2 years ago

Motivation

When visualizing the currently effective regulations of an agency, all policies which are not superseeded are relevant.

Problem

As per the specification, all published policies are immutable. Versioning and outdating superseeded policies is achieved by publishing a new policy, which holds the prev policies as a reference. While this is technically elegant (as the previous policy is really immutable and not even it's state is manipulated after publishing), it's cumbersome as a consumeras per the MDS policy read api, there is no option to retrieve only those policies which are not referenced as a prev policy by another one.

Ideas

It was nice if there was a transient state which could be queried for. This enum value would then internally get transformed to a query which in-/exludes the policy from prev. policies. While this sounds simple at first, it gets a bit tricky in detail: Both the information, whether a policy is published or "active" (not superseeded) depends on the point in time which is used to look at the states. Is there already a solution for that or does it need to be added to the implementation (and spec, yay!)?

avatarneil commented 2 years ago

Hi @mrsimpson, so funnily enough.. I'm pretty sure the current implementation in mds-core of the mds-policy-api actually does filter for only active policies within the queried time range. We ran into the exact same issue a couple years ago. Note, this behavior is a little out of spec; however, we haven't heard anyone complain about this additional filtering we've applied, and historical policies are still accessible by direct UUID lookup.

This could very well be something that should get promoted to spec level as a query parameter, though!