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
12 changes: 10 additions & 2 deletions pkgs/id/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ default-members = [".", "crates/id-core"]
[features]
default = ["sandbox", "world"]
sandbox = ["dep:wasmtime", "world", "id-core/sandbox"]
world = ["dep:subtle", "dep:hmac", "dep:scrypt", "dep:rmp-serde", "id-core/world"]
world = [
"dep:subtle",
"dep:hmac",
"dep:scrypt",
"dep:rmp-serde",
"id-core/world",
]
ssh = ["world", "dep:russh"]
web = [
"world",
Expand Down Expand Up @@ -163,7 +169,9 @@ russh = { version = "=0.65.0", optional = true }
# Paused-time session-driver tests. Dev only.
tokio = { version = "1", features = ["test-util"] }
# The root package's tests exercise dial deadlines using id-core's test-only helpers.
id-core = { path = "crates/id-core", default-features = false, features = ["test-utils"] }
id-core = { path = "crates/id-core", default-features = false, features = [
"test-utils",
] }
# SQLite for the bridge PoC's DO-shaped hosted store (#2276). Bundled, so no system SQLite is needed.
rusqlite = { version = "0.32", features = ["bundled"] }
wat = "=1.261.0"
Expand Down
50 changes: 25 additions & 25 deletions pkgs/id/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,32 +134,32 @@ it is — a valid world capability, minted by the host's admin with

## CLI Commands

| Command | Aliases | Description |
| -------------- | ------------------------------ | ----------------------------------------------- |
| `serve` | | Start server for peer requests |
| `repl` | `shell` | Interactive REPL with pipes and subshells |
| `put` | `in`, `add`, `store`, `import` | Store files in blob store |
| `put-hash` | | Store content by hash only (no named tag) |
| `get` | | Retrieve files by name or hash |
| `get-hash` | | Retrieve file by hash with explicit output path |
| `cat` | `output`, `out` | Output file content to stdout |
| `show` | `view` | Find file by pattern and output content |
| `peek` | | Preview with configurable head/tail lines |
| `find` | | Find files by query, optionally output content |
| `search` | | Search files and list all matches |
| `list` | `ls` | List all stored files |
| `tag` | `label`, `link` | Manage metadata tags on files |
| `migrate-tags` | `migrate` | Add name/file auto-tags to existing files |
| `id` | | Print local node public ID |
| Command | Aliases | Description |
| -------------- | ------------------------------ | -------------------------------------------------- |
| `serve` | | Start server for peer requests |
| `repl` | `shell` | Interactive REPL with pipes and subshells |
| `put` | `in`, `add`, `store`, `import` | Store files in blob store |
| `put-hash` | | Store content by hash only (no named tag) |
| `get` | | Retrieve files by name or hash |
| `get-hash` | | Retrieve file by hash with explicit output path |
| `cat` | `output`, `out` | Output file content to stdout |
| `show` | `view` | Find file by pattern and output content |
| `peek` | | Preview with configurable head/tail lines |
| `find` | | Find files by query, optionally output content |
| `search` | | Search files and list all matches |
| `list` | `ls` | List all stored files |
| `tag` | `label`, `link` | Manage metadata tags on files |
| `migrate-tags` | `migrate` | Add name/file auto-tags to existing files |
| `id` | | Print local node public ID |
| `key` | | Export or import a passphrase-wrapped identity key |
| `peers` | | Discover and list known peers |
| `world` | | Mint invites for, and join, multiplayer worlds |
| `match-audit` | | Export and verify signed match-audit v0 logs |
| `group` | | Groups: create, policy, add, remove, roles, join |
| `delegate` | | Grant a delegate a scope in a group |
| `revoke` | | Revoke a delegation by its grant event ID |
| `doc` | | Publish documents; list events/frontier/history |
| `claim` | | Tag claims on any subject (set, clear, search) |
| `peers` | | Discover and list known peers |
| `world` | | Mint invites for, and join, multiplayer worlds |
| `match-audit` | | Export and verify signed match-audit v0 logs |
| `group` | | Groups: create, policy, add, remove, roles, join |
| `delegate` | | Grant a delegate a scope in a group |
| `revoke` | | Revoke a delegation by its grant event ID |
| `doc` | | Publish documents; list events/frontier/history |
| `claim` | | Tag claims on any subject (set, clear, search) |

### Tag Subcommands

Expand Down
4 changes: 2 additions & 2 deletions pkgs/id/benches/BASELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ proof of a regression.

The slice-2 `guest_replay` line above (median=0.146) was measured with a
harness whose guest saw **zero** events: the journal was built from
committed *chat* events, and `WorldCore::restore` applies committed chat
to core state directly — only committed *input* (and journal system)
committed _chat_ events, and `WorldCore::restore` applies committed chat
to core state directly — only committed _input_ (and journal system)
events are put in `RestoredWorld.replay`. The old number was therefore
restore-only time divided by N, mislabeled as guest replay.

Expand Down
4 changes: 3 additions & 1 deletion pkgs/id/crates/id-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ iroh = "1"
iroh-base = "1"
iroh-blobs = "0.103"
p2panda-core = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc" }
p2panda-auth = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc", features = ["serde"] }
p2panda-auth = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b95269926bf58121cf6a2d3dd5ca41dfc", features = [
"serde",
] }
postcard = { version = "1", features = ["alloc"] }
qrcode = { version = "0.14.1", default-features = false, optional = true }
serde = { version = "1", features = ["derive"] }
Expand Down
1 change: 0 additions & 1 deletion pkgs/id/crates/id-core/src/membership/gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,3 @@ mod tests {
);
}
}

4 changes: 1 addition & 3 deletions pkgs/id/crates/id-core/src/membership/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,7 @@ fn canonical_feed_order(events: &[CausalEvent]) -> Vec<CausalEvent> {
}
waiting.insert(event.id, dependencies.len());
}
let by_id: HashMap<Hash, &CausalEvent> =
events.iter().map(|event| (event.id, event)).collect();
let by_id: HashMap<Hash, &CausalEvent> = events.iter().map(|event| (event.id, event)).collect();
let mut placed: HashSet<Hash> = HashSet::new();
let mut order = Vec::with_capacity(events.len());
while let Some(Reverse(id)) = ready.pop() {
Expand Down Expand Up @@ -1171,4 +1170,3 @@ mod tests {
}
}
}

31 changes: 11 additions & 20 deletions pkgs/id/crates/id-core/src/world_limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ pub const JOURNAL_ENTRY_OVERHEAD_BYTES: u64 = 64;
/// payload length plus the fixed structural allowance.
#[must_use]
pub fn journal_entry_charge(serialized_len: usize) -> u64 {
u64::try_from(serialized_len).unwrap_or(u64::MAX)
u64::try_from(serialized_len)
.unwrap_or(u64::MAX)
.saturating_add(JOURNAL_ENTRY_OVERHEAD_BYTES)
}

Expand Down Expand Up @@ -377,9 +378,11 @@ impl WorldExecutionProfile {
// them beneath the budget lands with the enforcement charge sites
// (Phase 3), so a configured budget never silently shrinks guest
// limits before the ledger exists to account for it.
let total_memory_bytes = self.total_memory_bytes.map_or(hard.total_memory_bytes, |value| {
value.min(hard.total_memory_bytes)
});
let total_memory_bytes = self
.total_memory_bytes
.map_or(hard.total_memory_bytes, |value| {
value.min(hard.total_memory_bytes)
});
#[cfg(feature = "sandbox")]
let sandbox = {
let hard_memory = u64::try_from(hard.sandbox.memory_bytes)?;
Expand Down Expand Up @@ -664,10 +667,7 @@ mod tests {
fn an_empty_profile_inherits_the_server_total_budget() {
let hard = RuntimeLimits::default();
let effective = WorldExecutionProfile::default().resolve(hard).unwrap();
assert_eq!(
effective.total_memory_bytes,
hard.total_memory_bytes
);
assert_eq!(effective.total_memory_bytes, hard.total_memory_bytes);
}

#[test]
Expand All @@ -679,10 +679,7 @@ mod tests {
}
.resolve(hard)
.unwrap();
assert_eq!(
lowered.total_memory_bytes,
hard.total_memory_bytes / 2
);
assert_eq!(lowered.total_memory_bytes, hard.total_memory_bytes / 2);
let raised = WorldExecutionProfile {
total_memory_bytes: Some(u64::MAX),
..Default::default()
Expand Down Expand Up @@ -710,14 +707,8 @@ mod tests {
#[cfg(feature = "sandbox")]
{
assert_eq!(effective.sandbox.fuel, hard.sandbox.fuel);
assert_eq!(
effective.sandbox.memory_bytes,
hard.sandbox.memory_bytes
);
assert_eq!(
effective.sandbox.message_bytes,
hard.sandbox.message_bytes
);
assert_eq!(effective.sandbox.memory_bytes, hard.sandbox.memory_bytes);
assert_eq!(effective.sandbox.message_bytes, hard.sandbox.message_bytes);
}
}

Expand Down
27 changes: 14 additions & 13 deletions pkgs/id/crates/id-core/src/world_presentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,11 +1039,10 @@ mod tests {

#[test]
fn text_parses_and_round_trips() {
let parsed = parse_surface(
r#"{"kind":"text","version":1,"lines":["hello","wide 界 line"]}"#,
)
.unwrap()
.unwrap();
let parsed =
parse_surface(r#"{"kind":"text","version":1,"lines":["hello","wide 界 line"]}"#)
.unwrap()
.unwrap();
let WorldSurface::Text(text) = &parsed else {
panic!("expected a text surface");
};
Expand All @@ -1067,19 +1066,21 @@ mod tests {
let text = TextSurface::with_width(4, vec!["abcdefghij".to_owned()]).unwrap();
assert_eq!(text.lines, ["abcd", "efgh", "ij"]);
let text = TextSurface::with_width(3, vec!["ab界cd".to_owned()]).unwrap();
assert!(text
.lines
.iter()
.all(|line| UnicodeWidthStr::width(line.as_str()) <= 3));
assert!(
text.lines
.iter()
.all(|line| UnicodeWidthStr::width(line.as_str()) <= 3)
);
assert_eq!(text.lines.concat(), "ab界cd");

// The default is 80 and any requested width is capped like a screen.
let text = TextSurface::with_width(10_000, vec!["x".repeat(200)]).unwrap();
assert_eq!(usize::from(text.width), MAX_SCREEN_WIDTH);
assert!(text
.lines
.iter()
.all(|line| UnicodeWidthStr::width(line.as_str()) <= MAX_SCREEN_WIDTH));
assert!(
text.lines
.iter()
.all(|line| UnicodeWidthStr::width(line.as_str()) <= MAX_SCREEN_WIDTH)
);
assert!(TextSurface::with_width(0, vec!["x".to_owned()]).is_err());
}

Expand Down
Loading
Loading