Repository navigation
Statement-level edits for raw Workshop: insert, replace, delete with canonical emission #532
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or requestready-for-implementationContract settled; an Engineer can implement without inventing a decisionContract settled; an Engineer can implement without inventing a decision
Description
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. inserttakes a non-empty statement list placed beforeindex(indexequal to the list length appends);replacetakes one statement;deletetakes none.replacekeeps the replaced statement's leading comment;deleteremoves the statement with its comment;insertwrites 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-USandzh-CNcoverage, 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestready-for-implementationContract settled; an Engineer can implement without inventing a decisionContract settled; an Engineer can implement without inventing a decision
Activity
e54-bot commentedon Oct 20, 2026
Dependency #531 is closed (#534 merged); removing
blocked.feat(rules): insert, replace and delete statements in raw Workshop so…