Skip to content

Add function contract completion and synchronization actions #182

Description

@julia-script

Summary

Add compiler-backed actions that complete or explicitly synchronize a function's full contract:

effect fn load() -> Data ! ParseError ? &FileSystem

This includes the result type, failure row, requirement row, and imports needed to spell those types.

Semantic product

Introduce a declaration-independent per-function summary such as:

FunctionDemand
  success/result type
  propagated failures
  propagated requirements
  effect/laziness facts
  provenance for every demanded member
  availability or underdetermination reason

It must derive facts from all reachable return/failure paths and remain available when the declared contract is missing or wrong—the state in which the action is needed.

Actions

  • Complete contract: conservatively add an absent result, failures, requirements, and required imports without narrowing an existing valid contract.
  • Minimize/synchronize contract: explicit refactor that may remove unused row members/imports or narrow a result after proving the implementation contract.
  • Return one atomic grouped change plan for header and import edits.
  • Reuse the scope-aware presentation and import planning introduced by Add scalable auto-import code actions to the Silk LSP #178.
  • Resolve actions against the originating revision.
  • Report recursive, generic, open-row, or otherwise underdetermined cases instead of guessing.

Lint behavior

Integrate with the warning framework from #181:

  • Missing required contract members may support actionable diagnostics.
  • Unnecessary failures/requirements may be linted where policy allows.
  • Public declarations must not be automatically narrowed merely because the current implementation is narrower; a wider public contract may be intentional.
  • Contract minimization for public functions must be opt-in or otherwise explicitly configured.

Acceptance criteria

  • Completion derives the result from all reachable returns, not only the final terminal.
  • Direct fail sites and rows demanded by run contribute structured canonical failures/requirements.
  • Missing imports for result/error/capability types are added or merged atomically.
  • Existing valid aliases and contract spelling are preserved unless the selected action explicitly synchronizes them.
  • Ambiguous or unavailable type presentation withholds the action or explains why it cannot be completed.
  • Recursive/generic/open-row tests cover determined and underdetermined cases.
  • Public/private contract minimization policy is specified and tested.
  • Stale action resolution never applies an old contract plan to new source.

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