Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore(skills): remove redundant bundled-skill tests

Steven Enamakel8b05039185cf
diff --git a/crates/openhuman-core/src/skills/bundled/mod_tests.rs b/crates/openhuman-core/src/skills/bundled/mod_tests.rs
index 71e06ce2a1..6844f8121b 100644
--- a/crates/openhuman-core/src/skills/bundled/mod_tests.rs
+++ b/crates/openhuman-core/src/skills/bundled/mod_tests.rs
@@ -1,48 +1,9 @@
-//! Tests for the compiled-in skill table and its materialisation.
+//! Tests for the compiled-in skill table and its host integration.
+//!
+//! Bundle validation, digests and materialisation are tested in `tinyskills`.
use super::*;
-const A: BundledFile = BundledFile {
- path: "WORKFLOW.md",
- contents: "---\nname: sample\ndescription: a sample\n---\n\nbody\n",
-};
-const B: BundledFile = BundledFile {
- path: "references/detail.md",
- contents: "detail\n",
-};
-
-const SAMPLE: BundledSkill = BundledSkill {
- dir_name: "sample",
- files: &[A, B],
-};
-
-fn validate_relative_path(dir_name: &str, path: &str) -> Result<(), String> {
- let path: &'static str = Box::leak(path.to_owned().into_boxed_str());
- let mut files = vec![BundledFile {
- path: "WORKFLOW.md",
- contents: "---\nname: test\ndescription: test\n---\n",
- }];
- if path != "WORKFLOW.md" {
- files.push(BundledFile {
- path,
- contents: "body",
- });
- }
- let skill = BundledSkill {
- dir_name: Box::leak(dir_name.to_owned().into_boxed_str()),
- files: Box::leak(files.into_boxed_slice()),
- };
- skill.validate()
-}
-
-fn install_one(root: &std::path::Path, skill: &BundledSkill) -> Result<bool, String> {
- let report = tinyskills::install(root, &[*skill]);
- if let Some((_, error)) = report.failed.into_iter().next() {
- return Err(error);
- }
- Ok(!report.written.is_empty())
-}
-
#[test]
fn every_shipped_bundle_is_valid() {
// The one assertion that covers the real table. `validate` exists because
@@ -69,146 +30,6 @@ fn shipped_bundle_names_are_unique() {
}
}
-#[test]
-fn the_digest_covers_paths_as_well_as_contents() {
- // The length-prefix rule from `digest`'s docs: moving a byte between two
- // files, or renaming a file, must change the digest. Without prefixing,
- // both of these collide with SAMPLE.
- let moved = BundledSkill {
- dir_name: "sample",
- files: &[
- BundledFile {
- path: "WORKFLOW.md",
- contents: A.contents,
- },
- BundledFile {
- path: "references/detail.md",
- contents: "detai",
- },
- ],
- };
- let renamed = BundledSkill {
- dir_name: "sample",
- files: &[
- A,
- BundledFile {
- path: "references/other.md",
- contents: B.contents,
- },
- ],
- };
- assert_ne!(SAMPLE.digest(), moved.digest());
- assert_ne!(SAMPLE.digest(), renamed.digest());
-}
-
-#[test]
-fn a_traversal_path_is_rejected() {
- // Checked against the free function rather than through `validate`,
- // because `BundledSkill::files` is `&'static [_]` — a table compiled into
- // the binary cannot be assembled from loop variables, which is itself part
- // of why the table is safe.
- for bad in [
- "../escape.md",
- "refs/../../escape.md",
- "/etc/passwd",
- "refs//x.md",
- "C:/windows/system32",
- ".hidden.md",
- "",
- ] {
- assert!(
- validate_relative_path("sample", bad).is_err(),
- "`{bad}` must be rejected as a bundled file path"
- );
- }
- for good in ["WORKFLOW.md", "references/expressions.md", "scripts/run.py"] {
- assert!(
- validate_relative_path("sample", good).is_ok(),
- "`{good}` must be accepted"
- );
- }
-}
-
-#[test]
-fn a_bad_dir_name_is_rejected() {
- for bad in ["", ".hidden", "a/b", "a\\b"] {
- let skill = BundledSkill {
- dir_name: bad,
- files: &[A],
- };
- assert!(
- skill.validate().is_err(),
- "`{bad}` must be rejected as a dir_name"
- );
- }
-}
-
-#[test]
-fn a_bundle_with_no_manifest_is_rejected() {
- // Discovery only loads a directory holding WORKFLOW.md / SKILL.md /
- // skill.json. A bundle without one would be written out and then silently
- // never appear — the worst failure mode available, because nothing errors.
- let skill = BundledSkill {
- dir_name: "sample",
- files: &[BundledFile {
- path: "references/detail.md",
- contents: "x",
- }],
- };
- assert!(skill.validate().is_err());
-}
-
-#[test]
-fn install_writes_the_files_and_is_idempotent() {
- let tmp = tempfile::tempdir().expect("tempdir");
- let root = builtin_root(tmp.path());
-
- assert!(install_one(&root, &SAMPLE).expect("first install"));
- let body = std::fs::read_to_string(root.join("sample").join("WORKFLOW.md")).expect("body");
- assert_eq!(body, A.contents);
- let detail =
- std::fs::read_to_string(root.join("sample").join("references/detail.md")).expect("detail");
- assert_eq!(detail, B.contents);
-
- // Second call must not rewrite — the digest matches.
- assert!(!install_one(&root, &SAMPLE).expect("second install"));
-}
-
-#[test]
-fn a_version_bump_removes_a_file_the_new_version_dropped() {
- // The reason `install_one` deletes instead of overwriting. A stale
- // reference doc left behind would keep answering `read_workflow_resource`
- // after the skill stopped shipping it.
- let tmp = tempfile::tempdir().expect("tempdir");
- let root = builtin_root(tmp.path());
- assert!(install_one(&root, &SAMPLE).expect("install v1"));
-
- let v2 = BundledSkill {
- dir_name: "sample",
- files: &[A],
- };
- assert!(install_one(&root, &v2).expect("install v2"));
- assert!(
- !root.join("sample").join("references/detail.md").exists(),
- "the dropped reference file must not survive the upgrade"
- );
-}
-
-#[test]
-fn an_interrupted_install_is_redone() {
- // The digest is written last on purpose. Simulate the interruption by
- // removing it: the next install must rewrite rather than trust the
- // directory.
- let tmp = tempfile::tempdir().expect("tempdir");
- let root = builtin_root(tmp.path());
- assert!(install_one(&root, &SAMPLE).expect("install"));
- std::fs::remove_file(root.join("sample").join(".digest")).expect("remove digest");
- assert!(
- install_one(&root, &SAMPLE).expect("reinstall"),
- "a bundle with no digest must be rewritten"
- );
-}
-
#[test]
fn install_reports_rather_than_fails_the_boot() {
// `install` is called from workspace init. A workspace it cannot write