Implementation Plan: Perf — Drop-in Regex Package + Enable uvloop for MCP Server#2206
Merged
Trecek merged 8 commits intoMay 8, 2026
Conversation
- Add regex>=2026.1 and uvloop>=0.21.0; sys_platform != 'win32' to runtime deps
- Replace bare `import re` with `import regex as re` across all src/autoskillit/
production modules except hooks/ and hook_registry.py (stdlib-only boundary)
- Change cli/app.py:128 anyio.run() call to pass backend="asyncio" and
backend_options={"use_uvloop": True} — enables uvloop for MCP server only
- Add test_src_uses_regex_not_bare_re arch guard (tests/arch/test_regex_import.py)
- Add test_serve_passes_uvloop_backend_options unit test
- Update test_rules_ci.py Pattern isinstance checks to accept regex.Pattern
alongside re.Pattern (regex is a drop-in superset)
- Update tests/arch/CLAUDE.md file table with new test file
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… change Replacing `import re` (stdlib) with `import regex as re` (third-party) caused ruff to insert a blank import-group separator line in several files, shifting subsequent line numbers by +1. Update SESSION_SIZE_BUDGETS and _LEGACY_JSON_WRITES to reflect the new line numbers.
core/ is IL-0 (stdlib-only, zero third-party imports). _install_detect.py, github_url.py, and core/types/_type_helpers.py all use only basic regex patterns that stdlib re handles identically.
…tError uvloop has a sys_platform != 'win32' dependency marker, so anyio's asyncio backend would raise ImportError when use_uvloop=True on Windows.
- test_regex_import: exempt core/ (IL-0, stdlib-only) from the regex guard; also check ast.ImportFrom to catch 'from re import ...' patterns - test_rules_ci: assert regex.Pattern exclusively for _NO_RUNS_RE and _TIMED_OUT_RE — dual isinstance check was too weak and would pass if the regex migration were accidentally reverted
Production serve() evaluates sys.platform != 'win32' at call time, so the test's unconditional assertion on use_uvloop is True would fail on Windows. Monkeypatching sys.platform to 'linux' pins the evaluation to True, and the docstring is updated to reflect the platform-conditional behavior.
…e uniformity The _re alias was preserved from the original stdlib import re as _re migration but the underscore prefix is unnecessary since _re is not re-exported. Aligns with the codebase-wide convention of import regex as re.
…t-rebase pre-commit) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
25f9ab6 to
bcfe417
Compare
Trecek
added a commit
that referenced
this pull request
May 8, 2026
… MCP Server (#2206) ## Summary Two independent, mechanical performance improvements with zero API changes: 1. **regex package**: Add `regex>=2026.1` to runtime deps and replace every `import re` with `import regex as re` across all `src/autoskillit/` production modules **except** `hooks/` and `hook_registry.py` (which are stdlib-only for subprocess safety). The `regex` package is a 100% API-compatible C-extension superset of `re`. 2. **uvloop for MCP server**: Add `uvloop>=0.21.0; sys_platform != "win32"` to runtime deps and change the single `anyio.run()` call in `cli/app.py:128` to pass `backend="asyncio"` and `backend_options={"use_uvloop": True}`. This applies exclusively to the MCP server entrypoint — the non-server `asyncio.run()` calls at `cli/app.py:292,388` (used for `quota_status` and `workspace_clean`) are NOT changed, since those paths spawn subprocesses where uvloop is benchmarked 2x slower. ## Acceptance Criteria - [ ] `regex` added to dependencies - [ ] uvloop enabled for MCP server backend - [ ] All existing tests pass - [ ] No subprocess spawning paths use uvloop ## Architecture Impact This PR includes validated architecture diagrams from the `concurrency` and `module-dependency` lenses. Please review the plan file for full diagram details. Closes #2190 ## Implementation Plan Plan file: `/home/talon/projects/autoskillit-runs/impl-20260507-160445-342766/.autoskillit/temp/make-plan/perf_drop_in_regex_uvloop_plan_2026-05-07_160445.md` 🤖 Generated with [Claude Code](https://claude.com/claude-code) via AutoSkillit <!-- autoskillit:pipeline-signature steps=prepare_pr,run_arch_lenses,compose_pr,annotate_pr_diff,review_pr --> ## Token Usage Summary | Step | Model | count | uncached | output | cache_read | peak_ctx | turns | cache_write | time | |------|-------|-------|----------|--------|------------|----------|-------|-------------|------| | plan | claude-sonnet-4-6 | 1 | 117 | 15.2k | 489.6k | 57.7k | 61 | 51.6k | 8m 22s | | verify | claude-sonnet-4-6 | 1 | 164 | 14.6k | 946.2k | 62.7k | 62 | 50.1k | 4m 20s | | implement* | MiniMax-M2.7-highspeed | 1 | 1.9M | 16.6k | 1.9M | 71.5k | 133 | 79.8k | 13m 33s | | fix | claude-sonnet-4-6 | 1 | 192 | 11.3k | 1.1M | 65.0k | 58 | 54.8k | 14m 43s | | prepare_pr* | MiniMax-M2.7-highspeed | 1 | 81.7k | 6.3k | 172.4k | 28.7k | 17 | 41.1k | 1m 40s | | compose_pr* | MiniMax-M2.7-highspeed | 1 | 49.6k | 1.2k | 198.3k | 28.7k | 14 | 15.1k | 37s | | **Total** | | | 2.0M | 65.2k | 4.8M | 71.5k | | 292.5k | 43m 18s | \* *Step used a non-Anthropic provider; caching behavior may differ.* ## Token Efficiency | Step | LoC Changed | cache_read/LoC | cache_write/LoC | output/LoC | |------|-------------|----------------|-----------------|------------| | plan | 0 | — | — | — | | verify | 0 | — | — | — | | implement | 418 | 4478.4 | 190.8 | 39.8 | | fix | 18 | 62136.1 | 3046.1 | 627.6 | | prepare_pr | 0 | — | — | — | | compose_pr | 0 | — | — | — | | **Total** | **436** | 11002.2 | 670.8 | 149.6 | ## Model Usage Breakdown | Model | steps | uncached | output | cache_read | cache_write | time | |-------|-------|----------|--------|------------|-------------|------| | claude-sonnet-4-6 | 3 | 473 | 41.1k | 2.6M | 156.6k | 27m 27s | | MiniMax-M2.7-highspeed | 3 | 2.0M | 24.1k | 2.2M | 135.9k | 15m 50s | --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Two independent, mechanical performance improvements with zero API changes:
regex package: Add
regex>=2026.1to runtime deps and replace everyimport rewithimport regex as reacross allsrc/autoskillit/production modules excepthooks/andhook_registry.py(which are stdlib-only for subprocess safety). Theregexpackage is a 100% API-compatible C-extension superset ofre.uvloop for MCP server: Add
uvloop>=0.21.0; sys_platform != "win32"to runtime deps and change the singleanyio.run()call incli/app.py:128to passbackend="asyncio"andbackend_options={"use_uvloop": True}. This applies exclusively to the MCP server entrypoint — the non-serverasyncio.run()calls atcli/app.py:292,388(used forquota_statusandworkspace_clean) are NOT changed, since those paths spawn subprocesses where uvloop is benchmarked 2x slower.Acceptance Criteria
regexadded to dependenciesArchitecture Impact
This PR includes validated architecture diagrams from the
concurrencyandmodule-dependencylenses. Please review the plan file for full diagram details.Closes #2190
Implementation Plan
Plan file:
/home/talon/projects/autoskillit-runs/impl-20260507-160445-342766/.autoskillit/temp/make-plan/perf_drop_in_regex_uvloop_plan_2026-05-07_160445.md🤖 Generated with Claude Code via AutoSkillit
Token Usage Summary
* Step used a non-Anthropic provider; caching behavior may differ.
Token Efficiency
Model Usage Breakdown