Skip to content

[Feature] Add bounded range export for C commit-message bodies #1327

Description

@suxiaogang223

Search before asking

Motivation

The C API already exports Java-compatible commit-message bodies, but its
export function serializes the entire handle without an output limit. An
embedding engine with a size-limited RPC cannot select smaller groups or
reject excessive output until encoding and allocation have already occurred.

Solution

Keep the existing API and add:

  • CommitMessage::serialize_with_limit(max_bytes) in core, checking before
    appending bytes to the output while preserving Java v14 body encoding.
  • A C query for the number of messages in a standard message handle.
  • A C export function taking offset, count and a cumulative body-byte
    limit, returning the existing byte-array result and ownership convention.

Reject invalid/overflowing ranges. An exceeded byte limit should return
ResourceExhausted, no partial array, and leave the source usable so the caller
can retry a smaller range. An empty range at or before the end should be valid.

Keep host framing and Java list wrapping outside the API. The byte limit bounds
accumulated body lengths, not peak memory: temporary metadata rows, vector
capacity and result conversion can allocate additional memory.

Anything else?

Coverage should include Java fixture equality, exact and cumulative limits,
range overflow, empty ranges, retry and output lifetime. Format Table export
should remain unsupported. This is a focused follow-up to #1257 rather than
another cross-process protocol. Prepared with AI assistance.

Willingness to contribute

  • I'm willing to submit a PR!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions