agent: builder model: sonnet max_turns: 70 budget_usd: 10 —

Brief: process::exit(2) in a throws helper ends with code 1 (#863)

Score: S=3 (a program asking for exit code 2 gets 1 and a stray error line; our own scripts’ escalation codes depend on it), O=unknown until reduced, bug lane 1.

Issue #863 (copied)

Found by the #858 builder: in a version of scripts/agent.nika, a helper marked throws, called from a throws main, calling process::exit(2) (agent_escalate, line 96 today), ended the program with exit code 1 and Error: process_Exit on stderr instead of code 2. Part III, process::exit: the requested code reaches the OS.

Architect’s probes (develop 8335430, target/fast/nikaia run p.nika; echo $?)

To build

  1. Reduce: find the smallest failing program (vary as above; git log -p ba1f1cc -- scripts/agent.nika shows the version of that time). If nothing fails after a fair matrix (about 8 forms), report Result: noop with the matrix under Deviation; the issue is then closed by hand.
  2. Test tests/compiler/tests/process_exit_in_a_throws_helper.nika (+ .stdout/.stderr; if the runner cannot check a status, a parent program running the child with process::run and printing its code).
  3. Fix at the root (main_exits in crates/nikaia-std/src/tools/emit_entry.nika, or process::ended in crates/nikaia-std/src/process.rs, or the combined error’s lowering), so the code reaches the OS whatever the throws chain; lower-std and rebuild after a tools/*.nika change. Commit Fixes #863.

Files you may change

crates/nikaia-std/src/tools/emit_entry.nika (+ its lowered/ file), crates/nikaia-std/src/process.rs, the new test. Anything else: stop and report under Needs. Known facts: read docs/builder-facts.md.

Rules (CLAUDE.md; this block is pasted into every brief, also a fix-forward)

Report (at most 15 lines, to exactly /home/user/Nikaia/docs/briefs/b863-exit-code.md.report.md)

Fields of docs/architect.md, Briefs and reports: Result: done|noop|partial|blocked (the bare word first; Owner: is a question for the owner or none, never a role), Files, Commit, Fixes, Pushed, Tests, Gate (green|red), Deviation, Found, Needs, Changelog, Owner, Disk freed. none where nothing, and then the bare word: Deviation: none (a note) cuts the batch (batch.nika compares exactly); a note goes into the commit message. Final answer, one line: done <sha>, report <path> (or BLOCKED: ... / PUSH REJECTED ...).

Attribution: Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01GFeMqxRbtUMiGVyDMxsvEq

This site is open source. Improve this page.