SvEx.Source.ApplicationEx (SvEx v0.4.2)

Adds a child to a project's supervision tree, structurally.

The most common structural edit a plugin makes — a cache, a job queue, a connection pool, a watcher — and the one that adding a list element makes look like a deletion: the previous last entry is rewritten to gain a comma, so SvEx.Plugin.Diff reports a removal and 2026-08-14-deletion-representation-design.md §1 forces the whole file to :manual. That is correct and loud, and it made every such plugin require a hand edit in every generated project. This module removes the cause rather than relaxing the guard.

Scoped to the children binding inside start/2, deliberately. A general list editor addressed by AST path has no second caller, and every extra shape it accepts is one nobody has verified.

Source text in, source text out, no filesystem — the shape SvEx.Source.MixExs established, over the same SvEx.Vendor.Sourceror engine.

Summary

Functions

Appends child to the supervision tree.

The supervision children declared in start/2, as the strings the author wrote.

Types

error()

@type error() ::
  {:no_start_function, :not_found}
  | {:children_not_a_literal, :start}
  | {:unparseable, term()}

Functions

add_child(source, child)

@spec add_child(binary(), binary()) :: {:ok, binary()} | {:error, error()}

Appends child to the supervision tree.

LAST, always. Supervision order is a semantic the plugin cannot reason about: it knows its own process needs the repo started first, but not whether it should precede another plugin's. After everything the project already had is the only position that is both deterministic and defensible, and prepending would let a plugin's process start before the project's own.

Idempotent by parsed comparison, not by substring: two identical children are a name clash at boot.

A children built by a function call, a comprehension or ++ returns {:error, {:children_not_a_literal, :start}} and the caller falls back to the :manual path it used before this module existed. Failing into the existing loud behaviour is the correct degradation.

children(source)

@spec children(binary()) :: {:ok, [binary()]} | {:error, error()}

The supervision children declared in start/2, as the strings the author wrote.

Commented-out examples are comments, not children: mix new --sup and phx.new both ship one, and a textual reader would count them.