Issue #2524: Under raw-sinks = “warn” a breached raw-sink precondition throws at run time (ADR-raw-sinks-1 D7)

Open and answer this issue on GitHub.

wip, safety · opened 2026-11-21 · updated 2026-11-22 · 12 comments

Part of #1253

What it is

Under raw-sinks = "warn" a raw sink whose precondition the compiler did not prove still builds; ADR-raw-sinks-1 D7 says the precondition is then checked where the call is reached and a breach throws the sink’s own error: io::IoError::Outside for a path, checked as under Dir("."); html::Raw and db::raw are checked where the value is made (decided on #2650 and #2705) and their error enters the function’s throw set before the prover runs (decided on #2704; ADR text in b7a0dd43d). Step 8 of the original list; its process::shell case is dropped with D9 (#2197). Where the check lives is the builder’s choice within CLAUDE.md’s rule on new Rust; a step that cannot be done without new Rust stops as that rule says.

To build

  1. A path under fs::Root::Anywhere reached under --raw-sinks=warn: done in 58c6f6f61.
  2. html::Raw and db::raw under --raw-sinks=warn:
    • an unproved outside part that fails html::is_plain at an html::Raw(...) site throws html::HtmlError::NotPlain(part) (declared in std::html) where the value is made; templates and html::Render stay as they are;
    • an unproved outside part that fails db::is_identifier at a db::raw(...) site throws db::NotIdentifier { part } from that site; the db package declares it with impl Error and fn message, as NullInField is declared; Raw gets no breach field and Raw::execute stays as it is;
    • in a function that does not throw, neither site is lowered by warn; it stays NK1308;
    • the throw-set inference counts every such site whose part is not a literal or a constant as throwing the sink’s error, syntactically, before the prover; a proof removes only the runtime check, not the set entry. Under error nothing changes. Tests beside the first: html::Raw throwing, db::raw throwing, and a non-throwing function staying NK1308.

Done when

Under --raw-sinks=warn tests show a markup part with < at html::Raw and a part a; drop at db::raw each throwing where the value is made, and a non-throwing function’s site staying NK1308; the commit of the last item carries Fixes #2524, a Found: line per finding.

Split from #1253 by Claude Code

Comments

keywan-ghadami, 2026-11-21

Brief queued: issue-2524


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

Issue #2524

Your work order is issue #2524, 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/2524/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-2524.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-21

Run: issue-2524, Result: blocked

Tokens: input 76, cache read 2203229, cache write 74448, output 16699 Cost: 1.41 USD, time 3 min 39 s, turns 38

Report

Result: blocked Files: none Commit: none Body: Nothing committed. Item 1 (a path under fs::Root::Anywhere) has a way to build: the claim prover’s NK1308 path site, keyed by the sink call’s node, carried into CheckFacts (ProverWalk -> prove.rs Proved -> check/host.rs -> check_walked_proved; the two Rust adapters forward one field, as outside does for ADR-396 D5), and the emitter turns that call’s Anywhere root into Dir(“.”) (a runtime/paths.nika helper), so the call throws io::IoError::Outside. Not started, because item 2 needs a decision first and the brief’s rule ends the run on a kind-2 gap. Pushed: none Tests: probes only, target/fast/nikaia at HEAD 96d1ce0d7; nothing built, no tests run Gate: green Deviation: none Found: html::Raw under --raw-sinks=warn has no call that throws where its markup is written, so ADR-raw-sinks-1 D7 (“html::Raw checks where its markup is written, a call that throws”) cannot be built, no decision yet: use std::html / use std::cli / fn page(markup: html::Raw) -> String { return dsl html { <div>{markup}</div> } eod } / fn main() throws { let mut name: String = "<b>"; for a in cli::args() { name = a }; let raw = html::Raw(f"<p>{name}</p>"); println(page(raw)) }, run as nikaia run --raw-sinks=warn src/main.nika -- '<script>' in a package p with no dependencies, gives warning NK1308 and then <div><p><script></p></div>. D7 wants a throw there. The dsl html template returns String without throws (emit_core_leaves.nika emit_core_template_segments writes __html.push_str(&html::Render::render(..)), and html.rs Render::render is infallible), and std::html declares no error type. Open questions: does the template throw, does the html::Raw construction throw at the site, or does the value carry the breach, and with which error? Needs: supervisor decision Changelog: none Issue: broke I5: the issue says a breach at html::Raw throws “where it is written”, but no throwing write and no html error type exist today, and it does not say this is a gap to decide first; broke I7: “Today Root::Anywhere resolves nothing at run time” is right (probe: nikaia run --raw-sinks=warn of fs::read(name, fs::Root::Anywhere) with name ../x from cli::args prints NK1308 then read 3), but the issue does not say how the prover’s unproved site reaches the emitter. The claim prover’s NK1308 sites are not in CheckFacts today, so a check at the call needs that channel, and that channel touches the Rust adapters prove.rs and check/host.rs Owner: none Comment: #2524 Run blocked on item 2: D7 says html::Raw “checks where its markup is written, a call that throws”, but the dsl html template returns String without throws and std::html has no error type, so a decision is needed (the template throws, or the html::Raw construction throws at an unproved site, or the value carries the breach, and with which error). Item 1 could be split out and built now: carry the claim prover’s NK1308 path sites (by the call’s node) into CheckFacts and have the emitter confine that call’s Anywhere root to Dir(“.”), which throws io::IoError::Outside. That forwards one field through prove.rs Proved and check/host.rs, which is Rust plumbing to name for the Rust inventory issue (#557). Friction: none Disk freed: none; target/nikaia-project-tests 1.3G, / 14G free of 252G, no new cache entry over 100 MB Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDvbkNUUMs8HdjJ8ixV

Debrief

  1. Most cost: working out how the prover reaches the code generator. I read the escaped_sinks, proven_calls and facts.claims paths before finding that NK1308 sites never land in CheckFacts. That took about 15 turns.
  2. Looked up: the text of ADR-raw-sinks-1 D7. Also that dsl html returns a String that cannot throw, the path NK1308 takes (prover_walk.nika raw_sink_finding → prove.rs Proved → check_walked_proved), and that the code generator’s proof inputs come in through emit_contracts.nika.
  3. Checks: four probes, of which two were needed (path and html). The other two failed on my own syntax: catch e {, fs::read_text, and an untyped let mut name. No builds or tests were run, and none were wasted.
  4. One change: the brief should say that each To build item that names a run-time throw must name the existing throwing call it relies on. Then the html gap shows up before any reading.
  5. What the issue lacked:
    • broke I5: it says html::Raw throws “where it is written”, but no such throwing call or html error type exists, and the issue does not mark this as a decision still to make.
    • rules-gap: it does not say how an unproved sink site reaches the code generator, which needs a field forwarded through the Rust adapters prove.rs and check/host.rs.
    • knowledge: Core std::fs has fs::read(path, root) returning Bytes, and no fs::read_text.
  6. Fact: Core A dsl html template returns String and never throws, and html::Render::render cannot fail, so no run-time check can throw where html::Raw markup is written.
    Fact: Core The claim prover’s NK1308 findings (prover_walk.nika) reach only the diagnostics, not CheckFacts, so the code generator cannot tell an unproved sink call from a proved one.
  7. Fact: Raw sinks Key files: prover_walk.nika raw_sink_part / raw_sink_finding (about lines 2913-3067), check_walked.nika check_walked_proved, prove.rs finished(), emit_contracts.nika (the code generator’s proof inputs), runtime/paths.nika (Root helpers), html.rs.
    Fact: Raw sinks Probe, 2026-11-21, HEAD 96d1ce0d7: fs::read(name, fs::Root::Anywhere), with name from cli::args set to ../x, under --raw-sinks=warn prints NK1308 and then reads the file (read 3).

Generated by Claude Code

keywan-ghadami, 2026-11-21

From the report of the run of issue-2524 (#2524):

Run blocked on item 2: D7 says html::Raw “checks where its markup is written, a call that throws”, but the dsl html template returns String without throws and std::html has no error type, so a decision is needed (the template throws, or the html::Raw construction throws at an unproved site, or the value carries the breach, and with which error). Item 1 could be split out and built now: carry the claim prover’s NK1308 path sites (by the call’s node) into CheckFacts and have the emitter confine that call’s Anywhere root to Dir(“.”), which throws io::IoError::Outside. That forwards one field through prove.rs Proved and check/host.rs, which is Rust plumbing to name for the Rust inventory issue (#557).


Generated by Claude Code

keywan-ghadami, 2026-11-21

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


Generated by Claude Code

keywan-ghadami, 2026-11-21

Driver: #2524 is not queued, its form misses what a builder needs (nikaia run scripts/issue-check.nika -- 2524, docs/issues.md, #2003):

Label swapped from ready to decision: add what is missing (a Needs #M line for an issue it waits for, or Part of #M), then set ready again.


Generated by Claude Code

keywan-ghadami, 2026-11-22

The decision this waited for is made: html::Raw under warn is checked where it is made and throws html::HtmlError::NotPlain (ADR-raw-sinks-1 D7, decided on html::Raw under warn (#2650), now closed). The form check passes; #557 is only where the report lists the Rust plumbing, not a dependency. Label ready.


Generated by Claude Code

keywan-ghadami, 2026-11-22

Run: issue-2524, Result: blocked

Tokens: input 300, cache read 10707267, cache write 256409, output 71759 Cost: 5.98 USD, time 59 min 45 s, turns 150

Report

Result: blocked Pushed: none (nothing committed on develop; item 1 built and saved as branch wip/issue-2524, de093970, made with a private index, the checkout untouched) Tests: wip: new a_path_from_outside_under_anywhere_is_checked_under_warn prints Outside/false/false (old binary eae0ac6ae543 printed false/false: failed there); 65 Anywhere/raw-sink tests: 62 pass, a_branch_value_is_outside_by_its_branch and a_guarded_join_carries_its_proof_to_a_binding re-blessed to D7 (absolute loose now throws Outside; “” under Dir(“.”) exists), drive_relower red (passes on the old binary) Gate: green Deviation: wip checks only a call that hands the outside path to Anywhere itself, not one reaching it through a function (raw_sink_through), not a root from outside under Dir(dir), and std/sysroot builds get an empty set; the NK1308 warning does not yet say the call is checked at run time Found: under the default raw-sinks = “warn”, D7’s check (wip/issue-2524) makes scripts/drive.nika throw io::IoError::Outside at run time: fs::exists(exe, fs::Root::Anywhere) (drive.nika:1201, exe an absolute worktree path from process output) and fs::exists(f"{git_dir}/MERGE_HEAD", fs::Root::Anywhere) (1575) leave .; drive_relower prints exit ok: false at case “clean, an example, merge build” instead of the blessed run. nikaia check counts direct Anywhere NK1308 in drive.nika 88, analysis_cost.nika 3, issue-check.nika 1, agent.nika 1. A script run with nikaia run FILE has no manifest, so no [allow] untrusted-paths-anywhere can let these through (ADR-raw-sinks-1 D4 names only the manifest); no decision yet Needs: supervisor decision: how a manifest-less script (scripts/*.nika) allows a path from outside under Anywhere (a manifest for scripts/, an in-file allow, or the scripts moved to roots first) before D7’s check can land; item 2 (html::Raw, db::Raw::execute) not started Changelog: none (nothing landed) Issue: ok I1-I13, but the issue does not name that the repository’s own scripts run under warn with direct Anywhere sinks, so D7 breaks the driver Owner: none Comment: #2524 Item 1 is built on branch wip/issue-2524 (de093970): prover records RawPathCheck per call (prover_walk), project_check_raw_path_checks keeps the unallowed ones under warn, emit_core_argument wraps the root in runtime::root_confined (Anywhere -> Dir(“.”)). It is held back because scripts/drive.nika (88 direct Anywhere NK1308) would throw at run time and drive_relower goes red. Rust plumbing for #557 (ADR-platform-layer-v1): prove.rs Proved.raw_paths, check/host.rs, project.rs (facts always requested, raw_path_checks per unit), modules.rs Program.raw_path_checks, emit/mod.rs parameter, comptime_run.rs and grammar_run.rs empty maps Friction: kept.helps.push(walk.findings[k].help ?? "") in prover_walk.nika passed lower-std but rustc refused the lowered code (E0507, move out of a shared reference, Option), and the same shape in a plain program compiles; `for one in walk.findings[before..] { ... (one.help ?? "").clone() }` lowers right; one build cycle lost Disk freed: none removed (15G free of 252G); target/nikaia-project-tests 1.6G; new entries over 100 MB: rust-library-splice/ae44960b 841 MB, rust-library-user/ae44960b 757 MB; target/fast/nikaia rebuilt from HEAD after the checkout was restored Attribution: Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UVxJDvbkNUUMs8HdjJ8ixV

Debrief

  1. What cost the most: tracing the raw-path facts across six layers, in Nikaia and Rust: prover walk → Proved → CheckWalkedProved → CheckFacts → project.rs → Program → emitter state. After that came a build cycle lost to a lowered E0507 that lower-std had accepted. Worst of all, I found that the change breaks scripts/drive.nika only after building everything, through drive_relower.
  2. What I looked up that the brief could have handed me:
    • How the facts reach the emitter: project.rs asked for CheckFacts only under keep || lsp.
    • That the effective default of raw-sinks is warn, while ADR D3 says error.
    • That scripts run with nikaia run have no manifest and so no [allow].
    • That node keys are stable from check to emit.
  3. Checks run:
    • Useful: lower-std, the build, the new test, and the 65 Anywhere and raw-sink tests filtered by name, which showed the regressions.
    • Partly wasted: the full build before counting the direct Anywhere NK1308 sites in scripts/. A nikaia check scripts/*.nika grep up front would have shown the driver break before any code was written.
    • Not run, because nothing was committed: clippy, fmt and pre-push.
  4. One change that would save the most: builder.md should say that a change to run-time behaviour under a default setting first counts the affected sites in the repo’s own scripts/*.nika and the tests, before the first edit.
  5. What the issue lacked:
    • broke I5: the issue does not name the consumers its change breaks. The driver itself makes 88 direct Anywhere calls that throw under D7.
    • rules-gap: how a manifest-less script allows a raw sink is undecided, and no rule asks an issue to check that before it says ready.
    • knowledge: Core | project.rs requests CheckFacts only under keep||lsp; a per-unit fact the emitter needs must make the request unconditional.
  6. Traps the next builder will meet:
    • Fact: Lowering | vec[k].field ?? “” with an Option[String] field can pass lower-std and fail rustc E0507; iterate the slice and write (one.field ?? “”).clone().
    • Fact: Core | The effective raw-sinks default is "warn" (stderr says "the default"), and scripts/*.nika run under it with no manifest to allow anything.
  7. For the next builder in this area:
    • Fact: Raw sinks | D7 item 1 is built on wip/issue-2524 (de093970, 2026-11-22): RawPathCheck in prover_claims.nika, recorded in prover_walk's fs branch, filtered by project_check_raw_path_checks, emitted by emit_core_argument as runtime::root_confined.
    • Fact: Raw sinks | On wip/issue-2524 (2026-11-22), drive_relower fails ("exit ok: false" at "clean, an example, merge build"); direct Anywhere NK1308: drive.nika 88, analysis_cost.nika 3, issue-check.nika 1, agent.nika 1.

Generated by Claude Code

keywan-ghadami, 2026-11-22

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


Generated by Claude Code

keywan-ghadami, 2026-11-22

Needs #2475

Run 2 built item 1 on wip/issue-2524 (de093970). Under warn it would make scripts/drive.nika throw Outside. By the decision on #2691 (ADR-raw-sinks-1 D8), D7 lands after the scripts pass by proof: “drive.nika reads, writes and lists by proof” (#2470, now ready), then “drive.nika proves the lane directory where it arrives” (#2475). Item 2 (html::Raw, db::Raw::execute) can be built from the same branch on the next run. Keep the branch.


Generated by Claude Code

keywan-ghadami, 2026-11-22

Run: issue-2524, Result: partial

Tokens: input 118, cache read 4073521, cache write 87012, output 23834 Cost: 2.04 USD, time 2 min 41 s, turns 59

Report

Result: partial Files: crates/nikaia-std/src/compiler/check_facts.nika crates/nikaia-std/src/compiler/check_walked.nika crates/nikaia-std/src/compiler/emit_contracts.nika crates/nikaia-std/src/compiler/emit_core_args.nika crates/nikaia-std/src/compiler/emit_state.nika crates/nikaia-std/src/compiler/lowered.rs crates/nikaia-std/src/compiler/lowered/check_facts.rs crates/nikaia-std/src/compiler/lowered/check_walked.rs crates/nikaia-std/src/compiler/lowered/emit_contracts.rs crates/nikaia-std/src/compiler/lowered/emit_core_args.rs crates/nikaia-std/src/compiler/lowered/emit_state.rs crates/nikaia-std/src/compiler/lowered/project_check.rs crates/nikaia-std/src/compiler/lowered/prove_run.rs crates/nikaia-std/src/compiler/lowered/prover_claims.rs crates/nikaia-std/src/compiler/lowered/prover_passes.rs crates/nikaia-std/src/compiler/lowered/prover_walk.rs crates/nikaia-std/src/compiler/project_check.nika crates/nikaia-std/src/compiler/prove_run.nika crates/nikaia-std/src/compiler/prover_claims.nika crates/nikaia-std/src/compiler/prover_passes.nika crates/nikaia-std/src/compiler/prover_walk.nika crates/nikaia-std/src/runtime/lowered.rs crates/nikaia-std/src/runtime/lowered/paths.rs crates/nikaia-std/src/runtime/paths.nika crates/nikaia/src/check/host.rs crates/nikaia/src/comptime_run.rs crates/nikaia/src/emit/mod.rs crates/nikaia/src/grammar_run.rs crates/nikaia/src/modules.rs crates/nikaia/src/project.rs crates/nikaia/src/prove.rs tests/compiler/tests/a_branch_value_is_outside_by_its_branch.nika tests/compiler/tests/a_branch_value_is_outside_by_its_branch.stderr tests/compiler/tests/a_branch_value_is_outside_by_its_branch.stdout tests/compiler/tests/a_guarded_join_carries_its_proof_to_a_binding.nika tests/compiler/tests/a_guarded_join_carries_its_proof_to_a_binding.stderr tests/compiler/tests/a_guarded_join_carries_its_proof_to_a_binding.stdout tests/compiler/tests/a_path_from_outside_under_anywhere_is_checked_under_warn.nika tests/compiler/tests/a_path_from_outside_under_anywhere_is_checked_under_warn.stderr tests/compiler/tests/a_path_from_outside_under_anywhere_is_checked_under_warn.stdout Commit: An unproved path from outside under fs::Root::Anywhere is checked as under Dir(“.”) under raw-sinks = warn (ADR-raw-sinks-1 D7) Part: #2524 Body: Item 1 built from wip/issue-2524 (de0939701), rebased by hand onto the check that runs dependency units ahead (#1949): the claim prover keeps each call whose path from outside reaches fs::Root::Anywhere unproved (ProverWalk.raw_paths, RawPathCheck: the root’s index and each NK1308’s help), CheckFacts carries it, project_check_raw_path_checks keeps those the build neither refuses (error) nor allows ([allow] key or NAME:key, D5/D15), and the emitter writes that call’s root as runtime::root_confined(root) (paths.nika), which turns Anywhere into Dir(“.”), so ../x throws io::IoError::Outside. Facts are now asked of every unit (also those checked ahead) to read these calls. Rust plumbing for #557 (ADR-platform-layer-v1): prove.rs Proved.raw_paths, check/host.rs forwards it, modules.rs Program.raw_path_checks, project.rs LowerHost.raw_path_checks and raw_path_checks_of, emit/mod.rs emit_module_body_at’s raw_path_checks, comptime_run.rs and grammar_run.rs pass an empty map. Tests: new a_path_from_outside_under_anywhere_is_checked_under_warn (FAILED on $NIKAIA_OLD b3bb9cd12, passes now); 22 touched programs ok (every Anywhere test with outside input, drive_relower, the_markup_of_html_raw_is_a_raw_sink, the_text_of_db_raw_is_a_raw_sink); a_branch_value_is_outside_by_its_branch and a_guarded_join_carries_its_proof_to_a_binding re-recorded with the run-time check; cargo test –lib project:: ok; clippy and pre-push green; lower-std fixpoint holds Gate: green Deviation: item 2 (html::Raw throwing html::HtmlError::NotPlain where made, db::Raw::execute throwing on a part that fails db::is_identifier) not built: both need a decision, see the Found lines Found: html::Raw under warn cannot throw html::HtmlError::NotPlain from its site as ADR-raw-sinks-1 D7 says, no decision yet: the function’s throw set (and the Rust error channel the emitter writes from it) is inferred into the ledger before the claim prover decides which html::Raw sites are unproved (project.rs check_unit_of checks against checking.promised, traced), so a new thrown type at an unproved site is in no function’s set; std::html also has no HtmlError (use std::html / fn main() throws { let e = html::HtmlError::NotPlain("<") } draws NK1245 today). Needs: whether inference counts every html::Raw site with a part not literal as throwing html::HtmlError under warn (over-approximating the set where the prover later proves it), or another rule; expected: fn main() throws { let name = io::read_line() ?? ""; let page = html::Raw(f"<p>{name}</p>") } with input <b> throws html::HtmlError::NotPlain(“”) (D7), today it builds with warning NK1308 and runs without a check Found: db::Raw::execute under warn cannot check the parts of db::raw’s text, no decision yet: db::raw(text) (packages/db/src/main.nika) stores only the joined text, so by execute the outside parts are gone; D7 says a part failing db::is_identifier throws from execute, which needs the Raw value to carry the breach (a field the compiler sets at an unproved db::raw site) or the check moved to the db::raw site, and which error execute throws for it (it is a bare throws). Expected: let s = db::raw(f"SELECT * FROM {name}") with name x; DROP makes s.execute(conn) throw naming the sink and the part (D7); today it builds with warning NK1308 and sends the text unchecked Needs: supervisor decision Changelog: Under raw-sinks = “warn” a path from outside that reaches fs::Root::Anywhere unproved is opened as under Dir(“.”), so one that leaves the directory throws io::IoError::Outside (ADR-raw-sinks-1 D7). Issue: broke I3: item 2’s D7 text names where html::Raw throws but not how the throw enters a function’s inferred throw set, which is fixed before the prover knows the site is unproved; and how db::Raw::execute learns of a breach at db::raw is not said Owner: none Comment: #2524 Item 1 is committed (an unproved Anywhere path under warn is opened as under Dir(“.”) and throws io::IoError::Outside). Item 2 waits for two decisions: how an unproved html::Raw site’s html::HtmlError enters the function’s throw set, which is inferred before the prover runs; and how db::Raw::execute sees a breach in db::raw’s parts, which it no longer holds. Friction: the wip’s project.rs hunks no longer applied after dependency units moved to the parallel check_ahead (#1949); applied by hand Disk freed: none (target/nikaia-project-tests 1.6G, / 12G free; new entries over 100 MB: rust-library-splice/ae44960b 841 MB, rust-library-user/ae44960b 757 MB) Reviewed: b192b7c22e5c1e7413194cb54e95be7ac294f98c7a225f9191599df7fea69db5 Pushed: local 58c6f6f61a0406853be58a1cc3b31711989f8042 Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01UVxJDvbkNUUMs8HdjJ8ixV

Debrief

  1. Most time: the build cycle (lower-std, build, lower-std) at about 8 minutes, then the test run. After that, re-applying three project.rs hunks from the parked branch, which no longer applied because dependency units are now checked ahead in parallel (check_ahead).
  2. Looked up: whether “Needs” #2475, #2691 and #2650 were closed (git log, plus ADR D7/D8 for the two decision issues), and how std declares an error type with variants ([type."io::IoError"] variants = [...] in std.contracts). I also had to find that the prover runs after throw-set inference (check_unit_of checks against checking.promised). The brief could have said that the parked branch’s base is older than #1949’s parallel check.
  3. Checks run: the cycle, 22 touched programs, the fails-before run on $NIKAIA_OLD, the project:: unit tests, clippy, pre-push, and two probes for item 2. None were wasted. Clippy ran alongside the tests, which slowed both a little.
  4. Change that would save most: a brief that resumes a wip/* branch should say “apply the diff without lowered/, re-run lower-std, and expect hunks in project.rs to need re-applying by hand”, plus give the command git diff BASE WIP -- . ':!*/lowered*'.
  5. What the issue lacked:
    • broke I3: item 2 says where html::Raw throws, but not how html::HtmlError enters a function’s thrown-error set, which is fixed before the prover knows the site is unproved.
    • broke I3: item 2 does not say how db::Raw::execute learns of a breach, since db::raw keeps only the joined text.
    • knowledge: Core | inference precedes the claim prover, so a prover result cannot add to a function's throw set.
  6. Traps for the next builder:
    • Fact: Core | A wip branch's diff applies without its lowered files (git diff BASE WIP -- . ':!*/lowered*'), then lower-std writes them again; hunks the base has since moved come back as .rej files to apply by hand.
    • Fact: Core | Dependency units are checked in project.rs check_ahead (in parallel, results in self.ahead), not check_unit, so a per-unit result collected only in check_unit misses every dependency.
  7. Work area (raw sinks):
    • Fact: Raw sinks | the D7 run-time path check: prover_walk.nika prover_raw_sink (raw_paths), project_check.nika project_check_raw_path_checks, emit_core_args.nika emit_core_argument (root_confined), runtime/paths.nika root_confined (commit 58c6f6f6, 2026-11-22).
    • Fact: Raw sinks | the 22 tests with Root::Anywhere and outside input, drive_relower among them, pass under the D7 check (2026-11-22, 58c6f6f6).

Generated by Claude Code

keywan-ghadami, 2026-11-22

Item 1 is built and pushed (58c6f6f61): under warn, an unproved path from outside that reaches fs::Root::Anywhere is opened as if under Dir("."), so ../x throws io::IoError::Outside.

Item 2, the To build as decided. It follows ADR-raw-sinks-1 D7 and the throw-set rule from #2704 (b7a0dd43d):

Done when: the two Found probes in the report behave as the ADR expects. <b> read in → html::HtmlError::NotPlain("<b>"). x; DROP → db::NotIdentifier { part: "x; DROP" } thrown at db::raw.


Generated by Claude Code

keywan-ghadami, 2026-11-22

Run: issue-2524, Result: done

Tokens: input 400, cache read 14072833, cache write 326144, output 95025 Cost: 7.84 USD, time 7 min 48 s, turns 200

Report

Result: done Files: crates/nikaia-std/src/compiler/check_core_expr.nika crates/nikaia-std/src/compiler/check_may_fail.nika crates/nikaia-std/src/compiler/check_state.nika crates/nikaia-std/src/compiler/emit_expr.nika crates/nikaia-std/src/compiler/emit_misc.nika crates/nikaia-std/src/compiler/lowered.rs crates/nikaia-std/src/compiler/lowered/check_core_expr.rs crates/nikaia-std/src/compiler/lowered/check_may_fail.rs crates/nikaia-std/src/compiler/lowered/check_state.rs crates/nikaia-std/src/compiler/lowered/emit_expr.rs crates/nikaia-std/src/compiler/lowered/emit_misc.rs crates/nikaia-std/src/compiler/lowered/project_check.rs crates/nikaia-std/src/compiler/lowered/prover_walk.rs crates/nikaia-std/src/compiler/lowered/throws.rs crates/nikaia-std/src/compiler/project_check.nika crates/nikaia-std/src/compiler/prover_walk.nika crates/nikaia-std/src/compiler/throws.nika crates/nikaia-std/src/html.rs crates/nikaia-std/src/runtime/lowered.rs crates/nikaia-std/src/runtime/lowered/raw_sinks.rs crates/nikaia-std/src/runtime/raw_sinks.nika crates/nikaia-std/std.contracts crates/nikaia/src/check/mod.rs crates/nikaia/src/contracts/mod.rs crates/nikaia/src/contracts/throws.rs crates/nikaia/src/project.rs packages/db/nikaia.contracts packages/db/nikaia.derived packages/db/nikaia.lock packages/db/src/main.nika tests/compiler/tests/a_markup_part_from_outside_throws_not_plain_under_warn.nika tests/compiler/tests/a_markup_part_from_outside_throws_not_plain_under_warn.stdout tests/compiler/tests/a_raw_sink_part_in_a_function_that_does_not_throw_stays_refused.nika tests/compiler/tests/a_raw_sink_part_in_a_function_that_does_not_throw_stays_refused.stderr tests/compiler/tests/an_sql_part_from_outside_throws_not_identifier_under_warn.nika tests/compiler/tests/an_sql_part_from_outside_throws_not_identifier_under_warn.stdout Commit: Under raw-sinks = warn an unproved part from outside at html::Raw or db::raw throws html::HtmlError::NotPlain or db::NotIdentifier where the value is made (ADR-raw-sinks-1 D7) Body: Item 2. std::html gets HtmlError { NotPlain(String) } (runtime/raw_sinks.nika, std.contracts, html.rs re-export) and packages/db gets pub struct NotIdentifier { part } with impl Error. Throws inference (throws.nika thrown_in, raw_sink_thrown/raw_sink_error) counts, under warn only, every html::Raw / db::raw call with a part that is not a literal as throwing the sink’s error, before the prover runs (#2704). The checker does the same for a catch around the site (check_may_fail.nika a_raw_sink_checked, CheckWorld.raw_sinks_warn), so it is not NK1134. The prover (prover_walk.nika raw_sink_checked_parts) records each unproved part in a fn that throws, not in a lambda, in raw_paths (-1 markup, -2 sql). project_check keeps them under warn minus [allow]. The emitter (emit_expr.nika emit_raw_sink_checked) wraps the part in an html::is_plain / db::is_identifier check, escaped by text::escape_control (ADR-398), and goes out by ? or by the catch’s break (emit_misc.nika: such a part nests the catch). In a fn that does not throw, the site stays NK1308 under warn, with a note that says why. A proof removes only the check. Rust plumbing for #557/#125 (ADR-platform-layer-v1): contracts/mod.rs raw_sinks_warn flag set in project.rs Settings::sinks, passed by contracts/throws.rs and check/mod.rs; html.rs pub use Fixes: #2524 Tests: three new programs, each FAILED on $NIKAIA_OLD 6cef2e362eb3 (NK1151 / NK1134 / built and ran unchecked) and ok –both-settings now: a_markup_part_from_outside_throws_not_plain_under_warn, an_sql_part_from_outside_throws_not_identifier_under_warn, a_raw_sink_part_in_a_function_that_does_not_throw_stays_refused. 17 touched raw-sink programs ok –both-settings (incl. the_markup_of_html_raw_is_a_raw_sink, the_text_of_db_raw_is_a_raw_sink, html_text_is_escaped_and_markup_is_not, a_path_from_outside_under_anywhere_is_checked_under_warn). packages/db tests 4 ok, examples/escaping ok, cargo test –lib contracts:: ok, clippy and pre-push green, lower-std fixpoint holds. sysroot not run (std’s raw_sinks.nika and std.contracts changed; left to the driver’s suite) Gate: green Deviation: none Found: under raw-sinks = warn a part from outside that reaches html::Raw through a parameter is neither checked nor refused, no decision yet: use std::cli use std::html fn page(name: String) -> html::Raw throws { return html::Raw(f"<p>{name}</p>") } fn main() throws { let name = cli::args().nth(1) ?? "<b>"; println(page(name).as_str()) } builds with warning NK1308 at the call page(name) (“lets this build through”) and prints <p><b></p> on HEAD’s build; D7 says an unproved part is checked where the value is made. Traced: prover_walk.nika raw_sink_part reports a parameter’s outside origin at the caller, while raw_sink_checked_parts records a check only for a finding at the sink itself. Needs a decision on where the check goes: on the caller’s argument, or on the callee’s sink for every call Found: a struct error declared in the file, matched by a pattern in the handler of a catch that nests its failure (a boxed catch), does not compile: pub struct Bad { pub part: String } impl Error for Bad { fn message(self) -> String { return f"bad {self.part}" } } fn g() -> String throws { throw Bad { part: "x" } } fn f(s: String) -> String { return s } fn main() throws { let v = f(g()) catch { match error { Bad { part } => println(part), else => println("other") }; return }; println(v) } gives NK1343 (rustc: ? couldn’t convert the error to Thrown<IoError>) on HEAD and on 6cef2e362eb3, and should print x (g() catch alone prints x). Suspected: emit_items.nika member_of, path.len()==1 asks error_kind(…)==1, which a struct error is not; check: print error_kind for “Bad” Found: a package’s error type, matched in a boxed catch, is not taken out of the box: with packages/db as a dependency, let made = db::raw(f"SELECT * FROM {name}") catch { match error { db::NotIdentifier { part } => println(part), else => println("other") }; return } gives NK1343 (rustc: mismatched types, expected Box, found NotIdentifier) on HEAD's build, and should print the part. Suspected: emit_items.nika member_of, where error_kind(declared, library) knows only this unit's errors and std's ledger, not a dependency's Needs: none Changelog: Under raw-sinks = "warn" a part from outside that reaches html::Raw or db::raw unproved, in a function that throws, is checked where the value is made: one that is not html::is_plain throws html::HtmlError::NotPlain, one that is not db::is_identifier throws db::NotIdentifier, each with the part escaped as the log escapes it. In a function that does not throw it stays NK1308 (ADR-raw-sinks-1 D7). Issue: complete Owner: none Comment: none Friction: a catch directly around db::raw(...) needed the checker to know the raw-sinks setting (NK1134 otherwise), which the issue did not name; built Disk freed: none (cache 1.6G, / 9.7G free of 252G, no new entry over 100 MB) Reviewed: f2f3acf7976f33b1548839275a7c12b6fc9255ebfd7f06121cd2e1e0f5e69d12 Pushed: local fd18419033fae51c80cd2ed2f3958d039dcbda2b Attribution: Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UVxJDvbkNUUMs8HdjJ8ixV

Debrief

  1. Most turns: the catch emission. A catch directly around db::raw(...) first drew NK1134, then was emitted as a plain match {Ok/Err}. Next, matching a struct pattern in the boxed catch hit two existing defects. Each needed a build-and-probe cycle. The rustc borrow error on returning db::Raw built over a temporary also cost a test rewrite.
  2. Looked up: how a checker CheckGuarded decides NK1134 (fallible/thrown), and the root codes in raw_paths (-1 markup, -2 sql). Also how project_check fills raw_path_checks only under warn, and that CheckWorld had no raw-sinks setting. Finally, which member_of/error_kind path opens a boxed error. The brief could have named check_may_fail.nika and emit_misc.nika emit_catch_nests_a_failure as touched files.
  3. Checks run: the build, the lower-std fixpoint, the 3 new tests on HEAD and on $NIKAIA_OLD, the 17 raw-sink programs, the packages/db tests, examples/escaping, --lib contracts::, fmt, clippy and pre-push. None was wasted. Several probe cycles on the struct-pattern catch were wasted, since those were existing defects and not mine.
  4. One change: in builder.md, say that a new error a construct can throw needs three places changed together: throws inference, the checker’s guarded set (NK1134), and the catch-nesting test in the emitter. Changing only one gives three separate failures.
  5. What the issue lacked:
    • broke I7: the issue did not say the checker must learn the raw-sinks setting (NK1134 on a direct catch). No file or function was named for it.
    • rules-gap: the issue did not name the interprocedural shape (an outside part passed as a parameter), which D7 leaves undecided. It became a Found with “no decision yet”.
    • knowledge: Lowering | db::Raw borrows its text, so a function cannot return one built over a temporary f-string (rustc borrow error); keep the f-string in a local that lives as long as the value.
  6. Facts (traps):
    • Fact: Core | nikaia test --bless does not create a missing .stderr/.stdout; create an empty file first, then bless.
    • Fact: Lowering | An emitted std String inside a generated block can mismatch rustc's expected String; wrap it as ::std::convert::Into::into(...).
    • Fact: Lowering | In a catch that nests its failure (the boxed form), a struct-pattern arm of an own or a package's error does not compile (NK1343); print {error} instead until the defect is fixed.
  7. Work area (raw sinks):
    • Fact: Raw sinks | Under warn, prover_walk.nika raw_sink_checked_parts records the checks, project_check.nika keeps them, and emit_expr.nika emit_raw_sink_checked emits them; throws.nika raw_sink_error and check_may_fail.nika a_raw_sink_checked must agree on the error type (2026-11-22, fd184190).
    • Fact: Raw sinks | The Rust flag contracts::raw_sinks_are_warn(), set by project.rs Settings::sinks, is how throws inference and the checker learn the setting (2026-11-22, fd184190).

Generated by Claude Code

Back to Open Issues