Skip to content

The agent that grows with you

fix(ci): lint legs after the main merge

ethernet9214174e07c9
diff --git a/apps/desktop/scripts/verify-side-by-side-macos.mjs b/apps/desktop/scripts/verify-side-by-side-macos.mjs
index e9fa740bcab..f3feaef311b 100644
--- a/apps/desktop/scripts/verify-side-by-side-macos.mjs
+++ b/apps/desktop/scripts/verify-side-by-side-macos.mjs
@@ -32,7 +32,7 @@ assert.deepEqual(
cases.map(row => row.label),
['stable', 'canary', 'commit-a', 'commit-b']
)
-const root = fs.mkdtempSync('/tmp/hermes-sxs-macos-')
+const root = fs.mkdtempSync(path.join(os.tmpdir(), 'hermes-sxs-macos-'))
const home = path.join(root, 'home')
fs.mkdirSync(home)
const env = {
diff --git a/hermes_cli/auth_codex.py b/hermes_cli/auth_codex.py
index 37940c25ad4..85810d8587d 100644
--- a/hermes_cli/auth_codex.py
+++ b/hermes_cli/auth_codex.py
@@ -322,30 +322,44 @@ def _codex_login_post(url: str, *, failure: Tuple[str, str], **kwargs: Any) -> "
_CODEX_AUTH_BODY_MAX_BYTES = 1024 * 1024 # real OAuth/device-auth payloads are a few hundred bytes
-class _CappedByteStream(httpx.SyncByteStream):
- """Body stream that raises once more than ``_CODEX_AUTH_BODY_MAX_BYTES`` came off the wire.
+def _capped_byte_stream_class() -> type:
+ """Build the capped stream subclass on first use.
- httpx type-checks ``response.stream`` against ``SyncByteStream``, so the cap has to be a
- stream subclass rather than a bare generator.
+ The base class is ``httpx.SyncByteStream``; naming it at module scope would resolve the
+ lazy ``httpx`` proxy at import time and put httpx back on the interactive-CLI startup path
+ (see ``auth_constants``).
"""
+ cached = getattr(_capped_byte_stream_class, "cls", None)
+ if cached is not None:
+ return cached
+
+ class _CappedByteStream(httpx.SyncByteStream):
+ """Body stream that raises once more than ``_CODEX_AUTH_BODY_MAX_BYTES`` came off the wire.
+
+ httpx type-checks ``response.stream`` against ``SyncByteStream``, so the cap has to be a
+ stream subclass rather than a bare generator.
+ """
+
+ def __init__(self, response: "httpx.Response") -> None:
+ self._response, self._raw = response, response.stream
+
+ def __iter__(self) -> Iterator[bytes]:
+ total = 0
+ for chunk in self._raw: # type: ignore[union-attr] # sync client only
+ total += len(chunk)
+ if total > _CODEX_AUTH_BODY_MAX_BYTES:
+ self.close()
+ raise _codex_err(
+ f"Codex auth response from {self._response.url.host} exceeded "
+ f"{_CODEX_AUTH_BODY_MAX_BYTES // 1024} KiB; refusing to parse it.",
+ "codex_auth_response_too_large", relogin=False)
+ yield chunk
- def __init__(self, response: "httpx.Response") -> None:
- self._response, self._raw = response, response.stream
-
- def __iter__(self) -> Iterator[bytes]:
- total = 0
- for chunk in self._raw: # type: ignore[union-attr] # sync client only
- total += len(chunk)
- if total > _CODEX_AUTH_BODY_MAX_BYTES:
- self.close()
- raise _codex_err(
- f"Codex auth response from {self._response.url.host} exceeded "
- f"{_CODEX_AUTH_BODY_MAX_BYTES // 1024} KiB; refusing to parse it.",
- "codex_auth_response_too_large", relogin=False)
- yield chunk
+ def close(self) -> None:
+ self._raw.close() # type: ignore[union-attr]
- def close(self) -> None:
- self._raw.close() # type: ignore[union-attr]
+ _capped_byte_stream_class.cls = _CappedByteStream # type: ignore[attr-defined]
+ return _CappedByteStream
def _cap_codex_response_body(response: "httpx.Response") -> None:
@@ -355,7 +369,7 @@ def _cap_codex_response_body(response: "httpx.Response") -> None:
200 with megabytes of "JSON" is cut off at the cap instead of being fully buffered and parsed
(#55253). Same cap for every status: error bodies are small diagnostics too.
"""
- response.stream = _CappedByteStream(response)
+ response.stream = _capped_byte_stream_class()(response)
def _codex_http_client(**kwargs: Any) -> "httpx.Client":
diff --git a/hermes_cli/update_stage.py b/hermes_cli/update_stage.py
index 0c09f61b845..877dfcf2384 100644
--- a/hermes_cli/update_stage.py
+++ b/hermes_cli/update_stage.py
@@ -57,8 +57,8 @@ def _status_from_marker() -> Path | None:
return None
if pid <= 0:
return None
- tmpdir = os.environ.get("TMPDIR") or "/tmp"
- candidate = Path(tmpdir) / f"hermes-update-status.{pid}"
+ # The shim writes beside ${TMPDIR:-/tmp}; gettempdir() resolves the same way.
+ candidate = Path(tempfile.gettempdir()) / f"hermes-update-status.{pid}"
return candidate if candidate.is_file() else None
diff --git a/pyproject.toml b/pyproject.toml
index 3233bf17744..2e6702d92a8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -847,10 +847,12 @@ select = ["PLW1514", "ASYNC210", "ASYNC220", "ASYNC221", "ASYNC251", "TID251"]
"pm.install.uv".msg = "The raw uv bridge was removed; use PM operations."
"pm._uv".msg = "Tool acquisition is private to PM."
"pm.environment".msg = "The environment engine is private; use PM operations."
-"pm.runtime_stage".msg = "Use pm.stage_manager_runtime for build-time bootstrap."
+"pm.runtime_stage".msg = "PM stages its own worker runtime; consumers call pm operations."
[tool.ruff.lint.per-file-ignores]
"pm/**" = ["TID251"]
+# Desktop E2E fixtures stand in for PM's worker/runtime and reach into it like tests do.
+"apps/desktop/electron/fixtures/**" = ["TID251"]
# Tests can intentionally exercise locale-encoding edge cases.
"tests/**" = [
"PLW1514",
diff --git a/scripts/install.sh b/scripts/install.sh
index 06ab9b5dd3b..6af17465e73 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -135,6 +135,7 @@ ensure_uv() {
if [ ! -x "$UV_CMD" ]; then
log "staging pinned uv $UV_PIN_VERSION ($_target) into the pm store"
local _tmp
+ # no-tmp: ok — last-resort fallback when mktemp itself is missing
_tmp="$(mktemp -d 2>/dev/null || echo "/tmp/hermes-uv-bootstrap.$$")"
mkdir -p "$_tmp"
local _fetched_from="$UV_PIN_URL"
diff --git a/scripts/termux/build_deb.sh b/scripts/termux/build_deb.sh
index d9b889ae65c..62c0bd62f8a 100644
--- a/scripts/termux/build_deb.sh
+++ b/scripts/termux/build_deb.sh
@@ -237,13 +237,14 @@ rm -rf "$STAGE"
[ -f "$DEB" ] || fail "dpkg-deb did not produce $DEB"
# The bare rootfs has no build toolchain to hide a missing payload library.
+ctmp=/tmp # no-tmp: ok — mount point inside the arm64 test container, not host scratch
docker run --rm --platform linux/arm64 \
--user 1000:1000 --network none \
- -v "$DEB:/tmp/pkg.deb:ro" \
- -v "$HERE/check_deb.sh:/tmp/check.sh:ro" \
- -v "$HERE/validate_installed.py:/tmp/validate_installed.py:ro" \
+ -v "$DEB:$ctmp/pkg.deb:ro" \
+ -v "$HERE/check_deb.sh:$ctmp/check.sh:ro" \
+ -v "$HERE/validate_installed.py:$ctmp/validate_installed.py:ro" \
"termux/termux-docker@$DIGEST" bash -c \
- 'source /tmp/check.sh; "$root/venv/bin/python" -m pm.cli status' \
+ "source $ctmp/check.sh; \"\$root/venv/bin/python\" -m pm.cli status" \
|| fail "container validation failed"
log "Built $DEB (validated)"
diff --git a/scripts/termux/check_apt.sh b/scripts/termux/check_apt.sh
index c45ddffdc82..3b257626621 100755
--- a/scripts/termux/check_apt.sh
+++ b/scripts/termux/check_apt.sh
@@ -6,6 +6,7 @@ export PATH="$PREFIX/bin:$PATH"
suite="${1:?APT suite required}"
expected="${2:?expected package version required}"
repository="${3:-file:/apt}"
+ctmp=/tmp # no-tmp: ok — where the caller mounts validate_installed.py inside this container
work="$(mktemp -d "$PREFIX/tmp/hermes-apt-proof.XXXXXX")"
trap 'rm -rf "$work"' EXIT
mkdir -p "$work/lists/partial" "$work/archives/partial"
@@ -34,7 +35,7 @@ actual="$(dpkg-query -W -f='${Version}' hermes-agent)"
root="$PREFIX/lib/hermes-agent"
export LD_LIBRARY_PATH="$root/tools/python$PREFIX/lib:$root/tools/node$PREFIX/lib:$root/tools/ffmpeg$PREFIX/lib:$root/runtime-libs/lib:$PREFIX/lib"
export PYTHONPATH="$root/app"
-"$root/venv/bin/python" /tmp/validate_installed.py
+"$root/venv/bin/python" "$ctmp/validate_installed.py"
printf 'SIGNED_APT_INSTALL_OK %s\n' "$actual"
if [ -f /previous.deb ]; then
printf 'SIGNED_APT_UPGRADE_OK %s -> %s\n' "$previous" "$actual"
diff --git a/scripts/termux/check_deb.sh b/scripts/termux/check_deb.sh
index 8e451d58286..b9bbbb45a2f 100755
--- a/scripts/termux/check_deb.sh
+++ b/scripts/termux/check_deb.sh
@@ -4,13 +4,14 @@ set -euo pipefail
export PREFIX=/data/data/com.termux/files/usr
export PATH="$PREFIX/bin:$PATH"
mkdir -p "$PREFIX/tmp"
+ctmp=/tmp # no-tmp: ok — where build_deb.sh mounts the inputs inside this container
# Termux runs without root. The image already owns the writable prefix.
-dpkg --force-not-root --force-script-chrootless --install /tmp/pkg.deb
+dpkg --force-not-root --force-script-chrootless --install "$ctmp/pkg.deb"
root="$PREFIX/lib/hermes-agent"
export LD_LIBRARY_PATH="$root/tools/python$PREFIX/lib:$root/tools/node$PREFIX/lib:$root/tools/ffmpeg$PREFIX/lib:$root/runtime-libs/lib:$PREFIX/lib"
export PYTHONPATH="$root/app"
-"$root/venv/bin/python" /tmp/validate_installed.py
+"$root/venv/bin/python" "$ctmp/validate_installed.py"
# Reinstall exercises maintainer-script idempotence without changing user state.
-dpkg --force-not-root --force-script-chrootless --install /tmp/pkg.deb
+dpkg --force-not-root --force-script-chrootless --install "$ctmp/pkg.deb"
[ "$(readlink "$PREFIX/bin/hermes")" = ../lib/hermes-agent/bin/hermes ]
printf 'DEB_INSTALL_AND_REINSTALL_OK\n'
diff --git a/tests-js/scripts/desktop-smoke.test.ts b/tests-js/scripts/desktop-smoke.test.ts
index 09fd5327d32..2ca37ea1138 100644
--- a/tests-js/scripts/desktop-smoke.test.ts
+++ b/tests-js/scripts/desktop-smoke.test.ts
@@ -324,12 +324,14 @@ test('a bundle-env HERMES_HOME clear cannot strand the mock config outside the r
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'smoke-bundle-clear-'))
const home = path.join(root, 'home')
const userData = path.join(root, 'root', 'user-data')
- // A real-but-dummy executable: admission passes, seeding runs, and the
- // Electron launch then fails fast because this is not an Electron app.
+ // A real-but-dummy executable so admission passes and seeding runs; the
+ // launcher itself is substituted below, so Playwright never spawns it (a
+ // process that exits at once leaves Playwright with dangling rejections).
const exe = path.join(root, 'root', 'fake-desktop')
fs.mkdirSync(path.join(root, 'root'), { recursive: true })
fs.writeFileSync(exe, '#!/bin/sh\nexit 1\n')
fs.chmodSync(exe, 0o755)
+ const refuseLaunch = async (): Promise<never> => { throw new Error('launch refused by test') }
try {
const mock = await startMockServer()
try {
@@ -337,7 +339,7 @@ test('a bundle-env HERMES_HOME clear cannot strand the mock config outside the r
// resolveDesktopHermesHome falls to <userData>/hermes-home. The driver must
// have seeded THAT home, not only the --home the caller named.
await expect(runInstalledDesktopSmoke({ exe, root: path.join(root, 'root'), origin: 'bundled', home,
- 'user-data': userData, out: root, phase: 'installed', 'expect-commit': 'a'.repeat(40) })).rejects.toThrow()
+ 'user-data': userData, out: root, phase: 'installed', 'expect-commit': 'a'.repeat(40) }, refuseLaunch)).rejects.toThrow('launch refused by test')
for (const candidate of candidateSmokeHermesHomes(home, userData)) {
expect(yaml.load(fs.readFileSync(path.join(candidate, 'config.yaml'), 'utf8'))).toMatchObject({ model: { provider: 'custom' } })
expect(fs.readFileSync(path.join(candidate, '.env'), 'utf8')).toMatch(/MOCK_API_KEY=/)
diff --git a/tests/install/e2e-assets/desktop-smoke.ts b/tests/install/e2e-assets/desktop-smoke.ts
index c9f1c495b06..37d7acffef6 100644
--- a/tests/install/e2e-assets/desktop-smoke.ts
+++ b/tests/install/e2e-assets/desktop-smoke.ts
@@ -262,7 +262,11 @@ async function verifyRunningDesktop(app: ElectronApplication, options: SmokeOpti
return running
}
-export async function runInstalledDesktopSmoke(options: SmokeOptions): Promise<void> {
+export type LaunchElectron = (launch: Parameters<typeof _electron.launch>[0]) => Promise<ElectronApplication>
+
+// `launchApp` is a parameter so a test can substitute a failing launcher and
+// exercise the seeding that happens before the launch without touching Playwright.
+export async function runInstalledDesktopSmoke(options: SmokeOptions, launchApp: LaunchElectron = (launch) => _electron.launch(launch)): Promise<void> {
const out = options.out
fs.mkdirSync(out, { recursive: true })
const receiptPath = path.join(out, `desktop-chat-${options.phase}.json`)
@@ -301,7 +305,7 @@ export async function runInstalledDesktopSmoke(options: SmokeOptions): Promise<v
writeMockProviderConfig(home, mockUrl)
writeEnvFile(home)
}
- app = await _electron.launch({ ...launch, timeout: 120_000 })
+ app = await launchApp({ ...launch, timeout: 120_000 })
app.process().stdout?.on('data', (chunk: Buffer): void => { consoleLines.push(redact(chunk.toString())) })
app.process().stderr?.on('data', (chunk: Buffer): void => { consoleLines.push(redact(chunk.toString())) })