Skip to content

[ISSUE-10] Implement domestication planner/service with approvals#77

Merged
Gonza10V merged 2 commits into
full_buildfrom
codex/implement-domestication-planner-and-service
May 6, 2026
Merged

[ISSUE-10] Implement domestication planner/service with approvals#77
Gonza10V merged 2 commits into
full_buildfrom
codex/implement-domestication-planner-and-service

Conversation

@Gonza10V
Copy link
Copy Markdown
Contributor

@Gonza10V Gonza10V commented May 6, 2026

Motivation

  • Add a deterministic, review-gated domestication step that proposes sequence edits for internal restriction sites without mutating sequences automatically.
  • Provide structured blockers, approval gates, and generated lvl0 plasmid products so downstream stages (lvl1) can consume domesticated inserts deterministically.

Description

  • Added a pure planner at src/buildcompiler/planning/domestication.py introducing SequenceEditProposal, DomesticationPlan, and DomesticationPlanner which validates part roles, requires a usable DNA sequence, and detects internal BsaI motifs (GGTCTC/GAGACC) as non-mutating proposals.
  • Added an SBOL service at src/buildcompiler/sbol/domestication.py with DomesticationJob, DomesticationSbolResult, and DomesticationService that emits a minimal generated IndexedPlasmid product, attaches provenance (source part, backbone, reagents, and proposals), and adds SBOL objects to the target document without writing files.
  • Added orchestration stage at src/buildcompiler/stages/domestication.py that resolves the source part, produces structured MissingBuildInput blockers for missing backbone/reagents, enforces a hard approval gate via RequiredApproval for proposed sequence edits, and indexes generated products via inventory.add_generated_product() with insert_identities set to the source part identity.
  • Exported the new planner/service/stage through src/buildcompiler/planning/__init__.py, src/buildcompiler/sbol/__init__.py, and src/buildcompiler/stages/__init__.py, and kept changes lightweight (no Opentrons/PUDU/SBOLInventory dependencies at runtime of core imports).
  • Approval policy: process name is domestication_sequence_edit and stable approval id convention is domestication-edit:<part_identity>; sequence edits are represented as SequenceEditProposal records surfaced in StageResult.protocol_artifacts and RequiredApproval.metadata.

Testing

  • Added unit tests: tests/unit/planning/test_domestication_planner.py (planner role/sequence/bsai detection), tests/unit/sbol/test_domestication_service.py (product/provenance), and tests/unit/stages/test_domestication_stage.py (missing backbone/reagent blockers, approval gating, protocol-mode behavior, approved-process success).
  • Commands run and results:
    • python -c "from buildcompiler.api.options import BuildOptions" — succeeded.
    • python -c "from buildcompiler.inventory import Inventory, CompatibilitySelector" — succeeded.
    • python -c "from buildcompiler.stages import AssemblyLvl1Stage" — succeeded.
    • python -c "from buildcompiler.domain import StageResult, MissingBuildInput, RequiredApproval, ApprovalStatus" — succeeded.
    • python -c "from buildcompiler.stages import DomesticationStage" — succeeded.
    • python -c "from buildcompiler.sbol import DomesticationService" — succeeded.
    • python -c "from buildcompiler.planning import DomesticationPlanner" — succeeded.
    • uv run pytest tests/unit/planning/test_domestication.py tests/unit/sbol/test_domestication_service.py tests/unit/stages/test_domestication.py — failed in this environment due to network/Git fetch of optional SBOLInventory dependency (403), so uv virtualenv provisioning could not complete.
    • pytest tests/unit/planning/test_domestication_planner.py tests/unit/sbol/test_domestication_service.py tests/unit/stages/test_domestication_stage.py — succeeded (these targeted tests passed).
    • pytest tests/unit/domain tests/unit/api tests/unit/inventory tests/unit/planning tests/unit/sbol tests/unit/stages — succeeded; all unit suites report 53 passed.
    • ruff check . && ruff format --check . — failed due to pre-existing unrelated lint issues in legacy files and notebooks (these are outside this PR scope).
  • Notes: targeted unit tests and full unit-suite pass locally for the core code added; uv-based environment setup failed due to network restrictions fetching an optional dependency and is a CI/environment issue rather than code failure.

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: eb16ac7dd8

ℹ️ 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".

Comment on lines +47 to +50
metadata = {
"source_stage": "domestication",
"source_part_identity": job.part_identity,
"insert_identities": [job.part_identity],
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 Create SBOL implementation for domesticated outputs

The domestication product metadata only records identities and never provides an implementation_identity, and this service also does not create an sbol2.Implementation for the new plasmid. When this generated product is later selected by AssemblyLvl1Stage, AssemblyService._implementation_from_plasmid_record raises because it requires either metadata implementation_identity or an implementation in the source document. That makes domesticated products non-consumable in downstream assembly for runs where no pre-existing part plasmid is available.

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, fix this issue

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

Testing

  • pytest tests/unit/sbol/test_domestication_service.py
  • pytest tests/unit/planning/test_domestication_planner.py tests/unit/sbol/test_domestication_service.py tests/unit/stages/test_domestication_stage.py

Committed on the current branch as:
58ccf8c - Fix domestication SBOL implementation metadata and role copying

Also created a follow-up PR message via make_pr summarizing these changes on top of the original PR.

View task →

Comment thread src/buildcompiler/sbol/domestication.py Outdated
Comment on lines +43 to +44
for role in component.roles:
product_component.roles = role
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Copy all roles instead of overwriting in loop

Assigning product_component.roles = role inside the loop overwrites prior values, so only the last source role is retained. If a source part carries multiple ontology roles, the generated domesticated SBOL object silently drops all but one role, which can break downstream logic that depends on preserved role annotations.

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, fix this issue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I checked the branch state, and this issue is already fixed in the current HEAD commit (b50b13f), so there was nothing additional to patch.

What I verified

  • git status --short (clean working tree; no pending changes)
  • git log --oneline -n 5 (includes b50b13f Fix domestication SBOL implementation metadata and role copying)

Because no new code changes were required, I did not create a new commit and did not call make_pr (per your workflow rules).

View task →

@Gonza10V Gonza10V merged commit 690f0bc into full_build May 6, 2026
0 of 4 checks passed
@Gonza10V Gonza10V deleted the codex/implement-domestication-planner-and-service branch May 6, 2026 05:52
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