diff --git a/apps/desktop/scripts/smoke-window.mjs b/apps/desktop/scripts/smoke-window.mjs index 0165de37e..226f24627 100644 --- a/apps/desktop/scripts/smoke-window.mjs +++ b/apps/desktop/scripts/smoke-window.mjs @@ -51,6 +51,18 @@ export async function smokeWindow({ window, host, getLocale }) { if (fixture) result.largeVideo = await smokeLargeVideo(window, host, projectId, JSON.parse(fixture), result.projectIds.length === 1); } if (result.projectIds.length === 1) await smokeTraceWindows(window, result.projectIds[0]); + if (process.env.OPENDIRECTOR_DESKTOP_SMOKE_USER_PATH === '1') { + const projectId = result.projectIds[0]; + const headers = { 'X-OpenDirector-Request': '1', 'X-OpenDirector-Desktop': host.token }; + const statusResponse = await fetch(`${host.url}/api/creation/projects/${projectId}/assistant/runtimes/pi/status`, { headers }); + const statusPayload = statusResponse.ok ? await statusResponse.json() : { status: `http-${statusResponse.status}` }; + const modelsResponse = await fetch(`${host.url}/api/creation/projects/${projectId}/assistant/runtimes/pi/models`, { headers }); + const modelsPayload = modelsResponse.ok ? await modelsResponse.json() : []; + result.inheritedUserPath = { + status: statusPayload.status, + models: Array.isArray(modelsPayload) ? modelsPayload.map(item => item.id) : [], + }; + } result.sidebarInitiallyOpen = await window.webContents.executeJavaScript("document.querySelector('.cw-workspace').dataset.desktopSidebar === 'open'"); if (!result.sidebarInitiallyOpen) { await window.webContents.executeJavaScript("document.querySelector('.od-caption-actions button').click()"); diff --git a/apps/desktop/scripts/smoke.mjs b/apps/desktop/scripts/smoke.mjs index 3caa182d3..312096ebc 100644 --- a/apps/desktop/scripts/smoke.mjs +++ b/apps/desktop/scripts/smoke.mjs @@ -1,4 +1,4 @@ -import { access, copyFile, mkdtemp, readFile, realpath, rm } from 'node:fs/promises'; +import { access, chmod, copyFile, mkdir, mkdtemp, readFile, realpath, rm, writeFile } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { delimiter, dirname, join, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -43,11 +43,51 @@ try { for (const [name, source] of fixtures) { await copyFile(fileURLToPath(new URL(source, import.meta.url)), join(directory, name)); } + let userShellEnv = {}; + if (process.platform !== 'win32') { + const shellHome = join(directory, 'smoke-home'); + const userCliBin = join(directory, 'smoke-user-cli-bin'); + const userInterpBin = join(directory, 'smoke-user-interp-bin'); + await mkdir(shellHome, { recursive: true }); + await mkdir(userCliBin, { recursive: true }); + await mkdir(userInterpBin, { recursive: true }); + const interp = join(userInterpBin, 'od-smoke-node'); + await writeFile(interp, `#!/bin/sh\nexec "${pythonBinary}" -I -B "$@"\n`, 'utf8'); + await chmod(interp, 0o755); + const piShim = join(userCliBin, 'pi'); + await writeFile(piShim, [ + '#!/usr/bin/env od-smoke-node', + 'import sys', + 'args = sys.argv[1:]', + 'if "--version" in args:', + ' print("1.8.0")', + ' raise SystemExit(0)', + 'if "--list-models" in args:', + ' print("provider model context max-out thinking images")', + ' print("smoke smoke-model 1M 32K yes no")', + ' raise SystemExit(0)', + 'if args[:2] == ["auth", "check"]:', + ' raise SystemExit(0)', + 'raise SystemExit(1)', + ].join('\n') + '\n', 'utf8'); + await chmod(piShim, 0o755); + const profile = `export PATH="${harnessBin}:${userCliBin}:${userInterpBin}:$PATH"\n`; + for (const name of ['.zshrc', '.zprofile', '.profile', '.bashrc', '.bash_profile']) { + await writeFile(join(shellHome, name), profile, 'utf8'); + } + userShellEnv = { + PATH: '/usr/bin:/bin:/usr/sbin:/sbin', + SHELL: process.platform === 'darwin' ? '/bin/zsh' : '/bin/sh', + ...(process.platform === 'darwin' ? { ZDOTDIR: shellHome } : { ENV: join(shellHome, '.profile') }), + OPENDIRECTOR_DESKTOP_SMOKE_USER_PATH: '1', + }; + } for (let attempt = 0; attempt < 3; attempt++) { const child = spawn(binary, ['--smoke'], { env: { ...process.env, PATH: [harnessBin, process.env.PATH].filter(Boolean).join(delimiter), + ...userShellEnv, OPENCODE_DISABLE_MODELS_FETCH: '1', OPENCODE_PURE: '1', OPENDIRECTOR_DESKTOP_DATA: directory, @@ -68,6 +108,11 @@ try { logOffset = log.length; if (result !== 0 || !latest) throw new Error(`Packaged desktop smoke failed on launch ${attempt + 1} (${result}):\n${log}`); const receipt = JSON.parse(latest.slice(6)); + if (process.platform !== 'win32') { + if (receipt.inheritedUserPath?.status !== 'ready' || !receipt.inheritedUserPath?.models?.includes('smoke/smoke-model')) { + throw new Error(`Desktop Host did not inherit user shell PATH: ${JSON.stringify(receipt.inheritedUserPath)}`); + } + } if (!receipt.mediaDrop || (mediaProject && receipt.mediaDrop !== mediaProject)) throw new Error('Desktop media drop was not verified'); mediaProject = receipt.mediaDrop; if (video) { diff --git a/apps/desktop/src/environment.mjs b/apps/desktop/src/environment.mjs new file mode 100644 index 000000000..ba125d67b --- /dev/null +++ b/apps/desktop/src/environment.mjs @@ -0,0 +1,152 @@ +import { spawn } from 'node:child_process'; + +const START_MARKER = '__OPENDIRECTOR_PATH_START__'; +const END_MARKER = '__OPENDIRECTOR_PATH_END__'; +const PROBE_COMMAND = `printf '${START_MARKER}\\n'; /usr/bin/env; printf '${END_MARKER}\\n'`; + +export function extractShellPath(output) { + const start = output.lastIndexOf(START_MARKER); + if (start === -1) return null; + const end = output.indexOf(END_MARKER, start + START_MARKER.length); + if (end === -1) return null; + const block = output.slice(start + START_MARKER.length, end); + for (const line of block.split(/\r?\n/)) { + if (line.startsWith('PATH=')) return line.slice(5); + } + return null; +} + +export function mergePath(segments, { platform = process.platform } = {}) { + const sep = platform === 'win32' ? ';' : ':'; + const seen = new Set(); + const entries = []; + for (const segment of segments) { + if (typeof segment !== 'string' || !segment) continue; + for (const raw of segment.split(sep)) { + if (!raw) continue; + const key = platform === 'win32' ? raw.toLowerCase() : raw; + if (seen.has(key)) continue; + seen.add(key); + entries.push(raw); + } + } + return entries.join(sep); +} + +function candidateShells(platform, env) { + const fallback = platform === 'darwin' ? '/bin/zsh' : '/bin/sh'; + const configured = env?.SHELL; + if (typeof configured === 'string' && configured.startsWith('/') && configured !== fallback) { + return [configured, fallback]; + } + return [fallback]; +} + +function runShellProbe(shell, args, env, timeoutMs) { + return new Promise((resolve, reject) => { + const child = spawn(shell, args, { + env: { ...env, TERM: 'dumb' }, + stdio: ['ignore', 'pipe', 'ignore'], + detached: true, + }); + let output = ''; + let settled = false; + const finish = (error, value) => { + if (settled) return; + settled = true; + clearTimeout(timer); + if (error) reject(error); + else resolve(value); + }; + const killGroup = () => { + if (child.pid) { + try { + process.kill(-child.pid, 'SIGKILL'); + return; + } catch {} + } + try { child.kill('SIGKILL'); } catch {} + }; + const timer = setTimeout(() => { + killGroup(); + finish(new Error(`Shell PATH probe timed out after ${timeoutMs}ms`)); + }, timeoutMs); + child.stdout.setEncoding('utf8'); + child.stdout.on('data', chunk => { + output += chunk; + if (output.length > 1024 * 1024) { + killGroup(); + finish(new Error('Shell PATH probe exceeded output limit')); + } + }); + child.once('error', error => finish(error)); + child.once('close', code => { + if (code !== 0) finish(new Error(`Shell PATH probe exited (${code})`)); + else finish(null, output); + }); + }); +} + +export async function resolveUserShellPath({ + platform = process.platform, + env = process.env, + probe = runShellProbe, + timeoutMs = 3000, + log, +} = {}) { + if (platform === 'win32') return null; + let lastError; + for (const shell of candidateShells(platform, env)) { + for (const args of [['-ilc', PROBE_COMMAND], ['-lc', PROBE_COMMAND]]) { + try { + const output = await probe(shell, args, env, timeoutMs); + const resolved = extractShellPath(output); + if (resolved) return resolved; + lastError = new Error('Shell PATH probe returned no PATH entry'); + } catch (error) { + lastError = error; + } + } + } + if (lastError) log?.write(`User shell PATH probe failed: ${lastError.message}\n`); + return null; +} + +export function buildHostEnv({ + runtimeBin, + workspace, + platform = process.platform, + env = process.env, + userPath = null, +} = {}) { + const result = {}; + const sep = platform === 'win32' ? ';' : ':'; + let existingPath = ''; + let pathKey = 'PATH'; + for (const [key, value] of Object.entries(env ?? {})) { + if (platform === 'win32' ? key.toLowerCase() === 'path' : key === 'PATH') { + if (typeof value === 'string' && value) { + existingPath = existingPath ? `${existingPath}${sep}${value}` : value; + } + if (platform === 'win32') pathKey = key; + continue; + } + result[key] = value; + } + result.OPENDIRECTOR_ROOT = workspace; + result[pathKey] = mergePath([runtimeBin, userPath, existingPath], { platform }); + return result; +} + +export async function resolveHostEnv({ + runtimeBin, + workspace, + platform = process.platform, + env = process.env, + probe = runShellProbe, + timeoutMs = 3000, + log, +} = {}) { + const userPath = await resolveUserShellPath({ platform, env, probe, timeoutMs, log }); + return buildHostEnv({ runtimeBin, workspace, platform, env, userPath }); +} diff --git a/apps/desktop/src/main.mjs b/apps/desktop/src/main.mjs index c1ba6060c..db8d0b23c 100644 --- a/apps/desktop/src/main.mjs +++ b/apps/desktop/src/main.mjs @@ -5,6 +5,7 @@ import { join, dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; import { homedir } from 'node:os'; import { Host, ownedURL, proxyRequest } from './host.mjs'; +import { resolveHostEnv } from './environment.mjs'; import { messages, localeFor } from './locale.mjs'; import { registerCommand, commandPath } from './command.mjs'; @@ -126,9 +127,9 @@ async function start() { const manifest = JSON.parse(readFileSync(join(runtime, 'manifest.json'), 'utf8')); if (typeof manifest.python !== 'string' || manifest.python.startsWith('/') || manifest.python.split(/[\\/]/).includes('..')) throw new Error('Invalid runtime Python path'); if (manifest.version !== 1 || manifest.platform !== process.platform || manifest.arch !== process.arch) throw new Error('Runtime platform does not match this application'); + const hostEnv = await resolveHostEnv({ runtimeBin: join(runtime, 'bin'), workspace, log }); host = new Host({ python: join(runtime, manifest.python), directory: workspace, log, - env: { ...process.env, OPENDIRECTOR_ROOT: workspace, - PATH: join(runtime, 'bin') + (process.platform === 'win32' ? ';' : ':') + process.env.PATH }, + env: hostEnv, onExit: () => { if (!quitting) void fatal(new Error(text().interrupted)); }, }); await host.ready; diff --git a/apps/desktop/tests/environment.test.mjs b/apps/desktop/tests/environment.test.mjs new file mode 100644 index 000000000..708f72df1 --- /dev/null +++ b/apps/desktop/tests/environment.test.mjs @@ -0,0 +1,152 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { chmod, mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { spawnSync } from 'node:child_process'; +import { buildHostEnv, extractShellPath, mergePath, resolveHostEnv, resolveUserShellPath } from '../src/environment.mjs'; + +test('extractShellPath ignores noisy rc output and extracts exported PATH', () => { + const output = [ + 'Welcome to zsh!', + '__OPENDIRECTOR_PATH_START__', + 'HOME=/Users/tester', + 'PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin', + 'SHELL=/bin/zsh', + '__OPENDIRECTOR_PATH_END__', + 'trailing noise', + ].join('\n'); + assert.equal(extractShellPath(output), '/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin'); + assert.equal(extractShellPath('no markers at all'), null); + assert.equal(extractShellPath('__OPENDIRECTOR_PATH_START__\nHOME=/tmp\n__OPENDIRECTOR_PATH_END__'), null); +}); + +test('mergePath deduplicates entries while preserving precedence across platforms', () => { + assert.equal( + mergePath(['/app/bin', '/opt/homebrew/bin:/app/bin:/usr/bin', undefined, '', '/usr/bin:/bin'], { platform: 'darwin' }), + '/app/bin:/opt/homebrew/bin:/usr/bin:/bin', + ); + assert.equal( + mergePath(['C:\\App\\bin', 'C:\\Tools;c:\\app\\bin;C:\\Windows\\System32', 'C:\\TOOLS'], { platform: 'win32' }), + 'C:\\App\\bin;C:\\Tools;C:\\Windows\\System32', + ); +}); + +test('buildHostEnv avoids undefined PATH and normalizes Windows Path casing', () => { + const posixEnv = buildHostEnv({ + runtimeBin: '/app/runtime/bin', + workspace: '/tmp/workspace', + platform: 'darwin', + env: { HOME: '/Users/tester' }, + userPath: '/opt/homebrew/bin:/usr/bin', + }); + assert.equal(posixEnv.OPENDIRECTOR_ROOT, '/tmp/workspace'); + assert.equal(posixEnv.PATH, '/app/runtime/bin:/opt/homebrew/bin:/usr/bin'); + assert.equal(posixEnv.PATH.includes('undefined'), false); + + const winEnv = buildHostEnv({ + runtimeBin: 'C:\\App\\bin', + workspace: 'C:\\Workspace', + platform: 'win32', + env: { Path: 'C:\\Tools;C:\\Windows\\System32', PATH: 'C:\\Extra' }, + }); + const pathKeys = Object.keys(winEnv).filter(key => key.toLowerCase() === 'path'); + assert.equal(pathKeys.length, 1); + assert.equal(winEnv[pathKeys[0]], 'C:\\App\\bin;C:\\Tools;C:\\Windows\\System32;C:\\Extra'); +}); + +test('resolveUserShellPath skips shell probing on Windows', async () => { + let called = false; + const result = await resolveUserShellPath({ + platform: 'win32', + probe: async () => { called = true; return ''; }, + }); + assert.equal(result, null); + assert.equal(called, false); +}); + +test('resolveUserShellPath falls back from interactive to login shell and logs on total failure', async () => { + const attempts = []; + const resolved = await resolveUserShellPath({ + platform: 'darwin', + env: { SHELL: '/bin/zsh' }, + probe: async (shell, args) => { + attempts.push([shell, args[0]]); + if (args[0] === '-ilc') throw new Error('timed out'); + return '__OPENDIRECTOR_PATH_START__\nPATH=/opt/homebrew/bin:/usr/bin\n__OPENDIRECTOR_PATH_END__\n'; + }, + }); + assert.equal(resolved, '/opt/homebrew/bin:/usr/bin'); + assert.deepEqual(attempts, [['/bin/zsh', '-ilc'], ['/bin/zsh', '-lc']]); + + const logs = []; + const failed = await resolveUserShellPath({ + platform: 'linux', + env: { SHELL: '/bin/sh' }, + probe: async () => { throw new Error('boom'); }, + log: { write: line => logs.push(line) }, + }); + assert.equal(failed, null); + assert.equal(logs.length, 1); + assert.match(logs[0], /boom/); +}); + +test('resolveHostEnv inherits user shell PATH under Finder-like minimal PATH for split-dir shebang CLIs', { skip: process.platform === 'win32' }, async () => { + const root = await mkdtemp(join(tmpdir(), 'od-env-gate-')); + const runtimeBin = join(root, 'runtime-bin'); + const cliDir = join(root, 'cli-bin'); + const interpDir = join(root, 'interp-bin'); + const shellHome = join(root, 'home'); + const workspace = join(root, 'workspace'); + try { + for (const dir of [runtimeBin, cliDir, interpDir, shellHome, workspace]) { + await mkdir(dir, { recursive: true }); + } + const interp = join(interpDir, 'od-fake-node'); + await writeFile(interp, '#!/bin/sh\necho "interp-ok:$1"\n', 'utf8'); + await chmod(interp, 0o755); + + const cli = join(cliDir, 'pi'); + await writeFile(cli, '#!/usr/bin/env od-fake-node\n', 'utf8'); + await chmod(cli, 0o755); + + const profile = `echo "rc banner noise"\nexport PATH="${cliDir}:${interpDir}:$PATH"\n`; + for (const file of ['.zshrc', '.zprofile', '.profile', '.bashrc', '.bash_profile']) { + await writeFile(join(shellHome, file), profile, 'utf8'); + } + + const minimalPath = '/usr/bin:/bin:/usr/sbin:/sbin'; + const brokenRun = spawnSync(cli, ['--version'], { + env: { PATH: `${runtimeBin}:${minimalPath}` }, + encoding: 'utf8', + }); + assert.equal(brokenRun.status, 127); + + const shell = process.platform === 'darwin' ? '/bin/zsh' : '/bin/sh'; + const hostEnv = await resolveHostEnv({ + runtimeBin, + workspace, + platform: process.platform, + env: { + HOME: shellHome, + ZDOTDIR: shellHome, + ENV: join(shellHome, '.profile'), + SHELL: shell, + PATH: minimalPath, + }, + timeoutMs: 5000, + }); + assert.equal(hostEnv.PATH.split(':')[0], runtimeBin); + assert.equal(hostEnv.PATH.split(':').includes(cliDir), true); + assert.equal(hostEnv.PATH.split(':').includes(interpDir), true); + + const inheritedRun = spawnSync(cli, ['--version'], { + env: hostEnv, + encoding: 'utf8', + }); + assert.equal(inheritedRun.status, 0, inheritedRun.stderr); + assert.match(inheritedRun.stdout, /^interp-ok:/); + } finally { + await rm(root, { recursive: true, force: true }); + } +}); diff --git a/docs/development/lessons.md b/docs/development/lessons.md index 082a36d98..292eaf466 100644 --- a/docs/development/lessons.md +++ b/docs/development/lessons.md @@ -195,3 +195,9 @@ When work exposes a consequential risk or a recurring problem, add a lesson or u - **Trigger:** Tightening a command model validator, such as requiring another `expectedVersions` entry at parse time. - **Lesson:** [#645](https://github.com/ThinkFlowLab/OpenDirector/issues/645) needed `generation.submit` to require the origin node version. Commit records also store rejected commands and are parsed with the same models on load, so a submission rejected for that missing version would make the project unreadable if the parser required it. - **Check:** Enforce new preconditions in `validate_command` against the project, and keep parse-time rules unchanged for recorded commands. Verify that a command rejected under the old rule still parses. + +## GUI-launched desktop apps do not inherit the user's shell PATH + +- **Trigger:** Launching the packaged desktop app from macOS Finder/Dock or a desktop launcher and probing an external CLI harness whose entry point uses `#!/usr/bin/env `. +- **Lesson:** Finder launches OpenDirector with `launchd`'s minimal `PATH` (`/usr/bin:/bin:/usr/sbin:/sbin`). Even when fallback discovery finds `~/.pi/agent/bin/pi`, the npm entry script invokes `/usr/bin/env node` while `node` lives in `/opt/homebrew/bin`, causing `pi --version` to exit 127. Terminal-launched smoke tests inherited the CI shell's full `PATH` and missed the failure, and discarding probe `stderr` hid the exit-127 root cause. +- **Check:** Resolve the user's login shell `PATH` once when starting the desktop Host (keeping bundled `runtime/bin` first and falling back cleanly on timeout/failure), log non-zero probe `stderr`, and run POSIX packaged desktop smoke under a stripped `/usr/bin:/bin:/usr/sbin:/sbin` `PATH` with a split-directory `#!/usr/bin/env` harness fixture. diff --git a/packages/core/src/opendirector/agent/pi.py b/packages/core/src/opendirector/agent/pi.py index ae2891d5a..26f1d9568 100644 --- a/packages/core/src/opendirector/agent/pi.py +++ b/packages/core/src/opendirector/agent/pi.py @@ -1,9 +1,12 @@ """pi coding agent: one `pi --mode json` process per turn over its JSONL event stream.""" import asyncio +import logging from opendirector.agent.process import terminate from opendirector.domain.projects import ProjectError +logger = logging.getLogger(__name__) + # A turn only inspects media and edits intermediates; project changes go through the CLI. TOOLS = 'read,bash,write,edit' @@ -89,9 +92,12 @@ def parse_models(output: str) -> list[dict]: async def _run(binary: str, args: list[str], timeout: float) -> tuple[int, str]: process = await asyncio.create_subprocess_exec( binary, *args, stdin=asyncio.subprocess.DEVNULL, stdout=asyncio.subprocess.PIPE, - stderr=asyncio.subprocess.DEVNULL, start_new_session=True) + stderr=asyncio.subprocess.PIPE, start_new_session=True) try: - output, _ = await asyncio.wait_for(process.communicate(), timeout) + output, err = await asyncio.wait_for(process.communicate(), timeout) + if process.returncode: + detail = next((line.strip() for line in err.decode('utf-8', 'replace').splitlines() if line.strip()), '')[:200] + logger.warning('pi probe %s exited with %s%s', args, process.returncode, f': {detail}' if detail else '') return process.returncode, output.decode('utf-8', 'replace') finally: await terminate(process, group=True) diff --git a/tests/test_pi_runtime.py b/tests/test_pi_runtime.py index 0dcf6b358..ce682d302 100644 --- a/tests/test_pi_runtime.py +++ b/tests/test_pi_runtime.py @@ -1,7 +1,9 @@ import asyncio from contextlib import aclosing import json +import logging from pathlib import Path +import sys from uuid import uuid4 import pytest @@ -236,3 +238,36 @@ def test_runtime_ids_and_api_models_admit_every_runtime(): for name in RUNTIMES: assert Turn(id=uuid4(), text='hi', runtime=name).runtime == name assert Draft(runtime=name).runtime == name + + +@pytest.mark.skipif(sys.platform == 'win32', reason='POSIX env shebang test') +def test_shebang_cli_requires_interpreter_on_path_and_logs_stderr(tmp_path, monkeypatch, caplog): + cli_dir = tmp_path / 'cli-bin' + interp_dir = tmp_path / 'interp-bin' + cli_dir.mkdir() + interp_dir.mkdir() + interp = interp_dir / 'od-test-pi-interp' + interp.write_text(f'#!/bin/sh\nexec "{sys.executable}" "$@"\n', encoding='utf-8') + interp.chmod(0o755) + binary = cli_dir / 'pi' + binary.write_text('#!/usr/bin/env od-test-pi-interp\n' + FAKE, encoding='utf-8') + binary.chmod(0o755) + monkeypatch.setattr('opendirector.agent.native.executable', lambda _: str(binary)) + monkeypatch.setattr('opendirector.agent.catalog.executable', lambda _: str(binary)) + monkeypatch.setenv('PI_TABLE', TABLE) + monkeypatch.setenv('PI_READY_PROVIDER', 'acme') + + minimal_path = '/usr/bin:/bin:/usr/sbin:/sbin' + monkeypatch.setenv('PATH', minimal_path) + with caplog.at_level(logging.WARNING, logger='opendirector.agent.pi'): + assert asyncio.run(runtime_readiness('pi')) == 'unknown' + with pytest.raises(ProjectError) as error: + asyncio.run(model_choices('pi')) + assert error.value.status == 503 + assert any('127' in record.message and 'od-test-pi-interp' in record.message for record in caplog.records) + + monkeypatch.setenv('PATH', f'{interp_dir}:{minimal_path}') + assert asyncio.run(runtime_readiness('pi')) == 'ready' + assert [row['id'] for row in asyncio.run(model_choices('pi'))] == [ + 'acme/think-fast', 'acme/plain', 'other/other-model', + ]