Skip to content

Scenario validator ignores extended_attributes when resolving attribute references #117

@RandomOscillations

Description

@RandomOscillations

Summary

validate_scenario() builds known_attributes from the base population spec only, and does not add ScenarioSpec.extended_attributes. This causes invalid validation behavior for scenario conditions that legitimately reference extended attributes.

Why This Matters

In the study-folder flow, sampling merges base + extended attributes before generating agents. Scenario rules should be validated against the same effective attribute namespace used downstream. Current mismatch creates false negatives and brittle authoring.

Current Behavior (Code)

In /Users/adithyasrinivasan/Projects/extropy/extropy/scenario/validator.py:

  • known_attributes is initialized from population_spec.attributes only (line ~120-123)
  • references in seed_exposure.rules[].when and spread.share_modifiers[].when are checked against that base-only set (line ~218, line ~295)
  • spec.extended_attributes is not included anywhere in the reference set

Expected Behavior

Attribute reference validation should use:

  • base population attributes
  • PLUS scenario extended_attributes

Proposed Fix

  1. Build known_attributes as:
  • base attr names from population_spec (if present)
  • union with {a.name for a in spec.extended_attributes or []}
  1. Apply this unified set to all expression-reference checks in scenario validator.

  2. Add tests:

  • scenario with extended_attributes=[foo_bar], and a when clause referencing foo_bar should pass
  • unknown attr should still fail

Acceptance Criteria

  • Valid references to extended attributes no longer fail validation.
  • Unknown references still produce errors.
  • Behavior is consistent across extropy validate and compile/load validation paths.

Pipeline Impact

Steps 2->3 consistency (scenario -> sample) improves by aligning validator namespace with merged-spec sampling behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions