SPB Git

Repository Public License

0003-custom-logic.md 2.0 KB 20 lines markdown

1# ADR 0003 — How custom logic runs23**Status:** accepted for rung 1; rungs 2 and 3 designed, not built (2026-11-22)45## Context6Arbitrary Swift must never be evaluated in the PRISM or satellite process. Most app logic (filter, compute, validate, write a record) does not need a general-purpose language.78## Decision — a ladder91. **Declarative actions + a small typed expression language (V1, built).**10   - Actions are a closed set interpreted by the runtime: `setState`, `navigate`, `createRecord`, `updateRecord`, `deleteRecord`, `importCSV`, `exportCSV`, `showNotification`, `validate`, `sequence`/`when`.11   - Expressions are pure and total: literals, state/record/query references, arithmetic, comparison, boolean logic, a conditional, and a fixed library of functions (`sum`, `count`, `avg`, `min`, `max`, `round`, `abs`, `lower`, `upper`, `contains`, `concat`, `length`, `formatCurrency`, `formatNumber`, `formatDate`, `month`, `year`, `today`, `coalesce`, `if`). No loops, no recursion, no I/O, no reflection. Evaluation has a node budget, so an expression cannot hang the UI.12   - Data access is a declarative query object compiled to parameterized SQL over identifiers validated against the blueprint schema. Expressions never contain SQL.13   - This rung runs in-process because it cannot express anything outside its own sandbox by construction.142. **Scripts in a separate constrained process (post-V1).** A worker with no ambient file or network access, CPU/memory/time quotas, talking over a typed pipe. Adding a script runtime is on the ask-first list.153. **Real Swift generation only in the Tier C export (post-V1).**1617## Consequences18- In V1 "generated logic" means generated *expressions and actions*; they are validated, labeled with `provenance.source = "agent"`, and covered by blueprint tests. The `code.*` agent tools answer with a structured `not_available` error.19- Requests the catalog and rung 1 cannot express are reported to the user as not implemented instead of being faked.20
Files main
Menu

Theme