Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
ci: run the unit shards in a loopback-only network namespace (#2763)
Call Whitefd879ee97024
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.ymlindex 0ebf549b1..d8bc68811 100644--- a/.github/workflows/lint.yml+++ b/.github/workflows/lint.yml@@ -299,8 +299,10 @@ jobs:# jsonschema) cannot drift from pyproject.run: uv pip install --system -e . --group dev+ # Only the tests run with loopback alone, so no process a test starts can+ # reach past it; installing dependencies above still needs the network.- name: Run unit tests shard ${{ matrix.shard }}/${{ matrix.shard-total }}- run: bash scripts/ci_unit_tests.sh "${{ matrix.shard }}" "${{ matrix.shard-total }}"+ run: bash scripts/ci_loopback_only.sh bash scripts/ci_unit_tests.sh "${{ matrix.shard }}" "${{ matrix.shard-total }}"unit-tests:runs-on: ubuntu-latestdiff --git a/scripts/ci_loopback_only.sh b/scripts/ci_loopback_only.shnew file mode 100755index 000000000..239ffff13--- /dev/null+++ b/scripts/ci_loopback_only.sh@@ -0,0 +1,41 @@+#!/usr/bin/env bash+#+# Run a command, as the calling user, in a network namespace that has only loopback.+#+# The unit tests' in-process guard (tests/network_guard.py) sees only the+# pytest interpreter. A child process a test starts -- the vibe CLI, a worker+# interpreter, git, node, uv -- is outside it. In this namespace every+# descendant gets one answer: loopback works, and anything past it fails at+# once with "network unreachable".+#+# Linux only, with passwordless sudo, as on GitHub-hosted runners. Ubuntu+# restricts unprivileged user namespaces, and a user namespace would also run+# the command as a mapped root that file permissions do not stop, so the+# namespace is made as root and the command runs as the calling user again.+# Before it runs, a probe proves nothing past loopback answers.+#+# Usage: scripts/ci_loopback_only.sh <command> [args...]+set -euo pipefail++if [ "${1:-}" = "--inside" ]; then+ uid="$2"+ gid="$3"+ shift 3+ ip link set lo up+ # An address literal, so the probe tests the route, not only name resolution.+ if probe=$(curl -sS --max-time 5 -o /dev/null https://1.1.1.1 2>&1); then+ echo "This network namespace reaches past loopback; refusing to run the command in it." >&2+ exit 1+ fi+ echo "Loopback-only network namespace: a request past loopback fails with: $probe"+ exec setpriv --reuid="$uid" --regid="$gid" --init-groups -- "$@"+fi++if [ "$#" -eq 0 ]; then+ echo "Usage: $0 <command> [args...]" >&2+ exit 2+fi++# sudo resets PATH; the command needs the caller's toolchain on it.+exec sudo --preserve-env env "PATH=$PATH" unshare --net -- \+ bash "$0" --inside "$(id -u)" "$(id -g)" "$@"diff --git a/tests/network_guard.py b/tests/network_guard.pyindex fc62c258d..88e88aa82 100644--- a/tests/network_guard.py+++ b/tests/network_guard.py@@ -38,7 +38,12 @@ whole run protocol, including the session-scoped fixtures it sets up.Outside the hook: child processes (each loads its own interpreter), a nativeresolver or transport that bypasses CPython's socket module, such as uvloop'sor c-ares's, and ``socket.getnameinfo``, whose audit event omits the flags-that say whether it queries DNS.+that say whether it queries DNS. On Linux CI the operating system covers them:+the unit shards run in a network namespace that has only loopback+(``scripts/ci_loopback_only.sh``), where anything past it fails at once with+"network unreachable". That refusal is the child's own error and names no+test; the hook stays the named signal for the pytest process itself. macOS and+Windows jobs have the hook alone."""from __future__ import annotationsdiff --git a/tests/test_conftest_network_guard.py b/tests/test_conftest_network_guard.pyindex 4183591c8..c6219e49b 100644--- a/tests/test_conftest_network_guard.py+++ b/tests/test_conftest_network_guard.py@@ -251,7 +251,14 @@ def _udp_connect(host):@pytest.mark.integration@pytest.mark.allow_network(reason="proves the opt-out; a UDP connect sends nothing")def test_an_opted_out_integration_test():- _udp_connect("203.0.113.14")+ try:+ _udp_connect("203.0.113.14")+ except network_guard.NetworkAccessRefused:+ raise+ except OSError:+ # The guard let it through; the host has no route there, as in the+ # loopback-only namespace the Linux CI shards run in.+ pass@pytest.mark.allow_network(reason="not an integration test")