# `Figler.Scene.Graph.OpenPencilOracle`
[🔗](https://github.com/open-pencil/figler/blob/v0.1.0-beta.3/lib/figler/scene/graph/open_pencil_oracle.ex#L1)

Compares effective scene graphs against OpenPencil's occurrence interpreter.

`scripts/openpencil_oracle.ts` runs OpenPencil's reader on a `.fig` file and
prints each page's interpreted tree. This module builds the same projection
from a Figler graph and reports field-level differences, aligning children by
their saved order.

With `scene: true`, OpenPencil materializes the document into its scene
graph, which also resolves variables, modes, and styles, and the comparison
covers resolved paints, text, and layout values (see `project_scene/2`).

# `diff`

```elixir
@type diff() :: %{
  path: String.t(),
  field: String.t(),
  openpencil: term(),
  figler: term()
}
```

# `compare`

```elixir
@spec compare(Figler.Scene.Graph.t(), map()) :: %{
  pages: [map()],
  diffs: [diff()],
  by_field: map()
}
```

Compares every page in `expected` against `graph`.

# `compare_projected`

```elixir
@spec compare_projected(map(), (String.t() -&gt; map() | nil)) :: %{
  pages: [map()],
  diffs: [diff()],
  by_field: map()
}
```

Compares every page in `expected` against trees already in the oracle's
shape, which `actual` returns for a page GUID string.

# `compare_scene`

```elixir
@spec compare_scene(Figler.Scene.Graph.t(), map()) :: %{
  pages: [map()],
  diffs: [diff()],
  by_field: map()
}
```

Compares every page of OpenPencil's materialized scene against `graph`.

# `expected!`

```elixir
@spec expected!(
  Path.t(),
  keyword()
) :: map()
```

Runs OpenPencil's reader on `fig_path` through `bun` and decodes its output.

Options:

  * `:openpencil` - OpenPencil checkout with installed dependencies. Defaults to
    `FIGLER_OPENPENCIL_DIR` or `../open-pencil-app`.
  * `:pages` - page GUID strings to read. Defaults to every visible page.
  * `:scene` - dump OpenPencil's materialized scene graph instead of its
    interpreted occurrence trees.

# `project`

```elixir
@spec project(Figler.Scene.Graph.t(), Figler.Scene.Node.t() | nil) :: map() | nil
```

Projects a graph node and its descendants into the oracle's shape.

# `project_scene`

Projects a graph node's resolved values into the scene oracle's shape.

OpenPencil's scene graph keeps source identity on layers built from source
records but not on components, instances, or anything inside them, which
pair by position.
Defaults follow OpenPencil's record conversion.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
