@stream item that views its input cannot be kept past its turn: winnow-grammar’s slice_each hands items a fresh lifetime per callOpen and answer this issue on GitHub.
blocked, bugs · opened 2026-11-22 · updated 2026-11-30 · 5 comments
Filed by the driver from the Found: of the run of issue-2708-run3 (#2708) (owner, 2026-11-06).
a stream item that views its input cannot be kept past its turn: struct Item { word: String } / grammar Words { @stream entry rule items -> Item = item* rule item -> Item = "[" w:until("]") "]" ";" -> { Item { word: w } } } / fn kept(text: String) -> i64 throws { let mut kept: Vec[Item] = []; for it in Words::items(text) { kept.push(it.clone()) }; return kept.len() as i64 } gives today NK1343 “Rustc output: borrowed data escapes outside of closure” at kept.push(it.clone()), and should run (ADR-grammar-typed-read-v1 D7 as rewritten on #2426: an item views the input, kept past its turn with .clone()); traced: winnow-grammar (rev e417f40) winnow-grammar-macros/src/codegen/stream.rs stream_each_fn writes parse_<rule>_slice_each(input: &[u8], ..., each: impl for<'a> FnMut(&Item<'a>) ...), whose item lifetime is fresh per call; the slice form needs input: &'i [u8] and each: impl FnMut(&Item<'i>) (the reader form keeps for<'a>), then a new rev in Cargo.toml
#2735 (item 6: yaml-deep counts once Event views its input)
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
Supervisor, 2026-11-22: a defect in winnow-grammar, not a decision; the Needs: line above was the run’s own (#2735) and does not hold this.
Traced on a310181. parse_<rule>_slice_each and __wg_<rule>_whole_each take each: impl for<'a> FnMut(&Item<'a>). Items are parsed in Stream::items from Held<'w, K, S>, and 'w is the window’s lifetime, higher-ranked per call. The fix is therefore not only in the signature:
Stream::whole, input &'c [u8] read in place) needs an item path whose window is 'c, e.g. items_in_place with F: FnMut(&mut Held<'c, K, S>, …), where Held splits the buffer’s lifetime from the stream’s borrow;each: impl FnMut(&Item<'c>);for<'a>.Order. This is not on the yaml benchmark’s path (the benchmark walks yaml::events(docs) in memory), so it comes after “The owned form of a @stream item for the Rust side” (#2735) and “yaml: events and nodes refer to their scalars in the input” (#2417). The supervisor builds it in winnow-grammar, then bumps the pin. Until then, an item kept past its turn needs its text copied, as the run’s test does.
Generated by Claude Code
Brief queued: issue-2741
agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —
Your work order is issue #2741, 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/2741/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/bugs/issue-2741.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-2741, Result: blocked
Tokens: input 12, cache read 185751, cache write 24884, output 3205 Cost: 0.33 USD, time 0 min 43 s, turns 6
Result: blocked
Files: none
Commit: none
Pushed: none
Tests: probe run on fbf32d15f’s tree (target/fast/nikaia, one emit commit older than HEAD, winnow-grammar pin unchanged at a310181): struct Item { word: String } / grammar Words { @stream entry rule items -> Item = item* rule item -> Item = "[" w:until("]") "]" ";" -> { Item { word: w } } } / fn kept(text: String) -> i64 throws { let mut kept: Vec[Item] = []; for it in Words::items(text) { kept.push(it.clone()) }; return kept.len() as i64 } with main printing kept(“[a];[b];”) gives NK1343 “Rustc output: borrowed data escapes outside of closure” at 10:36 kept.push(it.clone()), exit 101; should print 2 (ADR-grammar-typed-read-v1 D7)
Gate: green
Deviation: none
Found: a @stream item that views its input cannot be kept past its turn (probe in Tests:, still NK1343 today); traced by the supervisor on a310181: winnow-grammar winnow-grammar-macros/src/codegen/stream.rs writes each: impl for<'a> FnMut(&Item<'a>) for parse_
probe.nika --file refusing the scratchpad path, so I had to copy the probe under target/ and run it again.Cargo.toml:34, rev a310181) and whether a later commit had moved it (git log --grep). The supervisor’s comment already gave the cause and the order, so I read no ADR or language section.broke I9: the fix lives in an external repository that only the supervisor can change, yet the issue was queued ready for a builder.rules-gap: “it comes after #N” in a supervisor comment is not in the dependency words the driver reads (After #N, Needs #N, …), so the issue ran while #2417 was open.wrong I9/I6: the Needs: line still names #2735 (closed), while the real wait, #2417, appears only in the comment’s prose.| Fact: Probes | nikaia run scripts/probe.nika -- --file F accepts only a relative path below the working directory, so copy a scratchpad probe under target/ first. |
| Fact: Core | A fault traced into winnow-grammar (winnow-grammar-macros/src/codegen/*.rs) cannot be fixed in this checkout; it needs a supervisor change upstream plus a new pinned rev in the root Cargo.toml. |
| Fact: Grammar streams | The issue’s probe (Words::items kept with .clone()) still gives NK1343 “borrowed data escapes outside of closure” (2026-11-30, HEAD fbf32d15f, pin a310181); recheck it once the pin moves past a310181. |
Generated by Claude Code
From the report of the run of issue-2741 (#2741):
Probe re-run 2026-11-30 on fbf32d15f (pin a310181): still NK1343 “borrowed data escapes outside of closure” at kept.push(it.clone()). Nothing to build in this checkout until winnow-grammar has the in-place item path and the pin moves; waits for #2417 per the 2026-11-22 order.
Generated by Claude Code
Driver: not queued, this issue waits for #2417, #2979, which is still open (#1819). Set ready again when it is closed.
Generated by Claude Code