Commit 08f317bd
08f317bd2742Merged
Scott Nixon <[email protected]> · 7 months ago · 11 files · +1 added · ~10 modified
Description
fix: resolve 13 bugs found in codebase audit across 8 crates
- Fix UTF-8 byte-slice panics in truncation, agent, prompt_builder, codergen_handler, and DOT parser (use char boundaries / chars iterator)
- Prevent infinite loop on empty old_string in edit_file tool
- Guard LoopDetector panic on window_size=0
- Cache normalize_label regex with OnceLock instead of recompiling per call
- Fix engine step counter off-by-one (> to >=)
- Reject non-zero exit code in codergen_handler even when stdout present
- Add -- separator in ripgrep to prevent pattern-as-flag injection
- Sort HashMap keys in prompt_builder for deterministic output
Remaining 16 issues documented in docs/plans/ for follow-up.
Details
- Commit
- 08f317bd2742
- Parent
- bea5f23a6443
crates/attractor-agent/src/lib.rsmodifiedView file
@@ -166,16 +166,15 @@
166166
167167
/// Push a steering message to be injected at the next tool round boundary.168168
pub fn steer(&mut self, message: String) {169-
tracing::debug!(170-
"Steering message queued: {}",171-
&message[..message.len().min(80)]172-
);169+
let preview: String = message.chars().take(80).collect();170+
tracing::debug!("Steering message queued: {}", preview);173171
self.steering_queue.push(message);174172
}175173
176174
/// Push a follow-up input to be processed after the current input completes.177175
pub fn follow_up(&mut self, message: String) {178-
tracing::debug!("Follow-up queued: {}", &message[..message.len().min(80)]);176+
let preview: String = message.chars().take(80).collect();177+
tracing::debug!("Follow-up queued: {}", preview);179178
self.followup_queue.push_back(message);180179
}181180
@@ -383,10 +382,15 @@
383382
Some(tool) => match tool.execute(tc.arguments.clone(), self.env.as_ref()).await {384383
Ok(output) => {385384
let truncated = if output.len() > MAX_TOOL_OUTPUT_LEN {386-
let mut t = output[..MAX_TOOL_OUTPUT_LEN].to_string();385+
// Find a char-boundary-safe split point386+
let mut split = MAX_TOOL_OUTPUT_LEN;387+
while split > 0 && !output.is_char_boundary(split) {388+
split -= 1;389+
}390+
let mut t = output[..split].to_string();387391
t.push_str(&format!(388392
"\n\n[WARNING: Output truncated. {} characters removed.]",389-
output.len() - MAX_TOOL_OUTPUT_LEN393+
output.len() - split390394
));391395
t392396
} else {crates/attractor-agent/src/loop_detection.rsmodifiedView file
Loading diff…
crates/attractor-agent/src/prompt_builder.rsmodifiedView file
Loading diff…
crates/attractor-dot/src/parser.rsmodifiedView file
Loading diff…
crates/attractor-pipeline/src/edge_selection.rsmodifiedView file
Loading diff…
crates/attractor-pipeline/src/engine.rsmodifiedView file
Loading diff…
crates/attractor-pipeline/src/handlers/codergen_handler.rsmodifiedView file
Loading diff…
crates/attractor-tools/src/builtin/edit_file.rsmodifiedView file
Loading diff…
crates/attractor-tools/src/local_env.rsmodifiedView file
Loading diff…
crates/attractor-tools/src/truncation.rsmodifiedView file
Loading diff…
docs/plans/2026-04-14-fix-codebase-audit-outstanding-issues.mdaddedView file
Loading diff…