From 62fdec715635cef4be38c96053316c0e0b7c8b91 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 24 Oct 2026 22:42:44 -0700 Subject: [PATCH 01/20] fix(build): accept inlined fortified copies in hardened GNU links Known-bounds copies can inline under _FORTIFY_SOURCE=2, leaving no __memcpy_chk import. Keep exact stack-protector and __snprintf_chk requirements as hardening witnesses without requiring the optimizer to preserve an out-of-line memory-copy check. Exercise the verifier CLI with accepted and missing-import controls. The existing hardened arm64 compiler passes without any binary change; the ordinary compiler still fails the checked-formatting requirement. --- CHANGELOG.md | 2 + scripts/build/binary-expectations.ts | 3 +- test/internal/build-hardened-flags.test.ts | 55 +++++++++++++++++++++- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf5168acb7dd..ea34e518dd6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Accept hardened GNU builds whose fortified memory copies inline, while retaining stack-protector and checked-formatting import checks. + - Cover source-less generated helper entry counters in AOT image-map regression tests. - Resolve literal embedded module paths against prepared AOT entry points, including TypeScript and custom output names. diff --git a/scripts/build/binary-expectations.ts b/scripts/build/binary-expectations.ts index ac00b4023c52..e1c3158b638b 100644 --- a/scripts/build/binary-expectations.ts +++ b/scripts/build/binary-expectations.ts @@ -291,7 +291,8 @@ function requiredImports(cfg: Config): string[] { if (!cfg.hardened) return []; return [ "__stack_chk_fail", - ...(cfg.abi === "gnu" && cfg.release && !cfg.asan ? ["__memcpy_chk", "__snprintf_chk"] : []), + // Copies with known bounds inline even with _FORTIFY_SOURCE=2; formatted output retains its checked call. + ...(cfg.abi === "gnu" && cfg.release && !cfg.asan ? ["__snprintf_chk"] : []), ]; } diff --git a/test/internal/build-hardened-flags.test.ts b/test/internal/build-hardened-flags.test.ts index 1113a93ebb60..c04ba1a4cf5a 100644 --- a/test/internal/build-hardened-flags.test.ts +++ b/test/internal/build-hardened-flags.test.ts @@ -1,8 +1,9 @@ import { expect, test } from "bun:test"; -import { bunEnv, bunExe, tempDir } from "harness"; -import { existsSync } from "node:fs"; +import { bunEnv, bunExe, isWindows, tempDir } from "harness"; +import { chmodSync, existsSync, writeFileSync } from "node:fs"; import { join } from "node:path"; +import { binaryExpectations } from "../../scripts/build/binary-expectations.ts"; import { resolveConfig, type Config, type PartialConfig, type Toolchain } from "../../scripts/build/config.ts"; import { mimalloc } from "../../scripts/build/deps/mimalloc.ts"; import { webkit } from "../../scripts/build/deps/webkit.ts"; @@ -265,6 +266,56 @@ test("_FORTIFY_SOURCE is left out where nothing is optimized or ASan checks the } }); +test.skipIf(isWindows)( + "a hardened GNU link may inline fortified copies but still needs checked formatting and stack protection", + async () => { + using dir = tempDir("build-hardened-imports", {}); + const root = String(dir); + const tool = join(root, "llvm-fixture"); + writeFileSync( + tool, + `#!${bunExe()} +if (process.argv.includes("--undefined-only")) console.log(process.env.FIXTURE_IMPORTS); +`, + ); + chmodSync(tool, 0o755); + const { requiredImports } = binaryExpectations(linuxConfig({ hardened: true }, root)); + const spec = join(root, "binary.verify.json"); + writeFileSync( + spec, + JSON.stringify({ + name: "fixture", + exe: join(root, "fixture"), + tools: { nm: tool, readobj: tool, objdump: tool, cxxfilt: tool }, + expect: { + format: "elf", + exports: { exact: [], patterns: [] }, + neededLibs: { names: [], exact: true }, + forbiddenImports: [], + requiredImports, + }, + }), + ); + for (const [imports, missing] of [ + [["__stack_chk_fail", "__snprintf_chk"], undefined], + [["__stack_chk_fail", "__fprintf_chk", "__sprintf_chk"], "__snprintf_chk"], + [["__snprintf_chk"], "__stack_chk_fail"], + ] as const) { + await using proc = Bun.spawn({ + cmd: [bunExe(), join(import.meta.dirname, "../../scripts/build/verify-binary.ts"), "binary", spec], + env: { ...bunEnv, FIXTURE_IMPORTS: imports.join("\n") }, + stdout: "pipe", + stderr: "pipe", + }); + const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]); + expect(stderr).toBe(""); + if (missing) expect(stdout).toContain(`- ${missing} (required import)`); + else expect(stdout).toContain("2 imported symbols"); + expect(exitCode).toBe(missing ? 1 : 0); + } + }, +); + test("--hardened=on is refused where nothing can be hardened", () => { using dir = tempDir("build-hardened-flags-refused", {}); for (const partial of [ From b838e73072227c2652a41c689299284f1965cdc6 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 24 Oct 2026 23:44:27 -0700 Subject: [PATCH 02/20] fix(aot): retain the runtime for self-as-Bun disk scripts Backport macOS SIGBUS recognition for removed-code entry from upstream 8614cd7c234a4dbba782fbae2cdcfe14fb15a71e, preserving the intentional exit-70 response when the command line was omitted. When compile.trim.allow retains run, keep its external-script runtime, startup package loaders, built-in module sources and locale data. Preserve SharedArrayBuffer on macOS when the JIT was intentionally removed, rather than treating JIT removal as evidence of a sandbox restriction. Cover external ESM, a CommonJS CLI package, SharedArrayBuffer/Atomics, and an opt-in real npm CLI offline install. Document retaining jit for disk FFI and custom SQLite loaders. The default AOT command-line/JIT removal is unchanged. Validation: 232 trimming unit tests and 15 AOT command-line tests pass. Co-authored-by: Jarred Sumner --- CHANGELOG.md | 3 + docs/bundler/aot-size.mdx | 11 +++ src/crash_handler/lib.rs | 2 + src/jsc/bindings/ZigGlobalObject.cpp | 3 +- src/trim/decide.rs | 36 +++++++- src/trim/plan.rs | 26 +++++- ...utables-leave-out-the-command-line.test.ts | 92 ++++++++++++++++++- 7 files changed, 167 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba6f622210f6..2ee78ee13492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +- Recognize macOS SIGBUS when entering removed AOT code, and retain the external-script runtime when `compile.trim.allow` includes `"run"`. +- Preserve SharedArrayBuffer when a JIT-free AOT executable runs external scripts as Bun on macOS. + - Resolve literal embedded module paths against prepared AOT entry points, including TypeScript and custom output names. - Add `Bun.Terminal.pause()` and `resume()` for PTY output backpressure without blocking the event loop. diff --git a/docs/bundler/aot-size.mdx b/docs/bundler/aot-size.mdx index 54ad015177ea..77684b1b7490 100644 --- a/docs/bundler/aot-size.mdx +++ b/docs/bundler/aot-size.mdx @@ -52,6 +52,17 @@ Every size on this page is for Linux x64. Two things do use the tools: `BUN_BE_BUN=1`, and `Bun.build` with `check` or `compile.aot`. With `BUN_BE_BUN=1` the executable tells you to run `bun` instead, and exits with code `70`. A program that calls `Bun.build` keeps the type checker, the compiler and the JIT compilers, unless you pass `--trim`. `install.auto` in `bunfig.toml` has no effect, because the package manager is part of the command line. +To run external JavaScript with `BUN_BE_BUN=1`, explicitly retain `"run"` when building: + +```ts +await Bun.build({ + entrypoints: ["./app.ts"], + compile: { outfile: "./app", aot: true, trim: { allow: ["run"] } }, +}); +``` + +The compiled application still runs ahead of time. `BUN_BE_BUN=1 ./app script.cjs` runs the disk script in the interpreter. Keeping `"run"` also keeps the runtime APIs, built-in module sources and locale data that arbitrary disk scripts can use; these cannot be inferred from the compiled application. It does not retain the JIT or Bun's package manager. A JavaScript package manager such as npm can run from its own disk entry point. Disk scripts that use `bun:ffi`, including custom SQLite library loaders, also need `"jit"` in `allow`. Explicit removals still apply. + ### APIs `bun compile` reads the whole program, including dependencies. It knows which globals, which members of `Bun` and `process`, which built-in modules and which methods of built-in objects your code uses. Bun removes every feature that nothing uses. You don't list anything: a program that imports `bun:sqlite` gets SQLite, and a program that doesn't ships without it. diff --git a/src/crash_handler/lib.rs b/src/crash_handler/lib.rs index 05afacb82f4e..5688c0b524c7 100644 --- a/src/crash_handler/lib.rs +++ b/src/crash_handler/lib.rs @@ -1620,6 +1620,8 @@ mod draft { libc::SIGTRAP if cfg!(target_arch = "x86_64") => pc.map(|pc| pc.wrapping_sub(1)), libc::SIGTRAP | libc::SIGILL => pc, libc::SIGSEGV if is_unmapped => pc.filter(|&pc| pc == addr), + // macOS raises SIGBUS where something that cannot be run is mapped in their place. + libc::SIGBUS if cfg!(target_os = "macos") => pc.filter(|&pc| pc == addr), _ => None, }; if let Some(feature) = entered.and_then(crate::compiled_frames::removed_feature_entered) { diff --git a/src/jsc/bindings/ZigGlobalObject.cpp b/src/jsc/bindings/ZigGlobalObject.cpp index f8b13cf1ac27..abf483c6575e 100644 --- a/src/jsc/bindings/ZigGlobalObject.cpp +++ b/src/jsc/bindings/ZigGlobalObject.cpp @@ -373,7 +373,8 @@ extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(c // useWasmFaultSignalHandler/FastMemory when ASAN_OPTIONS lacks // allow_user_segv_handler=1, so we don't force it off here. #if OS(DARWIN) - if (runsCompiledCode) + // An intentionally removed JIT does not imply a sandbox that forbids Mach exception handlers. + if (runsCompiledCode || JSC::isFeatureRemoved(JSC::RemovableFeature::JIT)) JSC::Options::machExceptionHandlerSandboxPolicy = JSC::Options::SandboxPolicy::Allow; #endif JSC::MarkedBlockCage::setExhaustionHandler(Bun__outOfMemory); diff --git a/src/trim/decide.rs b/src/trim/decide.rs index 7172d69c4cf0..0ea1a53ca38a 100644 --- a/src/trim/decide.rs +++ b/src/trim/decide.rs @@ -135,9 +135,13 @@ fn retain_all_a_program_can_enter(retained: &mut RetainedFeatures) { retained.insert(feature, reason); } } + retained.insert_set(&features_of_program_runtime(), RetainReason::NotRequested); +} + +fn features_of_program_runtime() -> FeatureSet { let mut features = FeatureSet::all(); features.subtract(&Feature::all_outside_compiled_programs()); - retained.insert_set(&features, RetainReason::NotRequested); + features } pub fn features_kept_only_when_named() -> FeatureSet { @@ -196,6 +200,18 @@ fn language_features() -> FeatureSet { fn close(retained: &mut RetainedFeatures, edges: &FeatureEdges) { let mut worklist: VecDeque = retained.set.iter().collect(); while let Some(feature) = worklist.pop_front() { + // The command line can run any disk script, outside the compiled program's feature graph. + if feature == Feature::Tools { + let reason = RetainReason::NeededBy { + feature, + strength: EdgeStrength::Reference, + }; + for required in features_of_program_runtime().iter() { + if retained.insert(required, reason) { + worklist.push_back(required); + } + } + } for edge in edges.leaving(feature) { if !edge.is_followed { continue; @@ -702,6 +718,24 @@ mod tests { assert!(decision.unused.contains(Feature::Lint)); } + #[test] + fn retained_command_line_keeps_the_runtime_of_disk_scripts() { + let request = TrimRequest { + allow: vec![TrimFeature::Run], + ..removing_unused() + }; + let decision = decide_request(&using(&[]), &request); + for feature in Feature::all_entered_from(EnteredFrom::Program).iter() { + assert!(!decision.unused.contains(feature), "{feature:?}"); + } + assert!(!decision.unused.contains(Feature::Tools)); + assert!(!decision.unused.contains(Feature::PackageFiles)); + assert!(!decision.unused.contains(Feature::HotReload)); + assert!(decision.unused.contains(Feature::Jit)); + assert!(decision.unused.contains(Feature::Install)); + assert!(decision.unused.contains(Feature::Lint)); + } + #[test] fn what_a_kept_feature_refers_to_stays_in_compiled_program() { let requirement = references(&[(Feature::Sql, Feature::Install)]); diff --git a/src/trim/plan.rs b/src/trim/plan.rs index 721b3843fd94..dc058816628f 100644 --- a/src/trim/plan.rs +++ b/src/trim/plan.rs @@ -25,6 +25,7 @@ pub fn plan(input: &TrimInput<'_>, executable: &mut Image<'_>) -> Result, executable: &mut Image<'_>) -> Result, executable: &mut Image<'_>) -> Result { + using dir = tempDir("aot-as-bun", { + "entry.ts": `console.log("compiled entry");`, + "build.ts": ` + const result = await Bun.build({ + entrypoints: ["./entry.ts"], + compile: { outfile: "./app", aot: true, trim: { allow: ["run"] } }, + }); + if (!result.success) throw new AggregateError(result.logs); + `, + "external.mjs": ` + import { basename } from "node:path"; + const shared = new Int32Array(new SharedArrayBuffer(4)); + Atomics.store(shared, 0, 42); + console.log(basename(import.meta.filename), [1, 2, 3].map(x => x * 2).join(","), Atomics.load(shared, 0)); + `, + "node_modules/tiny/package.json": `{"name":"tiny","version":"1.0.0","bin":"bin/cli.cjs"}`, + "node_modules/tiny/bin/cli.cjs": `#!/usr/bin/env node\nrequire("../lib/cli.cjs")(process);`, + "node_modules/tiny/lib/cli.cjs": ` + const { basename } = require("node:path"); + module.exports = process => console.log(basename(process.argv[1]), /cli/.test(process.argv[1]), JSON.parse('{"answer":42}').answer); + `, + }); + const folder = String(dir); + expect(await run([bunExe(), "build.ts"], folder)).toEqual({ stdout: "", stderr: "", exitCode: 0 }); + const app = join(folder, "app"); + const removed = removedFeaturesOf(app); + expect(removed).not.toContain("Tools"); + expect(removed).not.toContain("Interpreter"); + expect(removed).toContain("JIT"); + const asBun = { ...bunEnv, BUN_BE_BUN: "1" }; + expect(await run([app, "external.mjs"], folder, asBun)).toEqual({ + stdout: "external.mjs 2,4,6 42\n", + stderr: "", + exitCode: 0, + }); + expect(await run([app, "node_modules/tiny/bin/cli.cjs"], folder, asBun)).toEqual({ + stdout: "cli.cjs true 42\n", + stderr: "", + exitCode: 0, + }); + expect(await run([app], folder)).toEqual({ stdout: "compiled entry\n", stderr: "", exitCode: 0 }); + }, 600_000); + + test.skipIf(!process.env.AOT_NPM_CLI)( + "retaining run executes npm's CLI to install and load a disk package", + async () => { + using dir = tempDir("aot-as-npm", { + "entry.ts": `console.log("compiled entry");`, + "build.ts": ` + const result = await Bun.build({ entrypoints: ["./entry.ts"], + compile: { outfile: "./app", aot: true, trim: { allow: ["run", "jit"] } } }); + if (!result.success) throw new AggregateError(result.logs); + `, + "package.json": `{"name":"installer","version":"1.0.0","private":true}`, + "tiny/package.json": `{"name":"tiny","version":"1.0.0","main":"index.cjs"}`, + "tiny/index.cjs": `module.exports = 42;`, + "load.cjs": `console.log(require("tiny"));`, + }); + const folder = String(dir); + expect(await run([bunExe(), "build.ts"], folder)).toEqual({ stdout: "", stderr: "", exitCode: 0 }); + const app = join(folder, "app"); + const asBun = { + ...bunEnv, + BUN_BE_BUN: "1", + HOME: folder, + npm_config_cache: join(folder, "cache"), + npm_config_userconfig: join(folder, "npmrc"), + }; + const installed = await run( + [ + app, + process.env.AOT_NPM_CLI!, + "install", + "--offline", + "--ignore-scripts", + "--no-audit", + "--no-fund", + "file:./tiny", + ], + folder, + asBun, + ); + expect(installed.stdout).toContain("added 1 package"); + expect(installed.exitCode).toBe(0); + expect(await run([app, "load.cjs"], folder, asBun)).toEqual({ stdout: "42\n", stderr: "", exitCode: 0 }); + }, + 600_000, + ); + test.each(["--help", "-h", "--check", "--aot", "-i"])( "%s in BUN_OPTIONS says to run bun", async option => { From 150c9620c53710060186b8b0cd50985e035408b0 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 25 Oct 2026 04:01:54 -0700 Subject: [PATCH 03/20] fix(runtime): resolve extensionless plugin imports Let runtime onResolve hooks see extensionless package names and subpaths before native package resolution. Keep the existing onLoad eligibility filter and namespace parsing, including Windows path handling. Add runtime namespace controls and an AOT external-module SDK import regression. The old pinned compiler fails the new behavior; native rebuilt validation follows the exact source commit. --- CHANGELOG.md | 2 ++ src/jsc/ModuleLoader.rs | 9 +++-- src/jsc/VirtualMachine.rs | 9 +++-- ...-time-plugins-and-compiled-modules.test.ts | 32 +++++++++++++++-- .../plugin-namespace-drive-letter.test.ts | 35 +++++++++++++++++++ 5 files changed, 78 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06da4c9718b1..d9ea358856a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Resolve extensionless package names through runtime plugin hooks, including Plugin SDK imports from external AOT code. + - Accept hardened GNU builds whose fortified memory copies inline, while retaining stack-protector and checked-formatting import checks. - Cover source-less generated helper entry counters in AOT image-map regression tests. diff --git a/src/jsc/ModuleLoader.rs b/src/jsc/ModuleLoader.rs index cda34fe11907..be7a31a6bc51 100644 --- a/src/jsc/ModuleLoader.rs +++ b/src/jsc/ModuleLoader.rs @@ -334,12 +334,17 @@ pub(crate) fn plugin_namespace_and_path(specifier: &[u8]) -> Option<(&[u8], &[u8 if !could_be_plugin(specifier) { return None; } + Some(split_plugin_specifier(specifier)) +} + +/// Resolution hooks can claim extensionless files and package names too. +pub(crate) fn split_plugin_specifier(specifier: &[u8]) -> (&[u8], &[u8]) { let namespace = extract_namespace(specifier); - Some(if namespace.is_empty() { + if namespace.is_empty() { (namespace, specifier) } else { (namespace, &specifier[namespace.len() + 1..]) - }) + } } /// The `namespace:` prefix of `specifier`, or `b""` if it has none diff --git a/src/jsc/VirtualMachine.rs b/src/jsc/VirtualMachine.rs index f56a7cd9bbc7..532df8b104f0 100644 --- a/src/jsc/VirtualMachine.rs +++ b/src/jsc/VirtualMachine.rs @@ -5584,8 +5584,9 @@ impl VirtualMachine { // installed, if `onResolve` answers about it as well. let answer_utf8 = answer.to_utf8(); let is_bare = bun_resolver::is_package_path(&answer_utf8) - && ModuleLoader::plugin_namespace_and_path(&answer_utf8) - .is_some_and(|(namespace, _)| namespace.is_empty()); + && ModuleLoader::split_plugin_specifier(&answer_utf8) + .0 + .is_empty(); drop(answer_utf8); let is_own = is_bare && (answer.eql(specifier) @@ -8096,9 +8097,7 @@ fn run_on_resolve( importer: &bun_core::String, ) -> JsResult>> { let specifier = specifier.to_utf8(); - let Some((namespace, path)) = ModuleLoader::plugin_namespace_and_path(&specifier) else { - return Ok(None); - }; + let (namespace, path) = ModuleLoader::split_plugin_specifier(&specifier); // The importer's key ends in the query it was imported with. let importer = importer.to_utf8(); let importer = match bun_core::strings::index_of_char_usize(&importer, b'?') { diff --git a/test/aot/run-time-plugins-and-compiled-modules.test.ts b/test/aot/run-time-plugins-and-compiled-modules.test.ts index 91130879daa7..b2ce788a5c1d 100644 --- a/test/aot/run-time-plugins-and-compiled-modules.test.ts +++ b/test/aot/run-time-plugins-and-compiled-modules.test.ts @@ -41,10 +41,10 @@ const header = String.raw` const emptyOnLoadCallback = `() => ({ contents: "", loader: "ts" })`; -async function compileAndRun(folder: string) { +async function compileAndRun(folder: string, flags: string[] = []) { const executable = join(folder, "program" + (isWindows ? ".exe" : "")); const build = await spawned( - [bunExe(), "build", "--compile", "--aot", "main.ts", "--outfile", executable], + [bunExe(), "build", "--compile", "--aot", ...flags, "main.ts", "--outfile", executable], folder, bunEnv, ); @@ -133,6 +133,34 @@ describe.concurrent("plugins registered at run time", () => { timeout, ); + test( + "extensionless SDK imports in external modules reach runtime resolution hooks", + () => + slot(async () => { + using dir = tempDir("aot-external-plugin-alias", { + "tsconfig.json": tsconfig, + "sdk.cjs": `exports.value = 42;`, + "external.mjs": `import { value } from "uninstalled-package/sdk"; export { value };`, + "main.ts": String.raw` + import { createRequire } from "node:module"; + import { join } from "node:path"; + Bun.plugin({ + name: "external-sdk-alias", + setup(build) { + build.onResolve({ filter: /^uninstalled-package\/sdk$/ }, () => ({ + path: join(process.cwd(), "sdk.cjs"), namespace: "file", + })); + }, + }); + console.log(createRequire(import.meta.url)("./external.mjs").value); + `, + }); + const { stdout, stderr, exitCode } = await compileAndRun(String(dir), ["--external=./external.mjs"]); + expect({ stdout, stderr, exitCode }).toEqual({ stdout: "42\n", stderr: "", exitCode: 0 }); + }), + timeout, + ); + test("plugins for other modules register under bun run", async () => { using dir = tempDir("aot-run-time-plugin", { ...library, "main.ts": accepted }); const { stdout, exitCode } = await spawned([bunExe(), "run", "main.ts"], String(dir), bunEnv); diff --git a/test/js/bun/plugin/plugin-namespace-drive-letter.test.ts b/test/js/bun/plugin/plugin-namespace-drive-letter.test.ts index 74d01ea66444..2e9a6ddbedba 100644 --- a/test/js/bun/plugin/plugin-namespace-drive-letter.test.ts +++ b/test/js/bun/plugin/plugin-namespace-drive-letter.test.ts @@ -51,3 +51,38 @@ test("single-letter plugin namespace does not capture Windows drive paths", asyn expect(exitCode).toBe(0); void stderr; }); + +test("onResolve accepts extensionless files and package subpaths", async () => { + using dir = tempDir("plugin-extensionless-resolve", { + "real.cjs": `exports.value = 42;`, + "dependency.mjs": `export { value } from "uninstalled-package/sdk";`, + "entry.mjs": String.raw` + import { join } from "node:path"; + const target = join(import.meta.dir, "real.cjs"); + Bun.plugin({ + name: "extensionless-alias", + setup(build) { + build.onResolve({ filter: /^(extensionless|uninstalled-package\/sdk)$/ }, () => ({ path: target })); + build.onResolve({ filter: /^with-extension\.js$/ }, () => ({ path: target, namespace: "file" })); + build.onResolve({ filter: /^value$/, namespace: "alias" }, args => ({ path: args.path, namespace: "virtual" })); + build.onLoad({ filter: /.*/, namespace: "virtual" }, () => ({ exports: { value: 43 }, loader: "object" })); + }, + }); + console.log( + (await import("extensionless")).value, + (await import("./dependency.mjs")).value, + (await import("with-extension.js")).value, + (await import("alias:value")).value, + ); + `, + }); + await using proc = Bun.spawn({ + cmd: [bunExe(), "--no-install", "entry.mjs"], + env: bunEnv, + cwd: String(dir), + stderr: "pipe", + }); + const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]); + expect({ stdout, stderr }).toEqual({ stdout: "42 42 42 43\n", stderr: "" }); + expect(exitCode).toBe(0); +}); From 8c71f9c89c4c00944951e760eecc2e42f56d6b74 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 25 Oct 2026 09:58:16 -0700 Subject: [PATCH 04/20] ci: build pinned Linux x64 AOT compilers --- .github/workflows/openclaw-build-test.yml | 98 ++++++++++++ scripts/openclaw-p6/bootstrap.sh | 77 +++++++++ .../openclaw-p6/build-bun-standalone-cb.py | 146 ++++++++++++++++++ scripts/openclaw-p6/compiler_resources.py | 100 ++++++++++++ scripts/openclaw-p6/container.sh | 42 +++++ scripts/openclaw-p6/deadline_process.py | 110 +++++++++++++ scripts/openclaw-p6/host.sh | 48 ++++++ scripts/openclaw-p6/preserve-compiler.py | 32 ++++ scripts/openclaw-p6/preserve-run-evidence.py | 35 +++++ scripts/openclaw-p6/setup-sysroot.sh | 98 ++++++++++++ scripts/openclaw-p6/source_files.py | 68 ++++++++ scripts/openclaw-p6/sources.json | 144 +++++++++++++++++ scripts/openclaw-p6/stage.py | 82 ++++++++++ 13 files changed, 1080 insertions(+) create mode 100644 .github/workflows/openclaw-build-test.yml create mode 100644 scripts/openclaw-p6/bootstrap.sh create mode 100644 scripts/openclaw-p6/build-bun-standalone-cb.py create mode 100644 scripts/openclaw-p6/compiler_resources.py create mode 100644 scripts/openclaw-p6/container.sh create mode 100644 scripts/openclaw-p6/deadline_process.py create mode 100644 scripts/openclaw-p6/host.sh create mode 100644 scripts/openclaw-p6/preserve-compiler.py create mode 100644 scripts/openclaw-p6/preserve-run-evidence.py create mode 100644 scripts/openclaw-p6/setup-sysroot.sh create mode 100644 scripts/openclaw-p6/source_files.py create mode 100644 scripts/openclaw-p6/sources.json create mode 100644 scripts/openclaw-p6/stage.py diff --git a/.github/workflows/openclaw-build-test.yml b/.github/workflows/openclaw-build-test.yml new file mode 100644 index 000000000000..1ccc49517c94 --- /dev/null +++ b/.github/workflows/openclaw-build-test.yml @@ -0,0 +1,98 @@ +name: P6 native Linux x64 AOT compilers + +on: + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: p6-native-linux-x64-compilers + cancel-in-progress: false + +jobs: + linux-x64: + if: github.repository == 'openclaw/bun' && github.ref == 'refs/heads/openclaw/aot-rd-P6' + runs-on: blacksmith-32vcpu-ubuntu-2404 + timeout-minutes: 240 + defaults: + run: + shell: bash + steps: + - name: Establish work deadline + run: | + { + echo "P6_DEADLINE_EPOCH=$(( $(date +%s) + 12600 ))" + echo "P6_WORK=$RUNNER_TEMP/p6-aot-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" + echo "P6_CONTAINER=p6-aot-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" + } >> "$GITHUB_ENV" + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + sparse-checkout: scripts/openclaw-p6 + - name: Stage exact source and bootstrap native Docker toolchain + run: | + mkdir -p "$P6_WORK" + bash scripts/openclaw-p6/host.sh bootstrap + - name: Build and preserve standard compiler + id: build_standard + run: bash scripts/openclaw-p6/host.sh cb-standard + - name: Export standard compiler + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: p6-linux-x64-standard-${{ github.sha }}-attempt${{ github.run_attempt }} + path: ${{ env.P6_WORK }}/data/rd150c-x64-highmem-deadline-v1/preserved-cb-standard/ + if-no-files-found: error + compression-level: 0 + retention-days: 7 + - name: Build and preserve physical ShadowRealm-off compiler + id: build_shadowrealm_off + run: bash scripts/openclaw-p6/host.sh cb-compat + - name: Export ShadowRealm-off compiler + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: p6-linux-x64-shadowrealm-off-${{ github.sha }}-attempt${{ github.run_attempt }} + path: ${{ env.P6_WORK }}/data/rd150c-x64-highmem-deadline-v1/preserved-cb-compat/ + if-no-files-found: error + compression-level: 0 + retention-days: 7 + - name: Stop and remove owned container + if: always() + run: bash scripts/openclaw-p6/host.sh cleanup + - name: Export UNQUALIFIED FAILED standard compiler diagnostics + if: failure() && steps.build_standard.outcome == 'failure' + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: p6-linux-x64-UNQUALIFIED-FAILED-standard-${{ github.sha }}-attempt${{ github.run_attempt }} + path: | + ${{ env.P6_WORK }}/data/rd150c-x64-highmem-deadline-v1/build-standard/bun + ${{ env.P6_WORK }}/data/rd150c-x64-highmem-deadline-v1/build-standard/configure.json + if-no-files-found: warn + compression-level: 0 + retention-days: 7 + - name: Export UNQUALIFIED FAILED ShadowRealm-off compiler diagnostics + if: failure() && steps.build_shadowrealm_off.outcome == 'failure' + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: p6-linux-x64-UNQUALIFIED-FAILED-shadowrealm-off-${{ github.sha }}-attempt${{ github.run_attempt }} + path: | + ${{ env.P6_WORK }}/data/rd150c-x64-highmem-deadline-v1/build-c2/bun + ${{ env.P6_WORK }}/data/rd150c-x64-highmem-deadline-v1/build-c2/configure.json + if-no-files-found: warn + compression-level: 0 + retention-days: 7 + - name: Export compiler receipts, including failures + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: p6-linux-x64-receipts-${{ github.sha }}-attempt${{ github.run_attempt }} + path: | + ${{ env.P6_WORK }}/data/proof/ + ${{ env.P6_WORK }}/data/rd150c-x64-highmem-deadline-v1/receipts/ + ${{ env.P6_WORK }}/data/rd150c-x64-highmem-deadline-v1/source-ready.json + ${{ env.P6_WORK }}/data/rd150c-x64-highmem-deadline-v1/raw-cb-*/ + ${{ env.P6_WORK }}/container-final.json + ${{ env.P6_WORK }}/containers-after-cleanup.txt + if-no-files-found: warn + compression-level: 0 + retention-days: 7 diff --git a/scripts/openclaw-p6/bootstrap.sh b/scripts/openclaw-p6/bootstrap.sh new file mode 100644 index 000000000000..536963c39e81 --- /dev/null +++ b/scripts/openclaw-p6/bootstrap.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +# Run only in the isolated P6 native x64 build container. +set -euo pipefail +root=${1:?absolute staged CB root} +[[ $(uname -s) == Linux && $(uname -m) == x86_64 ]] +[[ "$root" == /*/.cache/oc-ty-ext/P6/* && -f "$root/source-ready.json" ]] +python3 - "$root" <<'PY' +import json,pathlib,sys +root=pathlib.Path(sys.argv[1]);data=json.loads((root/'source-ready.json').read_text()) +assert data['bun']=='150c9620c53710060186b8b0cd50985e035408b0' +assert data['webkit']=='aaa690bfbf34c9d50775716ac2fc3c7d0573e0b8' +assert data['root']==str(root.resolve()) +assert not (root/'receipts/bootstrap.json').exists() +PY +export P6_WORK="$root" P6_HOME="$root/home" TMPDIR="$root/tmp" +export CARGO_HOME="$P6_HOME/.cargo" RUSTUP_HOME="$P6_HOME/.rustup" +export XDG_CACHE_HOME="$P6_HOME/.cache" BUN_INSTALL_CACHE_DIR="$root/bun-install-cache" +export BUN_BUILD_CACHE_DIR="$root/build-cache" +export DEBIAN_FRONTEND=noninteractive +if (( EUID == 0 )); then elevate=(); else elevate=(sudo -n); fi +apt_options=(-o "Dir::Cache::archives=$root/apt-archives" -o "Dir::State::lists=$root/apt-lists") +"${elevate[@]}" apt-get "${apt_options[@]}" update +"${elevate[@]}" apt-get "${apt_options[@]}" install -y --no-install-recommends \ + ca-certificates curl wget git build-essential cmake ninja-build pkg-config \ + python3 ruby perl automake libtool unzip xz-utils libicu-dev libxml2-dev \ + libssl-dev zlib1g-dev libzstd-dev libncurses-dev libatomic1 golang ccache \ + skopeo jq nasm time file binutils +fetch() { + local url=$1 destination=$2 expected=$3 + if [[ ! -f "$destination" ]]; then curl -fL --retry 2 --connect-timeout 30 -o "$destination" "$url"; fi + printf '%s %s\n' "$expected" "$destination" | sha256sum -c - +} +fetch https://github.com/oven-sh/bun/releases/download/bun-v1.4.4/bun-linux-x64-baseline.zip "$root/downloads/bun.zip" e0446eb55995772eb9894bebae9a6be368d985a8b9271ee124486f9946eedd76 +unzip -o "$root/downloads/bun.zip" -d "$root/opt" +fetch https://github.com/llvm/llvm-project/releases/download/llvmorg-23.1.1/LLVM-23.1.1-Linux-X64.tar.xz "$root/downloads/llvm.tar.xz" 832aeb58d105de1cabc7b982dd2c65de0610f7377df48ae8fc2dd8e97420a15c +mkdir -p "$root/opt/llvm" +tar -xJf "$root/downloads/llvm.tar.xz" --strip-components=1 -C "$root/opt/llvm" +ldd "$root/opt/llvm/bin/clang" > "$root/receipts/clang-ldd-before.txt" +if grep -q 'not found' "$root/receipts/clang-ldd-before.txt"; then + curl -fL --retry 2 -o "$root/downloads/libicu70.deb" https://archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu70_70.1-2_amd64.deb + curl -fL --retry 2 -o "$root/downloads/Packages.xz" https://archive.ubuntu.com/ubuntu/dists/jammy/main/binary-amd64/Packages.xz + python3 - "$root/downloads" <<'PY' +import hashlib,lzma,pathlib,sys +root=pathlib.Path(sys.argv[1]);text=lzma.decompress((root/'Packages.xz').read_bytes()).decode() +blocks=[b for b in text.split('\n\n') if b.startswith('Package: libicu70\n')] +assert len(blocks)==1 +fields=dict(line.split(': ',1) for line in blocks[0].splitlines() if ': ' in line and not line.startswith(' ')) +assert fields['Version']=='70.1-2' and fields['Architecture']=='amd64' +assert hashlib.sha256((root/'libicu70.deb').read_bytes()).hexdigest()==fields['SHA256'] +PY + dpkg-deb -x "$root/downloads/libicu70.deb" "$root/opt/llvm-runtime" +fi +export LD_LIBRARY_PATH="$root/opt/llvm-runtime/usr/lib/x86_64-linux-gnu" +export PATH="$root/opt/llvm/bin:$root/opt/bun-linux-x64-baseline:$CARGO_HOME/bin:/usr/local/bin:/usr/bin:/bin" +curl -fL --retry 2 -o "$root/downloads/rustup-init" https://static.rust-lang.org/rustup/archive/1.28.2/x86_64-unknown-linux-gnu/rustup-init +curl -fL --retry 2 -o "$root/downloads/rustup-init.sha256" https://static.rust-lang.org/rustup/archive/1.28.2/x86_64-unknown-linux-gnu/rustup-init.sha256 +(cd "$root/downloads" && sha256sum -c rustup-init.sha256) +chmod +x "$root/downloads/rustup-init" +"$root/downloads/rustup-init" -y --profile minimal --default-toolchain nightly-2026-09-15 +export RUSTUP_TOOLCHAIN=nightly-2026-09-15 +[[ $(bun --version) == 1.4.4 ]] +clang --version | tee "$root/receipts/clang-version.txt" +rustc --version | tee "$root/receipts/rust-version.txt" +bash "$root/setup-sysroot.sh" +fetch https://github.com/oven-sh/WebKit/releases/download/autobuild-preview-pr-757-63e317ba/bun-webkit-linux-amd64-lto-aot.tar.gz "$root/downloads/icu-prebuilt.tar.gz" b5f9e8554286eb31196ccd814b8ebd3ea47d042a89cc82d32413b56e6ffb2567 +mkdir -p "$root/opt/icu-static" +tar -xzf "$root/downloads/icu-prebuilt.tar.gz" --strip-components=1 -C "$root/opt/icu-static" bun-webkit/include/unicode bun-webkit/lib/libicudata.a bun-webkit/lib/libicuuc.a bun-webkit/lib/libicui18n.a +grep -q '#define U_ICU_VERSION "78.3"' "$root/opt/icu-static/include/unicode/uvernum.h" +fetch https://github.com/unicode-org/icu/releases/download/release-78.3/icu4c-78.3-sources.tgz "$root/downloads/icu4c-78.3-sources.tgz" 3a2e7a47604ba702f345878308e6fefeca612ee895cf4a5f222e7955fabfe0c0 +sha256sum "$root/opt/icu-static/lib/"*.a > "$root/receipts/icu-static.sha256" +dpkg-query -W -f='${Package}\t${Version}\n' > "$root/receipts/packages.tsv" +uname -a > "$root/receipts/kernel.txt" +python3 - "$root" <<'PY' +import datetime,json,pathlib,sys +root=pathlib.Path(sys.argv[1]);source=json.loads((root/'source-ready.json').read_text()) +(root/'receipts/bootstrap.json').write_text(json.dumps({'status':'bootstrap-complete-not-built','source':source,'at':datetime.datetime.now(datetime.timezone.utc).isoformat()},indent=2)+'\n') +PY diff --git a/scripts/openclaw-p6/build-bun-standalone-cb.py b/scripts/openclaw-p6/build-bun-standalone-cb.py new file mode 100644 index 000000000000..c1fe18edf0a7 --- /dev/null +++ b/scripts/openclaw-p6/build-bun-standalone-cb.py @@ -0,0 +1,146 @@ +#!/usr/bin/env python3 +"""One native CB compiler profile; caller owns the lease and heavy-work slot.""" +import argparse +import datetime +import json +import os +from pathlib import Path +import platform +import shutil +import signal +import subprocess +import sys +import time +sys.dont_write_bytecode = True +from source_files import digest, verify_files +from compiler_resources import CompilerResources +from deadline_process import run_bounded, stop_group + +PROFILES = { + 'cb-standard': ('build-standard', 'on', False), + 'cb-compat': ('build-c2', 'off', False), +} + + +class BuildInterrupted(Exception): + def __init__(self, signum): + self.signum = signum + + +def main(): + p=argparse.ArgumentParser(description=__doc__) + p.add_argument('--root',type=Path,required=True) + p.add_argument('--profile',choices=PROFILES,required=True) + p.add_argument('--lease-deadline-epoch',type=float,required=True) + a=p.parse_args();root=a.root.resolve() + if platform.system()!='Linux' or platform.machine()!='x86_64': p.error('Native Linux x64 required') + source=json.loads((root/'source-ready.json').read_text()) + bootstrap=json.loads((root/'receipts/bootstrap.json').read_text()) + if source['bun']!='150c9620c53710060186b8b0cd50985e035408b0' or source['webkit']!='aaa690bfbf34c9d50775716ac2fc3c7d0573e0b8' or bootstrap['source']!=source: p.error('Wrong source/bootstrap pins') + verify_files(root/'bun',json.loads((root/'bun-inputs.json').read_text())['targetManifest']) + verify_files(root/'WebKit',json.loads((root/'webkit-inputs.json').read_text())['manifest']) + if shutil.disk_usage(root).free<25_000_000_000: p.error('Less than25GB free') + mem=dict(line.split(':',1) for line in Path('/proc/meminfo').read_text().splitlines()) + if int(mem['MemTotal'].split()[0])*1024<30_000_000_000: p.error('Use the preserved >=30GB high-memory native profile') + build_dir,shadow,hardened=PROFILES[a.profile] + if (root/build_dir/'bun').exists(): p.error('Existing compiler output; inspect and resume deliberately, do not overwrite') + receipt_path=root/'receipts'/f'{a.profile}-build.json' + if receipt_path.exists(): p.error('Existing build attempt receipt; keep it and choose an explicit recovery workflow') + env={ + 'HOME':str(root/'home'),'TMPDIR':str(root/'tmp'),'LANG':'C.UTF-8', + 'PATH':f'{root}/opt/bun-linux-x64-baseline:{root}/opt/llvm/bin:{root}/home/.cargo/bin:/usr/local/bin:/usr/bin:/bin', + 'CARGO_HOME':str(root/'home/.cargo'),'RUSTUP_HOME':str(root/'home/.rustup'),'RUSTUP_TOOLCHAIN':'nightly-2026-09-15', + 'LD_LIBRARY_PATH':str(root/'opt/llvm-runtime/usr/lib/x86_64-linux-gnu'), + 'BUN_WEBKIT_PATH':str(root/'WebKit'),'BUN_ICU_ROOT':str(root/'opt/icu-static'), + 'BUN_ICU_SOURCES':str(root/'downloads/icu4c-78.3-sources.tgz'), + 'LINUX_GLIBC_SYSROOT':str(root/'opt/linux-sysroot-glibc-amd64'), + 'BUN_BUILD_CACHE_DIR':str(root/'build-cache'),'BUN_INSTALL_CACHE_DIR':str(root/'bun-install-cache'), + 'XDG_CACHE_HOME':str(root/'home/.cache'),'GIT_SHA':source['bun'], + } + compiler_bootstrap=root/'opt/bun-linux-x64-baseline/bun' + command=['/usr/bin/time','-v','-o',str(root/'receipts'/f'{a.profile}-time.txt'),'/usr/bin/nice','-n','10',str(compiler_bootstrap),'scripts/build.ts','--profile=release-local',f'--webkit-version={source["webkit"]}',f'--build-dir={root/build_dir}','--relr=off','--aot=on','--trimmable=on',f'--shadow-realm={shadow}','--baseline=on','--target=bun','-j2'] + if hardened: command.append('--hardened=on') + receipt={'status':'running','profile':a.profile,'source':source,'command':command,'started':datetime.datetime.now(datetime.timezone.utc).isoformat(),'measurementScope':'GNUtime maximum single descendant RSS plus1s sampled descendant/process-group RSS and existing-cgroup raw memory; none is automatically a task peak','experiment':'existing-high-memory-j2-compiler-only-not-application-fit','memoryFitQualified':False} + receipt_path.write_text(json.dumps(receipt,indent=2)+'\n') + remaining=a.lease_deadline_epoch-time.time() + fit={'at':datetime.datetime.now(datetime.timezone.utc).isoformat(),'leaseDeadlineEpoch':a.lease_deadline_epoch,'remainingSeconds':remaining,'reservedCaptureCleanupSeconds':300,'minimumBuildWindowSeconds':1860,'minimumCompileWindowSeconds':1800,'postBuildWindowSeconds':60,'maximumBuildSeconds':2700,'fits':2160<=remaining<=14400,'memoryFitQualified':False} + (root/'receipts'/f'{a.profile}-fit.json').write_text(json.dumps(fit,indent=2)+'\n') + if not fit['fits']: + receipt.update(status='declined-before-build',exitCode=2,timeBudget=fit) + receipt_path.write_text(json.dumps(receipt,indent=2)+'\n') + p.error('Decline before build: need1800s compile+60s postbuild window plus300s capture/cleanup within verified240min job') + build_deadline_epoch=time.time()+min(2700,remaining-300) + fit['buildDeadlineEpoch']=build_deadline_epoch + receipt['timeBudget']=fit + receipt['resourcesBefore']=CompilerResources(root/'receipts'/f'{a.profile}-unused-before.jsonl',os.getpid()).sample() + receipt_path.write_text(json.dumps(receipt,indent=2)+'\n') + start=time.monotonic() + stop_at=start+max(0,build_deadline_epoch-time.time()-60) + signals=[signal.SIGINT,signal.SIGTERM,signal.SIGHUP] + old_handlers={sig:signal.getsignal(sig) for sig in signals} + def interrupt(signum,frame): raise BuildInterrupted(signum) + for sig in signals: signal.signal(sig,interrupt) + code=1 + resources=None + try: + with (root/'receipts'/f'{a.profile}-build.log').open('wb') as log: + child=subprocess.Popen(command,cwd=root/'bun',env=env,stdout=log,stderr=subprocess.STDOUT,start_new_session=True) + try: + resources=CompilerResources(root/'receipts'/f'{a.profile}-resources.jsonl',child.pid) + resources.start() + while True: + try: + code=child.wait(timeout=min(30,max(0.001,stop_at-time.monotonic())));break + except subprocess.TimeoutExpired: + if time.monotonic()>=stop_at: + code=124 + receipt['timedOutBeforeCleanupReserve']=True + break + print(json.dumps({'profile':a.profile,'elapsedSeconds':round(time.monotonic()-start),'log':str(root/'receipts'/f'{a.profile}-build.log')}),flush=True) + finally: + for sig in signals: signal.signal(sig,signal.SIG_IGN) + stop_group(child) + if resources is not None: + receipt['resources']=resources.finish() + except BuildInterrupted as interrupted: + code=128+interrupted.signum + receipt['interruptedBySignal']=interrupted.signum + except Exception as error: + receipt['launcherError']=f'{type(error).__name__}: {error}' + finally: + for sig,handler in old_handlers.items(): signal.signal(sig,handler) + receipt.update(status='build-command-finished-not-qualified',exitCode=code,finished=datetime.datetime.now(datetime.timezone.utc).isoformat()) + if 'interruptedBySignal' in receipt: receipt['status']='interrupted-not-qualified' + receipt_path.write_text(json.dumps(receipt,indent=2)+'\n') + if code: raise SystemExit(code) + compiler=root/build_dir/'bun' + def probe(name, command, output_file=None): + with output_file.open('wb') if output_file else open(os.devnull, 'wb') as output: + measured, timing=run_bounded(command, deadline_epoch=build_deadline_epoch, + reserve_seconds=0, cleanup_grace=5, env=env, + stdout=output if output_file else subprocess.PIPE, stderr=subprocess.STDOUT) + receipt.setdefault('postBuildProbes',[]).append({'name':name,**timing}) + if measured.returncode: + raise subprocess.CalledProcessError(measured.returncode,command) + return measured.stdout.decode().strip() if measured.stdout is not None else '' + try: + revision=probe('revision',[compiler,'--revision']) + if '150c9620c' not in revision: raise RuntimeError('Fresh compiler revision mismatch') + versions=json.loads(probe('versions',[compiler,'-p','JSON.stringify({webkit:process.versions.webkit,arch:process.arch,platform:process.platform})'])) + if versions!={'webkit':source['webkit'],'arch':'x64','platform':'linux'}: raise RuntimeError('Fresh compiler platform/WebKit mismatch') + receipt.update(compiler=str(compiler),compilerSha256=digest(compiler),revision=revision,versions=versions) + (root/'receipts'/f'{a.profile}.sha256').write_text(receipt['compilerSha256']+' '+str(compiler)+'\n') + for name,cmd in [('ldd',['ldd',str(compiler)]),('elf-versions',['readelf','--version-info',str(compiler)]),('elf-dynamic',['readelf','-d',str(compiler)]),('file',['file',str(compiler)])]: + probe(name,cmd,root/'receipts'/f'{a.profile}-{name}.txt') + except Exception as error: + code=error.returncode if isinstance(error,subprocess.CalledProcessError) else 1 + receipt.update(status='compiled-but-postbuild-failed',exitCode=code,postBuildError=f'{type(error).__name__}: {error}') + finally: + receipt['finished']=datetime.datetime.now(datetime.timezone.utc).isoformat() + receipt_path.write_text(json.dumps(receipt,indent=2)+'\n') + print(json.dumps(receipt,indent=2)) + if code: raise SystemExit(code) + + + +if __name__=='__main__': main() diff --git a/scripts/openclaw-p6/compiler_resources.py b/scripts/openclaw-p6/compiler_resources.py new file mode 100644 index 000000000000..d4b9b8217933 --- /dev/null +++ b/scripts/openclaw-p6/compiler_resources.py @@ -0,0 +1,100 @@ +"""Sample owned compiler descendants and existing cgroups without changing them.""" +import datetime +import json +import os +from pathlib import Path +import threading +import time + + +class CompilerResources: + def __init__(self, path, pid): + self.path = path + self.pid = pid + self.done = threading.Event() + self.errors = [] + self.count = 0 + self.peak_rss_kib = 0 + self.thread = threading.Thread(target=self.run, name='compiler-resources') + self.cgroups = self.resolve_cgroups() + + def resolve_cgroups(self): + # Existing cgroups may be shared and their peaks may predate this build. + groups = [] + membership = Path(f'/proc/{self.pid}/cgroup').read_text() + for line in Path('/proc/self/mountinfo').read_text().splitlines(): + before, after = line.split(' - ', 1) + mount = before.split() + kind, _, options = after.split()[:3] + for entry in membership.splitlines(): + _, controllers, suffix = entry.split(':', 2) + if kind == 'cgroup2' and not controllers or kind == 'cgroup' and 'memory' in controllers.split(',') and 'memory' in options.split(','): + base = mount[3] + if base != '/' and suffix != base and not suffix.startswith(base.rstrip('/') + '/'): + continue + relative = suffix[len(base):] if base != '/' else suffix + path = Path(mount[4]) / relative.lstrip('/') + groups.append({'kind': kind, 'path': str(path), 'mountRoot': base, 'membership': entry}) + return groups + + def sample(self): + procs = {} + for path in Path('/proc').iterdir(): + if not path.name.isdigit(): + continue + try: + stat = (path / 'stat').read_text().rsplit(')', 1)[1].split() + procs[int(path.name)] = (int(stat[1]), int(stat[2]), int(stat[19])) + except (FileNotFoundError, ProcessLookupError): + continue + owned = {self.pid} + while True: + added = {pid for pid, (parent, group, _) in procs.items() if parent in owned or group == self.pid} + if added <= owned: + break + owned.update(added) + rows = [] + for pid in sorted(owned & procs.keys()): + try: + raw = Path(f'/proc/{pid}/status').read_text() + fields = {key: value.strip() for key, value in (line.split(':', 1) for line in raw.splitlines())} + selected = {key: fields.get(key) for key in ['Name', 'State', 'PPid', 'VmRSS', 'VmHWM', 'Threads']} + rows.append({'pid': pid, 'startTimeTicks': procs[pid][2], 'pgrp': procs[pid][1], 'status': selected}) + except (FileNotFoundError, ProcessLookupError): + continue + rss = sum(int(row['status']['VmRSS'].split()[0]) for row in rows if row['status']['VmRSS']) + self.peak_rss_kib = max(self.peak_rss_kib, rss) + cgroups = [] + for group in self.cgroups: + names = ['memory.current', 'memory.peak', 'memory.max', 'memory.swap.current', 'memory.swap.peak', 'memory.swap.max', 'memory.events', 'memory.events.local'] if group['kind'] == 'cgroup2' else ['memory.usage_in_bytes', 'memory.max_usage_in_bytes', 'memory.limit_in_bytes', 'memory.memsw.usage_in_bytes', 'memory.memsw.max_usage_in_bytes', 'memory.failcnt', 'memory.oom_control'] + values = {} + for name in names: + try: + values[name] = (Path(group['path']) / name).read_text() + except FileNotFoundError: + values[name] = None + cgroups.append({**group, 'raw': values, 'scope': 'existing cgroup; not isolated or reset by this monitor'}) + row = {'at': datetime.datetime.now(datetime.timezone.utc).isoformat(), 'monotonic': time.monotonic(), 'rootPid': self.pid, 'processes': rows, 'sampledAggregateRssKiB': rss, 'rssScope': 'sampled descendant/process-group RSS sum; shared pages counted more than once, short-lived processes may be missed', 'cgroups': cgroups, 'meminfo': Path('/proc/meminfo').read_text(), 'vmstat': '\n'.join(line for line in Path('/proc/vmstat').read_text().splitlines() if line.startswith(('oom_kill ', 'pswpin ', 'pswpout '))) + '\n'} + self.count += 1 + return row + + def run(self): + try: + with self.path.open('x') as output: + while True: + output.write(json.dumps(self.sample(), separators=(',', ':')) + '\n') + output.flush() + if self.done.wait(1): + output.write(json.dumps(self.sample(), separators=(',', ':')) + '\n') + output.flush() + break + except Exception as error: + self.errors.append(f'{type(error).__name__}: {error}') + + def start(self): + self.thread.start() + + def finish(self): + self.done.set() + self.thread.join() + return {'intervalSeconds': 1, 'samples': self.count, 'maximumSampledAggregateRssKiB': self.peak_rss_kib, 'errors': self.errors, 'rawPath': str(self.path), 'cgroupScope': 'existing cgroups; historical/shared peak is not a task peak', 'memoryFitQualified': False} diff --git a/scripts/openclaw-p6/container.sh b/scripts/openclaw-p6/container.sh new file mode 100644 index 000000000000..b842b285ef8b --- /dev/null +++ b/scripts/openclaw-p6/container.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +set -euo pipefail +phase=${1:?bootstrap, cb-standard or cb-compat} +: "${P6_DEADLINE_EPOCH:?Missing absolute work deadline}" +root=/root/.cache/oc-ty-ext/P6/rd150c-x64-highmem-deadline-v1 +recipe=/p6-recipe +proof=/root/.cache/oc-ty-ext/P6/proof +mkdir -p "$proof" +bounded() { + python3 "$recipe/deadline_process.py" --deadline-epoch "$P6_DEADLINE_EPOCH" \ + --reserve-seconds 600 --cleanup-grace-seconds 15 --receipt "$proof/$1-deadline.json" -- "${@:2}" +} +if [[ "$phase" == bootstrap ]]; then + [[ $(uname -m) == x86_64 && $(uname -s) == Linux ]] + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install -y --no-install-recommends python3 ca-certificates git + python3 - "$proof/resources.json" <<'PY' +import json,os,pathlib,shutil,sys +memory=int(next(x.split()[1] for x in pathlib.Path('/proc/meminfo').read_text().splitlines() if x.startswith('MemTotal:')))*1024 +limit=pathlib.Path('/sys/fs/cgroup/memory.max') +cgroup=limit.read_text().strip() if limit.exists() else None +effective=min(memory,int(cgroup)) if cgroup and cgroup!='max' else memory +facts={'memTotalBytes':memory,'cgroupMemoryMax':cgroup,'effectiveMemoryBytes':effective, + 'cpus':len(os.sched_getaffinity(0)),'diskFreeBytes':shutil.disk_usage('/root/.cache/oc-ty-ext/P6').free, + 'kernel':os.uname().release,'memoryFitQualified':False} +pathlib.Path(sys.argv[1]).write_text(json.dumps(facts,indent=2)+'\n') +assert effective>=30_000_000_000 and facts['cpus']>=2 and facts['diskFreeBytes']>=25_000_000_000, facts +PY + bounded stage python3 "$recipe/stage.py" + bounded bootstrap bash "$root/bootstrap.sh" "$root" + cd "$root/bun" + bounded source-preflight "$root/opt/bun-linux-x64-baseline/bun" scripts/glob-sources.ts --all > "$proof/source-globs-all.txt" +elif [[ "$phase" == cb-standard || "$phase" == cb-compat ]]; then + bounded "$phase-build" python3 "$root/build-bun-standalone-cb.py" --root "$root" \ + --profile "$phase" --lease-deadline-epoch "$P6_DEADLINE_EPOCH" + bounded "$phase-preserve" python3 "$root/preserve-compiler.py" --root "$root" --profile "$phase" + bounded "$phase-raw" python3 "$root/preserve-run-evidence.py" --root "$root" --profile "$phase" +else + echo "Unknown phase: $phase" >&2 + exit 2 +fi diff --git a/scripts/openclaw-p6/deadline_process.py b/scripts/openclaw-p6/deadline_process.py new file mode 100644 index 000000000000..c1251b9ac570 --- /dev/null +++ b/scripts/openclaw-p6/deadline_process.py @@ -0,0 +1,110 @@ +"""Own a subprocess group through an absolute deadline and bounded cleanup.""" +import argparse +import json +import os +from pathlib import Path +import signal +import subprocess +import time + + +class CommandInterrupted(Exception): + def __init__(self, signum): + self.signum = signum + + +def stop_group(child, grace=5): + try: + os.killpg(child.pid, signal.SIGTERM) + except ProcessLookupError: + child.wait() + return + until = time.monotonic() + grace + while time.monotonic() < until: + child.poll() # Reap an exited leader while checking for live descendants. + try: + os.killpg(child.pid, 0) + except ProcessLookupError: + break + time.sleep(0.05) + try: + os.killpg(child.pid, signal.SIGKILL) + except ProcessLookupError: + pass + child.wait() + + +def run_bounded(command, *, deadline_epoch, reserve_seconds=60, cleanup_grace=5, + cwd=None, env=None, stdout=None, stderr=None): + # Cleanup starts early enough to retain the reserve even for TERM-resistant children. + start = time.monotonic() + work_seconds = deadline_epoch - time.time() - reserve_seconds - cleanup_grace - 1 + facts = {'deadlineEpoch': deadline_epoch, 'reserveSeconds': reserve_seconds, + 'cleanupGraceSeconds': cleanup_grace, 'workSecondsAtStart': work_seconds, + 'timedOut': False, 'interruptedBySignal': None, 'launched': False} + if work_seconds <= 0: + facts.update(timedOut=True, exitCode=124, wallSeconds=0, finishedEpoch=time.time(), + finishedBeforeReserve=time.time() <= deadline_epoch-reserve_seconds) + return subprocess.CompletedProcess(command, 124, b'', b''), facts + handlers = {sig: signal.getsignal(sig) for sig in [signal.SIGINT, signal.SIGTERM, signal.SIGHUP]} + def interrupt(signum, _frame): + raise CommandInterrupted(signum) + for sig in handlers: + signal.signal(sig, interrupt) + child = None + output = error = None + code = 1 + try: + child = subprocess.Popen(command, cwd=cwd, env=env, stdout=stdout, stderr=stderr, + start_new_session=True) + facts['launched'] = True + try: + output, error = child.communicate(timeout=work_seconds) + code = child.returncode + except subprocess.TimeoutExpired: + facts['timedOut'] = True + code = 124 + except CommandInterrupted as interrupted: + facts['interruptedBySignal'] = interrupted.signum + code = 128 + interrupted.signum + finally: + for sig in handlers: + signal.signal(sig, signal.SIG_IGN) + try: + if child is not None: + stop_group(child, cleanup_grace) + output, error = child.communicate() + finally: + for sig, handler in handlers.items(): + signal.signal(sig, handler) + finished=time.time() + if finished > deadline_epoch-reserve_seconds: + code=124 + facts['timedOut']=True + facts.update(exitCode=code, wallSeconds=time.monotonic()-start, + finishedEpoch=finished, finishedBeforeReserve=finished <= deadline_epoch-reserve_seconds) + return subprocess.CompletedProcess(command, code, output, error), facts + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--deadline-epoch', type=float, required=True) + parser.add_argument('--reserve-seconds', type=float, default=60) + parser.add_argument('--cleanup-grace-seconds', type=float, default=15) + parser.add_argument('--receipt', type=Path, required=True) + parser.add_argument('command', nargs=argparse.REMAINDER) + args = parser.parse_args() + command = args.command[1:] if args.command[:1] == ['--'] else args.command + if not command: + parser.error('Command required') + args.receipt.parent.mkdir(parents=True, exist_ok=True) + result, facts = run_bounded(command, deadline_epoch=args.deadline_epoch, + reserve_seconds=args.reserve_seconds, + cleanup_grace=args.cleanup_grace_seconds) + args.receipt.write_text(json.dumps(facts, indent=2)+'\n') + print('P6_PHASE_DEADLINE '+json.dumps(facts), flush=True) + raise SystemExit(result.returncode if result.returncode >= 0 else 128-result.returncode) + + +if __name__ == '__main__': + main() diff --git a/scripts/openclaw-p6/host.sh b/scripts/openclaw-p6/host.sh new file mode 100644 index 000000000000..8bd1a5f3ba0e --- /dev/null +++ b/scripts/openclaw-p6/host.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +set -euo pipefail +phase=${1:?bootstrap, cb-standard, cb-compat or cleanup} +: "${P6_WORK:?Missing task directory}" +: "${P6_CONTAINER:?Missing owned container name}" +if [[ "$phase" == cleanup ]]; then + timeout --kill-after=5s 20s docker stop --time 10 "$P6_CONTAINER" > /dev/null 2>&1 || true + timeout --kill-after=5s 20s docker inspect "$P6_CONTAINER" > "$P6_WORK/container-final.json" 2>/dev/null || true + timeout --kill-after=5s 20s docker rm --force "$P6_CONTAINER" > /dev/null 2>&1 || true + timeout --kill-after=5s 20s docker ps --all --quiet --filter "name=^${P6_CONTAINER}$" > "$P6_WORK/containers-after-cleanup.txt" + [[ ! -s "$P6_WORK/containers-after-cleanup.txt" ]] + exit 0 +fi +: "${P6_DEADLINE_EPOCH:?Missing absolute work deadline}" +cleanup_on_error() { + code=$? + if (( code != 0 )); then + timeout --kill-after=5s 20s docker stop --time 10 "$P6_CONTAINER" > /dev/null 2>&1 || true + fi + exit "$code" +} +trap cleanup_on_error EXIT +trap 'exit 143' TERM +trap 'exit 130' INT +trap 'exit 129' HUP +remaining=$(( P6_DEADLINE_EPOCH - $(date +%s) - 600 )) +(( remaining > 0 )) || exit 124 +if [[ "$phase" == bootstrap ]]; then + [[ $(uname -m) == x86_64 && $(uname -s) == Linux ]] + image=ubuntu:24.04@sha256:a2d43bffc46670d7108bb3c0468c67c5557c4c92e83e1e34cbff1322ad1b94dc + timeout --kill-after=15s 300s docker pull "$image" + recipe=$(cd "$(dirname "$0")" && pwd -P) + mkdir -p "$P6_WORK/data" + remaining=$(( P6_DEADLINE_EPOCH - $(date +%s) - 600 )) + (( remaining > 10 )) || exit 124 + start_seconds=$(( remaining - 10 )) + (( start_seconds <= 50 )) || start_seconds=50 + timeout --signal=TERM --kill-after=10s "${start_seconds}s" \ + docker run --detach --name "$P6_CONTAINER" --init --platform linux/amd64 \ + --mount "type=bind,src=$recipe,dst=/p6-recipe,readonly" \ + --mount "type=bind,src=$P6_WORK/data,dst=/root/.cache/oc-ty-ext/P6" \ + "$image" sleep infinity > /dev/null +fi +remaining=$(( P6_DEADLINE_EPOCH - $(date +%s) - 600 )) +(( remaining > 0 )) || exit 124 +timeout --signal=TERM --kill-after=20s "${remaining}s" \ + docker exec -e P6_DEADLINE_EPOCH="$P6_DEADLINE_EPOCH" -e PYTHONDONTWRITEBYTECODE=1 \ + "$P6_CONTAINER" bash /p6-recipe/container.sh "$phase" diff --git a/scripts/openclaw-p6/preserve-compiler.py b/scripts/openclaw-p6/preserve-compiler.py new file mode 100644 index 000000000000..6e14872e1f67 --- /dev/null +++ b/scripts/openclaw-p6/preserve-compiler.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +"""Preserve one actual successful physical standard or SR-off compiler; no upload.""" +import argparse,hashlib,json,platform,tarfile +from pathlib import Path + +def sha(p): + with Path(p).open('rb') as stream:return hashlib.file_digest(stream,'sha256').hexdigest() + +def main(): + p=argparse.ArgumentParser(description=__doc__);p.add_argument('--root',type=Path,required=True);p.add_argument('--profile',choices=['cb-standard','cb-compat'],required=True);a=p.parse_args();profile=a.profile;directory='build-standard' if profile=='cb-standard' else 'build-c2' + assert platform.system()=='Linux' and platform.machine()=='x86_64' + root=a.root.resolve();assert root==Path.home()/'.cache/oc-ty-ext/P6/rd150c-x64-highmem-deadline-v1' + compiler=root/directory/'bun';build=root/'receipts'/f'{profile}-build.json';config=root/directory/'configure.json' + data=json.loads(build.read_text());settings=json.loads(config.read_text()) + assert data['status']=='build-command-finished-not-qualified' + assert data['exitCode']==0 and data['profile']==profile and data['compiler']==str(compiler) + assert data['compilerSha256']==sha(compiler) + assert data['source']['bun']=='150c9620c53710060186b8b0cd50985e035408b0' + assert data['source']['webkit']=='aaa690bfbf34c9d50775716ac2fc3c7d0573e0b8' + overrides=settings['overrides'];assert settings['profile']=='release-local' + assert overrides['shadowRealm'] is (profile=='cb-standard') and overrides.get('hardened',False) is False + assert overrides['webkitVersion']=='aaa690bfbf34c9d50775716ac2fc3c7d0573e0b8' + assert overrides['aot'] is True and overrides['trimmable'] is True + target=root/f'preserved-{profile}';target.mkdir(exist_ok=False) + entries=[compiler,config,build,root/'receipts'/f'{profile}.sha256'] + with tarfile.open(target/'compiler.tar','w') as archive: + for file in entries:archive.add(file,arcname=str(file.relative_to(root)),recursive=False) + receipt={'status':'native-preserved-not-downloaded','profile':profile,'compilerSha256':sha(compiler),'buildReceiptSha256':sha(build),'configureSha256':sha(config),'archive':str(target/'compiler.tar'),'archiveSha256':sha(target/'compiler.tar'),'archiveBytes':(target/'compiler.tar').stat().st_size,'members':{str(file.relative_to(root)):sha(file) for file in entries},'applicationQualified':False} + (target/'transport.json').write_text(json.dumps(receipt,indent=2)+'\n') + print(json.dumps(receipt,indent=2)) + +if __name__=='__main__':main() diff --git a/scripts/openclaw-p6/preserve-run-evidence.py b/scripts/openclaw-p6/preserve-run-evidence.py new file mode 100644 index 000000000000..eaca0011b668 --- /dev/null +++ b/scripts/openclaw-p6/preserve-run-evidence.py @@ -0,0 +1,35 @@ +"""Preserve original per-profile run evidence, including failed builds; no upload.""" +import argparse +import hashlib +import json +from pathlib import Path +import tarfile + + +def sha(path): + with path.open('rb') as stream: + return hashlib.file_digest(stream, 'sha256').hexdigest() + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--root', type=Path, required=True) + parser.add_argument('--profile', choices=['cb-standard','cb-compat'], required=True) + args = parser.parse_args() + root = args.root.resolve() + assert root == Path.home()/'.cache/oc-ty-ext/P6/rd150c-x64-highmem-deadline-v1' + files = sorted(p for p in (root/'receipts').glob(args.profile+'*') if p.is_file() and not p.is_symlink()) + assert files, 'No run evidence exists' + files.append(root/'source-ready.json') + target = root/('raw-'+args.profile) + target.mkdir(exist_ok=False) + with tarfile.open(target/'evidence.tar', 'w') as archive: + for path in files: + archive.add(path, arcname=str(path.relative_to(root)), recursive=False) + receipt = {'profile': args.profile, 'archive': str(target/'evidence.tar'), 'sha256': sha(target/'evidence.tar'), 'bytes': (target/'evidence.tar').stat().st_size, 'files': {str(path.relative_to(root)): sha(path) for path in files}, 'scope': 'original raw run evidence; may describe a failed or interrupted experiment', 'memoryFitQualified': False} + (target/'transport.json').write_text(json.dumps(receipt, indent=2)+'\n') + print(json.dumps(receipt, indent=2)) + + +if __name__ == '__main__': + main() diff --git a/scripts/openclaw-p6/setup-sysroot.sh b/scripts/openclaw-p6/setup-sysroot.sh new file mode 100644 index 000000000000..e33fc20bf611 --- /dev/null +++ b/scripts/openclaw-p6/setup-sysroot.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# P6 amd64 adaptation of scripts/build/ci-images/spec.ts::glibcSysroot(). +# Uses the x64 hashes and library layout from the same pinned build spec. +set -euo pipefail +: "${P6_WORK:?Set P6_WORK}" +if [[ $(uname -s) != Linux || $(uname -m) != x86_64 ]]; then + echo "Run this on the native P6 x64 Linux Testbox." >&2 + exit 1 +fi +for tool in skopeo jq curl sha256sum dpkg-deb tar python3; do + if ! command -v "$tool" >/dev/null; then + echo "Missing $tool. Install prerequisites in the task-owned container: apt-get -o Dir::Cache::archives=${P6_WORK}/apt-archives install -y --no-install-recommends skopeo jq" >&2 + exit 1 + fi +done +spec=${P6_WORK}/bun/scripts/build/ci-images/spec.ts +printf '%s %s\n' c628259fe7f37826a91feee3c2b144b3ee7ccedf461c566723bf458f51171466 "$spec" | sha256sum -c - +inputs=${P6_WORK}/sysroot-inputs +sysroot=${P6_WORK}/opt/linux-sysroot-glibc-amd64 +image="$inputs/image-amd64" +gcc_dir="$inputs/gcc-amd64" +mkdir -p "$inputs" "${P6_WORK}/opt" "${P6_WORK}/tmp" +if [[ -e "$sysroot" || -L "$sysroot" ]]; then + echo "Refusing to overwrite existing sysroot: $sysroot" >&2 + exit 1 +fi +mkdir "$sysroot" +export TMPDIR=${P6_WORK}/tmp +printf '%s\n' '{"auths":{}}' > "$inputs/empty-registry-auth.json" +skopeo copy --authfile "$inputs/empty-registry-auth.json" --override-arch amd64 docker://docker.io/library/ubuntu@sha256:8feb4d8ca5354def3d8fce243717141ce31e2c428701f6682bd2fafe15388214 "dir:$image" +while IFS= read -r layer; do + digest=${layer#sha256:} + printf '%s %s\n' "$digest" "$image/$digest" | sha256sum -c - + # Bun's bake tolerates tar failures because device nodes are not required. + # Retain each diagnostic log, then verify the libc/headers needed below. + if ! tar -xzf "$image/$digest" -C "$sysroot" 2>"$inputs/layer-$digest.stderr"; then + echo "Layer extraction reported errors; inspect $inputs/layer-$digest.stderr (upstream tolerates missing device nodes)." >&2 + fi +done < <(jq -r '.layers[].digest' "$image/manifest.json") +fetch() { + local url=$1 file=$2 digest=$3 + curl -fL --retry 2 --connect-timeout 30 -o "$file" "$url" + printf '%s %s\n' "$digest" "$file" | sha256sum -c - +} +# Exact Ubuntu focal pins and publisher hashes from Bun's image specification. +while IFS='|' read -r directory package version digest; do + file="$inputs/${package}_${version}_amd64.deb" + fetch "https://archive.ubuntu.com/ubuntu/pool/main/$directory/${package}_${version}_amd64.deb" "$file" "$digest" + dpkg-deb -x "$file" "$sysroot" +done <<'DEBS' +g/glibc|libc6|2.31-0ubuntu9.18|1b2281aac4935dfea1f89dfc19e445fdbb45303202af60679ccb8bf035f081a0 +g/glibc|libc6-dev|2.31-0ubuntu9.18|11029900f2315b93ce487792ae1bf15f0927e5e50880c091e6a440b14d4e164a +l/linux|linux-libc-dev|5.4.0-216.236|70c9addd36aabd2d031d5ea0fc444f8b193027aef79ff3d8275d25800aed8ede +libx/libxcrypt|libcrypt1|4.4.10-10ubuntu4|231b4dbbe5865775f118cfa61394f1e16fa7102b6953a327e672499a20876d73 +libx/libxcrypt|libcrypt-dev|4.4.10-10ubuntu4|f0a41d8e8cf379dbbdfc43169f34851ed452b3581e72c6654f2e290caf4e1b20 +DEBS +# Keep absolute image symlinks inside the sysroot, exactly as the bake does. +python3 - "$sysroot" <<'LINKS' +import os,sys +root=sys.argv[1] +for directory, dirs, files in os.walk(root, followlinks=False): + for name in dirs+files: + path=os.path.join(directory,name) + if os.path.islink(path): + target=os.readlink(path) + if target.startswith('/'): + os.unlink(path) + os.symlink(root+target,path) +LINKS +if [[ ! -e "$sysroot/lib/x86_64-linux-gnu/libc.so.6" ]]; then + mkdir -p "$sysroot/lib" + ln -s ../usr/lib/x86_64-linux-gnu "$sysroot/lib/x86_64-linux-gnu" +fi +fetch https://github.com/oven-sh/WebKit/releases/download/gcc-13-focal-debs/gcc-13-focal-amd64.tar.gz "$inputs/gcc-amd64.tar.gz" a2b3b6e10b175bbaaefeb3e9e703ca26a97ed6c1f19ca842d3e0b0c8f941e65b +mkdir -p "$gcc_dir" +tar -xzf "$inputs/gcc-amd64.tar.gz" -C "$gcc_dir" +shopt -s nullglob +gcc_debs=("$gcc_dir"/*.deb) +if ((${#gcc_debs[@]} == 0)); then + echo "No gcc-13 debs in the verified upstream archive." >&2 + exit 1 +fi +for deb in "${gcc_debs[@]}"; do + dpkg-deb -x "$deb" "$sysroot" +done +if [[ ! -e "$sysroot/lib64" ]]; then ln -s usr/lib/x86_64-linux-gnu "$sysroot/lib64"; fi +[[ -e "$sysroot/lib/x86_64-linux-gnu/libc.so.6" ]] +[[ -e "$sysroot/usr/include/stdio.h" ]] +[[ -d "$sysroot/usr/include/c++/13" ]] +python3 - "$inputs" "$sysroot" "$spec" <<'RECEIPT' +import datetime,hashlib,json,pathlib,sys +inputs,root,spec=map(pathlib.Path,sys.argv[1:]) +files=[p for p in inputs.iterdir() if p.suffix=='.deb']+[inputs/'gcc-amd64.tar.gz'] +receipt={'status':'prepared','arch':'x86_64','glibc':'2.31','gcc_headers':'13','sysroot':str(root),'source':str(spec),'source_sha256':hashlib.sha256(spec.read_bytes()).hexdigest(),'ubuntu_image':'sha256:8feb4d8ca5354def3d8fce243717141ce31e2c428701f6682bd2fafe15388214','files':{p.name:hashlib.sha256(p.read_bytes()).hexdigest() for p in files},'created_utc':datetime.datetime.now(datetime.timezone.utc).isoformat()} +(root/'P6-sysroot-receipt.json').write_text(json.dumps(receipt,indent=2)+'\n') +print(json.dumps(receipt,indent=2)) +RECEIPT +printf '\nUse for the compiler build:\nexport LINUX_GLIBC_SYSROOT=%q\n' "$sysroot" diff --git a/scripts/openclaw-p6/source_files.py b/scripts/openclaw-p6/source_files.py new file mode 100644 index 000000000000..7aca9824e3ea --- /dev/null +++ b/scripts/openclaw-p6/source_files.py @@ -0,0 +1,68 @@ +"""Verify pinned sparse exports without executing repository code.""" +import hashlib +import os +from pathlib import Path +import stat +import tarfile + + +def digest(path): + result = hashlib.sha256() + with Path(path).open('rb') as source: + for block in iter(lambda: source.read(1024 * 1024), b''): + result.update(block) + return result.hexdigest() + + +def blob(data): + return hashlib.sha1(b'blob ' + str(len(data)).encode() + b'\0' + data).hexdigest() + + +def verify_archive(archive, entries): + expected = {row['path']: row for row in entries} + seen = set() + with tarfile.open(archive, 'r:gz') as source: + for member in source: + if member.isdir(): + continue + row = expected.get(member.name) + if row is None or member.name in seen: + raise ValueError(f'Unexpected or duplicate archive member: {member.name}') + if member.issym() and row['mode'] == '120000': + data = os.fsencode(member.linkname) + elif member.isfile() and row['mode'] in ['100644', '100755']: + if bool(member.mode & 0o111) != (row['mode'] == '100755'): + raise ValueError(f'Executable mode mismatch: {member.name}') + data = source.extractfile(member).read() + else: + raise ValueError(f'Archive member type mismatch: {member.name}') + if blob(data) != row['blob']: + raise ValueError(f'Archive Git blob mismatch: {member.name}') + seen.add(member.name) + if seen != set(expected): + raise ValueError(f'Missing archive members: {sorted(set(expected) - seen)[:5]}') + return len(seen) + + +def verify_files(root, entries): + for row in entries: + path = Path(root) / row['path'] + mode = path.lstat().st_mode + if row['mode'] == '120000' and stat.S_ISLNK(mode): + data = os.fsencode(os.readlink(path)) + elif row['mode'] in ['100644', '100755'] and stat.S_ISREG(mode): + if bool(mode & 0o111) != (row['mode'] == '100755'): + raise ValueError(f'Executable mode mismatch: {path}') + data = path.read_bytes() + else: + raise ValueError(f'File type mismatch: {path}') + if blob(data) != row['blob']: + raise ValueError(f'Git blob mismatch: {path}') + + +def extract(archive, destination, entries): + verify_archive(archive, entries) + Path(destination).mkdir() + with tarfile.open(archive, 'r:gz') as source: + source.extractall(destination, filter='data') + verify_files(destination, entries) diff --git a/scripts/openclaw-p6/sources.json b/scripts/openclaw-p6/sources.json new file mode 100644 index 000000000000..a1b0c94cc66e --- /dev/null +++ b/scripts/openclaw-p6/sources.json @@ -0,0 +1,144 @@ +{ + "bun": { + "commit": "150c9620c53710060186b8b0cd50985e035408b0", + "repository": "https://github.com/openclaw/bun.git", + "roots": [ + ".aikido", + ".bk.yaml", + ".buildkite", + ".cargo", + ".clang-tidy", + ".clangd", + ".claude", + ".coderabbit.yaml", + ".cursor", + ".cursorignore", + ".dockerignore", + ".editorconfig", + ".git-blame-ignore-revs", + ".gitattributes", + ".github", + ".gitignore", + ".lldbinit", + ".mailmap", + ".prettierignore", + ".prettierrc", + ".vscode", + "AGENTS.md", + "CHANGELOG.md", + "CLAUDE.md", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.md", + "Cargo.lock", + "Cargo.toml", + "LATEST", + "LICENSE.md", + "README.md", + "REVIEW.md", + "SECURITY.md", + "bun.lock", + "bunfig.node-test.toml", + "bunfig.toml", + "clippy.toml", + "completions", + "dockerhub", + "docs", + "entitlements.debug.plist", + "entitlements.plist", + "flake.lock", + "flake.nix", + "hawk.toml", + "misctools", + "mordant-baseline.toml", + "mordant.toml", + "oxlint.json", + "package.json", + "packages", + "patches", + "rust-toolchain.toml", + "rustfmt.toml", + "scripts", + "shell.nix", + "src", + "tools", + "tsconfig.base.json", + "tsconfig.json", + "docs/bundler/aot-size.mdx", + "src/crash_handler/lib.rs", + "src/jsc/bindings/ZigGlobalObject.cpp", + "src/trim/decide.rs", + "src/trim/plan.rs", + "test/aot/executables-leave-out-the-command-line.test.ts", + "test/aot/code-size-map.test.ts", + "test/aot/run-time-plugins-and-compiled-modules.test.ts", + "test/internal/build-hardened-flags.test.ts", + "test/js/bun/plugin/plugin-namespace-drive-letter.test.ts" + ], + "manifestSha256": "2bc1d8331e91b2fef1bf0932d7ae815f099cd73fbadd6404908be78dd01c180b", + "files": 8896 + }, + "webkit": { + "commit": "aaa690bfbf34c9d50775716ac2fc3c7d0573e0b8", + "repository": "https://github.com/openclaw/WebKit.git", + "roots": [ + "jsc.md", + ".submitproject-tools", + "Dockerfile.macos", + ".dir-locals.el", + ".submitproject-append", + "CMakeLists.txt", + "Dockerfile.musl", + "CHANGELOG.md", + "Dockerfile", + "Makefile", + ".wkdev-sdk-version", + "Introduction.md", + "build-icu.ps1", + ".editorconfig", + "Makefile.shared", + "ReadMe.md", + "CMakePresets.json", + ".sourcefilters", + ".dockerignore", + ".gitignore", + "vcpkg.json", + ".submitproject", + "Dockerfile.freebsd", + ".clang-format", + ".gitattributes", + "Dockerfile.android", + ".swift-format", + "Dockerfile.windows", + ".metadata_never_index", + "a.patch", + "vcpkg-configuration.json", + "CLAUDE.md", + ".ccls", + "Source/JavaScriptCore", + "Source/CMakeLists.txt", + "Source/bmalloc", + "Source/cmake", + "Source/Makefile", + "Source/PlatformCocoa.cmake", + "Source/Makefile.shared", + "Source/PlatformWin.cmake", + "Source/PlatformWPE.cmake", + "Source/WTF", + "Source/PlatformGTK.cmake", + "Tools/PlatformPlayStation.cmake", + "Tools/CMakeLists.txt", + "Tools/Makefile", + "Tools/svn-config", + "Tools/PlatformCocoa.cmake", + "Tools/PlatformWin.cmake", + "Tools/PlatformWPE.cmake", + "Tools/.gitignore", + "Tools/Scripts", + "Tools/.gitattributes", + "Tools/PlatformGTK.cmake", + "icu" + ], + "manifestSha256": "24927013df4b269b3d6d5e2d9562571369bac0efc4933d3661706a4aa46c6cdc", + "files": 13968 + } +} diff --git a/scripts/openclaw-p6/stage.py b/scripts/openclaw-p6/stage.py new file mode 100644 index 000000000000..009306435075 --- /dev/null +++ b/scripts/openclaw-p6/stage.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python3 +"""Fetch and verify the exact sparse source trees reviewed for P6.""" +import datetime +import hashlib +import json +import os +from pathlib import Path +import platform +import shutil +import subprocess +import sys + +from source_files import verify_files + +HERE = Path(__file__).resolve().parent +ROOT = Path('/root/.cache/oc-ty-ext/P6/rd150c-x64-highmem-deadline-v1') + + +def git(directory, *args, **kwargs): + return subprocess.run(['git', '-c', 'credential.helper=', '-c', 'http.extraHeader=', *args], + cwd=directory, check=True, **kwargs) + + +def source_manifest(directory, pins): + raw = git(directory, 'ls-tree', '-rz', pins['commit'], stdout=subprocess.PIPE).stdout + rows = [] + for entry in raw.split(b'\0'): + if not entry: + continue + metadata, name = entry.split(b'\t', 1) + mode, kind, blob = metadata.decode().split() + path = name.decode() + if any(path == root or path.startswith(root + '/') for root in pins['roots']): + if kind != 'blob': + raise ValueError(f'Unexpected source kind: {path}: {kind}') + rows.append({'path': path, 'mode': mode, 'blob': blob}) + rows.sort(key=lambda row: row['path']) + encoded = json.dumps(rows, sort_keys=True, separators=(',', ':')).encode() + if len(rows) != pins['files'] or hashlib.sha256(encoded).hexdigest() != pins['manifestSha256']: + raise ValueError('Source tree differs from the reviewed P6 manifest') + return rows + + +def main(): + if platform.system() != 'Linux' or platform.machine() != 'x86_64' or sys.version_info < (3, 12): + raise SystemExit('Requires native Linux x64 and Python 3.12+') + if ROOT.exists() or shutil.disk_usage(ROOT.parent).free < 25_000_000_000: + raise SystemExit('Requires a fresh P6 root and at least 25GB free') + ROOT.mkdir() + pins = json.loads((HERE / 'sources.json').read_text()) + os.environ.update(GIT_TERMINAL_PROMPT='0', GIT_CONFIG_GLOBAL='/dev/null', GIT_CONFIG_NOSYSTEM='1') + for name, key in [('bun', 'targetManifest'), ('webkit', 'manifest')]: + source = ROOT / ('WebKit' if name == 'webkit' else 'bun') + source.mkdir() + spec = pins[name] + git(source, 'init', '--quiet') + git(source, 'remote', 'add', 'origin', spec['repository']) + git(source, 'sparse-checkout', 'init', '--no-cone') + git(source, 'sparse-checkout', 'set', '--no-cone', '--stdin', + input=''.join('/' + path + '\n' for path in spec['roots']).encode()) + git(source, 'fetch', '--depth=1', '--filter=blob:none', '--no-tags', 'origin', spec['commit']) + git(source, 'checkout', '--detach', '--quiet', 'FETCH_HEAD') + revision = git(source, 'rev-parse', 'HEAD', stdout=subprocess.PIPE).stdout.decode().strip() + if revision != spec['commit']: + raise ValueError('Source commit mismatch') + manifest = source_manifest(source, spec) + verify_files(source, manifest) + (ROOT / f'{name}-inputs.json').write_text(json.dumps({key: manifest}, indent=2) + '\n') + for path in HERE.iterdir(): + if path.is_file(): + shutil.copy2(path, ROOT / path.name) + for name in ['tmp', 'home', 'downloads', 'opt', 'receipts', 'apt-archives/partial', 'apt-lists/partial']: + (ROOT / name).mkdir(parents=True, exist_ok=True) + receipt = {'status': 'source-staged-not-built', 'bun': pins['bun']['commit'], + 'webkit': pins['webkit']['commit'], 'root': str(ROOT), + 'sourceTransport': 'anonymous-git-exact-commit', 'sources': pins, + 'recordedAt': datetime.datetime.now(datetime.timezone.utc).isoformat()} + (ROOT / 'source-ready.json').write_text(json.dumps(receipt, indent=2) + '\n') + + +if __name__ == '__main__': + main() From f9fa08790bf45b3e995280f6eb249e14fd9191c1 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 25 Oct 2026 10:05:50 -0700 Subject: [PATCH 05/20] fix(ci): prepare LLVM linker runtime dependencies --- scripts/openclaw-p6/bootstrap.sh | 16 +--------- scripts/openclaw-p6/ensure-llvm-runtime.sh | 37 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 scripts/openclaw-p6/ensure-llvm-runtime.sh diff --git a/scripts/openclaw-p6/bootstrap.sh b/scripts/openclaw-p6/bootstrap.sh index 536963c39e81..af3bab50b71e 100644 --- a/scripts/openclaw-p6/bootstrap.sh +++ b/scripts/openclaw-p6/bootstrap.sh @@ -35,22 +35,8 @@ unzip -o "$root/downloads/bun.zip" -d "$root/opt" fetch https://github.com/llvm/llvm-project/releases/download/llvmorg-23.1.1/LLVM-23.1.1-Linux-X64.tar.xz "$root/downloads/llvm.tar.xz" 832aeb58d105de1cabc7b982dd2c65de0610f7377df48ae8fc2dd8e97420a15c mkdir -p "$root/opt/llvm" tar -xJf "$root/downloads/llvm.tar.xz" --strip-components=1 -C "$root/opt/llvm" -ldd "$root/opt/llvm/bin/clang" > "$root/receipts/clang-ldd-before.txt" -if grep -q 'not found' "$root/receipts/clang-ldd-before.txt"; then - curl -fL --retry 2 -o "$root/downloads/libicu70.deb" https://archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu70_70.1-2_amd64.deb - curl -fL --retry 2 -o "$root/downloads/Packages.xz" https://archive.ubuntu.com/ubuntu/dists/jammy/main/binary-amd64/Packages.xz - python3 - "$root/downloads" <<'PY' -import hashlib,lzma,pathlib,sys -root=pathlib.Path(sys.argv[1]);text=lzma.decompress((root/'Packages.xz').read_bytes()).decode() -blocks=[b for b in text.split('\n\n') if b.startswith('Package: libicu70\n')] -assert len(blocks)==1 -fields=dict(line.split(': ',1) for line in blocks[0].splitlines() if ': ' in line and not line.startswith(' ')) -assert fields['Version']=='70.1-2' and fields['Architecture']=='amd64' -assert hashlib.sha256((root/'libicu70.deb').read_bytes()).hexdigest()==fields['SHA256'] -PY - dpkg-deb -x "$root/downloads/libicu70.deb" "$root/opt/llvm-runtime" -fi export LD_LIBRARY_PATH="$root/opt/llvm-runtime/usr/lib/x86_64-linux-gnu" +bash "$root/ensure-llvm-runtime.sh" "$root" export PATH="$root/opt/llvm/bin:$root/opt/bun-linux-x64-baseline:$CARGO_HOME/bin:/usr/local/bin:/usr/bin:/bin" curl -fL --retry 2 -o "$root/downloads/rustup-init" https://static.rust-lang.org/rustup/archive/1.28.2/x86_64-unknown-linux-gnu/rustup-init curl -fL --retry 2 -o "$root/downloads/rustup-init.sha256" https://static.rust-lang.org/rustup/archive/1.28.2/x86_64-unknown-linux-gnu/rustup-init.sha256 diff --git a/scripts/openclaw-p6/ensure-llvm-runtime.sh b/scripts/openclaw-p6/ensure-llvm-runtime.sh new file mode 100644 index 000000000000..de52a533b918 --- /dev/null +++ b/scripts/openclaw-p6/ensure-llvm-runtime.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -euo pipefail +root=${1:?absolute P6 build root} +export LD_LIBRARY_PATH="$root/opt/llvm-runtime/usr/lib/x86_64-linux-gnu" +# Native Linux compile, archive, strip and binary-check tools selected by build/tools.ts. +tools=(clang clang++ ld.lld llvm-ar llvm-strip llvm-nm llvm-readobj llvm-objdump llvm-cxxfilt) +needs_icu=false +for tool in "${tools[@]}"; do + receipt="$root/receipts/$tool-ldd-before.txt" + timeout --signal=TERM --kill-after=5s 30s ldd "$root/opt/llvm/bin/$tool" > "$receipt" + if grep -Eq 'libicu[^[:space:]]*\.so\.70[[:space:]]+=>[[:space:]]+not found' "$receipt"; then + needs_icu=true + fi +done +if [[ "$needs_icu" == true ]]; then + curl -fL --retry 2 -o "$root/downloads/libicu70.deb" https://archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu70_70.1-2_amd64.deb + curl -fL --retry 2 -o "$root/downloads/Packages.xz" https://archive.ubuntu.com/ubuntu/dists/jammy/main/binary-amd64/Packages.xz + python3 - "$root/downloads" <<'PY' +import hashlib,lzma,pathlib,sys +root=pathlib.Path(sys.argv[1]);text=lzma.decompress((root/'Packages.xz').read_bytes()).decode() +blocks=[b for b in text.split('\n\n') if b.startswith('Package: libicu70\n')] +assert len(blocks)==1 +fields=dict(line.split(': ',1) for line in blocks[0].splitlines() if ': ' in line and not line.startswith(' ')) +assert fields['Version']=='70.1-2' and fields['Architecture']=='amd64' +assert hashlib.sha256((root/'libicu70.deb').read_bytes()).hexdigest()==fields['SHA256'] +PY + dpkg-deb -x "$root/downloads/libicu70.deb" "$root/opt/llvm-runtime" +fi +for tool in "${tools[@]}"; do + receipt="$root/receipts/$tool-ldd-after.txt" + timeout --signal=TERM --kill-after=5s 30s ldd "$root/opt/llvm/bin/$tool" > "$receipt" + if grep -q 'not found' "$receipt"; then + cat "$receipt" >&2 + exit 1 + fi + timeout --signal=TERM --kill-after=5s 30s "$root/opt/llvm/bin/$tool" --version > "$root/receipts/$tool-version.txt" +done From 07534177941e96284e22e27285439c0d8c8532f4 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 25 Oct 2026 11:20:49 -0700 Subject: [PATCH 06/20] ci: qualify native Linux x64 AOT applications --- .github/workflows/openclaw-build-test.yml | 80 ++- scripts/openclaw-p6/app/README.md | 83 +++ scripts/openclaw-p6/app/admit.py | 54 ++ scripts/openclaw-p6/app/compiler-pins.json | 27 + scripts/openclaw-p6/app/docker-client.py | 15 + scripts/openclaw-p6/app/download.py | 84 +++ scripts/openclaw-p6/app/export.py | 129 +++++ scripts/openclaw-p6/app/guest.py | 77 +++ scripts/openclaw-p6/app/guest.sh | 4 + scripts/openclaw-p6/app/host.sh | 137 +++++ scripts/openclaw-p6/app/initialize.py | 42 ++ scripts/openclaw-p6/app/packet/commands.json | 55 ++ .../app/packet/input-projection.json | 104 ++++ .../admission-inputs/P0-artifacts.json | 25 + .../admission-inputs/p0-reference.json | 9 + .../admission-inputs/source-preparation.json | 60 ++ .../payload/admission-templates/c2-off.json | 76 +++ .../payload/admission-templates/js.json | 76 +++ .../payload/admission-templates/ts.json | 76 +++ .../app/packet/payload/adopt-compilers.py | 29 + .../payload/build-prep/artifact-contract.mjs | 52 ++ .../packet/payload/build-prep/build-linux.py | 474 +++++++++++++++ .../payload/build-prep/select-plugins.mjs | 40 ++ .../payload/cron-fixture/cron-cli-fixture.sh | 540 ++++++++++++++++++ .../packet/payload/cron-fixture/inputs.json | 22 + .../packet/payload/cron-fixture/run-native.sh | 65 +++ .../payload/guest/application/guest-cli.py | 72 +++ .../guest/application/memory-policy.py | 25 + .../application/run-application-guest.py | 156 +++++ .../guest/application/security/file-exec.c | 28 + .../application/security/fixture/index.js | 19 + .../security/fixture/openclaw.plugin.json | 7 + .../application/security/fixture/package.json | 9 + .../payload/guest/application/security/mdwe.c | 55 ++ .../payload/guest/application/trace-policy.py | 57 ++ .../packet/payload/guest/collect-evidence.py | 40 ++ .../payload/guest/guest-prerequisites.py | 44 ++ .../app/packet/payload/guest/manifest.json | 22 + .../app/packet/payload/guest/prepare-guest.py | 64 +++ .../guest/shared/guest_result_transport.py | 26 + .../payload/guest/shared/kvm-preflight.py | 21 + .../payload/guest/shared/run-kvm-guest.py | 142 +++++ .../app/packet/payload/manifest.json | 61 ++ .../app/packet/payload/measure-command.py | 58 ++ .../app/packet/payload/native-prep.py | 129 +++++ .../app/packet/payload/preserve.py | 218 +++++++ .../packet/payload/qualification/README.md | 167 ++++++ .../payload/qualification/docker-image.py | 34 ++ .../qualification/harness/Dockerfile.aot | 24 + .../qualification/harness/analyze-workers.py | 15 + .../qualification/harness/analyze-zero-js.py | 81 +++ .../qualification/harness/aot-entry.mjs | 7 + .../harness/capability-runner.mjs | 131 +++++ .../harness/config-roundtrip.mjs | 15 + .../qualification/harness/core-runner.mjs | 239 ++++++++ .../qualification/harness/elf-floor.py | 25 + .../qualification/harness/fixture-config.mjs | 22 + .../harness/gateway-readiness.mjs | 8 + .../harness/kitchen-sink-pin.json | 33 ++ .../harness/legacy/capability-provider.mjs | 141 +++++ .../harness/legacy/native_trace.py | 135 +++++ .../qualification/harness/openclaw-launcher | 2 + .../payload/qualification/manifest.json | 41 ++ .../packet/payload/qualification/qualify.py | 96 ++++ .../qualification/source-contract.json | 27 + .../app/packet/payload/runtime-controller.py | 126 ++++ .../openclaw-p6/app/packet/payload/stage.py | 17 + scripts/openclaw-p6/app/paging-host.py | 72 +++ scripts/openclaw-p6/app/paging/operation.py | 92 +++ scripts/openclaw-p6/app/paging/swap64.py | 267 +++++++++ scripts/openclaw-p6/app/paging/test_paging.py | 70 +++ .../openclaw-p6/app/paging/verify-active.py | 67 +++ scripts/openclaw-p6/app/prepare.sh | 27 + scripts/openclaw-p6/app/test-candidate.py | 222 +++++++ .../openclaw-p6/app/test-runtime-terminal.py | 95 +++ scripts/openclaw-p6/app/variant.sh | 44 ++ scripts/openclaw-p6/app/verify-compiler.py | 32 ++ scripts/openclaw-p6/app/verify-download.py | 53 ++ 78 files changed, 6114 insertions(+), 1 deletion(-) create mode 100644 scripts/openclaw-p6/app/README.md create mode 100644 scripts/openclaw-p6/app/admit.py create mode 100644 scripts/openclaw-p6/app/compiler-pins.json create mode 100755 scripts/openclaw-p6/app/docker-client.py create mode 100644 scripts/openclaw-p6/app/download.py create mode 100644 scripts/openclaw-p6/app/export.py create mode 100644 scripts/openclaw-p6/app/guest.py create mode 100644 scripts/openclaw-p6/app/guest.sh create mode 100644 scripts/openclaw-p6/app/host.sh create mode 100644 scripts/openclaw-p6/app/initialize.py create mode 100644 scripts/openclaw-p6/app/packet/commands.json create mode 100644 scripts/openclaw-p6/app/packet/input-projection.json create mode 100644 scripts/openclaw-p6/app/packet/payload/admission-inputs/P0-artifacts.json create mode 100644 scripts/openclaw-p6/app/packet/payload/admission-inputs/p0-reference.json create mode 100644 scripts/openclaw-p6/app/packet/payload/admission-inputs/source-preparation.json create mode 100644 scripts/openclaw-p6/app/packet/payload/admission-templates/c2-off.json create mode 100644 scripts/openclaw-p6/app/packet/payload/admission-templates/js.json create mode 100644 scripts/openclaw-p6/app/packet/payload/admission-templates/ts.json create mode 100644 scripts/openclaw-p6/app/packet/payload/adopt-compilers.py create mode 100644 scripts/openclaw-p6/app/packet/payload/build-prep/artifact-contract.mjs create mode 100644 scripts/openclaw-p6/app/packet/payload/build-prep/build-linux.py create mode 100644 scripts/openclaw-p6/app/packet/payload/build-prep/select-plugins.mjs create mode 100644 scripts/openclaw-p6/app/packet/payload/cron-fixture/cron-cli-fixture.sh create mode 100644 scripts/openclaw-p6/app/packet/payload/cron-fixture/inputs.json create mode 100644 scripts/openclaw-p6/app/packet/payload/cron-fixture/run-native.sh create mode 100755 scripts/openclaw-p6/app/packet/payload/guest/application/guest-cli.py create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/application/memory-policy.py create mode 100755 scripts/openclaw-p6/app/packet/payload/guest/application/run-application-guest.py create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/application/security/file-exec.c create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/application/security/fixture/index.js create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/application/security/fixture/openclaw.plugin.json create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/application/security/fixture/package.json create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/application/security/mdwe.c create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/application/trace-policy.py create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/collect-evidence.py create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/guest-prerequisites.py create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/manifest.json create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/prepare-guest.py create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/shared/guest_result_transport.py create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/shared/kvm-preflight.py create mode 100644 scripts/openclaw-p6/app/packet/payload/guest/shared/run-kvm-guest.py create mode 100644 scripts/openclaw-p6/app/packet/payload/manifest.json create mode 100644 scripts/openclaw-p6/app/packet/payload/measure-command.py create mode 100644 scripts/openclaw-p6/app/packet/payload/native-prep.py create mode 100644 scripts/openclaw-p6/app/packet/payload/preserve.py create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/README.md create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/docker-image.py create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/harness/Dockerfile.aot create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/harness/analyze-workers.py create mode 100755 scripts/openclaw-p6/app/packet/payload/qualification/harness/analyze-zero-js.py create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/harness/aot-entry.mjs create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/harness/capability-runner.mjs create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/harness/config-roundtrip.mjs create mode 100755 scripts/openclaw-p6/app/packet/payload/qualification/harness/core-runner.mjs create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/harness/elf-floor.py create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/harness/fixture-config.mjs create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/harness/gateway-readiness.mjs create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/harness/kitchen-sink-pin.json create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/harness/legacy/capability-provider.mjs create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/harness/legacy/native_trace.py create mode 100755 scripts/openclaw-p6/app/packet/payload/qualification/harness/openclaw-launcher create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/manifest.json create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/qualify.py create mode 100644 scripts/openclaw-p6/app/packet/payload/qualification/source-contract.json create mode 100644 scripts/openclaw-p6/app/packet/payload/runtime-controller.py create mode 100644 scripts/openclaw-p6/app/packet/payload/stage.py create mode 100644 scripts/openclaw-p6/app/paging-host.py create mode 100644 scripts/openclaw-p6/app/paging/operation.py create mode 100644 scripts/openclaw-p6/app/paging/swap64.py create mode 100644 scripts/openclaw-p6/app/paging/test_paging.py create mode 100644 scripts/openclaw-p6/app/paging/verify-active.py create mode 100644 scripts/openclaw-p6/app/prepare.sh create mode 100644 scripts/openclaw-p6/app/test-candidate.py create mode 100644 scripts/openclaw-p6/app/test-runtime-terminal.py create mode 100644 scripts/openclaw-p6/app/variant.sh create mode 100644 scripts/openclaw-p6/app/verify-compiler.py create mode 100644 scripts/openclaw-p6/app/verify-download.py diff --git a/.github/workflows/openclaw-build-test.yml b/.github/workflows/openclaw-build-test.yml index 1ccc49517c94..23e7d7c9a5af 100644 --- a/.github/workflows/openclaw-build-test.yml +++ b/.github/workflows/openclaw-build-test.yml @@ -2,6 +2,14 @@ name: P6 native Linux x64 AOT compilers on: workflow_dispatch: + inputs: + mode: + description: P6 compiler build or bounded application qualification + type: choice + default: compiler + options: + - compiler + - app permissions: contents: read @@ -12,7 +20,7 @@ concurrency: jobs: linux-x64: - if: github.repository == 'openclaw/bun' && github.ref == 'refs/heads/openclaw/aot-rd-P6' + if: github.repository == 'openclaw/bun' && github.ref == 'refs/heads/openclaw/aot-rd-P6' && (inputs.mode == 'compiler' || inputs.mode == '') runs-on: blacksmith-32vcpu-ubuntu-2404 timeout-minutes: 240 defaults: @@ -96,3 +104,73 @@ jobs: if-no-files-found: warn compression-level: 0 retention-days: 7 + linux-x64-app: + if: github.repository == 'openclaw/bun' && github.ref == 'refs/heads/openclaw/aot-rd-P6' && inputs.mode == 'app' + runs-on: blacksmith-32vcpu-ubuntu-2404 + timeout-minutes: 240 + permissions: + contents: read + actions: read + defaults: + run: + shell: bash + steps: + - name: Establish bounded application work deadline + run: | + { + echo "P6_DEADLINE_EPOCH=$(( $(date +%s) + 13800 ))" + echo "P6_WORK=$RUNNER_TEMP/p6-app-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" + echo "P6_CONTAINER=p6-app-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" + } >> "$GITHUB_ENV" + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + sparse-checkout: scripts/openclaw-p6 + - name: Initialize isolated native x64 application container + run: bash scripts/openclaw-p6/app/host.sh bootstrap + - name: Import the exact verified compiler pair + env: + GH_TOKEN: ${{ github.token }} + run: python3 -B scripts/openclaw-p6/app/download.py + - name: Prepare fresh frozen source, dependencies, dist and plugins + id: prepare + run: bash scripts/openclaw-p6/app/host.sh prepare + - name: Activate execution-bound encrypted task paging + id: paging + run: bash scripts/openclaw-p6/app/host.sh paging + - name: Build and qualify JS AOT + id: js + continue-on-error: true + run: bash scripts/openclaw-p6/app/host.sh variant js + - name: Build and qualify physical ShadowRealm-off C2 AOT + if: steps.prepare.outcome == 'success' && steps.paging.outcome == 'success' && !cancelled() + id: c2 + continue-on-error: true + run: bash scripts/openclaw-p6/app/host.sh variant c2-off + - name: Build and qualify TypeScript source AOT + if: steps.prepare.outcome == 'success' && steps.paging.outcome == 'success' && !cancelled() + id: ts + continue-on-error: true + run: bash scripts/openclaw-p6/app/host.sh variant ts + - name: Attempt actual application guest MDWE on the available native KVM device + if: steps.prepare.outcome == 'success' && steps.paging.outcome == 'success' && !cancelled() + continue-on-error: true + run: bash scripts/openclaw-p6/app/host.sh guest + - name: Stop owned workloads and remove encrypted task paging + if: always() + run: bash scripts/openclaw-p6/app/host.sh cleanup + - name: Select explicit application artifacts and synthetic receipts + if: always() + run: sudo -n env -i PATH=/usr/bin:/bin P6_WORK="$P6_WORK" python3 -B scripts/openclaw-p6/app/export.py + - name: Export bounded application attempt + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: p6-linux-x64-app-${{ github.sha }}-attempt${{ github.run_attempt }} + path: ${{ env.P6_WORK }}/export/ + if-no-files-found: error + compression-level: 0 + retention-days: 7 + - name: Require completed requested variants + if: always() + run: python3 -B scripts/openclaw-p6/app/export.py --require-complete diff --git a/scripts/openclaw-p6/app/README.md b/scripts/openclaw-p6/app/README.md new file mode 100644 index 000000000000..6e524b96e4f6 --- /dev/null +++ b/scripts/openclaw-p6/app/README.md @@ -0,0 +1,83 @@ +# P6 native x64 application attempt + +This is a bounded qualification attempt for OpenClaw +`670a7ab33bbd2e3ed4f0a5681e138159d74540a1` using the compiler pair from Actions +run `40214829538`, attempt 1, wrapper head +`f9fa08790bf45b3e995280f6eb249e14fd9191c1`. It never builds the compiler itself. +Both compiler artifacts must have reviewed IDs, ZIP digests, compiler digests, +transport digests and archive digests in `compiler-pins.json` before dispatch. + +The existing registered workflow defaults to compiler mode. Its app mode has +the same P6 branch guard, its own job and no dependency on the skipped compiler +job. The app job's 230-minute deadline leaves 20 minutes for workload shutdown, +paging evacuation and upload before the 240-minute job limit. Native preparation +and each JS, physical ShadowRealm-off C2 and TypeScript attempt use the existing +owners. Every build gets a fresh live paging verification. Variant timeouts and +failures stop the container before cleanup; a later variant restarts only the +same identity-labelled container after its E2E resources are gone. All +phase ceilings do not fit in the job budget. Missing/failed/skipped proof remains +unqualified and the final job check fails unless all requested phases passed. +Build and preservation are prerequisites. Runtime phase failures are collected +while later independent phases continue; owning-controller cancellation, +deadline and signal exits stop the variant. A bounded, reaped guest-test timeout +remains an ordinary failed case. Docker dependents retain their existing image-receipt guards. +Any failed phase makes the variant return nonzero. + +The container gets only the task trees, a read-only recipe, public execution +identity, the Docker client/Buildx plugin and the dedicated runner's Docker socket. The GitHub +token is used only by the host downloader and is removed on artifact redirects. +The original Docker E2E lanes create the application containers; a thin client +adapter labels created containers/networks with the actual Actions run/attempt. +Cleanup stops the app container, removes only that label's resources and verifies +their absence before paging cleanup. It never prunes the Docker host. + +`packet/payload` is a P6-derived public input projection, not a byte-identical P0 +index clone. Its selected CB6 record retains the exact source, signed status, +qualified status, executable hash and compiler facts of the private frozen +reference. That reference is historical provenance only. It supplies no Linux +application or performance qualification. The original capsule and P0 index are +unchanged; their hashes are provenance in `packet/input-projection.json`. +Unrelated CB4/CB5 history, local paths and private operational notes are excluded. +All executable owners except `runtime-controller.py` are unchanged from the +accepted capsule. That controller now preserves terminal exit classifications +after evidence collection and uses a shorter generated guest label so C2's QMP +socket path fits Linux's 107-byte limit. The original capsule is unchanged. +The source proof +retains the exact R2 tree, all 26 required ancestors and dependency/source file +hashes; native clone, frozen install, runtime build, boundary generation and plugin +selection still run afresh. + +`export.py` is the sole upload selection owner. It copies only explicitly named +build results, synthetic runtime archives and the preservation owner's app +archives. It does not export paging backing, private paging state, approval +directories, credentials, kernel keys, source trees or dependency caches. +The summary always leaves `applicationQualified` and `shipReady` false. This job +does not provide the post-run raw-trace Worker/strict zero-disk-JS assessment, +live provider evidence, or same-machine +Node/JIT versus AOT Gateway-ready/first-turn/RSS/CPU comparison backed by a fresh +npm installation. Old N1 measurements are not current evidence. The scheduled +native zero-JS and Worker diagnostic phases preserve their raw evidence for that +assessment; a zero exit from this workflow means only its named phases completed. + +After heavy builds, the available host `/dev/kvm` is passed to the app container. +With at least 1900 seconds left before the reserve, the unchanged prerequisite +owner installs the pinned guest tools/image, then the unchanged actual-app guest +owner tests each built JS/C2 artifact while at least 950 seconds remain. Missing +KVM, prerequisites, artifact/version receipts, failures and insufficient budget +are recorded as explicit gaps. This uses native KVM only; it adds no emulated +timings. The guest phase covers the actual app's main-thread MDWE boundary, not +Gateway or Worker guest behavior. + +The comparison follow-on consumes the exact completed app run/attempt and +artifact digest, plus the compiler pair above. The exported admissions, +build/core/controller receipts, plugin selection and projected reference facts +retain their native relative paths. On one fresh native x64 runner, recreate +the exact R2 source and canonical runtime with the existing preparation owner; +package with `scripts/package-openclaw-for-docker.mts`; install into a new prefix +using the source's exact lifecycle policy; then run the existing comparison +owner with one warmup and six alternating measured sweeps. No build-host sample +is reused. The separately prepared comparator capsule is +`46057637d4872e3660aa7ca7a2e8b5610e84da8f8ff4065fab82bb933c5c5420`; +its dedicated dispatch adapter requires separate review before execution. + +R2 uses the root freeze at `2026-10-25T18:15:36.057232+00:00`, including PR183756, acpx 0.21.0 and Knowledge with two workers. Fresh frozen installation, canonical build, boundary artifacts and plugin selection are required. Prior plugin counts, worker counts and dependency caches are not qualification evidence. diff --git a/scripts/openclaw-p6/app/admit.py b/scripts/openclaw-p6/app/admit.py new file mode 100644 index 000000000000..c19e0515b7af --- /dev/null +++ b/scripts/openclaw-p6/app/admit.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +"""Bind one prepared template to the facts produced by this native CI run.""" +import hashlib +import json +import os +from pathlib import Path +import sys +import time + +ROOT = Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1') + + +def read(path): + return json.loads(path.read_text()) + + +def sha(path): + with path.open('rb') as stream: + return hashlib.file_digest(stream, 'sha256').hexdigest() + + +def main(): + variant = sys.argv[1] + assert variant in ['js', 'c2-off', 'ts'] + template = read(ROOT / 'admission-templates' / (variant + '.json')) + records = read(ROOT / 'admission-inputs/compiler-records.json') + assert records['status'] == 'native-compilers-adopted-not-app-admitted' + prepared = read(ROOT / 'prep-receipts/plugins/result.json') + assert prepared['status'] == 'PASS' + execution = read(Path(os.environ['P6_WORK']) / 'execution.json') + assert execution['identity']['repository'] == 'openclaw/bun' and execution['identity']['job'] == 'linux-x64-app' + assert execution['sourceCommit'] == template['linuxCut']['commit'] + remaining = int(float(os.environ['P6_DEADLINE_EPOCH']) - time.time() - 1200) + assert remaining >= 120, 'No bounded build window remains' + template['decision'] = 'build-linux' + template['execution'] = execution + template['referenceRole'] = 'historical-provenance-only; no current-platform qualification transfer' + template['linuxCut']['mainRefSha'] = prepared['nativeSource']['mainRefSha'] + template['distBuildInfoSha256'] = prepared['distBuildInfoSha256'] + template['compiler']['sha256'] = records[template['compiler']['profile']]['sha256'] + template['buildNode'] = {key: prepared['buildNode'][key] for key in ['path', 'sha256']} + template['pluginsSha256'] = sha(Path(template['pluginsFile'])) + template['timeoutSeconds'] = min(7200, remaining) + directory = ROOT / 'admissions' + directory.mkdir(exist_ok=True) + path = directory / (variant + '.json') + with path.open('x') as stream: + json.dump(template, stream, indent=2) + stream.write('\n') + print(sha(path)) + + +if __name__ == '__main__': + main() diff --git a/scripts/openclaw-p6/app/compiler-pins.json b/scripts/openclaw-p6/app/compiler-pins.json new file mode 100644 index 000000000000..baab517521ce --- /dev/null +++ b/scripts/openclaw-p6/app/compiler-pins.json @@ -0,0 +1,27 @@ +{ + "schemaVersion": 1, + "repository": "openclaw/bun", + "runId": 40214829538, + "runAttempt": 1, + "headSha": "f9fa08790bf45b3e995280f6eb249e14fd9191c1", + "artifacts": { + "cb-standard": { + "id": 12608037481, + "name": "p6-linux-x64-standard-f9fa08790bf45b3e995280f6eb249e14fd9191c1-attempt1", + "zipSha256": "659eb35a30ec4b5446e2ef6ea6f182249f2949398d429c72ce2bb2d7f8bf492e", + "compilerSha256": "bc32f99d8c9ebda0de7d3cf0a216052d84afa70b85f011485ed49bae3d3f6d90", + "transportSha256": "2fba572c329a9c7dfdee1d7d0fd4f53492e1dbc508e9e405e4fb767fdfdb6149", + "archiveSha256": "36660357e450c1c6f8762492332828bbbe53ae2048999ff75b8681cda0140dae", + "zipBytes": 131892490 + }, + "cb-compat": { + "id": 12609305181, + "name": "p6-linux-x64-shadowrealm-off-f9fa08790bf45b3e995280f6eb249e14fd9191c1-attempt1", + "zipSha256": "8dca5ea6ba7e73d8b6833be1196e17e6e54ff7b5e3c16686440225579d10f64b", + "compilerSha256": "12abf71cff8b57f633dfc348c1071772b8fa5fb842fd692b69e57d01844889ce", + "transportSha256": "ebc2e022129ea1b2b4629d6829a33d6b1fb0144dca5c3eab25a9d69ead96d0b1", + "archiveSha256": "2a2407b9d1885743f451ba8cf7a8d59f2885a6b3936d98769a12307ab4c91919", + "zipBytes": 131851510 + } + } +} diff --git a/scripts/openclaw-p6/app/docker-client.py b/scripts/openclaw-p6/app/docker-client.py new file mode 100755 index 000000000000..9fa9d76b9ff5 --- /dev/null +++ b/scripts/openclaw-p6/app/docker-client.py @@ -0,0 +1,15 @@ +#!/usr/bin/python3 +"""Label resources created by the unchanged E2E owners for exact task cleanup.""" +import json +import os +from pathlib import Path +import sys + +identity = json.loads(Path('/p6-execution.json').read_text())['identity'] +label = 'openclaw.p6.actions=' + identity['runId'] + '-' + identity['runAttempt'] +args = sys.argv[1:] +if args[:1] in [['run'], ['create']]: + args[1:1] = ['--label', label] +elif args[:2] == ['network', 'create']: + args[2:2] = ['--label', label] +os.execv('/p6-host-docker', ['/p6-host-docker', *args]) diff --git a/scripts/openclaw-p6/app/download.py b/scripts/openclaw-p6/app/download.py new file mode 100644 index 000000000000..9beb2f208349 --- /dev/null +++ b/scripts/openclaw-p6/app/download.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python3 +"""Download the reviewed compiler pair; credentials never enter the app container.""" +import hashlib +import json +import os +from pathlib import Path +import shutil +import subprocess +import sys +import urllib.request + +HERE = Path(__file__).resolve().parent + + +class DownloadRedirect(urllib.request.HTTPRedirectHandler): + def redirect_request(self, request, fp, code, message, headers, newurl): + redirected = super().redirect_request(request, fp, code, message, headers, newurl) + if redirected is not None: + redirected.remove_header('Authorization') + return redirected + + +def fetch(path, target=None, expected_bytes=None): + request = urllib.request.Request('https://api.github.com/repos/openclaw/bun/' + path, + headers={'Authorization': 'Bearer ' + os.environ['GH_TOKEN'], + 'Accept': 'application/vnd.github+json', 'X-GitHub-Api-Version': '2022-11-28'}) + with urllib.request.build_opener(DownloadRedirect).open(request, timeout=60) as response: + if target is None: + return json.load(response) + with target.open('xb') as stream: + count = 0 + while block := response.read(1024 * 1024): + count += len(block) + assert count <= expected_bytes, 'Artifact exceeds pinned ZIP size' + stream.write(block) + assert count == expected_bytes, 'Artifact ZIP size differs' + + +def main(): + pins = json.loads((HERE / 'compiler-pins.json').read_text()) + assert all(pins['artifacts'].values()), 'Both reviewed compiler artifact identities required' + work = Path(os.environ['P6_WORK']) + destination = work / 'downloads' + destination.mkdir(parents=True, exist_ok=False) + run = fetch(f"actions/runs/{pins['runId']}/attempts/{pins['runAttempt']}") + assert run['id'] == pins['runId'] and run['head_sha'] == pins['headSha'] + assert run['run_attempt'] == pins['runAttempt'] and run['status'] == 'completed' + assert run['conclusion'] == 'success', 'Incomplete/failed compiler run is not app input' + (destination / 'run.json').write_text(json.dumps(run, indent=2) + '\n') + root = Path('/home/runner/.cache/oc-ty-ext/P6/rd150c-x64-v1') + assert not root.exists(), 'Fresh compiler import root required' + root.mkdir(parents=True) + for profile, expected in pins['artifacts'].items(): + metadata = fetch(f"actions/artifacts/{expected['id']}") + assert metadata['id'] == expected['id'] and metadata['name'] == expected['name'] + assert metadata['digest'] == 'sha256:' + expected['zipSha256'] + assert metadata['size_in_bytes'] == expected['zipBytes'] + metadata_file = destination / (profile + '.json') + metadata_file.write_text(json.dumps(metadata, indent=2) + '\n') + archive = destination / (profile + '.zip') + fetch(f"actions/artifacts/{expected['id']}/zip", archive, expected['zipBytes']) + verified = destination / ('verified-' + profile) + subprocess.run([sys.executable, str(HERE / 'verify-download.py'), '--metadata', + str(metadata_file), '--zip', str(archive), '--profile', profile, + '--out', str(verified)], check=True) + receipt = json.loads((verified / 'adoption-verification.json').read_text()) + assert receipt['compilerSha256'] == expected['compilerSha256'] + assert receipt['transportSha256'] == expected['transportSha256'] + transport = json.loads((verified / 'github-artifact/transport.json').read_text()) + assert transport['archiveSha256'] == expected['archiveSha256'] + directory = 'build-standard' if profile == 'cb-standard' else 'build-c2' + shutil.copytree(verified / 'compiler' / directory, root / directory) + (root / 'receipts').mkdir(exist_ok=True) + for source in (verified / 'compiler/receipts').iterdir(): + assert not (root / 'receipts' / source.name).exists() + shutil.copy2(source, root / 'receipts' / source.name) + preserved = root / ('preserved-' + profile) + preserved.mkdir() + shutil.copy2(verified / 'github-artifact/transport.json', preserved / 'transport.json') + print('P6_COMPILER_PAIR_VERIFIED', flush=True) + + +if __name__ == '__main__': + main() diff --git a/scripts/openclaw-p6/app/export.py b/scripts/openclaw-p6/app/export.py new file mode 100644 index 000000000000..997186aed523 --- /dev/null +++ b/scripts/openclaw-p6/app/export.py @@ -0,0 +1,129 @@ +#!/usr/bin/env python3 +"""Export only named synthetic results and preserved app archives, never paging state.""" +import hashlib +import json +import os +from pathlib import Path +import shutil +import stat +import sys + +ROOT = Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1') +VARIANTS = ['js', 'c2-off', 'ts'] +PHASES = ['core', 'elf-floor', 'zero-js', 'node-vm', 'node-vm-native-workers', 'pty', + 'plugin', 'docker-image', 'docker-gateway-network', 'docker-kitchen-sink', 'docker-cron'] + + +def load(path): + return json.loads(path.read_text()) + + +def facts(path): + if not path.is_file(): + return {'status': 'not-run'} + try: + return load(path) + except (OSError, ValueError): + return {'status': 'invalid-receipt'} + + +def selections(work, root): + for name in ['execution.json', 'resources.json', 'paging-activate.json', 'paging-cleanup.json', + 'guest-gaps.json', 'guest-skipped.json', 'terminal.json']: + yield work / name, Path('host') / name + for variant in VARIANTS: + yield root / 'admissions' / (variant + '.json'), Path('admissions') / (variant + '.json') + for name in [variant + '-skipped.json', variant + '-paging-live.json']: + yield work / name, Path('host') / name + for phase in ['preflight', 'build', 'preserve', *PHASES, 'guest-prerequisites', 'guest-security']: + name = f'{variant}-{phase}-deadline.json' + yield work / name, Path('host') / name + for name in ['plan.json', 'result.json', 'artifact-contract.stdout', 'artifact-contract.stderr', + 'measurement/receipt.json', 'measurement/stdout.txt', 'measurement/stderr.txt', + 'measurement/time.txt']: + yield root / 'build-receipts' / variant / name, Path('build-receipts') / variant / name + for phase in [*PHASES, 'guest-prerequisites', 'guest-security']: + for name in ['result.json', 'raw-index.json', 'raw-evidence.tar.gz']: + yield root / 'runtime-results' / (variant + '-' + phase) / name, Path('runtime-results') / (variant + '-' + phase) / name + yield root / 'qualification-results' / (variant + '-core') / 'run/result.json', Path('qualification-results') / (variant + '-core') / 'run/result.json' + for name in ['artifact.tar', 'transport.json']: + yield root / 'preserved' / variant / name, Path('preserved') / variant / name + labels = {'clone': ['clone', 'fetch-cut', 'checkout'], 'toolchain': [], + 'install': ['frozen-install'], 'runtime': ['pnpm-build'], + 'boundary': ['ts-boundary'], 'plugins': ['select-plugins']} + for phase, commands in labels.items(): + yield root / 'prep-receipts' / phase / 'result.json', Path('prep-receipts') / phase / 'result.json' + yield work / (phase + '-deadline.json'), Path('host') / (phase + '-deadline.json') + for command in commands: + for name in ['receipt.json', 'stdout.txt', 'stderr.txt', 'time.txt']: + relative = Path(phase) / command / name + yield root / 'prep-receipts' / relative, Path('prep-receipts') / relative + for name in ['compiler-records.json', 'plugins/desktop.json', 'plugins/plugin-selection.json', + 'source-preparation.json', 'p0-reference.json', 'P0-artifacts.json']: + yield root / 'admission-inputs' / name, Path('admission-inputs') / name + + +def summary(work, root): + result = {'sourceCommit': '670a7ab33bbd2e3ed4f0a5681e138159d74540a1', + 'referenceRole': 'historical CB6 provenance only', 'variants': {}, + 'scheduledPhasesComplete': True, 'applicationQualified': False, 'shipReady': False, + 'unrunRequiredProof': ['same-machine Node/JIT npm baseline and balanced six-sweep ready/first-turn/RSS/CPU comparison', + 'full raw-trace strict zero-disk-JS and Worker boundary assessment', + 'live provider streamed-turn proof']} + for variant in VARIANTS: + build = root / 'build-receipts' / variant / 'result.json' + skipped = work / (variant + '-skipped.json') + row = {'build': facts(build).get('status', 'invalid-receipt'), 'runtime': {}} + if skipped.is_file(): + row['skip'] = facts(skipped) + for phase in PHASES: + path = root / 'runtime-results' / (variant + '-' + phase) / 'result.json' + row['runtime'][phase] = facts(path).get('status', 'invalid-receipt') + row['complete'] = row['build'] == 'built-unsigned' and all(value == 'phase-passed' for value in row['runtime'].values()) + result['scheduledPhasesComplete'] = result['scheduledPhasesComplete'] and row['complete'] + result['variants'][variant] = row + result['guestSecurity'] = {variant: facts(root / 'runtime-results' / (variant + '-guest-security') / 'result.json').get('status', 'invalid-receipt') for variant in ['js', 'c2-off']} + result['guestGaps'] = facts(work / 'guest-gaps.json') + if any(value != 'phase-passed' for value in result['guestSecurity'].values()): + result['unrunRequiredProof'].append('actual application PR_SET_MDWE on Linux >=6.7 guest for JS and C2') + cleanup = work / 'paging-cleanup.json' + result['pagingCleanup'] = facts(cleanup) + clean = result['pagingCleanup'] + cleanup_ok = clean.get('status') == 'not-activated' or ( + clean.get('operationExitCode') == 0 and clean.get('metadata', {}).get('phase') == 'cleaned') + result['scheduledPhasesComplete'] = result['scheduledPhasesComplete'] and cleanup_ok + return result + + +def main(): + os.umask(0o022) + work = Path(os.environ['P6_WORK']) + if sys.argv[1:] == ['--require-complete']: + result = load(work / 'export/summary.json') + print(json.dumps(result, indent=2)) + return 0 if result['scheduledPhasesComplete'] else 1 + assert not sys.argv[1:] + out = work / 'export' + out.mkdir(exist_ok=False) + index = [] + for source, relative in selections(work, ROOT): + if not source.exists(): + continue + assert stat.S_ISREG(source.lstat().st_mode), f'Only regular selected files: {source}' + resolved = source.resolve(strict=True) + boundary = ROOT if source.is_relative_to(ROOT) else work + assert resolved.is_relative_to(boundary.resolve(strict=True)), 'Selected export escapes its task boundary' + assert not any(part in ['ephemeral-swap64', 'paging-tools'] for part in resolved.parts) + target = out / relative + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(source, target) + with target.open('rb') as stream: + digest = hashlib.file_digest(stream, 'sha256').hexdigest() + index.append({'path': str(relative), 'sha256': digest, 'bytes': target.stat().st_size}) + (out / 'index.json').write_text(json.dumps(index, indent=2) + '\n') + (out / 'summary.json').write_text(json.dumps(summary(work, ROOT), indent=2) + '\n') + return 0 + + +if __name__ == '__main__': + raise SystemExit(main()) diff --git a/scripts/openclaw-p6/app/guest.py b/scripts/openclaw-p6/app/guest.py new file mode 100644 index 000000000000..96709e4cac39 --- /dev/null +++ b/scripts/openclaw-p6/app/guest.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +"""Schedule the accepted actual-app KVM/MDWE owners if native capacity remains.""" +import hashlib +import json +import os +from pathlib import Path +import stat +import subprocess +import sys +import time + +ROOT = Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1') + + +def read(path): + return json.loads(path.read_text()) + + +def sha(path): + with path.open('rb') as stream: + return hashlib.file_digest(stream, 'sha256').hexdigest() + + +def main(): + work = Path(os.environ['P6_WORK']) + deadline = float(os.environ['P6_DEADLINE_EPOCH']) + gaps = [] + def gap(variant, reason): + gaps.append({'variant': variant, 'status': 'not-run', 'reason': reason}) + (work / 'guest-gaps.json').write_text(json.dumps(gaps, indent=2) + '\n') + device = Path('/dev/kvm') + if not device.exists() or not stat.S_ISCHR(device.stat().st_mode): + gap('all', 'Native /dev/kvm unavailable; no emulation fallback') + return 0 + ready = [] + for variant in ['js', 'c2-off']: + build = ROOT / 'build-receipts' / variant / 'result.json' + core = ROOT / 'qualification-results' / (variant + '-core') / 'run/result.json' + if not build.is_file() or read(build).get('status') != 'built-unsigned' or not core.is_file(): + gap(variant, 'Actual successful build and host core/version receipt required') + else: + ready.append(variant) + if not ready: + return 0 + def phase(variant, name): + admission = ROOT / 'admissions' / (variant + '.json') + command = [sys.executable, '/p6-recipe/deadline_process.py', '--deadline-epoch', str(deadline), + '--reserve-seconds', '1200', '--cleanup-grace-seconds', '30', '--receipt', + str(work / (variant + '-' + name + '-deadline.json')), '--', 'env', '-i', + 'HOME=/home/runner', 'PATH=/usr/bin:/bin:/usr/sbin:/sbin', 'PYTHONDONTWRITEBYTECODE=1', + 'TMPDIR=' + str(ROOT / 'tmp'), sys.executable, '-B', str(ROOT / 'runtime-controller.py'), + '--variant', variant, '--phase', name, '--admission-sha256', sha(admission)] + code = subprocess.run(command).returncode + return 128 - code if code < 0 else code + if deadline - time.time() - 1200 < 1900: + gap('all', 'Less than 1900s remain for bounded prerequisite + actual guest owners') + return 0 + code = phase(ready[0], 'guest-prerequisites') + if code == 124 or code >= 128: + return code + if code: + gap('all', 'Guest prerequisites failed; preserve actual owner receipt') + return 0 + for variant in ready: + if deadline - time.time() - 1200 < 950: + gap(variant, 'Less than 950s remain for actual guest owner') + continue + code = phase(variant, 'guest-security') + if code == 124 or code >= 128: + return code + if code: + gap(variant, 'Actual guest owner failed; preserve result and raw evidence') + return 0 + + +if __name__ == '__main__': + raise SystemExit(main()) diff --git a/scripts/openclaw-p6/app/guest.sh b/scripts/openclaw-p6/app/guest.sh new file mode 100644 index 000000000000..28cd51e3f616 --- /dev/null +++ b/scripts/openclaw-p6/app/guest.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -euo pipefail +cd "$P6_WORK" +python3 -B /p6-recipe/app/guest.py diff --git a/scripts/openclaw-p6/app/host.sh b/scripts/openclaw-p6/app/host.sh new file mode 100644 index 000000000000..511c25ed50c3 --- /dev/null +++ b/scripts/openclaw-p6/app/host.sh @@ -0,0 +1,137 @@ +#!/usr/bin/env bash +set -euo pipefail +phase=${1:?bootstrap, prepare, variant or cleanup} +: "${P6_WORK:?Missing task directory}" +: "${P6_CONTAINER:?Missing owned container}" +recipe=$(cd "$(dirname "$0")/.." && pwd -P) +base=/home/runner/.cache/oc-ty-ext/P6 +root=$base/app-x64-final-r2-v1 +label="openclaw.p6.actions=$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" +paging() { + sudo -n env -i PATH=/usr/sbin:/usr/bin:/sbin:/bin P6_WORK="$P6_WORK" \ + GITHUB_REPOSITORY="$GITHUB_REPOSITORY" GITHUB_RUN_ID="$GITHUB_RUN_ID" \ + GITHUB_RUN_ATTEMPT="$GITHUB_RUN_ATTEMPT" GITHUB_JOB="$GITHUB_JOB" GITHUB_SHA="$GITHUB_SHA" \ + python3 -B "$recipe/app/paging-host.py" "$@" +} +remove_children() { + local ids + ids=$(timeout --kill-after=5s 30s docker ps -aq --filter "label=$label") + if [[ -n "$ids" ]]; then + while IFS= read -r id; do timeout --kill-after=5s 30s docker rm -f "$id"; done <<< "$ids" + fi + ids=$(timeout --kill-after=5s 30s docker network ls -q --filter "label=$label") + if [[ -n "$ids" ]]; then + while IFS= read -r id; do timeout --kill-after=5s 30s docker network rm "$id"; done <<< "$ids" + fi + [[ -z "$(timeout --kill-after=5s 30s docker ps -aq --filter "label=$label")" ]] + [[ -z "$(timeout --kill-after=5s 30s docker network ls -q --filter "label=$label")" ]] +} +ensure_running() { + [[ $(timeout --kill-after=5s 30s docker inspect --format '{{index .Config.Labels "openclaw.p6.owner"}}' "$P6_CONTAINER") == "$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" ]] + if [[ $(timeout --kill-after=5s 30s docker inspect --format '{{.State.Running}}' "$P6_CONTAINER") != true ]]; then + remove_children + timeout --kill-after=10s 50s docker start "$P6_CONTAINER" >/dev/null + fi +} +if [[ "$phase" == cleanup ]]; then + timeout --kill-after=5s 30s docker stop --time 15 "$P6_CONTAINER" >/dev/null 2>&1 || true + timeout --kill-after=5s 30s docker rm -f "$P6_CONTAINER" >/dev/null 2>&1 || true + [[ -z "$(timeout --kill-after=5s 30s docker ps -aq --filter "name=^${P6_CONTAINER}$")" ]] + remove_children + paging cleanup + exit +fi +: "${P6_DEADLINE_EPOCH:?Missing absolute work deadline}" +remember_terminal() { + if (( $1 == 124 || $1 >= 128 )); then + python3 -B "$recipe/app/initialize.py" terminal "$1" || true + fi +} +stop_on_failure() { + code=$? + if (( code != 0 )); then + remember_terminal "$code" + timeout --kill-after=5s 30s docker stop --time 15 "$P6_CONTAINER" >/dev/null 2>&1 || true + remove_children || true + fi + return "$code" +} +trap stop_on_failure EXIT +if [[ "$phase" == bootstrap ]]; then + [[ $(uname -s) == Linux && $(uname -m) == x86_64 ]] + [[ ! -e "$root" ]] + mkdir -p "$P6_WORK" "$base" + python3 -B "$recipe/app/initialize.py" + timeout --kill-after=15s 300s sudo -n apt-get update + timeout --kill-after=15s 300s sudo -n apt-get install -y --no-install-recommends cryptsetup + image=ubuntu:24.04@sha256:a2d43bffc46670d7108bb3c0468c67c5557c4c92e83e1e34cbff1322ad1b94dc + timeout --kill-after=15s 300s docker pull "$image" + devices=() + if [[ -c /dev/kvm ]]; then devices=(--device /dev/kvm:/dev/kvm); fi + buildx=$(timeout --kill-after=5s 30s docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "buildx"}}{{.Path}}{{end}}{{end}}') + [[ -n "$buildx" && -f "$buildx" && -x "$buildx" ]] + timeout --kill-after=10s 50s docker run --detach --name "$P6_CONTAINER" --init \ + --platform linux/amd64 --ulimit core=0:0 --label "openclaw.p6.owner=$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" \ + "${devices[@]}" \ + --mount "type=bind,src=$recipe,dst=/p6-recipe,readonly" \ + --mount "type=bind,src=$base,dst=$base" \ + --mount "type=bind,src=$P6_WORK,dst=$P6_WORK" \ + --mount "type=bind,src=$P6_WORK/execution.json,dst=/p6-execution.json,readonly" \ + --mount "type=bind,src=$(command -v docker),dst=/p6-host-docker,readonly" \ + --mount "type=bind,src=$buildx,dst=/p6-host-buildx,readonly" \ + --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \ + "$image" sleep infinity >/dev/null + timeout --kill-after=5s 30s docker exec "$P6_CONTAINER" ln -s /p6-recipe/app/docker-client.py /usr/bin/docker + timeout --kill-after=5s 30s docker exec "$P6_CONTAINER" mkdir -p /usr/libexec/docker/cli-plugins + timeout --kill-after=5s 30s docker exec "$P6_CONTAINER" ln -s /p6-host-buildx /usr/libexec/docker/cli-plugins/docker-buildx + exit +fi +if [[ "$phase" == paging ]]; then + remaining=$((P6_DEADLINE_EPOCH - $(date +%s) - 1200)) + (( remaining > 120 )) || exit 124 + sudo -n python3 -B - "$root/prep-receipts/plugins/result.json" <<'PY' +import json,sys +from pathlib import Path +assert json.loads(Path(sys.argv[1]).read_text())['status']=='PASS', 'Actual completed native preparation required' +PY + paging activate + exit +fi +remaining=$((P6_DEADLINE_EPOCH - $(date +%s) - 1200)) +if (( remaining <= 120 )); then + python3 -B "$recipe/app/initialize.py" skip "${2:-$phase}" deadline + [[ "$phase" != prepare ]] || exit 124 + exit 0 +fi +if [[ ( "$phase" == variant || "$phase" == guest ) && -f "$P6_WORK/terminal.json" ]]; then + python3 -B "$recipe/app/initialize.py" skip "${2:-$phase}" previous-terminal-exit + exit 0 +fi +if [[ "$phase" == variant ]]; then + ensure_running + timeout --signal=TERM --kill-after=30s "${remaining}s" docker exec \ + -e HOME=/home/runner -e P6_WORK="$P6_WORK" -e P6_DEADLINE_EPOCH="$P6_DEADLINE_EPOCH" \ + -e PYTHONDONTWRITEBYTECODE=1 "$P6_CONTAINER" bash /p6-recipe/app/variant.sh "$2" prepare + paging verify "$2" + script=variant.sh +elif [[ "$phase" == prepare ]]; then + script=prepare.sh +elif [[ "$phase" == guest ]]; then + ensure_running + script=guest.sh +else + echo "Unknown app phase: $phase" >&2 + exit 2 +fi +remaining=$((P6_DEADLINE_EPOCH - $(date +%s) - 1200)) +(( remaining > 0 )) || exit 124 +code=0 +timeout --signal=TERM --kill-after=30s "${remaining}s" docker exec \ + -e HOME=/home/runner -e P6_WORK="$P6_WORK" -e P6_DEADLINE_EPOCH="$P6_DEADLINE_EPOCH" \ + -e PYTHONDONTWRITEBYTECODE=1 "$P6_CONTAINER" bash "/p6-recipe/app/$script" "${2:-}" run || code=$? +remember_terminal "$code" +if (( code != 0 )); then + timeout --kill-after=5s 30s docker stop --time 15 "$P6_CONTAINER" >/dev/null 2>&1 || true +fi +remove_children +exit "$code" diff --git a/scripts/openclaw-p6/app/initialize.py b/scripts/openclaw-p6/app/initialize.py new file mode 100644 index 000000000000..359f7dac0dd4 --- /dev/null +++ b/scripts/openclaw-p6/app/initialize.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +"""Record the actual Actions identity and bounded skip results.""" +import json +import os +from pathlib import Path +import platform +import re +import resource +import shutil +import sys +import time + +work = Path(os.environ['P6_WORK']) +resource.setrlimit(resource.RLIMIT_CORE, (0, 0)) +if len(sys.argv) > 1: + if sys.argv[1] == 'terminal': + code = int(sys.argv[2]) + assert code == 124 or code >= 128 + (work / 'terminal.json').write_text(json.dumps({'status': 'terminal', 'exitCode': code}) + '\n') + else: + assert sys.argv[1] == 'skip' and sys.argv[2] in ['prepare', 'js', 'c2-off', 'ts', 'guest'] + (work / (sys.argv[2] + '-skipped.json')).write_text(json.dumps({ + 'status': 'not-run', 'reason': sys.argv[3], 'applicationQualified': False}) + '\n') +else: + assert platform.system() == 'Linux' and platform.machine() == 'x86_64' + identity = {'repository': os.environ['GITHUB_REPOSITORY'], 'runId': os.environ['GITHUB_RUN_ID'], + 'runAttempt': os.environ['GITHUB_RUN_ATTEMPT'], 'job': os.environ['GITHUB_JOB']} + assert identity['repository'] == 'openclaw/bun' and identity['job'] == 'linux-x64-app' + assert all(re.fullmatch('[1-9][0-9]*', identity[key]) for key in ['runId', 'runAttempt']) + record = {'schemaVersion': 1, 'identity': identity, 'workflowHead': os.environ['GITHUB_SHA'], + 'sourceCommit': '670a7ab33bbd2e3ed4f0a5681e138159d74540a1', 'startedEpoch': time.time()} + with (work / 'execution.json').open('x') as stream: + json.dump(record, stream, indent=2) + stream.write('\n') + memory = int(next(row.split()[1] for row in Path('/proc/meminfo').read_text().splitlines() + if row.startswith('MemTotal:'))) * 1024 + facts = {'memTotalBytes': memory, 'cpus': len(os.sched_getaffinity(0)), + 'diskFreeBytes': shutil.disk_usage('/home/runner/.cache/oc-ty-ext/P6').free, + 'kernel': platform.release(), 'applicationFitQualified': False} + (work / 'resources.json').write_text(json.dumps(facts, indent=2) + '\n') + assert memory >= 30_000_000_000 and facts['cpus'] >= 2 + assert facts['diskFreeBytes'] >= 121 * 1024**3, '64GiB paging + 25GiB floor + 32GiB headroom required' diff --git a/scripts/openclaw-p6/app/packet/commands.json b/scripts/openclaw-p6/app/packet/commands.json new file mode 100644 index 000000000000..c9c09bbb617a --- /dev/null +++ b/scripts/openclaw-p6/app/packet/commands.json @@ -0,0 +1,55 @@ +{ + "adopt-compilers": "set -euo pipefail\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/adopt-compilers.py\"\n", + "clone": "set -euo pipefail\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/native-prep.py\" --root \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1\" --phase clone\n", + "toolchain": "set -euo pipefail\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/native-prep.py\" --root \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1\" --phase toolchain\n", + "install": "set -euo pipefail\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/native-prep.py\" --root \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1\" --phase install\n", + "runtime": "set -euo pipefail\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/native-prep.py\" --root \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1\" --phase runtime\n", + "boundary": "set -euo pipefail\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/native-prep.py\" --root \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1\" --phase boundary\n", + "plugins": "set -euo pipefail\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/native-prep.py\" --root \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1\" --phase plugins\n", + "js-preflight": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/build-prep/build-linux.py\" --root \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1\" --admission \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json\" --measure-command \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/measure-command.py\"\n", + "js-build": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/build-prep/build-linux.py\" --root \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1\" --admission \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json\" --measure-command \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/measure-command.py\" --run\n", + "js-preserve": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin python3 -B - \"$P6_ADMISSION_SHA256\" <<'P6_PRESERVE'\nfrom pathlib import Path\nimport hashlib,json,subprocess,sys\nroot=Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1');receipt=Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/build-receipts/js');admission=Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json')\nassert hashlib.sha256(admission.read_bytes()).hexdigest()==sys.argv[1]\nplan=receipt/'plan.json';result=receipt/'result.json';p=json.loads(plan.read_text())\nassert p['admissionSha256']==sys.argv[1]\ncommand=[sys.executable,'-B',str(root/'preserve.py'),'pack','--plan',str(plan),'--plan-sha256',hashlib.sha256(plan.read_bytes()).hexdigest(),'--result',str(result),'--result-sha256',hashlib.sha256(result.read_bytes()).hexdigest(),'--checker',str(root/'build-prep/artifact-contract.mjs'),'--out',str(root/'preserved'/'js')]\nsubprocess.run(command,check=True)\nP6_PRESERVE\n", + "js-core": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant js --phase core --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "js-elf-floor": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant js --phase elf-floor --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "js-zero-js": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant js --phase zero-js --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "js-node-vm": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant js --phase node-vm --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "js-node-vm-native-workers": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant js --phase node-vm-native-workers --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "js-pty": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant js --phase pty --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "js-plugin": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant js --phase plugin --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "js-docker-image": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant js --phase docker-image --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "js-docker-gateway-network": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant js --phase docker-gateway-network --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "js-docker-kitchen-sink": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant js --phase docker-kitchen-sink --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "js-docker-cron": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant js --phase docker-cron --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "js-guest-security": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant js --phase guest-security --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "c2-off-preflight": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/build-prep/build-linux.py\" --root \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1\" --admission \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json\" --measure-command \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/measure-command.py\"\n", + "c2-off-build": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/build-prep/build-linux.py\" --root \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1\" --admission \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json\" --measure-command \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/measure-command.py\" --run\n", + "c2-off-preserve": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin python3 -B - \"$P6_ADMISSION_SHA256\" <<'P6_PRESERVE'\nfrom pathlib import Path\nimport hashlib,json,subprocess,sys\nroot=Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1');receipt=Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/build-receipts/c2-off');admission=Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json')\nassert hashlib.sha256(admission.read_bytes()).hexdigest()==sys.argv[1]\nplan=receipt/'plan.json';result=receipt/'result.json';p=json.loads(plan.read_text())\nassert p['admissionSha256']==sys.argv[1]\ncommand=[sys.executable,'-B',str(root/'preserve.py'),'pack','--plan',str(plan),'--plan-sha256',hashlib.sha256(plan.read_bytes()).hexdigest(),'--result',str(result),'--result-sha256',hashlib.sha256(result.read_bytes()).hexdigest(),'--checker',str(root/'build-prep/artifact-contract.mjs'),'--out',str(root/'preserved'/'c2-off')]\nsubprocess.run(command,check=True)\nP6_PRESERVE\n", + "c2-off-core": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant c2-off --phase core --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "c2-off-elf-floor": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant c2-off --phase elf-floor --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "c2-off-zero-js": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant c2-off --phase zero-js --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "c2-off-node-vm": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant c2-off --phase node-vm --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "c2-off-node-vm-native-workers": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant c2-off --phase node-vm-native-workers --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "c2-off-pty": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant c2-off --phase pty --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "c2-off-plugin": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant c2-off --phase plugin --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "c2-off-docker-image": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant c2-off --phase docker-image --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "c2-off-docker-gateway-network": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant c2-off --phase docker-gateway-network --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "c2-off-docker-kitchen-sink": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant c2-off --phase docker-kitchen-sink --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "c2-off-docker-cron": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant c2-off --phase docker-cron --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "c2-off-guest-security": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/c2-off.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant c2-off --phase guest-security --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "ts-preflight": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/build-prep/build-linux.py\" --root \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1\" --admission \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json\" --measure-command \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/measure-command.py\"\n", + "ts-build": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/build-prep/build-linux.py\" --root \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1\" --admission \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json\" --measure-command \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/measure-command.py\" --run\n", + "ts-preserve": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin python3 -B - \"$P6_ADMISSION_SHA256\" <<'P6_PRESERVE'\nfrom pathlib import Path\nimport hashlib,json,subprocess,sys\nroot=Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1');receipt=Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/build-receipts/ts');admission=Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json')\nassert hashlib.sha256(admission.read_bytes()).hexdigest()==sys.argv[1]\nplan=receipt/'plan.json';result=receipt/'result.json';p=json.loads(plan.read_text())\nassert p['admissionSha256']==sys.argv[1]\ncommand=[sys.executable,'-B',str(root/'preserve.py'),'pack','--plan',str(plan),'--plan-sha256',hashlib.sha256(plan.read_bytes()).hexdigest(),'--result',str(result),'--result-sha256',hashlib.sha256(result.read_bytes()).hexdigest(),'--checker',str(root/'build-prep/artifact-contract.mjs'),'--out',str(root/'preserved'/'ts')]\nsubprocess.run(command,check=True)\nP6_PRESERVE\n", + "ts-core": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant ts --phase core --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "ts-elf-floor": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant ts --phase elf-floor --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "ts-zero-js": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant ts --phase zero-js --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "ts-node-vm": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant ts --phase node-vm --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "ts-node-vm-native-workers": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant ts --phase node-vm-native-workers --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "ts-pty": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant ts --phase pty --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "ts-plugin": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant ts --phase plugin --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "ts-docker-image": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant ts --phase docker-image --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "ts-docker-gateway-network": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant ts --phase docker-gateway-network --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "ts-docker-kitchen-sink": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant ts --phase docker-kitchen-sink --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "ts-docker-cron": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant ts --phase docker-cron --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "ts-guest-security": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/ts.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant ts --phase guest-security --admission-sha256 \"$P6_ADMISSION_SHA256\"\n", + "guest-prerequisites": "set -euo pipefail\n: \"${P6_ADMISSION_SHA256:?Set the SHA256 of this exact actual root admission}\"\npython3 -B - '/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admissions/js.json' \"$P6_ADMISSION_SHA256\" <<'P6_BIND'\nfrom pathlib import Path\nimport hashlib,sys\nassert hashlib.sha256(Path(sys.argv[1]).read_bytes()).hexdigest()==sys.argv[2]\nP6_BIND\nenv -i HOME=/home/runner PATH=/usr/bin:/bin TMPDIR=\"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/tmp\" PYTHONDONTWRITEBYTECODE=1 python3 -B \"/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/runtime-controller.py\" --variant js --phase guest-prerequisites --admission-sha256 \"$P6_ADMISSION_SHA256\"\n" +} diff --git a/scripts/openclaw-p6/app/packet/input-projection.json b/scripts/openclaw-p6/app/packet/input-projection.json new file mode 100644 index 000000000000..fa7dcb525092 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/input-projection.json @@ -0,0 +1,104 @@ +{ + "schemaVersion": 1, + "originalCapsuleSha256": "879c8909d02159882757675affbba14587c45b783bb480fd2fd73925c63372ec", + "projectionReason": "P6 public CB6 provenance projection with exact R2 source freeze and identity-only rebind. Previously reviewed runtime controller repairs remain; original879c is unchanged.", + "changedFiles": { + "admission-inputs/P0-artifacts.json": { + "originalSha256": "6ceb952c8c527152d3fb534e203985b493c7c94e3729f27b65d36a925c755ab2", + "projectedSha256": "220560f5474dbb93266d2fdcb23b93fecf46728778becdf54b5cda578f544e18" + }, + "admission-inputs/p0-reference.json": { + "originalSha256": "09b61d429272bd580e4ed064260d431e7a864743e4afefebbf18bd6d0eceab99", + "projectedSha256": "9c068ecfb5343e80c268892caa4e78644fe73b2fff9a069a619cd66fc9da6fc0" + }, + "admission-inputs/source-preparation.json": { + "originalSha256": "60fcbaa4d97242d8ed3f0b970f7a14e9be46356d1d1ee588e75bc73bbe01d0de", + "projectedSha256": "3a233e951847951410670bfb6cd859b8cf8aa3f946a863dd8835d3bd3cd08ca1" + }, + "admission-templates/c2-off.json": { + "originalSha256": "1f02cb47781a9e689fb7a3074945fca3a36bf05c064e5bac0047ebc2d49a57d2", + "projectedSha256": "5b382c423a42ba88d7121a46d92a445e35312ab867ebd3b024ec8de3d6cc5a06" + }, + "admission-templates/js.json": { + "originalSha256": "dcc439c33249b208d1f522f026fa21ecc8fa7aed7142c0f7991e3a9682c604f8", + "projectedSha256": "70e6c113167dc2d410b0e83ee79ce762bc0112cbe69370d90f9ea52eafb4f4ca" + }, + "admission-templates/ts.json": { + "originalSha256": "e73da6e668f071517b392cd56bf22cb32c0fbc2b2da61bfb9525357330752e93", + "projectedSha256": "fef0d8e5faf99fef129efb66d8d1d1a2d54bd6a6cf2ed888c77ed3f6801d5132" + }, + "adopt-compilers.py": { + "originalSha256": "e12f117f417d1bb108b5d4719f5e471ad75b2adba78a425e0dd9a2a0c697d2cf", + "projectedSha256": "8f4e0d8b7b118c2c125515a3724e1a27a82880f969d49d4c03bd2e3d139f6312" + }, + "cron-fixture/inputs.json": { + "originalSha256": "0971140eb17775d974eb509693c864a9e954d5e7a5fc0946bff7852e43785ff6", + "projectedSha256": "068059745aeca4ec0d3b39578f48e8b3ae6af87e8ff86743339fb613fa0ac983" + }, + "cron-fixture/run-native.sh": { + "originalSha256": "b07d4dac039fc0099a1697814b31cbf2ec32e56a2e2183aaef87be0a3b02ac46", + "projectedSha256": "1683c8b8710b2ecbd1c80108b2d43f833b4cc7318add99491f69b5ebe72560b0" + }, + "guest/manifest.json": { + "originalSha256": "4280c2f62a9168b812176bab9fb762432a5425fe29821a1720471d2ece242d12", + "projectedSha256": "0db9d11a46d8f746ce4600728cf48331b9f04230f3c87858046b829dee2f2d1a" + }, + "guest/prepare-guest.py": { + "originalSha256": "936bf471c1c6e06ac2bb1ec1efec0e8e0c4583853e8fcb0ff1a53fb42cfacd52", + "projectedSha256": "47922a51d8512cd3f88c2d88d66a69574f5f1dd08bcdf437e2e5c4da06abe1d1" + }, + "native-prep.py": { + "originalSha256": "8bfd331144ad876405e73f317e839b35cfc7647288f9fb2c34f95dab86f66e91", + "projectedSha256": "161d1732a7569dc695854574e24dfcf2981e6724f0e126ee81cbe6396eb483c8" + }, + "preserve.py": { + "originalSha256": "5851e29c0832b017f7e7a98b0f64e51b4951f451574f49a6d9632f0a57b08d34", + "projectedSha256": "c4bf1af86d21050f6d7f9c4b801017de18ac50ba35f8eda8179e00c88e2575ca" + }, + "qualification/README.md": { + "originalSha256": "cbf5adaed9ff418fa5d0092994cf05166efe215cf56a153c8dcff17d3f1e9fbb", + "projectedSha256": "9853f67d28ba0e9cff3b274dd7cab73ac7a6ccc55bd111431bae424106712640" + }, + "qualification/manifest.json": { + "originalSha256": "6a38454878806509950a1ea7fb9a15ffb2bb79b53f4ef586bee131474a3e9221", + "projectedSha256": "12aa097ba29107d3cefe1c5df3367816b0695a7fd3573078784b88ccb0f80a7c" + }, + "qualification/qualify.py": { + "originalSha256": "c32886e391f27eb8c66d333d07b15b4af4c8081c329bad2fe8dca28b2dd9c2d7", + "projectedSha256": "62cb7bc09d40be522aa14fcac1b3db1e448032d296909a589bf5ef8b95c47f13" + }, + "qualification/source-contract.json": { + "originalSha256": "e2056668fd189ba8505c75fbef695c535930600e08d6e8d7bb0df55f9cf13d2b", + "projectedSha256": "457efc17c28bbe8226ee512f55cea43c1ce8720ee48cfc2dba7ec221d97ef911" + }, + "runtime-controller.py": { + "originalSha256": "d0974f26f8432bc3fe5c59afb640105ce53dc0d268d8f85fe0598d363ff5d7d9", + "projectedSha256": "772fc60f2894c73ccc165b9b9c1e58c251abedea139d147628c31643a51d8940" + }, + "stage.py": { + "originalSha256": "d40bdf22aeae208f1165a0d74ee0b87eb7e93e9144a5092212211633b59124d3", + "projectedSha256": "1c95d9e5896bf9a0993c1819fae708d7dc4c9d355913b0dc0d87c6fec7773989" + } + }, + "manifestSha256": "b231556d4c03faf8131fd3577113c7393f230646f5434f51b8c98145f4a057dd", + "runtimeControllerRepair": { + "terminalClassification": "Actual SIGTERM fixture child exit -15 formerly normalized to 1; retain timeout, cancellation and signal classification after cleanup", + "guestQmpPath": "Generated C2 guest label shortened consistently for preparation and raw collection, reducing Linux QMP pathname from108 to98bytes" + }, + "sourceRebind": { + "fromSource": "247b73c9bdc34dd723533f50d56fc345ef624d9a", + "sourceCommit": "670a7ab33bbd2e3ed4f0a5681e138159d74540a1", + "sourceTree": "714180cb290e28dd167eaad5fd89f12733581a8b", + "frozenAt": "2026-10-25T18:15:36.057232+00:00", + "rootProofSha256": "9bfbb7fe39678fb0111afe504c762b14b6c6ccbc9d16ee7ef26f9bec3982a864", + "requiredAncestors": 26, + "nativeRoot": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1", + "compilerPairChanged": false, + "materialChanges": [ + "typed anonymous-package ownership repair PR183756", + "acpx0.21.0 lock/workspace refresh", + "Knowledge plugin with two workers and assets" + ], + "currentC2QmpPathBytes": 96 + } +} diff --git a/scripts/openclaw-p6/app/packet/payload/admission-inputs/P0-artifacts.json b/scripts/openclaw-p6/app/packet/payload/admission-inputs/P0-artifacts.json new file mode 100644 index 000000000000..f3e78bf6083c --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/admission-inputs/P0-artifacts.json @@ -0,0 +1,25 @@ +{ + "schemaVersion": 1, + "lane": "P0", + "referenceRole": "historical-provenance-only", + "artifacts": [ + { + "variant": "desktop-c2", + "mainSha": "83fb19513e8d3013a27db742a0610230070bc8df", + "sourceCommit": "83fb19513e8d3013a27db742a0610230070bc8df", + "sourceStatus": "main", + "platform": "darwin", + "arch": "arm64", + "sha256": "62c5ac39f9f1a35cae9eef038ac7c22091ef4b28ffb9effc70d8958f5d22f9f8", + "signed": true, + "compilerPins": { + "bun": "b838e73072227c2652a41c689299284f1965cdc6", + "webkit": "aaa690bfbf34c9d50775716ac2fc3c7d0573e0b8", + "shadowRealm": "retained", + "historicalC2Equivalent": false + }, + "qualified": true + } + ], + "projection": "P6-derived public projection of the selected CB6 record; not a byte-identical P0 index clone" +} diff --git a/scripts/openclaw-p6/app/packet/payload/admission-inputs/p0-reference.json b/scripts/openclaw-p6/app/packet/payload/admission-inputs/p0-reference.json new file mode 100644 index 000000000000..696a40e68c35 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/admission-inputs/p0-reference.json @@ -0,0 +1,9 @@ +{ + "referenceRole": "historical-provenance-only", + "sourceManifestSha256": "6ceb952c8c527152d3fb534e203985b493c7c94e3729f27b65d36a925c755ab2", + "projectedManifestSha256": "220560f5474dbb93266d2fdcb23b93fecf46728778becdf54b5cda578f544e18", + "executableSha256": "62c5ac39f9f1a35cae9eef038ac7c22091ef4b28ffb9effc70d8958f5d22f9f8", + "sourceCommit": "83fb19513e8d3013a27db742a0610230070bc8df", + "originalModified": false, + "executed": false +} diff --git a/scripts/openclaw-p6/app/packet/payload/admission-inputs/source-preparation.json b/scripts/openclaw-p6/app/packet/payload/admission-inputs/source-preparation.json new file mode 100644 index 000000000000..844b566f86d5 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/admission-inputs/source-preparation.json @@ -0,0 +1,60 @@ +{ + "sourceCommit": "670a7ab33bbd2e3ed4f0a5681e138159d74540a1", + "sourceTree": "714180cb290e28dd167eaad5fd89f12733581a8b", + "linuxCut": { + "status": "landed-main", + "commit": "670a7ab33bbd2e3ed4f0a5681e138159d74540a1", + "mainRef": "refs/remotes/origin/main", + "mainRefSha": "670a7ab33bbd2e3ed4f0a5681e138159d74540a1", + "frozenAt": "2026-10-25T18:15:36.057232+00:00", + "requiredAncestors": [ + "c36710ec04ba17c98a6d3ba59d68fcb124df8e49", + "a171cfb74891e3abce0fb8312e976323998b3654", + "4dfd92bbda37dd05db97d93d773b342245c632be", + "fe0be1ae7477634479885e788d1e0b058f84905f", + "2f3ab195038294f9b3ffb96f4f381752e580cdb4", + "d11b06c8e815cfb5dbb62e7663a89086c4b567c0", + "a355200eef8abe8504f1e83dadc5de4717d59d9c", + "2678ee8e0e04d4721a4fe74ffb0c3ad0c70e2c2d", + "25a70e7d1f0cdf4af26ea3fd54d4ba82801957f9", + "44dd89b76ce56ef532bb6868b5d39c0dbbed7714", + "1bb18fd0aa5163d348df3398a8c8acaf5efc9019", + "c887adba97b6ee6a9c7817564c69cad31f976ca1", + "2f95e977c77d74ba463cdfee9436da1004778fcc", + "bc22cdba591eac1698f7577db0c8966d950417e4", + "f7397050bdf9959d834e92eb3a8f6c243f9b61f9", + "60c3a7c35283dd6377baff1e6ab137d1e0e96c0d", + "3e579ec1ea51bce7b98cec4ea910a84f08e06c29", + "3963fb319b08ba71d26baf6f16f37d17c283b855", + "90d689c000053b46dd9ca4e24009a0e8a16fbb24", + "83fb19513e8d3013a27db742a0610230070bc8df", + "aff4d23ad1e471155921c75732417bd63984a753", + "e6a0dc9b0d20a4649807c920cb58d27fcc559743", + "ed818c4b396c1e8dd363b65d74c5f8f844b5310a", + "ded76f196cc2a64111ecf8fd24dcd306d9c445e5", + "247b73c9bdc34dd723533f50d56fc345ef624d9a", + "d465bda8766e9031f14bd266458e4bb09ac37ff2" + ], + "p0DifferenceRationale": "Latest landed main at root R2 freeze includes PR183756 typed anonymous-scope native ownership fix, PR183724 emitted-JS first-pass repair, PR183689 explicit TS source contracts, and all prior required repairs. Additional acpx0.21.0 and Knowledge plugin changes require fresh dependencies/build/selection. Immutable qualified P0 references remain distinct. Linux uses corrected Bun150c/WebKitaaa; no cross-cut or cross-compiler equivalence claimed." + }, + "files": { + "package.json": "afe1412c6470a96cb9ae33d4b79a4584f69c19de3afc9556958fb9cbf1fc2ad8", + "pnpm-lock.yaml": "6711dcbef4e6504260a6cd0ba5dfe09f91d49b1414bd64f48e2dab55759c2aba", + "pnpm-workspace.yaml": "331a1990bfba6a4bf33c982fbf3e47477a1f3a3d2bc8d3c83e919b9c9d1717f9", + "extensions/acpx/package.json": "5e1e7275d8b79dd5e02d2eaaa1176e00abbb79b03f681d944056f0124e10b0ec", + "scripts/build-all.mts": "797dd94f6c44263cb0106b583871b2680c27a5de81d586134e225e152ccb63d3", + "scripts/tsx.mjs": "e726c78d5a5a274215d9fe292ac91e4acf601c4554d68fbd57ff3b932573f9e6", + "scripts/prepare-extension-package-boundary-artifacts.mts": "a9f44a344a294bb8dc907053bb2267dff03d9301bc62e828fa1978aaa932a366", + "scripts/build-bun-standalone.mjs": "a32d46f7dd6e978834540ba1ca5d173afdd12d5df02acda7779c50b53119e0f0", + "scripts/lib/bun-standalone-bundle.mjs": "27d468a91b78819e68b2be08d1a4ec2b0c6ce985a45ac3e08d6f722d7af4afdc", + "scripts/lib/bun-standalone-contract.mjs": "7fadadc2f96e948cc2e18865e5df2bb6e5a334348ea913165485e9eaaf263b7c", + "scripts/lib/bun-standalone-source-parser.mjs": "ff6e6d31b0e6f32dcbd1bf0dbdcc3ca1ea8b032a88f0f210c373967560dfeb4e", + "scripts/lib/bun-standalone-plugins.mjs": "dc7a90471099b9ee73f5fdba02cd4c09ff92c8f5866120d6e3c526a18d9cc717", + "src/cli/security-cli.ts": "18a37df7b3eb2ccdb7bfb55b63aecd9f1cef739f8b5fac16b0f266bd12fe23e1", + "src/commands/backup-record.ts": "6b7b088fc997cd31fa0178c2bb1b67622ea9e5e9169190a65637b93ae5265810", + "src/config/sessions/session-transcript-worker-readers.ts": "c8baed3ee4957099240bfd7014beb6c57de724d9270e43e6ba3c2653dbe1430a", + "src/plugins/plugin-state-operation-source.ts": "61f39fc6b9c289d7cf96a03d87c1b20230f81ea65b0bf4e9287d72faff29319f", + "scripts/lib/bun-standalone-native.mjs": "f9a1f75d68afe4173ac134f770677fa3ade21f33f2cba7dcf30748a358d3db00", + "extensions/knowledge/package.json": "55e6d3f1a68f4596bf38cfd42409bdeecb5da38e2037f67c40ff76182065b767" + } +} diff --git a/scripts/openclaw-p6/app/packet/payload/admission-templates/c2-off.json b/scripts/openclaw-p6/app/packet/payload/admission-templates/c2-off.json new file mode 100644 index 000000000000..8d78beaad2a6 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/admission-templates/c2-off.json @@ -0,0 +1,76 @@ +{ + "schemaVersion": 1, + "lane": "P6", + "decision": "prepared-not-admitted", + "variant": "c2", + "source": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/source", + "output": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/artifacts/c2-off", + "receiptDirectory": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/build-receipts/c2-off", + "linuxCut": { + "status": "landed-main", + "commit": "670a7ab33bbd2e3ed4f0a5681e138159d74540a1", + "mainRef": "refs/remotes/origin/main", + "mainRefSha": "PENDING_ACTUAL_NATIVE_CLONE_MAIN_SHA", + "frozenAt": "2026-10-25T18:15:36.057232+00:00", + "requiredAncestors": [ + "c36710ec04ba17c98a6d3ba59d68fcb124df8e49", + "a171cfb74891e3abce0fb8312e976323998b3654", + "4dfd92bbda37dd05db97d93d773b342245c632be", + "fe0be1ae7477634479885e788d1e0b058f84905f", + "2f3ab195038294f9b3ffb96f4f381752e580cdb4", + "d11b06c8e815cfb5dbb62e7663a89086c4b567c0", + "a355200eef8abe8504f1e83dadc5de4717d59d9c", + "2678ee8e0e04d4721a4fe74ffb0c3ad0c70e2c2d", + "25a70e7d1f0cdf4af26ea3fd54d4ba82801957f9", + "44dd89b76ce56ef532bb6868b5d39c0dbbed7714", + "1bb18fd0aa5163d348df3398a8c8acaf5efc9019", + "c887adba97b6ee6a9c7817564c69cad31f976ca1", + "2f95e977c77d74ba463cdfee9436da1004778fcc", + "bc22cdba591eac1698f7577db0c8966d950417e4", + "f7397050bdf9959d834e92eb3a8f6c243f9b61f9", + "60c3a7c35283dd6377baff1e6ab137d1e0e96c0d", + "3e579ec1ea51bce7b98cec4ea910a84f08e06c29", + "3963fb319b08ba71d26baf6f16f37d17c283b855", + "90d689c000053b46dd9ca4e24009a0e8a16fbb24", + "83fb19513e8d3013a27db742a0610230070bc8df", + "aff4d23ad1e471155921c75732417bd63984a753", + "e6a0dc9b0d20a4649807c920cb58d27fcc559743", + "ed818c4b396c1e8dd363b65d74c5f8f844b5310a", + "ded76f196cc2a64111ecf8fd24dcd306d9c445e5", + "247b73c9bdc34dd723533f50d56fc345ef624d9a", + "d465bda8766e9031f14bd266458e4bb09ac37ff2" + ], + "p0DifferenceRationale": "Latest landed main at root R2 freeze includes PR183756 typed anonymous-scope native ownership fix, PR183724 emitted-JS first-pass repair, PR183689 explicit TS source contracts, and all prior required repairs. Additional acpx0.21.0 and Knowledge plugin changes require fresh dependencies/build/selection. Immutable qualified P0 references remain distinct. Linux uses corrected Bun150c/WebKitaaa; no cross-cut or cross-compiler equivalence claimed." + }, + "distBuildInfoSha256": "PENDING_ACTUAL_NATIVE_DIST_SHA256", + "p0Reference": { + "cohort": "cb-b838", + "manifest": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admission-inputs/P0-artifacts.json", + "manifestSha256": "220560f5474dbb93266d2fdcb23b93fecf46728778becdf54b5cda578f544e18", + "variant": "desktop-c2", + "sourceCommit": "83fb19513e8d3013a27db742a0610230070bc8df", + "executableSha256": "62c5ac39f9f1a35cae9eef038ac7c22091ef4b28ffb9effc70d8958f5d22f9f8" + }, + "compiler": { + "cohort": "rd-p6-150c", + "profile": "cb-compat", + "path": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/compilers/sr-off/bun", + "sha256": "PENDING_ACTUAL_PRESERVED_NATIVE_COMPILER_SHA256", + "bunCommit": "150c9620c53710060186b8b0cd50985e035408b0", + "webkitCommit": "aaa690bfbf34c9d50775716ac2fc3c7d0573e0b8", + "engineFeatures": { + "shadowRealm": false, + "hardened": false + } + }, + "buildNode": { + "path": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/opt/node/bin/node", + "sha256": "PENDING_ACTUAL_NATIVE_NODE_SHA256" + }, + "pluginsFile": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admission-inputs/plugins/desktop.json", + "pluginsSha256": "PENDING_ACTUAL_NATIVE_PLUGIN_SELECTION_SHA256", + "compileTrimAllow": [ + "run" + ], + "timeoutSeconds": "PENDING_ROOT_BOUNDED_TIMEOUT_SECONDS" +} diff --git a/scripts/openclaw-p6/app/packet/payload/admission-templates/js.json b/scripts/openclaw-p6/app/packet/payload/admission-templates/js.json new file mode 100644 index 000000000000..b0dfb4837282 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/admission-templates/js.json @@ -0,0 +1,76 @@ +{ + "schemaVersion": 1, + "lane": "P6", + "decision": "prepared-not-admitted", + "variant": "js", + "source": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/source", + "output": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/artifacts/js", + "receiptDirectory": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/build-receipts/js", + "linuxCut": { + "status": "landed-main", + "commit": "670a7ab33bbd2e3ed4f0a5681e138159d74540a1", + "mainRef": "refs/remotes/origin/main", + "mainRefSha": "PENDING_ACTUAL_NATIVE_CLONE_MAIN_SHA", + "frozenAt": "2026-10-25T18:15:36.057232+00:00", + "requiredAncestors": [ + "c36710ec04ba17c98a6d3ba59d68fcb124df8e49", + "a171cfb74891e3abce0fb8312e976323998b3654", + "4dfd92bbda37dd05db97d93d773b342245c632be", + "fe0be1ae7477634479885e788d1e0b058f84905f", + "2f3ab195038294f9b3ffb96f4f381752e580cdb4", + "d11b06c8e815cfb5dbb62e7663a89086c4b567c0", + "a355200eef8abe8504f1e83dadc5de4717d59d9c", + "2678ee8e0e04d4721a4fe74ffb0c3ad0c70e2c2d", + "25a70e7d1f0cdf4af26ea3fd54d4ba82801957f9", + "44dd89b76ce56ef532bb6868b5d39c0dbbed7714", + "1bb18fd0aa5163d348df3398a8c8acaf5efc9019", + "c887adba97b6ee6a9c7817564c69cad31f976ca1", + "2f95e977c77d74ba463cdfee9436da1004778fcc", + "bc22cdba591eac1698f7577db0c8966d950417e4", + "f7397050bdf9959d834e92eb3a8f6c243f9b61f9", + "60c3a7c35283dd6377baff1e6ab137d1e0e96c0d", + "3e579ec1ea51bce7b98cec4ea910a84f08e06c29", + "3963fb319b08ba71d26baf6f16f37d17c283b855", + "90d689c000053b46dd9ca4e24009a0e8a16fbb24", + "83fb19513e8d3013a27db742a0610230070bc8df", + "aff4d23ad1e471155921c75732417bd63984a753", + "e6a0dc9b0d20a4649807c920cb58d27fcc559743", + "ed818c4b396c1e8dd363b65d74c5f8f844b5310a", + "ded76f196cc2a64111ecf8fd24dcd306d9c445e5", + "247b73c9bdc34dd723533f50d56fc345ef624d9a", + "d465bda8766e9031f14bd266458e4bb09ac37ff2" + ], + "p0DifferenceRationale": "Latest landed main at root R2 freeze includes PR183756 typed anonymous-scope native ownership fix, PR183724 emitted-JS first-pass repair, PR183689 explicit TS source contracts, and all prior required repairs. Additional acpx0.21.0 and Knowledge plugin changes require fresh dependencies/build/selection. Immutable qualified P0 references remain distinct. Linux uses corrected Bun150c/WebKitaaa; no cross-cut or cross-compiler equivalence claimed." + }, + "distBuildInfoSha256": "PENDING_ACTUAL_NATIVE_DIST_SHA256", + "p0Reference": { + "cohort": "cb-b838", + "manifest": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admission-inputs/P0-artifacts.json", + "manifestSha256": "220560f5474dbb93266d2fdcb23b93fecf46728778becdf54b5cda578f544e18", + "variant": "desktop-c2", + "sourceCommit": "83fb19513e8d3013a27db742a0610230070bc8df", + "executableSha256": "62c5ac39f9f1a35cae9eef038ac7c22091ef4b28ffb9effc70d8958f5d22f9f8" + }, + "compiler": { + "cohort": "rd-p6-150c", + "profile": "cb-standard", + "path": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/compilers/standard/bun", + "sha256": "PENDING_ACTUAL_PRESERVED_NATIVE_COMPILER_SHA256", + "bunCommit": "150c9620c53710060186b8b0cd50985e035408b0", + "webkitCommit": "aaa690bfbf34c9d50775716ac2fc3c7d0573e0b8", + "engineFeatures": { + "shadowRealm": true, + "hardened": false + } + }, + "buildNode": { + "path": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/opt/node/bin/node", + "sha256": "PENDING_ACTUAL_NATIVE_NODE_SHA256" + }, + "pluginsFile": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admission-inputs/plugins/desktop.json", + "pluginsSha256": "PENDING_ACTUAL_NATIVE_PLUGIN_SELECTION_SHA256", + "compileTrimAllow": [ + "run" + ], + "timeoutSeconds": "PENDING_ROOT_BOUNDED_TIMEOUT_SECONDS" +} diff --git a/scripts/openclaw-p6/app/packet/payload/admission-templates/ts.json b/scripts/openclaw-p6/app/packet/payload/admission-templates/ts.json new file mode 100644 index 000000000000..896badabe1ef --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/admission-templates/ts.json @@ -0,0 +1,76 @@ +{ + "schemaVersion": 1, + "lane": "P6", + "decision": "prepared-not-admitted", + "variant": "ts", + "source": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/source", + "output": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/artifacts/ts", + "receiptDirectory": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/build-receipts/ts", + "linuxCut": { + "status": "landed-main", + "commit": "670a7ab33bbd2e3ed4f0a5681e138159d74540a1", + "mainRef": "refs/remotes/origin/main", + "mainRefSha": "PENDING_ACTUAL_NATIVE_CLONE_MAIN_SHA", + "frozenAt": "2026-10-25T18:15:36.057232+00:00", + "requiredAncestors": [ + "c36710ec04ba17c98a6d3ba59d68fcb124df8e49", + "a171cfb74891e3abce0fb8312e976323998b3654", + "4dfd92bbda37dd05db97d93d773b342245c632be", + "fe0be1ae7477634479885e788d1e0b058f84905f", + "2f3ab195038294f9b3ffb96f4f381752e580cdb4", + "d11b06c8e815cfb5dbb62e7663a89086c4b567c0", + "a355200eef8abe8504f1e83dadc5de4717d59d9c", + "2678ee8e0e04d4721a4fe74ffb0c3ad0c70e2c2d", + "25a70e7d1f0cdf4af26ea3fd54d4ba82801957f9", + "44dd89b76ce56ef532bb6868b5d39c0dbbed7714", + "1bb18fd0aa5163d348df3398a8c8acaf5efc9019", + "c887adba97b6ee6a9c7817564c69cad31f976ca1", + "2f95e977c77d74ba463cdfee9436da1004778fcc", + "bc22cdba591eac1698f7577db0c8966d950417e4", + "f7397050bdf9959d834e92eb3a8f6c243f9b61f9", + "60c3a7c35283dd6377baff1e6ab137d1e0e96c0d", + "3e579ec1ea51bce7b98cec4ea910a84f08e06c29", + "3963fb319b08ba71d26baf6f16f37d17c283b855", + "90d689c000053b46dd9ca4e24009a0e8a16fbb24", + "83fb19513e8d3013a27db742a0610230070bc8df", + "aff4d23ad1e471155921c75732417bd63984a753", + "e6a0dc9b0d20a4649807c920cb58d27fcc559743", + "ed818c4b396c1e8dd363b65d74c5f8f844b5310a", + "ded76f196cc2a64111ecf8fd24dcd306d9c445e5", + "247b73c9bdc34dd723533f50d56fc345ef624d9a", + "d465bda8766e9031f14bd266458e4bb09ac37ff2" + ], + "p0DifferenceRationale": "Latest landed main at root R2 freeze includes PR183756 typed anonymous-scope native ownership fix, PR183724 emitted-JS first-pass repair, PR183689 explicit TS source contracts, and all prior required repairs. Additional acpx0.21.0 and Knowledge plugin changes require fresh dependencies/build/selection. Immutable qualified P0 references remain distinct. Linux uses corrected Bun150c/WebKitaaa; no cross-cut or cross-compiler equivalence claimed." + }, + "distBuildInfoSha256": "PENDING_ACTUAL_NATIVE_DIST_SHA256", + "p0Reference": { + "cohort": "cb-b838", + "manifest": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admission-inputs/P0-artifacts.json", + "manifestSha256": "220560f5474dbb93266d2fdcb23b93fecf46728778becdf54b5cda578f544e18", + "variant": "desktop-c2", + "sourceCommit": "83fb19513e8d3013a27db742a0610230070bc8df", + "executableSha256": "62c5ac39f9f1a35cae9eef038ac7c22091ef4b28ffb9effc70d8958f5d22f9f8" + }, + "compiler": { + "cohort": "rd-p6-150c", + "profile": "cb-standard", + "path": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/compilers/standard/bun", + "sha256": "PENDING_ACTUAL_PRESERVED_NATIVE_COMPILER_SHA256", + "bunCommit": "150c9620c53710060186b8b0cd50985e035408b0", + "webkitCommit": "aaa690bfbf34c9d50775716ac2fc3c7d0573e0b8", + "engineFeatures": { + "shadowRealm": true, + "hardened": false + } + }, + "buildNode": { + "path": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/opt/node/bin/node", + "sha256": "PENDING_ACTUAL_NATIVE_NODE_SHA256" + }, + "pluginsFile": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/admission-inputs/plugins/desktop.json", + "pluginsSha256": "PENDING_ACTUAL_NATIVE_PLUGIN_SELECTION_SHA256", + "compileTrimAllow": [ + "run" + ], + "timeoutSeconds": "PENDING_ROOT_BOUNDED_TIMEOUT_SECONDS" +} diff --git a/scripts/openclaw-p6/app/packet/payload/adopt-compilers.py b/scripts/openclaw-p6/app/packet/payload/adopt-compilers.py new file mode 100644 index 000000000000..00c702a8a8a7 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/adopt-compilers.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +"""Copy actual preserved150c native compilers into this fresh app root; no build.""" +import hashlib,json,os,platform,shutil +from pathlib import Path +ROOT=Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1') +COMPILER_ROOT=Path('/home/runner/.cache/oc-ty-ext/P6/rd150c-x64-v1') +def sha(p): + with p.open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest() +def main(): + assert platform.system()=='Linux' and platform.machine()=='x86_64';os.umask(0o077) + record={'status':'native-compilers-adopted-not-app-admitted'};items=[] + for profile,directory,label,shadow in [('cb-standard','build-standard','standard',True),('cb-compat','build-c2','sr-off',False)]: + compiler=COMPILER_ROOT/directory/'bun';config=COMPILER_ROOT/directory/'configure.json';receipt=COMPILER_ROOT/'receipts'/f'{profile}-build.json';transport=COMPILER_ROOT/f'preserved-{profile}'/'transport.json' + built=json.loads(receipt.read_text());settings=json.loads(config.read_text());preserved=json.loads(transport.read_text()) + assert built['status']=='build-command-finished-not-qualified' and built['exitCode']==0 and built['profile']==profile + assert built['source']['bun']=='150c9620c53710060186b8b0cd50985e035408b0' and built['source']['webkit']=='aaa690bfbf34c9d50775716ac2fc3c7d0573e0b8' + assert preserved['status']=='native-preserved-not-downloaded' and preserved['profile']==profile + assert sha(compiler)==built['compilerSha256']==preserved['compilerSha256'] and sha(receipt)==preserved['buildReceiptSha256'] and sha(config)==preserved['configureSha256'] + assert settings['profile']=='release-local' and settings['overrides']['shadowRealm'] is shadow and settings['overrides'].get('hardened',False) is False + target=ROOT/'compilers'/label;assert not target.exists();items.append((profile,compiler,config,receipt,transport,target,shadow)) + assert not (ROOT/'admission-inputs/compiler-records.json').exists() + for profile,compiler,config,receipt,transport,target,shadow in items: + target.mkdir(parents=True) + for path,name in [(compiler,'bun'),(config,'configure.json'),(receipt,'build.json'),(transport,'transport.json')]:shutil.copy2(path,target/name) + assert sha(target/'bun')==sha(compiler) + record[profile]={'path':str(target/'bun'),'sha256':sha(target/'bun'),'cohort':'rd-p6-150c','bunCommit':'150c9620c53710060186b8b0cd50985e035408b0','webkitCommit':'aaa690bfbf34c9d50775716ac2fc3c7d0573e0b8','engineFeatures':{'shadowRealm':shadow,'hardened':False},'buildReceiptSha256':sha(receipt),'preservationReceiptSha256':sha(transport)} + with (ROOT/'admission-inputs/compiler-records.json').open('x') as f:json.dump(record,f,indent=2);f.write('\n') + print(json.dumps(record,indent=2)) +if __name__=='__main__':main() diff --git a/scripts/openclaw-p6/app/packet/payload/build-prep/artifact-contract.mjs b/scripts/openclaw-p6/app/packet/payload/build-prep/artifact-contract.mjs new file mode 100644 index 000000000000..98b90d54c903 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/build-prep/artifact-contract.mjs @@ -0,0 +1,52 @@ +// Linux packaging verification only; the runtime tree hash stays with its source owner. +import assert from 'node:assert/strict'; +import { createHash } from 'node:crypto'; +import fs from 'node:fs'; +import path from 'node:path'; +import { pathToFileURL } from 'node:url'; + +const [planFile] = process.argv.slice(2); +assert(planFile, 'Usage: bun artifact-contract.mjs plan.json'); +const plan = JSON.parse(fs.readFileSync(planFile, 'utf8')); +const manifestPath = path.join(plan.output, 'manifest.json'); +const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')); +const owner = path.join(plan.source, 'scripts/lib/bun-standalone-contract.mjs'); +const { describeStandaloneRuntime, sha256File } = await import(pathToFileURL(owner).href); +assert.equal(manifest.schemaVersion, 1); +assert.deepEqual(manifest.target, { platform: 'linux', arch: plan.arch }); +assert.equal(manifest.openclaw.commit, plan.sourceProof.commit); +assert.equal(manifest.openclaw.version, plan.sourceProof.version); +assert.equal(manifest.mode, plan.variant === 'jit' ? 'jit' : 'aot'); +assert.equal('sourceBuild' in manifest, plan.variant === 'ts'); +assert.equal(manifest.bun.executableSha256, plan.compiler.sha256); +assert.equal(manifest.bun.commit, plan.compiler.bunCommit); +assert.deepEqual(manifest.plugins.embedded, plan.plugins); +assert.equal(manifest.build.flavor, 'standard'); +for (const name of ['id', 'moduleGraphSha256', 'pluginSetSha256']) { + assert.match(manifest.build[name], /^[a-f0-9]{64}$/); +} +assert.equal(manifest.build.pluginSetSha256, + createHash('sha256').update(JSON.stringify(plan.plugins)).digest('hex')); +assert.equal(manifest.executable.path, 'openclaw'); +assert.equal(manifest.runtime.path, 'runtime'); +const executable = path.join(plan.output, 'openclaw'); +assert.equal(fs.statSync(executable).size, manifest.executable.sizeBytes); +assert.equal(await sha256File(executable), manifest.executable.sha256); +const runtime = await describeStandaloneRuntime(path.join(plan.output, 'runtime')); +for (const name of ['sha256', 'sizeBytes', 'fileCount', 'symlinkCount']) { + assert.equal(runtime[name], manifest.runtime[name], `Runtime ${name} differs`); +} +assert.equal(Object.values(manifest.runtime.categories).reduce((sum, item) => sum + item.bytes, 0), runtime.sizeBytes); +assert.equal(manifest.runtime.sqlite.source, 'bun'); +assert.equal(manifest.runtime.sqlite.extensionLoadingSupported, true); +assert.equal('macos' in manifest, false); +console.log(JSON.stringify({ applicationQualified: false, platform: 'linux', arch: plan.arch, + sourceCommit: manifest.openclaw.commit, version: manifest.openclaw.version, + mode: manifest.mode, build: manifest.build, compilerSha256: manifest.bun.executableSha256, + compilerCohort: plan.compiler.cohort, engineProfile: plan.compiler.profile, + admittedEngineFeatures: plan.compiler.engineFeatures, policyLabel: plan.policyLabel, + compileTrimAllow: plan.compileTrimAllow, p0ReferenceCohort: plan.p0ReferenceCohort, + c2ApplicationHardening: plan.c2ApplicationHardening, + historicalC2Equivalent: plan.historicalC2Equivalent, + executable: manifest.executable, runtime, sqlite: manifest.runtime.sqlite, + manifestSha256: await sha256File(manifestPath), contractOwnerSha256: await sha256File(owner) })); diff --git a/scripts/openclaw-p6/app/packet/payload/build-prep/build-linux.py b/scripts/openclaw-p6/app/packet/payload/build-prep/build-linux.py new file mode 100644 index 000000000000..825979a4e9cd --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/build-prep/build-linux.py @@ -0,0 +1,474 @@ +#!/usr/bin/env python3 +"""Admitted native P6 standalone build. Default is read-only preflight/dry-run.""" +import argparse +import datetime +import hashlib +import json +import os +from pathlib import Path +import platform +import re +import runpy +import shutil +import signal +import subprocess +import sys +import traceback + +BUN_PIN = 'fd40ba44187c721ee023062fa153a6a27560e6b1' +WEBKIT_PIN = 'aaa690bfbf34c9d50775716ac2fc3c7d0573e0b8' +CB_BUN_PIN = 'b838e73072227c2652a41c689299284f1965cdc6' +RD_BUN_PIN = '150c9620c53710060186b8b0cd50985e035408b0' +COHORTS = { + 'baseline-fd40': {'bun': BUN_PIN, 'webkit': WEBKIT_PIN, 'profiles': { + 'standard': {'shadowRealm': True, 'hardened': False}, + 'c2': {'shadowRealm': False, 'hardened': False}, + 'c2-linux-hardened': {'shadowRealm': False, 'hardened': True}, + }}, + 'cb-b838': {'bun': CB_BUN_PIN, 'webkit': WEBKIT_PIN, 'profiles': { + 'cb-standard': {'shadowRealm': True, 'hardened': False}, + 'cb-compat': {'shadowRealm': False, 'hardened': False}, + 'cb-linux-hardened': {'shadowRealm': False, 'hardened': True}, + }}, + 'rd-p6-150c': {'bun': RD_BUN_PIN, 'webkit': WEBKIT_PIN, 'profiles': { + 'cb-standard': {'shadowRealm': True, 'hardened': False}, + 'cb-compat': {'shadowRealm': False, 'hardened': False}, + 'cb-linux-hardened': {'shadowRealm': False, 'hardened': True}, + }}, +} +MEASURE_SHA = '373b56ced3b931233bc15a1d97c634f486602b3c9e5a02d75e0688d2f5552a5a' +FLAGS = { + 'js': ['--compile-aot', '--explain=statistics'], + 'c2': ['--compile-aot', '--no-compile-function-source', + '--disallow-code-generation-from-strings', '--explain=statistics'], + 'ts': ['--aot-source', '--explain=statistics'], + 'strong': ['--compile-aot', '--no-compile-function-source', + '--disallow-code-generation-from-strings', '--explain=statistics'], + 'jit': [], +} +PROFILES = {'js': 'standard', 'ts': 'standard', 'jit': 'standard', + 'c2': 'c2', 'strong': 'c2-linux-hardened'} + + +def now(): + return datetime.datetime.now(datetime.timezone.utc).isoformat() + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def sha(filename): + digest = hashlib.sha256() + with Path(filename).open('rb') as stream: + for data in iter(lambda: stream.read(8 << 20), b''): + digest.update(data) + return digest.hexdigest() + + +def load(filename): + return json.loads(Path(filename).read_text()) + + +def write(filename, value): + with Path(filename).open('x') as stream: + json.dump(value, stream, indent=2) + stream.write('\n') + + +def beneath(root, value): + path = Path(value) + require(path.is_absolute(), f'Absolute path required: {value}') + path = path.resolve() + require(path != root and root in path.parents, f'Path must be inside P6 root {root}: {path}') + return path + + +def git(source, *args): + result = subprocess.run(['git', '-c', f'safe.directory={source}', '-C', str(source), *args], + env={'PATH': '/usr/local/bin:/usr/bin:/bin', 'HOME': str(source.parent), + 'GIT_CONFIG_NOSYSTEM': '1'}, capture_output=True, text=True) + require(result.returncode == 0, f'git {args[0]} failed: {result.stderr.strip()}') + return result.stdout.strip() + + +def native_elf(executable, arch): + require(os.access(executable, os.X_OK), f'Not executable: {executable}') + with executable.open('rb') as stream: + header = stream.read(20) + machine = 183 if arch == 'arm64' else 62 + require(header[:6] == b'\x7fELF\x02\x01' and int.from_bytes(header[18:20], 'little') == machine, + f'ELF architecture differs from native Linux target: {executable}') + + +class BuildInterrupted(Exception): + pass + + +def interrupted(signum, _frame): + # subprocess/select treats InterruptedError as a syscall retry, not cancellation. + raise BuildInterrupted(f'Build driver interrupted by signal {signum}') + + +def run_probe(command, *, env, cwd, timeout): + child = subprocess.Popen(command, env=env, cwd=cwd, stdin=subprocess.DEVNULL, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + text=True, start_new_session=True) + try: + stdout, stderr = child.communicate(timeout=timeout) + return subprocess.CompletedProcess(command, child.returncode, stdout, stderr) + finally: + if child.poll() is None: + try: + os.killpg(child.pid, signal.SIGKILL) + except ProcessLookupError: + pass + child.communicate() + + +def admitted(admission): + require(admission.get('schemaVersion') == 1 and admission.get('lane') == 'P6' and + admission.get('decision') == 'build-linux', 'Explicit root P6 build admission required') + + +def cohort(name): + require(name in COHORTS, 'Explicit supported compiler/reference cohort required') + return COHORTS[name] + + +def retained_capabilities(root, admission, compiler_cohort, variant): + allow = admission.get('compileTrimAllow') + if compiler_cohort == 'baseline-fd40' or variant == 'jit': + require(allow is None, 'Baseline and untrimmed JIT use no retained-capability option') + return None, None + require(allow in [['run'], ['run', 'jit']], 'CB AOT requires explicit compileTrimAllow:[run] or [run,jit]') + reason = None + if 'jit' in allow: + proof = admission.get('jitRetentionProof', {}) + require(isinstance(proof.get('reason'), str) and proof['reason'].strip(), + 'JIT retention requires a named observed runtime failure') + filename = beneath(root, proof['failureReceipt']) + require(sha(filename) == proof['sha256'], 'JIT-retention failure receipt changed') + reason = {**proof, 'failureReceipt': str(filename)} + return allow, reason + + +def source_retention_contract(node, source, root, output, flags, plugins, allow): + if allow is None: + return None + script = ('const owner=await import(process.argv[1]); ' + 'console.log(JSON.stringify(owner.parseStandaloneArguments(process.argv.slice(2))));') + checked = run_probe([str(node), '--no-warnings', '--input-type=module', '--eval', script, + (source / 'scripts/lib/bun-standalone-contract.mjs').as_uri(), str(output), + *flags, '--trim-allow', ','.join(allow), '--plugins', ','.join(plugins)], + cwd=root, env={'PATH': f'{node.parent}:/usr/bin:/bin', 'HOME': str(root), + 'TMPDIR': str(root), 'LANG': 'C.UTF-8'}, timeout=30) + require(checked.returncode == 0, + 'Retained-capability build blocked: admitted landed source must implement --trim-allow. ' + + checked.stderr.strip()) + parsed = json.loads(checked.stdout) + trim = parsed.get('aotCompileOptions', {}).get('trim') + require(parsed.get('mode') == 'aot' and isinstance(trim, dict) and trim.get('allow') == allow and + bool(parsed.get('source')) == ('--aot-source' in flags), + 'Retained-capability build blocked: source parser did not preserve the requested allow list') + return parsed + + +def execution_paths(root, admission, reserved_receipt=None): + source = beneath(root, admission['source']) + output = beneath(root, admission['output']) + receipt = beneath(root, admission['receiptDirectory']) + for path in [output, receipt]: + if path != reserved_receipt: + require(not path.exists(), f'Fresh path required: {path}') + require(source not in path.parents and source != path, 'Output/receipt must be outside source') + require(output != receipt and output not in receipt.parents and receipt not in output.parents, + 'Artifact and receipt directories must be separate') + return source, output, receipt + + +def source_proof(source, cut): + commit = cut['commit'] + require(re.fullmatch('[0-9a-f]{40}', commit), 'Full Linux source commit required') + require(cut['status'] == 'landed-main', 'Linux cut must explicitly be landed-main') + require(cut['mainRef'] in ['refs/remotes/origin/main', 'refs/heads/main'], 'Explicit main ref required') + require(re.fullmatch('[0-9a-f]{40}', cut['mainRefSha']), 'Full observed-main SHA required') + require(isinstance(cut['frozenAt'], str) and cut['frozenAt'], 'Root campaign freeze timestamp required') + datetime.datetime.fromisoformat(cut['frozenAt'].replace('Z', '+00:00')) + require(git(source, 'rev-parse', 'HEAD') == commit, 'Source HEAD differs from admitted Linux cut') + require(git(source, 'rev-parse', cut['mainRef']) == cut['mainRefSha'], 'Local main ref differs from admission') + git(source, 'merge-base', '--is-ancestor', commit, cut['mainRefSha']) + require(not git(source, 'status', '--porcelain', '--untracked-files=no'), 'Tracked source is dirty') + ancestors = cut['requiredAncestors'] + require(isinstance(ancestors, list), 'requiredAncestors must be explicit') + for ancestor in ancestors: + require(re.fullmatch('[0-9a-f]{40}', ancestor), 'Full required-ancestor SHA required') + git(source, 'merge-base', '--is-ancestor', ancestor, commit) + info = load(source / 'dist/build-info.json') + package = load(source / 'package.json') + require(info.get('commit') == commit, 'dist/build-info.json belongs to another source commit') + require(info.get('version') == package['version'], 'dist/build-info.json version is stale') + require((source / 'dist/cli-startup-metadata.json').is_file(), 'Complete pnpm build first') + return {'commit': commit, 'mainRef': cut['mainRef'], 'mainRefSha': cut['mainRefSha'], + 'frozenAt': cut['frozenAt'], 'requiredAncestors': ancestors, + 'version': package['version'], 'distBuildInfo': info, + 'hashes': {name: sha(source / name) for name in ['dist/build-info.json', + 'package.json', 'pnpm-lock.yaml', 'scripts/build-bun-standalone.mjs', + 'scripts/lib/bun-standalone-contract.mjs', + 'scripts/lib/bun-standalone-source-parser.mjs']}} + + +def prepare(root, admission_file, measurement, reserved_receipt=None): + require(platform.system() == 'Linux', 'Driver requires native Linux') + arch = {'aarch64': 'arm64', 'x86_64': 'x64'}.get(platform.machine()) + require(arch, 'Only Linux arm64/x64 supported') + admission = load(admission_file) + admitted(admission) + variant = admission['variant'] + require(variant in FLAGS, 'Unknown variant') + source, output, receipt = execution_paths(root, admission, reserved_receipt) + proof = source_proof(source, admission['linuxCut']) + require(proof['hashes']['dist/build-info.json'] == admission['distBuildInfoSha256'], + 'Admitted dist/build-info.json bytes differ') + reference = admission['p0Reference'] + reference_cohort = cohort(reference.get('cohort')) + index = beneath(root, reference['manifest']) + require(index.name == 'P0-artifacts.json' and index.is_file(), 'P0 manifest clone is required') + require(sha(index) == reference['manifestSha256'], 'P0 manifest clone differs from admission') + state = load(index) + require(state.get('schemaVersion') == 1 and state.get('lane') == 'P0', 'Invalid P0 manifest') + entries = [row for row in state['artifacts'] if row['variant'] == reference['variant'] and + row['sourceCommit'] == reference['sourceCommit'] and + row['sha256'] == reference['executableSha256']] + require(len(entries) == 1, 'P0 reference does not identify one immutable artifact') + p0 = entries[0] + require(p0.get('signed') is True, 'P0 reference must be an indexed signed artifact') + require(p0['compilerPins']['bun'] == reference_cohort['bun'] and + p0['compilerPins']['webkit'] == reference_cohort['webkit'], + 'P0 reference uses different compiler pins') + if reference['cohort'] == 'cb-b838': + require(p0['compilerPins']['shadowRealm'] == 'retained' and + p0['compilerPins']['historicalC2Equivalent'] is False, + 'CB P0 reference must preserve its retained-ShadowRealm distinction') + require(p0['sourceStatus'] in ['main', 'main-plus-open-pr'], 'Unknown P0 source status') + if p0['sourceStatus'] == 'main': + require(p0['mainSha'] == p0['sourceCommit'], 'P0 main artifact has inconsistent identity') + if p0['sourceCommit'] != proof['commit']: + require(admission['linuxCut']['requiredAncestors'] and + admission['linuxCut'].get('p0DifferenceRationale', '').strip(), + 'Different P0/Linux cuts require explicit root rationale and landed-repair ancestry') + compiler = admission['compiler'] + selected_cohort = cohort(compiler.get('cohort')) + executable = beneath(root, compiler['path']) + allowed_profiles = [PROFILES[variant]] if compiler['cohort'] == 'baseline-fd40' else ( + ['cb-linux-hardened'] if variant == 'strong' else + ['cb-standard', 'cb-compat'] if variant == 'c2' else ['cb-standard']) + require(compiler['profile'] in allowed_profiles, 'Compiler engine profile differs from cohort/variant') + expected_features = selected_cohort['profiles'][compiler['profile']] + require(compiler.get('engineFeatures') == expected_features and + all(type(value) is bool for value in compiler['engineFeatures'].values()), + 'Compiler engine features differ from the explicit cohort/profile') + require(compiler['bunCommit'] == selected_cohort['bun'] and + compiler['webkitCommit'] == selected_cohort['webkit'], + 'Compiler provenance uses different pins') + require(sha(executable) == compiler['sha256'], 'Compiler bytes differ from admission') + native_elf(executable, arch) + node = admission['buildNode'] + node_path = beneath(root, node['path']) + require(node_path.name == 'node', 'Build Node must be named node for the source parser fallback') + require(sha(node_path) == node['sha256'], 'Build Node bytes differ from admission') + native_elf(node_path, arch) + strip_probe = '''import {stripTypeScriptTypes} from 'node:module'; +const input='const f = true ? async (x: number): Promise => x : null;'; +const output=stripTypeScriptTypes(input,{mode:'strip'}); +console.log(JSON.stringify({platform:process.platform,arch:process.arch,version:process.version, + offsetsPreserved:output.length===input.length,typesRemoved:!output.includes('number')}));''' + probed = run_probe([str(node_path), '--no-warnings', '--input-type=module', '--eval', strip_probe], + cwd=root, env={'PATH': f'{node_path.parent}:/usr/bin:/bin', 'HOME': str(root), + 'TMPDIR': str(root), 'LANG': 'C.UTF-8'}, timeout=30) + require(probed.returncode == 0, f'Build Node type-stripper preflight failed: {probed.stderr}') + node_probe = json.loads(probed.stdout) + require(node_probe['platform'] == 'linux' and node_probe['arch'] == arch and + node_probe['offsetsPreserved'] and node_probe['typesRemoved'], + f'Build Node type-stripper contract failed: {node_probe}') + plugins_file = beneath(root, admission['pluginsFile']) + require(sha(plugins_file) == admission['pluginsSha256'], 'Plugin selection differs from admission') + plugins = load(plugins_file) + require(isinstance(plugins, list) and plugins and plugins == sorted(set(plugins)) and + all(isinstance(item, str) and re.fullmatch('[a-z0-9][a-z0-9._-]*', item) for item in plugins), + 'Plugin IDs must be a nonempty sorted unique JSON array') + allow, retention_proof = retained_capabilities(root, admission, compiler['cohort'], variant) + source_contract = source_retention_contract(node_path, source, root, output, FLAGS[variant], plugins, allow) + retention_flags = ['--trim-allow', ','.join(allow)] if allow is not None else [] + measurement = beneath(root, str(measurement)) + require(sha(measurement) == MEASURE_SHA, 'Reviewed measurement utility bytes changed') + command = ['/usr/bin/nice', '-n', '10', str(executable), '--no-env-file', '--no-install', + str(source / 'scripts/build-bun-standalone.mjs'), str(output), + *FLAGS[variant], *retention_flags, '--plugins', ','.join(plugins)] + timeout = admission.get('timeoutSeconds', 12 * 3600) + require(type(timeout) is int and 1 <= timeout <= 24 * 3600, 'Invalid build timeout') + return {'operation': 'build-linux', 'variant': variant, 'platform': 'linux', 'arch': arch, + 'kernel': platform.release(), 'source': str(source), 'sourceProof': proof, + 'linuxCut': admission['linuxCut'], 'p0Reference': p0, + 'p0ReferenceCohort': reference['cohort'], + 'p0ManifestClone': str(index), 'p0ManifestSha256': reference['manifestSha256'], + 'compiler': compiler, 'buildNode': node, 'buildNodeProbe': node_probe, + 'compileTrimAllow': allow, 'jitRetentionProof': retention_proof, + 'sourceRetentionContract': source_contract, + 'policyLabel': '/'.join([compiler['cohort'], compiler['profile'], variant, + '+'.join(allow) if allow is not None else 'default']), + 'c2ApplicationHardening': variant in ['c2', 'strong'], + 'historicalC2Equivalent': variant == 'c2' and compiler['cohort'] == 'baseline-fd40', + 'plugins': plugins, 'pluginsFile': str(plugins_file), + 'pluginsSha256': admission['pluginsSha256'], 'output': str(output), + 'receiptDirectory': str(receipt), 'command': command, + 'measurementUtility': str(measurement), 'measurementUtilitySha256': MEASURE_SHA, + 'admissionFile': str(admission_file), 'admissionSha256': sha(admission_file), + 'driverSha256': sha(__file__), + 'artifactCheckerSha256': sha(Path(__file__).with_name('artifact-contract.mjs')), + 'buildEnvironmentOverrides': {'UV_THREADPOOL_SIZE': '2'}, + 'timeoutSeconds': timeout} + + +def reject_competing_builds(): + active = [] + for item in Path('/proc').iterdir(): + if not item.name.isdigit() or int(item.name) == os.getpid(): + continue + try: + argv = (item / 'cmdline').read_bytes().decode(errors='replace').rstrip('\0').split('\0') + except (FileNotFoundError, ProcessLookupError, PermissionError): + continue + builder = any(Path(arg).name == 'build-bun-standalone.mjs' for arg in argv) + bun_compile = (len(argv) > 1 and Path(argv[0]).name == 'bun' and argv[1] == 'build' and + any(arg.startswith(('--compile', '--aot')) for arg in argv[2:])) + if builder or bun_compile: + active.append({'pid': int(item.name), 'argv': argv}) + require(not active, f'Competing actual standalone compiler process: {active}') + + +def environment(receipt, compiler, node): + state = receipt / 'state' + for name in ['home', 'tmp', 'cache', 'workspace']: + (state / name).mkdir(parents=True) + return {'PATH': f'{Path(node).parent}:{Path(compiler).parent}:/usr/local/bin:/usr/bin:/bin', + 'HOME': str(state / 'home'), 'TMPDIR': str(state / 'tmp'), + 'TMP': str(state / 'tmp'), 'TEMP': str(state / 'tmp'), + 'XDG_CACHE_HOME': str(state / 'cache'), 'LANG': 'C.UTF-8', 'LC_ALL': 'C.UTF-8', + 'SHELL': '/bin/bash', 'USER': 'p6-synthetic', 'NO_COLOR': '1', 'TERM': 'dumb', + 'CI': '1', 'UV_THREADPOOL_SIZE': '2', 'NODE_DISABLE_COMPILE_CACHE': '1', + 'OPENCLAW_STATE_DIR': str(state), 'OPENCLAW_CONFIG_PATH': str(state / 'openclaw.json'), + 'OPENCLAW_NO_RESPAWN': '1', 'OPENCLAW_SUPERVISOR_MODE': 'external', + 'OPENCLAW_SERVICE_REPAIR_POLICY': 'external'} + + +def measure(plan, env, receipt): + # Execute the reviewed owner in this process so SIGINT/TERM raises through + # its existing finally block and kills/reaps its isolated compiler group. + old_argv, old_env, old_cwd = sys.argv, dict(os.environ), Path.cwd() + old_signals = {sig: signal.signal(sig, interrupted) for sig in [signal.SIGINT, signal.SIGTERM]} + try: + sys.argv = [plan['measurementUtility'], '--label', plan['variant'], '--out', + str(receipt / 'measurement'), '--timeout', str(plan['timeoutSeconds']), + '--', *plan['command']] + os.environ.clear() + os.environ.update(env) + os.chdir(plan['source']) + try: + runpy.run_path(plan['measurementUtility'], run_name='__main__') + except SystemExit as exit_result: + require(exit_result.code in [None, 0], f'Build command exited {exit_result.code}') + finally: + os.chdir(old_cwd) + os.environ.clear() + os.environ.update(old_env) + sys.argv = old_argv + for sig, handler in old_signals.items(): + signal.signal(sig, handler) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--root', required=True, help='P6 external-volume root as mounted on Linux') + parser.add_argument('--admission', required=True) + parser.add_argument('--measure-command', required=True) + parser.add_argument('--run', action='store_true') + args = parser.parse_args() + root = Path(args.root).resolve(strict=True) + admission_file = beneath(root, args.admission) + if not args.run: + old_signals = {sig: signal.signal(sig, interrupted) for sig in [signal.SIGINT, signal.SIGTERM]} + try: + plan = prepare(root, admission_file, Path(args.measure_command)) + print(json.dumps({'status': 'dry-run', **plan}, indent=2)) + finally: + for sig, handler in old_signals.items(): + signal.signal(sig, handler) + return + admission = load(admission_file) + admitted(admission) + _, _, receipt = execution_paths(root, admission) + receipt.mkdir(parents=True) + result = {'status': 'failed', 'startedAt': now(), 'phase': 'preflight', + 'admissionFile': str(admission_file), 'admissionSha256': sha(admission_file), + 'applicationQualified': False} + old_signals = {sig: signal.signal(sig, interrupted) for sig in [signal.SIGINT, signal.SIGTERM]} + try: + plan = prepare(root, admission_file, Path(args.measure_command), reserved_receipt=receipt) + result['plan'] = plan + require(shutil.disk_usage(root).free >= 25 * 1024**3, 'Linux volume below 25 GiB floor') + reject_competing_builds() + env = environment(receipt, plan['compiler']['path'], plan['buildNode']['path']) + result['phase'] = 'compiler-identity' + identity = run_probe([plan['compiler']['path'], '--no-env-file', '--no-install', '-p', + 'JSON.stringify({platform:process.platform,arch:process.arch,bun:Bun.revision,webkit:process.versions.webkit})'], + env=env, cwd=receipt / 'state/home', timeout=30) + result['compilerIdentityProbe'] = {'exitCode': identity.returncode, + 'stdout': identity.stdout, 'stderr': identity.stderr} + require(identity.returncode == 0, f'Compiler identity probe failed: {identity.stderr}') + identity = json.loads(identity.stdout) + require(identity == {'platform': 'linux', 'arch': plan['arch'], + 'bun': plan['compiler']['bunCommit'], 'webkit': plan['compiler']['webkitCommit']}, + f'Compiler runtime provenance mismatch: {identity}') + result['compilerRuntimeIdentity'] = identity + write(receipt / 'plan.json', plan) + reject_competing_builds() + result['phase'] = 'build' + measure(plan, env, receipt) + result['measurement'] = load(receipt / 'measurement/receipt.json') + result['phase'] = 'post-build-source-check' + require(source_proof(Path(plan['source']), plan['linuxCut']) == plan['sourceProof'], + 'Source or package build identity changed during compilation') + require(sha(admission_file) == plan['admissionSha256'] and + sha(plan['pluginsFile']) == plan['pluginsSha256'] and + sha(plan['buildNode']['path']) == plan['buildNode']['sha256'] and + sha(plan['compiler']['path']) == plan['compiler']['sha256'], + 'Admitted inputs changed during build') + result['phase'] = 'artifact-contract' + inspector = Path(__file__).with_name('artifact-contract.mjs') + check = run_probe(['/usr/bin/nice', '-n', '10', plan['compiler']['path'], + '--no-env-file', '--no-install', str(inspector), + str(receipt / 'plan.json')], env=env, + cwd=receipt / 'state/home', timeout=1800) + (receipt / 'artifact-contract.stdout').write_text(check.stdout) + (receipt / 'artifact-contract.stderr').write_text(check.stderr) + require(check.returncode == 0, f'Artifact contract failed: {check.stderr}') + result['artifact'] = json.loads(check.stdout) + result['status'] = 'built-unsigned' + result['phase'] = 'complete' + except BaseException: + result['error'] = traceback.format_exc() + if (receipt / 'measurement/receipt.json').exists(): + result['measurement'] = load(receipt / 'measurement/receipt.json') + raise + finally: + result['finishedAt'] = now() + write(receipt / 'result.json', result) + print(json.dumps({'status': result['status'], 'phase': result['phase'], 'receipt': str(receipt)})) + for sig, handler in old_signals.items(): + signal.signal(sig, handler) + + +if __name__ == '__main__': + main() diff --git a/scripts/openclaw-p6/app/packet/payload/build-prep/select-plugins.mjs b/scripts/openclaw-p6/app/packet/payload/build-prep/select-plugins.mjs new file mode 100644 index 000000000000..c7113a57930b --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/build-prep/select-plugins.mjs @@ -0,0 +1,40 @@ +// Run with the qualified Bun from the completed source checkout. +import assert from 'node:assert/strict'; +import { execFileSync } from 'node:child_process'; +import { createHash } from 'node:crypto'; +import fs from 'node:fs'; +import path from 'node:path'; +import { pathToFileURL } from 'node:url'; + +const [sourceInput, outputInput] = process.argv.slice(2); +assert(sourceInput && outputInput, 'Usage: bun select-plugins.mjs SOURCE FRESH_OUTPUT'); +const source = fs.realpathSync(sourceInput), output = path.resolve(outputInput); +assert(!fs.existsSync(output), 'Fresh selector output required'); +const sourceCommit = execFileSync('git', ['-C', source, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).trim(); +const runtimeBuildInfo = JSON.parse(fs.readFileSync(path.join(source, 'dist/build-info.json'), 'utf8')); +assert.equal(runtimeBuildInfo.commit?.trim().toLowerCase(), sourceCommit, 'Runtime build is from a different source commit; rerun pnpm build'); +assert.equal(runtimeBuildInfo.version, JSON.parse(fs.readFileSync(path.join(source, 'package.json'), 'utf8')).version, 'Runtime package version is stale'); +const owner = path.join(source, 'scripts/lib/bun-standalone-plugins.mjs'); +const { classifyStandalonePlugins, planStandalonePlugins } = await import(pathToFileURL(owner).href); +const inventory = classifyStandalonePlugins(source); +const byId = new Map(inventory.map(row => [row.id, row])); +assert(byId.has('codex'), 'Desktop Codex plugin missing from completed build'); +const selected = new Set([...inventory.filter(row => !row.hasInstallRoute && !row.devOnly).map(row => row.id), 'codex']); +let size; +do { + size = selected.size; + for (const id of selected) for (const dependency of byId.get(id).requiresPlugins) { + assert(byId.has(dependency), `Missing required plugin ${dependency} for ${id}`); + selected.add(dependency); + } +} while (size !== selected.size); +const desktop = planStandalonePlugins(source, [...selected].toSorted()); +const all = planStandalonePlugins(source); +const hash = file => createHash('sha256').update(fs.readFileSync(file)).digest('hex'); +const receipt = { sourceRoot: source, sourceCommit, owner, ownerSha256: hash(owner), + rule: 'classifyStandalonePlugins: !hasInstallRoute && !devOnly, plus codex, with requiresPlugins closure; validated by planStandalonePlugins', + inventory, desktop, all, runtimeBuildInfo, buildInfoSha256: hash(path.join(source, 'dist/build-info.json')) }; +fs.mkdirSync(output, { recursive: true }); +for (const [file, value] of [['plugin-selection.json', receipt], ['desktop.json', desktop.embedded], ['all.json', all.embedded]]) + fs.writeFileSync(path.join(output, file), JSON.stringify(value, null, 2) + '\n', { flag: 'wx' }); +console.log(JSON.stringify({ sourceCommit, desktop: desktop.embedded.length, all: all.embedded.length, output })); diff --git a/scripts/openclaw-p6/app/packet/payload/cron-fixture/cron-cli-fixture.sh b/scripts/openclaw-p6/app/packet/payload/cron-fixture/cron-cli-fixture.sh new file mode 100644 index 000000000000..93c01f919dbc --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/cron-fixture/cron-cli-fixture.sh @@ -0,0 +1,540 @@ +#!/usr/bin/env bash +# Bash 5.3+ can deadlock writing heredoc pipes on macOS before the reader starts. +if [[ ${OSTYPE:-} == darwin* && $BASH != /bin/bash ]] && ((BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 3))); then + exec /bin/bash "$0" "$@" +fi +set -euo pipefail + +ROOT_DIR="$(cd "${OPENCLAW_DOCKER_E2E_REPO_ROOT:?missing fixed source root}" && pwd -P)" +source "$ROOT_DIR/scripts/lib/docker-e2e-image.sh" + +IMAGE_NAME="$(docker_e2e_resolve_image "openclaw-cron-cli-e2e" OPENCLAW_IMAGE)" +TOKEN="cron-cli-e2e-$(date +%s)-$$" +CONTAINER_NAME="openclaw-cron-cli-e2e-$$" +CLIENT_LOG="$(mktemp -t openclaw-cron-cli-log.XXXXXX)" + +trap 'docker_e2e_cleanup_container_run "$CONTAINER_NAME" "$CLIENT_LOG"' EXIT + +docker_e2e_build_or_reuse "$IMAGE_NAME" cron-cli +OPENCLAW_TEST_STATE_SCRIPT_B64="$(docker_e2e_test_state_shell_b64 cron-cli empty)" + +echo "Running in-container Gateway + cron CLI smoke..." +set +e +docker_e2e_run_with_harness \ + --name "$CONTAINER_NAME" \ + -e "OPENCLAW_GATEWAY_TOKEN=$TOKEN" \ + -e "OPENCLAW_SKIP_CHANNELS=1" \ + -e "OPENCLAW_SKIP_GMAIL_WATCHER=1" \ + -e "OPENCLAW_SKIP_CANVAS_HOST=1" \ + -e "OPENCLAW_SKIP_ACPX_RUNTIME=1" \ + -e "OPENCLAW_SKIP_ACPX_RUNTIME_PROBE=1" \ + -e "OPENCLAW_TEST_STATE_SCRIPT_B64=$OPENCLAW_TEST_STATE_SCRIPT_B64" \ + -e "GW_TOKEN=$TOKEN" \ + -e "OPENCLAW_ALLOW_INSECURE_PRIVATE_WS=1" \ + -i \ + "$IMAGE_NAME" \ + bash -s >"$CLIENT_LOG" 2>&1 <<'INNER' +set -euo pipefail + +source scripts/lib/openclaw-e2e-instance.sh +openclaw_e2e_eval_test_state_from_b64 "${OPENCLAW_TEST_STATE_SCRIPT_B64:?missing OPENCLAW_TEST_STATE_SCRIPT_B64}" + +entry="$(openclaw_e2e_resolve_entrypoint)" +gateway_pid= +mock_pid= + +cleanup_inner() { + openclaw_e2e_stop_process "${gateway_pid:-}" + openclaw_e2e_stop_process "${mock_pid:-}" +} + +dump_logs_on_error() { + status=$? + if [ "$status" -ne 0 ]; then + openclaw_e2e_dump_logs \ + /tmp/cron-cli-gateway.log \ + /tmp/cron-cli-status.json \ + /tmp/cron-cli-add.json \ + /tmp/cron-cli-agent-add.json \ + /tmp/cron-cli-agent-default.json \ + /tmp/cron-cli-agent-restricted.json \ + /tmp/cron-cli-agent-cleared.json \ + /tmp/cron-authority-operator-matrix.json \ + /tmp/cron-cli-edit-exact.json \ + /tmp/cron-cli-edit-timeout.json \ + /tmp/cron-cli-get-after-edit.json \ + /tmp/cron-cli-script-add.json \ + /tmp/cron-cli-script-before.json \ + /tmp/cron-cli-script-generic-timeout.log \ + /tmp/cron-cli-script-after-generic.json \ + /tmp/cron-cli-script-edit-timeout.json \ + /tmp/cron-cli-script-after-specific.json \ + /tmp/cron-cli-event-add.json \ + /tmp/cron-cli-event-before.json \ + /tmp/cron-cli-event-generic-timeout.log \ + /tmp/cron-cli-event-after.json \ + /tmp/cron-cli-list.json \ + /tmp/cron-cli-show.json \ + /tmp/cron-cli-disable.json \ + /tmp/cron-cli-enable.json \ + /tmp/cron-cli-run.json \ + /tmp/cron-cli-runs.json \ + /tmp/cron-cli-remove.json + fi + cleanup_inner + exit "$status" +} + +trap cleanup_inner EXIT +trap dump_logs_on_error ERR + +cron_cli() { + node "$entry" cron "$@" --token "${GW_TOKEN:?missing GW_TOKEN}" +} + +run_operator_authority_matrix() { + local phase="$1" + node --input-type=module - "$entry" "${GW_TOKEN:?missing GW_TOKEN}" "$phase" <<'NODE' +import { readFile, writeFile } from "node:fs/promises"; +import { spawnSync } from "node:child_process"; + +const [entry, token, phase] = process.argv.slice(2); +const snapshotPath = "/tmp/cron-authority-operator-matrix.json"; + +function callGateway(method, params) { + const result = spawnSync( + process.execPath, + [entry, "gateway", "call", method, "--params", JSON.stringify(params), "--token", token, "--json"], + { encoding: "utf8", env: process.env }, + ); + if (result.status !== 0) { + throw new Error( + `${method} failed (${result.status}): ${String(result.stderr || result.stdout).trim()}`, + ); + } + return JSON.parse(result.stdout); +} + +function readAuthority(job) { + return { + toolsAllow: job.payload?.toolsAllow, + toolsAllowIsDefault: job.payload?.toolsAllowIsDefault, + }; +} + +function assertAuthority(label, job, expected) { + const actual = readAuthority(job); + if (JSON.stringify(actual) !== JSON.stringify(expected)) { + throw new Error( + `${label} authority mismatch: expected=${JSON.stringify(expected)} actual=${JSON.stringify(actual)}`, + ); + } +} + +if (phase === "create") { + const schedule = { kind: "every", everyMs: 3_600_000 }; + const cases = [ + { + label: "agent-default", + input: { + name: "operator agent default", + sessionTarget: "isolated", + payload: { kind: "agentTurn", message: "agent default" }, + }, + expected: { toolsAllow: ["*"] }, + }, + { + label: "agent-wildcard", + input: { + name: "operator agent wildcard", + sessionTarget: "isolated", + payload: { kind: "agentTurn", message: "agent wildcard", toolsAllow: ["*"] }, + }, + expected: { toolsAllow: ["*"] }, + }, + { + label: "agent-empty", + input: { + name: "operator agent empty", + sessionTarget: "isolated", + payload: { kind: "agentTurn", message: "agent empty", toolsAllow: [] }, + }, + expected: { toolsAllow: [] }, + }, + { + label: "script-default", + input: { + name: "operator script default", + sessionTarget: "isolated", + payload: { kind: "script", script: "return {}" }, + }, + expected: { toolsAllow: ["*"] }, + }, + { + label: "trigger-system-default", + input: { + name: "operator trigger system default", + sessionTarget: "main", + trigger: { script: "return { fire: false }" }, + payload: { kind: "systemEvent", text: "trigger system default" }, + }, + expected: { toolsAllow: ["*"] }, + }, + { + label: "trigger-command-default", + input: { + name: "operator trigger command default", + sessionTarget: "isolated", + trigger: { script: "return { fire: false }" }, + payload: { kind: "command", argv: ["printf", "trigger-command"] }, + }, + expected: { toolsAllow: ["*"] }, + }, + { + label: "transport-system-capless", + input: { + name: "operator transport system capless", + sessionTarget: "main", + payload: { kind: "systemEvent", text: "transport system capless" }, + }, + expected: {}, + }, + { + label: "transport-command-capless", + input: { + name: "operator transport command capless", + sessionTarget: "isolated", + payload: { kind: "command", argv: ["printf", "transport-command"] }, + }, + expected: {}, + }, + { + label: "transport-system-narrow-trigger", + input: { + name: "operator transport system narrow", + sessionTarget: "main", + payload: { kind: "systemEvent", text: "transport system narrow", toolsAllow: ["read"] }, + }, + expected: { toolsAllow: ["read"] }, + patch: { trigger: { script: "return { fire: false }" } }, + expectedAfterPatch: { toolsAllow: ["read"] }, + }, + { + label: "transport-system-capless-trigger", + input: { + name: "operator transport system adopts wildcard", + sessionTarget: "main", + payload: { kind: "systemEvent", text: "transport system adopts wildcard" }, + }, + expected: {}, + patch: { trigger: { script: "return { fire: false }" } }, + expectedAfterPatch: { toolsAllow: ["*"] }, + }, + ]; + + const snapshots = []; + for (const testCase of cases) { + let job = callGateway("cron.add", { + enabled: false, + schedule, + wakeMode: "now", + delivery: { mode: "none" }, + ...testCase.input, + }); + assertAuthority(`${testCase.label} create`, job, testCase.expected); + if (testCase.patch) { + callGateway("cron.update", { id: job.id, patch: testCase.patch }); + job = callGateway("cron.get", { id: job.id }); + assertAuthority(`${testCase.label} update`, job, testCase.expectedAfterPatch); + } + snapshots.push({ + id: job.id, + label: testCase.label, + authority: readAuthority(job), + }); + } + await writeFile(snapshotPath, `${JSON.stringify({ cases: snapshots }, null, 2)}\n`, "utf8"); + process.stdout.write(`operator authority matrix created ${snapshots.length} cases\n`); +} else if (phase === "verify") { + const snapshot = JSON.parse(await readFile(snapshotPath, "utf8")); + for (const testCase of snapshot.cases) { + const job = callGateway("cron.get", { id: testCase.id }); + assertAuthority(`${testCase.label} restart`, job, testCase.authority); + callGateway("cron.remove", { id: testCase.id }); + } + process.stdout.write(`operator authority matrix restart-verified ${snapshot.cases.length} cases\n`); +} else { + throw new Error(`unknown authority matrix phase: ${phase}`); +} +NODE +} + +read_json_field() { + local file="$1" + local field="$2" + node --input-type=module -e ' + const fs = await import("node:fs/promises"); + const [file, field] = process.argv.slice(1); + const value = JSON.parse(await fs.readFile(file, "utf8"))[field]; + if (typeof value !== "string" || value.length === 0) { + throw new Error(`missing string field ${field} in ${file}`); + } + process.stdout.write(value); + ' "$file" "$field" +} + +# Task-only fixture: disabled agent rows require a configured model route. +# Use the source-owned loopback mock; never real credentials or provider traffic. +MOCK_PORT=0 MOCK_REQUEST_LOG=/tmp/cron-cli-provider-requests.jsonl SUCCESS_MARKER=P6_CRON_SYNTHETIC \ + node scripts/e2e/mock-openai-server.mjs >/tmp/cron-cli-mock.log 2>&1 & +mock_pid="$!" +mock_port= +for attempt in {1..100}; do + mock_port="$(sed -n 's/^mock-openai listening on \([0-9][0-9]*\)$/\1/p' /tmp/cron-cli-mock.log | head -1)" + [ -z "$mock_port" ] || break + kill -0 "$mock_pid" 2>/dev/null || { cat /tmp/cron-cli-mock.log; exit 1; } + sleep 0.1 +done +[[ "$mock_port" =~ ^[1-9][0-9]*$ ]] || { cat /tmp/cron-cli-mock.log; exit 1; } +node --input-type=module - "$mock_port" <<'P6_CRON_PROVIDER' +import fs from 'node:fs'; +import {applyMockOpenAiModelConfig} from './scripts/e2e/lib/fixtures/mock-openai-config.mjs'; +const cfg={}; +applyMockOpenAiModelConfig(cfg,{mockPort:process.argv[2]}); +cfg.models.providers.openai.apiKey='p6-synthetic-cron-fixture-only'; +fs.writeFileSync(process.env.OPENCLAW_CONFIG_PATH,JSON.stringify(cfg,null,2)+'\n'); +console.log('P6_CRON_SYNTHETIC_PROVIDER '+JSON.stringify({baseUrl:cfg.models.providers.openai.baseUrl,credentialKind:'synthetic-fixture-only'})); +P6_CRON_PROVIDER + +node --input-type=module -e ' + const fs = await import("node:fs/promises"); + const configPath = process.env.OPENCLAW_CONFIG_PATH; + if (!configPath) { + throw new Error("OPENCLAW_CONFIG_PATH is required"); + } + const raw = await fs.readFile(configPath, "utf8").catch(() => "{}"); + const config = JSON.parse(raw || "{}"); + config.cron ??= {}; + config.cron.triggers = { ...(config.cron.triggers ?? {}), enabled: true }; + await fs.writeFile(configPath, `${JSON.stringify(config, null, 2)}\n`, "utf8"); +' + +gateway_pid="$(openclaw_e2e_start_gateway "$entry" 18789 /tmp/cron-cli-gateway.log)" +openclaw_e2e_wait_gateway_ready "$gateway_pid" /tmp/cron-cli-gateway.log 300 18789 + +run_operator_authority_matrix create +node --input-type=module - <<'P6_CRON_DISABLED' +import fs from 'node:fs'; +const file='/tmp/cron-cli-provider-requests.jsonl'; +const rows=fs.existsSync(file)?fs.readFileSync(file,'utf8').trim().split('\n').filter(Boolean).map(JSON.parse):[]; +const inference=rows.filter(row=>/\/v1\/(responses|chat\/completions)/.test(row.path??'')); +if(inference.length)throw Error('disabled authority rows unexpectedly requested inference'); +console.log('P6_CRON_DISABLED_INFERENCE '+JSON.stringify({requests:inference.length})); +P6_CRON_DISABLED +openclaw_e2e_stop_process "$gateway_pid" +gateway_pid= +gateway_pid="$(openclaw_e2e_start_gateway "$entry" 18789 /tmp/cron-cli-gateway.log)" +openclaw_e2e_wait_gateway_ready "$gateway_pid" /tmp/cron-cli-gateway.log 300 18789 +run_operator_authority_matrix verify + +cron_cli status --json > /tmp/cron-cli-status.json +cron_add_args=( + "cli cron smoke" + --cron "*/5 * * * *" + --command "printf openclaw-cli-cron-ok" + --no-deliver + --timeout-seconds 15 + --json +) +cron_cli add "${cron_add_args[@]}" > /tmp/cron-cli-add.json + +job_id="$(read_json_field /tmp/cron-cli-add.json id)" + +cron_cli add \ + "agent authority smoke" \ + --every 1h \ + --session isolated \ + --message "verify explicit cron tool authority" \ + --no-deliver \ + --json > /tmp/cron-cli-agent-add.json +agent_job_id="$(read_json_field /tmp/cron-cli-agent-add.json id)" + +cron_cli show "$agent_job_id" --json > /tmp/cron-cli-agent-default.json +cron_cli edit "$agent_job_id" --tools read +cron_cli show "$agent_job_id" --json > /tmp/cron-cli-agent-restricted.json +cron_cli edit "$agent_job_id" --clear-tools +cron_cli show "$agent_job_id" --json > /tmp/cron-cli-agent-cleared.json +node --input-type=module -e ' + const fs = await import("node:fs/promises"); + const readPayload = async (path) => JSON.parse(await fs.readFile(path, "utf8")).payload; + const defaultPayload = await readPayload("/tmp/cron-cli-agent-default.json"); + const restrictedPayload = await readPayload("/tmp/cron-cli-agent-restricted.json"); + const clearedPayload = await readPayload("/tmp/cron-cli-agent-cleared.json"); + if (JSON.stringify(defaultPayload?.toolsAllow) !== JSON.stringify(["*"])) { + throw new Error(`new agent job is not explicitly unrestricted: ${JSON.stringify(defaultPayload)}`); + } + if (JSON.stringify(restrictedPayload?.toolsAllow) !== JSON.stringify(["read"])) { + throw new Error(`cron edit --tools did not persist: ${JSON.stringify(restrictedPayload)}`); + } + if (JSON.stringify(clearedPayload?.toolsAllow) !== JSON.stringify(["*"])) { + throw new Error(`cron edit --clear-tools is not explicit: ${JSON.stringify(clearedPayload)}`); + } +' +cron_cli rm "$agent_job_id" --json >/dev/null + +cron_cli edit "$job_id" --exact > /tmp/cron-cli-edit-exact.json +cron_cli edit "$job_id" --timeout-seconds 30 > /tmp/cron-cli-edit-timeout.json +cron_cli get "$job_id" > /tmp/cron-cli-get-after-edit.json +node --input-type=module -e ' + const fs = await import("node:fs/promises"); + const value = JSON.parse(await fs.readFile("/tmp/cron-cli-get-after-edit.json", "utf8")); + if (value.schedule?.kind !== "cron" || value.schedule.staggerMs !== 0) { + throw new Error(`cron edit --exact did not persist: ${JSON.stringify(value.schedule)}`); + } + if (value.payload?.kind !== "command" || value.payload.timeoutSeconds !== 30) { + throw new Error(`cron timeout-only edit changed command payload kind: ${JSON.stringify(value.payload)}`); + } +' + +cat > /tmp/cron-cli-script.js <<'SCRIPT' +return { notify: "cron script timeout proof" }; +SCRIPT +cron_cli add \ + "script timeout smoke" \ + --every 1h \ + --session isolated \ + --script /tmp/cron-cli-script.js \ + --script-timeout-seconds 15 \ + --no-deliver \ + --json > /tmp/cron-cli-script-add.json +script_job_id="$(read_json_field /tmp/cron-cli-script-add.json id)" +cron_cli get "$script_job_id" > /tmp/cron-cli-script-before.json +if cron_cli edit "$script_job_id" --timeout-seconds 30 > /tmp/cron-cli-script-generic-timeout.log 2>&1; then + echo "generic timeout unexpectedly succeeded for script job" >&2 + exit 1 +fi +grep -q -- "Use --script-timeout-seconds for script jobs" /tmp/cron-cli-script-generic-timeout.log +cron_cli get "$script_job_id" > /tmp/cron-cli-script-after-generic.json +cron_cli edit "$script_job_id" --script-timeout-seconds 30 > /tmp/cron-cli-script-edit-timeout.json +cron_cli get "$script_job_id" > /tmp/cron-cli-script-after-specific.json +node --input-type=module -e ' + const fs = await import("node:fs/promises"); + const before = JSON.parse(await fs.readFile("/tmp/cron-cli-script-before.json", "utf8")); + const afterGeneric = JSON.parse( + await fs.readFile("/tmp/cron-cli-script-after-generic.json", "utf8"), + ); + const afterSpecific = JSON.parse( + await fs.readFile("/tmp/cron-cli-script-after-specific.json", "utf8"), + ); + if (before.payload?.kind !== "script" || before.payload.timeoutSeconds !== 15) { + throw new Error(`script setup mismatch: ${JSON.stringify(before.payload)}`); + } + if (JSON.stringify(afterGeneric.payload) !== JSON.stringify(before.payload)) { + throw new Error( + `rejected generic timeout changed script payload: ${JSON.stringify(afterGeneric.payload)}`, + ); + } + if (afterSpecific.payload?.kind !== "script" || afterSpecific.payload.timeoutSeconds !== 30) { + throw new Error( + `script-specific timeout did not persist: ${JSON.stringify(afterSpecific.payload)}`, + ); + } +' +cron_cli rm "$script_job_id" --json >/dev/null + +cron_cli add \ + "event timeout smoke" \ + --every 1h \ + --session main \ + --system-event "cron event timeout proof" \ + --json > /tmp/cron-cli-event-add.json +event_job_id="$(read_json_field /tmp/cron-cli-event-add.json id)" +cron_cli get "$event_job_id" > /tmp/cron-cli-event-before.json +if cron_cli edit "$event_job_id" --timeout-seconds 30 > /tmp/cron-cli-event-generic-timeout.log 2>&1; then + echo "generic timeout unexpectedly succeeded for systemEvent job" >&2 + exit 1 +fi +grep -q -- "--timeout-seconds is not supported for systemEvent jobs" \ + /tmp/cron-cli-event-generic-timeout.log +cron_cli get "$event_job_id" > /tmp/cron-cli-event-after.json +node --input-type=module -e ' + const fs = await import("node:fs/promises"); + const before = JSON.parse(await fs.readFile("/tmp/cron-cli-event-before.json", "utf8")); + const after = JSON.parse(await fs.readFile("/tmp/cron-cli-event-after.json", "utf8")); + if (before.payload?.kind !== "systemEvent") { + throw new Error(`event setup mismatch: ${JSON.stringify(before.payload)}`); + } + if (JSON.stringify(after.payload) !== JSON.stringify(before.payload)) { + throw new Error(`rejected generic timeout changed event payload: ${JSON.stringify(after.payload)}`); + } +' +cron_cli rm "$event_job_id" --json >/dev/null + +cron_cli list --all --json > /tmp/cron-cli-list.json +node --input-type=module -e ' + const fs = await import("node:fs/promises"); + const jobId = process.argv[1]; + const value = JSON.parse(await fs.readFile("/tmp/cron-cli-list.json", "utf8")); + if (!Array.isArray(value.jobs) || !value.jobs.some((job) => job.id === jobId && job.name === "cli cron smoke")) { + throw new Error("created job missing from cron list"); + } +' "$job_id" + +cron_cli show "$job_id" --json > /tmp/cron-cli-show.json +node --input-type=module -e ' + const fs = await import("node:fs/promises"); + const jobId = process.argv[1]; + const value = JSON.parse(await fs.readFile("/tmp/cron-cli-show.json", "utf8")); + if (value.id !== jobId || value.name !== "cli cron smoke") { + throw new Error("cron show returned the wrong job"); + } +' "$job_id" + +cron_cli disable "$job_id" > /tmp/cron-cli-disable.json +cron_cli enable "$job_id" > /tmp/cron-cli-enable.json + +cron_cli run "$job_id" --wait --wait-timeout 120s --poll-interval 500ms > /tmp/cron-cli-run.json +node --input-type=module -e ' + const fs = await import("node:fs/promises"); + const value = JSON.parse(await fs.readFile("/tmp/cron-cli-run.json", "utf8")); + if (value.completed !== true || value.status !== "ok") { + throw new Error(`cron run did not complete ok: ${JSON.stringify(value)}`); + } +' + +cron_cli runs --id "$job_id" --limit 5 > /tmp/cron-cli-runs.json +node --input-type=module -e ' + const fs = await import("node:fs/promises"); + const value = JSON.parse(await fs.readFile("/tmp/cron-cli-runs.json", "utf8")); + const matching = Array.isArray(value.entries) + ? value.entries.find((entry) => entry.status === "ok" && entry.summary === "openclaw-cli-cron-ok") + : undefined; + if (!matching) { + throw new Error("cron runs missing successful command summary"); + } +' + +cron_cli rm "$job_id" --json > /tmp/cron-cli-remove.json +node --input-type=module -e ' + const fs = await import("node:fs/promises"); + const value = JSON.parse(await fs.readFile("/tmp/cron-cli-remove.json", "utf8")); + if (value.ok !== true) { + throw new Error("cron remove failed"); + } +' + +node --input-type=module -e ' + process.stdout.write(JSON.stringify({ ok: true, jobId: process.argv[1] }) + "\n"); +' "$job_id" +INNER +status=${PIPESTATUS[0]} +set -e + +if [ "$status" -ne 0 ]; then + echo "Docker cron CLI smoke failed" + docker_e2e_print_log "$CLIENT_LOG" + exit "$status" +fi + +docker_e2e_print_log "$CLIENT_LOG" +echo "OK" diff --git a/scripts/openclaw-p6/app/packet/payload/cron-fixture/inputs.json b/scripts/openclaw-p6/app/packet/payload/cron-fixture/inputs.json new file mode 100644 index 000000000000..e88bd3764594 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/cron-fixture/inputs.json @@ -0,0 +1,22 @@ +{ + "status": "prepared-only-not-x64-proof", + "sourceCommit": "670a7ab33bbd2e3ed4f0a5681e138159d74540a1", + "nativeRoot": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1", + "nativeSource": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/source", + "controllerNode": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/opt/node/bin/node", + "fixtureSha256": "958adbfa641e24736306fd23a5cb3a5e2bfda2c4502889ca593c33da368be4a2", + "helpersSha256": { + "scripts/e2e/cron-cli-docker.sh": "6abf5cf3e174992d313c1f69f863565ebad078a17dae89723fb817ec6ae33245", + "scripts/lib/docker-e2e-image.sh": "b1227189675dff51e3a0218edc2715fad01b771668f1a402a9effba28aec49b1", + "scripts/lib/docker-e2e-package.sh": "88a00beb30de0aee79e679d33d504c4058335b433166eb35a5c9d9bc14bab575", + "scripts/lib/docker-e2e-container.sh": "7ae9be2f95729d17913413189790973aa97e8bd6ba24ff0fbddf2ad450a40fe0", + "scripts/lib/openclaw-e2e-instance.sh": "bd6cf54ea310f96a891f12ec55ed282d29de8370b3505482ec1ab7626e6eb08e", + "scripts/lib/openclaw-test-state.mts": "610f6982125dc456f04ac241ad71ba7f01ac107c10f177ed6c947f2b0e25cc99", + "scripts/e2e/mock-openai-server.mjs": "e68f6ce4b4024aa0c04d0504dbe403f2e310be1fd2e2a51c907244e31dbf1820", + "scripts/e2e/lib/fixtures/mock-openai-config.mjs": "26986b7a44259220a98ba616e20297888502a6ec9f0cb89f9306159b544ebfb1" + }, + "runtimeExecuted": false, + "imageReceipt": "required approved qualification-prep-v3 docker-image.py result.json; PASS source/manifest/binary identity, actual immutable image ID", + "imageReceiptProducerSha256": "5cc18ed7bf5d02fc0eed0d2688dba355e470e62fe7910b4a679eab0751c9a87a", + "controllerNodeReceipt": "/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1/prep-receipts/toolchain/result.json" +} diff --git a/scripts/openclaw-p6/app/packet/payload/cron-fixture/run-native.sh b/scripts/openclaw-p6/app/packet/payload/cron-fixture/run-native.sh new file mode 100644 index 000000000000..500afb2f819b --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/cron-fixture/run-native.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash +set -euo pipefail +[[ $# -eq 3 ]] || { echo 'Usage: run-native.sh ACTUAL_ARTIFACT APPROVED_DOCKER_IMAGE_RESULT_JSON FRESH_P6_OUTPUT' >&2; exit 2; } +here="$(cd "$(dirname "$0")" && pwd -P)" +root=/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1 +source="$(cd "$root/source" && pwd -P)" +node="$root/opt/node/bin/node" +artifact=$1 +image_receipt=$2 +output=$3 +[[ $(uname -s) == Linux && $(uname -m) == x86_64 ]] || exit 1 +image="$("$node" --input-type=module - "$here" "$source" "$artifact" "$image_receipt" "$output" <<'NODE' +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import path from 'node:path'; +import {createHash} from 'node:crypto'; +import {execFileSync} from 'node:child_process'; +const [here,source,artifactArg,receiptArg,outArg]=process.argv.slice(2); +const read=p=>JSON.parse(fs.readFileSync(p,'utf8')); +const hash=p=>createHash('sha256').update(fs.readFileSync(p)).digest('hex'); +const input=read(path.join(here,'inputs.json')); +const toolchain=read(input.controllerNodeReceipt); +assert.equal(toolchain.status,'PASS'); +assert.equal(toolchain.buildNode.path,input.controllerNode); +assert.equal(hash(input.controllerNode),toolchain.buildNode.sha256); +assert.equal(hash(path.join(here,'cron-cli-fixture.sh')),input.fixtureSha256); +assert.equal(execFileSync('git',['-C',source,'rev-parse','HEAD'],{encoding:'utf8'}).trim(),input.sourceCommit); +assert.equal(execFileSync('git',['-C',source,'status','--porcelain','--untracked-files=no'],{encoding:'utf8'}).trim(),'','tracked helper source changed'); +for(const [name,digest] of Object.entries(input.helpersSha256))assert.equal(hash(path.join(source,name)),digest,name); +const artifact=fs.realpathSync(artifactArg),out=path.resolve(outArg),p6=path.dirname(input.nativeRoot); +const manifest=read(path.join(artifact,'manifest.json')); +assert.deepEqual(manifest.target,{platform:'linux',arch:'x64'}); +assert.equal(manifest.openclaw.commit,input.sourceCommit); +assert.equal(manifest.mode,'aot'); +const receiptBytes=fs.readFileSync(receiptArg),receipt=JSON.parse(receiptBytes); +assert.equal(receipt.status,'PASS','successful owner docker-image result.json required'); +assert.equal(receipt.sourceCommit,input.sourceCommit); +assert.equal(receipt.manifestSha256,hash(path.join(artifact,'manifest.json'))); +assert.equal(receipt.binarySha256,hash(path.join(artifact,'openclaw'))); +assert.equal(manifest.executable.sha256,receipt.binarySha256); +assert.match(receipt.imageId,/^sha256:[0-9a-f]{64}$/); +assert(out.startsWith(p6+path.sep)&&out!==artifact&&!out.startsWith(artifact+path.sep)&&out!==source&&!out.startsWith(source+path.sep)); +assert(!fs.existsSync(out),'fresh output required');fs.mkdirSync(out,{recursive:true}); +fs.writeFileSync(path.join(out,'image-receipt.json'),receiptBytes,{flag:'wx'}); +fs.writeFileSync(path.join(out,'image-binding.json'),JSON.stringify({imageId:receipt.imageId,sourceCommit:receipt.sourceCommit,manifestSha256:receipt.manifestSha256,binarySha256:receipt.binarySha256,receiptSha256:createHash('sha256').update(receiptBytes).digest('hex')},null,2)+'\n',{flag:'wx'}); +console.log(receipt.imageId); +NODE +)" +output="$(cd "$output" && pwd -P)" +mkdir "$output/tmp" +export TMPDIR="$output/tmp" PATH="$root/opt/node/bin:/usr/local/bin:/usr/bin:/bin" +finish() { code=$?;trap - EXIT;printf '{"exitCode":%s}\n' "$code" >"$output/exit.json";exit "$code"; } +trap finish EXIT +require_equal() { if [[ "$1" != "$2" ]]; then echo "Image identity mismatch: $3" >&2;exit 1;fi; } +require_equal "$(docker image inspect "$image" --format '{{.Id}}')" "$image" immutable-image-id +require_equal "$(docker image inspect "$image" --format '{{.Os}}')" linux operating-system +require_equal "$(docker image inspect "$image" --format '{{.Architecture}}')" amd64 architecture +docker image inspect "$image" >"$output/image.json" +sha256sum "$here/inputs.json" "$here/cron-cli-fixture.sh" "$artifact/manifest.json" "$artifact/openclaw" "$output/image-receipt.json" >"$output/input-sha256.txt" +export OPENCLAW_SKIP_DOCKER_BUILD=1 OPENCLAW_DOCKER_E2E_REQUIRE_LOCAL_IMAGE=1 +export OPENCLAW_IMAGE="$image" OPENCLAW_DOCKER_E2E_IMAGE="$image" +export OPENCLAW_DOCKER_E2E_REPO_ROOT="$source" DOCKER_E2E_HARNESS_ROOT_DIR="$source" +export OPENCLAW_SELECTED_SHA=670a7ab33bbd2e3ed4f0a5681e138159d74540a1 +export OPENCLAW_DOCKER_E2E_SELECTED_SHA="$OPENCLAW_SELECTED_SHA" +/bin/bash "$here/cron-cli-fixture.sh" >"$output/lane.log" 2>&1 || exit "$?" diff --git a/scripts/openclaw-p6/app/packet/payload/guest/application/guest-cli.py b/scripts/openclaw-p6/app/packet/payload/guest/application/guest-cli.py new file mode 100755 index 000000000000..dbef1b0db4a2 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/application/guest-cli.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +"""Actual app CLI and native memory probes in its main JS context; no policy injection.""" +from pathlib import Path +import hashlib,importlib.util,json,os,platform,re,shutil,signal,stat,subprocess,traceback + +def module(path,name): + spec=importlib.util.spec_from_file_location(name,path);m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m);return m + +def main(): + os.umask(0o077) + payload=Path('/mnt/p6');manifest=json.loads((payload/'manifest.json').read_text());work=Path('/var/tmp/p6-application-security');work.mkdir(exist_ok=False);binary=payload/'artifact/openclaw' + report={**manifest,'kernel':platform.release(),'arch':platform.machine(),'pass':False,'applicationQualification':False,'qualificationKind':'application-main-memory-policy','performanceEligible':False,'scope':'Actual app main-thread anonymous RWX/RW-to-RX denial, allowed file-backed RX; no universal executable-memory claim','commands':[],'traces':{}} + try: + version=re.match(r'^(\d+)\.(\d+)',platform.release()) + if platform.machine()!='x86_64' or not version or tuple(map(int,version.groups()))<(6,7):raise RuntimeError('Requires Linux x64 kernel >=6.7') + if hashlib.file_digest(binary.open('rb'),'sha256').hexdigest()!=manifest['binarySha256']:raise RuntimeError('Application binary differs') + fixture_bytes={} + for name,expected in manifest['controlFiles'].items(): + raw=(payload/'security'/name).read_bytes() + if hashlib.sha256(raw).hexdigest()!=expected:raise RuntimeError('Control file differs: '+name) + if name.startswith('fixture/'):fixture_bytes[name]=raw + strace=shutil.which('strace') + if not strace:raise RuntimeError('Pinned guest strace absent') + report['straceVersion']=subprocess.run([strace,'--version'],capture_output=True,text=True,check=True).stdout.splitlines()[0] + for name in ['home','tmp','xdg','state','workspace']:(work/name).mkdir() + # mkfs -d preserves host ownership; the guest owns its verified fixture copy. + fixture=work/'fixture';fixture.mkdir(mode=0o700) + for name in ['package.json','openclaw.plugin.json','index.js']: + (fixture/name).write_bytes(fixture_bytes['fixture/'+name]) + def path_identity(path): + info=path.stat() + return {'path':str(path),'uid':info.st_uid,'gid':info.st_gid,'mode':oct(stat.S_IMODE(info.st_mode))} + report['fixtureAdmission']={'effectiveUid':os.geteuid(),'umask':'0077', + 'payload':[path_identity(payload/'security/fixture'),path_identity(payload/'security/fixture/index.js')], + 'owned':[path_identity(fixture),path_identity(fixture/'index.js')], + 'copiedFileSha256':{name:manifest['controlFiles']['fixture/'+name] for name in ['package.json','openclaw.plugin.json','index.js']}} + cfg={'gateway':{'mode':'local','bind':'loopback','port':33189,'auth':{'mode':'token','token':'p6-synthetic-mdwe'},'controlUi':{'enabled':False}},'agents':{'defaults':{'workspace':str(work/'workspace'),'skipBootstrap':True,'utilityModel':''},'entries':{'main':{}}},'browser':{'enabled':False},'update':{'checkOnStart':False},'plugins':{'enabled':True,'allow':['p6-mdwe-fixture'],'load':{'paths':[str(fixture)]},'entries':{'p6-mdwe-fixture':{'enabled':True}}}} + (work/'state/openclaw.json').write_text(json.dumps(cfg,indent=2)+'\n') + env={'PATH':'/usr/bin:/bin','HOME':str(work/'home'),'USERPROFILE':str(work/'home'),'OPENCLAW_HOME':str(work/'home'),'OPENCLAW_STATE_DIR':str(work/'state'),'OPENCLAW_CONFIG_PATH':str(work/'state/openclaw.json'),'OPENCLAW_TEST_WORKSPACE_DIR':str(work/'workspace'),'TMPDIR':str(work/'tmp'),'XDG_CONFIG_HOME':str(work/'xdg'),'OPENCLAW_NO_RESPAWN':'1','OPENCLAW_DISABLE_BONJOUR':'1','OPENCLAW_NO_AUTO_UPDATE':'1','LANG':'C.UTF-8','TZ':'UTC','NO_COLOR':'1','P6_EXPECT_MDWE':str(manifest['expectedMdwe'])} + def run(label,argv,prefix): + command=[strace,'-ff','-yy','-s','256','-e','trace=execve,prctl,mmap,mprotect,pkey_mprotect,memfd_create,ftruncate,write,munmap,exit_group','-o',str(work/prefix),str(binary),*argv] + row={'label':label,'command':command};report['commands'].append(row) + with (work/(label+'.stdout')).open('wb') as stdout,(work/(label+'.stderr')).open('wb') as stderr: + child=subprocess.Popen(command,cwd=work,env=env,stdout=stdout,stderr=stderr,start_new_session=True) + try:row['exitCode']=child.wait(timeout=180) + except subprocess.TimeoutExpired: + os.killpg(child.pid,signal.SIGTERM) + try:child.wait(timeout=5) + except subprocess.TimeoutExpired:os.killpg(child.pid,signal.SIGKILL);child.wait(timeout=5) + raise RuntimeError('Actual application command timed out: '+label) + row['stdout']=(work/(label+'.stdout')).read_text();row['stderr']=(work/(label+'.stderr')).read_text() + traces={f.name:f.read_text() for f in sorted(work.glob(prefix+'.*'))};report['traces'].update(traces) + if row['exitCode']!=0:raise RuntimeError('Actual application command failed: '+label) + return row,traces + analyzer=module(payload/'trace-policy.py','trace_policy') + row,traces=run('version',['--version'],'version.trace') + if row['stdout'].strip()!=manifest['expectedStdout'].strip():raise RuntimeError('Version differs from actual host result') + report['versionPolicy']=analyzer.analyze(traces,str(binary),manifest['expectedMdwe']) + row,traces=run('memory',['p6-mdwe'],'app.trace') + report['policy']=analyzer.analyze(traces,str(binary),manifest['expectedMdwe']) + rows=[json.loads(line[len('P6_MDWE_RESULT '):]) for line in row['stdout'].splitlines() if line.startswith('P6_MDWE_RESULT ')] + if len(rows)!=1:raise RuntimeError('Expected exactly one actual main-context probe row') + trace=report['policy']['trace'] + if trace!='app.trace.'+str(rows[0]['pid']):raise RuntimeError('Probe PID differs from direct application trace') + report['memoryPolicy']=module(payload/'memory-policy.py','memory_policy').analyze(traces[trace],rows[0],report['policy'],str(binary)) + report['pass']=True + except Exception as error:report['error']=str(error);report['traceback']=traceback.format_exc() + finally: + report['traces']={f.name:f.read_text() for f in sorted(work.glob('*.trace.*'))} + (work/'result.json').write_text(json.dumps(report,indent=2)+'\n');print('P6_GUEST_RESULT '+json.dumps(report),flush=True) + return 0 if report['pass'] else 1 +if __name__=='__main__':raise SystemExit(main()) diff --git a/scripts/openclaw-p6/app/packet/payload/guest/application/memory-policy.py b/scripts/openclaw-p6/app/packet/payload/guest/application/memory-policy.py new file mode 100644 index 000000000000..2d1e17e2f9af --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/application/memory-policy.py @@ -0,0 +1,25 @@ +"""Require actual main-thread probe results and corresponding post-activation syscalls.""" +import re + +def analyze(text,row,policy,binary): + if row.get('kind')!='actual-application-plugin-main' or row.get('isMainThread') is not True or row.get('executable')!=binary or row.get('platform')!='linux' or row.get('arch')!='x64': + raise ValueError('Probe did not execute in the actual application main context') + if row.get('mdwe')!=policy['requestedBits'] or row.get('rwToRx')!=-13 or row.get('rwx')!=-13 or row.get('filePrivateRx')!=42: + raise ValueError('Unexpected actual probe result') + if not policy['getAfter'] or policy['getAfter'][-1]!=policy['requestedBits']: + raise ValueError('Actual plugin GET_MDWE readback missing') + lines=text.splitlines() + positions=[i for i,line in enumerate(lines) if re.match(r'^prctl\(PR_GET_MDWE,',line)] + if not positions:raise ValueError('No probe readback trace') + tail=lines[positions[-1]+1:] + rw=re.compile(r'^mmap\(NULL, 4096, PROT_READ\|PROT_WRITE, MAP_PRIVATE\|MAP_ANONYMOUS, -1, 0\)\s+=\s+(0x[0-9a-f]+)$') + allocations=[(i,m.group(1)) for i,line in enumerate(tail) if (m:=rw.match(line))] + pairs=[] + for i,address in allocations: + denied=re.compile(r'^mprotect\('+re.escape(address)+r', 4096, PROT_READ\|PROT_EXEC\)\s+=\s+-1 EACCES\b') + pairs.extend((tail[i],line) for line in tail[i+1:] if denied.match(line)) + rwx=[line for line in tail if re.match(r'^mmap\(NULL, 4096, PROT_READ\|PROT_WRITE\|PROT_EXEC, MAP_PRIVATE\|MAP_ANONYMOUS, -1, 0\)\s+=\s+-1 EACCES\b',line)] + memfd=[line for line in tail if line.startswith('memfd_create("p6-synthetic-code",') and re.search(r'= \d+\(deleted\)$',line)] + file_rx=[line for line in tail if re.match(r'^mmap\(NULL, 4096, PROT_READ\|PROT_EXEC, MAP_PRIVATE, \d+\(deleted\), 0\)\s+=\s+0x[0-9a-f]+$',line)] + if not pairs or not rwx or not memfd or not file_rx:raise ValueError('Missing corresponding memory denial/allowed file-RX syscall evidence') + return {'pass':True,'scope':'Actual app main-thread anonymous RWX and RW-to-RX denial; file-backed private RX remains allowed','rwToRx':pairs,'rwx':rwx,'memfd':memfd,'filePrivateRx':file_rx,'probe':row} diff --git a/scripts/openclaw-p6/app/packet/payload/guest/application/run-application-guest.py b/scripts/openclaw-p6/app/packet/payload/guest/application/run-application-guest.py new file mode 100755 index 000000000000..f1179bc6ab18 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/application/run-application-guest.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python3 +"""Future admitted-artifact CLI proof; never builds or modifies an application.""" +from pathlib import Path +import argparse +import hashlib +import importlib.util +import json +import os +import platform +import re +import secrets +import shutil +import subprocess +import sys + +IMAGE_SHA = '04e8f2461a16a44e78a370284471f29616cdd9baf1893df25807b71f985b6c94' +OWNER_SHA = 'bca0eac25f6bd828f67c895c675fea6c8202583b1e6027f6a83f22212860ab42' +TRANSPORT_SHA = '1e0d155a7827e3fa44e3c377d935001a3db6f6546cdc397fa909c86be4dcdd7b' + + +def digest(file): + with Path(file).open('rb') as stream: + return hashlib.file_digest(stream, 'sha256').hexdigest() + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--artifact', type=Path, required=True) + parser.add_argument('--admission-receipt', type=Path, required=True) + parser.add_argument('--binary-sha256', required=True) + parser.add_argument('--main-sha', required=True) + parser.add_argument('--variant', choices=['js-aot', 'c2', 'ts-aot', 'c2-linux-hardened'], required=True) + parser.add_argument('--expected-stdout', required=True) + parser.add_argument('--image', type=Path, required=True) + parser.add_argument('--work-dir', type=Path, required=True) + parser.add_argument('--vm-owner', type=Path, required=True) + parser.add_argument('--prerequisites', type=Path, required=True) + parser.add_argument('--prerequisites-sha256', required=True) + args = parser.parse_args() + if platform.system() != 'Linux' or platform.machine() != 'x86_64': + parser.error('requires the owned native Linux x64 host') + if not re.fullmatch('[0-9a-f]{40}', args.main_sha) or not re.fullmatch('[0-9a-f]{64}', args.binary_sha256): + parser.error('requires full admitted source and binary hashes') + artifact = args.artifact.resolve(strict=True) + work = args.work_dir.resolve() + if work.exists() or work == artifact or artifact in work.parents: + parser.error('work-dir must be fresh and outside the artifact') + if not (artifact / 'runtime').is_dir() or not (artifact / 'manifest.json').is_file(): + parser.error('requires a complete standalone artifact with runtime and manifest') + if digest(artifact / 'openclaw') != args.binary_sha256: + parser.error('application differs from admitted binary hash') + if digest(args.image) != IMAGE_SHA or digest(args.vm_owner) != OWNER_SHA: + parser.error('cloud image or reviewed VM lifecycle owner hash differs') + transport_file = args.vm_owner.with_name('guest_result_transport.py') + if digest(transport_file) != TRANSPORT_SHA: + parser.error('reviewed shared guest result transport hash differs') + admission_sha = digest(args.admission_receipt) + for entry in artifact.rglob('*'): + if entry.is_symlink(): + if os.path.isabs(os.readlink(entry)) or not entry.resolve(strict=True).is_relative_to(artifact): + parser.error('artifact link is not portable and contained: ' + str(entry)) + elif not entry.is_file() and not entry.is_dir(): + parser.error('artifact contains a non-regular payload entry: ' + str(entry)) + if digest(args.prerequisites) != args.prerequisites_sha256: + parser.error('Guest prerequisite receipt changed') + prerequisites = json.loads(args.prerequisites.read_text()) + if prerequisites['status'] != 'guest-prerequisites-present-not-kvm-qualified' or prerequisites['imageSha256'] != IMAGE_SHA: + parser.error('Guest prerequisites incomplete') + if set(prerequisites['tools']) != {'qemu-system-x86_64','qemu-img','cloud-localds','mkfs.ext4','timeout','sudo'}: + parser.error('Guest prerequisite tool hash map incomplete') + for tool, item in prerequisites['tools'].items(): + if shutil.which(tool) != item['path'] or digest(item['path']) != item['sha256']: + parser.error('Guest host tool changed: ' + tool) + for tool in ['qemu-system-x86_64', 'qemu-img', 'cloud-localds', 'mkfs.ext4', 'timeout', 'sudo']: + if not shutil.which(tool): + parser.error('host prerequisite absent: ' + tool) + spec = importlib.util.spec_from_file_location('p6_vm_owner', args.vm_owner) + owner = importlib.util.module_from_spec(spec) + spec.loader.exec_module(owner) + transport_spec = importlib.util.spec_from_file_location('p6_guest_result_transport', transport_file) + transport_owner = importlib.util.module_from_spec(transport_spec) + sys.modules[transport_spec.name] = transport_owner + transport_spec.loader.exec_module(transport_owner) + preflight = subprocess.run(['sudo', '-n', 'python3', str(args.vm_owner.parent / 'kvm-preflight.py')], + capture_output=True, text=True, timeout=30, check=True) + kvm = json.loads(preflight.stdout) + if kvm.get('pass') is not True: + parser.error('current host privileged KVM preflight did not pass') + work.mkdir(parents=True, exist_ok=False) + transport = transport_owner.prepare_result_transport(work) + payload = work / 'payload' + payload.mkdir() + shutil.copytree(artifact, payload / 'artifact', symlinks=True) + if digest(payload / 'artifact/openclaw') != args.binary_sha256: + raise RuntimeError('Copied application differs from admitted binary') + here = Path(__file__).resolve().parent + for name in ['guest-cli.py', 'trace-policy.py', 'memory-policy.py']: + shutil.copy2(here / name, payload / name) + shutil.copytree(here / 'security', payload / 'security') + controls = work / 'control-build' + controls.mkdir() + cc = shutil.which('cc', path='/usr/bin:/bin') + if not cc: + raise RuntimeError('Native fixture C compiler is absent; no application result') + control_commands = [] + for source, library in [('mdwe.c', 'libp6mdwe.so'), ('file-exec.c', 'libp6fileexec.so')]: + command = [cc, '-shared', '-fPIC', '-O2', '-DP6_LIBRARY', str(payload / 'security' / source), '-o', str(payload / 'security' / library)] + control_commands.append(command) + with (controls / (source + '.log')).open('wb') as output: + subprocess.run(command, stdout=output, stderr=subprocess.STDOUT, timeout=60, check=True, env={'PATH':'/usr/bin:/bin','TMPDIR':str(controls),'LANG':'C.UTF-8'}) + control_receipt = {'status':'native-x64-fixtures-built-not-app-proof','compiler':cc,'compilerSha256':digest(cc),'commands':control_commands,'sha256':{str(file.relative_to(payload / 'security')):digest(file) for file in (payload / 'security').rglob('*') if file.is_file()}} + (controls / 'result.json').write_text(json.dumps(control_receipt, indent=2)+'\n') + nonce = 'p6-app-' + args.variant + '-' + secrets.token_hex(8) + manifest = {'nonce': nonce, 'variant': args.variant, 'mainSha': args.main_sha, + 'binarySha256': args.binary_sha256, 'admissionReceiptSha256': admission_sha, + 'artifactManifestSha256': digest(artifact / 'manifest.json'), + 'expectedStdout': args.expected_stdout, 'controlFiles':control_receipt['sha256'], 'prerequisitesSha256':args.prerequisites_sha256, + 'expectedMdwe': 1 if args.variant == 'c2-linux-hardened' else 3} + (payload / 'manifest.json').write_text(json.dumps(manifest, indent=2) + '\n') + payload_image = work / 'payload.ext4' + size = sum(file.stat().st_size for file in payload.rglob('*') if file.is_file()) + with payload_image.open('wb') as stream: + stream.truncate(((size + 128 * 1024**2) // (64 * 1024**2) + 1) * 64 * 1024**2) + subprocess.run(['mkfs.ext4', '-q', '-F', '-L', 'P6APP', '-d', str(payload), str(payload_image)], check=True) + config = {'datasource_list': ['NoCloud'], 'ssh_pwauth': False, 'disable_root': True, 'users': [], + 'ssh_deletekeys': True, 'ssh_genkeytypes': [], 'ssh_publish_hostkeys': {'enabled': False}, + 'bootcmd': [['touch', '/etc/ssh/sshd_not_to_be_run']], 'network': {'config': 'disabled'}, + 'runcmd': [['bash', '-c', 'exec >/var/tmp/p6-launch.log 2>&1; set -eu; udevadm settle --timeout=30; mkdir -p /mnt/p6; mount -o ro,nodev,nosuid /dev/disk/by-label/P6APP /mnt/p6; ' + transport.guest_redirect + '; python3 /mnt/p6/guest-cli.py']], + 'power_state': {'mode': 'poweroff', 'delay': 'now', 'timeout': 30, 'condition': True}} + (work / 'user-data').write_text('#cloud-config\n' + json.dumps(config, indent=2) + '\n') + (work / 'meta-data').write_text(json.dumps({'instance-id': nonce, 'local-hostname': 'p6-app-synthetic'}) + '\n') + seed, overlay = work / 'seed.img', work / 'guest.qcow2' + subprocess.run(['cloud-localds', str(seed), str(work / 'user-data'), str(work / 'meta-data')], check=True) + subprocess.run(['qemu-img', 'create', '-f', 'qcow2', '-F', 'qcow2', '-b', str(args.image.resolve()), str(overlay)], check=True) + subprocess.run(['qemu-img', 'resize', str(overlay), '8G'], check=True) + command = ['sudo', '-n', 'env', '-i', 'PATH=/usr/sbin:/usr/bin:/sbin:/bin', 'timeout', '--signal=TERM', '--kill-after=5s', '600s', + 'qemu-system-x86_64', '-accel', 'kvm', '-cpu', 'host', '-smp', '2', '-m', '4096', '-display', 'none', '-monitor', 'none', + '-pidfile', str(work / 'qemu.pid'), *transport.qemu_args, + '-qmp', 'unix:' + str(work / 'qmp.sock') + ',server=on,wait=off', '-no-reboot', '-nic', 'none', + '-drive', 'file=' + str(overlay) + ',if=virtio,format=qcow2', + '-drive', 'file=' + str(seed) + ',if=virtio,format=raw,readonly=on', + '-drive', 'file=' + str(payload_image) + ',if=virtio,format=raw,readonly=on'] + report = {**manifest, 'command': command, 'cloudImageSha256': IMAGE_SHA, 'vmOwnerSha256': OWNER_SHA, + 'guestResultTransportSha256': TRANSPORT_SHA, 'resultTransport': transport.metadata, + 'hostKvmPreflight': kvm, 'pass': False, 'applicationQualification': False, + 'scope': 'Actual application CLI/main-thread MDWE memory controls; Gateway, workers and performance remain separate.'} + owner.run_guest_vm(command, work, overlay, report) + for source, name in transport.artifacts: + shutil.copy2(source, work / name) + (work / 'application-guest-result.json').write_text(json.dumps(report, indent=2) + '\n') + print(json.dumps({'pass': report['pass'], 'result': str(work / 'application-guest-result.json')})) + return 0 if report['pass'] else 1 + + +if __name__ == '__main__': + raise SystemExit(main()) diff --git a/scripts/openclaw-p6/app/packet/payload/guest/application/security/file-exec.c b/scripts/openclaw-p6/app/packet/payload/guest/application/security/file-exec.c new file mode 100644 index 000000000000..28d8c58db662 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/application/security/file-exec.c @@ -0,0 +1,28 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#ifndef MFD_EXEC +#define MFD_EXEC 0x0010U +#endif +int p6_file_private_rx(void) { +#if defined(__aarch64__) + const uint32_t code[]={0x52800540,0xd65f03c0}; +#elif defined(__x86_64__) + const unsigned char code[]={0xb8,42,0,0,0,0xc3}; +#else +#error Unsupported architecture +#endif + int fd=memfd_create("p6-synthetic-code",MFD_CLOEXEC|MFD_EXEC); + if(fd<0) return -errno; + if(ftruncate(fd,4096)!=0 || write(fd,code,sizeof(code))!=(ssize_t)sizeof(code)) { + int e=errno; close(fd); return -e; + } + void *p=mmap(NULL,4096,PROT_READ|PROT_EXEC,MAP_PRIVATE,fd,0); + int e=errno; close(fd); + if(p==MAP_FAILED) return -e; + __builtin___clear_cache(p,(char*)p+sizeof(code)); + int result=((int(*)(void))p)(); munmap(p,4096); return result; +} diff --git a/scripts/openclaw-p6/app/packet/payload/guest/application/security/fixture/index.js b/scripts/openclaw-p6/app/packet/payload/guest/application/security/fixture/index.js new file mode 100644 index 000000000000..e0bbcd5c17d4 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/application/security/fixture/index.js @@ -0,0 +1,19 @@ +const { dlopen, FFIType } = require('bun:ffi'); +function probe() { + const first = dlopen('/mnt/p6/security/libp6mdwe.so', { + p6_get_mdwe:{args:[],returns:FFIType.i64}, + p6_try_exec:{args:[],returns:FFIType.i32}, + p6_try_rwx:{args:[],returns:FFIType.i32}, + }); + let row; + try { row={kind:'actual-application-plugin-main',isMainThread:require('node:worker_threads').isMainThread,pid:process.pid,executable:process.execPath,arch:process.arch,platform:process.platform,mdwe:Number(first.symbols.p6_get_mdwe()),rwToRx:first.symbols.p6_try_exec(),rwx:first.symbols.p6_try_rwx()}; } + finally { first.close(); } + const second=dlopen('/mnt/p6/security/libp6fileexec.so',{p6_file_private_rx:{args:[],returns:FFIType.i32}}); + try { row.filePrivateRx=second.symbols.p6_file_private_rx(); } + finally { second.close(); } + console.log('P6_MDWE_RESULT '+JSON.stringify(row)); + if(row.mdwe!==Number(process.env.P6_EXPECT_MDWE)||row.isMainThread!==true||row.rwToRx!==-13||row.rwx!==-13||row.filePrivateRx!==42) process.exitCode=1; +} +module.exports={id:'p6-mdwe-fixture',name:'P6 MDWE fixture',register(api){ + api.registerCli(({program})=>{program.command('p6-mdwe').description('Synthetic MDWE qualification').action(probe);},{descriptors:[{name:'p6-mdwe',description:'Synthetic MDWE qualification',hasSubcommands:false}]}); +}}; diff --git a/scripts/openclaw-p6/app/packet/payload/guest/application/security/fixture/openclaw.plugin.json b/scripts/openclaw-p6/app/packet/payload/guest/application/security/fixture/openclaw.plugin.json new file mode 100644 index 000000000000..5a81ff58eb8a --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/application/security/fixture/openclaw.plugin.json @@ -0,0 +1,7 @@ +{ + "id": "p6-mdwe-fixture", + "configSchema": { + "type": "object", + "properties": {} + } +} diff --git a/scripts/openclaw-p6/app/packet/payload/guest/application/security/fixture/package.json b/scripts/openclaw-p6/app/packet/payload/guest/application/security/fixture/package.json new file mode 100644 index 000000000000..27dadd2759f6 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/application/security/fixture/package.json @@ -0,0 +1,9 @@ +{ + "name": "@openclaw/p6-mdwe-fixture", + "version": "0.0.1", + "openclaw": { + "extensions": [ + "./index.js" + ] + } +} diff --git a/scripts/openclaw-p6/app/packet/payload/guest/application/security/mdwe.c b/scripts/openclaw-p6/app/packet/payload/guest/application/security/mdwe.c new file mode 100644 index 000000000000..681fedac3392 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/application/security/mdwe.c @@ -0,0 +1,55 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef PR_SET_MDWE +#define PR_SET_MDWE 65 +#define PR_GET_MDWE 66 +#define PR_MDWE_REFUSE_EXEC_GAIN 1 +#define PR_MDWE_NO_INHERIT 2 +#endif +long p6_get_mdwe(void) { errno=0; return prctl(PR_GET_MDWE, 0, 0, 0, 0); } +int p6_try_exec(void) { + void *p=mmap(NULL,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0); + if(p==MAP_FAILED) return -errno; +#if defined(__aarch64__) + const uint32_t code[]={0x52800540,0xd65f03c0}; +#elif defined(__x86_64__) + const unsigned char code[]={0xb8,42,0,0,0,0xc3}; +#else +#error Unsupported architecture +#endif + memcpy(p,code,sizeof(code)); + if(mprotect(p,4096,PROT_READ|PROT_EXEC)!=0){ int e=errno; munmap(p,4096); return -e; } + __builtin___clear_cache(p,(char*)p+sizeof(code)); + int answer=((int(*)(void))p)(); munmap(p,4096); return answer; +} +int p6_try_rwx(void) { + void *p=mmap(NULL,4096,PROT_READ|PROT_WRITE|PROT_EXEC,MAP_PRIVATE|MAP_ANONYMOUS,-1,0); + if(p==MAP_FAILED) return -errno; + munmap(p,4096); return 0; +} +#ifndef P6_LIBRARY +int main(int argc,char **argv){ + if(argc>1 && strcmp(argv[1],"no-inherit")==0){if(prctl(PR_SET_MDWE,3,0,0,0)!=0){perror("PR_SET_MDWE");return 2;}} + if(argc>1 && strcmp(argv[1],"inherit")==0){if(prctl(PR_SET_MDWE,1,0,0,0)!=0){perror("PR_SET_MDWE");return 2;}} + printf("{\"mdwe\":%ld,\"rw_to_rx\":%d,\"rwx\":%d}\n",p6_get_mdwe(),p6_try_exec(),p6_try_rwx()); fflush(stdout); + if(argc>2 && strcmp(argv[2],"child")==0){ + pid_t pid=fork(); + if(pid<0){perror("fork");return 2;} + if(pid==0){execl(argv[0],argv[0],NULL);_exit(127);} + int w; + pid_t waited; + do { waited=waitpid(pid,&w,0); } while(waited<0 && errno==EINTR); + if(waited!=pid){perror("waitpid");return 2;} + return WIFEXITED(w)?WEXITSTATUS(w):128+WTERMSIG(w); + } + return 0; +} +#endif diff --git a/scripts/openclaw-p6/app/packet/payload/guest/application/trace-policy.py b/scripts/openclaw-p6/app/packet/payload/guest/application/trace-policy.py new file mode 100644 index 000000000000..7c5d2211fd88 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/application/trace-policy.py @@ -0,0 +1,57 @@ +"""Read only the actual application's strace file; no policy is injected.""" +import hashlib +import json +import re + +BITS = {'PR_MDWE_REFUSE_EXEC_GAIN': 1, 'PR_MDWE_NO_INHERIT': 2} + + +def value(text): + token = text.strip().split(' /*', 1)[0].split(' (', 1)[0].strip() + result = 0 + for part in token.split('|'): + part = part.strip() + try: + result |= BITS[part] if part in BITS else int(part, 0) + except ValueError: + raise ValueError('Unrecognized MDWE value: ' + token) from None + return result + + +def analyze(traces, binary, expected): + execution = re.compile(r'^execve\(' + re.escape(json.dumps(binary)) + r',.*\)\s+=\s+0$') + roots = [(name, text) for name, text in traces.items() + if any(execution.match(line) for line in text.splitlines())] + if len(roots) != 1: + raise ValueError('Expected one trace of the direct application execve') + name, text = roots[0] + if not re.search(r'^\+\+\+ exited with 0 \+\+\+$', text, re.M): + raise ValueError('Application trace lacks a successful terminal exit') + observations = [] + for line in text.splitlines(): + match = re.match(r'^prctl\(PR_(GET|SET)_MDWE(?:,\s*(.*))?\)\s+=\s+(.+)$', line) + if not match: + continue + kind, arguments, returned = match.groups() + if returned.startswith('-1 '): + observations.append({'kind': kind, 'success': False, 'line': line}) + continue + row = {'kind': kind, 'success': True, 'returnValue': value(returned), 'line': line} + if kind == 'SET': + row['bits'] = value(arguments.split(',', 1)[0]) + observations.append(row) + sets = [index for index, row in enumerate(observations) + if row['kind'] == 'SET' and row['success'] and row['returnValue'] == 0 and row['bits'] == expected] + if len(sets) != 1: + raise ValueError('Expected one successful application PR_SET_MDWE for the admitted bits') + position = sets[0] + before = [row['returnValue'] for row in observations[:position] if row['kind'] == 'GET' and row['success']] + after = [row['returnValue'] for row in observations[position + 1:] if row['kind'] == 'GET' and row['success']] + if not before or before[-1] != 0: + raise ValueError('Application did not observe an unenforced MDWE baseline before its SET') + if any(bits != expected for bits in after): + raise ValueError('A post-SET application PR_GET_MDWE differs from the requested bits') + return {'trace': name, 'traceSha256': hashlib.sha256(text.encode()).hexdigest(), + 'requestedBits': expected, 'successfulSet': True, 'getBefore': before, + 'getAfter': after, 'observations': observations, + 'scope': 'Direct application CLI requested MDWE and the kernel accepted it; no injected GET or memory-mapping probe.'} diff --git a/scripts/openclaw-p6/app/packet/payload/guest/collect-evidence.py b/scripts/openclaw-p6/app/packet/payload/guest/collect-evidence.py new file mode 100644 index 000000000000..5e1274fe0d39 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/collect-evidence.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +"""Preserve complete existing guest outputs; never rerun a guest or trim traces.""" +import argparse,hashlib,json,re,tarfile +from pathlib import Path + +def sha(p): + with p.open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest() + +def main(): + p=argparse.ArgumentParser(description=__doc__);p.add_argument('--work',type=Path,required=True);p.add_argument('--proof',type=Path,required=True);p.add_argument('--input-proof',type=Path,required=True);a=p.parse_args() + inputs=json.loads(a.input_proof.read_text());a.proof.mkdir(parents=True,exist_ok=False) + result={'status':'failed-no-native-result','applicationQualified':False,'scope':inputs['scope'],'sourceCommit':inputs['sourceCommit'],'binarySha256':inputs['binarySha256'],'rootBuildAdmissionSha256':inputs['rootBuildAdmissionSha256'],'inputProofSha256':sha(a.input_proof),'work':str(a.work),'traceCount':0} + files=[a.input_proof];report_path=a.work/'application-guest-result.json' + if report_path.is_file(): + report=json.loads(report_path.read_text());guest=report.get('guest',{}) + result.update(status='collected-main-memory-policy-pass' if report.get('pass') is True and guest.get('pass') is True else 'collected-main-memory-policy-failed',guestKernel=guest.get('kernel'),variant=report.get('variant'),nonce=report.get('nonce')) + traces=guest.get('traces',{}) + if traces: + directory=a.work/'raw-traces';directory.mkdir(exist_ok=False) + for name,content in traces.items(): + if not re.fullmatch(r'(?:app|version)\.trace\.\d+',name) or not isinstance(content,str):raise ValueError('Unexpected raw trace entry') + path=directory/name;path.write_bytes(content.encode());files.append(path) + result['traceCount']=len(traces) + policy=guest.get('policy',{});selected=directory/policy.get('trace','absent') + if result['status']=='collected-main-memory-policy-pass' and (not selected.is_file() or sha(selected)!=policy.get('traceSha256')):raise ValueError('Selected raw trace hash mismatch') + for extra in sorted((a.work/'control-build').glob('*')): + if extra.is_file():files.append(extra) + for name in ['application-guest-result.json','vm-result.json','guest-result-stream.log','guest-boot-console.log','serial.log','boot-console.log','qemu.log','qmp.stdout','qmp.stderr']: + file=a.work/name + if file.is_file():files.append(file) + if a.work.is_dir(): + archive=a.work/'evidence.tar' + if archive.exists():raise ValueError('Evidence archive already exists') + index=a.work/'evidence-index.json';index.write_text(json.dumps({str(file):sha(file) for file in files},indent=2)+'\n');files.append(index) + with tarfile.open(archive,'w') as tar: + for file in files:tar.add(file,arcname='input-proof.json' if file==a.input_proof else str(file.relative_to(a.work)),recursive=False) + result.update(archive=str(archive),archiveSha256=sha(archive),archiveBytes=archive.stat().st_size) + (a.proof/'receipt.json').write_text(json.dumps(result,indent=2)+'\n');print(json.dumps(result,indent=2)) + +if __name__=='__main__':main() diff --git a/scripts/openclaw-p6/app/packet/payload/guest/guest-prerequisites.py b/scripts/openclaw-p6/app/packet/payload/guest/guest-prerequisites.py new file mode 100644 index 000000000000..bf0304025795 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/guest-prerequisites.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +"""Guest tools/image only; no compiler, LLVM, app, VM or carrier action.""" +import argparse,hashlib,json,os,platform,shutil,subprocess,tempfile +from pathlib import Path +IMAGE_SHA='04e8f2461a16a44e78a370284471f29616cdd9baf1893df25807b71f985b6c94' +URL='https://cloud-images.ubuntu.com/releases/noble/release-20261017/ubuntu-24.04-server-cloudimg-amd64.img' +TOOLS=['qemu-system-x86_64','qemu-img','cloud-localds','mkfs.ext4','timeout','sudo'] +def sha(p): + with Path(p).open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest() +def main(): + p=argparse.ArgumentParser(description=__doc__);p.add_argument('--out',type=Path,required=True);p.add_argument('--install-and-download',action='store_true');a=p.parse_args() + if platform.system()!='Linux' or platform.machine()!='x86_64':p.error('Native Linux x64 required') + os.umask(0o077);root=Path.home()/'.cache/oc-ty-ext/P6';image=root/'cb-x64-final-toolchain-input/ubuntu-24.04-release-20261017-amd64.img' + if a.out.exists() or not a.out.resolve().is_relative_to(root.resolve()):p.error('Fresh task-owned prerequisite receipt directory required') + a.out.mkdir(parents=True) + result={'status':'inventory-only-not-ready','applicationQualified':False,'performanceEligible':False,'image':str(image),'imageUrl':URL,'expectedImageSha256':IMAGE_SHA,'packages':['qemu-system-x86','qemu-utils','cloud-image-utils','e2fsprogs'],'compilerSetupRequired':False} + try: + if a.install_and_download: + env={'PATH':'/usr/sbin:/usr/bin:/sbin:/bin','HOME':str(Path.home()),'TMPDIR':str(root/'guest-prerequisites-tmp'),'DEBIAN_FRONTEND':'noninteractive','LANG':'C.UTF-8'};Path(env['TMPDIR']).mkdir(parents=True,exist_ok=True) + with (a.out/'apt.log').open('wb') as log: + for command in [['sudo','-n','apt-get','update'],['sudo','-n','apt-get','install','-y','--no-install-recommends',*result['packages']]]:subprocess.run(command,env=env,stdout=log,stderr=subprocess.STDOUT,check=True) + image.parent.mkdir(parents=True,exist_ok=True) + if image.is_symlink():raise ValueError('Image symlink refused') + if not image.exists(): + with tempfile.TemporaryDirectory(prefix='guest-image-',dir=image.parent) as directory: + temporary=Path(directory)/'download.img' + with (a.out/'download.log').open('wb') as log:subprocess.run(['curl','-fL','--retry','2','--connect-timeout','30','--max-time','1800','-o',str(temporary),URL],stdout=log,stderr=subprocess.STDOUT,check=True) + if sha(temporary)!=IMAGE_SHA:raise ValueError('Pinned cloud image hash mismatch') + os.link(temporary,image) + result['tools']={} + for name in TOOLS: + path=shutil.which(name) + result['tools'][name]={'path':path,'sha256':sha(path) if path else None} + if image.is_file() and not image.is_symlink():result['imageSha256']=sha(image) + if not all(x['path'] for x in result['tools'].values()) or result.get('imageSha256')!=IMAGE_SHA:raise ValueError('QEMU/image prerequisites incomplete') + packages=subprocess.run(['dpkg-query','-W','-f=${Package}\t${Version}\n',*result['packages']],capture_output=True,text=True,check=True);(a.out/'packages.tsv').write_text(packages.stdout) + result['packageInventorySha256']=sha(a.out/'packages.tsv') + for name in ['qemu-system-x86_64','qemu-img']: + version=subprocess.run([result['tools'][name]['path'],'--version'],capture_output=True,text=True,check=True);(a.out/(name+'-version.txt')).write_text(version.stdout+version.stderr) + result['status']='guest-prerequisites-present-not-kvm-qualified' + except Exception as error:result['error']=str(error) + (a.out/'result.json').write_text(json.dumps(result,indent=2)+'\n');print(json.dumps(result,indent=2)) + return 0 if result['status']=='guest-prerequisites-present-not-kvm-qualified' else 1 +if __name__=='__main__':raise SystemExit(main()) diff --git a/scripts/openclaw-p6/app/packet/payload/guest/manifest.json b/scripts/openclaw-p6/app/packet/payload/guest/manifest.json new file mode 100644 index 000000000000..238e7fbc9dec --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/manifest.json @@ -0,0 +1,22 @@ +{ + "files": { + "application/guest-cli.py": "9259fd3e518356cbc0a4e0ddabc8b1eba5dc1209b3dbb10d424a7b6fc7ddb741", + "application/memory-policy.py": "4ff6f0e9b1d84928115e4af7755359f74f501ef92b30999a6f3d2faada6ba1dc", + "application/run-application-guest.py": "faeb6a65aa52c8ac5943768c2148bf5d5115b93a090c1a4ec03cff9f63cf5a37", + "application/security/file-exec.c": "8d0707b88f72203b69e7b03e52887992eca12df2bd104dd27fca3ef3281aa2d5", + "application/security/fixture/index.js": "ea5c5fbceda9a536c64ef2c8a4509277b6aca2bf882307f865fa557beb6b171b", + "application/security/fixture/openclaw.plugin.json": "2d6cf08b7d9cd6c594ad2c8c1e8309748ca5ec5a864e5e2c667f40b87a18947f", + "application/security/fixture/package.json": "a00af8e500465b4ba10a1ccffd28f81b1ed049c4d9ce1a9030b011e0569ac5fb", + "application/security/mdwe.c": "02a21f72749fa26429ccbec58eb23bae65952d9db2dfedf389cab73c06b3de1b", + "application/trace-policy.py": "04a1558c00ccb2be9d87f4c0748ef253546ceb87f5727d38f3ac406a882e8963", + "collect-evidence.py": "59a49d27f372b4f2bce4c7ad95b00bcc01708ea59fb17acf857d4c15c233a652", + "guest-prerequisites.py": "463a6cc56a7de19a49bc873cd630a7da28082337ab7f340809c43f4b2604050c", + "prepare-guest.py": "47922a51d8512cd3f88c2d88d66a69574f5f1dd08bcdf437e2e5c4da06abe1d1", + "shared/guest_result_transport.py": "1e0d155a7827e3fa44e3c377d935001a3db6f6546cdc397fa909c86be4dcdd7b", + "shared/kvm-preflight.py": "6ba9f17413342ddca66437bdb3c9b18d7c7357c1028470ebdebc689981e41ca5", + "shared/run-kvm-guest.py": "bca0eac25f6bd828f67c895c675fea6c8202583b1e6027f6a83f22212860ab42" + }, + "originalOwnersUnchanged": true, + "unchangedOwnerCount": 4, + "versionedApplicationAdapters": true +} diff --git a/scripts/openclaw-p6/app/packet/payload/guest/prepare-guest.py b/scripts/openclaw-p6/app/packet/payload/guest/prepare-guest.py new file mode 100644 index 000000000000..6c5597f28e12 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/prepare-guest.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 +"""Validate actual app inputs and render the immutable guest owner command only.""" +import argparse,base64,hashlib,json,platform,re,shlex,subprocess,sys +from pathlib import Path +HERE=Path(__file__).resolve().parent +CUT='670a7ab33bbd2e3ed4f0a5681e138159d74540a1' +ROOT=Path('/home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1') +QUALIFIER_SHA='62cb7bc09d40be522aa14fcac1b3db1e448032d296909a589bf5ef8b95c47f13' + +def sha(p): + with Path(p).open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest() +def load(p):return json.loads(Path(p).read_text()) +def need(value,message): + if not value:raise ValueError(message) + +def main(): + p=argparse.ArgumentParser(description=__doc__) + for flag in ['artifact','build-receipt','root-admission','host-core-result']:p.add_argument('--'+flag,type=Path,required=True) + for flag in ['binary-sha256','manifest-sha256','build-receipt-sha256','root-admission-sha256','host-core-result-sha256']:p.add_argument('--'+flag,required=True) + p.add_argument('--prerequisites',type=Path,required=True);p.add_argument('--prerequisites-sha256',required=True) + p.add_argument('--label',required=True);a=p.parse_args() + need(sys.version_info >= (3,12),'Python3.12 or newer required') + need(platform.system()=='Linux' and platform.machine()=='x86_64','Native Linux x64 required') + need(re.fullmatch('[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}',a.label),'Safe fresh label required') + for value in [a.binary_sha256,a.manifest_sha256,a.build_receipt_sha256,a.root_admission_sha256,a.host_core_result_sha256,a.prerequisites_sha256]:need(re.fullmatch('[0-9a-f]{64}',value),'Actual full SHA256 required') + for name,expected in load(HERE/'manifest.json')['files'].items():need(sha(HERE/name)==expected,'Staged harness changed: '+name) + need(sha(a.root_admission)==a.root_admission_sha256,'Root build admission changed') + admission=load(a.root_admission);built=load(a.build_receipt) + need(admission.get('schemaVersion')==1 and admission.get('lane')=='P6' and admission.get('decision')=='build-linux','Explicit root P6 build admission required') + need(admission['linuxCut']['commit']==CUT and admission['linuxCut']['status']=='landed-main' and admission['source']==str(ROOT/'source'),'Wrong root source admission') + need(sha(a.build_receipt)==a.build_receipt_sha256,'Actual build receipt changed') + need(built.get('status')=='built-unsigned' and built.get('phase')=='complete','Successful actual build required') + need(built['plan']['admissionSha256']==a.root_admission_sha256,'Build is not bound to root admission') + need(str(a.artifact.resolve())==admission['output']==built['plan']['output'],'Different actual admitted artifact') + variant={'js':'js-aot','c2':'c2','ts':'ts-aot','strong':'c2-linux-hardened'}[admission['variant']] + qualifier=ROOT/'qualification/qualify.py';need(sha(qualifier)==QUALIFIER_SHA,'Reviewed qualification v3 required') + work=ROOT/'application-guest-runs'/a.label;need(not work.exists(),'Fresh guest work required') + # Reuse the actual-artifact/source/runtime validator without running any workload. + command=[sys.executable,str(qualifier),'--artifact',str(a.artifact),'--binary-sha256',a.binary_sha256,'--manifest-sha256',a.manifest_sha256,'--build-receipt',str(a.build_receipt),'--build-receipt-sha256',a.build_receipt_sha256,'--lane','core','--out',str(ROOT/'qualification-results'/('guest-input-'+a.label))] + checked=subprocess.run(command,check=True,capture_output=True,text=True,env={'HOME':str(Path.home()),'PATH':'/usr/bin:/bin','LANG':'C.UTF-8'}) + proof=json.loads(checked.stdout);need(proof['mode']=='aot','Actual AOT app required') + need(sha(a.host_core_result)==a.host_core_result_sha256,'Host version result changed') + host=load(a.host_core_result) + need(host['binarySha256']==a.binary_sha256 and host['artifact']==str(a.artifact.resolve()) and host['source']==str(ROOT/'source') and host['platform']=='linux' and host['arch']=='x64','Host version identity differs') + rows=[r for r in host['commands'] if r['label']=='version'];need(len(rows)==1,'Exactly one actual host version command required');row=rows[0] + need(row['command']==[str(a.artifact.resolve()/'openclaw'),'--version'] and row['code']==0 and row.get('spawnError') is None,'Host version command did not succeed') + stdout=a.host_core_result.parent/'logs/version.stdout';need(Path(row['stdout'])==stdout,'Unexpected host version stdout path') + raw=stdout.read_text();need(0&2; exit 1; }; exit "$rc"; }\ntrap collect EXIT\n'+shlex.join(guest)+'\n' + out['guestShell']=body + print(json.dumps(out,indent=2)) + +if __name__=='__main__':main() diff --git a/scripts/openclaw-p6/app/packet/payload/guest/shared/guest_result_transport.py b/scripts/openclaw-p6/app/packet/payload/guest/shared/guest_result_transport.py new file mode 100644 index 000000000000..3ec81e806818 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/shared/guest_result_transport.py @@ -0,0 +1,26 @@ +"""Non-TTY guest result transport; run_guest_vm keeps its serial.log contract.""" +from dataclasses import dataclass +from pathlib import Path + +@dataclass(frozen=True) +class GuestResultTransport: + qemu_args: list[str] + guest_redirect: str + metadata: dict[str, str] + artifacts: tuple[tuple[Path, str], ...] + +def prepare_result_transport(work: Path) -> GuestResultTransport: + port='org.openclaw.p6.result' + result=work/'serial.log' + console=work/'boot-console.log' + for path in [result,console]: path.touch(mode=0o600,exist_ok=False) + return GuestResultTransport( + qemu_args=['-serial','file:'+str(console),'-device','virtio-serial-pci', + '-chardev','file,id=p6-result,path='+str(result), + '-device','virtserialport,chardev=p6-result,name='+port], + guest_redirect='test -c /dev/virtio-ports/'+port+'; exec >/dev/virtio-ports/'+port+' 2>&1', + metadata={'kind':'virtio-serial/non-TTY','vmOwnerReceiveFile':'serial.log', + 'resultArtifact':'guest-result-stream.log','bootConsoleArtifact':'guest-boot-console.log', + 'guestPort':port}, + artifacts=((result,'guest-result-stream.log'),(console,'guest-boot-console.log')), + ) diff --git a/scripts/openclaw-p6/app/packet/payload/guest/shared/kvm-preflight.py b/scripts/openclaw-p6/app/packet/payload/guest/shared/kvm-preflight.py new file mode 100644 index 000000000000..e40558ff62ed --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/shared/kvm-preflight.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +import fcntl,json,os,platform +result={'arch':platform.machine(),'kernel':platform.release(),'kvmDevice':'/dev/kvm','effectiveUid':os.geteuid(),'vmStarted':False} +fd=None +vm=None +try: + fd=os.open('/dev/kvm',os.O_RDWR|os.O_CLOEXEC) + result['apiVersion']=fcntl.ioctl(fd,0xAE00,0) + if result['apiVersion']!=12: raise RuntimeError('Unsupported KVM API version') + vm=fcntl.ioctl(fd,0xAE01,0) + result['emptyVmCreated']=vm>=0 + os.close(vm);vm=None + result['emptyVmClosed']=True + result['pass']=True +except (OSError,RuntimeError) as error: + result['pass']=False;result['error']=str(error) +finally: + if vm is not None: os.close(vm) + if fd is not None: os.close(fd) +print(json.dumps(result),flush=True) +raise SystemExit(0 if result['pass'] else 1) diff --git a/scripts/openclaw-p6/app/packet/payload/guest/shared/run-kvm-guest.py b/scripts/openclaw-p6/app/packet/payload/guest/shared/run-kvm-guest.py new file mode 100644 index 000000000000..728077e01ad2 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/guest/shared/run-kvm-guest.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python3 +"""Run the synthetic x64 compiler suite in an offline, hardware-accelerated guest.""" +from pathlib import Path +import hashlib,json,os,platform,secrets,shutil,signal,subprocess,sys,time + +QMP_SCRIPT="import json,socket,sys\ns=socket.socket(socket.AF_UNIX,socket.SOCK_STREAM);s.settimeout(5);s.connect(sys.argv[1]);f=s.makefile('rwb',buffering=0)\ngreeting=json.loads(f.readline())\ndef command(name,number):\n f.write((json.dumps({'execute':name,'id':number})+'\\n').encode())\n while True:\n response=json.loads(f.readline())\n if response.get('id')==number:return response\ncommand('qmp_capabilities',1)\nresult=command('query-kvm',2)\nprint(json.dumps({'greeting':greeting,'queryKvm':result}))\ns.close()" + +class GuestInterrupted(Exception): + def __init__(self, signum): + self.signum=signum + super().__init__('Interrupted by '+signal.Signals(signum).name) + +def privileged_python(code, *args): + prefix=[sys.executable] if os.geteuid()==0 else ['sudo','-n','python3'] + return [*prefix,'-c',code,*map(str,args)] + +def run_guest_vm(command, work, overlay, report): + """Own the VM process through interruption, cleanup, and a durable result.""" + work=Path(work) + serial=work/'serial.log';qmp=work/'qmp.sock';pidfile=work/'qemu.pid' + state={'signal':None,'cleaning':False} + previous={} + child=None + def interrupted(signum, frame): + state['signal']=state['signal'] or signum + if not state['cleaning']: raise GuestInterrupted(signum) + qmp_script=QMP_SCRIPT + try: + for signum in [signal.SIGINT,signal.SIGTERM,signal.SIGHUP]: + previous[signum]=signal.signal(signum,interrupted) + with (work/'qemu.log').open('wb') as output: + child=subprocess.Popen(command,stdin=subprocess.DEVNULL,stdout=output,stderr=subprocess.STDOUT) + deadline=time.monotonic()+30 + while not qmp.exists() and child.poll() is None and time.monotonic()/dev/ttyS0 2>&1; set -eu; udevadm settle --timeout=30; mkdir -p /mnt/p6; mount -o ro,nodev,nosuid /dev/disk/by-label/P6PAYLOAD /mnt/p6; python3 /mnt/p6/guest-run.py']], + 'power_state':{'mode':'poweroff','delay':'now','timeout':30,'condition':True}} + user_data=work/'user-data';user_data.write_text('#cloud-config\n'+json.dumps(config,indent=2)+'\n') + meta_data=work/'meta-data';meta_data.write_text(json.dumps({'instance-id':nonce,'local-hostname':'p6-aot-synthetic'})+'\n') + seed=work/'seed.img' + subprocess.run(['cloud-localds',str(seed),str(user_data),str(meta_data)],check=True) + overlay=work/'guest.qcow2' + subprocess.run(['qemu-img','create','-f','qcow2','-F','qcow2','-b',str(image),str(overlay)],check=True) + subprocess.run(['qemu-img','resize',str(overlay),'8G'],check=True) + serial=work/'serial.log';serial.touch(mode=0o600,exist_ok=False) + qmp=work/'qmp.sock';pidfile=work/'qemu.pid' + command=['sudo','-n','env','-i','PATH=/usr/sbin:/usr/bin:/sbin:/bin','timeout','--signal=TERM','--kill-after=5s','600s','qemu-system-x86_64','-accel','kvm','-cpu','host','-smp','2','-m','4096','-display','none','-monitor','none','-pidfile',str(pidfile),'-serial','file:'+str(serial),'-qmp','unix:'+str(qmp)+',server=on,wait=off','-no-reboot','-nic','none','-drive','file='+str(overlay)+',if=virtio,format=qcow2','-drive','file='+str(seed)+',if=virtio,format=raw,readonly=on','-drive','file='+str(payload_image)+',if=virtio,format=raw,readonly=on'] + report={'nonce':nonce,'command':command,'cloudImage':{'url':url,'sha256':digest},'compilerSha256':compiler_sha,'hostKvmPreflight':preflight_result,'pass':False,'applicationQualification':False} + report=run_guest_vm(command,work,overlay,report) + for name in ['serial.log','qemu.log','qmp.stdout','qmp.stderr']: + if (work/name).exists(): shutil.copy2(work/name,proof/('guest-'+name)) + (proof/'guest-result.json').write_text(json.dumps(report,indent=2)+'\n') + print('P6_KVM_GUEST_RESULT '+json.dumps(report),flush=True) + return 0 if report['pass'] else 1 + +if __name__=='__main__': raise SystemExit(main()) diff --git a/scripts/openclaw-p6/app/packet/payload/manifest.json b/scripts/openclaw-p6/app/packet/payload/manifest.json new file mode 100644 index 000000000000..0d8a9d29864b --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/manifest.json @@ -0,0 +1,61 @@ +{ + "sourceCommit": "670a7ab33bbd2e3ed4f0a5681e138159d74540a1", + "status": "prepared-not-admitted", + "nativeCompilerHashes": "pending", + "applicationBuilt": false, + "files": { + "admission-inputs/P0-artifacts.json": "220560f5474dbb93266d2fdcb23b93fecf46728778becdf54b5cda578f544e18", + "admission-inputs/p0-reference.json": "9c068ecfb5343e80c268892caa4e78644fe73b2fff9a069a619cd66fc9da6fc0", + "admission-inputs/source-preparation.json": "3a233e951847951410670bfb6cd859b8cf8aa3f946a863dd8835d3bd3cd08ca1", + "admission-templates/c2-off.json": "5b382c423a42ba88d7121a46d92a445e35312ab867ebd3b024ec8de3d6cc5a06", + "admission-templates/js.json": "70e6c113167dc2d410b0e83ee79ce762bc0112cbe69370d90f9ea52eafb4f4ca", + "admission-templates/ts.json": "fef0d8e5faf99fef129efb66d8d1d1a2d54bd6a6cf2ed888c77ed3f6801d5132", + "adopt-compilers.py": "8f4e0d8b7b118c2c125515a3724e1a27a82880f969d49d4c03bd2e3d139f6312", + "build-prep/artifact-contract.mjs": "bac5e4b00d4a457941c1d2082f280d4dca544b3c77e4fe9a6a47f9f399d669b7", + "build-prep/build-linux.py": "b8cf6d97f60b4680dce980a7a9cf53288fb995c8f047a64f9226706127d1214b", + "build-prep/select-plugins.mjs": "14b4a6c3ca1415fcf31bd3f1d71f1e33dff4e4ba1290b09fa929652121199ee9", + "cron-fixture/cron-cli-fixture.sh": "958adbfa641e24736306fd23a5cb3a5e2bfda2c4502889ca593c33da368be4a2", + "cron-fixture/inputs.json": "068059745aeca4ec0d3b39578f48e8b3ae6af87e8ff86743339fb613fa0ac983", + "cron-fixture/run-native.sh": "1683c8b8710b2ecbd1c80108b2d43f833b4cc7318add99491f69b5ebe72560b0", + "guest/application/guest-cli.py": "9259fd3e518356cbc0a4e0ddabc8b1eba5dc1209b3dbb10d424a7b6fc7ddb741", + "guest/application/memory-policy.py": "4ff6f0e9b1d84928115e4af7755359f74f501ef92b30999a6f3d2faada6ba1dc", + "guest/application/run-application-guest.py": "faeb6a65aa52c8ac5943768c2148bf5d5115b93a090c1a4ec03cff9f63cf5a37", + "guest/application/security/file-exec.c": "8d0707b88f72203b69e7b03e52887992eca12df2bd104dd27fca3ef3281aa2d5", + "guest/application/security/fixture/index.js": "ea5c5fbceda9a536c64ef2c8a4509277b6aca2bf882307f865fa557beb6b171b", + "guest/application/security/fixture/openclaw.plugin.json": "2d6cf08b7d9cd6c594ad2c8c1e8309748ca5ec5a864e5e2c667f40b87a18947f", + "guest/application/security/fixture/package.json": "a00af8e500465b4ba10a1ccffd28f81b1ed049c4d9ce1a9030b011e0569ac5fb", + "guest/application/security/mdwe.c": "02a21f72749fa26429ccbec58eb23bae65952d9db2dfedf389cab73c06b3de1b", + "guest/application/trace-policy.py": "04a1558c00ccb2be9d87f4c0748ef253546ceb87f5727d38f3ac406a882e8963", + "guest/collect-evidence.py": "59a49d27f372b4f2bce4c7ad95b00bcc01708ea59fb17acf857d4c15c233a652", + "guest/guest-prerequisites.py": "463a6cc56a7de19a49bc873cd630a7da28082337ab7f340809c43f4b2604050c", + "guest/manifest.json": "0db9d11a46d8f746ce4600728cf48331b9f04230f3c87858046b829dee2f2d1a", + "guest/prepare-guest.py": "47922a51d8512cd3f88c2d88d66a69574f5f1dd08bcdf437e2e5c4da06abe1d1", + "guest/shared/guest_result_transport.py": "1e0d155a7827e3fa44e3c377d935001a3db6f6546cdc397fa909c86be4dcdd7b", + "guest/shared/kvm-preflight.py": "6ba9f17413342ddca66437bdb3c9b18d7c7357c1028470ebdebc689981e41ca5", + "guest/shared/run-kvm-guest.py": "bca0eac25f6bd828f67c895c675fea6c8202583b1e6027f6a83f22212860ab42", + "measure-command.py": "373b56ced3b931233bc15a1d97c634f486602b3c9e5a02d75e0688d2f5552a5a", + "native-prep.py": "161d1732a7569dc695854574e24dfcf2981e6724f0e126ee81cbe6396eb483c8", + "preserve.py": "c4bf1af86d21050f6d7f9c4b801017de18ac50ba35f8eda8179e00c88e2575ca", + "qualification/README.md": "9853f67d28ba0e9cff3b274dd7cab73ac7a6ccc55bd111431bae424106712640", + "qualification/docker-image.py": "5cc18ed7bf5d02fc0eed0d2688dba355e470e62fe7910b4a679eab0751c9a87a", + "qualification/harness/Dockerfile.aot": "f1f6c87b3e30bf319842b1d6ddc3d7ac27d46a51b766922bec0fe7e1896dbd4c", + "qualification/harness/analyze-workers.py": "ba2e5187c3dda4614c35e51aa6e0e1079840b372ecfa50cf8f2009804b008086", + "qualification/harness/analyze-zero-js.py": "cd5ac0436fa1ffeebcbaa4b760c93f2cdc94e31dfa4c26d9ca6529ac0d43a621", + "qualification/harness/aot-entry.mjs": "ccb32c3d2a895ed5a7bbf9a5966f38a0ea1e70e4b41e65d838285ef93f61510b", + "qualification/harness/capability-runner.mjs": "5606c0052b50be84903b270dcb9999cb1d0d75a61d8f4255be567424ead49563", + "qualification/harness/config-roundtrip.mjs": "511d9140896da1cff71e116a428a985b7d1f695bd07b0423afebac6f1601d6b0", + "qualification/harness/core-runner.mjs": "9bdd8d99f2ae2fa96a9cdf690e9ac37d034433bcc05d25ebe6fb1676e5f8ccfa", + "qualification/harness/elf-floor.py": "ec0a288f782b6786105f7801d62f32f2d44d23659655286008004fb59cbf2932", + "qualification/harness/fixture-config.mjs": "3cd13d2aeb10982bbda7198fbd6a451c57d24b184de5f07b892d67b63c3f5120", + "qualification/harness/gateway-readiness.mjs": "a007aa71fd55a888d0b159ee4ab51cc63a35492586c87769086d95a50e3d0759", + "qualification/harness/kitchen-sink-pin.json": "6e94c782845e34fcd4ded796d26202b7eb1d53bec1ff0dff3f62fa416f936af4", + "qualification/harness/legacy/capability-provider.mjs": "3b28c3bc5a5b892e2b14164a8633671c444257448dbfcfffd8812fc47a5301b4", + "qualification/harness/legacy/native_trace.py": "c1fda60c8a74b76811555ee895e1df0a5083951a53df38f35a7a18de8df15607", + "qualification/harness/openclaw-launcher": "fc343d0173e513aa7e74bfc1943d385beaab4ced57447ad7ea2023bdad2aee09", + "qualification/manifest.json": "12aa097ba29107d3cefe1c5df3367816b0695a7fd3573078784b88ccb0f80a7c", + "qualification/qualify.py": "62cb7bc09d40be522aa14fcac1b3db1e448032d296909a589bf5ef8b95c47f13", + "qualification/source-contract.json": "457efc17c28bbe8226ee512f55cea43c1ce8720ee48cfc2dba7ec221d97ef911", + "runtime-controller.py": "772fc60f2894c73ccc165b9b9c1e58c251abedea139d147628c31643a51d8940", + "stage.py": "1c95d9e5896bf9a0993c1819fae708d7dc4c9d355913b0dc0d87c6fec7773989" + } +} diff --git a/scripts/openclaw-p6/app/packet/payload/measure-command.py b/scripts/openclaw-p6/app/packet/payload/measure-command.py new file mode 100644 index 000000000000..ff23ea2f12d6 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/measure-command.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +"""Linux only; collect direct-executable wall/CPU/peak RSS without asserting application correctness.""" +import argparse, datetime, hashlib, json, os, pathlib, platform, signal, subprocess, time +p=argparse.ArgumentParser() +p.add_argument('--label',required=True) +p.add_argument('--out',required=True) +p.add_argument('--timeout',type=float,default=180) +p.add_argument('command',nargs=argparse.REMAINDER) +a=p.parse_args() +cmd=a.command[1:] if a.command[:1]==['--'] else a.command +if platform.system()!='Linux' or not cmd: p.error('requires Linux and a command after --') +out=pathlib.Path(a.out).resolve() +out.mkdir(parents=True,exist_ok=False) +timefile=out/'time.txt' +exe=pathlib.Path(cmd[0]) +receipt={'label':a.label,'at':datetime.datetime.now(datetime.timezone.utc).isoformat(), + 'arch':platform.machine(),'kernel':platform.release(),'command':cmd, + 'executableSha256':hashlib.file_digest(exe.open('rb'),'sha256').hexdigest() if exe.is_file() else None, + 'scope':'GNU time -v command plus reaped descendants; not exclusive gateway CPU'} +def signal_group(pgid, sig): + try: os.killpg(pgid,sig) + except ProcessLookupError: pass + +def stop_group(child, grace=5): + # GNU time may exit on TERM while its workload ignores it. Keep group custody + # for the full bounded grace, then send KILL independently of wrapper state. + signal_group(child.pid,signal.SIGTERM) + deadline=time.monotonic()+grace + while time.monotonic()=3.12 required') + if root!=Path.home()/'.cache/oc-ty-ext/P6/app-x64-final-r2-v1':p.error('Use the fresh owner root app-x64-final-r2-v1') + manifest=load(root/'manifest.json') + for name,expected in manifest['files'].items(): + if sha(root/name)!=expected:p.error('Staged input changed: '+name) + if shutil.disk_usage(root).free<25_000_000_000:p.error('Less than25GB free') + index=PHASES.index(a.phase) + if index and load(root/'prep-receipts'/PHASES[index-1]/'result.json')['status']!='PASS':p.error('Previous preparation phase must pass') + receipt=root/'prep-receipts'/a.phase;receipt.mkdir(parents=True,exist_ok=False) + source=root/'source';reference=load(root/'admission-inputs/source-preparation.json') + env={'HOME':str(root/'home'),'TMPDIR':str(root/'tmp'),'PATH':f'{root}/opt/node/bin:{root}/opt/bin:/usr/local/bin:/usr/bin:/bin','LANG':'C.UTF-8','LC_ALL':'C.UTF-8','CI':'1','NO_COLOR':'1','NODE_DISABLE_COMPILE_CACHE':'1','UV_THREADPOOL_SIZE':'2','XDG_CACHE_HOME':str(root/'cache'),'PNPM_HOME':str(root/'opt/bin'),'NPM_CONFIG_CACHE':str(root/'cache/npm'),'NPM_CONFIG_USERCONFIG':'/dev/null','NPM_CONFIG_GLOBALCONFIG':'/dev/null','GIT_CONFIG_GLOBAL':'/dev/null','GIT_CONFIG_SYSTEM':'/dev/null','GIT_TERMINAL_PROMPT':'0','GIT_ASKPASS':'/bin/false','SSH_ASKPASS':'/bin/false','OPENCLAW_STATE_DIR':str(root/'state'),'OPENCLAW_CONFIG_PATH':str(root/'state/openclaw.json'),'OPENCLAW_NO_RESPAWN':'1'} + for name in ['home','tmp','cache','state','downloads','opt']: (root/name).mkdir(exist_ok=True) + result={'phase':a.phase,'status':'FAIL','started':datetime.datetime.now(datetime.timezone.utc).isoformat(),'sourceCommit':CUT,'applicationBuildStarted':False,'aotAdmitted':False,'commands':[]} + node=root/'opt/node/bin/node';pnpm=root/'opt/pnpm/bin/pnpm.mjs' + def probe(args):return subprocess.check_output(list(map(str,args)),cwd=source,env=env,text=True,timeout=60).strip() + def source_ok(): + assert probe(['git','rev-parse','HEAD'])==CUT + assert not probe(['git','status','--porcelain','--untracked-files=no']) + for name,expected in reference['files'].items():assert sha(source/name)==expected,name + def run(label,command,cwd,timeout=3600): + result['commands'].append({'label':label,'command':list(map(str,command))}) + oldargv,oldenv,oldcwd=sys.argv,dict(os.environ),Path.cwd() + handlers={sig:signal.signal(sig,interrupted) for sig in [signal.SIGINT,signal.SIGTERM,signal.SIGHUP]} + try: + sys.argv=[str(root/'measure-command.py'),'--label',label,'--out',str(receipt/label),'--timeout',str(timeout),'--',*map(str,command)] + os.environ.clear();os.environ.update(env);os.chdir(cwd) + try:runpy.run_path(root/'measure-command.py',run_name='__main__') + except SystemExit as done: + if done.code not in [None,0]:raise RuntimeError(f'{label} failed with exit {done.code}') + finally: + os.chdir(oldcwd);os.environ.clear();os.environ.update(oldenv);sys.argv=oldargv + for sig,handler in handlers.items():signal.signal(sig,handler) + outer_handlers={sig:signal.signal(sig,interrupted) for sig in [signal.SIGINT,signal.SIGTERM,signal.SIGHUP]} + try: + if a.phase=='clone': + assert not source.exists() + run('clone',['/usr/bin/nice','-n','10','git','clone','--no-checkout','--depth=512','--single-branch','--branch','main','--no-tags','https://github.com/openclaw/openclaw.git',source],root,1800) + # Fetch the frozen cut explicitly as well, so main advancement cannot select a different checkout. + run('fetch-cut',['git','fetch','--depth=512','--no-tags','origin',CUT],source,1800) + run('checkout',['git','checkout','--detach',CUT],source,1800) + source_ok() + assert not (source/'.git/objects/info/alternates').exists() + assert not any((source/'.git/objects/pack').glob('*.promisor')) + assert len(reference['linuxCut']['requiredAncestors'])==26 + for ancestor in reference['linuxCut']['requiredAncestors']: + subprocess.run(['git','merge-base','--is-ancestor',ancestor,CUT],cwd=source,env=env,check=True,timeout=60) + main_sha=probe(['git','rev-parse','refs/remotes/origin/main']) + subprocess.run(['git','merge-base','--is-ancestor',CUT,main_sha],cwd=source,env=env,check=True,timeout=60) + result['nativeSource']={'commit':CUT,'mainRef':'refs/remotes/origin/main','mainRefSha':main_sha,'requiredAncestors':reference['linuxCut']['requiredAncestors'],'externalAlternates':False,'shallow':probe(['git','rev-parse','--is-shallow-repository'])} + else: + source_ok() + if a.phase=='toolchain': + assert not (root/'opt/node').exists() and not (root/'opt/pnpm').exists() + name='node-v26.12.1-linux-x64.tar.xz';base='https://nodejs.org/dist/v26.12.1/' + with urllib.request.urlopen(base+'SHASUMS256.txt',timeout=30) as f:lines=f.read().decode().splitlines() + expected=[line.split()[0] for line in lines if line.split()[-1]==name];assert len(expected)==1 + archive=root/'downloads'/name + with urllib.request.urlopen(base+name,timeout=30) as f,archive.open('xb') as target:shutil.copyfileobj(f,target) + assert sha(archive)==expected[0] + unpack=root/'downloads/node-unpack';unpack.mkdir() + with tarfile.open(archive) as t:t.extractall(unpack,filter='data') + (unpack/'node-v26.12.1-linux-x64').rename(root/'opt/node') + assert probe([node,'--version'])=='v26.12.1' + manager=load(source/'package.json')['packageManager'];prefix='pnpm@12.15.0+sha512.';assert manager.startswith(prefix) + archive=root/'downloads/pnpm-12.15.0.tgz' + with urllib.request.urlopen('https://registry.npmjs.org/pnpm/-/pnpm-12.15.0.tgz',timeout=30) as f,archive.open('xb') as target:shutil.copyfileobj(f,target) + assert sha(archive,'sha512')==manager[len(prefix):] + unpack=root/'downloads/pnpm-unpack';unpack.mkdir() + with tarfile.open(archive) as t:t.extractall(unpack,filter='data') + (unpack/'package').rename(root/'opt/pnpm');(root/'opt/bin').mkdir() + (root/'opt/bin/pnpm').symlink_to('../pnpm/pnpm') + assert probe([node,pnpm,'--version'])=='12.15.0' + assert probe(['pnpm','--version'])=='12.15.0' + native=root/'opt/pnpm/pnpm-native' + with native.open('rb') as stream:header=stream.read(20) + assert header[:6]==b'\x7fELF\x02\x01' and int.from_bytes(header[18:20],'little')==62 + result['buildNode']={'path':str(node),'sha256':sha(node),'version':'26.12.1'} + result['pnpm']={'path':str(pnpm),'sha256':sha(pnpm),'version':'12.15.0','archiveSha512':sha(archive,'sha512'),'nativeSha256':sha(native),'nativeResolution':'official pnpm.mjs + placeholder; signature/integrity checks unchanged'} + elif a.phase=='install':run('frozen-install',['/usr/bin/nice','-n','10',node,pnpm,'install','--frozen-lockfile'],source,3600) + elif a.phase=='runtime': + run('pnpm-build',['/usr/bin/nice','-n','10',node,pnpm,'build'],source,7200) + assert load(source/'dist/build-info.json')['commit']==CUT + result['distBuildInfoSha256']=sha(source/'dist/build-info.json') + elif a.phase=='boundary':run('ts-boundary',['/usr/bin/nice','-n','10',node,'--import','./scripts/tsx.mjs','scripts/prepare-extension-package-boundary-artifacts.mts'],source,3600) + elif a.phase=='plugins': + compiler=root/'compilers/standard/bun';records=load(root/'admission-inputs/compiler-records.json') + assert records['status']=='native-compilers-adopted-not-app-admitted' and sha(compiler)==records['cb-standard']['sha256'] + run('select-plugins',['/usr/bin/nice','-n','10',compiler,'--no-env-file','--no-install',root/'build-prep/select-plugins.mjs',source,root/'admission-inputs/plugins'],source,1800) + result['plugins']={name:sha(root/'admission-inputs/plugins'/name) for name in ['desktop.json','all.json','plugin-selection.json']} + result['buildNode']=load(root/'prep-receipts/toolchain/result.json')['buildNode'] + result['nativeSource']=load(root/'prep-receipts/clone/result.json')['nativeSource'] + result['distBuildInfoSha256']=sha(source/'dist/build-info.json') + + source_ok() + result['status']='PASS' + except Exception as error:result['error']=f'{type(error).__name__}: {error}' + finally: + result['finished']=datetime.datetime.now(datetime.timezone.utc).isoformat() + (receipt/'result.json').write_text(json.dumps(result,indent=2)+'\n') + for sig,handler in outer_handlers.items():signal.signal(sig,handler) + print('P6_FINAL_NATIVE_PREP '+json.dumps(result),flush=True) + return 0 if result['status']=='PASS' else 1 + +if __name__=='__main__':raise SystemExit(main()) diff --git a/scripts/openclaw-p6/app/packet/payload/preserve.py b/scripts/openclaw-p6/app/packet/payload/preserve.py new file mode 100644 index 000000000000..047bb0a44b74 --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/preserve.py @@ -0,0 +1,218 @@ +#!/usr/bin/env python3 +"""Preserve a successful P6 native artifact, then verify its relocated copy.""" +import argparse +import copy +import hashlib +import json +import os +from pathlib import Path, PurePosixPath +import stat +import subprocess +import tarfile + +SOURCE_COMMIT = '670a7ab33bbd2e3ed4f0a5681e138159d74540a1' + + +def require(ok, message): + if not ok: + raise ValueError(message) + + +def sha(filename): + digest = hashlib.sha256() + with Path(filename).open('rb') as stream: + for chunk in iter(lambda: stream.read(1024 * 1024), b''): + digest.update(chunk) + return digest.hexdigest() + + +def read_pinned(filename, digest): + data = Path(filename).read_bytes() + require(hashlib.sha256(data).hexdigest() == digest, 'Input hash mismatch: ' + str(filename)) + return data + + +def write_json(filename, value): + Path(filename).write_text(json.dumps(value, indent=2) + '\n') + + +def contained(root, child): + try: + Path(child).relative_to(root) + return True + except ValueError: + return False + + +def inventory(root): + """Transport metadata only; content/tree hashes remain with the source owner.""" + rows = [{'path': '.', 'kind': 'directory', 'mode': stat.S_IMODE(root.stat().st_mode)}] + def visit(directory): + for item in sorted(directory.iterdir(), key=lambda p: p.name): + info = item.lstat() + row = {'path': item.relative_to(root).as_posix(), 'mode': stat.S_IMODE(info.st_mode)} + if stat.S_ISLNK(info.st_mode): + row.update(kind='symlink', target=os.readlink(item)) + require(not Path(row['target']).is_absolute() and contained(root, item.resolve(strict=True)), + 'Artifact link is not relocatable: ' + row['path']) + elif stat.S_ISDIR(info.st_mode): + row['kind'] = 'directory' + elif stat.S_ISREG(info.st_mode): + row.update(kind='file', size=info.st_size) + else: + raise ValueError('Unsupported artifact member: ' + row['path']) + rows.append(row) + if row['kind'] == 'directory': + visit(item) + visit(root) + return rows + + +def inputs(plan_file, plan_sha, result_file, result_sha): + plan_data = read_pinned(plan_file, plan_sha) + result_data = read_pinned(result_file, result_sha) + plan, result = json.loads(plan_data), json.loads(result_data) + require(result['status'] == 'built-unsigned' and result['phase'] == 'complete' and + result['measurement']['exitCode'] == 0, 'No successful completed native build') + require(result['plan'] == plan, 'Result does not contain the exact native plan') + require(plan['platform'] == 'linux' and plan['arch'] == 'x64' and + plan['sourceProof']['commit'] == SOURCE_COMMIT, 'Wrong native target or final source cut') + return plan_data, result_data, plan, result + + +def check_artifact(plan_file, plan, result, checker, node, logs): + checker, node = Path(checker).resolve(), Path(node).resolve() + require(sha(checker) == plan['artifactCheckerSha256'], 'Artifact checker changed') + owner = Path(plan['source']) / 'scripts/lib/bun-standalone-contract.mjs' + require(sha(owner) == result['artifact']['contractOwnerSha256'], 'Source contract owner changed') + env = {'PATH': str(node.parent) + ':/usr/bin:/bin', 'HOME': str(logs), + 'TMPDIR': str(logs), 'LANG': 'C.UTF-8', 'NODE_NO_WARNINGS': '1'} + process = subprocess.run([str(node), str(checker), str(plan_file)], env=env, + cwd=logs, capture_output=True, text=True, timeout=1800) + (logs / 'checker.stdout').write_text(process.stdout) + (logs / 'checker.stderr').write_text(process.stderr) + require(process.returncode == 0, 'Artifact owner check failed; see checker.stderr') + actual = json.loads(process.stdout) + require(actual == result['artifact'], 'Relocated owner facts differ from native result') + return actual + + +def fresh_output(output, protected): + output = Path(output).resolve() + require(not output.exists(), 'Output already exists') + require(all(not contained(Path(root).resolve(), output) for root in protected), + 'Preservation output must be outside source and artifact') + output.mkdir(parents=True) + return output + + +def pack(args): + plan_data, result_data, plan, result = inputs(args.plan, args.plan_sha256, + args.result, args.result_sha256) + artifact = Path(plan['output']).resolve(strict=True) + require(artifact.is_dir() and not Path(plan['output']).is_symlink(), 'Artifact root is not a directory') + require(sha(plan['buildNode']['path']) == plan['buildNode']['sha256'], 'Admitted native Node changed') + output = fresh_output(args.out, [artifact, plan['source']]) + for name, data in [('native-plan.json', plan_data), ('native-result.json', result_data)]: + (output / name).write_bytes(data) + facts = check_artifact(output / 'native-plan.json', plan, result, args.checker, + plan['buildNode']['path'], output) + metadata = inventory(artifact) + write_json(output / 'artifact-metadata.json', metadata) + archive = output / 'artifact.tar' + with tarfile.open(archive, 'w', dereference=False, format=tarfile.PAX_FORMAT) as bundle: + bundle.add(artifact, arcname='artifact', recursive=True) + for name in ['native-plan.json', 'native-result.json', 'artifact-metadata.json']: + bundle.add(output / name, arcname=name, recursive=False) + require(sha(args.plan) == args.plan_sha256 and sha(args.result) == args.result_sha256, + 'Native plan/result changed during preservation') + receipt = {'status': 'preserved-not-downloaded', 'sourceCommit': SOURCE_COMMIT, + 'archive': str(archive), 'archiveSha256': sha(archive), + 'archiveBytes': archive.stat().st_size, 'helperSha256': sha(__file__), + 'nativePlanSha256': args.plan_sha256, 'nativeResultSha256': args.result_sha256, + 'checkerSha256': plan['artifactCheckerSha256'], + 'contractOwnerSha256': facts['contractOwnerSha256'], + 'manifestSha256': facts['manifestSha256'], 'executable': facts['executable'], + 'runtime': facts['runtime'], 'artifactMetadataSha256': sha(output / 'artifact-metadata.json')} + write_json(output / 'transport.json', receipt) + return receipt + + +def validate_members(members): + names, links = set(), set() + allowed = {'native-plan.json', 'native-result.json', 'artifact-metadata.json'} + for member in members: + name = PurePosixPath(member.name) + require(not name.is_absolute() and '..' not in name.parts and member.name not in names, + 'Unsafe or duplicate archive path') + require(name.parts and (name.parts[0] == 'artifact' or str(name) in allowed), 'Unexpected archive root') + require(member.isdir() or member.isfile() or member.issym() or member.islnk(), 'Special archive member') + names.add(member.name) + if member.issym(): + target = PurePosixPath(member.linkname) + require(not target.is_absolute(), 'Absolute archive symlink') + normalized = os.path.normpath(str(name.parent / target)) + require(normalized == 'artifact' or normalized.startswith('artifact/'), 'Escaping archive symlink') + links.add(member.name) + if member.islnk(): + target = PurePosixPath(member.linkname) + require(not target.is_absolute() and '..' not in target.parts and target.parts[0] == 'artifact', + 'Escaping archive hardlink') + for name in names: + require(not any(str(parent) in links for parent in PurePosixPath(name).parents), + 'Archive member traverses a symlink') + + +def verify(args): + receipt = json.loads(read_pinned(args.transport, args.transport_sha256)) + require(receipt['status'] == 'preserved-not-downloaded' and + receipt['sourceCommit'] == SOURCE_COMMIT and receipt['helperSha256'] == sha(__file__), + 'Wrong transport receipt or helper') + require(args.archive_sha256 == receipt['archiveSha256'] and + sha(args.archive) == receipt['archiveSha256'] and + Path(args.archive).stat().st_size == receipt['archiveBytes'], 'Archive transfer differs') + source = Path(args.source).resolve(strict=True) + head = subprocess.check_output(['git', '-C', str(source), 'rev-parse', 'HEAD'], text=True).strip() + require(head == SOURCE_COMMIT, 'Local carrier is not the final source cut') + output = fresh_output(args.out, [source]) + with tarfile.open(args.archive, 'r:') as bundle: + validate_members(bundle.getmembers()) + # Validated paths and links above; retain exact modes across Python defaults. + if hasattr(tarfile, 'fully_trusted_filter'): + bundle.extractall(output, filter=tarfile.fully_trusted_filter) + else: + bundle.extractall(output) + plan_data, result_data, native_plan, result = inputs(output / 'native-plan.json', receipt['nativePlanSha256'], + output / 'native-result.json', receipt['nativeResultSha256']) + require(sha(output / 'artifact-metadata.json') == receipt['artifactMetadataSha256'], 'Metadata transfer differs') + require(inventory(output / 'artifact') == json.loads((output / 'artifact-metadata.json').read_text()), + 'Artifact paths, kinds, modes, sizes, or link targets changed') + derived = copy.deepcopy(native_plan) + derived['source'], derived['output'] = str(source), str(output / 'artifact') + write_json(output / 'local-check-plan.json', derived) + facts = check_artifact(output / 'local-check-plan.json', derived, result, args.checker, args.node, output) + report = {'status': 'downloaded-and-verified', 'applicationQualified': False, + 'sourceCommit': SOURCE_COMMIT, 'archiveSha256': receipt['archiveSha256'], + 'nativePlanSha256': receipt['nativePlanSha256'], 'nativeResultSha256': receipt['nativeResultSha256'], + 'localCheckPlanSha256': sha(output / 'local-check-plan.json'), + 'derivedPlanChangedKeys': ['source', 'output'], 'facts': facts, + 'artifact': str(output / 'artifact'), 'localNodeSha256': sha(args.node)} + write_json(output / 'verification.json', report) + return report + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + commands = parser.add_subparsers(dest='mode', required=True) + native = commands.add_parser('pack') + for name in ['plan', 'plan-sha256', 'result', 'result-sha256', 'checker', 'out']: + native.add_argument('--' + name, required=True) + local = commands.add_parser('verify') + for name in ['archive', 'archive-sha256', 'transport', 'transport-sha256', 'source', 'checker', 'node', 'out']: + local.add_argument('--' + name, required=True) + args = parser.parse_args() + print(json.dumps(pack(args) if args.mode == 'pack' else verify(args), indent=2)) + + +if __name__ == '__main__': + main() diff --git a/scripts/openclaw-p6/app/packet/payload/qualification/README.md b/scripts/openclaw-p6/app/packet/payload/qualification/README.md new file mode 100644 index 000000000000..784ca912463e --- /dev/null +++ b/scripts/openclaw-p6/app/packet/payload/qualification/README.md @@ -0,0 +1,167 @@ +# Final native x64 qualification preparation + +Preparation only. No artifact is assumed to exist and no application, source +helper, Docker build, E2E lane, remote command or lease allocation has run here. +The native root is /home/runner/.cache/oc-ty-ext/P6/app-x64-final-r2-v1, source=root/source +at exact670a7ab33bbd2e3ed4f0a5681e138159d74540a1, Node=root/opt/node/bin/node26.12.1. +The application guest/kernel lane is separate and is not provided by this bundle. + +## Immutable inputs and actual-artifact gate + +payload/harness contains12 unchanged existing P6 harness owner files and2 explicitly recorded adaptations and +needed direct dependencies. owner-inputs.json pins their original paths/bytes; +source-contract.json pins matching25a test imports and existing Docker lane +owners. Native staging uses a new root/qualification-harness-v2 directory; it +never changes root/manifest.json, original helpers, source or artifacts. + +qualify.py requires actual artifact path, executable and manifest SHA256 values, +and the actual successful build-driver receipt path+SHA256. It rejects missing +or wrong bytes, source/target mismatch, stale source/test owners, non-native x64, +wrong Node or reused outputs. The existing source-owned runtime descriptor must +match the complete current sidecar tree and accepted build receipt. Values are +supplied only after a real build/acceptance; no example invents artifact hashes. +Without --run it prints a plan, not a qualification pass. With --run it execs the +unchanged lane owner so process/signal cleanup remains with that owner. + +Each output must be a fresh root/qualification-results/