Open and answer this issue on GitHub.
blocked, ci · opened 2026-11-18 · updated 2026-11-20 · 5 comments
Part of “Unobservable std tests” (#2088). Decided in ADR-401 (owner, 2026-11-18). Needed by “All tests in Nikaia…” (#2082) for crates/nikaia-std/src/rt/library.rs’s test a_thread_is_kept_for_the_next_call.
std has no thread module; a Nikaia program cannot name the thread it runs on.rt/library.rs:91-125 checks that a library’s _async calls reuse an idle kept thread (ADR-284 D9) and that a busy one is not waited for, by comparing Rust’s std::thread::current().id().tests/compiler/tests/a_package_built_as_a_rust_library_is_used_by_a_rust_crate.nika is the pattern for a Rust caller.std::thread::id() -> thread::Id: an opaque id for the calling thread. ==, != and a hash (usable as a map key or set member); no arithmetic, no order, no conversion to a number.id() and kept for its life; never reused, not the OS id or an address. A thread that never asks costs nothing. It names a thread, not a task.std::thread holds nothing else.thread::Id (equality and hash, nothing else) and a process-wide counter with a per-thread slot filled from it on the thread’s first call to id(), not at thread start. Written as .nika where it can be; what has to stay Rust is listed in the report for “Self-hosting” (#557).std::thread with Id, id() and ADR-401 D3’s note on tasks.tests/compiler/tests/thread_id.nika: id() twice on one thread is equal; a task started with its own thread (if Part II offers one) or a library thread gives an id that is not equal; an id as a map key finds its value. A compile-fail test (.stderr) shows that arithmetic on a thread::Id is refused._async function from a small C program twice one after the other (same id()), then twice at once with the first one blocked (different id()). It replaces a_thread_is_kept_for_the_next_call; delete the Rust test. Where no C compiler is found the builder reports it, never skips silently.thread::Id and thread::id() exist, is in Part I, and the tests of steps 3 and 4 pass.rt/library.rs is gone.Fixes.std’s thread module, docs/specification/10-nikaia-light.md, tests/compiler/tests/, crates/nikaia-std/src/rt/library.rs (only to delete the test).Generated by Claude Code
Brief queued: issue-2117
agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —
Your work order is issue #2117, 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/2117/comments -F body=@file,
ending with the Claude Code footer), rule I13.
develop in the main checkout; other agents’ uncommitted files are not yours: never touch or stage them.target/fast/nikaia run scripts/commit.nika -- REPORT (it adds exactly the report’s Files:); the driver pushes.cargo build --profile fast -p nikaia, lower-std and its fixpoint when a tools/*.nika changed, cargo fmt, cargo clippy --all-targets -- -D warnings, nikaia run scripts/pre-push.nika, the tests the issue names and the ones your change touches.CHANGELOG.md, badges and NK codes are the supervisor’s. New tests in Nikaia only: a Rust test file an older issue names is built as a tests/compiler/tests/ program, no Deviation: and no Issue: point (I9, #1671).Body:. Found: is only for what lies outside the area, cannot be fixed this run or needs a decision; the driver files it as an issue.std or the toolchain lacks stops the work, unless an ADR or Part I-III refuses it (name it): Result: blocked, Found: the gap with a probe, Needs: supervisor decision.NIKAIA_CACHE_LIMIT=2G; at the end delete your own clone’s target/ and target/release/nikaia-scratch.suspected, or does not mark (docs/issues.md I7), is a hypothesis: run the check that settles it (nikaia run scripts/where.nika -- NAME, the probe with a trace, callgrind for a cost) before you build on it (owner, 2026-11-16). Shown false: say so in Issue: as wrong I7: <what the check showed> (the driver comments it on the issue) and follow the real cause.Result: partial with what you ruled out, the probe, and the suspected file and function./home/user/Nikaia/docs/briefs/ci/issue-2117.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.
Result:, Gate: (green or red <check>), Deviation:, Found: and the other fields with nothing to say hold the bare word: done, none. Anything after it reads as content.Result: done only when the issue’s Done when holds; partial with the items left otherwise.Deviation: only for an item of the issue built otherwise than written, or not built. Found: only for a defect outside your area, or one this run cannot fix: one defect per Found: line, with its probe and the output it gives, only the shapes that fail today, and the suspected file and function or cause unknown (#1695); a by-design behaviour is none (#1677). A correct program your own change refuses (a fail-closed check’s false refusal) is no Deviation: but one Found: line per shape, with its probe (#1680). Everything else goes into Body:; how you verified goes into Tests:.Issue: by docs/issues.md, How a run judges its issue: complete, or broke I<n>: ..., rules-gap: ..., wrong I<n>: ..., joined with ;; a point your own commit built gets (built) after its kind (rules-gap (built): ...), and the driver does not file it. complete is the bare word: prose after it (complete; the earlier runs ...) is filed as an improvement issue (#1931); history or a note for your own issue goes into Body: or Comment: #N <text>.done <sha>, report <path> (or BLOCKED: ... / PUSH REJECTED ...).Generated by Claude Code
Run: issue-2117, Result: partial: step 4 (the C-library kept-thread test that replaces a_thread_is_kept_for_the_next_call, with Fixes) and step 3’s compile-fail test of arithmetic on a thread::Id are left; steps 1, 2 and the rest of 3 are built
Tokens: input 144, cache read 5453560, cache write 131254, output 30316 Cost: 2.88 USD, time 15 min 29 s, turns 72
Result: partial: step 4 (the C-library kept-thread test that replaces a_thread_is_kept_for_the_next_call, with Fixes) and step 3’s compile-fail test of arithmetic on a thread::Id are left; steps 1, 2 and the rest of 3 are built
Files: crates/nikaia-std/src/runtime/thread.nika crates/nikaia-std/src/runtime/lowered/thread.rs crates/nikaia-std/src/runtime/lowered.rs crates/nikaia-std/src/thread.rs crates/nikaia-std/src/lib.rs crates/nikaia-std/std.contracts docs/specification/10-nikaia-light.md tests/compiler/tests/thread_id.nika tests/compiler/tests/thread_id.stdout tests/compiler/tests/std_compiler_module_refused.stderr tests/specification/EXPECTED.txt tests/specification/COMPILES.txt
Commit: std::thread: thread::id() names the calling thread with an opaque thread::Id (ADR-401)
Body: thread::Id is a Nikaia struct with one private i64 (runtime/thread.nika, lowered with Copy, Eq, Hash); thread.rs keeps what Nikaia has no word for (for Self-hosting #557): the process-wide AtomicI64 counter and a const thread-local Cell<i64> slot with no destructor, filled on the thread’s first id() (D2), so a thread that never asks costs nothing. std.contracts declares the type equates/hashes/copies with no orders, and thread::id sync with no touches; prelude re-exports thread. Part I gains 6.10 (D1-D3, with the D3 note on tasks). thread_id.nika checks that two ids on one thread are equal, that an id finds its value as a HashMap key and that a HashSet holds one member; the “another thread differs” case is left to step 4, since a task gets its own thread only at user_parallelism = yes and --both-settings would see two outcomes. The NK1186 module list gains thread; the spec baselines move by the new compiling block.
Part: #2117
Pushed: local a5d5a4fb488c8b2c299df6f441a6512ead9fe7c8
Tests: thread_id and std_compiler_module_refused pass (nikaia test --both-settings); it specification:: passed; lower-std fixpoint clean (only runtime/lowered changed, by this commit); the no-arithmetic test drew NK1343 (rustc: Id does not implement Add<{integer}>), so it is not committed
Gate: green
Deviation: step 3’s compile-fail test (arithmetic on a thread::Id refused) is not built: the checker refuses no operator on any std type, so first + 1 reaches rustc as NK1343; step 3’s “a different thread gives a different id” moves to step 4’s library test, since a task’s own thread depends on user_parallelism and would differ between the two settings
Found: arithmetic on a std type is refused by no check and reaches rustc: use std::time\nfn main() throws {\n let a = time::now()\n let b = a + 1\n println(f"{b == a}")\n} gives NK1343 “Rustc output: mismatched types” (the same for thread::id() + 1, rustc Id does not implement Add<{integer}>); it should be NK1191, as P { x: 1 } + 1 on a program’s own struct is (“You can’t use + on a P”). Traced: declared_with_no_arithmetic (check_items.nika) looks only at the file’s own struct and enum items, and std.contracts has no key that says which std types have operators (Part I writes self * 2 on a time::Duration, the simd vectors have bit operators), so a fail-closed rule needs a new contracts key; no decision yet
Found: < on a type with no order is refused by no check and reaches rustc, for a program’s own struct too: struct P { x: i64 }\nfn main() throws {\n let a = P { x: 1 }\n let b = P { x: 2 }\n println(f"{a < b}")\n} gives NK1343 “Rustc output: binary operation < cannot be applied to type P”; use std::target\nfn main() throws {\n let a = target::Instruction::Crc32c\n println(f"{a < target::Instruction::Bmi2}")\n} gives NK1343 “Instruction does not implement PartialOrd”; it should be a checker refusal (Part I: order is the Ord trait, std.contracts’ orders key); cause unknown, suspected check_compare.nika (the compares/totally walk), settled by a trace of a < b through it
Needs: supervisor decision: how step 4’s C caller learns that a kept library thread is idle again, since the issue forbids a sleep and asks to “wait on what the runtime says”, and rt::library says nothing: a thread lists itself idle only after the job, done included, has returned (library.rs start), so a second _async call made from done’s signal may find none idle and start a thread; e.g. list the thread idle before done runs (then a call handed to it waits for done to return, against ADR-284 D9’s “no call waits”) or a runtime query; library.rs is outside the issue’s file limits except to delete the test
Changelog: std::thread — thread::id() gives an opaque thread::Id naming the calling thread, compared with ==/!= and usable as a map key or set member, taken from a counter on the thread’s first call and never reused (ADR-401); Part I 6.10.
Issue: broke I4a: step 4’s “no sleep … wait on what the runtime says” names a signal the runtime does not give (rt::library lists a thread idle only after the job, done included, returned); broke I4a: step 3 assumes the checker refuses arithmetic on a std type, it refuses none (thread::id() + 1 is NK1343); broke I9: step 3’s “a task started with its own thread” cannot be one tests/compiler test, which --both-settings also runs at user_parallelism = no
Owner: none
Comment: none
Friction: none
Disk freed: none (cache 3.2G, disk 6.9G 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_01UVxJDtmukJNapbMLmZMzTV
Reviewed: 9ee5231d1ca85d9a3d671c9efb188e47bb75c4a043c6399bfba25623036b50e3
time::now() + 1, < on a user struct). Second: working out that step 4 can’t be done without a sleep, which meant reading rt::library’s idle bookkeeping..nika lowering into runtime/lowered.rs); that adding a Part I block shifts COMPILES.txt ordinals and EXPECTED.txt; that the NK1186 module-list .stderr must be re-blessed.thread_id and std_compiler_module_refused with --both-settings, it specification::, fmt, clippy, pre-push. Wasted: the build and run of the compile-fail test, which could never pass..stderr and both spec baselines, so all of them are edited before the first build.rt::library does not give (a thread lists itself idle only after done returns).thread::id() + 1 reaches rustc as NK1343.tests/compiler test, because --both-settings also runs it at user_parallelism = no.| knowledge: Core | A new Part I code block shifts every later ordinal in tests/specification/COMPILES.txt, and EXPECTED.txt is regenerated with cargo run --profile fast -p nikaia --example specification. |
| Fact: Core | Adding a std module changes the NK1186 module list, so tests/compiler/tests/std_compiler_module_refused.stderr must be re-blessed. |
| Fact: Lowering | Operators on std types and < on types with no order are not refused by any checker today; they reach rustc as NK1343, so a compile-fail test of them can’t be written yet. |
| Fact: Core | Under --both-settings a task gets its own thread only at user_parallelism = yes, so a thread-identity test differs between the two runs. |
Generated by Claude Code
The report of the run of issue-2117 (#2117) judged this issue against docs/issues.md; the author fixes the issue by the rule it names (How a run judges its issue):
done included, returned)thread::id() + 1 is NK1343)tests/compiler test, which --both-settings also runs at user_parallelism = noGenerated by Claude Code
Supervisor, 2026-11-20: blocked. The rest of this issue waits for two decisions:
Steps 1, 2 and the rest of 3 are built.
Generated by Claude Code
Open question moved here from the closed improve issue #2124: how does the C caller learn that a kept library thread is idle (ADR-284 D9)? Either the thread is listed idle before done runs, or a runtime query is added.
Generated by Claude Code