1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Async job queue for memory-tree work.
//!
//! Replaces the synchronous `append_leaf → cascade_seal → LLM summarise` chain
//! on the ingest hot path with a SQLite-backed job queue and a worker driver.
//! The shape is:
//!
//! ```text
//! ingest::persist
//! └── writes chunk row (lifecycle = pending_extraction)
//! enqueues `extract_chunk`
//!
//! run_once (driven in a host loop) claims jobs by kind:
//! extract_chunk → score/admit → enqueue append_buffer + arm reembed
//! append_buffer → push to L0 → enqueue seal if gate met
//! seal → seal one level → enqueue parent seal if cascading
//! flush_stale → enqueue force-seals for time-stale buffers
//! reembed_backfill→ embed a bounded batch → Defer until covered
//! seal_document → build one document version's subtree
//! ```
//!
//! All persistence lives in the same `chunks.db` as `mem_tree_chunks` (the
//! `mem_tree_jobs` table is owned by the shared chunks schema), so a producer
//! can insert its side-effect and its follow-up job in one transaction — see
//! [`store::enqueue_tx`].
//!
//! ## Differences from OpenHuman
//!
//! - The `tokio` worker pool + wall-clock scheduler are reduced to [`run_once`]
//! plus plain scheduler functions a host drives, since `tokio` is a dev-only
//! dependency and the spawn/shutdown/Sentry plumbing is out of this crate's
//! surface. [`drain_until_idle`] settles the queue deterministically.
//! - The heavy per-kind work (LLM scoring/extraction, buffer push, sealing,
//! embedding) sits behind the [`QueueDelegates`] trait because those
//! operations are exposed only `pub(crate)` to `memory::tree` / `memory::score`
//! / `memory::chunks` (and some are not part of the ported surface). The
//! queue keeps its own logic — payload parsing, follow-up enqueues, gating,
//! defer — in-crate.
//! - The typed-failure classifier is the self-contained [`JobFailure`] rather
//! than the upstream `memory_tree::health::PipelineFailure`.
pub
pub use ;
pub use ;
pub use ;
pub use scrub_for_log;
pub use ;
pub use ;
pub use drain_until_idle;
pub use ;
pub use ;