Skip to content

[03/03] service-backup: stage and restore BackupSets idempotently with service-owned validation - #64

Open
chrischeng-c4 wants to merge 1 commit into
mainfrom
issue/18
Open

chrischeng-c4 wants to merge 1 commit into
mainfrom
issue/18

Conversation

@chrischeng-c4

Copy link
Copy Markdown
Contributor

Closes #18

Summary of Changes

Implement the pure domain logic for BackupSet restore progress tracking as scoped in #18:

  • Domain Model (RestoreLedger): Added RestoreLedger, ArtifactStage (Pending, Verified, Applied), RestorePhase (Staging, Applying, Committed), ResumePoint (Fresh, Continue, AlreadyCommitted), and ArtifactEntry under crates/service-backup/src/domain/restore_ledger.rs.
  • Domain Errors (RestoreLedgerError): Added typed error enum RestoreLedgerError under crates/service-backup/src/domain/restore_ledger_error.rs covering invalid input, illegal artifact and phase transitions, unverified/unapplied sets, ConflictingSet conflicts carrying both IDs, and inconsistent deserialized phases.
  • Exports: Declared and re-exported new types in crates/service-backup/src/domain.rs and crates/service-backup/src/lib.rs.
  • Transitions & Serialization:
    • RestoreLedger::begin validates set ID, manifest digest format, and artifact bounds.
    • Legal transition methods mark_verified, begin_apply, mark_applied, and commit leave state unchanged on error and allow idempotent repeats.
    • resume and resume_or_begin identify matching vs conflicting sets.
    • Compact JSON serialization with "version": 1, 1 MiB limit, camelCase fields, and deny_unknown_fields.
  • Test Suite:
    • Added new integration-test unit module crates/service-backup/tests/it/restore_ledger.rs registered in tests/it/main.rs.
    • Comprehensive coverage for: valid full path, all invalid begin inputs, illegal transitions, idempotent repeats, conflicting set / replaced manifest detection, already committed replay, JSON round-trips, rejected JSON documents, and crash-prefix model test verifying each artifact is applied exactly once.
    • Fixed needless .as_bytes().len() call in tests/it/projected_admin_transport.rs to satisfy clippy warnings.

Local Test Results

  • cargo fmt -p service-backup -- --check: passed
  • cargo clippy --locked -p service-backup --all-features --all-targets --no-deps -- -D warnings: passed (0 warnings)
  • cargo check --locked -p service-backup --all-features --all-targets: passed
  • cargo test --locked -p service-backup --test it restore_ledger: 9 passed, 0 failed, 0 ignored
  • cargo test --locked -p service-backup --test it: 25 passed, 0 failed

Cloud CI Status (MR Gates)

  • crate-gates (cargo test --locked -p service-backup --features http-client): PENDING cloud CI runner execution on PR head
  • Integration/HTTP network tests: DEFERRED to authorized cloud CI per user test policy
  • Release qualification acceptance matrix: NOT RUN (release operations not authorized)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[03/03] service-backup: stage and restore BackupSets idempotently with service-owned validation

1 participant