Skip to content

[M14] Validated source edits and semantic refactoring across Wright frontends #127

Description

@Teakowa

Goal

Make validated source-oriented mutation a first-class Wright tooling capability across supported source frontends, using semantic identity and project/source provenance rather than whole-source regeneration or mutable IR APIs.

The governing workflow is:

semantic understanding -> validated source edits -> original source

M14 should turn the existing OPY-focused safe-edit/rename work into a shared, agent-usable source mutation platform without coupling it to LSP, a specific agent harness, or reconstruction emitters.

Context

M13 completed the declared Workshop-centered interoperability matrix and established native OSTW semantic/tooling support. The next high-value gap is no longer conversion breadth.

Current repository evidence shows the source-edit layer has not caught up with the shared compiler/session architecture:

M14 should reconcile these layers around one source-aware mutation contract.

Scope

  • Reassess the existing M9 safe-edit contract and M10 project-wide semantic rename against the current OPY/OSTW/session/source-registry architecture.
  • Define a frontend-neutral, source-aware edit transaction model with:
    • source/file identity;
    • version/content preconditions;
    • exact source ranges;
    • multiple edits across multiple files where required;
    • deterministic overlap/conflict handling;
    • preview and validation results;
    • structured refusal diagnostics.
  • Validate edits through the same native project/session semantics as the original source kind instead of forcing OPY or regenerating source from WIR.
  • Preserve project roots, imports/includes, overlays, source provenance, and cross-file semantics while validating candidate edits.
  • Reuse and consolidate the proven M10 semantic-rename machinery rather than maintaining separate textual/LSP-only rename semantics.
  • Add semantics-backed rename for the declared OSTW source surface where symbol identity and source spans are sufficient to prove correctness.
  • Expose validated edit/refactoring preview through Wright-owned embedding/tool-service APIs so agents can request semantic edits without depending on LSP or a specific harness.
  • Keep transport adapters thin and map the same editor-neutral edit results to LSP/agent consumers where applicable.
  • Add real-project/cross-language regression evidence for stale versions, collisions, cross-file edits, overlays, unsupported constructs, and validation failures.

Non-goals

  • Whole-source OPY/OSTW regeneration as the normal mutation model.
  • Using Workshop -> OPY/OSTW reconstruction to edit an existing higher-level source project.
  • A generic arbitrary AST/HIR/WIR mutation API.
  • Automatically writing files from semantic core without an explicit caller/application boundary.
  • Extract-method, inline-function, formatter, code-action breadth, or other refactorings without concrete evidence.
  • Expanding OPY/OSTW language compatibility merely to make a refactoring possible.
  • Editor-specific UX or coupling core contracts to LSP types.
  • A plugin ABI or content registry.

Initial sequencing

  1. Reconcile/generalize the edit transaction + validation contract against current project/session semantics.
  2. Reuse that contract for semantic rename across the accepted OPY/OSTW source surfaces.
  3. Expose mutation preview/validation through the shared tool/embedding surface.
  4. Independently verify source correctness, stale/conflict refusal, provenance, agent/LSP reuse, and CI before adding broader refactorings.

Detailed later refactoring scope should be driven by actual agent/editor consumers rather than symmetry.

Acceptance criteria

  • The shared edit-validation path no longer hard-codes OPY or a synthetic edit.opy workflow and validates through the correct native frontend/project semantics.
  • A proposed multi-source edit carries sufficient source identity/version preconditions to reject stale or conflicting application safely.
  • Semantic rename for the declared supported source surfaces edits only occurrences belonging to the resolved semantic identity, including project-wide references where supported.
  • OSTW source edits operate against original OSTW source and project provenance; no reconstruction round-trip is used as the edit mechanism.
  • Edit preview/validation is available through a transport-neutral Wright-owned API suitable for agents and embedding.
  • LSP/editor adapters reuse the same underlying mutation contract rather than owning separate refactoring semantics.
  • Unsupported or unsafe edits fail explicitly with structured source-located diagnostics and no partial mutation.
  • Current compile/check/lint/analyze/inspect/convert behavior and compatibility gates remain green.
  • No public mutation contract freezes internal HIR/WIR layout.
  • PM performs a post-M14 reassessment before adding broader refactoring features.

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