From 7d1148a2a093d354b79e0a3625403737927586af Mon Sep 17 00:00:00 2001 From: David Corvoysier Date: Fri, 13 Nov 2026 10:07:36 +0000 Subject: [PATCH 1/3] test: pass the suite under any umask funes refuses an integration others could write to. Some test fixtures left their modes to the umask, so under umask 002 (the default on Debian and Ubuntu, where each user has a group of their own) 18 tests failed on funes refusing what they built: - the registry tests' integration() helper, and the temporary directories ten of them used as the registry root - the bundle add_fifth_integration places by hand, and the .memory note it writes Each now sets the mode funes gives its own files. CI runs the full suite under umask 002, so a fixture that depends on the umask fails there. The unit job keeps the runner's 022. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 5 ++++- CONTRIBUTING.md | 4 ++++ src/agents/registry.rs | 34 +++++++++++++++++++++++----------- tests/add_fifth_integration.rs | 13 +++++++++---- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a319e173..3f95eabc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -201,10 +201,13 @@ jobs: # is everything any test needs, so a test added later is covered without touching this file. # The Hub ones skip themselves when the secret is absent (on a fork) and clean up the # scratch repos they create. + # Under umask 002, the default on hosts with a group per user (Debian, Ubuntu). funes refuses + # an integration others could write to, so a test fixture that leaves its modes to the umask + # fails here, not only on those hosts. The unit job keeps the runner's 022. - name: Integration tests env: HF_FUNES_TEST_TOKEN: ${{ secrets.HF_FUNES_TEST_TOKEN }} - run: cargo test --profile ci -- --nocapture + run: umask 002 && cargo test --profile ci -- --nocapture - name: Save model weights if: ${{ !cancelled() && github.ref == 'refs/heads/main' && steps.models.outputs.cache-hit != 'true' }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c9a8ec77..a071cbae 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,6 +60,10 @@ fine; CI runs them with the repository secret. The ones that write each create a repo of their own under `optimum-internal-testing` and delete it after: the Hub's commit lock is repo-wide, so two test runs sharing a repo would refuse each other's commits. +The suite passes under any umask, and CI runs it under `umask 002`. funes refuses an integration +others could write to, so a test that builds one by hand (its directories, its `setup`, a note +beside it) sets their modes itself, as funes does when it installs one. + ## Style - **Format** with `cargo fmt` (stable rustfmt; [rustfmt.toml](rustfmt.toml) carries the one diff --git a/src/agents/registry.rs b/src/agents/registry.rs index 5147e328..5c847d2f 100644 --- a/src/agents/registry.rs +++ b/src/agents/registry.rs @@ -988,10 +988,22 @@ mod tests { format!(r#"{{"contract_version": {contract}, "id": "{id}", "label": "An Agent", "repo": "acme/funes-pi"}}"#) } + /// A registry root closed to other writers, as funes makes its own. `open` judges the root as + /// well, and a temporary directory otherwise takes its mode from the umask, which 002 leaves + /// group-writable. + fn registry_root() -> tempfile::TempDir { + tempfile::Builder::new() + .permissions(std::fs::Permissions::from_mode(0o755)) + .tempdir() + .unwrap() + } + /// Write an integration at `root/` declaring `manifest`, whose `setup` runs `body`. + /// Its directories are created as funes creates its own, so `open` judges what the test meant + /// and not the umask of whoever runs it. fn integration(root: &Path, dir_name: &str, manifest: &str, body: &str) -> PathBuf { let dir = root.join(dir_name); - std::fs::create_dir_all(&dir).unwrap(); + create_owned(&dir).unwrap(); std::fs::write(dir.join("manifest.json"), manifest).unwrap(); let setup = dir.join(SETUP); std::fs::write(&setup, format!("#!/bin/sh\n{body}\n")).unwrap(); @@ -1001,7 +1013,7 @@ mod tests { #[test] fn a_setup_others_could_have_written_is_refused() { - let root = tempfile::tempdir().unwrap(); + let root = registry_root(); let dir = integration(root.path(), "pi", &manifest("pi", CONTRACT_VERSION), "true"); assert!(open(root.path(), "pi").is_ok()); @@ -1563,7 +1575,7 @@ mod tests { /// source is even looked for. #[tokio::test] async fn an_id_that_is_not_one_is_refused_before_anything_is_written() { - let root = tempfile::tempdir().unwrap(); + let root = registry_root(); for id in ["../docs", "Pi", "a/b", ""] { let err = provision(root.path(), id, None).await.unwrap_err().to_string(); assert!(err.contains("not an integration id"), "{id:?}: {err}"); @@ -1576,7 +1588,7 @@ mod tests { #[test] fn the_mismatched_integrations_are_listed_with_their_contract() { - let root = tempfile::tempdir().unwrap(); + let root = registry_root(); integration(root.path(), "pi", &manifest("pi", CONTRACT_VERSION), "true"); integration(root.path(), "codex", &manifest("codex", CONTRACT_VERSION + 1), "true"); integration(root.path(), "hermes", "not json", "true"); @@ -1588,7 +1600,7 @@ mod tests { #[test] fn an_unknown_id_names_what_is_registered() { - let root = tempfile::tempdir().unwrap(); + let root = registry_root(); integration(root.path(), "pi", &manifest("pi", CONTRACT_VERSION), "true"); integration(root.path(), "codex", &manifest("codex", CONTRACT_VERSION), "true"); assert_eq!(registered_ids(root.path()), vec!["codex", "pi"]); @@ -1604,7 +1616,7 @@ mod tests { #[test] fn the_id_must_be_the_directory_name_and_facet_safe() { - let root = tempfile::tempdir().unwrap(); + let root = registry_root(); integration(root.path(), "pi", &manifest("codex", CONTRACT_VERSION), "true"); let err = open(root.path(), "pi").unwrap_err().to_string(); assert!(err.contains("directory name"), "{err}"); @@ -1616,7 +1628,7 @@ mod tests { #[test] fn a_manifest_declares_its_release_and_publisher() { - let root = tempfile::tempdir().unwrap(); + let root = registry_root(); integration( root.path(), "pi", @@ -1657,7 +1669,7 @@ mod tests { #[test] fn a_manifest_is_rejected_rather_than_guessed() { - let root = tempfile::tempdir().unwrap(); + let root = registry_root(); integration( root.path(), "pi", @@ -1679,7 +1691,7 @@ mod tests { #[test] fn setup_must_exist_and_be_executable() { - let root = tempfile::tempdir().unwrap(); + let root = registry_root(); let dir = integration(root.path(), "pi", &manifest("pi", CONTRACT_VERSION), "true"); let setup = dir.join(SETUP); @@ -1696,7 +1708,7 @@ mod tests { /// funes has no record of installing, are refreshed on every run. #[test] fn only_an_install_named_with_from_runs_as_installed() { - let root = tempfile::tempdir().unwrap(); + let root = registry_root(); integration(root.path(), "pi", &manifest("pi", CONTRACT_VERSION), "true"); let manifest: Manifest = serde_json::from_str(&manifest("pi", CONTRACT_VERSION)).unwrap(); assert!(refreshes_on_every_run(root.path(), "pi"), "no record"); @@ -1724,7 +1736,7 @@ mod tests { /// digest: the same digest from another source, or another digest, is not it. #[test] fn the_installed_release_is_known_by_its_recorded_digest() { - let root = tempfile::tempdir().unwrap(); + let root = registry_root(); integration(root.path(), "pi", &manifest("pi", CONTRACT_VERSION), "true"); let manifest: Manifest = serde_json::from_str(&manifest("pi", CONTRACT_VERSION)).unwrap(); let release = Release { diff --git a/tests/add_fifth_integration.rs b/tests/add_fifth_integration.rs index 09489fd4..b7bc90a5 100644 --- a/tests/add_fifth_integration.rs +++ b/tests/add_fifth_integration.rs @@ -9,7 +9,7 @@ mod support; use funes::inference::EmbeddingModel; use funes::memory::dataset; use std::fs; -use std::os::unix::fs::PermissionsExt; +use std::os::unix::fs::{DirBuilderExt, PermissionsExt}; use std::path::{Path, PathBuf}; use std::process::{Command, Output}; @@ -96,10 +96,12 @@ fn bundle(dir: &Path, id: &str, contract: u32, tag: &str) -> PathBuf { bundle_published_by(dir, id, "example/clyde", contract, tag) } -/// [`bundle`], declaring `repo` as where it is published from. +/// [`bundle`], declaring `repo` as where it is published from. Its directories are 0755 whatever +/// the umask, as funes makes its own: funes refuses a bundle under `~/.funes/agents` that others +/// could write to. fn bundle_published_by(dir: &Path, id: &str, repo: &str, contract: u32, tag: &str) -> PathBuf { let dir = dir.to_path_buf(); - fs::create_dir_all(&dir).unwrap(); + fs::DirBuilder::new().recursive(true).mode(0o755).create(&dir).unwrap(); fs::write( dir.join("manifest.json"), format!(r#"{{"contract_version":{contract},"id":"{id}","label":"Clyde","repo":"{repo}","version":"1.0.0"}}"#), @@ -1393,8 +1395,11 @@ fn the_memory_bound_through_one_agent_is_the_hosts() { // included, and the notes beside the agents go. A note saying `local`, which funes never // wrote, is no binding and no disagreement. fs::remove_file(&bound).unwrap(); + // 0644 whatever the umask, as funes wrote them: one others could write is refused. let older = |id: &str, memory: &str| { - fs::write(home.join(format!(".funes/agents/{id}.memory")), format!("{memory}\n")).unwrap() + let note = home.join(format!(".funes/agents/{id}.memory")); + fs::write(¬e, format!("{memory}\n")).unwrap(); + fs::set_permissions(¬e, fs::Permissions::from_mode(0o644)).unwrap(); }; older("clyde", memory); older("dotty", "local"); From 333bb699f99487479776f59054fc924cea7cdde2 Mon Sep 17 00:00:00 2001 From: David Corvoysier Date: Fri, 13 Nov 2026 10:22:32 +0000 Subject: [PATCH 2/3] review: drop the comments that paraphrase the fixtures And the paragraph in CONTRIBUTING. Co-Authored-By: Claude Opus 5.5 --- CONTRIBUTING.md | 4 ---- src/agents/registry.rs | 6 +----- tests/add_fifth_integration.rs | 5 +---- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a071cbae..c9a8ec77 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,10 +60,6 @@ fine; CI runs them with the repository secret. The ones that write each create a repo of their own under `optimum-internal-testing` and delete it after: the Hub's commit lock is repo-wide, so two test runs sharing a repo would refuse each other's commits. -The suite passes under any umask, and CI runs it under `umask 002`. funes refuses an integration -others could write to, so a test that builds one by hand (its directories, its `setup`, a note -beside it) sets their modes itself, as funes does when it installs one. - ## Style - **Format** with `cargo fmt` (stable rustfmt; [rustfmt.toml](rustfmt.toml) carries the one diff --git a/src/agents/registry.rs b/src/agents/registry.rs index 5c847d2f..a5d86a8d 100644 --- a/src/agents/registry.rs +++ b/src/agents/registry.rs @@ -988,9 +988,7 @@ mod tests { format!(r#"{{"contract_version": {contract}, "id": "{id}", "label": "An Agent", "repo": "acme/funes-pi"}}"#) } - /// A registry root closed to other writers, as funes makes its own. `open` judges the root as - /// well, and a temporary directory otherwise takes its mode from the umask, which 002 leaves - /// group-writable. + /// A registry root closed to other writers, as funes makes its own. fn registry_root() -> tempfile::TempDir { tempfile::Builder::new() .permissions(std::fs::Permissions::from_mode(0o755)) @@ -999,8 +997,6 @@ mod tests { } /// Write an integration at `root/` declaring `manifest`, whose `setup` runs `body`. - /// Its directories are created as funes creates its own, so `open` judges what the test meant - /// and not the umask of whoever runs it. fn integration(root: &Path, dir_name: &str, manifest: &str, body: &str) -> PathBuf { let dir = root.join(dir_name); create_owned(&dir).unwrap(); diff --git a/tests/add_fifth_integration.rs b/tests/add_fifth_integration.rs index b7bc90a5..093b895b 100644 --- a/tests/add_fifth_integration.rs +++ b/tests/add_fifth_integration.rs @@ -96,9 +96,7 @@ fn bundle(dir: &Path, id: &str, contract: u32, tag: &str) -> PathBuf { bundle_published_by(dir, id, "example/clyde", contract, tag) } -/// [`bundle`], declaring `repo` as where it is published from. Its directories are 0755 whatever -/// the umask, as funes makes its own: funes refuses a bundle under `~/.funes/agents` that others -/// could write to. +/// [`bundle`], declaring `repo` as where it is published from. fn bundle_published_by(dir: &Path, id: &str, repo: &str, contract: u32, tag: &str) -> PathBuf { let dir = dir.to_path_buf(); fs::DirBuilder::new().recursive(true).mode(0o755).create(&dir).unwrap(); @@ -1395,7 +1393,6 @@ fn the_memory_bound_through_one_agent_is_the_hosts() { // included, and the notes beside the agents go. A note saying `local`, which funes never // wrote, is no binding and no disagreement. fs::remove_file(&bound).unwrap(); - // 0644 whatever the umask, as funes wrote them: one others could write is refused. let older = |id: &str, memory: &str| { let note = home.join(format!(".funes/agents/{id}.memory")); fs::write(¬e, format!("{memory}\n")).unwrap(); From f866f62ee2fbd0e531d6587f643c6672cba6b9fe Mon Sep 17 00:00:00 2001 From: David Corvoysier Date: Fri, 13 Nov 2026 10:25:29 +0000 Subject: [PATCH 3/3] review: leave CI on the runner's umask Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f95eabc..a319e173 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -201,13 +201,10 @@ jobs: # is everything any test needs, so a test added later is covered without touching this file. # The Hub ones skip themselves when the secret is absent (on a fork) and clean up the # scratch repos they create. - # Under umask 002, the default on hosts with a group per user (Debian, Ubuntu). funes refuses - # an integration others could write to, so a test fixture that leaves its modes to the umask - # fails here, not only on those hosts. The unit job keeps the runner's 022. - name: Integration tests env: HF_FUNES_TEST_TOKEN: ${{ secrets.HF_FUNES_TEST_TOKEN }} - run: umask 002 && cargo test --profile ci -- --nocapture + run: cargo test --profile ci -- --nocapture - name: Save model weights if: ${{ !cancelled() && github.ref == 'refs/heads/main' && steps.models.outputs.cache-hit != 'true' }}