fix: strip inherited class definitions from amends output#45
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
When a module amends a base that defines classes (e.g., Config.pkl defining `class Script`), the class values were included in the base object at depth > 0 but never removed from the amending module's output at depth 0. This caused unexpected fields like "Script" to appear in the JSON output, breaking consumers that use deny_unknown_fields (e.g., hk's Config struct). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a39df41 to
e46975a
Compare
Greptile SummaryThis PR fixes a bug where class definitions declared in an amended base module leaked into the JSON output of the amending module, breaking consumers that use Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["eval_module(module, path, depth)"] --> B{module.amends?}
B -- "local file / file://" --> C["eval_file(base, depth+1)\n→ base_obj includes class defs\n(depth+1 ≠ 0, not stripped)"]
B -- "http/https" --> D["eval_module(base, depth+1)\n→ base_obj includes class defs"]
B -- "package://" --> E["eval_file(pkg_entry, depth+1)\n→ base_obj includes class defs"]
B -- No --> Z
C --> F["Class injection pass\n(local file only)"]
F --> G["scope.set(name, defaults)\nbase_obj.shift_remove(name) ✅ FIX"]
D --> H["No class injection pass\nclass defs remain in base_obj ⚠️"]
E --> I["No class injection pass\nclass defs remain in base_obj ⚠️"]
G --> Z
H --> Z
I --> Z
Z["out = base_obj\n+ current module props"] --> AA{depth == 0?}
AA -- Yes --> AB["strip OWN class_names\nstop own lambdas"]
AA -- No --> AC["keep everything\n(for dotted access)"]
AB --> OUT["Value::Object(out)"]
AC --> OUT
subgraph extends ["extends path (same leak)"]
EX1["eval_module(base, depth+1)\n→ base_obj includes class defs"]
EX2["scope.set class defs\nbut NO shift_remove ⚠️"]
EX1 --> EX2
end
|
Follow-up to #45: the class-definition leak also affected: - `extends` (both local file and HTTP) - `amends` with HTTP and package:// URIs The amends class injection pass now resolves base source for all URI schemes (HTTP via http_cache, package:// via extracted dirs), not just local files. The extends path now calls `base_obj.shift_remove()` for each class definition, matching the amends fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Follow-up to #45: the class-definition leak also affected: - `extends` (both local file and HTTP) - `amends` with HTTP and package:// URIs The amends class injection pass now resolves base source for all URI schemes (HTTP via http_cache, package:// via extracted dirs), not just local files. The extends path now calls `base_obj.shift_remove()` for each class definition, matching the amends fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…#48) ## Summary Follow-up to #45 — the class-definition leak also affected: - `extends` (both local file and HTTP paths) - `amends` with HTTP and `package://` URIs Changes: - The amends class injection pass now resolves base source for all URI schemes (HTTP via `http_cache`, `package://` via extracted dirs), not just local files - The `extends` path now calls `base_obj.shift_remove()` for each class definition, matching the amends fix ## Test plan - [x] Added `amends_strips_inherited_class_definitions` test - [x] Added `extends_strips_inherited_class_definitions` test - [x] All 227 tests pass *This PR was generated by Claude Code.* --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
## 🤖 New release * `pklr`: 0.2.1 -> 0.2.2 (✓ API compatible changes) <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## [0.2.2](v0.2.1...v0.2.2) - 2026-03-24 ### Added - add HTTP URL rewrite support ([#46](#46)) ### Fixed - strip inherited class definitions from extends and remote amends ([#48](#48)) - strip inherited class definitions from amends output ([#45](#45)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/).
Summary
class Script), the class values were included in the JSON output at the top leveldeny_unknown_fields(e.g., hk'sConfigstruct)base_objduring the amends class injection passTest plan
amends_strips_inherited_class_definitionstestThis PR was generated by Claude Code.