[#754] Centralise relationships into a SocialGraph resource#772
Merged
Conversation
Move canonical Affection / Trust / Respect off per-agent MindGraph triples and onto a centralised `SocialGraph` resource keyed by directed `(observer, target)` Entity pairs. Edges live on the resource, not on either entity, which is the LOD-survival prerequisite #752 needs (demoting an agent's entity must not destroy their relationships). Migration scope: - New `psyche::social_graph` module: SocialGraph + RelationshipEdge + RelationshipKind + NEUTRAL constant + affection/trust/respect accessors and forget_agent / iter helpers. - `relationships::update_relationships` and `decay_relationships` now read/write the SocialGraph instead of MindGraph triples. - `recognition::init_relationship_dimensions` writes a SocialGraph edge. - All callers of `mind.get(target, Affection|Trust|Respect)` migrated to `social_graph.affection(observer, target)` etc: brain_system, emotional, drift, flocking, greetings, converse, generic_action::TargetAffectionAtLeast gate, other_regarding's affection_channel, the test fixtures, scenarios, and TestWorld helpers. - Drops the (Self_, Affection|Trust|Respect, Other) MindGraph writes in spawner, recognition, and TestWorld pack-bond setup. Categorical IsA Friend / Rival / Kin still lives in MindGraph since classification is recognition-perceiver-side, not canonical edge data. - ActionContext + PreferenceContext + EmotionalInputs + ChannelContext carry the SocialGraph + observer entity; consumers look up directed edges through the central store. Behavioural drift expected to be zero — the values flowing through the pipeline are the same; only their storage shape changed. Filed for #752 follow-up: respawn-reconnect (re-materialised entity re-binding to its old edge) needs a stable AgentId — out of scope here. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move Node/Predicate/Value out of the parent module (only used in mod tests now that the canonical relationship triples no longer live in MindGraph) and drop Quantity from spawn_wolf_pack's local use since we write SocialGraph edges instead of Quantity::Exact triples. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Test was still asserting affection through a MindGraph triple. After the migration the gate reads through the SocialGraph edge — seed it there. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Compassion's affection_channel reads through the SocialGraph after the migration. The test_other_regarding fixture was still writing affection into MindGraph, so high-affection scenarios returned NEUTRAL=0.5 from the channel and produced no Compassion urgency. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Resolves: ActionContext / PreferenceContext callsites picked up an additional world_positions field from #773 alongside this branch's social_graph + agent_entity additions; reconciled both in production and test contexts. Bundled SocialGraph into brain_system's side_queries tuple to stay under the Bevy 16-param SystemParam cap. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The test_relationship_decay fixtures still wrote/read trust through MindGraph triples; migrate them to set/read on the SocialGraph resource so the decay system actually sees the seeded edge. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirrors testing/world.rs's wolf_pack_bonds_established_at_spawn unit test — pack-bond trust lives on the SocialGraph resource now, not on each wolf's MindGraph. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #754
Pulls canonical Affection / Trust / Respect off per-agent MindGraph triples and onto a centralised
SocialGraphresource keyed by directed(observer, target)Entity pairs. Edges live on the resource, not on either entity — the LOD-survival prerequisite #752 needs.What moved
psyche::social_graphmodule:SocialGraphresource +RelationshipEdge(affection / trust / respect / power_balance / last_interaction_tick / kind) +RelationshipKindenum +NEUTRALconstant +affection/trust/respect/get/get_mut/set/knows/iter/forget_agentAPI.relationships::update_relationships,decay_relationships,recognition::init_relationship_dimensions,world::spawner::setup_wolf_pack_bonds, TestWorld helpers, scenario builder) write to SocialGraph.mind.get(target, Affection|Trust|Respect)site: brain_system, emotional, drift, flocking, greetings, converse, generic_action'sTargetAffectionAtLeastgate, other_regarding'saffection_channel, plus test/scenario fixtures and TestWorld inspection helpers) read from SocialGraph.IsA Friend|Rival|Kinclassifications — those are recognition-perceiver-side narrative, not canonical edge state.ActionContext,PreferenceContext,EmotionalInputs, andChannelContextnow carry the SocialGraph reference plus the observer entity, so all consumers look up directed edges through the central store.Behavioural intent
Zero drift expected — the values flowing through the pipeline are the same; only their storage shape changed. Existing relationship tests should pass unchanged.
Out of scope
AgentId. Without one, despawning a Bevy entity leaves orphan edges keyed by the dead entity id. The data outlives the entity (assertion in unit tests) but the lookup path requires AgentId — filed for [Thinking] [Performance] [LOD] Architecture to support 1000-agent simulation #752.Vec<RelationshipEvent>on the edge). Per-agentRelationshipHistorylog already covers this; folding it into the edge is a follow-up to keep this PR's diff bounded.Test plan
SocialGraphunit tests: add/get round-trip, directed-edge asymmetry, NEUTRAL default for unknown pair, mutating one direction doesn't affect the reverse,forget_agentevicts both sidescargo check --testsclean,cargo fmt🤖 Generated with Claude Code