<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>CocoIndex Blog</title><description>Notes from the CocoIndex team — incremental data infrastructure, Rust internals, and production stories.</description><link>https://cocoindex.io/</link><language>en-us</language><item><title>How Tree-sitter Works: Parsing Code as You Type</title><link>https://cocoindex.io/blogs/how-tree-sitter-works/</link><guid isPermaLink="true">https://cocoindex.io/blogs/how-tree-sitter-works/</guid><description>Grammars, concrete syntax trees, GLR parsing, error recovery and queries, then how CocoIndex splits code into chunks on function and class boundaries.</description><pubDate>Thu, 05 Nov 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Tree-sitter is an incremental parser. It is used for editor syntax highlighting,
structural code search, and code-aware chunking in retrieval pipelines. CocoIndex
uses it in its
&lt;a href=&quot;https://cocoindex.io/docs/ops/text/#recursivesplitter&quot;&gt;&lt;code&gt;RecursiveSplitter&lt;/code&gt;&lt;/a&gt; to
split source files on function and class boundaries rather than arbitrary line
counts.&lt;/p&gt;
&lt;p&gt;Here is the result first. Move &lt;code&gt;chunk_size&lt;/code&gt; to see which classes and functions
stay in one chunk, then add two lines to a function to see which chunks need a
new embedding.&lt;/p&gt;
&lt;p&gt;The rest of this post explains how that works: the grammar, the parser and the
syntax tree, then how CocoIndex turns the tree into chunks.&lt;/p&gt;
&lt;h2&gt;What is Tree-sitter?&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://tree-sitter.github.io/tree-sitter/&quot;&gt;Tree-sitter&lt;/a&gt;, created by Max
Brunsfeld, is both a parser generator and a parsing library.&lt;/p&gt;
&lt;p&gt;First, it is a parser generator. A grammar author writes the rules of a
language&apos;s syntax in JavaScript. One rule might say &quot;a function is the keyword &lt;code&gt;def&lt;/code&gt;, then
a name, then a parameter list, a colon, and a block.&quot; Running &lt;code&gt;tree-sitter generate&lt;/code&gt; turns the rules into a &lt;code&gt;parser.c&lt;/code&gt; file: a large generated table of
parse states. The host application compiles it once and links it in. This is why
installing a parser in an editor often needs a C compiler: the editor builds
&lt;code&gt;parser.c&lt;/code&gt;, and &lt;code&gt;scanner.c&lt;/code&gt; when the grammar has one, into a shared library.&lt;/p&gt;
&lt;p&gt;Second, it is a parsing library with no runtime dependencies. It runs that parser to
turn source code into a tree whose nodes mirror the grammar, and after an edit it
updates the tree incrementally, reusing the structure the edit did not touch.
Given &lt;code&gt;def greet(name): ...&lt;/code&gt;, it returns the tree in the last panel of the
diagram: a &lt;code&gt;function_definition&lt;/code&gt; node whose children hold the name, the
parameters and the block.&lt;/p&gt;
&lt;p&gt;Four design goals shaped the engineering:&lt;/p&gt;
&lt;p&gt;Each grammar lives in its own repository and ships its generated parser as
C source, so adding a language to a host application is a matter of compiling
and linking that parser. &lt;a href=&quot;https://cocoindex.io/docs/examples/index-codebase&quot;&gt;CocoIndex&apos;s text engine&lt;/a&gt;,
for example, statically links the grammars below:&lt;/p&gt;
&lt;h2&gt;Concrete syntax tree vs. abstract syntax tree&lt;/h2&gt;
&lt;p&gt;The tree Tree-sitter produces is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Parse_tree&quot;&gt;concrete syntax tree&lt;/a&gt;
(CST), also called a parse tree. The distinction from an abstract syntax tree
(AST) decides what tools can do with the output.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;An AST&lt;/strong&gt; omits concrete syntax details that an analysis does not need, such as punctuation or comments.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A CST&lt;/strong&gt; (what Tree-sitter builds) retains grammar tokens such as parentheses, commas, and the &lt;code&gt;def&lt;/code&gt; keyword. Nodes carry byte ranges and row/column positions. Ordinary whitespace is usually skipped rather than represented by a leaf.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Highlighters, formatters and chunkers use the byte ranges to map each node back
to the exact text in the original source.&lt;/p&gt;
&lt;p&gt;Here is the CST for a small Python function:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def greet(name):
    return f&quot;hi {name}&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The keyword &lt;code&gt;def&lt;/code&gt;, the colon, and the parentheses (inside &lt;code&gt;parameters&lt;/code&gt;) are all
real nodes. Tree-sitter calls the meaningful, addressable nodes &quot;named&quot; nodes
(&lt;code&gt;function_definition&lt;/code&gt;, &lt;code&gt;identifier&lt;/code&gt;, &lt;code&gt;block&lt;/code&gt;) and the punctuation and keywords
&quot;anonymous&quot; nodes. A tool that needs AST-like structure walks only the named
nodes. A formatter, which needs punctuation and keywords, includes the anonymous
ones too.&lt;/p&gt;
&lt;h2&gt;How does the parser work?&lt;/h2&gt;
&lt;p&gt;A Tree-sitter grammar is a set of rules. Each rule names a syntactic construct
and describes the sequences of tokens and sub-rules that form it. A trimmed
fragment of the Python grammar looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;function_definition: $ =&amp;gt; seq(
  &apos;def&apos;,
  field(&apos;name&apos;, $.identifier),
  field(&apos;parameters&apos;, $.parameters),
  &apos;:&apos;,
  field(&apos;body&apos;, $._suite),
),
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;tree-sitter generate&lt;/code&gt; compiles this grammar into a set of state-machine
tables. At runtime the parser reads tokens left to right and, at
each step, follows the &lt;a href=&quot;https://en.wikipedia.org/wiki/LR_parser&quot;&gt;LR parsing&lt;/a&gt;
shift/reduce loop:&lt;/p&gt;
&lt;p&gt;Four mechanisms do the work:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Shift&lt;/strong&gt; pushes the next token onto a stack.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reduce&lt;/strong&gt; fires when the tokens on top of the stack complete a grammar rule:
the parser pops them off and replaces them with a single node.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lexing&lt;/strong&gt; runs in the same pass. Tree-sitter generates the lexer from the
string and regex tokens in the grammar.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;External scanners&lt;/strong&gt; cover what a regular lexer cannot. A grammar can supply a
hand-written scanner in C for tokens like Python&apos;s indentation or heredocs.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A plain LR parser needs exactly one action for every state and next token, and
the grammars of real languages have places where one token of lookahead is not
enough to choose. Tree-sitter uses
&lt;a href=&quot;https://en.wikipedia.org/wiki/GLR_parser&quot;&gt;GLR parsing&lt;/a&gt; (Generalized LR, from
Masaru Tomita&apos;s work on natural-language parsing) for those places. When the
table says more than one action is valid, the parser forks: it pursues each
interpretation in parallel on a shared stack and discards the branches that fail
to reach a valid parse.&lt;/p&gt;
&lt;p&gt;The grammar author still decides where that is allowed. &lt;code&gt;tree-sitter generate&lt;/code&gt;
stops with an &quot;Unresolved conflict&quot; error unless each conflict is settled with
precedence (&lt;code&gt;prec&lt;/code&gt;, &lt;code&gt;prec.left&lt;/code&gt;, &lt;code&gt;prec.right&lt;/code&gt;) or listed in the grammar&apos;s
&lt;a href=&quot;https://tree-sitter.github.io/tree-sitter/creating-parsers/2-the-grammar-dsl.html&quot;&gt;&lt;code&gt;conflicts&lt;/code&gt;&lt;/a&gt;
field. Only the listed conflicts become GLR forks at runtime.&lt;/p&gt;
&lt;h2&gt;How does it recover from syntax errors?&lt;/h2&gt;
&lt;p&gt;Code in an editor is often invalid while someone types: a bracket is unclosed, a
statement is half-finished, or an identifier is a prefix of the intended one. A
parser that stopped at the first error would be useless in an editor, so
Tree-sitter recovers and keeps parsing instead.&lt;/p&gt;
&lt;p&gt;When the parser encounters unrecognized text, it can represent that text with
&lt;code&gt;ERROR&lt;/code&gt; nodes. It may also insert zero-width tokens marked &lt;code&gt;MISSING&lt;/code&gt; to recover
and continue parsing. This often preserves useful structure around the broken
region, though recovery cannot guarantee the intended interpretation of the rest
of the file. In the example below (the real output of &lt;code&gt;tree-sitter-python&lt;/code&gt;), a
missing colon breaks the middle function, and the functions on either side still
parse cleanly. A highlighter can still color them, and a chunker can still find
them. &lt;code&gt;node.has_error&lt;/code&gt; and &lt;code&gt;node.is_missing&lt;/code&gt; mark the broken regions, so a tool
can skip or flag them and keep the rest of the parse.&lt;/p&gt;
&lt;h2&gt;What are queries?&lt;/h2&gt;
&lt;p&gt;Tree-sitter also has a small declarative query language for matching patterns
in a tree, written as
&lt;a href=&quot;https://tree-sitter.github.io/tree-sitter/using-parsers/queries/index.html&quot;&gt;S-expressions&lt;/a&gt;.
A query describes a tree shape and captures the nodes of interest with
&lt;code&gt;@&lt;/code&gt;-prefixed names:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(function_definition
  name: (identifier) @function.name
  parameters: (parameters) @function.params)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run against a file, this query returns every function definition with its name
and parameter list captured. This is the mechanism behind editor features built
on Tree-sitter: syntax highlighting is a query that tags nodes with color
classes (&lt;code&gt;highlights.scm&lt;/code&gt;), code folding and structural selection are queries,
and &quot;go to symbol&quot; is a query for definitions. Queries can also carry predicates
(for example, match an identifier only if its text equals a constant), which
keeps language-specific logic in declarative &lt;code&gt;.scm&lt;/code&gt; files instead of host code.&lt;/p&gt;
&lt;h2&gt;How CocoIndex uses Tree-sitter to chunk code&lt;/h2&gt;
&lt;p&gt;How a file is split into chunks affects retrieval quality. A
fixed 1,000-character split cuts functions in half and separates a method from
its class, leaving the embedding model fragments that mean little on their own.
Splitting on the structure the parser already produces, the CST, avoids that.&lt;/p&gt;
&lt;p&gt;CocoIndex&apos;s &lt;code&gt;RecursiveSplitter&lt;/code&gt; works this way. It takes the source text, a
target chunk size and a language, parses the text with Tree-sitter, and places
chunk boundaries on syntax nodes. The
language can be a name or a file extension, and a helper resolves it from a
filename:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from cocoindex.ops.text import RecursiveSplitter, detect_code_language

source = open(&quot;server.py&quot;).read()
language = detect_code_language(filename=&quot;server.py&quot;)  # -&amp;gt; &quot;python&quot;

splitter = RecursiveSplitter()
chunks = splitter.split(source, chunk_size=1000, chunk_overlap=300, language=language)

for c in chunks:
    print(c.start.line, c.end.line, len(c.text))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;c.start&lt;/code&gt; and &lt;code&gt;c.end&lt;/code&gt; are &lt;code&gt;TextPosition&lt;/code&gt; objects. Each holds a &lt;code&gt;byte_offset&lt;/code&gt;, a
&lt;code&gt;char_offset&lt;/code&gt;, and a 1-based &lt;code&gt;line&lt;/code&gt; and &lt;code&gt;column&lt;/code&gt;, so a search result can point
to the exact span in the original file.&lt;/p&gt;
&lt;p&gt;The splitter works in two passes. The first walks the syntax tree from the root
and breaks the file into small pieces along node boundaries. Nodes with no
children, such as long strings, fall back to text separators.&lt;/p&gt;
&lt;p&gt;The second pass treats chunking as an optimization over the whole file. Instead
of merging pieces greedily from left to right, it scores candidate sets of cuts
on syntax depth, line structure and chunk size, and it finds the lowest-cost set
with dynamic programming, in time linear in the file size for a fixed
&lt;code&gt;chunk_size&lt;/code&gt;. Overlap is part of the same search. The cuts tend to fall between
functions and classes and at blank lines. The splitter would rather leave a
chunk a little under the minimum size than cut through a function; a chunk far
under the minimum still costs too much to choose.&lt;/p&gt;
&lt;p&gt;The same search runs for all 39 bundled grammars, and &lt;code&gt;RecursiveSplitter&lt;/code&gt;
exposes it as one &lt;code&gt;split()&lt;/code&gt; call.&lt;/p&gt;
&lt;p&gt;The demo at the top of this post runs these two passes on a small Python file
with a nested class.&lt;/p&gt;
&lt;p&gt;If the language is unsupported or unspecified, or the parse fails, the splitter
skips Tree-sitter and treats the input as plain text: an unknown extension falls
back to regex separators instead of raising an error.&lt;/p&gt;
&lt;h3&gt;What happens when you edit a function&lt;/h3&gt;
&lt;p&gt;Splitting from the top keeps a function whole when it fits, and it puts
every cut on a syntax-node boundary. The second property matters when a file
changes. CocoIndex does not re-chunk a subtree for this. The splitter parses the
whole file again (it does not pass an old tree to Tree-sitter) and splits the
new tree from the root. The incremental work happens one level up. In the
&lt;a href=&quot;https://cocoindex.io/blogs/index-codebase-v1&quot;&gt;codebase indexing example&lt;/a&gt;, the
per-file function is memoized, so files that did not change are skipped and
only the edited file is parsed, split and embedded again. Inside that file, cuts
that sit on syntax nodes tend to stay where they were, so chunks away from the
edit often come out with the same text. The embedder&apos;s &lt;code&gt;embed&lt;/code&gt; call is memoized
on its input text, so those chunks reuse their stored vectors, and only chunks
with new text go to the model. A fixed-size split does not have this property:
inserting two lines moves every cut after the edit, and every later chunk has
new text.&lt;/p&gt;
&lt;p&gt;The boundaries can still move. The second pass chooses its cuts
for the file as a whole, so an edit that changes a function&apos;s size can move a
neighbor&apos;s boundary. In the demo at &lt;code&gt;chunk_size&lt;/code&gt; 200, the edit grows
&lt;code&gt;remove_item&lt;/code&gt; to 254 bytes, past the budget, so it is split, and the chunk that
holds &lt;code&gt;add_item&lt;/code&gt; takes its first line: three of eight chunks get new text. At
&lt;code&gt;chunk_size&lt;/code&gt; 300 and 400, the same edit changes one chunk, the one that holds
&lt;code&gt;remove_item&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Does syntax-aware chunking help retrieval?&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://arxiv.org/abs/2506.15655&quot;&gt;cAST (Zhang et al., 2025)&lt;/a&gt;, from Carnegie
Mellon University and Augment Code, evaluates a related approach: parse with
Tree-sitter, recursively split large nodes, and merge small siblings up to a
size budget. Against fixed-size chunks, the paper reports two headline gains:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Recall@5 on RepoEval (whether the right code lands in the top five retrieved
chunks) rises from 70.7 to 75.0 with the GIST-base retriever, a 4.3-point gain.&lt;/li&gt;
&lt;li&gt;Pass@1 on SWE-bench Lite (whether a generated patch fixes the issue on the
first try) rises from 14.0 to 16.7 with Claude 3.7 Sonnet as the generator and
CodeSage-small-v2 as the retriever, a 2.7-point gain (the abstract gives
2.67).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These results come from cAST&apos;s pipelines. The paper does not benchmark
CocoIndex, and the gain depends on the retriever: with CodeSage-small-v2, RepoEval Recall@5 rises
only from 82.1 to 83.9.&lt;/p&gt;
&lt;p&gt;Two findings apply to a splitter&apos;s parameters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The merge step.&lt;/strong&gt; Splitting without merging leaves tiny nodes
(imports, single assignments) as their own thin chunks, which inflate the index
and carry little context. In cAST&apos;s ablation with the CodeSage-small-v2
retriever, removing the merge step dropped retrieval nDCG from 85.1 to 66.1.
CocoIndex&apos;s second pass also groups adjacent pieces into chunks of up to
&lt;code&gt;chunk_size&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The budget unit.&lt;/strong&gt; One line can hold a single brace or a
200-character expression, so a line budget drifts across files and languages.
CocoIndex measures the budget in bytes; cAST counts non-whitespace characters.
cAST reports that retrieval
and generation peak with a maximum chunk size between 2,000 and 2,500
characters in its setup.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;How Tree-sitter helps coding agents&lt;/h2&gt;
&lt;p&gt;A coding agent works inside a fixed context window, so most of its effort goes
into finding the right code before it reads or edits anything. Tree-sitter gives
the agent&apos;s tools a structural view of a repository:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Whole-unit retrieval.&lt;/strong&gt; Search returns a function or class with its
signature, not a window that starts in the middle of a body.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;File outlines.&lt;/strong&gt; A query for definitions lists every class and function in
a file with its line range, so the agent opens only the part it needs instead
of the whole file.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Structural search.&lt;/strong&gt; Queries match code by shape, such as every call to a
function, which plain text search cannot express.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Exact locations.&lt;/strong&gt; Every node carries byte and line ranges, so a result
points at the lines to edit, and &lt;code&gt;has_error&lt;/code&gt; tells the agent whether its edit
still parses.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Half-written code.&lt;/strong&gt; Error recovery keeps the tree usable while the agent or
a person is in the middle of a change.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Tree-sitter parses one file at a time and keeps no index across the repository.
A repository changes on every save and every agent edit, and an index that lags
behind sends the agent to code that no longer exists. CocoIndex keeps that index
current: the pipeline parses and chunks with Tree-sitter, processes only the
files that changed, and reuses the embedding of every chunk whose text did not
change, as &lt;a href=&quot;#what-happens-when-you-edit-a-function&quot;&gt;the edit example above&lt;/a&gt;
shows.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex-code&quot;&gt;cocoindex-code&lt;/a&gt; packages this
for coding agents. It is a local CLI (&lt;code&gt;ccc&lt;/code&gt;) and MCP server for Claude Code,
Codex and Cursor that keeps an AST-chunked, incrementally updated semantic index
of a codebase. For many repositories on GitHub or GitLab,
&lt;a href=&quot;/cocoindex-code&quot;&gt;CocoIndex Code Plus&lt;/a&gt; also stores the definitions and
references of every symbol and a text index for grep, in your Postgres.&lt;/p&gt;
&lt;h2&gt;Where this falls short&lt;/h2&gt;
&lt;p&gt;Syntax-aware parsing and chunking have limits:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Tree-sitter returns syntax only. It does no name resolution, type
inference, or cross-file linking. Editors such as Neovim and Helix get those
from a language server (LSP) and run both side by side. A chunk can be syntactically whole and still miss the
caller or the type definition it depends on.&lt;/li&gt;
&lt;li&gt;Each language is a separate grammar with its own maturity. Tokens a regular
lexer cannot handle, like Python indentation or heredocs, rely on a
hand-written C scanner, and a thin or lagging grammar yields a coarser tree.&lt;/li&gt;
&lt;li&gt;Keeping every token, with a byte range on every node, uses more memory than the
pruned tree a compiler builds. The cost grows with file size.&lt;/li&gt;
&lt;li&gt;A function larger than &lt;code&gt;chunk_size&lt;/code&gt; has to be cut inside. A function that
fits is kept whole in nearly every case, but the splitter does not guarantee
it, and a class that fits can still be split across chunks.&lt;/li&gt;
&lt;li&gt;A node with no children that is still too large, such as a long string, is cut
at regex separators inside it.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;chunk_overlap&lt;/code&gt; repeats text across neighboring chunks, which preserves
continuity for retrieval but inflates the index.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Where to go next&lt;/h2&gt;
&lt;p&gt;For the parser internals, read the &lt;a href=&quot;https://tree-sitter.github.io/tree-sitter/&quot;&gt;Tree-sitter documentation&lt;/a&gt;
and a grammar repository such as
&lt;a href=&quot;https://github.com/tree-sitter/tree-sitter-python&quot;&gt;tree-sitter-python&lt;/a&gt;. For the
retrieval side, &lt;a href=&quot;https://arxiv.org/abs/2506.15655&quot;&gt;cAST&lt;/a&gt; benchmarks AST-based
chunking against fixed-size chunking. CocoIndex is open source at
&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;github.com/cocoindex-io/cocoindex&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To run this chunker on a real codebase, in a pipeline that embeds the chunks and
keeps the index current as files change, start with the tutorial:&lt;/p&gt;
</content:encoded><category>tree-sitter</category><category>parsing</category><category>code-indexing</category><category>chunking</category><category>rag</category><category>embeddings</category><category>deep-dive</category><author>Linghua Jin</author></item><item><title>CocoIndex 1.1: the highlights since 1.0</title><link>https://cocoindex.io/blogs/cocoindex-v1-1/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-v1-1/</guid><description>CocoIndex 1.0.1 to 1.1.0 in 27 releases: deadlines and rate limits, persistent state, previews that write nothing, cheaper commits, and 10 new connectors.</description><pubDate>Wed, 04 Nov 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;CocoIndex builds fresh, structured context for AI from agent sessions, codebases, instant messages, meeting notes, and all the other unstructured data in an enterprise, and keeps it up to date with an &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;incremental engine&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Since the v1.0 launch, most of our work has gone into running pipelines under production limits: time budgets, provider quotas, memory, and failures that stay local. We also made pipeline logic more flexible and runs cheaper across larger corpora.&lt;/p&gt;

&lt;h2&gt;Agent context breaks in four ways&lt;/h2&gt;
&lt;p&gt;Agents act on the context they read, and that context fails in four ways.&lt;/p&gt;
&lt;p&gt;Gartner &lt;a href=&quot;https://www.gartner.com/en/newsroom/press-releases/2025-02-26-lack-of-ai-ready-data-puts-ai-projects-at-risk&quot;&gt;predicts&lt;/a&gt; that through 2026, organizations will abandon 60% of AI projects unsupported by AI-ready data.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;/blogs/cocoindex-v1/&quot;&gt;CocoIndex v1&lt;/a&gt; set out the approach: you declare the target states your agents should read, and an incremental engine keeps them in step with every source as it changes.&lt;/p&gt;
&lt;h2&gt;What changed since 1.0&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Limits you set once.&lt;/strong&gt; One deadline for a call tree (&lt;code&gt;coco.timeout()&lt;/code&gt;), one quota shared by &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/&quot;&gt;components&lt;/a&gt; (&lt;code&gt;RateLimiter&lt;/code&gt;), and a component cap that holds across a hierarchy of any depth.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Failures stay local, keys stay stable.&lt;/strong&gt; A bad row fails only its own component, and connector keys no longer collide or drift between runs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Commits that cost less.&lt;/strong&gt; Engine memory per Postgres row 1,449 B → 487 B; moving 5,000 target states 243 s → 1–2 s.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;More state inside the pipeline.&lt;/strong&gt; Per-argument &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#memoization&quot;&gt;memo&lt;/a&gt; keys, persistent state with &lt;code&gt;coco.use_state()&lt;/code&gt;, &lt;code&gt;LiveMap&lt;/code&gt; between stages, and &lt;code&gt;coco.LogicDep&lt;/code&gt; for dependencies decided per call.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Visibility before and after an update.&lt;/strong&gt; A preview that writes nothing, a listing of every &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;target state&lt;/a&gt; and its owner, and stats per tenant or folder.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;10 new connectors&lt;/strong&gt;, among them Snowflake, BigQuery, Azure Blob Storage, and Neo4j, plus syntax-aware code splitting for 11 more languages.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;What you can run now&lt;/h2&gt;
&lt;p&gt;These 7 workloads got easier since 1.0; each diagram names the feature behind it. Hover or tap a diagram to explore. On phones, scroll wide diagrams sideways.&lt;/p&gt;
&lt;h2&gt;Upgrading from 1.0.x&lt;/h2&gt;
&lt;p&gt;:::warning[Check the upgrade notes before you move to 1.1.0]&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Linux before 1.0.24&lt;/strong&gt;: a long update can hang. Upgrade to 1.0.24 or later.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Object-store &lt;code&gt;prefix&lt;/code&gt;&lt;/strong&gt; (v1.1.0): for S3, Azure Blob, and OCI, &lt;code&gt;prefix=&quot;docs&quot;&lt;/code&gt; now lists only &lt;code&gt;docs/...&lt;/code&gt;, and target states built from objects that drop out of the listing are removed on the next update. Use &lt;code&gt;path_matcher&lt;/code&gt; to select objects by how their names start.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Neo4j and FalkorDB&lt;/strong&gt; (v1.1.0): moving an existing table to the new node and relationship APIs takes two updates. Skipping the first deletes the table&apos;s nodes or edges.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;First update after 1.1.0&lt;/strong&gt;: Google Drive items get new keys and are reprocessed, and values that reference one object twice get new memo fingerprints, so memoized work on them runs once more and IDs from &lt;code&gt;generate_id&lt;/code&gt; or &lt;code&gt;IdGenerator&lt;/code&gt; may change.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LiteLLM &lt;code&gt;timeout&lt;/code&gt;&lt;/strong&gt; (v1.0.22) now bounds a whole request, and &lt;strong&gt;exception handlers&lt;/strong&gt; (v1.0.23) receive the original typed exception.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The full lists are in the upgrade notes for &lt;a href=&quot;/blogs/changelog-1017-1025/#upgrade-notes&quot;&gt;1.0.17–1.0.25&lt;/a&gt; and &lt;a href=&quot;/blogs/changelog-1026-110/#upgrade-notes&quot;&gt;1.0.26–1.1.0&lt;/a&gt;.
:::&lt;/p&gt;
&lt;h2&gt;Run under real limits&lt;/h2&gt;
&lt;p&gt;Each limit is set in one place, and the engine enforces it.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;coco.timeout()&lt;/code&gt;: one deadline for a whole call tree (v1.0.17)&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;coco.timeout()&lt;/code&gt; (v1.0.17) gives a call tree one absolute deadline, so you don&apos;t have to pass a timeout through each call. &lt;code&gt;@coco.fn&lt;/code&gt; calls, &lt;code&gt;coco.map()&lt;/code&gt; item tasks, and &lt;code&gt;coco.use_mount()&lt;/code&gt; children inside the &lt;code&gt;with&lt;/code&gt; block inherit it. This example sets a 30-second budget for processing a file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def process_file(file: FileLike, target: postgres.TableTarget[DocRow]) -&amp;gt; None:
    # 30-second budget for this file; every call below checks it.
    with coco.timeout(timedelta(seconds=30)):
        parsed = await coco.use_mount(coco.component_subpath(&quot;parse&quot;), parse, file)
        summaries = await coco.map(summarize, parsed.sections)
        summary = &quot;\n&quot;.join(summaries)
        vector = await embed(summary)
    target.declare_row(
        row=DocRow(name=out_name(file), summary=summary, embedding=vector)
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The deadline is &lt;a href=&quot;/blogs/changelog-1017-1025/#cocotimeout-cooperative-deadlines-v1017&quot;&gt;cooperative&lt;/a&gt;. CocoIndex checks it at its own checkpoints and raises &lt;code&gt;coco.DeadlineExceededError&lt;/code&gt;, a subclass of &lt;code&gt;TimeoutError&lt;/code&gt;. A run that times out applies no target writes and memoizes nothing, so the next update retries it. The deadline does not extend to work the caller doesn&apos;t wait for (&lt;code&gt;mount()&lt;/code&gt; and &lt;code&gt;mount_each()&lt;/code&gt; children and live components). Batched function bodies and target writes do not inherit it either. The built-in retry helpers treat their own limit as a nested timeout, so the shorter budget wins.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;RateLimiter&lt;/code&gt;: one quota shared by every component (v1.0.8)&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://cocoindex.io/docs/common_resources/rate_limiting/&quot;&gt;&lt;code&gt;RateLimiter&lt;/code&gt;&lt;/a&gt; (v1.0.8) is a &lt;a href=&quot;/blogs/changelog-108-1016/#ratelimiter-one-shared-token-bucket-v108&quot;&gt;token bucket&lt;/a&gt; that &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/&quot;&gt;components&lt;/a&gt; share. Every component that acquires from the same instance draws on one budget, and concurrent callers are served in arrival order. It replaces hand-rolled sleep loops at each call site.&lt;/p&gt;
&lt;p&gt;In 1.1.0 a &lt;a href=&quot;/blogs/changelog-1026-110/#batching-a-bound-on-in-flight-batches-v110&quot;&gt;batched function&lt;/a&gt; takes two more parameters to control requests. &lt;code&gt;rate_limiter&lt;/code&gt; takes one token per batch instead of one per call, which fits APIs where each batch is one request. &lt;code&gt;max_in_flight&lt;/code&gt; caps how many batches run at once. A batch that isn&apos;t full yet can start as soon as a slot frees, instead of waiting until no batch is running. This example limits batches to 4 concurrent requests:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from cocoindex.resources.rate_limit import RateLimiter

limiter = RateLimiter(max_rows_per_second=1.0)

@coco.fn.as_async(
    batching=True,
    max_batch_size=100,
    max_in_flight=4,
    rate_limiter=limiter,
)
async def fetch(ids: list[str]) -&amp;gt; list[Item]:
    return await api.fetch_many(ids)  # one request, one token
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The LiteLLM embedder and transcriber also gained &lt;a href=&quot;/blogs/changelog-1017-1025/#litellm-request-timeouts-concurrency-caps-and-transcription-retries-v1022&quot;&gt;limits of their own&lt;/a&gt; in 1.0.22: &lt;code&gt;timeout&lt;/code&gt; bounds one request end to end, retries included, and &lt;code&gt;max_inflight_requests&lt;/code&gt; caps the requests one embedder keeps open against its backend.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;coco.RetryWithSmallerBatch&lt;/code&gt;: a failed batch splits until the bad item stands alone (v1.0.17)&lt;/h3&gt;
&lt;p&gt;The engine can &lt;a href=&quot;/blogs/changelog-1017-1025/#cocoretrywithsmallerbatch-batch-splitting-on-failure-v1017&quot;&gt;split and retry a failed batch&lt;/a&gt; so that one bad input does not fail the rest. A batched function body can raise &lt;code&gt;coco.RetryWithSmallerBatch&lt;/code&gt; (v1.0.17), and the engine halves the batch and retries the halves, down to single items. This helps with a provider&apos;s per-request token cap, a rejected input, or a GPU running out of memory. At size one the engine raises the original error for that item only. &lt;code&gt;LiteLLMEmbedder&lt;/code&gt; and &lt;code&gt;SentenceTransformerEmbedder&lt;/code&gt; already do this, for example when voyage-code-3 rejects a batch over 120k tokens, or on GPU out-of-memory.&lt;/p&gt;
&lt;p&gt;Since 1.0.23 the engine applies the same rule to the &lt;a href=&quot;/blogs/changelog-1017-1025/#target-sink-batches-v1023&quot;&gt;batches it builds for target writes&lt;/a&gt;. A sink call is one connector write to the target. The engine merges writes from components that finish while a sink call is in flight into the next call. A failure in that call used to fail every component in it. In one case, one bad row in a sink call of 59 rows rolled back the writes of 58 other components. A failed sink batch is now split along component boundaries and the halves are re-applied, so the error reaches only the component that caused it. Connector code doesn&apos;t change, and the happy path is still one sink call.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;max_inflight_components&lt;/code&gt;: a concurrency cap that can&apos;t deadlock a hierarchy (v1.0.26)&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;max_inflight_components&lt;/code&gt; (default 1024) caps how many processing components execute at once, and since 1.0.26 that cap holds across a hierarchy of any depth. Before, a parent waiting on its children held a slot, so the engine released it when the parent mounted its first child to avoid deadlock, which left everything after that point unbounded. One indexer ran out of memory with about 15,000 file components in flight under a limit of 256.&lt;/p&gt;
&lt;p&gt;Now a waiting parent keeps its slot and &lt;a href=&quot;/blogs/changelog-1026-110/#slot-lending-a-component-limit-that-holds-across-the-hierarchy-v1026&quot;&gt;lends it&lt;/a&gt; to one child at a time. A blocked parent always has one child that can run, so the hierarchy completes even with a limit of 1. In 1.1.0 the engine also &lt;a href=&quot;/blogs/changelog-1026-110/#fair-sharing-between-live-components-v110&quot;&gt;shares the pool fairly&lt;/a&gt; between independent updates, so a small live refresh no longer waits behind a new component&apos;s first full index.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;coco.GPU&lt;/code&gt; and &lt;code&gt;coco.GPUPool&lt;/code&gt;: GPU fractions and whole-card reservations (v1.0.15, v1.0.25)&lt;/h3&gt;
&lt;p&gt;Since 1.0.15, a function run with &lt;code&gt;runner=coco.GPU&lt;/code&gt; takes a GPU from a pool for the duration of the call. &lt;code&gt;coco.GPU(0.5)&lt;/code&gt; takes half of one, so two such calls share a card. In 1.0.25 CocoIndex &lt;a href=&quot;/blogs/changelog-1017-1025/#gpu-pool-whole-gpu-reservations-and-arrival-order-queueing-v1025&quot;&gt;rewrote the pool in Rust&lt;/a&gt; and exposed it as &lt;code&gt;coco.GPUPool&lt;/code&gt;. Queued requests reserve capacity in arrival order, so a stream of fractional requests can&apos;t starve a whole-GPU one, and &lt;code&gt;acquire_full(n)&lt;/code&gt; reserves &lt;code&gt;n&lt;/code&gt; free GPUs at once, for example for a model sharded across cards.&lt;/p&gt;
&lt;h2&gt;More state inside the pipeline&lt;/h2&gt;
&lt;p&gt;More of what a pipeline remembers now lives in the engine, under the same reconciliation rules as the rest of the app.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;memo_key&lt;/code&gt;: recompute only when an input that matters changes (v1.0.3)&lt;/h3&gt;
&lt;p&gt;Avoid repeating paid embedding or LLM calls when only a client, logger, config object, or debug flag changes. &lt;code&gt;@coco.fn&lt;/code&gt; takes a &lt;a href=&quot;/blogs/changelog-101-107/#memo_key-per-argument-memoization-control-v103&quot;&gt;per-argument &lt;code&gt;memo_key&lt;/code&gt;&lt;/a&gt; (v1.0.3) to control the &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#memoization&quot;&gt;memo&lt;/a&gt; cache key. A callable transforms an argument before fingerprinting, and &lt;code&gt;None&lt;/code&gt; leaves the argument out of the key. This example keys &lt;code&gt;entry&lt;/code&gt; by name and version and excludes &lt;code&gt;extra&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True, memo_key={&quot;entry&quot;: lambda e: (e.name, e.version), &quot;extra&quot;: None})
def transform(entry: SourceDataEntry, extra: str) -&amp;gt; str:
    ...
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;code&gt;coco.use_state()&lt;/code&gt;: state that survives updates (v1.0.8)&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;coco.use_state()&lt;/code&gt; (v1.0.8) lets a component keep &lt;a href=&quot;/blogs/changelog-108-1016/#cocouse_state-persistent-per-component-state-v108&quot;&gt;typed state across updates&lt;/a&gt; in the engine&apos;s LMDB state store. Running totals, seen-entity sets, watermarks, and stateful deduplication used to need a Redis or Postgres sidecar.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;LiveMap&lt;/code&gt;: a bridge between a producing and a consuming stage (v1.0.8)&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;LiveMap&lt;/code&gt; (v1.0.8) is an &lt;a href=&quot;/blogs/changelog-108-1016/#livemap-in-memory-intermediate-collections-v108&quot;&gt;in-memory keyed collection&lt;/a&gt; that connects a producing and a consuming stage of the same live run. Producing components declare entries into it as target states. The consuming side reads it as a live source through &lt;code&gt;mount_each()&lt;/code&gt;, which mounts one live component per entry and drops it when its producer stops declaring the key.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;coco.auto_refresh()&lt;/code&gt;: polling with reconciled deletes (v1.0.7)&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;coco.auto_refresh()&lt;/code&gt; (v1.0.7) &lt;a href=&quot;/blogs/changelog-101-107/#cocoauto_refresh-scheduled-live-refresh-v107&quot;&gt;re-runs a processor on an interval&lt;/a&gt; as a &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/live_component/&quot;&gt;live component&lt;/a&gt;. Each cycle reconciles target states against the previous one. When &lt;code&gt;sync_users&lt;/code&gt; stops declaring a row, CocoIndex deletes it. Cycle failures go through one error-handling channel. This example refreshes users every 5 minutes:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;await coco.mount(
    coco.auto_refresh(sync_users, interval=timedelta(minutes=5)),
    db, target,
)
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;code&gt;coco.LogicDep&lt;/code&gt;: invalidate only the calls that used a changed dependency (v1.1.0)&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;coco.LogicDep&lt;/code&gt; (v1.1.0) lets a call record only the logic dependencies it uses. &lt;code&gt;@coco.fn&lt;/code&gt; &lt;a href=&quot;/blogs/changelog-1026-110/#logic-tracking-beyond-the-decorator-v1026-to-v110&quot;&gt;fingerprints a function&apos;s logic&lt;/a&gt;, so editing the function invalidates the cached results that depend on it. Some dependencies are decided per call: a tree walk&apos;s &lt;code&gt;visit_file&lt;/code&gt; depends on the parser for that file&apos;s language only. &lt;code&gt;coco.LogicDep&lt;/code&gt; declares such a value at module import, and &lt;code&gt;coco.use_logic_dep()&lt;/code&gt; records it for the current call. This example records the parser dependency for each file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;PARSER_DEPS = {
    name: coco.LogicDep((&quot;parser&quot;, name, version))
    for name, version in PARSER_VERSIONS.items()
}

@coco.fn(logic_tracking=&quot;self&quot;, version=1)
async def visit_file(file: File) -&amp;gt; None:
    language = detect_language(file.path)
    if (dep := PARSER_DEPS.get(language)) is not None:
        coco.use_logic_dep(dep)  # this call&apos;s logic also depends on that parser
    ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When the Python parser&apos;s &lt;code&gt;LogicDep&lt;/code&gt; gets a new version, only the Python files and the directories above them re-run. Every other subtree is reused from memo.&lt;/p&gt;
&lt;p&gt;A related addition for library authors, &lt;code&gt;coco.logic_propagated_to_callers()&lt;/code&gt; (1.0.26), carries a user callback&apos;s logic through a library layer whose fingerprint excludes its callees (&lt;code&gt;logic_tracking=&quot;self&quot;&lt;/code&gt;), so an edit to the callback still invalidates the library&apos;s memos.&lt;/p&gt;
&lt;h2&gt;See what an update will do, and what it did&lt;/h2&gt;
&lt;p&gt;Review an update before it writes anything, for example in a pull-request check, and see every target state with the component that wrote it.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;cocoindex update --preview&lt;/code&gt;: a preview that writes nothing (v1.0.8, v1.0.26)&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;/blogs/changelog-1026-110/#preview-runs-on-real-pipelines-and-writes-nothing-v1026&quot;&gt;Preview&lt;/a&gt; an update before writing to its targets with &lt;code&gt;cocoindex update --preview&lt;/code&gt;. Preview arrived in 1.0.8 for target states with nothing nested under them. In 1.0.26 it reached nested states, such as rows under a Postgres table or files under a directory target, so it now runs on pipelines with nested target states. A preview reads cached results without changing them and writes no committed state. This makes it safe to run at any time: it can&apos;t make the next real update skip work. Run a preview for an app as follows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cocoindex update --preview path/to/app.py
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;code&gt;cocoindex show&lt;/code&gt;: every target state and the component that owns it (v1.0.12 to v1.0.18)&lt;/h3&gt;
&lt;p&gt;Inspect what CocoIndex wrote and which component owns it with &lt;code&gt;cocoindex show&lt;/code&gt; (v1.0.12 to v1.0.18). CocoIndex records every declared target state together with its owner. &lt;a href=&quot;/blogs/changelog-1017-1025/#cocoindex-show-target-state-inspection-v1017-to-v1018&quot;&gt;&lt;code&gt;--target-states&lt;/code&gt;&lt;/a&gt; lists every tracked &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;target state&lt;/a&gt; with its owner and marks entries nothing owns anymore as &lt;code&gt;[dangling]&lt;/code&gt;. With &lt;code&gt;--db&lt;/code&gt; and &lt;code&gt;--app-name&lt;/code&gt; it reads a database directly, without importing the app or installing its dependencies. This command lists target states as a tree:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ cocoindex show --db ./cocoindex.db --app-name FilesTransform --target-states --tree
Target states:
- @cocoindex/localfs
  - [null,&quot;output_html/data__bizarre_animals.md.html&quot;]
    owner:/@process_file/&quot;bizarre_animals.md&quot;
  - [null,&quot;output_html/data__chuck_norris.md.html&quot;]
    owner:/@process_file/&quot;chuck_norris.md&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;code&gt;coco.stats_group()&lt;/code&gt;: stats by tenant, project, or folder (v1.0.7)&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;coco.stats_group(title)&lt;/code&gt; (v1.0.7) &lt;a href=&quot;/blogs/changelog-101-107/#cocostats_group-stats-per-data-slice-v107&quot;&gt;breaks stats down by data slice&lt;/a&gt;, such as a tenant, a project, or a source folder, in addition to the existing breakdown by processor. Everything mounted inside the block reports separately under &lt;code&gt;title&lt;/code&gt;, so you can see which tenant is growing and which one caused a reprocess storm. This example reports stats for each tenant:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for tenant in tenants:
    with coco.stats_group(f&quot;tenant:{tenant.id}&quot;, report_to_stdout=True):
        files = localfs.walk_dir(tenant.docs_dir, ...)
        await coco.mount_each(process_doc, files.items(), target)
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Commits that cost less, especially when little changed&lt;/h2&gt;
&lt;p&gt;A component can now declare 1M rows, and an update where most of them are unchanged runs no per-row Python at commit on the SQL, warehouse, LanceDB, and graph table targets (for plain-data rows, outside &lt;code&gt;full_reprocess&lt;/code&gt; and schema changes).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;/blogs/changelog-108-1016/#batched-target-writes-across-components-v1015&quot;&gt;Batched target writes across components&lt;/a&gt; (v1.0.15). The engine batches rows that many components declare into one target and applies them together. Before, a 50-row ingest into LanceDB made about 50 commits and 50 table versions.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/blogs/changelog-1017-1025/#large-target-updates-less-memory-fewer-reconciles-v1025&quot;&gt;Large target updates&lt;/a&gt; (v1.0.25). The engine holds declared rows encoded instead of as Python objects and computes fingerprints natively. The SQL, warehouse, LanceDB, and graph table targets skip &lt;code&gt;reconcile()&lt;/code&gt; for unchanged rows. Postgres upserts of scalar-only tables use &lt;code&gt;unnest&lt;/code&gt;, 2,000 rows per statement. Tables with pgvector, enum, or domain columns stay on &lt;code&gt;VALUES&lt;/code&gt;. Composite-key deletes match against one key list instead of an &lt;code&gt;OR&lt;/code&gt; chain.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/blogs/changelog-1026-110/#moving-target-states-between-components-v110&quot;&gt;Moving target states between components&lt;/a&gt; (v1.1.0). Commit time was quadratic in the number of moved targets. Each previous owner&apos;s tracking record (what the engine stored about that owner&apos;s target states) is now decoded and encoded once per commit.&lt;/li&gt;
&lt;li&gt;LMDB (v1.0.10, v1.0.15). The engine prefetches cached results and state in one read transaction per cycle. The state store grows its map automatically when it fills, so &lt;code&gt;COCOINDEX_LMDB_MAP_SIZE&lt;/code&gt; needs no manual tuning.&lt;/li&gt;
&lt;/ul&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measurement&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Engine memory per declared Postgres row&lt;/td&gt;
&lt;td&gt;1,449 B&lt;/td&gt;
&lt;td&gt;487 B&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;200,000 unchanged rows at commit, no-op sink (no &lt;code&gt;reconcile()&lt;/code&gt; calls after)&lt;/td&gt;
&lt;td&gt;2.34 s&lt;/td&gt;
&lt;td&gt;1.34 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Postgres upsert, 631,119 rows, 10 connections&lt;/td&gt;
&lt;td&gt;5.1⁠–⁠5.6 s&lt;/td&gt;
&lt;td&gt;2.8⁠–⁠3.2 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Postgres delete, 8,000 4-column keys&lt;/td&gt;
&lt;td&gt;59.1 s&lt;/td&gt;
&lt;td&gt;0.26 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Move 5,000 target states in one commit (debug build)&lt;/td&gt;
&lt;td&gt;242.7 s&lt;/td&gt;
&lt;td&gt;1.0⁠–⁠1.8 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;Failures stay local, keys stay stable&lt;/h2&gt;
&lt;p&gt;One bad document no longer takes its neighbors&apos; writes down with it, and connector keys no longer collide or drift between runs. S3 overwrites within the same second now resolve correctly.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;/blogs/changelog-1026-110/#connector-keys-collisions-and-lost-writes-v110&quot;&gt;Connector keys&lt;/a&gt; (v1.1.0). CocoIndex matches every source item and target state with its previous run by key. An audit of how every Python connector builds its keys closed several edge cases. These included two objects sharing one key (Google Drive files with the same name, S3 keys that differ only in a doubled &lt;code&gt;/&lt;/code&gt;), one object&apos;s key changing between runs (a case-only rename on macOS), and deletes that missed their object.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/blogs/changelog-1017-1025/#long-updates-no-longer-hang-on-linux-v1024&quot;&gt;Long updates on Linux&lt;/a&gt; (v1.0.24). Under sustained load, a long &lt;code&gt;App.update()&lt;/code&gt; could hang permanently on LMDB&apos;s writer lock. Each write transaction now stays on one OS thread from open to commit.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/blogs/changelog-1017-1025/#write-transactions-v1025&quot;&gt;Shared write transactions&lt;/a&gt; (v1.0.25). Concurrent commits share one LMDB write transaction. A connector rejecting one component&apos;s declared value used to fail the commit of every component batched with it, including components of other apps in the same &lt;code&gt;Environment&lt;/code&gt;. Only the failing component gets the error; the others commit in a transaction of their own.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/blogs/changelog-1017-1025/#memoization-under-concurrency-and-redefinition-v1023-to-v1024&quot;&gt;Memoization&lt;/a&gt; (v1.0.23 to v1.1.0). Two overlapping runs of a memoized component with the same key now execute once. A re-run notebook cell or &lt;code&gt;importlib.reload&lt;/code&gt; no longer drops the memos of the surviving function. Memo fingerprints &lt;a href=&quot;/blogs/changelog-1026-110/#memo-fingerprints-depend-only-on-values-v110&quot;&gt;depend only on values&lt;/a&gt;, not on object identity.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/blogs/changelog-1017-1025/#correctness-fixes&quot;&gt;Schema changes under &lt;code&gt;full_reprocess&lt;/code&gt;&lt;/a&gt; (v1.0.20, v1.0.21). The table and graph targets did not apply schema changes that arrived in a &lt;code&gt;full_reprocess&lt;/code&gt; run. Later updates reported success while the target drifted. Fixed in Postgres, SQLite, Doris, Snowflake, BigQuery, SurrealDB, LanceDB, Neo4j, and FalkorDB.&lt;/li&gt;
&lt;li&gt;Security. The Postgres and SQLite connectors validate table and column identifiers before they put them into SQL (v1.0.4). litellm 1.107.0, a release published to PyPI with a credential stealer, is excluded from every &lt;code&gt;litellm&lt;/code&gt; requirement (v1.0.26).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Connectors&lt;/h2&gt;
&lt;p&gt;CocoIndex added 10 connectors from 1.0.1 to 1.1.0.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Connector&lt;/th&gt;
&lt;th&gt;Kind&lt;/th&gt;
&lt;th&gt;Release&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/oci_object_storage/&quot;&gt;OCI Object Storage&lt;/a&gt;, with live bucket watching&lt;/td&gt;
&lt;td&gt;Source&lt;/td&gt;
&lt;td&gt;v1.0.1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/iggy/&quot;&gt;Apache Iggy&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Source&lt;/td&gt;
&lt;td&gt;v1.0.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/azure_blob/&quot;&gt;Azure Blob Storage&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Source&lt;/td&gt;
&lt;td&gt;v1.0.16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/falkordb/&quot;&gt;FalkorDB&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Graph target&lt;/td&gt;
&lt;td&gt;v1.0.1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/neo4j/&quot;&gt;Neo4j&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Graph target&lt;/td&gt;
&lt;td&gt;v1.0.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/turbopuffer/&quot;&gt;Turbopuffer&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Vector target&lt;/td&gt;
&lt;td&gt;v1.0.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/zvec/&quot;&gt;zvec&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Vector target&lt;/td&gt;
&lt;td&gt;v1.0.11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/valkey/&quot;&gt;Valkey&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Vector target&lt;/td&gt;
&lt;td&gt;v1.0.12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/snowflake/&quot;&gt;Snowflake&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Warehouse target&lt;/td&gt;
&lt;td&gt;v1.0.15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/bigquery/&quot;&gt;BigQuery&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Warehouse target&lt;/td&gt;
&lt;td&gt;v1.0.16&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Changes to existing connectors:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;LanceDB: background table compaction and new columns added in place (v1.0.7), then vector and full-text index management (v1.0.11).&lt;/li&gt;
&lt;li&gt;Qdrant: native sparse vectors for hybrid search (v1.0.16).&lt;/li&gt;
&lt;li&gt;Local file system: in live mode, a periodic rescan catches events the OS watcher missed (v1.0.15).&lt;/li&gt;
&lt;li&gt;SurrealDB: an overhaul with &lt;code&gt;declare_fields&lt;/code&gt;, flexible record IDs, and typed parameters (v1.0.25). The connector raises statement errors instead of swallowing them.&lt;/li&gt;
&lt;li&gt;Neo4j and FalkorDB: &lt;code&gt;node_target&lt;/code&gt; and &lt;code&gt;relationship_target&lt;/code&gt; APIs replace the table and relation APIs (v1.1.0). The old APIs remain available but are deprecated.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Operations, SDKs, and examples&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/ops/text/&quot;&gt;Code splitting in 11 more languages&lt;/a&gt; (v1.0.3 to v1.0.26). &lt;code&gt;RecursiveSplitter&lt;/code&gt; gained tree-sitter grammars for Svelte, Vue, Julia, Elm, Astro, Bash, CMake, HCL, Dart, Lua, and Nix.&lt;/li&gt;
&lt;li&gt;Speech-to-text (v1.0.1). &lt;code&gt;LiteLLMTranscriber&lt;/code&gt; transcribes audio inside a pipeline through any LiteLLM-backed provider. In 1.0.22 transcription requests gained retries.&lt;/li&gt;
&lt;li&gt;Entity resolution in parallel (v1.0.7). &lt;a href=&quot;https://cocoindex.io/docs/ops/entity_resolution/&quot;&gt;Entity resolution&lt;/a&gt; resolves independent components of the candidate graph in parallel.&lt;/li&gt;
&lt;li&gt;Rust SDK. The core SDK is separate from the Python bindings (v1.0.5). In 1.0.25, &lt;code&gt;#[cocoindex::function(memo, batching)]&lt;/code&gt;, &lt;code&gt;context_key!&lt;/code&gt;, and &lt;code&gt;SchemaFields&lt;/code&gt; made batching, context keys, and connector schemas declarative. Start with the &lt;a href=&quot;https://cocoindex.io/docs/getting_started/rust_quickstart/&quot;&gt;Rust quickstart&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;17 &lt;a href=&quot;https://cocoindex.io/docs/examples/&quot;&gt;example walkthroughs&lt;/a&gt; (v1.0.13), written so that a coding agent can follow them step by step.&lt;/li&gt;
&lt;li&gt;Meeting notes to a knowledge graph now runs on Neo4j, FalkorDB, and SurrealDB.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/examples/slides-to-speech/&quot;&gt;Slides to speech&lt;/a&gt; narrates locally on the CPU without a TTS API key, and re-runs only the slides you edit.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Thanks&lt;/h2&gt;
&lt;p&gt;The four changelogs thank 50 contributors by name, more than 30 of them first-time contributors. The contributors behind the features this post leads with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Per-argument memo keys: &lt;a href=&quot;https://github.com/MrAnayDongre&quot;&gt;@MrAnayDongre&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;coco.use_state()&lt;/code&gt;: &lt;a href=&quot;https://github.com/hakuuww&quot;&gt;@hakuuww&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;coco.timeout()&lt;/code&gt;: &lt;a href=&quot;https://github.com/tomz-alt&quot;&gt;@tomz-alt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Target-state inspection in &lt;code&gt;cocoindex show&lt;/code&gt;: &lt;a href=&quot;https://github.com/junzh0u&quot;&gt;@junzh0u&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The Snowflake, BigQuery, and Azure Blob connectors: &lt;a href=&quot;https://github.com/sdhilip200&quot;&gt;@sdhilip200&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The GPU pool rewrite: &lt;a href=&quot;https://github.com/YaxinCheng&quot;&gt;@YaxinCheng&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The Google Drive fix that started the connector key audit: &lt;a href=&quot;https://github.com/Sujit-1509&quot;&gt;@Sujit-1509&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each changelog thanks everyone who contributed to it. For every change, see the four changelogs linked above or the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/releases&quot;&gt;GitHub releases&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>announcement</category><category>feature</category><category>changelog</category><author>George He</author></item><item><title>Dry-run previews, per-call dependencies and bounded batching</title><link>https://cocoindex.io/blogs/changelog-1026-110/</link><guid isPermaLink="true">https://cocoindex.io/blogs/changelog-1026-110/</guid><description>CocoIndex 1.0.26 and 1.1.0 add a preview that stores no state, per-call logic dependencies, bounded batching and component concurrency.</description><pubDate>Mon, 02 Nov 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This changelog covers CocoIndex 1.0.26 and 1.1.0. The releases add a preview that changes no state, per-call logic dependencies, bounds on batching and on component concurrency, and fixes from an audit of how every Python connector builds its keys.&lt;/p&gt;
&lt;p&gt;Before upgrading, read the &lt;a href=&quot;#upgrade-notes&quot;&gt;upgrade notes&lt;/a&gt;. They explain API changes, connector key changes, and one-time reprocessing.&lt;/p&gt;
&lt;p&gt;CocoIndex builds fresh, structured context for AI from sources such as PDFs, codebases, emails, screenshots, and meeting notes, and keeps it up to date with an &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;incremental engine&lt;/a&gt;. The source is on &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;:::tip[Start here]&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;You write pipelines:&lt;/strong&gt; read &lt;a href=&quot;#preview-runs-on-real-pipelines-and-writes-nothing-v1026&quot;&gt;preview&lt;/a&gt;, &lt;a href=&quot;#cocologicdep-and-cocouse_logic_dep-a-dependency-decided-per-call-v110&quot;&gt;per-call logic dependencies&lt;/a&gt; and the two batching sections, &lt;a href=&quot;#batching-a-bound-on-in-flight-batches-v110&quot;&gt;&lt;code&gt;max_in_flight&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;#batching-one-rate-limit-token-per-batch-v110&quot;&gt;&lt;code&gt;rate_limiter&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You run deployments:&lt;/strong&gt; read the &lt;a href=&quot;#upgrade-notes&quot;&gt;upgrade notes&lt;/a&gt;, &lt;a href=&quot;#slot-lending-a-component-limit-that-holds-across-the-hierarchy-v1026&quot;&gt;slot lending&lt;/a&gt; and &lt;a href=&quot;#fair-sharing-between-live-components-v110&quot;&gt;fair sharing&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You use or build connectors:&lt;/strong&gt; read &lt;a href=&quot;#connector-keys-collisions-and-lost-writes-v110&quot;&gt;connector keys&lt;/a&gt;, the &lt;a href=&quot;#graph-targets-node-and-relationship-apis&quot;&gt;graph target APIs&lt;/a&gt;, and the connector-author notes at the end of &lt;a href=&quot;#preview-runs-on-real-pipelines-and-writes-nothing-v1026&quot;&gt;preview&lt;/a&gt;.
:::&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Why this release cycle matters&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Preview writes nothing.&lt;/strong&gt; &lt;a href=&quot;#preview-runs-on-real-pipelines-and-writes-nothing-v1026&quot;&gt;&lt;code&gt;cocoindex update --preview&lt;/code&gt;&lt;/a&gt; now handles rows under table targets, so it runs on most pipelines, and it never stores a memo or writes committed state, so it can&apos;t make the next real update skip work.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Per-call logic dependencies.&lt;/strong&gt; &lt;a href=&quot;#logic-tracking-beyond-the-decorator-v1026-to-v110&quot;&gt;&lt;code&gt;coco.LogicDep&lt;/code&gt; and &lt;code&gt;coco.use_logic_dep()&lt;/code&gt;&lt;/a&gt; let one call record a dependency, such as the version of the parser it used. Bumping that dependency re-runs only the calls that recorded it and the memoized callers above them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bounded batching.&lt;/strong&gt; A batched function takes &lt;a href=&quot;#batching-a-bound-on-in-flight-batches-v110&quot;&gt;&lt;code&gt;max_in_flight&lt;/code&gt;&lt;/a&gt;, which caps how many batches run at once, and &lt;a href=&quot;#batching-one-rate-limit-token-per-batch-v110&quot;&gt;&lt;code&gt;rate_limiter&lt;/code&gt;&lt;/a&gt;, which takes one token per batch instead of per call.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A component limit that holds across the hierarchy.&lt;/strong&gt; &lt;a href=&quot;#slot-lending-a-component-limit-that-holds-across-the-hierarchy-v1026&quot;&gt;&lt;code&gt;max_inflight_components&lt;/code&gt;&lt;/a&gt; now bounds every running component: a parent lends its slot to one child at a time, and live components &lt;a href=&quot;#fair-sharing-between-live-components-v110&quot;&gt;share the pool fairly&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Faster commits when target states move.&lt;/strong&gt; Moving 5,000 target states from one component to another in one commit &lt;a href=&quot;#moving-target-states-between-components-v110&quot;&gt;took 243 seconds and now takes 1 to 2&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Keys that hold in the edge cases.&lt;/strong&gt; CocoIndex has identified each object by one key from the start. An audit of every Python connector &lt;a href=&quot;#connector-keys-collisions-and-lost-writes-v110&quot;&gt;closed the cases&lt;/a&gt; where a connector&apos;s key construction broke that rule: two objects sharing one key, one object&apos;s key changing between runs, or a delete missing its object.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Upgrade notes&lt;/h2&gt;
&lt;p&gt;Check these before upgrading. Each item names the release it applies from. The 1.1.0 items are what make this a minor version rather than another patch.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Deprecated, still working&lt;/strong&gt; (with a &lt;code&gt;DeprecationWarning&lt;/code&gt;):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Neo4j and FalkorDB table and relation APIs&lt;/strong&gt; (v1.1.0). Each has a replacement with the same parameters: &lt;code&gt;table_target&lt;/code&gt; → &lt;code&gt;node_target&lt;/code&gt;, &lt;code&gt;declare_table_target&lt;/code&gt; → &lt;code&gt;declare_node_target&lt;/code&gt;, &lt;code&gt;mount_table_target&lt;/code&gt; → &lt;code&gt;mount_node_target&lt;/code&gt; (which returns a &lt;code&gt;NodeTarget&lt;/code&gt;), &lt;code&gt;relation_target&lt;/code&gt; → &lt;code&gt;relationship_target&lt;/code&gt;, &lt;code&gt;declare_relation_target&lt;/code&gt; → &lt;code&gt;declare_relationship_target&lt;/code&gt;, &lt;code&gt;mount_relation_target&lt;/code&gt; → &lt;code&gt;mount_relationship_target&lt;/code&gt;, and &lt;code&gt;RelationTarget.declare_relation&lt;/code&gt; → &lt;code&gt;RelationshipTarget.declare_relationship&lt;/code&gt;. The deprecated calls keep the keys they had. Switching an existing table takes two updates, listed under &lt;a href=&quot;#graph-targets-node-and-relationship-apis&quot;&gt;node and relationship APIs&lt;/a&gt;; skipping the first deletes the table&apos;s nodes or edges.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Kafka &lt;code&gt;topic_as_map&lt;/code&gt; with a list of topics&lt;/strong&gt; (v1.1.0). The list form still works with its old keys. With one topic, pass it as a string; the keys don&apos;t change. With several, use one feed and one consumer per topic, each under its own subpath. That changes the item keys, so follow the replay steps in the &lt;a href=&quot;https://cocoindex.io/docs/connectors/kafka/&quot;&gt;Kafka docs&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Postgres &lt;code&gt;TableTarget(provider, table_schema)&lt;/code&gt;&lt;/strong&gt; (v1.1.0). Pass the table name: &lt;code&gt;TableTarget(provider, table_name, table_schema)&lt;/code&gt;. The keys don&apos;t change.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connector sink contracts&lt;/strong&gt; (v1.0.26). &lt;code&gt;from_fn_with_children&lt;/code&gt; and &lt;code&gt;from_async_fn_with_children&lt;/code&gt; are replaced by &lt;code&gt;TargetActionSink.from_fn(fn, child_handler=...)&lt;/code&gt; and &lt;code&gt;from_async_fn(...)&lt;/code&gt;. The old forms still run but don&apos;t support preview.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;coco.logic_tracked&lt;/code&gt;&lt;/strong&gt; (v1.0.26) is a deprecated alias of &lt;code&gt;coco.logic_propagated_to_callers&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Behavior changes:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Object-store &lt;code&gt;prefix&lt;/code&gt; names a folder&lt;/strong&gt; (v1.1.0). For S3, Azure Blob and OCI, &lt;code&gt;prefix=&quot;docs&quot;&lt;/code&gt; now lists only &lt;code&gt;docs/...&lt;/code&gt;; &lt;code&gt;docsa.md&lt;/code&gt; and &lt;code&gt;docs-old/x&lt;/code&gt; are no longer included. Target states built from objects that drop out of the listing are removed on the next update. To select objects by how their names start, use &lt;code&gt;path_matcher&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Preview leaves no trace&lt;/strong&gt; (v1.0.26). A preview no longer stores, deletes or refreshes memos and no longer writes committed state.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;FilePath&lt;/code&gt; comparisons&lt;/strong&gt; (v1.1.0). &lt;code&gt;FilePath&lt;/code&gt;s of different types no longer compare equal, and ordering them raises &lt;code&gt;TypeError&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;New errors:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;DirTarget&lt;/code&gt; names that are absolute or leave the directory (v1.1.0).&lt;/li&gt;
&lt;li&gt;A new zvec collection with an &lt;code&gt;Any&lt;/code&gt;, &lt;code&gt;object&lt;/code&gt;, union or &lt;code&gt;bytes&lt;/code&gt; key column (v1.1.0).&lt;/li&gt;
&lt;li&gt;LanceDB key column types that deletes can&apos;t filter on, such as dates, timestamps, &lt;code&gt;float16&lt;/code&gt; and lists (v1.1.0).&lt;/li&gt;
&lt;li&gt;Postgres vector indexes whose names truncate to the same 63 bytes (v1.1.0).&lt;/li&gt;
&lt;li&gt;The Valkey field name &lt;code&gt;vector&lt;/code&gt; (v1.1.0).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;@coco.fn(batching=...)&lt;/code&gt; and &lt;code&gt;@coco.fn(runner=...)&lt;/code&gt; are type errors; use &lt;code&gt;@coco.fn.as_async&lt;/code&gt;. A lone &lt;code&gt;max_batch_size=&lt;/code&gt; on a sync function is rejected instead of ignored (v1.0.26).&lt;/li&gt;
&lt;li&gt;A class the state reader can&apos;t load fails at the first write, with a hint to use &lt;code&gt;coco.unpickle_safe&lt;/code&gt;, instead of on the next run (v1.1.0).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;One-time effects on the first update after upgrading:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Google Drive components get new keys and are reprocessed (v1.1.0).&lt;/li&gt;
&lt;li&gt;Objects that shared a key become separate items (v1.1.0).&lt;/li&gt;
&lt;li&gt;SurrealDB relations declared without an explicit &lt;code&gt;id&lt;/code&gt; are re-created under a new record ID (v1.1.0).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;DirTarget&lt;/code&gt; files declared under a name that now normalizes, such as &lt;code&gt;./a.txt&lt;/code&gt;, are written once under the new name (v1.1.0).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To remove duplicate graph edges left by earlier versions, run one update with &lt;code&gt;--full-reprocess&lt;/code&gt; (v1.1.0).&lt;/p&gt;
&lt;p&gt;:::warning[Memo fingerprints change for values with shared sub-objects (v1.1.0)]
Memo keys and fingerprints now depend only on values, so a structure that references one object twice fingerprints the same as one holding equal copies. For such values, on the first update after upgrading: memoized work may run once more; &lt;code&gt;generate_id&lt;/code&gt;, &lt;code&gt;generate_uuid&lt;/code&gt;, &lt;code&gt;IdGenerator&lt;/code&gt; and &lt;code&gt;UuidGenerator&lt;/code&gt; may return new IDs, which changes row keys built from them; and rows tracked by &lt;code&gt;fingerprint_object&lt;/code&gt; are written again. See &lt;a href=&quot;#memo-fingerprints-depend-only-on-values-v110&quot;&gt;the fix&lt;/a&gt;.
:::&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Requirements and the Rust SDK:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;FalkorDB needs &lt;code&gt;falkordb&lt;/code&gt; 1.6.0 or later (v1.0.26).&lt;/li&gt;
&lt;li&gt;The Rust crates need Rust 1.91.1 or later (v1.0.26).&lt;/li&gt;
&lt;li&gt;Rust SDK: the Neo4j and FalkorDB table and relation target functions take &lt;code&gt;&amp;amp;ContextKey&lt;/code&gt; instead of &lt;code&gt;&amp;amp;Graph&lt;/code&gt; (v1.0.26).&lt;/li&gt;
&lt;li&gt;litellm 1.107.0 is excluded from every &lt;code&gt;litellm&lt;/code&gt; requirement (v1.0.26); see &lt;a href=&quot;#security-and-dependencies&quot;&gt;Security and dependencies&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;New APIs and capabilities&lt;/h2&gt;
&lt;h3&gt;Preview runs on real pipelines and writes nothing (v1.0.26)&lt;/h3&gt;
&lt;p&gt;A preview lists what an update would change in the targets, without changing them. Before 1.0.26 it handled only target states with nothing nested under them. Most real pipelines nest: rows under a Postgres table, points under a Qdrant collection, files under a directory target, where the table or directory is a container and the rows or files are its children. As soon as a preview reached a container with children it stopped with an error, &lt;code&gt;preview currently supports flat/leaf target actions only&lt;/code&gt;. It was also unsafe: a preview could store, delete or refresh &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#memoization&quot;&gt;memos&lt;/a&gt; (stored results of function calls, reused while their inputs and code are unchanged), and write committed state (the record of what earlier updates finished), so the next real update could skip work it had never done (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2510&quot;&gt;&lt;strong&gt;#2510&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Both are fixed. Preview now lists the planned actions for &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;target states&lt;/a&gt; under a container, reads memos without changing them, and writes no committed state. It also runs no deletes for &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/live_component/&quot;&gt;live components&lt;/a&gt; (components that stay running after their first full scan and react to each change). One exception is deliberate: &lt;code&gt;generate_id&lt;/code&gt; and &lt;code&gt;IdGenerator&lt;/code&gt; reserve IDs in a preview as in an update, because IDs are opaque and a gap in them has no effect. The IDs a preview prints for new items are therefore not the ones the next update assigns.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cocoindex update --preview path/to/app.py
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;handle = app.update(preview=True)
actions = await handle.result()  # one entry per planned target action; nothing was applied
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; The CLI prints one line per planned action, or &lt;code&gt;No target actions planned.&lt;/code&gt; Memos and committed state are as they were before the preview (only ID counters advance), so the next real update does the same work it would have done without the preview.&lt;/p&gt;
&lt;p&gt;A container&apos;s action is listed in every preview, even when its tracking record (what CocoIndex stored about it after the last run) is unchanged, because equal tracking records do not guarantee that applying the action has no external effect. A preview also applies no actions to a &lt;a href=&quot;https://cocoindex.io/docs/common_resources/live_map/&quot;&gt;live map&lt;/a&gt;, so consumers of the map see it empty; preview the producers&apos; own targets instead.&lt;/p&gt;
&lt;p&gt;For connector authors, a container&apos;s child handler is now a pure function of its action. &lt;code&gt;TargetActionSink.from_fn(fn, child_handler=...)&lt;/code&gt; and &lt;code&gt;from_async_fn(...)&lt;/code&gt; replace &lt;code&gt;from_fn_with_children&lt;/code&gt; and &lt;code&gt;from_async_fn_with_children&lt;/code&gt;: &lt;code&gt;fn(context_provider, actions)&lt;/code&gt; only applies the actions, and &lt;code&gt;child_handler(context_provider, action)&lt;/code&gt; builds the handler for the container&apos;s children, before &lt;code&gt;fn&lt;/code&gt; applies them in an update and in place of &lt;code&gt;fn&lt;/code&gt; in a preview. The old forms still run with a &lt;code&gt;DeprecationWarning&lt;/code&gt; but can&apos;t be previewed.&lt;/p&gt;

Quick check: you run &lt;code&gt;cocoindex update --preview&lt;/code&gt;, then &lt;code&gt;cocoindex update&lt;/code&gt;. Does the update skip the work the preview planned?
&lt;p&gt;No. The preview stores no memos and writes no committed state, so the update does all of that work itself. The one trace is the ID counters: IDs that &lt;code&gt;generate_id&lt;/code&gt; assigns in the update differ from the ones the preview printed.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;Logic tracking beyond the decorator (v1.0.26 to v1.1.0)&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;@coco.fn&lt;/code&gt; fingerprints a function&apos;s logic (computes a key from its code and declared dependencies) so that editing the function invalidates the memos that depend on it. Some dependencies don&apos;t fit that model: one that differs from call to call, and a callback whose logic a library hides. Both now have their own tools.&lt;/p&gt;
&lt;h4&gt;&lt;code&gt;coco.LogicDep&lt;/code&gt; and &lt;code&gt;coco.use_logic_dep()&lt;/code&gt;: a dependency decided per call (v1.1.0)&lt;/h4&gt;
&lt;p&gt;A parser upgrade should re-run only the work that used that parser. &lt;code&gt;deps=&lt;/code&gt; on the decorator can&apos;t express that, because it describes the whole function: every call depends on the value. Some dependencies are decided per call. A tree walk&apos;s &lt;code&gt;visit_file&lt;/code&gt; depends on the parser for &lt;em&gt;that file&apos;s&lt;/em&gt; language, and a change to one parser should re-run the files it parsed, not every file the walk saw. &lt;code&gt;coco.LogicDep&lt;/code&gt; declares such a value once, at module import, and &lt;code&gt;coco.use_logic_dep()&lt;/code&gt; records it as part of the current call&apos;s logic (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2590&quot;&gt;&lt;strong&gt;#2590&lt;/strong&gt;&lt;/a&gt;):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;PARSER_DEPS = {
    name: coco.LogicDep((&quot;parser&quot;, name, version))
    for name, version in PARSER_VERSIONS.items()
}

@coco.fn(logic_tracking=&quot;self&quot;, version=1)
async def visit_file(file: File) -&amp;gt; None:
    language = detect_language(file.path)
    if (dep := PARSER_DEPS.get(language)) is not None:
        coco.use_logic_dep(dep)  # this call&apos;s logic also depends on that parser
    ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the sample, &lt;code&gt;visit_file&lt;/code&gt; is tracked as &lt;code&gt;&quot;self&quot;&lt;/code&gt;, so the functions it calls are not part of its fingerprint; the parser dependency is recorded whatever the mode, because it describes the call rather than the function&apos;s code. A recorded dependency travels like the function&apos;s own fingerprint: into the entry of a memoized caller, onward through &lt;code&gt;&quot;full&quot;&lt;/code&gt; callers, and from a mounted component into every ancestor component&apos;s entry. When a later release constructs the &lt;code&gt;LogicDep&lt;/code&gt; with a new value, only the entries that recorded the old one are invalidated.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; In the example, bumping the Python parser&apos;s version re-runs the Python files and the directories above them. Every other subtree is reused from its memos.&lt;/p&gt;
&lt;p&gt;Two rules follow from how entries are validated:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Build every &lt;code&gt;LogicDep&lt;/code&gt; at module import, before any component runs. One constructed on first use registers too late, and one constructed per call is released too early; in both cases memoization silently stops working rather than returning stale data. Constructing one inside a component context raises.&lt;/li&gt;
&lt;li&gt;Adopting &lt;code&gt;use_logic_dep&lt;/code&gt; in a function whose memoized callers already stored entries does not re-store those entries. Ship the adoption with a &lt;code&gt;version&lt;/code&gt; bump on those callers.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The same PR fixed a related bug: a function-memo hit lost the logic dependencies its entry had recorded, so a caller re-stored on that hit missed later changes to deeper callees.&lt;/p&gt;

Quick check: to save work at import, you build each parser&apos;s &lt;code&gt;coco.LogicDep&lt;/code&gt; inside &lt;code&gt;visit_file&lt;/code&gt; the first time that parser is used. What happens?
&lt;p&gt;The construction raises, because &lt;code&gt;visit_file&lt;/code&gt; runs inside a component context. Build every &lt;code&gt;LogicDep&lt;/code&gt; at module import, as in the &lt;code&gt;PARSER_DEPS&lt;/code&gt; example above.&lt;/p&gt;

&lt;h4&gt;&lt;code&gt;coco.logic_propagated_to_callers()&lt;/code&gt;: callbacks through a &lt;code&gt;&quot;self&quot;&lt;/code&gt; boundary (v1.0.26)&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;logic_tracking=&quot;self&quot;&lt;/code&gt; hides the logic of everything a function calls, including callbacks it received as arguments. A library whose &lt;code&gt;accept&lt;/code&gt; is tracked as &lt;code&gt;&quot;self&quot;&lt;/code&gt; therefore hides the user&apos;s &lt;code&gt;visit_file&lt;/code&gt;: an edit to it invalidates nothing, even though it is the user&apos;s input and not the library&apos;s implementation detail. &lt;code&gt;coco.logic_propagated_to_callers(fn)&lt;/code&gt; fixes this (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2483&quot;&gt;&lt;strong&gt;#2483&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2529&quot;&gt;&lt;strong&gt;#2529&lt;/strong&gt;&lt;/a&gt;). It is library-side; the user only puts &lt;code&gt;@coco.fn&lt;/code&gt; on the callback.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Library
@coco.fn(memo=True, logic_tracking=&quot;self&quot;, version=1)
async def accept(file: File, visit_file: Callable[[File], Awaitable[None]]) -&amp;gt; None:
    await visit_file(file)

@coco.fn
async def walk(repo: Repo, visitor: RepoVisitor) -&amp;gt; None:
    visit_file = coco.logic_propagated_to_callers(visitor.visit_file)  # walk owns the callback
    for file in repo.files():
        await coco.use_mount(coco.component_subpath(file.path), accept, file, visit_file)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The function that calls it is the callback&apos;s owner. The wrapper runs &lt;code&gt;fn&lt;/code&gt; as usual; afterwards, &lt;code&gt;fn&lt;/code&gt;&apos;s logic is recorded in every memo entry between the call site and the owner, whatever their &lt;code&gt;logic_tracking&lt;/code&gt;. When the user edits &lt;code&gt;visit_file&lt;/code&gt;, every &lt;code&gt;accept&lt;/code&gt; memo entry misses. Two wrappers of the same function produce the same key. &lt;code&gt;coco.logic_tracked&lt;/code&gt;, its name before 1.0.26 shipped, remains as a deprecated alias and works with a &lt;code&gt;DeprecationWarning&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;Batching: a bound on in-flight batches (v1.1.0)&lt;/h3&gt;
&lt;p&gt;By default, one slow batch can hold back the calls queued behind it. A batched function starts a batch in three situations. The first call on an idle queue runs at once, on its own. A batch that fills to &lt;code&gt;max_batch_size&lt;/code&gt; starts as soon as it fills. And when a batch finishes, the next pending batch may start. A call that arrives while batches are running joins the open partial batch and waits for one of those triggers. Without a bound, the partial batch starts only once no batch is running at all.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;@coco.fn.as_async(batching=True, ...)&lt;/code&gt; now takes &lt;code&gt;max_in_flight&lt;/code&gt;, which bounds how many batches run at once and changes when a batch may start (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2588&quot;&gt;&lt;strong&gt;#2588&lt;/strong&gt;&lt;/a&gt;). With &lt;code&gt;max_in_flight=n&lt;/code&gt;, a batch that fills while &lt;code&gt;n&lt;/code&gt; batches are running waits in order, and whenever a batch finishes the next pending batch, full or partial, starts as long as fewer than &lt;code&gt;n&lt;/code&gt; are running. A partial batch no longer waits for the slowest batch, only for a free slot.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn.as_async(batching=True, max_batch_size=32, max_in_flight=4)
async def embed(texts: list[str]) -&amp;gt; list[list[float]]:
    return await client.embed(texts)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; At most 4 batches of up to 32 texts run at once. When one of them finishes, the next pending batch starts, even if it is partial and the other 3 are still running.&lt;/p&gt;
&lt;h3&gt;Batching: one rate-limit token per batch (v1.1.0)&lt;/h3&gt;
&lt;p&gt;When each batch is one request against a quota, the limit should count batches, not calls. The same decorator now takes &lt;code&gt;rate_limiter&lt;/code&gt;, the quota&apos;s &lt;a href=&quot;https://cocoindex.io/docs/common_resources/rate_limiting/&quot;&gt;&lt;code&gt;RateLimiter&lt;/code&gt;&lt;/a&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2589&quot;&gt;&lt;strong&gt;#2589&lt;/strong&gt;&lt;/a&gt;). Every batch takes one token before it runs, so a token pays for one batch rather than one call. No call runs on its own: the first call waits for a token like any other and goes out with everything that arrived meanwhile. Under a scarce quota, calls that arrive while the batcher waits for a token join the next batch; with tokens to spare, a batch goes out at once and the next one fills during its round trip. For requests the body makes beyond the batch&apos;s own, such as a retry or a per-item fallback, the body should take its own tokens from the same limiter. For a limiter kept on the instance, pass a callable that receives &lt;code&gt;self&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;class Client:
    def __init__(self, limiter: RateLimiter) -&amp;gt; None:
        self._limiter = limiter

    @coco.fn.as_async(
        batching=True, max_batch_size=100, rate_limiter=lambda self: self._limiter
    )
    async def fetch(self, ids: list[str]) -&amp;gt; list[Item]:
        return await self._api.fetch_many(ids)  # one request, one token
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; Each batch takes 1 token from the client&apos;s limiter before it runs, whether it holds 1 ID or 100.&lt;/p&gt;
&lt;h3&gt;Slot lending: a component limit that holds across the hierarchy (v1.0.26)&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;max_inflight_components&lt;/code&gt; (or &lt;code&gt;COCOINDEX_MAX_INFLIGHT_COMPONENTS&lt;/code&gt;, default 1024) caps how many processing components run at once. The difficulty with any such cap is a hierarchy: a parent that mounts children and waits for them holds a slot while it waits, so with a small cap the slots fill with waiting parents and the children they wait for can never start. Before 1.0.26 the engine avoided that deadlock by releasing a parent&apos;s slot when it mounted its first child, which left everything after that first mount unbounded. A tree walk that read files faster than the downstream stage drained them kept every file component in flight, each holding its contents; one indexer was killed for memory with about 15,000 file components in flight while the application&apos;s own limit allowed 256 (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2486&quot;&gt;&lt;strong&gt;#2486&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;1.0.26 replaces that with slot lending. A waiting parent keeps its slot and lends it to one child at a time: the first child runs on the parent&apos;s slot, further children take free slots from the pool and wait while it is empty, and when the lent child finishes the slot passes to the parent&apos;s next waiting child. A blocked parent therefore always has one child that can run, so a hierarchy of any depth completes even with &lt;code&gt;max_inflight_components=1&lt;/code&gt;, and the components executing at once never exceed the cap. Counting the parents waiting on children, the components in flight are bounded by the cap times the depth of the hierarchy.&lt;/p&gt;
&lt;p&gt;Three related rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A component that awaits a function call, batched or not, keeps its slot; only mounting a child lends it.&lt;/li&gt;
&lt;li&gt;Live components borrow the slot of the component that mounted them while it runs, then take slots from the pool.&lt;/li&gt;
&lt;li&gt;Component deletion draws on the same pool.&lt;/li&gt;
&lt;/ul&gt;

Quick check: with &lt;code&gt;max_inflight_components=1&lt;/code&gt;, a parent mounts 3 children and waits for them. Does the update deadlock?
&lt;p&gt;No. The parent lends its one slot to the first child; when that child finishes, the slot passes to the next waiting child. The 3 children run one after another and the parent then completes.&lt;/p&gt;

&lt;h3&gt;Fair sharing between live components (v1.1.0)&lt;/h3&gt;
&lt;p&gt;Live components update on their own schedules, and one can have far more work queued than another: a new component&apos;s first full index next to a refresh of a few changed items. A freed slot used to go to the oldest waiting component, so the component with the large backlog held back every other live component, and the small refresh waited behind the whole backlog (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2624&quot;&gt;&lt;strong&gt;#2624&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The pool is now shared fairly between independent updates: an &lt;code&gt;App.update()&lt;/code&gt;, one cycle of a live component, or one item update of &lt;code&gt;mount_each()&lt;/code&gt; over a live map. A slot that frees up goes to whichever waiting update holds the fewest slots, then to the earliest waiter among equals. No slot is reserved, so an update that runs alone still gets the whole pool. In the test that pins this, a small refresh running beside a 400-leaf first index used to finish after 283 to 292 of the large leaves and now finishes after 80 to 82.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;Smaller additions (v1.0.26)&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Nix&lt;/strong&gt; gets syntax-aware splitting and structural code patterns (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2434&quot;&gt;&lt;strong&gt;#2434&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/mulatta&quot;&gt;@mulatta&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;regex_required_literals&lt;/code&gt;&lt;/strong&gt; is public (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2525&quot;&gt;&lt;strong&gt;#2525&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Error cause chains.&lt;/strong&gt; Internal errors show their full cause chain, for example &lt;code&gt;db error: ERROR: deadlock detected&lt;/code&gt; instead of &lt;code&gt;db error&lt;/code&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2489&quot;&gt;&lt;strong&gt;#2489&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The optional &lt;code&gt;application&lt;/code&gt; telemetry tag&lt;/strong&gt; is documented (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2539&quot;&gt;&lt;strong&gt;#2539&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;ConnectionFactory.close()&lt;/code&gt;.&lt;/strong&gt; The Neo4j, FalkorDB and SurrealDB factories keep one connection per event loop, and the Neo4j and FalkorDB ones gain &lt;code&gt;close()&lt;/code&gt;, which SurrealDB&apos;s already had. FalkorDB needs &lt;code&gt;falkordb&lt;/code&gt; 1.6.0 or later (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2510&quot;&gt;&lt;strong&gt;#2510&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Rust SDK: memo frames, mount keys, and root-provider cleanup (v1.0.26)&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Memo frames.&lt;/strong&gt; Memoized calls join the enclosing caller&apos;s frame (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2503&quot;&gt;&lt;strong&gt;#2503&lt;/strong&gt;&lt;/a&gt;), so a memoized caller no longer returns stale values or deletes its children&apos;s outputs on a cache hit. Mounting inside &lt;code&gt;#[function(memo)]&lt;/code&gt; is rejected, as in Python.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mount keys.&lt;/strong&gt; &lt;code&gt;use_mount!&lt;/code&gt; and &lt;code&gt;mount_each!&lt;/code&gt; key by memo identity, so touching one file no longer re-runs every component. Connectors use one sink per handler instead of one apply per row.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Root-provider cleanup.&lt;/strong&gt; &lt;code&gt;App::drop_state&lt;/code&gt; and normal updates remove targets declared through root providers (directory files and Postgres, SQLite, LanceDB and Qdrant tables, among others) when they are no longer declared (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2512&quot;&gt;&lt;strong&gt;#2512&lt;/strong&gt;&lt;/a&gt;). Breaking: the Neo4j and FalkorDB table and relation target functions take &lt;code&gt;&amp;amp;ContextKey&lt;/code&gt; instead of &lt;code&gt;&amp;amp;Graph&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CI coverage.&lt;/strong&gt; Every SDK feature is type-checked and its hermetic feature tests run (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2523&quot;&gt;&lt;strong&gt;#2523&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Performance&lt;/h2&gt;
&lt;h3&gt;Moving target states between components (v1.1.0)&lt;/h3&gt;
&lt;p&gt;When a component takes target states that another component owns, the commit did work proportional to the old owner&apos;s whole tracking record for every moved target. The pending-retry check decoded the record once per moved target, and the first commit phase decoded it again, scanned every remaining item, and re-encoded it. Moving N targets from one owner was quadratic in N (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2621&quot;&gt;&lt;strong&gt;#2621&lt;/strong&gt;&lt;/a&gt;, from a fix by &lt;a href=&quot;https://github.com/badmonster0&quot;&gt;@badmonster0&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Each preempted owner&apos;s record is now decoded once per commit and shared by both passes, items are taken out of it in place, and each modified record is encoded once for writing. Writes are unchanged, since there was already one upsert per old owner, and they still apply inside the same transaction as before.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Targets moved in one commit&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1,000&lt;/td&gt;
&lt;td&gt;8.7 s&lt;/td&gt;
&lt;td&gt;0.29 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2,500&lt;/td&gt;
&lt;td&gt;67.2 s&lt;/td&gt;
&lt;td&gt;0.65 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5,000&lt;/td&gt;
&lt;td&gt;242.7 s&lt;/td&gt;
&lt;td&gt;1.0 to 1.8 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Debug build, LMDB, same machine for both columns. The previous changelog&apos;s &lt;a href=&quot;/blogs/changelog-1017-1025/#large-target-updates-less-memory-fewer-reconciles-v1025&quot;&gt;commit-path work&lt;/a&gt; covered the per-row cost of a large table; this removes the per-owner cost when ownership moves.&lt;/p&gt;
&lt;h2&gt;Fixes&lt;/h2&gt;
&lt;h3&gt;Connector keys: collisions and lost writes (v1.1.0)&lt;/h3&gt;
&lt;p&gt;Every source item and every target state has a key. CocoIndex uses the key to match an object with its previous run and to decide what to create, update or delete. That has been the rule from the first release; what 1.1.0 changes is the edge cases where a connector built keys in a way that broke it. A Google Drive fix (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2485&quot;&gt;&lt;strong&gt;#2485&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/Sujit-1509&quot;&gt;@Sujit-1509&lt;/a&gt;) started an audit of how every Python connector builds its keys. The audit found 4 kinds of bug, most of them edge cases, and 1.1.0 fixes each one.&lt;/p&gt;
&lt;p&gt;Two keys you choose can also reach one object, such as overlapping directories or two &lt;code&gt;ContextKey&lt;/code&gt;s for one database. CocoIndex can&apos;t detect that, so it stays your responsibility; the docs now explain where it can happen.&lt;/p&gt;
&lt;h4&gt;Two different objects shared one key&lt;/h4&gt;
&lt;p&gt;One overwrote or deleted the other.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Google Drive:&lt;/strong&gt; files with the same name, even in one folder. Items are now keyed by file ID (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2485&quot;&gt;&lt;strong&gt;#2485&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S3, Azure Blob and OCI:&lt;/strong&gt; object keys that differ only in a doubled or leading &lt;code&gt;/&lt;/code&gt;, a &lt;code&gt;./&lt;/code&gt; segment, or &lt;code&gt;\&lt;/code&gt; versus &lt;code&gt;/&lt;/code&gt;; with &lt;code&gt;prefix=&quot;docs&quot;&lt;/code&gt;, &lt;code&gt;docs/a.md&lt;/code&gt; and &lt;code&gt;docsa.md&lt;/code&gt;; and paths in different buckets, which compared equal (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2601&quot;&gt;&lt;strong&gt;#2601&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Kafka:&lt;/strong&gt; the same message key on two topics of one &lt;code&gt;topic_as_map&lt;/code&gt; feed. A tombstone (a message with no value, which marks its key as deleted) on one topic deleted the other topic&apos;s outputs (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2597&quot;&gt;&lt;strong&gt;#2597&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Neo4j and FalkorDB:&lt;/strong&gt; a node label and a relationship type with the same name, and derived edge IDs of different endpoints (&lt;code&gt;1&lt;/code&gt; versus &lt;code&gt;&quot;1&quot;&lt;/code&gt;, IDs containing &lt;code&gt;_&lt;/code&gt;). The fix comes as the new node and relationship target APIs below (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2612&quot;&gt;&lt;strong&gt;#2612&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SurrealDB:&lt;/strong&gt; derived relation IDs of different endpoints, such as &lt;code&gt;doc:&apos;chunk_1&apos;&lt;/code&gt; and &lt;code&gt;doc_chunk:1&lt;/code&gt; linked to the same tag (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2599&quot;&gt;&lt;strong&gt;#2599&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;zvec:&lt;/strong&gt; &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;&quot;1&quot;&lt;/code&gt; in an &lt;code&gt;Any&lt;/code&gt;, &lt;code&gt;object&lt;/code&gt; or union key column became one document (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2608&quot;&gt;&lt;strong&gt;#2608&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2613&quot;&gt;&lt;strong&gt;#2613&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Postgres:&lt;/strong&gt; two vector indexes on one table whose names Postgres truncates to the same 63 bytes, so only one of them could exist (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2603&quot;&gt;&lt;strong&gt;#2603&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2615&quot;&gt;&lt;strong&gt;#2615&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Valkey:&lt;/strong&gt; a payload key or &lt;code&gt;FieldDef&lt;/code&gt; named &lt;code&gt;vector&lt;/code&gt;, the hash field that holds the document&apos;s vector (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2606&quot;&gt;&lt;strong&gt;#2606&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;One object&apos;s key changed between runs&lt;/h4&gt;
&lt;p&gt;The delete for the old key removed what the new key had just written.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;localfs:&lt;/strong&gt; a case-only rename on macOS and Windows, or &lt;code&gt;./a.txt&lt;/code&gt; changed to &lt;code&gt;a.txt&lt;/code&gt;. The file stayed missing until its content changed (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2598&quot;&gt;&lt;strong&gt;#2598&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Qdrant:&lt;/strong&gt; a UUID point ID written in another text form: upper case, no hyphens, or a URN (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2602&quot;&gt;&lt;strong&gt;#2602&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Kafka target:&lt;/strong&gt; a message key that switched between &lt;code&gt;str&lt;/code&gt; and &lt;code&gt;bytes&lt;/code&gt;. Its tombstone erased the record on a compacted topic (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2597&quot;&gt;&lt;strong&gt;#2597&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Neo4j and FalkorDB:&lt;/strong&gt; a renamed vector index (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2611&quot;&gt;&lt;strong&gt;#2611&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;A delete missed its object&lt;/h4&gt;
&lt;p&gt;Stale data stayed behind.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;LanceDB:&lt;/strong&gt; every row delete failed for a key column that needs quoting (&lt;code&gt;doc-id&lt;/code&gt;), or that holds binary, fixed-size binary or the int64 minimum (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2600&quot;&gt;&lt;strong&gt;#2600&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Doris:&lt;/strong&gt; keys containing &lt;code&gt;\&lt;/code&gt;. Each update appended a duplicate row, removed items stayed, and a trailing &lt;code&gt;\&lt;/code&gt; broke the statement (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2605&quot;&gt;&lt;strong&gt;#2605&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Neo4j and FalkorDB:&lt;/strong&gt; an edge with an explicit ID whose endpoints changed. Neo4j kept the old edge beside the new one, and FalkorDB failed with a unique constraint violation (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2611&quot;&gt;&lt;strong&gt;#2611&lt;/strong&gt;&lt;/a&gt;). Dropping a node table, by un-declaring it or with &lt;code&gt;cocoindex drop&lt;/code&gt;, left its vector indexes (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2618&quot;&gt;&lt;strong&gt;#2618&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;A change went undetected&lt;/h4&gt;
&lt;p&gt;The item was not reprocessed.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;S3, Azure Blob, OCI and Google Drive binary files:&lt;/strong&gt; an overwrite that kept the modification time (S3 times are whole seconds). An equal time is now checked against the ETag or MD5 (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2601&quot;&gt;&lt;strong&gt;#2601&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Doris:&lt;/strong&gt; a changed vector or inverted index parameter (&lt;code&gt;index_type&lt;/code&gt;, &lt;code&gt;metric_type&lt;/code&gt;, dimension, parser). It now rebuilds the table (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2605&quot;&gt;&lt;strong&gt;#2605&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Graph targets: node and relationship APIs&lt;/h4&gt;
&lt;p&gt;The Neo4j and FalkorDB fix for a label and a relationship type sharing a name, and for ambiguous derived edge IDs, is a new pair of target APIs with the same parameters as the old ones (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2612&quot;&gt;&lt;strong&gt;#2612&lt;/strong&gt;&lt;/a&gt;):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Before (deprecated; still works with a DeprecationWarning)
entities = await neo4j.mount_table_target(KG_DB, &quot;Entity&quot;, entity_schema, primary_key=&quot;value&quot;)
edges = await neo4j.mount_relation_target(
    KG_DB, &quot;RELATIONSHIP&quot;, entities, entities, rel_schema, primary_key=&quot;id&quot;
)
edges.declare_relation(
    from_id=&quot;CocoIndex&quot;, to_id=&quot;Neo4j&quot;, record=RelationshipRow(id=&quot;rel-1&quot;, predicate=&quot;writes_to&quot;)
)

# After
entities = await neo4j.mount_node_target(KG_DB, &quot;Entity&quot;, entity_schema, primary_key=&quot;value&quot;)
edges = await neo4j.mount_relationship_target(
    KG_DB, &quot;RELATIONSHIP&quot;, entities, entities, rel_schema, primary_key=&quot;id&quot;
)
edges.declare_relationship(
    from_id=&quot;CocoIndex&quot;, to_id=&quot;Neo4j&quot;, record=RelationshipRow(id=&quot;rel-1&quot;, predicate=&quot;writes_to&quot;)
)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On the new APIs, Neo4j labels and relationship types can&apos;t contain &lt;code&gt;__&lt;/code&gt; or end with &lt;code&gt;_&lt;/code&gt;, because constraint and index names join the label to a property name with &lt;code&gt;__&lt;/code&gt;; on both connectors, derived edge IDs need &lt;code&gt;int&lt;/code&gt; or &lt;code&gt;str&lt;/code&gt; endpoint IDs.&lt;/p&gt;
&lt;p&gt;Switching an existing table keeps its nodes, edges, constraints and indexes, but takes two updates:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Add &lt;code&gt;managed_by=&quot;user&quot;&lt;/code&gt; to each deprecated declaration and run an update. Removing those declarations now deletes nothing.&lt;/li&gt;
&lt;li&gt;Replace each call with its replacement, without &lt;code&gt;managed_by=&quot;user&quot;&lt;/code&gt;, and run another update.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Without the first step, removing a deprecated declaration destroys its table, possibly after the new table has written it. The steps are in the &lt;a href=&quot;https://cocoindex.io/docs/connectors/neo4j/&quot;&gt;Neo4j&lt;/a&gt; and &lt;a href=&quot;https://cocoindex.io/docs/connectors/falkordb/&quot;&gt;FalkorDB&lt;/a&gt; docs under &quot;Switching an existing table&quot;.&lt;/p&gt;

Quick check: you replace &lt;code&gt;mount_table_target&lt;/code&gt; with &lt;code&gt;mount_node_target&lt;/code&gt; for an existing Neo4j table and run one update. What happens to the table?
&lt;p&gt;Removing the deprecated declaration destroys its table, possibly after the new target has written it. Run one update with &lt;code&gt;managed_by=&quot;user&quot;&lt;/code&gt; on the deprecated declaration first, then make the switch.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;Memo fingerprints depend only on values (v1.1.0)&lt;/h3&gt;
&lt;p&gt;A memo key or fingerprint used to depend on object identity in two ways. A structure that referenced one object twice fingerprinted differently from one holding two equal copies. And a temporary object freed during fingerprinting could produce a wrong memo hit, rather than a harmless recomputation, once Python reused its ID for another temporary value. Both are fixed by canonicalizing shared values independently and tracking only the active recursion path for cycle detection (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2411&quot;&gt;&lt;strong&gt;#2411&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/hatemadi15&quot;&gt;@hatemadi15&lt;/a&gt;, closing &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/issues/2391&quot;&gt;#2391&lt;/a&gt;). The one-time effect on fingerprints is in the &lt;a href=&quot;#upgrade-notes&quot;&gt;upgrade notes&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Hangs and shutdown (v1.0.26 to v1.1.0)&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;GPU pool.&lt;/strong&gt; A GPU released to a cancelled &lt;code&gt;acquire&lt;/code&gt; goes back to the pool (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2595&quot;&gt;&lt;strong&gt;#2595&lt;/strong&gt;&lt;/a&gt;). Before, every later &lt;code&gt;acquire&lt;/code&gt; of that GPU hung.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cancelled source listings.&lt;/strong&gt; Cancelling a pending read of a synchronous source listing (localfs, Google Drive) no longer hangs &lt;code&gt;asyncio.run()&lt;/code&gt; at shutdown (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2619&quot;&gt;&lt;strong&gt;#2619&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/Sujit-1509&quot;&gt;@Sujit-1509&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Resources released at stop.&lt;/strong&gt; &lt;code&gt;coco.stop()&lt;/code&gt; and &lt;code&gt;coco.stop_blocking()&lt;/code&gt; release the lifespan-provided resources that registered apps held, instead of keeping them until each app&apos;s next update (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2425&quot;&gt;&lt;strong&gt;#2425&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/hatemadi15&quot;&gt;@hatemadi15&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Free-threaded Python 3.14:&lt;/strong&gt; the background event loop no longer starts twice, and an environment can be reopened without &lt;code&gt;close()&lt;/code&gt; after a localfs-reading app (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2490&quot;&gt;&lt;strong&gt;#2490&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2499&quot;&gt;&lt;strong&gt;#2499&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;LiteLLM embedder: media-like text and refused requests (v1.0.26)&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;LiteLLMEmbedder&lt;/code&gt; embeds text starting with &lt;code&gt;data:…;base64,&lt;/code&gt;, &lt;code&gt;gs://&lt;/code&gt; or &lt;code&gt;files/&lt;/code&gt; as text rather than treating it as a file reference. A request litellm refuses to build no longer retries until the 10-minute deadline; the batch is split to isolate the bad text, the same mechanism &lt;a href=&quot;/blogs/changelog-1017-1025/#cocoretrywithsmallerbatch-batch-splitting-on-failure-v1017&quot;&gt;&lt;code&gt;RetryWithSmallerBatch&lt;/code&gt;&lt;/a&gt; introduced last cycle (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2532&quot;&gt;&lt;strong&gt;#2532&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;Other fixes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Graph drop&lt;/strong&gt; (v1.0.26). &lt;code&gt;cocoindex drop&lt;/code&gt; and un-declaring a table delete the Neo4j and FalkorDB nodes and relationships the app wrote, and a primary-key change rebuilds the table instead of leaving old-key nodes behind (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2498&quot;&gt;&lt;strong&gt;#2498&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Transient errors&lt;/strong&gt; (v1.0.26). A Neo4j apply batch retries on transient errors such as &lt;code&gt;DeadlockDetected&lt;/code&gt; instead of failing the component (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2491&quot;&gt;&lt;strong&gt;#2491&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;code_match&lt;/code&gt; prefilters&lt;/strong&gt; (v1.0.26). Regex prefilters no longer drop nested alternatives, which made searches miss matches (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2525&quot;&gt;&lt;strong&gt;#2525&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;C# file-scoped namespaces&lt;/strong&gt; (v1.1.0). A file-scoped namespace (&lt;code&gt;namespace X;&lt;/code&gt;) shows in the &lt;code&gt;render_match&lt;/code&gt; context frames of the declarations after it (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2629&quot;&gt;&lt;strong&gt;#2629&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;VectorSchema(dtype=np.float32)&lt;/code&gt;&lt;/strong&gt; (v1.1.0). A schema whose dtype is the class &lt;code&gt;np.float32&lt;/code&gt; rather than a dtype instance now reloads on the second run. Other classes the state reader can&apos;t load now fail when first written, with a hint to use &lt;code&gt;coco.unpickle_safe&lt;/code&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2536&quot;&gt;&lt;strong&gt;#2536&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/rtmalikian&quot;&gt;@rtmalikian&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Passwords out of &lt;code&gt;repr&lt;/code&gt;&lt;/strong&gt; (v1.1.0). Snowflake and Doris connection configs leave the password out of their &lt;code&gt;repr&lt;/code&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2620&quot;&gt;&lt;strong&gt;#2620&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/jerryqu-coco&quot;&gt;@jerryqu-coco&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OCI Object Storage&lt;/strong&gt; (v1.1.0). Zero-length reads, and partial reads of empty objects, return empty bytes instead of failing with HTTP 416 (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2466&quot;&gt;&lt;strong&gt;#2466&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/pranav440&quot;&gt;@pranav440&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reopening an open &lt;code&gt;db_path&lt;/code&gt;&lt;/strong&gt; (v1.1.0). The &lt;code&gt;RuntimeError&lt;/code&gt; now names the path and &lt;code&gt;Environment.close()&lt;/code&gt;, instead of a misleading message about different options (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2561&quot;&gt;&lt;strong&gt;#2561&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/Siddesh-bype&quot;&gt;@Siddesh-bype&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Internal improvements&lt;/h2&gt;
&lt;h3&gt;Documentation&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Key identity.&lt;/strong&gt; The docs explain that a target state&apos;s identity is its key, and where two keys can reach one object: target states, contexts, &lt;code&gt;mount_each()&lt;/code&gt;, and Postgres, SQLite and BigQuery tables. Mounting one component path twice in one run was already an error; its message now says how to fix it (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2609&quot;&gt;&lt;strong&gt;#2609&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2610&quot;&gt;&lt;strong&gt;#2610&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Examples that failed when run as written.&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;SeparatorSplitter&lt;/code&gt; usage example (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2476&quot;&gt;&lt;strong&gt;#2476&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/March-7&quot;&gt;@March-7&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;The localfs lifespan example, which named a &lt;code&gt;coco.EnvBuilder&lt;/code&gt; that doesn&apos;t exist (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2397&quot;&gt;&lt;strong&gt;#2397&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/Siddesh-bype&quot;&gt;@Siddesh-bype&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;get_context&lt;/code&gt; example, which called the async &lt;code&gt;coco.default_env()&lt;/code&gt; as if it were synchronous, and the App guide&apos;s component path tree (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2416&quot;&gt;&lt;strong&gt;#2416&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/hardness1020&quot;&gt;@hardness1020&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;drop_app&lt;/code&gt; semantics.&lt;/strong&gt; The docs now say why &lt;code&gt;drop_app&lt;/code&gt; clears the sub-database instead of removing it (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2431&quot;&gt;&lt;strong&gt;#2431&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/hardness1020&quot;&gt;@hardness1020&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;HTTP clients.&lt;/strong&gt; The docs standardize on httpx and explain why Doris Stream Load keeps aiohttp (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2626&quot;&gt;&lt;strong&gt;#2626&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Valkey &lt;code&gt;client_info_tag&lt;/code&gt;&lt;/strong&gt; defaults to &lt;code&gt;&quot;cocoindex&quot;&lt;/code&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2480&quot;&gt;&lt;strong&gt;#2480&lt;/strong&gt;&lt;/a&gt;, by &lt;a href=&quot;https://github.com/Jonathan-Improving&quot;&gt;@Jonathan-Improving&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Agent skills&lt;/strong&gt; install with uv rather than pip (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2546&quot;&gt;&lt;strong&gt;#2546&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2552&quot;&gt;&lt;strong&gt;#2552&lt;/strong&gt;&lt;/a&gt;), a release playbook was added (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2627&quot;&gt;&lt;strong&gt;#2627&lt;/strong&gt;&lt;/a&gt;), and the Rust guidelines distilled from review comments are linked from &lt;code&gt;AGENTS.md&lt;/code&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2500&quot;&gt;&lt;strong&gt;#2500&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Security and dependencies&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;litellm 1.107.0&lt;/strong&gt; was published to PyPI with a credential stealer and a backdoor. It is excluded from every &lt;code&gt;litellm&lt;/code&gt; requirement: the &lt;code&gt;litellm&lt;/code&gt;, &lt;code&gt;entity_resolution_llm&lt;/code&gt; and &lt;code&gt;all&lt;/code&gt; extras, and the examples. The locked version, 1.96.2, is unaffected (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2576&quot;&gt;&lt;strong&gt;#2576&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rust dependencies.&lt;/strong&gt; The legacy rustls 0.21 stack is dropped from the S3 client, which cleared the rustls-webpki advisories (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2544&quot;&gt;&lt;strong&gt;#2544&lt;/strong&gt;&lt;/a&gt;); &lt;code&gt;aws-smithy-json&lt;/code&gt; 0.62.7 is taken for GHSA-8ffr-xgwf-xj56, which raises the minimum Rust version to 1.91.1 (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2542&quot;&gt;&lt;strong&gt;#2542&lt;/strong&gt;&lt;/a&gt;); rustls moves to 0.23.46 for GHSA-2mjx-qc3c-rqvc (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2543&quot;&gt;&lt;strong&gt;#2543&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dependabot.&lt;/strong&gt; Security updates are grouped, one PR per ecosystem (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2591&quot;&gt;&lt;strong&gt;#2591&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;CI&lt;/h3&gt;
&lt;p&gt;The main change is that each landed commit now gets exactly one full run: a merge queue with tiered checks, a gate job that the required status checks point at, a skip for drafts, and support for stacked PRs (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2584&quot;&gt;&lt;strong&gt;#2584&lt;/strong&gt;&lt;/a&gt;). Around it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Job setup is shared through a composite action (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2578&quot;&gt;&lt;strong&gt;#2578&lt;/strong&gt;&lt;/a&gt;), sccache objects stay on local disk and are saved once per leg (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2583&quot;&gt;&lt;strong&gt;#2583&lt;/strong&gt;&lt;/a&gt;), and jobs free only the disk space they need (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2579&quot;&gt;&lt;strong&gt;#2579&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;The Rust SDK checks run only for SDK changes, plus daily (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2622&quot;&gt;&lt;strong&gt;#2622&lt;/strong&gt;&lt;/a&gt;); CodeQL scans &lt;code&gt;main&lt;/code&gt; daily instead of every pull request (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2596&quot;&gt;&lt;strong&gt;#2596&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Testcontainers images are pre-pulled before the first test, with a stall timeout and retries (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2551&quot;&gt;&lt;strong&gt;#2551&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2556&quot;&gt;&lt;strong&gt;#2556&lt;/strong&gt;&lt;/a&gt;); &lt;code&gt;ruff check&lt;/code&gt; and clippy are gated in pre-commit (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2540&quot;&gt;&lt;strong&gt;#2540&lt;/strong&gt;&lt;/a&gt;); root-relative &lt;code&gt;/docs/&lt;/code&gt; links are checked against the build output (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2557&quot;&gt;&lt;strong&gt;#2557&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2559&quot;&gt;&lt;strong&gt;#2559&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;What to try next&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Preview an update before you run it.&lt;/strong&gt; Run &lt;code&gt;cocoindex update --preview path/to/app.py&lt;/code&gt;, or &lt;code&gt;app.update(preview=True)&lt;/code&gt;, as in &lt;a href=&quot;#preview-runs-on-real-pipelines-and-writes-nothing-v1026&quot;&gt;the preview example&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Record a dependency per call.&lt;/strong&gt; If a function&apos;s result depends on a parser or model that differs by input, declare one &lt;code&gt;coco.LogicDep&lt;/code&gt; per version at module import and call &lt;code&gt;coco.use_logic_dep()&lt;/code&gt; in the call, as in &lt;a href=&quot;#cocologicdep-and-cocouse_logic_dep-a-dependency-decided-per-call-v110&quot;&gt;the parser example&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bound a batched function.&lt;/strong&gt; Add &lt;code&gt;max_in_flight=&lt;/code&gt; to cap concurrent batches, and &lt;code&gt;rate_limiter=&lt;/code&gt; when each batch is one request against a quota.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;On Neo4j or FalkorDB, plan the API switch.&lt;/strong&gt; Follow the two updates in &lt;a href=&quot;#graph-targets-node-and-relationship-apis&quot;&gt;node and relationship APIs&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Before you upgrade,&lt;/strong&gt; check the &lt;a href=&quot;#upgrade-notes&quot;&gt;upgrade notes&lt;/a&gt; for the object-store &lt;code&gt;prefix&lt;/code&gt; change and the one-time reprocessing.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the complete list of changes, see the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/releases&quot;&gt;GitHub releases&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Thanks to the community&lt;/h2&gt;
&lt;p&gt;Thanks to everyone who contributed this cycle, including 9 first-time contributors.&lt;/p&gt;
&lt;h3&gt;@Sujit-1509&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/Sujit-1509&quot;&gt;@Sujit-1509&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2485&quot;&gt;keying Google Drive items by file ID&lt;/a&gt;, the fix that prompted the key audit across every Python connector, and for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2619&quot;&gt;keeping a cancelled source listing from hanging shutdown&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@hatemadi15&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/hatemadi15&quot;&gt;@hatemadi15&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2411&quot;&gt;making memo fingerprints depend only on values&lt;/a&gt;, which also closed a wrong-memo-hit bug from reused object IDs, and for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2425&quot;&gt;releasing retained app resources at &lt;code&gt;coco.stop()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@hardness1020&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/hardness1020&quot;&gt;@hardness1020&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2416&quot;&gt;fixing three places where the docs and the code disagreed&lt;/a&gt; and for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2431&quot;&gt;correcting the explanation of what &lt;code&gt;drop_app&lt;/code&gt; does to the sub-database&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@Siddesh-bype&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/Siddesh-bype&quot;&gt;@Siddesh-bype&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2397&quot;&gt;replacing the nonexistent &lt;code&gt;coco.EnvBuilder&lt;/code&gt; with &lt;code&gt;coco.EnvironmentBuilder&lt;/code&gt; in the localfs guide&lt;/a&gt; and for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2561&quot;&gt;making the error on reopening an open &lt;code&gt;db_path&lt;/code&gt; actionable&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@mulatta&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/mulatta&quot;&gt;@mulatta&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2434&quot;&gt;adding Nix syntax support&lt;/a&gt; to code splitting and structural code patterns.&lt;/p&gt;
&lt;h3&gt;@rtmalikian&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/rtmalikian&quot;&gt;@rtmalikian&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2536&quot;&gt;failing fast at write time for classes the state reader rejects&lt;/a&gt;, so the error arrives on the run that caused it rather than the next one.&lt;/p&gt;
&lt;h3&gt;@pranav440&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/pranav440&quot;&gt;@pranav440&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2466&quot;&gt;handling zero-length and empty-object range reads in OCI Object Storage&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@jerryqu-coco&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/jerryqu-coco&quot;&gt;@jerryqu-coco&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2620&quot;&gt;leaving Snowflake and Doris passwords out of config &lt;code&gt;repr&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@March-7&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/March-7&quot;&gt;@March-7&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2476&quot;&gt;fixing the &lt;code&gt;SeparatorSplitter&lt;/code&gt; usage example&lt;/a&gt; so it runs as written.&lt;/p&gt;
&lt;h3&gt;@Jonathan-Improving&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/Jonathan-Improving&quot;&gt;@Jonathan-Improving&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2480&quot;&gt;documenting the Valkey &lt;code&gt;client_info_tag&lt;/code&gt; default&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@Avicennasis&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/Avicennasis&quot;&gt;@Avicennasis&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2593&quot;&gt;fixing a typo in the conversation_to_knowledge extraction prompt&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>changelog</category><category>feature</category><category>announcement</category><author>George He</author></item><item><title>Timeouts, batch retries, and target inspection in CocoIndex</title><link>https://cocoindex.io/blogs/changelog-1017-1025/</link><guid isPermaLink="true">https://cocoindex.io/blogs/changelog-1017-1025/</guid><description>CocoIndex 1.0.17–1.0.25 adds timeouts, batch retries, target inspection, faster target updates, and a Linux hang fix.</description><pubDate>Wed, 07 Oct 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This is the third changelog since the v1.0 launch, covering 9 releases (1.0.17–1.0.25). The new APIs include &lt;code&gt;coco.timeout()&lt;/code&gt; for cooperative deadlines, &lt;code&gt;coco.RetryWithSmallerBatch&lt;/code&gt; for splitting a failed batch, and target-state inspection in &lt;code&gt;cocoindex show&lt;/code&gt;. A much cheaper commit path for large target updates follows, then fixes, led by one for a permanent hang on Linux, then examples and internal improvements.&lt;/p&gt;
&lt;p&gt;CocoIndex builds fresh, structured context for AI from sources such as PDFs, codebases, emails, screenshots, and meeting notes, and keeps it up to date with an &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;incremental engine&lt;/a&gt;. The source is on &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If that context feeds an agent, the agent answers from whatever the last update committed. The demo below runs one update over 9 files on 1.0.25, with a 30-second &lt;code&gt;coco.timeout()&lt;/code&gt; per file and &lt;code&gt;LiteLLMEmbedder&lt;/code&gt;, which splits a failed batch for you. Switch to 1.0.16 to compare. One file is slow, and one holds a chunk the embedding provider rejects.&lt;/p&gt;
&lt;p&gt;:::tip[Start here]&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;You write pipelines:&lt;/strong&gt; read &lt;a href=&quot;#cocotimeout-cooperative-deadlines-v1017&quot;&gt;timeouts&lt;/a&gt;, &lt;a href=&quot;#cocoretrywithsmallerbatch-batch-splitting-on-failure-v1017&quot;&gt;batch retries&lt;/a&gt; and &lt;a href=&quot;#cocoindex-show-target-state-inspection-v1017-to-v1018&quot;&gt;&lt;code&gt;cocoindex show&lt;/code&gt;&lt;/a&gt; first.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You build connectors:&lt;/strong&gt; read &lt;a href=&quot;#for-connector-authors-v1021-to-v1025&quot;&gt;for connector authors&lt;/a&gt; and &lt;a href=&quot;#performance&quot;&gt;performance&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You run deployments:&lt;/strong&gt; read the &lt;a href=&quot;#upgrade-notes&quot;&gt;upgrade notes&lt;/a&gt; and &lt;a href=&quot;#long-updates-no-longer-hang-on-linux-v1024&quot;&gt;the Linux hang fix&lt;/a&gt;.
:::&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Why this release cycle matters&lt;/h2&gt;
&lt;p&gt;The rest of the cycle, in brief:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;More new APIs.&lt;/strong&gt; &lt;a href=&quot;#litellm-request-timeouts-concurrency-caps-and-transcription-retries-v1022&quot;&gt;LiteLLM&lt;/a&gt; request timeouts and concurrency caps, &lt;a href=&quot;#gpu-pool-whole-gpu-reservations-and-arrival-order-queueing-v1025&quot;&gt;whole-GPU reservations&lt;/a&gt;, &lt;a href=&quot;#smaller-additions-v1018-to-v1025&quot;&gt;&lt;code&gt;Environment.close()&lt;/code&gt; and &lt;code&gt;recollect_after_run&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;#for-connector-authors-v1021-to-v1025&quot;&gt;child slots&lt;/a&gt; for connector authors, and &lt;a href=&quot;#rust-sdk-declarative-batching-context-keys-and-row-type-schemas-v1025&quot;&gt;declarative batching and schemas&lt;/a&gt; in the Rust SDK.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cheaper large target updates.&lt;/strong&gt; &lt;a href=&quot;#large-target-updates-less-memory-fewer-reconciles-v1025&quot;&gt;Rows held encoded&lt;/a&gt;, native fingerprints, skipped &lt;code&gt;reconcile()&lt;/code&gt; for unchanged rows, and faster Postgres statements. Engine memory per declared Postgres row drops by two thirds.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fixes.&lt;/strong&gt; Long updates &lt;a href=&quot;#long-updates-no-longer-hang-on-linux-v1024&quot;&gt;no longer hang on Linux&lt;/a&gt;, a failure in a merged sink batch or write transaction &lt;a href=&quot;#failures-stay-with-the-component-that-caused-them-v1023-v1025&quot;&gt;stays with the component that caused it&lt;/a&gt;, and memoized components &lt;a href=&quot;#memoization-under-concurrency-and-redefinition-v1023-to-v1024&quot;&gt;run once&lt;/a&gt; under overlapping updates.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Upgrade notes&lt;/h2&gt;
&lt;p&gt;Check these before upgrading. Each item names the release it applies from:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Linux, before 1.0.24.&lt;/strong&gt; A long update could hang permanently on the writer lock of LMDB, the embedded database that holds CocoIndex&apos;s internal state, under sustained load. Upgrade to 1.0.24 or later; see &lt;a href=&quot;#long-updates-no-longer-hang-on-linux-v1024&quot;&gt;the fix&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LiteLLM &lt;code&gt;timeout&lt;/code&gt;&lt;/strong&gt; now bounds the whole request (v1.0.22). &lt;code&gt;LiteLLMEmbedder(timeout=30)&lt;/code&gt; used to forward a per-attempt value to litellm and retry for up to 10 minutes; it now means 30 seconds end to end, not retried. &lt;code&gt;LiteLLMTranscriber(timeout=...)&lt;/code&gt; means the same, and a per-call &lt;code&gt;timeout&lt;/code&gt; to &lt;code&gt;transcribe()&lt;/code&gt; raises &lt;code&gt;TypeError&lt;/code&gt;. Callers who passed &lt;code&gt;timeout&lt;/code&gt; before re-embed once, because it has left the memo key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Exception handlers&lt;/strong&gt; receive the original typed exception (v1.0.23), not a &lt;code&gt;RuntimeError&lt;/code&gt; wrapping a formatted string. The traceback is no longer inside &lt;code&gt;str(exc)&lt;/code&gt;; use &lt;code&gt;traceback.format_exception(exc)&lt;/code&gt; or &lt;code&gt;logging(..., exc_info=exc)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Composite-key deletes&lt;/strong&gt; on user-managed Postgres tables cast to the declared key types (v1.0.25). A &lt;code&gt;managed_by=&quot;user&quot;&lt;/code&gt; table whose key column is declared &lt;code&gt;text&lt;/code&gt; but is really &lt;code&gt;uuid&lt;/code&gt; or an enum now fails on multi-column-key deletes. Declare the real type.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Target action sinks&lt;/strong&gt; (v1.0.23). Returning a &lt;code&gt;ChildTargetDef&lt;/code&gt; list from a sink callback still works with a &lt;code&gt;DeprecationWarning&lt;/code&gt;; use &lt;code&gt;from_fn_with_children&lt;/code&gt;. Equal sink callbacks must also share a type and be weak-referenceable, so a &lt;code&gt;NamedTuple&lt;/code&gt; callback now raises &lt;code&gt;TypeError&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Valkey&lt;/strong&gt; needs &lt;code&gt;valkey-glide&lt;/code&gt; 2.5.2 or later (v1.0.25).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Batching decorator&lt;/strong&gt; (v1.0.26, after this span). &lt;code&gt;@coco.fn(batching=True)&lt;/code&gt;, &lt;code&gt;max_batch_size=&lt;/code&gt; and &lt;code&gt;runner=&lt;/code&gt; on &lt;code&gt;@coco.fn&lt;/code&gt; now raise &lt;code&gt;ValueError&lt;/code&gt;; use &lt;code&gt;@coco.fn.as_async(batching=True)&lt;/code&gt;. The examples in this post use the current form (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2493&quot;&gt;&lt;strong&gt;#2493&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;New APIs and capabilities&lt;/h2&gt;
&lt;h3&gt;&lt;code&gt;coco.timeout()&lt;/code&gt;: cooperative deadlines (v1.0.17)&lt;/h3&gt;
&lt;p&gt;One slow input can hold up a whole update: a file whose parse or LLM call never comes back keeps the run going long after every other file is done. &lt;code&gt;coco.timeout()&lt;/code&gt; gives a unit of work a time budget.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;coco.timeout()&lt;/code&gt; takes a &lt;code&gt;timedelta&lt;/code&gt; and sets an absolute deadline for everything inside the &lt;code&gt;with&lt;/code&gt; block (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2251&quot;&gt;&lt;strong&gt;#2251&lt;/strong&gt;&lt;/a&gt;, addressing &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/issues/2054&quot;&gt;&lt;strong&gt;#2054&lt;/strong&gt;&lt;/a&gt;). You set the budget once, typically in the component that owns a piece of work, and the whole call tree beneath it inherits it: &lt;code&gt;@coco.fn&lt;/code&gt; calls, the item tasks &lt;code&gt;coco.map()&lt;/code&gt; fans out to, and &lt;code&gt;coco.use_mount()&lt;/code&gt; children with subtrees of their own, with no timeout parameter threaded through any of them.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from datetime import timedelta

import cocoindex as coco
from cocoindex.connectors import postgres
from cocoindex.resources.file import FileLike

@coco.fn.as_async(batching=True)
async def embed(texts: list[str]) -&amp;gt; list[list[float]]:
    ...  # batched: each call inherits its caller&apos;s deadline; the shared batch body does not

@coco.fn
async def summarize(section: str) -&amp;gt; str:
    ...  # inherits the caller&apos;s deadline; nothing configured here

@coco.fn
async def parse(file: FileLike) -&amp;gt; ParsedDoc:
    ...  # inherits it too, through use_mount()

@coco.fn(memo=True)
async def process_file(file: FileLike, target: postgres.TableTarget[DocRow]) -&amp;gt; None:
    # 30-second budget for this file; every call below checks it.
    with coco.timeout(timedelta(seconds=30)):
        parsed = await coco.use_mount(coco.component_subpath(&quot;parse&quot;), parse, file)
        summaries = await coco.map(summarize, parsed.sections)
        summary = &quot;\n&quot;.join(summaries)
        vector = await embed(summary)
    target.declare_row(row=DocRow(name=out_name(file), summary=summary, embedding=vector))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; A file whose work runs past 30 seconds fails with &lt;code&gt;coco.DeadlineExceededError&lt;/code&gt; at its next checkpoint. Its rows are not written and nothing is cached for it, so the next update retries that file. The other files finish and commit as usual.&lt;/p&gt;
&lt;p&gt;A per-item budget like this stays meaningful as the source grows, where a whole-run limit does not, and it applies however the app runs, including through the &lt;code&gt;cocoindex update&lt;/code&gt; CLI. The budget is cooperative rather than preemptive: CocoIndex checks the deadline at its own checkpoints (when a &lt;code&gt;@coco.fn&lt;/code&gt; call starts or returns, in &lt;code&gt;coco.use_mount()&lt;/code&gt;, and in &lt;code&gt;coco.check_cancellation()&lt;/code&gt;) and raises &lt;code&gt;coco.DeadlineExceededError&lt;/code&gt;, a subclass of the built-in &lt;code&gt;TimeoutError&lt;/code&gt;, once it has passed. An &lt;code&gt;await&lt;/code&gt; of your own, such as an HTTP request or a database query, is generally not interrupted (the built-in retry helpers are the exception and cancel an in-flight attempt at the deadline), so keep the client library&apos;s own timeout on individual I/O calls; &lt;code&gt;coco.timeout()&lt;/code&gt; bounds the CocoIndex work between checkpoints.&lt;/p&gt;
&lt;p&gt;Pick a budget below to see where the deadline passes and where it is raised:&lt;/p&gt;
&lt;h4&gt;Which work gets the deadline&lt;/h4&gt;
&lt;p&gt;The deadline follows the work the caller waits for. Hover over, tap or focus a call in the tree to see why:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Work inside &lt;code&gt;coco.timeout()&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;Gets the deadline?&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;@coco.fn&lt;/code&gt; calls, at any depth&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;The caller waits for them.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;coco.map()&lt;/code&gt; item tasks&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Each item checks at its next checkpoint; finished items are not cancelled.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;coco.use_mount()&lt;/code&gt; children&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;The caller waits for them, so a child is never left half done.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nested &lt;code&gt;coco.timeout()&lt;/code&gt; scopes&lt;/td&gt;
&lt;td&gt;Yes, the shorter one&lt;/td&gt;
&lt;td&gt;The outer budget comes back on exit.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;coco.mount()&lt;/code&gt; and &lt;code&gt;coco.mount_each()&lt;/code&gt; children, live components&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;They run in the background. Set the timeout inside the child&apos;s processor.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Batched function bodies&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;One call serves callers with different budgets; each call still checks its own clock.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Target writes (submit and sinks)&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Writes finish once processing has succeeded.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

The full rules
&lt;p&gt;&lt;strong&gt;Inherits the deadline&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;@coco.fn&lt;/code&gt; calls&lt;/strong&gt;, at every depth of the tree.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;coco.map()&lt;/code&gt; item tasks&lt;/strong&gt;, so a fan-out to a thousand items is a thousand tasks under one budget. Items are not cancelled mid-flight; each observes the deadline at its next checkpoint.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;coco.use_mount()&lt;/code&gt; children&lt;/strong&gt;, because the caller awaits them. The child runs under the same deadline and raises at its own checkpoints; the parent sees &lt;code&gt;DeadlineExceededError&lt;/code&gt; only after the child has completed or failed, so there is never a half-done child.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nested &lt;code&gt;coco.timeout()&lt;/code&gt; scopes&lt;/strong&gt; take the shorter remaining budget and restore the outer one on exit.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Runs without it&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;coco.mount()&lt;/code&gt; and &lt;code&gt;coco.mount_each()&lt;/code&gt; children, and &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/live_component/&quot;&gt;live components&lt;/a&gt;.&lt;/strong&gt; These run in the background and the caller never waits for them, so the caller&apos;s clock must not rush them; the parent&apos;s timeout bounds only the parent&apos;s own wait on the handle &lt;code&gt;mount()&lt;/code&gt; returns. To time-box each mounted child, set the timeout inside the child&apos;s processor, as &lt;code&gt;process_file&lt;/code&gt; does above, rather than around &lt;code&gt;mount_each()&lt;/code&gt; in the parent.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Batched function bodies.&lt;/strong&gt; One call serves many callers with different budgets, so the body runs without any of them; the calls into it still check their own clocks.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Target writes (submit and sinks).&lt;/strong&gt; Once processing has succeeded, target synchronization is allowed to finish rather than being torn in half. A timeout ends only the component&apos;s own work.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Guarantees&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No partial writes.&lt;/strong&gt; A processor run that times out applies no target writes and caches no results (memoizes nothing); the next update retries it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Completed work stays completed.&lt;/strong&gt; Committed components and in-progress target synchronization are never rolled back, and &lt;code&gt;coco.map()&lt;/code&gt; items that already finished are not cancelled.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Long loops need a checkpoint.&lt;/strong&gt; A loop inside a processor should call &lt;code&gt;coco.check_cancellation()&lt;/code&gt; so it stops near the deadline rather than at the function&apos;s return.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That also makes a whole-update budget useful for callers that are themselves time-boxed, such as a CI job or a shared cron window: &lt;code&gt;with coco.timeout(timedelta(minutes=10)): app.update_blocking()&lt;/code&gt; indexes as much as it can in 10 minutes and then raises &lt;code&gt;DeadlineExceededError&lt;/code&gt;; everything that finished stays committed, and the next update resumes where this one left off.&lt;/p&gt;

Quick check: &lt;code&gt;process_file&lt;/code&gt; runs under a 30-second &lt;code&gt;coco.timeout()&lt;/code&gt; and calls &lt;code&gt;coco.mount_each()&lt;/code&gt; for its sub-items. Do the sub-items get the 30 seconds?
&lt;p&gt;No. Mounted children run in the background, so the parent&apos;s clock does not rush them; the parent&apos;s timeout bounds only its own wait. To time-box each sub-item, put &lt;code&gt;coco.timeout()&lt;/code&gt; inside the sub-item&apos;s processor.&lt;/p&gt;

&lt;h4&gt;Retries&lt;/h4&gt;
&lt;p&gt;Retry loops used to stop after a fixed number of attempts, an ad-hoc cap that does not correspond to time. The built-in retry logic now treats its own time limit as a nested &lt;code&gt;coco.timeout()&lt;/code&gt; scope, so it merges with any ambient deadline and the shorter wins; no attempt starts past the limit and backoff sleeps never exceed the remaining time. Without an ambient deadline a helper&apos;s own limit still applies: &lt;code&gt;LlmPairResolver&lt;/code&gt;, the LLM-based entity resolver, keeps its attempt cap. The LiteLLM embedder and transcriber expose that limit as a &lt;code&gt;timeout&lt;/code&gt; parameter; see &lt;a href=&quot;#litellm-request-timeouts-concurrency-caps-and-transcription-retries-v1022&quot;&gt;LiteLLM&lt;/a&gt; below.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;coco.RetryWithSmallerBatch&lt;/code&gt;: batch splitting on failure (v1.0.17)&lt;/h3&gt;
&lt;p&gt;Some batch failures depend on the batch&apos;s composition rather than on any single input: a provider&apos;s per-request token or payload cap, one input the provider rejects, a GPU running out of memory. No fixed &lt;code&gt;max_batch_size&lt;/code&gt; rules these out, because the threshold depends on the content. A batched function body can raise &lt;code&gt;coco.RetryWithSmallerBatch&lt;/code&gt; to have the engine halve the batch and retry the halves, recursing down to single items (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2270&quot;&gt;&lt;strong&gt;#2270&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn.as_async(batching=True, max_batch_size=64)
async def embed(texts: list[str]) -&amp;gt; list[list[float]]:
    try:
        return await provider.embed(texts)
    except ProviderError as e:
        if is_transient(e) or is_auth_error(e) or is_timeout(e):
            raise  # global, transient and not yet retried, or a timeout: splitting can&apos;t help
        raise coco.RetryWithSmallerBatch() from e
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; With one bad input in a batch of 8, the engine tries all 8, then the two halves of 4, then halves of 2, then single items: 7 calls in total. The 7 good inputs get their results, and only the bad one fails, with its original error.&lt;/p&gt;
&lt;p&gt;Whether to raise &lt;code&gt;RetryWithSmallerBatch&lt;/code&gt; depends on why the batch failed. Pick a cause below to see the branch the body takes and what each caller gets:&lt;/p&gt;
&lt;p&gt;What that gives you:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No size check needed.&lt;/strong&gt; At size 1 the engine unwraps the signal and raises the original error as that item&apos;s own failure, so &lt;code&gt;raise coco.RetryWithSmallerBatch() from e&lt;/code&gt; is correct at every batch size. An error that would fail at any size therefore bottoms out at single items and reaches every caller, at the cost of up to about twice the batch size in extra attempts.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Errors land per item.&lt;/strong&gt; A failed sub-batch fails only the callers whose inputs were in it. One poison input no longer takes the other 63 down with it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Works across subprocess runners.&lt;/strong&gt; The signal and its cause survive the trip through a subprocess boundary.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Re-raise, rather than wrap, errors where splitting cannot help: global ones such as bad credentials or a missing model, transient ones such as rate limits and network blips that have not yet been retried at the same size, and timeouts, since every sub-batch would start a fresh full budget against a backend that is already too slow.&lt;/p&gt;
&lt;p&gt;Two built-in embedders do this for you. &lt;code&gt;LiteLLMEmbedder&lt;/code&gt; raises it for errors that are neither transient, global, nor a timeout, such as a per-batch token cap: voyage-code-3 rejects batches over 120k tokens with &lt;code&gt;TOO_MANY_TOKENS_IN_BATCH&lt;/code&gt;, which 64 long chunks can exceed. &lt;code&gt;SentenceTransformerEmbedder&lt;/code&gt; raises it on OOM and frees the accelerator cache before retrying.&lt;/p&gt;
&lt;p&gt;The engine now confines failures the same way on its own, with no code, in merged target-sink batches and write transactions; see &lt;a href=&quot;#failures-stay-with-the-component-that-caused-them-v1023-v1025&quot;&gt;the fixes&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;cocoindex show&lt;/code&gt;: target-state inspection (v1.0.17 to v1.0.18)&lt;/h3&gt;
&lt;p&gt;After an update you may need to know which component wrote a given row, or whether an interrupted run left anything behind. &lt;code&gt;cocoindex show&lt;/code&gt; now tells you both from the CLI.&lt;/p&gt;
&lt;p&gt;A &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;target state&lt;/a&gt; is what a component declares should exist in an external system: a file in a directory, a row in a table, or an embedding in a vector store. CocoIndex records every declared target state under a stable path together with the component that owns it, and reconciles the declarations from run to run to apply only the necessary creates, updates, and deletes. That record is the ground truth for what CocoIndex has written where, and this cycle makes it readable from the CLI.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Readable paths in the long listing.&lt;/strong&gt; &lt;code&gt;cocoindex show &amp;lt;app&amp;gt; -l&lt;/code&gt; lists each component with the target states it owns. Paths now render as the target&apos;s name and key instead of raw fingerprints (output trimmed):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ cocoindex show main -l
Stable paths:
  ...
  /@process_file/&quot;bizarre_animals.md&quot;
    type:component version:1 processor:process_file
    has_memoization:true target_state_count:1
    Target states:
      - path:/@cocoindex/localfs/[null,&quot;output_html/data__bizarre_animals.md.html&quot;]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;The inverted view.&lt;/strong&gt; &lt;code&gt;--target-states&lt;/code&gt; starts from the target side instead: every tracked target state, with the component that owns it. This answers &quot;what does CocoIndex believe exists in this target, and which component put it there?&quot;, and it is the only view that can surface an entry its owner no longer tracks, for example after an interrupted run; the listing marks those &lt;code&gt;[dangling]&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ cocoindex show main --target-states
Target states:
  /@cocoindex/localfs/[null,&quot;output_html/data__bizarre_animals.md.html&quot;]
    owner:/@process_file/&quot;bizarre_animals.md&quot;
  /@cocoindex/localfs/[null,&quot;output_html/data__chuck_norris.md.html&quot;]
    owner:/@process_file/&quot;chuck_norris.md&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Flags that compose.&lt;/strong&gt; &lt;code&gt;--tree&lt;/code&gt; nests entries under their parent containers, so a table&apos;s rows sit beneath the table. &lt;code&gt;--fingerprints&lt;/code&gt; shows the stored fingerprints instead of readable keys, for correlating with logs or the raw store.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Without loading the app.&lt;/strong&gt; Pass &lt;code&gt;--db &amp;lt;path&amp;gt; --app-name &amp;lt;name&amp;gt;&lt;/code&gt; (the name from your &lt;code&gt;coco.AppConfig&lt;/code&gt;) instead of an app target to read a database directly, from any process, without importing the app module or installing its dependencies. This is how you look at a database copied out of a deployment:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ cocoindex show --db ./cocoindex.db --app-name FilesTransform --target-states --tree
Target states:
- @cocoindex/localfs
  - [null,&quot;output_html/data__bizarre_animals.md.html&quot;] owner:/@process_file/&quot;bizarre_animals.md&quot;
  - [null,&quot;output_html/data__chuck_norris.md.html&quot;] owner:/@process_file/&quot;chuck_norris.md&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Try the views and flags on a small app below. Turn on &quot;after an interrupted run&quot; to see where an entry its owner no longer tracks shows up:&lt;/p&gt;
&lt;p&gt;When to reach for it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;After an update, to confirm what was written and by which component.&lt;/li&gt;
&lt;li&gt;To find &lt;code&gt;[dangling]&lt;/code&gt; entries after an interrupted run.&lt;/li&gt;
&lt;li&gt;To inspect a database on a machine that does not have the app&apos;s dependencies.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Under the hood, this took five changes from &lt;a href=&quot;https://github.com/junzh0u&quot;&gt;@junzh0u&lt;/a&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2299&quot;&gt;&lt;strong&gt;#2299&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2301&quot;&gt;&lt;strong&gt;#2301&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2303&quot;&gt;&lt;strong&gt;#2303&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2306&quot;&gt;&lt;strong&gt;#2306&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2307&quot;&gt;&lt;strong&gt;#2307&lt;/strong&gt;&lt;/a&gt;), including a fix without which &lt;code&gt;--db&lt;/code&gt; inspection failed across processes, and a detail view about 2× faster at 10,000 target states.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;LiteLLM: request timeouts, concurrency caps, and transcription retries (v1.0.22)&lt;/h3&gt;
&lt;p&gt;Three changes affect how the LiteLLM embedder and transcriber talk to a provider. Both now share one retry and timeout implementation.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from datetime import timedelta

from cocoindex.ops.litellm import LiteLLMEmbedder

embedder = LiteLLMEmbedder(
    &quot;openai/bge-m3&quot;,
    api_base=&quot;http://localhost:7997&quot;,
    timeout=timedelta(minutes=30),  # one request end to end, retries included
    max_inflight_requests=8,  # open requests against this backend
)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;One clock per request.&lt;/strong&gt; &lt;code&gt;LiteLLMEmbedder(timeout=...)&lt;/code&gt; and &lt;code&gt;LiteLLMTranscriber(timeout=...)&lt;/code&gt; take a &lt;code&gt;timedelta&lt;/code&gt; or a number of seconds and bound one request end to end, defaulting to 10 minutes (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2394&quot;&gt;&lt;strong&gt;#2394&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2395&quot;&gt;&lt;strong&gt;#2395&lt;/strong&gt;&lt;/a&gt;). Within that bound, fast failures such as a 429, a 5xx, or a reset connection are retried with backoff. A timeout is terminal: neither retried nor split into smaller batches. A timeout has already spent its duration, so retrying it only re-spends what is left, and splitting is worse, because every sub-batch would start a fresh full budget against a backend that is already too slow. Before this change, one slow self-hosted endpoint could turn a batch of 64 into a 64 → 32 → … → 1 split tree with a fresh 10 minutes at every node. An HTTP 408 response stays retryable, since it arrives fast and spends nothing. See the upgrade notes if you already pass &lt;code&gt;timeout&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Bounded concurrent requests.&lt;/strong&gt; &lt;code&gt;LiteLLMEmbedder(max_inflight_requests=N)&lt;/code&gt; caps how many requests one embedder keeps open against its backend (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2392&quot;&gt;&lt;strong&gt;#2392&lt;/strong&gt;&lt;/a&gt;, v1.0.22). Batching bounds how many texts ride in one request, never how many requests are open: 2,334 chunks from one file at &lt;code&gt;max_batch_size=64&lt;/code&gt; formed 38 batches, 37 of them concurrent, and a batch that splits fans out further. The permit covers one backend request only, so it is not held during a backoff sleep or across a split; the default is no cap, and the cap is per instance. See &lt;a href=&quot;https://cocoindex.io/docs/ops/litellm/#limiting-concurrent-requests&quot;&gt;limiting concurrent requests&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Transcription retries.&lt;/strong&gt; Transcription requests are retried under the same contract; they were not retried at all before. Each attempt rebuilds the audio buffer, because litellm reads it to the end and a replayed buffer would transcribe silence.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;GPU pool: whole-GPU reservations and arrival-order queueing (v1.0.25)&lt;/h3&gt;
&lt;p&gt;Since v1.0.15, a function run with &lt;code&gt;runner=coco.GPU&lt;/code&gt; takes a whole GPU from a pool for the duration of the call, and &lt;code&gt;coco.GPU(0.5)&lt;/code&gt; takes half of one, so two such calls share a card while a third waits. The pool size comes from &lt;code&gt;COCOINDEX_NUM_GPUS&lt;/code&gt;, then &lt;code&gt;CUDA_VISIBLE_DEVICES&lt;/code&gt;, then &lt;code&gt;nvidia-smi&lt;/code&gt;, and defaults to one; &lt;code&gt;coco.configure_gpu_pool(n)&lt;/code&gt; overrides it. Inside the function, &lt;code&gt;coco.current_gpu()&lt;/code&gt; and &lt;code&gt;coco.current_gpu_fraction()&lt;/code&gt; report what was assigned. See the &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#runner&quot;&gt;runner&lt;/a&gt; section of the function guide.&lt;/p&gt;
&lt;p&gt;v1.0.25 rewrites the pool behind that runner in Rust and exposes it as &lt;code&gt;coco.GPUPool&lt;/code&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2277&quot;&gt;&lt;strong&gt;#2277&lt;/strong&gt;&lt;/a&gt;, closing &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/issues/2243&quot;&gt;&lt;strong&gt;#2243&lt;/strong&gt;&lt;/a&gt; and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/issues/2433&quot;&gt;&lt;strong&gt;#2433&lt;/strong&gt;&lt;/a&gt;). Two capabilities are new:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Requests are served in arrival order.&lt;/strong&gt; A request that arrives while others are queued cannot take the capacity those are waiting for, so a whole-GPU request is not starved by a stream of fractional ones. Releasing capacity serves the queue from the front.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Whole-GPU reservations.&lt;/strong&gt; &lt;code&gt;acquire_full(n)&lt;/code&gt; returns the ids of &lt;code&gt;n&lt;/code&gt; GPUs that are completely free. It holds the ones it has as the rest free up and returns only when all &lt;code&gt;n&lt;/code&gt; are held, so a caller never ends up with a partial set; asking for more GPUs than the pool has is an error. The &lt;code&gt;coco.GPU&lt;/code&gt; runner still requests a fraction of one GPU per call, so this is the building block for functions that need several cards at once, such as a model sharded across GPUs, rather than a new runner form.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The rewrite also fixes waiters that were never woken when capacity was released from another event loop. The Python pool rebound one &lt;code&gt;asyncio.Condition&lt;/code&gt; to whichever event loop touched it last; the Rust pool signals each waiter through its own channel. It was reported from a cocoindex-code deployment on 1.0.22, with a reproduction that needs no GPU; see the &lt;a href=&quot;#other-fixes&quot;&gt;other fixes&lt;/a&gt; table. Two limits are unchanged: subprocess mode (&lt;code&gt;COCOINDEX_RUN_GPU_IN_SUBPROCESS=1&lt;/code&gt;) does not yet support more than one GPU (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/issues/2382&quot;&gt;&lt;strong&gt;#2382&lt;/strong&gt;&lt;/a&gt;), and a function with both &lt;code&gt;batching=True&lt;/code&gt; and the GPU runner still serializes its batches through one queue.&lt;/p&gt;
&lt;h3&gt;Smaller additions (v1.0.18 to v1.0.25)&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;Environment.close()&lt;/code&gt;&lt;/strong&gt; releases the LMDB environment explicitly, so the same database path can be reopened without waiting for every Python reference to be collected (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2481&quot;&gt;&lt;strong&gt;#2481&lt;/strong&gt;&lt;/a&gt;, v1.0.25). On free-threaded Python 3.14 a thread started inside a component inherited the component&apos;s context for life, which kept the environment open and made reopening fail with &lt;code&gt;EnvAlreadyOpened&lt;/code&gt;. &lt;code&gt;LazyEnvironment.stop()&lt;/code&gt; now closes its environment. See &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/multiple_environments/#closing-an-environment&quot;&gt;closing an environment&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;recollect_after_run&lt;/code&gt; for memo states.&lt;/strong&gt; A memo state function can return &lt;code&gt;recollect_after_run=True&lt;/code&gt; in its &lt;code&gt;MemoStateOutcome&lt;/code&gt; to have the state collected again after the function body re-runs, for states that depend on what the body read (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2474&quot;&gt;&lt;strong&gt;#2474&lt;/strong&gt;&lt;/a&gt;, v1.0.25). Without the flag the stored state is the one the check returned before the run, which is right for states read from outside, such as a modification time. Functions only for now; a memoized component raises &lt;code&gt;ValueError&lt;/code&gt; for it. See &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/memoization_keys/#state-that-depends-on-what-the-function-did&quot;&gt;state that depends on what the function did&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SurrealDB: &lt;code&gt;declare_fields&lt;/code&gt; and flexible record IDs&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2439&quot;&gt;&lt;strong&gt;#2439&lt;/strong&gt;&lt;/a&gt;, v1.0.25). &lt;code&gt;TableTarget.declare_fields&lt;/code&gt; lets more than one component own fields of the same record, and record IDs and relation endpoints may be strings, integers, or arrays. The same change fixes statement errors that were silently swallowed; see the &lt;a href=&quot;#correctness-fixes&quot;&gt;correctness fixes&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Syntax-aware splitting for Dart and Lua.&lt;/strong&gt; &lt;code&gt;RecursiveSplitter&lt;/code&gt; gained tree-sitter grammars for both (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2316&quot;&gt;&lt;strong&gt;#2316&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2370&quot;&gt;&lt;strong&gt;#2370&lt;/strong&gt;&lt;/a&gt;), bringing grammar-backed splitting to 38 languages; &lt;code&gt;.dart&lt;/code&gt; and &lt;code&gt;.lua&lt;/code&gt; files previously fell back to separator-based splitting. The &lt;a href=&quot;https://cocoindex.io/docs/ops/text/&quot;&gt;supported-languages table&lt;/a&gt; was audited and corrected at the same time (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2367&quot;&gt;&lt;strong&gt;#2367&lt;/strong&gt;&lt;/a&gt;). Unknown &lt;code&gt;language=&lt;/code&gt; values fall back to separator splitting rather than raising, so if chunk quality looks off, check the value against the table (&lt;code&gt;&quot;csharp&quot;&lt;/code&gt;, not &lt;code&gt;&quot;c_sharp&quot;&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;For connector authors (v1.0.21 to v1.0.25)&lt;/h3&gt;
&lt;p&gt;Several contracts in the &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/custom_target_connector/&quot;&gt;custom target connector&lt;/a&gt; API changed this cycle. Shipped connectors are all migrated. The container-deletion contract is now documented too; see &lt;a href=&quot;#documentation&quot;&gt;documentation&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Child slots replace aligned child lists&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2407&quot;&gt;&lt;strong&gt;#2407&lt;/strong&gt;&lt;/a&gt;, v1.0.23). A container sink used to return a list of child handler definitions index-aligned with the batch; only the length was checked, so a wrong index attached a child to the wrong target state silently, and a leaf-only batch through a shared sink had to return a &lt;code&gt;None&lt;/code&gt; per row. Container sinks are now built with &lt;code&gt;TargetActionSink.from_fn_with_children&lt;/code&gt; or &lt;code&gt;from_async_fn_with_children&lt;/code&gt;, whose callback receives &lt;code&gt;child_slots&lt;/code&gt;, a mapping with an entry only for actions that carry a child provider, and fulfills each one. &lt;code&gt;TargetActionSink&lt;/code&gt; takes one type argument, so one shared sink serves a container level and its leaf level without casts. The old shape keeps working with a &lt;code&gt;DeprecationWarning&lt;/code&gt;; see the &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/custom_target_connector/#migrating-from-childtargetdef&quot;&gt;migration section&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Value-based sink identity, now type-keyed&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2368&quot;&gt;&lt;strong&gt;#2368&lt;/strong&gt;&lt;/a&gt;, v1.0.21; &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2404&quot;&gt;&lt;strong&gt;#2404&lt;/strong&gt;&lt;/a&gt;, v1.0.23). Sinks built from callbacks that compare equal share one batching identity, so writes to the same resource from different components are batched and, for transactional targets, committed together, without a hand-kept registry of sinks. Equality alone was not safe, since a &lt;code&gt;NamedTuple&lt;/code&gt; equals any same-shaped tuple and two connectors&apos; sinks could merge. Canonicalization now also requires the same type, and a callback that cannot be weak-referenced raises &lt;code&gt;TypeError&lt;/code&gt; at construction; use a frozen dataclass, with &lt;code&gt;weakref_slot=True&lt;/code&gt; if it uses &lt;code&gt;slots=True&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Handlers and sinks see equal copies of plain-data values&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2469&quot;&gt;&lt;strong&gt;#2469&lt;/strong&gt;&lt;/a&gt;, v1.0.25). The copy is taken at declaration, so mutating a value after declaring it is not observed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;tracks_value_fingerprint = True&lt;/code&gt;&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2472&quot;&gt;&lt;strong&gt;#2472&lt;/strong&gt;&lt;/a&gt;, v1.0.25). A handler whose tracking record is exactly &lt;code&gt;fingerprint_object(value)&lt;/code&gt; can set this class attribute to let the engine skip &lt;code&gt;reconcile()&lt;/code&gt; for unchanged values, as described under &lt;a href=&quot;#unchanged-rows-skip-reconcile-in-the-table-targets&quot;&gt;performance&lt;/a&gt;. A handler that opts in but tracks something else never matches, so it never skips.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;reconcile()&lt;/code&gt; may run more than once per commit&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2475&quot;&gt;&lt;strong&gt;#2475&lt;/strong&gt;&lt;/a&gt;, v1.0.25). It runs inside the pre-commit callback, which is re-invoked when an LMDB batch re-runs after a map grow or after a body ahead of it fails. Only the attempt that commits is applied, so &lt;code&gt;reconcile()&lt;/code&gt; must be free of side effects.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Rust SDK: declarative batching, context keys, and row-type schemas (v1.0.25)&lt;/h3&gt;
&lt;p&gt;The Rust SDK needed more hand wiring than the Python SDK for batching, context resources, and connector schemas. &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2287&quot;&gt;&lt;strong&gt;#2287&lt;/strong&gt;&lt;/a&gt; makes those three declarative:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;#[cocoindex::function(memo, batching)]&lt;/code&gt;&lt;/strong&gt; gives a Rust function item-shaped batching with per-item memoization and body-hash invalidation, so cache misses are coalesced into batches while hits are served item by item.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;context_key!&lt;/code&gt;&lt;/strong&gt; declares a context key in one line, replacing hand-written &lt;code&gt;LazyLock&amp;lt;ContextKey&amp;lt;_&amp;gt;&amp;gt;&lt;/code&gt; definitions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;SchemaFields&lt;/code&gt; and &lt;code&gt;TableSchema::from_row&lt;/code&gt;&lt;/strong&gt; derive a connector schema from a Rust row type, with the vector dimension resolved at runtime from the embedder. Duplicate columns and unresolved dimensions fail early.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;cocoindex::context_key!(static DB: postgres::Database);
cocoindex::context_key!(static EMBEDDER: SentenceTransformerEmbedder, detect_change);

#[derive(Clone, Serialize, Deserialize, SchemaFields)]
struct DocEmbedding {
    id: i64,
    filename: String,
    text: String,
    #[coco(vector)]
    embedding: Vec&amp;lt;f32&amp;gt;,
}

async fn app_main(ctx: Ctx) -&amp;gt; Result&amp;lt;()&amp;gt; {
    let dim = ctx.get_key(&amp;amp;EMBEDDER)?.dimension();
    let schema = postgres::TableSchema::from_row::&amp;lt;DocEmbedding&amp;gt;([&quot;id&quot;])?
        .with_vector_dim(&quot;embedding&quot;, dim)?;
    // ...
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;a href=&quot;https://cocoindex.io/docs/getting_started/rust_quickstart/&quot;&gt;Rust quickstart&lt;/a&gt; and the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/rust&quot;&gt;Rust examples&lt;/a&gt; teach the new forms across Postgres, Qdrant, Turbopuffer, and LanceDB.&lt;/p&gt;
&lt;h2&gt;Performance&lt;/h2&gt;
&lt;h3&gt;Large target updates: less memory, fewer reconciles (v1.0.25)&lt;/h3&gt;
&lt;p&gt;A component that declares a million rows used to cost the engine about a kilobyte per row in Python objects until it committed, and every update called &lt;code&gt;reconcile()&lt;/code&gt; once per row whether or not the row had changed. Four changes in v1.0.25 take most of that out. None of them changes a stored fingerprint or tracking record, so nothing re-runs after the upgrade.&lt;/p&gt;
&lt;h4&gt;Rows are held encoded and released early&lt;/h4&gt;
&lt;p&gt;The engine holds every declared target state from declaration until the component commits, and every action &lt;code&gt;reconcile()&lt;/code&gt; returns until the sink has applied it. In the Python profile both were the Python objects themselves: a row dict of 15 short strings and ints costs about 1.2 KB, so a component declaring 1.14 million rows held about 1.33 GiB of row dicts, and the map of declared states stayed alive through the final commit although nothing read it after pre-commit (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2469&quot;&gt;&lt;strong&gt;#2469&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Plain-data values are now encoded at declaration: dicts with string keys, lists, tuples, scalars, and the standard library and numpy types all round-trip exactly, and a dict row stores its values plus one interned reference to its key tuple, so column names cost nothing per row. The declared-state map is dropped as soon as pre-commit is done. Dataclasses, pydantic and msgspec models, handles, and encodings over 64 KiB stay as objects.&lt;/p&gt;
&lt;h4&gt;Smaller costs on the commit path&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Native fingerprints.&lt;/strong&gt; &lt;code&gt;fingerprint_object&lt;/code&gt;, which connectors call once per declared row at commit, and memo fingerprints now walk plain data natively instead of canonicalizing it in Python first (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2470&quot;&gt;&lt;strong&gt;#2470&lt;/strong&gt;&lt;/a&gt;). The result is identical to before, pinned by golden values in the tests, so existing tracking records and memo keys stay valid. Anything that is not plain data falls back to the Python canonicalizer as a whole.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Postgres upserts through &lt;code&gt;unnest&lt;/code&gt;.&lt;/strong&gt; Tables whose columns are all builtin scalars, or arrays of them, are upserted with one array parameter per column, &lt;code&gt;INSERT ... SELECT ... FROM unnest($1::t1[], ...) ON CONFLICT ...&lt;/code&gt;, 2,000 rows per statement, instead of a multi-row &lt;code&gt;VALUES&lt;/code&gt; list whose statement text grew with the row count (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2471&quot;&gt;&lt;strong&gt;#2471&lt;/strong&gt;&lt;/a&gt;). Column types come from the catalog, read once per table, so a &lt;code&gt;managed_by=&quot;user&quot;&lt;/code&gt; table whose declared types differ from the real ones keeps working. Tables with pgvector, enum, or domain columns stay on &lt;code&gt;VALUES&lt;/code&gt;; parsing the vectors dominates either statement.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Postgres composite-key deletes.&lt;/strong&gt; Rows with multi-column keys were deleted with an &lt;code&gt;OR&lt;/code&gt; chain of per-key conjunctions, which Postgres plans with time that grows quadratically in the key count; a full chunk took about a minute, so a pass deleting many rows could stall for hours. The delete now matches &lt;code&gt;(c1, c2, ...) IN (VALUES ...)&lt;/code&gt;, one join against the key list (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2458&quot;&gt;&lt;strong&gt;#2458&lt;/strong&gt;&lt;/a&gt;). The caveat from the upgrade notes applies: placeholders are cast to the declared key types.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Unchanged rows skip &lt;code&gt;reconcile()&lt;/code&gt; in the table targets&lt;/h4&gt;
&lt;p&gt;The row handlers of Postgres, SQLite, Doris, Snowflake, BigQuery, LanceDB, Neo4j, and FalkorDB now tell the engine that their tracking record is exactly the value&apos;s fingerprint (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2472&quot;&gt;&lt;strong&gt;#2472&lt;/strong&gt;&lt;/a&gt;). For those targets the engine fingerprints the declared value natively and calls &lt;code&gt;reconcile()&lt;/code&gt; only for rows that are new, changed, removed, or possibly missing. An update where most rows are unchanged runs no per-row Python at commit. Qdrant, Valkey, SurrealDB, Turbopuffer, and zvec fingerprint a derived value rather than the row, so they do not opt in yet, nor do index and attachment handlers; they behave exactly as before. &lt;code&gt;full_reprocess&lt;/code&gt;, a provider schema change, and a value that is not plain data still go through &lt;code&gt;reconcile()&lt;/code&gt;.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measurement&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Engine memory per declared Postgres row&lt;/td&gt;
&lt;td&gt;1,449 B&lt;/td&gt;
&lt;td&gt;487 B&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fingerprint, 15-column row with two list columns&lt;/td&gt;
&lt;td&gt;17.8 µs&lt;/td&gt;
&lt;td&gt;1.95 µs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;200,000 unchanged rows at commit, no-op sink&lt;/td&gt;
&lt;td&gt;2.34 s, 200,000 &lt;code&gt;reconcile()&lt;/code&gt; calls&lt;/td&gt;
&lt;td&gt;1.34 s, 0 calls&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Postgres upsert, 631,119 rows, 10 connections&lt;/td&gt;
&lt;td&gt;5.1–5.6 s&lt;/td&gt;
&lt;td&gt;2.8–3.2 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Postgres delete, 8,000 four-column keys&lt;/td&gt;
&lt;td&gt;59.1 s&lt;/td&gt;
&lt;td&gt;0.26 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;Fixes&lt;/h2&gt;
&lt;h3&gt;Long updates no longer hang on Linux (v1.0.24)&lt;/h3&gt;
&lt;p&gt;Under sustained load, a long &lt;code&gt;App.update()&lt;/code&gt; on Linux could stop making progress and never return, with every later write blocked behind it (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2426&quot;&gt;&lt;strong&gt;#2426&lt;/strong&gt;&lt;/a&gt;, fixing &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/issues/2424&quot;&gt;&lt;strong&gt;#2424&lt;/strong&gt;&lt;/a&gt;). LMDB ties a write transaction to the OS thread that began it. The engine opened the transaction and then awaited the batched bodies on the multi-thread runtime, so a body that suspended could resume on another worker thread. The commit then released the writer lock from the wrong thread, the release failed silently, and the next write waited forever.&lt;/p&gt;
&lt;p&gt;Triggering it needed a body that actually suspended inside the transaction, which took a large coalesced batch or a component with more than about 125 target states, so it surfaced in production rather than in tests. It never reproduced on macOS, where LMDB uses a different lock. Each write transaction now runs on one OS thread from open to commit, whatever a body awaits. One side effect: a batch whose callers have all been cancelled now always commits, where before it committed or rolled back depending on timing. If you run on Linux, upgrade to 1.0.24 or later.&lt;/p&gt;
&lt;h3&gt;Failures stay with the component that caused them (v1.0.23, v1.0.25)&lt;/h3&gt;
&lt;p&gt;The engine merges work in two places that user code never sees: actions from every component that finishes while a sink call (one connector write to the target) is in flight go into the next call, and concurrent write-transaction bodies share one LMDB transaction. Both merges are pure optimizations, and a failure inside a merged unit used to fail everyone in it. Reviewing a shared Postgres sink made the cost concrete: a &lt;code&gt;mount_each&lt;/code&gt; fan-out of 60 components produced one sink call with 59 rows, one poisoned row rolled back the other 58 components&apos; writes, and &lt;code&gt;app.update()&lt;/code&gt; returned without raising, because mounted children fail independently.&lt;/p&gt;
&lt;p&gt;Both layers now follow, automatically, the rule that &lt;a href=&quot;#cocoretrywithsmallerbatch-batch-splitting-on-failure-v1017&quot;&gt;&lt;code&gt;coco.RetryWithSmallerBatch&lt;/code&gt;&lt;/a&gt; gives batched functions: a failure reaches only the callers whose inputs caused it.&lt;/p&gt;
&lt;h4&gt;Target sink batches (v1.0.23)&lt;/h4&gt;
&lt;p&gt;A sink receives one flat action list and cannot see component boundaries, and the runner behind it was all-or-nothing, so a failed merged call fanned one error out to every component in it. The runner now returns one result per component (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2406&quot;&gt;&lt;strong&gt;#2406&lt;/strong&gt;&lt;/a&gt;). A batch spanning several components is applied whole first. If that fails, it is bisected along component boundaries, never inside a component, whose actions stay one atomic unit, and each half is re-applied, recursively. An error reaches only the components in a failing sub-batch, and a component that still fails alone gets its own error.&lt;/p&gt;
&lt;p&gt;The happy path is unchanged: one sink call, one transaction. The failure path costs at most 2n − 1 sink calls for n components, about 2·log₂(n) when a single component is bad. Cancellation and deadline errors are not retried, since no particular component caused them, and connector code is untouched.&lt;/p&gt;

Quick check: one row in a merged sink call of 59 rows is bad. Which components fail now?
&lt;p&gt;Only the component that declared the bad row. The engine bisects the call along component boundaries and re-applies each half, so the other components&apos; writes go through. It costs at most 2n − 1 sink calls for n components.&lt;/p&gt;

&lt;h4&gt;Write transactions (v1.0.25)&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;reconcile()&lt;/code&gt; runs inside pre-commit, which runs inside a batched write-transaction body. A connector rejecting one component&apos;s declared value therefore failed the pre-commit of every component batched with it, including components of other apps sharing the same &lt;code&gt;Environment&lt;/code&gt;, each reporting a copy of an unrelated error (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2451&quot;&gt;&lt;strong&gt;#2451&lt;/strong&gt;&lt;/a&gt;). The runner now reports one result per body. When a body fails, the transaction is aborted, since LMDB has no savepoints, and the error goes to that body&apos;s caller only. The bodies ahead of it ran cleanly, so they run again and commit in a transaction of their own; the bodies behind it continue in the next transaction, still in call order. Each body runs at most twice however many of its batch mates fail, and nothing changes on the happy path.&lt;/p&gt;
&lt;h4&gt;Where a failure is delivered&lt;/h4&gt;
&lt;p&gt;Component exception handlers now receive the component&apos;s original Python exception instead of a &lt;code&gt;RuntimeError&lt;/code&gt; wrapping a formatted string, and an exception a handler raises keeps its type through &lt;code&gt;await handle.ready()&lt;/code&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2383&quot;&gt;&lt;strong&gt;#2383&lt;/strong&gt;&lt;/a&gt;, v1.0.23). A handler installed with &lt;code&gt;coco.exception_handler&lt;/code&gt; around &lt;code&gt;coco.mount_each(fn, items)&lt;/code&gt; now receives the items&apos; failures when &lt;code&gt;items&lt;/code&gt; is a &lt;code&gt;LiveMap&lt;/code&gt;, as it already did for a list; &lt;code&gt;coco.auto_refresh&lt;/code&gt; items are covered the same way (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2478&quot;&gt;&lt;strong&gt;#2478&lt;/strong&gt;&lt;/a&gt;, v1.0.25).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;Memoization under concurrency and redefinition (v1.0.23 to v1.0.24)&lt;/h3&gt;
&lt;p&gt;Two classes of spurious re-execution are fixed. Neither changes a memo key or a stored entry.&lt;/p&gt;
&lt;h4&gt;Concurrent same-key component runs execute once&lt;/h4&gt;
&lt;p&gt;Two runs of one memoized component with the same key that both started before either had stored a memo, for example two overlapping &lt;code&gt;App.update()&lt;/code&gt; calls on an app whose main function is memoized, both executed the body (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2412&quot;&gt;&lt;strong&gt;#2412&lt;/strong&gt;&lt;/a&gt;). The engine now holds the component&apos;s build permit through the memo store, and a run queued on the permit re-checks the memo a same-key run just stored and reuses it. A failed run stores nothing, so the queued run executes as before. The same reuse applies under &lt;code&gt;full_reprocess&lt;/code&gt;, scoped to the current update: a memo stored earlier in the same update is reused, while memos left by previous updates are still ignored (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2414&quot;&gt;&lt;strong&gt;#2414&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;Redefinitions and copies no longer drop a memo&lt;/h4&gt;
&lt;p&gt;A &lt;code&gt;@coco.fn(memo=True)&lt;/code&gt; function registers its logic fingerprint in a process-global registry and releases it when the object is collected. Two live objects can share one fingerprint whenever identical code is defined twice: a re-run notebook cell, &lt;code&gt;importlib.reload&lt;/code&gt;, or a factory that defines the function on each call. Dropping the old object removed the fingerprint for both, and the surviving function&apos;s memo entries then failed the logic check and re-ran, paid embedding calls included. The registry is now reference-counted (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2405&quot;&gt;&lt;strong&gt;#2405&lt;/strong&gt;&lt;/a&gt;), and &lt;code&gt;copy.copy&lt;/code&gt; and &lt;code&gt;copy.deepcopy&lt;/code&gt; of a coco function return the function itself rather than an unregistered copy whose deletion had the same effect (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2409&quot;&gt;&lt;strong&gt;#2409&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;Correctness fixes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SurrealDB statement errors are raised&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2439&quot;&gt;&lt;strong&gt;#2439&lt;/strong&gt;&lt;/a&gt;, v1.0.25). A statement error inside a batch was silently swallowed by &lt;code&gt;query()&lt;/code&gt;; it is now raised. The same change sends values as typed CBOR parameters, writes records with &lt;code&gt;UPSERT ... MERGE&lt;/code&gt; so fields no longer declared are unset, bounds transactions at 500 actions with a retry on conflict, makes DDL idempotent, and keeps vector indexes HNSW only, since MTREE was removed in SurrealDB 3. Its new APIs are listed under &lt;a href=&quot;#smaller-additions-v1018-to-v1025&quot;&gt;smaller additions&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Replacing a component with a deeper one no longer deletes the deeper component&apos;s rows&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2379&quot;&gt;&lt;strong&gt;#2379&lt;/strong&gt;&lt;/a&gt;, v1.0.22). When a component at &lt;code&gt;a/b&lt;/code&gt; from a previous run was replaced by &lt;code&gt;a/b/c&lt;/code&gt;, the demotion of &lt;code&gt;a/b&lt;/code&gt; was meant to remove only its own target states; it removed every child row under it as well, and the next sweep then deleted target states &lt;code&gt;a/b/c&lt;/code&gt; had written in the same update.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Live mode terminates even when a child&apos;s exception is retained&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2385&quot;&gt;&lt;strong&gt;#2385&lt;/strong&gt;&lt;/a&gt;, v1.0.22). A component counted as active while any strong reference to it existed, and an exception&apos;s traceback holds such a reference, so appending a child&apos;s exception to a list in a handler kept &lt;code&gt;update_blocking(live=True)&lt;/code&gt; from ever returning. Activity is now an explicit count of in-flight tasks.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LiteLLM embeddings are aligned to inputs by index&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2381&quot;&gt;&lt;strong&gt;#2381&lt;/strong&gt;&lt;/a&gt;, v1.0.22). A provider or proxy that returned items out of order attached embeddings to the wrong texts with no error. The memo version is deliberately unchanged, so vectors cached while misaligned are not invalidated automatically; if you suspect a proxy reordered responses, run a &lt;code&gt;full_reprocess&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Schema changes under &lt;code&gt;full_reprocess&lt;/code&gt;, in the table and graph targets.&lt;/strong&gt; These connectors silently skipped a schema change (a table column, or a node or relationship property in the graph targets) that arrived in an update run with &lt;code&gt;full_reprocess=True&lt;/code&gt;. Row writes then failed on the missing column, yet later updates reported success, and the target stayed out of sync. The gap was in the connectors&apos; reconcile and apply paths rather than in the engine, and it is fixed in Postgres, SQLite, Doris, Snowflake, BigQuery, and SurrealDB (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2346&quot;&gt;&lt;strong&gt;#2346&lt;/strong&gt;&lt;/a&gt;), LanceDB (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2352&quot;&gt;&lt;strong&gt;#2352&lt;/strong&gt;&lt;/a&gt;), and Neo4j and FalkorDB (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2362&quot;&gt;&lt;strong&gt;#2362&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Failed DDL is reported, not recorded as applied.&lt;/strong&gt; SQLite no longer treats a genuine &lt;code&gt;ADD COLUMN&lt;/code&gt; failure as an idempotent no-op (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2328&quot;&gt;&lt;strong&gt;#2328&lt;/strong&gt;&lt;/a&gt;), and Doris does the same for &lt;code&gt;ADD COLUMN&lt;/code&gt; and &lt;code&gt;DROP COLUMN&lt;/code&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2359&quot;&gt;&lt;strong&gt;#2359&lt;/strong&gt;&lt;/a&gt;), so the tracked schema cannot drift from the real table.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Memoization preserves target invalidation&lt;/strong&gt; (the same &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2346&quot;&gt;&lt;strong&gt;#2346&lt;/strong&gt;&lt;/a&gt;). Before, if a &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/memoization_keys/&quot;&gt;memoized&lt;/a&gt; function declared rows and the target&apos;s provider changed in a way that should rewrite them, a cache hit could skip the rewrite. Provider changes are now part of what a cache hit validates.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Recreated container target states no longer replay stale deletes&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2365&quot;&gt;&lt;strong&gt;#2365&lt;/strong&gt;&lt;/a&gt;). Recreating a container, for example a partition after its parent table&apos;s primary key changed, could replay deletes from the old layout against its children, failing the component or silently dropping fresh rows.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Memoization keys with &lt;code&gt;Fingerprint&lt;/code&gt; values are order-independent&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2334&quot;&gt;&lt;strong&gt;#2334&lt;/strong&gt;&lt;/a&gt;). Dictionaries and sets of &lt;code&gt;Fingerprint&lt;/code&gt; keys built in different orders now produce the same key instead of a spurious cache miss.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Other fixes&lt;/h4&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;th&gt;Impact&lt;/th&gt;
&lt;th&gt;Release&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2244&quot;&gt;Recursively strip NUL from Postgres array and composite bindings&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Strings containing &lt;code&gt;U+0000&lt;/code&gt; inside &lt;code&gt;text[]&lt;/code&gt; or composite values no longer fail with &lt;code&gt;ValueError: string cannot contain NUL&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;v1.0.17&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2318&quot;&gt;Clear the inverted target-owner index on component deletion&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;No permanently dangling owner rows after a component is dropped&lt;/td&gt;
&lt;td&gt;v1.0.19&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2374&quot;&gt;Avoid blocking the event loop during iterator cleanup&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Async source iterators no longer stall the event loop while their producer thread exits&lt;/td&gt;
&lt;td&gt;v1.0.21&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2376&quot;&gt;Parse Windows app target paths&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;C:\project\main.py:app2&lt;/code&gt; is no longer parsed as module &lt;code&gt;C&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;v1.0.21&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2403&quot;&gt;Preserve tuple and bytes path segments through state-store decoding&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Components keyed by a tuple or by bytes no longer leak or misattribute target-state ownership; rows already leaked are not repaired&lt;/td&gt;
&lt;td&gt;v1.0.23&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2447&quot;&gt;Collect preview actions once when a write batch re-runs&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Preview no longer reports an action once per LMDB map grow&lt;/td&gt;
&lt;td&gt;v1.0.25&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2419&quot;&gt;Purge Valkey document hashes when an index is deleted&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Un-declaring an index or running &lt;code&gt;App.drop()&lt;/code&gt; no longer leaves the index&apos;s document hashes behind&lt;/td&gt;
&lt;td&gt;v1.0.25&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2443&quot;&gt;Tag Valkey connections with &lt;code&gt;LIB-NAME cocoindex&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;CocoIndex clients are identifiable in &lt;code&gt;CLIENT LIST&lt;/code&gt;; requires &lt;code&gt;valkey-glide&lt;/code&gt; ≥ 2.5.2&lt;/td&gt;
&lt;td&gt;v1.0.25&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2456&quot;&gt;Stop recursive localfs walks at symlink cycles&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;A directory containing a symlink back to itself or a parent no longer yields an endless stream of keys&lt;/td&gt;
&lt;td&gt;v1.0.25&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2437&quot;&gt;Return empty bytes for zero-length and empty-object S3 reads&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;read(0)&lt;/code&gt; and partial reads of an empty object no longer send a range request S3 rejects&lt;/td&gt;
&lt;td&gt;v1.0.25&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2277&quot;&gt;Wake GPU pool waiters across event loops&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;A function waiting for a GPU on one event loop no longer sleeps forever when capacity is released on another, which could leave a process idle with embeddings pending&lt;/td&gt;
&lt;td&gt;v1.0.25&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;Examples&lt;/h2&gt;
&lt;h3&gt;Slides-to-speech, local narration and per-slide incrementality&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;https://cocoindex.io/docs/examples/slides-to-speech/&quot;&gt;slides-to-speech example&lt;/a&gt; now narrates locally on the CPU with no TTS API key: Kyutai&apos;s Pocket TTS replaces Piper, and a typed DSPy signature drives the vision model, which still needs LLM credentials (Gemini by default) (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2262&quot;&gt;&lt;strong&gt;#2262&lt;/strong&gt;&lt;/a&gt;). It is also incremental per slide rather than per deck (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2267&quot;&gt;&lt;strong&gt;#2267&lt;/strong&gt;&lt;/a&gt;): editing one slide re-runs the vision call, synthesis, and embedding for that slide only, and the chosen TTS voice is a tracked input, so switching voices re-narrates every slide.&lt;/p&gt;
&lt;h3&gt;Meeting notes to a knowledge graph on SurrealDB&lt;/h3&gt;
&lt;p&gt;A new example builds a knowledge graph from meeting notes into SurrealDB (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2329&quot;&gt;&lt;strong&gt;#2329&lt;/strong&gt;&lt;/a&gt;), joining the Neo4j and FalkorDB versions of the same example (the &lt;a href=&quot;https://cocoindex.io/docs/examples/meeting-notes-to-knowledge-graph/&quot;&gt;walkthrough&lt;/a&gt; covers the Neo4j one).&lt;/p&gt;
&lt;h2&gt;Internal improvements&lt;/h2&gt;
&lt;h3&gt;Documentation&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#memoization&quot;&gt;Memoization placement&lt;/a&gt;: where &lt;code&gt;memo=True&lt;/code&gt; belongs relative to component structure, what a cache entry costs, and that &lt;code&gt;full_reprocess&lt;/code&gt; re-runs every memoized function and component, paid LLM and embedding calls included (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2363&quot;&gt;&lt;strong&gt;#2363&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/internal_storage/&quot;&gt;LMDB map auto-resize&lt;/a&gt; and logic-fingerprint propagation, including the gotcha that setting &lt;code&gt;version=&lt;/code&gt; on a &lt;code&gt;@coco.fn&lt;/code&gt; replaces automatic source-change tracking, so later code edits stop invalidating until you bump it (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2364&quot;&gt;&lt;strong&gt;#2364&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;A dedicated &lt;a href=&quot;https://cocoindex.io/docs/common_resources/rate_limiting/&quot;&gt;rate limiting&lt;/a&gt; page (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2265&quot;&gt;&lt;strong&gt;#2265&lt;/strong&gt;&lt;/a&gt;), &lt;code&gt;mount_each()&lt;/code&gt; return semantics (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2327&quot;&gt;&lt;strong&gt;#2327&lt;/strong&gt;&lt;/a&gt;), connection resolution at action time in the custom target connector guide (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2291&quot;&gt;&lt;strong&gt;#2291&lt;/strong&gt;&lt;/a&gt;), and the &lt;a href=&quot;https://cocoindex.io/docs/ops/litellm/#shared-behavior&quot;&gt;LiteLLM shared behavior&lt;/a&gt; section (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2396&quot;&gt;&lt;strong&gt;#2396&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Container deletion, destroy versus abandon&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2418&quot;&gt;&lt;strong&gt;#2418&lt;/strong&gt;&lt;/a&gt;, v1.0.24). The docs now spell out an existing contract that connector authors depend on. Once a container is no longer declared, its own removal runs and its children are not visited individually. A container handler therefore either destroys, for containers CocoIndex owns (&lt;code&gt;DROP TABLE&lt;/code&gt;, &lt;code&gt;rmtree&lt;/code&gt;), or abandons, for user-managed ones such as Kafka and Iggy topics and &lt;code&gt;managed_by=&quot;user&quot;&lt;/code&gt; tables, which CocoIndex stops writing to and leaves untouched, with no tombstones or deletion messages. &lt;code&gt;App.drop()&lt;/code&gt; follows the same rule; the &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;target-state guide&lt;/a&gt; and the &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/custom_target_connector/#deleting-a-container&quot;&gt;connector guide&lt;/a&gt; now say so.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Security and dependencies&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;pyo3 0.27 → 0.29&lt;/strong&gt; plus lockfile dependency bumps, resolving open security advisories (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2292&quot;&gt;&lt;strong&gt;#2292&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2293&quot;&gt;&lt;strong&gt;#2293&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;surrealdb ≥ 3.2.3&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2315&quot;&gt;&lt;strong&gt;#2315&lt;/strong&gt;&lt;/a&gt;), raising the floor for a quinn-proto denial of service (CVSS 7.5) and two ammonia XSS advisories in the optional SurrealDB feature; the lockfile bump that moved quinn-proto to 0.11.16 and ammonia to 4.1.4 shipped in v1.0.20 with &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2355&quot;&gt;&lt;strong&gt;#2355&lt;/strong&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dependency upgrade sweep&lt;/strong&gt; clearing the remaining high-severity alerts; two low-severity, upstream-blocked ones remain (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2355&quot;&gt;&lt;strong&gt;#2355&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;What to try next&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Put a time budget on your slowest unit of work.&lt;/strong&gt; Wrap its processor body in &lt;code&gt;with coco.timeout(timedelta(seconds=30)):&lt;/code&gt;, as in &lt;a href=&quot;#cocotimeout-cooperative-deadlines-v1017&quot;&gt;the timeout example&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Let one bad input fail alone.&lt;/strong&gt; In a batched function, &lt;code&gt;raise coco.RetryWithSmallerBatch() from e&lt;/code&gt; for errors that depend on the batch, as in &lt;a href=&quot;#cocoretrywithsmallerbatch-batch-splitting-on-failure-v1017&quot;&gt;the batch example&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Check what CocoIndex wrote.&lt;/strong&gt; Run &lt;code&gt;cocoindex show &amp;lt;app&amp;gt; --target-states&lt;/code&gt;, or add &lt;code&gt;--db &amp;lt;path&amp;gt; --app-name &amp;lt;name&amp;gt;&lt;/code&gt; to read a copied database.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;On Linux, upgrade to 1.0.24 or later&lt;/strong&gt; to get &lt;a href=&quot;#long-updates-no-longer-hang-on-linux-v1024&quot;&gt;the hang fix&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the complete list of changes, see the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/releases&quot;&gt;GitHub releases&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Thanks to the community&lt;/h2&gt;
&lt;p&gt;Thanks to everyone who contributed this cycle, including 11 first-time contributors.&lt;/p&gt;
&lt;h3&gt;@junzh0u&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/junzh0u&quot;&gt;@junzh0u&lt;/a&gt;, a first-time contributor, for making target state legible: &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2299&quot;&gt;fixing cross-process &lt;code&gt;show --db&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2301&quot;&gt;rendering tracked paths readably&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2303&quot;&gt;adding the &lt;code&gt;--target-states&lt;/code&gt; listing&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2306&quot;&gt;persisting names for provider-only segments&lt;/a&gt;, and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2307&quot;&gt;a faster detail view&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@Sujit-1509&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/Sujit-1509&quot;&gt;@Sujit-1509&lt;/a&gt; for carrying the schema-evolution fix across connectors: &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2352&quot;&gt;LanceDB&lt;/a&gt; and then &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2362&quot;&gt;Neo4j and FalkorDB&lt;/a&gt;, plus &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2334&quot;&gt;deterministic &lt;code&gt;Fingerprint&lt;/code&gt; canonicalization&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2244&quot;&gt;recursive NUL stripping in Postgres array and composite bindings&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2456&quot;&gt;stopping localfs walks at symlink cycles&lt;/a&gt;, and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2437&quot;&gt;zero-length and empty-object S3 reads&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@hardness1020&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/hardness1020&quot;&gt;@hardness1020&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2370&quot;&gt;wiring the tree-sitter Lua grammar&lt;/a&gt;, then for three correctness fixes: &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2381&quot;&gt;aligning LiteLLM embeddings to inputs by index&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2383&quot;&gt;preserving typed exceptions in component exception handlers&lt;/a&gt;, and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2403&quot;&gt;preserving tuple and bytes path segments through state-store decoding&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@tomz-alt&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/tomz-alt&quot;&gt;@tomz-alt&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2251&quot;&gt;cooperative timeout support&lt;/a&gt;: &lt;code&gt;coco.timeout()&lt;/code&gt;, &lt;code&gt;DeadlineExceededError&lt;/code&gt;, and the inheritance rule that separates foreground work from background and shared work; and for the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2287&quot;&gt;Rust SDK ergonomics&lt;/a&gt; release: declarative batching with per-item memoization, &lt;code&gt;context_key!&lt;/code&gt;, and schemas derived from row types.&lt;/p&gt;
&lt;h3&gt;@prrao87&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/prrao87&quot;&gt;@prrao87&lt;/a&gt; for rebuilding slides-to-speech: &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2262&quot;&gt;local CPU TTS with a DSPy vision signature&lt;/a&gt;, then &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2267&quot;&gt;moving the incremental boundary to the slide&lt;/a&gt; with the TTS voice as a tracked context value.&lt;/p&gt;
&lt;h3&gt;@martinschaer&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/martinschaer&quot;&gt;@martinschaer&lt;/a&gt;, a first-time contributor, for the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2439&quot;&gt;SurrealDB connector overhaul&lt;/a&gt;: raised statement errors, typed CBOR values, flexible record IDs, &lt;code&gt;UPSERT ... MERGE&lt;/code&gt; writes with &lt;code&gt;declare_fields&lt;/code&gt;, bounded transactions, and HNSW-only indexes for SurrealDB 3.&lt;/p&gt;
&lt;h3&gt;@YaxinCheng&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/YaxinCheng&quot;&gt;@YaxinCheng&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2277&quot;&gt;rewriting the GPU pool in Rust&lt;/a&gt;: a fair arrival-order queue, whole-GPU reservations through &lt;code&gt;acquire_full(n)&lt;/code&gt;, and a fix for waiters never woken when capacity was released from another event loop.&lt;/p&gt;
&lt;h3&gt;@suju-droid&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/suju-droid&quot;&gt;@suju-droid&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2318&quot;&gt;clearing the inverted target-owner index on component deletion&lt;/a&gt; and for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2328&quot;&gt;preserving SQLite schema consistency on failed column migrations&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@ca-ke&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/ca-ke&quot;&gt;@ca-ke&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2316&quot;&gt;wiring the tree-sitter Dart grammar&lt;/a&gt;, so &lt;code&gt;.dart&lt;/code&gt; files get syntax-aware splitting instead of the separator fallback.&lt;/p&gt;
&lt;h3&gt;@AmirF194&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/AmirF194&quot;&gt;@AmirF194&lt;/a&gt;, a first-time contributor, for making the Doris connector &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2359&quot;&gt;re-raise genuine column DDL failures instead of swallowing them&lt;/a&gt;, including tests that exercise the real control flow without a live cluster.&lt;/p&gt;
&lt;h3&gt;@AbhayMahalle&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/AbhayMahalle&quot;&gt;@AbhayMahalle&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2443&quot;&gt;tagging Valkey connections with the CocoIndex library name&lt;/a&gt;, so they can be told apart in the server&apos;s &lt;code&gt;CLIENT LIST&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;@aeonframework&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/aeonframework&quot;&gt;@aeonframework&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2315&quot;&gt;raising the surrealdb floor to ≥ 3.2.3&lt;/a&gt; for two security advisories.&lt;/p&gt;
&lt;h3&gt;@justavibedev&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/justavibedev&quot;&gt;@justavibedev&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2374&quot;&gt;keeping the event loop unblocked during async iterator cleanup&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@yhz5613813&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/yhz5613813&quot;&gt;@yhz5613813&lt;/a&gt;, a first-time contributor, for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2376&quot;&gt;parsing Windows app target paths&lt;/a&gt;, so a drive-letter colon is no longer read as the app-name separator.&lt;/p&gt;
</content:encoded><category>changelog</category><category>feature</category><category>announcement</category><author>George He</author></item><item><title>Persistent state, rate limits, Snowflake and BigQuery</title><link>https://cocoindex.io/blogs/changelog-108-1016/</link><guid isPermaLink="true">https://cocoindex.io/blogs/changelog-108-1016/</guid><description>CocoIndex 1.0.8–1.0.16 adds per-component state, LiveMap, a shared rate limiter, batched target writes, and Snowflake, BigQuery and Azure Blob connectors.</description><pubDate>Tue, 07 Jul 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This is the second changelog since the v1.0 launch, covering 9 releases (1.0.8–1.0.16). The new engine APIs are &lt;code&gt;coco.use_state()&lt;/code&gt; for state that persists between runs, &lt;code&gt;LiveMap&lt;/code&gt; for passing data between two parts of a live pipeline, and a shared token-bucket &lt;code&gt;RateLimiter&lt;/code&gt;. Writes from many components to one target are now batched. New connectors add Snowflake and BigQuery targets and an Azure Blob Storage source. Debugging tools, examples, and fixes follow.&lt;/p&gt;
&lt;p&gt;CocoIndex builds fresh, structured context for AI from sources such as PDFs, codebases, emails, screenshots, and meeting notes, and keeps it up to date with an &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;incremental engine&lt;/a&gt;. The source is on &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;:::tip[Start here]&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;You write pipelines:&lt;/strong&gt; read &lt;a href=&quot;#cocouse_state-persistent-per-component-state-v108&quot;&gt;&lt;code&gt;use_state&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;#livemap-in-memory-intermediate-collections-v108&quot;&gt;&lt;code&gt;LiveMap&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;#ratelimiter-one-shared-token-bucket-v108&quot;&gt;&lt;code&gt;RateLimiter&lt;/code&gt;&lt;/a&gt; first.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You write to a warehouse or vector store:&lt;/strong&gt; read &lt;a href=&quot;#batched-target-writes-across-components-v1015&quot;&gt;batched target writes&lt;/a&gt; and &lt;a href=&quot;#connectors&quot;&gt;connectors&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You run deployments:&lt;/strong&gt; read &lt;a href=&quot;#preview-mode-for-update-actions-v108&quot;&gt;preview mode&lt;/a&gt;, &lt;a href=&quot;#cocoindex-show-an-inspection-tool-for-debugging-v1012&quot;&gt;&lt;code&gt;cocoindex show&lt;/code&gt;&lt;/a&gt; and the &lt;a href=&quot;#engine-performance&quot;&gt;LMDB fixes&lt;/a&gt;.
:::&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Why this release cycle matters&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Persistent state.&lt;/strong&gt; &lt;a href=&quot;#cocouse_state-persistent-per-component-state-v108&quot;&gt;&lt;code&gt;coco.use_state()&lt;/code&gt;&lt;/a&gt; gives a component a value that it reads at the start of a run and that the next run sees, with no external store.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;In-memory collections.&lt;/strong&gt; &lt;a href=&quot;#livemap-in-memory-intermediate-collections-v108&quot;&gt;&lt;code&gt;LiveMap&lt;/code&gt;&lt;/a&gt; lets one part of a live pipeline declare keyed entries and another part run one component per entry.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shared rate limits.&lt;/strong&gt; &lt;a href=&quot;#ratelimiter-one-shared-token-bucket-v108&quot;&gt;&lt;code&gt;RateLimiter&lt;/code&gt;&lt;/a&gt; puts every caller that holds the same instance under one token budget, served in arrival order.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Batched target writes.&lt;/strong&gt; Rows that many components write to the &lt;a href=&quot;#batched-target-writes-across-components-v1015&quot;&gt;same target&lt;/a&gt; at the same time go out in one apply. A 50-row LanceDB ingest used to make about 50 commits.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectors.&lt;/strong&gt; &lt;a href=&quot;#connectors&quot;&gt;Snowflake and BigQuery&lt;/a&gt; targets, an Azure Blob Storage source, a Valkey vector store target, and sparse vectors in Qdrant.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;New engine primitives&lt;/h2&gt;
&lt;h3&gt;&lt;code&gt;coco.use_state()&lt;/code&gt;: persistent per-component state (v1.0.8)&lt;/h3&gt;
&lt;p&gt;The incremental engine already knows &lt;em&gt;what&lt;/em&gt; changed between runs. A component did not know &lt;em&gt;what it had already done&lt;/em&gt;: a running total, the set of entities it has seen, or a watermark (the position it read up to) needed an external Redis or Postgres. &lt;code&gt;coco.use_state()&lt;/code&gt; gives any pipeline component a persistent, typed state slot that survives across update cycles.&lt;/p&gt;
&lt;p&gt;The state is stored in the LMDB state store (the embedded key-value database where CocoIndex keeps its own metadata), keyed by a &lt;code&gt;StableKey&lt;/code&gt;, such as a string, a number, a UUID, or a tuple of these. Before &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2085&quot;&gt;&lt;strong&gt;#2085&lt;/strong&gt;&lt;/a&gt; the key was a plain string. A &lt;code&gt;type_hint&lt;/code&gt; parameter added in v1.0.15 decodes the stored value back into your own type, such as a dataclass.&lt;/p&gt;
&lt;p&gt;This counter counts how many times the component has run:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import cocoindex as coco

@coco.fn
async def process_feed(feed: Feed) -&amp;gt; None:
    runs = coco.use_state(&quot;runs&quot;, 0)  # 0 on the first run
    runs.value += 1                   # stored when the component commits
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; On the first run &lt;code&gt;runs.value&lt;/code&gt; is &lt;code&gt;0&lt;/code&gt;, and &lt;code&gt;1&lt;/code&gt; is stored. Each later run of the same component reads the value the previous run committed. The value is written once, when the component commits.&lt;/p&gt;
&lt;p&gt;Stateful logic of this kind can now live inside the pipeline declaration, under the same incremental reconciliation as the rest of CocoIndex.&lt;/p&gt;

Quick check: can you call &lt;code&gt;coco.use_state()&lt;/code&gt; inside a &lt;code&gt;@coco.fn(memo=True)&lt;/code&gt; function?
&lt;p&gt;No. On a cache hit the memoized body is skipped, so the key would never be declared and the stored state would be cleaned up as stale. CocoIndex raises &lt;code&gt;RuntimeError&lt;/code&gt; instead. Call &lt;code&gt;use_state&lt;/code&gt; in the component&apos;s own processor.&lt;/p&gt;

&lt;h3&gt;&lt;code&gt;LiveMap&lt;/code&gt;: in-memory intermediate collections (v1.0.8)&lt;/h3&gt;
&lt;p&gt;Some live pipelines have two halves: one part reads a stream and finds items, and another part processes each item. &lt;code&gt;LiveMap&lt;/code&gt; is a new in-memory keyed collection that connects the two halves of the same live run. Producing components &lt;em&gt;declare&lt;/em&gt; entries into it as target states (&lt;code&gt;LiveMap.declare_entry&lt;/code&gt;). A &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;target state&lt;/a&gt; is something a component declares should exist; CocoIndex adds, updates and removes it to match. The consuming side reads the same in-memory &lt;code&gt;dict&lt;/code&gt; as a live source through &lt;code&gt;mount_each&lt;/code&gt;, which mounts one component per entry.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import cocoindex as coco
from cocoindex.resources.live_map import LiveMap

@coco.fn
async def app_main() -&amp;gt; None:
    lm: LiveMap[str, str] = await LiveMap.create()
    await coco.mount(produce_entries, lm)     # producers call lm.declare_entry(key, value)
    await coco.mount_each(process_entry, lm)  # one component per entry
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;LiveComponent&lt;/code&gt; classes can now be used inside &lt;code&gt;mount_each()&lt;/code&gt; as well, so the consuming side can be a tree of live components, one per entry, mounted and dropped as producers add keys and stop declaring them.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; When a producer declares a new key, a component for it mounts. When the value for a key changes, that key&apos;s component runs again. When the producer stops declaring a key, its component is removed. The map lives in process memory and is rebuilt from its producers each time the app starts.&lt;/p&gt;

Quick check: a producer stops declaring &lt;code&gt;user:4&lt;/code&gt;. What happens on the consuming side?
&lt;p&gt;The entry is removed, because deletion follows target-state ownership, and &lt;code&gt;mount_each&lt;/code&gt; removes the component for &lt;code&gt;user:4&lt;/code&gt;. There is no explicit delete call.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;RateLimiter&lt;/code&gt;: one shared token bucket (v1.0.8)&lt;/h3&gt;
&lt;p&gt;An external API allows a fixed number of requests per second. Each call site used to pace itself with its own sleep loop, so the sources and targets that call one API had no shared view of that limit. &lt;code&gt;RateLimiter&lt;/code&gt; is now an engine primitive that implements a token bucket: tokens refill at a steady rate up to a fixed capacity, and each call takes a token or waits for one. Any component that acquires a token from the same &lt;code&gt;RateLimiter&lt;/code&gt; instance draws from the same budget, and concurrent callers are served FIFO (first in, first out), so none starve.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from cocoindex.resources.rate_limit import RateLimiter

limiter = RateLimiter(max_rows_per_second=20.0)  # burst_window_secs defaults to 1.0

async def fetch(item: Item) -&amp;gt; Data:
    await limiter.acquire()  # waits until a token is free
    return await call_external_api(item)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; Calls go out at about 20 per second. After an idle period, up to 20 calls (&lt;code&gt;max_rows_per_second&lt;/code&gt; × &lt;code&gt;burst_window_secs&lt;/code&gt;) can start at once before the rate settles. Set &lt;code&gt;burst_window_secs=0.0&lt;/code&gt; for strict spacing.&lt;/p&gt;
&lt;p&gt;With the retry-on-429 (HTTP &quot;too many requests&quot;) behavior from earlier cycles, pipelines now set their rate up front and keep retries for the requests that still get rejected.&lt;/p&gt;

Quick check: two connectors each create &lt;code&gt;RateLimiter(max_rows_per_second=10)&lt;/code&gt;. What is their combined rate?
&lt;p&gt;Up to 20 per second. The budget lives in the instance, so two instances are two independent budgets. To share one budget, pass the same instance to both, for example through a context key.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;Preview mode for update actions (v1.0.8)&lt;/h3&gt;
&lt;p&gt;Before you point a pipeline at a production store, you want to see what it would change. Update actions can now be previewed before they are applied. A run with preview enabled describes the adds, reprocesses, and deletes it &lt;em&gt;would&lt;/em&gt; perform, without writing to any target. Use it for dry-run validation and to audit changes before they reach a production store.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cocoindex update main.py --preview
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; The command prints &lt;code&gt;Preview: planned target actions&lt;/code&gt; and one line per action, or &lt;code&gt;No target actions planned.&lt;/code&gt; Nothing is written. In Python, &lt;code&gt;app.update(preview=True)&lt;/code&gt; returns the list of actions. Preview cannot be combined with &lt;code&gt;--live&lt;/code&gt; or &lt;code&gt;--reset&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Performance&lt;/h2&gt;
&lt;h3&gt;Batched target writes across components (v1.0.15)&lt;/h3&gt;
&lt;p&gt;Row-level writes to the same target from different components can now be coalesced into a single batched apply. The common shape is &lt;code&gt;mount_each(..., table_target)&lt;/code&gt;, where many child components each declare one row into the same target. The coalescing is keyed by the target &lt;em&gt;sink&lt;/em&gt; (the connector function that applies writes to the external system), so any components whose writes land on the same sink concurrently are batched together. Previously each component submitted its leaf actions directly to the sink after precommit, so the connector saw a stream of single-row calls even though its API already accepts a batch. In practice a 50-row ingest into LanceDB produced roughly 50 &lt;code&gt;merge_insert&lt;/code&gt; commits and 50 table versions instead of one (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/issues/2219&quot;&gt;&lt;strong&gt;#2219&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;An app-scoped batcher, keyed by the target sink, merges concurrent commits that hit the same sink before the connector&apos;s apply call (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2221&quot;&gt;&lt;strong&gt;#2221&lt;/strong&gt;&lt;/a&gt;). It reuses CocoIndex&apos;s existing &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/blob/main/rust/utils/src/batching.rs&quot;&gt;&lt;code&gt;Batcher&lt;/code&gt;&lt;/a&gt; primitive rather than a separate queue, so leaf-target batching shares the same path as the engine&apos;s other batched work and adds no debounce latency to a lone write. Batching preserves order, and each output maps back to its input. Container targets, which return per-action child handlers, stay on the direct apply path; the batched path handles leaf writes. Sink lifetime drives cleanup: a keeper owns the batcher one-to-one and drops its registry entry when the sink goes away, so a pipeline with an unbounded number of sink functions cannot leak batcher entries.&lt;/p&gt;
&lt;p&gt;For connectors with real per-operation cost, such as LanceDB and cloud warehouses, write cost depends on the number of write transactions (round-trips and commits) more than on row count. Coalescing N single-row applies into one batched apply turns N write transactions into one. For a store like LanceDB it also turns N table versions into one, which keeps version history and compaction manageable under heavy fan-out.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; The same 50-row ingest that made about 50 &lt;code&gt;merge_insert&lt;/code&gt; commits can land as one commit and one new table version, when the rows reach the sink together. You change no pipeline code.&lt;/p&gt;
&lt;h3&gt;Engine performance&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Prefetch fn-memos and user-states in one read transaction&lt;/strong&gt;: the engine now batches all LMDB reads for function memos and user states into a single read transaction per cycle, replacing N individual reads (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2076&quot;&gt;&lt;strong&gt;#2076&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Minimize serialization for UserStateCache&lt;/strong&gt;: reduces round-trip cost for state reads during hot-path execution (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2127&quot;&gt;&lt;strong&gt;#2127&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LMDB map auto-resize&lt;/strong&gt;: the state store now resizes the LMDB map (the maximum database size that LMDB reserves up front) when it fills, so operators no longer tune &lt;code&gt;LMDB_MAP_SIZE&lt;/code&gt; by hand (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2231&quot;&gt;&lt;strong&gt;#2231&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LMDB map size rounded to page size&lt;/strong&gt;: map sizes are now aligned to the OS page boundary, preventing allocation failures on some Linux kernels (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2109&quot;&gt;&lt;strong&gt;#2109&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Connectors&lt;/h2&gt;
&lt;p&gt;The table lists the connectors added or extended in this cycle. Details follow it.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Connector&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Release&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Snowflake&lt;/td&gt;
&lt;td&gt;Data warehouse target&lt;/td&gt;
&lt;td&gt;v1.0.15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BigQuery&lt;/td&gt;
&lt;td&gt;Data warehouse target&lt;/td&gt;
&lt;td&gt;v1.0.16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Azure Blob Storage&lt;/td&gt;
&lt;td&gt;Object store source&lt;/td&gt;
&lt;td&gt;v1.0.16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Valkey&lt;/td&gt;
&lt;td&gt;Vector store target&lt;/td&gt;
&lt;td&gt;v1.0.12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Qdrant sparse vectors&lt;/td&gt;
&lt;td&gt;Enhanced vector target&lt;/td&gt;
&lt;td&gt;v1.0.16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LanceDB vector + FTS indexes&lt;/td&gt;
&lt;td&gt;Enhanced vector target&lt;/td&gt;
&lt;td&gt;v1.0.11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;zvec FTS fields&lt;/td&gt;
&lt;td&gt;Enhanced target&lt;/td&gt;
&lt;td&gt;v1.0.14&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;Target: Snowflake (v1.0.15)&lt;/h3&gt;
&lt;p&gt;A native Snowflake target connector brings CocoIndex&apos;s declare-target-state model to the Snowflake cloud data warehouse. Snowflake targets take part in the same incremental reconciliation as all other CocoIndex targets: rows for deleted sources are removed automatically, and only changed rows are upserted.&lt;/p&gt;
&lt;h3&gt;Target: BigQuery (v1.0.16)&lt;/h3&gt;
&lt;p&gt;A Google BigQuery target connector was added in the same cycle as the Snowflake connector. Teams on Google Cloud can now write to their warehouse directly.&lt;/p&gt;
&lt;h3&gt;Source: Azure Blob Storage (v1.0.16)&lt;/h3&gt;
&lt;p&gt;An &lt;a href=&quot;https://cocoindex.io/docs/connectors/azure_blob/&quot;&gt;Azure Blob Storage&lt;/a&gt; source connector mirrors the S3 source API: &lt;code&gt;list_blobs()&lt;/code&gt;, &lt;code&gt;get_blob()&lt;/code&gt; and &lt;code&gt;read()&lt;/code&gt; over an async Azure &lt;code&gt;ContainerClient&lt;/code&gt;. Each update lists the container and reprocesses only the blobs that changed. Like the S3 source, it has no live mode: it does not watch the container for change events, as the OCI source does.&lt;/p&gt;
&lt;h3&gt;Target: Valkey vector store (v1.0.12)&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://valkey.io&quot;&gt;Valkey&lt;/a&gt;, the open-source Redis fork under Linux Foundation governance, gains a target connector with vector store support. Teams that run Valkey instead of Redis get a supported vector index target without a separate vector database.&lt;/p&gt;
&lt;h3&gt;Qdrant: native sparse vector support (v1.0.16)&lt;/h3&gt;
&lt;p&gt;The Qdrant connector gained native sparse vector support and eager point-ID validation: &lt;code&gt;declare_point&lt;/code&gt; rejects an ID that is not an unsigned 64-bit integer or a UUID before anything is written, instead of failing later in the server. Hybrid search pipelines combine dense (semantic) vectors with sparse vectors (BM25 or TF-IDF term weights), and need both in one store. The Qdrant target now holds both.&lt;/p&gt;
&lt;h3&gt;LanceDB: vector and FTS index support (v1.0.11)&lt;/h3&gt;
&lt;p&gt;LanceDB gained explicit vector and full-text search (FTS) index management. The &lt;code&gt;drop_index&lt;/code&gt; operation was added alongside a dependency bump to LanceDB 0.33.0 and PyArrow 23.0.0. Nullable schema-only row rewrites (a correctness bug that appeared on partial schema changes) were fixed in both the Python and Rust layers. In v1.0.15, LanceDB table maintenance was tied to LanceDB&apos;s own stats API, so compaction runs on actual table metrics rather than a fixed interval.&lt;/p&gt;
&lt;h3&gt;zvec: FTS field support (v1.0.14)&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;zvec&lt;/code&gt; target connector gained full-text search field support, so a pipeline can write both vector and FTS fields to zvec in a single target export.&lt;/p&gt;
&lt;h3&gt;OCI: skip startup scan on unchanged logic (v1.0.11)&lt;/h3&gt;
&lt;p&gt;The OCI Object Storage source now detects when pipeline logic is unchanged since the last run and skips the full-bucket startup scan, going directly to live-stream event processing. For large buckets, this can reduce cold-start time from minutes to seconds (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2116&quot;&gt;&lt;strong&gt;#2116&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;Local file system: periodic rescan in live mode (v1.0.15)&lt;/h3&gt;
&lt;p&gt;The local file system source in live mode now periodically rescans and recreates the watcher if it becomes stale. OS file-system watchers (&lt;code&gt;inotify&lt;/code&gt;, &lt;code&gt;kqueue&lt;/code&gt;) have known limitations under high churn, on network mounts, and with certain editors. The periodic rescan catches events the watcher missed.&lt;/p&gt;
&lt;h2&gt;Debugging and developer experience&lt;/h2&gt;
&lt;h3&gt;&lt;code&gt;cocoindex show&lt;/code&gt;: an inspection tool for debugging (v1.0.12)&lt;/h3&gt;
&lt;p&gt;When a pipeline misbehaves in production, you need to see its state without querying the LMDB or Postgres state store directly. &lt;code&gt;cocoindex show&lt;/code&gt; was upgraded from a basic state dump into an inspection tool for pipeline debugging. It prints structured, human-readable output of pipeline state, component configuration, and target schema.&lt;/p&gt;
&lt;h3&gt;Python error messages&lt;/h3&gt;
&lt;p&gt;Runtime errors crossing the Rust-to-Python boundary now use &lt;code&gt;Display&lt;/code&gt; (human-readable) rather than &lt;code&gt;Debug&lt;/code&gt; (Rust internals) formatting, so the messages in Python stack traces describe the problem instead of Rust data structures.&lt;/p&gt;
&lt;h3&gt;Multiple GPU and fractional GPU allocation (v1.0.15)&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;GPUPool&lt;/code&gt; was added to support multiple GPUs and fractional GPU allocations within a pipeline. Embedding pipelines on multi-GPU machines can spread work across the available GPUs without splitting the pipeline by hand.&lt;/p&gt;
&lt;h2&gt;Examples&lt;/h2&gt;
&lt;p&gt;v1.0.13 added 17 new &lt;a href=&quot;https://cocoindex.io/docs/examples/&quot;&gt;example walkthroughs&lt;/a&gt; (10 full and 7 variants) across CocoIndex use cases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;/blogs/meeting-notes-graph/&quot;&gt;Meeting Notes → Knowledge Graph&lt;/a&gt;&lt;/strong&gt;, with &lt;a href=&quot;https://cocoindex.io/docs/examples/meeting-notes-to-knowledge-graph/&quot;&gt;Neo4j and FalkorDB variants&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;/blogs/csv-to-kafka-live/&quot;&gt;CSV → Kafka&lt;/a&gt;&lt;/strong&gt; &lt;a href=&quot;https://cocoindex.io/docs/examples/csv-to-kafka/&quot;&gt;streaming pipeline&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;/blogs/pdf-elements/&quot;&gt;Semantic Search over PDFs&lt;/a&gt;&lt;/strong&gt; with &lt;a href=&quot;https://cocoindex.io/docs/examples/pdf-embedding/&quot;&gt;mixed embedding models&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;/blogs/live-image-search/&quot;&gt;Search Images by Text&lt;/a&gt;&lt;/strong&gt;, a &lt;a href=&quot;https://cocoindex.io/docs/examples/image-search/&quot;&gt;multimodal CLIP walkthrough&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;/blogs/face-detection/&quot;&gt;Face Recognition&lt;/a&gt;&lt;/strong&gt;, &lt;a href=&quot;https://cocoindex.io/docs/examples/face-recognition/&quot;&gt;ported from v0 to v1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;/blogs/knowledge-graph-for-docs/&quot;&gt;Docs to Knowledge&lt;/a&gt;&lt;/strong&gt; &lt;a href=&quot;https://cocoindex.io/docs/examples/docs-to-knowledge-graph/&quot;&gt;graph construction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each walkthrough uses consistent headings, copyable commands, and explicit prerequisites, so an AI coding agent can follow it step by step.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;Fixes&lt;/h2&gt;
&lt;h3&gt;Engine fixes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;coco.fn&lt;/code&gt; callable outside a component context&lt;/strong&gt;: &lt;code&gt;coco.fn&lt;/code&gt;-decorated functions can now be called directly in scripts and tests without being inside a mounted pipeline component (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2101&quot;&gt;&lt;strong&gt;#2101&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;!&lt;/code&gt;-prefixed negation in &lt;code&gt;excluded_patterns&lt;/code&gt;&lt;/strong&gt;: source file filters now support &lt;code&gt;!pattern&lt;/code&gt; to un-exclude a path that matched an earlier pattern, following the &lt;code&gt;.gitignore&lt;/code&gt;-style rule ordering (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1901&quot;&gt;&lt;strong&gt;#1901&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Retry transient LiteLLM embedding errors&lt;/strong&gt;: transient failures (network blips, upstream 5xx) during embedding calls are retried automatically (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2090&quot;&gt;&lt;strong&gt;#2090&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reject rows with missing or null primary keys&lt;/strong&gt;: the engine now fails fast rather than silently writing corrupt rows (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2239&quot;&gt;&lt;strong&gt;#2239&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Correctness fixes&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Issue&lt;/th&gt;
&lt;th&gt;Impact&lt;/th&gt;
&lt;th&gt;Release&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;S3 ETag encoded to bytes for content fingerprint&lt;/td&gt;
&lt;td&gt;Prevents false cache invalidation on binary ETags&lt;/td&gt;
&lt;td&gt;v1.0.10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;StableKey::Bytes&lt;/code&gt; serde round-trip via msgpack&lt;/td&gt;
&lt;td&gt;Correct key serialization for binary primary keys&lt;/td&gt;
&lt;td&gt;v1.0.14&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Postgres: preserve data and NOT NULL on column type evolution&lt;/td&gt;
&lt;td&gt;Schema evolution no longer drops non-null constraints&lt;/td&gt;
&lt;td&gt;v1.0.15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Postgres: schema-qualify DROP INDEX for vector indexes&lt;/td&gt;
&lt;td&gt;Avoids dropping wrong-schema indexes in multi-schema deployments&lt;/td&gt;
&lt;td&gt;v1.0.15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Logic deps propagated across mount boundary&lt;/td&gt;
&lt;td&gt;Dependency tracking correct for nested mounted components&lt;/td&gt;
&lt;td&gt;v1.0.12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Orphaned child-existence rows when Directory→Component&lt;/td&gt;
&lt;td&gt;Prevents stale rows when a directory node becomes a component node&lt;/td&gt;
&lt;td&gt;v1.0.15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LanceDB: escape single quotes in delete filter predicates&lt;/td&gt;
&lt;td&gt;Prevents filter injection on document paths containing apostrophes&lt;/td&gt;
&lt;td&gt;v1.0.11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LanceDB: nullable schema-only row rewrites&lt;/td&gt;
&lt;td&gt;Correct behavior on partial schema updates&lt;/td&gt;
&lt;td&gt;v1.0.15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Idle batchers cleared to avoid stale accumulation&lt;/td&gt;
&lt;td&gt;Prevents write amplification on quiet pipelines&lt;/td&gt;
&lt;td&gt;v1.0.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PEP 695 type aliases in numpy 2.5 NDArray&lt;/td&gt;
&lt;td&gt;Fixes &lt;code&gt;analyze_type_info&lt;/code&gt; crash on numpy 2.5+&lt;/td&gt;
&lt;td&gt;v1.0.13&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;What to try next&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Keep a value between runs.&lt;/strong&gt; Call &lt;code&gt;coco.use_state(&quot;key&quot;, initial)&lt;/code&gt; in a component&apos;s processor and assign to &lt;code&gt;.value&lt;/code&gt;, as in &lt;a href=&quot;#cocouse_state-persistent-per-component-state-v108&quot;&gt;the counter example&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Put every caller of one API under one budget.&lt;/strong&gt; Create one &lt;code&gt;RateLimiter(max_rows_per_second=...)&lt;/code&gt; and share the instance, as in &lt;a href=&quot;#ratelimiter-one-shared-token-bucket-v108&quot;&gt;the rate limiter example&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;See what an update would change.&lt;/strong&gt; Run &lt;code&gt;cocoindex update main.py --preview&lt;/code&gt; before you point the pipeline at a production store.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Inspect a running pipeline.&lt;/strong&gt; Run &lt;code&gt;cocoindex show&lt;/code&gt; to see pipeline state, component configuration, and target schema.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the complete list of changes, see the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/releases&quot;&gt;GitHub releases&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Thanks to the community&lt;/h2&gt;
&lt;p&gt;Thanks to everyone who contributed this cycle, core maintainers and community, including 12 first-time contributors.&lt;/p&gt;
&lt;h3&gt;@georgeh0&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/georgeh0&quot;&gt;@georgeh0&lt;/a&gt; for most of this cycle&apos;s engine work: &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2088&quot;&gt;&lt;code&gt;LiveMap&lt;/code&gt;&lt;/a&gt;, the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2057&quot;&gt;token-bucket &lt;code&gt;RateLimiter&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2091&quot;&gt;&lt;code&gt;LiveComponent&lt;/code&gt; support inside &lt;code&gt;mount_each&lt;/code&gt;&lt;/a&gt;, and the shared-parse &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2253&quot;&gt;code infrastructure&lt;/a&gt; behind cocoindex-code.&lt;/p&gt;
&lt;h3&gt;@badmonster0&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/badmonster0&quot;&gt;@badmonster0&lt;/a&gt; for the documentation updates.&lt;/p&gt;
&lt;h3&gt;@hakuuww&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/hakuuww&quot;&gt;@hakuuww&lt;/a&gt; for building &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2034&quot;&gt;&lt;code&gt;coco.use_state()&lt;/code&gt;&lt;/a&gt;, persistent per-component state, then following it with engine-side performance work: &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2076&quot;&gt;prefetching fn-memos and user states in one read transaction&lt;/a&gt; and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2127&quot;&gt;minimizing UserStateCache serialization&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@sdhilip200&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/sdhilip200&quot;&gt;@sdhilip200&lt;/a&gt; for the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2046&quot;&gt;Snowflake&lt;/a&gt; and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2250&quot;&gt;BigQuery&lt;/a&gt; targets, the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2252&quot;&gt;Azure Blob source&lt;/a&gt;, and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2045&quot;&gt;Mermaid diagram rendering in the docs&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@Sujit-1509&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/Sujit-1509&quot;&gt;@Sujit-1509&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2115&quot;&gt;LanceDB vector and FTS indexing&lt;/a&gt;, plus correctness fixes: &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2228&quot;&gt;preserving data and NOT NULL constraints during Postgres column-type evolution&lt;/a&gt; and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2212&quot;&gt;reconciling orphaned child-existence rows&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@prrao87&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/prrao87&quot;&gt;@prrao87&lt;/a&gt; for LanceDB work: &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2245&quot;&gt;tying table maintenance to LanceDB&apos;s own stats&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2132&quot;&gt;implementing &lt;code&gt;drop_index&lt;/code&gt;&lt;/a&gt;, and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2235&quot;&gt;fixing nullable schema-only row rewrites&lt;/a&gt;, plus &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2221&quot;&gt;batching leaf target actions&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@lichuang&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/lichuang&quot;&gt;@lichuang&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2224&quot;&gt;&lt;code&gt;GPUPool&lt;/code&gt;&lt;/a&gt;, supporting multiple and fractional GPU allocations, and for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2210&quot;&gt;adding &lt;code&gt;type_hint&lt;/code&gt; to &lt;code&gt;use_state&lt;/code&gt;&lt;/a&gt; for typed state deserialization.&lt;/p&gt;
&lt;h3&gt;@Haleshot&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/Haleshot&quot;&gt;@Haleshot&lt;/a&gt; for the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2092&quot;&gt;initial &lt;code&gt;zvec&lt;/code&gt; target integration&lt;/a&gt; and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2215&quot;&gt;adding FTS field support to it&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@nuthalapativarun&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/nuthalapativarun&quot;&gt;@nuthalapativarun&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2052&quot;&gt;switching runtime errors crossing into Python to &lt;code&gt;Display&lt;/code&gt; formatting&lt;/a&gt;, adding &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1952&quot;&gt;Qdrant&lt;/a&gt; and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2083&quot;&gt;local file system&lt;/a&gt; connector unit tests, and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2081&quot;&gt;fixing broken documentation links&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@daric93&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/daric93&quot;&gt;@daric93&lt;/a&gt; for the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2027&quot;&gt;Valkey vector store target connector&lt;/a&gt;, a vector index target for teams that run Valkey.&lt;/p&gt;
&lt;h3&gt;@prithvi-moonshot&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/prithvi-moonshot&quot;&gt;@prithvi-moonshot&lt;/a&gt; for upgrading &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1920&quot;&gt;&lt;code&gt;cocoindex show&lt;/code&gt; into a full-fledged inspection tool for debugging&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@MrAnayDongre&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/MrAnayDongre&quot;&gt;@MrAnayDongre&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1945&quot;&gt;preview mode for update actions&lt;/a&gt;, letting a run describe the adds, reprocesses, and deletes it would perform before touching a target.&lt;/p&gt;
&lt;h3&gt;@pyjuan91&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/pyjuan91&quot;&gt;@pyjuan91&lt;/a&gt; for making the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2116&quot;&gt;OCI source skip its full startup scan when pipeline logic is unchanged&lt;/a&gt;, cutting cold-start time on large buckets.&lt;/p&gt;
&lt;h3&gt;@tomz-alt&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/tomz-alt&quot;&gt;@tomz-alt&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2242&quot;&gt;native sparse vector support and eager point-ID validation in the Qdrant connector&lt;/a&gt;, which lets the Qdrant target serve hybrid retrieval.&lt;/p&gt;
&lt;h3&gt;@jordigilh&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/jordigilh&quot;&gt;@jordigilh&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2232&quot;&gt;adding periodic rescan and watcher recreation to the local file system source in live mode&lt;/a&gt;, a safety net for events an OS watcher misses.&lt;/p&gt;
&lt;h3&gt;@MaxRong&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/MaxRong&quot;&gt;@MaxRong&lt;/a&gt; for making the engine &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2239&quot;&gt;reject rows with missing or null primary keys&lt;/a&gt; instead of silently writing corrupt rows.&lt;/p&gt;
&lt;h3&gt;@slliland&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/slliland&quot;&gt;@slliland&lt;/a&gt; for making the state store &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2231&quot;&gt;automatically resize the LMDB map when it fills&lt;/a&gt;, removing the manual &lt;code&gt;LMDB_MAP_SIZE&lt;/code&gt; tuning operators used to need.&lt;/p&gt;
&lt;h3&gt;@SuperMarioYL&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/SuperMarioYL&quot;&gt;@SuperMarioYL&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1901&quot;&gt;&lt;code&gt;!&lt;/code&gt;-prefixed negation in &lt;code&gt;excluded_patterns&lt;/code&gt;&lt;/a&gt;, so a path matched by an earlier rule can be explicitly un-excluded.&lt;/p&gt;
&lt;h3&gt;@davidmyriel&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/davidmyriel&quot;&gt;@davidmyriel&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2063&quot;&gt;documenting Tigris alongside MinIO as a supported S3-compatible service&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@dashitongzhi&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/dashitongzhi&quot;&gt;@dashitongzhi&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2009&quot;&gt;improving the docs CI with proper triggers and build verification&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>connectors</category><category>performance</category><author>George He</author></item><item><title>Codebase Indexing for AI Agents with CocoIndex</title><link>https://cocoindex.io/blogs/index-codebase-v1/</link><guid isPermaLink="true">https://cocoindex.io/blogs/index-codebase-v1/</guid><description>Index a codebase for RAG and AI coding agents with CocoIndex V1 and Tree-sitter: language-aware chunking, embedding, and a live vector index in async Python.</description><pubDate>Wed, 10 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Build a live semantic index over a codebase with &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex V1&lt;/a&gt;. Point it at a repo, and you get a vector index you can search in natural language (&quot;where do we embed chunks?&quot;). In live mode the index follows your edits, which gives a coding agent current context. The indexing pipeline is about 120 lines of async Python (200 with the query demo), with Tree-sitter chunking built in.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://cocoindex.io/blogs/incremental-processing&quot;&gt;Incremental processing&lt;/a&gt;, change tracking and managed targets run in a Rust engine. With a source that watches for changes, like the local filesystem in &lt;code&gt;live&lt;/code&gt; mode, the index tracks your edits as they happen: save a file, and only the chunks whose text changed are embedded again; their rows are inserted and the old ones deleted.&lt;/p&gt;
&lt;h2&gt;What the index is for&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Code context for agents: semantic context for Claude, Codex, OpenCode, Factory.&lt;/li&gt;
&lt;li&gt;Code search: natural-language and semantic search over your repo.&lt;/li&gt;
&lt;li&gt;Review &amp;amp; refactor agents: context for code review, security analysis, and large-scale refactoring.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Why CocoIndex for codebase indexing&lt;/h2&gt;
&lt;p&gt;Code needs structure-aware chunks, and it changes all the time:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Chunks follow code structure (functions, classes, blocks) instead of arbitrary line windows. Tree-sitter grammars for the common languages are built into the splitter.&lt;/li&gt;
&lt;li&gt;Most commits touch a few files. CocoIndex re-embeds only the chunks that changed, and with &lt;code&gt;live=True&lt;/code&gt; plus &lt;code&gt;cocoindex update -L&lt;/code&gt; it keeps watching and applies each edit as it happens.&lt;/li&gt;
&lt;li&gt;The engine is Rust. The &lt;a href=&quot;#run-the-pipeline&quot;&gt;run below&lt;/a&gt; indexed 622 files of the CocoIndex repo in 43 seconds from an empty table; after that, a save re-processes one file.&lt;/li&gt;
&lt;li&gt;The pipeline is ordinary &lt;code&gt;async&lt;/code&gt; Python and your own types. You choose the embedding model, the chunking and the vector database.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;Overview&lt;/h2&gt;
&lt;p&gt;The steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Read code files from a local directory.&lt;/li&gt;
&lt;li&gt;Split each file into syntax-aware chunks with Tree-sitter, then embed every chunk.&lt;/li&gt;
&lt;li&gt;Store the chunks and their embeddings in Postgres (as &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;&lt;strong&gt;target states&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;With CocoIndex, you &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;declare the transformation logic&lt;/a&gt; in Python: the target state is a function of the source state, and you write no update logic.&lt;/p&gt;
&lt;p&gt;When your codebase changes, or your processing logic changes (a different embedding model, a new chunk size), only the difference is reprocessed. The &lt;a href=&quot;#incremental-updates&quot;&gt;Incremental updates&lt;/a&gt; section shows what each kind of change recomputes.&lt;/p&gt;
&lt;h2&gt;Setup&lt;/h2&gt;
&lt;p&gt;In this example we store the indexed rows in Postgres with the &lt;a href=&quot;https://github.com/pgvector/pgvector&quot;&gt;pgvector&lt;/a&gt; extension. Your metadata and the vector search index both live there. CocoIndex also writes to other &lt;a href=&quot;https://cocoindex.io/docs/connectors/&quot;&gt;targets&lt;/a&gt;.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Get the example and start Postgres. If you already run Postgres with pgvector, skip the &lt;code&gt;docker compose&lt;/code&gt; line.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git clone https://github.com/cocoindex-io/cocoindex.git
cd cocoindex
docker compose -f dev/postgres.yaml up -d
cd examples/code_embedding
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Copy the environment file. It sets &lt;code&gt;POSTGRES_URL&lt;/code&gt; for the target table and &lt;code&gt;COCOINDEX_DB&lt;/code&gt;, the local file where CocoIndex keeps its own state. The &lt;code&gt;cocoindex&lt;/code&gt; CLI loads &lt;code&gt;.env&lt;/code&gt; from the current directory.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cp .env.example .env
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install CocoIndex and the dependencies.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pip install -U &quot;cocoindex[postgres,sentence_transformers]&quot; asyncpg pgvector numpy python-dotenv
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Define the App&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/app/&quot;&gt;Apps&lt;/a&gt; are the top-level runnable unit in CocoIndex. An app names your pipeline and binds a main function with its parameters.&lt;/p&gt;
&lt;h3&gt;Define the data and shared resources&lt;/h3&gt;
&lt;p&gt;This block sets up two things the rest of the code builds on. &lt;code&gt;CodeEmbedding&lt;/code&gt; defines one row of the output table: each chunk of code becomes one row, with its text, location, and embedding vector. &lt;code&gt;coco_lifespan&lt;/code&gt; provides the &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/context/&quot;&gt;shared resources&lt;/a&gt; every step needs, the Postgres connection pool and the embedding model, built once at startup instead of per file.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import os
import pathlib
from dataclasses import dataclass
from typing import AsyncIterator, Annotated

import asyncpg
from numpy.typing import NDArray

import cocoindex as coco
from cocoindex.connectors import localfs, postgres
from cocoindex.ops.text import RecursiveSplitter, detect_code_language
from cocoindex.ops.sentence_transformers import SentenceTransformerEmbedder
from cocoindex.resources.chunk import Chunk
from cocoindex.resources.file import FileLike, PatternFilePathMatcher
from cocoindex.resources.id import IdGenerator

DATABASE_URL = os.getenv(&quot;POSTGRES_URL&quot;, &quot;postgres://cocoindex:cocoindex@localhost/cocoindex&quot;)
TABLE_NAME = &quot;code_embeddings&quot;
PG_SCHEMA_NAME = &quot;coco_examples&quot;
EMBED_MODEL = &quot;sentence-transformers/all-MiniLM-L6-v2&quot;

PG_DB = coco.ContextKey[asyncpg.Pool](&quot;code_embedding_db&quot;)
EMBEDDER = coco.ContextKey[SentenceTransformerEmbedder](&quot;embedder&quot;, detect_change=True)

_splitter = RecursiveSplitter()

@dataclass
class CodeEmbedding:
    id: int
    filename: str
    code: str
    embedding: Annotated[NDArray, EMBEDDER]
    start_line: int
    end_line: int

@coco.lifespan
async def coco_lifespan(builder: coco.EnvironmentBuilder) -&amp;gt; AsyncIterator[None]:
    async with asyncpg.create_pool(DATABASE_URL) as pool:
        builder.provide(PG_DB, pool)
        builder.provide(EMBEDDER, SentenceTransformerEmbedder(EMBED_MODEL))
        yield
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Define file processing&lt;/h3&gt;
&lt;p&gt;With the row schema and shared resources in place, we can write the per-file work: turning a file into rows.&lt;/p&gt;
&lt;h4&gt;Process file&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def process_file(
    file: FileLike,
    table: postgres.TableTarget[CodeEmbedding],
) -&amp;gt; None:
    text = await file.read_text()
    language = detect_code_language(filename=str(file.file_path.path.name))
    chunks = _splitter.split(
        text,
        chunk_size=1000,
        min_chunk_size=300,
        chunk_overlap=300,
        language=language,
    )
    id_gen = IdGenerator()
    await coco.map(process_chunk, chunks, file.file_path.path, id_gen, table)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;process_file&lt;/code&gt; runs once per file. It reads the file, detects the language so Tree-sitter can parse it, &lt;a href=&quot;https://cocoindex.io/docs/ops/text/&quot;&gt;splits the code&lt;/a&gt; along the syntax tree, and maps each chunk to &lt;code&gt;process_chunk&lt;/code&gt;. &lt;a href=&quot;https://cocoindex.io/blogs/how-tree-sitter-works&quot;&gt;How Tree-sitter works&lt;/a&gt; explains how the splitter walks that tree and which chunks change when you edit a file.&lt;/p&gt;
&lt;p&gt;The splitter places chunk boundaries between syntax nodes (definitions, statements, blocks) where it can, so a chunk usually holds whole functions or statements rather than an arbitrary window of lines. A definition longer than &lt;code&gt;chunk_size&lt;/code&gt; (in bytes) is split at its inner blocks. All major languages are supported (Python, Rust, JavaScript, TypeScript, Java, C++, and more); unknown file types fall back to plain text.&lt;/p&gt;
&lt;p&gt;Note that &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/&quot;&gt;&lt;code&gt;@coco.fn&lt;/code&gt;&lt;/a&gt; with &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/memoization_keys/&quot;&gt;&lt;code&gt;memo=True&lt;/code&gt;&lt;/a&gt; is what makes this incremental: if a file&apos;s content and this function&apos;s code are both unchanged, the whole file is skipped on the next run. &lt;code&gt;coco.map&lt;/code&gt; fans out to one &lt;code&gt;process_chunk&lt;/code&gt; call per chunk.&lt;/p&gt;
&lt;p&gt;Here is what chunking produces for one file the example indexes, &lt;code&gt;python/cocoindex/resources/id.py&lt;/code&gt; from the CocoIndex repo (225 lines), with the settings above:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Lines&lt;/th&gt;
&lt;th&gt;Chunk holds&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1–25&lt;/td&gt;
&lt;td&gt;module docstring, imports&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;18–31&lt;/td&gt;
&lt;td&gt;imports, start of &lt;code&gt;generate_id()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;32–57&lt;/td&gt;
&lt;td&gt;rest of &lt;code&gt;generate_id()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;60–86&lt;/td&gt;
&lt;td&gt;&lt;code&gt;generate_uuid()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;89–104&lt;/td&gt;
&lt;td&gt;&lt;code&gt;IdGenerator&lt;/code&gt; docstring&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;101–124&lt;/td&gt;
&lt;td&gt;end of the docstring, &lt;code&gt;IdGenerator.__init__()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;126–149&lt;/td&gt;
&lt;td&gt;&lt;code&gt;IdGenerator.next_id()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;152–168&lt;/td&gt;
&lt;td&gt;&lt;code&gt;UuidGenerator&lt;/code&gt; docstring&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;165–188&lt;/td&gt;
&lt;td&gt;end of the docstring, &lt;code&gt;UuidGenerator.__init__()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;190–213&lt;/td&gt;
&lt;td&gt;&lt;code&gt;UuidGenerator.next_uuid()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;216–225&lt;/td&gt;
&lt;td&gt;&lt;code&gt;_generate_next_id()&lt;/code&gt;, &lt;code&gt;_generate_next_uuid()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The long &lt;code&gt;generate_id()&lt;/code&gt; is split between its signature and the rest of the function. Neighboring chunks overlap by up to &lt;code&gt;chunk_overlap=300&lt;/code&gt; bytes, so text near a boundary appears in both: lines 101–104 of the &lt;code&gt;IdGenerator&lt;/code&gt; docstring are in the chunks at 89–104 and 101–124.&lt;/p&gt;
&lt;h4&gt;Process chunk&lt;/h4&gt;
&lt;p&gt;Next, we embed the chunk with the shared embedder and declare the target row.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn
async def process_chunk(
    chunk: Chunk,
    filename: pathlib.PurePath,
    id_gen: IdGenerator,
    table: postgres.TableTarget[CodeEmbedding],
) -&amp;gt; None:
    embedding = await coco.use_context(EMBEDDER).embed(chunk.text)
    table.declare_row(
        row=CodeEmbedding(
            id=await id_gen.next_id(chunk.text),
            filename=str(filename),
            code=chunk.text,
            embedding=embedding,
            start_line=chunk.start.line,
            end_line=chunk.end.line,
        ),
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We use &lt;a href=&quot;https://cocoindex.io/docs/ops/sentence_transformers/&quot;&gt;&lt;code&gt;SentenceTransformerEmbedder&lt;/code&gt;&lt;/a&gt; with &lt;code&gt;all-MiniLM-L6-v2&lt;/code&gt;; there are 12k+ sentence-transformer models on &lt;a href=&quot;https://huggingface.co/models?other=sentence-transformers&quot;&gt;Hugging Face&lt;/a&gt;, so swap in whichever you prefer. Note &lt;code&gt;chunk.start.line&lt;/code&gt; and &lt;code&gt;chunk.end.line&lt;/code&gt;: V1 carries line numbers through, so search results point straight at the lines that matched.&lt;/p&gt;
&lt;h3&gt;Define the main function&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;app_main&lt;/code&gt; wires the source to the target. It mounts the Postgres table (with a &lt;a href=&quot;https://cocoindex.io/docs/common_resources/vector_schema/&quot;&gt;vector index&lt;/a&gt;), walks the codebase, and mounts one &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/&quot;&gt;processing component&lt;/a&gt; per file.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn
async def app_main(sourcedir: pathlib.Path) -&amp;gt; None:
    target_table = await postgres.mount_table_target(
        PG_DB,
        table_name=TABLE_NAME,
        table_schema=await postgres.TableSchema.from_class(
            CodeEmbedding, primary_key=[&quot;id&quot;],
        ),
        pg_schema_name=PG_SCHEMA_NAME,
    )
    target_table.declare_vector_index(column=&quot;embedding&quot;)

    files = localfs.walk_dir(
        sourcedir,
        recursive=True,
        path_matcher=PatternFilePathMatcher(
            included_patterns=[&quot;**/*.py&quot;, &quot;**/*.rs&quot;, &quot;**/*.toml&quot;, &quot;**/*.md&quot;, &quot;**/*.mdx&quot;],
            excluded_patterns=[&quot;**/.*&quot;, &quot;**/target&quot;, &quot;**/node_modules&quot;],
        ),
        live=True,  # watch for changes; pass -L to `cocoindex update` to run live
    )
    await coco.mount_each(process_file, files.items(), target_table)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We walk the codebase from &lt;code&gt;sourcedir&lt;/code&gt; (point this at the repository you want to index). We index files with the extensions &lt;code&gt;.py&lt;/code&gt;, &lt;code&gt;.rs&lt;/code&gt;, &lt;code&gt;.toml&lt;/code&gt;, &lt;code&gt;.md&lt;/code&gt;, &lt;code&gt;.mdx&lt;/code&gt;, and skip dot-directories, &lt;code&gt;target&lt;/code&gt;, and &lt;code&gt;node_modules&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;mount_table_target&lt;/code&gt; creates and manages the Postgres table (&lt;code&gt;coco_examples.code_embeddings&lt;/code&gt;) for you: the schema, the pgvector index, and inserts, updates and deletes by primary key, including deletion of rows whose file is gone. &lt;code&gt;live=True&lt;/code&gt; makes the &lt;a href=&quot;https://cocoindex.io/docs/connectors/localfs/&quot;&gt;filesystem source&lt;/a&gt; &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/live_mode/&quot;&gt;watch for changes&lt;/a&gt;, and &lt;code&gt;mount_each&lt;/code&gt; runs one component per file so the engine can track and update them independently.&lt;/p&gt;
&lt;h3&gt;Create the App&lt;/h3&gt;
&lt;p&gt;Bind &lt;code&gt;app_main&lt;/code&gt; into a &lt;code&gt;coco.App&lt;/code&gt; and point it at the codebase root.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;app = coco.App(
    coco.AppConfig(name=&quot;CodeEmbeddingV1&quot;),
    app_main,
    sourcedir=pathlib.Path(__file__).parent / &quot;..&quot; / &quot;..&quot;,  # index from repo root
)
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Run the pipeline&lt;/h2&gt;
&lt;p&gt;Run the &lt;a href=&quot;https://cocoindex.io/docs/cli/&quot;&gt;&lt;code&gt;cocoindex&lt;/code&gt; CLI&lt;/a&gt; to set up and update the index. Choose catch-up (scan, sync, exit) or live (catch up, then keep watching):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Catch-up run
cocoindex update main

# Live run: keep watching for file changes
cocoindex update -L main
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The CLI prints a per-function summary of the update:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;✅ app_main: 1 total | 1 added
✅ declare_target_state_with_child: 1 total | 1 added
✅ _MountEachLiveComponent.process: 1 total | 1 added
✅ process_file: 622 total | 622 added
⏳ Elapsed: 43.4s
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Query the index&lt;/h2&gt;
&lt;p&gt;We match user text against the index with a plain SQL query, using the same embedding model as the indexing flow so queries and chunks land in the same vector space.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import asyncio
import sys

from dotenv import load_dotenv
from pgvector.asyncpg import register_vector

TOP_K = 5

async def query_once(pool, embedder, query: str, *, top_k: int = TOP_K) -&amp;gt; None:
    query_vec = await embedder.embed(query)
    async with pool.acquire() as conn:
        rows = await conn.fetch(
            f&quot;&quot;&quot;
            SELECT filename, code, embedding &amp;lt;=&amp;gt; $1 AS distance, start_line, end_line
            FROM &quot;{PG_SCHEMA_NAME}&quot;.&quot;{TABLE_NAME}&quot;
            ORDER BY distance ASC
            LIMIT $2
            &quot;&quot;&quot;,
            query_vec, top_k,
        )
    for r in rows:
        score = 1.0 - float(r[&quot;distance&quot;])
        print(f&quot;[{score:.3f}] {r[&apos;filename&apos;]} (L{r[&apos;start_line&apos;]}-L{r[&apos;end_line&apos;]})&quot;)
        print(f&quot;    {r[&apos;code&apos;]}&quot;)
        print(&quot;---&quot;)

async def query(text: str) -&amp;gt; None:
    embedder = SentenceTransformerEmbedder(EMBED_MODEL)
    async with asyncpg.create_pool(DATABASE_URL, init=register_vector) as pool:
        await query_once(pool, embedder, text)

if __name__ == &quot;__main__&quot;:
    load_dotenv()
    asyncio.run(query(&quot; &quot;.join(sys.argv[1:])))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;embedder.embed&lt;/code&gt; returns a NumPy array. &lt;code&gt;init=register_vector&lt;/code&gt; registers pgvector&apos;s type with each connection in the pool, so asyncpg can send that array as a &lt;code&gt;vector&lt;/code&gt; parameter; without it, the query fails. The &lt;code&gt;&amp;lt;=&amp;gt;&lt;/code&gt; operator is pgvector&apos;s cosine distance. We turn it into a similarity score and print the filename, the matched line range, and the chunk. Run it against your index:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;python main.py &quot;where do we embed chunks&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It prints the top 5 chunks, each with its similarity score, file, and line range. Chunks are cut to their first lines here (&lt;code&gt;…&lt;/code&gt;):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[0.527] rust/ops_text/src/split/by_separators.rs (L72-L94)
            let bytes = text.as_bytes();

        // Collect raw chunks (byte ranges)
        struct RawChunk {
            start: usize,
            end: usize,
    …
---
[0.459] rust/ops_text/src/split/by_separators.rs (L116-L138)
            let mut positions: Vec&amp;lt;Position&amp;gt; = raw_chunks
            .iter()
            .flat_map(|c| vec![Position::new(c.start), Position::new(c.end)])
            .collect();

        set_output_positions(text, positions.iter_mut());
    …
---
[0.448] rust/ops_text/src/split/recursive.rs (L560-L578)
        fn split_root_chunk(&amp;amp;self, kind: ChunkKind&amp;lt;&apos;t&amp;gt;) -&amp;gt; Vec&amp;lt;ChunkOutput&amp;gt; {
        let mut atom_collector = AtomChunksCollector {
            full_text: self.full_text,
            min_level: 0,
            curr_level: 0,
            atom_chunks: Vec::new(),
    …
---
[0.447] rust/sdk/cocoindex/tests/code.rs (L300-L314)
    #[test]
fn code_ast_split_chunk_positions_are_accurate() {
    // Three-line Python source; verify start/end positions of first chunk.
    let src = &quot;a = 1\nb = 2\nc = 3\n&quot;;
    let ast = CodeAst::new(src, &quot;python&quot;).unwrap();
    let chunks = ast.split(200, None, None).unwrap(); // one big chunk
    …
---
[0.444] rust/sdk/cocoindex/src/ops/code.rs (L315-L341)
            let config = RecursiveChunkConfig {
            chunk_size,
            min_chunk_size,
            chunk_overlap,
        };
        let raw = chunker.split(&amp;amp;self.source, config);
    …
---
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Incremental updates&lt;/h2&gt;
&lt;p&gt;You change the code or the pipeline, and CocoIndex works out what to embed, insert, update and delete. Two mechanisms decide it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;What to recompute.&lt;/strong&gt; &lt;code&gt;process_file&lt;/code&gt; is &lt;code&gt;@coco.fn(memo=True)&lt;/code&gt;: a file is skipped when its content and the code of &lt;code&gt;process_file&lt;/code&gt; (and the functions it calls) are unchanged. &lt;code&gt;SentenceTransformerEmbedder.embed&lt;/code&gt; is memoized too, so a chunk whose text this file embedded on the previous run gets its vector without a model call.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What to write.&lt;/strong&gt; Each row&apos;s id comes from &lt;code&gt;IdGenerator.next_id(chunk.text)&lt;/code&gt;, so the same chunk text keeps the same id from run to run. &lt;code&gt;mount_table_target&lt;/code&gt; compares the rows declared in this run with the rows already in Postgres: a new id is inserted, a missing id is deleted, and a row whose columns changed is updated.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Pick an edit to see what the next run does to one file of the indexed repository, the &lt;code&gt;id.py&lt;/code&gt; from the table above:&lt;/p&gt;
&lt;h3&gt;Changes to the indexed code&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A file is added&lt;/strong&gt;: only that file is split and embedded, and its rows are inserted. The rest of the repo is untouched.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A file is deleted&lt;/strong&gt;: its rows are removed from the target.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A file is edited&lt;/strong&gt;: the whole file is read and split again. A chunk with unchanged text keeps its id and its embedding. If its lines moved, its row is rewritten with the new &lt;code&gt;start_line&lt;/code&gt; and &lt;code&gt;end_line&lt;/code&gt;, with no embedding call. A chunk with new text is embedded and inserted, and a chunk whose text is gone is deleted. In 3 of the demo&apos;s 4 edits to the file&apos;s text, only the chunk that holds the edit is replaced (or, for the deleted function, deleted). Because the splitter balances chunk sizes, an edit can also move a nearby boundary: the line inserted at line 123 also replaces the chunk at lines 89–104.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Changes to the pipeline&lt;/h3&gt;
&lt;p&gt;Pipeline changes are reconciled the same way: CocoIndex compares the new rows with the rows already in Postgres and applies only the difference.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Change the file patterns&lt;/strong&gt; (&lt;code&gt;included_patterns&lt;/code&gt; / &lt;code&gt;excluded_patterns&lt;/code&gt;): files that now match are indexed, and rows of files that no longer match are deleted.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tune the chunking&lt;/strong&gt; (&lt;code&gt;chunk_size&lt;/code&gt;, &lt;code&gt;chunk_overlap&lt;/code&gt;): the code of &lt;code&gt;process_file&lt;/code&gt; changed, so every file is split again. Chunks whose text is unchanged keep their rows and embeddings; the rest are embedded and inserted, and the old ones deleted.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Swap the embedding model&lt;/strong&gt;: &lt;code&gt;EMBEDDER&lt;/code&gt; is declared with &lt;code&gt;detect_change=True&lt;/code&gt;, so every chunk is embedded again. The chunk text is unchanged, so the ids stay the same: the &lt;code&gt;embedding&lt;/code&gt; column is updated in place, with no rows added or removed. If the new model has a different dimension, CocoIndex also changes the column type (recreating the column if needed) and rewrites every row.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In live mode (&lt;code&gt;cocoindex update -L main&lt;/code&gt;), each change is applied as you save.&lt;/p&gt;
&lt;h2&gt;Next steps&lt;/h2&gt;
&lt;p&gt;The full, runnable example is in the CocoIndex repo: &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/code_embedding&quot;&gt;examples/code_embedding&lt;/a&gt;, with a walkthrough in the &lt;a href=&quot;https://cocoindex.io/docs/examples/index-codebase/&quot;&gt;index-codebase example&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Point &lt;code&gt;sourcedir&lt;/code&gt; at your own repository.&lt;/li&gt;
&lt;li&gt;Swap the embedding model or the target store; the pipeline is plain Python.&lt;/li&gt;
&lt;li&gt;Read the &lt;a href=&quot;https://cocoindex.io/docs/&quot;&gt;CocoIndex V1 docs&lt;/a&gt; for more on incremental processing, components, and targets.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Issues and contributions are welcome on &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>examples</category><category>rag</category><category>embeddings</category><category>ai-agents</category><category>incremental-processing</category><author>Linghua Jin</author></item><item><title>Memoization keys, scheduled refresh and scoped stats</title><link>https://cocoindex.io/blogs/changelog-101-107/</link><guid isPermaLink="true">https://cocoindex.io/blogs/changelog-101-107/</guid><description>CocoIndex 1.0.1–1.0.7 adds per-argument memo keys, scheduled live refresh, scoped stats, OCI and Iggy sources, and Neo4j, FalkorDB and Turbopuffer targets.</description><pubDate>Mon, 01 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;CocoIndex reached &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;v1.0&lt;/a&gt; at the start of this cycle.&lt;/p&gt;
&lt;p&gt;This is the first changelog since the v1 launch, covering 7 releases (1.0.1–1.0.7). The new engine APIs are &lt;code&gt;memo_key&lt;/code&gt; on &lt;code&gt;@coco.fn&lt;/code&gt; for control over cache keys, &lt;code&gt;coco.auto_refresh()&lt;/code&gt; for processors that re-run on a schedule, and &lt;code&gt;coco.stats_group()&lt;/code&gt; for stats per data slice. New connectors add OCI Object Storage and Apache Iggy sources and Neo4j, FalkorDB, and Turbopuffer targets. Security and correctness fixes and new examples follow.&lt;/p&gt;
&lt;p&gt;CocoIndex builds fresh, structured context for AI from sources such as PDFs, codebases, emails, screenshots, and meeting notes, and keeps it up to date with an &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;incremental engine&lt;/a&gt;. The source is on &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;:::tip[Start here]&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;You write pipelines:&lt;/strong&gt; read &lt;a href=&quot;#memo_key-per-argument-memoization-control-v103&quot;&gt;&lt;code&gt;memo_key&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;#cocoauto_refresh-scheduled-live-refresh-v107&quot;&gt;&lt;code&gt;auto_refresh&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;#cocostats_group-stats-per-data-slice-v107&quot;&gt;&lt;code&gt;stats_group&lt;/code&gt;&lt;/a&gt; first.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You index code or audio:&lt;/strong&gt; read &lt;a href=&quot;#code-splitter-8-new-languages-v103-to-v107&quot;&gt;the code splitter languages&lt;/a&gt; and &lt;a href=&quot;#litellm-speech-to-text-v101&quot;&gt;LiteLLM speech-to-text&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You run Postgres or SQLite targets:&lt;/strong&gt; read &lt;a href=&quot;#fixes&quot;&gt;the fixes&lt;/a&gt;, starting with SQL identifier validation.
:::&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Why this release cycle matters&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cache keys.&lt;/strong&gt; A per-argument &lt;a href=&quot;#memo_key-per-argument-memoization-control-v103&quot;&gt;&lt;code&gt;memo_key&lt;/code&gt;&lt;/a&gt; leaves clients, loggers, and debug flags out of the cache key, so a cached result is reused when only those change.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scheduled refresh.&lt;/strong&gt; &lt;a href=&quot;#cocoauto_refresh-scheduled-live-refresh-v107&quot;&gt;&lt;code&gt;coco.auto_refresh()&lt;/code&gt;&lt;/a&gt; re-runs a processor on an interval as a live component, with one error-handling path and target-state reconciliation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scoped stats.&lt;/strong&gt; &lt;a href=&quot;#cocostats_group-stats-per-data-slice-v107&quot;&gt;&lt;code&gt;coco.stats_group()&lt;/code&gt;&lt;/a&gt; reports &lt;code&gt;adds&lt;/code&gt; / &lt;code&gt;reprocesses&lt;/code&gt; / &lt;code&gt;deletes&lt;/code&gt; per data slice (a tenant, a project, or a folder), not only per processor.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Connectors.&lt;/strong&gt; &lt;a href=&quot;#source-oci-object-storage-with-live-bucket-watching-v101&quot;&gt;OCI Object Storage&lt;/a&gt; and &lt;a href=&quot;#source-apache-iggy-v107&quot;&gt;Apache Iggy&lt;/a&gt; sources; &lt;a href=&quot;#target-turbopuffer-v103&quot;&gt;Turbopuffer&lt;/a&gt;, &lt;a href=&quot;#target-neo4j-v103&quot;&gt;Neo4j&lt;/a&gt;, and &lt;a href=&quot;#target-falkordb-v101&quot;&gt;FalkorDB&lt;/a&gt; targets; &lt;a href=&quot;#target-lancedb-v107&quot;&gt;LanceDB&lt;/a&gt; compaction and in-place schema evolution.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fixes.&lt;/strong&gt; SQL identifier validation in the Postgres and SQLite connectors, and a fix for an ownership race that appeared only under real database latency.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Engine&lt;/h2&gt;
&lt;h3&gt;&lt;code&gt;memo_key&lt;/code&gt;: per-argument memoization control (v1.0.3)&lt;/h3&gt;
&lt;p&gt;A memoized function (&lt;code&gt;@coco.fn(memo=True)&lt;/code&gt;) reuses its cached result while its arguments do not change. Production functions take more than data: clients, handles, config objects, loggers, tracing context, and debug flags. Those values change between runs even when the input that matters is the same, and each change invalidated the cache and re-ran transforms, embeddings, or LLM calls even though the result would be the same.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;@coco.fn&lt;/code&gt; now accepts a per-argument &lt;strong&gt;&lt;code&gt;memo_key&lt;/code&gt;&lt;/strong&gt;, which controls which arguments take part in the memoization cache key. It maps parameter names to either a callable (transform the value before fingerprinting) or &lt;code&gt;None&lt;/code&gt; (exclude the parameter entirely). A fingerprint is the hash CocoIndex computes from a value to decide whether it changed.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True, memo_key={&quot;entry&quot;: lambda e: (e.name, e.version), &quot;extra&quot;: None})
def transform(entry: SourceDataEntry, extra: str) -&amp;gt; str:
    ...
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Callable&lt;/strong&gt;: applied to the argument; its return value is fingerprinted in place of the original.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;None&lt;/code&gt;&lt;/strong&gt;: the parameter is excluded from the memo key; changing it never invalidates the cache.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not listed&lt;/strong&gt;: fingerprinted normally.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; If only &lt;code&gt;extra&lt;/code&gt; changes between runs, &lt;code&gt;transform&lt;/code&gt; returns the cached result and does not run. If &lt;code&gt;entry.version&lt;/code&gt; changes, the key changes and &lt;code&gt;transform&lt;/code&gt; runs again. Other fields of &lt;code&gt;entry&lt;/code&gt; do not affect the key.&lt;/p&gt;

Quick check: you write &lt;code&gt;{&apos;memo_key={&quot;clinet&quot;: None}&apos;}&lt;/code&gt;, with a typo in the parameter name. What happens?
&lt;p&gt;CocoIndex validates &lt;code&gt;memo_key&lt;/code&gt; when the decorator runs. An unknown parameter name raises &lt;code&gt;ValueError&lt;/code&gt;, and a value that is neither callable nor &lt;code&gt;None&lt;/code&gt; raises &lt;code&gt;TypeError&lt;/code&gt;. The typo fails at import time, not silently at run time.&lt;/p&gt;

&lt;p&gt;Read more in &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/memoization_keys/&quot;&gt;Memoization keys &amp;amp; states → Override at the call site&lt;/a&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1888&quot;&gt;&lt;strong&gt;#1888&lt;/strong&gt;&lt;/a&gt;, docs in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2000&quot;&gt;&lt;strong&gt;#2000&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;coco.auto_refresh()&lt;/code&gt;: scheduled live refresh (v1.0.7)&lt;/h3&gt;
&lt;p&gt;Some sources have no change events, such as a database table you can only query. The common live-mode answer is to run a processor on a fixed schedule. Without an engine-level primitive, every pipeline wrote its own loop and decided again how errors propagate and how missing rows get reconciled.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;coco.auto_refresh()&lt;/code&gt; wraps any processor function as a &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/live_mode/&quot;&gt;live component&lt;/a&gt; (a component that keeps running and updates its output in live mode) that re-runs on an interval and routes cycle failures through one error-handling channel.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import datetime
import cocoindex as coco

@coco.fn
async def app_main(db, target) -&amp;gt; None:
    await coco.mount(
        coco.auto_refresh(sync_users, interval=datetime.timedelta(minutes=5)),
        db, target,
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each cycle reconciles target states against the previous cycle. If &lt;code&gt;sync_users&lt;/code&gt; stops declaring a row, CocoIndex deletes the corresponding target automatically.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; In live mode, &lt;code&gt;sync_users&lt;/code&gt; runs once at mount, then again 5 minutes after each cycle ends. The interval is a fixed delay, so cycles never overlap. An exception in one cycle goes to the parent&apos;s exception handler, and the next cycle still runs. In catch-up mode (an update without live mode), &lt;code&gt;sync_users&lt;/code&gt; runs once and the interval is ignored.&lt;/p&gt;

Quick check: a cycle of &lt;code&gt;sync_users&lt;/code&gt; takes 2 minutes and the interval is 5 minutes. How often does it start?
&lt;p&gt;About every 7 minutes. The 5-minute wait starts when a cycle ends, not when it starts.&lt;/p&gt;

&lt;p&gt;See &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/live_component/&quot;&gt;Live components → periodic refresh&lt;/a&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1995&quot;&gt;&lt;strong&gt;#1995&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;coco.stats_group()&lt;/code&gt;: stats per data slice (v1.0.7)&lt;/h3&gt;
&lt;p&gt;By default, CocoIndex breaks stats down &lt;strong&gt;by processor&lt;/strong&gt;: each entry function (&lt;code&gt;process_doc&lt;/code&gt;, &lt;code&gt;process_code&lt;/code&gt;, …) reports its own counts of &lt;code&gt;adds&lt;/code&gt;, &lt;code&gt;reprocesses&lt;/code&gt;, and &lt;code&gt;deletes&lt;/code&gt;. It did not break those counts down across &lt;strong&gt;data slices&lt;/strong&gt;, so when one tenant caused a reprocess storm, the aggregate did not show which one.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;coco.stats_group(title)&lt;/code&gt; opens a scope where everything mounted inside aggregates into a &lt;strong&gt;separate&lt;/strong&gt; report under &lt;code&gt;title&lt;/code&gt;, split out of the parent (no double counting). The natural slice is the data: per tenant, per project, or per source folder.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn
async def app_main(tenants, target):
    for tenant in tenants:
        # same processor, but stats scoped per tenant
        with coco.stats_group(f&quot;tenant:{tenant.id}&quot;, report_to_stdout=True):
            files = localfs.walk_dir(tenant.docs_dir, ...)
            await coco.mount_each(process_doc, files.items(), target)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; Each tenant gets its own report. With &lt;code&gt;report_to_stdout=True&lt;/code&gt;, the counts also print as log lines that start with the tenant&apos;s title. One tenant with 600 reprocesses and another with 1,150 new adds show up as two separate lines, not as one total for &lt;code&gt;process_doc&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The block also yields a handle with the same &lt;code&gt;stats()&lt;/code&gt; and &lt;code&gt;watch()&lt;/code&gt; methods as &lt;code&gt;UpdateHandle&lt;/code&gt;, so you can stream a single slice&apos;s counts to a dashboard. See &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/progress_monitoring/&quot;&gt;Progress monitoring → Scoped reports&lt;/a&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2042&quot;&gt;&lt;strong&gt;#2042&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;

Quick check: a file is processed inside &lt;code&gt;stats_group(&quot;tenant:acme&quot;)&lt;/code&gt;. Does it also count in the parent report?
&lt;p&gt;No. The group&apos;s counts are split out of the enclosing report, so each change is counted once.&lt;/p&gt;

&lt;h3&gt;Other engine improvements&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Configurable logging&lt;/strong&gt;: set the Python logger level directly via the &lt;code&gt;COCOINDEX_LOG_LEVEL&lt;/code&gt; environment variable (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2035&quot;&gt;&lt;strong&gt;#2035&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cleaner Rust internals&lt;/strong&gt;: the workspace was unified and the core SDK isolated from PyO3 (the Rust-to-Python binding library), separating the engine from its Python bindings as groundwork for native Rust consumers of the engine (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1973&quot;&gt;&lt;strong&gt;#1973&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Built-in operations&lt;/h2&gt;
&lt;h3&gt;LiteLLM speech-to-text (v1.0.1)&lt;/h3&gt;
&lt;p&gt;CocoIndex added &lt;strong&gt;speech-to-text (STT)&lt;/strong&gt; support through &lt;a href=&quot;https://cocoindex.io/docs/ops/litellm/&quot;&gt;LiteLLM&lt;/a&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1889&quot;&gt;&lt;strong&gt;#1889&lt;/strong&gt;&lt;/a&gt;), so audio sources can be transcribed inside a pipeline using an STT provider that LiteLLM supports. A &lt;code&gt;LiteLLMTranscriber&lt;/code&gt; wraps the transcription API:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from cocoindex.ops.litellm import LiteLLMTranscriber

transcriber = LiteLLMTranscriber(&quot;whisper-1&quot;)
transcript = await transcriber.transcribe(audio_file)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; &lt;code&gt;transcribe()&lt;/code&gt; takes an audio file (a &lt;code&gt;FileLike&lt;/code&gt;) and returns the transcript as a string.&lt;/p&gt;
&lt;h3&gt;Code splitter: 8 new languages (v1.0.3 to v1.0.7)&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;https://cocoindex.io/docs/ops/text/&quot;&gt;&lt;code&gt;RecursiveSplitter&lt;/code&gt;&lt;/a&gt; gained &lt;a href=&quot;https://cocoindex.io/blogs/how-tree-sitter-works&quot;&gt;tree-sitter&lt;/a&gt; support for &lt;strong&gt;8 new languages&lt;/strong&gt; this cycle. With tree-sitter, chunks follow the syntax tree, so a function or a block stays in one chunk instead of being cut at a fixed line or character count.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Svelte&lt;/strong&gt; and &lt;strong&gt;Vue&lt;/strong&gt;: component-aware chunking for frontend code (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1937&quot;&gt;&lt;strong&gt;#1937&lt;/strong&gt;&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Julia&lt;/strong&gt;: for scientific and numerical codebases (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1942&quot;&gt;&lt;strong&gt;#1942&lt;/strong&gt;&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Elm&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1955&quot;&gt;&lt;strong&gt;#1955&lt;/strong&gt;&lt;/a&gt;) and &lt;strong&gt;Astro&lt;/strong&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1984&quot;&gt;&lt;strong&gt;#1984&lt;/strong&gt;&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bash, CMake, and HCL&lt;/strong&gt;: shell scripts, build files, and Terraform/infra configs (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1954&quot;&gt;&lt;strong&gt;#1954&lt;/strong&gt;&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Pass the language name to &lt;code&gt;language=&lt;/code&gt; (or let &lt;a href=&quot;https://cocoindex.io/docs/ops/text/&quot;&gt;&lt;code&gt;detect_code_language()&lt;/code&gt;&lt;/a&gt; infer it from a filename):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from cocoindex.ops.text import RecursiveSplitter

splitter = RecursiveSplitter()
chunks = splitter.split(source_code, chunk_size=2000, chunk_overlap=200, language=&quot;svelte&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Entity resolution: parallel by default (v1.0.7)&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://cocoindex.io/docs/ops/entity_resolution/&quot;&gt;Entity resolution&lt;/a&gt; (dedup-and-canonicalize a set of extracted entity names) now resolves independent connected components of the candidate graph in parallel. Names that cannot match each other no longer wait on each other, which speeds up LLM-backed deduplication on large entity sets (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2006&quot;&gt;&lt;strong&gt;#2006&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h2&gt;Connectors&lt;/h2&gt;
&lt;h3&gt;Source: OCI Object Storage with live bucket watching (v1.0.1)&lt;/h3&gt;
&lt;p&gt;A new &lt;a href=&quot;https://cocoindex.io/docs/connectors/oci_object_storage/&quot;&gt;&lt;strong&gt;Oracle Cloud Infrastructure (OCI) Object Storage&lt;/strong&gt;&lt;/a&gt; source mirrors the S3 source&apos;s API for scanning a bucket, and adds an optional live mode.&lt;/p&gt;
&lt;p&gt;It shows the &lt;strong&gt;stream–state duality&lt;/strong&gt; in CocoIndex&apos;s source model. A bucket is &lt;em&gt;state&lt;/em&gt;: &lt;code&gt;list_objects()&lt;/code&gt; scans it and establishes the full set of objects. A change feed is a &lt;em&gt;stream&lt;/em&gt;: when you supply a &lt;code&gt;live_stream&lt;/code&gt;, CocoIndex does the initial scan once and then keeps watching, applying &lt;code&gt;createobject&lt;/code&gt; / &lt;code&gt;updateobject&lt;/code&gt; / &lt;code&gt;deleteobject&lt;/code&gt; events incrementally instead of rescanning. For OCI those events flow through OCI Streaming, consumed over the &lt;a href=&quot;https://cocoindex.io/blogs/csv-to-kafka-live&quot;&gt;Kafka&lt;/a&gt; protocol; an event-time cutoff with a 5-second clock-skew tolerance decides which streamed events predate the scan. It is built on a new lower-level &lt;code&gt;LiveStream&lt;/code&gt; abstraction: a keyless stream of messages with in-memory watermark tracking (the position up to which messages are processed) and ack-on-completion (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1905&quot;&gt;&lt;strong&gt;#1905&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; With &lt;code&gt;live_stream&lt;/code&gt; set, the walker&apos;s &lt;code&gt;items()&lt;/code&gt; returns a live view instead of a plain list. Passed to &lt;code&gt;mount_each()&lt;/code&gt;, it processes new, updated, and deleted objects as their events arrive, without a full rescan.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://cocoindex.io/docs/connectors/localfs/&quot;&gt;local file system&lt;/a&gt; source uses the same model, with the change stream from OS file-system events instead of Kafka. More sources, such as S3, will gain live mode over time.&lt;/p&gt;
&lt;h3&gt;Source: Apache Iggy (v1.0.7)&lt;/h3&gt;
&lt;p&gt;CocoIndex now reads from &lt;strong&gt;Apache Iggy&lt;/strong&gt;, a persistent message-streaming platform (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1969&quot;&gt;&lt;strong&gt;#1969&lt;/strong&gt;&lt;/a&gt;). The &lt;a href=&quot;https://cocoindex.io/docs/connectors/iggy/&quot;&gt;Iggy source&lt;/a&gt; exposes one topic partition either as a raw live stream of messages (&lt;code&gt;topic_as_stream()&lt;/code&gt;) or as a live keyed map (&lt;code&gt;topic_as_map()&lt;/code&gt;), where a &lt;code&gt;key&lt;/code&gt; function derives the application-level key from each payload. The same connector also ships an Iggy topic target. Install it with &lt;code&gt;pip install cocoindex[iggy]&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Target: Turbopuffer (v1.0.3)&lt;/h3&gt;
&lt;p&gt;A new &lt;a href=&quot;https://cocoindex.io/docs/connectors/turbopuffer/&quot;&gt;&lt;strong&gt;Turbopuffer&lt;/strong&gt;&lt;/a&gt; target connector landed, along with a runnable text-embedding example (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1934&quot;&gt;&lt;strong&gt;#1934&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;Target: Neo4j (v1.0.3)&lt;/h3&gt;
&lt;p&gt;A native &lt;a href=&quot;https://cocoindex.io/docs/connectors/neo4j/&quot;&gt;&lt;strong&gt;Neo4j&lt;/strong&gt;&lt;/a&gt; property-graph target landed alongside a &lt;code&gt;meeting_notes_graph_neo4j&lt;/code&gt; example, mapping nodes and relationships into Neo4j without writing Cypher by hand (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1932&quot;&gt;&lt;strong&gt;#1932&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;Target: FalkorDB (v1.0.1)&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;https://cocoindex.io/docs/connectors/falkordb/&quot;&gt;&lt;strong&gt;FalkorDB&lt;/strong&gt;&lt;/a&gt; property-graph target was brought forward into the v1 connector set, with support for nodes, relationships, and vector/FTS (full-text search) indexes (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1908&quot;&gt;&lt;strong&gt;#1908&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;Target: LanceDB (v1.0.7)&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/lancedb/&quot;&gt;LanceDB&lt;/a&gt; got two upgrades for production workloads:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The v1 target now &lt;strong&gt;optimizes (compacts) tables periodically&lt;/strong&gt; in the background, keeping query performance steady as data churns (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2008&quot;&gt;&lt;strong&gt;#2008&lt;/strong&gt;&lt;/a&gt;, with a scheduling fix in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2013&quot;&gt;&lt;strong&gt;#2013&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Table targets can &lt;strong&gt;add new columns in place&lt;/strong&gt;, so schema evolution doesn&apos;t require a rebuild (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1951&quot;&gt;&lt;strong&gt;#1951&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Fixes&lt;/h2&gt;
&lt;h3&gt;Postgres correctness&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;halfvec&lt;/code&gt; op classes are now used for indexes on half-precision vectors (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2029&quot;&gt;&lt;strong&gt;#2029&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;U+0000&lt;/code&gt; (NUL) bytes are stripped when writing &lt;code&gt;text&lt;/code&gt;/&lt;code&gt;jsonb&lt;/code&gt;, so Postgres no longer rejects otherwise-valid payloads (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2032&quot;&gt;&lt;strong&gt;#2032&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;pgvector&lt;/code&gt; extension now installs into the default schema, avoiding &lt;code&gt;search_path&lt;/code&gt; surprises (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1979&quot;&gt;&lt;strong&gt;#1979&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Other fixes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SQL identifier validation&lt;/strong&gt; (v1.0.4): the Postgres and SQLite connectors now validate table and column identifiers before interpolating them into statements, closing a class of SQL-injection vectors at the connector boundary (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1947&quot;&gt;&lt;strong&gt;#1947&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1965&quot;&gt;&lt;strong&gt;#1965&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ownership-transfer race&lt;/strong&gt; (v1.0.7): when a target state moves from one component to another, a pending-state protocol closes a preempt race, so the transfer stays correct under Postgres I/O latency and not only on fast LMDB, where it takes microseconds (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1994&quot;&gt;&lt;strong&gt;#1994&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Clean cancellation&lt;/strong&gt;: cancellation propagates through task spawn boundaries, tearing work down cleanly instead of leaking orphaned tasks (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1902&quot;&gt;&lt;strong&gt;#1902&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;on_error&lt;/code&gt; cascade&lt;/strong&gt;: errors cascade through the Build-mode GC sweep (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1999&quot;&gt;&lt;strong&gt;#1999&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;numpy serde&lt;/strong&gt;: &lt;code&gt;_frombuffer&lt;/code&gt; is registered under both numpy 1.x and 2.x paths (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2012&quot;&gt;&lt;strong&gt;#2012&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Responsive progress display&lt;/strong&gt;: the PTY reader moved onto a dedicated OS thread, keeping the async runtime responsive under heavy logging (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2033&quot;&gt;&lt;strong&gt;#2033&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2040&quot;&gt;&lt;strong&gt;#2040&lt;/strong&gt;&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Examples&lt;/h2&gt;
&lt;h3&gt;Meeting notes → knowledge graph, now on Neo4j&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;/blogs/meeting-notes-graph/&quot;&gt;Meeting Notes Knowledge Graph&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;meeting-notes-to-knowledge-graph&lt;/strong&gt; example now ships in a Neo4j flavor (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/meeting_notes_graph_neo4j&quot;&gt;&lt;code&gt;meeting_notes_graph_neo4j&lt;/code&gt;&lt;/a&gt;). It watches a folder of meeting notes, uses LLM extraction to pull out structured entities (Meetings, People, Tasks) and the relationships between them, then maps everything into Neo4j as nodes and edges. When one note changes, CocoIndex reprocesses only that note and updates the graph.&lt;/p&gt;
&lt;h3&gt;Turbopuffer and OCI text-embedding examples&lt;/h3&gt;
&lt;p&gt;Two more end-to-end examples landed alongside the new connectors: &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/text_embedding_turbopuffer&quot;&gt;&lt;code&gt;text_embedding_turbopuffer&lt;/code&gt;&lt;/a&gt; shows a complete embed-and-query pipeline against Turbopuffer, and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/oci_object_storage_embedding&quot;&gt;&lt;code&gt;oci_object_storage_embedding&lt;/code&gt;&lt;/a&gt; ingests from OCI Object Storage with live bucket watching.&lt;/p&gt;
&lt;h3&gt;Video: build it end to end on FalkorDB&lt;/h3&gt;
&lt;p&gt;The &lt;a href=&quot;https://www.youtube.com/watch?v=r1eRG8JPMJM&quot;&gt;Build with CocoIndex walkthrough&lt;/a&gt; builds the meeting-notes-to-knowledge-graph pipeline end to end on FalkorDB. The &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/meeting_notes_graph_falkordb&quot;&gt;&lt;code&gt;meeting_notes_graph_falkordb&lt;/code&gt;&lt;/a&gt; example has the same code to run yourself.&lt;/p&gt;
&lt;h2&gt;What to try next&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Keep a client out of the cache key.&lt;/strong&gt; Add &lt;code&gt;memo_key={&quot;client&quot;: None}&lt;/code&gt; to a memoized function that takes a client, as in &lt;a href=&quot;#memo_key-per-argument-memoization-control-v103&quot;&gt;the memo_key example&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Refresh a source that has no change events.&lt;/strong&gt; Mount &lt;code&gt;coco.auto_refresh(fn, interval=...)&lt;/code&gt; in live mode, as in &lt;a href=&quot;#cocoauto_refresh-scheduled-live-refresh-v107&quot;&gt;the auto_refresh example&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;See stats per tenant or folder.&lt;/strong&gt; Wrap a &lt;code&gt;mount_each()&lt;/code&gt; in &lt;code&gt;with coco.stats_group(title, report_to_stdout=True):&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Chunk code by syntax.&lt;/strong&gt; Pass &lt;code&gt;language=&lt;/code&gt; to &lt;code&gt;RecursiveSplitter.split()&lt;/code&gt; for one of the new languages.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the complete list of changes, see the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/releases&quot;&gt;GitHub releases&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Thanks to the community&lt;/h2&gt;
&lt;p&gt;Thanks to everyone who contributed this cycle.&lt;/p&gt;
&lt;h3&gt;@prrao87&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/prrao87&quot;&gt;@prrao87&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2013&quot;&gt;fixing LanceDB optimize scheduling&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@zherendong&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/zherendong&quot;&gt;@zherendong&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2006&quot;&gt;parallelizing entity resolution via candidate-graph components&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@countradooku&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/countradooku&quot;&gt;@countradooku&lt;/a&gt; for adding the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1969&quot;&gt;Apache Iggy connector&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@Haleshot&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/Haleshot&quot;&gt;@Haleshot&lt;/a&gt; for keeping the docs in shape after the v1 launch: &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1924&quot;&gt;removing the stale &lt;code&gt;v1&lt;/code&gt; mention from the install command&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1958&quot;&gt;fixing a broken URL&lt;/a&gt;, and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1959&quot;&gt;updating stale &lt;code&gt;v1&lt;/code&gt; branch links to &lt;code&gt;main&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@galshubeli&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/galshubeli&quot;&gt;@galshubeli&lt;/a&gt; for bringing the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1908&quot;&gt;FalkorDB target connector&lt;/a&gt; into the v1 connector set.&lt;/p&gt;
&lt;h3&gt;@Gohlub&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/Gohlub&quot;&gt;@Gohlub&lt;/a&gt; for adding &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1889&quot;&gt;LiteLLM speech-to-text support&lt;/a&gt;, CocoIndex&apos;s first audio operation.&lt;/p&gt;
&lt;h3&gt;@MrAnayDongre&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/MrAnayDongre&quot;&gt;@MrAnayDongre&lt;/a&gt; for adding &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1888&quot;&gt;per-argument &lt;code&gt;memo_key&lt;/code&gt; support&lt;/a&gt; to &lt;code&gt;@coco.fn&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;@aaronjmars&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/aaronjmars&quot;&gt;@aaronjmars&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1947&quot;&gt;validating SQL identifiers in the Postgres and SQLite connectors&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@tuanaiseo&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/tuanaiseo&quot;&gt;@tuanaiseo&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1965&quot;&gt;reporting and fixing a potential SQL injection in the Postgres connector&lt;/a&gt;, responsibly disclosed.&lt;/p&gt;
&lt;h3&gt;@nuthalapativarun&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/nuthalapativarun&quot;&gt;@nuthalapativarun&lt;/a&gt; for splitter work: adding &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1955&quot;&gt;Elm&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1984&quot;&gt;Astro&lt;/a&gt;, and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1954&quot;&gt;Bash, CMake, and HCL&lt;/a&gt; tree-sitter support, plus &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1986&quot;&gt;adding context to Rust→Python error messages&lt;/a&gt; and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1953&quot;&gt;expanding the supported-languages docs&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@qWaitCrypto&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/qWaitCrypto&quot;&gt;@qWaitCrypto&lt;/a&gt; for making the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2008&quot;&gt;LanceDB v1 target optimize tables periodically&lt;/a&gt; and for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1951&quot;&gt;adding columns in place&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@shaiar&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/shaiar&quot;&gt;@shaiar&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/2012&quot;&gt;fixing serde &lt;code&gt;_frombuffer&lt;/code&gt; registration across numpy 1.x and 2.x&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@octo-patch&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/octo-patch&quot;&gt;@octo-patch&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1855&quot;&gt;adding Python formatting and linting commands to CLAUDE.md&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@phuctoan123&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/phuctoan123&quot;&gt;@phuctoan123&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1949&quot;&gt;documenting &lt;code&gt;gws&lt;/code&gt; for Google Drive setup&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>changelog</category><category>announcement</category><category>connectors</category><category>performance</category><author>George He</author></item><item><title>Stream CSV changes to Kafka: publish only changed rows</title><link>https://cocoindex.io/blogs/csv-to-kafka-live/</link><guid isPermaLink="true">https://cocoindex.io/blogs/csv-to-kafka-live/</guid><description>Watch a folder of CSV files and publish each changed row as JSON to a Kafka topic with CocoIndex, with no producer loop.</description><pubDate>Tue, 28 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex&lt;/a&gt; has a &lt;strong&gt;Kafka target connector&lt;/strong&gt;. You declare a Kafka topic as a target of your pipeline the same way you declare a &lt;a href=&quot;https://cocoindex.io/docs/connectors/postgres/&quot;&gt;Postgres table&lt;/a&gt; or a vector index, and CocoIndex produces a message only when the value declared for a key changes. You do not write a producer loop or keep track of which rows you already published.&lt;/p&gt;
&lt;p&gt;This post builds a pipeline of about 60 lines of Python. It watches a local folder of CSV files, turns each row into a JSON message keyed by the row&apos;s primary key, and publishes it to a Kafka topic on &lt;a href=&quot;https://streamnative.io/&quot;&gt;StreamNative&lt;/a&gt;. It runs in &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/live_mode/&quot;&gt;live mode&lt;/a&gt;: edit a CSV, and only the changed rows appear on the topic.&lt;/p&gt;
&lt;h2&gt;Why agents need a stream of changes&lt;/h2&gt;
&lt;p&gt;Many agent stacks are built on periodic snapshots of their knowledge sources: for example, a wiki re-indexed overnight or a codebase re-embedded on a cron. For an agent that runs for hours, a snapshot taken at the start of the run drifts out of sync with the data it describes.&lt;/p&gt;
&lt;p&gt;The next step teams often take is to wire each source to each consumer with webhooks. With more than one consumer, this gets expensive: point-to-point webhooks lack a shared path for replay and backfill, a buffer for bursts, and a common schema for a change. Each integration ends up rebuilding parts of a durable log.&lt;/p&gt;
&lt;p&gt;CocoIndex with Kafka handles the knowledge layer the way operational data is already handled: as a stream of change events on a durable topic. CocoIndex computes what changed in each source, so indexes and agent context are refreshed only for changed data. Every consumer (a vector index, an agent, search, a Flink job) reads the same topic, and a consumer added later replays the log to catch up. The offsets and timestamps on each event also record which change an agent saw, and when.&lt;/p&gt;
&lt;h2&gt;The example: CSV files to JSON messages&lt;/h2&gt;
&lt;p&gt;CSV is a simple starting point that teams meet often: BI exports, vendor dumps without a webhook, spreadsheets in a shared drive. CSV files look structured but behave like unstructured assets. They are dropped into a folder and edited at any time, with no notifications and no schema contract. The same pattern carries over to PDFs, codebases, and wikis (see &lt;a href=&quot;#beyond-csv-unstructured-sources-on-kafka&quot;&gt;the last section&lt;/a&gt;); CSV keeps the focus on the connector and the live-update loop.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We have a &lt;code&gt;data/&lt;/code&gt; folder with a couple of CSV files:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# data/products.csv
sku,name,category,price
SKU001,Wireless Mouse,Electronics,29.99
SKU002,Mechanical Keyboard,Electronics,89.99
SKU003,USB-C Hub,Accessories,45.00
SKU004,Monitor Stand,Furniture,65.50
SKU005,Desk Lamp,Furniture,34.99
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;# data/employees.csv
emp_id,first_name,last_name,department,email
E101,Alice,Chen,Engineering,alice.chen@example.com
E102,Bob,Smith,Marketing,bob.smith@example.com
E103,Carol,Johnson,Engineering,carol.johnson@example.com
E104,David,Lee,Sales,david.lee@example.com
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The goal: every row becomes a JSON message on a Kafka topic, keyed by the value of the row&apos;s first column (the primary key). When a CSV file is edited, only the rows that changed are published again.&lt;/p&gt;
&lt;h2&gt;The pipeline&lt;/h2&gt;
&lt;p&gt;First, the app creates the Kafka producer once at startup in a &lt;code&gt;lifespan&lt;/code&gt; hook and provides it under a &lt;code&gt;ContextKey&lt;/code&gt;, so the rest of the pipeline can use it without passing it around:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import csv
import io
import json
import os
from collections.abc import AsyncIterator

from confluent_kafka.aio import AIOProducer

import cocoindex as coco
from cocoindex.connectors import kafka, localfs
from cocoindex.resources.file import FileLike, PatternFilePathMatcher

KAFKA_PRODUCER = coco.ContextKey[AIOProducer](&quot;kafka_producer&quot;)

KAFKA_TOPIC = os.environ.get(&quot;KAFKA_TOPIC&quot;, &quot;cocoindex-csv-rows&quot;)
KAFKA_BOOTSTRAP_SERVERS = os.environ.get(&quot;KAFKA_BOOTSTRAP_SERVERS&quot;, &quot;localhost:9092&quot;)
KAFKA_SASL_USERNAME = os.environ.get(&quot;KAFKA_SASL_USERNAME&quot;, &quot;&quot;)
KAFKA_SASL_PASSWORD = os.environ.get(&quot;KAFKA_SASL_PASSWORD&quot;, &quot;&quot;)

@coco.lifespan
async def coco_lifespan(builder: coco.EnvironmentBuilder) -&amp;gt; AsyncIterator[None]:
    config: dict[str, str] = {&quot;bootstrap.servers&quot;: KAFKA_BOOTSTRAP_SERVERS}
    if KAFKA_SASL_USERNAME:
        config.update(
            {
                &quot;sasl.mechanism&quot;: &quot;PLAIN&quot;,
                &quot;security.protocol&quot;: &quot;SASL_SSL&quot;,
                &quot;sasl.username&quot;: KAFKA_SASL_USERNAME,
                &quot;sasl.password&quot;: KAFKA_SASL_PASSWORD,
            }
        )
    producer = AIOProducer(config)
    builder.provide(KAFKA_PRODUCER, producer)
    yield
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/context/&quot;&gt;&lt;code&gt;ContextKey&lt;/code&gt;&lt;/a&gt; shares the producer across components without passing it through every function call; its name also matters for state tracking, as &lt;a href=&quot;#what-the-flag-does-and-does-not-do&quot;&gt;a later section&lt;/a&gt; shows. StreamNative and many managed brokers use SASL_SSL with PLAIN. With &lt;code&gt;KAFKA_SASL_USERNAME&lt;/code&gt; empty, the producer connects to a local broker such as &lt;code&gt;localhost:9092&lt;/code&gt; without them.&lt;/p&gt;
&lt;p&gt;Next, the per-file processor, where the Kafka API appears:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def process_csv(file: FileLike, topic_target: kafka.KafkaTopicTarget) -&amp;gt; None:
    text = await file.read_text()
    reader = csv.DictReader(io.StringIO(text))

    headers = reader.fieldnames
    if not headers:
        return
    first_col = headers[0]

    for row in reader:
        key_value = row.get(first_col, None)
        if key_value is not None:
            value = json.dumps(row)
            topic_target.declare_target_state(key=key_value, value=value)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;@coco.fn(memo=True)&lt;/code&gt; memoizes the per-file work as well: while a file&apos;s content is unchanged, &lt;code&gt;process_csv&lt;/code&gt; does not run for it.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;declare_target_state&lt;/code&gt;: you declare rows, CocoIndex sends messages&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;topic_target.declare_target_state(key=key, value=value)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The method name describes its input: the state that the target holds for one key. CocoIndex derives the messages from it.&lt;/p&gt;
&lt;p&gt;CocoIndex is a &lt;strong&gt;state-driven&lt;/strong&gt; data framework. The mental model is the one behind a spreadsheet, a React component tree, or a SQL materialized view: you describe what the target should look like as a function of the source, and the framework works out the transitions. Your code does not compute deltas or remember what it sent last time, and insert, update, and delete are one code path. Your code says: given this CSV row, the target state for key &lt;code&gt;SKU001&lt;/code&gt; is this JSON value.&lt;/p&gt;
&lt;p&gt;Kafka&apos;s wire model works the other way. A topic is a log of change events: producers send events, and consumers (or compacted topics) rebuild state from the log. Something has to turn desired states into the change events the broker receives.&lt;/p&gt;
&lt;p&gt;In CocoIndex, the framework does that. When you call &lt;code&gt;declare_target_state(key=k, value=v)&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If &lt;code&gt;k&lt;/code&gt; is new or &lt;code&gt;v&lt;/code&gt; differs from the last value the framework remembers for &lt;code&gt;k&lt;/code&gt;, it emits an &lt;strong&gt;upsert&lt;/strong&gt; message: &lt;code&gt;(k, v)&lt;/code&gt; on the wire.&lt;/li&gt;
&lt;li&gt;If &lt;code&gt;k&lt;/code&gt; was previously declared but isn&apos;t declared this time, it emits a &lt;strong&gt;delete&lt;/strong&gt; message: &lt;code&gt;(k, None)&lt;/code&gt;, which Kafka calls a tombstone, or &lt;code&gt;(k, deletion_value_fn(k))&lt;/code&gt; if you pass a &lt;code&gt;deletion_value_fn&lt;/code&gt; to &lt;code&gt;mount_kafka_topic_target&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If &lt;code&gt;k&lt;/code&gt; was previously declared with the same &lt;code&gt;v&lt;/code&gt;, nothing is sent to the broker, and no consumer wakes up.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Try it on the example&apos;s &lt;code&gt;products.csv&lt;/code&gt;. The demo below runs the same rules in your browser; the outcomes match what the connector sends in cocoindex 1.1.1. Change a key to see a delete and an upsert in one run.&lt;/p&gt;
&lt;p&gt;Your code deals only with states, and CocoIndex derives the messages from the transitions between them. The Postgres target follows the same pattern (&lt;code&gt;declare_target_state&lt;/code&gt; → INSERT / UPDATE / DELETE), and so do the vector index targets.&lt;/p&gt;
&lt;p&gt;In practice, the same &lt;code&gt;process_csv&lt;/code&gt; function is correct on the first run and on every run after it: when a row is edited or removed, when a file is deleted, and after a crash and restart. There is one code path for the initial load and for each &lt;a href=&quot;https://cocoindex.io/blogs/incremental-processing&quot;&gt;incremental update&lt;/a&gt;. The code states what the target should look like for the current source, and that holds for any starting state of the target.&lt;/p&gt;
&lt;p&gt;Finally, wire it all together:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn
async def app_main() -&amp;gt; None:
    topic_target = await kafka.mount_kafka_topic_target(KAFKA_PRODUCER, KAFKA_TOPIC)

    files = localfs.walk_dir(
        localfs.FilePath(path=&quot;./data&quot;),
        path_matcher=PatternFilePathMatcher(included_patterns=[&quot;**/*.csv&quot;]),
        live=True,
    )
    await coco.mount_each(process_csv, files.items(), topic_target)

app = coco.App(
    coco.AppConfig(name=&quot;CsvToKafka&quot;),
    app_main,
)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Two details:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;mount_kafka_topic_target(...)&lt;/code&gt; resolves the producer from the context key and returns a handle. The topic is user-managed: CocoIndex produces into a topic you already own and does not create or delete topics.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;localfs.walk_dir(..., live=True)&lt;/code&gt; turns the directory walker into a live source: it scans once, then watches the filesystem and pushes changes downstream. With &lt;code&gt;cocoindex update -L&lt;/code&gt;, the pipeline keeps running instead of exiting after one pass.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Live mode is one argument and one flag&lt;/h2&gt;
&lt;p&gt;The same &lt;code&gt;process_csv&lt;/code&gt; runs as a &lt;strong&gt;catch-up run&lt;/strong&gt; (scan once, reconcile everything that changed since the last run, exit) or as a pipeline that keeps watching for changes. The difference is one keyword argument and one CLI flag:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Catch-up run:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;files = localfs.walk_dir(
    localfs.FilePath(path=&quot;./data&quot;),
    path_matcher=PatternFilePathMatcher(included_patterns=[&quot;**/*.csv&quot;]),
)
await coco.mount_each(process_csv, files.items(), topic_target)
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;cocoindex update main.py
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Live:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;files = localfs.walk_dir(
    localfs.FilePath(path=&quot;./data&quot;),
    path_matcher=PatternFilePathMatcher(included_patterns=[&quot;**/*.csv&quot;]),
    live=True,                 # ← +1 line
)
await coco.mount_each(process_csv, files.items(), topic_target)
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;cocoindex update -L main.py   # ← +1 flag
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;process_csv&lt;/code&gt; and the Kafka target stay the same in both modes.&lt;/p&gt;
&lt;p&gt;Run the live version:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cocoindex update -L main.py
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;CocoIndex scans &lt;code&gt;data/&lt;/code&gt; first, publishes one message per row, then watches the folder:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Edit one non-key cell&lt;/strong&gt; in &lt;code&gt;products.csv&lt;/code&gt;: one Kafka message is produced for that row (modulo broker retries; the producer is at-least-once by default). The other 4 rows in &lt;code&gt;products.csv&lt;/code&gt; produce no messages.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Add a new row&lt;/strong&gt;: one new message.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Delete a row&lt;/strong&gt;: one delete message (no value, since this example doesn&apos;t supply a &lt;code&gt;deletion_value_fn&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Add a CSV file&lt;/strong&gt;: &lt;code&gt;process_csv&lt;/code&gt; runs once for that file, publishing its rows.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Delete a CSV file&lt;/strong&gt;: every row from that file gets a delete message.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;What the flag does and does not do&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;-L&lt;/code&gt; flag controls continuous updates. Reconciliation happens in both modes: whether you run &lt;code&gt;cocoindex update&lt;/code&gt; or &lt;code&gt;cocoindex update -L&lt;/code&gt;, you declare &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;target states&lt;/a&gt; and CocoIndex computes deltas against the previous run, emitting only the upsert and delete messages needed to bring the topic in line. To do that, CocoIndex maintains an &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/internal_storage/&quot;&gt;internal state store&lt;/a&gt; that remembers, for every declared key, the fingerprint of the value last sent. That store survives restarts, so a restarted pipeline continues where it stopped and does not send unchanged rows again.&lt;/p&gt;
&lt;p&gt;This is also where the &lt;code&gt;ContextKey&lt;/code&gt; from earlier matters. The state store identifies the topic by the &lt;code&gt;ContextKey&lt;/code&gt; it was anchored to (here, &lt;code&gt;KAFKA_PRODUCER&lt;/code&gt;) plus the topic name, and not by SASL credentials or the bootstrap address. Rotating the SASL password or reconfiguring the &lt;code&gt;AIOProducer&lt;/code&gt; keeps the same state. Pointing the producer at a different cluster also keeps it, so CocoIndex does not re-send unchanged rows to the new cluster; use a new &lt;code&gt;ContextKey&lt;/code&gt; name to publish everything again.&lt;/p&gt;
&lt;p&gt;In a catch-up run, CocoIndex scans sources once, reconciles up to the moment, and exits. In live mode, it does the same catch-up and then, instead of exiting, keeps watching the sources and reconciles each change as it arrives.&lt;/p&gt;
&lt;p&gt;The watching comes from the source: &lt;code&gt;localfs.walk_dir(..., live=True)&lt;/code&gt; returns a &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/live_component/&quot;&gt;live source&lt;/a&gt; backed by &lt;a href=&quot;https://github.com/samuelcolvin/watchfiles&quot;&gt;&lt;code&gt;watchfiles&lt;/code&gt;&lt;/a&gt;, which reports filesystem changes. A non-live source (or &lt;code&gt;live=False&lt;/code&gt;) lists the current files and stops. The CLI &lt;code&gt;-L&lt;/code&gt; flag keeps the app running so those changes are processed.&lt;/p&gt;
&lt;p&gt;The connector keeps Kafka&apos;s partitioning: each declared key is hashed to a partition by the &lt;code&gt;confluent_kafka&lt;/code&gt; client&apos;s default partitioner, so a key lands on the same partition as long as the partition count does not change. Log compaction and key-based consumers behave as they would with a hand-written producer.&lt;/p&gt;
&lt;h2&gt;Each row is one keyed message&lt;/h2&gt;
&lt;p&gt;We ran the example against a Kafka cluster on &lt;a href=&quot;https://streamnative.io/&quot;&gt;StreamNative Cloud&lt;/a&gt;. We partner with StreamNative on real-time data for AI workloads: StreamNative&apos;s Ursa-based Kafka service delivers the changes CocoIndex computes to every subscriber and keeps them for replay. The cluster has a SASL_SSL endpoint and a hosted console for inspecting messages without writing a consumer. A local broker on &lt;code&gt;localhost:9092&lt;/code&gt; works as well.&lt;/p&gt;
&lt;p&gt;The console shows the &lt;code&gt;cocoindex-csv-rows&lt;/code&gt; topic after the first run:&lt;/p&gt;
&lt;p&gt;Keys are the row&apos;s primary-key column (&lt;code&gt;SKU001&lt;/code&gt;, &lt;code&gt;E101&lt;/code&gt;, …); values are the JSON-encoded rows. Edit a CSV locally and refresh: a new message with the same key appears. A compacted topic eventually keeps only the latest value for each key, so its consumers see the current state.&lt;/p&gt;
&lt;h2&gt;Beyond CSV: unstructured sources on Kafka&lt;/h2&gt;
&lt;p&gt;A Kafka topic takes a message in and delivers it to every consumer, which is why Flink, ksqlDB, vector stores, OLAP sinks, search backends, and agent runtimes can share it. Typical Kafka payloads are structured: orders, clicks, telemetry, and Debezium CDC from Postgres or MySQL. Meeting notes, codebases, design files, PDFs, file shares, and wikis usually stay outside, behind vendor webhooks, nightly batch jobs, and one-off ETL scripts.&lt;/p&gt;
&lt;p&gt;The CSV pipeline above is the general pattern. Replace &lt;code&gt;process_csv&lt;/code&gt; with a function that parses a PDF, chunks a Markdown file, or extracts fields with an LLM, give each output a stable key, and CocoIndex emits the same upsert and delete events for it, and nothing for unchanged keys. When the transformation code changes, CocoIndex re-runs it and sends messages for the outputs whose values changed. The same app can also write to Postgres, a vector database, or a search index next to the Kafka topic, so all of them stay in sync with the source. Consumers that already read Kafka need no new code.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;Try it&lt;/h2&gt;
&lt;p&gt;The Kafka connector ships as an optional dependency group: &lt;code&gt;pip install &quot;cocoindex[kafka]&quot;&lt;/code&gt; adds it to an existing project. To run the example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git clone https://github.com/cocoindex-io/cocoindex
cd cocoindex/examples/csv_to_kafka
cp .env.example .env  # set KAFKA_BOOTSTRAP_SERVERS, KAFKA_TOPIC, and SASL credentials for a managed broker
pip install -e .
cocoindex update -L main.py
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Without a cloud broker, leave &lt;code&gt;KAFKA_BOOTSTRAP_SERVERS&lt;/code&gt; at &lt;code&gt;localhost:9092&lt;/code&gt; and the SASL fields empty. The example works with any Kafka broker that the &lt;code&gt;confluent_kafka&lt;/code&gt; client can connect to.&lt;/p&gt;
&lt;p&gt;Then edit &lt;code&gt;data/products.csv&lt;/code&gt; and watch the messages arrive. The &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex source is on GitHub&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>feature</category><category>examples</category><category>connectors</category><category>incremental-processing</category><category>ai-agents</category><author>George He</author></item><item><title>CocoIndex V1 is Live!</title><link>https://cocoindex.io/blogs/cocoindex-v1/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-v1/</guid><description>CocoIndex V1 is live: a ground-up redesign of incremental data pipelines, built for AI engineers and agent builders shipping RAG, memory, and knowledge graphs.</description><pubDate>Wed, 22 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;import &apos;./fig/v1-native.css&apos;;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex&lt;/a&gt; is an incremental engine for long-horizon agents. It continuously transforms data from any source (codebase, meeting notes) and builds the context for agents deployed in production.&lt;/p&gt;
&lt;p&gt;CocoIndex V1 is now live. It is a redesign of how you write incremental data pipelines, built from a year of watching what people wanted to do with CocoIndex.&lt;/p&gt;
&lt;p&gt;CocoIndex V1 is built for AI engineers and agent builders: people building context, RAG, memory, knowledge graphs that live agents depend on. For that audience the most important design choice is a small one: you write the pipeline in Python, with the data types you already use, so code that Claude or Cursor already writes works here.&lt;/p&gt;
&lt;p&gt;The headline change: V1 has &lt;strong&gt;no DSL&lt;/strong&gt;. Your whole pipeline is now regular &lt;code&gt;async&lt;/code&gt; Python, growing organically as functions call each other. The engine still does what CocoIndex has always done (managed targets, incremental processing, change tracking in Rust), but it now sits behind a Python-native API instead of a DSL with its own type system and rules.&lt;/p&gt;
&lt;p&gt;The mental model is unchanged: you declare what the &lt;em&gt;target&lt;/em&gt; should look like as a function of the &lt;em&gt;source&lt;/em&gt;, and the engine figures out the transitions. CocoIndex calls this &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;&lt;strong&gt;state-driven programming&lt;/strong&gt;&lt;/a&gt;, the same shape as React, spreadsheets, or SQL materialized views.&lt;/p&gt;
&lt;h2&gt;Why CocoIndex: the incremental engine for long-horizon agents&lt;/h2&gt;
&lt;p&gt;[Agents] use tools that were designed for &lt;em&gt;human-speed&lt;/em&gt; interaction … In this world where you have an agent that is operating &lt;span&gt;50 times faster&lt;/span&gt; than a human …&lt;/p&gt;
&lt;p&gt;At &lt;a href=&quot;https://www.nvidia.com/en-us/on-demand/session/gtc26-s82167/&quot;&gt;GTC 2026&lt;/a&gt;, Jeff Dean, in conversation with Bill Dally, described a bottleneck that affects every piece of infrastructure around AI. He compared it to Amdahl&apos;s law: no matter how fast the model gets, end-to-end throughput is capped by the slowest thing in the loop, and for an agent that is often a tool built for people, such as a compiler&apos;s startup time.&lt;/p&gt;
&lt;p&gt;Jeff Dean also stressed low-latency inference for agents that work on their own for hours or even days, doing many things and correcting themselves along the way.&lt;/p&gt;
&lt;p&gt;Data infrastructure is one of those tools, and it matters beyond inference. An agent reasoning over a codebase, a conversation graph, a document corpus, or a stream of events needs that data fresh, organized, and cheap to query throughout the run, not only on the first call, because:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Agents write code.&lt;/strong&gt; The artifacts they produce become source data for the next reasoning step.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Agents make decisions and record them.&lt;/strong&gt; Traces, plans, audit logs: written by agents, read by other agents.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Agents update data while they run.&lt;/strong&gt; A long-horizon agent isn&apos;t a one-shot query; it&apos;s a process that edits its own context as it proceeds.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Source data arrives faster, too.&lt;/strong&gt; Codebases, logs, Slack, PRs, tickets, sensor feeds: all updating in the background, all expected to be visible to whatever the agent is doing next.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The default pattern for indexing that data (&quot;batch-rebuild overnight&quot;) was built for humans who check a dashboard every morning. For agents running 50 times faster, that cadence &lt;em&gt;is&lt;/em&gt; the bottleneck. What agents need is an engine that treats &lt;strong&gt;derived data as a function of source data&lt;/strong&gt; and keeps it in sync &lt;strong&gt;incrementally&lt;/strong&gt;: only what changed gets re-embedded, re-upserted, or re-published, without a full rebuild or a wait for the next batch window.&lt;/p&gt;
&lt;p&gt;That has always been CocoIndex&apos;s job. V1 keeps the same incremental, state-driven guarantees and makes them cover the pipeline shapes agents produce (entity resolution, clustering, multi-phase reduction, per-tenant topologies, conditional targets), beyond &quot;chunk → embed → upsert.&quot;&lt;/p&gt;
&lt;p&gt;The patterns in the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples&quot;&gt;examples gallery&lt;/a&gt; are ones a long-horizon agent can run itself, with outputs that become fresh source data for the next agent and no refresh job to maintain by hand.&lt;/p&gt;
&lt;h2&gt;What is an incremental engine, and why it&apos;s hard to build for production&lt;/h2&gt;
&lt;p&gt;An incremental engine does one job: keep derived data in sync with source data without redoing work that&apos;s already been done. The source data is changing and the processing code is dynamic.&lt;/p&gt;
&lt;p&gt;To do it right, you need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Reliable change detection across heterogeneous sources (filesystems, databases, queues, APIs).&lt;/li&gt;
&lt;li&gt;Content fingerprints stable enough to diff but cheap enough to compute every run.&lt;/li&gt;
&lt;li&gt;Persistent state that records what the last run produced so this run can compare against it.&lt;/li&gt;
&lt;li&gt;Memoization keyed on &lt;em&gt;both&lt;/em&gt; data and code fingerprints so that editing a helper function invalidates only the callers that depended on it.&lt;/li&gt;
&lt;li&gt;Managed target lifecycles (schema evolution, orphan cleanup when a source disappears, idempotent upserts).&lt;/li&gt;
&lt;li&gt;Transactional behavior when you&apos;re writing to multiple targets at once.&lt;/li&gt;
&lt;li&gt;Recovery logic for every partial failure in between.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Building this in-house is a large engineering project, and the maintenance continues as sources, targets, and schemas evolve. CocoIndex ships all of this in the engine, so the code you write is the pipeline itself, not the scaffolding around it.&lt;/p&gt;
&lt;p&gt;Notion &lt;a href=&quot;https://www.notion.com/blog/two-years-of-vector-search-at-notion&quot;&gt;published&lt;/a&gt; the engineering work behind its in-house incremental pipeline for vector search, which serves live agents and runs simpler transformations than the ones above (no clustering, for example).&lt;/p&gt;
&lt;h2&gt;The V1 mental model: declare states, not steps&lt;/h2&gt;
&lt;p&gt;The mental model is the same as in V0; the execution model changed.&lt;/p&gt;
&lt;p&gt;CocoIndex has always been a &lt;strong&gt;state-driven&lt;/strong&gt; framework. You don&apos;t write code that says &quot;compute this delta and apply it&quot;; you describe what the &lt;em&gt;target&lt;/em&gt; should look like as a function of the &lt;em&gt;source&lt;/em&gt;, and the engine works out the transitions. If you&apos;ve used React, spreadsheets, or SQL materialized views, you already know the shape of this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;React&lt;/strong&gt;: declare UI as a function of state → React re-renders what changed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Spreadsheets&lt;/strong&gt;: declare formulas → cells recompute when inputs change.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CocoIndex&lt;/strong&gt;: declare target states as a function of source → engine syncs what changed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What&apos;s new in V1 is &lt;em&gt;how&lt;/em&gt; you express that declaration. The whole pipeline is now plain &lt;code&gt;async&lt;/code&gt; Python, without &lt;code&gt;FlowBuilder&lt;/code&gt;, &lt;code&gt;DataScope&lt;/code&gt;, or a two-phase &quot;define, then run&quot; lifecycle. Functions call other functions, and loops and &lt;code&gt;if&lt;/code&gt; statements are ordinary Python. Behind the scenes, CocoIndex tracks every target state you declare and every memoized intermediate value, so the next run only does what changed.&lt;/p&gt;
&lt;p&gt;V1 is deliberately not intrusive. You can start with a single &lt;code&gt;@coco.fn&lt;/code&gt; on a plain Python function and opt into more of the engine as the pipeline grows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Flip on &lt;code&gt;memo=True&lt;/code&gt; when re-running starts to cost real time.&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;declare_*&lt;/code&gt; targets when you want the engine to own the output lifecycle.&lt;/li&gt;
&lt;li&gt;Move to &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/live_mode/&quot;&gt;live mode&lt;/a&gt; when you want the pipeline to keep watching for changes.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That model rests on a small vocabulary:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;An &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/app/&quot;&gt;&lt;strong&gt;App&lt;/strong&gt;&lt;/a&gt; is the top-level entity you run.&lt;/li&gt;
&lt;li&gt;Inside it, each &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/&quot;&gt;&lt;strong&gt;processing component&lt;/strong&gt;&lt;/a&gt; groups one item&apos;s work with its &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;&lt;strong&gt;target states&lt;/strong&gt;&lt;/a&gt; and runs independently.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;&lt;strong&gt;Incremental processing&lt;/strong&gt;&lt;/a&gt; means only what changed gets reapplied to the target.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/&quot;&gt;&lt;strong&gt;Function memoization&lt;/strong&gt;&lt;/a&gt; skips any function whose input and code haven&apos;t changed since the last run.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What that means in practice is code you don&apos;t have to write: a bookkeeping table tracking which file was last processed, insert / update / delete branches, &quot;did I already embed this chunk?&quot; checks, migration scripts when your schema changes. The engine owns the target state, diffs against the previous run, and only does what changed. V0 already did this; V1 lets you write it as plain Python.&lt;/p&gt;
&lt;p&gt;A complete V1 app (a PDF-to-Markdown converter) is short enough to read at a glance:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import pathlib
import cocoindex as coco
from cocoindex.connectors import localfs
from cocoindex.resources.file import PatternFilePathMatcher
from docling.document_converter import DocumentConverter

_converter = DocumentConverter()

@coco.fn(memo=True)
def process_file(file: localfs.File, outdir: pathlib.Path) -&amp;gt; None:
    markdown = _converter.convert(file.file_path.resolve()).document.export_to_markdown()
    outname = file.file_path.path.stem + &quot;.md&quot;
    localfs.declare_file(outdir / outname, markdown, create_parent_dirs=True)

@coco.fn
async def app_main(sourcedir: pathlib.Path, outdir: pathlib.Path) -&amp;gt; None:
    files = localfs.walk_dir(
        sourcedir, path_matcher=PatternFilePathMatcher(included_patterns=[&quot;**/*.pdf&quot;]),
    )
    await coco.mount_each(process_file, files.items(), outdir)

app = coco.App(&quot;PdfToMarkdown&quot;, app_main,
               sourcedir=pathlib.Path(&quot;./pdf_files&quot;),
               outdir=pathlib.Path(&quot;./out&quot;))
app.update_blocking()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Three things to notice:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;process_file&lt;/code&gt; is just a function: you can set a breakpoint in it, call it directly, or run it under pytest. The &lt;code&gt;@coco.fn(memo=True)&lt;/code&gt; decorator hooks it into the engine&apos;s change-detection and memoization, but doesn&apos;t change its calling convention.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;localfs.declare_file(...)&lt;/code&gt; is a &lt;em&gt;declaration&lt;/em&gt;, not a write. It tells CocoIndex &quot;the target state for this path is this content.&quot; If the target state hasn&apos;t changed since the last run, nothing happens on disk. If the source file disappears, the declaration disappears too, and CocoIndex deletes the corresponding output file automatically.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;coco.mount_each(...)&lt;/code&gt; mounts one &lt;strong&gt;processing component&lt;/strong&gt; per file. Each component is its own unit of incremental change detection: when one file&apos;s content changes, only that component re-runs.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Why V1: the V0 ceiling&lt;/h2&gt;
&lt;p&gt;V0 worked (developers shipped real pipelines in production), but four constraints kept coming back, all consequences of the DSL-first design:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Two worlds, one program.&lt;/strong&gt; &lt;code&gt;FlowBuilder&lt;/code&gt; / &lt;code&gt;DataScope&lt;/code&gt; / &lt;code&gt;DataSlice&lt;/code&gt; for topology, regular Python for leaves. The DSL world couldn&apos;t &lt;code&gt;if&lt;/code&gt; its way into a different shape, couldn&apos;t pass values into normal Python and back. Clustering, entity resolution, reduction across items, conditional sources: every one of them hit the seam.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A separate type system.&lt;/strong&gt; Like a database, the engine had its own types distinct from Python&apos;s, so every Python type you wanted to use needed a bi-directional conversion wired in. &lt;code&gt;dataclass&lt;/code&gt; and &lt;code&gt;NDArray&lt;/code&gt; were covered; a PIL &lt;code&gt;Image&lt;/code&gt; or a pyarrow array was not: if no conversion existed, you couldn&apos;t hand it to a function, and what did cross the boundary got marshaled on the way in and out.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Postgres as a hard dependency.&lt;/strong&gt; The engine used Postgres for its own bookkeeping, so &lt;code&gt;pip install cocoindex &amp;amp;&amp;amp; python script.py&lt;/code&gt; wasn&apos;t a real path: you stood up a database first, even for a tiny local pipeline.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Static topology.&lt;/strong&gt; &lt;code&gt;add_source()&lt;/code&gt; and &lt;code&gt;.export()&lt;/code&gt; were declared before execution, so multi-tenancy, config-driven topologies, and runtime target selection all required scaffolding &lt;em&gt;around&lt;/em&gt; CocoIndex rather than being expressible &lt;em&gt;in&lt;/em&gt; it.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Four shifts that change what you can build&lt;/h2&gt;
&lt;h3&gt;1. No more DSL: the flow grows during execution&lt;/h3&gt;
&lt;p&gt;In V0, the flow had to be fully described before any data moved through it. &lt;code&gt;FlowBuilder&lt;/code&gt; returned a frozen graph; the engine then interpreted that graph at execution time. In V1, the flow is built as your code executes. &lt;code&gt;app_main&lt;/code&gt; runs as the root processing component. Every &lt;code&gt;await coco.mount(...)&lt;/code&gt; it does adds a child component. Every &lt;code&gt;declare_*&lt;/code&gt; call records a target state. The component tree is built by running your code, not by parsing a graph beforehand.&lt;/p&gt;
&lt;p&gt;V1 supports these pipeline shapes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Reduction patterns&lt;/strong&gt;: &quot;for each project, look at all its files, then aggregate.&quot; The &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/multi_codebase_summarization&quot;&gt;multi-codebase summarization example&lt;/a&gt; does exactly this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def process_project(project_name, files, output_dir):
    file_infos = await coco.map(extract_file_info, files)         # fan out
    project_info = await aggregate_project_info(project_name, file_infos)  # reduce
    markdown = generate_markdown(project_name, project_info, file_infos)
    localfs.declare_file(output_dir / f&quot;{project_name}.md&quot;, markdown)
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Multi-phase pipelines with cross-item logic&lt;/strong&gt;: entity resolution across sessions, clustering, deduplication. The &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/conversation_to_knowledge&quot;&gt;conversation-to-knowledge example&lt;/a&gt; uses three phases (per-session extraction, cross-session entity resolution, knowledge-base assembly) all expressed as function calls in a single &lt;code&gt;app_main&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Conditional topology&lt;/strong&gt;: &lt;code&gt;if config.enable_kafka: await kafka.mount_kafka_topic_target(...)&lt;/code&gt;. This needs neither a flag pattern nor a separate flow definition.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The engine calls your functions directly instead of interpreting a graph, so the debugging tools you already use work.&lt;/p&gt;
&lt;h3&gt;2. Native Python types instead of a separate type system&lt;/h3&gt;
&lt;p&gt;V1 doesn&apos;t have a separate type system: it uses Python&apos;s directly. The types V0 supported through bindings (&lt;code&gt;dataclass&lt;/code&gt;, &lt;code&gt;Pydantic&lt;/code&gt;, &lt;code&gt;NDArray&lt;/code&gt;, &lt;code&gt;dict&lt;/code&gt;, &lt;code&gt;list&lt;/code&gt;, &lt;code&gt;tuple&lt;/code&gt;) still work with nothing to wire up, and types V0 couldn&apos;t express (a PIL &lt;code&gt;Image&lt;/code&gt;, a pyarrow array, an arbitrary class from a library you just pulled in) can be passed as function arguments the same way:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from PIL.Image import Image

@coco.fn(memo=True)
async def caption_image(img: Image) -&amp;gt; str:
    return await vlm.describe(img)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That &lt;code&gt;Image&lt;/code&gt; is just &lt;code&gt;PIL.Image&lt;/code&gt;: no wrapper, no conversion. Pass the function a pyarrow &lt;code&gt;Table&lt;/code&gt;, a &lt;code&gt;torch.Tensor&lt;/code&gt;, or any class from a library you happen to have imported; the signature is whatever you&apos;d write in plain Python.&lt;/p&gt;
&lt;p&gt;Targets, function arguments, return types, memoization keys: everything is described in the type hints you&apos;d write anyway. For memoized return values that persist between runs, the same type hint drives serialization; we wrote a long &lt;a href=&quot;https://cocoindex.io/blogs/type-guided-serde&quot;&gt;post on how the type-guided serializer works&lt;/a&gt; underneath.&lt;/p&gt;
&lt;h3&gt;3. Embedded LMDB instead of a Postgres dependency&lt;/h3&gt;
&lt;p&gt;V0&apos;s &quot;Postgres for engine bookkeeping&quot; requirement is gone. V1 stores its internal state in &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/internal_storage/&quot;&gt;LMDB&lt;/a&gt;, an embedded key-value store that lives in a local directory (&lt;code&gt;COCOINDEX_DB&lt;/code&gt;). There&apos;s no server process to run, schema to migrate, or port to expose.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pip install cocoindex
# where CocoIndex keeps its LMDB state
export COCOINDEX_DB=./cocoindex.db
cocoindex update main.py
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That is the setup (the examples ship &lt;code&gt;COCOINDEX_DB&lt;/code&gt; in their &lt;code&gt;.env&lt;/code&gt;). The LMDB store holds the target-state ledger, the memoization cache, and the component-path tree across runs. The memory map starts at 4 GiB, and since 1.0.15 CocoIndex enlarges it automatically when a write needs more space, so &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/internal_storage/&quot;&gt;&lt;code&gt;map_size&lt;/code&gt;&lt;/a&gt; is a starting point, not a cap. On a 64-bit system the map is reserved virtual address space, not physical memory.&lt;/p&gt;
&lt;p&gt;Postgres is still a first-class &lt;strong&gt;target&lt;/strong&gt; (with pgvector support); it&apos;s just no longer required for the engine to function.&lt;/p&gt;
&lt;h3&gt;4. Dynamic sources and targets&lt;/h3&gt;
&lt;p&gt;In V0, sources and targets were declared in the flow definition, before execution. In V1, they&apos;re created during execution, by regular function calls, and the &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/&quot;&gt;component-path tree&lt;/a&gt; tracks their identity across runs. So you can:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Mount a target conditionally&lt;/strong&gt; based on a config row, an environment variable, or a feature flag.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Create different targets per item&lt;/strong&gt;: e.g., one Postgres schema per tenant, one Kafka topic per category, one LanceDB table per dataset.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Build the topology from a database&lt;/strong&gt;: query the list of active tenants at startup and mount one component per tenant, each with its own set of targets. When a tenant disappears from the list, CocoIndex automatically cleans up their target states (because the path is no longer mounted).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/conversation_to_knowledge&quot;&gt;conversation-to-knowledge example&lt;/a&gt; does this for entity types: it iterates over a list of entity configurations and mounts one SurrealDB target per type, all from a dict comprehension in &lt;code&gt;app_main&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;entity_tables = {
    cfg.name: await surrealdb.mount_table_target(SURREAL_DB, cfg.name, entity_schema)
    for cfg in ENTITY_TYPES
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add a new entity type to &lt;code&gt;ENTITY_TYPES&lt;/code&gt;, restart, and a new table appears, managed by CocoIndex from then on. Remove a type, and CocoIndex drops its table, without a migration script and without leaving orphaned data.&lt;/p&gt;
&lt;p&gt;The larger difference from V0 shows when that list isn&apos;t a constant (a changing file, a database row, a live tenant registry): V0 could already generate topology from static inputs at flow-creation time, but couldn&apos;t react when those inputs changed.&lt;/p&gt;
&lt;h2&gt;What we kept from V0&lt;/h2&gt;
&lt;p&gt;V1 exists to make what V0 already did well available to more pipelines. Those guarantees are unchanged, and they now apply across a much wider set of pipeline shapes.&lt;/p&gt;
&lt;h3&gt;Fully managed targets&lt;/h3&gt;
&lt;p&gt;You declare what your target should look like; CocoIndex makes sure it&apos;s in that state, on &lt;em&gt;any&lt;/em&gt; change, whether to source data or to your code. This is the lifecycle, top to bottom:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Upsert (first or changed declaration)&lt;/th&gt;
&lt;th&gt;Delete (no longer declared)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Container&lt;/strong&gt;: schema (tables · directories · other containers)&lt;/td&gt;
&lt;td&gt;Create or alter&lt;/td&gt;
&lt;td&gt;Drop&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Leaf&lt;/strong&gt;: data (rows · files · embeddings · other leaves)&lt;/td&gt;
&lt;td&gt;Insert or update&lt;/td&gt;
&lt;td&gt;Delete&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The target is fully owned by CocoIndex: if you stop declaring something, it goes away. You write neither migrations nor &quot;did I already write this row?&quot; checks, and no orphaned data is left behind. This is the same contract whether the target is a Postgres table, a LanceDB table, a Neo4j node label, or a directory of files on disk. (A Kafka topic gets a tombstone for each key you stop declaring.)&lt;/p&gt;
&lt;h3&gt;Incremental processing, two levels deep&lt;/h3&gt;
&lt;p&gt;Incremental processing is still the core of the engine, and V1 exposes it through two concepts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Components own target states.&lt;/strong&gt; When a component finishes, CocoIndex diffs its declared target states against the last run and applies only the changes (create / alter / drop for containers, insert / update / delete for contents), including recursive cleanup of sub-paths no longer mounted. When a memoized component&apos;s inputs and code haven&apos;t changed, the whole component is skipped.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;@coco.fn&lt;/code&gt; functions participate in change detection.&lt;/strong&gt; Every decorated function&apos;s code is fingerprinted, and that fingerprint propagates up the call chain. Add &lt;code&gt;memo=True&lt;/code&gt; and the return value is also cached, keyed on the function&apos;s arguments plus its code fingerprint and any change-tracked context it reads, so the body is skipped when none of them has changed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Edit a &lt;code&gt;@coco.fn&lt;/code&gt; helper and only the components and memoized callers that depend on it are invalidated.&lt;/p&gt;
&lt;h3&gt;Rust-powered engine&lt;/h3&gt;
&lt;p&gt;The change-detection, fingerprinting, target-state diffing, and persistence are all written in Rust on top of Tokio. That has not changed: Python is the user-facing API, and the hot paths still run in Rust, as they did in V0.&lt;/p&gt;
&lt;h2&gt;An end-to-end text-embedding pipeline&lt;/h2&gt;
&lt;p&gt;Here&apos;s a complete text-embedding pipeline that walks markdown files, chunks them, embeds the chunks with a SentenceTransformer model, and writes everything (with a vector index) to Postgres. It&apos;s the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/text_embedding&quot;&gt;&lt;code&gt;text_embedding&lt;/code&gt; example&lt;/a&gt; trimmed down: every line of pipeline logic is below.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import pathlib
from dataclasses import dataclass
from typing import AsyncIterator, Annotated

import asyncpg
from numpy.typing import NDArray

import cocoindex as coco
from cocoindex.connectors import localfs, postgres
from cocoindex.ops.text import RecursiveSplitter
from cocoindex.ops.sentence_transformers import SentenceTransformerEmbedder
from cocoindex.resources.chunk import Chunk
from cocoindex.resources.file import FileLike, PatternFilePathMatcher
from cocoindex.resources.id import IdGenerator

PG_DB = coco.ContextKey[asyncpg.Pool](&quot;text_embedding_db&quot;)
EMBEDDER = coco.ContextKey[SentenceTransformerEmbedder](&quot;embedder&quot;, detect_change=True)

_splitter = RecursiveSplitter()

@coco.lifespan
async def coco_lifespan(builder: coco.EnvironmentBuilder) -&amp;gt; AsyncIterator[None]:
    async with asyncpg.create_pool(&quot;postgres://...&quot;) as pool:
        builder.provide(PG_DB, pool)
        builder.provide(EMBEDDER, SentenceTransformerEmbedder(&quot;sentence-transformers/all-MiniLM-L6-v2&quot;))
        yield

@dataclass
class DocEmbedding:
    id: int
    filename: str
    chunk_start: int
    chunk_end: int
    text: str
    embedding: Annotated[NDArray, EMBEDDER]

@coco.fn
async def process_chunk(chunk, filename, id_gen, table):
    table.declare_row(row=DocEmbedding(
        id=await id_gen.next_id(chunk.text),
        filename=str(filename),
        chunk_start=chunk.start.char_offset,
        chunk_end=chunk.end.char_offset,
        text=chunk.text,
        embedding=await coco.use_context(EMBEDDER).embed(chunk.text),
    ))

@coco.fn(memo=True)
async def process_file(file: FileLike, table) -&amp;gt; None:
    text = await file.read_text()
    chunks = _splitter.split(text, chunk_size=2000, chunk_overlap=500, language=&quot;markdown&quot;)
    id_gen = IdGenerator()
    await coco.map(process_chunk, chunks, file.file_path.path, id_gen, table)

@coco.fn
async def app_main(sourcedir: pathlib.Path) -&amp;gt; None:
    table = await postgres.mount_table_target(
        PG_DB, table_name=&quot;doc_embeddings&quot;,
        table_schema=await postgres.TableSchema.from_class(DocEmbedding, primary_key=[&quot;id&quot;]),
    )
    table.declare_vector_index(column=&quot;embedding&quot;)

    files = localfs.walk_dir(
        sourcedir, recursive=True,
        path_matcher=PatternFilePathMatcher(included_patterns=[&quot;**/*.md&quot;]),
    )
    await coco.mount_each(process_file, files.items(), table)

app = coco.App(coco.AppConfig(name=&quot;TextEmbedding&quot;), app_main,
               sourcedir=pathlib.Path(&quot;./markdown_files&quot;))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Several things you would expect in a pipeline are not in the code, because the engine handles them:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Not in the code&lt;/th&gt;
&lt;th&gt;What handles it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A flow definition phase&lt;/td&gt;
&lt;td&gt;&lt;code&gt;app_main&lt;/code&gt; runs and the topology emerges.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Custom column types&lt;/td&gt;
&lt;td&gt;&lt;code&gt;embedding: Annotated[NDArray, EMBEDDER]&lt;/code&gt; is the schema; &lt;code&gt;from_class&lt;/code&gt; reads it.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Insert / update / delete branches&lt;/td&gt;
&lt;td&gt;&lt;code&gt;declare_row(...)&lt;/code&gt; describes the desired state; the engine diffs.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A &quot;did this chunk already get embedded?&quot; check&lt;/td&gt;
&lt;td&gt;Memoization.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A bookkeeping table for which file was last processed&lt;/td&gt;
&lt;td&gt;LMDB keeps the previous run&apos;s fingerprints.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A manual migration when you change &lt;code&gt;DocEmbedding&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Schema evolution is part of the managed-target contract.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The same code handles every kind of change. Pick one below to see what the next &lt;code&gt;cocoindex update&lt;/code&gt; does: which per-file components run, which memoized calls hit, and which rows change in Postgres.&lt;/p&gt;
&lt;h2&gt;Pipeline shapes V0 couldn&apos;t express&lt;/h2&gt;
&lt;p&gt;A short tour of pipeline shapes the V1 model makes natural, drawn from the example gallery:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/multi_codebase_summarization&quot;&gt;Multi-codebase summarization&lt;/a&gt;&lt;/strong&gt;: fan out per project, fan out per file with &lt;code&gt;coco.map&lt;/code&gt;, reduce back up to a project summary, write a markdown file per project. The control flow is plain Python; the engine decides which projects need re-summarizing.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/conversation_to_knowledge&quot;&gt;Conversation-to-knowledge&lt;/a&gt;&lt;/strong&gt;: three phases in one &lt;code&gt;app_main&lt;/code&gt;: per-session extraction (&lt;code&gt;use_mount&lt;/code&gt; per YouTube ID), cross-session entity resolution (&lt;code&gt;use_mount&lt;/code&gt; per entity type), and knowledge-base assembly (one final &lt;code&gt;mount&lt;/code&gt;). Each phase reads the outputs of the prior one through normal function returns.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/csv_to_kafka&quot;&gt;CSV → Kafka live&lt;/a&gt;&lt;/strong&gt;: a live filesystem watcher feeding a Kafka topic target, producing one message per changed row (a tombstone when a row is deleted), in about 60 lines. File-level source, row-level change events: one Kafka message per changed CSV row.&lt;/p&gt;
&lt;p&gt;Most V0 connectors came over to V1, and new ones joined them, including SurrealDB, SQLite, Kafka, Valkey, Snowflake, BigQuery and Iggy. Examples include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/hn_trending_topics&quot;&gt;HN trending topics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/image_search&quot;&gt;Image search&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/pdf_embedding&quot;&gt;PDF embedding&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/paper_metadata&quot;&gt;Paper metadata extraction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/amazon_s3_embedding&quot;&gt;Amazon S3 + embeddings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/gdrive_text_embedding&quot;&gt;Google Drive + embeddings&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/code_embedding_lancedb&quot;&gt;Code embedding to LanceDB&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Try it&lt;/h2&gt;
&lt;pre&gt;&lt;code&gt;pip install cocoindex
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then either follow the &lt;a href=&quot;https://cocoindex.io/docs/getting_started/quickstart/&quot;&gt;Quickstart&lt;/a&gt; (PDF → Markdown in about 30 lines), or clone the repo and run any of the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples&quot;&gt;examples&lt;/a&gt; directly:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git clone https://github.com/cocoindex-io/cocoindex
cd cocoindex/examples/text_embedding
pip install -e .
cocoindex update main.py
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The docs for V1 live at &lt;a href=&quot;https://cocoindex.io/docs/&quot;&gt;cocoindex.io/docs&lt;/a&gt;. The pieces most worth reading first:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;&lt;strong&gt;Core Concepts&lt;/strong&gt;&lt;/a&gt;: state-driven processing, target states, processing components, memoization&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/app/&quot;&gt;&lt;strong&gt;App&lt;/strong&gt;&lt;/a&gt;: top-level entry point, lifespan, CLI&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/&quot;&gt;&lt;strong&gt;Processing Component&lt;/strong&gt;&lt;/a&gt;: &lt;code&gt;mount&lt;/code&gt;, &lt;code&gt;use_mount&lt;/code&gt;, &lt;code&gt;mount_each&lt;/code&gt;, component paths&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/&quot;&gt;&lt;strong&gt;Function&lt;/strong&gt;&lt;/a&gt;: &lt;code&gt;@coco.fn&lt;/code&gt;, memoization, change detection&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/live_mode/&quot;&gt;&lt;strong&gt;Live Mode&lt;/strong&gt;&lt;/a&gt;: pipelines that keep watching for changes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Report bugs, request features, or suggest documentation changes on &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/issues&quot;&gt;GitHub issues&lt;/a&gt;. Join the community on &lt;a href=&quot;https://discord.com/invite/zpA9S2DR7s&quot;&gt;Discord&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>announcement</category><category>feature</category><category>incremental-processing</category><category>architecture</category><category>ai-agents</category><author>Linghua Jin, George He</author></item><item><title>Build a Knowledge Graph from YouTube Podcasts with an LLM</title><link>https://cocoindex.io/blogs/podcast-to-knowledge-graph/</link><guid isPermaLink="true">https://cocoindex.io/blogs/podcast-to-knowledge-graph/</guid><description>Build a pipeline that turns YouTube podcasts into a knowledge graph: extract speakers, statements, and entities with an LLM, then dedupe them with embeddings.</description><pubDate>Thu, 02 Apr 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;An agent that answers questions about a podcast archive has to know who said what, about which technology, and in which episode. A transcript does not give it that structure. Search over transcript chunks returns passages. Listing every guest who discussed large language models across 50 episodes, or matching &quot;GPT4&quot; in one episode to &quot;GPT-4&quot; in another, needs structure that the transcript lacks.&lt;/p&gt;
&lt;p&gt;This tutorial builds that structure as a knowledge graph. A &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex&lt;/a&gt; app downloads YouTube episodes, transcribes them with speaker labels, &lt;a href=&quot;https://cocoindex.io/docs/ops/litellm/&quot;&gt;uses an LLM to extract&lt;/a&gt; statements and the people, technologies and organizations they mention, merges duplicate names across episodes, and stores the result in &lt;a href=&quot;https://github.com/surrealdb/surrealdb&quot;&gt;SurrealDB&lt;/a&gt; as a graph.&lt;/p&gt;
&lt;p&gt;The code follows the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/conversation_to_knowledge&quot;&gt;&lt;code&gt;conversation_to_knowledge&lt;/code&gt;&lt;/a&gt; example (Python package &lt;code&gt;conv_knowledge&lt;/code&gt;) on CocoIndex v1. If you are new to knowledge graphs, the &lt;a href=&quot;/blogs/knowledge-graph-for-docs/&quot;&gt;documents-to-graph tutorial&lt;/a&gt; covers the basics on a smaller pipeline.&lt;/p&gt;
&lt;h2&gt;Why an agent needs a graph of the archive&lt;/h2&gt;
&lt;p&gt;CocoIndex is an &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;incremental&lt;/a&gt; data transformation framework: it records what each function produced, so a re-run processes only new or changed episodes, and it deletes the graph rows of an episode you remove. The &lt;a href=&quot;#what-re-runs-when-you-change-the-pipeline&quot;&gt;demo further down&lt;/a&gt; shows what each kind of change re-runs.&lt;/p&gt;
&lt;h2&gt;What the graph holds&lt;/h2&gt;
&lt;p&gt;The graph has 5 node types and 4 relationship types:&lt;/p&gt;
&lt;p&gt;A &lt;strong&gt;session&lt;/strong&gt; is one podcast episode. A &lt;strong&gt;statement&lt;/strong&gt; is one claim extracted from the conversation, for example &quot;Scaling laws suggest that larger models will continue to improve.&quot; Each statement links to the person who made it and to the entities it mentions.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Person&lt;/strong&gt;, &lt;strong&gt;tech&lt;/strong&gt; and &lt;strong&gt;org&lt;/strong&gt; are named entities. The same entity often appears under different names across episodes (&quot;GPT-4&quot;, &quot;GPT4&quot;, &quot;OpenAI&apos;s GPT-4&quot;). &lt;a href=&quot;https://cocoindex.io/docs/ops/entity_resolution/&quot;&gt;Entity resolution&lt;/a&gt; merges them into one node, as described in &lt;a href=&quot;#phase-2-merge-duplicate-entities-across-episodes&quot;&gt;phase 2&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;The pipeline runs in three phases&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Phase 1&lt;/strong&gt; processes each episode on its own: download, transcribe, then two LLM calls that identify the speakers and extract statements. The session and its statements are written right away, because they do not depend on other episodes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Phase 2&lt;/strong&gt; collects the raw entity names (persons, techs, orgs) from all episodes and merges duplicates with embedding similarity and LLM confirmation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Phase 3&lt;/strong&gt; writes one node per canonical entity and the relationships that point to those nodes.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Phase 1: process each episode&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;process_session&lt;/code&gt; handles one episode. It fetches the transcript, runs the two extraction steps, and declares the session and its statements:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def process_session(
    youtube_id: str,
    session_table: surrealdb.TableTarget[Any],
    statement_table: surrealdb.TableTarget[Any],
    session_statement_rel: surrealdb.RelationTarget[Any],
) -&amp;gt; SessionRawEntities:
    &quot;&quot;&quot;Process a single session: fetch, extract (2-step), declare session + statements.&quot;&quot;&quot;
    transcript = await fetch_transcript(youtube_id)

    # Step 1: format with empty map (no names known yet), then extract metadata
    step1_text = format_transcript(transcript.utterances, {})
    metadata = await extract_metadata(step1_text, transcript)

    # Step 2: format with real names, then extract statements
    speaker_map = {s.label: s.name for s in metadata.speakers}
    step2_text = format_transcript(transcript.utterances, speaker_map)
    stmt_extraction = await extract_statements(step2_text)
    # ... declare the session and its statements (below)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The sections below follow it step by step.&lt;/p&gt;
&lt;h3&gt;Fetch and transcribe the audio&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;fetch_transcript&lt;/code&gt; downloads the audio with &lt;code&gt;yt-dlp&lt;/code&gt; and transcribes it with &lt;a href=&quot;https://www.assemblyai.com/&quot;&gt;AssemblyAI&lt;/a&gt;. With &lt;code&gt;speaker_labels=True&lt;/code&gt;, AssemblyAI returns utterances labeled by speaker (&quot;A&quot;, &quot;B&quot;, ...). yt-dlp also returns the YouTube metadata (channel, title, description, upload date), which step 1 uses to name the speakers:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def fetch_transcript(youtube_id: str) -&amp;gt; SessionTranscript:
    &quot;&quot;&quot;Download audio via yt-dlp, transcribe with speaker diarization via AssemblyAI.&quot;&quot;&quot;
    import yt_dlp

    url = f&quot;https://www.youtube.com/watch?v={youtube_id}&quot;

    with tempfile.TemporaryDirectory() as tmpdir:
        # 1. Download audio + metadata via yt-dlp
        outtmpl = os.path.join(tmpdir, &quot;audio.%(ext)s&quot;)
        ydl_opts: dict[str, Any] = {
            &quot;format&quot;: &quot;bestaudio/best&quot;,
            &quot;outtmpl&quot;: outtmpl,
            &quot;postprocessors&quot;: [
                {
                    &quot;key&quot;: &quot;FFmpegExtractAudio&quot;,
                    &quot;preferredcodec&quot;: &quot;mp3&quot;,
                    &quot;preferredquality&quot;: &quot;64&quot;,
                }
            ],
            &quot;quiet&quot;: True,
            &quot;no_warnings&quot;: True,
        }
        with yt_dlp.YoutubeDL(ydl_opts) as ydl:
            info = ydl.extract_info(url, download=True)
        # ... read channel, title, description, upload date; find the .mp3 (actual_path)

        # 2. Transcribe with AssemblyAI (speaker diarization)
        aai.settings.api_key = os.environ[&quot;ASSEMBLYAI_API_KEY&quot;]
        config = aai.TranscriptionConfig(
            speaker_labels=True,
        )
        # SDK 0.58.0 enum doesn&apos;t include newer models; pass raw string.
        config.speech_models = [&quot;universal-3-pro&quot;]  # type: ignore[assignment]
        transcript = aai.Transcriber().transcribe(actual_path, config)

        if transcript.status == aai.TranscriptStatus.error:
            raise RuntimeError(f&quot;AssemblyAI transcription failed: {transcript.error}&quot;)

    # 3. Build structured utterances
    utterances = _extract_utterances(transcript)

    return SessionTranscript(
        utterances=utterances,
        yt_channel=yt_channel,
        yt_title=yt_title,
        yt_description=yt_description,
        yt_upload_date=yt_upload_date,
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;@coco.fn(memo=True)&lt;/code&gt; &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#memoization&quot;&gt;memoizes&lt;/a&gt; the function. On a later run with the same &lt;code&gt;youtube_id&lt;/code&gt; and the same function code, CocoIndex returns the stored transcript and does not download or transcribe the audio again. This matters while you iterate on the extraction prompts: re-running an extraction step does not repeat the transcription.&lt;/p&gt;
&lt;h3&gt;Two LLM passes: speakers first, then statements&lt;/h3&gt;
&lt;p&gt;The example splits extraction into two LLM calls. To attribute a statement, the LLM has to know who is speaking, and the diarized transcript only says &quot;Speaker A&quot; and &quot;Speaker B&quot;. So the pipeline makes two passes over the transcript. Both use &lt;code&gt;format_transcript()&lt;/code&gt;, which replaces each diarization label with a name when one is known:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def format_transcript(
    utterances: list[Utterance], speaker_map: Mapping[str, str | None]
) -&amp;gt; str:
    &quot;&quot;&quot;Format structured utterances into text with speaker names.

    Used by both extraction steps:
    - Step 1: pass empty dict → all speakers shown as &quot;(Speaker A)&quot;, ...
    - Step 2: pass mapping from Step 1 → recognized speakers get real names,
              unrecognized stay as &quot;(Speaker X)&quot;
    &quot;&quot;&quot;
    lines: list[str] = []
    for u in utterances:
        name = speaker_map.get(u.speaker)
        if name is not None:
            lines.append(f&quot;{name}: {u.text}&quot;)
        else:
            lines.append(f&quot;(Speaker {u.speaker}): {u.text}&quot;)
    return &quot;\n&quot;.join(lines)
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;Step 1: identify the speakers&lt;/h4&gt;
&lt;p&gt;Step 1 gives the LLM the transcript with generic labels, plus the YouTube channel, title, description and upload date as clues. It returns the session metadata and a name for each speaker it can identify:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def extract_metadata(
    reformatted_transcript: str, transcript: SessionTranscript
) -&amp;gt; SessionMetadata:
    &quot;&quot;&quot;Give LLM the reformatted transcript + all YouTube metadata to identify speakers.&quot;&quot;&quot;
    client = cast(
        instructor.AsyncInstructor,
        instructor.from_litellm(litellm.acompletion, mode=instructor.Mode.JSON),
    )
    result = await client.chat.completions.create(
        model=coco.use_context(LLM_MODEL),
        response_model=SessionMetadata,
        messages=[
            {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: METADATA_PROMPT},
            {
                &quot;role&quot;: &quot;user&quot;,
                &quot;content&quot;: (
                    f&quot;YouTube channel: {transcript.yt_channel}\n&quot;
                    f&quot;Video title: {transcript.yt_title}\n&quot;
                    f&quot;Description: {transcript.yt_description or &apos;N/A&apos;}\n&quot;
                    f&quot;Upload date: {transcript.yt_upload_date or &apos;unknown&apos;}\n\n&quot;
                    f&quot;Transcript:\n{reformatted_transcript}&quot;
                ),
            },
        ],
    )
    # Re-validate to restore class identity for pickling.
    metadata = SessionMetadata.model_validate(result.model_dump())
    # Post-filter: drop speakers whose name is not a plausible person name
    # (e.g. LLM might output &quot;null&quot;, &quot;all&quot;, &quot;unknown&quot;, single words, etc.)
    metadata.speakers = [
        s for s in metadata.speakers if _is_plausible_person_name(s.name)
    ]
    return metadata
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The response is a Pydantic model, enforced by &lt;a href=&quot;https://github.com/instructor-ai/instructor&quot;&gt;instructor&lt;/a&gt;. The &lt;code&gt;Field&lt;/code&gt; descriptions are part of the JSON schema that instructor sends, so they also guide the LLM:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;class SpeakerIdentification(pydantic.BaseModel):
    &quot;&quot;&quot;Maps a diarization label to a real person name.&quot;&quot;&quot;

    label: str = pydantic.Field(
        description=&apos;The diarization label from the transcript, e.g. &quot;A&quot;, &quot;B&quot;.&apos;
    )
    name: str = pydantic.Field(
        description=(
            &quot;Full canonical, Wikipedia-style name of the speaker &quot;
            &apos;(e.g. &quot;Lex Fridman&quot;, &quot;Sam Altman&quot;). &apos;
            &quot;Only include speakers you can confidently identify — do not guess.&quot;
        )
    )

class SessionMetadata(pydantic.BaseModel):
    &quot;&quot;&quot;LLM output from Step 1: session metadata + speaker mapping.&quot;&quot;&quot;

    name: str = pydantic.Field(
        description=&quot;A clear, descriptive name for this session or episode.&quot;
    )
    description: str | None = pydantic.Field(
        default=None,
        description=&quot;A brief 1-2 sentence summary of the session&apos;s main topics.&quot;,
    )
    date: str | None = pydantic.Field(
        default=None,
        description=(
            &quot;Date of the session in ISO format (YYYY-MM-DD). &quot;
            &quot;Use the date mentioned in the conversation if available; &quot;
            &quot;otherwise fall back to the upload date.&quot;
        ),
    )
    speakers: list[SpeakerIdentification] = pydantic.Field(
        description=(
            &quot;Identified speakers: maps each diarization label to the speaker&apos;s &quot;
            &quot;real full name. Omit any speaker you cannot confidently identify.&quot;
        )
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The post-filter in &lt;code&gt;extract_metadata&lt;/code&gt; keeps only names of at least two words, so an answer such as &quot;unknown&quot; or &quot;Lex&quot; is not used as a speaker name in step 2 or as a session participant.&lt;/p&gt;
&lt;h4&gt;Step 2: extract statements with real names&lt;/h4&gt;
&lt;p&gt;Step 2 reformats the transcript with the names from step 1 (&lt;code&gt;speaker_map&lt;/code&gt; in &lt;code&gt;process_session&lt;/code&gt;), so &quot;Speaker A&quot; becomes &quot;Lex Fridman&quot;, and asks the LLM for thematic statements:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def extract_statements(
    reformatted_transcript: str,
) -&amp;gt; StatementExtraction:
    &quot;&quot;&quot;Extract statements and involved entities from the reformatted transcript.&quot;&quot;&quot;
    client = cast(
        instructor.AsyncInstructor,
        instructor.from_litellm(litellm.acompletion, mode=instructor.Mode.JSON),
    )
    result = await client.chat.completions.create(
        model=coco.use_context(LLM_MODEL),
        response_model=StatementExtraction,
        messages=[
            {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: STATEMENTS_PROMPT},
            {
                &quot;role&quot;: &quot;user&quot;,
                &quot;content&quot;: f&quot;Transcript:\n{reformatted_transcript}&quot;,
            },
        ],
    )
    # Re-validate to restore class identity for pickling.
    extraction = StatementExtraction.model_validate(result.model_dump())
    # Post-filter: strip speaker labels that leaked through from the LLM
    for stmt in extraction.statements:
        stmt.speakers = [s for s in stmt.speakers if not is_speaker_label(s)]
        stmt.mentioned_person = [
            p for p in stmt.mentioned_person if not is_speaker_label(p)
        ]
    return extraction
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each statement carries the speakers who made it and the entities it is about:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;class RawStatement(pydantic.BaseModel):
    &quot;&quot;&quot;A thematic claim or statement made during the session.&quot;&quot;&quot;

    statement: str = pydantic.Field(
        description=(
            &quot;The claim or assertion, written as a clear, standalone sentence. &quot;
            &quot;Do NOT include the speaker&apos;s name or attribution &quot;
            &apos;(avoid &quot;X says...&quot;, &quot;X believes...&quot;, &quot;According to X...&quot;) — &apos;
            &quot;the speaker is captured separately.&quot;
        )
    )
    speakers: list[str] = pydantic.Field(
        description=(
            &quot;Full canonical names of the speakers who made this statement, &quot;
            &quot;exactly as they appear in the transcript.&quot;
        )
    )
    mentioned_person: list[str] = pydantic.Field(
        default=[],
        description=(
            &quot;Full canonical names of people this statement is ABOUT. &quot;
            &quot;Do NOT include the speakers themselves unless the statement is &quot;
            &quot;specifically about them (e.g. their background or credentials).&quot;
        ),
    )
    mentioned_tech: list[str] = pydantic.Field(
        default=[],
        description=&quot;Technologies, tools, frameworks, or technical concepts this statement is about.&quot;,
    )
    mentioned_org: list[str] = pydantic.Field(
        default=[],
        description=&quot;Organizations or companies this statement is about, using their canonical names.&quot;,
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Every entity name has to be &lt;strong&gt;self-contained&lt;/strong&gt;. The step 2 prompt (&lt;code&gt;STATEMENTS_PROMPT&lt;/code&gt;) tells the LLM: &quot;Never use pronouns (&quot;he&quot;, &quot;she&quot;, &quot;they&quot;), speaker labels (&quot;Speaker A&quot;), or contextual references (&quot;the host&quot;, &quot;the guest&quot;, &quot;the interviewer&quot;). Every name must be a clear, unambiguous identifier that stands on its own.&quot; Statements from different episodes are joined later, and a name like &quot;he&quot; or &quot;the host&quot; means nothing outside its own transcript.&lt;/p&gt;
&lt;h3&gt;Declare the session and its statements&lt;/h3&gt;
&lt;p&gt;After extraction, &lt;code&gt;process_session&lt;/code&gt; declares the session and its statements as records in SurrealDB. CocoIndex uses a declarative model: you describe the &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;target state&lt;/a&gt;, and the framework works out the inserts, updates and deletes.&lt;/p&gt;
&lt;p&gt;IDs come from &lt;a href=&quot;https://cocoindex.io/docs/common_resources/id_generation/&quot;&gt;&lt;code&gt;IdGenerator&lt;/code&gt;&lt;/a&gt;, whose IDs are stable across runs: the same calls in the same component return the same IDs, so a re-run does not create duplicates. &lt;code&gt;next_id()&lt;/code&gt; with no argument gives the next ID in sequence. &lt;code&gt;next_id(stmt.statement)&lt;/code&gt; ties the ID to the statement text, so a statement keeps its ID when the order of statements changes:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    id_gen = IdGenerator(youtube_id)

    # Declare session node (store the fully-resolved transcript)
    session_id = await id_gen.next_id()
    session = Session(
        id=session_id,
        youtube_id=youtube_id,
        name=metadata.name or transcript.yt_title,
        description=metadata.description,
        transcript=step2_text,
        date=metadata.date or transcript.yt_upload_date,
    )
    session_table.declare_record(row=session)

    # Declare statements + session_statement edges
    identified_stmts: list[IdentifiedStatement] = []
    for stmt in stmt_extraction.statements:
        stmt_id = await id_gen.next_id(stmt.statement)
        statement_table.declare_record(
            row=Statement(id=stmt_id, statement=stmt.statement)
        )
        session_statement_rel.declare_relation(from_id=session_id, to_id=stmt_id)
        identified_stmts.append(IdentifiedStatement(id=stmt_id, raw=stmt))
    # ... return SessionRawEntities(...) with the speakers and statements
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Because a statement&apos;s ID comes from its text, a statement that comes back worded differently after a prompt change is a new row, and CocoIndex deletes the old one.&lt;/p&gt;
&lt;h3&gt;One component per episode&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;app_main&lt;/code&gt; reads the URLs from every &lt;code&gt;.txt&lt;/code&gt; file under &lt;code&gt;INPUT_DIR&lt;/code&gt; (default &lt;code&gt;./input&lt;/code&gt;) and mounts &lt;code&gt;process_session&lt;/code&gt; once per YouTube ID with &lt;code&gt;coco.use_mount()&lt;/code&gt;. Each mount is a &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/&quot;&gt;processing component&lt;/a&gt;: a unit of work that CocoIndex tracks on its own, together with the rows it declared:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    session_coros = []
    async for _key, file in files.items():
        text = await file.read_text()
        for line in text.strip().splitlines():
            line = line.strip()
            if not line or line.startswith(&quot;#&quot;):
                continue
            youtube_id = extract_video_id(line)
            session_coros.append(
                coco.use_mount(
                    coco.component_subpath(&quot;session&quot;, youtube_id),
                    process_session,
                    youtube_id,
                    session_table,
                    statement_table,
                    session_statement_rel,
                )
            )
    all_session_raw = list(await asyncio.gather(*session_coros))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;process_session&lt;/code&gt; is memoized too, so on a re-run an unchanged episode is skipped as a whole: its body does not run, and the rows it declared last time are kept. A URL you delete from the input files is no longer mounted, and CocoIndex deletes its session, statements and &lt;code&gt;session_statement&lt;/code&gt; edges.&lt;/p&gt;
&lt;p&gt;Each component returns a &lt;code&gt;SessionRawEntities&lt;/code&gt;, the raw names and statements that phases 2 and 3 need:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@dataclass
class SessionRawEntities:
    &quot;&quot;&quot;Raw entities from a single session, for entity resolution.&quot;&quot;&quot;

    session_id: int
    # Maps entity type name → session-level participants (e.g. &quot;person&quot; → identified speakers).
    # Statement-level entities are accessed directly via IdentifiedStatement.raw.
    raw_entities: dict[str, list[str]]
    statements: list[IdentifiedStatement]
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Phase 2: merge duplicate entities across episodes&lt;/h2&gt;
&lt;p&gt;After phase 1, the raw names from all episodes contain duplicates: &quot;GPT-4&quot; and &quot;GPT4&quot;, &quot;Google&quot; and &quot;Google LLC&quot;, &quot;Sam Altman&quot; and &quot;Samuel Altman&quot;. The example merges them with &lt;code&gt;resolve_entities&lt;/code&gt; from &lt;a href=&quot;https://cocoindex.io/docs/ops/entity_resolution/&quot;&gt;&lt;code&gt;cocoindex.ops.entity_resolution&lt;/code&gt;&lt;/a&gt; and its built-in LLM resolver, &lt;code&gt;LlmPairResolver&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from cocoindex.ops.entity_resolution import resolve_entities
from cocoindex.ops.entity_resolution.llm_resolver import LlmPairResolver
from cocoindex.ops.sentence_transformers import SentenceTransformerEmbedder

# ...
EMBEDDER = coco.ContextKey[SentenceTransformerEmbedder](&quot;embedder&quot;, detect_change=True)

@coco.fn(memo=True)
async def _resolve_entities(
    all_raw_entities: set[str],
) -&amp;gt; dict[str, str | None]:
    result = await resolve_entities(
        entities=all_raw_entities,
        embedder=coco.use_context(EMBEDDER),
        resolve_pair=LlmPairResolver(
            model=coco.use_context(RESOLUTION_LLM_MODEL),
        ),
    )
    return result.to_dict()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;resolve_entities&lt;/code&gt; works in two stages:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;It embeds every name (the app provides &lt;code&gt;Snowflake/snowflake-arctic-embed-xs&lt;/code&gt; as the embedder) and uses a FAISS index to compare each name, in sorted order, with the canonical names before it. Up to 5 candidates within cosine distance 0.3 (similarity of at least 0.7) count as near-matches.&lt;/li&gt;
&lt;li&gt;For each name with candidates, it asks the pair resolver whether the name matches one of them. &lt;code&gt;LlmPairResolver&lt;/code&gt; sends the name and its candidates to the LLM, which returns the match and which side should be the canonical name.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;A name with no candidate within the threshold never reaches the LLM, so the number of LLM calls follows the number of near-matches. The embeddings and each decision (one name and its candidate list) are memoized. On a later run, only new names are embedded, and LLM calls go to new names and to names whose candidate list changed. The resolver model is set separately from the extraction model, with &lt;code&gt;RESOLUTION_LLM_MODEL&lt;/code&gt; (default &lt;code&gt;openai/gpt-5-mini&lt;/code&gt;). The result maps each name to the name it merged into, or to &lt;code&gt;None&lt;/code&gt; when the name is itself canonical (phase 3 follows the chain to the root), for example &lt;code&gt;{&quot;Google&quot;: None, &quot;Google LLC&quot;: &quot;Google&quot;}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;/blogs/meeting-notes-graph/&quot;&gt;meeting notes graph tutorial&lt;/a&gt; uses the same entity resolution with a Neo4j target.&lt;/p&gt;
&lt;p&gt;Resolution runs once per entity type (person, tech, org), each as its own component, and the three run concurrently:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    entity_dedup: dict[str, dict[str, str | None]] = dict(
        zip(
            [cfg.name for cfg in ENTITY_TYPES],
            await asyncio.gather(
                *(
                    coco.use_mount(
                        coco.component_subpath(&quot;resolve&quot;, cfg.name),
                        _resolve_entities,
                        _collect_all_raw(all_session_raw, cfg.name),
                    )
                    for cfg in ENTITY_TYPES
                )
            ),
        )
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Phase 3: write the knowledge graph&lt;/h2&gt;
&lt;p&gt;With the dedup maps ready, &lt;code&gt;create_knowledge_base&lt;/code&gt; declares one node per canonical entity, then every relationship with canonical names. A helper chases the dedup chain to the root name:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def resolve_canonical(name: str, dedup: dict[str, str | None]) -&amp;gt; str:
    &quot;&quot;&quot;Chase dedup chains to find the canonical name.&quot;&quot;&quot;
    while dedup.get(name) is not None:
        name = dedup[name]  # type: ignore[assignment]
    return name
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn
async def create_knowledge_base(
    all_session_raw: list[SessionRawEntities],
    entity_dedup: dict[str, dict[str, str | None]],
    entity_tables: dict[str, surrealdb.TableTarget[Any]],
    person_session_rel: surrealdb.RelationTarget[Any],
    person_statement_rel: surrealdb.RelationTarget[Any],
    statement_mentions_rel: surrealdb.RelationTarget[Any],
) -&amp;gt; None:
    &quot;&quot;&quot;Declare canonical entity nodes and all relationships.&quot;&quot;&quot;
    # Declare canonical nodes for each entity type (name is the ID)
    for cfg in ENTITY_TYPES:
        dedup = entity_dedup[cfg.name]
        table = entity_tables[cfg.name]
        for name, upstream in dedup.items():
            if upstream is None:
                table.declare_record(row=Entity(id=name, name=name))

    person_dedup = entity_dedup[PERSON_ENTITY_NAME]

    # Declare relationships
    for session_raw in all_session_raw:
        # person_session: person attended session
        for person_name in session_raw.raw_entities.get(PERSON_ENTITY_NAME, []):
            canonical = resolve_canonical(person_name, person_dedup)
            person_session_rel.declare_relation(
                from_id=canonical,
                to_id=session_raw.session_id,
            )

        # person_statement + statement_mentions
        for identified in session_raw.statements:
            stmt = identified.raw
            stmt_id = identified.id
            # person_statement: person made the statement
            seen_speakers: set[str] = set()
            for speaker in stmt.speakers:
                canonical = resolve_canonical(speaker, person_dedup)
                if canonical not in seen_speakers:
                    seen_speakers.add(canonical)
                    person_statement_rel.declare_relation(
                        from_id=canonical, to_id=stmt_id
                    )
            # statement_mentions: deduplicate after resolution
            for cfg in ENTITY_TYPES:
                dedup = entity_dedup[cfg.name]
                table = entity_tables[cfg.name]
                for canonical in {
                    resolve_canonical(e, dedup)
                    for e in getattr(stmt, f&quot;mentioned_{cfg.name}&quot;)
                }:
                    statement_mentions_rel.declare_relation(
                        from_id=stmt_id,
                        to_id=canonical,
                        to_table=table,
                    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;statement_mentions&lt;/code&gt; is &lt;strong&gt;polymorphic&lt;/strong&gt;: its target can be a person, a tech or an org. &lt;code&gt;app_main&lt;/code&gt; mounts it with a list of target tables, and each &lt;code&gt;declare_relation&lt;/code&gt; call names the table with &lt;code&gt;to_table&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    statement_mentions_rel = await surrealdb.mount_relation_target(
        SURREAL_DB,
        &quot;statement_mentions&quot;,
        statement_table,
        [entity_tables[cfg.name] for cfg in ENTITY_TYPES],  # polymorphic TO
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;create_knowledge_base&lt;/code&gt; is not memoized, so it runs on every update. It makes no LLM calls, and CocoIndex compares what it declares with the previous run and writes only the difference to SurrealDB.&lt;/p&gt;
&lt;h2&gt;What re-runs when you change the pipeline&lt;/h2&gt;
&lt;p&gt;Typical changes are adding or removing episodes, adding an entity type such as &lt;code&gt;Product&lt;/code&gt;, or editing a prompt. A memoized function re-runs when its logic (its code, the &lt;code&gt;@coco.fn&lt;/code&gt; functions it calls, declared &lt;code&gt;deps&lt;/code&gt;), its arguments, or a change-detected &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/context/&quot;&gt;context value&lt;/a&gt; it reads has changed; otherwise CocoIndex reuses its result. Pick a change below and run the pipeline again:&lt;/p&gt;
&lt;p&gt;The demo shows these cases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Add an episode.&lt;/strong&gt; Only the new episode is fetched, transcribed and extracted. Resolution re-runs for each entity type because its set of names changed, but decisions whose name and candidate list are unchanged are memo hits, so LLM calls go to new names and to names whose candidates changed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Remove an episode.&lt;/strong&gt; Delete its URL from &lt;code&gt;input/sample.txt&lt;/code&gt;. Its component is not mounted on the next run, so CocoIndex deletes its session, statements and edges, and the entities that no other episode mentions. Nothing is transcribed or extracted.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Add an entity type or edit the step 2 prompt.&lt;/strong&gt; Step 2 re-runs for every episode; the audio download, transcription and step 1 are memo hits. For 50 episodes that is 50 step 2 calls, plus resolution calls for new name pairs, and no transcription. Statements the LLM words differently get new IDs, so their old rows and edges are replaced.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To add &lt;code&gt;Product&lt;/code&gt;, add an &lt;code&gt;EntityTypeConfig&lt;/code&gt; to &lt;code&gt;ENTITY_TYPES&lt;/code&gt; in &lt;code&gt;models.py&lt;/code&gt; and a &lt;code&gt;mentioned_product: list[str]&lt;/code&gt; field to &lt;code&gt;RawStatement&lt;/code&gt;. &lt;code&gt;STATEMENTS_PROMPT&lt;/code&gt; is built from &lt;code&gt;ENTITY_TYPES&lt;/code&gt;, so the prompt lists the new type. &lt;code&gt;app_main&lt;/code&gt; and &lt;code&gt;create_knowledge_base&lt;/code&gt; loop over &lt;code&gt;ENTITY_TYPES&lt;/code&gt;, so the new table, its resolution component and its mention edges need no other change.&lt;/p&gt;
&lt;p&gt;:::caution[Declare module-level prompts as dependencies]
CocoIndex fingerprints a function&apos;s source code, not the module-level values it reads. &lt;code&gt;STATEMENTS_PROMPT&lt;/code&gt; is a module-level string, so editing it, or adding an entity type, does not invalidate &lt;code&gt;extract_statements&lt;/code&gt; by itself: the next run returns the memoized statements. Declare the prompt with &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#deps&quot;&gt;&lt;code&gt;deps&lt;/code&gt;&lt;/a&gt; so that a change to it re-runs step 2 (the demo assumes this). The same applies to &lt;code&gt;METADATA_PROMPT&lt;/code&gt; and &lt;code&gt;extract_metadata&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True, deps=STATEMENTS_PROMPT)
async def extract_statements(
    reformatted_transcript: str,
) -&amp;gt; StatementExtraction:
    ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A model change needs no extra step: &lt;code&gt;LLM_MODEL&lt;/code&gt; is a context key with &lt;code&gt;detect_change=True&lt;/code&gt;, so changing it re-runs both extraction steps.
:::&lt;/p&gt;
&lt;h2&gt;Run it&lt;/h2&gt;
&lt;h3&gt;Prerequisites&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Python 3.11+, &lt;a href=&quot;https://ffmpeg.org/&quot;&gt;FFmpeg&lt;/a&gt; and Docker&lt;/li&gt;
&lt;li&gt;An &lt;a href=&quot;https://www.assemblyai.com/&quot;&gt;AssemblyAI API key&lt;/a&gt; for transcription&lt;/li&gt;
&lt;li&gt;An &lt;a href=&quot;https://platform.openai.com/&quot;&gt;OpenAI API key&lt;/a&gt; for LLM extraction and resolution&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Setup&lt;/h3&gt;
&lt;p&gt;Clone the example and start &lt;a href=&quot;https://cocoindex.io/docs/connectors/surrealdb/&quot;&gt;SurrealDB&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git clone https://github.com/cocoindex-io/cocoindex.git
cd cocoindex/examples/conversation_to_knowledge

docker run -d --name surrealdb --user root -p 8787:8000 \
  -v surrealdb-data:/data surrealdb/surrealdb:latest \
  start --user root --pass root surrealkv:/data/database
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Set the API keys. The other variables are optional and shown with their defaults:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;export ASSEMBLYAI_API_KEY=&quot;...&quot;   # speaker-diarized transcription
export OPENAI_API_KEY=&quot;sk-...&quot;    # LLM extraction via LiteLLM

# Optional (shown with defaults)
export SURREALDB_URL=&quot;ws://localhost:8787/rpc&quot;
export SURREALDB_NS=&quot;cocoindex&quot;
export SURREALDB_DB=&quot;yt_conversations&quot;
export SURREALDB_USER=&quot;root&quot;
export SURREALDB_PASS=&quot;root&quot;
export INPUT_DIR=&quot;./input&quot;
export LLM_MODEL=&quot;openai/gpt-5-mini&quot;
export RESOLUTION_LLM_MODEL=&quot;openai/gpt-5-mini&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The lifespan reads the SurrealDB and model variables, and provides the embedder and the two model names as context values:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.lifespan
async def coco_lifespan(
    builder: coco.EnvironmentBuilder,
) -&amp;gt; AsyncIterator[None]:
    surreal_db = surrealdb.ConnectionFactory(
        url=os.environ.get(&quot;SURREALDB_URL&quot;, &quot;ws://localhost:8787/rpc&quot;),
        namespace=os.environ.get(&quot;SURREALDB_NS&quot;, &quot;cocoindex&quot;),
        database=os.environ.get(&quot;SURREALDB_DB&quot;, &quot;yt_conversations&quot;),
        credentials={
            &quot;username&quot;: os.environ.get(&quot;SURREALDB_USER&quot;, &quot;root&quot;),
            &quot;password&quot;: os.environ.get(&quot;SURREALDB_PASS&quot;, &quot;root&quot;),
        },
    )
    builder.provide(SURREAL_DB, surreal_db)
    builder.provide(
        EMBEDDER,
        SentenceTransformerEmbedder(&quot;Snowflake/snowflake-arctic-embed-xs&quot;),
    )
    builder.provide(
        LLM_MODEL,
        os.environ.get(&quot;LLM_MODEL&quot;, &quot;openai/gpt-5-mini&quot;),
    )
    builder.provide(
        RESOLUTION_LLM_MODEL,
        os.environ.get(&quot;RESOLUTION_LLM_MODEL&quot;, &quot;openai/gpt-5-mini&quot;),
    )
    yield
    await surreal_db.close()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Install the package:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pip install -e .
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add YouTube URLs to &lt;code&gt;input/sample.txt&lt;/code&gt;, one per line (&lt;code&gt;#&lt;/code&gt; starts a comment):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# AI podcasts
https://www.youtube.com/watch?v=VIDEO_ID_1
https://www.youtube.com/watch?v=VIDEO_ID_2
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Build the knowledge graph&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;cocoindex update conv_knowledge.app
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Run the same command after you change the URL list or the code. It processes only what changed, as in the &lt;a href=&quot;#what-re-runs-when-you-change-the-pipeline&quot;&gt;demo above&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Explore the graph in SurrealDB&lt;/h2&gt;
&lt;p&gt;Open &lt;a href=&quot;https://surrealdb.com/surrealist&quot;&gt;Surrealist&lt;/a&gt;, SurrealDB&apos;s query and graph UI, and connect to &lt;code&gt;ws://localhost:8787&lt;/code&gt; with namespace &lt;code&gt;cocoindex&lt;/code&gt; and database &lt;code&gt;yt_conversations&lt;/code&gt;. The graph view of &lt;code&gt;SELECT * FROM statement, person;&lt;/code&gt; shows persons in blue and the statements they made or are mentioned in, in pink:&lt;/p&gt;
&lt;p&gt;You can also run analytical queries. This one ranks technologies by the number of distinct people whose statements mention them:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SELECT
  name,
  array::distinct(
    &amp;lt;-statement_mentions&amp;lt;-statement&amp;lt;-person_statement&amp;lt;-person.name
  ) AS persons,
  array::len(array::distinct(
    &amp;lt;-statement_mentions&amp;lt;-statement&amp;lt;-person_statement&amp;lt;-person.id
  )) AS person_count
FROM tech
ORDER BY person_count DESC
LIMIT 15;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;More queries to start from:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-- All statements a person made
SELECT &amp;lt;-person_statement&amp;lt;-person.name AS speaker, statement FROM statement;

-- Full graph around a person
SELECT name,
  -&amp;gt;person_session-&amp;gt;session.name AS sessions,
  -&amp;gt;person_statement-&amp;gt;statement.statement AS statements
FROM person;

-- All entities involved in statements
SELECT statement,
  -&amp;gt;statement_mentions-&amp;gt;person.name AS persons,
  -&amp;gt;statement_mentions-&amp;gt;tech.name AS techs,
  -&amp;gt;statement_mentions-&amp;gt;org.name AS orgs
FROM statement;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;p&gt;The pipeline turns YouTube episodes into a graph an agent can query:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Fetch&lt;/strong&gt;: download the audio and transcribe it with speaker labels.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Extract&lt;/strong&gt; in two LLM steps: name the speakers from the YouTube metadata, then extract statements from the transcript with real names.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Resolve&lt;/strong&gt;: merge duplicate entity names across episodes with &lt;code&gt;resolve_entities&lt;/code&gt;, where embeddings find candidates and an LLM confirms near-matches.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Store&lt;/strong&gt;: declare the nodes and edges in SurrealDB; CocoIndex writes only the difference from the previous run.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Each episode is a memoized component and each expensive step is memoized, so adding an episode or changing a prompt (once declared with &lt;code&gt;deps&lt;/code&gt;) re-runs only the work it affects. The full code is in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/conversation_to_knowledge&quot;&gt;&lt;code&gt;examples/conversation_to_knowledge&lt;/code&gt;&lt;/a&gt;, and the &lt;a href=&quot;https://cocoindex.io/docs/examples/podcast-to-knowledge-graph/&quot;&gt;docs version of this tutorial&lt;/a&gt; has the same walkthrough.&lt;/p&gt;
</content:encoded><category>examples</category><category>knowledge-graph</category><category>llm</category><category>structured-extraction</category><category>incremental-processing</category><author>George He</author></item><item><title>A Safe pickle Alternative: Serialize Python with Type Hints</title><link>https://cocoindex.io/blogs/type-guided-serde/</link><guid isPermaLink="true">https://cocoindex.io/blogs/type-guided-serde/</guid><description>Why CocoIndex replaced pickle with serialization that reads Python type hints to choose msgspec, Pydantic or restricted pickle for each value.</description><pubDate>Fri, 27 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Python&apos;s built-in &lt;code&gt;pickle&lt;/code&gt; can run code while it reads data back: a crafted payload executes arbitrary Python on the machine that loads it. It is also large: the integer &lt;code&gt;1024&lt;/code&gt; takes 15 bytes in pickle and 3 bytes in msgpack. Our first fix for the security problem, an allowlist, needed &lt;strong&gt;9&lt;/strong&gt; decorators and &lt;strong&gt;4 rounds&lt;/strong&gt; of run-fail-annotate in one of our own examples. This post explains how CocoIndex moved to serialization guided by type hints, and the union-type edge cases that remain.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex&lt;/a&gt; is a framework for building &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;incremental data pipelines&lt;/a&gt;. It has a Rust core for performance and exposes a Python SDK for users to define their pipelines. Under the hood, the engine needs to &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/serialization/&quot;&gt;serialize and deserialize&lt;/a&gt; Python objects constantly (serde for short: turning an object into bytes and back). It does this to cache function results, persist pipeline state and track records for change detection. The serialized data crosses the Rust/Python boundary and is stored by the Rust core.&lt;/p&gt;
&lt;p&gt;In CocoIndex v0, we had a closed type system: a fixed set of supported data types, with serialization handled entirely in Rust. It was safe and fast but rigid: users could not use their own data types without converting them into our type system first.&lt;/p&gt;
&lt;p&gt;When we started building &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;v1&lt;/a&gt;, we wanted to natively support any Python data type. Pickle was the first choice.&lt;/p&gt;
&lt;h2&gt;Pickle runs code on load and wastes bytes&lt;/h2&gt;
&lt;p&gt;Pickle is Python&apos;s built-in serialization. It handles almost any Python object out of the box: dataclasses, NamedTuples, Pydantic models, nested containers and custom classes. For early prototyping under prerelease, it needed one line of code.&lt;/p&gt;
&lt;p&gt;Pickle has two problems that make it unsuitable for production.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Security.&lt;/strong&gt; Pickle executes arbitrary code during deserialization. A crafted payload can run any Python code on your machine, for example &lt;code&gt;os.system(...)&lt;/code&gt;. In CocoIndex&apos;s case, the serialized data lives in &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/internal_storage/&quot;&gt;internal storage&lt;/a&gt; (a database managed by the framework), so the risk requires an attacker to have access to that storage, which is unlikely for most deployments. Defense in depth (more than one layer of protection) still matters: if the storage is ever exposed through a misconfiguration or a compromised database, pickle becomes an escalation path from data access to code execution. We did not want that risk in the foundation of our persistence layer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Overhead.&lt;/strong&gt; Pickle encodes type information into every value: each value is a sequence of opcodes that tells the deserializer what type to reconstruct and how. This makes pickle self-describing, at a cost. The integer &lt;code&gt;1024&lt;/code&gt; takes 15 bytes in pickle, while &lt;a href=&quot;https://msgpack.org/&quot;&gt;msgpack&lt;/a&gt; (a compact binary format similar to JSON) encodes it in 3. Msgpack can be this compact because it relies on the deserializer already knowing the expected type:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;th&gt;pickle&lt;/th&gt;
&lt;th&gt;msgpack&lt;/th&gt;
&lt;th&gt;Ratio&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&quot;&quot;&lt;/code&gt; (empty string)&lt;/td&gt;
&lt;td&gt;15 bytes&lt;/td&gt;
&lt;td&gt;1 byte&lt;/td&gt;
&lt;td&gt;15x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;1024&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;15 bytes&lt;/td&gt;
&lt;td&gt;3 bytes&lt;/td&gt;
&lt;td&gt;5x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&quot;hello&quot;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;20 bytes&lt;/td&gt;
&lt;td&gt;6 bytes&lt;/td&gt;
&lt;td&gt;3.3x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{&quot;key&quot;: [1,2,3]}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;31 bytes&lt;/td&gt;
&lt;td&gt;9 bytes&lt;/td&gt;
&lt;td&gt;3.4x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Point(42, &quot;origin&quot;)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;63 bytes&lt;/td&gt;
&lt;td&gt;16 bytes&lt;/td&gt;
&lt;td&gt;3.9x&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;For a pipeline that caches thousands of intermediate results, this overhead adds up.&lt;/p&gt;
&lt;h2&gt;An allowlist fixed security but added decorators&lt;/h2&gt;
&lt;p&gt;Our first attempt to fix the security problem was a restricted unpickler: a pickle reader that refuses any class that is not on a list. We maintained an allowlist of types that were safe to deserialize, and rejected everything else. Users could opt their types into the allowlist with a &lt;code&gt;@coco.unpickle_safe&lt;/code&gt; decorator:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.unpickle_safe
@dataclass
class DocumentChunk:
    text: str
    embedding: list[float]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This solved the security problem and introduced a new one: annotation burden.&lt;/p&gt;
&lt;p&gt;Every type that appeared anywhere in a serialized object graph needed the decorator: the top-level type and every type nested inside it. A missed type causes a runtime error.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; When a type is missing from the allowlist, the read fails with an error such as &lt;code&gt;_pickle.UnpicklingError: Forbidden global during unpickling: myapp.models.Summary&lt;/code&gt;. You add the decorator, run again, and meet the next missing type.&lt;/p&gt;
&lt;p&gt;We experienced this when building the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/fc3b4b54044875fe3777b556b0e66498c0050942/examples/conversation_to_knowledge&quot;&gt;&lt;code&gt;conversation_to_knowledge&lt;/code&gt;&lt;/a&gt; example. It needed &lt;strong&gt;9&lt;/strong&gt; &lt;code&gt;@coco.unpickle_safe&lt;/code&gt; annotations across the codebase. Getting there took &lt;strong&gt;4 rounds&lt;/strong&gt; of run-fail-annotate-repeat: run the pipeline, hit an error about an unregistered type, add the decorator, run again, hit the next error.&lt;/p&gt;
&lt;p&gt;That was our own example. A user pipeline with dozens of model types needs the decorator on each of them.&lt;/p&gt;
&lt;h2&gt;Type hints tell the decoder what to build&lt;/h2&gt;
&lt;p&gt;We looked for something that already describes the shape of users&apos; data, and found it in their code: &lt;strong&gt;type hints&lt;/strong&gt;, the annotations such as &lt;code&gt;-&amp;gt; list[float]&lt;/code&gt; that name the type of a value.&lt;/p&gt;
&lt;p&gt;In CocoIndex, there are 3 places where data gets serialized and deserialized: &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/memoization_keys/&quot;&gt;memoized function return values&lt;/a&gt; (the most common case), memo state values for change detection, and target tracking records. A memoized function is one whose results CocoIndex caches, so that unchanged work can be skipped on later runs. For memoized return values, the type hint is in the function signature:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def embed_chunk(chunk: str) -&amp;gt; list[float]:
    return await embedding_model.embed(chunk)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The return type &lt;code&gt;list[float]&lt;/code&gt; tells us exactly how to deserialize the cached result. No extra annotation is needed: the type hint that users already write for readability and IDE support doubles as the deserialization schema.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; When &lt;code&gt;embed_chunk&lt;/code&gt; is called again with the same &lt;code&gt;chunk&lt;/code&gt; and its code has not changed, CocoIndex returns the cached &lt;code&gt;list[float]&lt;/code&gt; instead of calling the embedding model. If a memoized function has no return annotation, cached values may come back as basic Python types such as &lt;code&gt;dict&lt;/code&gt; or &lt;code&gt;list&lt;/code&gt; instead of the original type.&lt;/p&gt;
&lt;p&gt;This led us to a type-guided serialization system built on &lt;a href=&quot;https://msgspec.dev/&quot;&gt;msgspec&lt;/a&gt;, a fast msgpack-based serialization library for Python. Msgspec natively handles dataclasses, NamedTuples, and standard types (str, int, list, dict, datetime, UUID, etc.), and it does so by relying on type information at deserialization time.&lt;/p&gt;
&lt;h3&gt;One routing byte picks the engine&lt;/h3&gt;
&lt;p&gt;Different types need different serialization engines. We use a single routing byte at the start of each payload to select the engine:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Byte&lt;/th&gt;
&lt;th&gt;Engine&lt;/th&gt;
&lt;th&gt;Used for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0x01&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;msgspec (msgpack)&lt;/td&gt;
&lt;td&gt;Dataclasses, NamedTuples, primitives, collections&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0x02&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Pydantic&lt;/td&gt;
&lt;td&gt;&lt;code&gt;BaseModel&lt;/code&gt; subclasses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;0x80&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Pickle&lt;/td&gt;
&lt;td&gt;Opted-in types, legacy data&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Serialization checks types in priority order: explicit pickle opt-in first (the user specifically requested it), then Pydantic models, then msgspec as the default. Deserialization reads the routing byte and dispatches accordingly.&lt;/p&gt;
&lt;p&gt;For &lt;strong&gt;Pydantic models&lt;/strong&gt;, we serialize via &lt;code&gt;model_dump(mode=&quot;json&quot;)&lt;/code&gt; into msgpack, and deserialize via &lt;code&gt;TypeAdapter.validate_python()&lt;/code&gt;. This avoids pickle entirely while preserving Pydantic&apos;s validation semantics.&lt;/p&gt;
&lt;p&gt;For types that msgspec can&apos;t handle natively, like numpy arrays or pathlib paths, CocoIndex uses pickle. These types get the pickle routing byte (&lt;code&gt;0x80&lt;/code&gt;) and are still read through a restricted unpickler. Users opt their own types in with &lt;code&gt;@coco.serialize_by_pickle&lt;/code&gt;. Current CocoIndex registers numpy arrays and pathlib paths itself, so they need no decorator; see the &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/serialization/#supported-types&quot;&gt;supported types&lt;/a&gt;.&lt;/p&gt;

Quick check: a memoized function returns a Pydantic &lt;code&gt;BaseModel&lt;/code&gt;. Which routing byte does its cached payload start with, and how is it read back?
&lt;p&gt;&lt;code&gt;0x02&lt;/code&gt;. The model is written with &lt;code&gt;model_dump(mode=&quot;json&quot;)&lt;/code&gt; into msgpack and read back with &lt;code&gt;TypeAdapter.validate_python()&lt;/code&gt; for the function&apos;s return type, so Pydantic&apos;s validation runs on the way in.&lt;/p&gt;

&lt;h3&gt;What changed for users&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;conversation_to_knowledge&lt;/code&gt; example dropped all 9 &lt;code&gt;@coco.unpickle_safe&lt;/code&gt; annotations. Users define their data types with standard Python type hints, and serialization works without extra code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@dataclass
class DocumentChunk:
    text: str
    embedding: list[float]
    metadata: dict[str, str]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;No decorator or registration step is needed, so the run-fail-annotate cycle is gone. The framework reads the type hint and picks the serializer and deserializer.&lt;/p&gt;

Quick check: &lt;code&gt;DocumentChunk&lt;/code&gt; is a dataclass nested inside another dataclass. Should you add &lt;code&gt;@coco.serialize_by_pickle&lt;/code&gt; to it?
&lt;p&gt;No. Dataclasses, NamedTuples and &lt;code&gt;msgspec.Struct&lt;/code&gt; types are supported natively. When such a type is nested inside another supported type, msgspec encodes it directly and the decorator has no effect. If one &lt;em&gt;field&lt;/em&gt; of the dataclass has an unsupported type, register that field&apos;s type instead. See &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/serialization/#custom-types&quot;&gt;custom types&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Ambiguous unions do not round-trip&lt;/h2&gt;
&lt;p&gt;This approach does not round-trip every type. There are edge cases with &lt;strong&gt;union types&lt;/strong&gt; (a field that accepts one of several types, such as &lt;code&gt;date | str&lt;/code&gt;) that users should be aware of. They are not specific to CocoIndex: they come from how msgspec and Pydantic handle ambiguous types.&lt;/p&gt;
&lt;h3&gt;msgspec: loud failure&lt;/h3&gt;
&lt;p&gt;msgspec rejects ambiguous unions at construction time:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import msgspec.msgpack

# These all raise TypeError immediately:
msgspec.msgpack.Decoder(str | datetime.date)     # two str-like types
msgspec.msgpack.Decoder(list[int] | tuple[int, ...])  # two array-like types
msgspec.msgpack.Decoder(bytes | bytearray)        # two bytes-like types
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is the safer behavior: msgspec tells you up front that these types can&apos;t be distinguished on the wire, rather than silently corrupting your data.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What you see in CocoIndex.&lt;/strong&gt; When a memoized function&apos;s return type contains such a union, reading its cached value fails with a &lt;code&gt;DeserializationError&lt;/code&gt;. The message names the type hint and the function (&lt;code&gt;source=return type of &amp;lt;function&amp;gt;()&lt;/code&gt;), and its cause is &lt;code&gt;Cannot build msgspec Decoder for ...&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Pydantic: silent surprise&lt;/h3&gt;
&lt;p&gt;Pydantic is more permissive: it accepts &lt;code&gt;date | str&lt;/code&gt;, but the behavior after a serialization-deserialization round-trip can be surprising.&lt;/p&gt;
&lt;p&gt;Consider a Pydantic model with a &lt;code&gt;date | str&lt;/code&gt; field:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;class Event(BaseModel):
    ts: datetime.date | str

e = Event(ts=datetime.date(2024, 1, 15))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you serialize this to JSON (or msgpack), &lt;code&gt;date&lt;/code&gt; becomes the string &lt;code&gt;&quot;2024-01-15&quot;&lt;/code&gt;. On deserialization, Pydantic sees a string input and needs to decide: is it a &lt;code&gt;str&lt;/code&gt; or a &lt;code&gt;date&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;With Pydantic v2&apos;s default &lt;strong&gt;smart mode&lt;/strong&gt;, the answer is always &lt;code&gt;str&lt;/code&gt;. Smart mode scores candidates by exactness: a string input is an &lt;em&gt;exact match&lt;/em&gt; for &lt;code&gt;str&lt;/code&gt; but only a &lt;em&gt;lax match&lt;/em&gt; (requires coercion) for &lt;code&gt;date&lt;/code&gt;. Exact wins. Ordering doesn&apos;t matter: &lt;code&gt;date | str&lt;/code&gt; and &lt;code&gt;str | date&lt;/code&gt; both produce &lt;code&gt;str&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; The round-tripped &lt;code&gt;Event&lt;/code&gt; has &lt;code&gt;ts == &quot;2024-01-15&quot;&lt;/code&gt;, a &lt;code&gt;str&lt;/code&gt;, where the original had &lt;code&gt;datetime.date(2024, 1, 15)&lt;/code&gt;. No error is raised.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Left-to-right mode&lt;/strong&gt; behaves differently. With &lt;code&gt;date | str&lt;/code&gt; ordering, Pydantic tries &lt;code&gt;date&lt;/code&gt; first, the lax coercion from &lt;code&gt;&quot;2024-01-15&quot;&lt;/code&gt; succeeds, and you get your date back:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from pydantic import Field
from typing import Annotated

class Event(BaseModel):
    # Left-to-right mode: more specific type first
    ts: Annotated[datetime.date | str, Field(union_mode=&apos;left_to_right&apos;)]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This requires users to explicitly opt in to left-to-right mode and put the more specific type first.&lt;/p&gt;
&lt;h3&gt;The wire format erases the type&lt;/h3&gt;
&lt;p&gt;The cause is the wire format (the bytes as stored), and it applies to both libraries. Msgpack (like JSON) has no &lt;code&gt;date&lt;/code&gt; type: dates are serialized as strings. Once the type information is erased on the wire, no decoder can reliably recover it when multiple types map to the same wire representation.&lt;/p&gt;
&lt;p&gt;The practical advice: &lt;strong&gt;avoid union types where members share a wire representation&lt;/strong&gt; in data objects that go through serialization. Use unambiguous types, or use Pydantic&apos;s discriminated unions with a literal tag field.&lt;/p&gt;

Quick check: a Pydantic model stores &lt;code&gt;created: datetime.date | str&lt;/code&gt; with default settings. You cache &lt;code&gt;date(2024, 1, 15)&lt;/code&gt;. What type comes back?
&lt;p&gt;&lt;code&gt;str&lt;/code&gt;: the value is &lt;code&gt;&quot;2024-01-15&quot;&lt;/code&gt;. Smart mode prefers the exact match for a string input, whatever the order of the union. To get a &lt;code&gt;date&lt;/code&gt; back, use one type for the field, a discriminated union with a literal tag, or &lt;code&gt;union_mode=&apos;left_to_right&apos;&lt;/code&gt; with &lt;code&gt;date&lt;/code&gt; listed first.&lt;/p&gt;

&lt;h2&gt;What we learned&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Type hints as a source of truth.&lt;/strong&gt; Python developers already annotate their data types. Using those annotations for serialization adds no new concepts, decorators or registration APIs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ambiguity reported early.&lt;/strong&gt; msgspec rejects ambiguous unions at construction time, which is better than silently producing wrong results. A serialization layer should fail early and clearly.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The wire format sets the limit.&lt;/strong&gt; If the wire format can&apos;t distinguish two types, your serialization layer can&apos;t either. Design your data types around what the serialization format can express.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;A staged design.&lt;/strong&gt; Pickle was right for prototyping. The allowlisted pickle was right for the security fix. The type-guided approach was right for production. Each step taught us what the next step needed to be.&lt;/p&gt;
&lt;h2&gt;What to try next&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Annotate memoized return types.&lt;/strong&gt; Give each &lt;code&gt;@coco.fn(memo=True)&lt;/code&gt; function a return type such as &lt;code&gt;-&amp;gt; list[float]&lt;/code&gt; or &lt;code&gt;-&amp;gt; DocumentChunk&lt;/code&gt;, so cached values come back as that type.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Check unions in cached data.&lt;/strong&gt; Look for fields such as &lt;code&gt;date | str&lt;/code&gt; whose members share a wire representation. Use one type, a Pydantic discriminated union with a literal tag field, or tagged &lt;code&gt;msgspec.Struct&lt;/code&gt; variants (&lt;code&gt;tag=True&lt;/code&gt;); the &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/serialization/#union-types&quot;&gt;union types&lt;/a&gt; section shows the pattern.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Register types outside the supported list.&lt;/strong&gt; Decorate your own class with &lt;code&gt;@coco.serialize_by_pickle&lt;/code&gt;, or call &lt;code&gt;coco.serialize_by_pickle(SomeType)&lt;/code&gt; for a third-party type.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;If an upgrade shows &lt;code&gt;Forbidden global during unpickling&lt;/code&gt;,&lt;/strong&gt; older cached data references an unregistered type. Add &lt;code&gt;@coco.serialize_by_pickle&lt;/code&gt; to it, or for a dataclass or NamedTuple add &lt;code&gt;@coco.unpickle_safe&lt;/code&gt; until the cache is rebuilt; see &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/serialization/#troubleshooting&quot;&gt;troubleshooting&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Further reading:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/serialization/&quot;&gt;Value serialization for memoization&lt;/a&gt;: supported types, custom types and troubleshooting&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;CocoIndex v1 Documentation&lt;/a&gt;: getting started guides and API reference&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/blogs/building-an-invisible-daemon&quot;&gt;Building an Invisible Daemon&lt;/a&gt;: how we built the local daemon architecture behind CocoIndex&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex on GitHub&lt;/a&gt;: the open-source data indexing framework and its source&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>insight</category><category>architecture</category><category>best-practices</category><author>George He</author></item><item><title>Build a Python Daemon for a CLI: Auto-Start, Upgrade, Stop</title><link>https://cocoindex.io/blogs/building-an-invisible-daemon/</link><guid isPermaLink="true">https://cocoindex.io/blogs/building-an-invisible-daemon/</guid><description>Five patterns for a Python CLI background daemon that auto-starts, upgrades transparently, and shuts down fast, from the daemon behind cocoindex-code.</description><pubDate>Tue, 24 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;These five patterns, for a Python CLI with a background daemon, remove manual start and restart, connection leaks, and shutdowns that end in SIGKILL:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Auto-start on first use&lt;/strong&gt; via a Unix socket probe (no &lt;code&gt;daemon start&lt;/code&gt; command), and a restart on the next call if the daemon has exited.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Version handshake&lt;/strong&gt; on every connection for transparent upgrades after &lt;code&gt;pipx upgrade&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Per-request connections&lt;/strong&gt; instead of persistent sessions, so a connection cannot leak.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Resource closure&lt;/strong&gt; instead of thread signaling: wake or close the listener that a thread is blocked on, instead of having it poll a shutdown flag.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PID file removal&lt;/strong&gt; as the exit signal, because &lt;code&gt;os.kill(pid, 0)&lt;/code&gt; returns True for zombies.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is how we built the daemon behind &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex-code&quot;&gt;cocoindex-code&lt;/a&gt; (&lt;code&gt;ccc&lt;/code&gt;), an embedded AST-based semantic code search tool for Claude Code, Codex, and Cursor.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;cocoindex-code&lt;/code&gt; is a local MCP server and CLI that gives coding agents semantic understanding of your whole codebase via &lt;a href=&quot;https://cocoindex.io/docs/examples/index-codebase/&quot;&gt;AST-based chunking&lt;/a&gt;: &lt;a href=&quot;https://cocoindex.io/blogs/index-codebase-v1&quot;&gt;Tree-sitter&lt;/a&gt; parses code by syntax (functions, classes, methods), and only &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;changed chunks are re-embedded on update&lt;/a&gt;. The daemon described here is the background process that makes that possible: it loads the ML model once, watches for file changes, and serves searches in under a second. If you&apos;re building something similar (a local AI context layer, a code-aware MCP server, any dev tool with a heavy background process), the patterns below are what we landed on after shipping to production.&lt;/p&gt;
&lt;p&gt;We moved cocoindex-code from a monolithic per-session process (load model, index, search, exit) to a persistent daemon with a thin CLI (&lt;code&gt;ccc&lt;/code&gt;) and a lightweight MCP client as frontends. This unlocked a benefit beyond performance: humans can call &lt;code&gt;ccc search &quot;auth logic&quot;&lt;/code&gt; directly from the terminal and pipe it into other tools.&lt;/p&gt;
&lt;p&gt;Building the daemon involved removing state and connections that complicated its lifecycle. Here’s what the user sees:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ccc init                    # one-time setup: creates settings files (no daemon)
ccc index                   # build the search index (daemon auto-starts here)
ccc search &quot;auth logic&quot;     # semantic search (daemon handles it)
ccc search --refresh &quot;auth&quot; # re-index then search (two daemon requests)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;ccc init&lt;/code&gt; is purely local: it creates configuration files and a &lt;code&gt;.gitignore&lt;/code&gt; entry. The commands that index or search talk to the daemon, and the user never starts, stops, or restarts it by hand.&lt;/p&gt;
&lt;p&gt;The initial daemon was largely built by Claude Code: persistent connections, async handler loops, multi-step shutdown. It worked, but it was complex in ways we didn&apos;t appreciate until we looked closely. The simplifications came from stepping back and questioning the design rather than fixing individual bugs.&lt;/p&gt;
&lt;p&gt;These patterns apply to local daemons for developer tools. The code below is from cocoindex-code as of November 2026; it runs on macOS, Linux and Windows, and the Windows notes are called out where they differ.&lt;/p&gt;
&lt;h2&gt;How do you make a local daemon invisible to the user?&lt;/h2&gt;
&lt;p&gt;The main design constraint is that users should never have to manage the daemon. The setup guide has no &lt;code&gt;ccc daemon start&lt;/code&gt; step, and neither an upgrade nor a config edit asks the user to restart anything.&lt;/p&gt;
&lt;h3&gt;How do you auto-start a Python daemon on first use without a manual command?&lt;/h3&gt;
&lt;p&gt;The first time a user runs &lt;code&gt;ccc index&lt;/code&gt; or &lt;code&gt;ccc search&lt;/code&gt;, the client tries to connect to the daemon&apos;s Unix socket (a named pipe on Windows). If nothing answers, it starts the daemon as a detached background process and waits for the socket to appear.&lt;/p&gt;
&lt;p&gt;This logic is built into the lowest-level connection function, not into a separate &quot;ensure daemon&quot; step. Every request goes through it, so a daemon that exited between two commands is started again on the next one:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def _connect_and_handshake() -&amp;gt; Connection:
    global _daemon_ensured, _ensured_daemon_pid, _consecutive_crash_restarts

    try:
        result = _raw_connect_and_handshake()
        _daemon_ensured = True
        _ensured_daemon_pid = result.resp.pid
        _consecutive_crash_restarts = 0
        return result.conn
    except DaemonVersionError as e:
        if _daemon_ensured and not e.resp.ok:
            raise                    # binary replaced mid-session: fail fast
        stop_daemon()                # old version, or stale global settings
    except DaemonProtocolError:
        if _daemon_ensured:
            raise
        stop_daemon()                # reply didn&apos;t decode: much older daemon
    except (ConnectionRefusedError, OSError):
        if _daemon_ensured:
            _handle_vanished_daemon()   # graceful exit or crash?

    if _is_daemon_supervised():
        _wait_for_daemon()           # Docker or systemd restarts it
    else:
        proc = start_daemon()
        _wait_for_daemon(proc=proc)
    # ... retry the handshake and return the connection
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When the daemon is running, the handshake connection also carries the request, so there is no throwaway probe. &lt;code&gt;_daemon_ensured&lt;/code&gt; records that this process has already reached a matching daemon once. The check still runs on every call; &lt;code&gt;_daemon_ensured&lt;/code&gt; decides how the client reacts when it fails:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The daemon has exited.&lt;/strong&gt; The daemon writes a last-exit marker with its PID when it shuts down gracefully (a manual stop, a signal, or the idle stop below). If the marker matches the daemon the client last talked to, the restart is silent.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The daemon crashed.&lt;/strong&gt; With no matching marker, the client restarts it and prints a warning that points at the daemon log. After 3 consecutive crashes it raises instead of starting a daemon that keeps crashing. The counter lives in the client process, so it matters most for the long-lived MCP server.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A supervisor owns the daemon.&lt;/strong&gt; With &lt;code&gt;COCOINDEX_CODE_DAEMON_SUPERVISED=1&lt;/code&gt; (a Docker entrypoint loop or systemd), the client can stop the daemon but never starts one. It waits for the supervisor to bring the socket back.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;start_daemon()&lt;/code&gt; launches &lt;code&gt;ccc run-daemon&lt;/code&gt; with &lt;code&gt;subprocess.Popen&lt;/code&gt;: in a new session (&lt;code&gt;start_new_session=True&lt;/code&gt;) on Unix, and with no console window on Windows. If that process exits before its socket appears, &lt;code&gt;_wait_for_daemon&lt;/code&gt; raises at once with the daemon log instead of waiting for the full timeout.&lt;/p&gt;
&lt;h3&gt;Stop when idle, restart on the next command&lt;/h3&gt;
&lt;p&gt;A daemon that holds an embedding model should not keep that memory forever. The daemon exits after 180 minutes without client activity (&lt;code&gt;daemon.idle_timeout_minutes&lt;/code&gt; in &lt;code&gt;global_settings.yml&lt;/code&gt;; &lt;code&gt;0&lt;/code&gt; disables the idle stop). It never idle-exits while a request is in progress or a project is indexing, and never under a supervisor.&lt;/p&gt;
&lt;p&gt;The idle stop goes through the normal graceful shutdown, so it leaves a last-exit marker, and the next &lt;code&gt;ccc&lt;/code&gt; command restarts the daemon silently. While an MCP session is open, the MCP server sends a heartbeat request every third of the timeout (clamped to 30–300 s) to keep the model warm. The heartbeat never starts a daemon itself. Set &lt;code&gt;daemon.keep_alive_with_mcp: false&lt;/code&gt; to let the daemon idle-exit under an open session too.&lt;/p&gt;
&lt;h3&gt;How do you auto-restart a daemon when the CLI tool upgrades?&lt;/h3&gt;
&lt;p&gt;When a user runs &lt;code&gt;pipx upgrade cocoindex-code&lt;/code&gt;, the next CLI command should use the new version without a manual restart.&lt;/p&gt;
&lt;p&gt;Every connection starts with a version handshake. The client sends its version; the daemon responds with its version:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# In the client
conn.send_bytes(encode_request(HandshakeRequest(version=__version__)))
resp = decode_response(conn.recv_bytes())
if not resp.ok or _needs_restart(resp):
    raise DaemonVersionError(resp)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On the first contact in a process, a version mismatch triggers a restart: stop the old daemon, start a new one. After the client has reached a matching daemon, a new version mismatch means the binary was replaced mid-session. That is unusual and worth surfacing, so the client raises instead of looping on restarts. A daemon from a much older release may reply in a wire format the client cannot decode at all; that raises &lt;code&gt;DaemonProtocolError&lt;/code&gt;, which is handled the same way.&lt;/p&gt;
&lt;h3&gt;How should a local daemon handle config: restart, reload, or re-read fresh?&lt;/h3&gt;
&lt;p&gt;We have two levels of configuration:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Global settings&lt;/strong&gt; (&lt;code&gt;~/.cocoindex_code/global_settings.yml&lt;/code&gt;): embedding model, API keys, environment variables. These affect daemon-wide state: the ML model is loaded once at startup, environment variables are set once. When these change, the daemon &lt;em&gt;must&lt;/em&gt; restart.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Project settings&lt;/strong&gt; (&lt;code&gt;$PROJECT/.cocoindex_code/settings.yml&lt;/code&gt;): include/exclude patterns, language overrides. These only affect per-operation behavior: which files to index, how to parse them.&lt;/p&gt;
&lt;p&gt;Both files are created automatically by &lt;code&gt;ccc init&lt;/code&gt; with sensible defaults. Users only edit them if they need to customize.&lt;/p&gt;
&lt;p&gt;For global settings, the daemon records the file&apos;s mtime (as integer microseconds) at startup and reports it in every handshake response. The client compares it with the current mtime and restarts the daemon when they differ. Unlike a version mismatch, this restart happens at any point in a session, because a settings edit (or a &lt;code&gt;ccc init&lt;/code&gt; retry that rewrites the file) is expected.&lt;/p&gt;
&lt;p&gt;For project settings, we do nothing special. Each indexing pass reads the settings file fresh from disk, so there is no staleness check or cache to invalidate. The one exception is custom chunker modules listed under &lt;code&gt;chunkers&lt;/code&gt;: the daemon loads them when it first opens the project, so a change there takes effect after &lt;code&gt;ccc daemon restart&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The principle is to minimize what the daemon holds as state. Global settings are unavoidable state (the loaded model), so we detect staleness. Project settings can be stateless, so we make them stateless.&lt;/p&gt;
&lt;h2&gt;Per-request vs. persistent connections: which is better for local IPC?&lt;/h2&gt;
&lt;p&gt;Per-request connections. Each request opens a fresh Unix socket connection, sends, receives, and closes. Setup takes about 0.1 ms, which is negligible for human-initiated CLI commands. Persistent connections require idle handler tasks, shutdown signaling across async/thread boundaries, and connection lifecycle management at every call site. We started with persistent connections and later removed them. That removal was the largest simplification in the daemon, and a bug led to it.&lt;/p&gt;
&lt;h3&gt;Why we tried persistent connections first&lt;/h3&gt;
&lt;p&gt;Our first design followed the obvious pattern: the client connects, handshakes, then sends multiple requests on the same connection. The daemon handler loops, reading and dispatching requests until the client disconnects:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# The original handler: persistent connection with recv loop
async def handle_connection(conn, registry, ...):
    loop = asyncio.get_event_loop()

    def _recv():
        while not shutdown_event.is_set():
            if conn.poll(0.5):          # wake every 0.5s to check shutdown
                return conn.recv_bytes()
        raise EOFError(&quot;shutdown&quot;)

    try:
        while not shutdown_event.is_set():
            data = await loop.run_in_executor(None, _recv)
            req = decode_request(data)
            # ... handshake, dispatch, respond ...
    except Exception:
        logger.exception(&quot;Error handling connection&quot;)
    finally:
        conn.close()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This handler had to deal with a lot:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;code&gt;_recv&lt;/code&gt; helper that polls every 0.5 seconds, checking &lt;code&gt;shutdown_event&lt;/code&gt; for shutdown&lt;/li&gt;
&lt;li&gt;An executor thread per connection, blocked in &lt;code&gt;conn.poll()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;while&lt;/code&gt; loop waiting for the next request that may never come&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Two problems emerged from this design:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Leaked connections.&lt;/strong&gt; A one-shot &lt;code&gt;ccc&lt;/code&gt; process closes its socket when it exits, but long-lived clients (the MCP server, and tests that ran the daemon in-process) did not always close theirs. Each leaked connection meant a handler task stuck in &lt;code&gt;_recv&lt;/code&gt;, waiting forever. Every call site needed an explicit &lt;code&gt;client.close()&lt;/code&gt;, and each new call site could leak a connection again.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Broken shutdown.&lt;/strong&gt; Our test suite took 15 seconds per test teardown. The &lt;code&gt;stop_daemon()&lt;/code&gt; function had a 5-step escalation (StopRequest, wait 5 seconds, SIGTERM, wait 2 seconds, SIGKILL) and always fell through to SIGKILL. Three bugs were stacked on top of each other:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;asyncio.Event.is_set()&lt;/code&gt; called from executor threads, but &lt;code&gt;asyncio.Event&lt;/code&gt; is not thread-safe. The &lt;code&gt;_recv&lt;/code&gt; threads never saw the shutdown signal.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;asyncio.run()&lt;/code&gt; cleanup hanging: it calls &lt;code&gt;shutdown_default_executor(wait=True)&lt;/code&gt;, which waits for the &lt;code&gt;_recv&lt;/code&gt; threads that would never exit (because of bug #1).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;os.kill(pid, 0)&lt;/code&gt; returning True for zombie processes, so the client kept waiting for a process that had already exited.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We fixed each bug individually. But when we stepped back, the first two bugs traced back to persistent connections: they needed idle handler tasks, the idle tasks needed a shutdown signal, and that signal had to cross the boundary between asyncio and threads. The third bug is about process liveness; the PID-file check described &lt;a href=&quot;#how-do-you-cleanly-shut-down-a-python-daemon-without-falling-through-to-sigkill&quot;&gt;below&lt;/a&gt; fixed it in the same change.&lt;/p&gt;
&lt;p&gt;The demo replays both designs. Run a few searches, then stop the daemon. The persistent mode follows the handler above and the old &lt;code&gt;stop_daemon()&lt;/code&gt; in real time: its clock adds up the waits of 5 s, 2 s, and 1 s for the kernel to reap the process after SIGKILL. The per-request mode follows the current daemon.&lt;/p&gt;
&lt;h3&gt;The per-request model: read two messages, respond, close&lt;/h3&gt;
&lt;p&gt;We removed the persistent connection: each request opens its own.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;connect → handshake → one request → response(s) → close
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The handler becomes straight-line code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# The current handler: per-request, no loop, no polling
async def handle_connection(conn, registry, ...):
    loop = asyncio.get_event_loop()
    try:
        # 1. Handshake
        data = await loop.run_in_executor(None, conn.recv_bytes)
        req = decode_request(data)
        # ... validate handshake, send response, return on version mismatch ...

        # 2. Single request
        data = await loop.run_in_executor(None, conn.recv_bytes)
        req = decode_request(data)
        result = await _dispatch(req, registry, ...)

        # 3. Send response(s) and done
        if isinstance(result, AsyncIterator):
            async for resp in result:
                conn.send_bytes(encode_response(resp))
        else:
            conn.send_bytes(encode_response(result))
    except (EOFError, OSError, asyncio.CancelledError):
        pass
    finally:
        conn.close()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The full function in &lt;code&gt;daemon.py&lt;/code&gt; is about 70 lines today, close to the old handler&apos;s length, because it also reports errors inside a streaming response and passes more context to &lt;code&gt;_dispatch&lt;/code&gt;. The difference is its shape: it has no loop and no polling.&lt;/p&gt;
&lt;h3&gt;What per-request connections eliminated&lt;/h3&gt;
&lt;p&gt;The change removed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;_recv&lt;/code&gt; polling loop, which woke every 0.5 seconds to check &lt;code&gt;shutdown_event&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;shutdown_event&lt;/code&gt; itself, and the handler threads that had to notice it.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;DaemonClient&lt;/code&gt; class, and the &lt;code&gt;client.close()&lt;/code&gt; call at each call site.&lt;/li&gt;
&lt;li&gt;Connection leaks: a connection now lives for one request, so the client cannot keep one open by mistake.&lt;/li&gt;
&lt;li&gt;Shutdown bugs 1 and 2, because no idle handler task is left to signal.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The client module went from a stateful class to module-level functions:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Module-level function: the connection lives for this call only
def index(project_root, on_progress=None, on_waiting=None):
    conn = _connect_and_handshake()
    try:
        conn.send_bytes(encode_request(IndexRequest(project_root=project_root)))
        # ... read streaming responses ...
    finally:
        conn.close()
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Compound operations open a second connection&lt;/h3&gt;
&lt;p&gt;What about operations that need multiple requests? &lt;code&gt;ccc search --refresh&lt;/code&gt; needs to index first, then search. It opens two connections:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def search_cmd(project_root, refresh=False):
    if refresh:
        client.index(project_root)       # connection 1
    client.search(project_root, query)   # connection 2
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;MCP background indexing calls &lt;code&gt;client.index()&lt;/code&gt; from a thread. It opens its own connection, with no shared state or connection-isolation bugs to reason about. The MCP heartbeat works the same way: one short connection every few minutes.&lt;/p&gt;
&lt;p&gt;The overhead is negligible: Unix socket setup takes about 0.1 ms, the handshake is a tiny msgspec payload, and CLI commands are human-initiated. Streaming responses (like indexing progress) still work: the connection lives for one request&apos;s full response stream, and it closes when that stream ends.&lt;/p&gt;
&lt;h2&gt;How do you cleanly shut down a Python daemon without falling through to SIGKILL?&lt;/h2&gt;
&lt;p&gt;Per-request connections solved the hardest shutdown problems (no idle tasks to signal). The remaining lesson is to design shutdown around closing resources, not coordinating threads.&lt;/p&gt;
&lt;p&gt;The accept loop runs in a background thread, blocking on &lt;code&gt;listener.accept()&lt;/code&gt;. To stop it, the daemon acts on the call the thread is blocked in, instead of setting a flag for the thread to poll. When we introduced per-request connections, that meant closing the listener: &lt;code&gt;accept()&lt;/code&gt; raises &lt;code&gt;OSError&lt;/code&gt;, and the thread exits. Today the daemon first wakes &lt;code&gt;accept()&lt;/code&gt; with a connection of its own, for the Windows reason below, and closing the listener remains the fallback:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def _accept_loop():
    while True:
        try:
            conn = listener.accept()
        except OSError:
            break                   # listener closed: exit
        if shutting_down.is_set():  # woken by the daemon&apos;s own connection
            conn.close()
            break
        loop.call_soon_threadsafe(_spawn_handler, conn)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Windows named pipes.&lt;/strong&gt; Closing a named-pipe listener does not cancel an &lt;code&gt;accept()&lt;/code&gt; that is already waiting. So shutdown sets &lt;code&gt;shutting_down&lt;/code&gt;, a &lt;code&gt;threading.Event&lt;/code&gt;, and then opens one dummy connection to its own pipe. &lt;code&gt;accept()&lt;/code&gt; returns that connection, the thread sees the flag, closes the connection and exits. The thread checks the flag only when &lt;code&gt;accept()&lt;/code&gt; returns; nothing polls it on a timer. The daemon runs the same wake-up on macOS and Linux too, where it is harmless, so the path is tested on every platform. (On Unix, the listener also calls &lt;code&gt;socket.shutdown()&lt;/code&gt; before &lt;code&gt;close()&lt;/code&gt;, because on Linux only &lt;code&gt;shutdown()&lt;/code&gt; wakes a thread blocked in &lt;code&gt;accept()&lt;/code&gt;.)&lt;/p&gt;
&lt;p&gt;The same principle applies to the full shutdown sequence:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;try:
    loop.run_forever()
finally:
    write_last_exit_marker(pid=os.getpid(), reason=shutdown_reason)
    # 1. stop accepting; the dummy connection wakes accept() on named pipes
    shutting_down.set()
    Client(sock_path, family=connection_family()).close()
    listener.close()
    accept_thread.join(timeout=5)
    # 2. cancel handlers and the idle reaper
    pending = [*tasks, reaper_task]
    for task in pending:
        task.cancel()
    loop.run_until_complete(asyncio.gather(*pending, return_exceptions=True))
    registry.close_all()                # 3. release resources
    loop.close()
    # 4. remove the PID file ...
    os._exit(0)                         # 5. skip slow Python teardown
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Last-exit marker first.&lt;/strong&gt; The daemon writes it before anything else in cleanup, so a client that races the rest of the shutdown already sees it. A crashed daemon never reaches this block, and the missing marker is how the client tells a crash from a graceful exit.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;PID file as the exit signal.&lt;/strong&gt; The client needs to know when the daemon has finished cleaning up.&lt;/p&gt;
&lt;p&gt;:::note
&lt;code&gt;os.kill(pid, 0)&lt;/code&gt; returns True for zombie processes: they&apos;re still in the process table. The fix: the daemon removes its PID file as the last cleanup step, and the client polls for its absence instead.
:::&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;os._exit(0)&lt;/code&gt; for fast teardown.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;:::note
Python&apos;s normal exit takes seconds when torch is loaded (atexit handlers, GC finalizers, module teardown). &lt;code&gt;os._exit(0)&lt;/code&gt; skips all of that, safe because we&apos;ve already cleaned up explicitly.
:::&lt;/p&gt;
&lt;p&gt;(One caveat: &lt;code&gt;os._exit(0)&lt;/code&gt; terminates the &lt;em&gt;entire process&lt;/em&gt;, so we guard it with &lt;code&gt;threading.current_thread() is threading.main_thread()&lt;/code&gt; for tests that run the daemon in a thread.)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Event loop on the main thread.&lt;/strong&gt; The accept loop runs in a background thread, but the asyncio event loop stays on the main thread. This is required for &lt;code&gt;loop.add_signal_handler()&lt;/code&gt; to work: SIGTERM and SIGINT call &lt;code&gt;loop.stop()&lt;/code&gt;, which causes &lt;code&gt;run_forever()&lt;/code&gt; to return into the &lt;code&gt;finally&lt;/code&gt; block above. A &lt;code&gt;StopRequest&lt;/code&gt; and the idle stop call &lt;code&gt;loop.stop()&lt;/code&gt; the same way. Windows has no &lt;code&gt;add_signal_handler()&lt;/code&gt;, so there &lt;code&gt;ccc daemon stop&lt;/code&gt; relies on the &lt;code&gt;StopRequest&lt;/code&gt;, and its SIGTERM fallback ends the process with &lt;code&gt;TerminateProcess&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;The result: thin clients and one long-lived daemon&lt;/h2&gt;
&lt;p&gt;Before and after per-request connections:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;Persistent connections&lt;/th&gt;
&lt;th&gt;Per-request connections&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Connection handler&lt;/td&gt;
&lt;td&gt;Recv loop, 0.5 s polling, shutdown event&lt;/td&gt;
&lt;td&gt;Straight-line read, respond, close; no loop (about 70 lines either way)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Client&lt;/td&gt;
&lt;td&gt;&lt;code&gt;DaemonClient&lt;/code&gt; class, &lt;code&gt;client.close()&lt;/code&gt; at each call site&lt;/td&gt;
&lt;td&gt;Module-level functions, no state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shutdown concepts&lt;/td&gt;
&lt;td&gt;&lt;code&gt;shutdown_event&lt;/code&gt; polled by executor threads&lt;/td&gt;
&lt;td&gt;&lt;code&gt;loop.stop()&lt;/code&gt;, wake or close the listener, &lt;code&gt;os._exit(0)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ccc daemon stop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Always fell through to SIGKILL: 8 s of waits, about 15 s per test teardown&lt;/td&gt;
&lt;td&gt;Under 1 s; the StopRequest, SIGTERM, SIGKILL escalation remains only as a fallback&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Against the original per-session design, the daemon itself is the gain for coding-agent users: the ML model loads once instead of on every &lt;code&gt;ccc search&lt;/code&gt;, and a search returns in under 1 second.&lt;/p&gt;
&lt;h2&gt;Five principles for a local daemon&lt;/h2&gt;
&lt;p&gt;The five patterns at the top are the mechanisms. If you&apos;re building a local daemon for developer tools, these are the principles behind them:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;An invisible daemon.&lt;/strong&gt; Auto-start on first use. Auto-restart on version mismatch, after a crash, and after an idle stop. Auto-reload config where possible. The user&apos;s mental model should be &quot;I run CLI commands&quot;. The daemon is an implementation detail.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Stateless IPC.&lt;/strong&gt; Per-request connections can&apos;t leak by construction. Unix socket setup takes about 0.1 ms, which is negligible for developer tools. The handshake on every connection catches staleness faster.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;State sorted by what must persist.&lt;/strong&gt; What &lt;em&gt;must&lt;/em&gt; live in the daemon (loaded ML model, open databases) vs what can be read fresh (config files, file lists)? Only restart for the former. The less state the daemon holds, the fewer staleness bugs you&apos;ll have.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Shutdown by resource closure.&lt;/strong&gt; Act on the call a thread is blocked in (close the listener, or connect to it) instead of having the thread poll a flag. Remove the PID file to signal completion.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;A design review when debugging gets complex.&lt;/strong&gt; We fixed three stacked shutdown bugs with careful threading, event types, and process liveness checks. Removing persistent connections made the first two go away, because that design was what created them.&lt;/p&gt;
&lt;h2&gt;Implementation&lt;/h2&gt;
&lt;p&gt;Read the implementation in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex-code&quot;&gt;cocoindex-code&lt;/a&gt;: &lt;code&gt;client.py&lt;/code&gt; holds the connection and lifecycle code, and &lt;code&gt;daemon.py&lt;/code&gt; holds the handler and the shutdown sequence.&lt;/p&gt;
</content:encoded><category>best-practices</category><category>architecture</category><category>ai-agents</category><author>George He</author></item><item><title>Five new targets and Python 3.14 free-threading in CocoIndex</title><link>https://cocoindex.io/blogs/changelog-0327-0334/</link><guid isPermaLink="true">https://cocoindex.io/blogs/changelog-0327-0334/</guid><description>CocoIndex 0.3.27–0.3.34 adds Apache Doris, ChromaDB, FalkorDB, Ladybug and Pinecone targets, LocalFile change notifications and Python 3.14 free-threading.</description><pubDate>Tue, 10 Mar 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This changelog covers &lt;strong&gt;8 releases (0.3.27–0.3.34)&lt;/strong&gt;. Most of the work went into targets, the databases CocoIndex writes to: five new target connectors (Apache Doris, ChromaDB, FalkorDB, Ladybug, and Pinecone) and new index options for LanceDB. The engine also cleans up after removed sources, validates names earlier, and runs on Python 3.14 in free-threaded mode.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex&lt;/a&gt; incrementally updates derived data from sources such as PDFs, codebases, and meeting notes. This post describes the 0.3.x API. Headings name the release in which each change first shipped.&lt;/p&gt;
&lt;p&gt;:::tip[Start here]&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;You pick a database for retrieval:&lt;/strong&gt; read &lt;a href=&quot;#targets&quot;&gt;targets&lt;/a&gt; and the &lt;a href=&quot;#sec-edgar-financial-analytics-with-cocoindex--apache-doris&quot;&gt;SEC EDGAR example&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You run pipelines in production:&lt;/strong&gt; read &lt;a href=&quot;#automatic-stale-source-cleanup-v0329&quot;&gt;stale source cleanup&lt;/a&gt;, &lt;a href=&quot;#custom-database-schema-for-internal-tables-v0329&quot;&gt;custom schema for internal tables&lt;/a&gt;, and &lt;a href=&quot;#slow-http-request-warnings-v0329&quot;&gt;slow HTTP request warnings&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You index local files:&lt;/strong&gt; read &lt;a href=&quot;#local-file-change-notifications-v0332&quot;&gt;local file change notifications&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;You use Kuzu:&lt;/strong&gt; read &lt;a href=&quot;#ladybug-successor-to-kuzu-v0333&quot;&gt;Ladybug&lt;/a&gt;.
:::&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Where to find these features in v1&lt;/h2&gt;
&lt;p&gt;This post covers the v0 API. CocoIndex v1 replaces flows with apps and processing components, so each feature has a different shape there.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;v0 feature (0.3.x)&lt;/th&gt;
&lt;th&gt;In CocoIndex v1&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Stale source cleanup&lt;/td&gt;
&lt;td&gt;v1 does this by default: when a component is no longer mounted, CocoIndex deletes the target states it owned. See &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/#how-target-states-sync&quot;&gt;how target states sync&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Python 3.14 free-threaded&lt;/td&gt;
&lt;td&gt;v1 publishes free-threaded &lt;code&gt;cp314t&lt;/code&gt; wheels (&lt;a href=&quot;https://pypi.org/project/cocoindex/#files&quot;&gt;PyPI files&lt;/a&gt;).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;update(print_stats=True)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;app.update_blocking(report_to_stdout=True)&lt;/code&gt;, or &lt;code&gt;UpdateHandle.stats()&lt;/code&gt;. See &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/progress_monitoring/&quot;&gt;progress monitoring&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;db_schema_name&lt;/code&gt; for internal tables&lt;/td&gt;
&lt;td&gt;v1 has no internal tables in Postgres: it keeps its state in a local LMDB database (&lt;code&gt;COCOINDEX_DB&lt;/code&gt;). See &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/internal_storage/&quot;&gt;internal storage&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;LocalFile&lt;/code&gt; &lt;code&gt;watch_changes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The &lt;code&gt;localfs&lt;/code&gt; source with &lt;code&gt;live=True&lt;/code&gt;, in &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/live_mode/&quot;&gt;live mode&lt;/a&gt;. See &lt;a href=&quot;https://cocoindex.io/docs/connectors/localfs/#live-file-watching&quot;&gt;live file watching&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Apache Doris target&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/doris/&quot;&gt;Doris connector&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FalkorDB target&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/falkordb/&quot;&gt;FalkorDB connector&lt;/a&gt;, added in &lt;a href=&quot;/blogs/changelog-101-107/&quot;&gt;v1.0.1 to v1.0.7&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LanceDB index options&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/lancedb/&quot;&gt;LanceDB connector&lt;/a&gt;, with vector and FTS indexes since &lt;a href=&quot;/blogs/changelog-108-1016/#lancedb-vector-and-fts-index-support-v1011&quot;&gt;v1.0.11&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ChromaDB, Pinecone and Ladybug targets&lt;/td&gt;
&lt;td&gt;No v1 connector yet. Use them on 0.3.x, or write a &lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/custom_target_connector/&quot;&gt;custom target connector&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SEC EDGAR example&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/examples/sec-edgar-analytics/&quot;&gt;SEC EDGAR analytics&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Slides-to-speech example&lt;/td&gt;
&lt;td&gt;&lt;a href=&quot;https://cocoindex.io/docs/examples/slides-to-speech/&quot;&gt;Slides to speech&lt;/a&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;Core capability&lt;/h2&gt;
&lt;p&gt;The engine changes in this cycle are about state and visibility. CocoIndex now removes what a deleted source left behind, rejects bad table and column names before setup, and reports more about what a running pipeline is doing. It also runs on Python 3.14 in free-threaded mode.&lt;/p&gt;
&lt;h3&gt;Automatic stale source cleanup (v0.3.29)&lt;/h3&gt;
&lt;p&gt;When you renamed or removed a source in a flow, its rows used to stay in the target, along with CocoIndex&apos;s tracking metadata for them (the records of which source rows produced which target rows). No step read or deleted them.&lt;/p&gt;
&lt;p&gt;Now flow setup detects the renamed or removed source, streams through its tracking metadata, deletes the matching target rows, and removes the stale state records. It runs with controlled parallelism, so it does not overload your database (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1468&quot;&gt;&lt;strong&gt;#1468&lt;/strong&gt;&lt;/a&gt;). You do not delete anything by hand.&lt;/p&gt;
&lt;h3&gt;Python 3.14 free-threaded support (v0.3.29 to v0.3.30)&lt;/h3&gt;
&lt;p&gt;Standard CPython has a global interpreter lock (GIL), which lets only one thread run Python code at a time. Python 3.14 has a free-threaded build without it, so threads that run Python code can use several cores at once.&lt;/p&gt;
&lt;p&gt;CocoIndex now runs natively in Python 3.14&apos;s free-threaded mode. CI builds ship free-threaded wheels on manylinux. Install CocoIndex into a free-threaded Python 3.14 interpreter; CocoIndex itself needs no config change (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1357&quot;&gt;&lt;strong&gt;#1357&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1609&quot;&gt;&lt;strong&gt;#1609&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1638&quot;&gt;&lt;strong&gt;#1638&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;Tighter target validation (v0.3.34)&lt;/h3&gt;
&lt;p&gt;An invalid table or column name used to reach the database and fail there, with an error that did not point back to your flow. CocoIndex now validates table and column names before target setup (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1714&quot;&gt;&lt;strong&gt;#1714&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;Execution plan initialization fix (v0.3.34)&lt;/h3&gt;
&lt;p&gt;A race condition let the execution plan run before target setup completed. Target setup now completes first (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1715&quot;&gt;&lt;strong&gt;#1715&lt;/strong&gt;&lt;/a&gt;). The figure shows the order in 0.3.34.&lt;/p&gt;
&lt;h3&gt;Pipeline stats in &lt;code&gt;update()&lt;/code&gt; API (v0.3.28)&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;cocoindex update&lt;/code&gt; CLI printed statistics, but a call to &lt;code&gt;update()&lt;/code&gt; from your own code did not. A new &lt;code&gt;print_stats&lt;/code&gt; option on the &lt;code&gt;update()&lt;/code&gt; API prints runtime statistics at the call site, which helps when you benchmark or debug a pipeline (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1525&quot;&gt;&lt;strong&gt;#1525&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;stats = my_flow.update(print_stats=True)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; One line per source, with a progress bar and the number of source rows added, updated, reprocessed, deleted, unchanged, or in error.&lt;/p&gt;
&lt;h3&gt;Custom database schema for internal tables (v0.3.29)&lt;/h3&gt;
&lt;p&gt;CocoIndex keeps its internal metadata and tracking tables in Postgres. In a database that other applications share, those tables used to land in the connection&apos;s default schema.&lt;/p&gt;
&lt;p&gt;They can now live in a custom Postgres schema (a named namespace for tables inside one database). Set &lt;code&gt;db_schema_name&lt;/code&gt; in &lt;code&gt;cocoindex.Settings&lt;/code&gt;, or the &lt;code&gt;COCOINDEX_DATABASE_SCHEMA_NAME&lt;/code&gt; environment variable. CocoIndex writes &lt;code&gt;schema.table&lt;/code&gt; names instead of changing &lt;code&gt;search_path&lt;/code&gt;, so other users of a shared database see no change (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1459&quot;&gt;&lt;strong&gt;#1459&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;export COCOINDEX_DATABASE_SCHEMA_NAME=cocoindex_internal
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; CocoIndex&apos;s internal tables appear in the &lt;code&gt;cocoindex_internal&lt;/code&gt; schema, which is created if it does not exist. Without the setting, they stay in the connection&apos;s default schema, usually &lt;code&gt;public&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Slow HTTP request warnings (v0.3.29)&lt;/h3&gt;
&lt;p&gt;A stalled update often waits on one slow call to an LLM provider or an external API. The runtime now logs a warning for slow HTTP requests, so you can find that call (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1617&quot;&gt;&lt;strong&gt;#1617&lt;/strong&gt;&lt;/a&gt;). The threshold is 30 seconds:&lt;/p&gt;
&lt;h3&gt;Enhanced tracing (v0.3.29)&lt;/h3&gt;
&lt;p&gt;Tracing now covers more of the engine, which helps when you debug a pipeline (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1618&quot;&gt;&lt;strong&gt;#1618&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;ColPali/ColQwen organization prefix fix (v0.3.29)&lt;/h3&gt;
&lt;p&gt;Fixed a crash when using ColPali or ColQwen models with organization-prefixed model names (e.g., &lt;code&gt;org/model-name&lt;/code&gt;) (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1624&quot;&gt;&lt;strong&gt;#1624&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;

Quick check: you remove a source from a flow. What happens to the rows it wrote to the target?
&lt;p&gt;From 0.3.29, CocoIndex deletes them during flow setup, together with the tracking metadata and state records for that source.&lt;/p&gt;

&lt;h2&gt;Integrations&lt;/h2&gt;
&lt;p&gt;This cycle adds five target connectors, local filesystem change notifications, and more LanceDB index options.&lt;/p&gt;
&lt;h3&gt;Sources&lt;/h3&gt;
&lt;h4&gt;Local file change notifications (v0.3.32)&lt;/h4&gt;
&lt;p&gt;To see new or changed files, a source must either poll (list and compare the files on a schedule) or receive change events from the operating system. Polling costs CPU and adds delay.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://cocoindex.io/docs-v0/sources/localfile/&quot;&gt;&lt;code&gt;LocalFile&lt;/code&gt; source&lt;/a&gt; now supports &lt;strong&gt;native filesystem change notifications&lt;/strong&gt; through the &lt;code&gt;notify&lt;/code&gt; crate, a Rust library for OS file events. With the new &lt;code&gt;watch_changes&lt;/code&gt; option, CocoIndex reacts to OS events instead of polling. Changes reach the update sooner, scans no longer cost CPU, and your include/exclude patterns still apply (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1669&quot;&gt;&lt;strong&gt;#1669&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;:::warning[Python API in 0.3.34]
In 0.3.34, &lt;code&gt;watch_changes&lt;/code&gt; exists in the engine&apos;s &lt;code&gt;LocalFile&lt;/code&gt; spec and in the &lt;code&gt;LocalFile&lt;/code&gt; docs. The Python &lt;code&gt;cocoindex.sources.LocalFile&lt;/code&gt; class has no &lt;code&gt;watch_changes&lt;/code&gt; field, so &lt;code&gt;LocalFile(path=..., watch_changes=True)&lt;/code&gt; raises &lt;code&gt;TypeError&lt;/code&gt;. The field is still missing in 0.3.39, the last 0.3.x release.
:::&lt;/p&gt;
&lt;h3&gt;Targets&lt;/h3&gt;
&lt;p&gt;Each new target fits a different kind of retrieval: vector search (Apache Doris, ChromaDB, Pinecone), graph queries (FalkorDB, Ladybug), or analytics with SQL (Apache Doris).&lt;/p&gt;
&lt;p&gt;0.3.34 has 9 built-in targets: Postgres, Qdrant, Pinecone, LanceDB, ChromaDB, Apache Doris, Neo4j, FalkorDB, and Ladybug (with Kuzu aliases).&lt;/p&gt;
&lt;p&gt;In the notes below, HNSW and IVF are two families of approximate nearest-neighbor vector index: HNSW is a layered graph, and IVF groups vectors into clusters and searches only the clusters closest to the query.&lt;/p&gt;
&lt;h4&gt;Apache Doris (v0.3.28 to v0.3.30)&lt;/h4&gt;
&lt;p&gt;CocoIndex now writes to &lt;a href=&quot;https://cocoindex.io/docs-v0/targets/doris/&quot;&gt;&lt;strong&gt;Apache Doris 4.0&lt;/strong&gt;&lt;/a&gt; (and VeloDB Cloud) as a vector database target. The target includes HNSW and IVF vector indexes, inverted full-text search indexes with Unicode/English/Chinese parsers, Stream Load ingestion (Doris&apos;s HTTP bulk-load API) with batching and exponential backoff, and upsert/delete support. A text embedding example ships alongside (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1475&quot;&gt;&lt;strong&gt;#1475&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1642&quot;&gt;&lt;strong&gt;#1642&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;ChromaDB (v0.3.29 to v0.3.31)&lt;/h4&gt;
&lt;p&gt;The new ChromaDB target supports &lt;code&gt;PersistentClient&lt;/code&gt;, &lt;code&gt;CloudClient&lt;/code&gt; (with SPANN+SPFresh, the vector indexes of Chroma Cloud), and &lt;code&gt;HttpClient&lt;/code&gt;. It includes HNSW configuration options, explicit &lt;code&gt;document_field&lt;/code&gt; specification, and early validation for vector fields (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1548&quot;&gt;&lt;strong&gt;#1548&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1663&quot;&gt;&lt;strong&gt;#1663&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;FalkorDB (v0.3.29)&lt;/h4&gt;
&lt;p&gt;New &lt;strong&gt;property graph target&lt;/strong&gt; powered by &lt;a href=&quot;https://www.falkordb.com/&quot;&gt;FalkorDB&lt;/a&gt;, a graph database built on Redis. A property graph stores nodes and relationships, each with a label and key-value properties. The target supports nodes, relationships, vector and FTS (full-text search) indexes, and batch operations. It ships with a docs-to-knowledge-graph example using LLM extraction (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1481&quot;&gt;&lt;strong&gt;#1481&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;Ladybug, successor to Kuzu (v0.3.33)&lt;/h4&gt;
&lt;p&gt;Kuzu was archived in October 2025. &lt;strong&gt;Ladybug&lt;/strong&gt; is the maintained community fork of Kuzu. Like Kuzu, it is an embedded property graph database, and CocoIndex writes to it with Cypher, the graph query language both use. CocoIndex now targets Ladybug natively, with backward-compatible &lt;code&gt;Kuzu*&lt;/code&gt; type aliases so existing pipelines can retain their &lt;code&gt;Kuzu*&lt;/code&gt; type names (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1487&quot;&gt;&lt;strong&gt;#1487&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;LanceDB (v0.3.29)&lt;/h4&gt;
&lt;p&gt;LanceDB was already a target. It now supports &lt;code&gt;VectorIndexMethod&lt;/code&gt; for &lt;strong&gt;HNSW and IVF Flat indexes&lt;/strong&gt; in &lt;a href=&quot;https://cocoindex.io/docs-v0/targets/lancedb/&quot;&gt;LanceDB&lt;/a&gt;, which gives you control over index configuration (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1409&quot;&gt;&lt;strong&gt;#1409&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;Pinecone (v0.3.31)&lt;/h4&gt;
&lt;p&gt;Pinecone is now a built-in target connector, so a CocoIndex pipeline can write to your managed Pinecone indexes. A text embedding example is included (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1556&quot;&gt;&lt;strong&gt;#1556&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;

Quick check: a pipeline uses the &lt;code&gt;Kuzu&lt;/code&gt; target type. Must you rename it to upgrade?
&lt;p&gt;No. &lt;code&gt;Kuzu&lt;/code&gt;, &lt;code&gt;KuzuConnection&lt;/code&gt;, and &lt;code&gt;KuzuDeclaration&lt;/code&gt; remain as aliases for the Ladybug types, so existing pipelines keep their names.&lt;/p&gt;


Quick check: which of the new targets is a property graph built on Redis?
&lt;p&gt;FalkorDB. Ladybug is the other new graph target; it is the community fork of Kuzu.&lt;/p&gt;

&lt;h2&gt;Build with CocoIndex&lt;/h2&gt;
&lt;h3&gt;SEC EDGAR financial analytics with CocoIndex + Apache Doris&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;/blogs/sec-edgar-analytics/&quot;&gt;SEC EDGAR Financial Analytics with CocoIndex + Apache Doris&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A &lt;strong&gt;multi-source ETL pipeline&lt;/strong&gt; that builds a financial analytics system from SEC EDGAR data with CocoIndex and Apache Doris.&lt;/p&gt;
&lt;p&gt;The example ingests three data sources: TXT filings (10-K/10-Q risk factors), JSON company facts from the SEC XBRL API, and PDF proxy statements. It then indexes them into Apache Doris with &lt;strong&gt;hybrid search&lt;/strong&gt; (vector + keyword via Reciprocal Rank Fusion, which merges the two ranked lists by rank position), &lt;strong&gt;topic filtering&lt;/strong&gt; with JSON arrays, and &lt;strong&gt;portfolio-level search&lt;/strong&gt; with per-company aggregation.&lt;/p&gt;
&lt;p&gt;It also scrubs PII (personal data such as names and contact details) before indexing, and uses incremental updates with caching.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/sec_edgar_analytics&quot;&gt;tutorial&lt;/a&gt; has the full code.&lt;/p&gt;
&lt;h3&gt;Slides-to-Speech: Turn slide decks into searchable, narrated knowledge&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;/blogs/slides-to-speech/&quot;&gt;Slides-to-Speech: Turn slide decks into searchable, narrated knowledge&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Slide decks in Google Drive hold knowledge that is hard to search. The walkthrough builds a &lt;strong&gt;continuously updating slides-to-speech pipeline&lt;/strong&gt; with CocoIndex and LanceDB.&lt;/p&gt;
&lt;p&gt;The pipeline watches a Drive folder for new or modified PDF decks, converts each slide to an image with &lt;strong&gt;PyMuPDF&lt;/strong&gt;, extracts structured speaker notes using &lt;strong&gt;BAML + Gemini Vision&lt;/strong&gt;, synthesizes narration with &lt;strong&gt;Piper-TTS&lt;/strong&gt;, generates embeddings, and indexes everything into &lt;strong&gt;LanceDB&lt;/strong&gt;: images, transcripts, audio bytes, and metadata in one place.&lt;/p&gt;
&lt;p&gt;What the example shows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Incremental processing&lt;/strong&gt;: Only changed slides get reprocessed. If you update one slide in a 200-page deck, CocoIndex regenerates the audio, transcript, and embedding for that slide only.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multimodal search&lt;/strong&gt;: Semantic queries return the top matching slides with their images, speaker notes, and synced audio.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Local TTS&lt;/strong&gt;: Neural text-to-speech runs locally via Piper, so there are no API costs for audio generation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A searchable dataset&lt;/strong&gt;: The PDF becomes a searchable, listenable dataset that stays current, for agents, accessibility tools, or video generation.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;a href=&quot;https://cocoindex.io/blogs/slides-to-speech&quot;&gt;blog post&lt;/a&gt; walks through each step.&lt;/p&gt;
&lt;h2&gt;What to try next&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Pick a target for your retrieval pattern.&lt;/strong&gt; Start from the Apache Doris or Pinecone text embedding example, or the FalkorDB docs-to-knowledge-graph example, all described &lt;a href=&quot;#targets&quot;&gt;above&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Print stats from code.&lt;/strong&gt; Call &lt;code&gt;update(print_stats=True)&lt;/code&gt; to see added, updated, and deleted rows per source, as in &lt;a href=&quot;#pipeline-stats-in-update-api-v0328&quot;&gt;the stats example&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Move internal tables out of &lt;code&gt;public&lt;/code&gt;.&lt;/strong&gt; Set &lt;code&gt;COCOINDEX_DATABASE_SCHEMA_NAME&lt;/code&gt; in a shared Postgres database, as in &lt;a href=&quot;#custom-database-schema-for-internal-tables-v0329&quot;&gt;the schema example&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Watch for slow calls.&lt;/strong&gt; Look in your logs for &lt;code&gt;Taking longer than 30s&lt;/code&gt; to find the HTTP requests that hold up an update.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;On Kuzu, move to Ladybug.&lt;/strong&gt; Your &lt;code&gt;Kuzu*&lt;/code&gt; type names keep working; see &lt;a href=&quot;#ladybug-successor-to-kuzu-v0333&quot;&gt;Ladybug&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Move to CocoIndex v1.&lt;/strong&gt; v1 has shipped and replaces the v0 API on this page. Its release notes start with &lt;a href=&quot;/blogs/changelog-101-107/&quot;&gt;CocoIndex 1.0.1 to 1.0.7&lt;/a&gt;, and the &lt;a href=&quot;#where-to-find-these-features-in-v1&quot;&gt;table above&lt;/a&gt; maps these features to v1.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The source is on &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Thanks to the community&lt;/h2&gt;
&lt;p&gt;Welcome to the new CocoIndex contributors.&lt;/p&gt;
&lt;h3&gt;@tomz-alt&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/tomz-alt&quot;&gt;@tomz-alt&lt;/a&gt; for adding the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1475&quot;&gt;Apache Doris 4.0 vector database connector&lt;/a&gt; (a target with vector indexes, full-text search, and Stream Load ingestion) and for building the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1623&quot;&gt;SEC EDGAR financial analytics example&lt;/a&gt; which shows multi-source ETL with hybrid search, plus &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1567&quot;&gt;improving the Doris text embedding example&lt;/a&gt; and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1650&quot;&gt;cleaning up the SEC EDGAR tutorial&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@prrao87&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/prrao87&quot;&gt;@prrao87&lt;/a&gt; for adding &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1487&quot;&gt;Ladybug&lt;/a&gt; (the Kuzu successor) as a target, which gives CocoIndex users a migration path to the maintained graph database fork.&lt;/p&gt;
&lt;h3&gt;@galshubeli&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/galshubeli&quot;&gt;@galshubeli&lt;/a&gt; for adding the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1481&quot;&gt;FalkorDB target&lt;/a&gt;, a property graph integration with nodes, relationships, vector/FTS indexes, and a docs-to-knowledge-graph example.&lt;/p&gt;
&lt;h3&gt;@Geoff-Robin&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/Geoff-Robin&quot;&gt;@Geoff-Robin&lt;/a&gt; for adding &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1459&quot;&gt;custom database schema support&lt;/a&gt; for CocoIndex&apos;s internal tables, so they stay apart from other tables in a shared Postgres database, with explicit &lt;code&gt;schema.table&lt;/code&gt; qualification.&lt;/p&gt;
&lt;h3&gt;@wuxiaobai24&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/wuxiaobai24&quot;&gt;@wuxiaobai24&lt;/a&gt; for adding &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1357&quot;&gt;Python 3.14 free-threaded support&lt;/a&gt;, configuring PyO3 so CocoIndex runs without the GIL.&lt;/p&gt;
&lt;h3&gt;@ceshine&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/ceshine&quot;&gt;@ceshine&lt;/a&gt; for &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1624&quot;&gt;fixing the ColPali/ColQwen crash&lt;/a&gt; when using models with organization prefixes.&lt;/p&gt;
&lt;h3&gt;@LED-0102&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/LED-0102&quot;&gt;@LED-0102&lt;/a&gt; for adding &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1669&quot;&gt;filesystem change notifications&lt;/a&gt; to the LocalFile source using the &lt;code&gt;notify&lt;/code&gt; crate, so live updates react to OS file events.&lt;/p&gt;
&lt;h3&gt;@prithvi-moonshot&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/prithvi-moonshot&quot;&gt;@prithvi-moonshot&lt;/a&gt; for adding &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1556&quot;&gt;Pinecone as a target connector&lt;/a&gt; with a text embedding example.&lt;/p&gt;
&lt;h3&gt;@Haleshot&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/Haleshot&quot;&gt;@Haleshot&lt;/a&gt; for building the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1548&quot;&gt;initial ChromaDB target integration&lt;/a&gt; with support for PersistentClient, CloudClient, and HttpClient, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1663&quot;&gt;fixing ChromaDB collection creation on first run&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1621&quot;&gt;adding ChromaDB documentation&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1455&quot;&gt;adding llms.txt to docs&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1458&quot;&gt;adding short flag aliases for common CLI options&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1574&quot;&gt;clarifying .env usage across examples&lt;/a&gt;, and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1564&quot;&gt;migrating CI from pre-commit to prek&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;@thisisharsh7&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/thisisharsh7&quot;&gt;@thisisharsh7&lt;/a&gt; for adding &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1468&quot;&gt;automatic cleanup of stale source data&lt;/a&gt;, ensuring renamed or removed sources don&apos;t leave orphaned tracking metadata or target rows.&lt;/p&gt;
&lt;h3&gt;@majiayu000&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/majiayu000&quot;&gt;@majiayu000&lt;/a&gt; for adding &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1409&quot;&gt;&lt;code&gt;VectorIndexMethod&lt;/code&gt; support for HNSW and IVF Flat indexes&lt;/a&gt; in LanceDB.&lt;/p&gt;
</content:encoded><category>changelog</category><category>connectors</category><category>performance</category><category>incremental-processing</category><author>George He</author></item><item><title>CocoIndex joins the GitHub Secure Open Source Fund</title><link>https://cocoindex.io/blogs/cocoindex-joins-security-github-secure-open-source-fund/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-joins-security-github-secure-open-source-fund/</guid><description>CocoIndex joined the GitHub Secure Open Source Fund, hardening the AI data infrastructure developers depend on with threat modeling, CodeQL, and audits.</description><pubDate>Tue, 17 Feb 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex&lt;/a&gt; is a &lt;a href=&quot;https://cocoindex.io/blogs/data-for-ai&quot;&gt;data transformation framework&lt;/a&gt; that sits between raw data and the AI systems that depend on it. That position makes security a core requirement.&lt;/p&gt;
&lt;p&gt;When developers trust CocoIndex to process sensitive documents, codebases, and enterprise data, the security of that path is our responsibility. We were selected to join the &lt;a href=&quot;https://resources.github.com/github-secure-open-source-fund/&quot;&gt;GitHub Secure Open Source Fund&lt;/a&gt;, a program that gave us structure and expert guidance to formalize our security practices.&lt;/p&gt;
&lt;h2&gt;What is GitHub&apos;s Secure Open Source Fund?&lt;/h2&gt;
&lt;p&gt;When the Log4j &lt;a href=&quot;https://en.wikipedia.org/wiki/Log4Shell&quot;&gt;&quot;Log4Shell&quot;&lt;/a&gt; vulnerability hit in December 2021, it showed that a bug in one small, underfunded open-source project can ripple through the software that depends on it. Most apps today rely on many dependencies, many maintained by unpaid volunteers, and a weakness in any one of them reaches everyone downstream.&lt;/p&gt;
&lt;p&gt;Recognizing this, GitHub launched the &lt;a href=&quot;https://github.com/open-source/github-secure-open-source-fund&quot;&gt;Secure Open Source (SOS) Fund&lt;/a&gt; in late 2024 to strengthen the foundation of open-source security. The program pairs direct funding with a focused 3-week security sprint that combines expert guidance, better tooling, and a community of security-conscious maintainers.&lt;/p&gt;
&lt;p&gt;In its first two cohorts, 125 maintainers from 71 projects participated, collectively fixing over 1,100 vulnerabilities, disclosing 50+ new CVEs, and resolving nearly 270 secret exposures.&lt;/p&gt;
&lt;p&gt;Participants also exchanged knowledge, used AI-assisted tools like GitHub Copilot for security tasks, and developed incident response plans that many have since published for others to reuse.&lt;/p&gt;
&lt;h2&gt;What is CocoIndex?&lt;/h2&gt;
&lt;p&gt;CocoIndex is a declarative, Python-native &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/core_concepts/&quot;&gt;data transformation engine&lt;/a&gt; for AI workloads.&lt;/p&gt;
&lt;p&gt;As AI systems evolve from chatbots to autonomous agents, one hard problem keeps coming back: keeping context accurate and up to date as the underlying data changes.&lt;/p&gt;
&lt;p&gt;Enterprises sit on large, changing datasets (documents, codebases, emails, APIs), yet most data infrastructure is still batch-oriented and blind to change. A change in data or logic usually means a rebuild from scratch, which breaks the feedback loop between the current state of the world and AI decision-making. CocoIndex keeps an AI system&apos;s view of that data current and incremental: you declare the transformation, and the engine detects what changed and recomputes only the affected results. The model is close to React for UI, applied to data processing.&lt;/p&gt;
&lt;h2&gt;The cohort&lt;/h2&gt;
&lt;p&gt;We were in the program alongside &lt;a href=&quot;https://github.com/pandas-dev/pandas&quot;&gt;Pandas&lt;/a&gt;, &lt;a href=&quot;https://github.com/apache/airflow&quot;&gt;Apache Airflow&lt;/a&gt;, &lt;a href=&quot;https://github.com/fabricjs/fabric.js&quot;&gt;Fabric.js&lt;/a&gt;, &lt;a href=&quot;https://github.com/pypi&quot;&gt;PyPI&lt;/a&gt;, and others. We heard from teams dealing with similar challenges: how they handle dependency updates, structure security reviews, and think about trust boundaries.&lt;/p&gt;
&lt;p&gt;Open source can be isolating. You&apos;re deep in your own codebase, solving your own problems. Hearing how other maintainers answer the same security questions was one of the most useful parts of the program.&lt;/p&gt;
&lt;h2&gt;What we hardened during the sprint&lt;/h2&gt;
&lt;p&gt;During the program, the CocoIndex team ran a focused security sprint to harden both our codebase and the way we build and ship it. With guidance from GitHub Security Lab and community experts, we concentrated on four areas that matter for a framework sitting directly in AI data paths.&lt;/p&gt;
&lt;h3&gt;Threat modeling and AI-specific risk assessment&lt;/h3&gt;
&lt;p&gt;We systematically threat-modeled the CocoIndex framework, examining how an attacker might exploit a data transformation pipeline that feeds directly into AI systems. We mapped out attack vectors including adversarial document content that could poison embeddings, prompt injection through source data that could manipulate LLM-based extraction, and compromised dependencies that could silently corrupt downstream indexes. Resources like the &lt;a href=&quot;https://github.com/rzhade3/adversarial-ai-reading-list&quot;&gt;Adversarial AI Reading List&lt;/a&gt; and &lt;a href=&quot;https://embracethered.com/&quot;&gt;Embrace The Red&lt;/a&gt; were particularly useful in shaping this analysis. By identifying these failure points upfront, we developed mitigation strategies before they could be exploited in production pipelines.&lt;/p&gt;
&lt;h3&gt;Secure coding and automated checks&lt;/h3&gt;
&lt;p&gt;We wired GitHub&apos;s security tooling directly into CocoIndex&apos;s development loop. &lt;a href=&quot;https://codeql.github.com/&quot;&gt;CodeQL&lt;/a&gt; now runs on every pull request, scanning both our Rust core and Python SDK for vulnerability patterns. For a system where data flows from sources through transformations to targets, CodeQL&apos;s data flow analysis maps naturally onto our architecture, tracing untrusted input from ingestion all the way to exported artifacts. We also enabled secret scanning to keep credentials and API keys out of the repository, and we started using GitHub Copilot as a guardrail during development to surface potential issues before code is committed. Together, these checks act as a continuous security layer in our CI pipeline, catching problems early instead of after a release.&lt;/p&gt;
&lt;h3&gt;Dependency and supply chain hardening&lt;/h3&gt;
&lt;p&gt;CocoIndex integrates with embedding models, vector databases, document parsers, and cloud storage backends, each one pulling in its own dependency chain. We audited our dependencies across both the Rust core and Python SDK, going beyond direct dependencies to examine the transitive tree underneath. We tightened our dependency review process with more systematic tracking of what we depend on and why. We also adopted the &lt;a href=&quot;https://securityscorecards.dev/&quot;&gt;OpenSSF Scorecard&lt;/a&gt; to continuously benchmark our project&apos;s security posture across branch protection, dependency updates, CI/CD practices, and more. Following &lt;a href=&quot;https://openssf.org/&quot;&gt;OpenSSF&lt;/a&gt; standards, we&apos;re working toward a software bill of materials (SBOM) for each release, giving users visibility into exactly what ships with CocoIndex.&lt;/p&gt;
&lt;h3&gt;Policy, documentation and vulnerability response&lt;/h3&gt;
&lt;p&gt;We formalized our &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/blob/main/.github/SECURITY.md&quot;&gt;SECURITY.md&lt;/a&gt; with clear instructions for responsible disclosure and defined response commitments. Vulnerabilities should be reported to security@cocoindex.io, not filed as public issues. We also established an internal process for triaging and patching reported vulnerabilities: who gets involved, how we communicate, and how quickly we ship fixes. Every new connector or &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/&quot;&gt;transformation function&lt;/a&gt; now gets reviewed through the lens of: what&apos;s the worst-case input, and what happens if a dependency in this path is compromised?&lt;/p&gt;
&lt;p&gt;The automated checks catch classes of issues that a manual review can miss, and the disclosure process gives users a clear channel when something does slip through. Because CocoIndex sits in the data path of the AI systems built on it, these improvements carry downstream to the applications built on those pipelines.&lt;/p&gt;
&lt;h2&gt;Thanks to our contributors&lt;/h2&gt;
&lt;p&gt;This work rests on the people who build CocoIndex with us every day. Everyone who has submitted a PR, reported a bug, reviewed code, or helped another user in Discord: this project exists, and was recognized, because of you.&lt;/p&gt;
&lt;p&gt;We especially want to thank those doing the work that doesn&apos;t show up in commit logs: writing documentation, answering questions, and building examples that help new users get started.&lt;/p&gt;
&lt;h2&gt;What stays after the sprint&lt;/h2&gt;
&lt;p&gt;The sprint is over, but the checks it added stay in CI, and the review habits stay with us for every new connector and integration.&lt;/p&gt;
&lt;p&gt;The GitHub Secure Open Source Fund gave us dedicated time, expert guidance, and a community of peers to learn from. The improvements ship in CocoIndex itself, so they reach anyone who builds a pipeline on it.&lt;/p&gt;
&lt;p&gt;We&apos;re grateful to GitHub and the entire cohort for this experience, and we plan to keep sharing what we&apos;ve learned with the broader AI infrastructure community.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;CocoIndex is open source on &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;GitHub&lt;/a&gt;. Questions or feedback: join our &lt;a href=&quot;https://discord.com/invite/zpA9S2DR7s&quot;&gt;Discord&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>announcement</category><category>security</category><category>best-practices</category><category>community</category><author>Linghua Jin</author></item><item><title>Hybrid search over SEC EDGAR filings with Apache Doris</title><link>https://cocoindex.io/blogs/sec-edgar-analytics/</link><guid isPermaLink="true">https://cocoindex.io/blogs/sec-edgar-analytics/</guid><description>Index SEC 10-K text and XBRL facts into one Apache Doris table with CocoIndex v1, then rank each chunk by meaning and by keywords, fused with RRF.</description><pubDate>Mon, 09 Feb 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Every public company in the United States files reports with the SEC (the U.S. Securities and Exchange Commission). The reports are public on EDGAR, the SEC&apos;s filing system. Say you want to ask questions across them: which companies name cybersecurity as a risk, what a company reported as revenue, or how often a risk comes up by filing year.&lt;/p&gt;
&lt;p&gt;Two things make this harder than a text search. First, one company&apos;s data comes in different formats: its risks are prose in an annual report, and its financial numbers are structured data. Second, a question such as &quot;cloud computing and AI risk&quot; needs both kinds of search. Keyword search finds the exact words. Search by meaning finds passages that say the same thing in other words.&lt;/p&gt;
&lt;p&gt;An agent or a RAG pipeline that retrieves from filings needs both. A question that names a company, a CIK or a metric such as &quot;net income&quot; must hit those exact words; a vector places them near similar words but does not guarantee a match. A question about &quot;risks of hosted services&quot; must also find a 10-K that says &quot;a data breach in our cloud services&quot;. The same company&apos;s numbers are in JSON, not prose, so both formats have to land in one searchable form.&lt;/p&gt;
&lt;p&gt;This tutorial walks through the &lt;strong&gt;SEC EDGAR Financial Analytics&lt;/strong&gt; example, a CocoIndex v1 pipeline that handles both. It reads the 2 formats, removes personal data and splits the text into chunks. It tags each chunk with topics and turns it into a vector (a list of numbers that captures its meaning). Everything lands in one Apache Doris table that has 2 indexes: an inverted index for keywords and a vector index for meaning. A search then ranks every chunk both ways and combines the 2 rankings into one score.&lt;/p&gt;
&lt;p&gt;The numbers in the figures come from the example&apos;s own code and sample data: &lt;code&gt;download.py&lt;/code&gt; writes 2 short 10-K excerpts and 2 company-facts files, for Apple and Microsoft. We ran the example&apos;s functions on them and made the vectors with the same model, &lt;code&gt;all-MiniLM-L6-v2&lt;/code&gt;. We did not run Doris; the search ranks follow the rules in &lt;code&gt;search.py&lt;/code&gt;. The code is in the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/sec_edgar_analytics&quot;&gt;CocoIndex v1 repo&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;A few terms used below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;10-K:&lt;/strong&gt; a company&apos;s annual report to the SEC. Its &quot;Item 1A. Risk Factors&quot; section lists what could go wrong. The 10-Q is the quarterly report.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CIK (Central Index Key):&lt;/strong&gt; the number the SEC assigns to each filer, such as &lt;code&gt;0000320193&lt;/code&gt; for Apple.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;XBRL (eXtensible Business Reporting Language):&lt;/strong&gt; the tagged format for the numbers in a filing. A company-facts JSON file lists the values a company reported, such as revenue and net income, by period.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;The pipeline: 4 files in, 4 rows out&lt;/h2&gt;
&lt;p&gt;The example is one CocoIndex app, &lt;code&gt;SECFilingAnalytics&lt;/code&gt;, in one &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/blob/main/examples/sec_edgar_analytics/main.py&quot;&gt;&lt;code&gt;main.py&lt;/code&gt;&lt;/a&gt;. Each format has its own function that reads a file and turns it into text with metadata. Both functions then call one shared function, &lt;code&gt;_index_text&lt;/code&gt;, that does the rest.&lt;/p&gt;
&lt;p&gt;CocoIndex is a data transformation framework with a Rust engine. You describe what the target (here, the Doris table) should contain as a function of the source, &lt;code&gt;target_state = transformation(source_state)&lt;/code&gt;, in plain Python. CocoIndex keeps the target in sync with &lt;a href=&quot;https://cocoindex.io/blogs/incremental-processing&quot;&gt;incremental processing&lt;/a&gt;: when a file or the code changes, it redoes only the work that the change affects.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/doris/&quot;&gt;Apache Doris&lt;/a&gt; is an open-source analytical database. It is the target here because one Doris table can hold an inverted (full-text) index and a vector index side by side, so one table serves both kinds of search.&lt;/p&gt;
&lt;p&gt;The app starts with these imports and the app object:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import json
import os
import re
import uuid
from collections.abc import AsyncIterator
from dataclasses import dataclass
from typing import Annotated

from numpy.typing import NDArray

import cocoindex as coco
from cocoindex.connectors import doris, localfs
from cocoindex.ops.text import RecursiveSplitter
from cocoindex.ops.sentence_transformers import SentenceTransformerEmbedder
from cocoindex.resources.file import FileLike, PatternFilePathMatcher

app = coco.App(coco.AppConfig(name=&quot;SECFilingAnalytics&quot;), app_main)
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Step 1: read each format&lt;/h2&gt;
&lt;h3&gt;&lt;code&gt;app_main&lt;/code&gt;: one table, then one processor per file&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;app_main&lt;/code&gt; sets up (mounts) the Doris table, then walks each source folder and runs a processor once for every file that matches:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn
async def app_main() -&amp;gt; None:
    table = await doris.mount_table_target(
        DORIS_DB,
        TABLE,
        await doris.TableSchema.from_class(FilingChunk, primary_key=[&quot;chunk_id&quot;]),
        vector_indexes=[
            doris.VectorIndexDef(field_name=&quot;embedding&quot;, metric_type=&quot;l2_distance&quot;)
        ],
        inverted_indexes=[doris.InvertedIndexDef(field_name=&quot;text&quot;, parser=&quot;unicode&quot;)],
    )

    txt = localfs.walk_dir(
        localfs.FilePath(path=&quot;./data/filings&quot;),
        path_matcher=PatternFilePathMatcher(included_patterns=[&quot;**/*.txt&quot;]),
    )
    await coco.mount_each(process_filing, txt.items(), table)

    facts = localfs.walk_dir(
        localfs.FilePath(path=&quot;./data/company_facts&quot;),
        path_matcher=PatternFilePathMatcher(included_patterns=[&quot;**/*.json&quot;]),
    )
    await coco.mount_each(process_facts, facts.items(), table)
&lt;/code&gt;&lt;/pre&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Source folder&lt;/th&gt;
&lt;th&gt;File pattern&lt;/th&gt;
&lt;th&gt;Processor&lt;/th&gt;
&lt;th&gt;&lt;code&gt;source_type&lt;/code&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;./data/filings&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;**/*.txt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;process_filing&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&quot;filing&quot;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;./data/company_facts&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;**/*.json&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;process_facts&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&quot;facts&quot;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;a href=&quot;https://cocoindex.io/docs/connectors/localfs/&quot;&gt;&lt;code&gt;localfs.walk_dir&lt;/code&gt;&lt;/a&gt; lists the files, and &lt;code&gt;coco.mount_each&lt;/code&gt; gives each file its own &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/&quot;&gt;processing component&lt;/a&gt;. A component is a unit of work that CocoIndex runs, tracks and cleans up on its own. That is what lets it update one file without touching the others. The 2 indexes on the table come up again in &lt;a href=&quot;#step-3-one-table-two-indexes&quot;&gt;Step 3&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;process_filing&lt;/code&gt;: metadata from the file name&lt;/h3&gt;
&lt;p&gt;A 10-K file is named &lt;code&gt;{CIK}_{date}_{form}.txt&lt;/code&gt;. &lt;code&gt;process_filing&lt;/code&gt; splits the name to get the company, the filing date and the form type, then passes the text and the metadata to &lt;code&gt;_index_text&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def process_filing(
    file: FileLike, table: doris.DorisTableTarget[FilingChunk]
) -&amp;gt; None:
    &quot;&quot;&quot;10-K text filing: metadata from the {CIK}_{date}_{form}.txt filename.&quot;&quot;&quot;
    name = file.file_path.path.name
    parts = name.rsplit(&quot;.&quot;, 1)[0].split(&quot;_&quot;)
    cik = parts[0] if parts else &quot;unknown&quot;
    filing_date = parts[1] if len(parts) &amp;gt; 1 else &quot;2024-01-01&quot;
    form_type = parts[2] if len(parts) &amp;gt; 2 else &quot;10-K&quot;
    await _index_text(
        await file.read_text(), &quot;filing&quot;, name, cik, filing_date, form_type, table
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The metadata comes from a string split. When you know the file-name format in advance, a parser like this skips an LLM call per document and returns the same result every time. For formats you do not know in advance, CocoIndex can &lt;a href=&quot;https://cocoindex.io/docs/examples/manuals-llm-extraction/&quot;&gt;extract fields with an LLM&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;memo=True&lt;/code&gt; turns on &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/&quot;&gt;memoization&lt;/a&gt;: CocoIndex stores the result, and on the next run it skips a file whose content and function code are unchanged.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;process_facts&lt;/code&gt;: XBRL numbers as text&lt;/h3&gt;
&lt;p&gt;A company-facts file is JSON, not prose. To make it searchable, &lt;code&gt;process_facts&lt;/code&gt; renders it as text with &lt;code&gt;_company_facts_to_text&lt;/code&gt; and passes that text to the same &lt;code&gt;_index_text&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def process_facts(
    file: FileLike, table: doris.DorisTableTarget[FilingChunk]
) -&amp;gt; None:
    &quot;&quot;&quot;XBRL company-facts JSON: render to text, then index.&quot;&quot;&quot;
    name = file.file_path.path.name
    content = await file.read_text()
    cik = name.replace(&quot;CIK&quot;, &quot;&quot;).replace(&quot;.json&quot;, &quot;&quot;)
    filing_date = (
        json.loads(content).get(&quot;filingDate&quot;, &quot;2024-01-01&quot;) if content else &quot;2024-01-01&quot;
    )
    await _index_text(
        _company_facts_to_text(content), &quot;facts&quot;, name, cik, filing_date, &quot;FACTS&quot;, table
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is what &lt;code&gt;_company_facts_to_text&lt;/code&gt; makes of Apple&apos;s sample file:&lt;/p&gt;
&lt;p&gt;To add a third format such as PDF, you write one more &lt;code&gt;process_*&lt;/code&gt; function that turns the file into text and calls &lt;code&gt;_index_text&lt;/code&gt;. &lt;a href=&quot;https://cocoindex.io/docs/examples/manuals-llm-extraction/&quot;&gt;Manuals to Structured Data&lt;/a&gt; shows a PDF path with docling.&lt;/p&gt;
&lt;h2&gt;Step 2: clean, chunk, tag and embed&lt;/h2&gt;
&lt;p&gt;Both formats end in &lt;code&gt;_index_text&lt;/code&gt;. It removes personal data, splits the text into chunks, and declares one row per chunk:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;_splitter = RecursiveSplitter()

async def _index_text(text, source_type, filename, cik, filing_date, form_type, table):
    embedder = coco.use_context(EMBEDDER)
    for chunk in _splitter.split(
        _scrub_pii(text), chunk_size=1000, chunk_overlap=200, language=&quot;markdown&quot;
    ):
        table.declare_row(row=FilingChunk(
            chunk_id=_chunk_id(filename, chunk.start.char_offset, chunk.end.char_offset),
            source_type=source_type,
            doc_filename=filename,
            cik=cik,
            filing_date=filing_date,
            form_type=form_type,
            text=chunk.text,
            topics=_extract_topics(chunk.text),
            embedding=await embedder.embed(chunk.text),
        ))
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;code&gt;_scrub_pii&lt;/code&gt;: remove personal data first&lt;/h3&gt;
&lt;p&gt;PII (personally identifiable information) includes Social Security numbers (SSNs), phone numbers and email addresses. A filing can contain them by accident, and a search index should not. &lt;code&gt;_scrub_pii&lt;/code&gt; replaces each match of 3 regular expressions with a placeholder:&lt;/p&gt;
&lt;p&gt;The order matters. &lt;code&gt;_scrub_pii&lt;/code&gt; runs on the whole document, before the split. If it ran on each chunk instead, a phone number cut in half by a chunk boundary would no longer match the pattern. Both halves would then reach the index.&lt;/p&gt;
&lt;p&gt;Regular expressions catch only the patterns they describe. A name or a home address passes through, so treat this as a first filter. It does not catch every kind of personal data.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;RecursiveSplitter&lt;/code&gt;: chunks of up to about 1,000 characters&lt;/h3&gt;
&lt;p&gt;A search should return the passage that answers the question, not a whole report. So the text is split into chunks, and each chunk becomes its own row with its own vector. &lt;a href=&quot;https://cocoindex.io/docs/ops/text/&quot;&gt;&lt;code&gt;RecursiveSplitter&lt;/code&gt;&lt;/a&gt; with &lt;code&gt;language=&quot;markdown&quot;&lt;/code&gt; picks split points from the structure: headings first, then paragraphs, then sentences. &lt;code&gt;chunk_size=1000&lt;/code&gt; and &lt;code&gt;chunk_overlap=200&lt;/code&gt; are in bytes; for English text that is about the same number of characters.&lt;/p&gt;
&lt;p&gt;The sample documents are short, so each one is a single chunk: 4 files give 4 chunks. A full 10-K is far longer and gives many chunks. Chunk size is a tradeoff: a large chunk matches many questions loosely, and a small one may lack the context to make sense on its own.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;_extract_topics&lt;/code&gt;: tags from keyword lists&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;_extract_topics&lt;/code&gt; gives each chunk a list of topic tags, such as &lt;code&gt;RISK:CYBER&lt;/code&gt; or &lt;code&gt;TOPIC:AI&lt;/code&gt;. Each tag has a keyword list in &lt;code&gt;_TOPIC_KEYWORDS&lt;/code&gt;, and a chunk gets the tag when its lower-cased text contains any keyword from the list:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def _extract_topics(text: str) -&amp;gt; list[str]:
    low = text.lower()
    return [t for t, kws in _TOPIC_KEYWORDS.items() if any(k in low for k in kws)]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The tags are stored as a JSON array, so you can filter on them in SQL, for example &lt;code&gt;json_contains(topics, &apos;&quot;RISK:CYBER&quot;&apos;)&lt;/code&gt;. Substring matching is simple and fast, but crude: the keyword &lt;code&gt;sec&lt;/code&gt; also matches inside &quot;cybersecurity&quot;. On the sample data that does not change any tag, because both 10-Ks also contain &quot;regulation&quot;. For production tags, match whole words or use an LLM.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;embedder.embed&lt;/code&gt;: 384 numbers per chunk&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;embedder.embed(chunk.text)&lt;/code&gt; turns the chunk into a vector of 384 numbers with the &lt;code&gt;all-MiniLM-L6-v2&lt;/code&gt; model. Texts with similar meaning get vectors that are close together, which is what the meaning side of the search uses. The embedder is created once when the app starts and shared through &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/context/&quot;&gt;context&lt;/a&gt;, together with the Doris connection:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;TABLE = &quot;filing_chunks&quot;
EMBED_MODEL = &quot;sentence-transformers/all-MiniLM-L6-v2&quot;

DORIS_DB = coco.ContextKey[doris.ManagedConnection](&quot;sec_doris&quot;)
EMBEDDER = coco.ContextKey[SentenceTransformerEmbedder](&quot;embedder&quot;, detect_change=True)

@coco.lifespan
async def coco_lifespan(builder: coco.EnvironmentBuilder) -&amp;gt; AsyncIterator[None]:
    builder.provide(DORIS_DB, doris.connect(doris.DorisConnectionConfig(...)))
    builder.provide(EMBEDDER, SentenceTransformerEmbedder(EMBED_MODEL))
    yield
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;DorisConnectionConfig(...)&lt;/code&gt; reads the Doris host, ports, user and database from environment variables (see &lt;code&gt;.env.example&lt;/code&gt; in the example). &lt;code&gt;detect_change=True&lt;/code&gt; tells CocoIndex to watch the embedder itself: if you change &lt;code&gt;EMBED_MODEL&lt;/code&gt;, the next run embeds every chunk again.&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;FilingChunk&lt;/code&gt;: one typed row per chunk&lt;/h3&gt;
&lt;p&gt;The row is a plain dataclass. CocoIndex creates the Doris table from it, so you do not write &lt;code&gt;CREATE TABLE&lt;/code&gt;. The &lt;code&gt;embedding&lt;/code&gt; field is annotated with the embedder, so CocoIndex gets the vector size (384) from the model:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@dataclass
class FilingChunk:
    chunk_id: str            # primary key: uuid5 of (filename, chunk offsets)
    source_type: str         # &quot;filing&quot; | &quot;facts&quot;
    doc_filename: str
    cik: str
    filing_date: str
    form_type: str
    text: str
    topics: list[str]
    embedding: Annotated[NDArray, EMBEDDER]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is the real row for Apple&apos;s sample 10-K:&lt;/p&gt;
&lt;p&gt;, -0.0073, 0.0154, 0.0623, 0.0320 and more, 384 numbers. chunk_id is a uuid5 of the file name and the chunk&apos;s start and end offsets, so the same chunk gets the same id on every run.&quot;} width={960} height={496} detailScale={1.4} minWidth={840} /&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;declare_row&lt;/code&gt; does not write to Doris at once. It declares a &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;target state&lt;/a&gt;, a row that should exist. CocoIndex compares the declared rows with the ones from the last run and writes only the difference. Because &lt;code&gt;chunk_id&lt;/code&gt; is computed from the file name and the chunk&apos;s offsets, a re-run updates rows in place instead of adding copies.&lt;/p&gt;

Quick check: a filing has a phone number that starts at character 990, across the boundary of the first 1,000-character chunk. Can part of the number end up in the index?
&lt;p&gt;No. &lt;code&gt;_scrub_pii&lt;/code&gt; replaces the number in the whole document before &lt;code&gt;RecursiveSplitter&lt;/code&gt; runs, so the splitter only sees &lt;code&gt;[PHONE REDACTED]&lt;/code&gt;. If scrubbing ran per chunk, the chunk that ends mid-number would hold a fragment that the regular expression cannot match, and that fragment would be indexed.&lt;/p&gt;

&lt;h2&gt;Step 3: one table, two indexes&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;mount_table_target&lt;/code&gt; in &lt;code&gt;app_main&lt;/code&gt; asks for 2 indexes on the same table:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;An &lt;strong&gt;inverted index&lt;/strong&gt; on &lt;code&gt;text&lt;/code&gt;. It maps each word to the rows that contain it, so a keyword search does not read every row. &lt;code&gt;parser=&quot;unicode&quot;&lt;/code&gt; sets how the text is split into words. SQL queries use it with &lt;code&gt;MATCH_ANY&lt;/code&gt;, which is true when the text contains any of the given words.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;vector index&lt;/strong&gt; on &lt;code&gt;embedding&lt;/code&gt;, of the ANN (approximate nearest neighbor) kind. It finds the vectors closest to the question&apos;s vector without comparing it with every row. Closeness is &lt;code&gt;l2_distance&lt;/code&gt;, the straight-line distance between 2 vectors: smaller means closer.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The 2 indexes answer different questions. The inverted index finds exact words, such as the product name &quot;azure&quot;. A vector does not guarantee an exact word match; it only places &quot;azure&quot; near similar words. The vector index finds passages that say the same thing in other words. Hybrid search uses both kinds of match.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;search.py&lt;/code&gt; keeps its SQL simple: it scores every row exactly, with &lt;code&gt;l2_distance&lt;/code&gt; and with &lt;code&gt;MATCH_ANY&lt;/code&gt; inside a &lt;code&gt;CASE&lt;/code&gt;. On 4 rows that is instant. On a large table you would take the top &lt;em&gt;k&lt;/em&gt; from each side instead: &lt;code&gt;ORDER BY l2_distance_approximate(...) LIMIT k&lt;/code&gt; uses the vector index, and &lt;code&gt;MATCH_ANY&lt;/code&gt; in a &lt;code&gt;WHERE&lt;/code&gt; clause uses the inverted index.&lt;/p&gt;
&lt;h2&gt;Step 4: hybrid search with RRF&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;search.py&lt;/code&gt; ranks the chunks twice in one SQL query and combines the 2 ranks with Reciprocal Rank Fusion (RRF):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def search(query: str, source_type: str | None = None, limit: int = 5) -&amp;gt; None:
    vec = asyncio.run(_embedder.embed(query))
    vstr = &quot;[&quot; + &quot;,&quot;.join(f&quot;{x:.6f}&quot; for x in vec) + &quot;]&quot;
    keywords = &quot; &quot;.join(re.findall(r&quot;[A-Za-z]{3,}&quot;, query.lower()))
    where = f&quot;source_type = &apos;{source_type}&apos;&quot; if source_type else &quot;1 = 1&quot;

    sql = f&quot;&quot;&quot;
    WITH semantic AS (
        SELECT chunk_id, doc_filename, source_type, topics, text,
               ROW_NUMBER() OVER (ORDER BY l2_distance(embedding, {vstr})) AS rk
        FROM filing_chunks WHERE {where}
    ),
    lexical AS (
        SELECT chunk_id,
               ROW_NUMBER() OVER (ORDER BY CASE WHEN text MATCH_ANY &apos;{keywords}&apos;
                                  THEN 0 ELSE 1 END) AS rk
        FROM filing_chunks WHERE {where}
    )
    SELECT s.doc_filename, s.source_type, s.topics, s.text,
           1.0/(60 + s.rk) + 1.0/(60 + l.rk) AS rrf
    FROM semantic s JOIN lexical l USING (chunk_id)
    ORDER BY rrf DESC LIMIT {limit}
    &quot;&quot;&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The query has 3 parts:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;semantic&lt;/code&gt; gives each chunk its meaning rank. &lt;code&gt;search.py&lt;/code&gt; first embeds the question in Python with the same model; &lt;code&gt;semantic&lt;/code&gt; then numbers the chunks by &lt;code&gt;l2_distance&lt;/code&gt;, closest first.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;lexical&lt;/code&gt; gives each chunk its keyword rank: it numbers the chunks again, the ones that match any keyword first.&lt;/li&gt;
&lt;li&gt;The last &lt;code&gt;SELECT&lt;/code&gt; gives each chunk the score &lt;code&gt;1/(60 + meaning rank) + 1/(60 + keyword rank)&lt;/code&gt; and returns the highest scores.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;RRF uses only the ranks, not the raw scores, so a distance and a keyword match never need to be on the same scale. The constant 60 (often written &lt;em&gt;k&lt;/em&gt;) keeps the gap between rank 1 and rank 2 small, so a top rank in one list alone rarely decides the result. A chunk ranked 1st in both lists scores &lt;code&gt;1/61 + 1/61 = 0.0328&lt;/code&gt;; a chunk ranked 1st by meaning but 100th by keywords scores &lt;code&gt;1/61 + 1/160 = 0.0226&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This is the ranking for &quot;cloud computing and AI risk&quot; on the sample data:&lt;/p&gt;
&lt;p&gt;Two details of &lt;code&gt;search.py&lt;/code&gt; show up here. The keyword regex keeps only words of 3 or more letters, so &quot;AI&quot; is not a keyword; the meaning side still reads the whole question. And the keyword side has only 2 values, match or no match, so all matching chunks tie. &lt;code&gt;ROW_NUMBER()&lt;/code&gt; numbers tied rows in an order that Doris picks, so the 2 10-Ks can swap their keyword ranks between runs. The 2 facts rows tie the same way; swapped, both score &lt;code&gt;0.0315&lt;/code&gt;. Doris may also ignore &quot;and&quot; as a stopword, which does not change the ranks here. With a full set of filings, a keyword relevance score (or &lt;code&gt;RANK()&lt;/code&gt;, which gives tied rows the same rank) would make the keyword side more useful.&lt;/p&gt;
&lt;p&gt;The playground below runs the same rules on the 4 sample chunks. The distances are fixed at the values in the figure; the keyword side is computed from the chunk texts. Turn keywords on and off, move &lt;em&gt;k&lt;/em&gt;, and swap the tie order:&lt;/p&gt;
&lt;p&gt;With the question&apos;s own keywords, &lt;em&gt;k&lt;/em&gt; changes the scores but not the order: the Microsoft 10-K matches every word the Apple 10-K matches, so the 2 lists agree. To see &lt;em&gt;k&lt;/em&gt; change the order, keep only &lt;code&gt;apple&lt;/code&gt; on and swap the tie order. The Apple 10-K is 2nd in both lists. The Microsoft 10-K is 1st by meaning and 4th by keywords, and the Apple facts row is the reverse. At &lt;em&gt;k&lt;/em&gt; = 60 the Apple 10-K comes first (0.0323 against 0.0320). At &lt;em&gt;k&lt;/em&gt; = 1 the step from rank 1 to rank 2 is large, and both rows with a 1st place pass it (0.7000 against 0.6667).&lt;/p&gt;
&lt;p&gt;Keep only &lt;code&gt;revenues&lt;/code&gt; on, and the facts rows take keyword ranks 1 and 2. Each one then ties with a 10-K: RRF sees only ranks, and 1st plus 3rd scores the same as 3rd plus 1st.&lt;/p&gt;
&lt;p&gt;To search one format only, call &lt;code&gt;search(question, source_type=&quot;facts&quot;)&lt;/code&gt; (or &lt;code&gt;&quot;filing&quot;&lt;/code&gt;).&lt;/p&gt;

Quick check: chunk A ranks 1st by meaning and 100th by keywords. Chunk B ranks 2nd in both. Which one does RRF put first?
&lt;p&gt;Chunk B. A scores &lt;code&gt;1/61 + 1/160 = 0.0226&lt;/code&gt;. B scores &lt;code&gt;1/62 + 1/62 = 0.0323&lt;/code&gt;. Here, A&apos;s 1st place by meaning does not make up for its 100th place by keywords.&lt;/p&gt;

&lt;h2&gt;Run it&lt;/h2&gt;
&lt;p&gt;You need Python 3.11+ and Docker with Docker Compose. Compose runs Apache Doris, which must be 4.0 or later for the vector index. Clone the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex repo&lt;/a&gt; and work in &lt;code&gt;examples/sec_edgar_analytics&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cd examples/sec_edgar_analytics

# 1. Start Doris: one frontend (FE) and one backend (BE)
docker compose up -d fe be

# 2. Write the sample data, configure, and install
python download.py           # writes data/filings/*.txt + data/company_facts/*.json
cp .env.example .env         # Doris host and ports
pip install -e .

# 3. Build the index
cocoindex update main
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In a Doris cluster, the FE (frontend) receives queries and keeps metadata, and the BE (backend) stores data and runs queries. Wait until both containers have started before step 3.&lt;/p&gt;
&lt;p&gt;The first &lt;code&gt;cocoindex update main&lt;/code&gt; loads 4 rows into &lt;code&gt;filing_chunks&lt;/code&gt;, 1 per sample file. It also creates the vector index &lt;code&gt;idx_vec_embedding&lt;/code&gt; and the inverted index &lt;code&gt;idx_inv_text&lt;/code&gt;. The tags follow each filing&apos;s wording: Apple gets &lt;code&gt;RISK:CYBER, RISK:CLIMATE, RISK:SUPPLY, RISK:REGULATORY, TOPIC:AI&lt;/code&gt;, and Microsoft &lt;code&gt;RISK:CYBER, RISK:REGULATORY, TOPIC:AI, TOPIC:CLOUD&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Then search:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;python search.py &quot;cloud computing and AI risk&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;search.py&lt;/code&gt; prints each hit with its RRF score, its file and the first 160 characters of the chunk. On the sample data the 10-Ks come first:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Hybrid search: &quot;cloud computing and AI risk&quot;

[0.0328] 0000789019_2025-10-15_10-K.txt (filing)  topics=[&quot;RISK:CYBER&quot;,&quot;RISK:REGULATORY&quot;,&quot;TOPIC:AI&quot;,&quot;TOPIC:CLOUD&quot;]
    MICROSOFT CORPORATION FORM 10-K ANNUAL REPORT

Item 1A. Risk Factors

Our cloud computing business (Azure) faces intense competition. Outages or a
data breach i

[0.0323] 0000320193_2025-11-01_10-K.txt (filing)  topics=[&quot;RISK:CYBER&quot;,&quot;RISK:CLIMATE&quot;,&quot;RISK:SUPPLY&quot;,&quot;RISK:REGULATORY&quot;,&quot;TOPIC:AI&quot;]
    APPLE INC. FORM 10-K ANNUAL REPORT

Item 1A. Risk Factors

Cybersecurity threats are a material risk. A data breach or ransomware attack
on our systems could di
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We computed these scores without Doris, using the tie order in the figure above. If Doris breaks the keyword tie the other way, both lines show &lt;code&gt;0.0325&lt;/code&gt;. Doris computes &lt;code&gt;1.0/(60 + rk)&lt;/code&gt; in decimal arithmetic, so the last digit can differ. The 2 company-facts rows follow below the 10-Ks.&lt;/p&gt;
&lt;h2&gt;A re-run redoes only what changed&lt;/h2&gt;
&lt;p&gt;Run &lt;code&gt;cocoindex update main&lt;/code&gt; again, and CocoIndex does only the work that a change needs:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;memo=True&lt;/code&gt; on the 2 processors skips files that did not change, and &lt;code&gt;embed()&lt;/code&gt; is memoized too, so only new chunk text goes to the model (unless &lt;code&gt;EMBED_MODEL&lt;/code&gt; changes). A deleted file&apos;s component goes away, and its rows are deleted with it.&lt;/p&gt;
&lt;p&gt;The last row in the figure needs a manual step. CocoIndex tracks the code of functions decorated with &lt;code&gt;@coco.fn&lt;/code&gt;. &lt;code&gt;_index_text&lt;/code&gt;, &lt;code&gt;_scrub_pii&lt;/code&gt;, &lt;code&gt;_extract_topics&lt;/code&gt; and &lt;code&gt;_TOPIC_KEYWORDS&lt;/code&gt; are plain Python, so an edit to them does not invalidate the stored results. After you change one of them, run &lt;code&gt;cocoindex update main --full-reprocess&lt;/code&gt;, which skips all memoized results and processes every file again (including the embeddings).&lt;/p&gt;

Quick check: you edit the Microsoft 10-K file and run &lt;code&gt;cocoindex update main&lt;/code&gt; again. Which files does the pipeline process?
&lt;p&gt;Only the edited file. &lt;code&gt;process_filing&lt;/code&gt; and &lt;code&gt;process_facts&lt;/code&gt; use &lt;code&gt;memo=True&lt;/code&gt;, so files whose content and code are unchanged are skipped. &lt;code&gt;chunk_id&lt;/code&gt; comes from the file name and chunk offsets, so the re-run replaces that file&apos;s rows instead of adding copies.&lt;/p&gt;

&lt;h2&gt;Query Doris directly&lt;/h2&gt;
&lt;p&gt;The table is plain SQL, so you can also query it over the MySQL protocol:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mysql -h localhost -P 9030 -u root
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Filter by topic tag:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-- Chunks tagged with cybersecurity risk
SELECT doc_filename, text, topics
FROM sec_analytics.filing_chunks
WHERE json_contains(topics, &apos;&quot;RISK:CYBER&quot;&apos;);

-- Chunks with either of 2 tags
SELECT doc_filename, text
FROM sec_analytics.filing_chunks
WHERE json_contains(topics, &apos;&quot;RISK:CYBER&quot;&apos;)
   OR json_contains(topics, &apos;&quot;RISK:CLIMATE&quot;&apos;);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The 3 closest chunks per company, for a question vector:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;WITH scored AS (
    SELECT cik, doc_filename, text,
           l2_distance(embedding, [...]) AS score   -- [...] is the question&apos;s 384-number vector
    FROM sec_analytics.filing_chunks
    WHERE cik IN (&apos;0000320193&apos;, &apos;0000789019&apos;)
),
ranked AS (
    SELECT *, ROW_NUMBER() OVER (PARTITION BY cik ORDER BY score) AS rk
    FROM scored
)
SELECT * FROM ranked WHERE rk &amp;lt;= 3;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Keyword matches by filing year:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;SELECT LEFT(filing_date, 4) AS filing_year,
       COUNT(DISTINCT cik) AS companies,
       COUNT(*) AS chunks
FROM sec_analytics.filing_chunks
WHERE text MATCH_ANY &apos;cybersecurity risk&apos;
GROUP BY filing_year
ORDER BY filing_year DESC;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;What to try next&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Index your own filing.&lt;/strong&gt; Save a 10-K as &lt;code&gt;{CIK}_{date}_{form}.txt&lt;/code&gt; in &lt;code&gt;data/filings&lt;/code&gt;, for example &lt;code&gt;0000320193_2025-11-01_10-K.txt&lt;/code&gt;, and run &lt;code&gt;cocoindex update main&lt;/code&gt;. Only the new file is processed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Add a topic tag.&lt;/strong&gt; Add an entry to &lt;code&gt;_TOPIC_KEYWORDS&lt;/code&gt; in &lt;code&gt;main.py&lt;/code&gt;, then run &lt;code&gt;cocoindex update main --full-reprocess&lt;/code&gt; so every chunk is tagged again.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Preview before you write.&lt;/strong&gt; &lt;code&gt;cocoindex update main --preview&lt;/code&gt; computes the changes to the target and prints them without applying them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Add a third format.&lt;/strong&gt; Write a &lt;code&gt;process_pdf&lt;/code&gt; that turns a PDF into text and calls &lt;code&gt;_index_text&lt;/code&gt;, and mount it with &lt;code&gt;coco.mount_each&lt;/code&gt; like the other 2.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Filter, then search.&lt;/strong&gt; Add a &lt;code&gt;json_contains(topics, ...)&lt;/code&gt; condition to the &lt;code&gt;where&lt;/code&gt; in &lt;code&gt;search.py&lt;/code&gt;, so the hybrid search only ranks chunks with a given tag.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The same pattern fits other document collections, such as contracts or support tickets: several formats into one table, personal data removed first, tags for filters, and hybrid search. The &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/sec_edgar_analytics&quot;&gt;full source code&lt;/a&gt; is in the CocoIndex v1 repo, with the sample-data generator and the search script.&lt;/p&gt;
</content:encoded><category>examples</category><category>structured-extraction</category><category>vector-search</category><category>embeddings</category><category>connectors</category><author>Tom Zhang, Linghua Jin</author></item><item><title>Generate Codebase Documentation with an LLM, Kept Current</title><link>https://cocoindex.io/blogs/multi-codebase-summarization/</link><guid isPermaLink="true">https://cocoindex.io/blogs/multi-codebase-summarization/</guid><description>Generate a Markdown wiki page for every Python project in a folder with an LLM and CocoIndex v1. On each run, the LLM re-reads only the files that changed.</description><pubDate>Thu, 05 Feb 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;A wiki that describes your code goes out of date as soon as someone refactors a module. Nobody updates it, and readers stop trusting it. You can ask an LLM to write the documentation from the source instead, but a script that sends every file to the model on every run is slow and costs money, and most files did not change since the last run.&lt;/p&gt;
&lt;p&gt;The same summaries are useful context for &lt;a href=&quot;https://cocoindex.io/docs/getting_started/ai_coding_agents/&quot;&gt;coding agents&lt;/a&gt;, and there a stale page costs more. An agent reads a summary as a description of the code as it is now. If the summary predates last week&apos;s refactor, the agent plans against functions and modules that no longer exist, and nothing in the text tells it so.&lt;/p&gt;
&lt;p&gt;This tutorial builds a CocoIndex v1 pipeline that writes one Markdown wiki page for each Python project in a folder. An LLM reads each file and returns structured data: public classes, public functions, a summary, and Mermaid call graphs. The pipeline combines the files into a project summary and writes the page. When you run it again, the LLM re-reads only the files that changed, plus one summary call for each multi-file project they belong to. This is &lt;a href=&quot;https://cocoindex.io/blogs/incremental-processing&quot;&gt;incremental processing&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The full example is in the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/multi_codebase_summarization&quot;&gt;CocoIndex repo&lt;/a&gt;, with a &lt;a href=&quot;https://cocoindex.io/docs/examples/multi-codebase-summarization/&quot;&gt;walkthrough in the docs&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;What you build&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A CocoIndex app, &lt;code&gt;MultiCodebaseSummarization&lt;/code&gt;,&lt;/strong&gt; in &lt;code&gt;main.py&lt;/code&gt;. It treats each subdirectory of a root folder as one project. By default the root is &lt;code&gt;../&lt;/code&gt;, so in the CocoIndex repo it documents the folders in &lt;code&gt;examples/&lt;/code&gt; (about 40 when this was updated).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Three Pydantic models&lt;/strong&gt; in &lt;code&gt;models.py&lt;/code&gt; (&lt;code&gt;CodebaseInfo&lt;/code&gt;, &lt;code&gt;ClassInfo&lt;/code&gt;, &lt;code&gt;FunctionInfo&lt;/code&gt;) that define what the LLM returns for a file and for a project.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;One LLM call per Python file&lt;/strong&gt; through &lt;a href=&quot;https://github.com/instructor-ai/instructor&quot;&gt;Instructor&lt;/a&gt; and &lt;a href=&quot;https://docs.litellm.ai/&quot;&gt;LiteLLM&lt;/a&gt;, plus one more call per multi-file project to combine the file summaries.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;One Markdown page per project&lt;/strong&gt; in &lt;code&gt;output/&lt;/code&gt;, with an Overview, a Components list, a Mermaid diagram of the CocoIndex pipeline when the project has one, and per-file summaries.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;You need&lt;/strong&gt; Python 3.11+, &lt;code&gt;cocoindex&amp;gt;=1.0.7&lt;/code&gt; (1.1 at the time of writing), and an API key for an LLM. The default model is &lt;code&gt;gemini/gemini-2.5-flash&lt;/code&gt;, so the default key is &lt;code&gt;GEMINI_API_KEY&lt;/code&gt;. &lt;a href=&quot;#run-it&quot;&gt;Run it&lt;/a&gt; has the commands.&lt;/p&gt;
&lt;p&gt;A few terms used below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Structured output:&lt;/strong&gt; the LLM returns JSON that matches a schema (here, a Pydantic model), and the code validates it, so you get typed objects instead of free text.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Memoization:&lt;/strong&gt; CocoIndex caches the result of a function and reuses it while the inputs and the function&apos;s code stay the same.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Processing component:&lt;/strong&gt; a unit of work that CocoIndex runs, tracks and cleans up on its own. Here, each project is one component.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Why not write a script?&lt;/h2&gt;
&lt;p&gt;A script that loops through files, calls an LLM and writes Markdown works for a one-time run. Keeping it correct over time raises several problems:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;File changes:&lt;/strong&gt; after you edit one file, re-running the whole pipeline is slow and expensive.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tracking state:&lt;/strong&gt; to process only what changed, you have to track timestamps, checksums or diffs yourself.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LLM costs:&lt;/strong&gt; re-analyzing unchanged files wastes API calls, and the cost grows with the size of the codebase.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Logic changes:&lt;/strong&gt; when you change the extraction prompt, every result from the old prompt is stale and must be recomputed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These are caching, invalidation and orchestration concerns, separate from the extraction logic you want to write. Codebases also change often, as people and coding agents add and modify files. A scheduled full rebuild is out of date until it runs again, and most of its work is on files that did not change.&lt;/p&gt;
&lt;p&gt;CocoIndex separates the transformation logic from the change tracking. You write the functions that extract, combine and format, as plain async Python. The model behind this is one &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;relationship&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;target_state = transformation(source_state)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;You declare the transformation, and CocoIndex decides which inputs need reprocessing. When a source file changes, or the code of a function changes (an edited prompt, for example), only the affected outputs are recomputed.&lt;/p&gt;
&lt;h2&gt;How the pipeline fits together&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;app_main&lt;/code&gt; finds the projects and mounts one &lt;code&gt;process_project&lt;/code&gt; component for each. Inside a component, every Python file goes to the LLM once, the results are combined into one project summary, and the summary becomes a Markdown file. The sections below follow the data: the models first, then each function, then the wiring.&lt;/p&gt;
&lt;h2&gt;Step 1: Define the data models&lt;/h2&gt;
&lt;p&gt;The LLM fills in Pydantic models. The field descriptions are part of the prompt: Instructor sends the schema, with its descriptions, to the model. &lt;code&gt;CodebaseInfo&lt;/code&gt; serves twice, once per file and once per project:&lt;/p&gt;
&lt;p&gt;for coco.mount.&quot;} title={&quot;The data models&quot;} width={960} height={512} detailScale={1.4} minWidth={840} /&amp;gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot;Pydantic models for multi-codebase summarization.&quot;&quot;&quot;

from pydantic import BaseModel, Field

class FunctionInfo(BaseModel):
    &quot;&quot;&quot;Information about a public function.&quot;&quot;&quot;

    name: str = Field(description=&quot;Function name&quot;)
    signature: str = Field(
        description=&quot;Function signature, e.g. &apos;async def foo(x: int) -&amp;gt; str&apos;&quot;
    )
    is_coco_function: bool = Field(description=&quot;Whether decorated with @coco.fn&quot;)
    summary: str = Field(description=&quot;Brief summary of what the function does&quot;)

class ClassInfo(BaseModel):
    &quot;&quot;&quot;Information about a public class.&quot;&quot;&quot;

    name: str = Field(description=&quot;Class name&quot;)
    summary: str = Field(description=&quot;Brief summary of what the class represents/does&quot;)

MERMAID_GRAPH_DESCRIPTION = &quot;&quot;&quot;
Mermaid graph showing CocoIndex function call relationships. Requirements:
- Use &apos;graph TD&apos; (top-down) layout
- Include ONLY functions defined in this codebase (not external libraries)
- Use **bold** text for @coco.fn decorated functions
- Use thick arrows (==&amp;gt;) for coco.mount/coco.use_mount calls
- Use normal arrows (--&amp;gt;) for regular function calls
- Include a comment with the app name if this is for a coco.App

Example:
```mermaid
graph TD
    %% App: MyApp
    app_main[&amp;lt;b&amp;gt;app_main&amp;lt;/b&amp;gt;] ==&amp;gt; process_file[&amp;lt;b&amp;gt;process_file&amp;lt;/b&amp;gt;]
    process_file --&amp;gt; helper_func[helper_func]
```
&quot;&quot;&quot;

class CodebaseInfo(BaseModel):
    &quot;&quot;&quot;Extracted information from Python code (file or project level).&quot;&quot;&quot;

    name: str = Field(
        description=&quot;File path (for files) or project name (for projects)&quot;
    )
    summary: str = Field(description=&quot;Brief summary of purpose and functionality&quot;)
    public_classes: list[ClassInfo] = Field(
        default_factory=list,
        description=&quot;Public classes (not starting with _)&quot;,
    )
    public_functions: list[FunctionInfo] = Field(
        default_factory=list,
        description=&quot;Public functions (not starting with _)&quot;,
    )
    mermaid_graphs: list[str] = Field(
        default_factory=list,
        description=MERMAID_GRAPH_DESCRIPTION,
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;MERMAID_GRAPH_DESCRIPTION&lt;/code&gt; is the longest instruction in the example. It asks for a top-down graph of the codebase&apos;s own functions, bold labels for &lt;code&gt;@coco.fn&lt;/code&gt; functions, and thick &lt;code&gt;==&amp;gt;&lt;/code&gt; arrows for &lt;code&gt;coco.mount&lt;/code&gt; calls, so every page draws its diagram the same way.&lt;/p&gt;
&lt;h2&gt;Step 2: Extract one file with an LLM&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;extract_file_info&lt;/code&gt; reads one file, puts its path and content into a prompt, and asks for a &lt;code&gt;CodebaseInfo&lt;/code&gt;. &lt;code&gt;instructor.from_litellm&lt;/code&gt; wraps LiteLLM&apos;s async &lt;code&gt;acompletion&lt;/code&gt;, so &lt;code&gt;response_model=CodebaseInfo&lt;/code&gt; returns a validated object for any model LiteLLM supports. &lt;code&gt;Mode.JSON&lt;/code&gt; asks the model for JSON in the schema:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;LLM_MODEL = os.environ.get(&quot;LLM_MODEL&quot;, &quot;gemini/gemini-2.5-flash&quot;)

_instructor_client = cast(
    instructor.AsyncInstructor,
    instructor.from_litellm(acompletion, mode=instructor.Mode.JSON),
)

@coco.fn(memo=True)
async def extract_file_info(file: FileLike) -&amp;gt; CodebaseInfo:
    &quot;&quot;&quot;Extract structured information from a single Python file using LLM.&quot;&quot;&quot;
    content = await file.read_text()
    file_path = str(file.file_path.path)

    prompt = f&quot;&quot;&quot;Analyze the following Python file and extract structured information.

File path: {file_path}

```python
{content}
```

Instructions:
1. Identify all PUBLIC classes (not starting with _) and summarize their purpose
2. Identify all PUBLIC functions (not starting with _) and summarize their purpose
3. If this file contains CocoIndex apps (coco.App), create Mermaid graphs showing the
   function call relationships (see the mermaid_graphs field description for format)
4. Provide a brief summary of the file&apos;s purpose
&quot;&quot;&quot;

    result = await _instructor_client.chat.completions.create(
        model=LLM_MODEL,
        response_model=CodebaseInfo,
        messages=[{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: prompt}],
    )
    return CodebaseInfo.model_validate(result.model_dump())
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#memoization&quot;&gt;&lt;code&gt;memo=True&lt;/code&gt;&lt;/a&gt; caches the result for each file. For a file argument, CocoIndex checks the modified time first, and reads the content for a fingerprint only when the time changed. A file you save without changes still hits the cache. The prompt is in the function body, so editing it changes the function&apos;s code, and every cached result for it misses once.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;LLM_MODEL&lt;/code&gt; is a module-level value, read from the environment when &lt;code&gt;main.py&lt;/code&gt; is imported, and the example does not list it in &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#deps&quot;&gt;&lt;code&gt;deps&lt;/code&gt;&lt;/a&gt;. If you change only &lt;code&gt;LLM_MODEL&lt;/code&gt;, files that did not change keep their cached results from the old model.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; Each call returns one &lt;code&gt;CodebaseInfo&lt;/code&gt; whose &lt;code&gt;name&lt;/code&gt; is the file path. Its lists hold the public classes and functions the model found. The prompt asks for &lt;code&gt;mermaid_graphs&lt;/code&gt; only when the file contains a &lt;code&gt;coco.App&lt;/code&gt;.&lt;/p&gt;

Quick check: you reword instruction 4 in the prompt. Which files go to the LLM on the next run?
&lt;p&gt;All of them. The prompt is part of the source code of &lt;code&gt;extract_file_info&lt;/code&gt;, and CocoIndex includes a function&apos;s code in its memo key, so every cached result misses once. The change also invalidates the memo of &lt;code&gt;process_project&lt;/code&gt;, which calls it, so every project runs again. On the run after that, unchanged files hit the cache again.&lt;/p&gt;

&lt;h2&gt;Step 3: Combine the files into one project summary&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;aggregate_project_info&lt;/code&gt; turns the per-file results into one &lt;code&gt;CodebaseInfo&lt;/code&gt; for the project. It calls the LLM only when the project has more than one file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn
async def aggregate_project_info(
    project_name: str,
    file_infos: list[CodebaseInfo],
) -&amp;gt; CodebaseInfo:
    &quot;&quot;&quot;Aggregate multiple file extractions into a project-level summary.&quot;&quot;&quot;
    if not file_infos:
        return CodebaseInfo(
            name=project_name, summary=&quot;Empty project with no Python files.&quot;
        )

    # Single file - just update the name to be the project name
    if len(file_infos) == 1:
        info = file_infos[0]
        return CodebaseInfo(
            name=project_name,
            summary=info.summary,
            public_classes=info.public_classes,
            public_functions=info.public_functions,
            mermaid_graphs=info.mermaid_graphs,
        )

    # Multiple files - use LLM to create aggregated summary

    # Format file summaries for the prompt
    files_text = &quot;\n\n&quot;.join(
        f&quot;### {info.name}\n&quot;
        f&quot;Summary: {info.summary}\n&quot;
        f&quot;Classes: {&apos;, &apos;.join(c.name for c in info.public_classes) or &apos;None&apos;}\n&quot;
        f&quot;Functions: {&apos;, &apos;.join(f.name for f in info.public_functions) or &apos;None&apos;}&quot;
        for info in file_infos
    )

    # Collect all mermaid graphs from files
    all_graphs = [g for info in file_infos for g in info.mermaid_graphs]

    prompt = f&quot;&quot;&quot;Aggregate the following Python files into a project-level summary.

Project name: {project_name}

Files:
{files_text}

Create a unified CodebaseInfo that:
1. Summarizes the overall project purpose (not individual files)
2. Lists the most important public classes across all files
3. Lists the most important public functions across all files
4. For mermaid_graphs: create a single unified graph showing how the CocoIndex
   components connect across the project (if applicable)
&quot;&quot;&quot;

    result = await _instructor_client.chat.completions.create(
        model=LLM_MODEL,
        response_model=CodebaseInfo,
        messages=[{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: prompt}],
    )
    result = CodebaseInfo.model_validate(result.model_dump())

    # Keep original file-level graphs if LLM didn&apos;t generate a unified one
    if not result.mermaid_graphs and all_graphs:
        result.mermaid_graphs = all_graphs

    return result
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;.md. A note says process_project is memoized, so a project with no changed files skips all of this and makes 0 calls.&quot;} title={&quot;Inside one project&quot;} width={960} height={412} detailScale={1.4} minWidth={840} /&amp;gt;&lt;/p&gt;
&lt;p&gt;The aggregation prompt sees each file&apos;s name, summary and the names of its classes and functions, not the source code. If the model returns no unified graph, the file-level graphs are kept.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;aggregate_project_info&lt;/code&gt; is not memoized. It runs each time its component runs, so a change to any file in a multi-file project costs one extraction call for that file plus one aggregation call.&lt;/p&gt;
&lt;h2&gt;Step 4: Render the Markdown page&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;generate_markdown&lt;/code&gt; is plain string formatting, with no LLM call:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn
def generate_markdown(
    project_name: str, info: CodebaseInfo, file_infos: list[CodebaseInfo]
) -&amp;gt; str:
    &quot;&quot;&quot;Generate markdown documentation from project info.&quot;&quot;&quot;
    lines = [
        f&quot;# {project_name}&quot;,
        &quot;&quot;,
        &quot;## Overview&quot;,
        &quot;&quot;,
        info.summary,
        &quot;&quot;,
    ]

    # Components
    if info.public_classes or info.public_functions:
        lines.extend([&quot;## Components&quot;, &quot;&quot;])

        if info.public_classes:
            lines.append(&quot;**Classes:**&quot;)
            for cls in info.public_classes:
                lines.append(f&quot;- `{cls.name}`: {cls.summary}&quot;)
            lines.append(&quot;&quot;)

        if info.public_functions:
            lines.append(&quot;**Functions:**&quot;)
            for fn in info.public_functions:
                marker = &quot; ★&quot; if fn.is_coco_function else &quot;&quot;
                lines.append(f&quot;- `{fn.signature}`{marker}: {fn.summary}&quot;)
            lines.append(&quot;&quot;)

    # Mermaid graphs
    if info.mermaid_graphs:
        lines.extend([&quot;## CocoIndex Pipeline&quot;, &quot;&quot;])
        for graph in info.mermaid_graphs:
            # Ensure proper code fence wrapping (LLM may or may not include them)
            graph_content = graph.strip()
            if graph_content.startswith(&quot;```&quot;):
                # Already has fences, use as-is
                lines.append(graph_content)
            else:
                # Add mermaid code fences
                lines.append(&quot;```mermaid&quot;)
                lines.append(graph_content)
                lines.append(&quot;```&quot;)
            lines.append(&quot;&quot;)

    # File details (if multiple files)
    if len(file_infos) &amp;gt; 1:
        lines.extend([&quot;## File Details&quot;, &quot;&quot;])
        for fi in file_infos:
            lines.extend([f&quot;### {fi.name}&quot;, &quot;&quot;, fi.summary, &quot;&quot;])

    # Legend
    lines.extend([&quot;---&quot;, &quot;&quot;, &quot;*★ = CocoIndex function*&quot;])

    return &quot;\n&quot;.join(lines)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;.md, with the field each section comes from. The heading is the project name. Overview is info.summary. Components lists Classes as name and summary, and Functions as signature and summary, with a star when is_coco_function is true. CocoIndex Pipeline holds each entry of info.mermaid_graphs in a mermaid code fence, and appears only when there is a graph. File Details has 1 subsection per file with that file&apos;s summary, and appears only for projects with 2 or more files. The page ends with the legend: star = CocoIndex function.&quot;} title={&quot;One generated page&quot;} width={960} height={468} detailScale={1.4} minWidth={840} /&amp;gt;&lt;/p&gt;
&lt;p&gt;The page has 4 sections; only Overview is always present:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Overview:&lt;/strong&gt; the project summary.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Components:&lt;/strong&gt; classes, and functions by signature; ★ marks a function decorated with &lt;code&gt;@coco.fn&lt;/code&gt;. Omitted when the model found no public classes or functions.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CocoIndex Pipeline:&lt;/strong&gt; each Mermaid graph in a &lt;code&gt;mermaid&lt;/code&gt; code fence. The function adds the fence only when the model did not already include one. Omitted when there is no graph.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;File Details:&lt;/strong&gt; one summary per file, for projects with 2 or more files.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Check the generated diagrams against the code. A response that validates against the schema can still describe a call relationship incorrectly.&lt;/p&gt;
&lt;h2&gt;Step 5: Mount one component per project&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;process_project&lt;/code&gt; runs the 3 steps for one project and declares the output file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def process_project(
    project_name: str,
    files: Collection[localfs.File],
    output_dir: pathlib.Path,
) -&amp;gt; None:
    &quot;&quot;&quot;Process a single project: extract info from all files, aggregate, and output markdown.&quot;&quot;&quot;
    # Extract info from each file.
    file_infos = await coco.map(extract_file_info, files)

    # Aggregate into project-level summary
    project_info = await aggregate_project_info(project_name, file_infos)

    # Generate and output markdown
    markdown = generate_markdown(project_name, project_info, file_infos)
    localfs.declare_file(
        output_dir / f&quot;{project_name}.md&quot;, markdown, create_parent_dirs=True
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;coco.map&lt;/code&gt; runs &lt;code&gt;extract_file_info&lt;/code&gt; on every file concurrently and returns the results in input order. It creates no new components: the calls run as async tasks inside the project&apos;s component. &lt;code&gt;localfs.declare_file&lt;/code&gt; declares a &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;target state&lt;/a&gt;, a file that should exist with this content. CocoIndex writes it, rewrites it when the content changes, and deletes it when no component declares it any more.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;app_main&lt;/code&gt; lists the projects and mounts the components:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn
async def app_main(
    root_dir: pathlib.Path,
    output_dir: pathlib.Path,
) -&amp;gt; None:
    &quot;&quot;&quot;
    Main application function.

    Scans subdirectories of root_dir, treating each as a Python project,
    and generates markdown documentation for each.
    &quot;&quot;&quot;
    # List subdirectories (each is a project)
    for entry in root_dir.resolve().iterdir():
        # Skip non-directories and hidden directories
        if not entry.is_dir() or entry.name.startswith(&quot;.&quot;):
            continue
        project_name = entry.name

        # Walk Python files in this project, excluding .venv directories
        files = [
            f
            async for f in localfs.walk_dir(
                entry,
                recursive=True,
                path_matcher=PatternFilePathMatcher(
                    included_patterns=[&quot;**/*.py&quot;],
                    excluded_patterns=[&quot;**/.*&quot;, &quot;**/__pycache__&quot;],
                ),
            )
        ]

        if files:
            # Mount a component to process this project
            await coco.mount(
                coco.component_subpath(&quot;project&quot;, project_name),
                process_project,
                project_name,
                files,
                output_dir,
            )

app = coco.App(
    coco.AppConfig(name=&quot;MultiCodebaseSummarization&quot;),
    app_main,
    root_dir=pathlib.Path(&quot;../&quot;),
    output_dir=pathlib.Path(&quot;./output&quot;),
)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;localfs.walk_dir&lt;/code&gt; is an async iterator, so the list is built with &lt;code&gt;async for&lt;/code&gt;. The patterns match Python files at any depth and skip hidden paths (such as &lt;code&gt;.venv&lt;/code&gt;) and &lt;code&gt;__pycache__&lt;/code&gt;. A folder with no Python files gets no component.&lt;/p&gt;
&lt;p&gt;You choose the granularity. A component could be one file, or a smaller unit such as a page or a section. This example uses one component per project directory because it writes one page per project. &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/&quot;&gt;&lt;code&gt;coco.mount&lt;/code&gt;&lt;/a&gt; takes a stable path, &lt;code&gt;(&quot;project&quot;, project_name)&lt;/code&gt;, and each &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/&quot;&gt;processing component&lt;/a&gt; owns the target states it declares, here its Markdown file. Components run independently: when one project finishes, its page is written without waiting for the other projects.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;process_project&lt;/code&gt; is memoized too. When none of a project&apos;s files changed and the code of the functions it calls is unchanged, CocoIndex skips the component&apos;s body and keeps the page it declared last time, so that project makes no LLM call.&lt;/p&gt;

Quick check: you delete a project folder and run the pipeline again. What happens to its page?
&lt;p&gt;It is deleted. &lt;code&gt;app_main&lt;/code&gt; no longer finds the folder, so it does not mount a component at &lt;code&gt;(&quot;project&quot;, &amp;lt;name&amp;gt;)&lt;/code&gt;. CocoIndex cleans up the target states of a component that is no longer mounted, and &lt;code&gt;output/&amp;lt;name&amp;gt;.md&lt;/code&gt; was one of them. No LLM call runs for that project.&lt;/p&gt;

&lt;h2&gt;Run it&lt;/h2&gt;
&lt;p&gt;From &lt;code&gt;examples/multi_codebase_summarization&lt;/code&gt; in the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex repo&lt;/a&gt;, copy the environment template and set your key, then install the example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cp .env.example .env     # set GEMINI_API_KEY (or LLM_MODEL=&amp;lt;provider/model&amp;gt; with its matching key)
pip install -e .
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;pip install -e .&lt;/code&gt; installs &lt;code&gt;cocoindex&amp;gt;=1.0.7&lt;/code&gt;, &lt;code&gt;instructor&lt;/code&gt;, &lt;code&gt;litellm&lt;/code&gt;, &lt;code&gt;pydantic&lt;/code&gt; and &lt;code&gt;python-dotenv&lt;/code&gt; from &lt;code&gt;pyproject.toml&lt;/code&gt;. The example&apos;s &lt;code&gt;.env&lt;/code&gt; sets &lt;code&gt;COCOINDEX_DB=./cocoindex.db&lt;/code&gt;, the local database where CocoIndex keeps its tracking state and memo cache. The &lt;code&gt;cocoindex&lt;/code&gt; CLI loads the nearest &lt;code&gt;.env&lt;/code&gt;, searching up from the current directory.&lt;/p&gt;
&lt;p&gt;Build the wiki:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cocoindex update main.py
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;root_dir&lt;/code&gt; is &lt;code&gt;../&lt;/code&gt;, so this documents the folders in &lt;code&gt;examples/&lt;/code&gt;, the example&apos;s own folder included. To document your own code, point &lt;code&gt;root_dir&lt;/code&gt; in &lt;code&gt;main.py&lt;/code&gt; at a folder of project subdirectories:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;my_projects/
├── my_project_1/
│   ├── main.py
│   └── utils.py
├── my_project_2/
│   └── app.py
└── ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Read the output:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ls output/
cat output/code_embedding.md
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;What you see.&lt;/strong&gt; &lt;code&gt;output/&lt;/code&gt; holds one &lt;code&gt;&amp;lt;folder name&amp;gt;.md&lt;/code&gt; per project folder that contains Python files, such as &lt;code&gt;code_embedding.md&lt;/code&gt;. Each page starts with &lt;code&gt;# &amp;lt;folder name&amp;gt;&lt;/code&gt; and &lt;code&gt;## Overview&lt;/code&gt;, and ends with &lt;code&gt;*★ = CocoIndex function*&lt;/code&gt;. The summaries and diagrams are written by the model, so their wording differs between models and between runs that miss the cache.&lt;/p&gt;
&lt;h2&gt;What a re-run does&lt;/h2&gt;
&lt;p&gt;Every &lt;code&gt;cocoindex update main.py&lt;/code&gt; lists the projects again and mounts a component for each. LLM calls happen only where a memo cache misses:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;An edited file&lt;/strong&gt; misses its &lt;code&gt;extract_file_info&lt;/code&gt; cache. The other files in the project hit theirs. For a multi-file project, &lt;code&gt;aggregate_project_info&lt;/code&gt; makes one more call.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A new project folder&lt;/strong&gt; gets a new component. Only its files go to the LLM, plus one aggregation call if it has 2 or more files.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A deleted project folder&lt;/strong&gt; loses its component, and CocoIndex deletes its page.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;An edited prompt&lt;/strong&gt; changes the code of &lt;code&gt;extract_file_info&lt;/code&gt;. That invalidates its cached results and the memo of &lt;code&gt;process_project&lt;/code&gt;, which calls it, so every file misses once.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A new &lt;code&gt;LLM_MODEL&lt;/code&gt;&lt;/strong&gt; changes no memo key, because the example does not list it in &lt;code&gt;deps&lt;/code&gt;. The run makes no calls, and each file keeps the old model&apos;s result until that file changes.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Try the cases on a small tree of 3 projects and 7 files. The second counter is a script that sends every file to the LLM on every run:&lt;/p&gt;

Quick check: a project has 5 Python files and you edit one of them. How many LLM calls does the next run make for that project?
&lt;p&gt;2: 1 &lt;code&gt;extract_file_info&lt;/code&gt; call for the edited file, and 1 &lt;code&gt;aggregate_project_info&lt;/code&gt; call, because the project has more than one file. The other 4 files hit the cache. For a single-file project, the answer is 1, because aggregation reuses the file&apos;s info without a call.&lt;/p&gt;

&lt;h2&gt;Beyond documentation: keeping derived knowledge current&lt;/h2&gt;
&lt;p&gt;The same pattern applies wherever derived knowledge has to follow a changing source. For the agent case in the introduction, the pages are context, and they are only as current as the last run.&lt;/p&gt;
&lt;p&gt;Processing the change, instead of rebuilding the whole corpus, keeps this practical:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cost:&lt;/strong&gt; unchanged files do not cause repeated LLM calls.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Latency:&lt;/strong&gt; a run after a small change spends LLM time only on the changed files.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scale:&lt;/strong&gt; after the first full run, a large codebase stays current without full reprocessing.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is the same incremental pattern behind &lt;a href=&quot;https://cocoindex.io/blogs/index-codebase-v1&quot;&gt;indexing a codebase for RAG&lt;/a&gt;, &lt;a href=&quot;https://cocoindex.io/blogs/text-embeddings-101&quot;&gt;text embeddings&lt;/a&gt; and &lt;a href=&quot;https://cocoindex.io/blogs/knowledge-graph-for-docs&quot;&gt;knowledge graphs&lt;/a&gt;: declare the transformation once, and only changed inputs are reprocessed.&lt;/p&gt;
&lt;h2&gt;What to try next&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Document your own repos.&lt;/strong&gt; Point &lt;code&gt;root_dir&lt;/code&gt; at a folder of project subdirectories and run &lt;code&gt;cocoindex update main.py&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Switch the model.&lt;/strong&gt; Set &lt;code&gt;LLM_MODEL&lt;/code&gt; in &lt;code&gt;.env&lt;/code&gt; to another &lt;a href=&quot;https://docs.litellm.ai/docs/providers&quot;&gt;LiteLLM provider&lt;/a&gt; model and add its key. Check that it returns JSON that validates against &lt;code&gt;CodebaseInfo&lt;/code&gt;. Cached results from the old model stay in use for unchanged files, because &lt;code&gt;LLM_MODEL&lt;/code&gt; is not in &lt;code&gt;deps&lt;/code&gt;; see &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#deps&quot;&gt;&lt;code&gt;deps&lt;/code&gt;&lt;/a&gt; to make it part of the memo key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Change what the page says.&lt;/strong&gt; Add a field to &lt;code&gt;CodebaseInfo&lt;/code&gt; and a section to &lt;code&gt;generate_markdown&lt;/code&gt;. A new field changes the schema the model sees, so check the output on one project first.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Refresh from CI.&lt;/strong&gt; Run &lt;code&gt;cocoindex update main.py&lt;/code&gt; from a commit hook or a CI job. The example scans the folders once per run; for a process that keeps running, read about &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/live_mode/&quot;&gt;live mode&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Give the pages to an agent.&lt;/strong&gt; Each page is a short Markdown summary of a project, with its public API and call graph, that you can put into a coding agent&apos;s context.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Further reading:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/multi_codebase_summarization&quot;&gt;The example on GitHub&lt;/a&gt;: &lt;code&gt;main.py&lt;/code&gt;, &lt;code&gt;models.py&lt;/code&gt; and the README&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/examples/multi-codebase-summarization/&quot;&gt;The example walkthrough in the docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/&quot;&gt;Functions and memoization&lt;/a&gt;: &lt;code&gt;memo=True&lt;/code&gt;, &lt;code&gt;deps&lt;/code&gt; and change detection&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/advanced_topics/memoization_keys/&quot;&gt;Memoization keys and states&lt;/a&gt;: how file arguments are fingerprinted&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/&quot;&gt;Processing components&lt;/a&gt;: mounting, ownership and cleanup&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Thanks to the community&lt;/h2&gt;
&lt;h3&gt;@prrao87&lt;/h3&gt;
&lt;p&gt;Thanks &lt;a href=&quot;https://github.com/prrao87&quot;&gt;@prrao87&lt;/a&gt; for reviewing the example and providing detailed feedback on terminology, style and conceptual clarity, which helped improve the developer experience.&lt;/p&gt;
&lt;p&gt;If you have ideas or questions, or want to contribute, join us on &lt;a href=&quot;https://discord.com/invite/zpA9S2DR7s&quot;&gt;Discord&lt;/a&gt;. The source is on &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>examples</category><category>llm</category><category>structured-extraction</category><category>incremental-processing</category><category>tutorial</category><author>Linghua Jin</author></item><item><title>Turn PDF Slides into Narrated Audio with Gemini and TTS</title><link>https://cocoindex.io/blogs/slides-to-speech/</link><guid isPermaLink="true">https://cocoindex.io/blogs/slides-to-speech/</guid><description>Build a CocoIndex v1 pipeline that turns PDF slides into vision-generated speaker notes, local Pocket TTS narration, and searchable LanceDB records.</description><pubDate>Thu, 22 Jan 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Slide decks hold a lot of company knowledge: quarterly updates, technical specs, sales reports, training material. They live in PDF files that change often, and they are hard to search or consume outside a presentation.&lt;/p&gt;
&lt;p&gt;This tutorial builds a pipeline that turns a folder of decks into a narrated, searchable knowledge base:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Listen to a deck&lt;/strong&gt; slide by slide instead of reading it, which also helps people with visual impairments.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Speaker notes for every slide&lt;/strong&gt;, written by a VLM (vision language model) that reads the rendered slide.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Semantic search over the notes&lt;/strong&gt;, so a query finds slides by meaning rather than by the words in a title or file name.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Producing those outputs once is half the job. When a deck changes, its notes, audio and embeddings have to change with it, and only for the slides that changed. &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex&lt;/a&gt; keeps derived data in sync with its sources and recomputes only what a change affects. &lt;a href=&quot;https://docs.lancedb.com&quot;&gt;LanceDB&lt;/a&gt; is an open-source, embedded retrieval library that stores the notes, MP3 bytes, embeddings and metadata in one table, with vector, full-text and secondary indexes next to the data.&lt;/p&gt;
&lt;p&gt;The code follows the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/slides_to_speech&quot;&gt;slides_to_speech example&lt;/a&gt; on the CocoIndex v1 API.&lt;/p&gt;
&lt;h2&gt;What we are building: one slide, three derived modalities&lt;/h2&gt;
&lt;p&gt;A PDF deck doesn&apos;t become one large database record. The pipeline fans it out page by page, then turns each slide into three related outputs: speaker notes, MP3 narration, and a text embedding for semantic search.&lt;/p&gt;
&lt;p&gt;The speaker notes sit at the center of the pipeline, but they first need to be generated by a vision model that reasons over the slide content. Once they exist, audio generation and embedding can start together. The completed outputs are then declared together as one &lt;code&gt;SlideRecord&lt;/code&gt;, identified by its filename and page number.&lt;/p&gt;
&lt;p&gt;Each tool has one focused job:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Role in the pipeline&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;CocoIndex&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Discovers PDFs, runs the transformations, and reconciles the declared slide rows with the source files.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;PyMuPDF&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Renders every PDF page as a PNG for the vision model.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DSPy + Gemini&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;DSPy calls the VLM through a typed signature. The VLM (Gemini, &lt;code&gt;gemini/gemini-2.5-flash&lt;/code&gt; unless &lt;code&gt;LLM_MODEL&lt;/code&gt; says otherwise) reads each rendered slide PNG and writes the speaker notes.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Pocket TTS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Synthesizes those notes as MP3 audio locally on the CPU.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Sentence Transformers&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Embeds the speaker notes locally with &lt;code&gt;sentence-transformers/all-MiniLM-L6-v2&lt;/code&gt; (384-dimensional vectors).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;LanceDB&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Stores text, binary audio, metadata, and vectors together, then searches the notes by meaning.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Everything except the VLM runs locally and needs no GPU: PyMuPDF renders the pages as images, &lt;a href=&quot;https://github.com/kyutai-labs/pocket-tts&quot;&gt;Pocket TTS&lt;/a&gt; synthesizes audio from the speaker notes, &lt;code&gt;sentence-transformers&lt;/code&gt; generates text embeddings, and LanceDB runs as an embedded library.&lt;/p&gt;
&lt;h2&gt;Start backwards from the target&lt;/h2&gt;
&lt;p&gt;CocoIndex pipelines are easiest to reason about &lt;em&gt;backwards&lt;/em&gt; from the target, i.e., where the data sits in its final form: &lt;code&gt;target_state = transformation(source_state)&lt;/code&gt;, where &lt;code&gt;transformation&lt;/code&gt; can be any function, or a set of functions. For this pipeline, the target state is one LanceDB row for &lt;strong&gt;each slide&lt;/strong&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Declare the LanceDB table shape via a strictly typed schema
# Pydantic or PyArrow schemas work well, but dataclasses are simpler for this example
@dataclass
class SlideRecord:
    id: str
    filename: str
    page: int
    speaker_notes: str
    voice: bytes
    embedding: Annotated[NDArray, EMBEDDER]

# Mount a LanceDB table as the target
table = await lancedb.mount_table_target(
    LANCE_DB,
    table_name=&quot;slides_to_speech&quot;,
    table_schema=await lancedb.TableSchema.from_class(
        SlideRecord,
        primary_key=[&quot;id&quot;],
    ),
)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each LanceDB row holds the slide&apos;s metadata, generated notes, MP3 narration bytes, and vector embedding side by side. &lt;code&gt;SlideRecord&lt;/code&gt; is the typed contract that keeps those values together.&lt;/p&gt;
&lt;p&gt;Each slide needs a stable primary key so CocoIndex can match it to the same LanceDB row across runs, updating or removing the correct record as the source changes. This example derives that key from the filename and page number: page 3 of &lt;code&gt;quarterly_review.pdf&lt;/code&gt; becomes &lt;code&gt;quarterly_review.pdf#3&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Functions vs. processing components&lt;/h2&gt;
&lt;p&gt;Incremental processing is only useful when its boundaries match the unit of change. We want our pipeline to run every time a change is detected in the source files, without recomputing what didn&apos;t change.&lt;/p&gt;
&lt;p&gt;In CocoIndex, functions define the work, while processing components group that work into independently synchronized units. Where we draw those component boundaries determines how much of the pipeline runs each time a change is detected, and which target states CocoIndex reconciles afterward.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Functions&lt;/strong&gt; are callable Python functions decorated with &lt;code&gt;@coco.fn&lt;/code&gt;. Setting &lt;code&gt;memo=True&lt;/code&gt; lets CocoIndex reuse results for unchanged inputs and code. Several functions can run inside the same processing component.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Processing components&lt;/strong&gt; are created by grouping functions and &lt;em&gt;mounting&lt;/em&gt; them to the target. They manage the necessary function calls and the target states they declare. Processing components help decide the granularity at which CocoIndex reruns work and synchronizes the result.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this example, we define the processing component at the &lt;strong&gt;per-slide level&lt;/strong&gt;, through the &lt;code&gt;process_file&lt;/code&gt; function. It takes a PDF file, renders each slide as an image, and mounts one &lt;code&gt;process_slide&lt;/code&gt; component for each slide.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def process_file(
    file: FileLike,
    table: lancedb.TableTarget[SlideRecord],
) -&amp;gt; None:
    slides = await pdf_to_slides(await file.read())
    await coco.mount_each(
        process_slide,
        ((slide.page_number, slide) for slide in slides),
        str(file.file_path.path),
        table,
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;process_file&lt;/code&gt; is memoized too, so CocoIndex can skip reading and rendering an unchanged PDF. If the file does change, &lt;code&gt;process_slide&lt;/code&gt; provides the finer-grained memoization boundary: slide images with unchanged inputs reuse their prior results, while changed slides go through note generation, TTS, embedding, and the declaration of &lt;code&gt;SlideRecord&lt;/code&gt; in the LanceDB target based on its stable key.&lt;/p&gt;
&lt;p&gt;Changing a slide in a PDF still reruns page rendering for that entire file. PyMuPDF rendering is cheap and no VLM call happens at this step. CocoIndex then compares each slide&apos;s PNG bytes with the previous run and processes &lt;em&gt;only&lt;/em&gt; the slides whose images changed, which is why the component is mounted per slide.&lt;/p&gt;
&lt;p&gt;Pick a change below to see which calls run again for each slide of the sample deck:&lt;/p&gt;
&lt;p&gt;If a PDF is deleted from the source folder, CocoIndex unmounts its per-file component and recursively cleans up the target states it owns. In this pipeline, that means deleting the PDF&apos;s slide rows from LanceDB.&lt;/p&gt;
&lt;p&gt;The next sections go through each stage of the pipeline.&lt;/p&gt;
&lt;h2&gt;Fan a PDF out into slides&lt;/h2&gt;
&lt;p&gt;The function &lt;code&gt;pdf_to_slides&lt;/code&gt; turns the PDF bytes into typed &lt;code&gt;SlidePage&lt;/code&gt; values, each carrying the page number and the rendered PNG that the vision model will inspect.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@dataclass
class SlidePage:
    page_number: int
    image: bytes

@coco.fn.as_async(runner=coco.GPU, memo=True)
def pdf_to_slides(content: bytes) -&amp;gt; list[SlidePage]:
    import pymupdf

    slides: list[SlidePage] = []
    doc = pymupdf.open(stream=content, filetype=&quot;pdf&quot;)
    for i, page in enumerate(doc):
        pix = page.get_pixmap(matrix=pymupdf.Matrix(2, 2))
        slides.append(
            SlidePage(page_number=i + 1, image=pix.tobytes(&quot;png&quot;))
        )
    doc.close()
    return slides
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;PyMuPDF renders each page at 2× scale, so the vision model sees a legible PNG rather than extracted PDF text. The image is an intermediate input: Gemini uses it to generate notes, but the pipeline discards it afterward. If you want to keep the rendered image for reuse, you can add an &lt;code&gt;image&lt;/code&gt; field and store its bytes in the same LanceDB table.&lt;/p&gt;
&lt;p&gt;:::note[Why &lt;code&gt;runner=coco.GPU&lt;/code&gt; on CPU code]
The &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#runner&quot;&gt;&lt;code&gt;coco.GPU&lt;/code&gt; runner&lt;/a&gt; doesn&apos;t require a GPU. Every function on it shares one queue, and a sync function runs on a dedicated thread, one call at a time. That suits blocking libraries that are not safe to call from several threads at once, such as PyMuPDF and Pocket TTS: &lt;code&gt;@coco.fn.as_async&lt;/code&gt; turns the blocking call into an awaitable that doesn&apos;t block the event loop, and the runner keeps two calls from overlapping.
:::&lt;/p&gt;
&lt;h2&gt;Turn a slide image into narration&lt;/h2&gt;
&lt;p&gt;Extracting speaker notes from the slide images gives the &lt;a href=&quot;https://github.com/kyutai-labs/pocket-tts&quot;&gt;Pocket TTS&lt;/a&gt; model the text it needs to narrate the slide. Text embeddings are also generated from the speaker notes, so semantic search can find slides by meaning rather than by keywords in their titles or filenames.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;class SlideNotes(dspy.Signature):
    &quot;&quot;&quot;Write natural spoken narration for a slide, as a presenter would say it aloud.&quot;&quot;&quot;

    slide: dspy.Image = dspy.InputField(desc=&quot;the rendered slide image&quot;)
    speaker_notes: str = dspy.OutputField(
        desc=&quot;a few sentences of spoken narration — no markdown or bullet symbols&quot;
    )

_speaker_notes = dspy.Predict(SlideNotes)

@functools.cache
def _get_lm(model: str) -&amp;gt; dspy.LM:
    return dspy.LM(model, max_tokens=8192)

@coco.fn(memo=True)
async def extract_speaker_notes(image: bytes) -&amp;gt; str:
    data_url = &quot;data:image/png;base64,&quot; + base64.b64encode(image).decode()
    with dspy.context(lm=_get_lm(coco.use_context(LLM_MODEL))):
        result = await _speaker_notes.acall(slide=dspy.Image(url=data_url))
    return result.speaker_notes
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;SlideNotes&lt;/code&gt; is a DSPy signature, a typed contract that tells the VLM what we need. When a slide image comes in, speaker notes come out. The CocoIndex function &lt;code&gt;extract_speaker_notes&lt;/code&gt; does the actual work of turning the PNG bytes into a text output.&lt;/p&gt;
&lt;p&gt;This extraction function is memoized because speaker-note generation is the most expensive step: it calls a VLM to reason over the image. Its memoization key includes the rendered image and the change-detected &lt;code&gt;LLM_MODEL&lt;/code&gt; context, so an unchanged slide reuses its notes while the image bytes and the model stay the same. If either changes, CocoIndex reruns the work for that slide.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;text_to_speech&lt;/code&gt; synthesizes the notes with Pocket TTS and packs the audio as MP3. The model and each voice&apos;s conditioning state load once and stay cached:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@functools.cache
def get_tts_model() -&amp;gt; TTSModel:
    return TTSModel.load_model()

@functools.cache
def get_voice_state(voice: str) -&amp;gt; dict:
    return get_tts_model().get_state_for_audio_prompt(voice)

@coco.fn.as_async(runner=coco.GPU, memo=True)
def text_to_speech(text: str, voice: str) -&amp;gt; bytes:
    model = get_tts_model()
    # Pocket TTS is not thread-safe; the coco.GPU runner serializes calls.
    audio = model.generate_audio(get_voice_state(voice), text)
    samples = np.clip(audio.to(&quot;cpu&quot;).numpy().reshape(-1), -1.0, 1.0)
    pcm16 = (samples * 32767.0).astype(&quot;&amp;lt;i2&quot;).tobytes()
    segment = AudioSegment(
        data=pcm16, sample_width=2, frame_rate=model.sample_rate, channels=1
    )
    out = io.BytesIO()
    segment.export(out, format=&quot;mp3&quot;, bitrate=&quot;64k&quot;)
    return out.getvalue()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The memo key is the text and the voice name, so the same notes in the same voice are not synthesized again while the function&apos;s code stays the same.&lt;/p&gt;
&lt;h2&gt;Turn speaker notes into audio and embeddings&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;process_slide&lt;/code&gt; reads top to bottom. The speaker notes must exist first, so it awaits &lt;code&gt;extract_speaker_notes&lt;/code&gt;. Audio synthesis and embedding don&apos;t depend on each other, so &lt;code&gt;asyncio.gather&lt;/code&gt; submits both at once; both heavy calls go through the &lt;code&gt;coco.GPU&lt;/code&gt; runner, which executes them one after the other. CocoIndex commits the row to the LanceDB table only after both are ready.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def process_slide(
    slide: SlidePage,
    filename: str,
    table: lancedb.TableTarget[SlideRecord],
) -&amp;gt; None:
    notes = await extract_speaker_notes(slide.image)
    voice, embedding = await asyncio.gather(
        text_to_speech(notes, coco.use_context(TTS_VOICE)),
        coco.use_context(EMBEDDER).embed(notes),
    )
    table.declare_row(
        row=SlideRecord(
            id=f&quot;{filename}#{slide.page_number}&quot;,
            filename=filename,
            page=slide.page_number,
            speaker_notes=notes,
            voice=voice,
            embedding=embedding,
        )
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The target state is declared as a &lt;code&gt;SlideRecord&lt;/code&gt; dataclass (per the LanceDB schema) keyed by its unique ID that combines the filename and page number. This is how CocoIndex reconciles the target state with the source files, updating or removing rows as needed.&lt;/p&gt;
&lt;p&gt;The expensive nested operations are memoized as well. If only the voice changes, CocoIndex reuses the notes and embedding and regenerates the audio. If the embedding model changes, it reuses the notes and audio and computes a new vector. This gives reuse at the file, slide, and individual transformation levels.&lt;/p&gt;
&lt;h2&gt;Define the app&lt;/h2&gt;
&lt;p&gt;Apps are the top-level runnable unit in CocoIndex. They name your pipeline and bind a &lt;code&gt;main&lt;/code&gt; function with its parameters. When you call &lt;code&gt;app.update()&lt;/code&gt;, CocoIndex runs that main function as the root processing component that can mount processing components (like our &lt;code&gt;process_file&lt;/code&gt; and its child component &lt;code&gt;process_slide&lt;/code&gt;) that do work and declare target states.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;app_main&lt;/code&gt; mounts the &lt;code&gt;SlideRecord&lt;/code&gt; table we defined earlier, uses &lt;code&gt;localfs.walk_dir&lt;/code&gt; in live mode to discover PDFs, then calls the outer &lt;code&gt;mount_each&lt;/code&gt;. The app is configured with a name, the main function, and the source directory to watch for changes.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn
async def app_main(sourcedir: pathlib.Path) -&amp;gt; None:
    table = await lancedb.mount_table_target(
        LANCE_DB,
        table_name=&quot;slides_to_speech&quot;,
        table_schema=await lancedb.TableSchema.from_class(
            SlideRecord,
            primary_key=[&quot;id&quot;],
        ),
    )
    files = localfs.walk_dir(
        sourcedir,
        recursive=True,
        path_matcher=PatternFilePathMatcher(
            included_patterns=[&quot;**/*.pdf&quot;]
        ),
        live=True,
    )
    await coco.mount_each(process_file, files.items(), table)

app = coco.App(
    coco.AppConfig(name=&quot;SlidesToSpeech&quot;),
    app_main,
    sourcedir=pathlib.Path(&quot;./slides&quot;),
)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The example&apos;s &lt;code&gt;coco_lifespan&lt;/code&gt; provides the context values the functions read: the LanceDB connection, the embedder, &lt;code&gt;LLM_MODEL&lt;/code&gt; and &lt;code&gt;TTS_VOICE&lt;/code&gt;, the last two from environment variables.&lt;/p&gt;
&lt;h2&gt;Run the pipeline and run semantic search&lt;/h2&gt;
&lt;h3&gt;Prerequisites&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Python 3.11+&lt;/li&gt;
&lt;li&gt;A Gemini API key for the default vision model&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ffmpeg&lt;/code&gt; for MP3 export&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Pocket TTS is open source and runs locally on the CPU. Its weights download on the first run, so it needs neither a TTS API key nor a GPU.&lt;/p&gt;
&lt;h3&gt;Quick start&lt;/h3&gt;
&lt;p&gt;From the example directory, copy the environment file and set &lt;code&gt;GEMINI_API_KEY&lt;/code&gt;. The file also sets &lt;code&gt;LLM_MODEL&lt;/code&gt; (&lt;code&gt;gemini/gemini-3.5-flash&lt;/code&gt;) and &lt;code&gt;POCKET_TTS_VOICE&lt;/code&gt; (&lt;code&gt;anna&lt;/code&gt;); without them, the code falls back to &lt;code&gt;gemini/gemini-2.5-flash&lt;/code&gt; and the &lt;code&gt;alba&lt;/code&gt; voice. Then install and run:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cp .env.example .env
uv sync
cocoindex update main

# Keep watching slides/ for changes instead:
cocoindex update -L main
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Search the deck&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;python main.py &quot;reducing latency and reliability&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The query helper embeds the question with the same sentence-transformer, then asks LanceDB for its nearest neighbors. The results already arrive ranked, so we can print the matching slide and its notes directly:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for row in table.search(vec).limit(5).to_list():
    print(f&quot;{row[&apos;filename&apos;]} slide {row[&apos;page&apos;]}&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The slide deck we use here is an example &quot;quarterly-review&quot; deck, so the query about &quot;reducing latency and reliability&quot; brings the slide about &quot;Engineering Priorities&quot; to the top because its notes discuss &quot;reducing p95 latency and multi-region resilience&quot;.&lt;/p&gt;
&lt;p&gt;The returned row can also fetch the &lt;code&gt;voice&lt;/code&gt; bytes, so a downstream application can serve them as &lt;code&gt;audio/mpeg&lt;/code&gt;, or write them to an MP3 file for playback.&lt;/p&gt;
&lt;p&gt;Here is the narration the pipeline generated for the sample deck, one MP3 per slide. The recordings and transcripts describe the illustrative quarterly-review deck:&lt;/p&gt;
&lt;h2&gt;How CocoIndex tracks changes&lt;/h2&gt;
&lt;p&gt;In this demo, CocoIndex watches the &lt;code&gt;./slides&lt;/code&gt; directory for changed PDFs. It then identifies the changed slides, and only those slides regenerate notes, audio, and embeddings.&lt;/p&gt;
&lt;p&gt;Source files changing is only one such scenario. The table below shows the other changes that CocoIndex tracks, and what they mean for this pipeline and others like it.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Change&lt;/th&gt;
&lt;th&gt;What it means in this pipeline&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Nothing&lt;/td&gt;
&lt;td&gt;Memoized calls reuse their prior results and retain their rows.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;One slide changes inside a PDF&lt;/td&gt;
&lt;td&gt;The PDF renders again, then only the slide with different PNG bytes reruns notes, TTS, embedding, and its row declaration.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A PDF is added or deleted&lt;/td&gt;
&lt;td&gt;CocoIndex creates or removes the file component and all of its owned slide rows.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LLM model, embedder, or voice changes&lt;/td&gt;
&lt;td&gt;The change-detected context refreshes the functions that consume it; unrelated memoized calls can be reused.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Decorated function logic changes&lt;/td&gt;
&lt;td&gt;A changed &lt;code&gt;@coco.fn&lt;/code&gt; fingerprint invalidates memoized calls that depend on that function, then CocoIndex reconciles the resulting rows.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SlideRecord&lt;/code&gt; fields or primary key change&lt;/td&gt;
&lt;td&gt;The target contract has changed. Treat compatibility, backfill, and identity changes as a deliberate migration decision.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;Extend the pipeline to other formats&lt;/h2&gt;
&lt;p&gt;This pipeline derives narration, embeddings, and searchable rows from slide decks. Similar pipelines can process other document and media formats into one collection that agents can retrieve from:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;One storage layer:&lt;/strong&gt; text, audio, vectors, and metadata in the same table.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;More structure:&lt;/strong&gt; speaker notes, extracted fields, embeddings, tags, and other derived signals.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Kept in sync:&lt;/strong&gt; incremental recomputation when source files change, with updated rows in LanceDB.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Applications on top:&lt;/strong&gt; semantic search, narrated slide playback, assistants, and video-generation pipelines.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Run the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/slides_to_speech&quot;&gt;complete slides-to-speech example&lt;/a&gt; with your own deck. The source repositories are &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex&lt;/a&gt; and &lt;a href=&quot;https://github.com/lancedb/lancedb&quot;&gt;LanceDB&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>examples</category><category>multimodal</category><category>lancedb</category><category>text-to-speech</category><category>tutorial</category><author>Prashanth Rao, Linghua Jin</author></item><item><title>Structured errors and Azure OpenAI support in CocoIndex</title><link>https://cocoindex.io/blogs/changelog-0311-0326/</link><guid isPermaLink="true">https://cocoindex.io/blogs/changelog-0311-0326/</guid><description>CocoIndex 0.3.11–0.3.26 adds structured errors with Python stack traces, warnings for slow live updates, Azure OpenAI and OpenRouter embeddings.</description><pubDate>Sun, 18 Jan 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;CocoIndex shipped 16 releases (0.3.11–0.3.26) in this cycle and reached #1 on GitHub Trending for Rust. The releases focus on production use: structured errors with stack traces across Rust and Python, warnings for slow live updates, failure handling, and new connector and LLM options.&lt;/p&gt;
&lt;p&gt;Agents need their context updated as source data and transformation logic change. CocoIndex incrementally updates derived data from sources such as PDFs, codebases, and meeting notes. The source and release history are in the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex repository&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Core runtime: errors, warnings and reprocessing&lt;/h2&gt;
&lt;p&gt;The runtime adds structured errors with stack traces across Rust and Python. Other changes cover target drop failures, slow-update warnings, forced reprocessing, progress rendering, and internal API cleanup.&lt;/p&gt;
&lt;h3&gt;Structured error system&lt;/h3&gt;
&lt;p&gt;The new error system changes how errors are defined and propagated:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Structured error framework&lt;/strong&gt; with host exception tunneling&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Python stack traces&lt;/strong&gt; that propagate end to end&lt;/li&gt;
&lt;li&gt;Unified &lt;strong&gt;error types&lt;/strong&gt; for exception messages and logging in the Rust and Python layers (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1380&quot;&gt;#1380&lt;/a&gt;, &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1413&quot;&gt;#1413&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;code&gt;refresh_interval&lt;/code&gt; warnings for slow live updates&lt;/h3&gt;
&lt;p&gt;CocoIndex now warns when a live update pass takes longer than &lt;code&gt;refresh_interval&lt;/code&gt;, which means updates are falling behind (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1408&quot;&gt;#1408&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;&lt;code&gt;--full-reprocess&lt;/code&gt;: force a full recomputation&lt;/h3&gt;
&lt;p&gt;Run &lt;code&gt;cocoindex update --full-reprocess ...&lt;/code&gt; to force a full recomputation during an incremental update, for example to reset state (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1385&quot;&gt;#1385&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;Tolerate target drop failures&lt;/h3&gt;
&lt;p&gt;Target drops can fail when a connection is unavailable, which blocks pipeline setup updates. Set &lt;code&gt;COCOINDEX_IGNORE_TARGET_DROP_FAILURES&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt; to log the failure and continue. By default, a drop failure still stops the update, and the error message names this option (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1454&quot;&gt;#1454&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;Flow correctness fixes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Corrected target diffing for user-managed setup states (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1369&quot;&gt;#1369&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Full-text search (FTS) fixes for LanceDB (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1403&quot;&gt;#1403&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Simpler progress bar&lt;/h3&gt;
&lt;p&gt;The progress bar now has a simpler presentation (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1467&quot;&gt;#1467&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;Internal API cleanup&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;datatype.py&lt;/code&gt; is now a separate module, and many internal entries moved to &lt;code&gt;_internal&lt;/code&gt;, which reduces the public API surface (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1402&quot;&gt;#1402&lt;/a&gt;).&lt;/p&gt;
&lt;h2&gt;Integrations: connector options and LLM support&lt;/h2&gt;
&lt;p&gt;These releases add connector options and LLM integrations.&lt;/p&gt;
&lt;h3&gt;Sources and targets&lt;/h3&gt;
&lt;h4&gt;Qdrant&lt;/h4&gt;
&lt;p&gt;The &lt;a href=&quot;https://cocoindex.io/docs-v0/targets/qdrant/&quot;&gt;Qdrant connector&lt;/a&gt; now supports &lt;code&gt;VectorIndexMethod&lt;/code&gt; HNSW configuration (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1410&quot;&gt;#1410&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;Postgres&lt;/h4&gt;
&lt;p&gt;The &lt;a href=&quot;https://cocoindex.io/docs-v0/sources/postgres/&quot;&gt;Postgres source&lt;/a&gt; now supports &lt;code&gt;pgvector&lt;/code&gt; types (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1387&quot;&gt;#1387&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;Local files&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;LocalFile&lt;/code&gt; source now follows symlinks. It treats symlinked directories as directories, and it skips broken symlinks with a warning (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1463&quot;&gt;#1463&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;LanceDB&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Calls &lt;code&gt;optimize()&lt;/code&gt; for post-ingest table compaction (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1466&quot;&gt;#1466&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Adds full-text search support in the &lt;a href=&quot;https://cocoindex.io/docs-v0/targets/lancedb/&quot;&gt;LanceDB connector&lt;/a&gt; (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1358&quot;&gt;#1358&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Functions and LLM providers&lt;/h3&gt;
&lt;h4&gt;Azure OpenAI&lt;/h4&gt;
&lt;p&gt;Azure OpenAI is now an LLM provider, so CocoIndex pipelines can use your Azure deployments (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1362&quot;&gt;#1362&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;OpenRouter embeddings&lt;/h4&gt;
&lt;p&gt;OpenRouter now supports embedding models, in addition to LLMs (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1359&quot;&gt;#1359&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;Shared OpenAI and Azure OpenAI code&lt;/h4&gt;
&lt;p&gt;&lt;code&gt;openai.rs&lt;/code&gt; and &lt;code&gt;azureopenai.rs&lt;/code&gt; now share logic (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1376&quot;&gt;#1376&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;&lt;code&gt;expected_output_dimension&lt;/code&gt; for &lt;code&gt;embed_text&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The new parameter is used for validation and the schema, separately from &lt;code&gt;output_dimension&lt;/code&gt;, which goes to the API. Use it with OpenAI-compatible embedding APIs that reject the &lt;code&gt;dimensions&lt;/code&gt; parameter (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1373&quot;&gt;#1373&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;Direct JSON output in functions&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;GeneratedOutput&lt;/code&gt; enum lets functions return structured JSON for downstream use (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1395&quot;&gt;#1395&lt;/a&gt;).&lt;/p&gt;
&lt;h4&gt;Gemini API key fix&lt;/h4&gt;
&lt;p&gt;The Gemini API key now propagates correctly across function calls (&lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1375&quot;&gt;#1375&lt;/a&gt;).&lt;/p&gt;
&lt;h2&gt;Projects built with CocoIndex&lt;/h2&gt;
&lt;p&gt;These 4 projects show CocoIndex pipelines in use.&lt;/p&gt;
&lt;h3&gt;Keep multimodal data fresh with LanceDB&lt;/h3&gt;
&lt;p&gt;Agents that search, reason, and act over long periods need infrastructure that keeps multimodal data fresh.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://lancedb.com&quot;&gt;LanceDB&lt;/a&gt; published a full walkthrough with us that builds a live-updating multimodal search index. Text, images, embeddings, and LLM-derived features stay in sync as data and logic change. The details are in the &lt;a href=&quot;https://lancedb.com/blog/keep-your-data-fresh-with-cocoindex-and-lancedb/&quot;&gt;tutorial&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;What the example covers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Incremental processing&lt;/strong&gt;: Only new or changed records are reprocessed. If you add 1 recipe, update 1 image, or fix 1 ingredient, CocoIndex touches only that change, not the other 100k rows.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multimodal indexing&lt;/strong&gt;: Text, images, embeddings, and metadata live together in LanceDB, which serves both search and analytics.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Schema evolution&lt;/strong&gt;: The example adds LLM-extracted feature columns (vegetarian, dairy, category, etc.) after data is live. CocoIndex updates the schema and backfills, with no table rebuilds.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Structured LLM extraction&lt;/strong&gt;: DSPy signatures define the input and output types, so the LLM returns typed fields.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Upserts and deletes&lt;/strong&gt;: Primary keys and incremental flows prevent duplicates and stale rows, so you maintain no &quot;did this record change?&quot; logic.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lineage and observability&lt;/strong&gt;: CocoInsight shows why a record changed and which transformation produced each field.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Live mode&lt;/strong&gt;: Run the pipeline continuously. As data arrives or logic changes, the search layer updates in near real time.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The same approach applies to PDFs, slides, screenshots, images, videos, and support tickets in enterprise data lakes.&lt;/p&gt;
&lt;h3&gt;Detect trending topics on HackerNews&lt;/h3&gt;
&lt;p&gt;Tracking emerging topics by hand across thousands of HackerNews threads and comments is not practical. This example builds an incremental trending topics pipeline on HackerNews with CocoIndex. It shows how high-volume community data can be incrementally ingested, enriched with LLMs, and queried as structured, up-to-date knowledge.&lt;/p&gt;
&lt;p&gt;An LLM extraction step processes each thread and comment to identify normalized topics (technologies, products, companies, people, etc.). These topics and the original messages are indexed into Postgres as queryable tables. Weighted scoring separates primary topics in threads from secondary mentions in comments, which gives better trend rankings.&lt;/p&gt;
&lt;p&gt;The result is a set of continuously updated tables that dashboards, analytics, or AI agents can query. The details are in the &lt;a href=&quot;https://cocoindex.io/blogs/hackernews-trending-topics&quot;&gt;blog post&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Build a knowledge graph from meeting notes&lt;/h3&gt;
&lt;p&gt;Meeting notes hold decisions, tasks, owners, and relationships, and they change over time. This walkthrough turns meeting notes in Drive into a live-updating knowledge graph using &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex&lt;/a&gt; and LLM extraction. The details are in the &lt;a href=&quot;https://cocoindex.io/examples/meeting_notes_graph&quot;&gt;tutorial&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;What the example covers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Incremental processing&lt;/strong&gt;: Only changed documents are reprocessed. If 1% of thousands of meeting notes change each day, CocoIndex reprocesses only that 1%, which saves 99% of the LLM cost and compute of a full run.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Structured extraction with LLMs&lt;/strong&gt;: A typed Python dataclass is the schema, so the LLM returns structured objects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Graph export&lt;/strong&gt;: CocoIndex maps nodes (Meeting, Person, Task) and relationships (ATTENDED, DECIDED, ASSIGNED_TO) directly into &lt;a href=&quot;https://www.linkedin.com/company/neo4j/&quot;&gt;Neo4j&lt;/a&gt;, with no hand-written Cypher.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Automatic updates&lt;/strong&gt;: If a meeting note changes (task reassigned, typo fixed, new discussion added), the graph updates.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Extract patient intake forms with DSPy&lt;/h3&gt;
&lt;p&gt;Patient intake forms hold structured clinical data, but OCR and regex pipelines do not reliably capture their nested, conditional, and variable structure.&lt;/p&gt;
&lt;p&gt;The &lt;a href=&quot;/blogs/extraction-dspy/&quot;&gt;DSPy and CocoIndex patient form extraction&lt;/a&gt; project extracts typed patient data from PDF intake forms. It uses vision models and Pydantic validation rather than a separate text-extraction step. The output is a set of up-to-date, queryable patient models for downstream systems, analytics, or AI agents. The details are in the &lt;a href=&quot;https://cocoindex.io/examples/patient_form_extraction_dspy&quot;&gt;tutorial&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Thanks to the community&lt;/h2&gt;
&lt;p&gt;Thanks to the contributors below. 8 of them made their first CocoIndex contribution in these releases.&lt;/p&gt;
&lt;p&gt;Thanks for adding Azure OpenAI support as an LLM provider in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1362&quot;&gt;#1362&lt;/a&gt;, enabling enterprise users to use CocoIndex with their Azure deployments.&lt;/p&gt;
&lt;p&gt;Thanks for adding field-level descriptions for data classes in the Product Recommendation example in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1327&quot;&gt;#1327&lt;/a&gt;, making the example more informative and easier to understand.&lt;/p&gt;
&lt;p&gt;Thanks for adding support for embedding models in OpenRouter in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1359&quot;&gt;#1359&lt;/a&gt;, expanding LLM provider options, and fixing typos and consistency issues in the docs in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1360&quot;&gt;#1360&lt;/a&gt;, making the documentation clearer and more polished.&lt;/p&gt;
&lt;p&gt;Thanks for improving the README note for better GitHub rendering in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1288&quot;&gt;#1288&lt;/a&gt;, shifting to the tracing crate for logging in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1363&quot;&gt;#1363&lt;/a&gt;, adding Postgres server reminder to quickstart docs in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1368&quot;&gt;#1368&lt;/a&gt;, fixing the broken workflow badge in README in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1370&quot;&gt;#1370&lt;/a&gt;, introducing a structured error system with host exception tunneling in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1380&quot;&gt;#1380&lt;/a&gt;, adding llms.txt file to docs in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1455&quot;&gt;#1455&lt;/a&gt;, adding short flag aliases for common CLI options in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1458&quot;&gt;#1458&lt;/a&gt;, and adding env file sourcing tip to meeting_notes_graph example in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1470&quot;&gt;#1470&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thanks for making &lt;code&gt;openai.rs&lt;/code&gt; generic to share logic with &lt;code&gt;azureopenai.rs&lt;/code&gt; in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1376&quot;&gt;#1376&lt;/a&gt;, including mypy type checking for the examples directory in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1383&quot;&gt;#1383&lt;/a&gt;, and adding the &lt;code&gt;GeneratedOutput&lt;/code&gt; enum for direct JSON returns in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1395&quot;&gt;#1395&lt;/a&gt;, enhancing type safety and code reusability.&lt;/p&gt;
&lt;p&gt;Thanks for adding &lt;code&gt;onBrokenAnchors&lt;/code&gt; config to report documentation errors in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1325&quot;&gt;#1325&lt;/a&gt;, providing an option to force reprocessing during update in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1385&quot;&gt;#1385&lt;/a&gt;, and making target deletion (drop) tolerate failures in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1454&quot;&gt;#1454&lt;/a&gt;, improving robustness of the data pipeline.&lt;/p&gt;
&lt;p&gt;Thanks for wrapping cargo test to avoid embedded Python stdlib discovery crash in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1398&quot;&gt;#1398&lt;/a&gt;, moving Query Support above Built-in Sources in the docs for better organization in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1397&quot;&gt;#1397&lt;/a&gt;, and adding a warning when live update pass exceeds &lt;code&gt;refresh_interval&lt;/code&gt; in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1408&quot;&gt;#1408&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thanks for adding &lt;code&gt;with_context&lt;/code&gt; to user-configured operations in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1275&quot;&gt;#1275&lt;/a&gt;, enabling context-aware flows for sources, functions, and targets.&lt;/p&gt;
&lt;p&gt;Thanks for adding &lt;code&gt;expected_output_dimension&lt;/code&gt; parameter to &lt;code&gt;embed_text&lt;/code&gt; in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1373&quot;&gt;#1373&lt;/a&gt;, providing more control over embedding output dimensions.&lt;/p&gt;
&lt;p&gt;Thanks for fixing mypy errors in example entry points and adding a local type-check script in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1248&quot;&gt;#1248&lt;/a&gt;, improving code quality and developer experience.&lt;/p&gt;
&lt;p&gt;Thanks for enabling programmatic API key passing besides reading from environment variables in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1134&quot;&gt;#1134&lt;/a&gt;, providing more flexibility in configuration.&lt;/p&gt;
&lt;p&gt;Thanks for enhancing the Button component with hover effects and styling improvements in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1393&quot;&gt;#1393&lt;/a&gt;, making the UI more polished and interactive.&lt;/p&gt;
&lt;p&gt;Thanks for adding &lt;code&gt;VectorIndexMethod&lt;/code&gt; support for HNSW configuration in Qdrant in &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/pull/1410&quot;&gt;#1410&lt;/a&gt;, enabling more fine-grained control over vector indexing parameters.&lt;/p&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;p&gt;This CocoIndex cycle adds structured errors, LLM integrations, and runtime diagnostics.&lt;/p&gt;
&lt;p&gt;CocoIndex v1 has since shipped and replaces the v0 API used on this page. The v1 release notes start with &lt;a href=&quot;/blogs/changelog-101-107/&quot;&gt;CocoIndex 1.0.1 to 1.0.7&lt;/a&gt;; all release notes are under the &lt;a href=&quot;/blogs/tags/changelog/&quot;&gt;changelog tag&lt;/a&gt;.&lt;/p&gt;
</content:encoded><category>changelog</category><category>connectors</category><category>structured-extraction</category><category>knowledge-graph</category><author>George He</author></item><item><title>Extract Patient Intake Forms with DSPy and CocoIndex</title><link>https://cocoindex.io/blogs/extraction-dspy/</link><guid isPermaLink="true">https://cocoindex.io/blogs/extraction-dspy/</guid><description>Extract Pydantic-typed patient records from PDF intake forms with DSPy and Gemini vision into Postgres with pgvector, and see which edits re-run extraction.</description><pubDate>Mon, 15 Dec 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This post extracts typed patient records from PDF intake forms with &lt;a href=&quot;https://github.com/stanfordnlp/dspy&quot;&gt;DSPy&lt;/a&gt; and &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex&quot;&gt;CocoIndex&lt;/a&gt;. DSPy declares the extraction as a typed signature over page images, and Gemini 2.5 Flash reads the pages. CocoIndex runs the extraction once per PDF and keeps one Postgres row per form in step with the folder, with a &lt;a href=&quot;https://github.com/pgvector/pgvector&quot;&gt;pgvector&lt;/a&gt; embedding of the visit for search.&lt;/p&gt;
&lt;p&gt;DSPy replaces hand-written prompts with a programming model. You declare what an LLM step takes and returns (a signature) and pick a strategy (a module such as &lt;code&gt;ChainOfThought&lt;/code&gt;); DSPy writes the prompt and parses the answer into your types. The same signature can later be tuned with DSPy&apos;s optimizers.&lt;/p&gt;
&lt;p&gt;The post covers the DSPy side: the Pydantic models, the signature and module, the page images the model sees, and which edits make CocoIndex re-run the extraction. The CocoIndex app is the same as in the &lt;a href=&quot;https://cocoindex.io/blogs/extraction-baml/&quot;&gt;BAML version&lt;/a&gt; of this post, so it is shown once, in a collapsed block. For a no-framework baseline and a comparison of plain prompts, BAML, DSPy and a local Ollama model, see &lt;a href=&quot;https://cocoindex.io/blogs/patient-intake-form-extraction-with-llm/&quot;&gt;Extract patient intake forms with an LLM&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The Pydantic models, the DSPy signature and module, and the PDF-to-image step come from the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/patient_intake_extraction_dspy&quot;&gt;DSPy patient intake example&lt;/a&gt; in the CocoIndex repo (Apache 2.0), which runs on CocoIndex v1 and writes one JSON file per form. This post writes to Postgres instead and adds the embedding.&lt;/p&gt;
&lt;h2&gt;DSPy and BAML on this task&lt;/h2&gt;
&lt;p&gt;The two versions share the CocoIndex app and differ in the extraction layer:&lt;/p&gt;
&lt;p&gt;DSPy is built around Python modules and optimizer-driven prompt tuning. BAML is built around a typed prompt language, schema checks, and generated clients for several languages.&lt;/p&gt;
&lt;h2&gt;What you build&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Read the PDF intake forms from a local directory.&lt;/li&gt;
&lt;li&gt;For each PDF, render the pages to images, run the DSPy extractor to get a &lt;code&gt;Patient&lt;/code&gt;, and embed a short summary of the visit.&lt;/li&gt;
&lt;li&gt;Write one row per form to a Postgres table: a few columns for the key fields, the whole &lt;code&gt;Patient&lt;/code&gt; as &lt;code&gt;jsonb&lt;/code&gt;, and the embedding as a pgvector &lt;code&gt;vector&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Prerequisites&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Run Postgres with the pgvector extension. With Docker:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;docker run -d --name pgvector -p 5432:5432 \
  -e POSTGRES_USER=cocoindex -e POSTGRES_PASSWORD=cocoindex -e POSTGRES_DB=cocoindex \
  pgvector/pgvector:pg17
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Install CocoIndex with its Postgres and sentence-transformers extras, and the other dependencies:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pip install -U &quot;cocoindex[postgres,sentence_transformers]&quot; dspy-ai pydantic pymupdf pillow pgvector python-dotenv
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a &lt;code&gt;.env&lt;/code&gt; file in the project directory. &lt;code&gt;COCOINDEX_DB&lt;/code&gt; is the local file where CocoIndex keeps its state between runs, and &lt;code&gt;POSTGRES_URL&lt;/code&gt; is the database that holds the &lt;code&gt;patients_dspy&lt;/code&gt; table:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;COCOINDEX_DB=./cocoindex.db
POSTGRES_URL=postgres://cocoindex:cocoindex@localhost/cocoindex
GEMINI_API_KEY=your_api_key_here
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Copy a few intake forms to &lt;code&gt;data/patient_forms/&lt;/code&gt;. The example ships 4 artificial PDFs in that folder.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Define &lt;code&gt;Patient&lt;/code&gt; in &lt;code&gt;models.py&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;The Pydantic classes follow a FHIR-inspired patient schema. &lt;code&gt;Patient&lt;/code&gt; nests the others: an &lt;code&gt;Address&lt;/code&gt;, lists of &lt;code&gt;Condition&lt;/code&gt;, &lt;code&gt;Medication&lt;/code&gt;, &lt;code&gt;Allergy&lt;/code&gt; and &lt;code&gt;Surgery&lt;/code&gt;, and an optional &lt;code&gt;Insurance&lt;/code&gt; and &lt;code&gt;Pharmacy&lt;/code&gt;, where &lt;code&gt;Pharmacy&lt;/code&gt; has an &lt;code&gt;Address&lt;/code&gt; of its own.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&quot;&quot;&quot;Pydantic models for patient intake form extraction.&quot;&quot;&quot;

from __future__ import annotations

import datetime

from pydantic import BaseModel, Field

class Contact(BaseModel):
    &quot;&quot;&quot;Emergency contact information.&quot;&quot;&quot;

    name: str
    phone: str
    relationship: str

class Address(BaseModel):
    &quot;&quot;&quot;Physical address.&quot;&quot;&quot;

    street: str
    city: str
    state: str
    zip_code: str

class Pharmacy(BaseModel):
    &quot;&quot;&quot;Pharmacy information.&quot;&quot;&quot;

    name: str
    phone: str
    address: Address

class Insurance(BaseModel):
    &quot;&quot;&quot;Insurance information.&quot;&quot;&quot;

    provider: str
    policy_number: str
    group_number: str | None = None
    policyholder_name: str
    relationship_to_patient: str

class Condition(BaseModel):
    &quot;&quot;&quot;Medical condition.&quot;&quot;&quot;

    name: str
    diagnosed: bool

class Medication(BaseModel):
    &quot;&quot;&quot;Current medication.&quot;&quot;&quot;

    name: str
    dosage: str

class Allergy(BaseModel):
    &quot;&quot;&quot;Known allergy.&quot;&quot;&quot;

    name: str

class Surgery(BaseModel):
    &quot;&quot;&quot;Past surgery.&quot;&quot;&quot;

    name: str
    date: str

class Patient(BaseModel):
    &quot;&quot;&quot;Complete patient information extracted from intake form.&quot;&quot;&quot;

    name: str
    dob: datetime.date
    gender: str
    address: Address
    phone: str
    email: str
    preferred_contact_method: str
    emergency_contact: Contact
    insurance: Insurance | None = None
    reason_for_visit: str
    symptoms_duration: str
    past_conditions: list[Condition] = Field(default_factory=list)
    current_medications: list[Medication] = Field(default_factory=list)
    allergies: list[Allergy] = Field(default_factory=list)
    surgeries: list[Surgery] = Field(default_factory=list)
    occupation: str | None = None
    pharmacy: Pharmacy | None = None
    consent_given: bool
    consent_date: str | None = None
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The models do more than describe the shape:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Validation.&lt;/strong&gt; Pydantic checks every field&apos;s type, so &lt;code&gt;dob&lt;/code&gt; has to parse as a &lt;code&gt;datetime.date&lt;/code&gt;, and it raises if the model returns data that does not fit.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Defaults.&lt;/strong&gt; &lt;code&gt;Field(default_factory=list)&lt;/code&gt; gives an empty list when a form lists no conditions or medications.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Serialization.&lt;/strong&gt; &lt;code&gt;model_dump(mode=&quot;json&quot;)&lt;/code&gt; turns the record into JSON values for the database, with &lt;code&gt;dob&lt;/code&gt; as an ISO date string such as &lt;code&gt;&quot;1992-07-22&quot;&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;The DSPy signature and module&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;PatientExtractionSignature&lt;/code&gt; is a &lt;code&gt;dspy.Signature&lt;/code&gt;: it declares the inputs and outputs of the LLM step and leaves the prompt to DSPy.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# DSPy Signature for patient information extraction from images
class PatientExtractionSignature(dspy.Signature):
    &quot;&quot;&quot;Extract structured patient information from a medical intake form image.&quot;&quot;&quot;

    form_images: list[dspy.Image] = dspy.InputField(
        desc=&quot;Images of the patient intake form pages&quot;
    )
    patient: Patient = dspy.OutputField(
        desc=&quot;Extracted patient information with all available fields filled&quot;
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;The input &lt;code&gt;form_images&lt;/code&gt; is a list of page images.&lt;/li&gt;
&lt;li&gt;The output &lt;code&gt;patient&lt;/code&gt; is typed as the Pydantic &lt;code&gt;Patient&lt;/code&gt;, so DSPy parses the answer into that class.&lt;/li&gt;
&lt;li&gt;The docstring and the &lt;code&gt;desc&lt;/code&gt; strings go into the prompt DSPy writes.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;PatientExtractor&lt;/code&gt; is a &lt;code&gt;dspy.Module&lt;/code&gt;, the unit DSPy composes and optimizes. It implements the signature with &lt;code&gt;ChainOfThought&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;class PatientExtractor(dspy.Module):
    &quot;&quot;&quot;DSPy module for extracting patient information from intake form images.&quot;&quot;&quot;

    def __init__(self) -&amp;gt; None:
        super().__init__()
        self.extract = dspy.ChainOfThought(PatientExtractionSignature)

    def forward(self, form_images: list[dspy.Image]) -&amp;gt; Patient:
        &quot;&quot;&quot;Extract patient information from form images and return as a Pydantic model.&quot;&quot;&quot;
        result = self.extract(form_images=form_images)
        return result.patient
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;ChainOfThought&lt;/code&gt; asks the model to reason about the page images before it fills in &lt;code&gt;patient&lt;/code&gt;. &lt;code&gt;forward&lt;/code&gt; is DSPy&apos;s standard entry point: calling the module runs it, and it returns the validated &lt;code&gt;Patient&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Render the pages and run the module&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;extract_patient&lt;/code&gt; is the only place the CocoIndex app touches DSPy: PDF bytes in, a &lt;code&gt;Patient&lt;/code&gt; out. It opens the PDF with PyMuPDF, renders each page at 2x (&lt;code&gt;pymupdf.Matrix(2, 2)&lt;/code&gt;) so small print stays legible, wraps each PNG in a &lt;code&gt;dspy.Image&lt;/code&gt;, and passes the list to the module in one call.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn
def extract_patient(pdf_content: bytes) -&amp;gt; Patient:
    &quot;&quot;&quot;Extract patient information from PDF content.&quot;&quot;&quot;
    pdf_doc = pymupdf.open(stream=pdf_content, filetype=&quot;pdf&quot;)

    form_images = []
    for page in pdf_doc:
        pix = page.get_pixmap(matrix=pymupdf.Matrix(2, 2))
        img_bytes = pix.tobytes(&quot;png&quot;)
        form_images.append(dspy.Image(img_bytes))

    pdf_doc.close()

    extractor = PatientExtractor()
    patient = extractor(form_images=form_images)
    return patient
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For the 4 sample forms, these are the pages the model gets:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/&quot;&gt;&lt;code&gt;@coco.fn&lt;/code&gt;&lt;/a&gt; puts the function&apos;s source under CocoIndex&apos;s change tracking. &lt;code&gt;models.py&lt;/code&gt;, the DSPy classes, and the &lt;code&gt;dspy.LM(...)&lt;/code&gt; setting are not in that source, which matters for &lt;a href=&quot;#what-invalidates-the-cache&quot;&gt;caching&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;The CocoIndex app&lt;/h2&gt;
&lt;p&gt;The rest of &lt;code&gt;main.py&lt;/code&gt; is the same app as in the BAML post, apart from the imports, the extraction call, and the table name. Three parts carry it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;process_patient_form&lt;/code&gt;&lt;/strong&gt;, decorated with &lt;code&gt;@coco.fn(memo=True)&lt;/code&gt;, runs once per PDF: it calls &lt;code&gt;extract_patient&lt;/code&gt;, embeds a short visit summary, and declares one row with &lt;code&gt;table.declare_row&lt;/code&gt;. If the PDF&apos;s bytes and the code of the functions it calls are unchanged, the next run skips it, with no rendering, no Gemini call, and no embedding.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;PatientRow&lt;/code&gt;&lt;/strong&gt; is the table schema. &lt;code&gt;patient_info: dict[str, Any]&lt;/code&gt; becomes a &lt;code&gt;jsonb&lt;/code&gt; column, and the &lt;code&gt;embedding&lt;/code&gt; field, annotated with the embedder, becomes a &lt;code&gt;vector(384)&lt;/code&gt; column.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;app_main&lt;/code&gt;&lt;/strong&gt; mounts the &lt;code&gt;patients_dspy&lt;/code&gt; table with &lt;a href=&quot;https://cocoindex.io/docs/connectors/postgres/&quot;&gt;&lt;code&gt;postgres.mount_table_target&lt;/code&gt;&lt;/a&gt;, walks &lt;code&gt;data/patient_forms/&lt;/code&gt; with &lt;a href=&quot;https://cocoindex.io/docs/connectors/localfs/&quot;&gt;&lt;code&gt;localfs.walk_dir&lt;/code&gt;&lt;/a&gt;, and mounts one &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/&quot;&gt;processing component&lt;/a&gt; per file with &lt;code&gt;coco.mount_each&lt;/code&gt;. A row is a &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;target state&lt;/a&gt;: CocoIndex inserts, updates, or deletes it to match what the components declare.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;dspy.LM(&quot;gemini/gemini-2.5-flash&quot;)&lt;/code&gt; is configured once, when &lt;code&gt;main.py&lt;/code&gt; loads, and reads &lt;code&gt;GEMINI_API_KEY&lt;/code&gt; from the environment.&lt;/p&gt;

The full &lt;code&gt;main.py&lt;/code&gt; (imports, row schema, DSPy classes, per-form component, app, search)
&lt;pre&gt;&lt;code&gt;from __future__ import annotations

import asyncio
import os
import pathlib
import sys
from dataclasses import dataclass
from typing import Annotated, Any, AsyncIterator

import asyncpg
import dspy
import pymupdf
from dotenv import load_dotenv
from numpy.typing import NDArray
from pgvector.asyncpg import register_vector

import cocoindex as coco
from cocoindex.connectors import localfs, postgres
from cocoindex.ops.sentence_transformers import SentenceTransformerEmbedder
from cocoindex.resources.file import FileLike, PatternFilePathMatcher

from models import Patient

DATABASE_URL = os.getenv(
    &quot;POSTGRES_URL&quot;, &quot;postgres://cocoindex:cocoindex@localhost/cocoindex&quot;
)
EMBED_MODEL = &quot;sentence-transformers/all-MiniLM-L6-v2&quot;
TABLE_NAME = &quot;patients_dspy&quot;

PG_DB = coco.ContextKey[asyncpg.Pool](&quot;patient_intake_db&quot;)
EMBEDDER = coco.ContextKey[SentenceTransformerEmbedder](&quot;embedder&quot;, detect_change=True)

@dataclass
class PatientRow:
    filename: str
    name: str
    reason_for_visit: str
    patient_info: dict[str, Any]
    embedding: Annotated[NDArray, EMBEDDER]

@coco.lifespan
async def coco_lifespan(builder: coco.EnvironmentBuilder) -&amp;gt; AsyncIterator[None]:
    async with asyncpg.create_pool(DATABASE_URL) as pool:
        builder.provide(PG_DB, pool)
        builder.provide(EMBEDDER, SentenceTransformerEmbedder(EMBED_MODEL))
        yield

# DSPy Signature for patient information extraction from images
class PatientExtractionSignature(dspy.Signature):
    &quot;&quot;&quot;Extract structured patient information from a medical intake form image.&quot;&quot;&quot;

    form_images: list[dspy.Image] = dspy.InputField(
        desc=&quot;Images of the patient intake form pages&quot;
    )
    patient: Patient = dspy.OutputField(
        desc=&quot;Extracted patient information with all available fields filled&quot;
    )

class PatientExtractor(dspy.Module):
    &quot;&quot;&quot;DSPy module for extracting patient information from intake form images.&quot;&quot;&quot;

    def __init__(self) -&amp;gt; None:
        super().__init__()
        self.extract = dspy.ChainOfThought(PatientExtractionSignature)

    def forward(self, form_images: list[dspy.Image]) -&amp;gt; Patient:
        &quot;&quot;&quot;Extract patient information from form images and return as a Pydantic model.&quot;&quot;&quot;
        result = self.extract(form_images=form_images)
        return result.patient

@coco.fn
def extract_patient(pdf_content: bytes) -&amp;gt; Patient:
    &quot;&quot;&quot;Extract patient information from PDF content.&quot;&quot;&quot;
    pdf_doc = pymupdf.open(stream=pdf_content, filetype=&quot;pdf&quot;)

    form_images = []
    for page in pdf_doc:
        pix = page.get_pixmap(matrix=pymupdf.Matrix(2, 2))
        img_bytes = pix.tobytes(&quot;png&quot;)
        form_images.append(dspy.Image(img_bytes))

    pdf_doc.close()

    extractor = PatientExtractor()
    patient = extractor(form_images=form_images)
    return patient

@coco.fn
def visit_summary(patient: Patient) -&amp;gt; str:
    &quot;&quot;&quot;The text to embed: why the patient came in, and their history.&quot;&quot;&quot;
    conditions = &quot;, &quot;.join(c.name for c in patient.past_conditions)
    medications = &quot;, &quot;.join(m.name for m in patient.current_medications)
    return (
        f&quot;Reason for visit: {patient.reason_for_visit}\n&quot;
        f&quot;Symptoms duration: {patient.symptoms_duration}\n&quot;
        f&quot;Past conditions: {conditions}\n&quot;
        f&quot;Current medications: {medications}&quot;
    )

@coco.fn(memo=True)
async def process_patient_form(
    file: FileLike, table: postgres.TableTarget[PatientRow]
) -&amp;gt; None:
    &quot;&quot;&quot;Extract one intake form, embed its visit summary, and declare its row.&quot;&quot;&quot;
    content = await file.read()
    patient_info = extract_patient(content)
    embedding = await coco.use_context(EMBEDDER).embed(visit_summary(patient_info))
    table.declare_row(
        row=PatientRow(
            filename=file.file_path.path.name,
            name=patient_info.name,
            reason_for_visit=patient_info.reason_for_visit,
            patient_info=patient_info.model_dump(mode=&quot;json&quot;),
            embedding=embedding,
        ),
    )

@coco.fn
async def app_main(sourcedir: pathlib.Path) -&amp;gt; None:
    &quot;&quot;&quot;Main application function that processes patient intake forms.&quot;&quot;&quot;
    table = await postgres.mount_table_target(
        PG_DB,
        table_name=TABLE_NAME,
        table_schema=await postgres.TableSchema.from_class(
            PatientRow, primary_key=[&quot;filename&quot;]
        ),
    )
    files = localfs.walk_dir(
        sourcedir,
        path_matcher=PatternFilePathMatcher(included_patterns=[&quot;**/*.pdf&quot;]),
    )
    await coco.mount_each(process_patient_form, files.items(), table)

lm = dspy.LM(&quot;gemini/gemini-2.5-flash&quot;)
dspy.configure(lm=lm)

app = coco.App(
    coco.AppConfig(name=&quot;PatientIntakeExtractionDSPy&quot;),
    app_main,
    sourcedir=pathlib.Path(&quot;./data/patient_forms&quot;),
)

async def search(query: str, top_k: int = 3) -&amp;gt; None:
    embedder = SentenceTransformerEmbedder(EMBED_MODEL)
    query_vec = await embedder.embed(query)
    async with asyncpg.create_pool(DATABASE_URL, init=register_vector) as pool:
        rows = await pool.fetch(
            f&quot;&quot;&quot;
            SELECT name, reason_for_visit, embedding &amp;lt;=&amp;gt; $1 AS distance
            FROM {TABLE_NAME}
            ORDER BY distance
            LIMIT $2
            &quot;&quot;&quot;,
            query_vec,
            top_k,
        )
    for r in rows:
        print(f&quot;[{1.0 - r[&apos;distance&apos;]:.3f}] {r[&apos;name&apos;]}: {r[&apos;reason_for_visit&apos;]}&quot;)

if __name__ == &quot;__main__&quot;:
    load_dotenv()
    asyncio.run(search(&quot; &quot;.join(sys.argv[1:])))
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can read from other sources too, for example &lt;a href=&quot;https://cocoindex.io/docs/connectors/amazon_s3/&quot;&gt;Amazon S3&lt;/a&gt; or &lt;a href=&quot;https://cocoindex.io/docs/connectors/google_drive/&quot;&gt;Google Drive&lt;/a&gt;. To keep the table updated as files change, see &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/live_mode/&quot;&gt;live mode&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Run it&lt;/h2&gt;
&lt;p&gt;Run the app. The update scans the forms, extracts, embeds, writes the rows, and exits:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cocoindex update main.py
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;patients_dspy&lt;/code&gt; table now has one row per form, and &lt;code&gt;patient_info&lt;/code&gt; holds the full record, so Postgres can query any field in it, for example &lt;code&gt;patient_info-&amp;gt;&amp;gt;&apos;dob&apos;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;python main.py &quot;&amp;lt;query&amp;gt;&quot;&lt;/code&gt; runs the search at the end of &lt;code&gt;main.py&lt;/code&gt;. It embeds the query with the same model and prints the 3 nearest forms, ordered by pgvector&apos;s cosine distance (&lt;code&gt;&amp;lt;=&amp;gt;&lt;/code&gt;), with &lt;code&gt;1 - distance&lt;/code&gt; as the score:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;python main.py &quot;headache&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The DSPy signature has no rule for missing fields (the BAML prompt asks for &lt;code&gt;&quot;N/A&quot;&lt;/code&gt;), so what a sparse form such as Jane Doe&apos;s returns for &lt;code&gt;reason_for_visit&lt;/code&gt; depends on the model. The &lt;a href=&quot;https://cocoindex.io/blogs/extraction-baml/#run-it&quot;&gt;BAML post&lt;/a&gt; shows sample scores for the same search.&lt;/p&gt;
&lt;h2&gt;What invalidates the cache&lt;/h2&gt;
&lt;p&gt;Run &lt;code&gt;cocoindex update main.py&lt;/code&gt; again after a change, and CocoIndex re-runs only the forms the change affects. Which edits count depends on what CocoIndex can see. Pick one:&lt;/p&gt;
&lt;p&gt;We checked the PDF, code, &lt;code&gt;models.py&lt;/code&gt; and &lt;code&gt;dspy.LM&lt;/code&gt; cases above against the same Postgres table, and these three as well:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Nothing changed:&lt;/strong&gt; every form is a cache hit, and the run makes no LLM call.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A form is added:&lt;/strong&gt; only that PDF is rendered, extracted, and embedded, and its row is inserted.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A form is deleted:&lt;/strong&gt; its component is not mounted on the next run, so CocoIndex deletes the row it declared.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;CocoIndex &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#change-detection&quot;&gt;tracks the source of &lt;code&gt;@coco.fn&lt;/code&gt; functions&lt;/a&gt; and the context values read with &lt;code&gt;detect_change=True&lt;/code&gt;; the Pydantic models, the DSPy classes, and the module-level &lt;code&gt;dspy.LM&lt;/code&gt; are plain Python outside them. To re-extract after such a change, do one of these:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Run &lt;code&gt;cocoindex update main.py --full-reprocess&lt;/code&gt; once, which bypasses every cache for that run.&lt;/li&gt;
&lt;li&gt;Add &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#version&quot;&gt;&lt;code&gt;version=&lt;/code&gt;&lt;/a&gt; to &lt;code&gt;@coco.fn&lt;/code&gt; on &lt;code&gt;extract_patient&lt;/code&gt; and increase it with each change. With &lt;code&gt;version&lt;/code&gt; set, CocoIndex tracks that number instead of the function&apos;s source code.&lt;/li&gt;
&lt;li&gt;For the model, pass its name as &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/#deps&quot;&gt;&lt;code&gt;deps=&lt;/code&gt;&lt;/a&gt;: set &lt;code&gt;LM_NAME = &quot;gemini/gemini-2.5-flash&quot;&lt;/code&gt;, configure &lt;code&gt;dspy.LM(LM_NAME)&lt;/code&gt;, and decorate &lt;code&gt;extract_patient&lt;/code&gt; with &lt;code&gt;@coco.fn(deps=LM_NAME)&lt;/code&gt;. A new name then re-runs every form.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Related&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/blogs/patient-intake-form-extraction-with-llm/&quot;&gt;Extract patient intake forms with an LLM&lt;/a&gt;: the no-framework baseline, and how BAML, DSPy and Ollama compare on this task.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://cocoindex.io/blogs/extraction-baml/&quot;&gt;The BAML version&lt;/a&gt;: the same app with a BAML schema and prompt, and the &lt;code&gt;role(&quot;user&quot;)&lt;/code&gt; gotcha for PDF input on OpenAI.&lt;/li&gt;
&lt;li&gt;The &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/patient_intake_extraction_dspy&quot;&gt;example in the CocoIndex repo&lt;/a&gt;, with a &lt;a href=&quot;https://cocoindex.io/docs/examples/patient-intake-dspy/&quot;&gt;walkthrough in the docs&lt;/a&gt; that writes JSON files instead of a table.&lt;/li&gt;
&lt;/ul&gt;
</content:encoded><category>examples</category><category>tutorial</category><category>structured-extraction</category><category>multimodal</category><category>llm</category><author>Linghua Jin</author></item><item><title>Build a Knowledge Graph from Meeting Notes with Neo4j</title><link>https://cocoindex.io/blogs/meeting-notes-graph/</link><guid isPermaLink="true">https://cocoindex.io/blogs/meeting-notes-graph/</guid><description>Build a self-updating Neo4j knowledge graph from meeting notes with CocoIndex v1: LLM-extracted decisions, tasks, and owners, with embedding-based dedupe.</description><pubDate>Mon, 08 Dec 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This post builds a Neo4j graph of meetings, people and tasks from Markdown meeting notes in Google Drive. Each update re-extracts only the notes that changed. An agent can then answer &lt;em&gt;&quot;Who attended the budget planning meetings?&quot;&lt;/em&gt; or &lt;em&gt;&quot;What tasks did Sarah get assigned across every meeting?&quot;&lt;/em&gt; with one Cypher query over every note.&lt;/p&gt;
&lt;p&gt;The pipeline is the &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/meeting_notes_graph_neo4j&quot;&gt;&lt;code&gt;meeting_notes_graph_neo4j&lt;/code&gt;&lt;/a&gt; example. It splits each note into meetings, extracts structure with an LLM, merges the different spellings of a person&apos;s name with embedding-based entity resolution, and writes the graph to Neo4j.&lt;/p&gt;
&lt;p&gt;The basics (Neo4j as a target, nodes keyed by a primary key, a two-phase build) are covered in &lt;a href=&quot;/blogs/knowledge-graph-for-docs/&quot;&gt;Build a knowledge graph from documents&lt;/a&gt;. This post focuses on what meeting notes add: one file holds several meetings, and the same person appears under several names.&lt;/p&gt;
&lt;p&gt;The code uses the Neo4j node and relationship API from CocoIndex 1.1.0 (&lt;code&gt;mount_node_target&lt;/code&gt;, &lt;code&gt;mount_relationship_target&lt;/code&gt;, &lt;code&gt;declare_relationship&lt;/code&gt;), the same as the example on GitHub. If your code still calls the deprecated &lt;code&gt;mount_table_target&lt;/code&gt; and &lt;code&gt;mount_relation_target&lt;/code&gt;, the &lt;a href=&quot;https://cocoindex.io/docs/connectors/neo4j/#deprecated-table-and-relation-apis&quot;&gt;Neo4j connector docs&lt;/a&gt; map each old name to its replacement.&lt;/p&gt;
&lt;h2&gt;Why an agent needs a graph of its meetings&lt;/h2&gt;
&lt;h2&gt;Three spellings, one Person node&lt;/h2&gt;
&lt;p&gt;The demo runs the post&apos;s pipeline on 3 sample notes. Move the threshold to change which name pairs become candidates, ask the LLM to confirm them, then edit one note and see what the next update writes.&lt;/p&gt;
&lt;p&gt;At the default threshold of 0.70, the 2 pairs that contain &quot;Sarah Chen&quot; become candidates and the LLM confirms both, so &quot;Sarah&quot; and &quot;S. Chen&quot; fold into one Person node. Each ATTENDED and ASSIGNED_TO relationship that pointed at an old spelling now points at Sarah Chen. A lower threshold sends more pairs to the LLM, including pairs such as Alex and Sarah that it rejects; a higher one leaves &quot;S. Chen&quot; as a separate person.&lt;/p&gt;
&lt;p&gt;The edit shows the incremental side. Only the changed note goes back to the LLM. The set of raw names is the same, so resolution is a cache hit, and Neo4j receives one deleted and one created ASSIGNED_TO relationship.&lt;/p&gt;
&lt;h2&gt;The graph: 3 node labels, 3 relationship types&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Nodes&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;Meeting&lt;/code&gt;&lt;/strong&gt;: one per meeting section, with its date and notes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;Person&lt;/code&gt;&lt;/strong&gt;: one per canonical person (organizer, participant, or task assignee)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;Task&lt;/code&gt;&lt;/strong&gt;: an action item decided in a meeting&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Relationships&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;ATTENDED&lt;/code&gt;&lt;/strong&gt;: &lt;code&gt;Person → Meeting&lt;/code&gt;, with an &lt;code&gt;is_organizer&lt;/code&gt; property&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;DECIDED&lt;/code&gt;&lt;/strong&gt;: &lt;code&gt;Meeting → Task&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;ASSIGNED_TO&lt;/code&gt;&lt;/strong&gt;: &lt;code&gt;Person → Task&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/target_state/&quot;&gt;target state docs&lt;/a&gt; explain how CocoIndex reconciles declared nodes and relationships with what is already in the database.&lt;/p&gt;
&lt;h2&gt;Define the pipeline&lt;/h2&gt;
&lt;p&gt;The whole example is one &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/blob/main/examples/meeting_notes_graph_neo4j/main.py&quot;&gt;&lt;code&gt;main.py&lt;/code&gt;&lt;/a&gt; with a &lt;code&gt;coco.App&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import cocoindex as coco
from cocoindex.connectors import google_drive, neo4j
from cocoindex.ops.entity_resolution import ResolvedEntities, resolve_entities
from cocoindex.ops.entity_resolution.llm_resolver import LlmPairResolver
from cocoindex.ops.sentence_transformers import SentenceTransformerEmbedder
from cocoindex.resources.id import IdGenerator

app = coco.App(coco.AppConfig(name=&quot;MeetingNotesGraphNeo4j&quot;), app_main)
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Shared resources&lt;/h3&gt;
&lt;p&gt;The lifespan provides the Neo4j connection, the two LLM model names and the embedder, and code reads them with &lt;code&gt;coco.use_context&lt;/code&gt;. This is the same pattern as the documents post, with two additions for entity resolution: a resolution model and an embedder.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;KG_DB = coco.ContextKey[neo4j.ConnectionFactory](&quot;kg_db&quot;)
LLM_MODEL = coco.ContextKey[str](&quot;llm_model&quot;, detect_change=True)
RESOLUTION_LLM_MODEL = coco.ContextKey[str](&quot;resolution_llm_model&quot;, detect_change=True)
EMBEDDER = coco.ContextKey[SentenceTransformerEmbedder](&quot;embedder&quot;, detect_change=True)

@coco.lifespan
async def coco_lifespan(builder: coco.EnvironmentBuilder) -&amp;gt; AsyncIterator[None]:
    kg_db = neo4j.ConnectionFactory(
        uri=os.environ.get(&quot;NEO4J_URI&quot;, &quot;bolt://localhost:7687&quot;),
        auth=(
            os.environ.get(&quot;NEO4J_USER&quot;, &quot;neo4j&quot;),
            os.environ.get(&quot;NEO4J_PASSWORD&quot;, &quot;cocoindex&quot;),
        ),
        database=os.environ.get(&quot;NEO4J_DATABASE&quot;, &quot;neo4j&quot;),
    )
    builder.provide(KG_DB, kg_db)
    builder.provide(LLM_MODEL, os.environ.get(&quot;LLM_MODEL&quot;, &quot;openai/gpt-5-mini&quot;))
    builder.provide(
        RESOLUTION_LLM_MODEL,
        os.environ.get(&quot;RESOLUTION_LLM_MODEL&quot;, &quot;openai/gpt-5-mini&quot;),
    )
    builder.provide(
        EMBEDDER,
        SentenceTransformerEmbedder(&quot;Snowflake/snowflake-arctic-embed-xs&quot;),
    )
    yield
    await kg_db.close()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;detect_change=True&lt;/code&gt; means that swapping a model or the embedder re-runs only the steps that use it.&lt;/p&gt;
&lt;h3&gt;Node and relationship schemas&lt;/h3&gt;
&lt;p&gt;Node rows are plain dataclasses. The primary key of each becomes the node&apos;s identity in Neo4j, so a re-run updates the existing node instead of adding a second one:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@dataclass
class Meeting:
    id: int
    note_file: str
    time: datetime.date
    note: str

@dataclass
class Person:
    name: str  # canonical

@dataclass
class Task:
    description: str

@dataclass
class AttendedRel:
    is_organizer: bool
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;AttendedRel&lt;/code&gt; holds the properties of an &lt;code&gt;ATTENDED&lt;/code&gt; relationship. &lt;code&gt;DECIDED&lt;/code&gt; and &lt;code&gt;ASSIGNED_TO&lt;/code&gt; have no properties, so they are declared without a record. A relationship without a record key gets an id derived from its two endpoints, so there is one relationship per endpoint pair. The &lt;a href=&quot;#the-graph-3-node-labels-3-relationship-types&quot;&gt;schema figure&lt;/a&gt; above shows the mapping.&lt;/p&gt;
&lt;h3&gt;The extraction schema&lt;/h3&gt;
&lt;p&gt;The LLM&apos;s output schema is a set of Pydantic models. &lt;code&gt;instructor&lt;/code&gt; passes them as the response schema, so the model returns data that matches these types:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;class ExtractedPerson(pydantic.BaseModel):
    name: str = pydantic.Field(
        description=&quot;Full name of the person, as written in the note.&quot;
    )

class ExtractedTask(pydantic.BaseModel):
    description: str = pydantic.Field(
        description=&quot;Concise, standalone description of the task or action item.&quot;
    )
    assigned_to: list[ExtractedPerson] = pydantic.Field(default_factory=list)

class ExtractedMeeting(pydantic.BaseModel):
    time: datetime.date
    note: str
    organizer: ExtractedPerson
    participants: list[ExtractedPerson] = pydantic.Field(default_factory=list)
    tasks: list[ExtractedTask] = pydantic.Field(default_factory=list)
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Split, then extract&lt;/h3&gt;
&lt;p&gt;A single note file often holds several meetings. &lt;code&gt;_split_meetings&lt;/code&gt; breaks the text at Markdown headings (&lt;code&gt;#&lt;/code&gt; or &lt;code&gt;##&lt;/code&gt;) so each section becomes one meeting:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;_HEADING_RE = re.compile(r&quot;\n\n##?\s+&quot;)

def _split_meetings(text: str) -&amp;gt; list[str]:
    parts = _HEADING_RE.split(&quot;\n\n&quot; + text)
    return [p.strip() for p in parts if p.strip()]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each section goes to &lt;code&gt;extract_meeting&lt;/code&gt;, which calls the model through LiteLLM and &lt;code&gt;instructor&lt;/code&gt;. The model comes from the &lt;code&gt;LLM_MODEL&lt;/code&gt; context (default &lt;code&gt;openai/gpt-5-mini&lt;/code&gt;). With &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/function/&quot;&gt;&lt;code&gt;memo=True&lt;/code&gt;&lt;/a&gt;, the result is cached, so a section whose text and model are unchanged is not sent to the LLM again:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def extract_meeting(section_text: str) -&amp;gt; ExtractedMeeting:
    client = instructor.from_litellm(litellm.acompletion, mode=instructor.Mode.JSON)
    result = await client.chat.completions.create(
        model=coco.use_context(LLM_MODEL),
        response_model=ExtractedMeeting,
        messages=[
            {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: EXTRACT_PROMPT},
            {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: section_text},
        ],
    )
    return ExtractedMeeting.model_validate(result.model_dump())
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Three phases&lt;/h2&gt;
&lt;p&gt;A Person node needs a canonical name, and a canonical name needs every raw name in the corpus. So the pipeline runs in three phases: phase 1 extracts each file and declares what it can on its own, phase 2 resolves person names across all files, and phase 3 declares the Person nodes and the relationships that touch people.&lt;/p&gt;
&lt;h3&gt;Phase 1: per-file extraction&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;process_file&lt;/code&gt; reads a Drive file, splits it, and for each meeting declares a &lt;code&gt;Meeting&lt;/code&gt; node, its &lt;code&gt;Task&lt;/code&gt; nodes and a &lt;code&gt;DECIDED&lt;/code&gt; relationship to each task. Meeting IDs come from an &lt;code&gt;IdGenerator&lt;/code&gt; keyed on the meeting date. Person names are not resolved yet, so the raw names go into a &lt;code&gt;MeetingExtraction&lt;/code&gt; that the function returns for the later phases:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def process_file(
    file: google_drive.DriveFile,
    meeting_table: neo4j.NodeTarget[Meeting],
    task_table: neo4j.NodeTarget[Task],
    decided_rel: neo4j.RelationshipTarget[Any],
) -&amp;gt; list[MeetingExtraction]:
    text = await file.read_text()
    note_file = file.file_path.path.as_posix()
    id_generator = IdGenerator()
    extractions = []
    for section in _split_meetings(text):
        extracted = await extract_meeting(section)
        meeting_id = await id_generator.next_id(extracted.time)

        meeting_table.declare_record(
            row=Meeting(
                id=meeting_id,
                note_file=note_file,
                time=extracted.time,
                note=extracted.note,
            )
        )

        for task in extracted.tasks:
            task_table.declare_record(row=Task(description=task.description))
            decided_rel.declare_relationship(from_id=meeting_id, to_id=task.description)

        extractions.append(
            MeetingExtraction(
                meeting_id=meeting_id,
                organizer=extracted.organizer.name,
                participants=[p.name for p in extracted.participants],
                task_assignees=[
                    (t.description, [a.name for a in t.assigned_to])
                    for t in extracted.tasks
                ],
            )
        )
    return extractions
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Phase 2: person entity resolution&lt;/h3&gt;
&lt;p&gt;The same person shows up under different names across files: &quot;Sarah&quot; in one note, &quot;Sarah Chen&quot; in another. If the graph has one &lt;code&gt;Person&lt;/code&gt; node per raw string, a query by name misses the relationships attached to the other spellings.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;_resolve_persons&lt;/code&gt; calls &lt;a href=&quot;https://cocoindex.io/docs/ops/entity_resolution/&quot;&gt;&lt;code&gt;resolve_entities&lt;/code&gt;&lt;/a&gt;. It embeds every raw name, finds candidates whose cosine similarity is at least 0.70 (the default &lt;code&gt;max_distance=0.3&lt;/code&gt;), and asks &lt;code&gt;LlmPairResolver&lt;/code&gt; whether a name matches one of its candidates and which spelling should be canonical. The result maps every raw name to a canonical one:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn(memo=True)
async def _resolve_persons(raw_persons: set[str]) -&amp;gt; ResolvedEntities:
    return await resolve_entities(
        entities=raw_persons,
        embedder=coco.use_context(EMBEDDER),
        resolve_pair=LlmPairResolver(model=coco.use_context(RESOLUTION_LLM_MODEL)),
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;ResolvedEntities.canonicals()&lt;/code&gt; returns the deduplicated names, and &lt;code&gt;.canonical_of(raw_name)&lt;/code&gt; returns the canonical name for a raw one. &quot;Sarah&quot; and &quot;Sarah Chen&quot; then map to a single &lt;code&gt;Person&lt;/code&gt; node. The function is memoized on the set of names, so an update that adds no new name does not call the embedder or the LLM. The &lt;a href=&quot;/blogs/podcast-to-knowledge-graph/&quot;&gt;podcast knowledge graph post&lt;/a&gt; applies the same resolution to several entity types at once (people, organizations and technologies).&lt;/p&gt;
&lt;h3&gt;Phase 3: canonical people and their relationships&lt;/h3&gt;
&lt;p&gt;With names resolved, &lt;code&gt;create_person_relations&lt;/code&gt; declares one &lt;code&gt;Person&lt;/code&gt; node per canonical name, then the relationships that touch people. &lt;code&gt;ATTENDED&lt;/code&gt; merges organizer and participants, so a person listed as both gets one relationship with &lt;code&gt;is_organizer=True&lt;/code&gt;. &lt;code&gt;ASSIGNED_TO&lt;/code&gt; is declared once per canonical person and task:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn
async def create_person_relations(
    meetings: list[MeetingExtraction],
    persons: ResolvedEntities,
    person_table: neo4j.NodeTarget[Person],
    attended_rel: neo4j.RelationshipTarget[Any],
    assigned_rel: neo4j.RelationshipTarget[Any],
) -&amp;gt; None:
    for canonical_name in persons.canonicals():
        person_table.declare_record(row=Person(name=canonical_name))

    for m in meetings:
        attendees: dict[str, bool] = {persons.canonical_of(m.organizer): True}
        for p in m.participants:
            attendees.setdefault(persons.canonical_of(p), False)

        for canonical, is_organizer in attendees.items():
            attended_rel.declare_relationship(
                from_id=canonical,
                to_id=m.meeting_id,
                record=AttendedRel(is_organizer=is_organizer),
            )

        for task_desc, assignees in m.task_assignees:
            seen: set[str] = set()
            for raw in assignees:
                canonical = persons.canonical_of(raw)
                if canonical in seen:
                    continue
                seen.add(canonical)
                assigned_rel.declare_relationship(from_id=canonical, to_id=task_desc)
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Wiring it together&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;app_main&lt;/code&gt; mounts the 3 node targets and the 3 relationship targets, then runs the phases. Each node target takes a &lt;code&gt;TableSchema&lt;/code&gt; and a primary key. The relationship targets have no schema, so each relationship&apos;s id comes from its endpoints. Each Drive file is processed in its own &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/processing_component/&quot;&gt;processing component&lt;/a&gt;, so change detection works per file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@coco.fn
async def app_main() -&amp;gt; None:
    meeting_table = await neo4j.mount_node_target(
        KG_DB, &quot;Meeting&quot;,
        await neo4j.TableSchema.from_class(Meeting, primary_key=&quot;id&quot;),
        primary_key=&quot;id&quot;,
    )
    person_table = await neo4j.mount_node_target(
        KG_DB, &quot;Person&quot;,
        await neo4j.TableSchema.from_class(Person, primary_key=&quot;name&quot;),
        primary_key=&quot;name&quot;,
    )
    task_table = await neo4j.mount_node_target(
        KG_DB, &quot;Task&quot;,
        await neo4j.TableSchema.from_class(Task, primary_key=&quot;description&quot;),
        primary_key=&quot;description&quot;,
    )

    attended_rel = await neo4j.mount_relationship_target(
        KG_DB, &quot;ATTENDED&quot;, person_table, meeting_table
    )
    decided_rel = await neo4j.mount_relationship_target(
        KG_DB, &quot;DECIDED&quot;, meeting_table, task_table
    )
    assigned_rel = await neo4j.mount_relationship_target(
        KG_DB, &quot;ASSIGNED_TO&quot;, person_table, task_table
    )

    # Phase 1: per-file extraction
    source = google_drive.GoogleDriveSource(
        service_account_credential_path=os.environ[&quot;GOOGLE_SERVICE_ACCOUNT_CREDENTIAL&quot;],
        root_folder_ids=[
            f.strip()
            for f in os.environ[&quot;GOOGLE_DRIVE_ROOT_FOLDER_IDS&quot;].split(&quot;,&quot;)
            if f.strip()
        ],
    )
    file_coros = []
    async for path_key, file in source.items():
        file_coros.append(
            coco.use_mount(
                coco.component_subpath(&quot;file&quot;, path_key),
                process_file, file, meeting_table, task_table, decided_rel,
            )
        )
    per_file = list(await asyncio.gather(*file_coros))
    all_meetings = [m for ms in per_file for m in ms]

    # Phase 2: person entity resolution
    raw_persons: set[str] = set()
    for m in all_meetings:
        raw_persons.add(m.organizer)
        raw_persons.update(m.participants)
        for _task_desc, assignees in m.task_assignees:
            raw_persons.update(assignees)
    persons = await coco.use_mount(
        coco.component_subpath(&quot;resolve_persons&quot;), _resolve_persons, raw_persons
    )

    # Phase 3: declare Person nodes + person-touching relationships
    await coco.mount(
        coco.component_subpath(&quot;person_relations&quot;),
        create_person_relations,
        all_meetings, persons, person_table, attended_rel, assigned_rel,
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When a component finishes, CocoIndex compares the nodes and relationships it declared with the ones from the previous run and writes only the difference: it inserts new items, updates changed ones, and deletes items whose source file is gone. Phase 3 is not memoized, so it runs on every update, but an update that changes one assignment still writes one relationship deletion and one insertion, as in the demo above.&lt;/p&gt;
&lt;h2&gt;Run&lt;/h2&gt;
&lt;h3&gt;Prerequisites&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Neo4j 5.18 or later, running locally. With Docker:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;docker run -d -p 7474:7474 -p 7687:7687 -e NEO4J_AUTH=neo4j/cocoindex --name cocoindex-neo4j neo4j:5.26-community
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The pipeline connects to &lt;code&gt;bolt://localhost:7687&lt;/code&gt; as &lt;code&gt;neo4j&lt;/code&gt; with password &lt;code&gt;cocoindex&lt;/code&gt;. See the &lt;a href=&quot;https://cocoindex.io/docs/connectors/neo4j/&quot;&gt;Neo4j connector docs&lt;/a&gt; for other settings.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;An &lt;a href=&quot;https://cocoindex.io/docs/ops/litellm/&quot;&gt;OpenAI API key&lt;/a&gt; (&lt;code&gt;OPENAI_API_KEY&lt;/code&gt;). Extraction and resolution both default to &lt;code&gt;openai/gpt-5-mini&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Google Drive service-account credentials. Create a Google Cloud service account, download its JSON key, share the source folders with the service-account email, and collect the folder IDs. See &lt;a href=&quot;https://cocoindex.io/docs/connectors/google_drive/&quot;&gt;Setup for Google Drive&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Set the environment variables (&lt;code&gt;GOOGLE_DRIVE_ROOT_FOLDER_IDS&lt;/code&gt; takes a comma-separated list):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;export OPENAI_API_KEY=sk-...
export GOOGLE_SERVICE_ACCOUNT_CREDENTIAL=/absolute/path/to/service_account.json
export GOOGLE_DRIVE_ROOT_FOLDER_IDS=folderId1,folderId2
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Build the graph&lt;/h3&gt;
&lt;p&gt;From the example folder:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pip install -e .
cocoindex update main
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The example&apos;s &lt;code&gt;pyproject.toml&lt;/code&gt; requires CocoIndex 1.1.0 or later, the first release with the node and relationship API.&lt;/p&gt;
&lt;p&gt;The source scans Drive once per update, so run &lt;code&gt;cocoindex update main&lt;/code&gt; again to pick up later changes. For continuous updates, wrap the scanning processor with &lt;a href=&quot;https://cocoindex.io/docs/programming_guide/live_mode/#periodic-refresh-with-cocoauto_refresh&quot;&gt;&lt;code&gt;coco.auto_refresh&lt;/code&gt;&lt;/a&gt;, mount that component, and enable live mode with &lt;code&gt;cocoindex update -L main&lt;/code&gt;. The &lt;code&gt;-L&lt;/code&gt; flag alone does not turn this scan into a watcher.&lt;/p&gt;
&lt;h3&gt;Browse the graph&lt;/h3&gt;
&lt;p&gt;Open &lt;a href=&quot;http://localhost:7474/&quot;&gt;Neo4j Browser&lt;/a&gt; at &lt;code&gt;localhost:7474&lt;/code&gt;, sign in as &lt;code&gt;neo4j&lt;/code&gt; / &lt;code&gt;cocoindex&lt;/code&gt;, and run Cypher:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// All relationships
MATCH p=()--&amp;gt;() RETURN p

// Who attended which meetings (including organizer)
MATCH (p:Person)-[:ATTENDED]-&amp;gt;(m:Meeting)
RETURN p, m

// Tasks decided in meetings
MATCH (m:Meeting)-[:DECIDED]-&amp;gt;(t:Task)
RETURN m, t

// Everything one person was assigned, by meeting date
MATCH (p:Person {name: &quot;Sarah Chen&quot;})-[:ASSIGNED_TO]-&amp;gt;(t:Task)&amp;lt;-[:DECIDED]-(m:Meeting)
RETURN m.time, t.description
ORDER BY m.time
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;() RETURN p on a set of sample notes: 12 nodes (3 Meeting, 3 Person, 6 Task) and 20 relationships (8 ATTENDED, 6 ASSIGNED_TO, 6 DECIDED).&quot;} title={&quot;Neo4j Browser: 12 nodes and 20 relationships from sample notes (captured with an earlier version of the example)&quot;} /&amp;gt;&lt;/p&gt;
&lt;h2&gt;Where else this applies&lt;/h2&gt;
&lt;p&gt;The same pattern (ingest, split, extract, resolve entities, build the graph) fits text where the entities and their relationships matter more than the raw text:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Research papers&lt;/strong&gt;: a graph of concepts, authors, and citations across a repository, updated as papers are added or revised.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Support tickets&lt;/strong&gt;: issues, solutions, customers, and recurring patterns across a large, frequently edited ticket base.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Compliance documents&lt;/strong&gt;: requirements extracted from policies, so you can trace which obligations a policy change affects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Competitive intelligence&lt;/strong&gt;: companies, products, and market moves extracted from public filings and news.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Source&lt;/h2&gt;
&lt;p&gt;The full example is &lt;a href=&quot;https://github.com/cocoindex-io/cocoindex/tree/main/examples/meeting_notes_graph_neo4j&quot;&gt;&lt;code&gt;examples/meeting_notes_graph_neo4j&lt;/code&gt;&lt;/a&gt; in the CocoIndex repo. FalkorDB and SurrealDB versions of the same pipeline sit next to it in &lt;code&gt;examples/&lt;/code&gt;.&lt;/p&gt;
</content:encoded><category>examples</category><category>connectors</category><category>knowledge-graph</category><category>llm</category><category>incremental-processing</category><author>Linghua Jin</author></item><item><title>Normalize and rank Hacker News topics with an LLM</title><link>https://cocoindex.io/blogs/hackernews-trending-topics/</link><guid isPermaLink="true">https://cocoindex.io/blogs/hackernews-trending-topics/</guid><description>Normalize free-text topics with an LLM prompt and rank them with a weighted SQL score in Postgres, in an incremental CocoIndex v1 pipeline over Hacker News.</description><pubDate>Tue, 02 Dec 2025 00:00:00 GMT</pubDate><category>examples</category><category>hackernews</category><category>llm</category><category>structured-extraction</category><category>incremental-processing</category><category>postgres</category><author>Linghua Jin</author></item><item><title>CocoIndex Changelog 0.2.21 - 0.3.10</title><link>https://cocoindex.io/blogs/changelog-0310/</link><guid isPermaLink="true">https://cocoindex.io/blogs/changelog-0310/</guid><description>Featuring batching support for CocoIndex functions, execution robustness, schema &amp; type system improvements, custom source support, and more.</description><pubDate>Tue, 25 Nov 2025 00:00:00 GMT</pubDate><category>changelog</category><category>feature</category><category>performance</category><category>custom-source</category><category>connectors</category><author>George He</author></item><item><title>Turn a polling API into an incremental source: Hacker News</title><link>https://cocoindex.io/blogs/custom-source-hackernews/</link><guid isPermaLink="true">https://cocoindex.io/blogs/custom-source-hackernews/</guid><description>Turn a polling API into an incremental CocoIndex v1 source in plain Python, using Hacker News: list keys, fetch by key, own rows, survive failed fetches.</description><pubDate>Tue, 25 Nov 2025 00:00:00 GMT</pubDate><category>examples</category><category>custom-source</category><category>hackernews</category><category>incremental-processing</category><category>postgres</category><category>llm</category><category>tutorial</category><author>Linghua Jin</author></item><item><title>Extracting Intake Forms with BAML and CocoIndex</title><link>https://cocoindex.io/blogs/extraction-baml/</link><guid isPermaLink="true">https://cocoindex.io/blogs/extraction-baml/</guid><description>Use BAML and CocoIndex v1 to extract typed patient records from PDF intake forms into Postgres with pgvector, and avoid the role(&quot;user&quot;) PDF gotcha on OpenAI.</description><pubDate>Fri, 21 Nov 2025 00:00:00 GMT</pubDate><category>examples</category><category>tutorial</category><category>structured-extraction</category><category>llm</category><author>Linghua Jin</author></item><item><title>Adaptive Batching - 5x throughput on your data pipelines</title><link>https://cocoindex.io/blogs/batching/</link><guid isPermaLink="true">https://cocoindex.io/blogs/batching/</guid><description>CocoIndex batches concurrent calls to embedders and your own functions, with no timer to tune. Batching made the code_embedding example about 5x faster on a small embedding model.</description><pubDate>Mon, 10 Nov 2025 00:00:00 GMT</pubDate><category>feature</category><category>performance</category><category>embeddings</category><category>best-practices</category><author>George He</author></item><item><title>AI-native data pipelines: why we built CocoIndex</title><link>https://cocoindex.io/blogs/data-for-ai/</link><guid isPermaLink="true">https://cocoindex.io/blogs/data-for-ai/</guid><description>Why AI applications need open, AI-native data pipelines that keep context fresh as sources and code change, and the design choices behind CocoIndex.</description><pubDate>Wed, 29 Oct 2025 00:00:00 GMT</pubDate><category>insight</category><category>architecture</category><category>ai-agents</category><category>data-indexing</category><author>Linghua Jin</author></item><item><title>Multimodal PDF Search: Embed Text and Images with CLIP</title><link>https://cocoindex.io/blogs/pdf-elements/</link><guid isPermaLink="true">https://cocoindex.io/blogs/pdf-elements/</guid><description>Split PDFs into text chunks and images, embed text with SentenceTransformers and images with CLIP, and search both in Qdrant with the page number on every hit.</description><pubDate>Mon, 27 Oct 2025 00:00:00 GMT</pubDate><category>examples</category><category>feature</category><category>multimodal</category><category>embeddings</category><category>vector-search</category><author>Linghua Jin</author></item><item><title>Write a Custom Source in Python: Index Any API</title><link>https://cocoindex.io/blogs/custom-source/</link><guid isPermaLink="true">https://cocoindex.io/blogs/custom-source/</guid><description>Index an internal API with CocoIndex v1: plain async Python, deletes propagate, and a memo on updated_at skips unchanged items.</description><pubDate>Tue, 21 Oct 2025 00:00:00 GMT</pubDate><category>feature</category><category>custom-source</category><category>connectors</category><category>data-indexing</category><category>architecture</category><author>Linghua Jin</author></item><item><title>CocoIndex Changelog 2025-10-19</title><link>https://cocoindex.io/blogs/cocoindex-changelog-2025-10-19/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-changelog-2025-10-19/</guid><description>Production-ready upgrades: durable execution, faster incremental processing over large datasets, GPU isolation, and richer native building blocks.</description><pubDate>Sun, 19 Oct 2025 00:00:00 GMT</pubDate><category>changelog</category><category>incremental-processing</category><category>postgres</category><category>structured-extraction</category><category>connectors</category><author>George He</author></item><item><title>Extract Invoice Data from PDFs into Snowflake with an LLM</title><link>https://cocoindex.io/blogs/etl-to-snowflake/</link><guid isPermaLink="true">https://cocoindex.io/blogs/etl-to-snowflake/</guid><description>Extract supplier invoices from PDFs in Azure Blob Storage into a typed Snowflake table with an LLM and CocoIndex, processing only new or changed files.</description><pubDate>Sat, 11 Oct 2025 00:00:00 GMT</pubDate><category>examples</category><category>tutorial</category><category>structured-extraction</category><category>connectors</category><category>incremental-processing</category><author>Dhilip Subramanian</author></item><item><title>Thinking in Rust: Ownership, Access, and Memory Safety</title><link>https://cocoindex.io/blogs/rust-ownership-access/</link><guid isPermaLink="true">https://cocoindex.io/blogs/rust-ownership-access/</guid><description>A mental framework for Rust&apos;s memory safety concepts. Think systematically about ownership, references, Send, Sync, and Rc, Arc, RefCell, Mutex, etc.</description><pubDate>Fri, 10 Oct 2025 00:00:00 GMT</pubDate><category>insight</category><category>architecture</category><category>best-practices</category><author>George He</author></item><item><title>Trace search results back to source data</title><link>https://cocoindex.io/blogs/query-support/</link><guid isPermaLink="true">https://cocoindex.io/blogs/query-support/</guid><description>Define query handlers in CocoIndex and trace search results back to source data in CocoInsight to close the loop on indexing strategy.</description><pubDate>Sun, 21 Sep 2025 00:00:00 GMT</pubDate><category>examples</category><category>feature</category><category>rag</category><category>vector-search</category><author>Linghua Jin</author></item><item><title>Add Semantic Search to a Postgres Table with pgvector</title><link>https://cocoindex.io/blogs/postgres-source/</link><guid isPermaLink="true">https://cocoindex.io/blogs/postgres-source/</guid><description>Use an existing PostgreSQL table as a CocoIndex source: derive fields, embed each row, and store the vectors in Postgres with pgvector, incrementally.</description><pubDate>Mon, 01 Sep 2025 00:00:00 GMT</pubDate><category>examples</category><category>postgres</category><category>incremental-processing</category><category>embeddings</category><category>vector-search</category><author>Linghua Jin</author></item><item><title>Search PDFs and Images Without OCR Using ColPali and Qdrant</title><link>https://cocoindex.io/blogs/multi-format-indexing/</link><guid isPermaLink="true">https://cocoindex.io/blogs/multi-format-indexing/</guid><description>Index PDFs and images into one Qdrant collection with CocoIndex v1 and ColPali multi-vector embeddings. Each page is embedded as an image, so no OCR is needed.</description><pubDate>Wed, 20 Aug 2025 00:00:00 GMT</pubDate><category>examples</category><category>multimodal</category><category>embeddings</category><category>vector-search</category><category>rag</category><author>Linghua Jin</author></item><item><title>CocoIndex Changelog 2025-08-18</title><link>https://cocoindex.io/blogs/cocoindex-changelog-2025-08-18/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-changelog-2025-08-18/</guid><description>CocoIndex updates: production readiness, scalability, and reliability, plus more customization, native integrations, and multi-modal pipeline features.</description><pubDate>Mon, 18 Aug 2025 00:00:00 GMT</pubDate><category>changelog</category><category>performance</category><category>multimodal</category><category>connectors</category><category>vector-search</category><author>Linghua Jin</author></item><item><title>Control Processing Concurrency in CocoIndex</title><link>https://cocoindex.io/blogs/flow-control/</link><guid isPermaLink="true">https://cocoindex.io/blogs/flow-control/</guid><description>How CocoIndex v1 caps concurrent processing components with one app-level limit, lends slots to nested mounts, and adds rate and batch bounds.</description><pubDate>Wed, 13 Aug 2025 00:00:00 GMT</pubDate><category>feature</category><category>performance</category><category>best-practices</category><category>architecture</category><author>George He</author></item><item><title>Multi-vector image search with ColPali and Qdrant</title><link>https://cocoindex.io/blogs/colpali/</link><guid isPermaLink="true">https://cocoindex.io/blogs/colpali/</guid><description>Index images with ColPali multi-vector patch embeddings and a Qdrant MaxSim collection using CocoIndex v1: incremental, live, in plain async Python.</description><pubDate>Tue, 12 Aug 2025 00:00:00 GMT</pubDate><category>examples</category><category>feature</category><category>multimodal</category><category>embeddings</category><category>vector-search</category><author>Linghua Jin</author></item><item><title>Multi-Dimensional Vector Support in CocoIndex</title><link>https://cocoindex.io/blogs/multi-vector/</link><guid isPermaLink="true">https://cocoindex.io/blogs/multi-vector/</guid><description>CocoIndex v1 describes vector and multi-vector columns with VectorSchema and MultiVectorSchema, so Qdrant gets dense vectors and MaxSim multi-vectors.</description><pubDate>Sun, 10 Aug 2025 00:00:00 GMT</pubDate><category>feature</category><category>embeddings</category><category>vector-search</category><category>multimodal</category><author>Linghua Jin</author></item><item><title>Write a Custom Target: Export Indexed Data Anywhere</title><link>https://cocoindex.io/blogs/custom-targets/</link><guid isPermaLink="true">https://cocoindex.io/blogs/custom-targets/</guid><description>Export CocoIndex data anywhere: implement a TargetHandler with a tracking record and an action sink; the engine handles diffing, syncing, and cleanup.</description><pubDate>Sun, 03 Aug 2025 00:00:00 GMT</pubDate><category>examples</category><category>feature</category><category>connectors</category><category>incremental-processing</category><category>tutorial</category><author>Linghua Jin</author></item><item><title>Search your photos by face with CocoIndex</title><link>https://cocoindex.io/blogs/face-detection/</link><guid isPermaLink="true">https://cocoindex.io/blogs/face-detection/</guid><description>Detect every face in a photo folder, embed each with dlib, and index one Qdrant point per face with CocoIndex v1, so a face finds the photos it appears in.</description><pubDate>Thu, 24 Jul 2025 00:00:00 GMT</pubDate><category>examples</category><category>tutorial</category><category>multimodal</category><category>embeddings</category><category>vector-search</category><author>Linghua Jin</author></item><item><title>Extract Metadata from Research Paper PDFs with an LLM</title><link>https://cocoindex.io/blogs/academic-papers-indexing/</link><guid isPermaLink="true">https://cocoindex.io/blogs/academic-papers-indexing/</guid><description>Index academic papers with CocoIndex: read the first page of each PDF, extract title, authors, and abstract with an LLM, and embed them for semantic search.</description><pubDate>Wed, 09 Jul 2025 00:00:00 GMT</pubDate><category>examples</category><category>structured-extraction</category><category>embeddings</category><category>rag</category><category>tutorial</category><author>Linghua Jin</author></item><item><title>CocoIndex Changelog 2025-07-07</title><link>https://cocoindex.io/blogs/cocoindex-changelog-2025-07-07/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-changelog-2025-07-07/</guid><description>CocoIndex updates: in-process setup/drop API, EmbedText building block, SplitRecursively improvements, union/NumPy types, and the Kuzu graph target.</description><pubDate>Mon, 07 Jul 2025 00:00:00 GMT</pubDate><category>changelog</category><category>embeddings</category><category>llm</category><category>knowledge-graph</category><category>incremental-processing</category><author>CocoIndex Team</author></item><item><title>Introducing CocoInsight</title><link>https://cocoindex.io/blogs/cocoinsight/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoinsight/</guid><description>CocoInsight, the CocoIndex v0 tool for inspecting pipeline data and lineage step by step. It is not part of CocoIndex v1; v1 apps use cocoindex show.</description><pubDate>Tue, 24 Jun 2025 00:00:00 GMT</pubDate><category>feature</category><category>announcement</category><category>insight</category><category>architecture</category><author>Linghua Jin</author></item><item><title>Schema inference for Qdrant collections</title><link>https://cocoindex.io/blogs/schema-inference-for-qdrant/</link><guid isPermaLink="true">https://cocoindex.io/blogs/schema-inference-for-qdrant/</guid><description>CocoIndex v1 creates your Qdrant collection from the code: the vector size comes from the embedding model, and a schema change rebuilds the collection.</description><pubDate>Sun, 08 Jun 2025 00:00:00 GMT</pubDate><category>feature</category><category>vector-search</category><category>connectors</category><category>data-indexing</category><author>Linghua Jin</author></item><item><title>CocoIndex + Kuzu: Real-time knowledge graph with Kuzu</title><link>https://cocoindex.io/blogs/kuzu-integration/</link><guid isPermaLink="true">https://cocoindex.io/blogs/kuzu-integration/</guid><description>Build a real-time knowledge graph with Kuzu as a native CocoIndex target: incremental updates, high-performance graph queries.</description><pubDate>Tue, 03 Jun 2025 00:00:00 GMT</pubDate><category>examples</category><category>feature</category><category>knowledge-graph</category><category>connectors</category><author>Linghua Jin</author></item><item><title>CocoIndex Changelog 2025-05-31</title><link>https://cocoindex.io/blogs/cocoindex-changelog-2025-05-31/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-changelog-2025-05-31/</guid><description>CocoIndex updates: Amazon S3 as a data source, improved query handling, a standalone runtime mode, and more connector and performance improvements.</description><pubDate>Sat, 31 May 2025 00:00:00 GMT</pubDate><category>changelog</category><category>connectors</category><category>incremental-processing</category><category>embeddings</category><category>vector-search</category><author>CocoIndex Team</author></item><item><title>Incremental ETL from Amazon S3 to Postgres pgvector</title><link>https://cocoindex.io/blogs/s3-incremental-etl/</link><guid isPermaLink="true">https://cocoindex.io/blogs/s3-incremental-etl/</guid><description>Index Markdown from Amazon S3 into Postgres pgvector with CocoIndex v1. A re-run reads only the objects that changed and embeds only the chunks with new text.</description><pubDate>Thu, 29 May 2025 00:00:00 GMT</pubDate><category>examples</category><category>incremental-processing</category><category>connectors</category><category>data-indexing</category><author>Linghua Jin</author></item><item><title>Build Text-to-Image Search with CLIP and Qdrant</title><link>https://cocoindex.io/blogs/live-image-search/</link><guid isPermaLink="true">https://cocoindex.io/blogs/live-image-search/</guid><description>Build live image search with CocoIndex v1, CLIP, FastAPI, and Qdrant. Embed photos and text in one vector space and search by meaning.</description><pubDate>Tue, 20 May 2025 00:00:00 GMT</pubDate><category>examples</category><category>multimodal</category><category>embeddings</category><category>vector-search</category><category>tutorial</category><author>Linghua Jin</author></item><item><title>What Are Text Embeddings? Build Semantic Search in Python</title><link>https://cocoindex.io/blogs/text-embeddings-101/</link><guid isPermaLink="true">https://cocoindex.io/blogs/text-embeddings-101/</guid><description>Text embeddings 101: what an embedding is, how similarity works, why you chunk, and how to build a semantic search index with CocoIndex v1 and pgvector.</description><pubDate>Mon, 19 May 2025 00:00:00 GMT</pubDate><category>examples</category><category>embeddings</category><category>vector-search</category><category>rag</category><category>tutorial</category><author>Linghua Jin</author></item><item><title>Story of CocoIndex, at 1k stars</title><link>https://cocoindex.io/blogs/cocoindex-1k/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-1k/</guid><description>The story of CocoIndex at 1,000 GitHub stars: the open-source engine that combines custom transformation logic with incremental processing for data indexing.</description><pubDate>Thu, 08 May 2025 00:00:00 GMT</pubDate><category>announcement</category><category>changelog</category><category>data-indexing</category><category>incremental-processing</category><category>architecture</category><author>Linghua Jin</author></item><item><title>Build a Product Recommendation Engine with an LLM and Neo4j</title><link>https://cocoindex.io/blogs/product-recommendation/</link><guid isPermaLink="true">https://cocoindex.io/blogs/product-recommendation/</guid><description>An LLM extracts each product&apos;s taxonomy and complementary taxonomy; CocoIndex turns the labels into a Neo4j knowledge graph that answers &apos;bought this, also need…&apos;.</description><pubDate>Wed, 07 May 2025 00:00:00 GMT</pubDate><category>examples</category><category>knowledge-graph</category><category>llm</category><category>structured-extraction</category><author>Linghua Jin</author></item><item><title>CocoIndex Changelog 2025-04-30</title><link>https://cocoindex.io/blogs/cocoindex-changelog-2025-04-30/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-changelog-2025-04-30/</guid><description>CocoIndex updates: knowledge graph support, Qdrant and Supabase targets, KTable and LTable data types, additional LLM providers, and more.</description><pubDate>Wed, 30 Apr 2025 00:00:00 GMT</pubDate><category>changelog</category><category>knowledge-graph</category><category>connectors</category><category>vector-search</category><category>llm</category><author>CocoIndex Team</author></item><item><title>Build a Knowledge Graph from Documents with an LLM and Neo4j</title><link>https://cocoindex.io/blogs/knowledge-graph-for-docs/</link><guid isPermaLink="true">https://cocoindex.io/blogs/knowledge-graph-for-docs/</guid><description>Build a Neo4j knowledge graph from Markdown docs with an LLM and CocoIndex v1. An edit re-extracts only that file, and unsupported nodes and edges are deleted.</description><pubDate>Tue, 29 Apr 2025 00:00:00 GMT</pubDate><category>examples</category><category>knowledge-graph</category><category>llm</category><category>structured-extraction</category><category>tutorial</category><author>Linghua Jin</author></item><item><title>CocoIndex Changelog 2025-04-07</title><link>https://cocoindex.io/blogs/cocoindex-changelog-2025-04-07/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-changelog-2025-04-07/</guid><description>CocoIndex updates: incremental live update mode, evaluation utilities, date/time types, a Google Drive source, and core performance improvements.</description><pubDate>Mon, 07 Apr 2025 00:00:00 GMT</pubDate><category>changelog</category><category>incremental-processing</category><category>connectors</category><category>structured-extraction</category><author>CocoIndex Team</author></item><item><title>Keep an AI agent&apos;s context in sync with live mode</title><link>https://cocoindex.io/blogs/continuous-updates/</link><guid isPermaLink="true">https://cocoindex.io/blogs/continuous-updates/</guid><description>Run a CocoIndex app in live mode so an agent&apos;s index follows every edit, add and delete as it happens, and re-embeds only what changed. Updated for v1.</description><pubDate>Mon, 07 Apr 2025 00:00:00 GMT</pubDate><category>feature</category><category>ai-agents</category><category>incremental-processing</category><category>data-indexing</category><category>connectors</category><author>CocoIndex Team</author></item><item><title>What Is Incremental Processing? Keep Indexes Fresh</title><link>https://cocoindex.io/blogs/incremental-processing/</link><guid isPermaLink="true">https://cocoindex.io/blogs/incremental-processing/</guid><description>Incremental processing re-runs only the work a change affects. See how CocoIndex v1 finds changes, reuses memoized results and deletes stale rows.</description><pubDate>Sun, 06 Apr 2025 00:00:00 GMT</pubDate><category>feature</category><category>incremental-processing</category><category>performance</category><category>architecture</category><category>ai-agents</category><author>Linghua Jin</author></item><item><title>Extract Patient Intake Forms from PDF and DOCX with an LLM</title><link>https://cocoindex.io/blogs/patient-intake-form-extraction-with-llm/</link><guid isPermaLink="true">https://cocoindex.io/blogs/patient-intake-form-extraction-with-llm/</guid><description>Extract typed Patient records from PDF and DOCX intake forms with an LLM and CocoIndex v1, and compare the plain, BAML, DSPy and local-model approaches.</description><pubDate>Wed, 26 Mar 2025 00:00:00 GMT</pubDate><category>examples</category><category>structured-extraction</category><category>llm</category><category>multimodal</category><author>CocoIndex Team</author></item><item><title>Semantic Search over Google Drive Files with pgvector</title><link>https://cocoindex.io/blogs/text-embedding-from-google-drive/</link><guid isPermaLink="true">https://cocoindex.io/blogs/text-embedding-from-google-drive/</guid><description>Index the documents in a shared Google Drive folder as text embeddings in Postgres with CocoIndex v1, then search them by meaning instead of by filename.</description><pubDate>Sun, 23 Mar 2025 00:00:00 GMT</pubDate><category>examples</category><category>embeddings</category><category>vector-search</category><category>connectors</category><category>data-indexing</category><author>CocoIndex Team</author></item><item><title>CocoIndex Changelog 2025-03-20</title><link>https://cocoindex.io/blogs/cocoindex-changelog-2025-03-20/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-changelog-2025-03-20/</guid><description>First release of CocoIndex Changelog: LLM support, codebase indexing, custom functions, and assorted core/performance improvements</description><pubDate>Thu, 20 Mar 2025 00:00:00 GMT</pubDate><category>changelog</category><category>llm</category><category>structured-extraction</category><category>rag</category><author>CocoIndex Team</author></item><item><title>Build Real-Time Codebase Indexing for AI Code Generation</title><link>https://cocoindex.io/blogs/index-code-base-for-rag/</link><guid isPermaLink="true">https://cocoindex.io/blogs/index-code-base-for-rag/</guid><description>Indexing codebase for RAG with CocoIndex and Tree-sitter in real-time: chunking, embedding, semantic search, and build vector index for efficient retrieval.</description><pubDate>Tue, 18 Mar 2025 00:00:00 GMT</pubDate><category>examples</category><category>rag</category><category>embeddings</category><category>vector-search</category><category>tutorial</category><author>CocoIndex Team</author></item><item><title>Extract Structured Data from PDFs Locally with Ollama</title><link>https://cocoindex.io/blogs/cocoindex-ollama-structured-extraction-from-pdf/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-ollama-structured-extraction-from-pdf/</guid><description>Turn PDFs into typed Postgres rows on your own hardware: docling converts each PDF to Markdown, a local Ollama model fills a nested schema.</description><pubDate>Mon, 17 Mar 2025 00:00:00 GMT</pubDate><category>examples</category><category>tutorial</category><category>structured-extraction</category><category>llm</category><category>postgres</category><author>CocoIndex Team</author></item><item><title>CocoIndex is now open source</title><link>https://cocoindex.io/blogs/cocoindex-open-source/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-open-source/</guid><description>CocoIndex is now open source: an engine that combines custom transformation logic with incremental processing for data indexing.</description><pubDate>Mon, 03 Mar 2025 00:00:00 GMT</pubDate><category>announcement</category><category>changelog</category><category>incremental-processing</category><category>data-indexing</category><category>rag</category><author>CocoIndex Team</author></item><item><title>Customizable Data Indexing Pipelines</title><link>https://cocoindex.io/blogs/data-indexing-custom-logic/</link><guid isPermaLink="true">https://cocoindex.io/blogs/data-indexing-custom-logic/</guid><description>What customizable data indexing pipelines are and why custom transformation logic matters, with practical CocoIndex examples.</description><pubDate>Thu, 20 Feb 2025 00:00:00 GMT</pubDate><category>data-indexing</category><category>insight</category><category>rag</category><category>embeddings</category><category>vector-search</category><author>CocoIndex Team</author></item><item><title>How indexing pipelines differ from other data pipelines</title><link>https://cocoindex.io/blogs/what-makes-indexing-pipelines-different/</link><guid isPermaLink="true">https://cocoindex.io/blogs/what-makes-indexing-pipelines-different/</guid><description>How indexing pipelines differ from ETL, streaming and transactional systems: an index is derived data that must stay correct as its source changes.</description><pubDate>Thu, 30 Jan 2025 00:00:00 GMT</pubDate><category>insight</category><category>incremental-processing</category><category>architecture</category><category>data-indexing</category><author>CocoIndex Team</author></item><item><title>How CocoIndex handles data and code changes</title><link>https://cocoindex.io/blogs/handle-system-update-for-indexing-flow/</link><guid isPermaLink="true">https://cocoindex.io/blogs/handle-system-update-for-indexing-flow/</guid><description>When a file, a function, a prompt or a table schema changes, CocoIndex re-runs only the work that depends on it. See what each change costs.</description><pubDate>Mon, 20 Jan 2025 00:00:00 GMT</pubDate><category>data-indexing</category><category>best-practices</category><category>feature</category><category>architecture</category><author>CocoIndex Team</author></item><item><title>Processing Large Files in Indexing Pipelines</title><link>https://cocoindex.io/blogs/indexing-for-single-large-file/</link><guid isPermaLink="true">https://cocoindex.io/blogs/indexing-for-single-large-file/</guid><description>A USPTO weekly XML file holds thousands of patents. Size CocoIndex processing components so rows land early and restarts resume, measured on Postgres.</description><pubDate>Fri, 10 Jan 2025 00:00:00 GMT</pubDate><category>data-indexing</category><category>best-practices</category><category>performance</category><category>architecture</category><author>CocoIndex Team</author></item><item><title>Data Consistency in Indexing Pipelines</title><link>https://cocoindex.io/blogs/indexing-data-consistency/</link><guid isPermaLink="true">https://cocoindex.io/blogs/indexing-data-consistency/</guid><description>How a crash or two racing versions leave stale rows in a RAG index, and how CocoIndex v1 keeps its internal store and your vector index consistent.</description><pubDate>Mon, 06 Jan 2025 00:00:00 GMT</pubDate><category>data-indexing</category><category>best-practices</category><category>insight</category><category>architecture</category><author>CocoIndex Team</author></item><item><title>Data Indexing Pipelines for RAG: Common Challenges</title><link>https://cocoindex.io/blogs/data-indexing-and-common-challenges/</link><guid isPermaLink="true">https://cocoindex.io/blogs/data-indexing-and-common-challenges/</guid><description>What a good RAG indexing pipeline needs, where pipelines break (incremental updates, upgrades, stale rows from LLM extraction), and how CocoIndex handles it.</description><pubDate>Sun, 05 Jan 2025 00:00:00 GMT</pubDate><category>data-indexing</category><category>best-practices</category><category>insight</category><author>CocoIndex Team</author></item><item><title>CocoIndex: a data indexing platform for AI applications</title><link>https://cocoindex.io/blogs/cocoindex-data-indexing-platform/</link><guid isPermaLink="true">https://cocoindex.io/blogs/cocoindex-data-indexing-platform/</guid><description>CocoIndex keeps AI-ready data in sync with its sources: connectors in, plain Python transforms, and incremental writes to vector, SQL and graph targets.</description><pubDate>Sat, 04 Jan 2025 00:00:00 GMT</pubDate><category>data-indexing</category><category>rag</category><category>embeddings</category><category>vector-search</category><category>knowledge-graph</category><author>CocoIndex Team</author></item><item><title>Welcome to CocoIndex</title><link>https://cocoindex.io/blogs/welcome/</link><guid isPermaLink="true">https://cocoindex.io/blogs/welcome/</guid><description>CocoIndex keeps derived data (chunks, embeddings, graphs, summaries) in sync with its sources and code, so AI agents read current context.</description><pubDate>Thu, 02 Jan 2025 00:00:00 GMT</pubDate><category>announcement</category><category>incremental-processing</category><category>ai-agents</category><category>data-indexing</category><author>Linghua Jin</author></item></channel></rss>