Skip to content

[M13 reverse] Reconstruct the declared Workshop surface as valid OPY source #124

Description

@Teakowa

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions