feat(embedding): explicit OpenAI-compatible semantic channel

- add a transport client for one current backend protocol with loopback http,
  TLS-only remote endpoints, explicit remote consent, disabled redirects,
  bounded timeout/batch/payload/response/dimension and no credential in URLs
- validate responses strictly (count, index order, dimension, finite values,
  non-zero norm, mixed-model rejection) and abort publication when any vector
  is missing so a mixed index is never stored
- embed search units in the same transaction that writes the projection, with
  content-digest/model-digest guarded reuse for incremental compiles; the
  build metadata records endpoint/model/revision/dimension/distance/chunking
- add the semantic query channel behind explicit --semantic using an exact
  cosine scan with a bounded vector budget; default queries stay completely
  offline even when vectors exist
- add a local mock-server integration test proving protocol handling,
  cross-vocabulary recall, offline default behaviour, remote consent rules and
  all-or-nothing failure; real-model quality remains NOT RUN and is not claimed
This commit is contained in:
marqdo-knowledge committed 2026-11-26 02:26:37 +08:00
1 parent 514d9fbd4c
commit 87b9c132aa
20 files changed
+2882 -106

No files matched your search

+3 -1
View File
@@ -44,7 +44,7 @@ fn build_graph(snapshot: &SourceSnapshot) -> marqdo_knowledge::graph::Graph {
sources.insert(file.rel_path.as_str(), file.text.as_str());
}
let missing: HashSet<String> = HashSet::new();
graph::build(facts, &sources, &snapshot.assets, &missing)
graph::build(facts, &sources, &snapshot.assets, &missing, false)
}
fn meta(
@@ -81,6 +81,7 @@ fn publish(
graph,
snapshot,
contexts: &[],
embeddings: None,
};
storage::publish(request).unwrap();
}
@@ -197,6 +198,7 @@ fn foreign_database_is_never_overwritten() {
graph: &graph,
snapshot: &snapshot,
contexts: &[],
embeddings: None,
};
let error = storage::publish(request).unwrap_err();
assert_eq!(error.code, "knowledge.database_not_ours");