tilo-actions 0.5.1

The Tilo action model: resources, the actions on them, and their registry, with the plain resource vocabulary that needs no store.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
//! Content puts: how a session client hands bytes to its workspace's content
//! store, chunk by chunk, and gets back a reference to them.
//!
//! Actions carry intent and references; bytes travel by session transport
//! into the content store. A client (an AI agent through MCP, first) puts
//! the bytes, receives `tilo.content:<hash>` ([`crate::content_resource`])
//! and passes that reference to an action, which resolves it in the workspace.
//!
//! A put is invisible to everyone until an action at its own node
//! references it: storing content is never authority over any document.

use std::sync::Arc;

use super::{ActionCallError, Caller, RemoteActionTarget};

/// The most raw bytes one append carries. MCP requests are bounded at
/// 1 MiB; 512 KiB is about 683 KiB of base64, leaving room for the rest of
/// the request.
pub const MAX_CONTENT_PUT_CHUNK: usize = 512 * 1024;

/// How far ahead of the bytes accepted so far one append may land: a client
/// sends a group of [`MAX_CONTENT_PUT_CHUNK`]-sized chunks at once and a slow
/// link then costs one round trip per group rather than per chunk. The
/// receiver holds the early ones and appends them as the gap before them
/// fills; the `written` an answer carries is the bytes held contiguously from
/// the start. Eight chunks is as many as a client sends in a group.
///
/// The frames a chunk is split into travel the same way
/// ([`super::ContentPut`]): a session hands a device every frame of an upload
/// before it waits for the first answer, so an upload costs a round trip per
/// window of frames, not one per frame.
pub const MAX_CONTENT_PUT_AHEAD: usize = 8 * MAX_CONTENT_PUT_CHUNK;

/// The most raw bytes one many-files step carries (hex doubles them, staying
/// within [`super::MAX_CONTENT_FRAME_BYTES`]).
pub const MAX_PUT_MANY_BYTES: usize = 384 * 1024;

/// The most files one many-files step carries: every one is a store write,
/// and a step answers within the peer's reply deadline.
pub const MAX_PUT_MANY_FILES: usize = 256;

/// The most hashes one step asks about at once. Every hash costs the store a
/// look, and one step must answer within the peer's reply deadline: a few
/// thousand is minutes of looking on a loaded disk, so a caller asks in
/// steps this size instead.
pub const MAX_HAVE_HASHES: usize = 1_024;

/// Uploads one session keeps open at once: a client putting a folder keeps
/// one open per file until it finishes, so it may hold as many as a workspace
/// keeps for all its callers ([`super::MAX_HOSTED_CONTENT_PUTS`]).
pub const MAX_OPEN_CONTENT_PUTS: usize = 64;

/// What a provider without a content store answers.
pub const CONTENT_PUTS_UNAVAILABLE: &str = "content uploads are not available here";

/// The scheme of a content reference: what a put answers for the content it stored.
pub const CONTENT_REFERENCE: &str = "tilo.content:";

/// The content hash (lowercase BLAKE3 hex) `address` names: a reference as a put answers it
/// (`tilo.content:<hash>`), or the bare hash of bytes a caller hashed itself. `None` for
/// anything else.
#[must_use]
pub fn content_hash(address: &str) -> Option<&str> {
    let hash = address.strip_prefix(CONTENT_REFERENCE).unwrap_or(address);
    (hash.len() == 64
        && hash
            .bytes()
            .all(|byte| byte.is_ascii_digit() || (b'a'..=b'f').contains(&byte)))
    .then_some(hash)
}

/// A provider's API for content puts.
pub trait ContentPuts: Send + Sync {
    /// Open an upload of exactly `size` bytes into the content store of
    /// `caller`'s workspace.
    fn begin(&self, caller: &Caller, size: u64) -> Result<Box<dyn ContentPut>, ActionCallError>;

    /// Store `files` whole, answering each one's reference in order: what a
    /// folder of small files needs, one call instead of three a file.
    ///
    /// # Errors
    /// What [`Self::begin`] or a file's store refused.
    fn put_many(&self, caller: &Caller, files: &[Vec<u8>]) -> Result<Vec<String>, ActionCallError> {
        let mut contents = Vec::with_capacity(files.len());
        for bytes in files {
            let size = u64::try_from(bytes.len()).unwrap_or(u64::MAX);
            let mut put = self.begin(caller, size)?;
            put.append(0, bytes)?;
            contents.push(put.finish()?);
        }
        Ok(contents)
    }

    /// Which of `hashes` the content store of `caller`'s workspace already
    /// holds, in order: each a reference a put answered, or a bare hash
    /// ([`content_hash`]). One that names no content is not held.
    ///
    /// # Errors
    /// A store that cannot be asked, or content `caller` may not read.
    fn have(&self, caller: &Caller, hashes: &[String]) -> Result<Vec<bool>, ActionCallError> {
        let _ = (caller, hashes);
        Err(ActionCallError::Unavailable {
            reason: "this workspace's content cannot be asked what it holds".into(),
        })
    }

    /// Store `put`, which `caller` may have begun on a connection that has since ended, and
    /// answer its reference.
    ///
    /// # Errors
    /// What the put refused ([`ContentPut::finish_as`]).
    fn finish(&self, caller: &Caller, put: Box<dyn ContentPut>) -> Result<String, ActionCallError> {
        put.finish_as(caller)
    }
}

/// One upload in progress, owned by the session that began it: dropped
/// unfinished (the session ended), it stores nothing.
pub trait ContentPut: Send {
    /// The size the upload began with.
    fn size(&self) -> u64;

    /// Bytes accepted so far. An upload that reaches another device over a
    /// session hands its pieces over without waiting for each answer, so it
    /// answers the bytes handed over: what a piece may land after, and what
    /// its finish verifies every piece of.
    fn written(&self) -> u64;

    /// Accept `chunk` at `offset`, answering the bytes accepted so far.
    /// `offset` must be exactly what was accepted so far, so a chunk sent
    /// again is refused, never stored twice; the refusal names the offset
    /// to resume at.
    fn append(&mut self, offset: u64, chunk: &[u8]) -> Result<u64, ActionCallError>;

    /// Store the content and answer its reference, `tilo.content:<hash>`.
    fn finish(self: Box<Self>) -> Result<String, ActionCallError>;

    /// [`Self::finish`], decided as `caller`: the same person or app as began the upload,
    /// finishing it on a later connection of theirs.
    ///
    /// # Errors
    /// What [`Self::finish`] refuses, or a caller other than the one that began the upload.
    fn finish_as(self: Box<Self>, caller: &Caller) -> Result<String, ActionCallError> {
        let _ = caller;
        self.finish()
    }
}

/// Open uploads one provider keeps for all its callers at once; past it, the
/// upload left untouched longest is dropped and stores nothing.
pub const MAX_HOSTED_CONTENT_PUTS: usize = 64;

/// One step of an upload asked of another device over a session
/// ([`super::RemoteActionMessage::ContentPutRequest`]): the same begin,
/// append and finish a local [`ContentPuts`] takes.
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case", deny_unknown_fields)]
pub enum ContentPutStep {
    /// Open an upload of exactly `size` bytes, `target` being the action their arguments are for
    /// when the caller knows it: an action of the caller's own device keeps what it reads on that
    /// device, and everything else a workspace's store.
    Begin {
        size: u64,
        #[serde(default)]
        target: Option<RemoteActionTarget>,
    },
    /// Accept the next bytes at `offset`, hex-encoded so the frame stays
    /// self-describing text.
    Append {
        upload: u64,
        offset: u64,
        bytes: String,
    },
    /// Store what the upload holds.
    Finish { upload: u64 },
    /// Store several whole files at once, each hex-encoded: the answer names
    /// each one's reference in order ([`ContentPutAnswer::Many`]), `target`
    /// naming the action they are for as [`Self::Begin`] does.
    Many {
        files: Vec<String>,
        #[serde(default)]
        target: Option<RemoteActionTarget>,
    },
    /// Ask which of these hashes (lowercase BLAKE3 hex) the store already
    /// holds ([`ContentPutAnswer::Have`]).
    Have { hashes: Vec<String> },
    /// Where the upload stands: answered with the bytes accepted so far
    /// ([`ContentPutAnswer::Appended`]), so a client whose append failed on
    /// the way resumes from there.
    Progress { upload: u64 },
}

impl ContentPutStep {
    /// The append of `chunk` at `offset` to `upload`.
    #[must_use]
    pub fn append(upload: u64, offset: u64, chunk: &[u8]) -> Self {
        Self::Append {
            upload,
            offset,
            bytes: hex::encode(chunk),
        }
    }
}

/// What a device answers a [`ContentPutStep`].
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case", deny_unknown_fields)]
pub enum ContentPutAnswer {
    /// The upload is open under `upload`, for the caller who began it.
    Begun { upload: u64 },
    /// The bytes accepted so far.
    Appended { written: u64 },
    /// The content's reference, `tilo.content:<hash>`.
    Finished { content: String },
    /// The reference of each file stored, in the order asked.
    Many { contents: Vec<String> },
    /// Whether each hash asked about is held, in the order asked.
    Have { present: Vec<bool> },
}

/// The uploads a provider keeps open for the callers that began them over a
/// session, each answerable only to its own caller.
#[derive(Default)]
pub struct HostedContentPuts {
    open: std::sync::Mutex<HostedOpen>,
}

#[derive(Default)]
struct HostedOpen {
    last: u64,
    /// By id: who began it, when it was last touched, the upload, and the store it was begun in,
    /// which finishes it.
    uploads: std::collections::BTreeMap<u64, OpenUpload>,
    touched: u64,
}

/// Where a step's bytes go: the store the action its arguments are for reads, or the caller's own
/// when it names none.
pub type PutsFor<'a> =
    dyn Fn(Option<&RemoteActionTarget>) -> Option<Arc<dyn ContentPuts>> + Send + Sync + 'a;

/// One upload a provider keeps open, and the store it was begun in.
struct OpenUpload {
    caller: Caller,
    touched: u64,
    put: Box<dyn ContentPut>,
    store: Arc<dyn ContentPuts>,
}

impl HostedContentPuts {
    /// Where `caller`'s open upload `upload` stands, if they have one so called.
    fn progress(&self, caller: &Caller, upload: u64) -> Option<ContentPutAnswer> {
        use tilo_lock::MutexRecover as _;
        self.open
            .lock_recover()
            .uploads
            .get(&upload)
            .filter(|open| open.caller == *caller)
            .map(|open| ContentPutAnswer::Appended {
                written: open.put.written(),
            })
    }

    /// Open `size` bytes of `caller`'s in `store`, answering its id here.
    fn begin(
        &self,
        store: Arc<dyn ContentPuts>,
        caller: &Caller,
        size: u64,
    ) -> Result<ContentPutAnswer, ActionCallError> {
        use tilo_lock::MutexRecover as _;
        let mut open = self.open.lock_recover();
        let mine = open
            .uploads
            .values()
            .filter(|open| open.caller == *caller)
            .count();
        if mine >= MAX_OPEN_CONTENT_PUTS {
            return Err(ActionCallError::InvalidRequest {
                reason: format!(
                    "this session already has {MAX_OPEN_CONTENT_PUTS} uploads open: finish one first"
                ),
            });
        }
        let put = store.begin(caller, size)?;
        while open.uploads.len() >= MAX_HOSTED_CONTENT_PUTS {
            let Some(stalest) = open
                .uploads
                .iter()
                .min_by_key(|(_, open)| open.touched)
                .map(|(id, _)| *id)
            else {
                break;
            };
            open.uploads.remove(&stalest);
        }
        open.last = open.last.saturating_add(1);
        open.touched = open.touched.saturating_add(1);
        let (upload, touched) = (open.last, open.touched);
        open.uploads.insert(
            upload,
            OpenUpload {
                caller: caller.clone(),
                touched,
                put,
                store,
            },
        );
        drop(open);
        Ok(ContentPutAnswer::Begun { upload })
    }

    /// Store the files of a [`ContentPutStep::Many`].
    fn many(
        puts: &dyn ContentPuts,
        caller: &Caller,
        files: &[String],
    ) -> Result<ContentPutAnswer, ActionCallError> {
        if files.is_empty() {
            return Err(ActionCallError::InvalidRequest {
                reason: "store at least one file".into(),
            });
        }
        if files.len() > MAX_PUT_MANY_FILES {
            return Err(ActionCallError::InvalidRequest {
                reason: format!("one call carries at most {MAX_PUT_MANY_FILES} files"),
            });
        }
        let mut decoded = Vec::with_capacity(files.len());
        let mut total = 0usize;
        for file in files {
            if file.len() > MAX_PUT_MANY_BYTES.saturating_mul(2) {
                return Err(ActionCallError::InvalidRequest {
                    reason: format!("one file carries at most {MAX_PUT_MANY_BYTES} bytes"),
                });
            }
            let bytes = hex::decode(file).map_err(|_| ActionCallError::InvalidRequest {
                reason: "a file's bytes must be hex".into(),
            })?;
            total = total.saturating_add(bytes.len());
            decoded.push(bytes);
        }
        if total > MAX_PUT_MANY_BYTES {
            return Err(ActionCallError::InvalidRequest {
                reason: format!("one call carries at most {MAX_PUT_MANY_BYTES} bytes of files"),
            });
        }
        puts.put_many(caller, &decoded)
            .map(|contents| ContentPutAnswer::Many { contents })
    }

    /// Answer which of a [`ContentPutStep::Have`]'s addresses the store holds.
    fn have(
        puts: &dyn ContentPuts,
        caller: &Caller,
        hashes: &[String],
    ) -> Result<ContentPutAnswer, ActionCallError> {
        if hashes.len() > MAX_HAVE_HASHES {
            return Err(ActionCallError::InvalidRequest {
                reason: format!("one call asks about at most {MAX_HAVE_HASHES} hashes"),
            });
        }
        let mut named = Vec::with_capacity(hashes.len());
        for address in hashes {
            let hash = content_hash(address).ok_or_else(|| ActionCallError::InvalidRequest {
                reason: format!(
                    "{address} names no content: neither a {CONTENT_REFERENCE} reference nor a \
                     lowercase BLAKE3 hash"
                ),
            })?;
            named.push(hash.to_owned());
        }
        puts.have(caller, &named)
            .map(|present| ContentPutAnswer::Have { present })
    }

    /// Answer `step` from `caller`, putting into the store `store_for` answers for the action the
    /// step names, or the one it names for none.
    ///
    /// # Errors
    ///
    /// What the store refused, an upload the caller has no such open, or bytes
    /// that are not hex.
    pub fn step(
        &self,
        store_for: &PutsFor<'_>,
        caller: &Caller,
        step: ContentPutStep,
    ) -> Result<ContentPutAnswer, ActionCallError> {
        use tilo_lock::MutexRecover as _;
        let gone = |upload: u64| ActionCallError::InvalidRequest {
            reason: format!("no upload {upload} is open in this session"),
        };
        let no_store = || ActionCallError::Unavailable {
            reason: "no content store is open here".into(),
        };
        match step {
            ContentPutStep::Begin { size, target } => {
                let store = store_for(target.as_ref()).ok_or_else(no_store)?;
                self.begin(store, caller, size)
            }
            ContentPutStep::Append {
                upload,
                offset,
                bytes,
            } => {
                if bytes.len() > super::MAX_CONTENT_FRAME_BYTES.saturating_mul(2) {
                    return Err(ActionCallError::InvalidRequest {
                        reason: format!(
                            "a piece carries at most {} bytes",
                            super::MAX_CONTENT_FRAME_BYTES
                        ),
                    });
                }
                let chunk = hex::decode(bytes).map_err(|_| ActionCallError::InvalidRequest {
                    reason: "a piece's bytes must be hex".into(),
                })?;
                let mut open = self.open.lock_recover();
                open.touched = open.touched.saturating_add(1);
                let now = open.touched;
                let entry = open
                    .uploads
                    .get_mut(&upload)
                    .filter(|open| open.caller == *caller)
                    .ok_or_else(|| gone(upload))?;
                entry.touched = now;
                let appended = entry.put.append(offset, &chunk);
                if matches!(appended, Err(ActionCallError::Refused { .. })) {
                    // The store refused the bytes: the upload is over.
                    open.uploads.remove(&upload);
                }
                drop(open);
                appended.map(|written| ContentPutAnswer::Appended { written })
            }
            ContentPutStep::Progress { upload } => {
                self.progress(caller, upload).ok_or_else(|| gone(upload))
            }
            ContentPutStep::Many { files, target } => {
                let puts = store_for(target.as_ref()).ok_or_else(no_store)?;
                Self::many(puts.as_ref(), caller, &files)
            }
            ContentPutStep::Have { hashes } => {
                let puts = store_for(None).ok_or_else(no_store)?;
                Self::have(puts.as_ref(), caller, &hashes)
            }
            ContentPutStep::Finish { upload } => {
                let mut open = self.open.lock_recover();
                let found = open
                    .uploads
                    .get(&upload)
                    .filter(|open| open.caller == *caller)
                    .ok_or_else(|| gone(upload))?;
                // Short of its size, the upload stays open to be completed.
                let (written, size) = (found.put.written(), found.put.size());
                if written != size {
                    return Err(ActionCallError::InvalidRequest {
                        reason: format!(
                            "the upload has {written} of {size} bytes: append the rest at offset \
                             {written}"
                        ),
                    });
                }
                let OpenUpload { put, store, .. } =
                    open.uploads.remove(&upload).ok_or_else(|| gone(upload))?;
                drop(open);
                store
                    .finish(caller, put)
                    .map(|content| ContentPutAnswer::Finished { content })
            }
        }
    }
}

