[ISSUE-11] Implement lvl2 assembly stage and engineered-region blockers#78
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3fdcf3e0c9
ℹ️ 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".
| constrained = constraints.get("region_order") | ||
| if constrained: | ||
| return list(constrained) |
There was a problem hiding this comment.
Preserve full region set when applying region_order
_extract_region_identities currently returns constraints["region_order"] directly, which drops any engineered regions not listed there and changes the requested region set before routing. That bypasses the hard validation in CompatibilitySelector.select_lvl2_route (which compares region_order against the requested regions) and can let lvl2 assembly proceed for only a subset of a ModuleDefinition when region_order is incomplete. In practice, a request with two module functional components and region_order containing one identity will assemble a partial product instead of blocking on a constraint mismatch.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Summary
- Fixed
AssemblyLvl2Stage._extract_region_identities(...)soregion_orderis no longer treated as the requested engineered-region set. The method now only uses explicit identity constraints (engineered_region_identities/region_identities) or falls back to allModuleDefinition.functionalComponents, which preserves full-region validation behavior. src/buildcompiler/stages/assembly_lvl2.pyL216-L229 - Added a regression test that verifies an incomplete
region_ordercauses lvl2 to block (no selected route) instead of proceeding with a partial assembly. tests/unit/stages/test_assembly_lvl2.pyL194-L207
Testing
- ✅
pytest -q tests/unit/stages/test_assembly_lvl2.py
Committed to current branch:
1264eba
…mention-issue-11]-implement-lvl2-assembly-stage-and
…ssue-11]-implement-lvl2-assembly-stage-and Fallback when `region_order` is unsatisfiable for lvl2 assembly and add warning
Motivation
Description
AssemblyLvl2Stage(addedsrc/buildcompiler/stages/assembly_lvl2.py) that resolves the sourceModuleDefinition, extracts engineered-region identities fromregion_order, planner constraints, orModuleDefinition.functionalComponents, and delegates route enumeration/selection toCompatibilitySelector.select_lvl2_route(...).selected_route+ up to 3rejected_routes) stored inStageResult.protocol_artifactsand promotes anymissing_region_identitiesintoMissingBuildInputrecords withmissing_kind="engineered_region"andrequired_stage=BuildStage.ASSEMBLY_LVL1.MissingBuildInputrecords, and only callsAssemblyService.run(...)when the selected route is complete; on success it indexes generated products intoInventorywhile appendinginsert_identitiesandsource_stagemetadata and emits a compiler-only PUDU JSON intermediate viaassembly_route_to_pudu_json(...).AssemblyLvl2Stagefromsrc/buildcompiler/stages/__init__.pyand added unit tests intests/unit/stages/test_assembly_lvl2.pycovering success, empty-region failure, engineered-region promotion, large-order blocking, and hardregion_orderconstraint behavior.Testing
python -c "from buildcompiler.stages import AssemblyLvl1Stage",python -c "from buildcompiler.inventory import CompatibilitySelector",python -c "from buildcompiler.inventory.compatibility import Lvl2Route, RouteSelection",python -c "from buildcompiler.sbol import AssemblyService, AssemblyJob, AssemblySbolResult", andpython -c "from buildcompiler.adapters.pudu import assembly_route_to_pudu_json"all passed.pytest tests/unit/stages/test_assembly_lvl2.pypassed, and the full unit test suitepytest tests/unit/domain tests/unit/api tests/unit/inventory tests/unit/planning tests/unit/sbol tests/unit/stages tests/unit/adapterspassed (59 tests, all passed).uv run pytest tests/unit/stages/test_assembly_lvl2.pyfailed due to environment network restriction when attempting to fetch optional dependencySBOLInventory(HTTP 403), so localpytestwas used as fallback and passed;ruff check .andruff format --check .reported pre-existing repo-wide issues outside the scope of this change while the modified files passruffchecks.Codex Task