[DAP-17] TaskConf AAD Part 2A: Mandatory task_info and Interval task validity - #4684
Conversation
…validity Provisions the task data the HPKE-AAD TaskConfiguration will need (Part 3), with no AAD changes yet. - task_info is now a mandatory, persisted Vec<u8> (non-empty, <=255 bytes) rather than an Option that serde silently dropped. In the DB it's BYTEA NOT NULL; serde/API forms carry it as an unpadded base64url; taskprov passes the real value from its TaskConfiguration. - Task validity is represented as a single Option<Interval> all the way to the DB: the task_end column becomes task_duration, and the API/serde forms are task_start + task_duration. Half-open intervals are now unrepresentable, as we all wanted. Report-admission checks derive start/end from the interval, and just for safety I added that the PATCH task-end path returns 400 when end is < task_start. Part 2B will change url::Url to janus_messages::Url for our in-DB representations, to keep from causing AAD errors with URL normalization business. That turns out to be a nice standalone task. Closes #4625.
|
Whoops, how'd I miss that test. Lemme work this out. |
| /// Sets or unsets the end date of a task. | ||
| /// | ||
| /// Because the task's validity interval is stored as a (start, duration) pair and a half-open | ||
| /// interval is not representable, the requested end is translated into a new `task_duration`: | ||
| /// | ||
| /// * `Some(end)`: `task_duration` is recomputed as `end - task_start`, leaving `task_start` | ||
| /// unchanged. If the task has no `task_start`, both columns remain NULL (the interval cannot | ||
| /// be set without a start), which is a no-op. | ||
| /// * `None`: both `task_start` and `task_duration` are cleared, removing the interval entirely. | ||
| #[tracing::instrument(skip(self), err(level = Level::DEBUG))] | ||
| pub async fn update_task_end( |
There was a problem hiding this comment.
This API actually poses a problem now, because it gets incorporated into the task's AAD. Changing the duration midstream would change the AAD, and break decryption of reports. We use this API as the backend for disabling or deleting a task from the control plane currently (not entirely sure which). I think we need to get rid of update_task_end() and introduce some new implementation-specific task field that we can modify to reimplement this feature.
There was a problem hiding this comment.
I'm playing with adding a deactivate_at time outside the task configuration, as an Option that we can set via API and it just ... deactivates then. If we set it to now or the past, it's instant.
There was a problem hiding this comment.
@divergentdave please take a look at aacea12 and see what you think!
Co-authored-by: David Cook <divergentdave@gmail.com>
When we get to part 3, the task validity interval is in the HPKE-AAD TaskConfiguration, so it must be immutable: mutating it would change the AAD and break decryption of already-uploaded reports. Remove update_task_end() and the PATCH task-end path. Task disable/expire now uses a new deactivate_at column that is not part of the TaskConfiguration, so it can change freely without affecting AADs. NOTE: open a divviup-api issue to switch task disabling to use deactivate_at.
Co-authored-by: David Cook <dcook@divviup.org>
Provisions the task data the HPKE-AAD TaskConfiguration will need (Part 3), with no AAD changes yet.
task_info is now a mandatory, persisted
Vec<u8>(non-empty, <=255 bytes) rather than anOptionthat serde silently dropped. In the DB it'sBYTEA NOT NULL; serde/API forms carry it as an unpadded base64url; taskprov passes the real value from itsTaskConfiguration.Task validity is represented as a single
Option<Interval>all the way to the DB: thetask_endcolumn becomestask_duration,and the API/serde forms aretask_start + task_duration. Half-open intervals are now unrepresentable, as we all wanted. Report-admission checks derive start/end from the interval, and just for safety I added that thePATCHtask-end path returns 400 when end is< task_start.Part 2B will change
url::Urltojanus_messages::Urlfor our in-DB representations, to keep from causing AAD errors with URL normalization business. That turns out to be a nice standalone task.Closes #4625.