merge queue: embarking main (f6dcf95) and #1272 together#1303
Closed
mergify[bot] wants to merge 2 commits intomainfrom
Closed
merge queue: embarking main (f6dcf95) and #1272 together#1303mergify[bot] wants to merge 2 commits intomainfrom
mergify[bot] wants to merge 2 commits intomainfrom
Conversation
Adds the Python shim that lets the Rust binary dispatch every command to the existing Python implementation. Phase 1.1's deliverable: a Rust binary that, from a user's perspective, behaves identically to the Python CLI. ## What the shim does 1. Embeds the full ``mergify_cli/`` Python source at compile time via ``include_dir!``. Today the payload is ~400KB of .py files plus tests; Phase 1.5 will add a build-time filter to drop the tests tree and any ``__pycache__`` directories. 2. On first invocation, extracts to ``~/.cache/mergify/py/<CARGO_PKG_VERSION>/mergify_cli/`` under a file lock. Extraction is atomic: write to a temp dir, rename, then write a ``.complete`` sentinel. Concurrent first-runs serialize safely; the fast path (sentinel present) touches only one ``exists()`` syscall. 3. Invokes ``python3 -m mergify_cli <args>`` with the extracted directory prepended to ``PYTHONPATH`` and ``PYTHONSAFEPATH=1`` so the cwd never shadows the extracted tree. Exit code and stdin/stdout/stderr are forwarded transparently. ## Cache keying Today the cache is keyed on ``CARGO_PKG_VERSION``. Since that's ``0.0.0`` during dev, the cache is shared across builds — clear ``~/.cache/mergify/py/`` by hand when iterating on Python source in a worktree. Phase 1.5 stamps a real version + git SHA, after which every build invalidates cleanly. ## Binary wire-up ``crates/mergify-cli/src/main.rs`` now delegates every argv tail to ``mergify_py_shim::run``. When Phase 1.3+ ports the first command, native Rust dispatch intercepts it before falling back to the shim for un-ported commands. Phase 6 deletes the shim crate entirely. ## Known gap ``python3`` on PATH must have mergify_cli's runtime dependencies (``httpx``, ``rich``, ``pydantic``, etc.) importable — the shim embeds only the source, not site-packages. Locally you get this via ``uv run``; in production the Python deps have to come from somewhere (PyPI install, a bootstrap venv, or a ``pip``-backed first-run step). Phase 1.5 decides the mechanism. For Phase 1.1 the shim mechanics are validated in isolation. ## Tests Three unit tests in the shim crate cover the extraction logic: files get written, nested directories preserved, second call is idempotent (sentinel fast-path). End-to-end smoke: ``uv run ./target/release/mergify --help`` extracts and produces Python's help output. Binary size: 2.6 MB. Well under the 15 MB design target. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Change-Id: I0c73b039c98011716bc72a441e92e57c6fab9926
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.
🎉 This pull request has been checked successfully and will be merged soon. 🎉
Branch main (f6dcf95) and #1272 are embarked together for merge.
This pull request has been created by Mergify to speculatively check the mergeability of #1272.
You don't need to do anything. Mergify will close this pull request automatically when it is complete.
Required conditions of queue rule
defaultfor merge:title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:#approved-reviews-by>=2author = dependabot[bot]author = mergify-ci-botauthor = renovate[bot]body ~= (?ms:.{48,})#changes-requested-reviews-by = 0#review-requested = 0#review-threads-unresolved = 0check-success=ci-gateRequired conditions to stay in the queue:
base=mainlabel!=manual mergetitle ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:#approved-reviews-by>=2author = dependabot[bot]author = mergify-ci-botauthor = renovate[bot]body ~= (?ms:.{48,})#changes-requested-reviews-by = 0#review-requested = 0#review-threads-unresolved = 0check-success=ci-gate