build(solana,sui): auto-generate presets/mod.rs from filesystem to eliminate per-PR conflicts#278
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR moves the Solana and Sui parser crates from hand-maintained presets/mod.rs / integrations/mod.rs files to build-generated module declarations, reducing merge conflicts when new presets or integrations are added while keeping build-time visualizer discovery intact.
Changes:
- Refactors both
build.rsfiles to returnResult, generategenerated_presets_mod.rs/generated_integrations_mod.rs, and keep the existing generated visualizer registry flow. - Replaces hand-edited
presets/mod.rsstubs in both crates withinclude!-based generated module declarations. - Replaces hand-edited
integrations/mod.rsstubs in both crates with the same generated-module pattern.
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 |
|---|---|
src/chain_parsers/visualsign-sui/src/presets/mod.rs |
Replaces manual Sui preset module list with generated include stub and guidance comments. |
src/chain_parsers/visualsign-sui/src/integrations/mod.rs |
Replaces manual Sui integration module wiring with generated include stub. |
src/chain_parsers/visualsign-sui/build.rs |
Adds generated module-declaration output alongside the existing generated visualizer list. |
src/chain_parsers/visualsign-solana/src/presets/mod.rs |
Replaces manual Solana preset module list with generated include stub and guidance comments. |
src/chain_parsers/visualsign-solana/src/integrations/mod.rs |
Replaces manual Solana integration module wiring with generated include stub. |
src/chain_parsers/visualsign-solana/build.rs |
Refactors build script error handling and generates module declarations for presets/integrations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6 tasks
pepe-anchor
previously approved these changes
May 13, 2026
a0dc3ee to
05bf317
Compare
4 tasks
`src/chain_parsers/visualsign-{solana,sui}/src/presets/mod.rs` was a
hand-edited list of `pub mod <name>;` lines, one per preset. Every PR
that added a preset edited this file at the alphabetically-correct
position, so any two preset PRs whose names landed in adjacent slots
collided on the same hunk during rebase.
This bit us on the most recent Kyle PR rebase batch — PRs #256
(jupiter_earn) and #263 (jupiter_borrow) both conflicted with main's
newly merged dflow_aggregator entry and required hand resolution. With
13 open preset PRs in flight, the conflict cost compounds.
Fix: extend each crate's `build.rs` to also emit
`OUT_DIR/generated_presets_mod.rs` (and the integrations equivalent)
containing `#[path = "<abs>/mod.rs"] pub mod <name>;` per subdirectory,
sorted alphabetically. The hand-edited `presets/mod.rs` becomes a
single-line `include!(concat!(env!("OUT_DIR"), "/generated_presets_mod.rs"))`
stub plus a doc header that says "do not edit". Adding a new preset is
now a directory drop-in — no `mod.rs` edit, no conflict surface.
The `#[path]` attributes are required because `include!` causes Rust to
resolve `pub mod` declarations relative to the included file's location
(OUT_DIR), not the file invoking `include!`. Absolute paths via
CARGO_MANIFEST_DIR keep the generated file build-portable.
Build scripts are now Result-returning (`fn main() -> BuildResult<()>`)
with `?`/`ok_or_else` propagation throughout — no `unwrap()`/`expect()`,
no `#[allow(clippy::unwrap_used)]` workspace-lint dodge.
Verification:
- `cargo build -p visualsign-solana` and `-p visualsign-sui` succeed.
- `cargo clippy --workspace --all-targets -- -D warnings` clean.
- `cargo test --workspace --lib` passes (all 369 library tests).
- `cargo fmt --check` clean.
- Generated content (sample): visualsign-solana writes 9 entries, one
per preset directory, sorted alphabetically.
Knock-on: open Kyle PRs will conflict on `presets/mod.rs` one last
time when rebasing onto this — resolution is to drop the PR's
`pub mod <name>;` line entirely. Future preset PRs need zero edits to
this file.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
05bf317 to
ecd947e
Compare
pepe-anchor
approved these changes
May 14, 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.
Why this PR exists
Every PR that adds a preset to
visualsign-solana(andvisualsign-sui) editssrc/chain_parsers/visualsign-{solana,sui}/src/presets/mod.rsto add a singlepub mod <name>;line at the alphabetically-correct position. Two preset PRs whose names land in adjacent slots collide on the same hunk during rebase.This just bit us on the Kyle PR rebase batch:
jupiter_earn) hit a 2-hunk conflict (added line vs main's newdflow_aggregator, plus a second hunk on the rename-to-Earn commit).jupiter_borrow) hit the same shape.What changed
Extends each crate's
build.rsto also emitOUT_DIR/generated_presets_mod.rs(and the integrations equivalent), containing one#[path = "<abs>/mod.rs"] pub mod <name>;per subdirectory, sorted alphabetically. The hand-editedpresets/mod.rsbecomes a single-lineinclude!(concat!(env!("OUT_DIR"), ...))stub plus a doc header saying "do not edit". Adding a new preset is now a directory drop-in — nomod.rsedit, no conflict surface.The
#[path]attributes are required:include!makes Rust resolvepub moddeclarations relative to the included file (OUT_DIR), not the file invokinginclude!. Absolute paths derived fromCARGO_MANIFEST_DIRkeep the generated file build-portable across machines and CI.Both
build.rsfiles are now Result-returning (fn main() -> BuildResult<()>) with?/ok_or_elsepropagation throughout — nounwrap()/expect(), no#[allow(clippy::unwrap_used)]workspace-lint dodge.Test plan
cargo build -p visualsign-solanaand-p visualsign-suisucceedcargo clippy --workspace --all-targets -- -D warningsis cleancargo test --workspace --lib(369 tests) passescargo fmt --checkis cleantarget/debug/build/visualsign-solana-*/out/generated_presets_mod.rslists every preset directory sorted alphabetically with absolute#[path]Knock-on for in-flight PRs
Open Kyle preset PRs (#256, #257, #258, #261, #263, #264, #265, #266, #267, #269, #270, #276) will need one more rebase after this lands; the
presets/mod.rsconflict on each resolves to dropping the PR'spub mod <name>;line entirely. After that, no more rebase conflicts on this file ever.Why draft
So you can review the
build.rsrewrite (Result-propagating +#[path]mechanism) before promoting / merging.🤖 Generated with Claude Code