Demux stage-2 rows per channel; produce per-channel histories.
Stage-2 rows are (checkpoint_id, channel, task_id, idx, type, value).
Final write order is oldest→newest globally and (task_id, idx) within
a checkpoint, matching the contract on DeltaChannelHistory.writes.
seed is omitted when the walk reached a true root with no snapshot
found (channel never entered seeded); consumers treat absence as
"start empty".
Stage-2 per-channel UNION ALL fetching writes from writes.
One branch per channel with a non-empty chain. Each branch inlines its
own IN (?, ?, ...) placeholder list because sqlite has no array-bind
equivalent of postgres's = ANY(%s). Caller passes parameters in
matching order: [thread_id, checkpoint_ns, channel, *chain_cids] per
branch.
Returns an empty string when no channel has a chain (caller skips
executing in that case). Per-channel UNION ALL avoids the over-fetch
of a single channel = ANY(channels) filter when channels have
different chain depths — same rationale as postgres.
Process one streamed stage-1 row in the merged ancestor walk.
The cursor returns (cid, parent_cid, type, blob) rows in
checkpoint_id DESC order starting at target. The first row is
target itself; we read its parent_cid to seed the walk and otherwise
skip it (target's own writes/seed are not part of the contract).
For each subsequent row, if cid matches the walk's current
position, we deserialize the blob, append the cid to every
not-yet-seeded channel's chain, and check channel_values for
seeds. The deserialized checkpoint is dropped before advancing — no
cross-row cache, so peak in-flight is one deserialized checkpoint.
Off-path rows (different branch on the same thread) advance the cursor without doing any work.
Returns True when every requested channel is seeded — the caller can stop iterating and close the cursor.
Return WHERE clause predicates for (a)search() given metadata filter
and before config.
This method returns a tuple of a string and a tuple of values. The string is the parametered WHERE clause predicate (including the WHERE keyword): "WHERE column1 = ? AND column2 IS ?". The tuple of values contains the values for each of the corresponding parameters.