Skip to content

migration: verify proves the store matches its own manifest, not the source, so a short source read verifies clean #1306

Done

Description

@chappie-daemon

Found by job 045's security lens (row 5 of #868) at 8488bf13.

The migration's verify pass proves the store matches the manifest, not the source.

The manifest's rows and checksum are folded from the same batches the store receives (crates/nostream-cli/src/commands/migrate.rs:236-258), and verify_with reads only the target (migrate.rs:294-350). A store truncated after the copy fails (row count or checksum), and a store replaced beside the manifest is refused up front (held.is_empty() probe at migrate.rs:183-201).

What no check covers is a source read that ends a table early: the table is marked complete on count < batch_size (the trait's end marker, crates/nostream-storage/src/migration.rs:228), so a short page is indistinguishable from end-of-table — and the manifest records the short total as the complete one. ADR 0013 D4 says "any added, removed or altered row moves it" and calls the check a completeness proof; that is true of the target against the manifest it wrote, not of the store against the source.

Acceptance

  • Either the verify pass reads both sides (source and target) and compares them, or the manifest records the source's own count per table and the verification names which claim it makes.
  • ADR 0013 D4 states what the checksum proves and what it does not.
  • A case where the source ends a page early (a short read) is detected, or the gap is recorded as accepted risk with the reason.

Record: docs/rewrite/reviews/2026-11-30-relay-storage.md — finding F18, lens security, tree 8488bf13. Site: crates/nostream-cli/src/commands/migrate.rs:254.

Activity

  1. added
    bug
    rewrite
    rust
    factory
    on Nov 30, 2026
  2. chappie-daemon commented on Dec 4, 2026

    @chappie-daemon
    CollaboratorAuthor

    Factory job started (row from the 2026-12-04 plan): recon in progress, branch factory/047-*' from rewrite/mainat7019957`.

  3. chappie-daemon commented on Dec 4, 2026

    @chappie-daemon
    CollaboratorAuthor

    Closed by 0238ed6ba0419a331a6d4784b66251e98e4aca51 (#1387).

    Verify now proves the copy read the source, not only that the store matches the manifest it wrote: MigrationSource::count_rows takes one count(*) per table on the master pool the copy already holds, the manifest records source_rows per table (format: 2; a format-1 manifest is refused with … this tool reads and writes 2; restart on a fresh --target), and verify_with asserts target rows == manifest rows == source count, refusing a short read with [<table>] source {n} rows, target {m} rows.

    Demonstrated before the fix: a 3-row source whose first page answers 1 gave copy exit 0, {"complete":true,"rows":1}, verify exit 0.

    What it does not prove, now stated in ADR 0013 D4 and the runbook: the count is cardinality, not content — a source that mutates between the count and its pages, leaving the total unchanged, still passes; that is why D9 requires the source's relay stopped during the copy.

    Evidence: the short_page oracle (absent at base, red with the old shape restored), old_manifest and failing_source_count cases, the accepted fixtures migrated to format 2, nine command criteria inverted and restored, migrate_cli 50 passing. The .changeset and the docs contract went through two review rounds; the irreversibility gate's three findings were the word "migration" in the tool's own paths and a format-constant flip with each assertion mirrored, verified against the diff and discharged by the operator.

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

Metadata

Metadata

Labels

bugfactoryrewriterust

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions