Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .agents/repo.md
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ xlsx,odt}.ts`) still reach the catch-all as `failed` + `indexer_error` and are r
harness YAML declares `capabilities.resume: false`: every later kick of a task, every automatic
retry and every answered ask starts a fresh conversation over the preserved workspace with the
brief and the earlier rounds restated, where the other harnesses hand the exec the announced
handle (2026-10). Paying it down means a sandbox-runtime pin that carries the upstream fix —
which first needs root-owned system-settings staging in `tale-gemini-run`, as the
`GEMINI_CLI_VERSION` note in `services/sandbox-runtime/Dockerfile` says — then flipping the
flag and restoring the `resume` argv slot (the schema holds the two coherent).
handle (2026-10). The runtime now bakes root-owned system settings for Gemini 0.62.0;
the resume bug remains open. Paying it down means a sandbox-runtime pin that carries
the upstream fix, then flipping the flag and restoring the `resume` argv slot (the schema
holds the two coherent).
16 changes: 10 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -855,10 +855,12 @@ jobs:
docker tag "ghcr.io/tale-project/tale/tale-sandbox-runtime:latest" \
"tale-sandbox-runtime:latest"

- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
# Runtime conformance imports workspace schemas and the exec builder.
- name: Setup toolchain
uses: ./.github/actions/setup-turbo
with:
bun-version: '1.3.12'
github-token: ${{ secrets.GITHUB_TOKEN }}
start-turbo-cache: 'false'

- name: Run image validation
run: bun services/platform/tests/integration/container-image-test.ts
Expand Down Expand Up @@ -899,10 +901,12 @@ jobs:
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
sudo docker image prune -af

- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
# The fork lane runs the same workspace-dependent conformance helpers.
- name: Setup toolchain
uses: ./.github/actions/setup-turbo
with:
bun-version: '1.3.12'
github-token: ${{ secrets.GITHUB_TOKEN }}
start-turbo-cache: 'false'

- name: Run image validation (local build)
run: bun services/platform/tests/integration/container-image-test.ts
Expand Down
16 changes: 10 additions & 6 deletions configs/platform/system/harnesses/gemini/harness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
#
# Prompt + instructions + settings travel as ONE JSON object on stdin, never
# argv: process lists leak argv, and a prompt starting with '-' would parse
# as a flag. The wrapper reads to EOF, stages the settings as a per-exec
# SYSTEM settings file (GEMINI_CLI_SYSTEM_SETTINGS_PATH — system scope wins
# as a flag. The wrapper reads to EOF, selects immutable image settings
# derived from this harness and the existing interpreter at image build
# (GEMINI_CLI_SYSTEM_SETTINGS_PATH — system scope wins
# over any repo .gemini/settings.json, so a run is reproducible regardless
# of repo contents), stages the instructions as a per-exec context file
# of repo contents, with the root ownership Gemini 0.60+ requires), refuses
# an image/settings mismatch, stages the instructions as a per-exec context file
# under ~/.gemini/ added to `context.fileName` alongside GEMINI.md (appended
# to the model context every turn WITHOUT replacing the CLI's core system
# prompt — GEMINI_SYSTEM_MD would replace it and drop the defaults), then
Expand Down Expand Up @@ -45,8 +47,7 @@ capabilities:
# FRESH conversation over the preserved workspace (the planners read this
# flag; the exec builder refuses a handle). Flip to true and restore the
# `resume: { flag: '--resume' }` argv slot once the pin carries the
# upstream fix — see the GEMINI_CLI_VERSION note in the sandbox-runtime
# Dockerfile for what a bump past 0.59.0 needs first.
# upstream fix (still open on the pinned 0.62.0).
resume: false
parser: gemini-stream
exec:
Expand Down Expand Up @@ -93,7 +94,10 @@ exec:
# no rule for unchanged — on both lanes, so a byo Google
# `gemini-3-flash` is not silently promoted either. Upstream
# narrowed the rewrite to its own aliases in 0.61.0
# (isPromotableFlashModel). The runtime image test drives the
# (isPromotableFlashModel). Keep the supported setting during
# rolling upgrades: older platform images still send it, and
# the runtime verifies the complete policy before launching.
# The runtime image test drives the
# pinned CLI through the wrapper with these settings and
# asserts the request path keeps a flash-suffixed id.
- set:
Expand Down
12 changes: 5 additions & 7 deletions configs/platform/system/harnesses/opencode/harness.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Sandbox harness — OpenCode (`opencode run`). Managed only: its provider
# config points at the platform gateway and authenticates with the session
# virtual key; there is no bring-your-own path. The prompt rides argv — the
# CLI has no stdin prompt channel. `opencode run` has no turn-cap flag; the
# virtual key; there is no bring-your-own path. The prompt rides argv for
# compatibility with existing runtime images. `opencode run` has no turn-cap flag; the
# runaway backstop is the platform runner.
#
# Config is injected via OPENCODE_CONFIG_CONTENT (the envDoc below) so
Expand Down Expand Up @@ -39,11 +39,9 @@ exec:
- model:
flag: '-m'
value: 'tale/${model}'
# Prompt as the trailing positional (argv element — no shell). Unlike
# the stdin contract the other harnesses honor, `opencode run` only
# accepts the prompt as a positional `[message..]` argument — it has no
# stdin/`-` prompt source — so it cannot honor the argv-leak guard. This
# is the CLI's documented surface, not a leak we can avoid here.
# Keep the trailing positional for older runtime images during a roll.
# OpenCode 1.18.34 also accepts piped stdin; moving this adapter to that
# channel requires a separately verified platform/runtime transition.
- prompt: {}
stdin:
mode: none
Expand Down
4 changes: 2 additions & 2 deletions configs/platform/system/harnesses/pi/harness.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Sandbox harness — Pi, driven through the tale-pi-run wrapper (prompt +
# per-exec config as one JSON object on stdin, staged to disk before the CLI
# starts — process lists leak argv, and a prompt starting with '-' would
# parse as a flag). Pi has no MCP support at all, so no MCP-delivered
# tooling (browser server, connector bridge) reaches it. Its
# parse as a flag). This adapter does not stage Pi's MCP configuration, so
# MCP-delivered tooling (browser server, connector bridge) is unavailable. Its
# bring-your-own backend is commonly OpenRouter-style and speaks the
# catalog's vendor-prefixed ids, so refs resolve in the catalog dialect.
#
Expand Down
52 changes: 43 additions & 9 deletions services/platform/backend/core/video_links/ytdlp_toolchain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* the processes it started.
*/
import { spawn } from 'node:child_process';
import { existsSync, readFileSync } from 'node:fs';
import fs from 'node:fs';
import { chmod, mkdir, mkdtemp, readFile, writeFile } from 'node:fs/promises';
import { createServer, type Server } from 'node:http';
import type { AddressInfo } from 'node:net';
Expand Down Expand Up @@ -41,13 +41,11 @@ const FAST = {
killGraceMs: 200,
};

/** Alive and not a zombie: an unreaped orphan must not count as stopped. */
/** A zombie is already stopped, even before its parent reaps it. */
function isAlive(pid: number): boolean {
const stat = `/proc/${pid}/stat`;
if (existsSync('/proc/self/stat')) {
if (!existsSync(stat)) return false;
const state = readFileSync(stat, 'utf8').split(') ')[1]?.[0];
return state !== undefined && state !== 'Z';
if (fs.existsSync('/proc/self/stat')) {
const state = procStat(pid)?.state;
return state !== undefined && state !== '' && state !== 'Z';
}
try {
process.kill(pid, 0);
Expand Down Expand Up @@ -86,7 +84,7 @@ function procStat(
): { comm: string; state: string; sid: number; startTime: string } | undefined {
let stat: string;
try {
stat = readFileSync(`/proc/${pid}/stat`, 'utf8');
stat = fs.readFileSync(`/proc/${pid}/stat`, 'utf8');
} catch (err) {
const code = (err as NodeJS.ErrnoException).code;
if (code === 'ENOENT' || code === 'ESRCH') return undefined;
Expand Down Expand Up @@ -350,6 +348,42 @@ async function stallingScript(
};
}

describe('process liveness observations', () => {
it.each(['ENOENT', 'ESRCH'])(
'counts a child that disappears during the stat read as gone (%s)',
(code) => {
// Force the procfs path on every host. Even a successful existence
// probe cannot guarantee the child remains alive until the read.
const exists = vi.spyOn(fs, 'existsSync').mockReturnValue(true);
const read = vi.spyOn(fs, 'readFileSync').mockImplementationOnce(() => {
throw Object.assign(new Error('process disappeared'), { code });
});
try {
expect(isAlive(12345)).toBe(false);
} finally {
read.mockRestore();
exists.mockRestore();
}
},
);

it('does not report an unreadable live process as gone', () => {
const error = Object.assign(new Error('permission denied'), {
code: 'EACCES',
});
const exists = vi.spyOn(fs, 'existsSync').mockReturnValue(true);
const read = vi.spyOn(fs, 'readFileSync').mockImplementationOnce(() => {
throw error;
});
try {
expect(() => isAlive(12345)).toThrow(error);
} finally {
read.mockRestore();
exists.mockRestore();
}
});
});

describe('downloadTo bounds', () => {
it('rejects a body that stops arriving, naming the body stage', async () => {
const url = await stub('stall-body');
Expand All @@ -366,7 +400,7 @@ describe('downloadTo bounds', () => {
/^\[video-toolchain\] yt-dlp download body: timed out after \d+ ms \(deadline 500 ms\)$/,
);
expect(Date.now() - startedAt).toBeLessThan(5_000);
expect(existsSync(join(scratch, 'yt-dlp'))).toBe(false);
expect(fs.existsSync(join(scratch, 'yt-dlp'))).toBe(false);
});

it('rejects a server that never answers, naming the response stage', async () => {
Expand Down
30 changes: 30 additions & 0 deletions services/platform/lib/harnesses/gemini-settings-build.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { describe, expect, it } from 'vitest';

import {
geminiPolicies,
GEMINI_BRIDGE_URL,
GEMINI_CONTEXT_FILE,
} from '../../../sandbox-runtime/build-gemini-settings';
import { loadHarnesses } from '../../backend/core/lib/providers/load_system_config';
import { buildHarnessExec } from './exec-builder';
import { batteryFor } from './test-helpers';

describe('Gemini image policy coverage', () => {
const fact = loadHarnesses().find((entry) => entry.slug === 'gemini')!;
const policies = [...geminiPolicies(fact).values()];
it.each(batteryFor(fact))(
'covers the complete settings of $name',
({ spec }) => {
const envelope = JSON.parse(buildHarnessExec(fact, spec).stdin!);
const settings = envelope.settings;
if (settings.mcpServers?.connectors) {
settings.mcpServers.connectors.env.TALE_CONNECTORS_URL =
GEMINI_BRIDGE_URL;
}
expect(policies).toContainEqual({
...settings,
context: { fileName: ['GEMINI.md', GEMINI_CONTEXT_FILE] },
});
},
);
});
4 changes: 4 additions & 0 deletions services/platform/tests/guards/turbo-inputs.guard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ const OUTSIDE_READS = [
path: 'services/sandbox-llm-gateway/docker-entrypoint.sh',
readers: 'backend/core/node_only/sandbox/gateway_setup_token.test.ts',
},
{
path: 'services/sandbox-runtime/build-gemini-settings.ts',
readers: 'lib/harnesses/gemini-settings-build.test.ts',
},
{
// Its engine install RUN, run under /bin/sh with recording doubles.
path: 'services/sandbox-runtime/Dockerfile',
Expand Down
8 changes: 6 additions & 2 deletions services/platform/tests/integration/container-image-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ const SIZE_BUDGETS: Record<string, number> = {
// markitdown's file-type model, reportlab, pdfplumber/pypdfium2) and the
// Node lock ~130 MB (react-icons alone ~85 MB, docx, pptxgenjs, sharp),
// taking amd64 from ~4.87 GB to an estimated ~5.3 GB.
// ~10% headroom over the ~5.3 GB amd64 image.
'sandbox-runtime': 5900,
// - the October refresh of all nine harnesses: upstream bundles grew
// (OpenClaw ~730 MB, Codex ~380 MB, Pi ~160 MB). CI measured 6166 MB
// before keeping ~120 MB of Bun/node-gyp build caches out of layers.
// ~10% headroom over the refreshed ~6.0 GB amd64 image. Runtime binaries
// and diagnostics stay intact; the image is shared by concurrent sessions.
'sandbox-runtime': 6600,
};

const SERVICES = [
Expand Down
Loading