#[test]
fn no_payload_carries_a_vector() {
const ALLOWED: &str = "embedding_model";
for trigger in macrame::schema::ddl::CREATE_TRIGGERS {
let scrubbed = trigger.replace(ALLOWED, "");
for needle in ["embedding", "vector", "F32_BLOB", "f32_blob"] {
assert!(
!scrubbed.contains(needle),
"a trigger payload references {needle:?}; Doctrine VII excludes \
embeddings from transaction_log. The only permitted exception is \
{ALLOWED:?}, which names a model rather than carrying a vector."
);
}
}
}
#[tokio::test]
async fn the_permitted_exception_is_still_a_scalar_column() {
let dir = tempfile::TempDir::new().unwrap();
let db = libsql::Builder::new_local(dir.path().join("t.db"))
.build()
.await
.unwrap();
let conn = db.connect().unwrap();
macrame::schema::run_migrations(&conn).await.unwrap();
let mut rows = conn.query("PRAGMA table_info(concepts)", ()).await.unwrap();
let mut found = None;
while let Some(row) = rows.next().await.unwrap() {
let name: String = row.get(1).unwrap();
if name == "embedding_model" {
found = Some(row.get::<String>(2).unwrap());
}
}
assert_eq!(
found.as_deref(),
Some("TEXT"),
"embedding_model must stay a scalar name, or Doctrine VII's carve-out \
in no_payload_carries_a_vector stops being sound"
);
}
const FOUNDATIONS: &str = include_str!("../docs/architecture/s0-s3-foundations.md");
#[test]
fn lineage_belongs_to_the_second_clock_and_is_not_a_third_axis() {
let doctrines: Vec<&str> = FOUNDATIONS
.match_indices("<a id=\"doctrine-")
.map(|(i, _)| {
let rest = &FOUNDATIONS[i..];
&rest[..rest.find("\n\n").unwrap_or(rest.len())]
})
.collect();
assert_eq!(
doctrines.len(),
8,
"§0 defines {} doctrines. Branching is a clause on Doctrine II and not a \
ninth doctrine (D-213), and the count is frozen by the stability \
contract (D-211)",
doctrines.len()
);
let second = doctrines
.iter()
.find(|d| d.starts_with("<a id=\"doctrine-ii\">"))
.expect("Doctrine II is anchored");
assert!(
second.contains("total order within one lineage")
&& second.contains("partial order across lineages"),
"Doctrine II no longer states that transaction time is a total order \
within a lineage and a partial order across them. That clause is what \
makes a branch a fork in the second clock rather than a new axis \
(D-213), and W12's schema is built against it"
);
const REFUSALS: &[&str] = &["not a ", "not the ", "never a ", "rather than a ", "nor a "];
for d in &doctrines {
let lower = d.to_lowercase();
for phrase in ["third axis", "third clock", "third temporal", "branch axis"] {
for (i, _) in lower.match_indices(phrase) {
let before = &lower[..i];
assert!(
REFUSALS.iter().any(|r| before.ends_with(r)),
"a doctrine describes lineage as {phrase:?} without refusing \
it. §15.1 refuses that framing by name: a branch is \
transaction time with a tree order, and treating it as a \
dimension is how the schema acquires a column that means \
nothing precise (D-213). Naming the framing is allowed \
where a negation precedes it; asserting it is not"
);
}
}
}
}