Datum: 2026-08-03
Status: Active
Primary: api_contracts/README.md, include/**/*.h
Bezug: Maschinenlesbare API-Verträge pro Modul
| API | Namespace | Input Contract | Output Contract | Errors | Thread-Safety | Ownership/Lifetime | Notes |
|---|---|---|---|---|---|---|---|
| `functionName(...)` | `themis::module` | Preconditions (types, ranges, null checks) | Return type, invariants, validity | Possible exceptions/error codes | Concurrent calls allowed? Single-writer? | Ownership transfer? Borrowed refs? | Performance class (P0/P1/P2), C++ version required, stability |- Function/method name with signature
- Link to header file if possible:
name (path/to/header.h)orname -> ../include/module/header.h
Example:
search(std::string_view key)
- Full namespace path including
themis::
Example:
themis::index
- Parameter types & allowed values
- Preconditions (null-check required? max size? encoding?)
- Format constraints (UTF-8? ASCII-safe?)
Example:
key: non-empty UTF-8 string, max 1 KB
options: valid IndexSearchOptions or default
- Return type & semantic meaning
- Validity guarantees (is result guaranteed non-null? immutable?)
- Invariants (sorted? deduplicated? ordered by score?)
Example:
std::optional<Value> or null if not found
Result guaranteed immutable; caller must not modify
- Possible exceptions / error codes
- When/why they occur
- Recovery strategy (can caller retry? should it abort?)
Example:
IndexCorruptionError: corrupted internal state → abort
NotFoundError: key not found → OK to retry
TimeoutError: inference took > 30s → caller may retry
- Can multiple threads call concurrently?
- Locking strategy (mutex per operation? RW-lock? lock-free?)
- Side effects on other threads?
Example:
✅ Thread-safe: multiple concurrent readers; writes serialized
🔒 Internal mutex per operation
⚠️ Not thread-safe: single-threaded only
- Does caller own returned pointer/reference?
- Transfer of ownership? Borrowed reference?
- Lifetime of output relative to input?
Example:
Returns std::unique_ptr<> → caller owns lifetime
Borrowed reference; valid until next call to put()
Returns view valid only within this transaction
- Performance class (P0/P1/P2), gate if applicable
- C++ standard required (C++17, C++20?)
- API stability (public/frozen, internal/fluid, deprecated?)
- Any special requirements
Example:
P0 (Hot-path); GATE-INDEX-01 ≤10µs
Public API v1.x (stable)
Requires C++20 concepts
| `search(string_view)` | `themis::index` | key: UTF-8 ≤1KB | std::optional<Value>, immutable | IndexCorruptionError, TimeoutError | ✅ Multi-reader, single-writer | Returns optional; no ownership | P0; GATE-INDEX-01 ≤10µs; public v1.x |Start with these (used heavily across codebase):
- api — HTTP/gRPC/GraphQL transport interface
- llm — LLM inference, model switching
- index — Index operations (search, insert, delete)
- storage — RocksDB K-V backend
- transaction — Transaction coordinator (2PC/3PC/SAGA)
- auth — Authentication & authorization
Script: scripts/ai-context-lint.py (optional future work)
- Scans
include/**/*.hfor public functions - Extracts Doxygen comments
- Generates skeleton rows (human review required)
Workflow: .github/workflows/maintenance-docs.yml
- On PR: validate API contract rows exist for modified public APIs
- On merge: regenerate skeleton rows for new functions (optional)
- On schedule: weekly verification
See api_contracts/api.md for filled example.
Key sections:
- Transport layer APIs (HTTP, gRPC)
- Version routing
- Error taxonomy
- Rate limiting & load shedding
Zuletzt geprueft (API Contract Templates): 2026-08-03