Snapshot only committed extensions and publish the last-good marker atomically
This commit is contained in:
@@ -36,6 +36,8 @@ fn setup(directory: &Path) -> Result<()> {
|
||||
"git",
|
||||
"-p",
|
||||
"curl",
|
||||
"-p",
|
||||
"sausage-archive-tools",
|
||||
"--target",
|
||||
"wasm32-wasip2",
|
||||
"--target-dir"
|
||||
@@ -58,6 +60,7 @@ fn setup(directory: &Path) -> Result<()> {
|
||||
std::fs::create_dir_all(disk.join("bin"))?;
|
||||
for (source, name) in [
|
||||
("git.wasm", "git.wasm"),
|
||||
("tar.wasm", "tar.wasm"),
|
||||
("curl.wasm", "curl.wasm"),
|
||||
("brush.wasm", "sh.wasm"),
|
||||
] {
|
||||
|
||||
@@ -141,7 +141,15 @@ pub fn build_git() -> &'static Path {
|
||||
cwd_init();
|
||||
assert!(
|
||||
Command::new("cargo")
|
||||
.args(["build", "--release", "-p", "git", "--manifest-path"])
|
||||
.args([
|
||||
"build",
|
||||
"--release",
|
||||
"-p",
|
||||
"git",
|
||||
"-p",
|
||||
"sausage-archive-tools",
|
||||
"--manifest-path"
|
||||
])
|
||||
.arg(userland.join("Cargo.toml"))
|
||||
.args(["--target", "wasm32-wasip2", "--target-dir"])
|
||||
.arg(&target)
|
||||
|
||||
@@ -52,10 +52,12 @@ async fn core_extensions() -> anyhow::Result<()> {
|
||||
let world = World::open(dir.path())?;
|
||||
let disk = dir.path().join("world");
|
||||
std::fs::create_dir_all(disk.join("bin"))?;
|
||||
std::fs::copy(
|
||||
target.join("wasm32-wasip2/release/git.wasm"),
|
||||
disk.join("bin/git.wasm"),
|
||||
)?;
|
||||
for binary in ["git", "tar"] {
|
||||
std::fs::copy(
|
||||
target.join(format!("wasm32-wasip2/release/{binary}.wasm")),
|
||||
disk.join(format!("bin/{binary}.wasm")),
|
||||
)?;
|
||||
}
|
||||
let source = disk.join("src/sausage");
|
||||
for name in ["core", "models", "prompt", "conversations"] {
|
||||
copy_tree(
|
||||
|
||||
@@ -38,10 +38,12 @@ fn prepare(dir: &Path) -> anyhow::Result<()> {
|
||||
let source = Path::new(env!("CARGO_MANIFEST_DIR")).join("..");
|
||||
let target = crate::common::build_git();
|
||||
std::fs::create_dir_all(disk.join("bin"))?;
|
||||
std::fs::copy(
|
||||
target.join("wasm32-wasip2/release/git.wasm"),
|
||||
disk.join("bin/git.wasm"),
|
||||
)?;
|
||||
for binary in ["git", "tar"] {
|
||||
std::fs::copy(
|
||||
target.join(format!("wasm32-wasip2/release/{binary}.wasm")),
|
||||
disk.join(format!("bin/{binary}.wasm")),
|
||||
)?;
|
||||
}
|
||||
copy_tree(&source.join("extensions"), &repo.join("extensions"))?;
|
||||
std::fs::create_dir_all(repo.join("extensions/probe"))?;
|
||||
std::fs::write(
|
||||
|
||||
@@ -95,8 +95,12 @@ async fn world_extensions() -> anyhow::Result<()> {
|
||||
let world = World::open(dir.path())?;
|
||||
let disk = dir.path().join("world");
|
||||
std::fs::create_dir_all(disk.join("bin"))?;
|
||||
let git = target.join("wasm32-wasip2/release/git.wasm");
|
||||
std::fs::copy(git, disk.join("bin/git.wasm"))?;
|
||||
for binary in ["git", "tar"] {
|
||||
std::fs::copy(
|
||||
target.join(format!("wasm32-wasip2/release/{binary}.wasm")),
|
||||
disk.join(format!("bin/{binary}.wasm")),
|
||||
)?;
|
||||
}
|
||||
let repo = disk.join("src/sausage");
|
||||
std::fs::create_dir_all(&repo)?;
|
||||
assert!(
|
||||
|
||||
+38
-13
@@ -22,7 +22,15 @@ impl Exec for Author {
|
||||
] {
|
||||
options.env.push((key.into(), value.into()));
|
||||
}
|
||||
self.0.exec(command, options, output).await
|
||||
let label = format!("{command:?}");
|
||||
let budget = options.timeout;
|
||||
let started = std::time::Instant::now();
|
||||
let result = self.0.exec(command, options, output).await;
|
||||
eprintln!(
|
||||
"Extension {label}: deadline {budget:?}, elapsed {:?}, result {result:?}",
|
||||
started.elapsed()
|
||||
);
|
||||
result
|
||||
}
|
||||
}
|
||||
#[tokio::test(flavor = "current_thread")]
|
||||
@@ -41,6 +49,8 @@ async fn commits_and_restart() -> anyhow::Result<()> {
|
||||
"git",
|
||||
"-p",
|
||||
"sausage-exec-tools",
|
||||
"-p",
|
||||
"sausage-archive-tools",
|
||||
"--manifest-path"
|
||||
])
|
||||
.arg(userland.join("Cargo.toml"))
|
||||
@@ -59,7 +69,7 @@ async fn commits_and_restart() -> anyhow::Result<()> {
|
||||
target.join("wasm32-wasip2/release/git.wasm"),
|
||||
disk.join("bin/git.wasm"),
|
||||
)?;
|
||||
for name in ["extensions-revert", "env"] {
|
||||
for name in ["extensions-revert", "env", "tar"] {
|
||||
std::fs::copy(
|
||||
target.join(format!("wasm32-wasip2/release/{name}.wasm")),
|
||||
disk.join(format!("bin/{name}.wasm")),
|
||||
@@ -113,7 +123,7 @@ async fn commits_and_restart() -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Model command time without a wall-clock delay, including work longer than the old 30 second budget.
|
||||
/// Model loader commands without delays, and require cancellation instead of a wall-clock deadline.
|
||||
struct LoaderCommand {
|
||||
root: Arc<dyn sausage_vfs::Layer>,
|
||||
failures: usize,
|
||||
@@ -131,18 +141,21 @@ impl Exec for LoaderCommand {
|
||||
let Command::Argv(args) = command else {
|
||||
anyhow::bail!("unexpected shell")
|
||||
};
|
||||
assert!(
|
||||
options.timeout.is_none(),
|
||||
"Loader work must not have a wall-clock deadline"
|
||||
);
|
||||
if args[0] == "tar" {
|
||||
return Ok(0);
|
||||
}
|
||||
match args[1].as_str() {
|
||||
"rev-parse" => output(Stream::Stdout, b"new\n"),
|
||||
"worktree" if args[2] == "prune" => {}
|
||||
"worktree" if args[2] == "add" => {
|
||||
"ls-tree" => output(Stream::Stdout, b"extensions\n"),
|
||||
"archive" => {
|
||||
let attempt = self
|
||||
.attempts
|
||||
.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
|
||||
if options
|
||||
.timeout
|
||||
.is_some_and(|budget| budget < std::time::Duration::from_secs(31))
|
||||
|| (attempt < self.failures && self.timeout)
|
||||
{
|
||||
if attempt < self.failures && self.timeout {
|
||||
anyhow::bail!("command timed out");
|
||||
}
|
||||
if attempt < self.failures {
|
||||
@@ -159,9 +172,21 @@ impl Exec for LoaderCommand {
|
||||
"Retry must publish its error: {status}"
|
||||
);
|
||||
}
|
||||
let snapshot = &args[4];
|
||||
let archive = args[3].strip_prefix("--output=").unwrap();
|
||||
let file = self
|
||||
.root
|
||||
.open(
|
||||
archive,
|
||||
sausage_vfs::Open {
|
||||
write: true,
|
||||
create: true,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
file.write(0, vec![]).await?;
|
||||
let snapshot = format!("{}.tmp", archive.strip_suffix(".tar").unwrap());
|
||||
for path in [
|
||||
snapshot.clone(),
|
||||
format!("{snapshot}/extensions"),
|
||||
format!("{snapshot}/extensions/demo"),
|
||||
] {
|
||||
@@ -217,7 +242,7 @@ async fn loader_command(failures: usize, timeout: bool) -> anyhow::Result<()> {
|
||||
const testState = testLoader.state();
|
||||
if(testState.good !== '{expected}') throw new Error(JSON.stringify(testState));
|
||||
if((testState.error !== null) !== ({expected:?} === 'old')) throw new Error(JSON.stringify(testState));
|
||||
if(testState.error && !testState.error.includes('git worktree add')) throw new Error(testState.error);
|
||||
if(testState.error && !testState.error.includes('git archive')) throw new Error(testState.error);
|
||||
await testLoader.close();
|
||||
await testHarness.close(BACKGROUND_CONTEXT);
|
||||
"#
|
||||
|
||||
@@ -13,10 +13,12 @@ fn prepare(dir: &Path) -> anyhow::Result<()> {
|
||||
let source = Path::new(env!("CARGO_MANIFEST_DIR")).join("..");
|
||||
let target = crate::common::build_git();
|
||||
std::fs::create_dir_all(disk.join("bin"))?;
|
||||
std::fs::copy(
|
||||
target.join("wasm32-wasip2/release/git.wasm"),
|
||||
disk.join("bin/git.wasm"),
|
||||
)?;
|
||||
for binary in ["git", "tar"] {
|
||||
std::fs::copy(
|
||||
target.join(format!("wasm32-wasip2/release/{binary}.wasm")),
|
||||
disk.join(format!("bin/{binary}.wasm")),
|
||||
)?;
|
||||
}
|
||||
crate::common::copy_tree(&source.join("extensions"), &repo.join("extensions"))?;
|
||||
std::fs::create_dir_all(repo.join("agents"))?;
|
||||
std::fs::create_dir_all(repo.join("extensions/probe"))?;
|
||||
|
||||
@@ -26,6 +26,8 @@ fn prepare(dir: &Path) -> anyhow::Result<()> {
|
||||
"git",
|
||||
"-p",
|
||||
"curl",
|
||||
"-p",
|
||||
"sausage-archive-tools",
|
||||
"--manifest-path"
|
||||
])
|
||||
.arg(userland.join("Cargo.toml"))
|
||||
@@ -57,10 +59,12 @@ fn prepare(dir: &Path) -> anyhow::Result<()> {
|
||||
target.join("wasm32-wasip2/release/harness-api-client.wasm"),
|
||||
disk.join("bin/harness-api-client.wasm"),
|
||||
)?;
|
||||
std::fs::copy(
|
||||
target.join("wasm32-wasip2/release/git.wasm"),
|
||||
disk.join("bin/git.wasm"),
|
||||
)?;
|
||||
for binary in ["git", "tar"] {
|
||||
std::fs::copy(
|
||||
target.join(format!("wasm32-wasip2/release/{binary}.wasm")),
|
||||
disk.join(format!("bin/{binary}.wasm")),
|
||||
)?;
|
||||
}
|
||||
std::fs::copy(
|
||||
target.join("wasm32-wasip2/release/curl.wasm"),
|
||||
disk.join("bin/curl.wasm"),
|
||||
|
||||
@@ -17,10 +17,12 @@ fn prepare(dir: &Path) -> anyhow::Result<()> {
|
||||
let source = Path::new(env!("CARGO_MANIFEST_DIR")).join("..");
|
||||
let target = crate::common::build_git();
|
||||
std::fs::create_dir_all(disk.join("bin"))?;
|
||||
std::fs::copy(
|
||||
target.join("wasm32-wasip2/release/git.wasm"),
|
||||
disk.join("bin/git.wasm"),
|
||||
)?;
|
||||
for binary in ["git", "tar"] {
|
||||
std::fs::copy(
|
||||
target.join(format!("wasm32-wasip2/release/{binary}.wasm")),
|
||||
disk.join(format!("bin/{binary}.wasm")),
|
||||
)?;
|
||||
}
|
||||
for directory in [
|
||||
"extensions/subagents",
|
||||
"extensions/messages",
|
||||
|
||||
@@ -338,6 +338,8 @@ async fn bundled_extensions_load() -> anyhow::Result<()> {
|
||||
const bundleLoader = await loadExtensions(bundleHarness, bundleRegistry, bundleStorage,
|
||||
bundleModels, BACKGROUND_CONTEXT, [CodingTools2, CredentialRequests]);
|
||||
if (bundleLoader.state().error) throw new Error(bundleLoader.state().error);
|
||||
const snapshotEntries=await fs2.list(`/run/sausage/extensions/${{bundleLoader.state().good}}`);
|
||||
if(JSON.stringify(snapshotEntries.map(entry=>entry.name)) !== '["extensions"]') throw new Error(JSON.stringify(snapshotEntries));
|
||||
await bundleLoader.close();
|
||||
await bundleHarness.close(BACKGROUND_CONTEXT);
|
||||
"#
|
||||
|
||||
+6
-4
@@ -30,10 +30,12 @@ fn prepare(dir: &Path, all_extensions: bool) -> anyhow::Result<()> {
|
||||
let source = Path::new(env!("CARGO_MANIFEST_DIR")).join("..");
|
||||
let target = crate::common::build_git();
|
||||
std::fs::create_dir_all(disk.join("bin"))?;
|
||||
std::fs::copy(
|
||||
target.join("wasm32-wasip2/release/git.wasm"),
|
||||
disk.join("bin/git.wasm"),
|
||||
)?;
|
||||
for binary in ["git", "tar"] {
|
||||
std::fs::copy(
|
||||
target.join(format!("wasm32-wasip2/release/{binary}.wasm")),
|
||||
disk.join(format!("bin/{binary}.wasm")),
|
||||
)?;
|
||||
}
|
||||
if !target.join("wasm32-wasip2/release/brush.wasm").exists() {
|
||||
anyhow::ensure!(
|
||||
crate::common::build_brush()?.success(),
|
||||
|
||||
+6
-1
@@ -24,7 +24,9 @@ fn prepare(dir: &Path) -> anyhow::Result<PathBuf> {
|
||||
.args(["rev-parse", "HEAD"])
|
||||
.output()?;
|
||||
ensure!(revision.status.success(), "fixture revision");
|
||||
if fs::read(bundle.join("revision")).ok().as_deref() != Some(revision.stdout.as_slice()) {
|
||||
if fs::read(bundle.join("revision")).ok().as_deref() != Some(revision.stdout.as_slice())
|
||||
|| !bundle.join("bin/tar.wasm").is_file()
|
||||
{
|
||||
if !userland.join("cwd-init/init.o").exists() {
|
||||
crate::common::cwd_init();
|
||||
}
|
||||
@@ -42,6 +44,8 @@ fn prepare(dir: &Path) -> anyhow::Result<PathBuf> {
|
||||
"undo",
|
||||
"-p",
|
||||
"sausage-coreutils",
|
||||
"-p",
|
||||
"sausage-archive-tools",
|
||||
]))?;
|
||||
ensure!(
|
||||
crate::common::build_brush()?.success(),
|
||||
@@ -53,6 +57,7 @@ fn prepare(dir: &Path) -> anyhow::Result<PathBuf> {
|
||||
("brush", "sh"),
|
||||
("brush", "bash"),
|
||||
("git", "git"),
|
||||
("tar", "tar"),
|
||||
("cargo", "cargo"),
|
||||
("box", "box"),
|
||||
("undo", "undo"),
|
||||
|
||||
@@ -10,10 +10,12 @@ async fn plan_todos_and_restart() -> anyhow::Result<()> {
|
||||
let disk = dir.path().join("world");
|
||||
let _world = World::open(dir.path())?;
|
||||
std::fs::create_dir_all(disk.join("bin"))?;
|
||||
std::fs::copy(
|
||||
target.join("wasm32-wasip2/release/git.wasm"),
|
||||
disk.join("bin/git.wasm"),
|
||||
)?;
|
||||
for binary in ["git", "tar"] {
|
||||
std::fs::copy(
|
||||
target.join(format!("wasm32-wasip2/release/{binary}.wasm")),
|
||||
disk.join(format!("bin/{binary}.wasm")),
|
||||
)?;
|
||||
}
|
||||
let repo = disk.join("src/sausage");
|
||||
std::fs::create_dir_all(&repo)?;
|
||||
assert!(
|
||||
|
||||
@@ -15,10 +15,12 @@ fn prepare(dir: &Path) -> anyhow::Result<()> {
|
||||
let source = Path::new(env!("CARGO_MANIFEST_DIR")).join("..");
|
||||
let target = crate::common::build_git();
|
||||
std::fs::create_dir_all(disk.join("bin"))?;
|
||||
std::fs::copy(
|
||||
target.join("wasm32-wasip2/release/git.wasm"),
|
||||
disk.join("bin/git.wasm"),
|
||||
)?;
|
||||
for binary in ["git", "tar"] {
|
||||
std::fs::copy(
|
||||
target.join(format!("wasm32-wasip2/release/{binary}.wasm")),
|
||||
disk.join(format!("bin/{binary}.wasm")),
|
||||
)?;
|
||||
}
|
||||
for directory in [
|
||||
"extensions/subagents",
|
||||
"extensions/models",
|
||||
|
||||
@@ -17,10 +17,12 @@ fn prepare(dir: &Path) -> anyhow::Result<()> {
|
||||
let source = Path::new(env!("CARGO_MANIFEST_DIR")).join("..");
|
||||
let target = crate::common::build_git();
|
||||
std::fs::create_dir_all(disk.join("bin"))?;
|
||||
std::fs::copy(
|
||||
target.join("wasm32-wasip2/release/git.wasm"),
|
||||
disk.join("bin/git.wasm"),
|
||||
)?;
|
||||
for binary in ["git", "tar"] {
|
||||
std::fs::copy(
|
||||
target.join(format!("wasm32-wasip2/release/{binary}.wasm")),
|
||||
disk.join(format!("bin/{binary}.wasm")),
|
||||
)?;
|
||||
}
|
||||
for directory in [
|
||||
"extensions/subagents",
|
||||
"extensions/messages",
|
||||
|
||||
@@ -34,7 +34,7 @@ fn prepare(dir: &Path) -> anyhow::Result<()> {
|
||||
assert!(crate::common::build_brush()?.success());
|
||||
}
|
||||
std::fs::create_dir_all(disk.join("bin"))?;
|
||||
for (binary, name) in [("git", "git"), ("brush", "sh")] {
|
||||
for (binary, name) in [("git", "git"), ("tar", "tar"), ("brush", "sh")] {
|
||||
std::fs::copy(
|
||||
target.join(format!("wasm32-wasip2/release/{binary}.wasm")),
|
||||
disk.join(format!("bin/{name}.wasm")),
|
||||
|
||||
Reference in New Issue
Block a user