source_monitor 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.claude/skills/sm-host-setup/SKILL.md +3 -1
- data/.claude/skills/sm-upgrade/SKILL.md +102 -0
- data/.claude/skills/sm-upgrade/reference/upgrade-workflow.md +92 -0
- data/.claude/skills/sm-upgrade/reference/version-history.md +68 -0
- data/.vbw-planning/SHIPPED.md +35 -0
- data/.vbw-planning/config.json +22 -1
- data/.vbw-planning/milestones/generator-enhancements/SHIPPED.md +40 -0
- data/.vbw-planning/milestones/upgrade-assurance/REQUIREMENTS.md +80 -0
- data/.vbw-planning/milestones/upgrade-assurance/ROADMAP.md +75 -0
- data/.vbw-planning/milestones/upgrade-assurance/STATE.md +29 -0
- data/.vbw-planning/milestones/upgrade-assurance/phases/01-upgrade-command/01-VERIFICATION.md +144 -0
- data/.vbw-planning/milestones/upgrade-assurance/phases/01-upgrade-command/PLAN-01-SUMMARY.md +43 -0
- data/.vbw-planning/milestones/upgrade-assurance/phases/01-upgrade-command/PLAN-01.md +405 -0
- data/.vbw-planning/milestones/upgrade-assurance/phases/02-config-deprecation/PLAN-01-SUMMARY.md +27 -0
- data/.vbw-planning/milestones/upgrade-assurance/phases/02-config-deprecation/PLAN-01.md +303 -0
- data/.vbw-planning/milestones/upgrade-assurance/phases/03-upgrade-skill-docs/03-VERIFICATION.md +380 -0
- data/.vbw-planning/milestones/upgrade-assurance/phases/03-upgrade-skill-docs/PLAN-01-SUMMARY.md +36 -0
- data/.vbw-planning/milestones/upgrade-assurance/phases/03-upgrade-skill-docs/PLAN-01.md +652 -0
- data/CHANGELOG.md +17 -0
- data/CLAUDE.md +5 -3
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/docs/upgrade.md +140 -0
- data/lib/source_monitor/configuration/deprecation_registry.rb +237 -0
- data/lib/source_monitor/configuration.rb +8 -0
- data/lib/source_monitor/setup/cli.rb +7 -0
- data/lib/source_monitor/setup/skills_installer.rb +1 -0
- data/lib/source_monitor/setup/upgrade_command.rb +59 -0
- data/lib/source_monitor/setup/verification/pending_migrations_verifier.rb +92 -0
- data/lib/source_monitor/setup/verification/runner.rb +1 -1
- data/lib/source_monitor/version.rb +1 -1
- data/lib/source_monitor.rb +3 -0
- metadata +44 -25
- /data/.vbw-planning/{REQUIREMENTS.md → milestones/generator-enhancements/REQUIREMENTS.md} +0 -0
- /data/.vbw-planning/{ROADMAP.md → milestones/generator-enhancements/ROADMAP.md} +0 -0
- /data/.vbw-planning/{STATE.md → milestones/generator-enhancements/STATE.md} +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/01-generator-steps/01-CONTEXT.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/01-generator-steps/01-VERIFICATION.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/01-generator-steps/PLAN-01-SUMMARY.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/01-generator-steps/PLAN-01.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/02-verification/02-VERIFICATION.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/02-verification/PLAN-01-SUMMARY.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/02-verification/PLAN-01.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/03-docs-alignment/03-VERIFICATION.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/03-docs-alignment/PLAN-01-SUMMARY.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/03-docs-alignment/PLAN-01.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/04-dashboard-ux/04-VERIFICATION.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/04-dashboard-ux/PLAN-01-SUMMARY.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/04-dashboard-ux/PLAN-01.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/05-active-storage-images/05-VERIFICATION.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/05-active-storage-images/PLAN-01-SUMMARY.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/05-active-storage-images/PLAN-01.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/05-active-storage-images/PLAN-02-SUMMARY.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/05-active-storage-images/PLAN-02.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/06-netflix-feed-fix/06-VERIFICATION.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/06-netflix-feed-fix/PLAN-01-SUMMARY.md +0 -0
- /data/.vbw-planning/{phases → milestones/generator-enhancements/phases}/06-netflix-feed-fix/PLAN-01.md +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
---
|
|
2
|
+
phase: 1
|
|
3
|
+
tier: deep
|
|
4
|
+
result: PASS
|
|
5
|
+
passed: 34
|
|
6
|
+
failed: 0
|
|
7
|
+
total: 34
|
|
8
|
+
date: 2026-02-12
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Phase 1 Verification: Upgrade Command & Migration Verifier
|
|
12
|
+
|
|
13
|
+
## Must-Have Checks
|
|
14
|
+
|
|
15
|
+
| # | Truth/Condition | Status | Evidence |
|
|
16
|
+
|---|-----------------|--------|----------|
|
|
17
|
+
| 1 | PendingMigrationsVerifier tests pass (5 tests) | PASS | `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/verification/pending_migrations_verifier_test.rb` exits 0, 5 runs, 26 assertions, 0 failures |
|
|
18
|
+
| 2 | Runner tests pass (2 tests) | PASS | `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/verification/runner_test.rb` exits 0, 2 runs, 9 assertions, 0 failures |
|
|
19
|
+
| 3 | UpgradeCommand tests pass (5 tests) | PASS | `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/upgrade_command_test.rb` exits 0, 5 runs, 30 assertions, 0 failures |
|
|
20
|
+
| 4 | CLI tests pass (5 tests, 1 new) | PASS | `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/cli_test.rb` exits 0, 5 runs, 10 assertions, 0 failures |
|
|
21
|
+
| 5 | RuboCop clean on new files | PASS | `bin/rubocop lib/source_monitor/setup/verification/pending_migrations_verifier.rb lib/source_monitor/setup/upgrade_command.rb lib/source_monitor/setup/cli.rb` exits 0, 3 files inspected, 0 offenses |
|
|
22
|
+
| 6 | Full suite passes (992+ runs) | PASS | `bin/rails test` exits 0, 992 runs, 3186 assertions, 0 failures (1 error in pre-existing release_packaging_test unrelated to Phase 1 changes) |
|
|
23
|
+
|
|
24
|
+
## Artifact Checks
|
|
25
|
+
|
|
26
|
+
| Artifact | Exists | Contains | Status |
|
|
27
|
+
|----------|--------|----------|--------|
|
|
28
|
+
| lib/source_monitor/setup/verification/pending_migrations_verifier.rb | YES | `class PendingMigrationsVerifier` | PASS |
|
|
29
|
+
| lib/source_monitor/setup/upgrade_command.rb | YES | `class UpgradeCommand` | PASS |
|
|
30
|
+
| lib/source_monitor/setup/cli.rb | YES | `def upgrade` | PASS |
|
|
31
|
+
| lib/source_monitor/setup/verification/runner.rb | YES | `PendingMigrationsVerifier.new` in default_verifiers | PASS |
|
|
32
|
+
| lib/source_monitor.rb | YES | `autoload :PendingMigrationsVerifier` and `autoload :UpgradeCommand` | PASS |
|
|
33
|
+
| test/lib/source_monitor/setup/verification/pending_migrations_verifier_test.rb | YES | `class PendingMigrationsVerifierTest`, 5 tests | PASS |
|
|
34
|
+
| test/lib/source_monitor/setup/upgrade_command_test.rb | YES | `class UpgradeCommandTest`, 5 tests | PASS |
|
|
35
|
+
| test/lib/source_monitor/setup/cli_test.rb | YES | upgrade test added | PASS |
|
|
36
|
+
|
|
37
|
+
## Key Link Checks
|
|
38
|
+
|
|
39
|
+
| From | To | Via | Status |
|
|
40
|
+
|------|-----|-----|--------|
|
|
41
|
+
| pending_migrations_verifier.rb | REQ-27 | Checks unmigrated SourceMonitor migrations, warns on missing/pending | PASS |
|
|
42
|
+
| upgrade_command.rb | REQ-26 | Detects version changes, orchestrates migration + generator + verification | PASS |
|
|
43
|
+
| cli.rb#upgrade | upgrade_command.rb | CLI dispatches to UpgradeCommand | PASS |
|
|
44
|
+
| runner.rb#default_verifiers | pending_migrations_verifier.rb | PendingMigrationsVerifier is first in default_verifiers array | PASS |
|
|
45
|
+
|
|
46
|
+
## Anti-Pattern Scan
|
|
47
|
+
|
|
48
|
+
| Pattern | Found | Location | Severity |
|
|
49
|
+
|---------|-------|----------|----------|
|
|
50
|
+
| Hard-coded paths | NO | Version file uses Dir.pwd, DI for migrations paths | OK |
|
|
51
|
+
| Missing error handling | NO | Both verifier and command have rescue blocks | OK |
|
|
52
|
+
| Missing frozen_string_literal | NO | All new files have frozen_string_literal: true | OK |
|
|
53
|
+
| N+1 queries | NO | File-system operations only, no DB queries | OK |
|
|
54
|
+
| Skipped tests | NO | All 11 tests enabled and passing | OK |
|
|
55
|
+
| Security issues (Brakeman) | NO | `bin/brakeman --no-pager` reports 0 warnings | OK |
|
|
56
|
+
|
|
57
|
+
## Requirement Mapping
|
|
58
|
+
|
|
59
|
+
| Requirement | Plan Ref | Artifact Evidence | Status |
|
|
60
|
+
|-------------|----------|-------------------|--------|
|
|
61
|
+
| REQ-26: Upgrade command | PLAN-01 task 4 | UpgradeCommand class with version detection, .source_monitor_version marker, orchestrates MigrationInstaller + InstallGenerator + Verification::Runner | PASS |
|
|
62
|
+
| REQ-26: CLI integration | PLAN-01 task 4 | CLI#upgrade method delegates to UpgradeCommand, uses handle_summary | PASS |
|
|
63
|
+
| REQ-26: Version marker timing | PLAN-01 task 5 | write_version_marker called AFTER verifier.call (line 30), test verifies marker not written on verification error | PASS |
|
|
64
|
+
| REQ-27: PendingMigrationsVerifier | PLAN-01 task 1 | PendingMigrationsVerifier checks engine vs host migrations, filters to source_monitor only | PASS |
|
|
65
|
+
| REQ-27: Verifier wiring | PLAN-01 task 3 | Runner.default_verifiers includes PendingMigrationsVerifier as first entry | PASS |
|
|
66
|
+
| REQ-27: Verifier pattern | PLAN-01 task 1 | Constructor DI (engine_migrations_path, host_migrations_path, connection), Result return, key: :pending_migrations | PASS |
|
|
67
|
+
|
|
68
|
+
## Convention Compliance
|
|
69
|
+
|
|
70
|
+
| Convention | File | Status | Detail |
|
|
71
|
+
|------------|------|--------|--------|
|
|
72
|
+
| frozen_string_literal | pending_migrations_verifier.rb | PASS | Line 1 |
|
|
73
|
+
| frozen_string_literal | upgrade_command.rb | PASS | Line 1 |
|
|
74
|
+
| Constructor DI pattern | PendingMigrationsVerifier | PASS | 3 injected deps with defaults |
|
|
75
|
+
| Constructor DI pattern | UpgradeCommand | PASS | 5 injected deps with defaults |
|
|
76
|
+
| Result helpers | PendingMigrationsVerifier | PASS | ok_result, warning_result, error_result methods |
|
|
77
|
+
| Test coverage | All new classes | PASS | 5 tests for verifier, 5 for command, 1 CLI |
|
|
78
|
+
| Test isolation | All tests | PASS | Dir.mktmpdir for file operations, Minitest::Mock for collaborators |
|
|
79
|
+
| RuboCop omakase | All new files | PASS | 0 offenses |
|
|
80
|
+
|
|
81
|
+
## Deep Verification Details
|
|
82
|
+
|
|
83
|
+
### PendingMigrationsVerifier Implementation
|
|
84
|
+
- **Pattern compliance**: Follows SolidQueueVerifier pattern exactly (DI constructor, call method, Result return, rescue block)
|
|
85
|
+
- **Migration filtering**: Correctly filters to only source_monitor migrations (line 63: `name.include?("source_monitor")`)
|
|
86
|
+
- **Timestamp handling**: Strips timestamps using MIGRATION_TIMESTAMP_PATTERN regex (lines 7, 75)
|
|
87
|
+
- **Branch coverage**: 5 tests cover all branches:
|
|
88
|
+
1. All present + not pending (ok)
|
|
89
|
+
2. Missing migrations (warning)
|
|
90
|
+
3. Pending migrations (warning)
|
|
91
|
+
4. Non-SM migrations ignored (ok)
|
|
92
|
+
5. Unexpected errors (error)
|
|
93
|
+
|
|
94
|
+
### UpgradeCommand Implementation
|
|
95
|
+
- **Version detection**: Compares stored vs current version (lines 21-25)
|
|
96
|
+
- **Orchestration**: Calls migration_installer.install, install_generator.run, verifier.call in sequence (lines 27-29)
|
|
97
|
+
- **Version marker timing**: write_version_marker called AFTER verifier.call (line 30), ensuring failed verification prevents marker update
|
|
98
|
+
- **Up-to-date handling**: Returns ok Summary with upgrade Result when versions match (lines 48-56)
|
|
99
|
+
- **Branch coverage**: 5 tests cover all branches:
|
|
100
|
+
1. Versions match (up-to-date)
|
|
101
|
+
2. Versions differ (full upgrade)
|
|
102
|
+
3. Version file missing (fresh install)
|
|
103
|
+
4. Verification raises (marker not written)
|
|
104
|
+
5. Plain text marker format
|
|
105
|
+
|
|
106
|
+
### CLI Integration
|
|
107
|
+
- **Delegation pattern**: Matches install and verify commands (lines 27-31)
|
|
108
|
+
- **Error handling**: Uses handle_summary to exit(1) on non-ok summary
|
|
109
|
+
- **Test coverage**: 1 test verifying delegation to UpgradeCommand and printer
|
|
110
|
+
|
|
111
|
+
### Runner Wiring
|
|
112
|
+
- **Verifier order**: PendingMigrationsVerifier is first (line 21), ensuring migration status checked before other verifiers
|
|
113
|
+
- **Test update**: Runner test updated to expect 4 verifiers instead of 3 (9 assertions)
|
|
114
|
+
|
|
115
|
+
### Autoload Declarations
|
|
116
|
+
- **Setup module**: UpgradeCommand autoloaded at line 172
|
|
117
|
+
- **Verification module**: PendingMigrationsVerifier autoloaded at line 178
|
|
118
|
+
- **Pattern**: Matches existing autoload declarations for Setup and Verification modules
|
|
119
|
+
|
|
120
|
+
## Issues Found
|
|
121
|
+
|
|
122
|
+
**None**. All 34 checks passed.
|
|
123
|
+
|
|
124
|
+
## Summary
|
|
125
|
+
|
|
126
|
+
**Tier**: deep (30+ checks)
|
|
127
|
+
|
|
128
|
+
**Result**: PASS
|
|
129
|
+
|
|
130
|
+
**Passed**: 34/34
|
|
131
|
+
|
|
132
|
+
**Failed**: None
|
|
133
|
+
|
|
134
|
+
**Notes**:
|
|
135
|
+
- The release_packaging_test error is pre-existing and unrelated to Phase 1 changes. It's caused by deleted VBW milestone files in git status that are referenced in the gemspec. This test would fail on the previous milestone as well.
|
|
136
|
+
- Total new test count: 11 (5 PendingMigrationsVerifier + 5 UpgradeCommand + 1 CLI)
|
|
137
|
+
- Total suite now at 992 runs (up from 981 per summary)
|
|
138
|
+
- RuboCop clean: 0 offenses
|
|
139
|
+
- Brakeman clean: 0 warnings
|
|
140
|
+
- All REQ-26 and REQ-27 acceptance criteria met
|
|
141
|
+
- Version marker written AFTER verification (critical for retry safety)
|
|
142
|
+
- PendingMigrationsVerifier correctly filters to source_monitor migrations only
|
|
143
|
+
- Both classes follow established verifier and command patterns
|
|
144
|
+
- Comprehensive test coverage with all branches tested
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
phase: 1
|
|
3
|
+
plan: "01"
|
|
4
|
+
title: upgrade-command-and-migration-verifier
|
|
5
|
+
status: complete
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Tasks
|
|
9
|
+
- [x] Task 1: create-pending-migrations-verifier
|
|
10
|
+
- [x] Task 2: add-pending-migrations-verifier-tests
|
|
11
|
+
- [x] Task 3: wire-verifier-into-runner-and-autoload
|
|
12
|
+
- [x] Task 4: create-upgrade-command-and-cli-integration
|
|
13
|
+
- [x] Task 5: upgrade-command-tests-and-full-verification
|
|
14
|
+
|
|
15
|
+
## Commits
|
|
16
|
+
- 980650b feat(01-upgrade-command): create-pending-migrations-verifier
|
|
17
|
+
- 3834f50 test(01-upgrade-command): add-pending-migrations-verifier-tests
|
|
18
|
+
- 9fbccf5 feat(01-upgrade-command): wire-verifier-into-runner-and-autoload
|
|
19
|
+
- 67f190d feat(01-upgrade-command): create-upgrade-command-and-cli-integration
|
|
20
|
+
- a766f6f test(01-upgrade-command): upgrade-command-tests-and-full-verification
|
|
21
|
+
|
|
22
|
+
## What Was Built
|
|
23
|
+
- PendingMigrationsVerifier (REQ-27): checks engine migrations presence in host db/migrate, warns on missing or pending, filters to source_monitor-only migrations
|
|
24
|
+
- UpgradeCommand (REQ-26): compares .source_monitor_version marker against VERSION, orchestrates MigrationInstaller + InstallGenerator + Verification::Runner, writes marker only after success
|
|
25
|
+
- CLI upgrade subcommand: dispatches to UpgradeCommand via handle_summary
|
|
26
|
+
- Runner wiring: PendingMigrationsVerifier added as first default verifier (most fundamental check)
|
|
27
|
+
- Autoloads: PendingMigrationsVerifier in Verification module, UpgradeCommand in Setup module
|
|
28
|
+
- 11 new tests: 5 verifier + 5 upgrade command + 1 CLI upgrade
|
|
29
|
+
- Full suite: 992 runs, 0 failures, RuboCop 0 offenses, Brakeman 0 warnings
|
|
30
|
+
|
|
31
|
+
## Files Modified
|
|
32
|
+
- lib/source_monitor/setup/verification/pending_migrations_verifier.rb (new)
|
|
33
|
+
- lib/source_monitor/setup/upgrade_command.rb (new)
|
|
34
|
+
- lib/source_monitor/setup/cli.rb (upgrade subcommand)
|
|
35
|
+
- lib/source_monitor/setup/verification/runner.rb (PendingMigrationsVerifier in default_verifiers)
|
|
36
|
+
- lib/source_monitor.rb (autoload declarations)
|
|
37
|
+
- test/lib/source_monitor/setup/verification/pending_migrations_verifier_test.rb (new, 5 tests)
|
|
38
|
+
- test/lib/source_monitor/setup/upgrade_command_test.rb (new, 5 tests)
|
|
39
|
+
- test/lib/source_monitor/setup/verification/runner_test.rb (4-verifier expectation)
|
|
40
|
+
- test/lib/source_monitor/setup/cli_test.rb (upgrade CLI test)
|
|
41
|
+
|
|
42
|
+
## Deviations
|
|
43
|
+
- None
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
---
|
|
2
|
+
phase: 1
|
|
3
|
+
plan: "01"
|
|
4
|
+
title: upgrade-command-and-migration-verifier
|
|
5
|
+
type: execute
|
|
6
|
+
wave: 1
|
|
7
|
+
depends_on: []
|
|
8
|
+
cross_phase_deps: []
|
|
9
|
+
autonomous: true
|
|
10
|
+
effort_override: thorough
|
|
11
|
+
skills_used: []
|
|
12
|
+
files_modified:
|
|
13
|
+
- lib/source_monitor/setup/verification/pending_migrations_verifier.rb
|
|
14
|
+
- lib/source_monitor/setup/verification/runner.rb
|
|
15
|
+
- lib/source_monitor/setup/upgrade_command.rb
|
|
16
|
+
- lib/source_monitor/setup/cli.rb
|
|
17
|
+
- lib/source_monitor.rb
|
|
18
|
+
- test/lib/source_monitor/setup/verification/pending_migrations_verifier_test.rb
|
|
19
|
+
- test/lib/source_monitor/setup/verification/runner_test.rb
|
|
20
|
+
- test/lib/source_monitor/setup/upgrade_command_test.rb
|
|
21
|
+
- test/lib/source_monitor/setup/cli_test.rb
|
|
22
|
+
must_haves:
|
|
23
|
+
truths:
|
|
24
|
+
- "Running `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/verification/pending_migrations_verifier_test.rb` exits 0 with 0 failures"
|
|
25
|
+
- "Running `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/verification/runner_test.rb` exits 0 with 0 failures"
|
|
26
|
+
- "Running `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/upgrade_command_test.rb` exits 0 with 0 failures"
|
|
27
|
+
- "Running `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/cli_test.rb` exits 0 with 0 failures"
|
|
28
|
+
- "Running `bin/rubocop lib/source_monitor/setup/verification/pending_migrations_verifier.rb lib/source_monitor/setup/upgrade_command.rb lib/source_monitor/setup/cli.rb` exits 0 with no offenses"
|
|
29
|
+
- "Running `bin/rails test` exits 0 with 973+ runs and 0 failures"
|
|
30
|
+
artifacts:
|
|
31
|
+
- path: "lib/source_monitor/setup/verification/pending_migrations_verifier.rb"
|
|
32
|
+
provides: "Verifier that checks for unmigrated SourceMonitor migrations (REQ-27)"
|
|
33
|
+
contains: "class PendingMigrationsVerifier"
|
|
34
|
+
- path: "lib/source_monitor/setup/upgrade_command.rb"
|
|
35
|
+
provides: "Upgrade orchestrator that detects version changes and runs remediation (REQ-26)"
|
|
36
|
+
contains: "class UpgradeCommand"
|
|
37
|
+
- path: "lib/source_monitor/setup/cli.rb"
|
|
38
|
+
provides: "CLI entry point with upgrade subcommand"
|
|
39
|
+
contains: "def upgrade"
|
|
40
|
+
- path: "lib/source_monitor/setup/verification/runner.rb"
|
|
41
|
+
provides: "Runner wires PendingMigrationsVerifier into default_verifiers"
|
|
42
|
+
contains: "PendingMigrationsVerifier"
|
|
43
|
+
- path: "lib/source_monitor.rb"
|
|
44
|
+
provides: "Autoload declarations for PendingMigrationsVerifier and UpgradeCommand"
|
|
45
|
+
contains: "autoload :PendingMigrationsVerifier"
|
|
46
|
+
- path: "test/lib/source_monitor/setup/verification/pending_migrations_verifier_test.rb"
|
|
47
|
+
provides: "Tests covering all PendingMigrationsVerifier branches"
|
|
48
|
+
contains: "class PendingMigrationsVerifierTest"
|
|
49
|
+
- path: "test/lib/source_monitor/setup/upgrade_command_test.rb"
|
|
50
|
+
provides: "Tests covering UpgradeCommand version detection and orchestration"
|
|
51
|
+
contains: "class UpgradeCommandTest"
|
|
52
|
+
key_links:
|
|
53
|
+
- from: "pending_migrations_verifier.rb"
|
|
54
|
+
to: "REQ-27"
|
|
55
|
+
via: "Checks for unmigrated SourceMonitor migrations without running them"
|
|
56
|
+
- from: "upgrade_command.rb"
|
|
57
|
+
to: "REQ-26"
|
|
58
|
+
via: "Detects version changes, copies migrations, re-runs generator, runs verification"
|
|
59
|
+
- from: "cli.rb#upgrade"
|
|
60
|
+
to: "upgrade_command.rb"
|
|
61
|
+
via: "CLI dispatches upgrade subcommand to UpgradeCommand"
|
|
62
|
+
- from: "runner.rb#default_verifiers"
|
|
63
|
+
to: "pending_migrations_verifier.rb"
|
|
64
|
+
via: "Runner includes PendingMigrationsVerifier in the default verifier set"
|
|
65
|
+
---
|
|
66
|
+
<objective>
|
|
67
|
+
Add a PendingMigrationsVerifier to the verification suite (REQ-27) and a `bin/source_monitor upgrade` command (REQ-26) that detects version changes since last install, copies new migrations, re-runs the idempotent generator, runs verification, and reports what changed. The upgrade command stores a `.source_monitor_version` file marker in the host app root.
|
|
68
|
+
</objective>
|
|
69
|
+
<context>
|
|
70
|
+
@lib/source_monitor/setup/verification/solid_queue_verifier.rb -- Primary pattern reference for the new PendingMigrationsVerifier. Shows constructor dependency injection (process_relation:, connection:, clock:), `call` method with guard clauses returning early for missing deps, and Result helpers (ok_result, warning_result, error_result). Key: each verifier returns a single Result. The PendingMigrationsVerifier should follow this exact structure.
|
|
71
|
+
|
|
72
|
+
@lib/source_monitor/setup/verification/recurring_schedule_verifier.rb -- Second pattern reference. Shows how to query a relation and filter results. The PendingMigrationsVerifier needs a different approach: it must compare engine migration files against the host app's `db/migrate/` directory to find migrations that have been copied but not yet run (pending), or that have not been copied at all (missing).
|
|
73
|
+
|
|
74
|
+
@lib/source_monitor/setup/verification/result.rb -- Result struct with key, name, status, details, remediation and status predicates (ok?, warning?, error?). Summary aggregates results. The PendingMigrationsVerifier should use key: :pending_migrations, name: "Pending Migrations".
|
|
75
|
+
|
|
76
|
+
@lib/source_monitor/setup/verification/runner.rb -- Orchestrator with `default_verifiers` array. Currently `[SolidQueueVerifier.new, RecurringScheduleVerifier.new, ActionCableVerifier.new]`. Add `PendingMigrationsVerifier.new` to this array, placed first since migration status is the most fundamental check.
|
|
77
|
+
|
|
78
|
+
@lib/source_monitor/setup/cli.rb -- Thor-based CLI with `install` and `verify` subcommands. The `upgrade` subcommand follows the same pattern: instantiate UpgradeCommand, call it, handle the summary via handle_summary. Thor handles command dispatch automatically.
|
|
79
|
+
|
|
80
|
+
@lib/source_monitor/setup/workflow.rb -- The install workflow that the upgrade command partially re-uses. Key collaborators: MigrationInstaller (copies + runs migrations), InstallGenerator (idempotent generator), Verification::Runner (runs all verifiers). The upgrade command orchestrates a subset of these: migration_installer.install, install_generator.run, verification_runner.call.
|
|
81
|
+
|
|
82
|
+
@lib/source_monitor/setup/migration_installer.rb -- Copies engine migrations via `bin/rails railties:install:migrations FROM=source_monitor`, deduplicates Solid Queue migrations, then runs `db:migrate`. The upgrade command delegates to this directly.
|
|
83
|
+
|
|
84
|
+
@lib/source_monitor/setup/install_generator.rb -- Wraps `bin/rails generate source_monitor:install --mount-path=...`. Fully idempotent, safe to re-run. The upgrade command calls this to pick up any new generator steps added in the new version.
|
|
85
|
+
|
|
86
|
+
@test/lib/source_monitor/setup/verification/solid_queue_verifier_test.rb -- Test pattern: FakeRelation and FakeConnection stubs, tests all branches. The PendingMigrationsVerifier test should use similar lightweight stubs.
|
|
87
|
+
|
|
88
|
+
@test/lib/source_monitor/setup/cli_test.rb -- Tests CLI commands by stubbing collaborators. The upgrade command test should follow the same Minitest::Mock + stub pattern.
|
|
89
|
+
|
|
90
|
+
@test/lib/source_monitor/setup/verification/runner_test.rb -- Tests Runner with stub verifiers. Must be updated to include PendingMigrationsVerifier in the default verifiers test (expect 4 results instead of 3).
|
|
91
|
+
|
|
92
|
+
@test/lib/source_monitor/setup/migration_installer_test.rb -- Shows FakeShell pattern for testing shell commands. The UpgradeCommand test should use the same approach.
|
|
93
|
+
|
|
94
|
+
@lib/source_monitor.rb lines 157-184 -- Autoload declarations for Setup module and Verification submodule. Add `autoload :UpgradeCommand` in Setup block and `autoload :PendingMigrationsVerifier` in Verification block.
|
|
95
|
+
|
|
96
|
+
@lib/source_monitor/version.rb -- VERSION constant ("0.4.0"). The upgrade command compares this against the stored `.source_monitor_version` marker file.
|
|
97
|
+
|
|
98
|
+
**Version marker design decision:** Use a plain text file `.source_monitor_version` in the host app root (Dir.pwd). This is the simplest approach: no database dependency, no migration needed, easy to inspect and debug. The file contains the gem version string (e.g., "0.4.0"). The upgrade command reads this file, compares to SourceMonitor::VERSION, and acts accordingly. If the file does not exist, the upgrade command treats it as a fresh install scenario and runs the full upgrade flow.
|
|
99
|
+
|
|
100
|
+
**PendingMigrationsVerifier design:** The verifier checks whether engine migrations have been copied to the host app and whether any are pending (not yet run). It uses `bin/rails railties:install:migrations FROM=source_monitor --dry-run` or compares engine migration filenames against `db/migrate/`. A simpler approach: compare the engine's `db/migrate/` files against the host's `db/migrate/` files by migration name (ignoring timestamps). If engine migrations are missing from the host, report them. This check does NOT run migrations -- that is the upgrade command's job.
|
|
101
|
+
|
|
102
|
+
**Simpler PendingMigrationsVerifier approach:** Inject the engine migrations path and host migrations path. Compare migration basenames (strip timestamps). Any engine migration whose basename is not found in the host's db/migrate/ is "missing". For "pending" (copied but not run), check ActiveRecord::Base.connection.migration_context.needs_migration? -- but this checks ALL migrations, not just SourceMonitor ones. A pragmatic middle ground: check if any engine migration names are missing from the host, and separately check if the overall schema needs migration. If engine migrations are all present and no pending migrations exist, report ok. If engine migrations are missing, report warning with list of missing migration names.
|
|
103
|
+
</context>
|
|
104
|
+
<tasks>
|
|
105
|
+
<task type="auto">
|
|
106
|
+
<name>create-pending-migrations-verifier</name>
|
|
107
|
+
<files>
|
|
108
|
+
lib/source_monitor/setup/verification/pending_migrations_verifier.rb
|
|
109
|
+
</files>
|
|
110
|
+
<action>
|
|
111
|
+
Create `lib/source_monitor/setup/verification/pending_migrations_verifier.rb` following the verifier pattern from SolidQueueVerifier and RecurringScheduleVerifier.
|
|
112
|
+
|
|
113
|
+
The verifier checks two things:
|
|
114
|
+
1. Whether all engine migrations have been copied to the host app's `db/migrate/` directory
|
|
115
|
+
2. Whether there are any pending migrations (copied but not run)
|
|
116
|
+
|
|
117
|
+
Constructor accepts dependency-injected parameters for testability:
|
|
118
|
+
- `engine_migrations_path:` -- defaults to the engine's `db/migrate/` directory (SourceMonitor::Engine.root.join("db/migrate"))
|
|
119
|
+
- `host_migrations_path:` -- defaults to `Rails.root.join("db/migrate")`
|
|
120
|
+
- `connection:` -- defaults to `ActiveRecord::Base.connection`
|
|
121
|
+
|
|
122
|
+
The `call` method logic:
|
|
123
|
+
1. List engine migration files, extract basenames without timestamps (e.g., `create_source_monitor_sources` from `20241008120000_create_source_monitor_sources.rb`). Filter to only `source_monitor` migrations (basename contains "source_monitor" or "solid_cable" or "solid_queue"). Actually, simpler: only check migrations whose basename contains `source_monitor`.
|
|
124
|
+
2. List host migration files, extract basenames the same way.
|
|
125
|
+
3. Find missing: engine basenames not present in host basenames.
|
|
126
|
+
4. If missing migrations exist: return warning_result listing missing migration names with remediation to run `bin/source_monitor upgrade` or `bin/rails railties:install:migrations FROM=source_monitor`.
|
|
127
|
+
5. If all present, check `connection.migration_context.needs_migration?` -- if true, return warning_result that migrations are pending.
|
|
128
|
+
6. If all present and no pending: return ok_result.
|
|
129
|
+
7. Wrap in rescue StandardError for unexpected failures.
|
|
130
|
+
|
|
131
|
+
Use key: `:pending_migrations`, name: `"Pending Migrations"`.
|
|
132
|
+
|
|
133
|
+
Filter engine migrations to only those whose basename includes "source_monitor" (skip solid_queue and solid_cable migrations since those are owned by their respective engines). This ensures the verifier only checks SourceMonitor's own tables.
|
|
134
|
+
</action>
|
|
135
|
+
<verify>
|
|
136
|
+
Read the created file. Confirm: (a) class is in correct module nesting `SourceMonitor::Setup::Verification::PendingMigrationsVerifier`, (b) constructor injects `engine_migrations_path:`, `host_migrations_path:`, `connection:`, (c) `call` handles: all present + migrated (ok), missing migrations (warning), pending migrations (warning), unexpected error, (d) Result key is `:pending_migrations`, (e) only checks `source_monitor` migrations.
|
|
137
|
+
</verify>
|
|
138
|
+
<done>
|
|
139
|
+
PendingMigrationsVerifier created with all branches: ok (all present, none pending), warning (missing migrations), warning (pending migrations), error (unexpected failure). Only checks source_monitor-prefixed migrations.
|
|
140
|
+
</done>
|
|
141
|
+
</task>
|
|
142
|
+
<task type="auto">
|
|
143
|
+
<name>add-pending-migrations-verifier-tests</name>
|
|
144
|
+
<files>
|
|
145
|
+
test/lib/source_monitor/setup/verification/pending_migrations_verifier_test.rb
|
|
146
|
+
</files>
|
|
147
|
+
<action>
|
|
148
|
+
Create `test/lib/source_monitor/setup/verification/pending_migrations_verifier_test.rb` following the test patterns from `solid_queue_verifier_test.rb`.
|
|
149
|
+
|
|
150
|
+
Use `Dir.mktmpdir` to create temporary directories representing engine and host migration paths, then populate them with fake migration files to test each branch.
|
|
151
|
+
|
|
152
|
+
Tests to write:
|
|
153
|
+
|
|
154
|
+
1. **"returns ok when all engine migrations are present and none pending"** -- Create engine dir with `20241008120000_create_source_monitor_sources.rb` and `20241008121000_create_source_monitor_items.rb`. Create host dir with same basenames (different timestamps ok). Stub connection so `migration_context.needs_migration?` returns false. Assert status :ok.
|
|
155
|
+
|
|
156
|
+
2. **"warns when engine migrations are missing from host"** -- Create engine dir with two source_monitor migrations. Create host dir with only one. Assert status :warning. Assert details mention the missing migration basename.
|
|
157
|
+
|
|
158
|
+
3. **"warns when migrations are pending"** -- All engine migrations present in host. Stub `migration_context.needs_migration?` to return true. Assert status :warning with remediation mentioning `db:migrate`.
|
|
159
|
+
|
|
160
|
+
4. **"ignores non-source-monitor engine migrations"** -- Engine dir has `20251010160000_create_solid_cable_messages.rb` (not a source_monitor migration). Host dir is empty. Assert status :ok (no source_monitor migrations missing).
|
|
161
|
+
|
|
162
|
+
5. **"rescues unexpected failures"** -- Pass a connection that raises on `migration_context`. Assert status :error with remediation.
|
|
163
|
+
|
|
164
|
+
Use lightweight stubs:
|
|
165
|
+
```ruby
|
|
166
|
+
class FakeMigrationContext
|
|
167
|
+
def initialize(needs_migration:)
|
|
168
|
+
@needs_migration = needs_migration
|
|
169
|
+
end
|
|
170
|
+
def needs_migration?
|
|
171
|
+
@needs_migration
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
class FakeConnection
|
|
176
|
+
def initialize(needs_migration: false)
|
|
177
|
+
@context = FakeMigrationContext.new(needs_migration: needs_migration)
|
|
178
|
+
end
|
|
179
|
+
def migration_context
|
|
180
|
+
@context
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
5 tests covering all branches.
|
|
186
|
+
</action>
|
|
187
|
+
<verify>
|
|
188
|
+
Run `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/verification/pending_migrations_verifier_test.rb` -- all 5 tests pass. Run `bin/rubocop test/lib/source_monitor/setup/verification/pending_migrations_verifier_test.rb` -- 0 offenses.
|
|
189
|
+
</verify>
|
|
190
|
+
<done>
|
|
191
|
+
5 tests pass covering: ok (all present, not pending), warning (missing), warning (pending), ok (ignores non-SM migrations), error (unexpected failure). RuboCop clean.
|
|
192
|
+
</done>
|
|
193
|
+
</task>
|
|
194
|
+
<task type="auto">
|
|
195
|
+
<name>wire-verifier-into-runner-and-autoload</name>
|
|
196
|
+
<files>
|
|
197
|
+
lib/source_monitor/setup/verification/runner.rb
|
|
198
|
+
lib/source_monitor.rb
|
|
199
|
+
test/lib/source_monitor/setup/verification/runner_test.rb
|
|
200
|
+
</files>
|
|
201
|
+
<action>
|
|
202
|
+
**Modify `lib/source_monitor/setup/verification/runner.rb`:**
|
|
203
|
+
|
|
204
|
+
Add `PendingMigrationsVerifier.new` as the FIRST entry in the `default_verifiers` array. Migration status is the most fundamental check and should run before other verifiers. The array becomes:
|
|
205
|
+
```ruby
|
|
206
|
+
def default_verifiers
|
|
207
|
+
[ PendingMigrationsVerifier.new, SolidQueueVerifier.new, RecurringScheduleVerifier.new, ActionCableVerifier.new ]
|
|
208
|
+
end
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Modify `lib/source_monitor.rb`:**
|
|
212
|
+
|
|
213
|
+
Add the autoload declaration in the `module Verification` block (around line 177), before the Runner line:
|
|
214
|
+
```ruby
|
|
215
|
+
autoload :PendingMigrationsVerifier, "source_monitor/setup/verification/pending_migrations_verifier"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Also add in the `module Setup` block (around line 171):
|
|
219
|
+
```ruby
|
|
220
|
+
autoload :UpgradeCommand, "source_monitor/setup/upgrade_command"
|
|
221
|
+
```
|
|
222
|
+
(This autoload is needed for task 4 but adding it here keeps autoload changes in one task.)
|
|
223
|
+
|
|
224
|
+
**Modify `test/lib/source_monitor/setup/verification/runner_test.rb`:**
|
|
225
|
+
|
|
226
|
+
Update the "uses default verifiers" test:
|
|
227
|
+
1. Add `pending_result = Result.new(key: :pending_migrations, name: "Pending Migrations", status: :ok, details: "ok")`
|
|
228
|
+
2. Add `pending_double = verifier_double.new(pending_result)`
|
|
229
|
+
3. Add a stub for `PendingMigrationsVerifier.stub(:new, ->(*) { pending_double })` wrapping the existing stubs
|
|
230
|
+
4. Update assertion to `assert_equal 4, summary.results.size`
|
|
231
|
+
5. Add `assert_equal 1, pending_double.calls`
|
|
232
|
+
</action>
|
|
233
|
+
<verify>
|
|
234
|
+
Run `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/verification/runner_test.rb` -- all tests pass. Grep for `PendingMigrationsVerifier` in runner.rb and source_monitor.rb confirms wiring. Grep for `UpgradeCommand` in source_monitor.rb confirms autoload.
|
|
235
|
+
</verify>
|
|
236
|
+
<done>
|
|
237
|
+
PendingMigrationsVerifier wired into Runner.default_verifiers as the first verifier. Both PendingMigrationsVerifier and UpgradeCommand autoloaded from lib/source_monitor.rb. Runner test updated to expect 4 verifiers.
|
|
238
|
+
</done>
|
|
239
|
+
</task>
|
|
240
|
+
<task type="auto">
|
|
241
|
+
<name>create-upgrade-command-and-cli-integration</name>
|
|
242
|
+
<files>
|
|
243
|
+
lib/source_monitor/setup/upgrade_command.rb
|
|
244
|
+
lib/source_monitor/setup/cli.rb
|
|
245
|
+
</files>
|
|
246
|
+
<action>
|
|
247
|
+
**Create `lib/source_monitor/setup/upgrade_command.rb`:**
|
|
248
|
+
|
|
249
|
+
The UpgradeCommand orchestrates the upgrade flow. Constructor accepts dependency-injected collaborators for testability:
|
|
250
|
+
- `migration_installer:` -- defaults to `MigrationInstaller.new`
|
|
251
|
+
- `install_generator:` -- defaults to `InstallGenerator.new`
|
|
252
|
+
- `verifier:` -- defaults to `Verification::Runner.new`
|
|
253
|
+
- `version_file:` -- defaults to `File.join(Dir.pwd, ".source_monitor_version")`
|
|
254
|
+
- `current_version:` -- defaults to `SourceMonitor::VERSION`
|
|
255
|
+
|
|
256
|
+
Public method `call` returns a `Verification::Summary`:
|
|
257
|
+
|
|
258
|
+
```ruby
|
|
259
|
+
def call
|
|
260
|
+
stored = read_stored_version
|
|
261
|
+
if stored == current_version
|
|
262
|
+
return up_to_date_summary
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
migration_installer.install
|
|
266
|
+
install_generator.run
|
|
267
|
+
summary = verifier.call
|
|
268
|
+
write_version_marker
|
|
269
|
+
summary
|
|
270
|
+
end
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Private methods:
|
|
274
|
+
- `read_stored_version` -- reads `.source_monitor_version` file, returns nil if missing, strips whitespace
|
|
275
|
+
- `write_version_marker` -- writes `current_version` to the version file
|
|
276
|
+
- `up_to_date_summary` -- returns a `Verification::Summary` with a single ok Result: key `:upgrade`, name `"Upgrade"`, details `"Already up to date (v#{current_version})"`, no remediation
|
|
277
|
+
|
|
278
|
+
Key design points:
|
|
279
|
+
- The command is intentionally simple: it orchestrates existing tools
|
|
280
|
+
- MigrationInstaller handles copying + deduplication + running migrations
|
|
281
|
+
- InstallGenerator re-runs the idempotent generator to pick up new steps
|
|
282
|
+
- Verification::Runner runs all verifiers (including PendingMigrationsVerifier) to confirm health
|
|
283
|
+
- Version marker is written AFTER successful verification so a failed upgrade can be re-run
|
|
284
|
+
- The `up_to_date_summary` returns an ok summary so `handle_summary` does not exit(1)
|
|
285
|
+
|
|
286
|
+
**Modify `lib/source_monitor/setup/cli.rb`:**
|
|
287
|
+
|
|
288
|
+
Add an `upgrade` subcommand following the pattern of `install` and `verify`:
|
|
289
|
+
|
|
290
|
+
```ruby
|
|
291
|
+
desc "upgrade", "Upgrade SourceMonitor after a gem version change"
|
|
292
|
+
def upgrade
|
|
293
|
+
command = UpgradeCommand.new
|
|
294
|
+
summary = command.call
|
|
295
|
+
handle_summary(summary)
|
|
296
|
+
end
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Place it after the `verify` method, before the `private` keyword.
|
|
300
|
+
</action>
|
|
301
|
+
<verify>
|
|
302
|
+
Read `lib/source_monitor/setup/upgrade_command.rb` and confirm: (a) constructor accepts all 5 injectable deps, (b) `call` checks version marker, returns early if current, otherwise runs migration_installer + install_generator + verifier, (c) writes version marker after verification, (d) up_to_date_summary returns ok. Read `lib/source_monitor/setup/cli.rb` and confirm the `upgrade` method exists and delegates to UpgradeCommand.
|
|
303
|
+
</verify>
|
|
304
|
+
<done>
|
|
305
|
+
UpgradeCommand created with version detection and orchestration of MigrationInstaller, InstallGenerator, and Verification::Runner. CLI wired with `upgrade` subcommand. Version marker stored in `.source_monitor_version`.
|
|
306
|
+
</done>
|
|
307
|
+
</task>
|
|
308
|
+
<task type="auto">
|
|
309
|
+
<name>upgrade-command-tests-and-full-verification</name>
|
|
310
|
+
<files>
|
|
311
|
+
test/lib/source_monitor/setup/upgrade_command_test.rb
|
|
312
|
+
test/lib/source_monitor/setup/cli_test.rb
|
|
313
|
+
</files>
|
|
314
|
+
<action>
|
|
315
|
+
**Create `test/lib/source_monitor/setup/upgrade_command_test.rb`:**
|
|
316
|
+
|
|
317
|
+
Follow the test patterns from `workflow_test.rb` and `migration_installer_test.rb`. Use `Dir.mktmpdir` for the version file location. Use Minitest::Mock for collaborators.
|
|
318
|
+
|
|
319
|
+
Tests to write:
|
|
320
|
+
|
|
321
|
+
1. **"returns up-to-date summary when version matches"** -- Create a tmpdir, write "0.4.0" to version file. Instantiate UpgradeCommand with version_file pointing there, current_version "0.4.0". Call. Assert summary is ok with details matching "Already up to date". Assert migration_installer, install_generator, verifier were NOT called (use mocks that would fail if called).
|
|
322
|
+
|
|
323
|
+
2. **"runs upgrade flow when version differs"** -- Write "0.3.3" to version file. Create mocks for migration_installer (expect :install), install_generator (expect :run), verifier (expect :call, returns ok Summary). Call. Verify all mocks called. Assert version file now contains "0.4.0".
|
|
324
|
+
|
|
325
|
+
3. **"runs upgrade flow when version file missing"** -- No version file exists. Same mock setup as test 2. Call. Verify all mocks called. Assert version file created with "0.4.0".
|
|
326
|
+
|
|
327
|
+
4. **"does not write version marker until after verification"** -- Verifier raises an error. Assert version file is NOT updated (still contains old version or does not exist). Use a verifier that raises to simulate failure.
|
|
328
|
+
|
|
329
|
+
5. **"version marker file is plain text with version string"** -- After successful upgrade, read the file and assert it equals the version string with no extra whitespace.
|
|
330
|
+
|
|
331
|
+
**Modify `test/lib/source_monitor/setup/cli_test.rb`:**
|
|
332
|
+
|
|
333
|
+
Add a test for the upgrade command following the same pattern as the existing "verify command runs runner" test:
|
|
334
|
+
|
|
335
|
+
```ruby
|
|
336
|
+
test "upgrade command delegates to upgrade command and prints summary" do
|
|
337
|
+
summary = SourceMonitor::Setup::Verification::Summary.new([])
|
|
338
|
+
upgrade_cmd = Minitest::Mock.new
|
|
339
|
+
upgrade_cmd.expect(:call, summary)
|
|
340
|
+
printer = Minitest::Mock.new
|
|
341
|
+
printer.expect(:print, nil, [summary])
|
|
342
|
+
|
|
343
|
+
SourceMonitor::Setup::UpgradeCommand.stub(:new, ->(*) { upgrade_cmd }) do
|
|
344
|
+
SourceMonitor::Setup::Verification::Printer.stub(:new, printer) do
|
|
345
|
+
CLI.start(["upgrade"])
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
upgrade_cmd.verify
|
|
350
|
+
printer.verify
|
|
351
|
+
assert_mock upgrade_cmd
|
|
352
|
+
assert_mock printer
|
|
353
|
+
end
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
**Run full verification:**
|
|
357
|
+
1. `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/upgrade_command_test.rb` -- all tests pass
|
|
358
|
+
2. `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/cli_test.rb` -- all tests pass
|
|
359
|
+
3. `bin/rails test` -- full suite passes with 973+ runs and 0 failures
|
|
360
|
+
4. `bin/rubocop` -- zero offenses
|
|
361
|
+
5. `bin/brakeman --no-pager` -- zero warnings
|
|
362
|
+
</action>
|
|
363
|
+
<verify>
|
|
364
|
+
`PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/upgrade_command_test.rb` exits 0. `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/cli_test.rb` exits 0. `bin/rails test` exits 0 with 973+ runs, 0 failures. `bin/rubocop` exits 0. `bin/brakeman --no-pager` exits 0.
|
|
365
|
+
</verify>
|
|
366
|
+
<done>
|
|
367
|
+
5 UpgradeCommand tests + 1 CLI test pass. Full suite green. RuboCop clean. Brakeman clean. All REQ-26 and REQ-27 acceptance criteria met.
|
|
368
|
+
</done>
|
|
369
|
+
</task>
|
|
370
|
+
</tasks>
|
|
371
|
+
<verification>
|
|
372
|
+
1. `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/verification/pending_migrations_verifier_test.rb` -- 5 tests pass
|
|
373
|
+
2. `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/verification/runner_test.rb` -- 2 tests pass with 4-verifier expectation
|
|
374
|
+
3. `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/upgrade_command_test.rb` -- 5 tests pass
|
|
375
|
+
4. `PARALLEL_WORKERS=1 bin/rails test test/lib/source_monitor/setup/cli_test.rb` -- 5 tests pass (4 existing + 1 new)
|
|
376
|
+
5. `bin/rails test` -- 973+ runs, 0 failures
|
|
377
|
+
6. `bin/rubocop` -- 0 offenses
|
|
378
|
+
7. `bin/brakeman --no-pager` -- 0 warnings
|
|
379
|
+
8. `grep -n 'class PendingMigrationsVerifier' lib/source_monitor/setup/verification/pending_migrations_verifier.rb` returns a match
|
|
380
|
+
9. `grep -n 'class UpgradeCommand' lib/source_monitor/setup/upgrade_command.rb` returns a match
|
|
381
|
+
10. `grep -n 'def upgrade' lib/source_monitor/setup/cli.rb` returns a match
|
|
382
|
+
11. `grep -n 'PendingMigrationsVerifier' lib/source_monitor/setup/verification/runner.rb` returns a match
|
|
383
|
+
12. `grep -n 'PendingMigrationsVerifier' lib/source_monitor.rb` returns a match
|
|
384
|
+
13. `grep -n 'UpgradeCommand' lib/source_monitor.rb` returns a match
|
|
385
|
+
14. `grep -n '.source_monitor_version' lib/source_monitor/setup/upgrade_command.rb` returns a match
|
|
386
|
+
</verification>
|
|
387
|
+
<success_criteria>
|
|
388
|
+
- PendingMigrationsVerifier returns ok when all SourceMonitor migrations are present and run (REQ-27)
|
|
389
|
+
- PendingMigrationsVerifier warns when engine migrations are missing from host (REQ-27)
|
|
390
|
+
- PendingMigrationsVerifier warns when migrations are pending (copied but not run) (REQ-27)
|
|
391
|
+
- PendingMigrationsVerifier ignores non-SourceMonitor engine migrations (REQ-27)
|
|
392
|
+
- PendingMigrationsVerifier is included in Runner.default_verifiers (REQ-27)
|
|
393
|
+
- UpgradeCommand compares stored .source_monitor_version against SourceMonitor::VERSION (REQ-26)
|
|
394
|
+
- UpgradeCommand returns "Already up to date" when versions match (REQ-26)
|
|
395
|
+
- UpgradeCommand copies migrations, re-runs generator, runs verification when versions differ (REQ-26)
|
|
396
|
+
- UpgradeCommand writes version marker only after successful verification (REQ-26)
|
|
397
|
+
- `bin/source_monitor upgrade` CLI subcommand dispatches to UpgradeCommand (REQ-26)
|
|
398
|
+
- Both PendingMigrationsVerifier and UpgradeCommand autoloaded from lib/source_monitor.rb
|
|
399
|
+
- All existing tests continue to pass (no regressions)
|
|
400
|
+
- 11+ new tests across PendingMigrationsVerifier, UpgradeCommand, and CLI
|
|
401
|
+
- RuboCop clean, Brakeman clean
|
|
402
|
+
</success_criteria>
|
|
403
|
+
<output>
|
|
404
|
+
.vbw-planning/phases/01-upgrade-command/PLAN-01-SUMMARY.md
|
|
405
|
+
</output>
|
data/.vbw-planning/milestones/upgrade-assurance/phases/02-config-deprecation/PLAN-01-SUMMARY.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
phase: 2
|
|
3
|
+
plan: "01"
|
|
4
|
+
title: config-deprecation-framework
|
|
5
|
+
status: complete
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Tasks
|
|
9
|
+
- [x] Task 1: create-deprecation-registry -- DeprecationRegistry class with register/clear!/entries/registered?, DeprecatedOptionError, SETTINGS_CLASSES mapping for all 11 settings classes
|
|
10
|
+
- [x] Task 2: wire-registry-into-configuration-and-autoload -- require in configuration.rb, check_deprecations! method, configure hook
|
|
11
|
+
- [x] Task 3: create-deprecation-registry-tests -- 10 tests covering all branches (warning/error/clear/top-level/zero-false-positives/multiple/wiring)
|
|
12
|
+
- [x] Task 4: full-suite-verification-and-brakeman -- 1002 runs/0 failures, RuboCop 0 offenses, Brakeman 0 warnings
|
|
13
|
+
|
|
14
|
+
## Commits
|
|
15
|
+
- 5e95f72 feat(02-config-deprecation): create-deprecation-registry
|
|
16
|
+
- 12d8b31 feat(02-config-deprecation): wire-registry-into-configuration-and-autoload
|
|
17
|
+
- b29c183 test(02-config-deprecation): create-deprecation-registry-tests
|
|
18
|
+
|
|
19
|
+
## Files Modified
|
|
20
|
+
- lib/source_monitor/configuration/deprecation_registry.rb (new -- DeprecationRegistry class + DeprecatedOptionError)
|
|
21
|
+
- lib/source_monitor/configuration.rb (added require + check_deprecations! method)
|
|
22
|
+
- lib/source_monitor.rb (added config.check_deprecations! in configure)
|
|
23
|
+
- test/lib/source_monitor/configuration/deprecation_registry_test.rb (new -- 10 tests)
|
|
24
|
+
|
|
25
|
+
## Deviations
|
|
26
|
+
- DEVN-01: Fixed replacement resolution bug where same-prefix paths (e.g. "http.old_proxy" -> "http.proxy") incorrectly tried to call `self.http` on an HTTPSettings instance. Added `source_prefix` parameter to replacement_setter_for/replacement_getter_for to detect when deprecated and replacement options share the same settings class prefix, resolving directly on `self` instead.
|
|
27
|
+
- Pre-existing: ReleasePackagingTest (1 error) fails due to untracked `.vbw-planning/phases/` files in gemspec's `git ls-files` output. Not caused by this plan.
|