Skip to content

L6: code generation owned by pycodify and objectstate.codegen - #1198

Merged
trissim merged 6 commits into
mainfrom
refactor/L6-codegen
Oct 11, 2026
Merged

trissim merged 6 commits into
mainfrom
refactor/L6-codegen

Conversation

@trissim

@trissim trissim commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Surface L6 (receipt). Pipelines persist as pycodify-generated .py files, so code generation is the persistence format.

Library PRs to release first, in this order:

  1. 0.2.0: generated source loads back every value it names pycodify#4: 0.2.0
  2. 2.1.0: objectstate.codegen; drop well_filter debug ObjectState#28: 2.1.0 (depends on pycodify 0.2.0)

Pins are raised here: pycodify>=0.2.0,<0.3, objectstate>=2.1,<3. The submodules point at the two branch heads.

Deleted from OpenHCS (now owned by the libraries)

  • openhcs/core/python_source_literal.py: FunctionReference now subclasses pycodify.PythonSourceLiteral, which has one source_fragment method.
  • openhcs/serialization/source_path_factoring.py: path factoring is built into generate_python_source, and the six document renderers call it directly.
  • EnumMemberFormatter, AxisDeclarationFormatter, OpenHCSImportableTypeFormatter and NameMappingLookup: replaced by pycodify.imported_name and TypeFormatter.
  • The LazyDataclass formatter (six classes) and FunctionStepCleanModeFieldPolicy: replaced by objectstate.codegen.
  • The repr() catch in OpenHCSCallableFormatter: an unreferenceable callable now raises instead of saving <function f at 0x…>.

Round-trip test (tests/unit/test_source_round_trip.py) runs four checks:

  • Every registered config dataclass (all 22 lazy/base pairs minus the abstract StreamingConfig), with every field set to a non-default value derived from its annotation. This covers axis classes, the PartitionFilterMode family, partition filters, nested source-binding records and paths.
  • The same configs at their defaults, in both clean and full mode.
  • A pipeline document with every function-pattern shape: callable, (callable, kwargs), a declared path kwarg, nested-enum kwargs (CropModule.Shape), hidden runtime kwargs, chain, and a dict by group. It asserts the path_root factoring.

Each check loads the source back and compares raw values.

It found one real bug: base configs that inherit through None (StepPartitionFilterConfig, PathPlanningConfig, the streaming configs and others) were written with their resolved values in full mode, so a saved GlobalPipelineConfig stopped inheriting. The fix is in ObjectState#28. I checked that the test fails without it.

Guards (tests/unit/test_l6_codegen_guards.py):

  • The two deleted modules stay deleted.
  • No OpenHCS can_format claims Enum, Path, classes, PythonSourceLiteral or lazy dataclasses.
  • No __qualname__.partition or _explicitly_set_fields appears under openhcs/.
  • No well_filter appears in ObjectState sources.

Deletion certificates

  • derived: every OpenHCS formatter and module listed above. The libraries own the same fact through imported_name, PythonSourceLiteral, PathFactoring and objectstate.codegen.
  • contract: pycodify FormatContext.extensions and generate_python_source(context=). Their only user was OpenHCS path factoring, which moved into the library.
  • contract: the repr() outputs, which never loaded back.

Checks run locally

  • Ratchet over openhcs, scripts and benchmark: no increases (5 counts decreased).
  • nra-r1: increased: [].
  • Unit tests: 365 + 263 passed across the codegen, document, GUI and agent tests listed in the receipt.

L6 · PR #1198 · guards 4/4 · production −591 +43 · tests −215 +419

🤖 Generated with Claude Code

trissim and others added 3 commits October 11, 2026 07:31
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OpenHCS deletes its copies of generic source-generation mechanisms:
- openhcs/core/python_source_literal.py: FunctionReference subclasses
  pycodify.PythonSourceLiteral (one source_fragment method).
- openhcs/serialization/source_path_factoring.py: path factoring is built into
  pycodify.generate_python_source; the six document renderers call it.
- EnumMemberFormatter, AxisDeclarationFormatter, OpenHCSImportableTypeFormatter,
  NameMappingLookup: pycodify.imported_name and TypeFormatter.
- The LazyDataclass formatter and FunctionStepCleanModeFieldPolicy:
  objectstate.codegen.
- OpenHCSCallableFormatter no longer writes repr() for a callable it cannot
  reference; it raises.

tests/unit/test_source_round_trip.py writes every registered config dataclass
(lazy and base) with every field set, and a pipeline document with every
function-pattern shape, then loads the source back and compares raw values.
It found base configs losing inheritance in full mode (fixed in ObjectState).

Submodules point at the pycodify 0.2.0 and ObjectState 2.1.0 branch heads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 11, 2026 12:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

trissim and others added 3 commits October 11, 2026 08:22
Submodule pycodify at the branch head with native-path factoring tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trissim
trissim merged commit 29b2ed6 into main Oct 11, 2026
5 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants