Contributing to Tessero
How to get involved in Tessero - from your first patch onward.
AI assistant
Build this with Claude Code, Cursor or Copilot
Copy a Tessero-tuned prompt for Contributing to Tessero, grounded in 16 real API signatures , into your IDE's AI. No chatbot, just exact context.
Thank you for helping. Tessero is numerical infrastructure, so the bar is correctness first, then clarity, then speed.
Ways to help
- Report a wrong number. This is the most valuable contribution. Include
the input (export it with
Tessero\Io\Npy::saveorserialize()), what NumPy/SciPy return for the same input, andvendor/bin/tessero info --json. - Report an installation problem with the output of
tessero doctorandphp -v, and your OS/architecture. - Improve the documentation. The docs are Markdown under
docs/(mkdocs serveto preview). - Pick an item from the roadmap (
docs/project/roadmap.md). Comment on the issue first so work is not duplicated.
Security problems: do not open an issue; see SECURITY.md.
Development setup
Requirements: PHP 8.2+ with ext-ffi and headers (php-dev), GCC or Clang,
Python 3 with NumPy and SciPy (for fixtures), Composer.
make -C csrc # build libtessero into lib/<platform>/ make -C csrc test # C unit tests make -C csrc sanitize # C tests under ASan + UBSan composer install vendor/bin/phpunit # unit + parity + fuzz (+ ext when loaded) cd ext && phpize && ./configure --enable-tessero && make && make test && cd .. php -d extension=ext/modules/tessero.so vendor/bin/phpunit --testsuite ext php -d ffi.enable=1 tests/docs/examples.php # doc examples bash tests/e2e/preload.sh # FPM-style preload php -d ffi.enable=1 bench/run.php # benchmarks with gates
After changing anything in csrc/, run bash tools/sync-ext.sh to update
the extension's copy. CI fails if they differ.
Rules for changes
- Tests come from the reference. New numerical behaviour gets a case in
tests/fixtures/generate_parity.pycomputed by NumPy/SciPy, not a hand-typed expected value. Regenerate withpython tests/fixtures/generate_parity.pyand commit the fixture. - Both backends. If a feature exists in the FFI package and the extension, the extension parity suite must cover it.
- No PHP loops over elements. Loops over data belong in
csrc/. - The ABI header stays FFI-parseable: declarations only in
csrc/include/tessero.h, no macros or includes. New op codes go incsrc/src/ops.handNative\Abitogether (a unit test checks them). - Memory: array-sized allocations use
tsr_alloc/tsr_free, so they count against the budget. Every error path frees what it allocated. ASan must stay clean. - No undefined behaviour: signed integer arithmetic on data uses the
TSR_W*wrap macros. - Errors are typed: C returns a negative code; bindings map it to an exception with a message that names shapes, sizes or the offending index.
- Documentation is part of the change. Update the guide page and the API
docblock, regenerate the API reference
(
php -d ffi.enable=1 -d extension=tessero tools/gen-api-docs.php), and add a changelog entry under "Unreleased". - Architecture changes need an ADR in
docs/architecture/adr/.
Style
- PHP: PSR-12,
declare(strict_types=1), typed signatures, docblocks for anything public. In hot loops, avoid compound assignment on array elements, list destructuring, and element-by-element reads ofCData(copy out withFFI::string+unpack). All three triggered PHP JIT miscompilations; seedocs/project/upstream-bugs.md. - C: C11, 4-space indent,
tsr_prefix for public symbols,staticfor everything else, comments that explain why. - Commit messages: imperative subject ≤ 72 characters, body explaining motivation.
Pull requests
- One topic per pull request, with tests.
- CI must be green. For numerical changes, say in the description which parity cases cover the change.
- Maintainers review within a week. Two approvals are needed for changes to
csrc/orext/, one elsewhere (seeGOVERNANCE.md).
By contributing you agree that your contribution is licensed under the project's BSD-3-Clause licence and that you follow the Code of Conduct.