A completed extraction run: document-ordered spans plus per-chunk errors.
The return value of LangExtract.run/4 and LangExtract.Runner.run/4
for all handled per-chunk failures — parse, HTTP, timeouts, and (on the
Runner) task crashes. Returned bare: errors is the failure channel.
Standalone run/4 still exits the caller on a bug-level linked chunk
crash (no Result); the Runner converts those to ChunkErrors.
A struct rather than a positional tuple so future fields (usage, timing)
can be added without breaking consumer matches — bind only the keys you
need:
%LangExtract.Result{spans: spans, errors: errors} =
LangExtract.run(client, source, template)spans are in document order by byte_start (located spans first;
:not_found spans have nil offsets and sort after every located
span). errors carry the byte range of each failed chunk, also in
document order. An empty errors list means every chunk extracted
cleanly.
usage totals the token counts across chunks whose provider response
reported them — nil when none did. Failed chunks and providers that
omit usage blocks contribute nothing, so with partial failures the
totals cover the successful chunks only.
Summary
Types
@type t() :: %LangExtract.Result{ errors: [LangExtract.ChunkError.t()], spans: [LangExtract.Span.t()], usage: LangExtract.Provider.Response.usage() | nil }