Identifies who made an edit to a buffer.
The rich source type flows through events, ghost cursors, and the edit
timeline. The undo stack uses a simpler atom-based source (see
Minga.Buffer.State.edit_source); use to_undo_source/1 to bridge.
Creating sources
Always use the constructor functions instead of building raw tuples:
EditSource.user()
EditSource.agent(session_pid, tool_call_id)
EditSource.lsp(:elixir_ls)
EditSource.formatter()
EditSource.unknown()Constructors validate arguments with guards (e.g. session_id must be a
pid, server_name must be an atom). Pattern matching on the raw shapes
is fine and encouraged; only construction should go through constructors.
Source variants
:user— interactive keystroke from the human{:agent, session_id, tool_call_id}— agent tool applying an edit{:lsp, server_name}— LSP-initiated edit (code action, rename):formatter— format-on-save or explicit format command:unknown— source not determined (legacy code paths during migration)
Summary
Functions
Edit from an agent tool call.
Edit from format-on-save or explicit format command.
Converts a simple undo source atom to the rich event source.
Edit from an LSP server (code action, rename, etc.).
Maps a rich edit source to the simple atom used by the undo stack.
Source not determined (legacy code paths during migration).
Interactive edit from the human user.
Types
Functions
Edit from an agent tool call.
@spec formatter() :: t()
Edit from format-on-save or explicit format command.
@spec from_undo_source(Minga.Buffer.State.edit_source()) :: t()
Converts a simple undo source atom to the rich event source.
Used when Buffer.Server mutation functions are called without an explicit source parameter, preserving backward compatibility.
Note: for :agent, the returned session_id is the Buffer.Server's own PID,
not an agent session PID. The undo stack doesn't preserve the original session
reference. Treat it as a sentinel indicating "some agent edit, origin unknown."
Edit from an LSP server (code action, rename, etc.).
@spec to_undo_source(t()) :: Minga.Buffer.State.edit_source()
Maps a rich edit source to the simple atom used by the undo stack.
This bridge exists so the undo system can continue using atom-based guards until Provenance Undo (#1108) migrates it to the rich type.
@spec unknown() :: t()
Source not determined (legacy code paths during migration).
@spec user() :: t()
Interactive edit from the human user.