Skip to content

feat: LLM-driven semantic_type and identity_dimensions#106

Merged
DeveshParagiri merged 3 commits intomainfrom
fix/semantic-type-and-identity-dimensions
Feb 17, 2026
Merged

feat: LLM-driven semantic_type and identity_dimensions#106
DeveshParagiri merged 3 commits intomainfrom
fix/semantic-type-and-identity-dimensions

Conversation

@DeveshParagiri
Copy link
Copy Markdown
Collaborator

Summary

Fixes #86 (dependent attributes for minors) and #90 (identity-threat framing) with a proper LLM-driven approach instead of hardcoded keywords.

Changes

semantic_type for AttributeSpec (fixes #86):

  • Added semantic_type field to AttributeSpec, DiscoveredAttribute, and HydratedAttribute
  • LLM sets this during spec creation (selector phase) - values: age, income, education, employment, occupation, or None
  • Used in sampler to normalize attributes for minors (e.g., promoted dependents becoming agents get age-appropriate education/employment values)
  • No hardcoded keyword matching - the LLM classifies once at spec time

identity_dimensions for ScenarioSpec (fixes #90):

  • Added IdentityDimension model and identity_dimensions field to ScenarioSpec
  • LLM detects relevant identity dimensions during scenario compilation (e.g., political_orientation, religious_affiliation, parental_status)
  • Engine renders identity_threat_summary in reasoning context from scenario's pre-classified dimensions
  • No hardcoded keywords like "book ban" or "school board" - the LLM classifies once at scenario creation time

Files Changed

  • extropy/core/models/population.py - Added semantic_type field
  • extropy/core/models/scenario.py - Added IdentityDimension model
  • extropy/core/models/simulation.py - Added identity_threat_summary to ReasoningContext
  • extropy/population/spec_builder/selector.py - LLM schema includes semantic_type
  • extropy/population/spec_builder/hydrators/*.py - Carry semantic_type through
  • extropy/population/spec_builder/binder.py - Bind semantic_type to AttributeSpec
  • extropy/population/sampler/core.py - Minor normalization functions using semantic_type
  • extropy/scenario/compiler.py - LLM-driven identity dimension detection
  • extropy/simulation/engine.py - Render identity threat summary
  • extropy/simulation/reasoning.py - Include identity relevance in prompts

Test plan

  • All 832 tests pass
  • Ruff checks pass
  • Manual test: create spec and verify semantic_type is set by LLM
  • Manual test: create scenario and verify identity_dimensions is populated

…cenarioSpec

Replace hardcoded keyword matching with LLM-driven classification:

1. AttributeSpec.semantic_type (age, income, education, employment, occupation)
   - Set by LLM during spec creation in selector
   - Flows through DiscoveredAttribute → HydratedAttribute → AttributeSpec
   - Used by sampler to normalize minor attributes without keyword heuristics

2. ScenarioSpec.identity_dimensions
   - Set by LLM during scenario creation in compiler
   - Lists which identity dimensions are activated by the scenario
   - Used by engine to render identity-threat context in reasoning prompts

This fixes:
- #86: Dependent attributes now use semantic_type instead of keyword matching
- #90: Identity framing now uses scenario-declared dimensions instead of hardcoded keywords

Closes #86, closes #90
@DeveshParagiri DeveshParagiri merged commit 96b9e57 into main Feb 17, 2026
4 checks passed
@DeveshParagiri DeveshParagiri deleted the fix/semantic-type-and-identity-dimensions branch February 17, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant