From 8a42cd2c7a62a8aa72ed344551a384fd6b060b4f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 31 Oct 2026 23:37:18 +0000 Subject: [PATCH] ci: resolve rust 1.99 clippy errors and flakehub caching failure Co-authored-by: dezren39 <11225574+dezren39@users.noreply.github.com> --- .github/workflows/id-check.yml | 6 ++-- .github/workflows/nix-ci.yml | 52 +++++++++++++------------------ pkgs/id/src/cli.rs | 6 ++-- pkgs/id/src/commands/find.rs | 12 ++----- pkgs/id/src/commands/group.rs | 8 ++--- pkgs/id/src/commands/repl.rs | 4 +-- pkgs/id/src/commands/serve.rs | 3 +- pkgs/id/src/commands/world.rs | 10 +++--- pkgs/id/src/event_store/ingest.rs | 14 --------- pkgs/id/src/event_store/range.rs | 21 ++++++------- pkgs/id/src/event_store/sync.rs | 20 ++++++------ pkgs/id/src/event_sync.rs | 3 +- pkgs/id/src/local_events.rs | 8 ++--- pkgs/id/src/meta_client.rs | 6 ++-- pkgs/id/src/search.rs | 1 + pkgs/id/src/server_config/mod.rs | 2 +- pkgs/id/src/shell_contract.rs | 2 +- pkgs/id/src/tag_claims.rs | 1 + pkgs/id/src/world_caps.rs | 4 +-- pkgs/id/src/world_doctor.rs | 2 +- pkgs/id/src/world_manifest.rs | 19 ++--------- pkgs/id/src/world_presentation.rs | 20 ++++++------ pkgs/id/src/world_session/mod.rs | 23 +++++++------- pkgs/id/src/world_store.rs | 10 +++--- 24 files changed, 105 insertions(+), 152 deletions(-) diff --git a/.github/workflows/id-check.yml b/.github/workflows/id-check.yml index 21b0239cb6..ac4470ca56 100644 --- a/.github/workflows/id-check.yml +++ b/.github/workflows/id-check.yml @@ -82,7 +82,7 @@ jobs: # JSON array for the matrix. The list file stays the single source of # truth: adding a check to id-pr-checks.txt adds a parallel job. guard: - name: guard PR check list + name: "basic: guard PR check list" runs-on: ubuntu-latest timeout-minutes: 10 outputs: @@ -124,7 +124,7 @@ jobs: # derivation. check-id-pr-checks.sh holds the exclusion list and keeps # this list in sync with pkgs/id/flake.nix. check_each: - name: nix flake check (${{ matrix.check }}) + name: "basic: nix flake check (${{ matrix.check }})" needs: guard runs-on: ubuntu-latest timeout-minutes: 30 @@ -183,7 +183,7 @@ jobs: # backstop. Nothing from the old PR matrix is lost: the union of this # job, id-e2e-nightly, and the PR matrix covers it. full-flake-check: - name: nix flake check (full, main tier) + name: "full (main tier): nix flake check" if: github.event_name != 'pull_request' runs-on: ubuntu-latest timeout-minutes: 180 diff --git a/.github/workflows/nix-ci.yml b/.github/workflows/nix-ci.yml index 3570190afd..4b2248ef06 100644 --- a/.github/workflows/nix-ci.yml +++ b/.github/workflows/nix-ci.yml @@ -5,6 +5,12 @@ on: push: branches: [main] pull_request: + # Merge queue pilot (see .github/ci-policy.md): the queue validates + # the combined merge-group head, and this workflow's PR-tier job + # (basic: proxy port fallbacks) is main's required status check — + # it must run on merge groups too, or the queue can never see its + # required context and stalls. + merge_group: schedule: # Nightly backstop: the full flake check runs on main + nightly, not PRs. - cron: "17 8 * * *" @@ -26,44 +32,28 @@ concurrency: cancel-in-progress: true jobs: - treefmt: - name: treefmt check + # Basic tier: the proxy ports' fallback copies (bin/*.mjs script + # defaults and the {env:VAR:-port} defaults in + # .opencode/opencode.jsonc) must match the single definitions in + # home/common/default.nix, or a non-shell launch silently dials + # the wrong — or an empty — port (#434, #435). Pure bash/grep: no + # Nix needed, runs on every PR. This job used to also run the + # treefmt format check; formatting is no longer a merge gate — + # it is auto-fixed on main by .github/workflows/auto-format.yml + # (see .github/ci-policy.md). + proxy-port-fallbacks: + name: "basic: proxy port fallbacks" runs-on: ubuntu-latest - timeout-minutes: 15 + timeout-minutes: 5 steps: - uses: actions/checkout@v7 - with: - fetch-depth: 0 - # The proxy ports' fallback copies (bin/*.mjs script defaults and - # the {env:VAR:-port} defaults in .opencode/opencode.jsonc) must - # match the single definitions in home/common/default.nix, or a - # non-shell launch silently dials the wrong — or an empty — port - # (#434, #435). Pure bash/grep: no Nix needed. - name: Check proxy port fallbacks match their definitions run: .github/scripts/check-proxy-port-fallbacks.sh - - uses: DeterminateSystems/nix-installer-action@3138316df39ed29be04236d7ffc686fa525866aa # v23 - - name: Check formatting for changed files - env: - BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }} - run: | - set -euo pipefail - base_sha="$BASE_SHA" - if [[ "$base_sha" =~ ^0+$ ]]; then - base_sha="$(git rev-parse HEAD^)" - fi - changed_files_file="$(mktemp)" - trap 'rm -f "$changed_files_file"' EXIT - git diff --name-only --diff-filter=ACMR -z "$base_sha...$GITHUB_SHA" > "$changed_files_file" - mapfile -d '' changed_files < "$changed_files_file" - if ((${#changed_files[@]} == 0)); then - echo "No changed files to format-check." - exit 0 - fi - nix run .#format-check -- "${changed_files[@]}" flake-check: - name: Nix flake evaluation - # Main tier only (Phase 2, #1781): PRs keep the treefmt/format gate above. + name: "full (main tier): Nix flake evaluation" + # Main tier only (Phase 2, #1781): PRs keep the basic proxy-port + # fallback check above; formatting is auto-fixed on main, never a gate. if: github.event_name != 'pull_request' runs-on: ubuntu-latest timeout-minutes: 15 diff --git a/pkgs/id/src/cli.rs b/pkgs/id/src/cli.rs index bdaba16e3a..8699214a08 100644 --- a/pkgs/id/src/cli.rs +++ b/pkgs/id/src/cli.rs @@ -318,7 +318,7 @@ pub enum Command { no_mdns: bool, /// Enable mainline DHT address lookup and publishing. /// - /// By default, the server does not use the mainline BitTorrent DHT + /// By default, the server does not use the mainline `BitTorrent` DHT /// for address discovery. This flag enables DHT lookup and publishing /// for the server's endpoint. #[arg(long)] @@ -1542,7 +1542,7 @@ pub enum WorldCommand { #[arg(long, value_enum, default_value_t = WorldVia::Iroh)] via: WorldVia, /// With `--via ssh`: the host key fingerprint `id serve` prints - /// (`SHA256:...`). Without it, the key must be in ~/.ssh/known_hosts. + /// (`SHA256:...`). Without it, the key must be in ~/.`ssh/known_hosts`. #[arg(long, value_name = "FINGERPRINT")] ssh_host_key: Option, /// World on the host to use (default: the host's default world). @@ -1558,7 +1558,7 @@ pub enum WorldCommand { /// Reach a host's world SSH server through iroh, so an ordinary `ssh` /// client can reach a world behind NAT: `ssh -p 2222 @127.0.0.1` /// (password: the guest capability). With `--stdio`, acts as an SSH - /// ProxyCommand instead of listening. + /// `ProxyCommand` instead of listening. SshTunnel { /// The host's node ID (64 hex characters). node: String, diff --git a/pkgs/id/src/commands/find.rs b/pkgs/id/src/commands/find.rs index 48864e4823..9e60e471c0 100644 --- a/pkgs/id/src/commands/find.rs +++ b/pkgs/id/src/commands/find.rs @@ -162,22 +162,16 @@ impl SearchOptions { /// verbatim behaviour. fn download_output_path(dir: Option<&str>, name: &str) -> Result { if name.is_empty() || name.ends_with('/') { - bail!( - "refusing download of match with unsafe name {:?}: no final path component", - name - ); + bail!("refusing download of match with unsafe name {name:?}: no final path component"); } let Some(file_name) = std::path::Path::new(name) .file_name() .and_then(|c| c.to_str()) else { - bail!( - "refusing download of match with unsafe name {:?}: no final path component", - name - ); + bail!("refusing download of match with unsafe name {name:?}: no final path component"); }; Ok(match dir { - Some(dir) => format!("{}/{}", dir, file_name), + Some(dir) => format!("{dir}/{file_name}"), None => file_name.to_owned(), }) } diff --git a/pkgs/id/src/commands/group.rs b/pkgs/id/src/commands/group.rs index 3e9e8e8645..8a32ca85b1 100644 --- a/pkgs/id/src/commands/group.rs +++ b/pkgs/id/src/commands/group.rs @@ -185,14 +185,10 @@ fn evaluate_group(group: Hash, members: usize) -> (usize, Option) { }; let now = std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) - .map(|d| d.as_secs()) - .unwrap_or(0); + .map_or(0, |d| d.as_secs()); let mut evaluator = Evaluator::default(); let warnings = evaluator.observe(&observation, now); - let size_warning = warnings - .iter() - .filter(|w| matches!(w, Warning::Size { .. })) - .last(); + let size_warning = warnings.iter().rfind(|w| matches!(w, Warning::Size { .. })); let churn_warning = warnings.iter().find(|w| matches!(w, Warning::Churn { .. })); let warning = match (size_warning, churn_warning) { (Some(size), Some(churn)) => Some(format!("{}; {}", size.message(), churn.message())), diff --git a/pkgs/id/src/commands/repl.rs b/pkgs/id/src/commands/repl.rs index bdf65b5dfd..82fe234294 100644 --- a/pkgs/id/src/commands/repl.rs +++ b/pkgs/id/src/commands/repl.rs @@ -95,8 +95,8 @@ use crate::commands::tag::{self as tag, TagDisplayOptions}; use crate::local::LocalNode; use crate::meta_client::{MetaRequester, expect_ok, read_capped_response, request_over}; use crate::{ - CLIENT_KEY_FILE, FindMatch, META_ALPN, MatchKind, MetaRequest, MetaResponse, StoreType, - export_blob, is_node_id, load_or_create_keypair, open_store, + CLIENT_KEY_FILE, FindMatch, META_ALPN, MetaRequest, MetaResponse, StoreType, export_blob, + is_node_id, load_or_create_keypair, open_store, }; /// REPL execution context managing connections and store access. diff --git a/pkgs/id/src/commands/serve.rs b/pkgs/id/src/commands/serve.rs index 71de10ab8d..3938d703cb 100644 --- a/pkgs/id/src/commands/serve.rs +++ b/pkgs/id/src/commands/serve.rs @@ -1455,8 +1455,7 @@ fn evaluate_group_warnings( fn unix_now() -> u64 { std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) - .map(|duration| duration.as_secs()) - .unwrap_or(0) + .map_or(0, |duration| duration.as_secs()) } /// Background loop for gossip-based peer discovery. diff --git a/pkgs/id/src/commands/world.rs b/pkgs/id/src/commands/world.rs index 2e38538a9d..a200b3d6b9 100644 --- a/pkgs/id/src/commands/world.rs +++ b/pkgs/id/src/commands/world.rs @@ -495,11 +495,13 @@ pub async fn cmd_world(command: WorldCommand) -> Result<()> { .collect::>() .join(", ") ); - if !dry_run { + if dry_run { + println!("dry run: nothing changed"); + } else { let applied = apply_steps(&mut client, &admin_token, &capability, &steps).await?; if applied == steps.len() { - println!("applied {} step(s)", applied); + println!("applied {applied} step(s)"); } else { println!( "applied {} of {} step(s); the rest were reported but not applied", @@ -507,8 +509,6 @@ pub async fn cmd_world(command: WorldCommand) -> Result<()> { steps.len() ); } - } else { - println!("dry run: nothing changed"); } } client.close(); @@ -905,7 +905,7 @@ async fn current_world_state( /// schedule steps are reported, not applied, until their apply paths are /// wired (#807), so they must not count toward the "applied N step(s)" /// summary (#818). -fn step_is_applied(step: &crate::world_manifest::ApplyStep) -> bool { +const fn step_is_applied(step: &crate::world_manifest::ApplyStep) -> bool { use crate::world_manifest::ApplyStep; matches!( step, diff --git a/pkgs/id/src/event_store/ingest.rs b/pkgs/id/src/event_store/ingest.rs index 984e2bdbf6..9544be0fd0 100644 --- a/pkgs/id/src/event_store/ingest.rs +++ b/pkgs/id/src/event_store/ingest.rs @@ -464,20 +464,6 @@ enum Staged { } impl Staged { - /// Whether the event is kept: stored, or held. A refused event and a fork are not. - fn keeps(&self) -> bool { - matches!( - self, - Self::Stored { .. } - | Self::Ready( - Ingest::Accepted { .. } - | Ingest::Voided { .. } - | Ingest::Duplicate { .. } - | Ingest::Waiting { .. }, - ) - ) - } - /// The outcome, with its labels read from the store as it is now. fn finish(self, txn: &WriteTransaction) -> Result { match self { diff --git a/pkgs/id/src/event_store/range.rs b/pkgs/id/src/event_store/range.rs index b1f1f1ba3e..3be24c1a54 100644 --- a/pkgs/id/src/event_store/range.rs +++ b/pkgs/id/src/event_store/range.rs @@ -97,7 +97,7 @@ impl Params { /// # Errors /// /// Refuses `k` below 2, and `t` below 1. - pub fn new(k: usize, t: usize) -> Result { + pub const fn new(k: usize, t: usize) -> Result { if k < 2 { return Err(ParamsError::FanOut(k)); } @@ -133,7 +133,7 @@ impl Params { /// # Errors /// /// Refuses a budget below one entry. - pub fn with_session_budget(self, bytes: usize) -> Result { + pub const fn with_session_budget(self, bytes: usize) -> Result { if bytes < MIN_FRAME_BUDGET { return Err(ParamsError::SessionBudget(bytes)); } @@ -250,12 +250,12 @@ impl Party { } /// The number of keys. - pub fn len(&self) -> usize { + pub const fn len(&self) -> usize { self.keys.len() } /// Whether the set is empty. - pub fn is_empty(&self) -> bool { + pub const fn is_empty(&self) -> bool { self.keys.is_empty() } @@ -388,13 +388,12 @@ impl Party { /// Appends an entry, merging it into the previous one when both are skips. fn push(out: &mut Vec, upper: Option>, mode: Mode) { - if mode == Mode::Skip { - if let Some(last) = out.last_mut() { - if last.mode == Mode::Skip { - last.upper = upper; - return; - } - } + if mode == Mode::Skip + && let Some(last) = out.last_mut() + && last.mode == Mode::Skip + { + last.upper = upper; + return; } out.push(Entry { upper, mode }); } diff --git a/pkgs/id/src/event_store/sync.rs b/pkgs/id/src/event_store/sync.rs index b7da633bf6..ec1610e454 100644 --- a/pkgs/id/src/event_store/sync.rs +++ b/pkgs/id/src/event_store/sync.rs @@ -127,7 +127,7 @@ struct Tally { } impl Tally { - fn add(&mut self, outcome: &Ingest) { + const fn add(&mut self, outcome: &Ingest) { match outcome { Ingest::Accepted { .. } => self.accepted += 1, Ingest::Duplicate { .. } => self.duplicates += 1, @@ -195,7 +195,7 @@ pub(crate) enum Cut { /// Runs one range session over an open connection. The dialer opens the stream and passes /// `initiator = true`. `now_ms` is the clock the store's waiting rules use. `deadline` bounds -/// the whole session, from opening the stream to the last event, as LogSync's does. +/// the whole session, from opening the stream to the last event, as `LogSync`'s does. /// /// # Errors /// @@ -362,7 +362,7 @@ struct ReadBudget { impl ReadBudget { /// Charges `cost` bytes. A charge that would pass the budget is refused, and nothing is /// charged. - fn charge(&mut self, cost: usize) -> Result<(), BudgetExceeded> { + const fn charge(&mut self, cost: usize) -> Result<(), BudgetExceeded> { let total = self.read.saturating_add(cost); if total > self.budget { return Err(BudgetExceeded { @@ -529,14 +529,14 @@ async fn run( let count = u32::try_from(offers.len())?; let mut bytes = write_frame(&mut send, &count.to_be_bytes()).await?; for (sent, id) in offers.iter().enumerate() { - if let Some((records, wait)) = &cut_records { - if sent == *records { - if let Some((signal, committed)) = wait { - wait_for_commit(signal, *committed).await; - } - conn.close(1u32.into(), b"cut"); - bail!("cut before event {}", sent + 1); + if let Some((records, wait)) = &cut_records + && sent == *records + { + if let Some((signal, committed)) = wait { + wait_for_commit(signal, *committed).await; } + conn.close(1u32.into(), b"cut"); + bail!("cut before event {}", sent + 1); } let record = lock(&store)? .sync_bytes(id)? diff --git a/pkgs/id/src/event_sync.rs b/pkgs/id/src/event_sync.rs index 9121502b98..cac9151848 100644 --- a/pkgs/id/src/event_sync.rs +++ b/pkgs/id/src/event_sync.rs @@ -12,7 +12,7 @@ //! the pull gate `serve` uses. //! //! The store these sessions serve is the *same* [`LocalEvents`] instance the web layer -//! publishes ProseMirror save revisions into. `serve` opens that store once and shares +//! publishes `ProseMirror` save revisions into. `serve` opens that store once and shares //! the `Arc>` between the web state and this handler, so there is no //! second, divergent store: a revision saved through the web UI is in the sync set of //! the next session, and a revision that arrives by sync is in the history the web UI @@ -74,6 +74,7 @@ pub fn open_gate() -> PullGate { } /// Serves range-sync sessions over the node's shared [`LocalEvents`] store. +/// /// Register it with `Router::builder(..).accept(ALPN, EventSyncProtocol::new(events))`, /// where `events` is the same instance the web layer publishes into. #[derive(Clone)] diff --git a/pkgs/id/src/local_events.rs b/pkgs/id/src/local_events.rs index 846b9e6713..712a8b4ea2 100644 --- a/pkgs/id/src/local_events.rs +++ b/pkgs/id/src/local_events.rs @@ -308,10 +308,10 @@ impl LocalEvents { let mut required: Vec = Vec::new(); let mut seen: HashSet = HashSet::new(); for claim in &group { - if seen.insert(claim.author) { - if let Some(head) = heads.get(&claim.author) { - required.push(*head); - } + if seen.insert(claim.author) + && let Some(head) = heads.get(&claim.author) + { + required.push(*head); } } let ids: Vec = group.iter().map(|claim| claim.id).collect(); diff --git a/pkgs/id/src/meta_client.rs b/pkgs/id/src/meta_client.rs index 9faadc0aac..3cce77d766 100644 --- a/pkgs/id/src/meta_client.rs +++ b/pkgs/id/src/meta_client.rs @@ -53,9 +53,9 @@ pub fn expect_ok(resp: MetaResponse) -> Result { /// limit instead. Any other read failure passes through unchanged. pub fn capped_response_error(err: ReadToEndError) -> anyhow::Error { match err { - ReadToEndError::TooLong => anyhow::anyhow!( - "response too large: exceeds the {MAX_RESPONSE_BYTES}-byte limit" - ), + ReadToEndError::TooLong => { + anyhow::anyhow!("response too large: exceeds the {MAX_RESPONSE_BYTES}-byte limit") + } other => other.into(), } } diff --git a/pkgs/id/src/search.rs b/pkgs/id/src/search.rs index 237f9f31f5..e48041c995 100644 --- a/pkgs/id/src/search.rs +++ b/pkgs/id/src/search.rs @@ -190,6 +190,7 @@ pub fn search_store( } /// The multi-term search over the store's live claims, read by [`EventStore::tag_claims`]. +/// /// [`Term::SubjectKind`] resolves through the store: the subject's event, read by /// [`EventStore::event_by_id`], and the kind in its header extension. /// diff --git a/pkgs/id/src/server_config/mod.rs b/pkgs/id/src/server_config/mod.rs index b2e1473db0..5628ca607f 100644 --- a/pkgs/id/src/server_config/mod.rs +++ b/pkgs/id/src/server_config/mod.rs @@ -193,7 +193,7 @@ impl ServerConfig { /// level, with the world and inviter levels unset, so a more specific setting made /// elsewhere still wins and the code default still applies when nothing is set. #[must_use] - pub fn freshness(&self) -> Freshness { + pub const fn freshness(&self) -> Freshness { Freshness { server: self.policy.freshness_window, world: None, diff --git a/pkgs/id/src/shell_contract.rs b/pkgs/id/src/shell_contract.rs index 6506ef817e..cdd41f4cae 100644 --- a/pkgs/id/src/shell_contract.rs +++ b/pkgs/id/src/shell_contract.rs @@ -431,7 +431,7 @@ fn check_fields( return Err(format!("`{kind}` needs field `{name}`")); } Some(value) => { - check_value(field, value).map_err(|error| format!("`{kind}.{name}` {error}"))? + check_value(field, value).map_err(|error| format!("`{kind}.{name}` {error}"))?; } } } diff --git a/pkgs/id/src/tag_claims.rs b/pkgs/id/src/tag_claims.rs index 6b8126310c..509c5d5976 100644 --- a/pkgs/id/src/tag_claims.rs +++ b/pkgs/id/src/tag_claims.rs @@ -156,6 +156,7 @@ fn check_text(field: &str, text: &str, min: usize, max: usize) -> Result<(), Tag } /// The events that `start` reaches by following parent links: its own causal past, transitively. +/// /// `parents` maps each event to the events it names, its `after` hashes and its backlink. The /// starting events are included. #[must_use] diff --git a/pkgs/id/src/world_caps.rs b/pkgs/id/src/world_caps.rs index bfa20f3cfe..e53ec0011b 100644 --- a/pkgs/id/src/world_caps.rs +++ b/pkgs/id/src/world_caps.rs @@ -27,7 +27,7 @@ //! //! A refused request or subscription carries a stable wire `"error"` code and, //! when the refusal has a specific cause, an advisory `"reason"`. Codes are -//! part of the wire contract and never change meaning; the DoS suite asserts +//! part of the wire contract and never change meaning; the `DoS` suite asserts //! them. //! //! | Code | Meaning | @@ -352,7 +352,7 @@ pub struct CapError { /// The stable wire code of a refused request or subscription. /// -/// These are documented in the capability guide and asserted by the DoS +/// These are documented in the capability guide and asserted by the `DoS` /// suite; adding a code changes the wire contract, so new refusals reuse an /// existing code before a new one is considered. #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/pkgs/id/src/world_doctor.rs b/pkgs/id/src/world_doctor.rs index 0f577c4b2b..63212516df 100644 --- a/pkgs/id/src/world_doctor.rs +++ b/pkgs/id/src/world_doctor.rs @@ -199,7 +199,7 @@ pub fn check_toolchain(inputs: &DoctorInputs) -> Finding { }; // A configured binary must exist. A bare name resolves through PATH. let exists = if roc_bin.contains('/') { - std::path::Path::new(roc_bin).is_file() + Path::new(roc_bin).is_file() } else { std::env::split_paths(&std::env::var_os("PATH").unwrap_or_default()) .map(|dir| dir.join(roc_bin)) diff --git a/pkgs/id/src/world_manifest.rs b/pkgs/id/src/world_manifest.rs index 03c4cf9a23..c63e797c2b 100644 --- a/pkgs/id/src/world_manifest.rs +++ b/pkgs/id/src/world_manifest.rs @@ -56,7 +56,7 @@ pub struct WorldManifest { /// The relevant current state of a live world, as `id world stats` would see /// it. This is the projection a manifest is compared against. -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, Default)] pub struct WorldState { /// The active module's content hash, if a program is installed. pub module_hash: Option, @@ -72,19 +72,6 @@ pub struct WorldState { pub schedules: BTreeMap, } -impl Default for WorldState { - fn default() -> Self { - Self { - module_hash: None, - seed: 0, - grants: Vec::new(), - ceiling: None, - profile: WorldExecutionProfile::default(), - schedules: BTreeMap::new(), - } - } -} - /// One reconciliation step, in the order a server applies it. Module install /// comes first because a changed seed or profile rides on the next install. #[derive(Clone, Debug, PartialEq, Eq)] @@ -131,7 +118,7 @@ pub enum ApplyStep { impl ApplyStep { /// A stable, human-readable name for the step. #[must_use] - pub fn kind(&self) -> &'static str { + pub const fn kind(&self) -> &'static str { match self { Self::InstallModule { .. } => "install_module", Self::SetGrants { .. } => "set_grants", @@ -388,7 +375,7 @@ fn render_steps(steps: &[ApplyStep]) -> String { } } ApplyStep::SetGrants { grants } => { - out.push_str(&format!("~ grants [{}]\n", grants.join(", "))) + out.push_str(&format!("~ grants [{}]\n", grants.join(", "))); } ApplyStep::SetCeiling { ceiling } => match ceiling { Some(names) => { diff --git a/pkgs/id/src/world_presentation.rs b/pkgs/id/src/world_presentation.rs index 7424aed397..f7143583a7 100644 --- a/pkgs/id/src/world_presentation.rs +++ b/pkgs/id/src/world_presentation.rs @@ -87,16 +87,16 @@ impl ScreenSurface { for y in 0..height { let start = y * usize::from(self.width); let mut row = self.cells[start..start + width].to_vec(); - if row.last().is_some_and(|cell| cell.columns == 2) { - if let Some(last) = row.last_mut() { - *last = ScreenCell { - symbol: " ".to_owned(), - fg: 0, - bg: 0, - bold: false, - columns: 1, - }; - } + if row.last().is_some_and(|cell| cell.columns == 2) + && let Some(last) = row.last_mut() + { + *last = ScreenCell { + symbol: " ".to_owned(), + fg: 0, + bg: 0, + bold: false, + columns: 1, + }; } cells.extend(row); } diff --git a/pkgs/id/src/world_session/mod.rs b/pkgs/id/src/world_session/mod.rs index 1600957577..befee87148 100644 --- a/pkgs/id/src/world_session/mod.rs +++ b/pkgs/id/src/world_session/mod.rs @@ -51,7 +51,7 @@ mod tests; mod types; pub(crate) use types::{ - CAPS_CEILING_NOTICE, ClientFrame, CompileFile, MAX_ADMIN_TOKEN_BYTES, MAX_CAPABILITY_BYTES, + CAPS_CEILING_NOTICE, ClientFrame, MAX_ADMIN_TOKEN_BYTES, MAX_CAPABILITY_BYTES, MAX_CONCURRENT_MODULE_UPLOADS, ServerFrame, invite_bounds, }; pub use types::{ @@ -186,7 +186,7 @@ impl WorldService { /// The world's host metrics registry (F11.7), for metering the /// frames this service sends. - pub(crate) fn frame_meter(&self) -> &WorldMetrics { + pub(crate) const fn frame_meter(&self) -> &WorldMetrics { &self.metrics } @@ -1165,14 +1165,12 @@ async fn run_world_session(service: &WorldService, io: &mut I, fra let auth_ok = if let Some(admin) = admin_token.as_deref() { service.authorize_admin(Some(admin)).is_ok() } else if let Some(cap) = capability.as_deref() { - let token = JoinCapability::from_wire(cap.to_string()); + let token = JoinCapability::from_wire(cap.to_owned()); service.world().participant_id(token).await.is_ok() } else { false }; - if !auth_ok { - let _ = send_error(service.frame_meter(), io, "access denied").await; - } else { + if auth_ok { match service.world().execution_profile().await { Ok(profile) => { let _ = send_json( @@ -1192,6 +1190,8 @@ async fn run_world_session(service: &WorldService, io: &mut I, fra let _ = send_error(service.frame_meter(), io, &format!("{error:#}")).await; } } + } else { + let _ = send_error(service.frame_meter(), io, "access denied").await; } } #[cfg(feature = "sandbox")] @@ -1325,8 +1325,8 @@ async fn query_session(service: &WorldService, io: &mut I, first: // Authorized exactly like `info`: holding a capability // that snapshots the world is enough to read its metrics. let token = JoinCapability::from_wire(capability); - match service.world().snapshot(token).await { - Ok(_) => match service.world().metrics().await { + if let Ok(_) = service.world().snapshot(token).await { + match service.world().metrics().await { Ok(metrics) => { if !send_json( service.frame_meter(), @@ -1343,11 +1343,10 @@ async fn query_session(service: &WorldService, io: &mut I, first: send_error(service.frame_meter(), io, &format!("{error:#}")).await; return; } - }, - Err(_) => { - let _ = send_error(service.frame_meter(), io, "join denied").await; - return; } + } else { + let _ = send_error(service.frame_meter(), io, "join denied").await; + return; } } ClientFrame::Records { diff --git a/pkgs/id/src/world_store.rs b/pkgs/id/src/world_store.rs index 7d9d7e28a0..e153b952e0 100644 --- a/pkgs/id/src/world_store.rs +++ b/pkgs/id/src/world_store.rs @@ -28,8 +28,8 @@ use std::path::{Path, PathBuf}; use anyhow::{Context, Result, bail, ensure}; use crate::world::{ - JOURNAL_VERSION, JOURNAL_VERSION_EXECUTION_PROFILE, JournalEntry, WorldCore, WorldEventKind, - WorldHandle, WorldJournal, WorldLimits, WorldProgram, journal_version_required_by, + JOURNAL_VERSION, JournalEntry, WorldCore, WorldEventKind, WorldHandle, WorldJournal, + WorldLimits, WorldProgram, journal_version_required_by, }; use crate::world_session::{WorldService, module_hash}; @@ -1573,7 +1573,7 @@ mod tests { matches!( entries[0], JournalEntry::Created { - version: JOURNAL_VERSION_EXECUTION_PROFILE, + version: crate::world::JOURNAL_VERSION_EXECUTION_PROFILE, .. } ), @@ -1619,7 +1619,7 @@ mod tests { assert!(matches!( entries[0], JournalEntry::Created { - version: JOURNAL_VERSION_EXECUTION_PROFILE, + version: crate::world::JOURNAL_VERSION_EXECUTION_PROFILE, .. } )); @@ -1627,7 +1627,7 @@ mod tests { assert!(matches!( on_disk[0], JournalEntry::Created { - version: JOURNAL_VERSION_EXECUTION_PROFILE, + version: crate::world::JOURNAL_VERSION_EXECUTION_PROFILE, .. } ));