Skip to content

refactor(stella-pipeline): retire every too_many_arguments allow behind three parameter objects - #1880

Merged
macanderson merged 2 commits into
mainfrom
worktree-1809-turn-tallies
Aug 6, 2026
Merged

refactor(stella-pipeline): retire every too_many_arguments allow behind three parameter objects#1880
macanderson merged 2 commits into
mainfrom
worktree-1809-turn-tallies

Conversation

@macanderson

@macanderson macanderson commented Aug 6, 2026

Copy link
Copy Markdown
Owner

What — #1809, Option A as triaged

The candidate plane (runrun_best_of_ndispatch_isolated_candidatesrun_candidateverify_candidaterevise_turnrun_engine_turn) threaded the same values positionally through every layer, and nine functions across pipeline.rs and fanout_stage.rs carried #[allow(clippy::too_many_arguments)] to keep it lawful (the issue counted seven; the sweep found two more in fanout_stage.rs). Each new stage input — #1701's mutating_actions, #1798's opaque_actions — meant widening half a dozen signatures and re-justifying allows.

Three parameter objects, each grouping values that already always travel together (transport, not semantics — every field keeps its own documented meaning):

  • TaskFrame (new pipeline/task_frame.rs, per the driver/settlement.rs sibling-module pattern): goal, staged prefix, plan, assessment. Built once in run where its last field settles; Copy, so the fan-out closures each take their own.
  • Spend (in pipeline/stage_budget.rs, beside FanOutBudget): the budget guard + running total. Borrowed rather than owned so every mutation lands at run's locals with no write-back on early returns — one missed return would be a silently vanished spend. The fan-out builds a per-candidate Spend over its claimed allowance, which is the shape that code already had.
  • ChangeSignals — no new type: the warrant's input struct replaces the three loose u32 counters on CandidateState, so run_engine_turn accumulates directly into the type the warrant reads. The deleted change_signals() accessor existed to stop the counts being transposed en route (the warrant() waives the witness as "NothingChanged" for a candidate that dispatched 10 mutating calls — a false deterministic pass on system-config tasks #1701 recurrence); holding the struct makes that protection structural.

revise_turn now takes &mut CandidateState — its only caller already held one and exploded seven fields out of it.

Result

  • rg too_many_arguments crates/stella-pipeline/srczero allows (one doc-comment mention).
  • Every function in the plane is at or under clippy's threshold; cargo clippy -p stella-pipeline --all-targets adds no warnings from this change.
  • pipeline.rs shrinks by 88 lines (3487 against its 3642 ceiling); the god-file and file-size guards pass for every touched file.

Verification

Pure refactor — no behavior change, so no witness test (per AGENTS.md). Evidence: all 566 existing stella-pipeline tests pass unchanged (544 lib + integration suites), cargo fmt --check clean, scoped RUSTDOCFLAGS="-D warnings" cargo doc clean.

Known-red main caveat: clippy currently fails on main with two witness_stage.rs warnings from #1813's auto-merge, and the file-size gate on event.rs/deck_render.rs skew — peer unbreaks #1859 and #1845 cover those; this PR deliberately does not duplicate them, so its CI stays red on those two axes until they land.

Exemplar for the parameter-object shape: rustc's own Session/context threading and this repo's existing WitnessAuthoring bundle.

Closes #1809
Refs #1798, #1808

Summary by Sourcery

Introduce parameter objects for shared task context, budget, and change signals to simplify the candidate execution/verification pipeline and remove all too_many_arguments allowances.

Bug Fixes:

  • Eliminate the risk of misordered change-signal counters by storing and passing them as a typed ChangeSignals struct rather than separate u32 fields.

Enhancements:

  • Thread immutable task context through the candidate pipeline via a new TaskFrame struct instead of multiple positional parameters.
  • Bundle budget guard and running cost into a Spend helper struct to centralize turn-level spending and reporting.
  • Replace loose change counters on CandidateState with the existing ChangeSignals struct to align execution tallies with warrant inputs and prevent miswiring.

