Parent: #90
Depends on: #119
Goal
Implement Wright-owned Workshop -> OPY source reconstruction for a declared, evidence-backed Workshop/WIR surface, producing canonical useful OPY that recompiles to semantically equivalent Workshop.
Context
Current raw Workshop inputs parse directly into validated Wright WIR. M13 forward work is complete: native OPY and OSTW frontends converge on the same Workshop semantics/WIR, and #119 proves the OSTW -> Workshop path.
Reverse reconstruction must therefore start from canonical Workshop/WIR semantics. It must not attempt to recover lost comments, formatting, macros, temporary-variable intent, or original high-level abstractions.
Scope
- Add an OPY-owned reconstruction/emission API that consumes validated Wright WIR.
- Emit deterministic canonical OPY for the subset that the native
wright-opy frontend can represent and recompile correctly.
- Cover the core structured Workshop surface evidenced by current Workshop fixtures: variable declarations/indices, subroutines, rules/events/conditions, scalar/array/vector/enum values, variable access, calls/actions, assignment/modify actions,
if, while, and representable for-loop forms.
- Resolve Workshop actions/values/enums through existing canonical Workshop catalog plus OPY manifest/source bindings; do not introduce a second content/signature table.
- Prefer simple low-level valid OPY over speculative recovery of functions/macros/source abstractions.
- Define explicit unsupported diagnostics for WIR constructs whose current OPY frontend/source syntax cannot represent semantically.
- Validate reconstruction with the full loop:
Workshop -> WIR -> OPY source -> native OPY frontend -> WIR -> Workshop, comparing observable/normalized semantics rather than source-text identity.
- Add deterministic fixtures and a machine-readable support boundary for reconstruction coverage.
Non-goals
- Recovering original OPY formatting/comments/includes/macros/function structure.
- Using OverPy as a production runtime dependency.
- Whole-source regeneration for agent edits; this is raw Workshop interoperability output only.
- Expanding OPY syntax or inventing Wright-only OPY.
- Workshop -> OSTW; tracked separately.
- Adding the shared CLI conversion command; final integration is a separate M13 step after both reconstructors exist.
Acceptance criteria
- A library consumer can reconstruct valid canonical OPY from every WIR construct declared supported by this issue.
- Reconstructed OPY is accepted by Wright's native OPY frontend without upstream runtime support.
- Recompiling reconstructed OPY produces Workshop semantically equivalent to the original under Wright's declared normalization/round-trip contract.
- Unsupported constructs fail deterministically and explicitly instead of emitting misleading source.
- Canonical Workshop/OPY metadata remains single-owned by the existing catalog/manifest contracts.
- Current OPY/Workshop/OSTW and CI compatibility gates remain green.
Relationships
Parent: #90
Depends on: #119
Goal
Implement Wright-owned Workshop -> OPY source reconstruction for a declared, evidence-backed Workshop/WIR surface, producing canonical useful OPY that recompiles to semantically equivalent Workshop.
Context
Current raw Workshop inputs parse directly into validated Wright WIR. M13 forward work is complete: native OPY and OSTW frontends converge on the same Workshop semantics/WIR, and #119 proves the OSTW -> Workshop path.
Reverse reconstruction must therefore start from canonical Workshop/WIR semantics. It must not attempt to recover lost comments, formatting, macros, temporary-variable intent, or original high-level abstractions.
Scope
wright-opyfrontend can represent and recompile correctly.if,while, and representable for-loop forms.Workshop -> WIR -> OPY source -> native OPY frontend -> WIR -> Workshop, comparing observable/normalized semantics rather than source-text identity.Non-goals
Acceptance criteria
Relationships