Skip to content

Delete the Kotlin callback lent-return quest: no callback can return lent bytes - #927

Merged
kixelated merged 2 commits into
mainfrom
quest/m1/ffi-kotlin-callback-lent
Nov 20, 2026
Merged

kixelated merged 2 commits into
mainfrom
quest/m1/ffi-kotlin-callback-lent

Conversation

@kixelated

@kixelated kixelated commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Deletes quest/m1/ffi-kotlin-callback-lent.md: its problem is not reachable, so there is nothing to fix.

Summary

The quest feared a Kotlin closure or callback returning Rust's lent Bytes, which the GC could free between __Writer.use { ...; finish() } returning and Rust reading the encoding. No such return can exist:

  • A callback trait method may return only a scalar (foreign_return in ffi/src/collect.rs; anything else is a callback signature refusal).
  • A closure may return only a scalar, a String, or a Copy opaque value or an Option of one, or a Result of those with a String error. A Copy value cannot hold Bytes, so the writer lower_ret builds for it never gets a kept owner.
  • ffi/fixtures/reject's gather (impl Fn() -> Vec<u8>) already pins the refusal: closure signature std::vec::Vec<u8>.

Reproduced it instead of assuming: a fixture supplied(count, impl Fn(u32) -> Packet) (a record holding Bytes) to return tokenBytes(..) over 1 KiB under four collector threads fails at export with cannot export fn supplied: closure signature Packet, and a callback trait method returning Packet lands in the census as callback signature supply. Those fixture changes are not kept: the existing gather rejection covers the refusal.

The old limit dates from the exporter spike (#41), so CodeRabbit's finding on #876 was against a path no input reaches; release's reachabilityFence window is moot for the same reason. The argument path, where a JNI call keeps __Lent alive, is unchanged.

Public API and wire impact

None.

Validation

No behavior to exercise: only a quest file is deleted. quest check --base origin/main passes. The reproduction above ran through just ffi test --test fixtures api_kotlin on a throwaway fixture, then reverted.

Decisions

  • Delete the quest rather than rewrite it or hedge the writer (recommended): a return of lent bytes would be new feature work, and it would need its own quest, with the sharing-at-return design (take a Rust owner share in Kotlin before returning) rather than this one.
  • No follow-up added: nothing consumes callback returns of bytes, and moq (the first consumer) does not need them.

Models

Size: S
Implementer: Claude, claude-sonnet-5-5, unknown effort (arm B)

(Written by Sonnet 5.5)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 2a85fd3

  • Base: origin/main at 24ff182

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a1f9d7-5247-7331-88b0-0c198503c5de, round 1

  • Score: 10/10, The deletion removes only an obsolete quest document, changes no executable code or tests, and leaves no references to the deleted file.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

  • Reviewer: Codex, gpt-6.1-sol, low effort, shadow

  • Session: 01a1f9d7-5247-7d33-a2f5-c848453162fa, round 1

  • Score: 10/10, The scoped diff only deletes a quest document, changes no implementation or tests, and introduces no demonstrable behavioral defect.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

Summary by CodeRabbit

  • Documentation
    • Removed the documentation describing the Kotlin callback lifetime issue, proposed test, and potential remedies.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The pull request deletes a quest document about Kotlin callback lent-return lifetimes. The document described the issue, a proposed test, and possible remedies.

Changes: Callback lifetime documentation

Layer / File(s) Summary
Remove callback lifetime note
quest/m1/ffi-kotlin-callback-lent.md
The document describing the lent-return lifetime issue, a proposed collection-forcing test, and possible ways to keep the owner alive during Rust’s read was deleted.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Other

Possibly related PRs

  • kixel-ai/rust2#876: This PR changes Kotlin callback lent-return lifetime handling and refers to the quest document deleted here.

Suggested reviewers: pullfrog

Merge Risk: Minimal · up to 2a85f

This change only removes an obsolete planning document and does not alter runtime behavior, public APIs, or data formats. It is safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: deleting the quest document for the Kotlin callback lent-return issue. The stated reason, that no callback can return lent bytes, matches the objectives. The title is …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: deleting the quest document for the Kotlin callback lent-return issue. The stated reason, that no callback can return lent bytes, matches the objectives. The title is specific, one sentence, and not vague. The changeset deletes only one 9-line file, which the title covers.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f66178e2-2606-4b40-a8c2-3302d78aaa07
Commits

Reviewing files that changed from the base of the PR and between 24ff182 and 2a85fd3.

Files selected for processing: 1

  • quest/m1/ffi-kotlin-callback-lent.md
Files with no reviewable changes: 1

  • quest/m1/ffi-kotlin-callback-lent.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

…lent bytes

The exporter refuses a closure or callback that returns Bytes, a Vec<u8>, or any
record, so the window the quest names has no consumer. fixtures/reject's gather
holds the refusal.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Keep a Kotlin callback's lent return alive until Rust reads it Delete the Kotlin callback lent-return quest: no callback can return lent bytes Nov 20, 2026
@kixelated
kixelated marked this pull request as ready for review November 20, 2026 16:43
@kixelated
kixelated enabled auto-merge November 20, 2026 16:44

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound — the PR's claim (no callback or closure signature can return lent Bytes) is backed by the existing gather rejection in ffi/fixtures/reject, so deleting the quest is the right call.

Reviewed changes

  • Quest deleted — removes quest/m1/ffi-kotlin-callback-lent.md; no other file references it.

Pullfrog  | View workflow run | Using claude-sonnet-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 084795f Nov 20, 2026
10 checks passed
@kixelated
kixelated deleted the quest/m1/ffi-kotlin-callback-lent branch November 20, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant