Implement approved-file import and integrity verification #11

Closed
opened 2026-07-24 19:38:14 -04:00 by JackFrostbyte · 1 comment

Goal

    Implement a deterministic command or library operation that locates an approved input file and verifies its repository boundary, byte size, and SHA-256 integrity.

    ## Why

    Arkive must prove that a metadata record refers to the exact approved file before any extraction or transformation begins.

    ## Scope

    - Locate an approved source file through metadata and the documented repository layout.
  • Resolve and validate paths without following inputs outside approved repository boundaries.

  • Reject absolute paths, traversal attempts, broken links, missing files, and unexpected file types where appropriate.

  • Calculate file byte size and SHA-256 deterministically.

  • Verify existing document integrity metadata or produce a deterministic proposed metadata result as defined by the processing contract.

  • Return clear machine-readable or structured errors for missing and mismatched files.

  • Avoid modifying committed source files.

  • Add tests using the approved pilot corpus and focused negative fixtures.

      ## Out of scope
    
      - Text or PDF extraction.
    
  • Text normalization or chunking.

  • Automatic network downloads.

  • License review automation.

  • Index generation.

      ## Dependencies
    
      - #7 — Establish the Python project and development-tooling baseline
    
  • #9 — Align metadata schemas and validation with the intake and processing contracts

  • #10 — Select and approve the five-document pilot corpus

      ## Acceptance criteria
    
      - Approved pilot files are located and verified deterministically.
    
  • A byte-size mismatch and SHA-256 mismatch are both detected.

  • Missing files and unsafe paths fail clearly.

  • Paths outside the approved repository boundary cannot be imported.

  • Repeated verification of unchanged files produces identical results.

  • No input file is modified.

  • Positive and negative tests pass.

      ## Validation
    
      - Run the complete unit-test suite.
    
  • Exercise all five approved files.

  • Exercise fixtures for missing files, checksum mismatches, size mismatches, absolute paths, traversal, and out-of-bound paths.

  • Repeat a successful verification and compare results.

      ## Suggested branch
    
      `feature/issue-11-file-integrity-import`
    
      <!-- arkive-planning-automation:2026-07-24-v3:M1-06 -->
    
## Goal Implement a deterministic command or library operation that locates an approved input file and verifies its repository boundary, byte size, and SHA-256 integrity. ## Why Arkive must prove that a metadata record refers to the exact approved file before any extraction or transformation begins. ## Scope - Locate an approved source file through metadata and the documented repository layout. - Resolve and validate paths without following inputs outside approved repository boundaries. - Reject absolute paths, traversal attempts, broken links, missing files, and unexpected file types where appropriate. - Calculate file byte size and SHA-256 deterministically. - Verify existing document integrity metadata or produce a deterministic proposed metadata result as defined by the processing contract. - Return clear machine-readable or structured errors for missing and mismatched files. - Avoid modifying committed source files. - Add tests using the approved pilot corpus and focused negative fixtures. ## Out of scope - Text or PDF extraction. - Text normalization or chunking. - Automatic network downloads. - License review automation. - Index generation. ## Dependencies - #7 — Establish the Python project and development-tooling baseline - #9 — Align metadata schemas and validation with the intake and processing contracts - #10 — Select and approve the five-document pilot corpus ## Acceptance criteria - Approved pilot files are located and verified deterministically. - A byte-size mismatch and SHA-256 mismatch are both detected. - Missing files and unsafe paths fail clearly. - Paths outside the approved repository boundary cannot be imported. - Repeated verification of unchanged files produces identical results. - No input file is modified. - Positive and negative tests pass. ## Validation - Run the complete unit-test suite. - Exercise all five approved files. - Exercise fixtures for missing files, checksum mismatches, size mismatches, absolute paths, traversal, and out-of-bound paths. - Repeat a successful verification and compare results. ## Suggested branch `feature/issue-11-file-integrity-import` <!-- arkive-planning-automation:2026-07-24-v3:M1-06 -->
Author
Owner

Issue completed by merged PR #55.

Implemented:

  • deterministic lookup of approved originals by document_id;
  • metadata-derived path resolution using the documented source layout;
  • strict confinement to the authoritative source directory;
  • rejection of absolute paths, traversal, cross-source paths, unapproved repository paths, missing files, broken links, all symbolic links, and non-regular files;
  • approved-source, original-role, source-ID, filename, media-type, extension, byte-size, and SHA-256 validation;
  • deterministic binary byte counting and SHA-256 calculation;
  • distinct byte-size and SHA-256 mismatch failures;
  • detection of files changing during verification;
  • immutable successful results;
  • stable machine-readable failure codes and structured details.

Verified:

  • all five approved pilot originals pass verification;
  • repeated verification produces identical results;
  • source-original contents, size, mode, and modification time remain unchanged;
  • focused positive and negative fixtures pass;
  • metadata validation passes for 6 sources, 6 documents, and 2 chunks across 13 record files;
  • all 55 unit tests pass;
  • Ruff linting and formatting checks pass;
  • python -m pip check reports no broken requirements.

Scope remained limited to the approved-file integrity operation and its tests. No schemas, policies, source records, committed originals, dependencies, extraction behavior, qpdf, or Poppler tooling were changed.

Issue #11 is complete. Issues #12 and #16 may now proceed using the verified approved-file boundary.

Issue completed by merged PR #55. Implemented: * deterministic lookup of approved originals by `document_id`; * metadata-derived path resolution using the documented source layout; * strict confinement to the authoritative source directory; * rejection of absolute paths, traversal, cross-source paths, unapproved repository paths, missing files, broken links, all symbolic links, and non-regular files; * approved-source, original-role, source-ID, filename, media-type, extension, byte-size, and SHA-256 validation; * deterministic binary byte counting and SHA-256 calculation; * distinct byte-size and SHA-256 mismatch failures; * detection of files changing during verification; * immutable successful results; * stable machine-readable failure codes and structured details. Verified: * all five approved pilot originals pass verification; * repeated verification produces identical results; * source-original contents, size, mode, and modification time remain unchanged; * focused positive and negative fixtures pass; * metadata validation passes for 6 sources, 6 documents, and 2 chunks across 13 record files; * all 55 unit tests pass; * Ruff linting and formatting checks pass; * `python -m pip check` reports no broken requirements. Scope remained limited to the approved-file integrity operation and its tests. No schemas, policies, source records, committed originals, dependencies, extraction behavior, qpdf, or Poppler tooling were changed. Issue #11 is complete. Issues #12 and #16 may now proceed using the verified approved-file boundary.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Arkive/arkive#11
No description provided.