Skip to content

Statement-level edits for raw Workshop: insert, replace, delete with canonical emission #532

Closed

Description

@Teakowa

Part of wrightkit/wright#838. Implements the workshop-rs side of wrightkit/wright ADR-0029 decisions 2, 3 and 5 (write direction). Required by wrightkit/wright#834.

Desired behavior

For a parsed raw Workshop program, the owner produces the checked SourceEdit that inserts statements before, replaces, or deletes the statement at a statement address (rule, list = conditions or actions, index), including each emitted statement's canonical text in the session's resolved Workshop locale, its indentation relative to the surrounding source, statement comments, and creation of a missing section.

Scope

  • A public statement-edit call built on Program::edit_source; bytes outside an edit are unchanged and failures are fail-closed.
  • insert takes a non-empty statement list placed before index (index equal to the list length appends); replace takes one statement; delete takes none.
  • replace keeps the replaced statement's leading comment; delete removes the statement with its comment; insert writes none.
  • Inserting into a rule with no conditions section creates the section. After deleting the last statement the rule reparses with an empty list; whether the empty section stays in the text is decided here.
  • A rule whose other content the export cannot express still accepts an insert or an edit to a different statement.

Non-goals

Rule-level edits, variable and subroutine declarations, settings, creating or editing comments, OverPy and OSTW authoring.

Constraints

  • Depends on Convert a rule-content-v1 statement into the public model #531 (content-to-model conversion, the input to this call).
  • Wright ADR-0029 decision 5: an edited statement is emitted canonically, so its spelling may differ from the replaced one; nothing outside it changes.
  • The exact Rust API, error ids and indentation rules belong to this repository.

Acceptance criteria

  • Round trip: for every statement the corpora parse and the export can express, content(parse(emit(statement_from_content(c)))) == c, in every supported Workshop locale.
  • Insert, replace, and delete at the start, middle, and end of a list each leave all bytes outside the edit unchanged and reparse to the expected content.
  • A replaced or deleted statement's comment is kept or removed as specified; an inserted statement has none.
  • Insert into an absent conditions section creates it; delete of the last statement reparses with an empty list.
  • Statements are emitted in the locale passed in, with en-US and zh-CN coverage, including a rule whose neighbours use that locale.
  • A stale or out-of-range address is refused without producing an edit.

Related

wrightkit/wright#834, wrightkit/wright ADR-0029.

Activity

  1. added
    enhancementNew feature or request
    blockedSettled contract, but an external dependency prevents the work
    on Oct 20, 2026
  2. added
    ready-for-implementationContract settled; an Engineer can implement without inventing a decision
    and removed
    blockedSettled contract, but an external dependency prevents the work
    on Oct 20, 2026
  3. e54-bot commented on Oct 20, 2026

    @e54-bot
    Contributor

    Dependency #531 is closed (#534 merged); removing blocked.

  4. added a commit that references this issue on Oct 20, 2026
    45493ab
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

    enhancementNew feature or requestready-for-implementationContract settled; an Engineer can implement without inventing a decision

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions