Open and answer this issue on GitHub.
async, blocked · opened 2026-12-01 · updated 2026-12-01 · 3 comments
Filed by the driver from the Found: of the run of issue-3026 (#3026) (owner, 2026-11-06).
A main-line write after a task’s value is read, still inside its async group, is NK1343 (rustc: cannot assign to cfg.count because it is borrowed); Part I 8.1.2 ends the task’s window at the read. Probe (nikaia run, HEAD build): struct Cfg { count: i64, items: Vec[i64] } / fn total(c: Cfg) -> i64 { let mut s = 0; for x in c.items { s = s + x }; return s } / fn count_of(c: Cfg) -> i64 { return c.count } / fn main() throws { let mut cfg = Cfg { count: 1, items: [1, 2, 3] }; async { let t = async total(cfg); let n = count_of(cfg); println(f"{t} {n}"); cfg.count = 3; println(f"{cfg.count}") } } gives error[NK1343] ... Rustc output: cannot assign to cfg.count because it is borrowed at cfg.count = 3; should print 6 1 and 3. Suspected: the emitter keeps the task’s future, which borrows &cfg, in the group’s Scope (__group_N_waiting.keep(__group_N.start_kept_gated(...))) until the group ends; the borrow outlives the join. Related to #3011’s shared-handle lowering.
develop first: the run that wrote it may have used a binary older than the tip, so it may be fixed already (#1822: #1788 was filed from a probe a fix under #1754 had already made pass). A probe that passes there names the commit that fixed it (git log -400 --grep by topic, since a fix often lands under another issue’s number), and the run builds only a tests/compiler/tests/ test that pins it (docs/issues.md I13).std defect with a probe (nikaia run scripts/probe.nika -- SNIPPET; a lowered file that differs, with an uncached lower-std of a git archive HEAD copy, NIKAIA_LOWER_CACHE_SALT fresh and --sysroot COPY/crates, its lowered/ diffed against the copy’s, never the shared working tree’s, #1793), a defect in docs/, guide/, website/ or scripts/ (a stale example, a wrong rule) with the command or check that shows it; a behaviour the code does on purpose (name the function or ADR) closes it as by design. The Found line may lack them (#1710): the commit message, or the report’s Body: when closed, gives the probe or check with its expected output, the ADR or Part I-III section that says so, and its actual output (docs/issues.md I5, I6), and the cause, file and function, traced or suspected (I7).std defect in the compiler, a stale page example or rule in its page or docs/ file, a script defect in the script. Add a test in tests/compiler/tests/ unless a check that already runs turns red on it (name it: pre-push’s page-examples for guide/ and website/, check-adr-refs.nika for a docs citation).The probe or check gives the expected output the first item names from its ADR or Part I-III section, and a tests/compiler/tests/ test (or the named check) that failed on the unfixed tree is green; or the probe already passes on develop and a test pins it, naming the commit that fixed it; or the issue is closed as by design, naming the function or ADR.
Generated by Claude Code
Brief queued: issue-3028
agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —
Your work order is issue #3028, 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/3028/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/async/issue-3028.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-3028, Result: blocked
Tokens: input 36, cache read 776880, cache write 44855, output 10843 Cost: 0.77 USD, time 2 min 1 s, turns 18
Result: blocked
Files: none
Commit: none
Body: Reproduced on HEAD f24b0b37c (target/fast/nikaia built after it). ADR-async-v7 D8 says a change of the binding “after the main line has waited for that task, it is allowed”, so this is a defect, not by design. Traced cause: the lowering keeps the task’s future, which borrows &cfg, in Rest<'b> (Rested<'b> holds Pin<Box<dyn Future + 'b>>, crates/nikaia-std/src/task/group.rs) and in Waiting<'x>::keep<'h: 'x> (Weak<dyn Pollable + 'x>, task/gate.rs). Both are named again at the block end (__group_16_waiting.during(__rest_17.finish())), so rustc keeps 'b, and with it &cfg, alive until then. The future is in fact dropped at the join, but safe Rust cannot tie the end of a borrow to a cell that empties at run time.
Fixes: none
Pushed: none
Tests: issue probe nikaia run p.nika on HEAD: NK1343 at cfg.count = 3; same probe without async { } (the function’s implicit group): NK1343 too; nothing built
Gate: green
Deviation: none
Found: A main-line write after a task’s value is read is NK1343 (rustc: cannot assign to cfg.count because it is borrowed). Expected by ADR-async-v7 D8: allowed once the main line has waited. Probe struct Cfg { count: i64, items: Vec[i64] } / fn total(c: Cfg) -> i64 { let mut s = 0; for x in c.items { s = s + x }; return s } / fn count_of(c: Cfg) -> i64 { return c.count } / fn main() throws { let mut cfg = Cfg { count: 1, items: [1, 2, 3] }; let t = async total(cfg); let n = count_of(cfg); println(f"{t} {n}"); cfg.count = 3; println(f"{cfg.count}") } gives NK1343 today, inside async { } too; it should print 6 1 and 3. Traced: Rest<'b> (task/group.rs) and Waiting<'x>::keep<'h: 'x> (task/gate.rs) hold the future’s lifetime until the block end. No decision yet: a safe-Rust fix does not exist with this runtime design; choose (a) a new ADR-218 unsafe crate whose type-erased task cell drops the lifetime, licensed by the checker’s D8 window (like proven-index), or (b) a redesign of Rest/Waiting plus emitter scoping that ends the borrow at the join
Needs: supervisor decision
Changelog: none
Issue: broke I7: the Found named only the gated Waiting.keep and suspected it; Rest<'b>, used at the block end, holds the borrow too, and so does a function’s implicit group
Owner: none
Comment: none
Friction: scripts/probe.nika refuses --file with a scratchpad path (“not a relative path below the working directory”), so a probe for a report must be copied under target/ or run with nikaia run directly
Disk freed: none; target/nikaia-project-tests not present, / 16G free of 252G
Attribution:
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01UVxJDv58s4ABZjDMtxcbrQ
Rest<'b> and Waiting<'x>::keep through task/group.rs and task/gate.rs, then read ADR-218 to learn that unsafe is banned in nikaia-std. One failed turn: scripts/probe.nika --file refuses a path in the scratchpad.unsafe in nikaia-std and puts each unsafe topic in its own crate under crates/unsafe/; where Rest, Rested and Waiting live. The brief could have handed me all three.nikaia run and nikaia lower; a variant without the group (fails too, useful); a variant writing after the group (stopped at NK2110, so wasted); the disk figures. Nothing was built or tested, and that was right for a blocked run.docs/issues.md:
wrong I7: the issue suspected only Waiting.keep. Rest<'b> also keeps the borrow alive until the block’s end, and the defect also shows without the gated async { } group.rules-gap: an issue whose fix needs unsafe or a runtime redesign should say so and be labelled decision, not ready.knowledge: Lowering and lower-std | A task's future borrows its arguments for the lifetime of Rest<'b>/Waiting<'x>, which the lowering names again at the block's end, so rustc keeps the borrow until the group ends.| Fact: Core | scripts/probe.nika --file takes only a path relative to the working directory; for a probe in the scratchpad, run target/fast/nikaia run F.nika from the scratchpad. |
| Fact: Lowering and lower-std | nikaia-std denies unsafe_code (ADR-218 D4), so a runtime fix that needs lifetime erasure is a new crate under crates/unsafe/ and needs a decision before it is built. |
| Fact: Lowering and lower-std | The runtime of a task group is crates/nikaia-std/src/task/group.rs (Rest, Rested, ChildHandle) and task/gate.rs (Waiting::keep); nikaia lower p.nika and then __nikaia_main in p.rs show how a group is lowered. |
| Fact: Lowering and lower-std | A main-line write after a task’s join is still NK1343 (2026-12-01, HEAD f24b0b37c), in a function body and inside async { }; it waits for a decision on ADR-218. |
Generated by Claude Code
Driver: not queued, this issue waits for #3032, which is still open (#1819). Set ready again when it is closed.
Generated by Claude Code