The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(ci): trust container checkouts and recursive submodules
Steven Enamakel4730df59ba58
diff --git a/.github/workflows/ci-full.yml b/.github/workflows/ci-full.ymlindex e5cab2dbb1..6206dfae87 100644--- a/.github/workflows/ci-full.yml+++ b/.github/workflows/ci-full.yml@@ -90,6 +90,9 @@ jobs:fetch-depth: 1persist-credentials: falsesubmodules: recursive+ - name: Trust container checkout and submodules+ shell: bash+ run: bash scripts/ci/trust-checkout.sh- name: Cache pnpm storeid: pnpm-cache@@ -156,6 +159,9 @@ jobs:fetch-depth: 1persist-credentials: falsesubmodules: recursive+ - name: Trust container checkout and submodules+ shell: bash+ run: bash scripts/ci/trust-checkout.sh- name: Cache pnpm storeid: pnpm-cache@@ -253,6 +259,9 @@ jobs:fetch-depth: 1persist-credentials: falsesubmodules: recursive+ - name: Trust container checkout and submodules+ shell: bash+ run: bash scripts/ci/trust-checkout.sh- name: Cache pnpm storeid: pnpm-cachediff --git a/.github/workflows/e2e-reusable.yml b/.github/workflows/e2e-reusable.ymlindex bb96d12917..57624f6ab7 100644--- a/.github/workflows/e2e-reusable.yml+++ b/.github/workflows/e2e-reusable.yml@@ -99,6 +99,9 @@ jobs:fetch-depth: 1persist-credentials: falsesubmodules: recursive+ - name: Trust container checkout and submodules+ shell: bash+ run: bash scripts/ci/trust-checkout.sh- name: Cache pnpm storeuses: actions/cache@v6@@ -213,6 +216,9 @@ jobs:ref: ${{ inputs.ref }}fetch-depth: 1submodules: recursive+ - name: Trust container checkout and submodules+ shell: bash+ run: bash scripts/ci/trust-checkout.sh- name: Cache pnpm storeuses: actions/cache@v6@@ -290,6 +296,9 @@ jobs:ref: ${{ inputs.ref }}fetch-depth: 1submodules: recursive+ - name: Trust container checkout and submodules+ shell: bash+ run: bash scripts/ci/trust-checkout.sh- name: Cache pnpm storeuses: actions/cache@v6@@ -412,6 +421,9 @@ jobs:fetch-depth: 1persist-credentials: falsesubmodules: recursive+ - name: Trust container checkout and submodules+ shell: bash+ run: bash scripts/ci/trust-checkout.sh- name: Cache pnpm storeuses: actions/cache@v6diff --git a/.github/workflows/test-reusable.yml b/.github/workflows/test-reusable.ymlindex 5ccc7809c0..596eccd3b9 100644--- a/.github/workflows/test-reusable.yml+++ b/.github/workflows/test-reusable.yml@@ -62,6 +62,9 @@ jobs:with:ref: ${{ inputs.ref }}fetch-depth: 1+ - name: Trust container checkout and submodules+ shell: bash+ run: bash scripts/ci/trust-checkout.sh- name: Cache pnpm storeuses: actions/cache@v6with:@@ -87,6 +90,9 @@ jobs:with:ref: ${{ inputs.ref }}fetch-depth: 1+ - name: Trust container checkout and submodules+ shell: bash+ run: bash scripts/ci/trust-checkout.sh# The RPC-catalog drift-guard test (rpcMethods.test.ts) reads# vendor/tinychannels/crates/tinychannels-bus/src/controllers/schemas.rs# at test time (controller metadata is contract, so it lives in the bus@@ -153,6 +159,9 @@ jobs:fetch-depth: 1persist-credentials: falsesubmodules: recursive+ - name: Trust container checkout and submodules+ shell: bash+ run: bash scripts/ci/trust-checkout.sh# Single dep-cache strategy repo-wide: Swatinem rust-cache (full target/).# sccache was removed here to match the ci-lite lanes — layered on a warm# rust-cache it logged 0% additional hits and just doubled cache footprint.@@ -319,6 +328,9 @@ jobs:# Required for crates/openhuman-app/vendor/tauri-cef.persist-credentials: falsesubmodules: recursive+ - name: Trust container checkout and submodules+ shell: bash+ run: bash scripts/ci/trust-checkout.sh# See rust-core-tests: rust-cache only, sccache dropped (0% hits warm).- name: Cache Rust build artifactsuses: Swatinem/rust-cache@v2diff --git a/scripts/__tests__/trust-checkout.test.mjs b/scripts/__tests__/trust-checkout.test.mjsnew file mode 100644index 0000000000..3f428f00d9--- /dev/null+++ b/scripts/__tests__/trust-checkout.test.mjs@@ -0,0 +1,124 @@+import assert from "node:assert/strict";+import { spawnSync } from "node:child_process";+import { mkdtempSync, mkdirSync, rmSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";+import test from "node:test";+import { fileURLToPath } from "node:url";++const helper = fileURLToPath(+ new URL("../ci/trust-checkout.sh", import.meta.url),+);++test("container checkout trust covers its submodules and excludes unrelated repositories", () => {+ const root = mkdtempSync(join(tmpdir(), "checkout-trust-"));+ const env = {+ ...process.env,+ GIT_CONFIG_GLOBAL: join(root, "gitconfig"),+ GIT_CONFIG_NOSYSTEM: "1",+ };+ const git = (directory, args, extra = {}) =>+ spawnSync("git", ["-C", directory, ...args], {+ encoding: "utf8",+ env: { ...env, ...extra },+ });+ const checked = (directory, args) => {+ const result = git(directory, args);+ assert.equal(result.status, 0, result.stdout + result.stderr);+ };+ try {+ for (const name of ["checkout", "dependency", "nested", "unrelated"]) {+ const directory = join(root, name);+ mkdirSync(directory);+ checked(directory, ["init", "--quiet"]);+ checked(directory, [+ "-c",+ "user.name=Fixture",+ "-c",+ "[email protected]",+ "-c",+ "core.hooksPath=/dev/null",+ "commit",+ "--allow-empty",+ "--quiet",+ "-m",+ "fixture",+ ]);+ }+ checked(join(root, "dependency"), [+ "-c",+ "protocol.file.allow=always",+ "submodule",+ "add",+ "--quiet",+ join(root, "nested"),+ "vendor/nested",+ ]);+ checked(join(root, "dependency"), [+ "-c",+ "user.name=Fixture",+ "-c",+ "[email protected]",+ "-c",+ "core.hooksPath=/dev/null",+ "commit",+ "--quiet",+ "-am",+ "nested fixture",+ ]);+ const checkout = join(root, "checkout");+ checked(checkout, [+ "-c",+ "protocol.file.allow=always",+ "submodule",+ "add",+ "--quiet",+ join(root, "dependency"),+ "vendor/dependency",+ ]);+ checked(checkout, [+ "-c",+ "protocol.file.allow=always",+ "submodule",+ "update",+ "--init",+ "--recursive",+ ]);+ const foreign = { GIT_TEST_ASSUME_DIFFERENT_OWNER: "1" };+ assert.notEqual(+ git(checkout, ["status", "--short"], foreign).status,+ 0,+ "reproduce the container ownership failure",+ );+ const result = spawnSync("bash", [helper, checkout], {+ encoding: "utf8",+ env: { ...env, ...foreign },+ });+ assert.equal(result.status, 0, result.stdout + result.stderr);+ assert.equal(git(checkout, ["status", "--short"], foreign).status, 0);+ assert.equal(+ git(join(checkout, "vendor/dependency"), ["status", "--short"], foreign)+ .status,+ 0,+ );+ assert.equal(+ git(+ join(checkout, "vendor/dependency/vendor/nested"),+ ["status", "--short"],+ foreign,+ ).status,+ 0,+ );+ assert.notEqual(+ git(join(root, "unrelated"), ["status", "--short"], foreign).status,+ 0,+ );+ assert.doesNotMatch(+ git(checkout, ["config", "--global", "--get-all", "safe.directory"])+ .stdout,+ /^\*$/m,+ );+ } finally {+ rmSync(root, { recursive: true, force: true });+ }+});diff --git a/scripts/ci/trust-checkout.sh b/scripts/ci/trust-checkout.shnew file mode 100644index 0000000000..3316da1fe7--- /dev/null+++ b/scripts/ci/trust-checkout.sh@@ -0,0 +1,8 @@+#!/usr/bin/env bash+# Container jobs mount a runner-owned checkout. Trust only that checkout and+# its initialized submodules, retaining Git's ownership checks everywhere else.+set -euo pipefail+checkout_root="$(cd "${1:-${GITHUB_WORKSPACE:-.}}" && pwd -P)"+git config --global --add safe.directory "$checkout_root"+git -C "$checkout_root" submodule foreach --recursive \+ 'git config --global --add safe.directory "$PWD"'