.vbw-planning/milestones/03-coverage-analysis-quick-wins-critical-path-test-co/phases/04-code-quality-conventions-cleanup/PLAN-03.md
Regenerate the coverage baseline to reflect all test improvements from Phases 2-4, verify the 60% reduction target is met, run full CI-equivalent checks (tests, RuboCop, Brakeman), and confirm no file exceeds 300 lines. This plan is the final gate before Phase 4 (and the entire VBW roadmap) can be marked complete.
@bin/update-coverage-baseline -- Script that regenerates the baseline from SimpleCov results. Requires running the test suite with coverage first (COVERAGE=1 bin/rails test or bin/test-coverage).
@bin/check-diff-coverage -- CI script that checks diff coverage against the baseline.
@AGENTS.md -- Documents the workflow: "refresh config/coverage_baseline.json by running bin/test-coverage followed by bin/update-coverage-baseline"
@test/test_helper.rb -- Coverage is enabled when CI or COVERAGE env var is set. Uses SimpleCov with branch coverage.
60% reduction target: The original baseline has 2117 uncovered lines. A 60% reduction means the new baseline must have at most 847 uncovered lines (2117 * 0.4 = 847). Phase 2 directly targeted ~630 lines in top files, and indirect coverage should bring more. If the target is not met, this task must identify the gap and either add targeted tests or document which files still need coverage.
CI-equivalent checks:
bin/rubocop -f github (lint job)bin/brakeman --no-pager (security job)bin/rails test (test job)config/coverage_baseline.jsonCOVERAGE=1 bin/rails test. Then regenerate the baseline: bin/update-coverage-baseline. Compare the new uncovered line count to the original 2117. The target is at most 847 uncovered lines (60% reduction). If the target is met, commit the regenerated baseline. If not, document the gap and identify which files still have the most uncovered lines for targeted fix in Task 2.ruby -rjson -e 'data = JSON.parse(File.read("config/coverage_baseline.json")); total = data.values.map(&:size).sum; puts "Uncovered: #{total}"; exit(total <= 847 ? 0 : 1)' exits 0config/coverage_baseline.json (re-regenerate after adding tests):nocov: exclusion zones. After adding tests, re-run COVERAGE=1 bin/rails test and bin/update-coverage-baseline to verify. If the target IS already met from Task 1, this task is a no-op -- simply verify and move on.ruby -rjson -e 'data = JSON.parse(File.read("config/coverage_baseline.json")); total = data.values.map(&:size).sum; puts "Uncovered: #{total}"; exit(total <= 847 ? 0 : 1)' exits 0name: full-ci-verification
files: (no modifications -- verification only)
action: Run all CI-equivalent checks in sequence:
bin/rubocop -f simple -- must show no offenses detectedbin/brakeman --no-pager -q -- must exit 0 with zero warningsbin/rails test -- must exit 0 with 760+ runs and 0 failuresfind app lib -name '*.rb' -exec wc -l {} + | sort -rn | awk '$1 > 300 && $2 != "total" {print; found=1} END {exit found ? 1 : 0}'frozen_string_literal: true: grep -rL 'frozen_string_literal: true' app/models/source_monitor/*.rb returns emptyfrozen_string_literal: true: grep -rL 'frozen_string_literal: true' app/controllers/source_monitor/*.rb returns emptyDocument any failures and fix them before marking this task done.
verify: All 6 checks above pass
done: All CI-equivalent checks pass. Codebase fully clean.
name: final-conventions-spot-check
files: (read-only audit, fix only if issues found)
action: Do a final walkthrough of all models, controllers, and service objects checking:
ModelExtensions.register(self, :key) (except ApplicationRecord)initialize/call pattern or self.call class methodsource_monitor_queueextend ActiveSupport::Concern and included do...endkeyword_init: trueFix any issues found. This should be a light pass since most conventions were already followed.
verify: bin/rails test exits 0 AND bin/rubocop -f simple shows no offenses detected
done: All conventions verified. Codebase passes final quality gate.
bin/rails test exits 0 with 760+ runs and 0 failuresbin/rubocop -f simple shows no offenses detectedbin/brakeman --no-pager -q exits 0