Skip to content

fix console log reassembler eating multi-chunk lines - #56

Merged
abdulsaheel merged 1 commit into
mainfrom
fix/console-log-reassembler-first-chunk
Sep 18, 2026
Merged

abdulsaheel merged 1 commit into
mainfrom
fix/console-log-reassembler-first-chunk

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

add() returning false was ambiguous - could mean a real gap, or just the first chunk into a fresh/flushed instance. the doc comment told callers to flush() on any false, but flush()'s no-completed branch always resets _lastIndex, so a caller following that advice would flush after every single chunk and never actually reassemble anything longer than one chunk.

not wired into edge yet so nothing shipped is broken, but it'd bite the first real caller.

fix: added hasCompletedRun getter, pointed the docs at checking that instead of add()'s return value. didn't touch add()/flush() logic or signatures so the existing gap test still passes untouched. added a test that reproduces the 4-chunk-line-split-into-4-fragments scenario and proves it's fixed.

Summary by Sourcery

Fix console log reassembly so contiguous multi-chunk lines remain intact across fresh and flushed instances.

New Features:

  • Expose whether the console log reassembler has a completed run ready to flush.

Bug Fixes:

  • Prevent callers from splitting contiguous multi-chunk console log lines by flushing on the ambiguous add() return value.

Enhancements:

  • Clarify the reassembler contract to use hasCompletedRun when deciding whether to flush.

Tests:

  • Add coverage for preserving a four-chunk console log line when the first chunk starts a fresh reassembler.

Summary by CodeRabbit

  • Bug Fixes

    • Improved console log reassembly so multi-chunk log lines remain intact when processed across several records.
    • Added clearer completion status reporting, helping callers flush logs only when a completed run is available.
  • Tests

    • Added coverage for multi-chunk console log handling, including fresh instances and gap-ended runs.

add() returning false meant two different things: a real gap, or just the
first chunk into a fresh/flushed instance. a caller following the doc
comment (flush after every false) would nuke _lastIndex on every chunk and
never actually reassemble a straddled log line.

added hasCompletedRun so callers can tell the difference, and pointed the
docs at it instead of add()'s raw return. add()/flush() behavior unchanged.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @abdulsaheel, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 6 days and 18 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 0c3845e5-2241-4cea-945c-5f1343973d95

📥 Commits

Reviewing files that changed from the base of the PR and between fe1464d and f6d7eb8.

📒 Files selected for processing (2)
  • lib/src/control.dart
  • test/control_plane_offsets_test.dart

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Console log reassembly

Layer / File(s) Summary
Completion state and conditional flush validation
lib/src/control.dart, test/control_plane_offsets_test.dart
ConsoleLogReassembler now exposes hasCompletedRun. Documentation directs callers to use it before flush. A test verifies that four chunks remain one complete log line.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: droptabl

Merge Risk: ⚪ Minimal · up to f6d7e

The explicit completion state and regression test support the intended console log reassembly behavior, so the change is mergeable.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: fixing the console log reassembler so it does not lose multi-chunk lines.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR fixes an ambiguous reassembler API contract by adding hasCompletedRun, updating usage documentation, and testing that callers can accumulate contiguous multi-chunk lines without prematurely flushing on the first chunk.

Sequence diagram for safe console log chunk reassembly

sequenceDiagram
    participant Caller
    participant Reassembler as ConsoleLogReassembler

    Caller->>Reassembler: add(chunk1)
    Reassembler-->>Caller: false
    Caller->>Reassembler: hasCompletedRun
    Reassembler-->>Caller: false

    Caller->>Reassembler: add(chunk2)
    Reassembler-->>Caller: true
    Caller->>Reassembler: add(chunk3)
    Reassembler-->>Caller: true
    Caller->>Reassembler: add(chunk4)
    Reassembler-->>Caller: false
    Caller->>Reassembler: hasCompletedRun
    Reassembler-->>Caller: true
    Caller->>Reassembler: flush()
    Reassembler-->>Caller: completed run
Loading

File-Level Changes

Change Details Files
Clarifies the reassembler’s caller contract by exposing whether a completed run is actually buffered, rather than relying on the ambiguous result of adding a chunk.
  • Adds the hasCompletedRun getter based on pending completed-run state.
  • Updates class and add() documentation to require checking the getter before flushing.
  • Leaves add() and flush() behavior and signatures unchanged.
lib/src/control.dart
Adds regression coverage for preserving a multi-chunk line when flushing only after a completed run is reported.
  • Feeds four contiguous chunks through the corrected caller pattern.
  • Verifies the chunks are returned as one complete line instead of four fragments.
  • Retains the existing gap behavior test unchanged.
test/control_plane_offsets_test.dart

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

@abdulsaheel
abdulsaheel merged commit 1521962 into main Sep 18, 2026
4 checks passed
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