Skip to content

[Think Tank] Config Field Validators #73

@rayketcham

Description

@rayketcham

Add pydantic field validators to catch misconfigured thresholds and port at startup.

src/project_forge/config.py exposes auto_scaffold_threshold and expand_cross_weight as bare floats with no range enforcement. A value like FORGE_AUTO_SCAFFOLD_THRESHOLD=1.5 or FORGE_EXPAND_CROSS_WEIGHT=-0.3 is silently accepted and causes subtle misbehavior — nothing ever scaffolds, or cross-pollination runs backwards — with no error surfaced at boot. Similarly, port accepts any integer including 0 or 99999. The fix is three @field_validator decorators in Settings: one constraining both float weights to [0.0, 1.0], one constraining port to [1, 65535]. tests/test_config.py (new file, distinct from the existing test_config_env_file.py) verifies that out-of-range values raise ValidationError at Settings() construction time, and that boundary values (0.0, 1.0, 1, 65535) are accepted.

Feasibility: 0.95
MVP Scope: Modify src/project_forge/config.py to add @field_validator on auto_scaffold_threshold, expand_cross_weight (clamp to [0.0, 1.0]) and port (clamp to [1, 65535]). Create tests/test_config.py with parametrized cases: invalid floats raise ValidationError, invalid ports raise ValidationError, boundary values pass, defaults round-trip cleanly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ci-queuePromoted self-improvement item — CI fails until addressed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions