polydat 0.11.2

Polydat — a variates construction engine
Documentation
# For agents working with polydat

This file is for an agent that uses polydat from another project, or
that works on polydat itself. It ships inside the published crate,
beside `docs/`, so it is on disk wherever the crate is.

## What polydat is for

Polydat is a language and runtime for building values: one function
graph, written in polydat source or assembled in Rust, run on an
interpreter, as closures, or as native code, with the same values on
every engine. Its grammar, its scope model and its node library are the
mechanism a host uses to shape data and to carry it between scopes. A
host's requirement is usually met by writing a program differently, not
by adding to polydat.

## Before you conclude something is missing

Look for it first. Most "polydat cannot do X" conclusions come from
not having read how polydat already does X.

1. **Find the rule.** The design documents are in `docs/design/`, and
   the table below routes a question to the one that answers it.
2. **Find the node.** `docs/reference/nodes.md` lists every node a
   program can call, by category, with what it does.
3. **Run two programs.** Write the smallest parent and child programs
   that show the behavior, bind one under the other, and read what the
   kernels hold. `examples/host_questions.rs` is that, for the common
   questions, and `docs/guides/host_questions.md` explains its output.

| Question | Read |
|---|---|
| How does a value get from a parent scope to a child? | `docs/guides/host_questions.md`, then `docs/design/scope_model.md` §3 to §5 and `docs/design/wire_materialization.md` |
| What does a kernel know before the first cycle? | `docs/guides/host_questions.md`, `docs/design/evaluation_model.md` "Const Binding Contract" |
| What does the language accept? | `docs/design/polydat_grammar.md` |
| What types are there, and what converts to what? | `docs/design/type_system.md`, `polydat_grammar.md` §15 |
| What nodes exist? | `docs/reference/nodes.md` |
| How do I embed polydat, drive a kernel, share one across threads? | `docs/guides/embedding.md`, `docs/design/native_scope_trees.md` |
| How do I add a node of my own? | `docs/design/library_catalog.md` |
| How do I read a vector dataset, its records and its predicates? | `docs/design/type_system.md` §1.8, `docs/guides/porting_to_0_11_0.md` Part 3 |
| What changed in a release? | `docs/guides/porting_to_*.md`, newest first in `docs/README.md` |
| Which engine runs what, and why do they agree? | `docs/design/engines.md`, `docs/guides/compilation.md` |

`docs/README.md` is the full index.

## The scope model in four sentences

A `const` is evaluated once when its scope is initialized, and its
value is copied into every child input of the same name when the child
is bound. A value computed per cycle reaches a child through a cell the
parent writes when it computes it, so a child holds nothing for it
until then. A child that declares a name owns it over its own subtree.
So a scope that needs a fact at construction takes the constant across
the boundary, and makes any per-cycle value from it itself.

## Asking polydat for a change

A request for a new capability says:

- which documents and sections were read, and what they say about the
  case;
- the two smallest programs that show what cannot be done, with the
  kernel calls made on them and what each returned;
- what was tried with the existing grammar, scope forms and nodes.

A request without these is answered by pointing here. This is not a
formality: writing the two programs is how most such requests find
their own answer.

## Working on polydat itself

- The same rule applies inward. Before adding a mechanism, check
  whether the grammar and the scope model already provide it, and test
  the existing behavior before building a new one.
- Every behavior a document states is held by a test. A guide's quoted
  output is real output (`tests/guide_output.rs`), the node reference
  is generated from the registry, and a change to either fails until
  the document is regenerated or corrected.
- `docs/guides/releasing.md` is how a release is made, and
  `cargo ws-release` runs every check CI runs before it publishes.