Skip to content

Enhance blob metadata validation and simplify API structure - #2042

Merged
imeoer merged 8 commits into
v3from
feature/blob-meatdata
Aug 25, 2026
Merged

Enhance blob metadata validation and simplify API structure#2042
imeoer merged 8 commits into
v3from
feature/blob-meatdata

Conversation

@gaius-qi

Copy link
Copy Markdown
Member

Overview

This pull request includes a number of improvements and clarifications to the Nydus documentation and codebase, focusing on terminology consistency, code modernization, and test simplification. The most significant changes are terminology updates in the documentation for greater clarity, refactoring of code to use updated APIs and naming, and improvements to test code for maintainability.

Documentation terminology and clarity updates:

  • Standardized terminology in docs/nydus.md, replacing "record" with "entry" for block groups and chunks, and updating field names for better consistency (e.g., compressed_byte_offsetcompressed_offset, block_group_block_bitsblock_group_block_count_bits). Also clarified various explanations and updated example code and tables accordingly. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]

Codebase modernization and improvements:

  • Updated the clap dependency in Cargo.toml to include the string feature, enabling additional command-line parsing capabilities.
  • Refactored usage of blob metadata constants and APIs in nydus-backend/src/local.rs to use the new NYDUS_BLOB_METADATA_SUFFIX and updated BlobMetadata::from_bytes API, simplifying metadata loading and improving code consistency. [1] [2] [3]
  • Updated the registry backend to use the new BlobMetadata::from_bytes API for loading metadata, improving error handling and consistency with local backend changes.
  • Changed a method call from is_redirect_blob() to is_redirect() in nydus-core/src/blob.rs for consistency with refactored naming.

Test code simplification:

  • Simplified test helpers in nydus-backend/src/local.rs to use updated constructors and removed unnecessary parameters, making tests easier to read and maintain. [1] [2] [3]

Related Issues

Please link to the relevant issue. For example: Fix #123 or Related #456.

Change Details

Please describe your changes in detail:

Test Results

If you have any relevant screenshots or videos that can help illustrate your changes, please add them here.

Change Type

Please select the type of change your pull request relates to:

  • Bug Fix
  • Feature Addition
  • Documentation Update
  • Code Refactoring
  • Performance Improvement
  • Other (please describe)

Self-Checklist

Before submitting a pull request, please ensure you have completed the following:

  • I have run a code style check and addressed any warnings/errors.
  • I have added appropriate comments to my code (if applicable).
  • I have updated the documentation (if applicable).
  • I have written appropriate unit tests.

…mats

Introduce a `blob::flag` module that centralises the EROFS-style
incompatible/compatible flag split (low 16 bits incompat, high 16 bits
compat) and a `validate_incompat_flags` helper that rejects records
carrying unknown incompat bits with a descriptive error. This replaces
ad-hoc per-format checks and ensures consistent forward-compatibility
enforcement across blob meta and blob footer readers.

Signed-off-by: Gaius <gaius.qi@gmail.com>
…tency

Rename `compressed_byte_offset` to `compressed_offset`, "record" to
"entry" throughout the blob metadata spec and implementation, add a
`NYDUS_` prefix to public constants, drop the `_byte_` infix from
method names, introduce typed algorithm enums for blob meta compressor
and digester, restructure header serialization to use byte-array
methods, and update docs and tests accordingly.

Signed-off-by: Gaius <gaius.qi@gmail.com>
…nd block group size to 4 MiB

Rename blob metadata constants to use the `DEFAULT_` prefix for clarity,
rename `block_group_block_bits` fields to `block_group_block_count_bits`,
expand the default block group size to 4 MiB, move validation logic into
methods, and add the clap `string` feature.

Signed-off-by: Gaius <gaius.qi@gmail.com>
Merge `validate_padding` and `validate_blob_metadata_crc32` free functions into a single `BlobMetadata::validate_bytes` method, and simplify chunk/block-group parsing to use `chunks_exact` instead of manual index arithmetic.

Signed-off-by: Gaius <gaius.qi@gmail.com>
Replace builder-pattern blob metadata loading with direct `from_bytes` calls,
rename and inline private helpers, add doc comments, and unify method naming
across blob metadata, cache, and storage layers for improved clarity.

Signed-off-by: Gaius <gaius.qi@gmail.com>
Remove the `blob_id` field from `BlobMetadata` and eliminate redundant
`blob_id`/`data_digest` parameters from related APIs, simplifying the
blob metadata construction and usage across build, check, optimize,
backend, format, and storage subsystems.

Signed-off-by: Gaius <gaius.qi@gmail.com>
@gaius-qi gaius-qi added this to the v3.0.0 milestone Aug 25, 2026
@gaius-qi gaius-qi self-assigned this Aug 25, 2026
@gaius-qi
gaius-qi requested review from a team as code owners August 25, 2026 08:58
@gaius-qi
gaius-qi removed the request for review from a team August 25, 2026 08:58
@gaius-qi gaius-qi added the enhancement New feature or request label Aug 25, 2026
@gaius-qi
gaius-qi requested review from ClementMaH, CormickKneey, EvanCley, bergwolf, fcgxz2003 and hhhhsdxxxx and removed request for a team August 25, 2026 08:58
gaius-qi and others added 2 commits August 25, 2026 09:03
…meatdata

# Conflicts:
#	docs/nydus.md
#	nydus-format/src/blob/algorithm.rs
#	nydus-format/src/blob/metadata.rs
#	nydus-format/src/blob/mod.rs
#	nydus-storage/src/cache/local.rs
#	nydus-storage/src/cache/mod.rs
#	nydus-storage/src/cache/remote.rs
#	nydus/src/bin/nydus/build.rs
#	nydus/src/build/blob_chunk.rs
#	nydus/src/check/mod.rs
#	nydus/src/optimize/mod.rs
#	nydus/tests/testsuite/nydus_core.rs

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…lobMetadataDigester

Clarify that the Display impl emits the lowercase algorithm name used in build and check summaries.

Signed-off-by: Gaius <gaius.qi@gmail.com>

@imeoer imeoer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@imeoer
imeoer merged commit 83b418c into v3 Aug 25, 2026
15 of 21 checks passed
@imeoer
imeoer deleted the feature/blob-meatdata branch August 25, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants