Issue #2769: Trust in the program’s manifest: [trust] replaces trusted: true on calls (ADR-trust-v1)

Open and answer this issue on GitHub.

ready, safety, queued · opened 2026-11-22 · updated 2026-11-29 · 0 comments

Goal

A program says in its own manifest which sources its operator chose. The trusted: true marker on a call goes away. Decided in ADR-trust-v1 (docs/specification/adr/adr-trust-v1.md, commit 671236870 “ADR-trust-v1: trust is set in the program’s manifest, not at a call”), which replaces ADR-365 D2 and ADR-399 D3.

# nikaia.toml of a benchmark
[trust]
stdin = true          # every read of standard input
args  = true          # cli::args() and main's parameters
files = ["data"]      # or true
// before (ADR-365 D2)
let path = cli::args(trusted: true).nth(1) ?? "measurements.txt"
let b = fs::map(ref path, fs::Root::Anywhere; trusted: true)
// after: no option; the manifest above says it once
let path = cli::args().nth(1) ?? "measurements.txt"
let b = fs::map(ref path, fs::Root::Anywhere)

Part of the safety lane (ADR-397, ADR-raw-sinks-1). Found while answering the owner’s question on benchmarks (2026-11-22: “dieses Vertrauen ist eine Programmeigenschaft”).

Governing decision (I6)

ADR-trust-v1 D1-D5. Text only today; nothing of it is built.

To build

  1. Read [trust] from the program’s manifest only (D1, D3).
    • Where: manifest.nika / project_settings.nika.
    • Keys: stdin, args, files. Each takes true; files also takes a list of directories.
    • Any other key, false, or an entry with a .. component is a manifest error, refused naming the keys, as an [allow] typo is.
    • A dependency’s [trust] is ignored.
    • A single file with no manifest has no trust.
    • The table is a cache-key dimension. No build flag raises it.
  2. Provenance from the table (D1, D2).
    • Where: trust.nika and the prover’s source rules.
    • stdin makes every standard-input read trusted.
    • args makes cli::args() and main’s parameters trusted.
    • files = true makes every fs read trusted, including the names walk/read_dir return.
    • files = [dirs] makes a read trusted only under fs::Root::Dir(d) where d is proved at or below a listed dir by component (path::is_below, ADR-raw-sinks-1 D14).
    • Anywhere stays untrusted.
  3. Remove the trusted: option from io::read, io::read_to_string, io::lines, cli::args and every fs read in std.contracts (D4).
    • A call that writes it is refused with NK1109. Its help names the [trust] line that says the same, e.g. stdin = true.
    • trusted: false goes too.
    • @untrusted grammar stays.
  4. Ledger and --trust (D5).
    • The trusted row reads "fs::map at main.nika:7 (files: data)".
    • The program entry records the [trust] table.
    • --trust prints the table with its manifest line, then each call it covers.
    • render in trust.nika changes; it says “trusted: true at …” today.
  5. The compiler’s hint. The prover_state.nika help that writes cli::args(trusted: true), and the trust.nika:266 comment, write the [trust] line instead.
  6. Migrate every use (counted on 6cef2e362 with grep -rn "trusted: *true" --include=*.nika).
    • Benchmarks. Each gets a nikaia.toml with [trust] and loses its markers:
      • benches/brc: fast 3, fast-unsafe 3, naive 3, scan 1
      • benches/game/k-nucleotide: main 2, speed 1
      • benches/wide-ops/wide.nika: 1
    • Examples. Each gets a manifest [trust] where it reads its own data, or proves the read (ADR-raw-sinks-1 D16):
      • examples/1brc.nika: 4. It is a single file, so it needs a manifest beside it.
      • examples/access-log, config, json, k-nucleotide (3), report (2), tally
    • Tests in tests/compiler/tests/:
      • a_file_or_stdin_read_is_untrusted_unless_marked (6)
      • the_command_line_is_untrusted_unless_marked (4)
      • trusted_markers_are_recorded_in_the_ledger (4)
      • a_line_read_takes_no_trusted_option (2)
      • a_connection_read_after_a_guard_is_proved (1)
      • an_environment_variable_is_the_operators_unless_a_host_fills_it (1)

      Each is rewritten to write a nikaia.toml with [trust] in its tmp project, or renamed where its name says “marked”. New expected output only where the decision changes the message; never a loosened one.

  7. Text.
    • The website/safe/ pages (index.html, outside-data.html).
    • The other ADR mentions, each a “Changed by ADR-trust-v1” note, not a rewrite: ADR-010, 016, 017, 019, 108, 133, 316, 396, 397, 398.
    • Part III (30-nikaia-tooling) is already updated in 671236870.
  8. New tests (.nika with .stdout/.stderr):
    • [trust] stdin = true makes a claim on stdin checked, not NK1202.
    • files = ["data"] trusts a read under Root::Dir("data/x") but not under Anywhere nor Root::Dir("other").
    • files = ["../x"], files = false and an unknown key are each a manifest error.
    • trusted: true on a call is NK1109, with the help naming stdin = true.
    • A dependency’s [trust] does not reach the caller.
    • The ledger row names the key.

Done when

nikaia run of a program whose manifest has [trust] stdin = true and that claims a property of a stdin line builds without NK1202. The same call written as io::read_to_string(trusted: true) is refused with NK1109, whose help names stdin = true. grep -rn "trusted: *true" --include=*.nika finds no use outside the refusal test. The commit that finishes step 6 says Fixes #N. The report gives a Found: line per finding.


Generated by Claude Code

Back to Open Issues