Strict rules, restrictions, and coding instructions for agents working in this repository. See DEVELOPMENT.md for repo layout, architecture, build/test commands, and upgrade procedures.
- No cgo in production: Never add
import "C". All production code must build withCGO_ENABLED=0(only the test-only C layout probe ininternal/abi/abi_test.gomay invokecc). - No unverified platforms: Do not widen build tags in
internal/abi/platform_accepted.gowithout a real-native acceptance run and an updated artifact/SHA-256 entry inREADME.md. - No extra dependencies: Keep direct external dependencies restricted to
github.com/ebitengine/purego(core) andgithub.com/apache/arrow-go/v18(duckdbarrow) unless explicitly asked otherwise. - No non-streaming
Query: Never switchQueryaway fromduckdb_pending_prepared_streamingor remove theduckdb_result_is_streaming == trueassertion. - No library unload: Never call
dlcloseon mapped native libraries. - No lossy type conversions: Never pass bound or decoded SQL values through
float64, string, or JSON intermediates. Reject unsupported logical types during prepare/result inspection even when all rows areNULLor the result is empty. - No globs in views:
ViewSpecmust bind explicit file paths insideinput/only.
- Complete symbol registration: Every field added to
abi.APImust be afuncregistered in(*API).symbols()(verified byTestSymbolsCoverEveryAPIField). - Explicit ownership: Document
ownedvs.borrowedlifetimes on everyabi.APIentry. Copy borrowed C strings/buffers before releasing the parent handle; release owned handles on both success and error paths. Never rely on finalizers for correctness. - Locking discipline:
Conn.muserializes native calls;Conn.cancelMucoordinates cancellation. Never holdConn.cancelMuacross a native call, and never letduckdb_interruptblock onConn.mu. - No-deadline join: Always
join()an activecancelScopebefore reusing or closing any native handle.
- Handle safety: Embed
noCopyin handle structs (checked bygo vet). MakeCloseidempotent and returnErrClosedfor post-close calls. - Owned Go values: Decoded values returned to callers must own their Go memory and never alias native or chunk-backed buffers.
- Error handling: Return and wrap sentinel errors with
%wso callers can match witherrors.Is; do not swallow cleanup errors silently when they indicate resource/state failure. - Context & goroutines: Respect
context.Contextcancellation on blocking operations, rejectnilcontexts withErrInvalidInput, and ensure every spawned goroutine has a deterministic shutdown/join path. - Idiomatic, minimal diffs: Follow standard Go formatting (
gofmt), keep exported API surfaces small and documented, and avoid speculative abstractions.
- Mock first, native paired: Add deterministic mock tests (using fake
abi.APIliterals) for lifecycle, error, budget, and race edge cases so CI (ubuntu-latest, nolibduckdb) covers them; pair native behavior changes with*_native_test.gotests. Use descriptive domain-based test filenames and test function names (never include internal plan phase prefixes such asp0_orTestP1a...). - Required checks before finishing:
- Run
CGO_ENABLED=0 go build ./...,CGO_ENABLED=0 go vet ./..., andCGO_ENABLED=0 go test -count=1 ./.... - When changing ABI, loader, cancellation, budget, session, or
PinnedVersion, also run the full real-native +-racematrix documented in DEVELOPMENT.md.
- Run