Skip to content

Define the canonical Workshop comment and source-preservation contract #32

Description

@Teakowa

Parent: #108
Related 1.0 API contract: #112

Goal

Define the canonical workshop-rs source-preservation contract for authored Workshop comments/trivia and mixed-source consumers while keeping source/provenance information an optional capability attached to the canonical Workshop semantic program rather than a mandatory part of ordinary semantic construction.

Context

workshop-rs owns the canonical public Workshop program model used by raw parsing, tooling, and independent source-language lowering. The 1.0 API contract in #112 requires ordinary generated/lowered Workshop nodes to remain usable without synthetic spans or repeated source-metadata fields, while source-aware consumers must still be able to retain the provenance required for diagnostics, validated edits, comment/trivia preservation, and useful reconstruction.

The current parser/WIR/validation/emitter surface represents ordinary supported Workshop semantics canonically. A source-language consumer embedding vanilla Workshop should therefore use the same canonical semantic model rather than require a DEL-local or workshop-rs opaque/raw rule model merely because the source originated inside another language.

deltin-rs integration history provides consumer evidence for source files that mix DEL/OSTW constructs with vanilla Workshop blocks and comments. workshop-rs owns the Workshop-language preservation semantics; deltin-rs owns how its grammar embeds/resolves those regions.

Scope

  • Define which Workshop comments/trivia are preserved and which are presentation-only/non-semantic.
  • Define stable attachment/provenance semantics for authored program/rule/condition/action/value/settings source where preservation is supported.
  • Keep source spans, provenance, comment/trivia attachment, and edit-oriented source information optional with respect to the Workshop semantic nodes themselves.
  • Allow raw Workshop parsing to populate source metadata automatically, source-language consumers to attach it when available, and programmatic generation to omit it entirely.
  • Preserve enough source structure for diagnostics, validated source edits, and useful reconstruction without requiring exact whole-file formatting reproduction.
  • Ensure embedded supported vanilla Workshop content uses the same canonical public Program semantics as standalone raw Workshop.
  • Define explicit failure/incompleteness behavior for malformed, genuinely unsupported, legacy, or evidence-insufficient embedded Workshop content.
  • Add focused parse/preserve/edit/emit/reparse evidence for comments and mixed-source Workshop regions where the owner-side contract applies.

Non-goals

  • Mandatory span: Option<_>/comment/provenance fields on every public Workshop semantic constructor or builtin API.
  • A second opaque/raw semantic representation for ordinary supported Workshop constructs.
  • DEL/OSTW grammar, project loading, source embedding syntax, or runtime lowering.
  • Exact formatting/trivia identity for untouched whole files unless separately required by a source-edit contract.
  • Full pretty-printer regeneration as the default edit model.
  • Workshop-to-DEL decompilation.
  • A provider-local catalog or emitter.

Acceptance criteria

  • Ordinary generated Workshop semantic construction requires no source metadata.
  • Raw parsing and source-aware consumers can associate stable source/provenance metadata with canonical Program concepts without exposing storage internals.
  • A reviewed public contract defines supported comment/trivia preservation and attachment/provenance behavior.
  • Supported source-aware edits preserve unrelated comments/trivia and structure rather than requiring full regeneration.
  • Malformed/unsupported embedded content fails or remains explicitly incomplete without guessed semantics.
  • Parser/program/source APIs provide enough stable provenance for consumers to explain and preserve authored Workshop content.
  • deltin-rs and future consumers can integrate through the canonical Workshop semantic/source APIs without copying parser/catalog/emitter logic or inventing a parallel raw Workshop model.
  • The resulting contract is compatible with the 1.0 public API contract in Define and migrate to the canonical Workshop-facing Rust API for 1.0 #112.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions