ADR-0024: Polymorphic SoulContext Hierarchy in AISME¶
| Field | Value |
|---|---|
| Status | Accepted (Implemented) |
| Date | 2026-08-23 |
| Authors | Spector Maintainers & Architecture Working Group |
| Deciders | Spector Technical Steering Committee (TSC) |
| Supersedes | None |
| Superseded By | None |
| Last Verified | 2026-09-16 (Verified against main) |
1. Context¶
Spector's domain model defines a rich, polymorphic sealed soul hierarchy in com.spectrayan.spector.memory.model:
UserSoul: Human digital twin and persona continuity (PersonaContext,IdiolectProfile,VocalProsodyDNA,EmbodiedKinesicsDNA,identityEmbedding).AgentSoul: Autonomous AI assistant persona, tools, and system prompt.TenantSoul: Enterprise compliance and domain focus policies.OrgUnitSoul: Team/department expertise and guardrails.
However, the initial AISME integration (GenerativeSelfModel, AismeBundle, SpectorMemoryBuilder) was constrained exclusively to AgentSoul.
2. Problem Statement¶
Restricting AISME to AgentSoul prevented UserSoul (digital twin and ancestral continuity) from directly seeding the top-down generative prior \(\boldsymbol{\mu}_0\) of the active inference self-model. Furthermore, enterprise multi-tenant soul stacks (TenantSoul, OrgUnitSoul) could not be exposed in AismeBundle, preventing departmental and tenant-level policies from influencing generative inference and policy selection.
3. Decision Drivers¶
- Polymorphic Generative Priors: All types in the
SoulContexthierarchy must be capable of seeding or influencing generative self-model priors. - Hierarchical Prior Blending: Multi-tier soul configurations (Tenant + Org + Agent + User) must support composite prior synthesis.
- Backward Compatibility: Existing clients and tests depending on
AgentSoulaccessors inAismeBundlemust continue functioning without modification. - Builder Unification:
SpectorMemoryBuilderandAismeBuildermust expose uniform polymorphic methods for soul configuration.
4. Considered Options¶
Option 1: Parallel Model Implementations¶
- Description: Create separate
UserGenerativeSelfModel,AgentGenerativeSelfModel, andTenantGenerativeSelfModelclasses. - Advantages: Avoids modifying existing classes.
- Disadvantages: Massive code duplication; fails to support blended multi-soul hierarchies.
Option 2: Polymorphic SoulContext Hierarchy Integration (Selected)¶
- Description: Upgrade
GenerativeSelfModelandAismeBundleto operate on the sealedSoulContextinterface, supporting polymorphic prior computation and multi-soul blending while providing backward-compatible adaptors. - Advantages: Universal support for all soul types; supports multi-tier composite blending; 100% backward compatible.
- Disadvantages: Requires updating constructor signatures in internal builders.
5. Decision Outcome¶
Chosen Option: Option 2 (Polymorphic SoulContext Hierarchy Integration).
Architectural Decisions:¶
D1: Polymorphic SoulContext in GenerativeSelfModel¶
- Replace
AgentSoul soulwithSoulContext soulinGenerativeSelfModel. - Support polymorphic prior mean initialization via
SoulContext.identityEmbedding(). - Add
fromSoulsAndProfile(List<SoulContext> soulContexts, CognitiveProfile profile, int dimensions)to compute a composite, blended generative prior \(\boldsymbol{\mu}_0\).
D2: Polymorphic AismeBundle¶
- Update
AismeBundleto holdSoulContext primarySoulandList<SoulContext> soulContexts. - Provide backward-compatible accessor
public AgentSoul agentSoul()which returns(AgentSoul) primarySoulif applicable, elsenull.
D3: Builder Alignment (SpectorMemoryBuilder & AismeBuilder)¶
- Expose
soul(SoulContext soul)andsoulContexts(List<SoulContext> contexts)inSpectorMemoryBuilder. - Pass polymorphic
soulandsoulContextstoAismeBuilder.build(...).
Positive Consequences¶
- Closes the architectural gap for human digital twin persona storage (Homo Digitalis) by allowing
UserSoulto directly drive active-inference self-models. - Supports multi-tenant enterprise and departmental policy integration.
- 100% backward compatible with existing code expecting
AgentSoul.
Negative Consequences & Trade-offs¶
- Internal bundle structures hold a collection of souls, requiring null-safe checks when casting to specific concrete types.
6. Pros and Cons of the Options¶
| Option | Pros | Cons |
|---|---|---|
| Option 1: Parallel Models | Preserves existing classes | Extreme code duplication, cannot blend multi-tier souls |
| Option 2: Polymorphic SoulContext | Clean inheritance, composite prior blending, backward compatible | Requires builder signature updates |
7. Implementation Plan¶
- Phase 1: Update
GenerativeSelfModelto acceptSoulContextand implement prior blending. - Phase 2: Refactor
AismeBundlewithprimarySoulandsoulContextswhile retainingagentSoul(). - Phase 3: Update
AismeBuilderandSpectorMemoryBuilderfluent APIs. - Phase 4: Add test coverage for
UserSoulactive-inference initialization.
8. Code Reference & Verification¶
- Primary Module(s):
memory/spector-memory - Key Packages:
com.spectrayan.spector.memory.model,com.spectrayan.spector.memory.aisme.fegr,com.spectrayan.spector.memory.builder - Classes:
SoulContext.java,UserSoul.java,AgentSoul.java,GenerativeSelfModel.java,AismeBundle.java,AismeBuilder.java - Verification Tests:
GenerativeSelfModelTest.java,PolymorphicSoulAismeTest.java