Skip to content

[AAASM-1218] ✨ (_install): Add ensure_runtime() install-time runtime fallback#56

Merged
Chisanan232 merged 6 commits into
masterfrom
v0.0.1/AAASM-1218/feat/install_ensure_runtime
May 23, 2026
Merged

[AAASM-1218] ✨ (_install): Add ensure_runtime() install-time runtime fallback#56
Chisanan232 merged 6 commits into
masterfrom
v0.0.1/AAASM-1218/feat/install_ensure_runtime

Conversation

@Chisanan232
Copy link
Copy Markdown
Contributor

Description

Adds agent_assembly/_install.py — a lean, synchronous presence-check module for the aasm sidecar binary, intended for use at SDK import time or early in long-running scripts. Fails fast with a clear install hint when the binary is unavailable, before the user discovers it via a subtle subprocess failure deep in the SDK call.

Resolution order

  1. shutil.which("aasm") — Homebrew tap, cargo install, curl installer default.
  2. agent_assembly/bin/aasm — bundled by the [runtime] platform wheel (AAASM-1215).
  3. RuntimeError(INSTALL_HINT) — copy-paste install commands for all channels.

Why a new module instead of reusing runtime.py

agent_assembly.runtime.find_aasm_binary() and friends manage the full lifecycle (port probe + subprocess spawn). _install.ensure_runtime() is purely presence-check + path-return — usable from contexts that can't yet (or don't want to) bring up the sidecar. Both modules observe the same agent_assembly/bin/aasm wheel-bundled location, so no coordination is needed.

This PR is independent of AAASM-1215/1216/1217 — _install.py works against existing master.

Type of Change

  • ✨ New feature

Breaking Changes

  • No

Net-new module. No existing API changed.

Related Issues

  • Related JIRA ticket: AAASM-1218 (sub-task of Story AAASM-1202, Epic AAASM-1199)

Testing

  • Unit tests added/updated
  • Manual testing performed

test/unit/test_install.py covers all three resolution branches:

  • test_ensure_runtime_returns_path_match_first — PATH binary wins
  • test_ensure_runtime_falls_back_to_wheel_bundled — WHEEL_BUNDLED_BIN used when PATH empty
  • test_ensure_runtime_raises_with_install_hint — RuntimeError carries INSTALL_HINT

Local full-suite run: 380 passed, 11 skipped (skips are pre-existing env-conditional tests).

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Comments added for complex logic
  • Documentation updated if needed
  • All tests passing

Commits

  1. ✨ (_install): Add module skeleton with BINARY_NAME, WHEEL_BUNDLED_BIN, INSTALL_HINT
  2. ✨ (_install): Add ensure_runtime() with PATH/wheel/RuntimeError fallback
  3. ✅ (test): Add isolate_runtime fixture for _install module tests
  4. ✅ (test): Add ensure_runtime returns PATH-resolved binary
  5. ✅ (test): Add ensure_runtime returns wheel-bundled binary when no PATH
  6. ✅ (test): Add ensure_runtime raises RuntimeError with install hint

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…, INSTALL_HINT

Establishes the install-time presence-check module. Module-level
constants only; ensure_runtime() lands in the next commit.

WHEEL_BUNDLED_BIN points to agent_assembly/bin/aasm — the same path
runtime.py already searches, so both modules observe the same wheel
artifact without inter-module coordination.

INSTALL_HINT lists all install channels (pip [runtime] extra,
Homebrew tap, curl installer) so users hitting the missing-binary
case get copy-paste recovery commands.

AAASM-1218
Three-branch resolution:

1. shutil.which(BINARY_NAME) — fastest, covers Homebrew tap, cargo
   install, and any binary on the user's PATH.
2. WHEEL_BUNDLED_BIN file+executable check — covers the platform-wheel
   install (`pip install agent-assembly[runtime]`).
3. Raise RuntimeError(INSTALL_HINT) — fail fast with copy-paste
   recovery commands.

Distinct from runtime.py's find_aasm_binary() in that this is a
synchronous presence check returning the Path (or raising), not a
lifecycle helper that spawns the sidecar. Suitable for use at SDK
import time or early in long-running scripts.

AAASM-1218
Pytest fixture that scrubs the host environment so ensure_runtime()
tests are deterministic:

* PATH is emptied — shutil.which() finds no system binary.
* WHEEL_BUNDLED_BIN is patched to a tmp_path location — tests can
  create or skip the file to exercise each branch.

Yields the fake-binary path so tests can populate it on demand.

AAASM-1218
Verifies the fast-path: a stub executable on PATH wins, regardless
of whether the wheel-bundled path is present. Uses tmp_path to
construct an isolated PATH so the test doesn't depend on the host's
real `aasm` install state.

AAASM-1218
Verifies the second-branch fallback: with PATH scrubbed by
isolate_runtime, ensure_runtime() resolves to WHEEL_BUNDLED_BIN when
the file is present and executable. This exercises the
`pip install agent-assembly[runtime]` installation path.

AAASM-1218
Verifies the unhappy-path branch: with neither a PATH match nor a
wheel-bundled binary, ensure_runtime() raises RuntimeError and the
exception text contains the full INSTALL_HINT (pip [runtime],
Homebrew tap, curl installer) — so a user hitting this in
production gets actionable copy-paste recovery commands.

AAASM-1218
@Chisanan232 Chisanan232 force-pushed the v0.0.1/AAASM-1218/feat/install_ensure_runtime branch from 261616b to 3d6c20d Compare May 23, 2026 05:09
@sonarqubecloud
Copy link
Copy Markdown

@Chisanan232 Chisanan232 merged commit 594dbd9 into master May 23, 2026
24 checks passed
@Chisanan232 Chisanan232 deleted the v0.0.1/AAASM-1218/feat/install_ensure_runtime branch May 23, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant