cursus.core.base.contract_base

Base Script Validation Classes

Defines ValidationResult/AlignmentResult and the ScriptAnalyzer (AST-based script analysis) used by the alignment validation framework. The legacy ScriptContract data class was removed — contract data now lives in the unified StepInterface (core/base/step_interface.py), sourced from the .step.yaml interfaces.

class ValidationResult(*, is_valid, errors=<factory>, warnings=<factory>)[source]

Bases: BaseModel

Result of script contract validation

is_valid: bool
errors: List[str]
warnings: List[str]
classmethod success(message='Validation passed')[source]

Create a successful validation result

classmethod error(errors)[source]

Create a failed validation result

classmethod combine(results)[source]

Combine multiple validation results

add_error(error)[source]

Add an error to the result and mark as invalid

add_warning(warning)[source]

Add a warning to the result

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class AlignmentResult(*, is_valid, errors=<factory>, warnings=<factory>, missing_outputs=<factory>, missing_inputs=<factory>, extra_outputs=<factory>, extra_inputs=<factory>)[source]

Bases: ValidationResult

Result of contract-specification alignment validation

missing_outputs: List[str]
missing_inputs: List[str]
extra_outputs: List[str]
extra_inputs: List[str]
classmethod success(message='Alignment validation passed')[source]

Create a successful alignment result

classmethod error(errors, missing_outputs=None, missing_inputs=None, extra_outputs=None, extra_inputs=None)[source]

Create a failed alignment result

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ScriptAnalyzer(script_path)[source]

Bases: object

Analyzes Python scripts to extract I/O patterns and environment variable usage

property ast_tree: Any

Lazy load and parse the script AST

get_input_paths()[source]

Extract input paths used by the script

get_output_paths()[source]

Extract output paths used by the script

get_env_var_usage()[source]

Extract environment variables accessed by the script

get_argument_usage()[source]

Extract command-line arguments used by the script