OpenAI-compatible batch API gateway for llm-d. Three binaries: apiserver, batch-processor, batch-gc.
- Think before coding: State assumptions explicitly. If uncertain, ask. Don't guess silently.
- Simplicity first: No features beyond what was asked. No abstractions for single-use code. No error handling for impossible scenarios.
- Surgical changes: Only touch what you must. Don't "improve" adjacent code, comments, or formatting. Match existing style.
- Logging: Use
logr.Logger— not stdliblog(banned in non-test code) orkloglogging functions. - Interfaces: Verify compliance at compile time:
var _ Interface = (*Impl)(nil). This project uses this pattern extensively. - Errors: Wrap with
%w(not%v) so callers can useerrors.Is/errors.As. Handle errors once — return OR log, never both. Only wrap when adding context the caller doesn't have — keep wrap messages short (function/operation name). Exported error vars useErrprefix (var ErrNotFound = errors.New(...)). - Tests: Table-driven with subtests. Group tests for the same function under one
TestXxxusingt.Run(), not separateTestXxx_Case1,TestXxx_Case2functions. Usenamefield for test case description. - Structs: Always use field names in initialization. Use
var s Tfor zero values, nots := T{}. - Goroutines: Never fire-and-forget. Always provide a shutdown signal mechanism. Prefer small channel buffers (0 or 1). Larger buffers need justification.
- Early return: Handle errors first and return early to reduce nesting.
- No panic: Never use
panic()in production code. Return errors instead. - No os.Exit outside main:
os.Exitandlog.Fatalbelong only inmain(). Everywhere else, return errors. - No mutable globals: Avoid package-level mutable variables. Use dependency injection. Exceptions: compiled regexps, SQL schemas, error sentinels.
- Type assertions: Always use comma-ok form
v, ok := x.(T)to avoid panics. - No init(): Avoid
func init(). Pass dependencies explicitly. - Defer for cleanup: Use
deferto release resources (files, locks, HTTP bodies).
make build— compile all binariesmake tidy— run after modifying go.mod/go.summake pre-commit— run before committing (formatting, vet, lint, unit tests, security scan)
- Unit tests:
make test - Integration tests:
make test-integration(ormake test-allfor unit + integration) - E2E:
make dev-deployto deploy to a local Kind cluster, thenmake test-e2e