clippy: struct-bundle enqueue_iteration_with_topic + fix doc list warnings
CI's clippy stage failed with -D warnings on three classes of lint:
1. map_clone in loops::recent_reorders — .map(|a| a.clone()) is the
pattern clippy wants replaced by .cloned(). Trivial swap.
2. too_many_arguments on enqueue_iteration_with_topic (8 args, ceiling
7). Refactored the caller-side surface into a new
IterationEnqueue<'a> struct with fields for each column. Matches
the pattern research::NewTopic + loops::NewLoop already use for
the same clippy ceiling. Callers in loops.rs (routes) + the
enqueue_iteration wrapper updated to build the struct literal.
3. doc_lazy_continuation + doc_list_indentation — two doc comment
blocks used ambiguous list-like layouts:
- compose_iteration_task's ASCII-art prepended-block preview:
wrapped in a ```text fence so clippy stops parsing "RESEARCH
ARTIFACT:" etc as list continuation.
- fire_initial_burst_if_set's mention of `burst - 1`: rewrote so
"- 1" doesn't start a line and get misread as list marker.
Purely a refactor + doc pass; no behavior change.
This commit is contained in:
@@ -45,14 +45,18 @@ fn loop_state_root() -> std::path::PathBuf {
|
|||||||
/// - Standalone loops (no source research topic bound): returns
|
/// - Standalone loops (no source research topic bound): returns
|
||||||
/// `task_template` verbatim, matching legacy behavior.
|
/// `task_template` verbatim, matching legacy behavior.
|
||||||
/// - Loops bound to a research topic: fetches the topic's latest
|
/// - Loops bound to a research topic: fetches the topic's latest
|
||||||
/// research_outcome and prepends
|
/// research_outcome and prepends a block of the shape:
|
||||||
|
///
|
||||||
|
/// ```text
|
||||||
/// RESEARCH ARTIFACT (integration plan you're executing):
|
/// RESEARCH ARTIFACT (integration plan you're executing):
|
||||||
/// <markdown>
|
/// <markdown>
|
||||||
/// ITERATION FOCUS: next unconsumed INT-XX in order. If prereqs are
|
/// ITERATION FOCUS: next unconsumed INT-XX in order. If prereqs are
|
||||||
/// unmet, work on the smallest unblocking INT-XX. Log
|
/// unmet, work on the smallest unblocking INT-XX. Log
|
||||||
/// `COMPLETED: INT-<NN>` at the end so the loop can advance.
|
/// COMPLETED: INT-<NN> at the end so the loop can advance.
|
||||||
/// ORIGINAL TASK:
|
/// ORIGINAL TASK:
|
||||||
/// <task_template>
|
/// <task_template>
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
/// The topology_worker's completion hook (P3) parses the COMPLETED
|
/// The topology_worker's completion hook (P3) parses the COMPLETED
|
||||||
/// marker to update `consumed_int_ids`.
|
/// marker to update `consumed_int_ids`.
|
||||||
/// One-shot compose + enqueue for a loop iteration. Reads the loop's
|
/// One-shot compose + enqueue for a loop iteration. Reads the loop's
|
||||||
@@ -94,13 +98,15 @@ pub async fn compose_and_enqueue_iteration(
|
|||||||
let task = compose_research_iteration_task(pool, topic_id, template_ref).await;
|
let task = compose_research_iteration_task(pool, topic_id, template_ref).await;
|
||||||
cm_db::repo::loops::enqueue_iteration_with_topic(
|
cm_db::repo::loops::enqueue_iteration_with_topic(
|
||||||
pool,
|
pool,
|
||||||
|
cm_db::repo::loops::IterationEnqueue {
|
||||||
loop_id,
|
loop_id,
|
||||||
workspace_id,
|
workspace_id,
|
||||||
&task,
|
task: &task,
|
||||||
graph,
|
graph,
|
||||||
iter,
|
iteration: iter,
|
||||||
parent_run_id,
|
parent_run_id,
|
||||||
Some(topic_id),
|
research_topic_id: Some(topic_id),
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
} else {
|
} else {
|
||||||
@@ -432,13 +438,13 @@ pub async fn create_loop(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Fire the initial_burst if the loop's triggers request one. On the
|
/// Fire the initial_burst if the loop's triggers request one. On the
|
||||||
/// first fire, ensures the per-loop container is spawned and
|
/// first fire, ensures the per-loop container is spawned and (for
|
||||||
/// (for kind='research' loops) that the topic's repo is cloned and
|
/// kind='research' loops) that the topic's repo is cloned and the
|
||||||
/// the topic container is up. Sets `initial_burst_remaining = burst
|
/// topic container is up. Sets `initial_burst_remaining` to
|
||||||
/// - 1` so the completion hook can continue the chain. Best-effort:
|
/// `burst - 1` so the completion hook can continue the chain.
|
||||||
/// a docker or DB hiccup on the FIRST fire logs but the loop row
|
/// Best-effort: a docker or DB hiccup on the FIRST fire logs but the
|
||||||
/// still lives — cron / on_artifact_update / webhook can still fire
|
/// loop row still lives — cron / on_artifact_update / webhook can
|
||||||
/// it later.
|
/// still fire it later.
|
||||||
pub async fn fire_initial_burst_if_set(
|
pub async fn fire_initial_burst_if_set(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
workspace_id: Uuid,
|
workspace_id: Uuid,
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ pub async fn recent_reorders(
|
|||||||
.await?;
|
.await?;
|
||||||
let arr: Vec<Value> = row
|
let arr: Vec<Value> = row
|
||||||
.and_then(|r| r.try_get::<Value, _>("reorder_events").ok())
|
.and_then(|r| r.try_get::<Value, _>("reorder_events").ok())
|
||||||
.and_then(|v| v.as_array().map(|a| a.clone()))
|
.and_then(|v| v.as_array().cloned())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
// Appended in chronological order (oldest → newest); reversing then
|
// Appended in chronological order (oldest → newest); reversing then
|
||||||
// taking `limit` yields the newest N in newest-first order.
|
// taking `limit` yields the newest N in newest-first order.
|
||||||
@@ -762,17 +762,33 @@ pub async fn enqueue_iteration(
|
|||||||
) -> Result<Uuid, DbError> {
|
) -> Result<Uuid, DbError> {
|
||||||
enqueue_iteration_with_topic(
|
enqueue_iteration_with_topic(
|
||||||
pool,
|
pool,
|
||||||
|
IterationEnqueue {
|
||||||
loop_id,
|
loop_id,
|
||||||
workspace_id,
|
workspace_id,
|
||||||
task,
|
task,
|
||||||
graph,
|
graph,
|
||||||
iteration,
|
iteration,
|
||||||
parent_run_id,
|
parent_run_id,
|
||||||
None,
|
research_topic_id: None,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Batched arguments for `enqueue_iteration_with_topic`. Bundled so the
|
||||||
|
/// signature stays under clippy's 7-arg ceiling — the columns are
|
||||||
|
/// all conceptually one "run to enqueue for a loop", not free-floating
|
||||||
|
/// parameters.
|
||||||
|
pub struct IterationEnqueue<'a> {
|
||||||
|
pub loop_id: Uuid,
|
||||||
|
pub workspace_id: Uuid,
|
||||||
|
pub task: &'a str,
|
||||||
|
pub graph: &'a Value,
|
||||||
|
pub iteration: i32,
|
||||||
|
pub parent_run_id: Option<Uuid>,
|
||||||
|
pub research_topic_id: Option<Uuid>,
|
||||||
|
}
|
||||||
|
|
||||||
/// Variant of `enqueue_iteration` that also sets `research_topic_id` on
|
/// Variant of `enqueue_iteration` that also sets `research_topic_id` on
|
||||||
/// the topology_runs row. Used by kind='research' loops so
|
/// the topology_runs row. Used by kind='research' loops so
|
||||||
/// `freeze_research_outcome` writes a new outcome version each
|
/// `freeze_research_outcome` writes a new outcome version each
|
||||||
@@ -780,14 +796,17 @@ pub async fn enqueue_iteration(
|
|||||||
/// and a research topic.
|
/// and a research topic.
|
||||||
pub async fn enqueue_iteration_with_topic(
|
pub async fn enqueue_iteration_with_topic(
|
||||||
pool: &PgPool,
|
pool: &PgPool,
|
||||||
loop_id: Uuid,
|
args: IterationEnqueue<'_>,
|
||||||
workspace_id: Uuid,
|
|
||||||
task: &str,
|
|
||||||
graph: &Value,
|
|
||||||
iteration: i32,
|
|
||||||
parent_run_id: Option<Uuid>,
|
|
||||||
research_topic_id: Option<Uuid>,
|
|
||||||
) -> Result<Uuid, DbError> {
|
) -> Result<Uuid, DbError> {
|
||||||
|
let IterationEnqueue {
|
||||||
|
loop_id,
|
||||||
|
workspace_id,
|
||||||
|
task,
|
||||||
|
graph,
|
||||||
|
iteration,
|
||||||
|
parent_run_id,
|
||||||
|
research_topic_id,
|
||||||
|
} = args;
|
||||||
let run_id = Uuid::now_v7();
|
let run_id = Uuid::now_v7();
|
||||||
// Dynamic query so the new column combination (loop_id +
|
// Dynamic query so the new column combination (loop_id +
|
||||||
// research_topic_id on the same row) doesn't require an offline
|
// research_topic_id on the same row) doesn't require an offline
|
||||||
|
|||||||
Reference in New Issue
Block a user