S1-4: Parse_Catalog and Build-Image API Enhancements for ImageGroup/Image Data Model#4265
Merged
Rajeshkumar-s2 merged 7 commits intodell:pub/build_streamfrom Apr 13, 2026
Merged
Conversation
Domain layer (core/image_group/): - ImageGroupId value object (String(128), non-UUID catalog identifier) - ImageGroupStatus enum (BUILT→DEPLOYING→DEPLOYED→RESTARTING→RESTARTED→ VALIDATING→PASSED/FAILED/CLEANED) with is_terminal() - PipelinePhase enum (BUILD, DEPLOY) - ImageGroup/Image domain entities with lifecycle state machine - Repository interfaces (ImageGroupRepository, ImageRepository) using ABC - Domain exceptions: DuplicateImageGroupError, ImageGroupNotFoundError, ImageGroupMismatchError, InvalidStateTransitionError - State machine guard functions with ALLOWED_TRANSITIONS and STATUS_FLOW ORM model changes (infra/db/models.py): - ImageGroupModel: String(128) PK, UNIQUE job_id FK (1:1 mapping), status with CHECK constraint, timestamps, cascade relationships - ImageModel: UUID PK, FK to image_groups, role+image_name, UNIQUE(image_group_id, role) constraint - JobModel: Added pipeline_phase column (nullable String(10)), singular image_group relationship (uselist=False) - StageModel: Added result_detail JSONB column Infrastructure: - ImageGroupMapper/ImageMapper in infra/db/mappers.py - SqlImageGroupRepository/SqlImageRepository in infra/db/repositories.py (save, find_by_id, find_by_job_id, find_by_job_id_for_update, update_status, list_by_status with pagination, exists, save_batch) - InMemoryImageGroupRepository/InMemoryImageRepository for dev/test - StageType enum extended with DEPLOY, PXE_BOOT, VALIDATE stages - Alembic migration 006: image_groups + images tables, pipeline_phase, result_detail columns - DI container updated (Dev + Prod) with new repository providers - API dependencies: get_image_group_repo, get_image_repo factories Tests (99 new tests, all passing): - Unit: value objects, entities, exceptions, state machine guards - Unit: in-memory repository operations and pagination - Integration: ORM round-trip with SQLite, relationships, constraints, cascade deletes, SQL repository operations, mapper conversions, StageModel.result_detail, JobModel.pipeline_phase Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
abhishek-sa1
approved these changes
Apr 9, 2026
Venu-p1
approved these changes
Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Staged Changes Summary — S1-4: API Enhancements for ImageGroup/Image Data Model
Overview
9 files staged (8 modified, 1 new) — 968 additions, 18 deletions
The changes implement two parts of S1-4:
• Part A (Parse-Catalog Enhancement): Extracts image_group_id from the catalog JSON top-level key, validates its uniqueness against the image_groups
table, and persists catalog metadata (roles, role-to-image mappings) as an NFS artifact for downstream consumption.
• Part B (Build-Image Completion): On build-image success, the ResultPoller loads the persisted catalog metadata and creates ImageGroup (status=BUILT) +
Image records in the database.
File-by-File Breakdown
File Status +/- What Changed
api/parse_catalog/dependencies.py Modified +7/-2 Injects image_group_repo into ParseCatalogUseCase for prod
api/parse_catalog/routes.py Modified +25/-0 Adds DuplicateImageGroupError (409) and InvalidCatalogFormatError (400) exception
handlers
container.py Modified +6/-0 Wires image_group_repo/image_repo into ResultPoller and ParseCatalogUseCase in both
Dev and Prod containers
core/catalog/exceptions.py Modified +4/-0 Adds InvalidCatalogFormatError exception class
orchestrator/catalog/dtos.py Modified +4/-1 Adds image_group_id, roles, role_images fields to ParseCatalogResult DTO
orchestrator/catalog/use_cases/parse_catalog.py Modified +216/-9 Core logic: _extract_image_group_id(), _check_image_group_uniqueness(),
_extract_catalog_metadata(), _store_catalog_metadata_artifact()
orchestrator/common/result_poller.py Modified +175/-5 Part B: _is_build_image_stage(), _on_build_image_success(), _load_catalog_metadata()
— creates ImageGroup/Image records on build completion
tests/.../test_parse_catalog_use_case.py Modified +3/-1 Relaxes existing assertion to accept IN_PROGRESS or FAILED job state (compatible with
new flow)
tests/.../test_s1_4_api_enhancements.py New +528/-0 20 new unit tests across 5 test classes
Newly Added Effective Lines of Code (Product Code Only)
Excluding blank lines, comments, and docstrings:
File Effective LoC
dependencies.py 2
routes.py 23
container.py 6
exceptions.py 1
dtos.py 4
parse_catalog.py 138
result_poller.py 122
Total 296
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Unit Test Report
New UTs (test_s1_4_api_enhancements.py — 20 tests)
Class Tests All Passed
TestExtractImageGroupId 7 (valid key, empty catalog, multi-key, empty string, whitespace, >128 chars, exactly 128) Yes
TestCheckImageGroupUniqueness 3 (unique passes, duplicate raises 409, no-repo skips) Yes
TestExtractCatalogMetadata 3 (roles+images, default image name, empty roles) Yes
TestParseCatalogWithImageGroup 3 (success includes group_id, duplicate raises 409, metadata artifact stored) Yes
TestResultPollerBuildImageCompletion 4 (stage detection, creates records, no-metadata skips, no-repos skips) Yes
Summary
Category Passed Failed Skipped Errors
New UTs 20 0 0 0
Overall UTs 714 0 1 0
Regressions No
All 714 unit tests pass with zero failures and no regressions. The 1 skipped test is pre-existing (not related to these changes).
Suggested Reviewers
If you wish to suggest specific reviewers for this solution, please include them in this section. Be sure to include the @ before the GitHub username.
@Venu-p1 @abhishek-sa1 @SOWJANYAJAGADISH123