omx(team): auto-checkpoint worker-1 [1]

This commit is contained in:
bellman
2026-05-14 18:11:53 +09:00
parent 7214573f35
commit 0b0d55d7ec
5 changed files with 40 additions and 28 deletions

View File

@@ -212,8 +212,7 @@ fn summarize_messages(messages: &[ConversationMessage]) -> String {
.filter_map(|block| match block { .filter_map(|block| match block {
ContentBlock::ToolUse { name, .. } => Some(name.as_str()), ContentBlock::ToolUse { name, .. } => Some(name.as_str()),
ContentBlock::ToolResult { tool_name, .. } => Some(tool_name.as_str()), ContentBlock::ToolResult { tool_name, .. } => Some(tool_name.as_str()),
ContentBlock::Text { .. } => None, ContentBlock::Text { .. } | ContentBlock::Thinking { .. } => None,
ContentBlock::Thinking { .. } => None,
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
tool_names.sort_unstable(); tool_names.sort_unstable();

View File

@@ -344,7 +344,7 @@ fn glob_search_impl(
if let Some(root) = canonical_root.as_deref() { if let Some(root) = canonical_root.as_deref() {
let canonical_walk_root = walk_root let canonical_walk_root = walk_root
.canonicalize() .canonicalize()
.unwrap_or_else(|_| walk_root.to_path_buf()); .unwrap_or_else(|_| walk_root.clone());
validate_workspace_boundary(&canonical_walk_root, root)?; validate_workspace_boundary(&canonical_walk_root, root)?;
} }
let entries = WalkDir::new(&walk_root) let entries = WalkDir::new(&walk_root)
@@ -484,27 +484,21 @@ fn grep_search_impl(
let (filenames, applied_limit, applied_offset) = let (filenames, applied_limit, applied_offset) =
apply_limit(filenames, input.head_limit, input.offset); apply_limit(filenames, input.head_limit, input.offset);
let content_output = if output_mode == "content" { if output_mode == "content" {
let (lines, limit, offset) = apply_limit(content_lines, input.head_limit, input.offset); return Ok(build_grep_content_output(
return Ok(GrepSearchOutput { output_mode,
mode: Some(output_mode),
num_files: filenames.len(),
filenames, filenames,
num_lines: Some(lines.len()), content_lines,
content: Some(lines.join("\n")), input.head_limit,
num_matches: None, input.offset,
applied_limit: limit, ));
applied_offset: offset, }
});
} else {
None
};
Ok(GrepSearchOutput { Ok(GrepSearchOutput {
mode: Some(output_mode.clone()), mode: Some(output_mode.clone()),
num_files: filenames.len(), num_files: filenames.len(),
filenames, filenames,
content: content_output, content: None,
num_lines: None, num_lines: None,
num_matches: (output_mode == "count").then_some(total_matches), num_matches: (output_mode == "count").then_some(total_matches),
applied_limit, applied_limit,
@@ -512,6 +506,26 @@ fn grep_search_impl(
}) })
} }
fn build_grep_content_output(
output_mode: String,
filenames: Vec<String>,
content_lines: Vec<String>,
head_limit: Option<usize>,
offset: Option<usize>,
) -> GrepSearchOutput {
let (lines, limit, offset) = apply_limit(content_lines, head_limit, offset);
GrepSearchOutput {
mode: Some(output_mode),
num_files: filenames.len(),
filenames,
num_lines: Some(lines.len()),
content: Some(lines.join("\n")),
num_matches: None,
applied_limit: limit,
applied_offset: offset,
}
}
fn canonicalize_workspace_root(workspace_root: &Path) -> PathBuf { fn canonicalize_workspace_root(workspace_root: &Path) -> PathBuf {
workspace_root workspace_root
.canonicalize() .canonicalize()

View File

@@ -2,7 +2,7 @@ use std::time::Duration;
pub type GreenLevel = u8; pub type GreenLevel = u8;
const STALE_BRANCH_THRESHOLD: Duration = Duration::from_secs(60 * 60); const STALE_BRANCH_THRESHOLD: Duration = Duration::from_hours(1);
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct PolicyRule { pub struct PolicyRule {

View File

@@ -298,8 +298,7 @@ fn unshare_user_namespace_works() -> bool {
.stdout(std::process::Stdio::null()) .stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null()) .stderr(std::process::Stdio::null())
.status() .status()
.map(|s| s.success()) .is_ok_and(|status| status.success())
.unwrap_or(false)
}) })
} }

View File

@@ -22,7 +22,7 @@ fn stale_branch_detection_flows_into_policy_engine() {
let stale_context = LaneContext::new( let stale_context = LaneContext::new(
"stale-lane", "stale-lane",
0, 0,
Duration::from_secs(2 * 60 * 60), // 2 hours stale Duration::from_hours(2), // 2 hours stale
LaneBlocker::None, LaneBlocker::None,
ReviewStatus::Pending, ReviewStatus::Pending,
DiffScope::Full, DiffScope::Full,
@@ -49,7 +49,7 @@ fn fresh_branch_does_not_trigger_stale_policy() {
let fresh_context = LaneContext::new( let fresh_context = LaneContext::new(
"fresh-lane", "fresh-lane",
0, 0,
Duration::from_secs(30 * 60), // 30 min stale — under 1 hour threshold Duration::from_mins(30), // 30 min stale — under 1 hour threshold
LaneBlocker::None, LaneBlocker::None,
ReviewStatus::Pending, ReviewStatus::Pending,
DiffScope::Full, DiffScope::Full,
@@ -212,8 +212,8 @@ fn end_to_end_stale_lane_gets_merge_forward_action() {
// when: build context and evaluate policy // when: build context and evaluate policy
let context = LaneContext::new( let context = LaneContext::new(
"lane-9411", "lane-9411",
3, // Workspace green 3, // Workspace green
Duration::from_secs(5 * 60 * 60), // 5 hours stale, definitely over threshold Duration::from_hours(5), // 5 hours stale, definitely over threshold
LaneBlocker::None, LaneBlocker::None,
ReviewStatus::Approved, ReviewStatus::Approved,
DiffScope::Scoped, DiffScope::Scoped,
@@ -261,8 +261,8 @@ fn end_to_end_stale_lane_gets_merge_forward_action() {
fn fresh_approved_lane_gets_merge_action() { fn fresh_approved_lane_gets_merge_action() {
let context = LaneContext::new( let context = LaneContext::new(
"fresh-approved-lane", "fresh-approved-lane",
3, // Workspace green 3, // Workspace green
Duration::from_secs(30 * 60), // 30 min — under 1 hour threshold = fresh Duration::from_mins(30), // 30 min — under 1 hour threshold = fresh
LaneBlocker::None, LaneBlocker::None,
ReviewStatus::Approved, ReviewStatus::Approved,
DiffScope::Scoped, DiffScope::Scoped,
@@ -347,7 +347,7 @@ fn worker_provider_failure_flows_through_recovery_to_policy() {
// (Simulating the policy check that would happen after successful recovery) // (Simulating the policy check that would happen after successful recovery)
let recovery_success = matches!(result, RecoveryResult::Recovered { .. }); let recovery_success = matches!(result, RecoveryResult::Recovered { .. });
let green_level = 3; // Workspace green let green_level = 3; // Workspace green
let not_stale = Duration::from_secs(30 * 60); // 30 min — fresh let not_stale = Duration::from_mins(30); // 30 min — fresh
let post_recovery_context = LaneContext::new( let post_recovery_context = LaneContext::new(
"recovered-lane", "recovered-lane",