feat(security): integrate Kata Containers for offline task execution - #6
Open
jeremy1392 wants to merge 3 commits into
Open
jeremy1392 wants to merge 3 commits into
jeremy1392 wants to merge 3 commits into
Conversation
Validate canonical public examples and both smoke generators; check the two published onboarding agents. Remove orphan tests for the gateway tool deleted in 15f12b7 and make the CLI path assertion portable.
jeremy1392
marked this pull request as ready for review
September 15, 2026 17:36
Contributor
|
I've replied on #5, where you asked the direction question — the short version is that we want VM-backed isolation, but at the xrlenv layer rather than in beagle's local runtime, and there may be a much cheaper first step than a full backend. Details there. Keeping this open for now rather than closing it: the prototype is the useful artifact even if the final home differs, and I'd rather not lose it while we settle the design. Two things worth knowing if you pick it up again:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and behavior
Refs #5.
Beagle has no explicit local Kata runtime. This adds an experimental
runtime.kind: kataadapter for prebuilt offline workloads: it selects an operator-configured Kata runtime and Unix Docker socket, launches each acquired task with--network none, checks Docker's reported runtime/network, and fails without falling back to runc.The adapter accepts only entrypoint overrides, rejects writable host mounts and unsupported requested CPU/memory limits, and force-removes containers before independently confirming their absence. Failed launches retain their generated name for cleanup; uncertain cleanup preserves the handle and reports its identifier for recovery.
Canonical evaluation YAML now accepts a runtime mapping with options, the CLI preserves those options, and
beagle.evaluateconstructs the requested Kata runtime. The runner supports DockerHarness plus InBandGrader and rejects runtime overrides, Harbor/Pier-owned environments, other harnesses and external evaluator paths that could bypass Kata.Research context
This contribution is inspired by my independent ExploitGym containment research, applying execution-infrastructure controls and explicit teardown verification to Beagle. The report is motivation, not evidence of a Beagle vulnerability or proof of this adapter's escape resistance.
Validation
eb4cf59), usingpython -B -m pytest tests/ -q: 925 passed, 16 skipped, zero failures and zero collection errors. No extra test exclusions or collection-error bypass were used; real smokes remain opt-in under the repository's existing pytest configuration. Skips require optional Harbor/Pier orevolve.poolmodules.git diff --checkpasses.beagle.evaluaterun constructs Kata from config, executes through Runner/DockerHarness, reduces the result with InBandGrader and writesrun.json.Public test-suite corrections
The upstream public snapshot
15f12b7retained tests for internal files and removed tooling. A separate test-only commit corrects those mismatches so the default suite can finish successfully:examples/evolution/config.yaml,README.mdandquick_start_inline.py, the canonical public filenames, instead of absent.osssource variants. Existing portability and link assertions remain active.15f12b7.test_gateway_proxy.pymodule:15f12b7explicitly deleted its entirescripts/gateway/implementation and documentation. This is deletion of tests for removed code, not a newly passing gateway implementation. Tests for currently shipped provider routing and gateway egress remain active.The production Kata adapter, model smoke and their previously recorded results are unchanged by this test-suite correction.
Reproduce the real-host smoke after configuring Kata and pre-pulling the image:
Real agent and local-model validation
The opt-in model smoke now runs mini-swe-agent 2.4.6 and Qwen2.5-Coder-7B-Instruct Q4_K_M inside the same Kata VM, with CPU inference and a loopback-only llama.cpp endpoint. Model weights are verified by SHA-256 and mounted read-only; both execution and verification containers use
--network none.The recorded run repaired a Python clamp function, reached mini-swe's
Submittedstate and recorded 388 completion tokens across four assistant turns. Three tests failed on the original source. Only the generated source was transferred to a fresh Kata VM, where all five acceptance tests passed. Both containers and their associated QEMU processes were then confirmed absent. Beagle retained the native trajectory, patch and run record.The smoke reuses the existing
MiniSweAgent.run_inimplementation. A test-only setup subclass starts preinstalled dependencies and the local model; a runtime subclass supplies the read-only model input. These helpers do not add general preinstalled-agent support to the production adapter.Recorded result and versions · Reproduction instructions. The model smoke used 4 vCPUs and 8 GiB guest RAM. It is one functional repair scenario, not a full benchmark or an adversarial containment certification.
Scope and limits
This is a draft for maintainer feedback on the integration boundary. Existing agents requiring Git/package downloads or external model APIs cannot use this offline profile unchanged. Harbor/Pier, SWE-bench's separate evaluator, Compose, DarwinX evolution and provider allowlists are outside this first step.
The Docker daemon/runtime registration and host-side agent/harness Python remain trusted. Runtime metadata is not VM attestation. Docker removal is a point-in-time observation; late daemon operations after a timeout and recovery after a Beagle process crash require a separate reconciler. The smoke verifies lifecycle behavior, not adversarial containment. The upstream Docker integration currently uses Kata's deprecated Go runtime.
See setup, configuration and boundaries. This branch starts from upstream main and does not include the separate cleanup or Compose-volume PRs.