Skip to content

[Refactor] Add a shared validated Python bundle reader #974

Description

@chaofengw-nv

Parent

Inspired by #963: repeated format parsing indicates that a shared format interface is missing.

What to build

Add a read-only Python bundle reader alongside the existing bundle writer. The reader should validate the bundle magic and header length, decode the JSON header once, validate section ranges against file size, and expose narrow operations for reading the header and named sections.

Shared CLI and tooling code currently reimplements the binary bundle header in dozens of files and parse sites. Implementations disagree on magic checks, truncation limits, maximum header size, and section bounds. Model-owned tests may keep local artifact code where the repository's isolation policy explicitly requires it; migrate shared tools first.

Acceptance criteria

  • A shared reader exposes validated header metadata and named-section access without requiring callers to understand binary offsets.
  • Magic, truncated length/header, invalid JSON, excessive header size, duplicate/missing sections, overflow, overlap, and out-of-file ranges are rejected consistently.
  • Shared build, validation, comparison, and inspection tools use the reader instead of unpacking bundle headers locally.
  • Representative local readers are deleted, and a repository scan/test prevents new shared parse sites from bypassing the reader.
  • Model-local exceptions remain consistent with the documented model-plugin isolation policy.

Blocked by

None - can start immediately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions