Repository navigation
recipes: compare imported analysis code by code equality, not marshal output - #778
Merged
juliankang4 merged 1 commit intoOct 24, 2026
Merged
Conversation
… output Python 3.14 folds constant slices into code constants, and marshal formats before version 5 cannot write a slice, so every reached-input key failed with 'analysis code changed after import'. Marshal output from the current format also depends on object sharing, so it cannot compare imported code with newly compiled code. Code equality compares bytecode, constants, names and line tables recursively on 3.11 through 3.15. The interpreter version joins the cache identity in place of the bytecode digest.
Contributor
There was a problem hiding this comment.
Verdict: CLEAN: The changed comparison preserves stale-import rejection and invalidates older cache identities.
Checked
- Duplicates: 1 replacement helper checked; no existing duplicate owner found. No dryer pairs were reported.
- Complexity: No branches added; compilation, import validation and cache identity retain their existing owners.
- Silent failure: 2 rejection paths followed. Compilation errors and unequal code reach the caller as named errors with no key.
- Tests: No tests changed. The existing stale-import test asserts an error with no key after each analysis module is edited. Removing the mismatch guard would defeat that assertion.
- Gates: No pins, thresholds or test cases moved or were removed.
- Escape catalog: No patterns matched. Older cache identities differ and are rejected before hydration.
Notes
Dryer and crapper did not run because no Rust file changed.
Tests were inspected, not executed during validation. The reported eleven local checks could not be verified from the supplied inputs; the author's Python 3.14/3.15 results were not rerun.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
Collaborator
Author
|
The review is done and the contribution check passed, so I'm merging this. |
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.
Python 3.14 이상에서 reached-input key가 전부 거부되던 문제를 고칩니다.
What and why
On Python 3.14 and 3.15,
tools/recipes-key-test.py --self-testand the recipe self-test reject every reached-input key with "analysis code changed after import", even when no file changed.The cause is in
tools/bloomery/reach_cache.py. Since 3.14 the compiler folds the constant slice indirs[:]into the code constants, andmarshal.dumps(code, 2)cannot write a slice, so it raisesValueError: unmarshallable object._code_identityturns that error into the "changed after import" rejection. Raising the marshal version does not help: the output then depends on object sharing, so an imported code object and a fresh compile of the same bytes dump differently. The imported and the freshly compiled code objects themselves compare equal._code_identitynow compares the two code objects with==, which checks bytecode, constants, names, line tables and flags recursively and gives the same answer on every version. An edit to the file after import is still rejected. The identity row keeps the file path and the SHA-256 of its bytes, and the cache identity now includessys.version, so a cache written by another interpreter is a miss.Release notes: Fixed | Reached-input keys work again on Python 3.14 and 3.15.
Code shape
_disk_code_digestwith_disk_code; no new helper.marshalimport and the second digest are removed.cargo fmtandcargo clippy: no Rust is touched, so I did not run them.Duplication found or removed (
path:line), or "none": none.What I ran
Command, on a Mac mini with Homebrew interpreters for each version:
Before the change, on the base commit:
After the change:
The existing test
test_analysis_code_edited_after_import_never_emits_a_skippable_keyedits each analysis file after import and expects a rejection. It passes on all five versions, which shows a changed file is still caught. I added no new test, since CI runs only one Python version and no test file can reproduce the version split.tools/recipes.py --self-testalso ends with "self-test: ok (227 gate recipes, 0 failures)" on 3.14.9 and 3.15.0.I did not run any GPU gate or a node check; the change is Python tooling only.
Hardware (if the change is for a machine)
Not applicable. CPU-only tooling change.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.