Operations: building, deploying, benchmarking, releasing
The commands behind the vib-bench deployment and the dbpedia-openai-1M benchmark, and how a version of the SDKs
is released (Releasing). What each stage does: Build pipeline; every driver
flag: Build flags; the scripts themselves: bench/README.md.
Prepare the dataset
Section titled “Prepare the dataset”# prep dataset (dbpedia-openai-1M-1536-angular) and upload shards.venv/bin/python bench/prep/prep_dataset.pybench/prep/upload_shards.sh 6Build the wasm and deploy the Worker
Section titled “Build the wasm and deploy the Worker”cargo build --release --target wasm32-unknown-unknown -p thread-wasmwasm-bindgen --target web --experimental-reset-state-function --out-dir crates/thread-wasm/pkg --out-name thread target/wasm32-unknown-unknown/release/thread_wasm.wasm(cd examples/cloudflare-worker && cf deploy --secrets-file .env.secrets) # run from the example dir, not the repo rootThat is the only deployment: build stages and writes run in build slots (dynamic Workers of vib-bench, one
isolate per slot id, see Build pipeline and
The reference Worker). The stage bundle the slots run is
built by the same cf deploy (vite plugin in examples/cloudflare-worker/vite.config.ts). THREAD_ORCH /
THREAD_SLOTS point the drivers at another deployment / change the build width (default 8).
--experimental-reset-state-function makes wasm-bindgen emit __wbg_reset_state(), which the Worker uses to
recover from a trap. After rebuilding the wasm, sdk/ts/scripts/sync-wasm.sh copies it into the SDK
(cd sdk/ts && npm test).
examples/cloudflare-worker/.env.secrets holds BUILD_TOKEN=<random> and EMBED_API_KEY=<key or -> (an
OpenAI-compatible key for generations whose embedding.provider is openai, - for none; Workers AI needs no
secret, it is the AI binding); every endpoint except /health requires Authorization: Bearer <token>. The SDK
example Worker deploys the same way from sdk/ts/examples/basic (its .env.secrets: AUTH_TOKEN, the S3_*
values and EMBED_API_KEY). Deploy both after a release so the served code and the published SDK share a wasm.
Build a generation and benchmark it
Section titled “Build a generation and benchmark it”# build an index generation (edge profile), then benchmark queriesnode bench/driver.mjs --gen g4 --profile edgenode bench/query_bench.mjs --gen g4 --n 1000 --concurrency 50 # manifest defaultsnode bench/query_bench.mjs --gen g4 --n 1000 --concurrency 50 --nprobe 22 --rerank 100# filtered queries (g4's words are all 0, so only {"attrs":0} or {"attrs":{"$none":...}} match; a schema'd index takes field conditions)node bench/query_bench.mjs --gen g4 --n 1000 --concurrency 50 --filter '{"attrs":{"$lt":1}}' --maxNprobe 68
# change a generation's query defaults (new manifest revision; isolates pick it up within 30 s)curl -X POST -H "authorization: Bearer $TOKEN" $URL/build/publish-rev -d '{"gen":"g4","defaults":{"nprobe":34,"rerank":150}}'# add a centroid tree to an existing generation (new revision; records its recall), compare routingsnode bench/driver.mjs --gen g4 --publish-rev --tree 128,8 --treeRecallBeams 4,16,32node bench/query_bench.mjs --gen g4 --n 6000 --concurrency 50 --nprobe 34 --rerank 150 --extras "route=flat|route=beam&beam=8|route=beam&beam=16"query_bench.mjs sends nprobe/rerank/pc only when the flag is given and prints the values the server used
(server params: nprobe=10 (manifest) ...).
Updates, compaction, splits
Section titled “Updates, compaction, splits”Details: Update path.
node bench/compact.mjs --gen g4 [--purge 1] # fold deltas/tombstones into new slab revisions (build slots)node bench/update_bench.mjs --gen g4 # upsert/delete/compaction benchmark -> data/bench-updates.txtnode bench/update_bench.mjs --gen g4 --only trigger --out data/bench-trigger.txt # automatic compaction benchmarknode bench/split_bench.mjs --gen g4 --maxCellEntries 2400 # split the largest cells, recall/latency before/aftercurl -H "authorization: Bearer $TOKEN" "$URL/index/status?gen=g4" # deltas, tombstones, thresholds, lock, last runsSet or change the automatic compaction policy of a generation:
node bench/driver.mjs --gen g4 --publish-rev --compaction profile \ [--compactMaxDeltas N --compactMaxDeltaMB N --compactMaxTombstones N --compactMaxCellEntries N \ --compactCellsPerRun N --compactDeadlineMs N --compactSplitCellsPerRun N] # --compaction 0 removes itStorage cleanup
Section titled “Storage cleanup”After a generation is published and its build has stopped, POST /build/delete-prefix can remove
build/{gen}/partials/, build/{gen}/parts/ and build/{gen}/pq/partials/. Query serving reads the published
objects under idx/{gen}/, not these intermediates. Send { "prefix": "build/g4/parts/", "dryRun": true }
first, inspect the object count and bytes, then repeat with dryRun: false. The build driver now does this
automatically unless --gcBuild 0 is set; older builds may still have leftovers.
For superseded index objects, use POST /build/gc with { "gen": "g4", "keep": 2, "graceSec": 300, "dryRun": true } before repeating with dryRun: false. This keeps objects referenced by the newest two
revisions and protects recent writes. Older revisions can become unreadable; see GC. The
TypeScript SDK has the same collector (gcGeneration) and deletes a whole superseded generation with
dropGeneration (Switching generations).
Cleanup on 2026-10-04
Section titled “Cleanup on 2026-10-04”Removed the following build intermediates after checking that their counts and bytes matched the dry run, their newest objects were more than an hour old, and the published generations answered queries:
| generation | objects removed | bytes removed |
|---|---|---|
| g2 | 623 | 16,479,425,168 |
| g3 | 1,053 | 32,655,614,160 |
| g4 | 911 | 22,057,584,560 |
| total | 2,587 | 71,192,623,888 |
Every cleaned prefix was empty afterward. Manifests, current pointer, and the first benchmark query’s top-10
IDs and scores matched before and after for g2 rev 0, g3 rev 0, g4 rev 179 and g5 rev 32, with cache=none.
Index GC dry runs found no garbage in g2–g5. g1’s GC failed because idx/g1/slabs.json is missing; its build
intermediates were retained for possible repair. The allowlisted test scratch prefixes were already empty.
Locally, removed data/dbpedia_openai_1M.tgz (5,098,686,329 bytes) after both archive members, vectors.npy
and tests.jsonl, matched their extracted copies by size and SHA-256. Kept the extracted dataset, prepared
ingest shards, benchmark inputs and results, and offline experiment data.
Lexical segments on local files
Section titled “Lexical segments on local files”thread --help and thread <command> --help describe every command and option:
cargo build --release -p thread-clitarget/release/thread seg build --out seg.thread --docs docs.jsonl --text # {"id", "text", "meta"} per linetarget/release/thread seg search --text "deploy failed" --k 10 --with-docs seg.threadA segment built locally is byte-for-byte what an upsert writes (see Text index).
Checks before a commit
Section titled “Checks before a commit”cargo test --workspacecargo check -p thread-core -p thread-wasm --target wasm32-unknown-unknowncargo fmt --all --checkcargo clippy --all-targetscd sdk/ts && npm run typecheck && npm testcd sdk/python && maturin develop --uv && pytest && mypy thread_sdkThe dense-side files predate rustfmt and carry #![cfg_attr(rustfmt, rustfmt::skip)], so the formatter touches
only the lexical modules and new code (clippy warns on 64 pre-existing spots in thread-core; warnings are not
errors). The Python tests include a cross-check against the built TypeScript SDK in sdk/ts/dist. The same checks
run on every push and pull request in .github/workflows/ci.yml, with the wasm built from source there.
Releasing
Section titled “Releasing”A release is a v<version> tag. .github/workflows/release.yml checks the tag against the versions, runs every
check above, builds the wasm from source (so a stale local build can never be published), publishes
@aiuitech/thread-sdk to npm and thread-sdk to PyPI, and attaches the artifacts to a GitHub release.
# 1. one version in three places (the workflow refuses a tag that differs from any of them), a CHANGELOG entrysed -i 's/"version": "0.2.0"/"version": "0.3.0"/' sdk/ts/package.json sdk/ts/package-lock.json # the lock's two root entriessed -i 's/^version = "0.2.0"/version = "0.3.0"/' sdk/python/pyproject.toml Cargo.tomlcargo check --workspace # updates Cargo.lock(cd sdk/ts/examples/basic && npm install) # its lock records the SDK version$EDITOR CHANGELOG.mdgit commit -am "v0.3.0" # in the upstream repository (see below), then push it there
# 2. tag: in the upstream repository, this pushes main here and then the tag v0.3.0, which starts the release../scripts/dev thread releasegh run watch -R aiuitech/thread --exit-status \ "$(gh run list -R aiuitech/thread --workflow release.yml --branch v0.3.0 --limit 1 --json databaseId --jq '.[0].databaseId')"
# 3. deploy the Workers from the same commit(cd examples/cloudflare-worker && cf deploy --secrets-file .env.secrets)(cd sdk/ts/examples/basic && cf deploy --secrets-file .env.secrets)What the workflow produces: the npm tarball (dist/ + the wasm), abi3 wheels (CPython >= 3.11, one per platform:
manylinux x86_64, manylinux aarch64, macOS universal2, Windows x86_64) and an sdist, and a GitHub release
holding all of them plus the raw crates/thread-wasm/pkg as thread-wasm-<version>.tgz.
Credentials and settings the workflow relies on (set once):
- npm: no secret. The package
@aiuitech/thread-sdkhas a trusted publisher (package settings on npmjs.com): GitHub Actions,aiuitech/thread, workflowrelease.yml, environmentnpm, withnpm publishallowed. The job installs npm 11.5.1 or later, which trusted publishing needs, and sets noregistry-url, so no token is asked for. The publish passes--provenance, so it fails rather than publish without an attestation; that needs this repository and the package to stay public.repository.urlinsdk/ts/package.jsonmust name this repository exactly. A new trusted publisher expires unless it publishes within 2 days of its creation; after that, delete it and create it again before a release. - PyPI: no secret. The project
thread-sdkhas a trusted publisher: owneraiuitech, repositorythread, workflowrelease.yml, environmentpypi. The publish step passesskip-existing, so a rerun after a partial publish does not fail on files already uploaded. - GitHub: environments
npmandpypiexist on the repository (no protection rules; add required reviewers there to gate publishing).wasm-bindgenis installed at the version pinned in both workflows (WASM_BINDGEN_VERSION), which must equal the dependency incrates/thread-wasm/Cargo.toml.
This repository is a mirror of the thread/ folder of inseam’s repository, where thread is developed. The
upstream pushes each change of thread/ here as a fast-forward of main, and a release pushes main and then the
tag, so the tag always names a commit of this history.
A tag never moves. If a job fails for a reason outside the code (a runner, a token), run the workflow again on the
same tag (gh run rerun -R aiuitech/thread <run>, or gh workflow run release.yml -R aiuitech/thread --ref vX
when the tag did not trigger it). If the code
must change, release a new patch version: npm may already have the version from the first run, and the published
packages must come from the commit the tag names. Published versions are immutable on both registries.
After the release, Workers outside this repo install the SDK with npm install @aiuitech/thread-sdk@<version> and
import it as sdk/ts/examples/basic does; Python with pip install thread-sdk==<version>.