Skip to content

Commit e45d408

Browse files
npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7wpfleger96
andcommitted
chore(buzz-acp): merge boot-recovery ledger infrastructure onto origin/main
Integrates the full boot-recovery/ledger subsystem (a17863c) onto origin/main (daf1f40). Semantic conflict resolution: lib.rs: kept origin/main's handle_prompt_result with the new TimeoutKind::Hard { recently_active: bool } split (#2175). Updated classify_and_complete_batch (the shutdown-drain seam) to handle both recently_active variants with matching retry/dead-letter semantics. Updated three BatchEvent initializers in #2175 tests to include the four admission/recovery fields added by our boot-recovery work. queue.rs: took both sides — origin/main's extend_in_flight_deadline and its tests (#2175 steer renewal) + our set_next_admission_seq, recoverable_triggers, take_dirty_channels, and their tests. Made requeue/requeue_as_cancelled pub to match origin/main (handle_prompt_ result calls them directly in the main loop; classify_and_complete_ batch calls them via complete_batch — both usages are valid). Co-authored-by: Will Pfleger <[email protected]> Signed-off-by: Will Pfleger <[email protected]>
2 parents daf1f40 + a17863c commit e45d408

8 files changed

Lines changed: 3711 additions & 199 deletions

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/buzz-acp/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@ nix = { version = "0.31", default-features = false, features = ["signal"] }
7979
[dev-dependencies]
8080
tokio = { workspace = true, features = ["test-util"] }
8181
httparse = "1"
82+
tempfile = "3"

‎crates/buzz-acp/src/config.rs‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,22 @@ pub struct CliArgs {
418418
)]
419419
pub base_prompt_file: Option<PathBuf>,
420420

421+
/// Resume in-progress work on restart (kill -9, crash, manual restart,
422+
/// or app update) by replaying a durable pending-turn ledger on boot.
423+
/// On by default. See `PLANS/AGENT_AUTO_RESUME_LEDGER.md`.
424+
#[arg(long, env = "BUZZ_ACP_RESUME_ON_RESTART", default_value_t = true)]
425+
pub resume_on_restart: bool,
426+
427+
/// TTL (seconds) for resume ledger entries, by original admission time.
428+
/// 0 = no expiry (default) — the ledger only ever holds never-completed
429+
/// turns, so even a long-idle relaunch should still resume them.
430+
#[arg(long, env = "BUZZ_ACP_RESUME_TTL", default_value_t = 0)]
431+
pub resume_ttl_secs: u64,
432+
433+
/// Directory for the resume ledger file. Defaults to `<cwd>/.buzz-acp/`.
434+
#[arg(long, env = "BUZZ_ACP_STATE_DIR")]
435+
pub state_dir: Option<PathBuf>,
436+
421437
/// Desired LLM model ID. Applied to every new ACP session after creation.
422438
/// Use `buzz-acp models` to discover available model IDs.
423439
#[arg(long, env = "BUZZ_ACP_MODEL")]
@@ -546,6 +562,14 @@ pub struct Config {
546562
/// `from_cli()`. `None` when using the compiled-in default or when
547563
/// `--no-base-prompt` is set.
548564
pub base_prompt_content: Option<String>,
565+
/// Whether to replay the durable pending-turn ledger on boot. On by
566+
/// default; `--resume-on-restart=false` restores today's stateless-boot
567+
/// behavior.
568+
pub resume_on_restart: bool,
569+
/// TTL (seconds) for resume ledger entries. 0 = no expiry (default).
570+
pub resume_ttl_secs: u64,
571+
/// Directory for the resume ledger file. `None` = `<cwd>/.buzz-acp/`.
572+
pub state_dir: Option<PathBuf>,
549573
}
550574

551575
/// Validate and deduplicate allowlist entries: each must be exactly 64 hex chars.
@@ -996,6 +1020,9 @@ impl Config {
9961020
agent_owner: args.agent_owner.map(|s| s.trim().to_ascii_lowercase()),
9971021
no_base_prompt: args.no_base_prompt,
9981022
base_prompt_content,
1023+
resume_on_restart: args.resume_on_restart,
1024+
resume_ttl_secs: args.resume_ttl_secs,
1025+
state_dir: args.state_dir,
9991026
};
10001027

10011028
Ok(config)
@@ -1017,7 +1044,7 @@ impl Config {
10171044
format!(" allowed_respond_to=[{}]", modes.join(","))
10181045
};
10191046
format!(
1020-
"relay={} pubkey={} agent_cmd={} {} mcp_cmd={} idle_timeout={}s max_turn={}s agents={} heartbeat={}s subscribe={:?} dedup={:?} meh={:?} ignore_self={} context_limit={} max_turns_per_session={} presence={} typing={} memory={} model={} permission_mode={} {}{}",
1047+
"relay={} pubkey={} agent_cmd={} {} mcp_cmd={} idle_timeout={}s max_turn={}s agents={} heartbeat={}s subscribe={:?} dedup={:?} meh={:?} ignore_self={} context_limit={} max_turns_per_session={} presence={} typing={} memory={} model={} permission_mode={} resume={} resume_ttl={}s {}{}",
10211048
self.relay_url,
10221049
self.keys.public_key().to_hex(),
10231050
self.agent_command,
@@ -1038,6 +1065,8 @@ impl Config {
10381065
self.memory_enabled,
10391066
self.model.as_deref().unwrap_or("(agent default)"),
10401067
self.permission_mode,
1068+
self.resume_on_restart,
1069+
self.resume_ttl_secs,
10411070
respond_to_detail,
10421071
allowed_respond_to_detail,
10431072
)
@@ -1364,6 +1393,9 @@ mod tests {
13641393
agent_owner: None,
13651394
no_base_prompt: false,
13661395
base_prompt_content: None,
1396+
resume_on_restart: true,
1397+
resume_ttl_secs: 0,
1398+
state_dir: None,
13671399
}
13681400
}
13691401

0 commit comments

Comments
 (0)