Development Conventions
Version: 0.4.x
Code style
- Python: type hints everywhere, ruff for formatting/linting, Python 3.11+
- TypeScript: strict mode, ESM, Node 18+
- Docstrings on public APIs and modules
Architecture rules
- Route handlers must be thin — delegate to services
- Business logic in
server/services/ - Data access in
server/db/repositories.py— all SQL lives here - Domain types in
server/domain/models.py - API schemas in
server/schemas/(requests.py, responses.py) - Error definitions in
server/core/errors.py - Middleware in
server/core/(middleware.py, auth.py, ratelimit.py, tenant.py) - Compilers implement
server/services/compilers.BaseCompilerprotocol - Embedding providers implement
server/services/embeddings.BaseEmbeddingProviderprotocol
Error handling
- All errors return structured
{"error": {"code", "message", "details", "request_id"}}shape - Custom exceptions (
NotFoundError,ConflictError,ValidationError) inserver/core/errors.py - Middleware errors (auth, rate limit, tenant) use the same JSON shape
- SDKs parse these into typed exception classes
Testing
- pytest for Python repos (server + SDK),
asyncio_mode = "auto" - vitest for TypeScript SDK
- Server: 97 tests (75 unit + 22 integration; integration requires Postgres)
- Python SDK: 14 tests (model parsing + exports)
- TypeScript SDK: ~10 tests (construction + error classes)
- Integration tests use a separate test database via
conftest.pywithNullPool - New features should include unit tests; integration tests for data-path changes
CI
All repos have GitHub Actions CI workflows:
statewave: lint + unit tests + integration tests on push/PRstatewave-py: lint + tests on push/PRstatewave-ts: build + tests on push/PR
SDK versions
| SDK | Version | Key features |
|---|---|---|
| statewave-py | 0.4.x | Sync + async clients, typed exceptions, auth, tenant, semantic search, batch ingestion, subject listing |
| statewave-ts | 0.4.x | Typed errors, auth, tenant, semantic search, batch ingestion, subject listing, ESM |
Configuration
All server settings via STATEWAVE_ prefixed env vars or .env file. See API contract for the full configuration reference.
Git
- Conventional commits preferred
- One logical change per commit
- PRs should reference the target repo clearly
- Version tags:
v0.X.Yon each repo