Skip to content

Consolidate Rust guard FFI serialization and output handling - #15776

Merged
lpcox merged 3 commits into
mainfrom
copilot/rust-guard-consolidate-serialize
Oct 30, 2026
Merged

lpcox merged 3 commits into
mainfrom
copilot/rust-guard-consolidate-serialize

Conversation

Copilot AI commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Four FFI output paths duplicate serialization and buffer-write handling while requiring distinct failure semantics: -1 for agent/resource labeling, 0 to skip response labeling.

  • Shared helper: Route all four paths through serialize_and_write, with an explicit caller-selected error code.
  • Preserved behavior: Retain response skip-labeling diagnostics and existing buffer validation.
  • Regression coverage: Check serialization and undersized-buffer failures for each export path.
serialize_and_write(&output, output_ptr, output_size, "label_resource", -1)
serialize_and_write(&output, output_ptr, output_size, "label_response/path", 0)

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot AI changed the title [WIP] Extract serialize and write helper for FFI exports Consolidate Rust guard FFI serialization and output handling Oct 30, 2026
Copilot AI requested a review from lpcox October 30, 2026 20:45
@lpcox
lpcox marked this pull request as ready for review October 30, 2026 20:54
Copilot AI auto review requested due to automatic review settings October 30, 2026 20:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The Rust guard FFI serialization and output-handling refactor has no active review issues.

No open issues 🎉

What changed in this PR

Consolidates Rust guard FFI serialization and output handling into a shared helper, addressing #15743 while preserving each export’s failure behavior.

Changes:

  • Routes all four output paths through serialize_and_write.
  • Preserves -1 errors for agent/resource labeling, 0 skip results for response labeling, and existing buffer validation.
  • Adds helper regression tests for serialization and undersized-buffer failures across all four caller configurations.
File Description
guards/​github-guard/​rust-guard/​src/​lib.rs Adds the shared helper, replaces duplicated output handling, and tests failure-code preservation.

Review effort: Balanced (auto)

@lpcox

lpcox commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main and resolve conflicts

…nsolidate-serialize

# Conflicts:
#	guards/github-guard/rust-guard/src/lib.rs

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>

Copilot AI commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge main and resolve conflicts

Merged main and resolved the conflict in rust-guard/src/lib.rs, preserving both test additions. Merge commit: 7fa1599.

@lpcox
lpcox merged commit 0e74bbf into main Oct 30, 2026
30 checks passed
@lpcox
lpcox deleted the copilot/rust-guard-consolidate-serialize branch October 30, 2026 21:27
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.

[rust-guard] Consolidate duplicated serialize-and-write blocks in FFI exports

3 participants