Skip to content

Make settlement destination claims atomic - #1

Merged
fabianwgl merged 1 commit into
mainfrom
agent/atomic-settlement-destinations
Aug 16, 2026
Merged

fabianwgl merged 1 commit into
mainfrom
agent/atomic-settlement-destinations

Conversation

@fabianwgl

Copy link
Copy Markdown
Owner

What changed

  • lock the settling account and destination map rows before checking culture points or creating a village
  • require a free, buildable wdata tile with a matching free available_villages row and no existing vdata row
  • return settlers and founding resources when a stale or competing destination loses the claim
  • treat an unexpected village-creation failure as a retryable scheduled-task failure
  • add fresh-process regression coverage for stale availability state and two simultaneous settlement movements targeting one tile

Why

Settlement resolution previously checked only wdata.occupied and then performed separate, unlocked reads. A stale availability row or two workers targeting the same tile could consume a movement without safely creating exactly one village, losing settlers or producing duplicate player-facing effects.

Impact

Valid settlement, including grey-area settlement and its Natar response, keeps the existing behavior. Invalid or concurrently claimed targets now resolve deterministically and conserve the losing settlers/resources.

Verification

  • ./scripts/verify.sh
  • two-process settlement race in tests/runtime-regression.php
  • PHP syntax and PHPStan checks
  • formula golden regressions
  • complete-round regression
  • independent diff review

@fabianwgl
fabianwgl marked this pull request as ready for review August 16, 2026 16:19
@fabianwgl
fabianwgl merged commit 2e098c3 into main Aug 16, 2026
2 checks 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