Single-commit clean baseline after security scrub of niche-tells, project codenames, internal jargon, and contributor-email leaks. Contents: - 100 Rust crates (_primitives/_rust/) - 37 agent manifests (_manifests/) + generated specs (_generated/) - 67 user-invocable skills (skills/) - 33 hooks (hooks/) - Composition blocks (_blocks/) - Documentation (docs/, README.md) - TS adapter packages (_ts_packages/) - Assembler (_assembler/) - Roles (_roles/) - Templates (_templates/) - Forgejo CI (.forgejo/) Author: Denis Parfionovich <info@greendragon.info> License: see LICENSE.
40 lines
1.6 KiB
Rust
40 lines
1.6 KiB
Rust
//! Re-registering the same (path, body) returns the existing DNA. Single
|
|
//! row in the table; the original `created` timestamp is preserved.
|
|
|
|
use kei_registry::{open_db, register, BlockType};
|
|
use tempfile::tempdir;
|
|
|
|
#[test]
|
|
fn re_register_same_body_returns_same_dna() {
|
|
let tmp = tempdir().unwrap();
|
|
let db_path = tmp.path().join("registry.sqlite");
|
|
let conn = open_db(&db_path).unwrap();
|
|
|
|
let body = b"the body bytes never change";
|
|
let path = "/tmp/fixture/foo";
|
|
let first = register(&conn, BlockType::Atom, "foo", path, body, "md").unwrap();
|
|
let second = register(&conn, BlockType::Atom, "foo", path, body, "md").unwrap();
|
|
|
|
assert_eq!(first.dna, second.dna, "DNA must be identical on re-register");
|
|
assert_eq!(first.id, second.id, "row id must be preserved");
|
|
assert_eq!(first.nonce, second.nonce, "nonce must be stable");
|
|
|
|
let count: i64 = conn
|
|
.query_row("SELECT COUNT(*) FROM blocks", [], |r| r.get(0))
|
|
.unwrap();
|
|
assert_eq!(count, 1, "exactly one row after re-register");
|
|
}
|
|
|
|
#[test]
|
|
fn re_register_different_caps_same_body_still_idempotent() {
|
|
// The idempotency rule keys on (path, body_sha) only — caps drift on a
|
|
// re-register call should NOT spawn a new row when the body is byte
|
|
// identical. This protects against scanner-config churn.
|
|
let tmp = tempdir().unwrap();
|
|
let conn = open_db(tmp.path().join("r.sqlite")).unwrap();
|
|
let body = b"x";
|
|
let path = "/some/path";
|
|
let first = register(&conn, BlockType::Atom, "x", path, body, "md").unwrap();
|
|
let second = register(&conn, BlockType::Atom, "x", path, body, "md,extra").unwrap();
|
|
assert_eq!(first.dna, second.dna);
|
|
}
|