Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkgs/id/crates/id-cli/src/commands/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,9 @@ pub async fn cmd_serve(opts: ServeOptions) -> Result<()> {
Ok(Some(id)) => info!("serve: published identity event {id}"),
Ok(None) => info!("serve: identity event already in the log"),
Err(err) => {
warn!("serve: identity event not published ({err:#}); user subject falls back to the earliest event");
warn!(
"serve: identity event not published ({err:#}); user subject falls back to the earliest event"
);
}
}
Some(Arc::new(tokio::sync::Mutex::new(events)))
Expand Down
9 changes: 5 additions & 4 deletions pkgs/id/crates/id-core/tests/screen_parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use std::path::PathBuf;

use id_core::world_presentation::{ScreenCell, ScreenSurface, StyleToken};
use serde_json::{json, Value};
use serde_json::{Value, json};

fn cell(symbol: &str, fg: u8, bg: u8, bold: bool, columns: u8) -> ScreenCell {
ScreenCell {
Expand Down Expand Up @@ -139,8 +139,8 @@ fn build_cases() -> Vec<Value> {
cases()
.into_iter()
.map(|(name, width, height, cells)| {
let surface = ScreenSurface::from_cells(width, height, cells)
.expect("corpus case must build");
let surface =
ScreenSurface::from_cells(width, height, cells).expect("corpus case must build");
json!({
"name": name,
"width": width,
Expand Down Expand Up @@ -171,7 +171,8 @@ fn screen_parity_corpus_matches_rust_presenter() {
.expect("screen-parity corpus must be checked in at pkgs/id/test-data/");
let corpus: Value = serde_json::from_str(&raw).unwrap();
assert_eq!(
corpus["cases"], json!(built),
corpus["cases"],
json!(built),
"Rust presenter verdicts drifted from the checked-in parity corpus; \
if the change is intentional, regenerate with SCREEN_PARITY_GENERATE=1 \
and record the divergence on #8340"
Expand Down
12 changes: 1 addition & 11 deletions pkgs/id/crates/id-events/src/local_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,17 +313,7 @@ impl LocalEvents {
}
}
}
let id = self.record(
IDENTITY_KIND,
None,
None,
None,
None,
None,
None,
None,
&[],
)?;
let id = self.record(IDENTITY_KIND, None, None, None, None, None, None, None, &[])?;
Ok(Some(id))
}

Expand Down
22 changes: 16 additions & 6 deletions pkgs/id/crates/id-sync/src/announcement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ impl SignedAnnouncement {
pub fn sign(key: &SigningKey, announcement: Announcement) -> Result<Self> {
announcement.validate()?;
if key.verifying_key().to_bytes() != announcement.world_id {
bail!("announcement world_id is not the signing key: it verifies only against its world key");
bail!(
"announcement world_id is not the signing key: it verifies only against its world key"
);
}
let body = announcement.encode_body()?;
let signature = key.sign(&body);
Expand Down Expand Up @@ -313,8 +315,7 @@ impl SignedAnnouncement {
bytes.len()
);
}
let value = cbor_core::Value::decode(bytes)
.context("signed announcement is not CBOR")?;
let value = cbor_core::Value::decode(bytes).context("signed announcement is not CBOR")?;
value
.deserialized()
.context("signed announcement does not decode")
Expand Down Expand Up @@ -412,14 +413,23 @@ mod tests {
fn print_vectors() {
let (key, announcement) = world_announcement();
let signed = SignedAnnouncement::sign(&key, announcement.clone()).unwrap();
println!("WORLD_BODY={}", hex_encode(&announcement.encode_body().unwrap()));
println!(
"WORLD_BODY={}",
hex_encode(&announcement.encode_body().unwrap())
);
println!("WORLD_SIG={}", hex_encode(&signed.signature));
println!("WORLD_PACKET={}", hex_encode(&signed.to_bytes().unwrap()));
let (key2, announcement2) = program_announcement();
let signed2 = SignedAnnouncement::sign(&key2, announcement2.clone()).unwrap();
println!("PROGRAM_BODY={}", hex_encode(&announcement2.encode_body().unwrap()));
println!(
"PROGRAM_BODY={}",
hex_encode(&announcement2.encode_body().unwrap())
);
println!("PROGRAM_SIG={}", hex_encode(&signed2.signature));
println!("PROGRAM_PACKET={}", hex_encode(&signed2.to_bytes().unwrap()));
println!(
"PROGRAM_PACKET={}",
hex_encode(&signed2.to_bytes().unwrap())
);
}

fn world_announcement() -> (SigningKey, Announcement) {
Expand Down
28 changes: 17 additions & 11 deletions pkgs/id/crates/id-web/src/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ fn tag_labels<'a>(
.map(|identity| {
let plain = plain_tag_label(identity);
let label = if plain_counts.get(&plain).copied().unwrap_or(0) > 1 {
serde_json::to_string(&serde_json::json!([identity.0, identity.1]))
.unwrap_or(plain)
serde_json::to_string(&serde_json::json!([identity.0, identity.1])).unwrap_or(plain)
} else {
plain
};
Expand Down Expand Up @@ -190,12 +189,7 @@ pub(super) async fn feed_handler(State(state): State<AppState>) -> axum::respons
}
let tag_occurrences: std::collections::BTreeMap<String, (usize, u64)> = tag_occurrences
.into_iter()
.map(|(identity, counts)| {
(
labels.get(&identity).cloned().unwrap_or_default(),
counts,
)
})
.map(|(identity, counts)| (labels.get(&identity).cloned().unwrap_or_default(), counts))
.collect();

let mut recent = documents.clone();
Expand Down Expand Up @@ -601,7 +595,11 @@ mod tests {
// two.md and three.md carry only (a, b:c): its occurrence
// count is the number of documents carrying that exact tag.
for name in ["two.md", "three.md"] {
let blob = store.blobs().add_bytes(name.as_bytes().to_vec()).await.unwrap();
let blob = store
.blobs()
.add_bytes(name.as_bytes().to_vec())
.await
.unwrap();
store.tags().set(name, blob.hash).await.unwrap();
tags.set_tag(&tags.global, name.as_bytes(), b"a", Some(b"b:c"), b"")
.await
Expand All @@ -627,8 +625,16 @@ mod tests {
.find(|doc| doc.name == "one.md")
.expect("one.md in feed");
assert_eq!(one.tag_count, 2);
assert!(one.tags.contains(&"[\"a:b\",\"c\"]".to_string()), "{:?}", one.tags);
assert!(one.tags.contains(&"[\"a\",\"b:c\"]".to_string()), "{:?}", one.tags);
assert!(
one.tags.contains(&"[\"a:b\",\"c\"]".to_string()),
"{:?}",
one.tags
);
assert!(
one.tags.contains(&"[\"a\",\"b:c\"]".to_string()),
"{:?}",
one.tags
);
// Across documents: exact-tag occurrence counts drive the
// ranking — (a, b:c) on 3 documents outranks (a:b, c) on 1.
assert_eq!(feed.popular_tags[0].label, "[\"a\",\"b:c\"]");
Expand Down
4 changes: 3 additions & 1 deletion pkgs/id/crates/id-worlds/src/world_ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4147,7 +4147,9 @@ mod tests {
}
crate::world_line::WorldLine::AnchorList => WorldCommand::AnchorList,
crate::world_line::WorldLine::Talk { target } => WorldCommand::Talk { target },
crate::world_line::WorldLine::Anchors { target } => WorldCommand::Anchors { target },
crate::world_line::WorldLine::Anchors { target } => {
WorldCommand::Anchors { target }
}
crate::world_line::WorldLine::Resolve { thread, into } => {
WorldCommand::Resolve { thread, into }
}
Expand Down
18 changes: 16 additions & 2 deletions pkgs/id/web/src/world-surface.parity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,22 @@ const corpus = JSON.parse(readFileSync(corpusPath, "utf8")) as { cases: CorpusCa
function xtermHex(index: number): string | null {
if (index === 0) return null;
const basic = [
"#000000", "#800000", "#008000", "#808000", "#000080", "#800080", "#008080", "#c0c0c0",
"#808080", "#ff0000", "#00ff00", "#ffff00", "#0000ff", "#ff00ff", "#00ffff", "#ffffff",
"#000000",
"#800000",
"#008000",
"#808000",
"#000080",
"#800080",
"#008080",
"#c0c0c0",
"#808080",
"#ff0000",
"#00ff00",
"#ffff00",
"#0000ff",
"#ff00ff",
"#00ffff",
"#ffffff",
];
if (index < 16) return basic[index] ?? null;
if (index <= 231) {
Expand Down