Back to Source Monitor

Result Pattern for Completion Handlers & Consistent Logging

.vbw-planning/milestones/07-rails-audit-and-refactoring/04-job-pipeline-reliability/03-SUMMARY.md

0.13.02.3 KB
Original Source

What Was Built

  • Result structs for RetentionHandler (:applied/:failed), FollowUpHandler (:applied/:skipped/:failed), EventPublisher (:published/:failed)
  • FetchRunner now captures and logs handler Results at warn level on failure
  • Fetch Scheduler and Scrape Scheduler wrapped in rescue StandardError with warn-level logging
  • Consistent log prefixes using full class names across all completion handlers
  • 9 new tests covering success, failure, and skip paths for all three handlers

Commits

  • 77893eb test(04-03): add Result pattern tests for completion handlers
  • e03723d feat(04-03): add Result structs to completion handlers
  • a2baebf fix(04-03): add error handling to fetch and scrape schedulers
  • 5bd538a feat(04-03): wire Result usage in FetchRunner for handler visibility

Tasks Completed

  1. Write handler Result tests (TDD red) -- 9 new tests across 3 files, all failing on missing Result constant
  2. Add Result structs to completion handlers -- RetentionHandler, FollowUpHandler, EventPublisher all return typed Results
  3. Standardize logging in handlers and schedulers -- full class name prefixes, scheduler rescue with warn logging
  4. Wire Result usage in FetchRunner -- log_handler_result helper, backward-compatible with nil returns
  5. Verify -- 1491 runs, 0 failures, 0 RuboCop offenses; 11 errors are pre-existing HostAppHarness failures

Files Modified

  • lib/source_monitor/fetching/completion/retention_handler.rb -- added Result struct, return typed result, updated log prefix
  • lib/source_monitor/fetching/completion/follow_up_handler.rb -- added Result struct, collect per-item errors, return typed result, updated log prefix
  • lib/source_monitor/fetching/completion/event_publisher.rb -- added Result struct, wrapped dispatch in rescue, updated log prefix
  • lib/source_monitor/fetching/fetch_runner.rb -- added log_handler_result, capture handler return values
  • lib/source_monitor/scheduler.rb -- added rescue StandardError with warn logging
  • lib/source_monitor/scraping/scheduler.rb -- added rescue StandardError with warn logging
  • test/lib/source_monitor/fetching/completion/retention_handler_test.rb -- new (3 tests)
  • test/lib/source_monitor/fetching/completion/event_publisher_test.rb -- new (2 tests)
  • test/lib/source_monitor/fetching/completion/follow_up_handler_test.rb -- added 4 Result tests

Deviations

None.