feat: add hidden entity traits (Workstream A) + idempotent migration
Entity.traits (alignment/power/volatility/deceptiveness, 0.0-1.0 each) is
rolled once at mint time in entities.py, seeded from the entity's
signature via random.Random(f"traits:{signature}") — a separate rng
namespace from normalize_profile's existing "norm:" rng, and never fed
into mint_prompt, so persona text stays fully decoupled from ground
truth. normalize_profile now includes "traits" in its returned dict;
fallback_profile inherits it for free since it already delegates to
normalize_profile.
Adds the new JSONB column to the Entity model (default {}) and the
idempotent `ALTER TABLE entities ADD COLUMN IF NOT EXISTS traits ...`
migration line to main.py's lifespan, per the live-Postgres migration
convention this spec introduces (no Alembic in this repo).
Tests cover trait value ranges, signature-determinism, and
persona/trait independence (same persona template pairs with a wide
spread of alignment rolls across signatures), plus a regression check
that mint_prompt's signature never grows a traits parameter.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,6 +24,7 @@ class Entity(Base):
|
||||
signature: Mapped[str] = mapped_column(String(64), unique=True, index=True)
|
||||
voice_profile: Mapped[dict] = mapped_column(JSONB, default=dict)
|
||||
visual_profile: Mapped[dict] = mapped_column(JSONB, default=dict)
|
||||
traits: Mapped[dict] = mapped_column(JSONB, default=dict)
|
||||
sample_quotes: Mapped[list] = mapped_column(JSONB, default=list)
|
||||
contact_count: Mapped[int] = mapped_column(Integer, default=0)
|
||||
discovered_by: Mapped[uuid.UUID | None] = mapped_column(
|
||||
|
||||
Reference in New Issue
Block a user