Skip to content

refactor(cli): introduce shared package metadata model#1467

Closed
Harsh-Sahu43 wants to merge 1 commit into
dora-rs:mainfrom
Harsh-Sahu43:shared-pkg-metadata-model
Closed

refactor(cli): introduce shared package metadata model#1467
Harsh-Sahu43 wants to merge 1 commit into
dora-rs:mainfrom
Harsh-Sahu43:shared-pkg-metadata-model

Conversation

@Harsh-Sahu43
Copy link
Copy Markdown
Contributor

@Harsh-Sahu43 Harsh-Sahu43 commented Mar 19, 2026

Problem

Dora.toml metadata and registry metadata describe the same package semantics but are evolving independently.

If these paths define and validate package data independently, they can drift quickly as Project #2 grows. That would make later resolver, install, publish, and lockfile work harder to align.

Related context

This PR is aligned with the same package-management direction being explored in:

  • #1451 — Dora.toml metadata validation
  • #1453 — local registry index reader / inspect flow

What this PR changes

This PR introduces a shared package metadata model inside the CLI crate and makes both manifest and registry parsing normalize into it. This PR is intentionally scoped to the shared semantic layer and does not introduce new CLI surface.

Added

  • a shared validated package model in binaries/cli/src/package_metadata.rs
  • shared helpers for:
    • package/dependency name validation
    • semver parsing
    • entrypoint validation

Refactored

  • binaries/cli/src/dora_toml.rs

    • keeps raw Dora.toml parsing separate
    • normalizes manifest metadata into the shared package model
  • binaries/cli/src/registry.rs

    • keeps raw registry index parsing separate
    • normalizes registry package records into the same shared package model

Why this matters

This establishes a clean architectural foundation:

  • Raw structs → file-oriented
  • Shared model → semantic-oriented
  • later layers like resolver, lockfile, install, and publish can build on one package model instead of multiple ad hoc ones

This prevents schema drift and ensures that future layers (resolver, lockfile, install, publish) operate on a single consistent package representation.

Design

Inspired by Cargo’s separation of concerns:

  • parsing remains format-specific
  • validation is centralized
  • normalized package model is shared

Resolver and higher-level workflows are intentionally deferred.

Validation

cargo fmt --all --check
cargo check -p dora-cli
cargo test -p dora-cli package_metadata
cargo test -p dora-cli dora_toml
cargo test -p dora-cli registry
cargo clippy -p dora-cli --all-targets

@heyong4725
Copy link
Copy Markdown
Collaborator

Hi @Harsh-Sahu43, thanks for putting this together — the code itself is clean (PackageIdentity / PackageDefinition / DependencyRequirement is a reasonable shape, and the validator helpers are well-factored).

Closing this one as part of the broader call on the package-management track. Where the project is right now:

This is not a quality judgment on the work — closing it on direction, not merit. Your other contributions are exactly the kind we want:

Both landed cleanly because they tackled concrete pain the project already had. If you're looking for the next thing to work on, the patterns that rescue well are: defensive fixes for crashes / panics, gaps in cross-platform CI, missing CLI ergonomics, and edge cases in existing features. The recent rescue stack (#1855, #1859, #1861, #1864, #1865, #1869, #1870) is a good shape to mirror.

Thanks again — please don't read this close as "stop contributing." Just "the foundation isn't laid here yet."

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants