Skip to content

fix(lang-python): preserve grouped imports in the oracle - #781

Merged
avidianity merged 5 commits into
mainfrom
fix/python-oracle-imports
Dec 2, 2026
Merged

avidianity merged 5 commits into
mainfrom
fix/python-oracle-imports

Conversation

@avidianity

@avidianity avidianity commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

Report named Python from-imports in the grouped form used by the Language plugin.
The evaluator can compare the original imported names, including aliased names and Unicode source spelling.

Closes #780

Tier

Tier 3 from cargo xtask risk-tier --base origin/main.
The test-oracle guard flags the updated assertion for the former bare-module output.

Task

  • Preserve and sort original names from the same module.
  • Keep relative imports, wildcard imports, and existing oracle thresholds.
  • Reproduce the mismatch with a one-file regression and verify the actual evaluator.

Fail-first test

python_oracle::the_python_oracle_preserves_names_in_a_from_import ran once and failed.
The oracle emitted collections instead of from collections import Counter.
After grouping was fixed, the extended fixture ran once and failed because the AST emitted K for the original name K. The extended fixture also reproduced two Unicode module keys collapsing into one, and the CR-only fixture exposed an oracle crash. Those cases ran and passed after the follow-up. On Python 3.12.15, the encoding regression ran once and failed with invalid or missing encoding declaration for a valid Latin-1 source file. The final six-test group passed on Python 3.12.15.

Checks

Check Result
Python oracle integration tests 6 passed on Python 3.12.15, including the named grouping, CR-only, and Latin-1 regressions
Evaluation documentation accuracy 3 passed
Hooks and merged-result Passed
Standards and Independent Spec review PASS on de599cd72a61560464666c544b5e41c5fd242a03
Corpus workflow All eight jobs passed, including Python. Exact-revision run

Safety proof

The change preserves the import comparison and its recall and precision thresholds.
The regression asserts the original names, deduplication, relative imports, wildcard imports, and source spelling for an AST-normalized name.
The actual evaluator verified one expected static import, one actual import, and one match.
The adversarial probes confirmed distinct Unicode module spellings, CR-only line endings, and valid Latin-1 cookies on Python 3.12.15. The focused changes preserved oracle error records and thresholds.

Runtime evidence

A one-file Git fixture used from collections import Counter.
Before the fix, codeint check exited 0 and codeint-eval exited 1 with 0/1 matches.
After the fix, both exited 0 with 1/1 matches.
The Evaluation HOW-TO documents this comparison.

Risk summary

The Python corpus check compares grouped import names against the plugin.
Incorrect grouping can lower measured recall or precision and fail the corpus job.
Reverting restores the previous oracle output and the reproduced corpus failure.
Recommendation: merge on required CI and a green Python corpus run.
The Owner approved the focused fix.

Gaps

  • Deferred coverage: Broad checks run in CI.
  • Pre-existing parser limitation: The Python scanner misses an inline named import after a lambda condition. The corrected oracle exposes that miss in an adversarial fixture. The scanner is outside this issue.
  • Environmental failures: None observed.

@github-actions github-actions Bot added the tier-3 Tier 3 from the tier check label Dec 2, 2026
@avidianity
avidianity merged commit 79a0199 into main Dec 2, 2026
29 checks passed
@avidianity
avidianity deleted the fix/python-oracle-imports branch December 2, 2026 21:58
@avidianity avidianity mentioned this pull request Dec 2, 2026
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tier-3 Tier 3 from the tier check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python corpus oracle drops names from grouped imports

1 participant