Skip to content

[ISSUE-02] Implement domain enums and result dataclasses#69

Merged
Gonza10V merged 2 commits into
full_buildfrom
codex/implement-domain-enums-and-result-dataclasses
May 5, 2026
Merged

[ISSUE-02] Implement domain enums and result dataclasses#69
Gonza10V merged 2 commits into
full_buildfrom
codex/implement-domain-enums-and-result-dataclasses

Conversation

@Gonza10V
Copy link
Copy Markdown
Contributor

@Gonza10V Gonza10V commented May 5, 2026

Motivation

  • Provide a stable, importable domain contract layer for the full_build clean-architecture refactor so planner/executor/stages/inventory/reporting can depend on pure enums and dataclasses rather than runtime or automation-specific objects.
  • Follow ARCHITECTURE.md guidance: use SBOL identity strings in contracts, represent expected blockers and approvals as structured data, and avoid coupling domain imports to PUDU/Opentrons/SynBioHub/SBOLInventory.

Description

  • Added pure enum contracts for build stages and statuses: BuildStage, StageStatus, BuildStatus, MaterialState, and DesignKind in src/buildcompiler/domain/.
  • Implemented approval/protocol minimal enum and dataclass: ApprovalStatus and RequiredApproval.
  • Added dataclass contracts for requests, blockers, warnings, inventory records, and results: BuildRequest, MissingBuildInput (with MissingKind), BuildWarning, IndexedPlasmid, IndexedBackbone, IndexedReagent, StageResult, and FullBuildResult using safe mutable defaults (field(default_factory=...)) and conservative Any typing for not-yet-implemented neighboring contracts or raw SBOL fields.
  • Exported the new contract types through src/buildcompiler/domain/__init__.py for lightweight imports.
  • Files added/changed and primary contracts:
    • src/buildcompiler/domain/build_stage.py: BuildStage
    • src/buildcompiler/domain/status.py: StageStatus, BuildStatus
    • src/buildcompiler/domain/material_state.py: MaterialState
    • src/buildcompiler/domain/design.py: DesignKind
    • src/buildcompiler/domain/build_request.py: BuildRequest
    • src/buildcompiler/domain/missing_input.py: MissingBuildInput, MissingKind
    • src/buildcompiler/domain/approvals.py: ApprovalStatus, RequiredApproval
    • src/buildcompiler/domain/warnings.py: BuildWarning
    • src/buildcompiler/domain/plasmid.py: IndexedPlasmid, IndexedBackbone
    • src/buildcompiler/domain/reagent.py: IndexedReagent
    • src/buildcompiler/domain/build_result.py: StageResult, FullBuildResult
    • src/buildcompiler/domain/__init__.py: exports
  • Kept the domain layer free of runtime automation or network dependencies and left placeholders (Any) for plan, graph, summary, and report in FullBuildResult to be defined by later milestones.

Testing

  • Import checks (offline): PYTHONPATH=src python -c "from buildcompiler.domain.build_result import StageResult" succeeded and PYTHONPATH=src python -c "import buildcompiler.domain" succeeded.
  • Unit tests: PYTHONPATH=src pytest tests/unit/domain ran and passed: 3 tests passed.
  • Added test file: tests/unit/domain/test_contracts.py which covers enum values, BLOCKED vs FATAL semantics for MissingBuildInput.required_stage, and mutable-default isolation for BuildRequest, StageResult, RequiredApproval, and BuildWarning.
  • Lint/format attempts: uv run ruff check . reported pre-existing repository-wide lint issues unrelated to this change; these are outside the scope of this PR and not introduced by the new domain contracts.
  • Tooling/network blocker: running uv run pytest in the project virtualenv attempted to fetch an optional git dependency (SBOLInventory) and failed due to network/Git fetch error (HTTP CONNECT 403), so the uv-driven virtualenv install path is blocked by network access; the smallest reproducible test command to run locally later is PYTHONPATH=src pytest tests/unit/domain.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c843d6418d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

id: str
stage: BuildStage
source_identity: str
source_display_id: str | None
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve advertised Python compatibility in domain contracts

The project metadata still advertises requires-python = ">=3.7", but this new contract class uses 3.10-only annotation syntax (str | None) without postponed annotation evaluation, so importing buildcompiler.domain will fail on supported interpreters (3.7–3.9) at class-definition time. This turns a previously importable package namespace into an import-time error for those environments; either add compatibility-friendly annotations (Optional[...], etc. or from __future__ import annotations) or bump the declared minimum Python version.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@codex Good catch, lets change the declared minimum Python version to 3.10 onwards

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

  • Updated the project metadata to declare Python 3.10+ support by changing requires-python from >=3.7 to >=3.10 in pyproject.toml, matching the 3.10-style type-union syntax already present in the domain contracts.
  • Committed the change on the current branch (e994682) and created a follow-up PR with title [ISSUE-02 follow-up] Bump declared Python minimum to 3.10.

Testing

  • python -m py_compile src/buildcompiler/domain/build_request.py
  • git diff -- pyproject.toml (verified only the Python version metadata line changed)

View task →

@Gonza10V
Copy link
Copy Markdown
Contributor Author

Gonza10V commented May 5, 2026

Closes #54

@Gonza10V Gonza10V merged commit 72303d1 into full_build May 5, 2026
0 of 4 checks passed
@Gonza10V Gonza10V deleted the codex/implement-domain-enums-and-result-dataclasses branch May 5, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant