← Back to issue list

Project model hierarchy

View original Github issue

Metadata

Project
snapcraft
Number
#5543
Type
issue
State
closed
Author
sergiusens
Labels
Bounty
Created
Updated
Closed

Current evaluation

Project hierarchy redesign landed with Pydantic validation and declarative JSON Schema generation in merged PR #5730 (7cfb25977).

Resolution: closed resolved

Reason: PR canonical/snapcraft#5730 merged as 7cfb25977 and closed #5543, adding inheritance-based models and schema tooling. A rollout regression in 8.13.0 was temporarily reverted by #5857, then the change was restored and model selection corrected by #5846.

Evaluated by: mr-cal-bot

No scores available.

Issue body

### What needs to get done #### Acceptance criteria * A redesign of the project models (see section below) * Migrate to a schema based validation * Per-base reference documentation of the schema * Automatically generated base-aware and type-aware JSON schema * This should be generated declaratively from the project models. The schema should not be post-processed beyond [what Charmcraft does](https://github.com/canonical/charmcraft/blob/main/tools/schema.py) #### ## Rough design The hierarchy would look something along the lines of this pseudocode: ```py class Project: ... class BaseProject(Project): type: Literal["base"] build-base: BaseEnum class AppProject(Project): base: BaseEnum class BareProject(AppProject): base: BaseEnum.BARE class Core22Project(AppProject): base: BaseEnum.CORE22 class Core22KernelProject(Core22Project): type: kernel UnionAppProject = ... UnionKernelProject = ... SnapcraftProject = Annotated[ BaseProject | SnapdProject | GadgetProject | UnionAppProject | UnionKernelProject, Field(discriminator="type") ] ``` ### Why it needs to get done Snapcraft has a monolithic project model that represents core22 and core24 snaps in addition to different types of snaps (e.g. base snaps, kernel snaps, gadget snaps). There are 3 major problems with a monolithic project model: Documentation * It’s not possible to generate per-base documentation of the project model JSON schema * It’s not possible to generate a base-aware JSON schema, so editing a snapcraft.yaml in an IDE isn’t a good experience. IDEs inform users that valid keys are invalid and vise-versa. Maintainability * Instead of using modern programming constructs like inheritance, model validation is driven by sets of if/else statements. This is bug prone and burdensome to maintain.

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Project hierarchy redesign landed with Pydantic validation and declarative JSON Schema generation in merged PR #5730 (7cfb25977).
stealth/space-bunny-alpha — closed resolved Project hierarchy validation and generated schemas landed in #5730 (7cfb25977). Its 8.13.0 rollout was reverted by #5857, followed by model-selection fixes in #5846.
stealth/space-bunny-alpha — closed resolved Project-model hierarchy work was merged in #5846 (3249bed8e), fixing model selection by snap type and base; the author confirmed the contribution was merged in October 2025.
qwen/qwen3.6-35b-a3b — — Merged by @EdmilsonRodrigues. A live clinic simplified the design, replacing the monolithic model with a cleaner inheritance hierarchy for schema-based validation and auto-generated JSON schemas. Bounty increased to $1000.
qwen/qwen3.6-35b-a3b — — A redesigned hierarchical project model for improved validation and schema generation was merged. Following clinic discussions and a bounty increase to $1000, the contributor's simplified implementation was successfully integrated.
qwen3.6-35b-a3b-mtp-q6 — — The project model hierarchy was redesigned to enable base-aware JSON schema generation and improve maintainability. After a live clinic simplified the approach, the bounty increased to $1000. The implementation was successfully merged by EdmilsonRodrigues.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/snapcraft#5730 (confidence 100%)

    Merged as commit 7cfb25977; implemented the project model hierarchy and schema generation.

  • Related To: canonical/snapcraft#5857 (confidence 99%)

    Merged commit 5b50af9cd temporarily reverted the changes after their 8.13.0 rollout; 063c3c89e later restored them.

  • Related To: canonical/snapcraft#5846 (confidence 98%)

    Merged commit 3249bed8e corrected project-model selection after the new hierarchy was enabled.

Related issues

Issue Project State Summary Similarity
#4885 Redesign Project models snapcraft closed Project model redesign completed through #5543; PR #5730 merged as 7cfb25977, adding inheritance-based Pydantic validation and JSON Schema generation.
82%