#[cfg(test)]
mod tests {

    use super::*;

    /// Puts kept in memory, finished as the bytes' length.
    struct Memory;

    struct Held(u64, Vec<u8>);

    impl ContentPuts for Memory {
        fn begin(&self, _: &Caller, size: u64) -> Result<Box<dyn ContentPut>, ActionCallError> {
            Ok(Box::new(Held(size, Vec::new())))
        }
    }

    impl ContentPut for Held {
        fn size(&self) -> u64 {
            self.0
        }
        fn written(&self) -> u64 {
            u64::try_from(self.1.len()).unwrap()
        }
        fn append(&mut self, offset: u64, chunk: &[u8]) -> Result<u64, ActionCallError> {
            if offset != self.written() {
                return Err(ActionCallError::InvalidRequest {
                    reason: "offset".into(),
                });
            }
            self.1.extend_from_slice(chunk);
            Ok(self.written())
        }
        fn finish(self: Box<Self>) -> Result<String, ActionCallError> {
            Ok(format!("{} bytes", self.1.len()))
        }
    }

    /// The store every step of these tests goes to.
    #[expect(
        clippy::unnecessary_wraps,
        reason = "a step asks where its bytes go, and this store is always there"
    )]
    fn store(_: Option<&RemoteActionTarget>) -> Option<Arc<dyn ContentPuts>> {
        Some(Arc::new(Memory))
    }

    /// An upload over a session answers only the caller that began it,
    /// finishes only once whole, and is gone once finished.
    #[test]
    fn an_upload_is_its_callers_and_finishes_whole() {
        let puts = HostedContentPuts::default();
        let (ada, eve) = (Caller::local_person("ada"), Caller::local_person("eve"));
        let ContentPutAnswer::Begun { upload } = puts
            .step(
                &store,
                &ada,
                ContentPutStep::Begin {
                    size: 4,
                    target: None,
                },
            )
            .unwrap()
        else {
            panic!("begun")
        };
        assert!(
            puts.step(&store, &eve, ContentPutStep::append(upload, 0, b"ab"))
                .is_err(),
            "another caller's upload is not there for it"
        );
        assert_eq!(
            puts.step(&store, &ada, ContentPutStep::append(upload, 0, b"ab"))
                .unwrap(),
            ContentPutAnswer::Appended { written: 2 }
        );
        assert!(
            puts.step(&store, &ada, ContentPutStep::Finish { upload })
                .is_err(),
            "half an upload does not finish"
        );
        assert_eq!(
            puts.step(&store, &ada, ContentPutStep::append(upload, 0, b"ab"))
                .ok(),
            None,
            "a piece sent again is refused"
        );
        assert_eq!(
            puts.step(&store, &ada, ContentPutStep::Progress { upload })
                .unwrap(),
            ContentPutAnswer::Appended { written: 2 },
            "the upload says where to resume"
        );
        assert!(
            puts.step(&store, &eve, ContentPutStep::Progress { upload })
                .is_err(),
            "nobody else learns where it stands"
        );
        puts.step(&store, &ada, ContentPutStep::append(upload, 2, b"cd"))
            .unwrap();
        assert_eq!(
            puts.step(&store, &ada, ContentPutStep::Finish { upload })
                .unwrap(),
            ContentPutAnswer::Finished {
                content: "4 bytes".into()
            }
        );
        assert!(
            puts.step(&store, &ada, ContentPutStep::Finish { upload })
                .is_err(),
            "a finished upload is closed"
        );
    }

    /// A many-files step takes at most [`MAX_PUT_MANY_FILES`] files, so it
    /// answers within the peer's reply deadline however small they are.
    #[test]
    fn a_many_files_step_takes_at_most_its_files() {
        let puts = HostedContentPuts::default();
        let ada = Caller::local_person("ada");
        let whole = vec![String::new(); MAX_PUT_MANY_FILES];
        let ContentPutAnswer::Many { contents } = puts
            .step(
                &store,
                &ada,
                ContentPutStep::Many {
                    files: whole,
                    target: None,
                },
            )
            .unwrap()
        else {
            panic!("many")
        };
        assert_eq!(contents.len(), MAX_PUT_MANY_FILES);
        let past = vec![String::new(); MAX_PUT_MANY_FILES.saturating_add(1)];
        assert!(
            puts.step(
                &store,
                &ada,
                ContentPutStep::Many {
                    files: past,
                    target: None
                }
            )
            .is_err(),
            "a step of more files is refused rather than made to wait"
        );
    }
}