Changelog
Versions are shared by the npm package @aiuitech/thread-sdk, the PyPI package thread-sdk and the Rust crates
(Cargo.toml workspace version). A release is a v<version> tag; .github/workflows/release.yml builds the wasm
from source, runs every check and publishes.
0.2.10 (2026-11-18)
Section titled “0.2.10 (2026-11-18)”No change to the code, the format or the SDKs’ behaviour.
- Releases publish to npm through trusted publishing. The release workflow has no npm token: npm’s trusted
publisher for
@aiuitech/thread-sdkissues one through OIDC, and the publish passes--provenance. - This repository is public, as a mirror of thread’s folder in the repository where it is developed
(README,
docs/operations.md).
0.2.9 (2026-11-16)
Section titled “0.2.9 (2026-11-16)”- A must-clause:
idsonsearchandlexicalSearch(TypeScript). Only the given document ids may be returned. The BM25 list keeps to them inside each segment’s scan (LexPostings::search_inin the core; the wasmsearchtakes the set as its last argument,u32LE sorted unique, empty for none), so the top k is exactly the top k of the set, however many other documents score higher. The dense list keeps them after its scan, atrecallKdepth. An empty list returns nothing. For inseam’s guest search (a person shown only the messages they were party to), which ranked the whole host and kept the set, and missed set members below the depth.
0.2.8 (2026-11-14)
Section titled “0.2.8 (2026-11-14)”- Optional vectors per document in an upsert (TypeScript and Python). In the one-row-per-document form of
vectors, a row may benull/None: that document is written without a vector (text, meta, attrs and key in the segment; an older vector of it is hidden, as by any whole-document put) and the others with theirs, in one revision. Before, a batch was all vectors or none, so a caller with some documents to embed and some not wrote two revisions. The delta holds only the rows given, with their ids, attrs and payloads, and its manifestcountis the number of rows;UpsertResult.cellslists one cell per row given. Every rownullis a text-only batch (no delta). Refused, with nothing written: anullrow without a lexical configuration, or in a batch with no texts, metas or keys (the document would be only a tombstone); a non-empty payload at anullrow; anynullrow underscope: "dense". Given vectors are never embedded over, so in a generation that names its model anullrow is text-only. The flatn * dimform is unchanged. BulkBuildloads each stage with one upsert (TypeScript): a stage that mixed documents with and without a vector was replayed as two upserts, two revisions; it is now one, withnullrows.
0.2.7 (2026-11-14)
Section titled “0.2.7 (2026-11-14)”- Dense compaction reads what its slice needs, not the whole backlog, and the oldest delta always folds
(TypeScript,
compact()/compactDeltas). Before it planned, a call read every tombstone set (one get each) and every delta’s entry table (two range gets each), and the deadline counted from the start of the call. When that read phase took longer than the deadline, no cell started, the run endeddeadlinewith 0 cells, and the backlog only grew (inseam, 2026-11-14, SDK 0.2.5: 767 deltas of about 3 KB and 2,531 tombstone sets, about 4,000 gets taking 20 to 30 s against a 10 s deadline; every run endeddeadlinewith 0 cells, and one Durable Object alarm passed its limit of 10,000 R2 reads). Now:- The deltas’ cells are read oldest first in windows of 8, and the call plans after each window. Reading stops
when the slice is full (16 deltas in a row could not join it), or when reading has used a third of
deadline - 2.5 s; the first window is always read. A delta up to 64 KiB is read whole, one get that is also the fold’s input (before: two range gets, then the whole delta again). While some deltas are unread, a split cell keeps its mean andforcetakes no oversized cell on its own. - A tombstone set’s ids are read once, when a cell being rewritten or a delta being folded is filtered by it (a slab of slabRev r by the dense-view sets with rev >= r, an empty slab by none, a delta added at rev a by those with rev > a), or when its drop depends on the build-id test alone. Lexical-scoped sets are not read for this (only, within the deadline, to merge them: see the next entry). The planner’s memory estimate uses the counts in the manifest.
- The oldest delta folds in every call that plans: the cells it needs to commit run first, whatever the deadline,
and are committed. Only the lock, a conflict or a 413 stops it. Such a call can take longer than
deadlineMswhen the oldest delta alone needs more; its note then startsread phase passed the deadline:with what was read. A purge- orforce-only call whose read phase passed the deadline endsdeadlinewith that note. CompactResult.reads(also incompact.last.json): deltas and tombstone sets read, of those the base lists, and the ms to the plan.- The objects a compaction writes are unchanged (
test/compact-worker.test.tsstill matches the Worker byte for byte).test/compact-backlog.test.tsbuilds 300 deltas and 1,240 tombstone sets from small upserts, dense-scoped and lexical-scoped re-puts and deletes, then callscompact({ deadlineMs: 1 })until nothing is due: on 0.2.6 each call made 2,145 gets and endeddeadlinewith 0 cells; now 56 calls take the backlog from 300 deltas to 3, each folds at least one, reads 8 deltas, never reads a lexical-scoped set, and makes at most 1,157 gets (613 on average with the next entry, 615 without). Every live document, deleted id and replaced vector answers as before. The tombstone sets are most of those gets: a delta being folded needs every set newer than it, and a cell whose slab predates a set needs it (the next entry merges what it can).
- The deltas’ cells are read oldest first in windows of 8, and the call plans after each window. Reading stops
when the slice is full (16 deltas in a row could not join it), or when reading has used a third of
- Dense compaction merges tombstone sets no reader can tell apart (TypeScript,
compact(),tombMergeRuns). Every upsert or delete writes a set, so small writers leave thousands (inseam: 2,531 at rev 2,803), and every cold open and every purge reads them one get each; before, a set left the manifest only when droppable. Now the commit replaces each run of sets of one scope that no delta (addedRev in [s1, sn)), slab (slabRev in (s1, sn]) or segment (addedRev in [s1, sn)) of the committed revision tells apart by one settombstones.{sn}.m{s1}.u32holding the union, at rev sn: every filter a reader builds stays the same, and the merged set drops exactly when all its members would. Sets with build ids merge only with each other (they never drop). A run merges once it has 8 sets, longest first; the sets the call read anyway are free, at most 256 others are read for it, none within 1 s of the deadline. A call with nothing else to do still commits a merge; withforce,morestays true while runs are left after a call that merged.CompactResult.mergedTombstoneSetsandtombSets,change.mergedTombstoneSetsandmergedInto, andcompact.last.jsonrecord it;mergeTombstoneSets: falseturns it off.countis the union’s size, so themaxTombstonespressure counts the ids a filter holds, without repeats. No format change: readers of every version take sets byTombRef.key(TS, Python, the Worker), packs and GC list them by key, and the old sets stay for the revisions that list them (/build/rollbackacross a merge needsforce).test/compact-merge.test.ts(78 cells, 805 sets from small writes, deletes and re-inserts, compacted with and without merging, every answer compared with an uncompacted copy): 500 sets left instead of 805 after the short calls, 2 instead of 730 after a segment compaction, 94 instead of 998 after more writes; the purge read 69 sets instead of 973. What it cannot change: a call folding the oldest delta of a backlog still needs every set newer than that delta, and the deltas between them keep them apart (89,430 against 95,852 set reads over 218 short calls).test/tomb-merge.test.tschecks the rule on 3,000 random histories (every filter and every drop, now and after deltas fold and slabs are rewritten; every cut needed). - Small writes: no delta coalescing, a batch size instead. Folding is the coalescing: one call folds many tiny deltas (83 deltas of one vector into 60 cells in one call of the test above). docs/update-path.md “Small writes” lists what each write costs (a revision whose manifest lists the whole backlog, about ten requests, a delta, a segment, a set) and recommends at least 64 documents per write, or what arrived in the last second.
- Python: no change;
tests/test_interop.pyreads a generation whose sets the TS SDK merged, and the revision before the merges, and answers as TS does. The Worker’s own compaction is unchanged (it reads, filters and drops merged sets like any other;test/compact-worker.test.tscompacts and rolls back such a generation with it).
0.2.6 (2026-11-09, not published: it ships in 0.2.7)
Section titled “0.2.6 (2026-11-09, not published: it ships in 0.2.7)”- The block cache keeps alive only the bytes a read asked for (TypeScript,
CachedBlobStoreover the Workers Cache API). 0.2.5’s block reads returnedsubarrayviews of the blocks they filled, so every range a caller kept held its whole block after the block’sblockBuffersslot was released, andblockBuffersbounded nothing: 160 ranges of 16 bytes across a large segment, read cold, kept 160 MiB alive withblockBuffers: 2(inseam’s review, 2026-11-09; 0.2.4 kept 2,560 bytes). In a Worker (128 MB isolate) a cold search over sparse ranges of large segments could run out of memory. Now each range is copied out of its block (or out of the cache response it came in) before the block’s slot is given back, on every path ofgetandgetRanges: a block filled from the origin, a block being filled by another reader, a cached block (206 or 200), and an object cached whole read for a range withoutfill. The memory block reads keep alive is the bytes returned plus at mostblockBuffersblocks in flight.test/blocks.test.tscounts the block buffers alive after a forced GC: 160 cold reads of 16 bytes over 64 KiB blocks kept 160 blocks (10 MiB) on 0.2.5 and keep none (2,560 bytes) now, and a block read starts with at most one other block alive atblockBuffers: 2(159 before). The 0.2.5 workaroundopen({ blockBytes: 64 * 1024 })can go back to the default. - Unchanged, on purpose: a
fillread (a slab’s scan prefix) still returns a view into the whole object, so the query takes the slab’s rerank records from the buffer (stats.wholeSlabs); hits of an in-process cache (MemoryCache) are still views into the object it holds (bounded by its per-object cap, a quarter ofmaxBytes; a copy would hold the bytes twice while it is cached); packs and warm packs in memory still serve views into themselves. S3BlobStore: a range answered with the whole object (200, Range ignored) returns the range copied out, not a view that holds the whole object.- Python: no change. Its
CachedBlobStorehas no block cache (fillsis always 0); itsmemoryviews are into whole objects held by its in-process caches or read for afill, as in TypeScript.
0.2.5 (2026-11-09)
Section titled “0.2.5 (2026-11-09)”- Large lexical segments are cached in blocks (TypeScript,
CachedBlobStoreover the Workers Cache API). A segment over 2 MiB (LexSegmentOptions.fillBytes) was read by range and never cached: a range read withoutfillthat missed went to R2 and was not stored, so every search read every large segment from R2 again, and merging segments made search slower (inseam, 2026-11-09: 39 segments of 4 MiB, 293 R2 reads and 4.2 s in the lexical list on a warm cache). Now such reads pass the segment’s size (GetOptions.size) and the store serves them from aligned blocks ofblockBytes(default 1 MiB), each cached under its own key in the store’s scope; a block that misses is read from R2 (that block only, never the whole object), serves the read and is put in the cache throughwaitUntil. Concurrent readers of a block share one R2 read, at mostblockBuffersblocks (16 MiB worth) are held from their read until their put settles, and block reads in flight stay withininflight. An object already cached whole is still served from that entry; slabs, deltas, manifests and segments up to 2 MiB keep whole-object caching. Measured against R2 (bench/blocks/, docs/lexical.md “Block cache”): a warm hybrid search over 8 segments of 4.1 MB went from 4.3 s and 125 R2 reads to 0.2 s and none; over 2 segments of 46 MB, from 1.3 s and 54 reads to 0.1 s and none. Dense-only searches are unchanged. open({ blockBytes, blockBuffers })andCachedBlobStoreOptions.blockBytes/blockBuffers;blockBytes: 0turns blocks off.CachedBlobStore.blockStatscounts fills;drain()also waits for block fills.fillsin the trace envelope’sio(TraceIo.fills,BlobTrace.fills,PhaseStat.fills): the blocks a span read from R2 into the cache. Each fill is also areadand amiss, and its whole block is inbytes; a block lookup is onehitormiss. Python’s envelopes carryfills: 0, so both SDKs keep one schema.
0.2.4 (2026-11-08)
Section titled “0.2.4 (2026-11-08)”- A bulk build step ends by progress, not only by the clock (TypeScript
BulkBuild.step). Aloadpass starts no replay within 4 s of the deadline; when opening the build’s index left less than that,step()called the phase again and again, and in WorkersDate.now()does not move without I/O, so the deadline never came and the invocation ran until its CPU limit (inseam, 2026-11-08: a rebuild alarm killed at 32 s of CPU in the load of a 23,594-document, 40-cell build). Nowstep()returns as soon as a pass over its phase commits nothing (no piece done, no state written), withdone: falseand the phase it stopped in; every pass it repeats has written something. The same holds in the other phases: asamplepass with no time left writes nothing (it used to write the state unchanged), and a heldcompact.lockinloadorcompactends the step instead of being retried until the deadline. BulkStepResult.progressed: false when the call committed nothing (call again; keep the handle, so that the next call does not open the index again).workednow lists only the phases the call made progress in.- The
loadreserve is at most 40% ofdeadlineMs: with a deadline of 4 s or less,loadcould never start a replay. - A
compactphase with no delta left (the last compaction ofloadfolded them all) finishes the build: the forced compaction is anoop, and the build used to stay incompact. Anoopof a due compaction inloaddrops the handle’s index, so the next pass opens the head. BulkBuild.close(): releases the index the handle opened forloadandcompact, and writes or deletes nothing;thread.bulkBuildon the samegenresumes the build, and a laterstepon the handle opens the index again. For a handle dropped beforedone, e.g. after a failed step whose state ETag may be stale.
0.2.3 (2026-11-08)
Section titled “0.2.3 (2026-11-08)”- Dense compaction keeps every cell processable by its budget (TypeScript
index.compact/compactDeltas). Before, at dim 1024 a 32 MiB call folded a one-cell generation up to just undermaxCellEntries(3000, profileedge) and then could never split it (a split of 3000 entries needs about 46 MiB), so every later call wasblockedand the deltas piled up (inseam’se1, 2026-11-04). NowmaxBytesalso sizes the cells: they split atmin(maxCellEntries, splitEntries / 2), wheresplitEntriesis the largest cell the budget can split on its own; no fold takes a cell pastsplitEntries, and a cell that keeps a delta out is split first (r.presplit).compactionLimits(manifest, { maxBytes })/index.compactionLimits(maxBytes)givecellEntries,splitEntries,foldEntries,upsertVectors(an upsert of that many vectors always folds) andsplitCommitCellswithout I/O;r.limitshas them too. - Input a budget cannot process is an error, not
blocked: a delta with more entries in one cell than one call can fold, a cell an older writer let grow pastsplitEntries, a delta overcellsPerRuncells, or a split commit whose fine means pass the budget throw aThreadErrorwith status 413 that names it and what it needs.blockedis left only for a slice whose splits were deferred (moreis true). estimatedPeakBytesis an upper bound again: measured with the wasm memory growth counted (bench/compact_memory.mjs), a fold holds about 3x the old slab plus 6x the new one (the model said 4x the new one: inseam’s 16:57 fold was planned at 18.2 MB and measured 38.9 MB), a split 8x plus the decoded vectors, and 1 MiB is fixed; the fine means of a split commit are a phase of their own after the cells. Details in docs/update-path.md “Memory of a call”.- A split whose 2-means leaves one half empty (identical vectors) halves the entries under the one mean, so such a cell still shrinks.
- With splits, a compaction keeps up to 4.5 s more than the 2.5 s commit reserve, scaled by the fine means’ bytes (all of it with a tree): before, it always kept 7 s, so under a deadline under about 8 s a call with splits started no cell.
- Bulk build (TypeScript,
@experimental):thread.bulkBuild({ store, gen, embedding | dim, lex, attrs, maxBytes })stages documents with vectors (add) underbuild/{gen}/, thenseal()andstep({ deadlineMs })run sample, k-means (wasm), create, load (each stage replayed as an upsert intokcells, compacting when due) and compaction, in steps bounded bymaxBytesand resumable frombuild/{gen}/state.json;cleanup()removes the staging objects.bulkBuildPlan(n, dim, { maxBytes })givesk, the cell and sample sizes andmaxCells(about 1000 cells at dim 1024 and 32 MiB; larger builds belong in the Worker’s build slots). See docs/embedding.md “A bulk build in bounded steps”. createGeneration({ means })(TypeScript): rev 0 withkempty cells with those means.upsert(TypeScript) refusesmetasandtextsthat are not strings or null with a 400 naming the entry, before the chunker, the embedder or the wasm: an object passed as a meta used to trap the wasm instance and reset it for every index in the isolate.bulkBuild.addchecks the same when staging.- Trace envelopes (Observability): every SDK operation (query, search,
lexical search, open, get, listKeys, upsert, delete) builds one JSON envelope, the same schema in TypeScript,
Python and the reference Worker: spans with their start, wall time and store work, counters, the CPU of each
kernel (wasm calls timed in Node, the native
QueryRuntiming its scans, merge and rerank with the GIL released) and, opt-in, one event per store read (traceEvents/trace_events).stats.trace/stats["trace"],r.trace,index.openTrace/index.open_trace;open({ onTrace, traceSample })/open_index(on_trace=, trace_sample=)hand a sampled share to a function. The interop test compares both SDKs’ envelopes. Python’sKeyPage,UpsertResultandDeleteResultgain atracefield (excluded from equality). pushed: the scan kernels count entries pushed into the top-T heap (ScanStats.pushed, the wasm scans’ fourth stats slot,stats.pushed). Callers passing a three-slot stats array keep working.- Reference Worker:
/queryreturns its envelope (trace,sdk: "worker");TRACE_SAMPLE(default"0") logs a share of them as JSON lines and writes them to theQUERY_METRICSAnalytics Engine dataset (thread_queries). - Profiling: Criterion benches of the query kernels at g4’s shape (
cargo bench -p thread-core, real slab and codebook fixtures viaTHREAD_BENCH_SLAB/THREAD_BENCH_PQ), aprofilingcargo profile (release with line tables) for flamegraphs,bench/scenarios.mjs(workload scenarios over the SDK), andbench/query_bench.mjsprints the Worker’s per-span breakdown.
0.2.2 (2026-11-04)
Section titled “0.2.2 (2026-11-04)”- Committing a segment merged elsewhere:
index.commitMergedSegment({ run, readRev, key, bytes, count, keys })/commitMergedSegment(ctx, input). A process with the memory to read a large run whole (thread-coresegment::merge, which the wasmmerge_segmentswraps) writes the merged object underidx/{gen}/seg/, and the index’s writer commits it in place of the run. The object is opened first (container, section headers, directories) and its size checked, so a truncated or foreign object is refused before a revision names it.merged0 and no revision when the head no longer lists the run contiguously. The segment getsaddedRev = readRev: sets newer than the plan still hide its ids, and the lexical-only sets the merge applied drop once no segment predates them. For writers with little memory (a Durable Object) whose boundedcompactSegments({ maxInputBytes })cannot keep a large index in shape. TypeScript only.
0.2.1 (2026-11-03)
Section titled “0.2.1 (2026-11-03)”- Bounded lexical compaction:
compactSegments({ maxInputBytes })/compact_segments(max_input_bytes=)merges one contiguous run of segments whose bytes (plus 4 bytes per tombstoned id) fit the budget, for writers with little memory (a Durable Object). The run keeps its place and its newestaddedRev;merged0 when no two adjacent segments fit. - Cache keys: the in-process cache (
MemoryCache, anyBlobCache) is scoped by the index’s key prefix, as the Cache API was in 0.2.0, and so is astorepassed as aPrefixedBlobStorewithoutprefix. - Dense compaction in the TypeScript SDK:
index.compact(opts)/compactDeltas(ctx, opts)folds delta segments into slab revisions, splits cells overmaxCellEntriesand drops unreferenced tombstone sets in one isolate, bounded bymaxBytes(estimated peak memory, default 48 MiB),cellsPerRunanddeadlineMs(a cut slice commits its finished part);r.moretells whether to call again. Same objects as the Worker’s compaction, byte for byte, and the samecompact.lock.index.compactionDue()/compactionStatus(manifest)check the thresholds without I/O. Not in the Python SDK. - Switching generations from the SDK:
setCurrent(store, { gen, rev?, expect? })/index.setCurrentmovesidx/current.jsonto another generation with a compare-and-swap (409 unless the pointer isexpect);gcGeneration/index.gcis the Worker’s/build/gc(keep, graceSec, dry run);dropGenerationdeletes a generation the pointer left once the grace period has passed with no write to it. TypeScript only. - Scoped tombstones:
upsert({ scope: "dense" | "lexical" })(Pythonscope=) replaces one side of the documents: a vector for existing keys without touching their docs, texts and keys, or new texts and metas without the vector (attrs cannot drift between the sides).TombRef.scope; dense reads and the dense compaction use the dense view, segments, docs and keys the lexical view; sets drop per side, and segment compaction now drops the lexical-only ones. Manifests with scoped sets carryfeatures: ["scoped-tombstones"]; readers refuse features they do not know (readers before 0.2.1 ignorefeaturesand would over-hide). The Worker reads the dense view, compacts per scope and takesscope: "dense"on/upsert. BlobStore.deleteandBlobStore.listObjects(key, size, upload time), optional; implemented by the R2, S3, memory, file, prefixed and cached stores.sdk/ts/package-lock.jsonnames the package@aiuitech/thread-sdk.
0.2.0 (2026-11-03)
Section titled “0.2.0 (2026-11-03)”First published version.
- Embedding models (Embedding models):
manifest.embeddingnames the model a dense generation is for;open({ embed })/open_index(embed=...)takes the Workers AI binding, Workers AI REST credentials, an OpenAI-compatible key or a function;search({ text })embeds the query (and still fuses with BM25),upsert({ texts })embeds documents;index.embed(texts, kind),index.canEmbed,index.embedding. - A dense generation from nothing:
createGeneration/create_generation/ the Worker’sPOST /createpublish one empty cell for a model (or a baredim); it grows through upserts, the Worker’s automatic compaction and cell splits. Readers clamp a manifest defaultnprobeto the cell count. - Worker:
AIandEMBED_API_KEYbindings; JSON/query {text}and/upsert {texts}are embedded in the orchestrator before forwarding;POST /embed. - The TypeScript package is now
@aiuitech/thread-sdk(was the unpublishedthread-sdk); the import paths@aiuitech/thread-sdk,@aiuitech/thread-sdk/nodeand@aiuitech/thread-sdk/wasm/thread_bg.wasm.
Before 0.2.0 (unreleased, see the git history): blob-native dense index in R2/S3 (two-tier slabs, PQ scan tier, centroid tree routing), BM25 segments and fusion in thread-core, keys and the docs store, attribute filters, chunking, incremental updates with compaction and cell splitting, packs, cold-start work, the Python SDK.