Skip to content
Closed
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
6 changes: 3 additions & 3 deletions .github/workflows/id-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
52 changes: 21 additions & 31 deletions .github/workflows/nix-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 * * *"
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pkgs/id/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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<String>,
/// World on the host to use (default: the host's default world).
Expand All @@ -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 <world>@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,
Expand Down
12 changes: 3 additions & 9 deletions pkgs/id/src/commands/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,16 @@ impl SearchOptions {
/// verbatim behaviour.
fn download_output_path(dir: Option<&str>, name: &str) -> Result<String> {
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(),
})
}
Expand Down
8 changes: 2 additions & 6 deletions pkgs/id/src/commands/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,10 @@ fn evaluate_group(group: Hash, members: usize) -> (usize, Option<String>) {
};
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())),
Expand Down
4 changes: 2 additions & 2 deletions pkgs/id/src/commands/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions pkgs/id/src/commands/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions pkgs/id/src/commands/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,20 +495,20 @@ pub async fn cmd_world(command: WorldCommand) -> Result<()> {
.collect::<Vec<_>>()
.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",
applied,
steps.len()
);
}
} else {
println!("dry run: nothing changed");
}
}
client.close();
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 0 additions & 14 deletions pkgs/id/src/event_store/ingest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ingest, StoreError> {
match self {
Expand Down
21 changes: 10 additions & 11 deletions pkgs/id/src/event_store/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl Params {
/// # Errors
///
/// Refuses `k` below 2, and `t` below 1.
pub fn new(k: usize, t: usize) -> Result<Self, ParamsError> {
pub const fn new(k: usize, t: usize) -> Result<Self, ParamsError> {
if k < 2 {
return Err(ParamsError::FanOut(k));
}
Expand Down Expand Up @@ -133,7 +133,7 @@ impl Params {
/// # Errors
///
/// Refuses a budget below one entry.
pub fn with_session_budget(self, bytes: usize) -> Result<Self, ParamsError> {
pub const fn with_session_budget(self, bytes: usize) -> Result<Self, ParamsError> {
if bytes < MIN_FRAME_BUDGET {
return Err(ParamsError::SessionBudget(bytes));
}
Expand Down Expand Up @@ -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()
}

Expand Down Expand Up @@ -388,13 +388,12 @@ impl Party {

/// Appends an entry, merging it into the previous one when both are skips.
fn push(out: &mut Vec<Entry>, upper: Option<Vec<u8>>, 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 });
}
Expand Down
20 changes: 10 additions & 10 deletions pkgs/id/src/event_store/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
///
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)?
Expand Down
3 changes: 2 additions & 1 deletion pkgs/id/src/event_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Mutex<LocalEvents>>` 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
Expand Down Expand Up @@ -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)]
Expand Down
8 changes: 4 additions & 4 deletions pkgs/id/src/local_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ impl LocalEvents {
let mut required: Vec<Hash> = Vec::new();
let mut seen: HashSet<AuthorKey> = 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<Hash> = group.iter().map(|claim| claim.id).collect();
Expand Down
6 changes: 3 additions & 3 deletions pkgs/id/src/meta_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ pub fn expect_ok(resp: MetaResponse) -> Result<MetaResponse> {
/// 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(),
}
}
Expand Down
Loading
Loading