Skip to content

Preserve manually edited relationship affinities - #80

Merged
RANGROO merged 2 commits into
unstablefrom
codex/preserve-relationship-affinities
Aug 10, 2026
Merged

Preserve manually edited relationship affinities#80
RANGROO merged 2 commits into
unstablefrom
codex/preserve-relationship-affinities

Conversation

@RANGROO

@RANGROO RANGROO commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Problem

Manually edited relationship affinities could disappear after a normal NPC/game snapshot or reconnect. Stobe stored affinities inside extended_data, while generic snapshot updates replaced that object and manual relationship saves were not anchored to Kenshi's current game timestamp. Locked profiles could also retain relationship state from the future after loading an older save.

Changes

  • preserve relationship-owned extended_data keys atomically during generic NPC and game-snapshot writes
  • allow only explicit UI, chat, and relationship-worker paths to replace affinity state
  • serialize all relationship writes for an NPC through the same PostgreSQL advisory lock
  • stamp successful relationship writes with the latest known Kenshi game time before releasing the lock
  • retain distinct relationship states in NPC history for rollback/reconnect recovery
  • restore relationship state independently for locked and unlocked profiles when an older save is loaded
  • prefer relationship snapshots over generic snapshots at the same game timestamp
  • clear future-only relationship state without changing unrelated profile or extended_data fields
  • propagate failed NPC database updates instead of reporting a successful save
  • extend the existing rollback and history regression coverage

No schema changes or migrations are required.

Validation

  • PHP lint passed for all changed PHP files
  • tests/playthrough_rollback_regression.php passed against the isolated stobe_test database
  • tests/npc_history_snapshot_regression.php passed against the isolated stobe_test database
  • tests/relationship_system_regression.php passed against the isolated stobe_test database
  • tests/chat_flow_regression.php passed against the isolated stobe_test database
  • tests/npc_profile_lock_controls_regression.php passed against the isolated stobe_test database
  • git diff --check passed

Deployment

Not deployed.

Manual limits

The NPC editor, reconnect behavior, and an in-game save rollback still need local browser/in-game verification.

CHIM parity references: abeiro/HerikaServer#560, abeiro/HerikaServer#572, and abeiro/HerikaServer#634.

@RANGROO
RANGROO marked this pull request as ready for review August 10, 2026 14:27
@RANGROO
RANGROO merged commit 0628734 into unstable Aug 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant