[AAASM-1227] ✨ (runtime): Add SDK runtime auto-detection and lifecycle (F115)#48
Merged
Merged
Conversation
Module-level constants and the install-hint message that the four lifecycle functions in subsequent commits will share. The orchestrator stays inside the runtime submodule to avoid collision with the existing gateway-based agent_assembly.init_assembly. Refs AAASM-1227 / AAASM-1205.
Resolves the aasm binary in this order: $PATH → ~/.local/bin/aasm → agent_assembly/bin/aasm (wheel-bundled) → /usr/local/bin/aasm (Docker base image). Each non-PATH candidate must exist and be executable to match. Returns Path | None; callers convert None into the install hint. Refs AAASM-1227.
Attempts a 100 ms TCP connect to 127.0.0.1:DEFAULT_PORT and returns the boolean outcome. Any OSError (connection refused, timeout, unreachable) is treated as no sidecar — the lifecycle orchestrator uses this to skip start_runtime() when the sidecar is already up (idempotent re-init). Refs AAASM-1227.
Spawns `aasm serve --port <port>` with stdin closed, stdout+stderr appended to .aasm-runtime.log under log_dir (default: CWD), and start_new_session=True so the child detaches from this process's controlling terminal. Returns the Popen handle; the caller does not block on the child. Refs AAASM-1227.
Implements the F115 four-step lifecycle: probe → resolve binary → spawn. Returns early when is_running() reports a live sidecar (idempotent re-init), raises RuntimeError with INSTALL_HINT when find_aasm_binary() returns None. agent_id is accepted per the AAASM-1227 signature but is not consumed at the lifecycle layer; the existing gateway-aware agent_assembly.init_assembly handles register-and-connect once the sidecar is reachable. Closes AAASM-1227.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Module docstring + imports + the agent_assembly.runtime under-test import. Test functions land in subsequent commits — one per AC scenario (binary-in-PATH, binary-bundled, binary-not-found, already-running). Refs AAASM-1227 / AAASM-1230.
Writes an executable aasm shim into a tmp_path, points PATH at it via monkeypatch, and asserts find_aasm_binary returns that exact path. This is the primary install-via-Homebrew / cargo install / curl installer code path. Also adds the _make_fake_aasm helper that the next two tests will reuse. Refs AAASM-1227 / AAASM-1230.
Empties $PATH, points USER_LOCAL_BIN + DOCKER_BASE_BIN at non-existent dirs, points WHEEL_BUNDLED_BIN at a tmp dir containing the fake aasm shim, and asserts find_aasm_binary returns the bundled path. Covers the `pip install agent-assembly-python[runtime]` wheel scenario from the AAASM-1205 install matrix. Refs AAASM-1227 / AAASM-1230.
Sets every search location to a non-existent directory and forces is_running to return False, then asserts init_assembly raises RuntimeError whose message is exactly runtime.INSTALL_HINT — i.e. the full pip / brew / curl install copy-paste shown to end users. Refs AAASM-1227 / AAASM-1230.
Patches is_running to True and asserts neither find_aasm_binary nor start_runtime is called — the orchestrator's structural guarantee that repeated init_assembly invocations do not spawn duplicate sidecars. Closes the 4th scenario from the AAASM-1230 AC checklist for the Python SDK. Also drops the unused os/subprocess imports the skeleton speculatively included. Refs AAASM-1227 / AAASM-1230.
|
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.


Description
Adds
agent_assembly/runtime.py, a new submodule that implements the F115 runtime lifecycle: locate theaasmRust sidecar, probe whether it's already running, start it if not, and report a clear install hint when no binary is found. The new orchestrator is exposed asagent_assembly.runtime.init_assembly(agent_id)and is not re-exported from the top-level package — the existing gateway-basedagent_assembly.init_assembly(gateway_url, api_key, ...)keeps its meaning.Type of Change
Breaking Changes
The new module is additive. Nothing under
agent_assemblyor any framework adapter is touched.Related Issues
Testing
Tests for
runtime.pyare intentionally deferred to AAASM-1230 (cross-SDK test sub-task) per the story decomposition.Local verification:
ruff check agent_assembly/runtime.py→ cleanruff format --check agent_assembly/runtime.py→ cleanmypy --ignore-missing-imports agent_assembly/runtime.py→ 0 errors attributable to this file (the 10 errors intypes.py,client/gateway.py,core/assembly.pyare pre-existing onmasterHEAD6abb6c3).pre-commit run --files agent_assembly/runtime.py→ all hooks pass except the project-wide mypy step (pre-existing red).Checklist
Commit breakdown (5 commits, each ≈ one logical unit)
✨ (runtime): Add agent_assembly/runtime.py skeleton with F115 constants✨ (runtime): Add find_aasm_binary() resolver across the 5 install paths✨ (runtime): Add is_running() local TCP liveness probe✨ (runtime): Add start_runtime() detached sidecar spawn✨ (runtime): Add init_assembly() lifecycle orchestratorWhat
init_assembly()doesBinary search order
$PATH(viashutil.which)brew install,cargo install~/.local/bin/aasmcurl | shagent_assembly/bin/aasm(wheel-bundled)pip install agent-assembly-python[runtime]/usr/local/bin/aasm