Skip to content

Prove Textual creation hooks under OrderPreservingReads & cache star-import scan - #638

Merged
trissim merged 1 commit into
mainfrom
fix/class-creation-prefix-namespace-loop
Nov 27, 2026
Merged

trissim merged 1 commit into
mainfrom
fix/class-creation-prefix-namespace-loop

Conversation

@trissim

@trissim trissim commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Numbers

  • Live Toad sibling_override_step synthesis: 0 -> 3 executable candidates unlocked (5b2d3de6af FuzzyPane.toggled, 153131fe1f FuzzyPane.cursor_owner, 78b1dafe63 ConversationThreadSidebar.make_panels)
  • Live Toad synthesis wall-clock: >120s timeout -> 8.2s after removing quadratic ast.walk(module.module) per decorator on installed modules
  • Focused + guard tests: 101/101 passing (test_installed_creation_hooks.py 16/16, test_restated_overrides.py 20/20, test_class_overlap_codemod.py 58/58, test_repository_architecture.py 7/7), REL_IMPORTS=0

Mechanisms

  1. OrderPreservingReads(CreationReads) (class_creation.py, restated_overrides.py): shared intermediate class for MRO-preserving creation proofs (walk.before == walk.after), inherited by both BaseDropReads and MemberDeletionReads (hoisting walked_by, walked, only_stores, setattr, and deleting the duplicates on BaseDropReads).
  2. Textual _MessagePumpMeta & DeclaredWidgetActions proofs (class_creation.py):
    • Unmatched attr.startswith(prefix) namespace loops (textual/message_pump.py:144), refusing whenever the composer binds or moves a prefix* name.
    • Metaclass-ancestry fallback in CreationReads.called (textual/message_pump.py:157 built._compile_dispatch()).
    • Type-filtered values()/items() namespace loops behind isinstance(v, PlainClass) (textual/_on.py DispatchScope.from_class).
    • JoinedStr constant prefix/suffix key avoidance in CreationReads.constant_key (toad/widget_actions.py:179), with _in_own_function_scope ignoring comprehension-scoped variables of the same name.
    • Prefix-filtered dir(cls) comprehensions (textual/dom.py:1039 startswith(('_compute_', 'compute_'))), still refusing matching moved/added names and keeping unfiltered dir(cls) strict.
  3. AbstractHooksMeta modelled (class_creation_store.py:39): added metaclass_registry.abstract_hooks.AbstractHooksMeta to MODELLED_METACLASSES (identical __abstractmethods__ contract to abc.ABCMeta).
  4. Quadratic scan removed (ast_tools.py:875, binding_proofs.py:279, class_creation.py:647): cached ParsedModule.has_star_import (eliminating repeated ast.walk(textual/widget.py) per decorator) and short-circuited type_filtered_bindings_unchanged to O(|deleted|) when walk.before == walk.after.

…r-import scan

- Add OrderPreservingReads(CreationReads) shared by BaseDropReads and MemberDeletionReads (hoisting walked_by, walked, only_stores, setattr, and plain_class; eliminating duplicate BaseDropReads overrides)
- Prove unmatched prefix-filtered namespace loops (textual/message_pump.py:144), metaclass-ancestry method resolution in CreationReads.called (:157), type-filtered namespace values/items loops (:163 DispatchScope.from_class), f-string prefix/suffix key avoidance (toad/widget_actions.py:179), and prefix-filtered dir(cls) comprehensions (textual/dom.py:1039)
- Add metaclass_registry.abstract_hooks.AbstractHooksMeta to MODELLED_METACLASSES (same __abstractmethods__ contract as abc.ABCMeta)
- Cache ParsedModule.has_star_import and short-circuit type_filtered_bindings_unchanged when walk.before == walk.after (eliminating quadratic ast.walk(module.module) per decorator on installed Textual modules; live Toad sibling_override_step >120s timeout -> 8.2s, unlocking 0 -> 3 executable candidates)
@trissim
trissim merged commit c07a399 into main Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant