Issue #1435: The compiler proves which code cannot measure time and which code is deterministic

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 #1433 (the clock kinds). Decided by the owner (2026-11-08); the ADR is item 1.

Done when

The ledger records, for every function and package, whether it can measure time and whether it is deterministic; nikaia permissions shows both; and a dependency that only computes (a parser, a compressor) is reported as unable to measure time, including through hidden clocks.

Why time needs care (WebAssembly’s lesson)

After Spectre (2018), memory safety turned out not to isolate code: code with a precise clock can read memory of the same process speculatively, through cache timings. Browsers coarsened performance.now() and switched off SharedArrayBuffer, because a second thread counting in shared memory is a clock with nanosecond resolution, whatever clock API is missing. Three lessons:

Decided

Two kinds (from #1433): clock(wall), the date and time of day, needed for calendars and logs; clock(mono), time::Instant and elapsed, the measuring one.

“Can measure time” holds for a function or package where any of these holds:

“Deterministic” holds where the result depends only on the parameters: no clock, no random, no env, args, stdin or system, no input from files or the network, no result that depends on the order tasks run in. A grammar’s run at build time is the existing reference case (Part II 10.2).

Not this issue: code that reveals a secret through its own timing (a comparison that is not constant-time). That is information flow, on the axis of provenance (ADR-010); see #1432 Later.

To build

  1. The ADR (working name ADR-permissions-2): the lessons above, the two properties and their rules.
  2. “Can measure time” in the ledger, derived over the call graph like touches; tests: one .nika per hidden clock above, and a pure function that reports false.
  3. “Deterministic” in the ledger; tests: a pure function (true), one that reads env (false), a par_iter over a sync lambda that touches nothing (true), a select (false).
  4. The report (nikaia permissions) shows both per package.
  5. Granting: clock(mono) and the hidden clocks are part of what #1434 refuses for a dependency. Once both are built, a dependency that gains the ability to measure time is refused like one that gains net.

Files and limits

touch.nika or a sibling tools/*.nika, std.contracts for the waiting and racing entries, the ledger writer. Not changed: how select, sleep or the scheduler behave.

Ruled out

Back to Open Issues