Skip to content

Commit 503d515

Browse files
bellmanGajae Code
authored andcommitted
style: cargo fmt after merged PRs (#3164, #3209, #3214, #3216)
Fix formatting inconsistencies introduced by merged external PRs. Generated with https://github.com/Yeachan-Heo/gajae-code Co-authored-by: Gajae Code <dev@gajae-code.com>
1 parent 114c2da commit 503d515

2 files changed

Lines changed: 30 additions & 18 deletions

File tree

rust/crates/runtime/src/permission_enforcer.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -242,19 +242,13 @@ fn is_read_only_command(command: &str) -> bool {
242242
// Shell metacharacters that enable command chaining, substitution,
243243
// piping, redirection, or subshells. Presence of any of these means we
244244
// cannot reason about the command from its leading token alone.
245-
const SHELL_METACHARS: &[char] =
246-
&[';', '|', '&', '$', '`', '>', '<', '(', ')', '{', '}', '\n'];
245+
const SHELL_METACHARS: &[char] = &[';', '|', '&', '$', '`', '>', '<', '(', ')', '{', '}', '\n'];
247246
if command.contains(SHELL_METACHARS) {
248247
return false;
249248
}
250249

251250
let mut tokens = command.split_whitespace();
252-
let first_token = tokens
253-
.next()
254-
.unwrap_or("")
255-
.rsplit('/')
256-
.next()
257-
.unwrap_or("");
251+
let first_token = tokens.next().unwrap_or("").rsplit('/').next().unwrap_or("");
258252

259253
// `git` is only read-only for a curated set of subcommands.
260254
if first_token == "git" {
@@ -503,7 +497,10 @@ mod tests {
503497

504498
#[test]
505499
fn workspace_rejects_parent_traversal() {
506-
assert!(!is_within_workspace("/workspace/../etc/passwd", "/workspace"));
500+
assert!(!is_within_workspace(
501+
"/workspace/../etc/passwd",
502+
"/workspace"
503+
));
507504
assert!(!is_within_workspace(
508505
"/workspace/../../etc/crontab",
509506
"/workspace"
@@ -514,7 +511,10 @@ mod tests {
514511
"/workspace"
515512
));
516513
// Legitimate paths still resolve inside.
517-
assert!(is_within_workspace("/workspace/./src/main.rs", "/workspace"));
514+
assert!(is_within_workspace(
515+
"/workspace/./src/main.rs",
516+
"/workspace"
517+
));
518518
assert!(is_within_workspace(
519519
"/workspace/src/../src/main.rs",
520520
"/workspace"

rust/crates/rusty-claude-cli/src/main.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7781,7 +7781,9 @@ impl LiveCli {
77817781
|| error_str.contains("no parseable body")
77827782
|| error_str.contains("exceed_context_size")
77837783
|| error_str.contains("exceeds the available context size")
7784-
|| error_str.to_ascii_lowercase().contains("context size has been exceeded");
7784+
|| error_str
7785+
.to_ascii_lowercase()
7786+
.contains("context size has been exceeded");
77857787

77867788
// Also treat "assistant stream produced no content" and reqwest decode failures
77877789
// as recoverable errors that may benefit from auto-compaction. Some backends (e.g.
@@ -7888,16 +7890,24 @@ impl LiveCli {
78887890
|| retry_str.contains("no parseable body")
78897891
|| retry_str.contains("exceed_context_size")
78907892
|| retry_str.contains("exceeds the available context size")
7891-
|| retry_str.to_ascii_lowercase().contains("context size has been exceeded");
7892-
let still_no_content = retry_str.contains("assistant stream produced no content")
7893+
|| retry_str
7894+
.to_ascii_lowercase()
7895+
.contains("context size has been exceeded");
7896+
let still_no_content = retry_str
7897+
.contains("assistant stream produced no content")
78937898
|| retry_str.contains("Failed to parse input at pos")
78947899
|| retry_str.contains("error decoding response body");
78957900

7896-
if (still_context_window || still_no_content) && round + 1 < max_compact_rounds {
7901+
if (still_context_window || still_no_content)
7902+
&& round + 1 < max_compact_rounds
7903+
{
78977904
// If the retry error reveals the context window, adapt threshold.
7898-
if let Some(window) = extract_context_window_tokens_from_error(&retry_str) {
7905+
if let Some(window) =
7906+
extract_context_window_tokens_from_error(&retry_str)
7907+
{
78997908
let threshold: u32 = (window as f64 * 0.7).round() as u32;
7900-
new_runtime.set_auto_compaction_input_tokens_threshold(threshold);
7909+
new_runtime
7910+
.set_auto_compaction_input_tokens_threshold(threshold);
79017911
}
79027912

79037913
// The compacted session was still too large for the model's context.
@@ -12831,15 +12841,17 @@ fn extract_context_window_tokens_from_error(error_str: &str) -> Option<u32> {
1283112841
// Pattern: "(NNNNNN tokens)" appearing after context-size markers
1283212842
for line in error_str.lines() {
1283312843
let lowered = line.to_ascii_lowercase();
12834-
if lowered.contains("context size") || lowered.contains("context length")
12844+
if lowered.contains("context size")
12845+
|| lowered.contains("context length")
1283512846
|| lowered.contains("context window")
1283612847
{
1283712848
// Try parenthesised form: (81920 tokens)
1283812849
if let Some(start) = lowered.find('(') {
1283912850
if let Some(end) = lowered.find(")") {
1284012851
if start < end {
1284112852
let inner = &line[start + 1..end];
12842-
let digits: String = inner.chars().take_while(|c| c.is_ascii_digit()).collect();
12853+
let digits: String =
12854+
inner.chars().take_while(|c| c.is_ascii_digit()).collect();
1284312855
if let Ok(n) = digits.parse::<u32>() {
1284412856
if n > 1000 {
1284512857
return Some(n);

0 commit comments

Comments
 (0)