Skip to content

Commit 29f6a21

Browse files
authored
Merge pull request #928 from openmobilityfoundation/feature-policy-realtime
Real-time Policy Improvements and Clarifications
2 parents 9b3a610 + a343752 commit 29f6a21

3 files changed

Lines changed: 73 additions & 1680 deletions

File tree

policy/README.md

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<a href="/policy/"><img src="https://i.imgur.com/66QXveN.png" width="120" align="right" alt="MDS Policy Icon" border="0"></a>
44

5-
The Policy API endpoints are intended to be implemented by regulatory agencies and consumed by mobility providers. Providers query the Policy API to get information about local rules that may affect the operation of their mobility service or which may be used to determine compliance.
5+
The Policy API endpoints are intended to be implemented by regulatory agencies and consumed by mobility providers across all supported MDS [modes](../modes#list-of-supported-modes) and services (scooters, bikeshare, car share, delivery robots, taxis, TNCs, autonomous vehicles, agency fleets, commuter shuttles, etc). Providers query the Policy API to get information about local rules that may affect the operation of their mobility service or which may be used to determine compliance.
66

77
This specification describes the digital relationship between _mobility as a service_ providers and the agencies that regulate them. The Policy API communicates municipal policies (such as as vehicle deployment caps and speed limits) in a clear, consistent manner.
88

@@ -37,12 +37,12 @@ This specification describes the digital relationship between _mobility as a ser
3737
- [Messages](#messages)
3838
- [Value URL](#value-url)
3939
- [Order of Operations](#order-of-operations)
40+
- [Policy Relationship Diagram](#policy-relationship-diagram)
4041
- [Requirement](#requirement)
4142
- [Examples](#examples)
4243
- [Public Hosting](#public-hosting)
4344
- [Update Frequency](#requirement-update-frequency)
4445
- [Version Tracking](#version-tracking)
45-
- [Beta Limitations](#beta-limitations)
4646
- [Format](#requirement-format)
4747
- [Metadata](#requirement-metadata)
4848
- [Programs](#requirement-programs)
@@ -57,35 +57,39 @@ The following information applies to all `policy` API endpoints.
5757

5858
### Background
5959

60-
The goal of the Policy API specification is to enable agencies to create, revise, and publish machine-readable policies, as sets of rules for individual and collective device behavior exhibited by both _mobility as a service_ providers and riders / users. [Examples](./examples/README.md) of policies include:
60+
The goal of the Policy API specification is to enable public agencies to create, revise, and publish machine-readable policies (in near real-time if needed), as sets of rules for individual and collective device behavior exhibited by both _mobility as a service_ providers and riders / users. [Examples](./examples/README.md) of policies include:
6161

6262
- City-wide and localized caps (e.g. "Minimum 500 and maximum 3000 scooters within city boundaries")
6363
- Exclusion zones (e.g. "No scooters are permitted in this district on weekends")
6464
- Cap allowances (e.g. "Up to 500 additional scooters are permitted near train stations")
6565
- Speed-limit restrictions (e.g. "15 mph outside of downtown, 10 mph downtown")
6666
- Idle-time and disabled-time limitations (e.g. "5 days idle while rentable, 12 hours idle while unrentable, per device")
6767
- Trip fees and subsidies (e.g. "A 25 cent fee applied when a trip ends downtown")
68+
- Real-time emergency notifications (e.g. "A no travel geofence around a fire reported by a 911 call")
69+
- Large event policy rules (e.g. "No AVs or carshare near a planned stadium event, but 25 cent bikeshare subsidy when trips end near event")
6870

6971
The machine-readable format allows Providers to obtain policies and compute compliance where it can be determined entirely by data obtained internally, and know what data is required from them and provided to them.
7072

7173
[Top][toc]
7274

7375
### Policy Examples
7476

75-
See the [Policy Examples](./examples/README.md) for ways Policy can be implemented.
77+
See the [MDS Policy Examples](https://github.com/openmobilityfoundation/mobility-data-specification/wiki/MDS-Policy-Examples) wiki page for code examples of specific MDS Policy use cases, ideas on how Policy can be implemented.
7678

7779
[Top][toc]
7880

7981
### Authorization
8082

81-
The Policy endpoints should be made public. Authorization is not required.
83+
The Policy endpoints should be made public. Authorization is not required. Agencies may make reasonable accommodations to manage their endpoints, for example, using an API key that has a clear, public way to obtain - this can be useful for rate limiting requests, ensure proper use, tracking access per requestor, and/or customization of the Policy tailored to the requestor.
8284

8385
[Top][toc]
8486

8587
### Update Frequency
8688

8789
The publishing agency should establish beforehand and communicate to providers how frequently the Policy endpoints are expected to change, how often they should be polled to get the latest information, and expectations around emergency updates.
8890

91+
For real-time uses of MDS Policy, public agencies should set a recommended minimum threshold (eg, every 1 minute at most).
92+
8993
[Top][toc]
9094

9195
### Updating or Ending Policies
@@ -110,12 +114,15 @@ Policies shall be published by regulatory bodies or their authorized delegates a
110114

111115
Policies typically refer to one or more associated geographies. Geographic information is obtained from the MDS [Geography](/geography) API. Each policy and geography shall have a unique ID (UUID).
112116

117+
Policies must be unique. A Policy may not have the exact same [Policy](#policy) object field values with a different `policy_id`. For example if the required or optional fields have the same values (either exactly identical or functionally identical), it is considered the same Policy and must not be duplicated as two different policies in the Policy payload.
118+
113119
Geographical data shall be represented as GeoJSON `Feature` objects. No part of the geographical data should be outside the [municipality boundary][muni-boundary].
114120

115121
Policies should be re-fetched whenever:
116122

117123
1. a policy expires (via its `end_date`), or
118124
2. at an interval specified by the regulatory body, e.g. "daily at midnight".
125+
3. when the `last_updated` timestamp is newer than the previously fetched timestamp
119126

120127
Flat files have an optional `end_date` field that will apply to the file as a whole.
121128

@@ -127,7 +134,7 @@ Among other use-cases, configuring a REST API allows an Agency to:
127134

128135
1. Dynamically adjust caps
129136
2. Set Provider specific policies
130-
3. Adjust other attributes in closer to real time
137+
3. Adjust other attributes in close to real-time
131138
4. Enumerate when policies are set to change
132139

133140
Responses must set the `Content-Type` header, as specified in the [versioning][versioning] section.
@@ -159,6 +166,8 @@ _Query Parameters:_
159166
| `policy_id` | UUID | Optional | If provided, returns one policy object with the matching UUID; default is to return all policy objects. |
160167
| `start_date` | [timestamp][ts] | Optional | Beginning date of the queried time range; the default value is the request time |
161168
| `end_date` | [timestamp][ts] | Optional | Ending date of the queried time range; the default value is null, which captures all policies that are effective in the future|
169+
| `last_updated` | Boolean | Optional | If true, the endpoint only returns two fields: `version`, `last_updated`. Useful to quickly check when any data in the file has last been changed, without downloading the entire Policy payload. See the [Schema](#schema) section for an example. If not provided, value is false. |
170+
| `active_only` | Boolean | Optional | If true, return only the current active and future policies, not the retired/previous policies. Any policy that is a prev_policies would not be returned. However, the array of prev_policies still will be returned for reference as part of any relevant active policy. Useful to reduce the Policy payload size for use cases where you do not need to know the previous policy details. If not provided, value is false. |
162171

163172
`start_date` and `end_date` are only considered when no `id` parameter is provided. They should return any policy whose effectiveness overlaps with or is contained with this range. Suppose there's a policy with a `start_date` of 1/1/21 and `end_date` of 1/31/21. Assuming an `end_date` that is null, 12/1/20 and 1/5/21 `start_dates` will return the policy, but 2/10/21 wouldn't. Assuming a `start_date` parameter of say, 11/1/20, then an `end_date` of 12/1/20 wouldn't return the policy, but 1/5/21 and 2/10/21 would. Lastly, a `start_date` of 1/5/21 and `end_date` of 1/6/21 would also return the policy. Please note also that while dates in the format MM:DD:YY are being used here, `start_date` and `end_date` must be numbers representing milliseconds since the Unix epoch time.
164173

@@ -286,6 +295,8 @@ Response bodies must be a `UTF-8` encoded JSON object and must minimally include
286295
}
287296
```
288297

298+
Note that `data` payload will not be returned if the `last_updated` query string parameter is set to true.
299+
289300
### Data Schema
290301

291302
See the [Endpoints](#endpoints) below for information on their specific schema, and the [`mds-openapi`](https://github.com/openmobilityfoundation/mds-openapi) repository for full details and interactive documentation.
@@ -458,6 +469,59 @@ The internal mechanics of ordering are up to the Policy editing and hosting soft
458469

459470
[Top][toc]
460471

472+
### Policy Relationship Diagram
473+
474+
```mermaid
475+
---
476+
title: MDS Policy relationships
477+
---
478+
classDiagram
479+
Policy <|-- Rules
480+
Policy <|-- Previous_Policies
481+
Rules <|-- Rule_Type
482+
Rules <|-- Rule_Units
483+
Rules <|-- Geographies
484+
class Policy {
485+
Name *
486+
Mode ID *
487+
Policy ID *
488+
Description *
489+
Start Date *
490+
Published Date *
491+
Rule IDs *
492+
Provider ID
493+
End Date
494+
Currency
495+
Previous Policy IDs
496+
}
497+
class Rules{
498+
Name *
499+
Rule ID *
500+
Rule Type *
501+
Geographies *
502+
States *
503+
Rule Units *
504+
Vehicle Type
505+
Propultion Type
506+
...
507+
}
508+
class Rule_Units{
509+
Name *
510+
}
511+
class Rule_Type{
512+
Name *
513+
}
514+
class Previous_Policies{
515+
IDs *
516+
}
517+
class Geographies{
518+
IDs *
519+
}
520+
classDef default color:#373737,fill:#2af1be,stroke:#373737,stroke-width:2px;
521+
```
522+
[Top][toc]
523+
524+
461525
### Requirement
462526

463527
A public agency's Policy program Requirements endpoint enumerates all of the parts of MDS, [CDS](https://github.com/openmobilityfoundation/curb-data-specification), GBFS, and other specifications that an agency requires from providers for certain programs, including APIs, endpoints, and optional fields, as well as information for providers about the APIs the agency is hosting. The program requirements are specific to the needs and use cases of each agency, and ensure there is clarity on what data is being asked for in operating policy documents from providers, reducing the burden on both. This also allows additional public transparency and accountability around data requirements from agencies, and encourages privacy by allowing agencies to ask for only the data they need.
@@ -468,7 +532,7 @@ Requirements can also be used to define a scaled-down MDS implementation in situ
468532

469533
#### Examples
470534

471-
See [Policy Requirements Examples](/policy/examples/requirements.md) for ideas on how this can be implemented.
535+
See the [MDS Policy Examples](https://github.com/openmobilityfoundation/mobility-data-specification/wiki/MDS-Policy-Requirements-Examples) wiki page for code examples of specific MDS Policy Requirements use cases, ideas on how Requirements can be implemented.
472536

473537
[Top][toc]
474538

0 commit comments

Comments
 (0)