Tests:

  • Rely on the existing stella-pipeline test suite to validate that the refactor preserves behavior without adding new tests.

…nd three parameter objects

The candidate plane threaded the same values positionally through every
layer — the task view (goal, staged prefix, plan, assessment), the money
pair (budget guard + running total), and the per-candidate tallies — and
nine functions across pipeline.rs and fanout_stage.rs carried
#[allow(clippy::too_many_arguments)] to keep it lawful. Each addition
(#1701's mutating_actions, #1798's opaque_actions) widened half a dozen
signatures and re-justified the allows.

Three groupings, each transport for values that already travel together:

- TaskFrame (new pipeline/task_frame.rs): the immutable per-turn view,
  built once in run() where its last field settles.
- Spend (in pipeline/stage_budget.rs beside FanOutBudget): the budget
  guard and running total, borrowed so mutations land at run()'s locals
  with no write-back on early returns.
- ChangeSignals (already the warrant's input type) replaces the three
  loose u32 counters on CandidateState, so run_engine_turn accumulates
  directly into the type the warrant reads and the counts can never be
  transposed en route — the #1701 recurrence the deleted change_signals()
  accessor guarded against by hand.

revise_turn now takes &mut CandidateState like its only caller already
did, instead of seven exploded fields. Every function in the plane is at
or under clippy's argument threshold; the crate carries zero
too_many_arguments allows. pipeline.rs shrinks by 88 lines.

Pure refactor: no behavior change; 566 existing stella-pipeline tests
pass unchanged.

Closes #1809
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
stella-cli-docs Ignored Ignored Preview Aug 6, 2026 6:37pm

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @macanderson, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@sourcery-ai

sourcery-ai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Refactors the stella-pipeline candidate plane to eliminate clippy too_many_arguments allows by introducing TaskFrame and Spend parameter objects and by threading ChangeSignals structurally instead of loose counters, updating all candidate/verification paths accordingly.

Sequence diagram for candidate execution with TaskFrame, Spend, and ChangeSignals

sequenceDiagram
    participant P as Pipeline
    participant W as Worker
    participant E as Engine
    participant S as Spend
    participant C as CandidateState

    P->>P: run()
    P->>P: TaskFrame{goal, base_messages, plan, assessment}
    P->>S: Spend{budget, total}
    P->>P: run_best_of_n(frame, n, frames, authored_witness, &mut Spend)
    alt shared_tree
        P->>P: run_shared_candidates(frame, &worker, n, &mut Spend)
    else isolated_workspaces
        P->>P: dispatch_isolated_candidates(frame, &worker, authoring, workspaces, width, &mut Spend)
        P->>P: run_isolated_candidate(frame, &worker, authoring, ws, fan, &mut Spend)
    end
    P->>P: run_candidate(frame, authoring, &Engine, surface, &mut Spend)
    P->>C: init CandidateState{messages, final_text, signals = ChangeSignals::default()}
    P->>P: execute_plan(frame.plan, &Engine, &mut Spend, &mut CandidateState)
    loop per_engine_turn
        P->>E: run_engine_turn(&Engine, &mut messages, Spend.budget, &mut C.signals, flip_halt)
        E-->>P: TurnOutcome{cost_usd}
        P->>S: Spend.total += cost_usd
    end
    P->>P: verify_candidate(frame, witness, &Engine, surface, &mut Spend, CandidateState)
    P->>P: warrant(&C.diff_text, C.signals)
Loading

File-Level Changes

Change Details Files
Introduce TaskFrame to carry immutable per-turn task inputs through the candidate pipeline instead of passing multiple positional parameters.
  • Add new pipeline::task_frame module defining TaskFrame with goal, base_messages, plan, assessment
  • Construct a single TaskFrame in Pipeline::run once all four inputs are settled
  • Refactor run_shared_candidates, run_best_of_n, degrade_to_bare_execution, dispatch_isolated_candidates, run_isolated_candidate, run_candidate, and verify_candidate to accept and use TaskFrame instead of separate goal/messages/plan/assessment arguments
  • Update mcp_prefetch logic to rebuild a TaskFrame with possibly-prefetched base_messages while preserving other fields
crates/stella-pipeline/src/pipeline.rs
crates/stella-pipeline/src/pipeline/fanout_stage.rs
crates/stella-pipeline/src/pipeline/task_frame.rs
Introduce Spend parameter object to couple BudgetGuard and total cost across execution, verification, and witness stages.
  • Define Spend struct in stage_budget.rs borrowing BudgetGuard and total f64, with documentation tying them together conceptually
  • Replace paired budget and total parameters with &mut Spend across candidate execution functions, verification loop, revise paths, and witness authoring
  • Adjust budget accounting (FanOutBudget, budget_abort, affords_repair, verifier/verifier_guidance calls) to use Spend.budget and Spend.total
crates/stella-pipeline/src/pipeline.rs
crates/stella-pipeline/src/pipeline/fanout_stage.rs
crates/stella-pipeline/src/pipeline/witness_stage.rs
crates/stella-pipeline/src/pipeline/stage_budget.rs
Thread ChangeSignals structurally through CandidateState and engine turns, replacing separate u32 counters and an accessor.
  • Change CandidateState to hold a ChangeSignals field instead of separate file_changes, mutating_actions, opaque_actions u32s
  • Update run_engine_turn to accumulate event tallies directly into ChangeSignals
  • Refactor execute_plan, revise_turn, verify_probes, disclosure helpers, verifier waiver, and warrant calls to read/write ChangeSignals from CandidateState
  • Remove CandidateState::change_signals accessor now made redundant by the signals struct field
crates/stella-pipeline/src/pipeline.rs
crates/stella-pipeline/src/pipeline/disclosure.rs
crates/stella-pipeline/src/pipeline/verify_probes.rs
Simplify revise_turn and related flows by operating on &mut CandidateState instead of exploding multiple mutable fields.
  • Change revise_turn signature to take &mut CandidateState plus Spend instead of many separate mutable references
  • Update revise_candidate and all callers in verify_candidate to pass state and Spend
  • Inline previous message/final_text/file_changes/mutating_actions/opaque_actions/untracked_before handling into revise_turn using CandidateState fields
crates/stella-pipeline/src/pipeline.rs
Remove all clippy::too_many_arguments allows from the candidate pipeline and fanout, keeping function signatures under lint thresholds.
  • Delete #[allow(clippy::too_many_arguments)] attributes from run_best_of_n, run_shared_candidates, degrade_to_bare_execution, run_candidate, verify_candidate, dispatch_isolated_candidates, run_isolated_candidate, run_engine_turn, revise_turn, and witness_stage functions
  • Ensure all updated signatures use TaskFrame, Spend, and ChangeSignals to keep argument counts within clippy’s limit
crates/stella-pipeline/src/pipeline.rs
crates/stella-pipeline/src/pipeline/fanout_stage.rs
crates/stella-pipeline/src/pipeline/witness_stage.rs

Assessment against linked issues

Issue Objective Addressed Explanation
#1809 Restructure the candidate pipeline to stop positional threading of shared per-turn/per-candidate parameters (goal/messages/plan/assessment, budget/total, tallies) by introducing appropriate parameter objects/structs in sibling modules, thereby eliminating the need for clippy::too_many_arguments allows.
#1809 Explicitly document the chosen shape (Option A: parameter objects) and preserve the semantic independence of the per-candidate tallies, clarifying that any grouping is about transport rather than meaning.
#1809 Make stella-pipeline build clean under cargo clippy -p stella-pipeline --all-targets -- -D warnings with fewer (ideally zero) too_many_arguments allows.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@macanderson
macanderson merged commit adea918 into main Aug 6, 2026
4 checks passed
@macanderson
macanderson deleted the worktree-1809-turn-tallies branch August 6, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stella-pipeline: seven too_many_arguments allows in pipeline.rs — decide a shape for per-candidate turn state

1 participant