Issue #1436: A grammar states what its dsl blocks reach (meta::touches), so a SQL SELECT is known to read only its tables

Open and answer this issue on GitHub.

compiler, blocked, future, safety · opened 2026-11-08 · updated 2026-11-22 · 0 comments

Part of #1432. Blocked on #1434 (granting and refusing). Decided by the owner (2026-11-08); the ADR text is item 1.

Done when

A grammar can declare, while the program is built, what a dsl block reaches (SELECT name FROM users → db(users) read, DELETE FROM sessions → db(sessions) write); the ledger and nikaia permissions show it as the grammar’s claim, apart from what the compiler derived; and a grant in nikaia.toml can name it.

Why it is sound enough to have

A grammar’s run at build time is sync, reaches nothing but its build parameters and holds no foreign code (Part II 10.2, NK1152), so its result is reproducible: the registry’s CI and every consumer derive it again from the sources. And holes are parameters, never spliced text (meta::parameter, Part II 10.5), so no value at run time can change what the block does. A grammar already decides the block’s result type this way (meta::column).

The limit (decided, and shown)

The claim says what the foreign interpreter will do: “this SELECT does not write” is true only if SQLite is correct. It is therefore exactly as trustworthy as the driver package, and is shown as “stated by grammar sqlite::Sql”, never as derived. It narrows only what the block’s run function reaches; a run function that is native stays native for every other reason.

For dsl js, what JavaScript reaches in a browser (DOM, fetch) is the host’s set and outside the compiler’s view; that block stays native.

To build

  1. The ADR text (in ADR-permissions-1, or a grammar record if the supervisor prefers): meta::touches(kind, mode), which kinds a grammar may name (its own family, such as db(table), registered by the package), how a claim joins the run function’s derived set, how it is shown.
  2. meta::touches as a build-time intrinsic beside meta::column; test: a grammar that declares db(users) read for a block, and the report of a program using it.
  3. The ledger and the report mark the claim with its grammar.
  4. Granting: permissions = ["db(users) read"] for the driver; test: a DELETE in a program that grants only read is refused.

Files and limits

The grammar intrinsics (Part II 10.8), touch.nika, the report. Not changed: how a grammar parses, or a block’s result type.

Back to Open Issues