Repository navigation
feat(repo-map): activate TypeScript/JavaScript tsconfig paths/baseUrl during scan (#540) - #546
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce210a3996
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
ce210a3 to
41a2ac4
Compare
|
codex P2 "resolve inherited tsconfig options before indexing" (tsconfig #540 explicitly scopes out config inheritance ( |
f6632d8 to
17fc59f
Compare
… during scan (#540) Wire the tsconfig alias parser (#481) into a real scan_repo via the #484 scan-local preparation lifecycle. TypeScriptResolver now implements the prepare(context) hook: it derives a scan-local _TsConfigIndex of every tsconfig.json keyed by its own directory and returns a fresh scan-local resolver carrying it, so the registered singleton is never mutated and sequential/concurrent scans share nothing. Each importer resolves its non-relative specifiers against its NEAREST applicable tsconfig, so paths/baseUrl aliases resolve to real files without flattening unrelated workspaces' alias tables into one. A missing config is the silent path-only fallback; an unreadable or malformed/non-UTF-8 config degrades to path-only with one deterministic `other` warning, never aborting the scan. parse_tsconfig is split into _load_tsconfig_json + _build_tsconfig so preparation can tell a malformed config from a valid-but-empty one (to emit the warning) without a second parse; its public behaviour is unchanged. Committed sibling-workspace fixture (ts_workspaces) plus an exact-edge-set scan test with the alias-edge positive AND the sibling-workspace true negative, so an over-matching resolver that flattened both configs cannot pass.
17fc59f to
77061c1
Compare
🤖 I have created a release *beep* *boop* --- ## [0.58.0](v0.57.1...v0.58.0) (2026-07-20) ### Features * **repo-map:** activate TypeScript/JavaScript tsconfig paths/baseUrl during scan ([#540](#540)) ([#546](#546)) ([e321a33](e321a33)) --- 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>
…red input (#563) (#565) Closes #563. Hardens the repo-map import resolvers against the six adversarial/misconfigured-input edge cases from the post-merge codex review of the #484 adapter features (#546/#547/#548, shipped in 0.60.0). Each was reproduced as a **red test first** and confirmed on current `main` (the issue warns codex findings can be stale), then fixed with a true-negative test. ## Reconcile (all six confirmed on `main`) Probed on `main` (d9aecf6, 0.60.0) with the `[treesitter]` extra on Python 3.14 (`recursionlimit=1000`); every finding reproduced. Recorded on the issue: #563 (comment) | # | Finding | Before | After | |---|---|---|---| | 1 | TS absolute import specifier via catch-all `paths` | `/outside/pkg` resolves to `src/fixed.ts` (phantom) | no edge | | 2 | TS bare-drive `baseUrl: "C:"` (no separator) | `util` resolves to `C:/util.ts` (phantom) | alias config dropped | | 3 | PHP absolute PSR-4 base `/src/` | `App\Widget` resolves to `packages/a/src/Widget.php` (phantom) | base treated as external | | 4 | C# drive-absolute `<ProjectReference>` | `C:\B\B.csproj` folds to `A/C:/B` (phantom) | no edge | | 5 | C# ~1,500 nested namespaces | `RecursionError` aborts the scan | scan completes | | 6 | C# `Condition="false"` `<ProjectReference>` | reference added | reference skipped | **Drift found (recorded on the issue):** finding #5 had a second crash site the issue did not cite. `extract` also raises `RecursionError` via the recursive `TSNode.descendants()` generator, not only `declared_namespaces`. The fix makes **both** walk sites iterative. ## Changes - **Unified out-of-repo guard:** a shared `is_out_of_repo_specifier()` in `repo_map_resolvers/base.py` (a leading `/`, `\`, or a Windows drive `C:` **with or without** a trailing separator). Used at every entry point the issue named (TS import specifier + `baseUrl`/`paths` targets, PHP PSR-4 base dirs, C# `<ProjectReference>` include) so absoluteness is judged identically. A repo-escaping value that lands back in-repo (a sibling `../shared` package/project) stays legitimate; only truly-absolute (and escape-above-root, already covered) values drop. - **TS** (`typescript.py`): an absolute import specifier no longer alias-resolves; `_WINDOWS_DRIVE_RE`'s trailing-separator requirement (which let `C:` through) is replaced by the shared guard. - **PHP** (`php.py`): an absolute PSR-4 base dir is dropped instead of anchored into a phantom in-repo path; a sibling-escaping base still resolves. - **C#** (`csharp.py`): an absolute include emits no edge; a literal-false `Condition` (`"false"`/`'false'`, exact spelling) reference is skipped, other conditions kept (full MSBuild condition evaluation is out of scope). - **No-abort robustness** (`csharp.py` `_collect_namespaces`, `repo_map_treesitter.py` `descendants()`): both walks are now iterative, so a pathologically deep namespace nest degrades gracefully instead of overflowing the recursion limit and aborting the whole scan. Took the scope's "iterative walk" option (the file still indexes and the scan completes) over the depth-cap-degrade alternative. ## Review The sumo-qa self-review passed the diff, then an adversarial codex pass over the local diff (pre-PR) found two further edge cases, both fixed with red→green regression tests in this PR: - **PHP root `/` base:** a base of exactly `/` was collapsed to `""` by `_normalise_dir` **before** the absolute guard ran, so `App\Widget` still produced a phantom `packages/a/Widget.php`. The guard now checks the **raw** base in `_normalise_psr4`, before normalization strips the `/`. - **C# `Condition="' false '"`:** whitespace inside the quotes was being trimmed, mis-classifying `' false '` as literal-false. MSBuild only recognizes the exact `'false'` spelling, so the inner strip was removed; `' false '` and any other condition now stay enabled. ## Evidence - New red→green tests per finding, each with a true-negative that a legitimate in-repo value still resolves: TS specifier + bare-drive `baseUrl`; PHP absolute base + root-`/` base + sibling-escape-still-resolves; C# drive-absolute include + literal-false-Condition-skipped + non-false-Condition-kept + inner-whitespace-Condition-kept; C# deep-nest unit (`declared_namespaces` and `extract`) + end-to-end `scan_repo` no-abort. - Full suite green at **100% coverage**. The two local failures (`test_built_wheel_contains_py_typed_marker` and `test_module_fallback_when_script_not_on_path`) are pre-existing uv-venv artifacts: the venv lacks `pip`, and `sys.executable`'s path literally contains `uv`. Both pass on CI and reproduce identically on clean `main`. - `ruff check`, `ruff format`, `mypy` clean. - No regression to #484 activation (the scan-activation + resolver suites stay green). `docs/REPO-MAP.md` updated. ## Acceptance criteria - [x] Each phantom-edge case emits no edge: red test first, true-negative test after. - [x] The deep-nested C# namespace case completes the scan instead of raising (iterative walk, the scope-sanctioned alternative to "degrade to path-only"; the file indexes and the scan continues). - [x] Literal-false `Condition` references are skipped. - [x] No regression to #484 activation behaviour. - [x] 100% coverage intact. ## Post-open review (/finish-pr) A per-file `sumo-qa-reviewing-before-merge` pass during /finish-pr found that this PR's diff had accidentally dropped the final assertion of an unrelated pre-existing PHP test (`test_prepare_returns_new_instance_and_leaves_singleton_path_only`): the line proving the prepared resolver still resolves its PSR-4 import. Restored in a follow-up commit (the assertion passes; the suite stays green at 100% coverage). The same pass surfaced a pre-existing C# gap: a literal-false `Condition` on an ancestor `<ItemGroup>` (as opposed to the `<ProjectReference>`'s own `Condition`, which this PR now skips) is not evaluated. That is out of this issue's scope (non-goal: no full MSBuild condition evaluator) and is documented as a limitation; tracked as follow-up #568.
#708) Updates the requirements on [mutmut](https://github.com/boxed/mutmut) to permit the latest version. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/boxed/mutmut/releases">mutmut's releases</a>.</em></p> <blockquote> <h2>3.8.0</h2> <h2>What's Changed</h2> <ul> <li>feat: mutate ternary conditions by <a href="https://github.com/espressolee"><code>@espressolee</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/546">boxed/mutmut#546</a></li> <li>fix: mutate methods of decorated classes by <a href="https://github.com/Sanjays2402"><code>@Sanjays2402</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/539">boxed/mutmut#539</a></li> <li>Add mutation score badge support by <a href="https://github.com/rxdt"><code>@rxdt</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/549">boxed/mutmut#549</a></li> <li>wip: don't mutate lines excluded from coverage by <a href="https://github.com/nedbat"><code>@nedbat</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/547">boxed/mutmut#547</a></li> <li>chore: add support python3.15 by <a href="https://github.com/even-even"><code>@even-even</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/551">boxed/mutmut#551</a></li> <li>Fix mutants missed when tests clear os.environ by <a href="https://github.com/DSeaStar"><code>@DSeaStar</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/552">boxed/mutmut#552</a></li> <li>chore: up mypy to 2.3.1 by <a href="https://github.com/even-even"><code>@even-even</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/553">boxed/mutmut#553</a></li> <li>Honour 'pragma: no mutate block' on else/except/finally arms by <a href="https://github.com/dylanpulver"><code>@dylanpulver</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/559">boxed/mutmut#559</a></li> <li>refac: main decomposition by <a href="https://github.com/nicklafleur"><code>@nicklafleur</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/561">boxed/mutmut#561</a></li> <li>ci: pre-commit workflow by <a href="https://github.com/nicklafleur"><code>@nicklafleur</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/567">boxed/mutmut#567</a></li> <li>fix: delete twice "-24" param and up ruff for tests it by <a href="https://github.com/even-even"><code>@even-even</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/565">boxed/mutmut#565</a></li> <li>Fix "pragma: no mutate" on match/case headers being silently ignored by <a href="https://github.com/mathieu-lacage"><code>@mathieu-lacage</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/554">boxed/mutmut#554</a></li> <li>misc: update history by <a href="https://github.com/nicklafleur"><code>@nicklafleur</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/576">boxed/mutmut#576</a></li> <li>feat: process isolation and fork-safe test runners by <a href="https://github.com/nicklafleur"><code>@nicklafleur</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/566">boxed/mutmut#566</a></li> <li>Fix obsolete test names never being removed from the stats file by <a href="https://github.com/t-roi33"><code>@t-roi33</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/569">boxed/mutmut#569</a></li> <li>Release 3.8.0 by <a href="https://github.com/nicklafleur"><code>@nicklafleur</code></a> in <a href="https://redirect.github.com/boxed/mutmut/pull/581">boxed/mutmut#581</a></li> </ul> <h2>New Contributors</h2> <ul> <li><a href="https://github.com/espressolee"><code>@espressolee</code></a> made their first contribution in <a href="https://redirect.github.com/boxed/mutmut/pull/546">boxed/mutmut#546</a></li> <li><a href="https://github.com/rxdt"><code>@rxdt</code></a> made their first contribution in <a href="https://redirect.github.com/boxed/mutmut/pull/549">boxed/mutmut#549</a></li> <li><a href="https://github.com/nedbat"><code>@nedbat</code></a> made their first contribution in <a href="https://redirect.github.com/boxed/mutmut/pull/547">boxed/mutmut#547</a></li> <li><a href="https://github.com/DSeaStar"><code>@DSeaStar</code></a> made their first contribution in <a href="https://redirect.github.com/boxed/mutmut/pull/552">boxed/mutmut#552</a></li> <li><a href="https://github.com/dylanpulver"><code>@dylanpulver</code></a> made their first contribution in <a href="https://redirect.github.com/boxed/mutmut/pull/559">boxed/mutmut#559</a></li> <li><a href="https://github.com/mathieu-lacage"><code>@mathieu-lacage</code></a> made their first contribution in <a href="https://redirect.github.com/boxed/mutmut/pull/554">boxed/mutmut#554</a></li> <li><a href="https://github.com/t-roi33"><code>@t-roi33</code></a> made their first contribution in <a href="https://redirect.github.com/boxed/mutmut/pull/569">boxed/mutmut#569</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/boxed/mutmut/compare/3.7.0...3.8.0">https://github.com/boxed/mutmut/compare/3.7.0...3.8.0</a></p> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/boxed/mutmut/blob/main/HISTORY.rst">mutmut's changelog</a>.</em></p> <blockquote> <p>3.8.0</p> <pre><code> * Fix obsolete test names never being removed from ``mutants/mutmut-stats.json`` (`[#564](https://github.com/boxed/mutmut/issues/564)`) <ul> <li> <p>Fix <code># pragma: no mutate block</code> being silently ignored when placed on an <code>else</code>, <code>except</code>, <code>except*</code> or <code>finally</code> header, and on the <code>try</code> line of a <code>try</code>/<code>except*</code> (<code>[#559](https://github.com/boxed/mutmut/issues/559)</code>)</p> </li> <li> <p>Fix <code># pragma: no mutate</code> being silently ignored on <code>match</code> and <code>case</code> headers (<code>[#554](https://github.com/boxed/mutmut/issues/554)</code>)</p> </li> <li> <p>Fix mutants being reported as survived when a test uses <code>patch.dict(os.environ, ..., clear=True)</code> (<code>[#511](https://github.com/boxed/mutmut/issues/511)</code>, <code>[#552](https://github.com/boxed/mutmut/issues/552)</code>)</p> </li> <li> <p>Fix <code>mutate_only_covered_lines</code> mutating code that coverage.py excludes from measurement (<code># pragma: no cover</code>, <code>exclude_lines</code>, <code>exclude_also</code>) (<code>[#547](https://github.com/boxed/mutmut/issues/547)</code>)</p> </li> <li> <p>Fix mutations that delete ignored code. Dropping a <code>case</code> from a <code>match</code>, or an argument from a call, is a mutation of the enclosing node, so it used to be made even when the removed lines were themselves ignored (<code>[#547](https://github.com/boxed/mutmut/issues/547)</code>)</p> </li> <li> <p>Fix methods of decorated classes (for example <code>@DataClass</code>) not being mutated (<code>[#480](https://github.com/boxed/mutmut/issues/480)</code>, <code>[#539](https://github.com/boxed/mutmut/issues/539)</code>)</p> </li> <li> <p>Fix time measurement including test setup/teardown instead of only the main test run (<code>[#544](https://github.com/boxed/mutmut/issues/544)</code>)</p> </li> <li> <p>Fix mutants stopped by the CPU-time limit being reported as killed instead of timed out (<code>[#565](https://github.com/boxed/mutmut/issues/565)</code>)</p> </li> <li> <p>Fix <code>mutate_only_covered_lines</code> breaking when the test suite imports a dependency that cannot be initialized twice in one process, which raised for numpy and libyaml, produced misleading type errors for cryptography, and segfaulted for asyncpg. Coverage is now gathered in a separate process, so the modules the coverage run imports are no longer unloaded and re-imported in the main process (<code>[#528](https://github.com/boxed/mutmut/issues/528)</code>, <code>[#566](https://github.com/boxed/mutmut/issues/566)</code>)</p> </li> <li> <p>Mutate the condition of ternary expressions (<code>[#196](https://github.com/boxed/mutmut/issues/196)</code>, <code>[#546](https://github.com/boxed/mutmut/issues/546)</code>)</p> </li> <li> <p>Add a <code>process_isolation</code> config for choosing which process mutant workers are forked from. The new <code>forkserver</code> strategy keeps mutmut's main process free of pytest and your <code>conftest.py</code>, routing every fork through a dedicated fork server process, for test setups that are not fork-safe (<code>gevent</code>, <code>grpc</code>, <code>torch</code>). Tune what it preloads with <code>forkserver_warmup</code> (<code>[#578](https://github.com/boxed/mutmut/issues/578)</code>, <code>[#566](https://github.com/boxed/mutmut/issues/566)</code>)</p> </li> <li> <p>Add a <code>badge</code> command that writes a shields.io endpoint file, for publishing the mutation score (<code>[#549](https://github.com/boxed/mutmut/issues/549)</code>)</p> </li> <li> <p>Support python3.15 (<code>[#551](https://github.com/boxed/mutmut/issues/551)</code>)</p> </li> </ul> <p>3.7.0</p> <pre><code> * Fix the trampoline dropping a generator's return value, so ``yield from`` on a mutated generator no longer yields ``None`` instead of its result * Fix async generators, so that `aclose()`/`athrow()` are handled by the `except`/`finally` blocks of the mutated function instead of being swallowed by the trampoline * Fix `max_stack_depth` when a test changes the working directory (for example via a tmpdir fixture) * Fix `type_check_command` reporting type errors in copied files that have no mutants * Per-function source hashing for incremental cache invalidation — only re-test mutants in functions that changed * Cross-call dependency tracking — invalidate mutants in callers when a called function changes * Use git to detect non-Python dependency file changes; falls back to a curated file list when git is unavailable * Add `cache_invalidation_exclude` config to suppress noisy files from change detection &lt;/tr&gt;&lt;/table&gt; </code></pre> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="boxed/mutmut@14a7230049a5c8abd90c2bb0f7438e30da6471f5"><code>14a7230</code></a> Release 3.8.0 (<a href="https://redirect.github.com/boxed/mutmut/issues/581">#581</a>)</li> <li><a href="boxed/mutmut@4ff5d9e9c23c5f75404cc3696ad6fb7c1e4888e8"><code>4ff5d9e</code></a> Fix obsolete test names never being removed from the stats file (<a href="https://redirect.github.com/boxed/mutmut/issues/569">#569</a>)</li> <li><a href="boxed/mutmut@c3a8f4b402b01873cc788774c0ce15d2a1cebb86"><code>c3a8f4b</code></a> feat: process isolation and fork-safe test runners (<a href="https://redirect.github.com/boxed/mutmut/issues/566">#566</a>)</li> <li><a href="boxed/mutmut@7f8ba005185ac98216cbeedfcacffeb4229366fa"><code>7f8ba00</code></a> misc: update history (<a href="https://redirect.github.com/boxed/mutmut/issues/576">#576</a>)</li> <li><a href="boxed/mutmut@301df52797ae34a1fadac176cd2afa50186050ea"><code>301df52</code></a> Fix pragma: no mutate on match/case headers being silently ignored</li> <li><a href="boxed/mutmut@630e84662635eb57d35fe935365af0152d58094a"><code>630e846</code></a> fix: delete twice &quot;-24&quot; param and up ruff for tests it</li> <li><a href="boxed/mutmut@b1d127060ad4f79d2e81f8317842263435586851"><code>b1d1270</code></a> ci: pre-commit workflow (<a href="https://redirect.github.com/boxed/mutmut/issues/567">#567</a>)</li> <li><a href="boxed/mutmut@748bfc06bddbeb09855dda592c2156cb9ef42310"><code>748bfc0</code></a> refac: main decomposition (<a href="https://redirect.github.com/boxed/mutmut/issues/561">#561</a>)</li> <li><a href="boxed/mutmut@2f39c84dcbf3b9fdabafe395200d090d4f47de65"><code>2f39c84</code></a> Honour 'pragma: no mutate block' on else/except/finally arms (<a href="https://redirect.github.com/boxed/mutmut/issues/559">#559</a>)</li> <li><a href="boxed/mutmut@e450cfcf52ce5bbd89941cef9c2e988cb798231b"><code>e450cfc</code></a> chore: up mypy to 2.3.1</li> <li>Additional commits viewable in <a href="boxed/mutmut@3.7.0...3.8.0">compare view</a></li> </ul> </details> <br /></code></pre> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: sumithr <38540179+sumithr@users.noreply.github.com>
Closes #540. Part of epic #484 (TypeScript/JavaScript language-adapter slice).
Activates scan-time TS/JS tsconfig
paths/baseUrlalias resolution through the already-mergedPreparableResolver.prepare(context)foundation (#525).What changed
TypeScriptResolver.prepare(context)builds a per-directory_TsConfigIndexfrom the scan's bounded reads;_nearest_tsconfigselects each importer's nearesttsconfig.json(unrelated workspaces' alias tables are never flattened). Returns a new scan-local instance; the registered singleton is never mutated.otherwarning, shadow to path-only; a RecursionError/ValueError on pathological JSON never aborts the scan.baseUrl(leading/,\, or a Windows driveC://C:\) OR an absolute/escapingpathstarget drops to path-only, so no phantom (false-dependency) edge is emitted.\->/) inbaseUrl/paths.tests/fixtures/repo_map/ts_workspaces/(two sibling workspaces) with an exact-edge-set scan test and a sibling-workspace true negative.Deferred
extendsinheritance was attempted on this branch but pulled back out: it did not converge under incremental review (it needs a ground-up design pass covering string/array/DAG extends, merge/clear semantics, absolute-path fail-closed, and context-correct memoization). Tracked as [Task]: TypeScript tsconfigextendsinheritance (ground-up design, full spec) #555.extendsis currently a safe no-op (ignored, never a wrong edge).Evidence
uv run pytest -q: 3246 passed, 4 skipped, 1 xfailed; 100% coverage. ruff + mypy + pre-commit clean.reviewing-before-merge: SAFE (per-file). codex adversarial pass: reviewed the core clean across multiple passes (every finding was in the now-removedextends); the final post-revert confirmation hit a codex broker outage, so re-run codex before merge if you want a fresh pass.scan_repoon the fixture emits the alias edge in each workspace and no cross-config edge for the sibling.