|
| 1 | +## Project |
| 2 | +mdkd: An LSP client lightning node integrated with [MoneyDevKit](https://moneydevkit.com/) |
| 3 | +This project is released. Be careful about backwards compatibility. |
| 4 | + |
| 5 | +## Commands |
| 6 | +`just` lists all recipes. Use `just check` for quick validation (clippy, fmt, tests, nix) |
| 7 | +as you work. Use `just integration-tests` to run the slower integration tests when |
| 8 | +you are finished as a final check. |
| 9 | + |
| 10 | +## Planning |
| 11 | +- When planning a non-trivial change, you can use `git --no-pager log -n 3 -L <start>,<end>:<file>` |
| 12 | +for more context about a particular section of code. Commit messages can carry important context in |
| 13 | +this project so leverage that. Skip this for obvious fixes and additions. |
| 14 | + |
| 15 | +## Guidelines |
| 16 | +- **Pure core, thin effectful shell.** Separate logic from I/O and other side-effects. Build pure data structures that describe intent, |
| 17 | + then interpret them in a thin layer that performs effects. Test the pure core; the effectful shell should be too simple to fail. |
| 18 | +- **Use integration tests to verify end-to-end behaviour** The unit tests cover the business logic but an integration test |
| 19 | + should still be added to verify end-to-end correctness. These often catch false assumptions of how LDK works. |
| 20 | +- **Only make public what needs to be public** Watch out for and remove unnecessary `pub` modifiers. |
| 21 | +- **Do not reference the plan in code comments.** The code comments should stand on their own as context for the code and not |
| 22 | + refer to plan details like commit numbers and planned followups. Genuine TODOs for deferred work like cleanups |
| 23 | + or refactors are okay when not being performed shortly. |
| 24 | +- **Leverage the bkb-mcp tool** This gives you access to the Bitcoin Knowledge Base. Use this to discover and verify important details about the Bitcoin and Lightning protocols and how they are implemented in LDK. |
| 25 | + |
| 26 | +## Commit Messages |
| 27 | +The commit messaged must be focused on just the staged changes. Do not look at unstaged changes. |
| 28 | +Use context from the conversation to help explain the changes. |
| 29 | + |
| 30 | +Follow the seven basic rules on structure: |
| 31 | + - Separate subject from body with blank line |
| 32 | + - Limit subject to 50 characters (72 hard limit) |
| 33 | + - Capitalize subject line |
| 34 | + - No period at end of subject |
| 35 | + - Use imperative mood in subject (e.g., "Fix bug" not "Fixed bug" or "Fixes bug") |
| 36 | + - Wrap body at 72 characters |
| 37 | + - Body explains what and why, not how. The code diff explains how |
| 38 | + |
| 39 | +Subject test: "If applied, this commit will [subject]" must make sense. |
| 40 | + |
| 41 | +In addition: |
| 42 | +- Avoid listing bullet points that are obvious from the code diff. |
| 43 | +- Nobody should ever wonder why a particular change was made. That said, keep it |
| 44 | + concise and to the point. |
| 45 | + |
| 46 | +## Style |
| 47 | +- Rust 2024 edition |
| 48 | +- Functional: iterators, combinators, folds over mutable loops |
| 49 | +- Algebraic data types; make invalid states unrepresentable in the type system |
| 50 | +- Static dispatch over trait objects (trait objects only for runtime polymorphism) |
| 51 | +- Implement std traits (`FromStr`, `From`, `Display`) over ad-hoc methods |
| 52 | +- Enum variants and match arms in alphabetical order |
| 53 | + |
| 54 | +## Useful Information |
| 55 | +- You can find LDK source code at ../ldk-node and ../rust-lightning |
| 56 | + |
| 57 | +IMPORTANT: Check the README to see if it should be updated after completing a task |
0 commit comments