feat(agent): expose the HNSW parameters in MemoryConfig
Graph degree and the build- and query-time candidate list sizes were constants, so a deployment had no way to trade recall against memory or query speed. They are now `MemoryConfig::hnsw_m`, `hnsw_ef_construction` and `hnsw_ef_search`, persisted with the store and defaulting to exactly the previous behaviour (16, 64, and a query list that scales with `k`). Two things the straightforward version would have got wrong: `clawhdf5-ann` asserts a graph degree of at least 2, so a configured 0 — from a file, or from a caller reading 0 as "use the default" — aborted the process inside the index builder. The store clamps instead, and a test covers it: removing the clamp makes that test panic rather than fail. `ef_search` and the candidate pool handed to score fusion were the same number. Tying the pool to the new setting would mean lowering `ef` for speed also narrows what fusion sees, quietly degrading hybrid results through a knob that looks like it only costs time. They are now independent. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
@@ -108,6 +108,15 @@ pub fn build_hdf5_file_with_meta(
|
||||
"quantized_index",
|
||||
AttrValue::I64(config.quantized_index.into()),
|
||||
);
|
||||
meta.set_attr("hnsw_m", AttrValue::I64(config.hnsw_m as i64));
|
||||
meta.set_attr(
|
||||
"hnsw_ef_construction",
|
||||
AttrValue::I64(config.hnsw_ef_construction as i64),
|
||||
);
|
||||
meta.set_attr(
|
||||
"hnsw_ef_search",
|
||||
AttrValue::I64(config.hnsw_ef_search as i64),
|
||||
);
|
||||
meta.set_attr(
|
||||
"edgehdf5_version",
|
||||
AttrValue::String(ZEROCLAW_VERSION.into()),
|
||||
@@ -489,6 +498,15 @@ pub fn validate_and_load(
|
||||
.and_then(|v| usize::try_from(v).ok())
|
||||
.unwrap_or(500),
|
||||
quantized_index: optional_bool_attr(&attrs, "quantized_index", false),
|
||||
hnsw_m: optional_i64_attr(&attrs, "hnsw_m")
|
||||
.and_then(|v| usize::try_from(v).ok())
|
||||
.unwrap_or(16),
|
||||
hnsw_ef_construction: optional_i64_attr(&attrs, "hnsw_ef_construction")
|
||||
.and_then(|v| usize::try_from(v).ok())
|
||||
.unwrap_or(64),
|
||||
hnsw_ef_search: optional_i64_attr(&attrs, "hnsw_ef_search")
|
||||
.and_then(|v| usize::try_from(v).ok())
|
||||
.unwrap_or(0),
|
||||
};
|
||||
|
||||
// Load /memory group
|
||||
|
||||
Reference in New Issue
Block a user