PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
FIX (verification): Allow manual verification when scheduling is disabled
Rostislav Duginfff220647c7e
diff --git a/backend/internal/features/verification/runs/repository.go b/backend/internal/features/verification/runs/repository.goindex 99e0f984..85708c7d 100644--- a/backend/internal/features/verification/runs/repository.go+++ b/backend/internal/features/verification/runs/repository.go@@ -273,7 +273,10 @@ func (r *VerificationRepository) FindRunningByAgent(return verifications, err}-func (r *VerificationRepository) FindNonTerminalForDisabledConfigs() ([]*RestoreVerification, error) {+func (r *VerificationRepository) GetNonTerminalAutomaticVerificationsForDisabledSchedules() (+ []*RestoreVerification,+ error,+) {verifications := make([]*RestoreVerification, 0)err := storage.GetDb().@@ -281,8 +284,9 @@ func (r *VerificationRepository) FindNonTerminalForDisabledConfigs() ([]*RestoreSelect("v.*").Joins("JOIN backup_verification_configs c ON c.database_id = v.database_id").Where(- "c.is_scheduled_verification_enabled = ? AND v.status IN ?",+ "c.is_scheduled_verification_enabled = ? AND v.trigger IN ? AND v.status IN ?",false,+ []VerificationTrigger{VerificationTriggerScheduled, VerificationTriggerAfterBackup},[]VerificationStatus{VerificationStatusPending, VerificationStatusRunning},).Scan(&verifications).Errordiff --git a/backend/internal/features/verification/runs/scheduler.go b/backend/internal/features/verification/runs/scheduler.goindex 5bcf8571..08f45071 100644--- a/backend/internal/features/verification/runs/scheduler.go+++ b/backend/internal/features/verification/runs/scheduler.go@@ -63,7 +63,7 @@ func (s *VerificationScheduler) Run(ctx context.Context) {tickLogger.ErrorContext(ctx, "failed to reap stale verification runs", "error", err)}- if err := s.sweepCanceledByDisabledConfig(ctx, tickLogger); err != nil {+ if err := s.cancelAutomaticVerificationsForDisabledSchedules(ctx, tickLogger); err != nil {tickLogger.ErrorContext(ctx, "failed to cancel verifications for disabled configs", "error", err)}}@@ -235,10 +235,12 @@ func (s *VerificationScheduler) reapStaleRuns(ctx context.Context, logger *slog.return nil}-// sweepCanceledByDisabledConfig sends no notification-// — disable is user-initiated, not a failure.-func (s *VerificationScheduler) sweepCanceledByDisabledConfig(ctx context.Context, logger *slog.Logger) error {- rows, err := s.repo.FindNonTerminalForDisabledConfigs()+// Disabling a schedule is user initiated, so cancellation does not send a failure notification.+func (s *VerificationScheduler) cancelAutomaticVerificationsForDisabledSchedules(+ ctx context.Context,+ logger *slog.Logger,+) error {+ rows, err := s.repo.GetNonTerminalAutomaticVerificationsForDisabledSchedules()if err != nil {return err}diff --git a/backend/internal/features/verification/runs/scheduler_test.go b/backend/internal/features/verification/runs/scheduler_test.goindex e207bc4e..f1589354 100644--- a/backend/internal/features/verification/runs/scheduler_test.go+++ b/backend/internal/features/verification/runs/scheduler_test.go@@ -338,7 +338,9 @@ func Test_ReapStaleRuns_WhenPendingExceedsMaxDuration_MarksTerminalRegardlessOfPassert.Contains(t, *final.FailMessage, "not picked up")}-func Test_SweepCanceledByDisabledConfig_WhenScheduledVerificationDisabled_CancelsNonTerminalRows(t *testing.T) {+func Test_CancelAutomaticVerificationsForDisabledSchedules_WhenScheduledVerificationDisabled_CancelsNonTerminalRows(+ t *testing.T,+) {router := createTestRouter()owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleAdmin)workspace := workspaces_testing.CreateTestWorkspace(t.Context(), "ws "+uuid.New().String(), owner, router)@@ -371,7 +373,7 @@ func Test_SweepCanceledByDisabledConfig_WhenScheduledVerificationDisabled_CancelVerificationInterval: intervals.Interval{Type: intervals.IntervalHourly},})- require.NoError(t, scheduler.sweepCanceledByDisabledConfig(t.Context(), logger.GetLogger()))+ require.NoError(t, scheduler.cancelAutomaticVerificationsForDisabledSchedules(t.Context(), logger.GetLogger()))final := GetVerificationByIDViaAPI(t, router, owner.Token, scheduledRowID)assert.Equal(t, VerificationStatusCanceled, final.Status)@@ -379,6 +381,245 @@ func Test_SweepCanceledByDisabledConfig_WhenScheduledVerificationDisabled_Cancelassert.Contains(t, *final.FailMessage, "schedule was disabled")}+func Test_CancelAutomaticVerificationsForDisabledSchedules_WhenManualVerificationExists_LeavesItPending(+ t *testing.T,+) {+ router := createTestRouter()+ owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleAdmin)+ workspace := workspaces_testing.CreateTestWorkspace(t.Context(), "ws "+uuid.New().String(), owner, router)+ defer workspaces_testing.RemoveTestWorkspace(t.Context(), workspace, router)++ testStorage := storages.CreateTestStorage(workspace.ID)+ defer storages.RemoveTestStorage(t.Context(), testStorage.ID)++ notifier := notifiers.CreateTestNotifier(workspace.ID)+ defer notifiers.RemoveTestNotifier(notifier)++ database := databases.CreateTestDatabase(workspace.ID, testStorage, notifier)+ defer databases.RemoveTestDatabase(t.Context(), database)++ verification_config.SaveVerificationConfigViaAPI(t, router, owner.Token, database.ID,+ verification_config.SaveBackupVerificationConfigDTO{+ IsScheduledVerificationEnabled: false,+ ScheduleType: verification_config.VerificationScheduleInterval,+ VerificationInterval: intervals.Interval{Type: intervals.IntervalHourly},+ })++ backup := backuping_logical.SeedTestBackup(t, database.ID, testStorage.ID, 100)+ manualVerification := EnqueueManualVerificationViaAPI(t, router, owner.Token, backup.ID)++ require.NoError(+ t,+ GetVerificationScheduler().cancelAutomaticVerificationsForDisabledSchedules(t.Context(), logger.GetLogger()),+ )++ verificationAfterSweep := GetVerificationByIDViaAPI(t, router, owner.Token, manualVerification.ID)+ assert.Equal(t, VerificationStatusPending, verificationAfterSweep.Status)+ assert.Nil(t, verificationAfterSweep.FailMessage)+}++func Test_CancelAutomaticVerificationsForDisabledSchedules_WhenManualVerificationIsRunning_LeavesItRunning(+ t *testing.T,+) {+ router := createTestRouter()+ owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleAdmin)+ workspace := workspaces_testing.CreateTestWorkspace(t.Context(), "ws "+uuid.New().String(), owner, router)+ defer workspaces_testing.RemoveTestWorkspace(t.Context(), workspace, router)++ testStorage := storages.CreateTestStorage(workspace.ID)+ defer storages.RemoveTestStorage(t.Context(), testStorage.ID)++ notifier := notifiers.CreateTestNotifier(workspace.ID)+ defer notifiers.RemoveTestNotifier(notifier)++ database := databases.CreateTestDatabase(workspace.ID, testStorage, notifier)+ defer databases.RemoveTestDatabase(t.Context(), database)++ verification_config.SaveVerificationConfigViaAPI(t, router, owner.Token, database.ID,+ verification_config.SaveBackupVerificationConfigDTO{+ IsScheduledVerificationEnabled: false,+ ScheduleType: verification_config.VerificationScheduleInterval,+ VerificationInterval: intervals.Interval{Type: intervals.IntervalHourly},+ })++ backup := backuping_logical.SeedTestBackup(t, database.ID, testStorage.ID, 100)+ manualVerification := EnqueueManualVerificationViaAPI(t, router, owner.Token, backup.ID)++ agent := verification_agents.CreateTestVerificationAgent(+ t, router, owner.Token, "manual-running-"+uuid.New().String(),+ )+ defer verification_agents.RemoveTestVerificationAgent(t, router, owner.Token, agent.Agent.ID)++ assignment := ClaimVerificationViaAPI(+ t, router, agent.Agent.ID, agent.Token,+ AgentCapacity{MaxCPU: 4, MaxRAMMb: 4096, MaxDiskGb: 50, MaxConcurrentJobs: 1},+ )+ require.Equal(t, manualVerification.ID, assignment.VerificationID)++ require.NoError(+ t,+ GetVerificationScheduler().cancelAutomaticVerificationsForDisabledSchedules(t.Context(), logger.GetLogger()),+ )++ verificationAfterSweep := GetVerificationByIDViaAPI(t, router, owner.Token, manualVerification.ID)+ assert.Equal(t, VerificationStatusRunning, verificationAfterSweep.Status)+ assert.Nil(t, verificationAfterSweep.FailMessage)+}++func Test_CancelAutomaticVerificationsForDisabledSchedules_WhenAutomaticVerificationExists_CancelsIt(+ t *testing.T,+) {+ automaticVerificationCases := []struct {+ scenario string+ trigger VerificationTrigger+ isRunning bool+ }{+ {"SCHEDULED PENDING", VerificationTriggerScheduled, false},+ {"SCHEDULED RUNNING", VerificationTriggerScheduled, true},+ {"AFTER_BACKUP PENDING", VerificationTriggerAfterBackup, false},+ {"AFTER_BACKUP RUNNING", VerificationTriggerAfterBackup, true},+ }++ for _, verificationCase := range automaticVerificationCases {+ t.Run(verificationCase.scenario, func(t *testing.T) {+ router := createTestRouter()+ owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleAdmin)+ workspace := workspaces_testing.CreateTestWorkspace(+ t.Context(), "ws "+uuid.New().String(), owner, router,+ )+ defer workspaces_testing.RemoveTestWorkspace(t.Context(), workspace, router)++ testStorage := storages.CreateTestStorage(workspace.ID)+ defer storages.RemoveTestStorage(t.Context(), testStorage.ID)++ notifier := notifiers.CreateTestNotifier(workspace.ID)+ defer notifiers.RemoveTestNotifier(notifier)++ database := databases.CreateTestDatabase(workspace.ID, testStorage, notifier)+ defer databases.RemoveTestDatabase(t.Context(), database)++ backup := backuping_logical.SeedTestBackup(t, database.ID, testStorage.ID, 100)++ switch verificationCase.trigger {+ case VerificationTriggerScheduled:+ enableHourlyVerificationViaAPI(t, router, owner.Token, database.ID)+ require.NoError(t, GetVerificationScheduler().createScheduledRuns(t.Context(), logger.GetLogger()))+ case VerificationTriggerAfterBackup:+ enableAfterBackupVerificationViaAPI(t, router, owner.Token, database.ID)+ GetVerificationService().OnBackupCompleted(backup.ID)+ default:+ t.Fatalf("unsupported automatic verification trigger %q", verificationCase.trigger)+ }++ verifications := ListVerificationsByDatabaseViaAPI(t, router, owner.Token, database.ID)+ require.Len(t, verifications, 1)+ automaticVerification := verifications[0]+ require.Equal(t, verificationCase.trigger, automaticVerification.Trigger)++ if verificationCase.isRunning {+ agent := verification_agents.CreateTestVerificationAgent(+ t, router, owner.Token, "automatic-running-"+uuid.New().String(),+ )+ defer verification_agents.RemoveTestVerificationAgent(t, router, owner.Token, agent.Agent.ID)++ assignment := ClaimVerificationViaAPI(+ t, router, agent.Agent.ID, agent.Token,+ AgentCapacity{MaxCPU: 4, MaxRAMMb: 4096, MaxDiskGb: 50, MaxConcurrentJobs: 1},+ )+ require.Equal(t, automaticVerification.ID, assignment.VerificationID)+ }++ disabledConfig := verification_config.SaveBackupVerificationConfigDTO{+ IsScheduledVerificationEnabled: false,+ ScheduleType: verification_config.VerificationScheduleAfterBackup,+ }+ if verificationCase.trigger == VerificationTriggerScheduled {+ disabledConfig.ScheduleType = verification_config.VerificationScheduleInterval+ disabledConfig.VerificationInterval = intervals.Interval{Type: intervals.IntervalHourly}+ }++ verification_config.SaveVerificationConfigViaAPI(+ t, router, owner.Token, database.ID, disabledConfig,+ )++ require.NoError(+ t,+ GetVerificationScheduler().cancelAutomaticVerificationsForDisabledSchedules(+ t.Context(), logger.GetLogger(),+ ),+ )++ verificationAfterSweep := GetVerificationByIDViaAPI(+ t, router, owner.Token, automaticVerification.ID,+ )+ assert.Equal(t, VerificationStatusCanceled, verificationAfterSweep.Status)+ require.NotNil(t, verificationAfterSweep.FailMessage)+ assert.Contains(t, *verificationAfterSweep.FailMessage, "schedule was disabled")+ })+ }+}++func Test_CancelAutomaticVerificationsForDisabledSchedules_WhenManualAndAutomaticVerificationsCoexist_CancelsOnlyAutomatic(+ t *testing.T,+) {+ router := createTestRouter()+ owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleAdmin)+ workspace := workspaces_testing.CreateTestWorkspace(t.Context(), "ws "+uuid.New().String(), owner, router)+ defer workspaces_testing.RemoveTestWorkspace(t.Context(), workspace, router)++ testStorage := storages.CreateTestStorage(workspace.ID)+ defer storages.RemoveTestStorage(t.Context(), testStorage.ID)++ notifier := notifiers.CreateTestNotifier(workspace.ID)+ defer notifiers.RemoveTestNotifier(notifier)++ database := databases.CreateTestDatabase(workspace.ID, testStorage, notifier)+ defer databases.RemoveTestDatabase(t.Context(), database)++ backup := backuping_logical.SeedTestBackup(t, database.ID, testStorage.ID, 100)+ manualVerification := EnqueueManualVerificationViaAPI(t, router, owner.Token, backup.ID)++ enableHourlyVerificationViaAPI(t, router, owner.Token, database.ID)+ require.NoError(t, GetVerificationScheduler().createScheduledRuns(t.Context(), logger.GetLogger()))++ verifications := ListVerificationsByDatabaseViaAPI(t, router, owner.Token, database.ID)+ require.Len(t, verifications, 2)++ var scheduledVerification *RestoreVerification+ for _, verification := range verifications {+ if verification.Trigger == VerificationTriggerScheduled {+ scheduledVerification = verification+ break+ }+ }+ require.NotNil(t, scheduledVerification)++ verification_config.SaveVerificationConfigViaAPI(t, router, owner.Token, database.ID,+ verification_config.SaveBackupVerificationConfigDTO{+ IsScheduledVerificationEnabled: false,+ ScheduleType: verification_config.VerificationScheduleInterval,+ VerificationInterval: intervals.Interval{Type: intervals.IntervalHourly},+ })++ require.NoError(+ t,+ GetVerificationScheduler().cancelAutomaticVerificationsForDisabledSchedules(t.Context(), logger.GetLogger()),+ )++ manualVerificationAfterSweep := GetVerificationByIDViaAPI(+ t, router, owner.Token, manualVerification.ID,+ )+ assert.Equal(t, VerificationStatusPending, manualVerificationAfterSweep.Status)+ assert.Nil(t, manualVerificationAfterSweep.FailMessage)++ scheduledVerificationAfterSweep := GetVerificationByIDViaAPI(+ t, router, owner.Token, scheduledVerification.ID,+ )+ assert.Equal(t, VerificationStatusCanceled, scheduledVerificationAfterSweep.Status)+ require.NotNil(t, scheduledVerificationAfterSweep.FailMessage)+ assert.Contains(t, *scheduledVerificationAfterSweep.FailMessage, "schedule was disabled")+}+func Test_CreateScheduledRuns_AfterUserCancel_DoesNotImmediatelyRecreate(t *testing.T) {router := createTestRouter()owner := users_testing.CreateTestUser(t.Context(), users_enums.UserRoleAdmin)@@ -455,7 +696,7 @@ func Test_CreateScheduledRuns_AfterUserCancel_DoesNotRequeueOrRestart(t *testingrequire.NoError(t, scheduler.createScheduledRuns(t.Context(), logger.GetLogger()))require.NoError(t, scheduler.reapStaleRuns(t.Context(), logger.GetLogger()))- require.NoError(t, scheduler.sweepCanceledByDisabledConfig(t.Context(), logger.GetLogger()))+ require.NoError(t, scheduler.cancelAutomaticVerificationsForDisabledSchedules(t.Context(), logger.GetLogger()))final := GetVerificationByIDViaAPI(t, router, owner.Token, scheduledRowID)assert.Equal(t, VerificationStatusCanceled, final.Status)diff --git a/openspec/changes/allow-manual-verification-with-disabled-schedule/.openspec.yaml b/openspec/changes/allow-manual-verification-with-disabled-schedule/.openspec.yamlnew file mode 100644index 00000000..1a62d62b--- /dev/null+++ b/openspec/changes/allow-manual-verification-with-disabled-schedule/.openspec.yaml@@ -0,0 +1,2 @@+schema: spec-driven+created: 2026-09-06diff --git a/openspec/changes/allow-manual-verification-with-disabled-schedule/design.md b/openspec/changes/allow-manual-verification-with-disabled-schedule/design.mdnew file mode 100644index 00000000..23b34e33--- /dev/null+++ b/openspec/changes/allow-manual-verification-with-disabled-schedule/design.md@@ -0,0 +1,64 @@+## Context++`EnqueueManualVerification` creates a `MANUAL` verification in `PENDING` after the existing authorization and backup checks (`backend/internal/features/verification/runs/service.go:39-106`). The verification scheduler calls `sweepCanceledByDisabledConfig` on every tick (`backend/internal/features/verification/runs/scheduler.go:42-68`). That sweep cancels every row returned by `FindNonTerminalForDisabledConfigs` (`backend/internal/features/verification/runs/scheduler.go:240-263`).++`FindNonTerminalForDisabledConfigs` currently filters by disabled configuration and non-terminal status, but not by verification trigger (`backend/internal/features/verification/runs/repository.go:276-290`). The model distinguishes `MANUAL`, `SCHEDULED`, and `AFTER_BACKUP` triggers (`backend/internal/features/verification/runs/enums.go:13-19`). This change is constrained by `AGENTS.md` and `backend/AGENTS.md`, including their naming, controller-backed testing, formatting, linting, and mandatory review rules.++## Goals / Non-Goals++**Goals:**++- Make the cancellation sweep select only automatic verification runs.+- Encode the selection and cancellation responsibilities in their function names.+- Preserve manual runs in both non-terminal states without changing their enqueue or execution path.+- Preserve cancellation of time-based and after-backup automatic runs.++**Non-Goals:**++- Redesign verification scheduling or cancellation.+- Change authorization, retries, notifications, agent assignment, or stale-run handling.+- Add a database migration, API field, configuration option, or frontend control.++## Decisions++### Select automatic triggers in the repository query++`FindNonTerminalForDisabledConfigs` will be renamed to `GetNonTerminalAutomaticVerificationsForDisabledSchedules` and include an explicit trigger predicate for `SCHEDULED` and `AFTER_BACKUP`. The database will return only rows that satisfy the automatic, non-terminal, and disabled-schedule conditions. The old name will be removed without an alias.++Rejected alternatives:++- Fetch all non-terminal rows and skip `MANUAL` inside the scheduler. This reads unrelated rows and splits the selection rule between the repository and scheduler.+- Select every trigger except `MANUAL`. A future user-initiated trigger would then be canceled by default. An allowlist makes new trigger semantics an explicit decision.+- Name the method `GetAutomaticVerificationsToCancelForDisabledSchedules`. A repository query should describe the rows it returns rather than decide what its caller will do with them.+- Keep the `Find` prefix. The repository method retrieves a defined collection, so the project `Get` convention applies.+- Add `IsAutomatic()` to `VerificationTrigger`. The SQL query still needs the explicit trigger values, so a separate predicate would duplicate the classification for this path instead of replacing it.+- Add a separate configuration flag for manual verification. The requested behavior is that manual runs are independent of automatic scheduling, so another setting would create a second source of truth.++### Name the scheduler action by the transition it performs++`sweepCanceledByDisabledConfig` will be renamed to `cancelAutomaticVerificationsForDisabledSchedules`. The action will continue to mark the selected rows `CANCELED` with the existing disabled-schedule reason. The repository query will select both automatic trigger types in one pass. The old name will be removed without an alias.++Rejected alternatives:++- Keep `sweepCanceledByDisabledConfig`. That name suggests it processes rows that are already canceled, and `Config` does not identify which setting controls the transition.+- Add one sweep for time-based runs and another for after-backup runs. Both have the same disabled-configuration rule and terminal transition, so separate paths would duplicate behavior and tests.+- Stop canceling existing automatic runs and only prevent new ones. That would change established behavior beyond the requested manual-verification exception.++### Exercise the real API setup and a single scheduler sweep in tests++Tests will create the database configuration and manual verification through existing API-backed helpers. Time-based runs will come from the scheduler path, after-backup runs from backup-completion handling, and running states from the agent claim path. Each test will invoke one cancellation sweep directly and inspect the API-visible result. Coverage will include pending and running manual runs plus the two automatic trigger types.++Rejected alternatives:++- Wait for the scheduler ticker. This would make the tests slower and dependent on timing while exercising the same sweep.+- Test only the SQL query in isolation. The backend guidelines prefer controller-backed coverage, and the observable status after a sweep is the relevant contract.++## Risks / Trade-offs++- A future automatic trigger could be omitted from the allowlist. Its introduction must update the cancellation selection and add a disabled-schedule regression case.+- A focused sweep test does not test ticker timing. Existing scheduler wiring already calls the sweep, while the new tests cover the incorrect selection that caused the defect.+- Filtering in the query ties cancellation semantics to persisted trigger values. Those values already define the distinction between manual and automatic runs, so no new coupling is introduced.++## Migration Plan++No schema or data migration is needed. Deploy the backend change normally. Rollback consists of reverting the query change; existing verification rows need no conversion.diff --git a/openspec/changes/allow-manual-verification-with-disabled-schedule/proposal.md b/openspec/changes/allow-manual-verification-with-disabled-schedule/proposal.mdnew file mode 100644index 00000000..22e2262e--- /dev/null+++ b/openspec/changes/allow-manual-verification-with-disabled-schedule/proposal.md@@ -0,0 +1,33 @@+## Why++Manual verification is an on-demand action and must not depend on whether automatic verification is enabled. The current scheduler cancellation sweep treats every non-terminal verification for a disabled configuration as automatic, so it cancels manual runs shortly after they are enqueued.++## What Changes++- Keep manual verifications in `PENDING` or `RUNNING` when automatic verification is disabled or becomes disabled.+- Continue canceling non-terminal `SCHEDULED` and `AFTER_BACKUP` verifications when automatic verification is disabled.+- Express the cancellation boundary in the data selection itself: only automatic triggers enter the disabled-schedule cancellation set.+- Rename the repository selection and scheduler action so their names state the automatic-verification rule they enforce.+- Add regression coverage for manual and automatic verification behavior during the cancellation sweep.+- This change is not breaking. It does not remove or alter any API, configuration field, or stored data shape.++## Capabilities++### New Capabilities++- `backup-verification`: Defines how manual and automatic backup verifications behave when scheduled verification is disabled.++### Modified Capabilities++None.++## Impact++The implementation is limited to the backend verification scheduler, its data selection, and adjacent tests. It is governed by `AGENTS.md` and `backend/AGENTS.md`. No frontend, verification agent, database migration, API contract, external dependency, or deployment change is expected.++Out of scope:++- Changing who may enqueue or cancel a manual verification.+- Changing verification retries, agent assignment, or stale-run handling.+- Changing notification behavior or user-facing copy.+- Changing how automatic verification runs are created.diff --git a/openspec/changes/allow-manual-verification-with-disabled-schedule/specs/backup-verification/spec.md b/openspec/changes/allow-manual-verification-with-disabled-schedule/specs/backup-verification/spec.mdnew file mode 100644index 00000000..c7aa54a7--- /dev/null+++ b/openspec/changes/allow-manual-verification-with-disabled-schedule/specs/backup-verification/spec.md@@ -0,0 +1,43 @@+## Purpose++Defines the relationship between on-demand backup verification and the configuration that controls automatic verification runs.++## ADDED Requirements++### Requirement: Manual verification is independent of automatic scheduling++The system SHALL allow an authorized user to enqueue and run a manual backup verification while automatic verification is disabled.++#### Scenario: Enqueue manual verification while automatic verification is disabled++- **WHEN** an authorized user requests manual verification of an eligible backup whose automatic verification is disabled and no other manual verification for that database is pending or running+- **THEN** the system accepts the request and keeps the manual verification pending for an agent++#### Scenario: Disable automatic verification while a manual verification is pending++- **WHEN** automatic verification is disabled for a database with a pending manual verification+- **THEN** the manual verification remains pending++#### Scenario: Disable automatic verification while a manual verification is running++- **WHEN** automatic verification is disabled for a database with a running manual verification+- **THEN** the manual verification remains running and can reach its normal terminal status++### Requirement: Disabling automatic verification cancels only automatic runs++The system SHALL cancel non-terminal automatic verification runs when automatic verification is disabled without canceling manual verification runs for the same database.++#### Scenario: Disable automatic verification with a time-based run++- **WHEN** automatic verification is disabled for a database with a pending or running time-based verification+- **THEN** the system cancels that automatic verification++#### Scenario: Disable automatic verification with an after-backup run++- **WHEN** automatic verification is disabled for a database with a pending or running after-backup verification+- **THEN** the system cancels that automatic verification++#### Scenario: Manual and automatic runs coexist when scheduling is disabled++- **WHEN** automatic verification is disabled for a database with both manual and automatic non-terminal verifications+- **THEN** the system cancels the automatic verifications and leaves the manual verifications unchangeddiff --git a/openspec/changes/allow-manual-verification-with-disabled-schedule/tasks.md b/openspec/changes/allow-manual-verification-with-disabled-schedule/tasks.mdnew file mode 100644index 00000000..eb0d2c03--- /dev/null+++ b/openspec/changes/allow-manual-verification-with-disabled-schedule/tasks.md@@ -0,0 +1,15 @@+## 1. Regression coverage++- [x] 1.1 Keep the pending manual-verification reproduction in `scheduler_test.go`, add a running manual-verification case, and confirm with `cd backend && go test ./internal/features/verification/runs -run 'Test_SweepCanceledByDisabledConfig_WhenManualVerification' -count=1` that the cases fail before the query fix.+- [x] 1.2 Cover disabled-schedule cancellation for `SCHEDULED` and `AFTER_BACKUP` verifications in both non-terminal states, including coexistence with a manual verification, and verify the API-visible statuses match the `backup-verification` scenarios.++## 2. Cancellation selection++- [x] 2.1 Rename `FindNonTerminalForDisabledConfigs` to `GetNonTerminalAutomaticVerificationsForDisabledSchedules` without an alias and restrict it to the explicit `SCHEDULED` and `AFTER_BACKUP` trigger allowlist.+- [x] 2.2 Rename `sweepCanceledByDisabledConfig` to `cancelAutomaticVerificationsForDisabledSchedules` without an alias, update its callers and tests, and verify the focused scheduler tests pass with neither old name left in the backend.++## 3. Final verification++- [x] 3.1 Run `cd backend && go test ./internal/features/verification/runs -count=1` and resolve every unexpected failure.+- [x] 3.2 Run `cd backend && make lint` and resolve every issue.+- [x] 3.3 Run the mandatory reviewer against the implementation diff, resolve every `CHANGES REQUIRED` finding, and leave the working tree ready to commit with a `PASS` verdict.