Commit 88da9b9
committed
docs: add BackendRegistry typing and uniform-signature rules to AI instructions
Document two new conventions in CLAUDE.md, AGENTS.md, and
.cursor/rules/project.mdc so future contributors (and AI assistants)
don't reintroduce untyped registries or per-backend dispatcher branches:
1. **Registry typing rule** -- every BackendRegistry[F] instance MUST
be parameterised with an explicit Protocol type F defined next to
the backends it describes. Never declare a bare BackendRegistry
without a type parameter (caller loses type inference on
compute_fn). Include a concrete example with RMSDMatrixBackendFn.
2. **Uniform signature rule** -- every backend registered in the same
registry MUST accept the exact Protocol call signature. If one
backend needs an extra kwarg (e.g. periodic on mdtraj), every
other backend MUST also accept that kwarg, silently ignoring it
with # noqa: ARG001 and a docstring note. This keeps the
dispatcher branch-free and preserves type inference.
Also add an "Adding a New Backend Registry" checklist to CLAUDE.md
and AGENTS.md so contributors know the Protocol/Literal/__init__
bookkeeping needed for a brand-new multi-backend compute function.
No code changes.1 parent 4200897 commit 88da9b9
3 files changed
Lines changed: 96 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
53 | 74 | | |
54 | 75 | | |
55 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
143 | 162 | | |
144 | 163 | | |
145 | 164 | | |
146 | 165 | | |
147 | | - | |
| 166 | + | |
148 | 167 | | |
| 168 | + | |
149 | 169 | | |
150 | 170 | | |
151 | | - | |
| 171 | + | |
152 | 172 | | |
153 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
154 | 183 | | |
155 | 184 | | |
156 | 185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
301 | 334 | | |
302 | 335 | | |
303 | 336 | | |
304 | 337 | | |
305 | 338 | | |
306 | 339 | | |
307 | | - | |
| 340 | + | |
308 | 341 | | |
309 | 342 | | |
310 | | - | |
| 343 | + | |
311 | 344 | | |
312 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
313 | 355 | | |
314 | 356 | | |
315 | 357 | | |
| |||
0 commit comments