Tamale.Anchor (tamale v0.1.0)

Copy Markdown

The anchor algebra.

An anchor is an expression over a Tamale.Space, stamped with the at_version it is valid at. Tamale.Transport carries it forward along the op log. Three native shapes:

  • Ordinal — references element identity (one id, or several conjunctively; adjacent? expresses boundary anchors like "A|B").
  • Metric — references a coordinate interval (ticks, seconds, frame index); transported by Tamale.Warp, not by identity.
  • Relative — identity first, then an offset interval from the element's span ("0–50 ms after the start of phoneme 3").

The algebra is deliberately closed: new shapes mean a new kernel version covered by new conformance vectors, not a user callback.

Summary

Functions

Projects a Relative anchor to an absolute Metric interval, given the host element's current span from the Caller.

Types

Functions

project(anchor, coord, span_fun)

@spec project(
  Tamale.Anchor.Relative.t(),
  term(),
  (Tamale.id() -> {Tamale.Coord.input(), Tamale.Coord.input()} | nil)
) ::
  {:ok, Tamale.Anchor.Metric.t()}
  | {:error,
     {:unknown_id, Tamale.id()}
     | {:invalid_coordinate, term()}
     | :invalid_interval}

Projects a Relative anchor to an absolute Metric interval, given the host element's current span from the Caller.

Offsets may be negative and may overhang the host (preutterance); there is no within-host invariant. What an overhanging interval means for survival is judged later, by warp (Tamale.Warp.map_interval/3 clip semantics), not here. An inverted offset interval (from_offset > to_offset) is not an overhang — it is rejected with {:error, :invalid_interval}. Offsets and the span are cast to rational coordinates; floats are {:error, {:invalid_coordinate, value}}.