bamboo-storage 2026.10.13

Session storage backends for the Bamboo agent framework
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
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
//! One cross-process Child question transaction. The caller supplies only a
//! bounded execution observation; this store rereads canonical identity and
//! transcript under the same writer lock used by ordinary full saves.

use super::*;
use bamboo_domain::{
    ParentQuestion, ParentQuestionCheckpointV1, ParentQuestionResolution, PendingQuestionSource,
    PARENT_QUESTION_REQUEST_KEY, PARENT_QUESTION_RESOLUTION_KEY,
};

pub(super) fn parent_request_is_durable(parent: &Session, question: &ParentQuestion) -> bool {
    let expected = question.envelope();
    let mut matches = parent
        .messages
        .iter()
        .filter(|message| message.id == expected.id.as_str());
    let Some(message) = matches.next() else {
        return false;
    };
    matches.next().is_none()
        && message
            .metadata
            .as_ref()
            .and_then(|metadata| metadata.get("session_message"))
            .and_then(|marker| {
                serde_json::from_value::<SessionMessageEnvelope>(marker.clone()).ok()
            })
            .as_ref()
            == Some(&expected)
        && is_matching_session_message(message, &expected)
        && expected.to_provider_message().is_ok_and(|provider| {
            serde_json::to_value(message).ok() == serde_json::to_value(provider).ok()
        })
}

impl SessionStoreV2 {
    pub async fn checkpoint_parent_question(
        &self,
        expected_child: &Session,
        parent: &Session,
        observation: &ParentQuestionCheckpointV1,
    ) -> io::Result<Option<(Session, ParentQuestion)>> {
        if observation.validate_shape().is_err() || expected_child.kind != SessionKind::Child {
            return Ok(None);
        }
        let started = Instant::now();
        let lifecycle = self.lock_default_writer_lifecycle().await?;
        let task = self.lock_runtime_task_sidecar_shared().await?;
        let writer = self
            .acquire_session_write_lock(&expected_child.id, SaveKind::Full)
            .await?;
        let guards = DefaultWriterGuards::shared(lifecycle, task, writer);
        let Some(mut child) = self.load_session_unlocked(&expected_child.id).await? else {
            return Ok(None);
        };
        if child.id != expected_child.id
            || child.kind != SessionKind::Child
            || child.created_at != expected_child.created_at
            || child.parent_session_id != expected_child.parent_session_id
            || child.root_session_id != expected_child.root_session_id
            || child.spawn_depth != expected_child.spawn_depth
            || child.project_id_meta() != expected_child.project_id_meta()
            || !child.provider_transcript.groups().is_empty()
            || child.parent_session_id.as_deref() != Some(parent.id.as_str())
            || child.last_run_status().as_deref() != Some("running")
            || child.messages.len() < observation.prefix_message_count
            || ParentQuestion::prefix_digest(&child.messages[..observation.prefix_message_count])
                .as_ref()
                != Some(&observation.prefix_digest)
        {
            return Ok(None);
        }
        if let Some(raw) = child.metadata.get(PARENT_QUESTION_REQUEST_KEY) {
            let Ok(existing) = serde_json::from_str::<ParentQuestion>(raw) else {
                return Ok(None);
            };
            // A lost ACK may be replayed even if the parent already answered.
            let original_pair = observation
                .suffix
                .iter()
                .find(|message| message.id == observation.tool_result_message_id);
            if existing.child.session_id == child.id
                && existing.child.created_at == child.created_at
                && existing.parent.session_id == parent.id
                && existing.parent.created_at == parent.created_at
                && existing.tool_call_id == observation.tool_call_id
                && existing.tool_result_message_id == observation.tool_result_message_id
                && existing.question == observation.pending.question
                && existing.options == observation.pending.options
                && existing.allow_custom == observation.pending.allow_custom
                && original_pair.is_some_and(|pair| {
                    bamboo_domain::SessionMessageId::stable(
                        "direct-parent-question-result-v1",
                        &serde_json::to_value(pair).unwrap_or_default(),
                    ) == existing.paired_result_digest
                })
                && (ParentQuestion::for_pending(parent, &child).as_ref() == Some(&existing)
                    || bamboo_domain::ParentQuestionResolution::from_child(
                        parent,
                        &child,
                        &existing.id,
                    )
                    .is_some_and(|resolution| resolution.request == existing))
            {
                return Ok(Some((child, existing)));
            }
            return Ok(None);
        }
        // The Host can have checkpointed an initial Inbox delivery after the
        // Worker captured its prefix. Require any overlap to be byte-exact.
        // A replay of an already answered question is checked above: its
        // paired Tool result was correctly rewritten by the parent CAS.
        let overlapping = child.messages.len() - observation.prefix_message_count;
        if overlapping > observation.suffix.len()
            || serde_json::to_value(&child.messages[observation.prefix_message_count..]).ok()
                != serde_json::to_value(&observation.suffix[..overlapping]).ok()
        {
            return Ok(None);
        }
        if child.pending_question.is_some()
            || child.metadata.contains_key(PARENT_QUESTION_RESOLUTION_KEY)
        {
            return Ok(None);
        }
        let ids = child
            .messages
            .iter()
            .map(|message| message.id.as_str())
            .collect::<std::collections::HashSet<_>>();
        if observation.suffix[overlapping..]
            .iter()
            .any(|message| ids.contains(message.id.as_str()))
        {
            return Ok(None);
        }
        child
            .messages
            .extend_from_slice(&observation.suffix[overlapping..]);
        let mut pending = observation.pending.clone();
        pending.source = PendingQuestionSource::DirectParent;
        child.pending_question = Some(pending);
        child.metadata.insert(
            "runtime.suspend_reason".into(),
            "awaiting_clarification".into(),
        );
        child.updated_at = Utc::now();
        let Some(question) = ParentQuestion::issue_at(parent, &child, child.updated_at) else {
            return Ok(None);
        };
        child.metadata.insert(
            PARENT_QUESTION_REQUEST_KEY.into(),
            serde_json::to_string(&question).map_err(|error| other_io_error(error.to_string()))?,
        );
        self.save_session_after_lock(&child, started, &guards, None)
            .await?;
        Ok(Some((child, question)))
    }

    /// The only writer allowed to replace an ACKed suspended Tool result with
    /// a parent's answer. The parent request, Child pending state, answer and
    /// transcript all receive fresh canonical checks under the Child V2 lock.
    /// Generic Session save/mutate paths never receive this one-use permit.
    pub async fn answer_parent_question<F>(
        &self,
        question: &ParentQuestion,
        text: &str,
        publish: F,
    ) -> io::Result<Option<(Session, bool)>>
    where
        F: FnOnce(&Session) + Send,
    {
        self.answer_parent_question_with_root_writer(question, text, None, publish)
            .await
    }

    /// A runtime answer retains its original Root capability through the
    /// existing Child answer transaction and every final filesystem replace.
    pub async fn answer_parent_question_with_root_writer<F>(
        &self,
        question: &ParentQuestion,
        text: &str,
        root_owner: Option<&bamboo_domain::RootActorRuntimeWrite>,
        publish: F,
    ) -> io::Result<Option<(Session, bool)>>
    where
        F: FnOnce(&Session) + Send,
    {
        if question.validate_answer(text).is_err()
            || validate_session_id(&question.child.session_id).is_err()
            || validate_session_id(&question.parent.session_id).is_err()
            || ParentQuestion::from_envelope(&question.envelope()).as_ref() != Some(question)
        {
            return Ok(None);
        }
        let started = Instant::now();
        let lifecycle = self.lock_default_writer_lifecycle().await?;
        let task = self.lock_runtime_task_sidecar_shared().await?;
        // Validate the immutable direct-parent ordering before acquiring two
        // Session locks. A forged reverse/self relation must not choose an
        // inconsistent lock order. The complete request is rechecked below.
        let Some(observed_child) = self
            .load_session_unlocked(&question.child.session_id)
            .await?
        else {
            return Ok(None);
        };
        if observed_child.kind != SessionKind::Child
            || observed_child.created_at != question.child.created_at
            || observed_child.parent_session_id.as_deref()
                != Some(question.parent.session_id.as_str())
            || observed_child.parent_created_at != Some(question.parent.created_at)
        {
            return Ok(None);
        }
        // Ancestor -> Child -> tree is the fixed acquisition order. Retain
        // both physical Session guards even for the existing control-plane
        // answer API without a runtime Root owner. Actor renewals acquire the
        // same Session lock before tree and cannot race the exact witnesses.
        let root_guard = Some(
            self.acquire_session_write_lock(&question.parent.session_id, SaveKind::Full)
                .await?,
        );
        let writer = self
            .acquire_session_write_lock(&question.child.session_id, SaveKind::Full)
            .await?;
        let origin = if let Some(owner) = root_owner {
            if owner.fence.actor_id != question.parent.session_id
                || owner.created_at != question.parent.created_at
            {
                return Err(root_actor_runtime::conflict(
                    "Parent answer Root execution target changed",
                ));
            }
            let proof = root_actor_runtime::RootActorWriteProof::new(
                self.sessions_dir.join(&question.parent.session_id),
                owner.clone(),
            );
            proof.validate()?;
            Some(proof)
        } else {
            None
        };
        let mut guards = DefaultWriterGuards::shared_with_root_origin(
            lifecycle, task, writer, root_guard, origin,
        );
        let Some(parent) = self
            .load_session_unlocked(&question.parent.session_id)
            .await?
        else {
            return Ok(None);
        };
        let Some(mut child) = self
            .load_session_unlocked(&question.child.session_id)
            .await?
        else {
            return Ok(None);
        };
        if parent.id != question.parent.session_id
            || parent.created_at != question.parent.created_at
            || child.id != question.child.session_id
            || child.created_at != question.child.created_at
            || !parent_request_is_durable(&parent, question)
        {
            return Ok(None);
        }
        if let Some(terminal) = ParentQuestionResolution::from_child(&parent, &child, &question.id)
        {
            if terminal.request == *question {
                if let Some(proof) = &guards.root_origin {
                    proof.validate()?;
                }
                publish(&child);
                return Ok(Some((child, false)));
            }
            return Ok(None);
        }
        if Utc::now() >= question.deadline
            || ParentQuestion::for_pending(&parent, &child).as_ref() != Some(question)
        {
            return Ok(None);
        }
        let original = child.clone();
        let Some(paired) = child
            .messages
            .iter_mut()
            .find(|message| message.id == question.tool_result_message_id)
        else {
            return Ok(None);
        };
        paired.content = text.to_owned();
        paired.tool_success = Some(true);
        let Some(resolution) = ParentQuestionResolution::answered(question, Utc::now(), text)
        else {
            return Ok(None);
        };
        child.metadata.insert(
            PARENT_QUESTION_RESOLUTION_KEY.into(),
            serde_json::to_string(&resolution)
                .map_err(|error| other_io_error(error.to_string()))?,
        );
        let parent_directory = self.abs_path_from_rel(&Self::default_writer_rel_path(&parent)?);
        let child_directory = self.abs_path_from_rel(&Self::default_writer_rel_path(&child)?);
        let candidate = child.clone();
        let request = question.clone();
        let proof = Self::default_writer_job(&guards, move || {
            parent_question_answer_proof::ParentQuestionAnswerProof::capture(
                parent_directory,
                child_directory,
                &original,
                &candidate,
                &request,
            )
        })
        .await?;
        Arc::get_mut(&mut guards)
            .expect("answer proof before publication jobs")
            .parent_question_answer = Some(proof);
        self.save_session_after_lock(&child, started, &guards, Some(question))
            .await?;
        if let Some(proof) = &guards.root_origin {
            proof.validate()?;
        }
        guards
            .parent_question_answer
            .as_ref()
            .expect("exact answer proof")
            .validate_publication()?;
        publish(&child);
        Ok(Some((child, true)))
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use bamboo_domain::{FunctionCall, ParentQuestionResolution, PendingQuestion, ToolCall};

    #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
    async fn expired_root_answer_cannot_publish_child_winner_at_final_main_replace() {
        use super::super::default_actor_context_tests::DefaultWriteHook;
        use bamboo_domain::{ActorActivationClaim, ActorDirectoryPort, RootActorRuntimeWrite};
        use std::sync::atomic::{AtomicUsize, Ordering};

        struct Release(Arc<DefaultWriteHook>);
        impl Drop for Release {
            fn drop(&mut self) {
                self.0.release();
            }
        }
        let temp = tempfile::tempdir().unwrap();
        let store = Arc::new(SessionStoreV2::new(temp.path().into()).await.unwrap());
        let mut parent = Session::new("origin-parent", "model");
        store.save_session(&parent).await.unwrap();
        let mut child = Session::new_child_of("origin-child", &parent, "model", "Child");
        child.add_message(Message::user("assignment"));
        child.set_last_run_status("running");
        store.save_session(&child).await.unwrap();
        let observed = observation(&child.messages, PendingQuestionSource::AgenticClarification);
        let (before, question) = store
            .checkpoint_parent_question(&child, &parent, &observed)
            .await
            .unwrap()
            .unwrap();
        parent.add_message(question.envelope().to_provider_message().unwrap());
        store.save_session(&parent).await.unwrap();
        let now = Utc::now();
        let deadline = now + chrono::Duration::seconds(2);
        let claim = store
            .claim_activation(&ActorActivationClaim {
                actor_id: parent.id.clone(),
                run_id: "answer-a".into(),
                lease_owner: "host-a".into(),
                lease_expires_at: deadline,
                inbox_generation: 0,
                placement_ref: None,
                now,
            })
            .await
            .unwrap();
        store
            .start_activation(&claim.fence(), Utc::now())
            .await
            .unwrap();
        let owner = RootActorRuntimeWrite {
            fence: claim.fence(),
            created_at: parent.created_at,
        };
        let child_path = store
            .sessions_dir
            .join(&parent.id)
            .join("children")
            .join(&child.id)
            .join("session.json");
        let bytes = std::fs::read(&child_path).unwrap();
        let hook = DefaultWriteHook::install(
            &store,
            "session.json",
            DurableWritePhase::BeforeReplace,
            false,
        );
        let _release = Release(hook.clone());
        let calls = Arc::new(AtomicUsize::new(0));
        let published = calls.clone();
        let active = store.clone();
        let request = question.clone();
        let job = tokio::spawn(async move {
            active
                .answer_parent_question_with_root_writer(&request, "A", Some(&owner), move |_| {
                    published.fetch_add(1, Ordering::SeqCst);
                })
                .await
        });
        hook.wait();
        while Utc::now() <= deadline {
            tokio::time::sleep(Duration::from_millis(20)).await;
        }
        hook.release();
        assert!(tokio::time::timeout(Duration::from_secs(10), job)
            .await
            .unwrap()
            .unwrap()
            .is_err());
        assert_eq!(std::fs::read(&child_path).unwrap(), bytes);
        assert_eq!(calls.load(Ordering::SeqCst), 0);
        let cold = store.load_session(&child.id).await.unwrap().unwrap();
        assert_eq!(
            serde_json::to_value(&cold.messages).unwrap(),
            serde_json::to_value(&before.messages).unwrap()
        );
        assert_eq!(
            ParentQuestionResolution::from_child(&parent, &cold, &question.id),
            None
        );
        let other = SessionStoreV2::new(temp.path().into()).await.unwrap();
        let now = Utc::now();
        let successor = other
            .claim_activation(&ActorActivationClaim {
                actor_id: parent.id.clone(),
                run_id: "answer-b".into(),
                lease_owner: "host-b".into(),
                lease_expires_at: now + chrono::Duration::seconds(30),
                inbox_generation: 0,
                placement_ref: None,
                now,
            })
            .await
            .unwrap();
        assert!(successor.lease_epoch > claim.lease_epoch);
        other
            .start_activation(&successor.fence(), Utc::now())
            .await
            .unwrap();
        let owner = RootActorRuntimeWrite {
            fence: successor.fence(),
            created_at: parent.created_at,
        };
        let (saved, wrote) = other
            .answer_parent_question_with_root_writer(&question, "B", Some(&owner), |_| {})
            .await
            .unwrap()
            .unwrap();
        assert!(wrote);
        assert_eq!(saved.messages.last().unwrap().content, "B");
        assert!(ParentQuestionResolution::from_child(&parent, &saved, &question.id).is_some());
    }

    fn observation(
        prefix: &[Message],
        source: PendingQuestionSource,
    ) -> ParentQuestionCheckpointV1 {
        let assistant = Message::assistant(
            "",
            Some(vec![ToolCall {
                id: "question-call".into(),
                tool_type: "function".into(),
                function: FunctionCall {
                    name: "AgenticQuestion".into(),
                    arguments: "{}".into(),
                },
            }]),
        );
        let result = Message::tool_result_with_status(
            "question-call",
            "Clarification needed: Which option?",
            true,
        );
        let pending = PendingQuestion {
            tool_call_id: "question-call".into(),
            tool_name: "AgenticQuestion".into(),
            question: "Which option?".into(),
            options: vec!["A".into(), "B".into()],
            allow_custom: true,
            source,
        };
        ParentQuestionCheckpointV1 {
            version: 1,
            prefix_message_count: prefix.len(),
            prefix_digest: ParentQuestion::prefix_digest(prefix).unwrap(),
            suffix: vec![assistant, result.clone()],
            tool_call_id: pending.tool_call_id.clone(),
            question_digest: ParentQuestion::question_digest(&pending, &result.id),
            tool_result_message_id: result.id,
            pending,
        }
    }

    #[tokio::test]
    async fn child_question_checkpoint_is_atomic_replayable_and_rejects_pause_source() {
        let temp = tempfile::tempdir().unwrap();
        let store = SessionStoreV2::new(temp.path().to_path_buf())
            .await
            .unwrap();
        let parent = Session::new("question-parent", "model");
        store.save_session(&parent).await.unwrap();
        let mut child = Session::new_child_of("question-child", &parent, "model", "Child");
        child.add_message(Message::user("assignment"));
        child.set_last_run_status("running");
        store.save_session(&child).await.unwrap();
        let mut forged = observation(&child.messages, PendingQuestionSource::PauseTool);
        assert!(store
            .checkpoint_parent_question(&child, &parent, &forged)
            .await
            .unwrap()
            .is_none());
        forged.pending.source = PendingQuestionSource::AgenticClarification;
        forged.question_digest =
            ParentQuestion::question_digest(&forged.pending, &forged.tool_result_message_id);
        forged.suffix[1].content = "Clarification needed: a different question".into();
        assert!(store
            .checkpoint_parent_question(&child, &parent, &forged)
            .await
            .unwrap()
            .is_none());
        let valid = observation(&child.messages, PendingQuestionSource::AgenticClarification);
        let (saved, issued) = store
            .checkpoint_parent_question(&child, &parent, &valid)
            .await
            .unwrap()
            .unwrap();
        assert_eq!(saved.messages.len(), child.messages.len() + 2);
        assert_eq!(
            ParentQuestion::for_pending(&parent, &saved),
            Some(issued.clone())
        );
        let reopened = SessionStoreV2::new(temp.path().to_path_buf())
            .await
            .unwrap();
        let (replayed, same) = reopened
            .checkpoint_parent_question(&child, &parent, &valid)
            .await
            .unwrap()
            .unwrap();
        assert_eq!(same.id, issued.id);
        assert_eq!(replayed.messages.len(), saved.messages.len());
        let mut answered = replayed;
        let resolution = ParentQuestionResolution::answered(&issued, Utc::now(), "A").unwrap();
        answered
            .messages
            .iter_mut()
            .find(|message| message.id == issued.tool_result_message_id)
            .unwrap()
            .content = "A".into();
        answered.metadata.insert(
            PARENT_QUESTION_RESOLUTION_KEY.into(),
            serde_json::to_string(&resolution).unwrap(),
        );
        reopened.save_session(&answered).await.unwrap();
        let (replayed_after_answer, same) = reopened
            .checkpoint_parent_question(&child, &parent, &valid)
            .await
            .unwrap()
            .expect("lost ACK is stable after the parent rewrites the Tool result");
        assert_eq!(same.id, issued.id);
        assert_eq!(
            replayed_after_answer.messages.len(),
            answered.messages.len()
        );
        assert_eq!(replayed_after_answer.messages.last().unwrap().content, "A");
        let mut stale = valid;
        stale.prefix_digest = bamboo_domain::SessionMessageId::new();
        assert!(reopened
            .checkpoint_parent_question(&child, &parent, &stale)
            .await
            .unwrap()
            .is_none());
    }

    #[tokio::test]
    async fn choice_only_child_question_checkpoints_with_exact_options() {
        let temp = tempfile::tempdir().unwrap();
        let store = SessionStoreV2::new(temp.path().to_path_buf())
            .await
            .unwrap();
        let parent = Session::new("choice-parent", "model");
        store.save_session(&parent).await.unwrap();
        let mut child = Session::new_child_of("choice-child", &parent, "model", "Child");
        child.add_message(Message::user("assignment"));
        child.set_last_run_status("running");
        store.save_session(&child).await.unwrap();

        let mut observed =
            observation(&child.messages, PendingQuestionSource::AgenticClarification);
        observed.pending.allow_custom = false;
        observed.pending.options.clear();
        observed.question_digest =
            ParentQuestion::question_digest(&observed.pending, &observed.tool_result_message_id);
        assert!(store
            .checkpoint_parent_question(&child, &parent, &observed)
            .await
            .unwrap()
            .is_none());

        observed.pending.options = vec!["A".into(), "B".into()];
        observed.question_digest =
            ParentQuestion::question_digest(&observed.pending, &observed.tool_result_message_id);
        let (saved, question) = store
            .checkpoint_parent_question(&child, &parent, &observed)
            .await
            .unwrap()
            .expect("Host must accept a choice-only Child question with offered options");
        assert!(!question.allow_custom);
        assert_eq!(
            ParentQuestion::for_pending(&parent, &saved),
            Some(question.clone())
        );
        assert!(question.validate_answer("A").is_ok());
        assert!(question.validate_answer("C").is_err());
        assert_eq!(
            store
                .checkpoint_parent_question(&child, &parent, &observed)
                .await
                .unwrap()
                .unwrap()
                .1,
            question
        );
    }
}