Skip to content

Conversation

@shivasurya
Copy link
Owner

Summary

Replaces noisy per-file worker status messages with clean progress bar tracking during code graph initialization. Workers now report progress via callbacks instead of direct logging.

Why this change?

  • Much cleaner output: Eliminates spam like "Worker 1 ....... Done processing file X"
  • Better UX: Single progress bar shows overall file parsing status
  • Consistent design: Matches other progress indicators added in PR-02
  • Performance visibility: Users see real-time progress through all files
  • Less log pollution: Stderr stays clean for actual errors/warnings

Before (PR-03)

2026/01/19 22:11:42 Worker 1 ....... Done processing file generate_stdlib_registry.py []
2026/01/19 22:11:42 Worker 2 ....... Done processing file test_generator.py []
2026/01/19 22:11:42 Worker 3 ....... Done processing file process_rules_for_r2.py []
2026/01/19 22:11:42 Worker 4 ....... Done processing file sample.py []
2026/01/19 22:11:42 Worker 5 ....... Done processing file utils.py []

After (PR-04)

Building code graph ████████████████████ 100% | 245/245 files

Changes

  • Add ProgressCallbacks struct with OnStart/OnProgress callbacks
  • Update Initialize() signature: func Initialize(directory string, callbacks *ProgressCallbacks)
  • Remove statusChan and all worker status logging
  • Integrate progress callbacks in scan.go and ci.go
  • Update all 16 test files to pass nil callbacks where progress tracking not needed
  • Add 10 comprehensive tests for callback functionality (90.9% coverage)
  • Fix: Remove noisy "No container rules found" warning

Technical Details

Callback Design:

type ProgressCallbacks struct {
    OnStart func(totalFiles int)    // Called once before processing
    OnProgress func()                // Called after each file (success or error)
}

Integration:

graph.Initialize(projectPath, &graph.ProgressCallbacks{
    OnStart: func(totalFiles int) {
        logger.StartProgress("Building code graph", totalFiles)
    },
    OnProgress: func() {
        logger.UpdateProgress(1)
    },
})
logger.FinishProgress()

Testing

  • 10 new callback-specific tests:
    • Progress callback invocation verification
    • Nil callbacks handling
    • Partial callbacks (OnStart/OnProgress only)
    • Dockerfile read errors with callbacks
    • Docker-compose parse errors with callbacks
    • Valid Docker file processing
    • Java/Python file read errors
    • Java/Python file processing
  • Coverage: 90.9% for initialize.go (up from 75%)
  • Remaining 9.1% is defensive code (unreachable paths)
  • All existing tests pass with nil callbacks

Stack

  • Depends on: PR-03 (Logging cleanup)
  • Final PR in CLI Output Enhancement initiative (PR-04 of 4)

🤖 Generated with Claude Code

@shivasurya shivasurya added the enhancement New feature or request label Jan 20, 2026
@shivasurya shivasurya self-assigned this Jan 20, 2026
@safedep
Copy link

safedep bot commented Jan 20, 2026

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

This report is generated by SafeDep Github App

@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 44.73684% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.94%. Comparing base (2b8e9fc) to head (f0e70c3).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sast-engine/cmd/scan.go 0.00% 8 Missing ⚠️
sast-engine/cmd/ci.go 0.00% 7 Missing ⚠️
sast-engine/graph/initialize.go 80.95% 4 Missing ⚠️
sast-engine/cmd/resolution_report.go 0.00% 1 Missing ⚠️
sast-engine/cmd/serve.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #476      +/-   ##
==========================================
- Coverage   79.97%   79.94%   -0.03%     
==========================================
  Files         101      101              
  Lines       11114    11107       -7     
==========================================
- Hits         8888     8880       -8     
- Misses       1874     1879       +5     
+ Partials      352      348       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Owner Author

shivasurya commented Jan 20, 2026

Copy link
Owner Author

shivasurya commented Jan 20, 2026

Merge activity

  • Jan 20, 3:40 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jan 20, 3:46 AM UTC: Graphite rebased this pull request as part of a merge.
  • Jan 20, 3:47 AM UTC: @shivasurya merged this pull request with Graphite.

@shivasurya shivasurya changed the base branch from feature/cli-logging-cleanup-pr03 to graphite-base/476 January 20, 2026 03:44
@shivasurya shivasurya changed the base branch from graphite-base/476 to main January 20, 2026 03:45
shivasurya and others added 4 commits January 20, 2026 03:46
Replaces verbose worker status messages with clean progress bar tracking
during code graph initialization. Workers no longer output per-file status
messages; instead, progress is reported via callbacks to the logger.

Changes:
- Add ProgressCallbacks struct with OnStart/OnProgress callbacks
- Update Initialize() signature to accept optional callbacks
- Remove statusChan and progressChan worker communication
- Remove all worker status logging (e.g., "Worker 1 ....... Done")
- Integrate progress callbacks in scan.go and ci.go commands
- Update all Initialize() callers to pass nil callbacks (tests)
- Add comprehensive tests for progress callback functionality

Test coverage:
- TestInitializeWithProgressCallbacks: Verifies callbacks are invoked
- TestInitializeWithNilCallbacks: Ensures nil handling works
- TestInitializeWithPartialCallbacks: Tests partial callback configuration
- Coverage: 75% for Initialize(), 89.8% for graph package

Fixes #PR-04 - Clean up noisy worker output

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Silently skip container rule execution if no container rules are found
instead of showing a warning. This reduces noise for projects that have
Docker files but aren't scanning with container-specific rules.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Add comprehensive tests for progress callback error paths:
- Dockerfile read errors (unreadable files)
- Docker-compose parse errors (invalid YAML)
- Valid Dockerfile/compose with callbacks
- Java file read errors
- Python file read errors
- Java/Python file processing with callbacks

Document unreachable code paths:
- Default case in file type switch (defensive programming)
- Tree-sitter ParseCtx errors (nearly impossible to trigger)

Coverage improved from 75% to 90.9% for initialize.go.
Remaining 9.1% is defensive code that cannot be practically tested.

Test summary:
- 13 new callback-related tests added
- All tests pass
- No regressions in existing functionality

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
The workerID parameter was unused after removing status printing.
Fixes golangci-lint unparam check failure.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@shivasurya shivasurya force-pushed the feature/cli-worker-progress-pr04 branch from 9cfbc05 to f0e70c3 Compare January 20, 2026 03:46
@shivasurya shivasurya merged commit 18540ff into main Jan 20, 2026
5 checks passed
@shivasurya shivasurya deleted the feature/cli-worker-progress-pr04 branch January 20, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants