Choice lists

A dropdown offers a list of choices. Most lists are fixed; some are not. This page covers the kinds of list a template can declare, and what the platform guarantees for each (issue #104).

KindExampleDeclared asA change to it is
FixedYes/No, verdicts, item typesvalues: [...]a template change (a new version)
Recipespell-request's Executive Vote dateschoices: { recipe: "<expression>" }a template change when the recipe changes; never when only its output moves with time
DataPrimes (spell-request, the Prime spell batch, allocation risk)choices: { source: "primes" }never a template change: the list is live data (see data sources)

Recipes

A recipe is a closed platform expression whose only input is the current instant. It returns the list of choices: distinct, non-empty strings of at most 256 characters, at most 500 of them.

{
  key: "execDate",
  type: "dropdown",
  title: "Targeted Executive Vote",
  mandatory: true,
  // The next 10 cadence Thursdays at least 22 days out, skipping a no-vote date.
  choices: { recipe: 'cadenceDates("2026-07-30", 14, isoDateAddDays(todayIsoDate(), 23), 10, ["2026-12-31"])' },
}
  • Closed. The recipe may read the clock helpers (todayIsoDate(), and anything built on the instant) and nothing else: not the process, the user, permissions or the form. The compiler refuses a recipe that reads anything else (compileChoiceRecipe), and registration validation refuses a compiled recipe whose input is anything but now. So the same instant always gives the same list, in the browser and on the server.
  • The digest covers the rule, not its output. The compiled recipe is part of the execution definition; the dates it produces are not. A template with a recipe compiles to the same digest whatever day it is compiled, so a rolling list no longer means a new build every window.
  • Evaluated when shown and again when written. The form evaluates the recipe when it renders the field (@processos/forms/choices, which uses the server's evaluator, @processos/expressions/choices). The server evaluates it again, at the instant of the write, whenever a request writes a new value to the field: a step edit or completion, or a value seeded when a process starts (initial values and defaults). A value outside the list is refused with 400 invalid-choice, naming the value and the choices offered at that instant. This holds for every input policy (compatible and strict): the rule is the field's contract.
  • The instant is recorded. Each accepted value is appended to the process's choice audit (choiceAudit: at, step, field, value). Replaying the recipe at at reproduces the acceptance, so revalidation is deterministic. A step or field rename rewrites these entries like the field audit (originals kept in the migration audit).
  • Stored values are kept. A value accepted earlier stays valid when it leaves the list (a past vote date). A form re-sends it unchanged and the server keeps it; the dropdown shows it first, marked "(not currently offered)". Clearing a value is always allowed. Choosing it again is a new write and is checked.
  • No recipe in rows. Rule-defined choices are for top-level fields only, not item_list rows.

Date helpers

Generic helpers for date recipes (domain/shared/src/declarative/calendar.ts); UTC calendar dates as YYYY-MM-DD, and none reads the clock itself:

HelperGives
todayIsoDate()Today's date at the instant of evaluation.
isoDateAddDays(date, days)date plus days whole days (negative goes back).
cadenceDates(anchor, everyDays, onOrAfter, count, exclude)The first count dates of the cadence anchor + k × everyDays on or after onOrAfter, skipping the dates in exclude. At most 100 dates and 100 exclusions.

Data sources

A data source is a named list of entries with stable ids and names that the deployment binds and the server reads live (Phase 4 of the unified-platform plan). The one bound today is primes: the ontology's Prime agents (organizations of type PRIME_AGENT).

{
  key: "_prime",
  type: "dropdown",
  title: "Prime",
  mandatory: true,
  choices: { source: "primes" },
  // The Prime the starter's affiliation names, by id, from the same live list.
  defaultValue: "{{ matchOrgPrime(currentUser.organizationName) }}",
}
  • Where the list comes from. Main binds primes to GET /api/prime-agents?size=200 (every PRIME_AGENT organization with its open profile) on the templates' own ontology endpoint (PROCESS_ONTOLOGY_ORIGIN with the engine's token PROCESS_ONTOLOGY_TOKEN, a principal holding ontology:read), read through the same protected-HTTP driver, credential and egress policy as a template's ontologyRequest, under the asking template's grants (choiceSourceBindings in applications/main/src/composition/application-configuration.ts; the reader is @processos/runtime/choice-sources). No copy of the list lives in the deployment or the code. The read follows the API's pages and refuses a partial or malformed answer. A successful read is reused for 30 seconds, so a Prime added in the ontology is offered within that time, with no deploy.
  • What a run stores. A reference { id, name } (@processos/contracts/choice-ref): the entry's ontology id, and its name as a snapshot taken when it was accepted. A write names the id (the form sends the id; a name sent with it is ignored), and the server stores the live entry's name. The choice audit records the id and the name (value, label).
  • How it shows. The dropdown offers the live entries (value: id, label: current name). A stored reference is shown by its entry's current name; once the entry has left the source (a Prime removed from the ontology) it is shown by its stored name, marked "(retired)". Read-only views, records and exports show the stored name.
  • Checked when written. A new value must be the id of an entry the source lists at that moment; a retired or unknown id, or a name, is refused with 400 invalid-choice. A stored reference sent back unchanged (the same id) keeps its snapshot, even once retired. Clearing is always allowed. Seeded values at start (initial values, defaults) are checked the same way.
  • Fail closed. When the source cannot be read (the ontology unreachable, the endpoint unbound, a refused or malformed answer): the form offers only the stored value, disabled, and says "The list of choices could not be loaded, so this field cannot be changed now"; the server refuses a new value with 503 choice-source-unavailable (other fields still save); a template with a source field does not start (503); matchOrgPrime matches nothing. Nothing unchecked is ever stored, and there is no fallback list.
  • Served with the form. The form reads GET /api/templates/:key/choice-sources/:source (any signed-in member of the template's application; no-store), through useChoiceSources in @processos/browser-session/react; the generic, spell-review and allocation-risk renderers all use it. The entries are also the expression scope's choiceSources.<name>, in the browser and at start on the server.
  • matchOrgPrime(value) returns the id of the one live Prime whose name occurs in value (case-insensitive), or "" when none does, or when more than one does (an ambiguous affiliation names no Prime: the person chooses).
  • Attributes. An entry may carry scalar attributes the binding names (primes: reviewsOwnSpells, forumCategoryUrl, from prime_agent_profiles). They are served with the list, never stored on runs. primeAttribute(s01._prime, "reviewsOwnSpells") reads the attribute of the live Prime the stored reference names (null without the list): a rule about a kind of Prime, never a Prime named in the template.
  • The digest covers the source's name, never its entries. A shape records it as choiceRule: "source:<name>". A change to the list is data: no version, no migration, nothing in the template.
  • Top-level fields only, as for recipes.

Versions and migrations

A dropdown's choices are part of its contract (see template versions).

  • Changing a fixed list, changing a recipe, or turning a fixed list into a recipe (or back) is a contract change: the migration declares changeField(step, field, existing). A shape records a recipe by its digest (choiceRule: "recipe:<sha256>"), never by its output, so a frozen shape does not depend on the day it was taken.
  • When the new choices are a recipe, only existing: "keep" is accepted: a recipe is checked when a value is written, so there is nothing to validate stored values against.
  • A recipe's output moving with time is not a template change at all.
  • Turning a fixed list into a data source declares changeField(step, field, { existing: "keep" }) and resolveChoice(step, field, source): each stored name that is exactly one live entry's name becomes its reference; a name the source does not hold once refuses the process, and the publication commits nothing until a person adds or renames the entry in the source or corrects the run (template versions). spell-request v19 and spell-prime-batch v5 did this for the Primes.
  • A change to a data source's entries is never a template change.

Known gaps

  • Other data lists are not bound yet. The Merkl and IB payout co-signers are still fixed lists; a source for them is a new binding beside primes, not a new mechanism.
  • allocation-risk is unversioned. Its Prime field is the primes source for new runs; its existing runs stay on the build they were started on, with the Prime's name as text (no lineage, so no migration moves them).
  • A source's list is not replayable. A recipe can be replayed at the recorded instant; a source's list at that instant is not kept, so the choice audit records the id and the name that were checked instead.
  • Values a migration writes to a recipe field are type-checked only (a string), not checked against the recipe. Nor are values a parent seeds into a spawned child (spawnChild copies completed intake history, not a new answer); no template with a recipe spawns children today.
  • Clock skew. The form evaluates the recipe with the browser's clock and the server with its own. At the moment a choice leaves the list (UTC midnight for a date recipe), a choice shown a moment earlier can be refused; the error names the current choices.
  • The template editor shows a recipe's current output but cannot author one; recipes are written in code-owned templates.