Add member directory and aggregates, cut citation economics from spec (Draft 0.4)

This commit is contained in:
George Coles
2026-09-15 03:56:11 -04:00
parent 82a95fb907
commit fb45cfa8cf
13 changed files with 890 additions and 79 deletions
+29 -18
View File
@@ -116,7 +116,7 @@ fn envelope_field_set_is_fixed() {
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn ordering_travels_scores_dont() {
async fn scores_never_travel_and_selection_is_local() {
let root = tempfile::tempdir().unwrap();
let relay_url = spawn_relay().await;
let _bob = start_node_with_corpus(
@@ -126,8 +126,8 @@ async fn ordering_travels_scores_dont() {
true,
EXPOSURE_FULL,
&[
("strong.txt", "rust rust rust rust search engine"),
("weak.txt", "rust notes"),
("alpha.txt", "rust search engine document"),
("beta.txt", "rust notes"),
],
)
.await;
@@ -135,20 +135,23 @@ async fn ordering_travels_scores_dont() {
let http = client();
let responses = raw_query(&http, &relay_url, &alice, "rust", 700).await;
assert_eq!(responses.len(), 1);
let results = responses[0]
.pointer("/body/results")
.and_then(Value::as_array)
.unwrap();
let body = responses[0].pointer("/body").unwrap();
let results = body.pointer("/results").and_then(Value::as_array).unwrap();
assert_eq!(results.len(), 2);
let first_url = results[0].get("url").and_then(Value::as_str).unwrap();
assert!(
first_url.contains("strong"),
"best match should lead the ordering: {first_url}"
);
let urls: BTreeSet<&str> = results
.iter()
.map(|result| result.get("url").and_then(Value::as_str).unwrap())
.collect();
assert!(urls.iter().any(|url| url.contains("alpha")));
assert!(urls.iter().any(|url| url.contains("beta")));
for result in results {
assert!(!keys(result).contains("score"));
assert!(!keys(result).contains("rank"));
}
assert_eq!(
body.pointer("/truncated").and_then(Value::as_bool),
Some(false)
);
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
@@ -350,15 +353,23 @@ async fn entities_are_optional_hints() {
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn trusted_keys_allowlist_filters_senders() {
async fn member_directory_filters_senders() {
let root = tempfile::tempdir().unwrap();
let relay_url = spawn_relay().await;
let alice = Keypair::generate();
let untrusted = Keypair::generate();
let docs = corpus_dir(root.path(), "bob", &[("doc.txt", "rust document")]);
let mut config = config_for(&root.path().join("bob"), "bob", &relay_url);
config.node.trusted_keys = vec![alice.public_hex()];
let config = config_for(&root.path().join("bob"), "bob", &relay_url);
frxd::config::save_members(
&config.members_path(),
&[frxd::config::Member {
name: "alice".to_string(),
pubkey: alice.public_hex(),
class: frxd::config::CLASS_SOURCE.to_string(),
}],
)
.unwrap();
{
let index = LocalIndex::open(&config.index_dir()).unwrap();
index
@@ -718,7 +729,7 @@ async fn aggregates_are_unicast_only_and_ignored_by_nodes() {
let broadcast = Envelope::new(
&sender,
TYPE_AGGREGATE,
json!({"period": "2026-03", "sent": 1, "passed": 0, "cited": 0}),
json!({"period": "2026-03", "sent": 1, "passed": 0}),
);
assert_eq!(
publish(&http, &relay_url, &broadcast).await.status(),
@@ -729,7 +740,7 @@ async fn aggregates_are_unicast_only_and_ignored_by_nodes() {
let unicast_envelope = Envelope::new(
&sender,
TYPE_AGGREGATE,
json!({"period": "2026-03", "sent": 1, "passed": 0, "cited": 0}),
json!({"period": "2026-03", "sent": 1, "passed": 0}),
);
assert_eq!(
unicast(&http, &relay_url, &bob.pubkey, &unicast_envelope)
@@ -874,7 +885,7 @@ fn canonical_signing_bytes_are_stable() {
assert_eq!(first, second);
assert_eq!(
String::from_utf8(first).unwrap(),
"FRX/0.3\nquery\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n1700000000\n00112233445566778899aabbccddeeff\n{\"budget\":{\"max_results\":5},\"entities\":[],\"qid\":\"q1\",\"text\":\"rust\"}"
"FRX/0.4\nquery\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n1700000000\n00112233445566778899aabbccddeeff\n{\"budget\":{\"max_results\":5},\"entities\":[],\"qid\":\"q1\",\"text\":\"rust\"}"
);
}