mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
chore(desktop): clear desktop-tauri clippy backlog (#1612)
Signed-off-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
@@ -27,7 +27,7 @@ fn make_observer_frame(owner_keys: &Keys, agent_keys: &Keys, frame_type: &str) -
|
||||
Tag::parse(["agent", &agent_pk]).unwrap(),
|
||||
Tag::parse(["frame", frame_type]).unwrap(),
|
||||
];
|
||||
EventBuilder::new(Kind::Custom(24200), &"A".repeat(200))
|
||||
EventBuilder::new(Kind::Custom(24200), "A".repeat(200))
|
||||
.tags(tags)
|
||||
.sign_with_keys(agent_keys)
|
||||
.unwrap()
|
||||
@@ -170,7 +170,7 @@ fn test_ephemeral_validator_rejects_missing_p_tag() {
|
||||
let owner_pk = owner_keys.public_key().to_hex();
|
||||
let relay_url = "wss://relay.example";
|
||||
add_sub(&conn, &owner_pk, relay_url, "owner_p", &owner_pk, "[24200]");
|
||||
let ev = EventBuilder::new(Kind::Custom(24200), &"A".repeat(200))
|
||||
let ev = EventBuilder::new(Kind::Custom(24200), "A".repeat(200))
|
||||
.tags(vec![
|
||||
Tag::parse(["agent", &agent_keys.public_key().to_hex()]).unwrap(),
|
||||
Tag::parse(["frame", OBSERVER_FRAME_TELEMETRY]).unwrap(),
|
||||
@@ -190,7 +190,7 @@ fn test_ephemeral_validator_rejects_missing_agent_tag() {
|
||||
let owner_pk = owner_keys.public_key().to_hex();
|
||||
let relay_url = "wss://relay.example";
|
||||
add_sub(&conn, &owner_pk, relay_url, "owner_p", &owner_pk, "[24200]");
|
||||
let ev = EventBuilder::new(Kind::Custom(24200), &"A".repeat(200))
|
||||
let ev = EventBuilder::new(Kind::Custom(24200), "A".repeat(200))
|
||||
.tags(vec![
|
||||
Tag::parse(["p", &owner_pk]).unwrap(),
|
||||
Tag::parse(["frame", OBSERVER_FRAME_TELEMETRY]).unwrap(),
|
||||
@@ -225,7 +225,7 @@ fn test_ephemeral_validator_rejects_wrong_author() {
|
||||
let owner_pk = owner_keys.public_key().to_hex();
|
||||
let relay_url = "wss://relay.example";
|
||||
add_sub(&conn, &owner_pk, relay_url, "owner_p", &owner_pk, "[24200]");
|
||||
let ev = EventBuilder::new(Kind::Custom(24200), &"A".repeat(200))
|
||||
let ev = EventBuilder::new(Kind::Custom(24200), "A".repeat(200))
|
||||
.tags(vec![
|
||||
Tag::parse(["p", &owner_pk]).unwrap(),
|
||||
Tag::parse(["agent", &agent_keys.public_key().to_hex()]).unwrap(),
|
||||
|
||||
@@ -256,6 +256,7 @@ pub(super) async fn query_buckets(buckets: Vec<Bucket>, state: &AppState) -> Vec
|
||||
/// every write in the batch commits or none do. This preserves the invariant
|
||||
/// that every `archived_events` row has at least one matching `archived_event_scopes`
|
||||
/// row — a partial failure can never leave an orphaned event with no scope proof.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(super) fn commit_archive(
|
||||
bucket_results: Vec<BucketWithResult>,
|
||||
ephemeral: Vec<Parsed>,
|
||||
|
||||
@@ -390,6 +390,8 @@ pub fn get_subscription_kinds(
|
||||
/// Upsert an event row (idempotent on the PK).
|
||||
///
|
||||
/// Does nothing if the event is already archived (same identity/relay/id).
|
||||
// Args mirror the archived_events columns; a params struct would just rename them.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn upsert_archived_event(
|
||||
conn: &Connection,
|
||||
identity_pubkey: &str,
|
||||
@@ -471,6 +473,8 @@ pub fn upsert_event_scope(
|
||||
/// An optional `kinds` slice filters by event kind; `None` admits all kinds.
|
||||
///
|
||||
/// Returns at most `limit` rows (caller is responsible for a sane default).
|
||||
// Query surface: four scope keys + kind filter + compound cursor + limit.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn read_archived_events(
|
||||
conn: &Connection,
|
||||
identity_pubkey: &str,
|
||||
|
||||
@@ -366,16 +366,16 @@ fn openai_dated_snapshot_alias(id: &str) -> Option<String> {
|
||||
fn openai_model_display_name(id: &str) -> String {
|
||||
let canonical = openai_dated_snapshot_alias(id).unwrap_or_else(|| id.to_string());
|
||||
if let Some(rest) = canonical.strip_prefix("chatgpt-") {
|
||||
return format!("ChatGPT {}", title_case_model_suffix(rest, false));
|
||||
return format!("ChatGPT {}", title_case_model_suffix(rest));
|
||||
}
|
||||
if let Some(rest) = canonical.strip_prefix("gpt-") {
|
||||
return format!("GPT-{}", title_case_model_suffix(rest, true));
|
||||
return format!("GPT-{}", title_case_model_suffix(rest));
|
||||
}
|
||||
|
||||
canonical
|
||||
}
|
||||
|
||||
fn title_case_model_suffix(value: &str, preserve_first_separator: bool) -> String {
|
||||
fn title_case_model_suffix(value: &str) -> String {
|
||||
value
|
||||
.split('-')
|
||||
.enumerate()
|
||||
@@ -390,9 +390,7 @@ fn title_case_model_suffix(value: &str, preserve_first_separator: bool) -> Strin
|
||||
part.to_string()
|
||||
};
|
||||
|
||||
if preserve_first_separator && index == 0 {
|
||||
part
|
||||
} else if index == 0 {
|
||||
if index == 0 {
|
||||
part
|
||||
} else {
|
||||
format!(" {part}")
|
||||
|
||||
@@ -774,7 +774,7 @@ You are Paul.
|
||||
description: None,
|
||||
persona_ids: vec![],
|
||||
is_builtin: false,
|
||||
source_dir: source_dir.map(|s| std::path::PathBuf::from(s)),
|
||||
source_dir: source_dir.map(std::path::PathBuf::from),
|
||||
is_symlink: false,
|
||||
symlink_target: None,
|
||||
version: None,
|
||||
|
||||
@@ -65,12 +65,13 @@ mod tests {
|
||||
/// logic as read_config_file but without touching the filesystem.
|
||||
fn parse_settings(json: &str) -> RuntimeFileConfig {
|
||||
let val: serde_json::Value = serde_json::from_str(json).unwrap();
|
||||
let mut cfg = RuntimeFileConfig::default();
|
||||
cfg.model = json_string(&val, "model");
|
||||
cfg.thinking_effort = json_string(&val, "effortLevel");
|
||||
let skip = &["model", "effortLevel"];
|
||||
cfg.extra = super::super::schema_walker::extract_config_fields(&val, skip);
|
||||
cfg
|
||||
RuntimeFileConfig {
|
||||
model: json_string(&val, "model"),
|
||||
thinking_effort: json_string(&val, "effortLevel"),
|
||||
extra: super::super::schema_walker::extract_config_fields(&val, skip),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -209,6 +209,7 @@ pub(crate) fn read_config_surface(
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn build_model_field(
|
||||
record_model: &Option<String>,
|
||||
file_model: &Option<String>,
|
||||
@@ -516,18 +517,19 @@ fn build_system_prompt_field(
|
||||
})
|
||||
}
|
||||
|
||||
/// Picks the first `Some` value from `tiers` (highest-precedence first) and
|
||||
/// returns `(value, origin, overridden_value, overridden_origin)` where the
|
||||
/// overridden pair is the next `Some` tier after the winner. Returns `None`
|
||||
/// when no tier has a value.
|
||||
fn resolve_with_override(
|
||||
tiers: &[(Option<&str>, ConfigOrigin)],
|
||||
) -> Option<(
|
||||
/// `(value, origin, overridden_value, overridden_origin)` — the resolved
|
||||
/// winner plus the next `Some` tier it shadows, if any.
|
||||
type ResolvedOverride = (
|
||||
Option<String>,
|
||||
ConfigOrigin,
|
||||
Option<String>,
|
||||
Option<ConfigOrigin>,
|
||||
)> {
|
||||
);
|
||||
|
||||
/// Picks the first `Some` value from `tiers` (highest-precedence first);
|
||||
/// the overridden pair is the next `Some` tier after the winner. Returns
|
||||
/// `None` when no tier has a value.
|
||||
fn resolve_with_override(tiers: &[(Option<&str>, ConfigOrigin)]) -> Option<ResolvedOverride> {
|
||||
let winner_idx = tiers.iter().position(|(v, _)| v.is_some())?;
|
||||
let (value, origin) = &tiers[winner_idx];
|
||||
let value = value.map(str::to_string);
|
||||
|
||||
@@ -66,6 +66,9 @@ pub(crate) struct EffectiveAgentEnv {
|
||||
/// The process-env map the spawned harness would receive.
|
||||
pub env: BTreeMap<String, String>,
|
||||
/// Harness config file path, if any (e.g. `~/.config/goose/config.yaml`).
|
||||
// Not read yet; kept for the unified-agent-record rewrite (chunk A) which
|
||||
// replaces this resolution path wholesale.
|
||||
#[allow(dead_code)]
|
||||
pub config_file_path: Option<&'static str>,
|
||||
/// The resolved harness binary name (e.g. `"buzz-agent"`, `"goose"`).
|
||||
pub effective_command: String,
|
||||
@@ -150,17 +153,6 @@ pub enum Requirement {
|
||||
},
|
||||
}
|
||||
|
||||
impl Requirement {
|
||||
/// Short label for logging/nudge copy.
|
||||
pub(crate) fn label(&self) -> String {
|
||||
match self {
|
||||
Requirement::NormalizedField { field } => format!("missing {field}"),
|
||||
Requirement::EnvKey { key } => format!("missing env {key}"),
|
||||
Requirement::CliLogin { setup_copy, .. } => setup_copy.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── AgentReadiness ────────────────────────────────────────────────────────────
|
||||
|
||||
/// Whether a managed agent has all required configuration to start.
|
||||
@@ -178,11 +170,13 @@ pub enum AgentReadiness {
|
||||
|
||||
impl AgentReadiness {
|
||||
/// Returns `true` if the agent is ready to spawn.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn is_ready(&self) -> bool {
|
||||
matches!(self, AgentReadiness::Ready)
|
||||
}
|
||||
|
||||
/// Returns the missing requirements, or an empty slice if ready.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn requirements(&self) -> &[Requirement] {
|
||||
match self {
|
||||
AgentReadiness::Ready => &[],
|
||||
@@ -290,31 +284,28 @@ fn buzz_agent_requirements(effective: &EffectiveAgentEnv) -> Vec<Requirement> {
|
||||
// Provider-specific credential requirements.
|
||||
// A key present with an empty value is treated as absent — matching the
|
||||
// dialog's (envVars[key] ?? "").length === 0 emptiness check.
|
||||
let env_key_missing = |key: &str| effective.env.get(key).map_or(true, |v| v.is_empty());
|
||||
let env_key_missing = |key: &str| effective.env.get(key).is_none_or(|v| v.is_empty());
|
||||
match provider {
|
||||
Some("anthropic") => {
|
||||
if env_key_missing("ANTHROPIC_API_KEY") {
|
||||
Some("anthropic")
|
||||
if env_key_missing("ANTHROPIC_API_KEY") => {
|
||||
missing.push(Requirement::EnvKey {
|
||||
key: "ANTHROPIC_API_KEY".to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
Some("openai") => {
|
||||
if env_key_missing("OPENAI_COMPAT_API_KEY") {
|
||||
Some("openai")
|
||||
if env_key_missing("OPENAI_COMPAT_API_KEY") => {
|
||||
missing.push(Requirement::EnvKey {
|
||||
key: "OPENAI_COMPAT_API_KEY".to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
Some("databricks") | Some("databricks_v2") => {
|
||||
Some("databricks") | Some("databricks_v2")
|
||||
// DATABRICKS_HOST is hard-required; DATABRICKS_TOKEN is optional
|
||||
// (OAuth PKCE is the normal path — see buzz-agent/src/config.rs:143).
|
||||
if env_key_missing("DATABRICKS_HOST") {
|
||||
if env_key_missing("DATABRICKS_HOST") => {
|
||||
missing.push(Requirement::EnvKey {
|
||||
key: "DATABRICKS_HOST".to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
// Unknown provider or no provider yet — only the NormalizedField
|
||||
// requirement above captures this gap.
|
||||
@@ -390,38 +381,37 @@ fn goose_requirements(
|
||||
}
|
||||
|
||||
// Provider-specific credentials — same empty-string semantics as buzz-agent.
|
||||
let env_key_missing = |key: &str| effective.env.get(key).map_or(true, |v| v.is_empty());
|
||||
let env_key_missing = |key: &str| effective.env.get(key).is_none_or(|v| v.is_empty());
|
||||
// A credential key is also satisfied when the file config's `extra` map
|
||||
// contains it (e.g. DATABRICKS_HOST set in the goose config file).
|
||||
let file_key_present = |key: &str| -> bool {
|
||||
file_cfg
|
||||
.as_ref()
|
||||
.map(|c| c.extra.get(key).map_or(false, |v| !v.is_empty()))
|
||||
.map(|c| c.extra.get(key).is_some_and(|v| !v.is_empty()))
|
||||
.unwrap_or(false)
|
||||
};
|
||||
match effective_provider {
|
||||
Some("anthropic") => {
|
||||
if env_key_missing("ANTHROPIC_API_KEY") && !file_key_present("ANTHROPIC_API_KEY") {
|
||||
missing.push(Requirement::EnvKey {
|
||||
key: "ANTHROPIC_API_KEY".to_string(),
|
||||
});
|
||||
}
|
||||
Some("anthropic")
|
||||
if env_key_missing("ANTHROPIC_API_KEY") && !file_key_present("ANTHROPIC_API_KEY") =>
|
||||
{
|
||||
missing.push(Requirement::EnvKey {
|
||||
key: "ANTHROPIC_API_KEY".to_string(),
|
||||
});
|
||||
}
|
||||
Some("openai") => {
|
||||
Some("openai")
|
||||
if env_key_missing("OPENAI_COMPAT_API_KEY")
|
||||
&& !file_key_present("OPENAI_COMPAT_API_KEY")
|
||||
{
|
||||
missing.push(Requirement::EnvKey {
|
||||
key: "OPENAI_COMPAT_API_KEY".to_string(),
|
||||
});
|
||||
}
|
||||
&& !file_key_present("OPENAI_COMPAT_API_KEY") =>
|
||||
{
|
||||
missing.push(Requirement::EnvKey {
|
||||
key: "OPENAI_COMPAT_API_KEY".to_string(),
|
||||
});
|
||||
}
|
||||
Some("databricks") | Some("databricks_v2") => {
|
||||
if env_key_missing("DATABRICKS_HOST") && !file_key_present("DATABRICKS_HOST") {
|
||||
missing.push(Requirement::EnvKey {
|
||||
key: "DATABRICKS_HOST".to_string(),
|
||||
});
|
||||
}
|
||||
Some("databricks") | Some("databricks_v2")
|
||||
if env_key_missing("DATABRICKS_HOST") && !file_key_present("DATABRICKS_HOST") =>
|
||||
{
|
||||
missing.push(Requirement::EnvKey {
|
||||
key: "DATABRICKS_HOST".to_string(),
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ use path::build_augmented_path;
|
||||
|
||||
mod sweep;
|
||||
pub(crate) use sweep::sweep_untracked_bundle_harnesses;
|
||||
pub use sweep::{expected_harness_exe_path, select_untracked_bundle_harnesses, ProcessSnapshot};
|
||||
|
||||
type RespondToEnv = (Vec<(&'static str, String)>, Vec<&'static str>);
|
||||
|
||||
@@ -70,9 +69,7 @@ fn name_matches_known_binary(name: &str) -> bool {
|
||||
/// a managed agent wrapper (e.g. `node` running an npm shim for `codex-acp`).
|
||||
/// Callers must additionally verify `BUZZ_MANAGED_AGENT` ownership.
|
||||
fn name_matches_interpreter(name: &str) -> bool {
|
||||
KNOWN_SCRIPT_INTERPRETERS
|
||||
.iter()
|
||||
.any(|&interp| name == interp)
|
||||
KNOWN_SCRIPT_INTERPRETERS.contains(&name)
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
||||
Reference in New Issue
Block a user