Repository navigation
fix(repo-map): resolve src-layout Python imports and add Python/Java import-edge fixtures - #790
Merged
Merged
Conversation
15 tasks done
Python and Java were the only import-edge resolvers without a committed multi-file fixture tree, which epic #353's acceptance criteria require. Add a src-layout Python package and a two-module Maven project, each pinned by an exact-edge-set scan_repo test that also covers the external and unproven-root true negatives. Part of #353
…ven poms Compare sorted edge lists instead of dicts so a duplicated edge fails, name the src-layout script import as an accepted under-edge rather than a true negative, and give the Java fixture its parent and module poms. Part of #353
A src-layout project's tests and scripts import the installed package, but src/ is never one of their ancestor roots, so those imports emitted no edge and analyze_diff_impact missed the dependants. The Python resolver now prepares a scan-local root per project whose marker file (pyproject.toml, setup.py or setup.cfg) sits beside a src/ holding a regular package, searched after the importer's own ancestors. Part of #353
A src/ holding its own __init__.py is a flat layout imported as src.x, so it is no longer treated as an installed-package root. The docs now say the root helps scripts and tools outside src/: test files link to sources through likely_tests and emit no import edges. Part of #353
A one-segment nested project has the root project's slash count, so the deepest-first sort needs its tiebreak; a test now fails without it. Docs name the flat-layout exclusion and a fixture comment says where the marker must sit. Part of #353
sumithr
force-pushed
the
chore/epic-353-close-gate
branch
from
October 1, 2026 13:37
fa75cb5 to
963af91
Compare
sumithr
added a commit
that referenced
this pull request
Oct 1, 2026
🤖 I have created a release *beep* *boop* --- ## [0.68.4](v0.68.3...v0.68.4) (2026-10-01) ### Bug Fixes * **repo-map:** resolve src-layout Python imports and add Python/Java import-edge fixtures ([#790](#790)) ([7b69cff](7b69cff)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: release-please[bot] <release-please[bot]@users.noreply.github.com>
This was referenced Oct 2, 2026
sumithr
added a commit
that referenced
this pull request
Oct 3, 2026
… context into one call, and audit context budgets in CI (#812) ## Summary Three context-cost changes from #512: a compact session bootstrap, a one-call bundle mode for a routed skill's working context (wired into `sumo-qa-reviewing-before-merge` only), and a deterministic context-budget audit that runs in CI. A build-time pass also serves every tool description through `inspect.cleandoc`, so `tools/list` is identical on every supported Python. Measured honestly: the bundle does NOT reduce turns or total tokens on a real review. It makes the review load its modules in one call where the per-loader path skipped them. Details under "How it was verified". ## Related issue Refs #512. Child of epic #508. This PR does not close #512: its turn/token acceptance criterion is not met (see below), and wiring the bundle into the other routed skills is split to #802, which first re-checks the premise per skill family. Bringing every root skill under its token budget is #798. ## Changes - **Compact bootstrap.** `hooks/session-start` injects `hooks/compact-bootstrap.md` (the QA-trigger rule, the canonical first hop, and a fallback naming the absolute router path) instead of the full router body. It falls back to the full body when `uvx` is missing; `SUMO_QA_BOOTSTRAP=auto|compact|full` overrides, and an unrecognised value adds a one-line notice. On Git Bash the path is converted with `cygpath -m`. Claude, Cursor and Codex/Copilot envelopes are unchanged and schema-valid. - **Bundle mode.** `sumo_qa_load_skill_context(mode="bundle", classification=..., modules=..., include_body=...)` returns the skill body, the named modules, the catalogue entries, and the rules and standards in one call. - Rules and standards parts are `sumo_qa_load_rules` / `sumo_qa_load_standards` called once each with the same argument, so they equal the single loaders by construction. - Catalogue entries are looked up by exact id. Classification ids are matched exactly (case-sensitive), in request order. Any id that matches nothing returns an error envelope listing the catalogue ids plus the rules keys. A loader exception returns an "unreadable" envelope; the tool never raises. - Module ids are split on commas and looked up exactly as `mode="module"` does. - `known_hash` / `content_hash` and the oversize cap work on the served form. - `src/sumo_qa/knowledge_loaders.py` is unchanged from `main`. - **Review skill.** Step 3 makes one bundle call: `test-only-diff` when every changed file is a test, otherwise `runtime-scope`, `discovery-probes`, `coverage-ledger` plus any conditional module the file list calls for. The root stays within its 3,000-token ceiling. The deciding-approach routing line names the bundle call and stays within its own budget. - **Tool descriptions.** MCPServer serves a tool's docstring unchanged. Python 3.13+ strips docstring indentation at compile time and 3.10 to 3.12 keep it, so `tools/list` used to be larger on the older interpreters. A build-time pass now normalises every served description with `inspect.cleandoc`, and a test pins that no served description carries docstring indentation. - **Conformance.** Scenario S02 requires rules to be loaded: `sumo_qa_load_rules`, or a bundle call with a classification (argument-aware `required_one_of`). A module-only call fails it. - **Audit.** `scripts/audit_context_budget.py` reads `[tool.sumo-qa.context-budget]` in `pyproject.toml`, measures the real hook and the real server, and fails configured budgets. CI runs it as the `context-budget` job, and the suite enforces it on every pytest matrix leg. The root-skill budget is report-only. - **Docs.** ARCHITECTURE (session bootstrap), TOOLS, SKILLS, DEVELOPMENT, README. Rebased onto `main` after the tool registry with core and full profiles (#811) and the executable-ness routing change (#818) landed. ## How it was verified - **Audit (`context budget: OK`, identical on Python 3.12 and 3.14):** compact bootstrap 359 estimated tokens (budget 1,000; the full router body is 4,185); tools/list 11,681 of 11,900; bundles 5,547 of 5,800 (business logic), 6,719 of 7,000 (security), 2,218 of 2,250 (test-only). Modelled per workflow, the bundle cuts loader calls from 11/12/9 to 6. Before the description fix, Python 3.12 measured tools/list at 12,525 and failed the budget, which is why the 3.10 to 3.12 pytest legs were red. - **Real session measurement (`compare-mcp-versions --review-mode`, haiku, one run each, a real review of the #790 diff, tests run, full ledger and verdict on both sides):** | | main | this branch (ab4cf33) | |---|---|---| | Total tokens | 1,405,091 | 1,485,677 (+5.7%) | | API calls | 17 | 17 | | Cost | $0.361 | $0.383 | | Review modules loaded | none | runtime-scope, discovery-probes, coverage-ledger (one call) | | Verdict | SAFE TO MERGE | SAFE TO MERGE | The #512 criterion "reaches its ledger in measurably fewer turns than the 16-call baseline" is not met: that baseline came from a Gemini CLI run, and on haiku both versions take 17 calls. Main is cheaper partly because it never loads the review modules. The compact bootstrap saving is not in this measurement, because the harness launches the server without the plugin's SessionStart hook. Full write-up on #512. - **Behaviour on a clean wheel build, driven by headless haiku through the MCP tools:** in a real Claude Code session the SessionStart hook injected 390 estimated tokens with no router body, and a non-QA prompt made no sumo-qa call. A development-framed QA prompt took the first hop (`using_sumo_qa`, `sumo_qa_deciding_approach`, one routed skill). A review prompt loaded its context in one bundle call. The bundle's rules, standards and module text were byte-identical to the separate loader calls. `using_sumo_qa` and `sumo_qa_load_classifications` returned identical output on this branch and on `main`. The hook was also run with uvx absent, with `SUMO_QA_BOOTSTRAP=full`, `compact` and an unknown value, and in the Codex shape. - **Evals (Claude pair, on the final skill text):** `skill-reviewing-before-merge.yaml` 1/1; `skill-deciding-approach.yaml` 5/5. - **Byte-identity:** `load_rules()`, `load_standards()`, `load_rules("api_contract_change")`, `load_rules("Business_Logic_Change")` and `load_standards("api_contract_change")` return the same text as `main`. - **Suite:** full local suite 5,411 passed, 7 skipped, 1 xfailed, 100% coverage. - **Review:** sumo-qa per-file review of every changed file plus `/code-review` high on the full diff and on every fix delta. Rounds 2 to 4 of the original review kept finding mismatches between a case-insensitive bundle and the case-sensitive loaders, so the bundle was simplified to pass ids through to the unchanged loaders. The post-rebase fixes (the budget trim, the description normalisation and a test docstring correction) were reviewed in two rounds, which found no high or medium defect. Not changed, deliberately: the bundle's error lists rules keys but not standards-only ids (the message says those are accepted too); rules-file keys containing separators are listed but cannot be requested; the bundle is not wired into the other routed skills (#802). ## Checklist - [x] PR title follows [Conventional Commits](https://www.conventionalcommits.org/) - [x] Tests pass locally (`pytest`) and lint/type checks are green (`pre-commit run --all-files`, `python -m mypy`) - [x] Added or updated tests covering the change - [x] Updated the relevant docs in this same PR - [x] No breaking changes (or they are called out above)
9 tasks
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
Closes the last acceptance-criteria gaps on epic #353.
scan_repotest.src/that imports the project's installed package used to get no import edge, soanalyze_diff_impactmissed it. Test files are unaffected: they link to sources throughlikely_testsand emit no import edges.Related issue
Closes #353
Changes
src/sumo_qa/repo_map_resolvers/python.py: newpreparestep. A directory withpyproject.toml,setup.pyorsetup.cfgbeside asrc/holding a regular package adds thatsrc/as an import root for every file in the project, searched after the file's own ancestor roots. Nested projects resolve against their ownsrc/first. Asrc/with no marker, only namespace dirs, or its own__init__.py(flat layout) adds no root. An explicitpackage-dirsetting is not read.tests/fixtures/repo_map/python_project/: src-layout package with relative, lazy, package-stop, external and outside-src imports.tests/fixtures/repo_map/java_project/: two-module Maven project with single-type, wildcard and static cross-module imports, plus JDK and third-party drops.docs/REPO-MAP.md: Python repository-context paragraph.How it was verified
src/sumo_qa/report_html.pychanged,scripts/regen_report_snapshots.pyis now an affected node at high confidence; main does not list it. Import edges went from 180 to 185, matching the script's 5sumo_qaimports. Router payload is byte-identical to main.Checklist
pytest) and lint/type checks are green