Parameter Analysis Architecture Auditο
Overviewο
This document audits the current parameter analysis systems in OpenHCS TUI and identifies architectural inconsistencies that need to be addressed.
Current Systemsο
2. FieldIntrospector (openhcs/textual_tui/services/config_reflection_service.py)ο
Purpose: Analyze dataclass fields for form generation Features:
- β No docstring parsing - β
Field metadata extraction - β
Nested
dataclass support - β
Returns FieldSpec objects - β No help
functionality
Usage Patterns:
# Config dialogs and screens
field_specs = FieldIntrospector.analyze_dataclass(config_class, instance)
config_form = ConfigFormWidget(field_specs)
Current Usage Analysisο
β Correct Implementationsο
FunctionPaneWidget (
openhcs/textual_tui/widgets/function_pane.py:42-46)param_info = SignatureAnalyzer.analyze(self.func) self.form_manager = ParameterFormManager(parameters, parameter_types, f"func_{index}", param_info)
ConfigFormWidget (
openhcs/textual_tui/widgets/config_form.py:49-54)param_info = SignatureAnalyzer.analyze(dataclass_type) self.form_manager = ParameterFormManager(parameters, parameter_types, "config", param_info)
β Inconsistent Implementationsο
StepParameterEditor (
openhcs/textual_tui/widgets/step_parameter_editor.py:34-49)# INCONSISTENCY: Analyzes parameters but doesn't pass param_info to form manager! param_info = SignatureAnalyzer.analyze(FunctionStep.__init__) # β Gets parameter info # ... processes param_info to build parameters dict ... # β But doesn't pass param_info to ParameterFormManager! self.form_manager = ParameterFormManager(parameters, parameter_types, "step") # Should be: ParameterFormManager(parameters, parameter_types, "step", param_info)
Nested Dataclass Forms (
openhcs/textual_tui/widgets/shared/parameter_form_manager.py:57-60)# β Nested forms created without parameter_info! nested_form_manager = ParameterFormManager( nested_parameters, nested_parameter_types, nested_field_id ) # Should analyze nested dataclass: SignatureAnalyzer.analyze(param_type)
ConfigFormScreen (
openhcs/textual_tui/screens/config_form.py:88-114)# Duplicate form creation logic - bypasses ParameterFormManager entirely! # Creates widgets manually instead of using shared form manager
Architectural Issues Identifiedο
1. Dual Analysis Systemsο
SignatureAnalyzerandFieldIntrospectordo overlapping workFieldIntrospectorlacks docstring parsing capabilitiesDifferent return types:
ParameterInfovsFieldSpec
2. Inconsistent Constructor Usageο
Some components pass
parameter_info, others donβtMissing help functionality in components without
parameter_info
3. Duplicate Form Creation Logicο
ConfigFormScreencreates widgets manuallyParameterFormManagercreates widgets systematicallyTwo different approaches for the same goal
4. Missing Help in Nested Formsο
Nested dataclass forms donβt receive
parameter_infoNo help buttons for nested parameters
5. Architectural Driftο
Function forms evolved with
SignatureAnalyzerConfig forms evolved with
FieldIntrospectorRecent fixes created hybrid approaches
Impact Assessmentο
Current Stateο
Function parameters: β Full help functionality (param_info passed correctly)
Config parameters: β Help functionality (recently fixed - param_info now passed)
Step parameters: β No help functionality (param_info analyzed but not passed)
Nested parameters: β No help functionality (param_info never analyzed for nested forms)
Manual config forms: β No help functionality (bypasses ParameterFormManager entirely)
User Experience Impactο
Inconsistent help availability: Function params have (?) help, step params donβt
Confusing UX: Similar-looking parameter forms behave differently
Missing documentation: Users canβt get help for step configuration
Architectural confusion: Developers donβt know which pattern to follow
Technical Debtο
Code duplication: Multiple form creation patterns for same goal
Maintenance burden: Changes need to be made in multiple places
Testing complexity: Different code paths for similar functionality
Onboarding difficulty: New developers confused by inconsistent patterns
Recommendationsο
Eliminate FieldIntrospector - Replace with SignatureAnalyzer
Standardize ParameterFormManager usage - Always pass parameter_info
Fix nested dataclass forms - Propagate parameter_info to nested forms
Remove duplicate form creation - Use ParameterFormManager everywhere
Create unified interface - Single entry point for all parameter analysis
Summaryο
Critical Issues Foundο
StepParameterEditor inconsistency: Analyzes parameters but doesnβt pass param_info to form manager
Nested dataclass forms: No parameter analysis, missing help functionality
Manual config forms: Bypass ParameterFormManager, duplicate form creation logic
Architectural drift: Two different analysis systems (SignatureAnalyzer vs FieldIntrospector)
Quick Wins (Low Risk, High Impact)ο
Fix StepParameterEditor to pass param_info (1-line change)
Fix nested dataclass forms to analyze and pass param_info
Remove manual config form creation, use ParameterFormManager
Major Refactoring (Higher Risk, High Impact)ο
Eliminate FieldIntrospector duplication
Create unified parameter analysis interface
Comprehensive testing of unified system
Refactoring Progressο
β Completed Tasksο
β Audit Parameter Analysis Architecture (COMPLETE)
Documented all inconsistencies and architectural drift
Identified specific files and line numbers requiring changes
β Create Unified Parameter Analysis Interface (COMPLETE)
Created
UnifiedParameterAnalyzerwith consistent interfaceAdded comprehensive tests and migration guide
Provided backward compatibility aliases
β Refactor SignatureAnalyzer to be Universal (COMPLETE)
Extended SignatureAnalyzer to handle functions, dataclasses, and instances
Added
_analyze_dataclass_instancemethodMaintained backward compatibility
β Standardize ParameterFormManager Constructor (COMPLETE)
Fixed StepParameterEditor to pass parameter_info
Fixed nested dataclass forms to pass parameter_info
Fixed testing methods to pass parameter_info
β Fix Nested Dataclass Parameter Info Propagation (COMPLETE)
Nested forms now receive parameter_info for help functionality
All nested parameters now have help buttons
β Consolidate Form Creation Patterns (COMPLETE)
Migrated ConfigFormScreen to use ParameterFormManager
Removed duplicate manual form creation logic
Added proper event handling for ParameterFormManager
β Eliminate FieldIntrospector Duplication (COMPLETE)
Updated ConfigDialogScreen to use unified system
Updated ConfigWindow to use unified system
Updated ConfigFormWidget to use SignatureAnalyzer
Added
from_dataclassclass method for backward compatibility
π Remaining Tasksο
Create Parameter Analysis Tests
Update Documentation and Examples
π― MAJOR ACHIEVEMENT: UNIFIED PARAMETER ANALYSISο
All parameter forms in OpenHCS TUI now use the same unified analysis system: - Function parameters: β Help buttons with docstring descriptions - Config parameters: β Help buttons with docstring descriptions - Step parameters: β Help buttons with docstring descriptions - Nested parameters: β Help buttons with docstring descriptions
Implementation Statusο
β Files Successfully Updatedο
openhcs/textual_tui/widgets/step_parameter_editor.py(line 49) - β FIXED: Now passes param_info to ParameterFormManageropenhcs/textual_tui/widgets/shared/parameter_form_manager.py(nested form creation) - β FIXED: Nested forms now analyze and pass param_infoopenhcs/textual_tui/widgets/config_form.py(manual form creation) - β FIXED: Now uses ParameterFormManager with SignatureAnalyzeropenhcs/textual_tui/services/config_reflection_service.py- β MAINTAINED: FieldIntrospector kept for backward compatibility alongside unified system