Skip to content

Default stream: parallel scan + stdout serialization#8

Merged
bschellenberger2600 merged 5 commits into
mainfrom
feat/default-stream-parallel-scan
Apr 19, 2026
Merged

Default stream: parallel scan + stdout serialization#8
bschellenberger2600 merged 5 commits into
mainfrom
feat/default-stream-parallel-scan

Conversation

@bschellenberger2600
Copy link
Copy Markdown
Member

@bschellenberger2600 bschellenberger2600 commented Apr 17, 2026

Summary

Merges latest main into this branch and fixes a race where default-stream summary lines could interleave with the folder scan-progress ticker.

Changes

  • Summary under printMu: After workers and scan complete, summary output uses the same mutex as workers and the scan ticker so lines cannot splice mid-write.
  • Ticker shutdown ordering: Wait for the scan-progress ticker goroutine to exit after scanDone so a tick that was already eligible cannot emit a scan line after the summary (which would otherwise be possible once printMu is released).

Testing

  • make test-race
  • make lint (go vet ./...)
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes

    • Improved synchronization of scan progress output to prevent display issues during concurrent operations.
  • Chores

    • Updated project dependencies for enhanced stability.

bschellenberger2600 and others added 5 commits April 17, 2026 03:19
- Replace blocking scan+process with runRainDefaultStream (git-fire-style):
  cancellable scan, upsert/filter pipeline, FetchWorkers pool, atomic totals
- Per-repo output via runRainOnRepo with [N/M] headers and mutex-serialized blocks
- Scan progress ticker (2s), post-run TTY scan-wait or non-interactive cancel
- Tests: streaming integration, helper coverage, fetchFailureMessage/weather/outcome/buildKnownPaths/upsert
Drop unreachable post-worker scan prompt (scan always finishes before
repoChan closes). Serialize folder-progress lines with printMu like
worker output. Await scanDone before reading scanErr to avoid a race.

Co-authored-by: Ben Schellenberger <bschellenberger2600@users.noreply.github.com>
… under printMu

Co-authored-by: Ben Schellenberger <bschellenberger2600@users.noreply.github.com>
- Resolve merge conflicts in cmd/root.go and cmd/root_test.go
- Hold printMu while printing runRainDefaultStream summary lines
- Wait for scan progress ticker exit after scanDone so a final tick
  cannot print after the summary

Co-authored-by: Ben Schellenberger <bschellenberger2600@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 17, 2026

Warning

Rate limit exceeded

@bschellenberger2600 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes and 56 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 56 minutes and 56 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7d46c917-32c0-4ecc-a3d3-81bf29786cff

📥 Commits

Reviewing files that changed from the base of the PR and between 265e6e7 and 160e3d8.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • cmd/root.go
  • go.mod
📝 Walkthrough

Walkthrough

Changes synchronize ticker shutdown and final output printing in the scan-progress function by introducing a signaling channel and mutex locking. Additionally, dependency management is updated to promote gofrs/flock from indirect to direct and demote go-isatty from direct to indirect.

Changes

Cohort / File(s) Summary
Scan Progress Synchronization
cmd/root.go
Adds scanProgressTickerDone channel closed by the ticker goroutine via defer, waits for it after scan completion, and wraps final output serialization (repository not found/summary) with printMu lock to prevent interleaving with ticker output.
Dependency Management
go.mod
Swaps github.com/gofrs/flock v0.12.1 and github.com/mattn/go-isatty v0.0.20 between direct and indirect dependency classifications, making flock direct and go-isatty indirect.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A ticker tamed with gentle care,
Through channels hopped with flair—
No races now, just synchronized bliss,
Dependencies aligned in a rabbit's kiss! 🐾

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: parallel scanning and stdout serialization through mutex protection, which directly addresses the race condition fix in the PR objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/default-stream-parallel-scan

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 and usage tips.

@bschellenberger2600 bschellenberger2600 marked this pull request as ready for review April 19, 2026 02:51
@bschellenberger2600
Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2026

✅ Actions performed

Full review triggered.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@go.mod`:
- Line 31: The go.mod lists github.com/mattn/go-isatty as an indirect dependency
but cmd/root.go imports it directly; update go.mod to make
github.com/mattn/go-isatty a direct dependency by running `go mod tidy` (or
removing the "// indirect" marker and ensuring the require line is present) so
the module appears in the direct dependencies; check cmd/root.go import of
github.com/mattn/go-isatty and verify `go.sum` is updated accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 48635ac6-61fa-4224-b23d-0f5184ea9a61

📥 Commits

Reviewing files that changed from the base of the PR and between 265e6e7 and 160e3d8.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • cmd/root.go
  • go.mod

Comment thread go.mod
github.com/gofrs/flock v0.12.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify whether go-isatty is directly imported by repository Go files.

rg -n --type=go -C2 '"github\.com/mattn/go-isatty"'
rg -n -C2 'github\.com/mattn/go-isatty' go.mod

Repository: git-fire/git-rain

Length of output: 532


Move go-isatty from indirect to direct dependencies.

cmd/root.go line 19 directly imports github.com/mattn/go-isatty, so marking it // indirect is inconsistent with the source code. Running go mod tidy will move it to the direct dependency section.

Proposed fix
 require (
 	github.com/charmbracelet/bubbles v1.0.0
 	github.com/charmbracelet/bubbletea v1.3.10
 	github.com/charmbracelet/lipgloss v1.1.0
 	github.com/git-fire/git-testkit v0.2.0
 	github.com/gofrs/flock v0.12.1
+	github.com/mattn/go-isatty v0.0.20
 	github.com/mattn/go-runewidth v0.0.19
 	github.com/pelletier/go-toml/v2 v2.2.4
 	github.com/spf13/cobra v1.10.2
 	github.com/spf13/viper v1.21.0
 )
@@
 	github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
 	github.com/inconshreveable/mousetrap v1.1.0 // indirect
 	github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
-	github.com/mattn/go-isatty v0.0.20 // indirect
 	github.com/mattn/go-localereader v0.0.1 // indirect
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go.mod` at line 31, The go.mod lists github.com/mattn/go-isatty as an
indirect dependency but cmd/root.go imports it directly; update go.mod to make
github.com/mattn/go-isatty a direct dependency by running `go mod tidy` (or
removing the "// indirect" marker and ensuring the require line is present) so
the module appears in the direct dependencies; check cmd/root.go import of
github.com/mattn/go-isatty and verify `go.sum` is updated accordingly.

@bschellenberger2600
Copy link
Copy Markdown
Member Author

bugbot run

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 160e3d8. Configure here.

@bschellenberger2600 bschellenberger2600 merged commit cd0cda5 into main Apr 19, 2026
11 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.

2 participants