From e7be031238ed155e1610f9daef11d64da166443c Mon Sep 17 00:00:00 2001 From: Surma Date: Fri, 6 Nov 2026 22:21:03 +0000 Subject: [PATCH] Package the complete v3 bundle and retain WITX sources --- README.md | 3 ++- flake.nix | 39 +++++++++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 8e83941..feca733 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Sausage v3 -Sausage is a world of WASI programs and durable agents. The Rust host combines a process table, a shared virtual filesystem, and a durable JavaScript harness. Agents and their programs see the same world. The filesystem prevents mistakes, not attacks between agents. The host credentials manager is the intended security boundary. Hierarchical coordination and the credentials manager remain later phases of the plan. +Sausage is a world of WASI programs and durable agents. The Rust host combines a process table, a shared virtual filesystem, and a durable JavaScript harness. Agents and their programs see the same world. The filesystem prevents mistakes, not attacks between agents. The host credentials manager is the intended security boundary. Hierarchical coordination remains a later phase of the plan. ## Build and run @@ -12,6 +12,7 @@ result/bin/sausage sh /path/to/world -c 'echo hi | tr a-z A-Z; git --version' The package includes the userland bundle. At world creation, the host copies its tools into `/bin` as `.wasm` files. +It also copies a committed source snapshot into `/src/sausage`. The console uses `PI_PROXY_BASE_URL` and `PI_PROXY_API_KEY` from the host environment. Secrets do not enter the world. diff --git a/flake.nix b/flake.nix index 4be7cb2..29699b9 100644 --- a/flake.nix +++ b/flake.nix @@ -9,7 +9,7 @@ crane.url = "github:ipetkov/crane"; }; - outputs = { nixpkgs, flake-utils, rust-overlay, crane, ... }: + outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }: flake-utils.lib.eachSystem flake-utils.lib.allSystems (system: let pkgs = import nixpkgs { @@ -40,7 +40,8 @@ let relative = pkgs.lib.removePrefix (toString ./. + "/") path; in !(pkgs.lib.hasPrefix "userland/" relative || pkgs.lib.hasPrefix "spikes/" relative) && (craneLib.filterCargoSources path type - || pkgs.lib.hasSuffix ".wit" path || pkgs.lib.hasSuffix ".js" path); + || pkgs.lib.hasSuffix ".wit" path || pkgs.lib.hasSuffix ".witx" path + || pkgs.lib.hasSuffix ".js" path); }; v8Archive = pkgs.fetchurl { url = "https://github.com/denoland/rusty_v8/releases/download/v150.4.0/librusty_v8_release_${pkgs.stdenv.hostPlatform.rust.rustcTarget}.a.gz"; @@ -69,13 +70,9 @@ rev = "943553433ae04f5b3bd55d2cf207e39eb9ef2af7"; hash = "sha256-a1eMkqx4nBqJ8R+h+rxtU35pAungcEnXoxwZnb1poH8="; }; - userlandSrc = pkgs.lib.cleanSourceWith { - src = ./.; - filter = path: type: - let relative = pkgs.lib.removePrefix (toString ./. + "/") path; - in type == "directory" || pkgs.lib.hasPrefix "userland/" relative - || pkgs.lib.hasPrefix "host/wit/" relative; - }; + # bundle.nu archives these sources, not the sandbox's development patches. + userlandSrc = pkgs.lib.cleanSource ./.; + revision = self.rev or self.dirtyRev or "unknown"; userlandCommon = { pname = "sausage-userland"; version = "0.3.0"; @@ -85,7 +82,16 @@ cargoLockList = [ ./userland/Cargo.lock ./userland/brush/Cargo.lock ]; }; nativeBuildInputs = [ pkgs.nushell pkgs.wasm-tools pkgs.git pkgs.pkg-config ] ++ mold; + GIT_AUTHOR_NAME = "Sausage"; + GIT_AUTHOR_EMAIL = "sausage@localhost"; + GIT_COMMITTER_NAME = "Sausage"; + GIT_COMMITTER_EMAIL = "sausage@localhost"; + GIT_AUTHOR_DATE = "2000-01-01T00:00:00+0000"; + GIT_COMMITTER_DATE = "2000-01-01T00:00:00+0000"; postPatch = '' + git init --quiet --initial-branch=main + git add host vfs userland Cargo.toml Cargo.lock flake.nix flake.lock README.md AGENTS.md .gitignore + git commit --no-gpg-sign --quiet -m 'Bundle source ${revision}' cp -r ${brushSource} userland/brush/source chmod -R u+w userland/brush/source # The fixed-output source fetch replaces the development checkout's Git check. @@ -97,7 +103,12 @@ preBuild = '' export CARGO_TARGET_DIR="$PWD/target" ''; - buildPhaseCargoCommand = "nu userland/bundle.nu"; + buildPhaseCargoCommand = '' + nu userland/bundle.nu + # bundle.nu sees the reconstructed repository's HEAD. Restore the flake revision. + git -C target/userland/bundle/src/sausage commit --amend --no-gpg-sign --quiet \ + -m 'Bundle source ${revision}' + ''; doCheck = false; } // wasiCcEnv // moldEnv; # Keep the real local patch crates: registry dependencies use their full APIs. @@ -108,7 +119,7 @@ cargoArtifacts = userlandArtifacts; installPhaseCommand = '' mkdir -p $out - cp -a target/userland/bin $out/bin + cp -a target/userland/bundle/. $out/ ''; doInstallCargoArtifacts = false; }); @@ -118,7 +129,7 @@ doCheck = false; nativeBuildInputs = common.nativeBuildInputs ++ [ pkgs.makeWrapper ]; postInstall = '' - wrapProgram $out/bin/sausage --set-default SAUSAGE_USERLAND ${userland}/bin + wrapProgram $out/bin/sausage --set-default SAUSAGE_USERLAND ${userland} ''; meta.mainProgram = "sausage"; }); @@ -127,10 +138,10 @@ checks.package = sausage; checks.tests = craneLib.cargoTest (common // wasiCcEnv // { inherit cargoArtifacts; - cargoExtraArgs = "--workspace --lib --test harness --test p1 --test layers --test regressions --test streams --test wasi"; + cargoExtraArgs = "--workspace --lib --test harness --test p1 --test durable --test 'cred*' --test layers --test regressions --test streams --test wasi"; preCheck = '' mkdir -p target/userland - ln -s ${userland}/bin target/userland/bin + ln -s ${userland} target/userland/bundle ''; doInstallCargoArtifacts = false; });