.vbw-planning/milestones/07-rails-audit-and-refactoring/04-job-pipeline-reliability/03-PLAN.md
Add Result pattern to EventPublisher, RetentionHandler, and FollowUpHandler (S4), standardize their log formats (S5), add error handling to fetch/scrape Schedulers, and wire Result usage into FetchRunner for visibility.
Create/update test files:
test/lib/source_monitor/fetching/completion/retention_handler_test.rb: test returns Result with :applied on success; test returns Result with :failed and error on StandardError; test :skipped when result status is not :fetchedtest/lib/source_monitor/fetching/completion/follow_up_handler_test.rb: test returns Result with :applied and enqueued_count; test returns Result with :failed on error; test per-item errors captured in errors arraytest/lib/source_monitor/fetching/completion/event_publisher_test.rb: test returns Result with :published on success; test returns Result with :failed on errorModify three files:
lib/source_monitor/fetching/completion/retention_handler.rb: Add Result = Struct.new(:status, :removed_total, :error, keyword_init: true) with success? helper. Return Result from call.lib/source_monitor/fetching/completion/follow_up_handler.rb: Add Result = Struct.new(:status, :enqueued_count, :errors, keyword_init: true) with success? helper. Return Result from call. Collect per-item errors into errors array.lib/source_monitor/fetching/completion/event_publisher.rb: Add Result = Struct.new(:status, :error, keyword_init: true) with success? helper. Wrap dispatch in begin/rescue, return Result.Modify completion handlers (same files as Task 2):
[SourceMonitor] to [SourceMonitor::Fetching::Completion::RetentionHandler][SourceMonitor::Fetching::Completion::FollowUpHandler] (consistent format)Modify schedulers:
lib/source_monitor/scheduler.rb (fetch): wrap run body in begin/rescue StandardError, log at warn level with [SourceMonitor::Scheduler] prefixlib/source_monitor/scraping/scheduler.rb (scrape): wrap run body in begin/rescue StandardError, log at warn level with [SourceMonitor::Scraping::Scheduler] prefixModify lib/source_monitor/fetching/fetch_runner.rb:
retention_handler.call, follow_up_handler.call, event_publisher.callbin/rails test test/lib/source_monitor/fetching/completion/ -- all completion handler tests passbin/rails test test/lib/source_monitor/fetching/fetch_runner_test.rb -- FetchRunner tests passbin/rails test -- full suite passesbin/rubocop -- zero offensesgrep -r "\[SourceMonitor::" lib/source_monitor/fetching/completion/ shows uniform prefixes