fmt: apply rustfmt across the P2 arc
CI's rustfmt check flagged the multi-line sqlx::query() calls I introduced in P2 (loop_id_for_run, zeroclaw_gateway_url, etc.). No behavior change — pure formatting.
This commit is contained in:
@@ -372,6 +372,8 @@ pub async fn teardown_loop(loop_id: Uuid) {
|
|||||||
};
|
};
|
||||||
match stop(&docker, &name).await {
|
match stop(&docker, &name).await {
|
||||||
Ok(_) => eprintln!("research_container::teardown_loop({loop_id}): removed {name}"),
|
Ok(_) => eprintln!("research_container::teardown_loop({loop_id}): removed {name}"),
|
||||||
Err(e) => eprintln!("research_container::teardown_loop({loop_id}): stop {name} failed: {e}"),
|
Err(e) => {
|
||||||
|
eprintln!("research_container::teardown_loop({loop_id}): stop {name} failed: {e}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,14 +49,13 @@ async fn ensure_loop_container(pool: &PgPool, workspace_id: Uuid, loop_id: Uuid)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let state_root = loop_state_root().join(loop_id.to_string()).join("state");
|
let state_root = loop_state_root().join(loop_id.to_string()).join("state");
|
||||||
let spawned =
|
let spawned = match crate::research_container::spawn_loop(&docker, loop_id, &state_root).await {
|
||||||
match crate::research_container::spawn_loop(&docker, loop_id, &state_root).await {
|
Ok(s) => s,
|
||||||
Ok(s) => s,
|
Err(e) => {
|
||||||
Err(e) => {
|
eprintln!("loops::ensure_loop_container({loop_id}): spawn failed: {e}");
|
||||||
eprintln!("loops::ensure_loop_container({loop_id}): spawn failed: {e}");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
if let Err(e) = cm_db::repo::loops::set_zeroclaw_container(
|
if let Err(e) = cm_db::repo::loops::set_zeroclaw_container(
|
||||||
pool,
|
pool,
|
||||||
loop_id,
|
loop_id,
|
||||||
|
|||||||
@@ -883,10 +883,7 @@ async fn decide_publish(
|
|||||||
if approval.status != "pending" {
|
if approval.status != "pending" {
|
||||||
return Err(ApiError::Conflict);
|
return Err(ApiError::Conflict);
|
||||||
}
|
}
|
||||||
let notes_ref = notes
|
let notes_ref = notes.as_deref().map(str::trim).filter(|s| !s.is_empty());
|
||||||
.as_deref()
|
|
||||||
.map(str::trim)
|
|
||||||
.filter(|s| !s.is_empty());
|
|
||||||
let landed = cm_db::repo::research_publish_approvals::decide(
|
let landed = cm_db::repo::research_publish_approvals::decide(
|
||||||
&state.pool,
|
&state.pool,
|
||||||
id,
|
id,
|
||||||
@@ -992,12 +989,21 @@ pub async fn get_artifact(
|
|||||||
let safe_title: String = topic
|
let safe_title: String = topic
|
||||||
.title
|
.title
|
||||||
.chars()
|
.chars()
|
||||||
.map(|c| if c.is_ascii_alphanumeric() || c == '-' || c == '_' { c } else { '-' })
|
.map(|c| {
|
||||||
|
if c.is_ascii_alphanumeric() || c == '-' || c == '_' {
|
||||||
|
c
|
||||||
|
} else {
|
||||||
|
'-'
|
||||||
|
}
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let filename = format!("{}-v{}.md", safe_title.trim_matches('-'), outcome.version);
|
let filename = format!("{}-v{}.md", safe_title.trim_matches('-'), outcome.version);
|
||||||
Ok((
|
Ok((
|
||||||
[
|
[
|
||||||
(header::CONTENT_TYPE, "text/markdown; charset=utf-8".to_string()),
|
(
|
||||||
|
header::CONTENT_TYPE,
|
||||||
|
"text/markdown; charset=utf-8".to_string(),
|
||||||
|
),
|
||||||
(
|
(
|
||||||
header::CONTENT_DISPOSITION,
|
header::CONTENT_DISPOSITION,
|
||||||
format!("attachment; filename=\"{filename}\""),
|
format!("attachment; filename=\"{filename}\""),
|
||||||
|
|||||||
@@ -113,11 +113,9 @@ async fn run_job(
|
|||||||
per_topic_url
|
per_topic_url
|
||||||
} else {
|
} else {
|
||||||
match cm_db::repo::topology_runs::loop_id_for_run(pool, id).await {
|
match cm_db::repo::topology_runs::loop_id_for_run(pool, id).await {
|
||||||
Ok(Some(loop_id)) => {
|
Ok(Some(loop_id)) => cm_db::repo::loops::zeroclaw_gateway_url(pool, loop_id)
|
||||||
cm_db::repo::loops::zeroclaw_gateway_url(pool, loop_id)
|
.await
|
||||||
.await
|
.unwrap_or(None),
|
||||||
.unwrap_or(None)
|
|
||||||
}
|
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -252,13 +252,15 @@ pub async fn set_zeroclaw_container(
|
|||||||
/// daemon over the workspace-wide one.
|
/// daemon over the workspace-wide one.
|
||||||
pub async fn zeroclaw_gateway_url(pool: &PgPool, loop_id: Uuid) -> Result<Option<String>, DbError> {
|
pub async fn zeroclaw_gateway_url(pool: &PgPool, loop_id: Uuid) -> Result<Option<String>, DbError> {
|
||||||
use sqlx::Row;
|
use sqlx::Row;
|
||||||
let row = sqlx::query(
|
let row = sqlx::query("SELECT zeroclaw_gateway_url FROM loops WHERE id = $1")
|
||||||
"SELECT zeroclaw_gateway_url FROM loops WHERE id = $1",
|
.bind(loop_id)
|
||||||
)
|
.fetch_optional(pool)
|
||||||
.bind(loop_id)
|
.await?;
|
||||||
.fetch_optional(pool)
|
Ok(row.and_then(|r| {
|
||||||
.await?;
|
r.try_get::<Option<String>, _>("zeroclaw_gateway_url")
|
||||||
Ok(row.and_then(|r| r.try_get::<Option<String>, _>("zeroclaw_gateway_url").ok().flatten()))
|
.ok()
|
||||||
|
.flatten()
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Staffing ---------------------------------------------------------------
|
// --- Staffing ---------------------------------------------------------------
|
||||||
|
|||||||
@@ -186,12 +186,11 @@ pub async fn research_topic_id(pool: &PgPool, id: Uuid) -> Result<Option<Uuid>,
|
|||||||
/// None.
|
/// None.
|
||||||
pub async fn loop_id_for_run(pool: &PgPool, id: Uuid) -> Result<Option<Uuid>, DbError> {
|
pub async fn loop_id_for_run(pool: &PgPool, id: Uuid) -> Result<Option<Uuid>, DbError> {
|
||||||
use sqlx::Row;
|
use sqlx::Row;
|
||||||
let row: Option<sqlx::postgres::PgRow> = sqlx::query(
|
let row: Option<sqlx::postgres::PgRow> =
|
||||||
"SELECT loop_id FROM topology_runs WHERE id = $1",
|
sqlx::query("SELECT loop_id FROM topology_runs WHERE id = $1")
|
||||||
)
|
.bind(id)
|
||||||
.bind(id)
|
.fetch_optional(pool)
|
||||||
.fetch_optional(pool)
|
.await?;
|
||||||
.await?;
|
|
||||||
Ok(row.and_then(|r| r.try_get::<Option<Uuid>, _>("loop_id").ok().flatten()))
|
Ok(row.and_then(|r| r.try_get::<Option<Uuid>, _>("loop_id").ok().flatten()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user