Skip to content

Type-design: WireField layout-version prefixes (Flat/V10/Fdi) #145

@r6e

Description

@r6e

Source

PR #144 R1 type-design review (MEDIUM finding, deferred to follow-up).

Problem

PR #144 introduced WireField (16 variants) and AllocationContext (11 variants) typed enums. AllocationContext applied a clean prefix discipline:

  • Inline* / Encoded* for the two compression-block read paths
  • Flat* for v3-v9 flat-layout
  • V10* for v10+-specific sites
  • Bytes suffix for raw byte buffers

WireField did NOT apply the same discipline. 4 variants are layout-version-specific but lack the prefix:

  • EntryCount is flat-index only (v3-v9). Should be FlatEntryCount.
  • NonEncodedCount is v10+ main-index only. Should be V10NonEncodedCount.
  • FileCount is FDI-only (bounded by fdi_size / MIN_FDI_FILE_RECORD_BYTES). Should be FdiFileCount.
  • DirCount is FDI-only (bounded by fdi_size / MIN_FDI_DIR_RECORD_BYTES). Should be FdiDirCount.

Tests reading WireField::FileCount at a matches! site can't tell from the name whether they're matching the FDI's file_count or some hypothetical future flat-index file_count. Display strings ("file_count", "dir_count") are similarly ambiguous.

Fix

Rename the 4 variants. Decide whether to break the Display strings too:

Option A — variant rename only, keep Display strings (preserves operator log greps):

WireField::FlatEntryCount      // Display: "entry_count"
WireField::V10NonEncodedCount  // Display: "non_encoded_count"
WireField::FdiFileCount        // Display: "file_count"
WireField::FdiDirCount         // Display: "dir_count"

Option B — rename both variant and Display string (symmetric, breaks dashboards):

WireField::FlatEntryCount      // Display: "flat_entry_count"
WireField::V10NonEncodedCount  // Display: "v10_non_encoded_count"
WireField::FdiFileCount        // Display: "fdi_file_count"
WireField::FdiDirCount         // Display: "fdi_dir_count"

Option A is safer for log-grep stability. Option B is more honest. Pick one and update the per-variant Display pin test (wire_field_display_tokens_are_wire_stable in error.rs).

Files

  • crates/paksmith-core/src/error.rs (definition + Display + pin test)
  • crates/paksmith-core/src/container/pak/index/{path_hash,flat,entry_header}.rs (call sites)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-designType system improvements: invariants, encapsulation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions