Skip to content

Upload verification: manifest checksums + row counts, resumable inserts, and a content-addressed insert ledger #93

Backlog

Description

@azimov

Upload verification: manifest checksums + row counts, resumable inserts, and a content-addressed insert ledger

Tracking issue for the next round of review following PR #91 (yaml-schema-config).
Part of the RMM 1.0.0 release. See the full working plan in PLAN.md.

Summary

Introduce a new upload path in ResultModelManager that validates every upload
against a manifest (per-file sha256 checksum and row count), records
each insert in a package-owned upload ledger table (uploading / completed
/ failed), never re-inserts an identical file, and makes resuming
interrupted inserts fast. Errors are file-scoped, never package-scoped.

Used alongside the existing ResultExportManager (which already validates
primary keys at export), this catches insert errors that would otherwise fail
silently.

Status / decisions already locked

  1. Row-count source of truth: re-scan the final written CSV (callbacks can
    drop rows unpredictably).
  2. Dedupe key: sha256 checksum (+ table_name, database_id).
  3. Forced inserts supported per file (force = TRUE + invalidateChecksum()),
    designed so AI agents can remediate partial/failed inserts.
  4. Ledger table is RMM-owned, created via the existing migration pattern.
  5. Interface: R6 (ResultsUploadManager + createResultsUploadManager()).
  6. Row-count algorithm: readr::read_csv_chunked streaming count (data rows,
    excl. header) at manifest-write time.
  7. Row-count validation is delta-based (table_count(after) − table_count(before)),
    because tables accumulate rows from multiple files over time.

Proposed pieces

  • Manifest v2 (ResultExportManager): add rowCount per file, bump
    manifestVersion. Also fix the pre-existing digest-missing-from-DESCRIPTION
    issue.
  • Insert ledger {tablePrefix}upload_ledger:
    (database_id, table_name, checksum) PK, plus row_count_expected,
    row_count_actual, status, error_message, started_at, uploaded_at.
    Created via ensureLedgerTable() + RMM-owned example migration
    Migration_3-CreateUploadLedger.sql.
  • ResultsUploadManager (R6): skip-if-identical, resume-retry, file-scoped
    failure isolation (§6b in PLAN.md), forceInsert() / invalidateChecksum().
  • Standard interface: factory + vignette UsingTheUploadLedger.Rmd.
  • Adoption PRs: SelfControlledCohort + CohortDiagnostics as reference
    implementations (CSV → YAML first, preserving is_vocabulary_table).

Questions for reviewers

  1. Hash dependency — add digest to Imports, or switch to openssl::sha256
    to avoid a new dependency?
  2. Delta counting and concurrency — is after − before (accepted as racy
    under concurrent inserts, mitigated by database_id scoping) acceptable, or
    should we require PK-based counting?
  3. Ledger lifecycle — auto-create at runtime (ensureLedgerTable()) vs.
    require the migration to have run first?
  4. Error propagation contract — should upload() return a per-file report
    (default) and only throw on opt-in (stopOnFirstError), or should it always
    throw an aggregate error after isolation is recorded?

Release

Targets RMM 1.0.0 alongside the SCCS / CohortDiagnostics adoption PRs.

Activity

  1. added
    enhancement
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions