Skip to content

Refactor: organize components into folders - #135

Closed
fedgiac wants to merge 9 commits into
mainfrom
reorganize-folder-structure
Closed

Refactor: organize components into folders#135
fedgiac wants to merge 9 commits into
mainfrom
reorganize-folder-structure

Conversation

@fedgiac

@fedgiac fedgiac commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

We're starting to have too many files in the same folders.
The current components can be reorganized nicely by purpose, and this is what this PR aims to do. It should make it easier to find what we need by looking at the filesystem.

To get an idea of the changes, programs/settlement/src/ is very representative:

  before                                     after
  ────────────────────────────────           ────────────────────────────────
  ├── add_solver.rs                           ├── buffer/
  ├── create_buffer.rs                        │   ├── create.rs
  ├── create_order.rs                         │   ├── reclaim.rs
  ├── initialize.rs                           │   └── mod.rs
  ├── lib.rs                                  ├── order/
  ├── processor.rs                            │   ├── create.rs
  ├── reclaim_buffer.rs                       │   ├── reclaim.rs
  ├── reclaim_order.rs                        │   └── mod.rs
  ├── remove_solver.rs                        ├── solver_auth/
  ├── settle/                                 │   ├── add.rs
  │   ├── begin.rs                            │   ├── remove.rs
  │   ├── finalize.rs                         │   └── mod.rs
  │   └── mod.rs                              ├── settle/            (unchanged)
  └── transfer_authority.rs                   │   ├── begin.rs
                                              │   ├── finalize.rs
                                              │   └── mod.rs
                                              ├── initialize.rs
                                              ├── lib.rs
                                              └── processor.rs

How to review

Check in your code locally and make sure that you like the new folder structure.
Only then, check the code and confirm that nothing really changes apart from the import paths.

Also, make sure that all tests are still being run and that we didn't drop tests by accident. For example by running:

cargo test --workspace -- --list 2>/dev/null | grep -cE ': test$'

before and after to check that the number of tests is the same.

@fedgiac
fedgiac requested a review from a team as a code owner August 31, 2026 19:52

@kaze-cow kaze-cow 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.

for the program structure specifically, the reason its somewhat confusing right now is because we mix the processors with everything else in a flattish folder structure. Instead, we should have a folder structure like:

- programs/settlement/src/processors
  - begin_settle.rs
  - finalize_settle.rs
  - create_buffers.rs
  - ...
- programs/settlement/src/helpers
  - settle.rs
  - token.rs
  - ...

Exactly one file per processor. An onlooker can easily find the entrypoint instruction processor they are interested in, which is arguably the most important part to understand about the program.

For the interface, the existing folder structure was better. Grouping by groups of operations doesn't do a lot for our program with only like 10 instructions

For any utilities shared between instructions, those can go in a helpers/ folder

(btw I am not all that opinionated on this, in fact we could keep the folder structure the same! but since you asked me to review if I liked it or not, these are my thoughts)

@fedgiac

fedgiac commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Your suggestion is more complicated than just a folder reorganization like I did here!
Since it's a separate concern (it's about how we treat helpers and files more than folders, it requires splitting existing files, not just moving them), I created a new PR for it, #140.
The folder split is orthogonal so if you don't like it we can close it.
With the changes from #140, the only folder that's starting to get messy is the test folder. Should I keep the changes in this pr for program/settlement/tests/ or just close it?

@fedgiac
fedgiac requested a review from kaze-cow September 1, 2026 22:41

@kaze-cow kaze-cow 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.

This PR appears to be in conflict with #140 , which also splits a number of files and moves them. For example,

interface/src/instruction/create_buffer.rs‎ -> ‎interface/src/instruction/buffer/create.rs

I don't like this change because it breaks the , and making the /file names shorter doesn't do a lot for me. Personally when finding files in the project I use Control-P so there is very little need to navigate or "find" files. but having shorter, more generic file names with longer parent paths like create.rs does make it harder to find the relevant file.

With the changes from #140, the only folder that's starting to get messy is the test folder. Should I keep the changes in this pr for program/settlement/tests/ or just close it?

#140 is great! lets close this one if thats ok

Base automatically changed from federico/sc-361-add-function-to-remove-solvers to main September 4, 2026 08:19
@fedgiac fedgiac closed this Sep 4, 2026
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.

2 participants