Repository navigation
fix(plugin): plumb Document.tags/links through plugin round-trip (closes #1214) - #1217
Merged
Merged
Conversation
#1214) The plugin layer dropped Document.tags and Document.links on **both legs** of the round-trip, meaning any Document passing through a plugin (even a no-op) lost its tags/links, and plugins synthesizing Document directives couldn't attach them. Four sites needed plumbing -- all `#1144`'s incomplete cascade: 1. **`DocumentData` DTO** (`crates/rustledger-plugin-types/src/lib.rs:821`) -- add `tags: Vec<String>` and `links: Vec<String>` with `#[serde(default)]` for backward-compat with serialized plugin state that predates this field. 2. **`document_to_data`** (`crates/rustledger-plugin/src/convert/to_wrapper.rs:236`) -- propagate `doc.tags`/`doc.links` via the same `.iter().map(ToString::to_string).collect()` pattern Transaction uses one site above. 3. **`data_to_document`** (`crates/rustledger-plugin/src/convert/from_wrapper.rs:389`) -- reconstruct `tags`/`links` from the DTO via `.iter().map(|t| t.as_str().into()).collect()`, mirroring Transaction's reverse path. 4. **WIT `record document`** (`crates/rustledger-plugin/wit/world.wit:145`) -- add `tags: list<string>, links: list<string>` so non-Rust plugins (Component Model consumers) see the new fields. No codegen to regenerate -- this WIT is a contract definition; the actual plugin transport uses MessagePack. Drive-by: `document_discovery.rs` plugin constructs `DocumentData` directly; updated to fill `tags: vec![], links: vec![]` so the new required fields type-check (the plugin discovers documents from disk and has no tag/link source). Regression test `test_roundtrip_document_tags_and_links_1214` in `rustledger-plugin::convert::tests` constructs a Document with non-empty tags/links, runs it through `directive_to_wrapper` -> `wrapper_to_directive`, and asserts both fields survived. Pre-fix this test would have failed at both `document_to_data` (where fields were unread) and `data_to_document` (where they were hardcoded to empty). Co-Authored-By: Claude Opus 4.7 <[email protected]>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes loss of Document.tags and Document.links when Documents pass through the plugin system by plumbing these fields through both directions of the plugin wrapper conversion, updating the plugin DTOs and WASM plugin WIT schema, and adding a regression test to prevent recurrence.
Changes:
- Added
tags/linkstoDocumentData(with#[serde(default)]for backward compatibility) and populated them indocument_to_data/data_to_document. - Extended the WASM plugin WIT
documentrecord to includetags/links. - Updated the filesystem-based document discovery plugin to initialize empty
tags/links, and added a round-trip regression test.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/rustledger-plugin-types/src/lib.rs | Extends DocumentData with tags/links and defaults for backward-compatible deserialization. |
| crates/rustledger-plugin/src/convert/to_wrapper.rs | Propagates Document.tags/links into DocumentData when wrapping core directives for plugins. |
| crates/rustledger-plugin/src/convert/from_wrapper.rs | Reconstructs core Document.tags/links from DocumentData on the return path. |
| crates/rustledger-plugin/src/convert/mod.rs | Adds a focused regression test ensuring Document tags/links survive plugin round-trip conversion. |
| crates/rustledger-plugin/src/native/plugins/document_discovery.rs | Updates direct DocumentData construction to include empty tags/links. |
| crates/rustledger-plugin/wit/world.wit | Updates WASM plugin ABI schema for Document directives to include tags/links. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
📊 Benchmark Results
vs main branch (2026-05-28)
What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
This was referenced May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The plugin layer dropped
Document.tagsandDocument.linkson both legs of the round-trip, meaning any Document passing through a plugin (even a no-op) lost its tags/links, and plugins synthesizing Document directives couldn't attach them. Surfaced during the #1212 deep review; same#1144-cascade as #1213, but with wider plumbing.Four sites:
DocumentDataDTO (rustledger-plugin-types) — addtags/linkswith#[serde(default)]for backward-compat with serialized plugin state.document_to_data(rustledger-plugin/convert/to_wrapper.rs) — propagate from coreDocument; same pattern Transaction uses one site above.data_to_document(rustledger-plugin/convert/from_wrapper.rs) — reconstruct on the way back; mirror Transaction's reverse path.record document(rustledger-plugin/wit/world.wit) — addtags: list<string>, links: list<string>so non-Rust Component Model plugins see the fields.Drive-by:
document_discovery.rsconstructsDocumentDatadirectly; updated to fill emptytags/links(no source for them in a filesystem-discovery plugin).Adds
test_roundtrip_document_tags_and_links_1214— pre-fix it would fail at both legs.Test plan
cargo test -p rustledger-plugin -p rustledger-plugin-types— all suites pass (126 + 176 + integration)cargo check --workspace --all-targets— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo fmt --all -- --check— cleanCloses #1214.
🤖 Generated with Claude Code