Derive widget canvas metadata from NODE_SPEC - #50
Merged
Conversation
Every bundled widget re-declared the six canvas-metadata attributes (name, description, icon, category, keywords, priority) its NODE_SPEC already carries. Extend ZugWidget.__init_subclass__'s spec derivation to cover them and delete the duplicates from all 26 widgets (-171 lines). A pre-change sweep confirmed zero widget/spec mismatches, so no canvas-visible value changes; the shared test_node_spec_consistency now pins all six fields (previously only name) so drift is caught if a widget overrides one. Also remove the unreachable unmigrated-widget scaffolding from PatchMethodWidget: every bundled widget declares a node_spec with a task factory, so the generated-params-model fallback and the task built from widget-level method_name/call_style attributes could never run. Those four leftover widget attrs (taper, detrend, analytic, ufunc_unary) were dead. _OPTIONS subclasses must now declare their own node_spec; get_task always goes through node_spec.build_task.
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.
Description
The last structural decoupling item from the architecture review: every bundled widget re-declared the six canvas-metadata attributes (
name,description,icon,category,keywords,priority) that itsNODE_SPECalready carries. This PR makes the spec the single source:ZugWidget.__init_subclass__'s existing spec derivation (_SPEC_DERIVED_ATTRS) now also covers the six metadata fields, filling them in only when the widget class doesn't declare its own — deliberate overrides still work.derzug.widgetsentry point and compared all six fields against the spec: zero mismatches, so nothing canvas-visible changes.test_node_spec_consistencynow pins all six fields (previously onlyname), so any future widget/spec drift fails the widget's default test suite.Also removes the unreachable "unmigrated widget" scaffolding from
PatchMethodWidget: with every bundled widget declaring anode_spec+ task factory, the generated-params-model fallback and theoptions_task_factorytask built from widget-levelmethod_name/call_styleattributes could never run — and the four leftovermethod_name/call_styleattrs on taper/detrend/analytic/ufunc_unary were dead._OPTIONSsubclasses must now declare their ownnode_spec(enforced with a clearTypeError), andget_taskalways goes throughnode_spec.build_task. The Qt-freebuild_params_model/options_task_factoryremain where they belong — used by the node modules themselves.CHANGELOG updated under Changed (breaking) for the external-subclass contract tightening.
Counterpart review: Codex CLI still rate-limited (resets Aug 8); adversarial self-review record in the untracked
.scratch/review_spec_metadata.md(pre-change drift sweep, derivation-order check vs Orange discovery, AST-based deletion validation, and confirmation that the node modules still own the options machinery).Checklist
I have (if applicable):
test_node_spec_consistencynow asserts all six metadata fields across every widget's default suite).prek run --all-filesandpytest tests(2114 passed, 44 skipped; all 10 hooks pass — staged before linting this time).python scripts/bench_compare.py --baseline main. (n/a — class-creation-time attribute copies; no executed path changes)