|
| 1 | +# Conversations |
| 2 | +any resulting updates to agents.md should go under the section "## Rules to follow" |
| 3 | +When you see a convincing argument from me on how to solve or do something. add a summary for this in agents.md. so you learn what I want over time. |
| 4 | +If I say any of the following point, you do this: add the context to agents.md, and associate this with a specific type of task. |
| 5 | +if I say "never do x" in some way. |
| 6 | +if I say "always do x" in some way. |
| 7 | +if I say "the process is x" in some way. |
| 8 | +If I tell you to remember something, you do the same, update |
| 9 | + |
| 10 | + |
| 11 | +## Rules to follow (SUPER IMPORTANT) |
| 12 | +For any code modification task: run dotnet build before applying changes to capture the current error count. After the changes, run dotnet build again and only commit if the error count stays the same or decreases; revert if it increases. |
| 13 | + |
| 14 | + |
| 15 | +# MLXSharp Maintenance Playbook |
| 16 | + |
| 17 | +This repository tracks MLX as a submodule (`extern/mlx`) and publishes a native |
| 18 | +bridge plus .NET bindings. Use the checklist below whenever upstream MLX moves |
| 19 | +forward. |
| 20 | + |
| 21 | +## 1. Sync the Submodule |
| 22 | + |
| 23 | +1. Run the **Sync MLX** GitHub workflow or update manually: |
| 24 | + ```bash |
| 25 | + git submodule update --remote extern/mlx |
| 26 | + ``` |
| 27 | +2. Record the new upstream tag/commit in the PR description. Every automated |
| 28 | + run opens a branch `mlx-sync/<version>` with a tracking issue for follow-up. |
| 29 | + |
| 30 | +## 2. Review Upstream Changes |
| 31 | + |
| 32 | +1. Compare tags: `https://github.com/ml-explore/mlx/compare/<old>...<new>`. |
| 33 | +2. Pay special attention to headers in `extern/mlx/mlx/` and the public C++ API. |
| 34 | +3. Enumerate interface changes that affect our C ABI and managed wrappers. |
| 35 | + |
| 36 | +## 3. Update the Native Bridge |
| 37 | + |
| 38 | +1. Edit `native/include/mlxsharp/api.h` to reflect new structs/functions. |
| 39 | +2. Implement the bridge in `native/src/mlxsharp.cpp` using real MLX calls—no |
| 40 | + stubs. Keep error handling and lifetime management consistent. |
| 41 | +3. Regenerate build files if needed and ensure macOS/Linux settings remain in |
| 42 | + `native/CMakeLists.txt`. |
| 43 | +4. Build the native library on each platform: |
| 44 | + ```bash |
| 45 | + cmake -S native -B native/build/<os> -DCMAKE_BUILD_TYPE=Release |
| 46 | + cmake --build native/build/<os> --target mlxsharp --config Release |
| 47 | + ``` |
| 48 | + |
| 49 | +## 4. Refresh Managed Bindings |
| 50 | + |
| 51 | +1. Extend enums/handles in `src/MLXSharp/Core/*.cs` to cover new constructs. |
| 52 | +2. Add P/Invoke signatures in `src/MLXSharp/Native/MlxNativeMethods.cs` and new |
| 53 | + safe handles or helper classes as needed. |
| 54 | +3. Update higher-level APIs that rely on the bridge; keep Microsoft.Extensions |
| 55 | + integration disabled until parity is re-implemented on top of the new core. |
| 56 | + |
| 57 | +## 5. Validate |
| 58 | + |
| 59 | +1. Build the .NET project: `dotnet build src/MLXSharp/MLXSharp.csproj`. |
| 60 | +2. Ensure native binaries land under `src/MLXSharp/runtimes/...` using the |
| 61 | + provided MSBuild targets. |
| 62 | +3. Run the smoke tests (they skip automatically if the native library is |
| 63 | + missing): `dotnet test src/MLXSharp.Tests/MLXSharp.Tests.csproj`. |
| 64 | +4. Add targeted tests for new functionality before merging. |
| 65 | + |
| 66 | +## 6. Documentation & Release Notes |
| 67 | + |
| 68 | +1. Update `docs/native-roadmap.md` if module coverage or sequencing changes. |
| 69 | +2. Mention notable binding changes in PR descriptions and release notes. |
| 70 | + |
| 71 | +## 7. Before Merging |
| 72 | + |
| 73 | +1. Confirm the automated PR + tracking issue produced by the sync workflow look |
| 74 | + correct (issue assigned to `copoit`). |
| 75 | +2. Resolve the tracking issue only after code, tests, and docs are updated. |
| 76 | + |
| 77 | +Following this playbook keeps the native interop layer aligned with upstream MLX |
| 78 | +and ensures future automation has a single source of truth for maintenance |
| 79 | +steps. |
| 80 | + |
0 commit comments