Code Quality Guardrails
What this skill is for
Use this skill any time you:
- touch core indexing/query code, storage/durability, schema parsing, or the JSON request model
- add/modify CLI flags or HTTP endpoints
- change behavior that could affect correctness, durability, or performance
- add feature-gated functionality (
vectors, gpu, zstd, ffi, wasm/IndexedDB storage)
This is not a “nice-to-have.” The point is to make changes reviewable, reproducible, and safe.
Non-negotiables (definition of done)
A change is “done” only when:
- Formatting is applied to the whole workspace
- Clippy passes with warnings denied
- Build passes with
--all-features (and ideally default features too)
- Tests pass with
--all-features
- Perf-sensitive changes have at least one concrete validation (bench, profiling, or a before/after metric)
- API/schema changes update the artifacts that define the contract (
openapi.yaml, search-request.schema.json, and docs/README examples)
Required commands (workspace root)
Canonical Cargo commands
Run these in the repo root:
just shortcuts
If you use the workspace Justfile, keep the “one-liner” workflows working and equivalent:
just fmt
just lint
just build
just test
just bench
If you update one side (Cargo vs just), update the other.
Toolchain policy (MSRV/pinned toolchain)
- The repo pins a specific Rust toolchain via
rust-toolchain.toml and documents that setup explicitly (currently 1.92.0).
- Treat that as the “works everywhere” baseline unless you intentionally raise it.
If you need a newer language/library feature:
- Prefer an alternative implementation compatible with the pinned toolchain.
- If you must bump the toolchain (currently pinned in
rust-toolchain.toml to 1.92.0):
- change the toolchain file
- update README “Development setup”
- ensure CI (if any) uses the same toolchain
- call out the bump explicitly in the changelog/release notes
Feature matrix expectations
Searchlite is explicitly feature-gated in key areas:
vectors (vector fields + ANN/HNSW behavior)
gpu (GPU stubs / rerank integration points)
zstd (docstore compression behavior)
ffi (C ABI)
- wasm bindings (
searchlite-wasm, IndexedDB-backed storage)
Quality bar:
- Don’t break non-default combinations.
- If you add code under a feature flag, add at least one:
- unit test gated with
#[cfg(feature = "...")], and/or
- integration test that runs only when the feature is enabled.
“Hot path” performance rules
Searchlite advertises small footprint + fast top-k via WAND/BMW pruning and block maxes. That implies real constraints:
When touching query evaluation / ranking
- Avoid allocations in inner loops.
- Prefer reusing buffers (e.g., keep scratch vectors on the struct, clear not reallocate).
- Avoid iterator-heavy abstractions in the deepest loops if they obscure costs.
- Measure with Searchlite’s built-in profiling modes when possible (see debugging-playbook).
Validate pruning modes didn’t regress
Search supports multiple execution strategies:
bm25 (full evaluation)
wand (exact WAND pruning)
bmw (block-max WAND)
When changing ranking/pruning logic, verify correctness/perf by:
- running the pruning example:
cargo run -p searchlite-core --example pruning
- and/or comparing the same query under
execution=bm25 vs wand vs bmw.
Durability & storage invariants (do not weaken)
Searchlite’s durability story is a core product claim. Preserve it:
Core guarantees
- Segment files/manifests are flushed (
fsync) on write.
- WAL is truncated only after the manifest is persisted and synced.
- Manifest updates use atomic rename + directory fsync.
- Crash window is explicitly documented: a crash after manifest write but before WAL truncation causes WAL replay to reapply the last batch (no data loss; compaction cleans it up).
What this means for PRs that touch storage/commit logic
If you change anything in:
- segment writing
- manifest writing
- WAL appending/truncation
- compaction + cleanup
- storage backends (FS vs in-memory vs IndexedDB)
…you must:
- state the durability invariant(s) you preserved in the PR description
- add/adjust tests that cover the crash window / replay behavior
- keep atomic rename + directory fsync semantics for on-disk storage
- keep in-memory storage explicitly “no durability” (don’t accidentally add fsync-ish behavior there)
API contract sync checklist
When you change any of:
- HTTP endpoints, request/response shapes, error format
- CLI flags or subcommand behavior
- JSON request schema (query/filter/aggs/suggest/collapse/etc)
You must update:
openapi.yaml (HTTP contract)
search-request.schema.json (JSON request contract)
- at least one runnable example (README or docs) that exercises the new behavior
Also preserve:
- HTTP errors return the structured form:
{"error":{"type":"...","reason":"..."}}
Review checklist (copy into PRs)
Commit & changelog hygiene
- Prefer Conventional Commit prefixes:
feat:, fix:, perf:, refactor:, docs:, test:, chore:.
- If change impacts compatibility or durability semantics, call it out explicitly.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: code-quality-133description: Guardrails for keeping the Searchlite Rust workspace compliant with formatting, lint, build, test, and perf expectations; use when preparing or reviewing changes to ensure they meet project quality bars. Use when this capability is needed.4---56# Code Quality Guardrails78## What this skill is for910Use this skill any time you:1112- touch core indexing/query code, storage/durability, schema parsing, or the JSON request model13- add/modify CLI flags or HTTP endpoints14- change behavior that could affect correctness, durability, or performance15- add feature-gated functionality (`vectors`, `gpu`, `zstd`, `ffi`, wasm/IndexedDB storage)1617This is not a “nice-to-have.” The point is to make changes **reviewable, reproducible, and safe**.1819---2021## Non-negotiables (definition of done)2223A change is “done” only when:24251. **Formatting** is applied to the whole workspace262. **Clippy** passes with warnings denied273. **Build** passes with `--all-features` (and ideally default features too)284. **Tests** pass with `--all-features`295. **Perf-sensitive changes** have at least one concrete validation (bench, profiling, or a before/after metric)306. **API/schema changes** update the artifacts that define the contract (`openapi.yaml`, `search-request.schema.json`, and docs/README examples)3132---3334## Required commands (workspace root)3536### Canonical Cargo commands3738Run these in the repo root:3940- Format:41 - `cargo fmt --all`4243- Lint (deny warnings):44 - `cargo clippy --all --all-features --all-targets -- -D warnings`4546- Build:47 - `cargo build --all --all-features`4849- Test:50 - `cargo test --all --all-features`5152- Bench (when touching ranking/index/query hot paths):53 - `cargo bench -p searchlite-core`5455### `just` shortcuts5657If you use the workspace `Justfile`, keep the “one-liner” workflows working and equivalent:5859- `just fmt`60- `just lint`61- `just build`62- `just test`63- `just bench`6465> If you update one side (Cargo vs `just`), update the other.6667---6869## Toolchain policy (MSRV/pinned toolchain)7071- The repo pins a specific Rust toolchain via `rust-toolchain.toml` and documents that setup explicitly (currently `1.92.0`).72- Treat that as the “works everywhere” baseline unless you intentionally raise it.7374**If you need a newer language/library feature:**7576- Prefer an alternative implementation compatible with the pinned toolchain.77- If you must bump the toolchain (currently pinned in `rust-toolchain.toml` to `1.92.0`):78 - change the toolchain file79 - update README “Development setup”80 - ensure CI (if any) uses the same toolchain81 - call out the bump explicitly in the changelog/release notes8283---8485## Feature matrix expectations8687Searchlite is explicitly feature-gated in key areas:8889- `vectors` (vector fields + ANN/HNSW behavior)90- `gpu` (GPU stubs / rerank integration points)91- `zstd` (docstore compression behavior)92- `ffi` (C ABI)93- wasm bindings (`searchlite-wasm`, IndexedDB-backed storage)9495**Quality bar:**9697- Don’t break non-default combinations.98- If you add code under a feature flag, add at least one:99 - unit test gated with `#[cfg(feature = "...")]`, and/or100 - integration test that runs only when the feature is enabled.101102---103104## “Hot path” performance rules105106Searchlite advertises small footprint + fast top-k via WAND/BMW pruning and block maxes. That implies real constraints:107108### When touching query evaluation / ranking109110- Avoid allocations in inner loops.111- Prefer reusing buffers (e.g., keep scratch vectors on the struct, clear not reallocate).112- Avoid iterator-heavy abstractions in the deepest loops if they obscure costs.113- Measure with Searchlite’s built-in profiling modes when possible (see debugging-playbook).114115### Validate pruning modes didn’t regress116117Search supports multiple execution strategies:118119- `bm25` (full evaluation)120- `wand` (exact WAND pruning)121- `bmw` (block-max WAND)122123When changing ranking/pruning logic, verify correctness/perf by:124125- running the pruning example:126 - `cargo run -p searchlite-core --example pruning`127- and/or comparing the same query under `execution=bm25` vs `wand` vs `bmw`.128129---130131## Durability & storage invariants (do not weaken)132133Searchlite’s durability story is a core product claim. Preserve it:134135### Core guarantees136137- Segment files/manifests are flushed (`fsync`) on write.138- WAL is truncated **only after** the manifest is persisted and synced.139- Manifest updates use atomic rename + directory fsync.140- Crash window is explicitly documented: a crash after manifest write but before WAL truncation causes WAL replay to reapply the last batch (no data loss; compaction cleans it up).141142### What this means for PRs that touch storage/commit logic143144If you change anything in:145146- segment writing147- manifest writing148- WAL appending/truncation149- compaction + cleanup150- storage backends (FS vs in-memory vs IndexedDB)151152…you must:153154- state the durability invariant(s) you preserved in the PR description155- add/adjust tests that cover the crash window / replay behavior156- keep atomic rename + directory fsync semantics for on-disk storage157- keep in-memory storage explicitly “no durability” (don’t accidentally add fsync-ish behavior there)158159---160161## API contract sync checklist162163When you change any of:164165- HTTP endpoints, request/response shapes, error format166- CLI flags or subcommand behavior167- JSON request schema (query/filter/aggs/suggest/collapse/etc)168169You must update:170171- `openapi.yaml` (HTTP contract)172- `search-request.schema.json` (JSON request contract)173- at least one runnable example (README or docs) that exercises the new behavior174175Also preserve:176177- HTTP errors return the structured form:178 - `{"error":{"type":"...","reason":"..."}}`179180---181182## Review checklist (copy into PRs)183184- [ ] `cargo fmt --all` clean185- [ ] `cargo clippy --all --all-features --all-targets -- -D warnings` clean186- [ ] `cargo build --all --all-features` clean187- [ ] `cargo test --all --all-features` clean188- [ ] If perf-sensitive: bench/profiling evidence included189- [ ] If API/schema touched: `openapi.yaml` + schema JSON updated190- [ ] If durability touched: atomic rename/fsync/WAL ordering preserved + test coverage updated191- [ ] Feature flags respected (vectors/gpu/zstd/ffi/wasm)192- [ ] Docs/examples updated and copy/paste runnable193194---195196## Commit & changelog hygiene197198- Prefer Conventional Commit prefixes: `feat:`, `fix:`, `perf:`, `refactor:`, `docs:`, `test:`, `chore:`.199- If change impacts compatibility or durability semantics, call it out explicitly.200201---202> Converted and distributed by [TomeVault](https://tomevault.io/claim/davidkelley) — claim your Tome and manage your conversions.203<!-- tomevault:4.0:skill_md:2026-04-14 -->