Scoria (scoria v0.1.3)

Copy Markdown View Source

Scoria is the public facade for starting, inspecting, and resuming AI work inside a Phoenix app.

Start here when wiring Scoria into an application. The normal path is:

  1. Normalize request or session context with identity/1
  2. Start a durable run with start_run/2
  3. Persist the returned run_id
  4. Inspect or resume that exact run through the same module

session_id is the host-owned continuity key that groups related turns. run_id is Scoria's exact durable handle for one run. Reuse a session_id across turns, but resume only by run_id.

Use this facade from controllers, LiveViews, jobs, or service modules when the host app already owns identity, authorization, policy values, prompts, and business meaning. Scoria records the durable execution trace and returns public Scoria.Runtime.RunSummary / Scoria.Runtime.RunDetail data.

For the first-run walkthrough, see guides/getting-started.md and guides/golden-path.md. For the ownership split, see Scoria.Identity and guides/ownership-boundary.md. For lower-level lifecycle APIs behind this facade, see Scoria.Runtime.

Examples

iex> identity =
...>   Scoria.identity(%{
...>     actor_id: "user_123",
...>     tenant_id: "tenant_456",
...>     session_id: "session_789"
...>   })
iex> {identity.actor_id, identity.tenant_id, identity.session_id}
{"user_123", "tenant_456", "session_789"}
iex> identity.metadata
%{}

Summary

Functions

Returns the stable public summary for a run.

Returns the stable public summary for a run or raises.

Returns the curated detailed public view for a run.

Returns the curated detailed public view for a run or raises.

Normalizes caller-supplied edge identity into the canonical runtime envelope.

Lists runs that share the same host-owned session_id.

Resumes a run by exact durable run_id.

Starts a bounded delegated run with one explicit handoff and scoped context.

Starts a run through the canonical public runtime facade.

Functions

get_run(run_id)

Returns the stable public summary for a run.

get_run!(run_id)

Returns the stable public summary for a run or raises.

get_run_detail(run_id)

Returns the curated detailed public view for a run.

get_run_detail!(run_id)

Returns the curated detailed public view for a run or raises.

identity(attrs \\ %{})

Normalizes caller-supplied edge identity into the canonical runtime envelope.

list_runs_for_session(session_id)

Lists runs that share the same host-owned session_id.

resume_run(run_id, opts \\ [])

Resumes a run by exact durable run_id.

start_handoff_run(identity, delegated_role_id, opts \\ [])

Starts a bounded delegated run with one explicit handoff and scoped context.

Prefer scoped_context: for the host-curated context slice passed to the delegated role:

Scoria.start_handoff_run(identity, "critic",
  root_role_id: "planner",
  delegated_kind: "review",
  handoff_input: %{"brief" => "Review the draft answer"},
  scoped_context: %{"task" => "policy review"}
)

projected_context: remains accepted as a legacy 0.1.x compatibility alias. The stored field name is not renamed by the terminology migration.

start_run(identity, opts \\ [])

Starts a run through the canonical public runtime facade.