Issue #2302: The compiler, scripts and packages pass the raw path sink check by proof, not trusted:

Open and answer this issue on GitHub.

blocked, safety · opened 2026-11-19 · updated 2026-11-21 · 12 comments

What

The compiler (crates/nikaia-std/src/compiler/*.nika), scripts/*.nika and examples/ / packages/ pass the raw path sink check (NK1308, brought to develop behind warn by #2303) by proof, not by trusted: (ADR-raw-sinks-1 D13, D14, D15, D16; owner’s decision on #2242, 2026-11-19): each site is looked at alone. A name from fs::read_dir is opened under root.join(dir); a name from outside that must be one component is guarded with path::is_component; a relative path that must stay below a root with path::is_below; a temporary directory comes from fs::scratch(). What is the tool’s job (nikaia build FILE opens the file it is given) is said once in the manifest by a D15 line with a comment, e.g. untrusted-paths-read = ["args"], never trusted: at a site.

Part of #2242 Needs #2300 Needs #2303

Today: the NK1308 check of the local ref wip/issue-2242 (0254f60c3) reports 41 sites in the compiler, 52 in scripts/, 14 in examples/ and packages/. At 57379dba7 grep -c 'Root::Anywhere' gives 203 in the compiler, 243 in scripts/, 18 in examples/ and packages/ (most are not reached by data from outside and stay unreported); mktemp 0 in the compiler, 11 in scripts/. Largest groups: scripts/drive.nika 20, scripts/agent.nika 11; in the compiler project_drive.nika (project_run_dir_tests, a read_dir name opened under Anywhere).

The read_dir shape:

for name in fs::read_dir(dir, fs::Root::Anywhere) {
    let src = fs::read_to_string(f"{dir}/{name}", fs::Root::Anywhere)
}

becomes

let tests = root.join(dir)
for name in fs::read_dir(".", tests) {
    let src = fs::read_to_string(name, tests)
}

Governing decision

ADR-raw-sinks-1 D13, D14, D15, D16.2 (nikaia’s own D15 line with a comment), D16.3 (what no form covers is reported, not written around).

Done when

The NK1308 check of wip/issue-2242, run over the compiler, scripts/ and examples/ / packages/, reports no site that neither a proof (join, guard, scratch) nor a commented D15 line in the manifest covers; no trusted: is added anywhere; the D15 lines of nikaia’s manifest (and of each package that needs one) carry a comment naming why; the builds and the tests the changed files touch pass; the last step’s commit carries Fixes #THIS. A Found: line per finding, one per site no form covers.

To build

  1. The D15 line for nikaia in its manifest (the builder finds which one nikaia reads its settings from; nikaia.toml at the top), with a comment: the paths the tool opens come from its command line. Test tests/compiler/tests/a_manifest_allows_untrusted_paths_from_args_for_reading.nika: a package with untrusted-paths-read = ["args"] reads a file named by cli::args and builds; the same with stdin as the source is still reported (needs the NK1308 check: the builder may leave this test to the check’s issue and say so in the report).
  2. The compiler, site by site, one commit per file group (project_drive.nika, then the rest): join for read_dir names, guards where a component is meant, the D15 line where the tool opens what it is given. Each change built with nikaia lower-std and the touched tests run.
  3. scripts/: drive.nika, agent.nika and the rest; mktemp to fs::scratch() where a scratch root fits, else fs::scratch().path() (a method on its value, #2336); the script’s own D15 line if it is a package with a manifest. One commit per script or group.
  4. examples/ and packages/: the 14 sites; a package that reads a path from its user gets its own D15 line with a comment.
  5. The report lists each site no proof and no D15 line covers as Found: with file, line and what it would need.

Files and limits

crates/nikaia-std/src/compiler/*.nika and their lowered files, scripts/*.nika, examples/**, packages/**, the manifests that get a D15 line, the one test above. Not tests/compiler/tests/ (the test migration issue), not std (the std issue), not the check itself (project_check_let_raw_sinks_through, prover_raw_sink). No new Rust. Each D15 line is as narrow as the site needs: -read before -anywhere, a source list before true.

Ruled out


Generated by Claude Code

Comments

keywan-ghadami, 2026-11-19

Driver: not queued, this issue waits for #2300, which is still open (#1819). Set ready again when it is closed.


Generated by Claude Code

keywan-ghadami, 2026-11-19

Brief queued: issue-2302


agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —

Issue #2302

Your work order is issue #2302, inlined below with its comments. There is no brief written around it: plan your own steps from its To build list, build them in order, commit after each finished step, and end when its Done when holds (or at the limits of builder.md, reporting what is left). The facts in your prompt are Core of docs/builder-facts.md; more on a topic: nikaia run scripts/syntax.nika -- KEYWORD, a probe: nikaia run scripts/probe.nika -- SNIPPET.

Measure the issue against docs/issues.md while you work: what it lacked, what was wrong in it. That answer goes into the report’s Issue: field. A finding, a changed plan or a finished item also goes into the issue as a comment (gh api repos/Nikaia-Foundation/Nikaia/issues/2302/comments -F body=@file, ending with the Claude Code footer), rule I13.

Rules (CLAUDE.md; shared checkout)

Report (at most 15 lines, to exactly /home/user/Nikaia/docs/briefs/safety/issue-2302.md.report.md)

Fields: Result, Files, Commit, Body (optional), Fixes, Pushed, Tests, Gate, Deviation, Found, Needs, Changelog, Issue, Owner (a question for the owner), Comment (#N <text>, what to say on another issue; the driver posts it, one line each), Friction, Disk freed, and last Attribution: with your commit trailer lines below it.


Generated by Claude Code

keywan-ghadami, 2026-11-19

Run: issue-2302, Result: blocked

Tokens: input 18, cache read 270913, cache write 24978, output 4042 Cost: 0.36 USD, time 0 min 51 s, turns 9

Report

Result: blocked Files: none Commit: none Body: none Pushed: none Tests: probe only, nothing built; target/fast/nikaia current with HEAD ec0d49b74 Gate: green Deviation: none Found: the D15 [allow] keys with source lists are not built on develop nor on wip/issue-2242: package p with nikaia.toml [package] name = "p" version = "0.1.0" and [allow] untrusted-paths-read = ["args"], src/main.nika use std::fs use std::cli fn main() throws { for a in cli::args() { let r = fs::Root::Anywhere; println(fs::read_to_string(a, r)) } }, target/fast/nikaia check src/main.nika prints [allow] has no key called untrusted-paths-read. The keys are: untrusted-shell, untrusted-sql, untrusted-markup, untrusted-paths-anywhere.; ADR-raw-sinks-1 D15 says it is accepted with a source list; traced: allow_keys in crates/nikaia-std/src/compiler/manifest.nika:46 lists only the four keys and allow holds only keys set to true (no source lists), same at wip/issue-2242 Found: the NK1308 check (project_check_let_raw_sinks_through) is not on develop, only on the unmerged wip/issue-2242 (0254f60c3, "not to merge"); #2302's Done when and steps 1-4 judge each site by that check, so no site can be shown covered on develop Needs: #2242 Changelog: none Issue: broke I3: names only Needs #2300 (closed by 7945a9632) but also depends on the D15 manifest keys and the NK1308 check landing on develop, neither of which has an issue named as a dependency; the issue says the check is "built after this" yet its Done when needs it Owner: none Comment: #2242 #2302 (paths by proof in the compiler, scripts and packages) waits for the D15 keys (untrusted-paths-read/-write/-remove with source lists, manifest.nika allow_keys`) and the NK1308 check on develop; neither is built, so #2302 is blocked on them Friction: none Disk freed: none Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDvbkNUUMs8HdjJ8ixV

Debrief

  1. Most cost: not much. It took about 8 tool calls, and most went to finding out whether the NK1308 check and the D15 keys exist. The issue says the check is “built after this” but then judges Done when by it, so I had to look at both develop and wip/issue-2242.
  2. Looked up: the D11–D16 text of ADR-raw-sinks-1, and that allow_keys sits at manifest.nika:46. I also had to find out whether fs::scratch and Root::join had landed (#2300’s commit).
  3. Checks: the dependency git log (needed), the manifest probe (decisive) and the key list on the wip branch (needed). The first nikaia check call without a FILE was wasted. I skipped building, since the binary was current with HEAD.
  4. One change: the driver should check that every form the issue’s To build uses (here, the manifest key) is accepted on develop before it queues the issue, or the issue should carry that probe as its first line.
  5. What the issue lacked:
    • broke I3: the D15 keys and the NK1308 check are dependencies, but they are not named as Needs #N. Only #2300 is named.
    • wrong I3: “Needs #2300” was the only gate it named, and once #2300 closed it read as ready although it was not.
    • rules-gap: no rule requires that a gate an issue’s Done when uses (here the NK1308 check) is on develop before the issue is ready.
  6. Traps:
    • Fact: Core | nikaia check needs the FILE argument even inside a package directory (nikaia check src/main.nika); bare "nikaia check" is a clap error.
    • Fact: Packages | [allow] accepts only untrusted-shell, untrusted-sql, untrusted-markup, untrusted-paths-anywhere, each as true; the D15 keys (untrusted-paths-read/-write/-remove with source lists) are not built yet (manifest.nika allow_keys).

Generated by Claude Code

keywan-ghadami, 2026-11-19

The report of the run of issue-2302 (#2302) judged this issue against docs/issues.md; the author fixes the issue by the rule it names (How a run judges its issue):


Generated by Claude Code

keywan-ghadami, 2026-11-19

Driver: not queued, this issue waits for #2242, #2330, #2331, which is still open (#1819). Set ready again when it is closed.


Generated by Claude Code

keywan-ghadami, 2026-11-20

Supervisor: ready again. #2242 is the umbrella this issue is part of, not a need. #2330 and #2331 were built as part of #2303. #2300 and #2303 are closed. Every site is fixed by proof, never by trusted: (owner, 2026-11-20). A site no proof fits is reported as blocked.


Generated by Claude Code

keywan-ghadami, 2026-11-20

Run: issue-2302, ESCALATE claude exited with code 1

Tokens: input 248, cache read 7852489, cache write 181219, output 65005 Cost: 4.54 USD, time 67 min 16 s, turns 125

Report

(none)

Debrief

Two commits were made, both local: 3c4f0b2e (the D15 lines for inventory and the solver rod) and d621b0a9 (project_drive.nika, down from 28 NK1308 sites to 11). The project_tests.nika change is uncommitted and untested, and the final report at docs/briefs/safety/issue-2302.md.report.md was never written.

  1. What cost the most: listing the NK1308 sites. A nikaia check of project_drive.nika takes about 7.5 minutes, lower-std prints no NK1308, and each lower-std/build cycle took about 10 minutes. I also guessed the nikaia test filter syntax wrong once (it is --filter), lost a turn to a shell cat > that hung, and missed that other files call project_tests_is_file until the cycle refused the build.
  2. What I looked up that the brief could have handed me:
    • ADR-raw-sinks-1 D11–D16.
    • That a Dir root must exist before use.
    • That Root::join and a guard carried through a struct field are not followed by the check.
    • That fs::copy takes one root.
    • That a nikaia.toml in scripts/ breaks nikaia run.
    • That project_check_raw_sinks_in_std passes an empty allow list.
  3. Checks:
    • Useful: the cycle, the splice and rustc-store test programs, the inventory build (the publishable copy), pre-push, and the per-file check.
    • Wasted: test --std --filter project_drive, which matched 0 tests, and a cycle spent on a helper whose callers I had not grepped.
  4. One change to the brief: list the NK1308 sites per file, with line numbers, in the brief, so the builder does not need a 7-minute check per file to find them.
  5. What the issue lacked:
    • wrong I3: it assumes nikaia and the single-file scripts can carry a D15 manifest line. Neither has a home (no nikaia.toml, and a manifest in scripts/ turns the directory into a project).
    • wrong I4: the site counts are stale (scripts went from 52 to about 210).
    • broke I6: where nikaia’s own D15 line lives is not decided yet, so the issue cannot be built as written.
    • knowledge: Core | NK1308 only shows from nikaia check FILE, never from lower-std.
  6. Facts for the next builder:
    • Fact: Core | a fs::Root::Dir whose directory does not exist refuses every name, so create the directory before building the root on it.
    • Fact: Lowering | changing a compiler helper's signature needs a grep of every compiler .nika first; callers across files only show up in lower-std.
    • Fact: Core | fs::copy takes one root, so a copy across two Dir roots is a read and a write, which drops the file's mode bits.

Generated by Claude Code

keywan-ghadami, 2026-11-20

Run: issue-2302, refused: docs/briefs/safety/ESCALATE exists

Tokens: input 248, cache read 7852489, cache write 181219, output 65005 Cost: 0.00 USD, time 67 min 16 s, turns 125

Report

(none)

Debrief

Two commits were made, both local: 3c4f0b2e (the D15 lines for inventory and the solver rod) and d621b0a9 (project_drive.nika, down from 28 NK1308 sites to 11). The project_tests.nika change is uncommitted and untested, and the final report at docs/briefs/safety/issue-2302.md.report.md was never written.

  1. What cost the most: listing the NK1308 sites. A nikaia check of project_drive.nika takes about 7.5 minutes, lower-std prints no NK1308, and each lower-std/build cycle took about 10 minutes. I also guessed the nikaia test filter syntax wrong once (it is --filter), lost a turn to a shell cat > that hung, and missed that other files call project_tests_is_file until the cycle refused the build.
  2. What I looked up that the brief could have handed me:
    • ADR-raw-sinks-1 D11–D16.
    • That a Dir root must exist before use.
    • That Root::join and a guard carried through a struct field are not followed by the check.
    • That fs::copy takes one root.
    • That a nikaia.toml in scripts/ breaks nikaia run.
    • That project_check_raw_sinks_in_std passes an empty allow list.
  3. Checks:
    • Useful: the cycle, the splice and rustc-store test programs, the inventory build (the publishable copy), pre-push, and the per-file check.
    • Wasted: test --std --filter project_drive, which matched 0 tests, and a cycle spent on a helper whose callers I had not grepped.
  4. One change to the brief: list the NK1308 sites per file, with line numbers, in the brief, so the builder does not need a 7-minute check per file to find them.
  5. What the issue lacked:
    • wrong I3: it assumes nikaia and the single-file scripts can carry a D15 manifest line. Neither has a home (no nikaia.toml, and a manifest in scripts/ turns the directory into a project).
    • wrong I4: the site counts are stale (scripts went from 52 to about 210).
    • broke I6: where nikaia’s own D15 line lives is not decided yet, so the issue cannot be built as written.
    • knowledge: Core | NK1308 only shows from nikaia check FILE, never from lower-std.
  6. Facts for the next builder:
    • Fact: Core | a fs::Root::Dir whose directory does not exist refuses every name, so create the directory before building the root on it.
    • Fact: Lowering | changing a compiler helper's signature needs a grep of every compiler .nika first; callers across files only show up in lower-std.
    • Fact: Core | fs::copy takes one root, so a copy across two Dir roots is a read and a write, which drops the file's mode bits.

Generated by Claude Code

keywan-ghadami, 2026-11-20

Run: issue-2302, Result: partial

Tokens: input 280, cache read 9406561, cache write 195558, output 71985 Cost: 5.10 USD, time 22 min 59 s, turns 141

Report

Result: partial Pushed: local 3c4f0b2e (inventory and rod D15 lines), d621b0a9 (project_drive.nika, 28 NK1308 sites to 11), 06001c01 (project_tests.nika, 35 to 0) Body: Names are opened under the directory they were read from (D13), and the rustc store key is guarded with path::is_component (D14). fs::copy across two Dir roots became read+write, so mode bits are dropped (spliced sources, test .in inputs). Left: comptime_bundle, project_members, describe, proofs_answers, sysroot_cache, lsp, sources, modules; scripts/ (about 210 sites); packages/yaml tests. Tests: splice, rustc store and a_published test programs, both settings, 11/11; examples/report output tests 2/2; inventory package tests 2/2; publishable copy checked by hand (stale file removed); lower-std fixpoint; pre-push green Gate: green Deviation: step 1’s test already exists as a_manifest_allows_untrusted_paths_per_operation_and_source (#2303), so no new test was added. nikaia has no D15 line: there is no nikaia.toml to put it in. Found: no NK1308 for a Dir root taken from outside: let dir = cli::args().nth(1) ?? "."; let at = fs::Root::Dir(dir); println(fs::read_to_string("x", at)) gives no warning under nikaia check, but ADR-raw-sinks-1 D11 says such a root is itself a sink; suspected cause in prover_walk.nika prover_raw_sink (root_part outside test) Found: no NK1308 for an unguarded Root::join: with key from fs::read, fs::read(... , fs::Root::Dir(cache).join(key)) gives no warning, but D14 asks for an is_component guard; suspected cause in prover_walk.nika, Root::join not walked as a path part Found: where nikaia’s own D15 line lives, no decision yet: no nikaia.toml exists, and project_check_raw_sinks_in_std (project_check.nika:333) passes allow=[]. project_drive’s paths from Cargo dep-info and the compiler’s record (lines 685-728, 1644) and rustc’s –out-dir (1664, 1682, 1685) need untrusted-paths-read=[“file”] and untrusted-paths-write=[“args”] Found: how single-file scripts/.nika state D15, no decision yet: a nikaia.toml in scripts/ makes nikaia run scripts/x.nika fail with “not the entry point of the project”, and their roots come from cli::args, which no proof covers under D11 Needs: supervisor decision Changelog: none Issue: wrong I3: the issue assumes a nikaia.toml for nikaia and manifests for the scripts, and neither can exist; wrong I4: the scripts’ site count is about 210, not 52 Friction: every nikaia run scripts/.nika now prints dozens of NK1308 warnings; lower-std prints none, so each file’s sites take a 7-minute nikaia check FILE to list Disk freed: about 5.9G (this run’s rust-library-splice/-user cache entries); target/nikaia-project-tests 510M, / 17G free Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDvbkNUUMs8HdjJ8ixV

Debrief

Three commits landed locally: the D15 lines for inventory and the rod (3c4f0b2e), project_drive.nika from 28 NK1308 sites to 11 (d621b0a9), and project_tests.nika from 35 to 0 (06001c01); the report is written. Eight compiler files, scripts/ and the yaml package tests are still open.

Two flaws in my report: the second Found line (the Root::join hole) gives a retyped snippet, not the probe copied whole, so the bug lane must re-run it. I also wrote the Pushed: line by hand with all three shas; the commit script normally writes it.

  1. Most cost: listing NK1308 sites (lower-std shows none; nikaia check FILE takes about 7 minutes per file) and four build cycles of about 10 minutes each. One cycle was wasted because I changed a shared helper’s signature without first grepping its callers in other files.
  2. Looked up that the brief could have handed me:
    • ADR-raw-sinks-1 D11–D16.
    • The prover’s rule that only Root forms and guarded joins are proved (prover_walk.nika ~2740).
    • That a Dir root must exist before use, and that fs::copy takes one root.
    • That project_check_raw_sinks_in_std passes allow=[].
    • That a manifest in scripts/ breaks nikaia run.
    • The --filter flag of nikaia test.
  3. Checks:
    • Useful: the cycle, nikaia check per file, the splice and rustc test programs (both settings), the output tests of examples/report, the inventory build, pre-push.
    • Wasted: test --std --filter project_drive, which matched 0 tests, and the cycle that hit the callers’ NK1101.
  4. One change: give the brief a per-file list of NK1308 sites from a reference check, plus the rule “grep every caller before changing a compiler helper’s signature”.
  5. What the issue lacked:
    • wrong I3: it assumes a nikaia.toml for nikaia and manifests for single-file scripts; neither can exist.
    • wrong I4: the site count for scripts/ is about 210, not 52.
    • broke I6: where nikaia’s own D15 line lives is a decision not taken yet, and the issue was filed ready.
    • knowledge: Core | NK1308 shows only under nikaia check FILE, never in lower-std output.
  6. Traps for the next builder:
    • Fact: Core | a fs::Root::Dir on a directory that does not exist refuses every name, so create the directory first.
    • Fact: Lowering | a compiler helper's callers in other .nika files show up only as NK1101 in lower-std, so grep them before changing a signature.
    • Fact: Core | fs::copy takes one root, so copying across two Dir roots is fs::read plus fs::write, which drops mode bits.
    • Fact: Core | running the rust-library-splice test programs adds about 0.8 GB of cache per entry, so remove your own entries at the end.

Generated by Claude Code

keywan-ghadami, 2026-11-20

Partly built and pushed in 0.0.1506 (project_drive.nika 28 → 11 NK1308 sites, project_tests.nika 35 → 0, inventory and rod D15 lines), all by proof, no trusted:.

Blocked on:

Left: comptime_bundle, project_members, describe, proofs_answers, sysroot_cache, lsp, sources, modules; scripts/ (about 210 sites); packages/yaml tests.


Generated by Claude Code

keywan-ghadami, 2026-11-21

Updated count for scripts/ and the split by helper

Agreed between the bug lane and the safety lane, owner approved 2026-11-21, measured on develop 5ed0fac18 with raw-sinks = "warn".

The count of 52 sites in scripts/ is out of date. Distinct sink sites today:

Script Sink sites Reports
drive.nika 111 313
agent.nika 36  
batch.nika 6  
cycle.nika 5  
issue-check.nika 1 1

What the reports in drive.nika concern: every one is an fs call under fs::Root::Anywhere (exists, read_to_string, write, read_dir). None concerns the program of process::run, so these are real findings, not false positives of the check.

Where the untrusted values come from:

The same report repeats through helpers. For example:

Split:

issue-check.nika is handled by “The driver queues an issue unchecked when scripts/issue-check.nika fails to run” (#2466): the body comes over stdin, so there is no path. Whether a file name given directly stays allowed is the open decision “How single-file scripts/*.nika satisfy the raw path sink check without a manifest” (#2443).

Order:

  1. #2466
  2. this issue, for scripts/
  3. “The raw path sink check (NK1308) is switched from warn to deny” (#2332)

Generated by Claude Code

keywan-ghadami, 2026-11-21

Split for scripts/ (445 NK1308 reports at about 211 sink lines in 21 scripts; 10 scripts already clean). Every part passes by proof (root fs::Root::Dir("."), fs::scratch(), guard at arrival): no trusted:, no [allow], no nikaia.toml in scripts/.

  1. #2470 drive.nika: generic helpers under Dir("."), scratch for mktemp, joined read_dir names
  2. #2475 drive.nika: lane directory guarded where it arrives (needs #2470)
  3. #2471 agent.nika (without the --claude program, which stays with #2443)
  4. #2472 batch, cycle, commit, ledgers
  5. #2473 the 15 small scripts; pre-push and java_binding name their binary by a literal relative path, CI drops --exe

Defect found on the way: #2469 (a guard ending in process::exit does not prove the name). Order: after #2466, as planned by the bug lane.


Generated by Claude Code

Back to Open Issues