Skip to content

Add safe ordinary/effect function conversion refactors #183

Description

@julia-script

Summary

Add proven-safe whole-workspace refactors between ordinary fn and lazy effect fn.

This must not be implemented as a keyword toggle: ordinary statements execute eagerly, while invoking an effect function delays its entire body. An ordinary function may intentionally perform eager setup and return an effect {} recipe.

Scope

  • Add compiler-owned refactor.rewrite actions for eligible ordinary/effect functions.
  • Use the function-demand/effect-footprint facts from Add function contract completion and synchronization actions #182.
  • Use workspace reference summaries and use contexts from Index workspace references beyond the open-root import closure #179.
  • Update the declaration kind and complete contract.
  • Insert or remove run at semantically corresponding direct call sites.
  • Validate callable annotations and first-class callable uses.
  • Preserve ownership, capture access, eager/lazy timing, and trap behavior.
  • Return one atomic multi-file change plan or refuse the action with the first untransformable use.
  • Resolve against a complete, current workspace revision.
  • Keep intentionally behavior-changing conversion separate from safe refactoring.

Safety constraints

Conversion must be withheld when it would change or cannot prove preservation of:

  • eager setup timing;
  • trap timing;
  • effect construction/run layering;
  • ownership or affine cleanup;
  • capture access/repeatability;
  • callable identity or first-class callable types;
  • public contract semantics;
  • any call site outside the complete editable workspace set.

Lint behavior

Integrate with #181 only for patterns proven semantics-preserving and enabled by policy. Do not emit a universal “could be an effect function” or “could be ordinary” warning based on textual shape.

If intentionally behavior-changing conversion is later desired, expose it as a separately named previewed action rather than an ordinary safe refactor.

Acceptance criteria

  • Eligible direct-call conversions rewrite declaration and call sites atomically.
  • Ordinary functions with meaningful eager setup are not presented as safely convertible.
  • Effect functions with failures/requirements or effectful behavior are converted only when the target ordinary form preserves the contract and behavior.
  • First-class callable uses are either rewritten with preserved types or block the action with an explanation.
  • Closed reverse-dependent callers are included through Index workspace references beyond the open-root import closure #179.
  • Partial/stale/uneditable workspace state prevents a partial refactor.
  • Tests cover direct calls, run, returned effect recipes, traps, captures, affine values, callbacks, aliases, public functions, and recursive call graphs.

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    new featureNew functionality outside the current stable-release language surface

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions