Skip to content

fix(stella-pipeline): do not render an untracked file through both diff channels - #2041

Merged
macanderson merged 2 commits into
mainfrom
dedup-untracked-diff-channels
Aug 7, 2026
Merged

fix(stella-pipeline): do not render an untracked file through both diff channels#2041
macanderson merged 2 commits into
mainfrom
dedup-untracked-diff-channels

Conversation

@macanderson

@macanderson macanderson commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Follow-up to #2034, which merged before this landed on the same branch.

The problem #2034 introduced

#2034 made the probe half of the diff render an untracked file's content. The authored half (FileTouchPort::authored_diff) already rendered the same content for any file written through the file tools — and absorb_probe concatenates the two halves.

So after #2034, a file written with write_file that is also untracked — the single commonest shape of agent work — reached the verifier twice: once as a probe hunk, once as an authored chunk. That spends the diff budget twice to say one thing, and leaves a reader to wonder whether it is looking at one change or two.

The fix

DiffProbe now names the untracked paths whose content its text carries (untracked_rendered), and splice_authored drops those chunks from the authored half.

Reuses verify::strip_witness_hunks rather than writing a second chunk parser, so the two callers cannot come to disagree about where a chunk boundary is.

Which half survives is deliberate, and follows the precedence authored's own module docs already state — probe first, since on-disk state is the stronger claim where it exists. Only a hunk body claims the path: git's Binary files ... differ sentence is not content, so the authored channel still covers a binary file, and a path whose probe failed is likewise absent from the list.

This is the text-side analogue of the max (never a sum) that absorb_probe already applies to the two channels' line counts, for the same stated reason — they are two views of one change, not two changes.

Witness

a_file_the_probe_already_rendered_is_not_repeated_by_the_authored_half asserts the content appears exactly once (matches(...).count() == 1), which is the property that actually matters and which a "does it contain" assertion would not catch.

a_file_the_probe_did_not_render_is_still_spliced pins the other side: the drop is per path, and a file only the tools saw is still spliced — that being the entire reason the authored channel exists.

Gate

guards-fast (all 14), clippy -D warnings on stella-pipeline/stella-cli/stella-serve, and cargo test -p stella-pipeline — 605 pass, up from 603 by exactly these two tests.

Refs #2034

Summary by Sourcery

Prevent untracked files written by tools from having their contents rendered twice across probe and authored diff channels in the stella pipeline.

Bug Fixes:

  • Avoid duplicate diff output for untracked files whose contents are present in both the probe and authored channels by dropping redundant authored chunks for those paths.

Tests:

  • Add regression tests ensuring untracked files rendered by the probe are not repeated by the authored half, while files only seen by tools are still included in the final diff.

…ff channels

Rendering untracked content in the probe half made the authored half's copy
of the same file redundant, and the two are concatenated — so a file written
through `write_file` reached the verifier twice, spending the diff budget
twice to say one thing and leaving a reader to wonder whether it was looking
at one change or two.

`DiffProbe` now names the untracked paths whose content its text carries, and
`splice_authored` drops those chunks from the authored half via the existing
`strip_witness_hunks` — one definition of "a chunk for this path", so the two
callers cannot disagree about a chunk boundary.

The probe's copy is the one kept, by the precedence `authored`'s module docs
already state: on-disk state is the stronger claim about what survived. Only
a hunk body claims the path — git's `Binary files ... differ` sentence is not
content, so the authored channel still covers a binary file.

This is the text-side analogue of the `max` (never a sum) that `absorb_probe`
already applies to the two channels' line counts, and it is there for the
same reason: two views of one change, not two changes.

@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

@vercel

vercel Bot commented Aug 7, 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 7, 2026 4:53am

@sourcery-ai

sourcery-ai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Ensures untracked files rendered by the diff probe are not redundantly rendered again in the authored diff, by tracking which untracked paths had their content emitted by the probe and dropping those chunks from the authored half while reusing shared chunk-parsing logic, plus tests to pin the new behavior.

Sequence diagram for combining probe and authored diffs without duplicate untracked content

sequenceDiagram
    participant Pipeline
    participant DiffProbe
    participant AuthoredChange
    participant authored as authored_module
    participant verify as verify_module

    Pipeline->>DiffProbe: gather_diff()
    DiffProbe-->>Pipeline: DiffProbe{text, available, untracked_rendered}

    Pipeline->>AuthoredChange: collect_authored_changes()
    AuthoredChange-->>Pipeline: AuthoredChange{text, ...}

    Pipeline->>authored: splice_authored(probe.text, &authored, &probe.untracked_rendered)
    activate authored
    authored->>verify: strip_witness_hunks(&authored.text, already_rendered)
    verify-->>authored: StripResult{diff}
    authored-->>Pipeline: combined_diff_text
    deactivate authored

    Pipeline->>Pipeline: verification_honest_diff(combined_diff_text)
Loading

File-Level Changes

Change Details Files
Make splice_authored aware of probe-rendered untracked paths and drop corresponding authored chunks while handling empty-text edge cases correctly.
  • Extend splice_authored to accept a slice of already-rendered untracked paths and pass authored.text through verify::strip_witness_hunks before splicing.
  • Return probe_text alone when authored is empty or when all authored chunks for the listed paths are stripped resulting in empty content.
  • Ensure that when only the authored side has content, the function returns the filtered authored_text without adding the authored section header; otherwise join probe and authored with the header using the filtered text.
crates/stella-pipeline/src/pipeline/authored.rs
Track which untracked files had their content rendered by the diff probe and propagate that metadata into splice_authored via DiffProbe.
  • Add an untracked_rendered: Vec field to DiffProbe, initialize it in all construction paths, and propagate it out of gather_diff.
  • When rendering untracked file content in the probe, push the path into untracked_rendered only when a text hunk body is present (starts with "@@ "), excluding binary or failed probe cases.
  • Update the verification path to pass probe.untracked_rendered into authored::splice_authored so redundant authored hunks are removed for those paths.
crates/stella-pipeline/src/pipeline/verify_probes.rs
Add tests to pin non-duplication of probe-rendered untracked files and preservation of authored-only files.
  • Add a test ensuring that when the probe already rendered an untracked file’s content, the spliced diff does not repeat that content and it appears exactly once.
  • Add a test ensuring that if the probe rendered some other file, an authored-only file is still included in the spliced diff and the authored section header appears.
  • Update existing tests for splice_authored to pass the new already_rendered parameter explicitly.
crates/stella-pipeline/src/pipeline/authored.rs

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

… double

`stella-pipeline`'s `patch_body` makes two assertions about what this argv
prints: everything above the first `@@` is strippable preamble, and a binary
file yields `Binary files ... differ` and no hunk. Every test of those rules
lives over there and runs against a scripted string, so the double and git
could drift and only a live run would notice.

These two run the real `GitDiagnosticRunner` against a real temp repo. They
cost no model call and no network, which is the point — the gap was reachable
without either.
Comment thread crates/stella-pipeline/src/pipeline/authored.rs
@macanderson
macanderson merged commit 94d013c into main Aug 7, 2026
13 of 15 checks passed
@macanderson
macanderson deleted the dedup-untracked-diff-channels branch August 7, 2026 05:03
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.

1 participant