Skip to content

[M9] Define safe source edit and refactoring contracts #59

Description

@Teakowa

Parent: #10

Depends on: #56, #57

Planning status: provisional until the M8 v1 gate is complete.

Goal

Define a safe, source-oriented mutation boundary for tools and agents without exposing Wright's mutable compiler internals as a public API.

Scope

  • Identify high-value transformations that can be expressed as validated source edits/refactorings.
  • Define source-edit/result models with version/source identity, spans, preconditions, conflicts, and diagnostics.
  • Evaluate symbol rename and other semantics-backed edits first; add broader transformations only with evidence.
  • Ensure edits can be previewed/validated through the normal compiler/session pipeline before application.
  • Define behavior for stale source versions and overlapping/conflicting edits.
  • Keep raw HIR/WIR mutation internal unless a separate proven use case requires it.

Non-goals

  • A general-purpose arbitrary AST mutation protocol.
  • Letting agents bypass validation and write unchecked compiler structures.
  • Implementing editor-specific WorkspaceEdit/LSP types in core.

Acceptance criteria

  • At least the proven safe refactoring/edit workflows have structured source-oriented contracts.
  • Proposed edits can be validated against source identity and compilation/semantic checks before application.
  • Public mutation contracts do not freeze internal arena/IR layout.
  • Unsupported/unsafe edits fail explicitly.

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