|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +AbstractPPL.jl is a Julia interface package for probabilistic programming. It is used by `DynamicPPL.jl` (`https://github.com/TuringLang/DynamicPPL.jl`) and `JuliaBUGS.jl` (`https://github.com/TuringLang/JuliaBUGS.jl`). Most of the package is contract surface: a small model API, a prepared-evaluator API, and a nontrivial `VarName`/optic subsystem used across the Turing ecosystem. |
| 4 | + |
| 5 | +## Conventions |
| 6 | + |
| 7 | + - Make the smallest correct change. |
| 8 | + - Treat exported behaviour, examples, and tests as the package contract. |
| 9 | + - Keep source, tests, and docs aligned for public behaviour changes. |
| 10 | + - Prefer narrow, explicit methods over broad signatures. |
| 11 | + - Keep weakdep-specific behaviour in `ext/`. |
| 12 | + - Prefer targeted fixes over broad refactors. |
| 13 | + - Avoid new dependencies unless clearly justified. |
| 14 | + |
| 15 | +## Package-Specific Notes |
| 16 | + |
| 17 | + - Preserve the model invariants documented in `src/abstractprobprog.jl`: `condition`/`decondition` and `fix`/`unfix` are intended to round-trip when supported. |
| 18 | + - `rand(model)` and `predict(model, params)` have default RNG/type forwarding behaviour covered by tests; changes here should stay consistent with `AbstractMCMC` expectations. |
| 19 | + - The evaluator API in `src/evaluator.jl` is structural. `prepare(..., prototype::NamedTuple)` fixes field structure, `capabilities` defaults conservatively to `DerivativeOrder{0}()`, and AD-aware prepared objects are expected to return gradients with the same named structure as inputs. |
| 20 | + - `VarName` and optics are the main complexity in this repo. Preserve equality, hashing, pretty-printing, composition/decomposition, and type-stability behaviour. |
| 21 | + - Dynamic indices (`begin`, `end`, expressions containing them) are intentionally deferred until `concretize`; do not silently erase that distinction. |
| 22 | + - Unconcretized dynamic indices must not be serialised. If serialization changes, keep `varname_to_string` / `string_to_varname` round-tripping for supported index types. |
| 23 | + - `@varname(..., true)` cannot auto-concretize when the top-level symbol is interpolated; preserve that error path unless the design is intentionally changed. |
| 24 | + - `subsumes` is conservative by design. Do not broaden it casually for ambiguous indexing forms. |
| 25 | + - `getvalue` / `hasvalue` on `AbstractDict{<:VarName}` intentionally prefer exact matches, then walk up to more general parents when possible. |
| 26 | + - The Distributions extension exists to reconstruct structured values from elementwise `VarName` entries. Keep that logic in `ext/`, and prefer the simpler two-argument `getvalue` / `hasvalue` methods unless distribution-shaped reconstruction is actually needed. |
| 27 | + - There is explicit code to keep optic equality JET-friendly and to work around Julia tuple-equality issues; changes around optic equality need extra care. |
| 28 | + |
| 29 | +## Testing |
| 30 | + |
| 31 | + - Start with a minimal reproducer and run the smallest relevant test scope. |
| 32 | + - Main test command: `julia --project=. -e 'using Pkg; Pkg.test()'` |
| 33 | + - CI-style variants: |
| 34 | + `GROUP=Tests julia --project=. -e 'using Pkg; Pkg.test()'` |
| 35 | + `GROUP=Doctests julia --project=. -e 'using Pkg; Pkg.test()'` |
| 36 | + - VarName or optic changes usually need coverage for equality/hash, concretization, `hasvalue`/`getvalue`, serialization, and JET-sensitive cases. |
| 37 | + - Public API changes should keep Aqua and doctests passing. |
| 38 | + - If a change may affect ecosystem compatibility, consider the downstream `DynamicPPL.jl` integration workflow as part of validation. |
| 39 | + - Do not weaken tests just to make CI pass without explicit confirmation. |
| 40 | + |
| 41 | +## Docs |
| 42 | + |
| 43 | + - Keep `docs/src/` aligned with public API and examples. |
| 44 | + - `docs/src/interface.md` is explicitly marked outdated and aspirational; prefer current source, tests, and docstrings over that page when they conflict. |
| 45 | + - Build docs with: `julia --project=docs -e 'using Pkg; Pkg.instantiate(); include("docs/make.jl")'` |
| 46 | + - Follow `.JuliaFormatter.toml` when formatting is part of the task. |
0 commit comments