| 1 | # Contract In Force Policy Specification |
| 2 | |
| 3 | This document defines an interoperable policy for specifying in force periods for contract agreements. An in force |
| 4 | period can be defined as a __duration__ or a __fixed date__. |
| 5 | All dates must be expressed as UTC. |
| 6 | |
| 7 | ## 1. Duration |
| 8 | |
| 9 | A duration is a period of time starting from an offset. EDC defines a simple expression language for specifying the |
| 10 | offset and duration in time units: |
| 11 | |
| 12 | ```<offset> + <numeric value>ms|s|m|h|d``` |
| 13 | |
| 14 | The following values are supported for `<offset>`: |
| 15 | |
| 16 | | Value | Description | |
| 17 | |-------------------|---------------------------------------------------------------------------------------------------------------------------------------| |
| 18 | | contractAgreement | The start of the contract agreement defined as the timestamp when the provider enters the AGREED state expressed in UTC epoch seconds | |
| 19 | |
| 20 | The following values are supported for the time unit: |
| 21 | |
| 22 | | Value | Description | |
| 23 | |-------|--------------| |
| 24 | | ms | milliseconds | |
| 25 | | s | seconds | |
| 26 | | m | minutes | |
| 27 | | h | hours | |
| 28 | | d | days | |
| 29 | |
| 30 | A duration is defined in a `ContractDefinition` using the following policy and left-hand |
| 31 | operands `https://w3id.org/edc/v0.0.1/ns/inForceDate`: |
| 32 | |
| 33 | ```json |
| 34 | { |
| 35 | "@context": { |
| 36 | "cx": "https://w3id.org/cx/v0.8/", |
| 37 | "@vocab": "http://www.w3.org/ns/odrl.jsonld" |
| 38 | }, |
| 39 | "@type": "Offer", |
| 40 | "@id": "a343fcbf-99fc-4ce8-8e9b-148c97605aab", |
| 41 | "permission": [ |
| 42 | { |
| 43 | "action": "use", |
| 44 | "constraint": { |
| 45 | "and": [ |
| 46 | { |
| 47 | "leftOperand": "https://w3id.org/edc/v0.0.1/ns/inForceDate", |
| 48 | "operator": "gte", |
| 49 | "rightOperand": { |
| 50 | "@value": "contractAgreement", |
| 51 | "@type": "https://w3id.org/edc/v0.0.1/ns/inForceDate:dateExpression" |
| 52 | } |
| 53 | }, |
| 54 | { |
| 55 | "leftOperand": "https://w3id.org/edc/v0.0.1/ns/inForceDate:inForceDate", |
| 56 | "operator": "lte", |
| 57 | "rightOperand": { |
| 58 | "@value": "contractAgreement + 100d", |
| 59 | "@type": "https://w3id.org/edc/v0.0.1/ns/inForceDate:dateExpression" |
| 60 | } |
| 61 | } |
| 62 | ] |
| 63 | } |
| 64 | } |
| 65 | ] |
| 66 | } |
| 67 | ``` |
| 68 | |
| 69 | ## 2. Fixed Date |
| 70 | |
| 71 | Fixed dates may also be specified as follows using `https://w3id.org/edc/v0.0.1/ns/inForceDate` operands: |
| 72 | |
| 73 | ```json |
| 74 | { |
| 75 | "@context": { |
| 76 | "edc": "https://w3id.org/edc/v0.0.1/ns/inForceDate", |
| 77 | "@vocab": "http://www.w3.org/ns/odrl.jsonld" |
| 78 | }, |
| 79 | "@type": "Offer", |
| 80 | "@id": "a343fcbf-99fc-4ce8-8e9b-148c97605aab", |
| 81 | "permission": [ |
| 82 | { |
| 83 | "action": "use", |
| 84 | "constraint": { |
| 85 | "and": [ |
| 86 | { |
| 87 | "leftOperand": "https://w3id.org/edc/v0.0.1/ns/inForceDate", |
| 88 | "operator": "gte", |
| 89 | "rightOperand": { |
| 90 | "@value": "2023-01-01T00:00:01Z", |
| 91 | "@type": "xsd:datetime" |
| 92 | } |
| 93 | }, |
| 94 | { |
| 95 | "leftOperand": "https://w3id.org/edc/v0.0.1/ns/inForceDate", |
| 96 | "operator": "lte", |
| 97 | "rightOperand": { |
| 98 | "@value": "2024-01-01T00:00:01Z", |
| 99 | "@type": "xsd:datetime" |
| 100 | } |
| 101 | } |
| 102 | ] |
| 103 | } |
| 104 | } |
| 105 | ] |
| 106 | } |
| 107 | ``` |
| 108 | |
| 109 | Although `xsd:datatime` supports specifying timezones, UTC should be used. It is an error to use an `xsd:datetime` |
| 110 | without specifying the timezone. |
| 111 | |
| 112 | ## 3. No Period |
| 113 | |
| 114 | If no period is specified the contract agreement is interpreted as having an indefinite in force period and will remain |
| 115 | valid until its other constraints evaluate to false. |
| 116 | |
| 117 | ## 4. Not Before and Until |
| 118 | |
| 119 | `Not Before` and `Until` semantics can be defined by specifying a single `https://w3id.org/edc/v0.0.1/ns/inForceDate` |
| 120 | fixed date constraint and an |
| 121 | appropriate operand. For example, the following policy |
| 122 | defines a contact is not in force before `January 1, 2023`: |
| 123 | |
| 124 | ```json |
| 125 | { |
| 126 | "@context": { |
| 127 | "edc": "https://w3id.org/edc/v0.0.1/ns/", |
| 128 | "@vocab": "http://www.w3.org/ns/odrl.jsonld" |
| 129 | }, |
| 130 | "@type": "Offer", |
| 131 | "@id": "a343fcbf-99fc-4ce8-8e9b-148c97605aab", |
| 132 | "permission": [ |
| 133 | { |
| 134 | "action": "use", |
| 135 | "constraint": { |
| 136 | "leftOperand": "edc:inForceDate", |
| 137 | "operator": "gte", |
| 138 | "rightOperand": { |
| 139 | "@value": "2023-01-01T00:00:01Z", |
| 140 | "@type": "xsd:datetime" |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | ] |
| 145 | } |
| 146 | ``` |
| 147 | |
| 148 | ## 5. Examples |
| 149 | |
| 150 | - In-force policy with a fixed validity: [policy.inforce.fixed.json](./policy.inforce.fixed.json) |
| 151 | - In-force policy with a relative validity duration: [policy.inforce.duration.json](./policy.inforce.duration.json) |
| 152 | |
| 153 | _Please note that the samples use the abbreviated prefix notation `"edc:inForceDate"` instead of the full |
| 154 | namespace `"https://w3id.org/edc/v0.0.1/ns/inForceDate"`._ |