diff --git a/pkgs/atlas-search/crates/atlas-core/tests/parity.rs b/pkgs/atlas-search/crates/atlas-core/tests/parity.rs index 31b3b9d2af..122afd7b3f 100644 --- a/pkgs/atlas-search/crates/atlas-core/tests/parity.rs +++ b/pkgs/atlas-search/crates/atlas-core/tests/parity.rs @@ -78,6 +78,74 @@ fn build_fixture_db(tag: &str) -> PathBuf { db } +/// Build the isolated DNS-source fixture for code#2469. Its toy vector +/// proves the local vector-search path returns the named source chunk; +/// it is not production embedding or corpus-ingestion evidence. +fn build_dns_fixture_db() -> (PathBuf, Json) { + let dir = std::env::temp_dir().join(format!("atlas-core-dns-{}", std::process::id())); + std::fs::create_dir_all(&dir).expect("create temp dir"); + let db = dir.join("dns-fixture.db"); + let _ = std::fs::remove_file(&db); + let sql = std::fs::read_to_string(fixtures_dir().join("dns-search-corpus.sql")) + .expect("read DNS corpus SQL"); + let spec: Json = serde_json::from_str( + &std::fs::read_to_string(fixtures_dir().join("dns-search-spec.json")) + .expect("read DNS search spec"), + ) + .expect("parse DNS search spec"); + let con = rusqlite::Connection::open(&db).expect("open DNS fixture DB"); + con.execute_batch(&sql).expect("load DNS corpus SQL"); + for (cid, vec) in spec["vectors"].as_object().expect("spec vectors") { + let mut blob = Vec::new(); + for x in vec.as_array().expect("vector array") { + blob.extend_from_slice(&(x.as_f64().expect("vector value") as f32).to_le_bytes()); + } + con.execute( + "INSERT INTO vec_snowflake_m_v2_768_f32 (chunk_id, vec) VALUES (?, ?)", + rusqlite::params![cid.parse::().expect("chunk id"), blob], + ) + .expect("insert DNS vector"); + } + drop(con); + (db, spec) +} + +#[test] +fn dns_config_source_is_retrievable_by_vector_search_fixture() { + let (db, spec) = build_dns_fixture_db(); + let be = LocalBackend::new(db.to_str().unwrap(), None, DEFAULT_VEC_TABLE, 0) + .expect("DNS fixture backend"); + let query_vector: Vec = spec["query_vector"] + .as_array() + .expect("query vector") + .iter() + .map(|x| x.as_f64().expect("query vector value") as f32) + .collect(); + let query = spec["query"].as_str().expect("query text"); + let mut options = SearchOptions::new(query); + options.mode = SearchMode::Vector; + options.k = 1; + let got = run_search( + &be, + &FixedEmbedder { raw: query_vector }, + &default_filters(), + &options, + ) + .expect("DNS vector search"); + let first = &got["results"][0]; + assert_eq!( + first["session"]["title"], spec["expected_source"], + "query should retrieve the named DNS source" + ); + assert!( + first["text"] + .as_str() + .expect("result text") + .contains(spec["expected_record"].as_str().expect("record text")), + "retrieved source should contain the known DNS record" + ); +} + fn filters( kinds: &[&str], topics: &[&str], diff --git a/pkgs/atlas-search/fixtures/README.md b/pkgs/atlas-search/fixtures/README.md index fae7c065c1..deeb85b32e 100644 --- a/pkgs/atlas-search/fixtures/README.md +++ b/pkgs/atlas-search/fixtures/README.md @@ -8,6 +8,23 @@ embedded singly and in one fixed mixed batch. Provenance (model revision, file hashes, runtime version, thread counts, padding and pooling semantics) is recorded inside the JSON itself. +## DNS source retrieval fixture (code#2469) + +`dns-search-corpus.sql` and `dns-search-spec.json` are a small, +isolated synthetic fixture for the `atlas-core` vector-search path. +`dns_config_source_is_retrievable_by_vector_search_fixture` proves +that a DNS-record query returns a result titled +`infra/dns/dns_config.yaml` containing the known MX record. Its fixed +toy vectors exercise retrieval plumbing only; they are **not** a +production embedding-quality or production-corpus claim. + +The production Atlas corpus is maintained outside this repository by +the local corpus pipeline. First-pass ingestion of code-repository +documents is tracked separately by code#6025; that work remains gated +on its corpus-ingestion prerequisites. Do not add this source to the +personal conversation corpus or claim production ingestion from this +fixture alone. + Bit-identity is a **version-matched** claim (code#6663): the gate must load the ONNX Runtime version named in the provenance (1.31.1, the atlas venv build). A different runtime — e.g. the nix diff --git a/pkgs/atlas-search/fixtures/dns-search-corpus.sql b/pkgs/atlas-search/fixtures/dns-search-corpus.sql new file mode 100644 index 0000000000..dabf49fa19 --- /dev/null +++ b/pkgs/atlas-search/fixtures/dns-search-corpus.sql @@ -0,0 +1,51 @@ +-- Synthetic, isolated search fixture for developing-today/code#2469. +-- This is not the production Atlas corpus. It mirrors the small subset +-- of the publish schema needed to prove that an indexed DNS source can +-- be returned by Atlas's vector-search path. + +CREATE TABLE sessions ( + id TEXT PRIMARY KEY, + title TEXT, + client TEXT, + created_at TEXT +); +CREATE TABLE messages ( + id TEXT PRIMARY KEY, + session_id TEXT, + role TEXT, + text TEXT +); +CREATE TABLE chunks ( + id INTEGER PRIMARY KEY, + message_id TEXT NOT NULL, + chunk_idx INTEGER, + text TEXT NOT NULL, + content_hash TEXT UNIQUE NOT NULL, + sensitivity TEXT +); +CREATE TABLE session_labels ( + session_id TEXT PRIMARY KEY, + client TEXT, + kind TEXT, + topics TEXT, + projects TEXT, + sensitivity TEXT, + confidence TEXT, + scheme TEXT +); +CREATE TABLE vec_snowflake_m_v2_768_f32 ( + chunk_id INTEGER PRIMARY KEY, + vec BLOB NOT NULL +); +CREATE VIRTUAL TABLE chunks_fts USING fts5(text); + +INSERT INTO sessions (id, title, client, created_at) VALUES + ('dns-source', 'infra/dns/dns_config.yaml', 'atlas-fixture', '2026-11-08T00:00:00Z'); +INSERT INTO session_labels (session_id, client, kind, topics, projects, sensitivity, confidence, scheme) VALUES + ('dns-source', 'atlas-fixture', 'code', '["dns", "infrastructure"]', '["developing-today/code"]', 'shareable', 'high', 'fixture'); +INSERT INTO messages (id, session_id, role, text) VALUES + ('dns-message', 'dns-source', 'document', '01b.us MX priority 10: monday.mxrouting.net'); +INSERT INTO chunks (id, message_id, chunk_idx, text, content_hash, sensitivity) VALUES + (1, 'dns-message', 0, 'source: infra/dns/dns_config.yaml\ndomain: 01b.us\nrecord: MX\npriority: 10\ncontent: monday.mxrouting.net', 'dns-config-01b-us-mx', 'shareable'); +INSERT INTO chunks_fts (rowid, text) VALUES + (1, 'source infra/dns/dns_config.yaml domain 01b.us record MX priority 10 content monday.mxrouting.net'); diff --git a/pkgs/atlas-search/fixtures/dns-search-spec.json b/pkgs/atlas-search/fixtures/dns-search-spec.json new file mode 100644 index 0000000000..2921b89342 --- /dev/null +++ b/pkgs/atlas-search/fixtures/dns-search-spec.json @@ -0,0 +1,10 @@ +{ + "comment": "Synthetic fixed-vector fixture for issue #2469. The query and document vectors are deliberately identical toy vectors, matching the existing atlas-core fixture convention; this proves the local vector-search retrieval path, not production embedding quality or production-corpus ingestion.", + "query": "Which MX host handles mail for 01b.us?", + "expected_source": "infra/dns/dns_config.yaml", + "expected_record": "monday.mxrouting.net", + "query_vector": [1.0, 0.0, 0.0, 0.0], + "vectors": { + "1": [1.0, 0.0, 0.0, 0.0] + } +}