Skip to content

[DAP-17/18] Move TaskConfig/VdafConfig from taskprov into base DAP as TaskConfiguration#4624

Open
jcjones wants to merge 4 commits into
mainfrom
jcj/dap-17-task-and-vdaf-config-to-base-dap
Open

[DAP-17/18] Move TaskConfig/VdafConfig from taskprov into base DAP as TaskConfiguration#4624
jcjones wants to merge 4 commits into
mainfrom
jcj/dap-17-task-and-vdaf-config-to-base-dap

Conversation

@jcjones

@jcjones jcjones commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

DAP-17+ defines TaskConfiguration and VDAF config encodings in the base protocol rather than the taskprov extension. This PR:

  • Moves TaskProv stuff from messages/src/taskprov.rs to messages/src/task.rs with minor renames
  • min_batch_size is now u64 (was u32)
  • VDAF max_measurement/max_weight fields are now u64 (was u32)
  • task_start/task_duration are removed as direct fields, replaced by a task_interval TaskExtension
  • batch_config is now an explicit opaque field
  • TaskExtensionType gains a TaskInterval variant
  • VdafConfig and TaskExtensionType preserve unknown codepoints via Unknown variants, so a peer advertising a newer revision's VDAF type or task extension stays interoperable

… TaskConfiguration

DAP-17+ defines TaskConfiguration and VDAF config encodings in the base protocol rather than the taskprov extension. This commit:

- Creates `messages/src/task.rs` with a `TaskConfiguration`
- `min_batch_size` is now `u64` (was `u32`)
- VDAF `max_measurement`/`max_weight` fields are now `u64` (was `u32`)
- `task_start`/`task_duration` are removed as direct fields, replaced by a `task_interval` `TaskExtension`
- `batch_config` is now an explicit opaque field
- `TaskExtensionType` gains a `TaskInterval` variant
- `VdafConfig` and `TaskExtensionType` preserve unknown codepoints via `Unknown` variants, so a peer advertising a newer revision's VDAF type or task extension stays interoperable
@jcjones jcjones added the allow-changed-migrations Override the ci-migrations check to allow migrations that have changed. label Jun 5, 2026
Comment thread messages/src/task.rs
Co-authored-by: David Cook <dcook@divviup.org>
Comment thread core/src/vdaf.rs Outdated
Comment thread messages/src/task.rs Outdated
Comment thread messages/src/task.rs Outdated
@jcjones jcjones marked this pull request as ready for review June 5, 2026 20:31
@jcjones jcjones requested a review from a team as a code owner June 5, 2026 20:31
Comment thread aggregator/src/aggregator/taskprov_tests.rs Outdated
let task_end = task_config
.task_start()
.add_duration(task_config.task_duration())?;
let (task_start, task_end) = match task_config.task_interval()? {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's kinda funky that we transform an Interval into two Times like this. It looks like we do this because AggregatorTask::new expects task start and end as separate values, but I would think it's no longer possible to have a task have a start but no end, and vice versa. Should we revisit the data model here so that these values are an Interval all the way through?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a pretty sizable refactor down into the database, but I agree with you. How about I take that on as a follow-up?

/// This field is used to distinguish tasks with otherwise equivalent DAP task parameters.
taskprov_task_info: Option<Vec<u8>>,
/// The `task_info` byte string from a `TaskConfiguration` struct. `None` for API-provisioned
/// tasks, which have no `TaskConfiguration`; used to distinguish tasks with otherwise

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separately from this PR, we should consider allowing API-provisioned tasks to set a task info string. That would require plumbing this up into divviup-api, so it's a minor undertaking, but I don't see why we wouldn't allow this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread messages/src/task.rs Outdated
Comment thread messages/src/task.rs
Comment on lines +58 to +60
if task_info.is_empty() {
return Err(Error::InvalidParameter("task_info must not be empty"));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? We observe elsewhere that tasks provisioned via aggregator API could have empty task info. I just went and looked and sure enough, draft-ietf-ppm-dap-18 has opaque task_info<1..2^8-1>; which means empty task_info is illegal.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/shrug

Comment thread messages/src/task.rs
Comment on lines +93 to +94
task_start: Time,
task_duration: Duration,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this echoes a comment I left elsewhere, but why not have a single Interval parameter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to match what the database had. See above. I'm opening a follow-on: #4625

Comment thread messages/src/task.rs Outdated
Comment thread messages/src/task.rs
/// `Unknown(0x0001)` compares and hashes equal to `TaskInterval`.
#[derive(Clone, Copy, Debug)]
#[non_exhaustive]
pub enum TaskExtensionType {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elsewhere, like HpkeKemId, we used #[repr(u16)]. I think we should be consistent here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, I went with the ExtensionType strategy here rather than the HpkeKemId one to be forward-compatibile -- repr will hard-fail decoding anything it doesn't reocgnize, but the task-extension TLV framing is supposed to let receivers round-trip extensions they don't understand, right? So I went with this pattern.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On HpkeKemId we're using the num_enum derive macros, and those seem to care about having a #[repr(u_)] macro on the enum. I think we can achieve forwards-compatibility either way, the difference is whether we write the match blocks or the macro does.

Comment thread messages/src/task.rs Outdated
Comment thread messages/src/task.rs
Comment on lines +53 to +54
batch_mode: batch_mode::Code,
batch_config: Vec<u8>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since batch_config is intended to model extra parameters that may be required by a future batch mode, it might be nicer to model these two as a single Rust enum (similar to VdafConfig). If we ever support a batch mode with a non-empty batch_config, we could decode the embedded opaque data at the same time we decode the whole TaskConfiguration. For the current state of the code base, this means we wouldn't have to sprinkle empty byte arrays into our initialization (which is a bit of a layering violation).

Comment thread messages/src/task.rs
/// `task_start` and `task_duration`, inserting it at the correct sorted position in the
/// given extensions.
#[allow(clippy::too_many_arguments)]
pub fn new_with_task_interval(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think introducing a builder for TaskConfiguration may be a bit nicer for our test code. The two constructors we have now share a lot of their signatures.

Comment thread messages/src/task.rs
Comment on lines +162 to +163
/// Searches extensions for a `task_interval` extension and decodes it.
pub fn task_interval(&self) -> Result<Option<Interval>, Error> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, we may want to consider representing task extensions with an enum, and only storing the raw encoded form of an extension if we don't have support for the extension.

Comment thread messages/src/lib.rs
InvalidParameter(&'static str),
/// A codec error occurred while processing a message.
#[error("codec error: {0}")]
Codec(#[from] prio::codec::CodecError),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we get rid of encoded byte arrays for inner fields of TaskConfiguration, we could potentially drop this error variant.

Comment thread messages/src/task.rs
/// `Unknown(0x0001)` compares and hashes equal to `TaskInterval`.
#[derive(Clone, Copy, Debug)]
#[non_exhaustive]
pub enum TaskExtensionType {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On HpkeKemId we're using the num_enum derive macros, and those seem to care about having a #[repr(u_)] macro on the enum. I think we can achieve forwards-compatibility either way, the difference is whether we write the match blocks or the macro does.

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

Labels

allow-changed-migrations Override the ci-migrations check to allow migrations that have changed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants