Issue #2741: A @stream item that views its input cannot be kept past its turn: winnow-grammar’s slice_each hands items a fresh lifetime per call

Open 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).

Found

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

Needs

#2735 (item 6: yaml-deep counts once Event views its input)

To build

Done when

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

Comments

keywan-ghadami, 2026-11-22

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:

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

keywan-ghadami, 2026-11-30

Brief queued: issue-2741


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

Issue #2741

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.

Rules (CLAUDE.md; shared checkout)

Report (at most 15 lines, to exactly /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.


Generated by Claude Code

keywan-ghadami, 2026-11-30

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

Report

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__slice_each and __wg__whole_each, items come from Stream::items over Held<'w,K,S> with a per-call window lifetime; the fix lives in the external winnow-grammar repo (an items_in_place path with Held<'c,..>, then each: impl FnMut(&Item<'c>)) plus a new rev in Cargo.toml, which this checkout cannot build or push Needs: #2417 (the supervisor's 2026-11-22 comment orders this after "yaml: events and nodes refer to their scalars in the input", still open); supervisor builds the fix in winnow-grammar and bumps the pin Changelog: none Issue: broke I9: the fix is a change in the external winnow-grammar repository that the supervisor's comment reserves to itself ("The supervisor builds it in winnow-grammar, then bumps the pin"), so the issue should not be queued for a builder; its To build names no Nikaia-side step Comment: #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. Friction: probe.nika refuses a --file outside the working directory (scratchpad path), copy needed under target/ Disk freed: removed target/probe-2741 Attribution: Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UVxJDutPTwP5Xj5HkGuidk

Debrief

  1. Most cost: almost nothing. The one wasted turn came from probe.nika --file refusing the scratchpad path, so I had to copy the probe under target/ and run it again.
  2. Looked up: only where the winnow-grammar pin sits (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.
  3. Checks: the staleness check of the binary, one probe run and the disk figures. None was wasted. I skipped rebuilding because the one newer commit is an emitter change and the fault is in the external crate.
  4. One change: the driver should not hand a builder an issue whose comment says “the supervisor builds it”, or that waits for an open issue (“comes after #2417”). Failing that, the brief should say at the top that the issue is blocked or belongs to the supervisor.
  5. What the issue lacked:
    • 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.
  6. Traps for the next builder:
    • 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.
  7. For the next builder in this area:
    • 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

keywan-ghadami, 2026-11-30

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

keywan-ghadami, 2026-11-30

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

Back to Open Issues