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
//! Shared assembly logic for checkpoint construction.
//! Assembly helpers for resumable run checkpoints.
//!
//! This module combines checkpoint identity data supplied by the caller with
//! state extracted from the session transcript. It keeps construction logic
//! separate from extraction and field-update helpers so each checkpoint module
//! has a single responsibility.
use ;
use PathBuf;
/// Assemble a [`RunCheckpoint`] from identity fields and extracted state.
///
/// The caller provides the stable identity fields for the interrupted run:
/// original objective, exhausted step budget, session identifier, optional
/// workspace path, and message count. The `extracted` argument supplies runtime
/// details recovered from transcript messages, such as browser state, completed
/// actions, blockers, and the inferred next action.
///
/// The function starts from [`checkpoint_defaults::empty_checkpoint`], applies
/// identity fields, then applies extracted transcript state. It performs no I/O
/// and has no side effects outside the returned checkpoint.
///
/// # Arguments
///
/// * `objective` - Original user objective for the run being resumed.
/// * `max_steps` - Step budget that was exhausted.
/// * `session_id` - Identifier of the session that owns the checkpoint.
/// * `workspace` - Optional workspace path associated with the run.
/// * `message_count` - Number of session messages present when checkpointing.
/// * `extracted` - Transcript-derived checkpoint state.
///
/// # Returns
///
/// A populated [`RunCheckpoint`] ready to persist or turn into a resume prompt.
pub