Skip to content

Building position belongs to sim-core, not the workplace (ADR 0008) - #17

Merged
teceer merged 3 commits into
mainfrom
building-placement-ownership
Aug 7, 2026
Merged

teceer merged 3 commits into
mainfrom
building-placement-ownership

Conversation

@teceer

@teceer teceer commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Workplaces (farm, tavern) no longer declare their own map position — that was the same "second source of truth" shape ADR 0004 already fixed once for max_workers. workplace/v1.DescribeResponse.position is deprecated; world-gateway now supplies position from its own WORKPLACE_POSITIONS config and refuses to register a building it has no configured position for.
  • sim-core is now the sole authority on placement: RegisterWorkplace intents are rejected (no effect on the world) if the position is off the map or within one tile of another building — on both insert and update.
  • Rejection is observable without going through Kafka: a new WorkplaceRegistrationRejected fact is turned into a tracing::warn! and an OTel counter (pipsim.sim.workplace_registration_rejected) in crates/server, on the reasoning that this concerns whoever runs the cluster, not other services (rule 2 in CLAUDE.md).
  • See docs/adr/0008-sim-core-owns-building-position.md for the full writeup, including alternatives considered.

Test plan

  • buf lint / buf breaking clean, gen/ regenerated (Go, TS, Elixir)
  • cargo test --workspace in services/sim-core (35/35 in crates/sim, workspace builds)
  • cargo clippy --workspace -D warnings and cargo fmt --check --all clean
  • go test ./... in services/world-gateway, services/workplaces/farm, services/workplaces/conformance, services/bank
  • mix test in services/workplaces/tavern (32/32)
  • helm template on farm, tavern, world-gateway charts to confirm rendered env vars

🤖 Generated with Claude Code

teceer added 3 commits August 7, 2026 14:32
…e workplace (ADR 0008)

Farm and tavern used to declare their own map position via env vars, and the
gateway blindly copied it into sim-core — the same "second source of truth"
shape ADR 0004 already fixed once for max_workers. A building's kind is the
workplace service's business; where it stands on the map is not.

- workplace/v1.DescribeResponse.position deprecated (buf breaking forbids
  removal); farm and tavern stop populating it
- world-gateway now sources position from its own WORKPLACE_POSITIONS config
  and refuses to register a workplace it has no configured position for
- Helm: xMilli/yMilli move out of the farm/tavern charts into
  world-gateway's workplacePositions
- gen/ regenerated, buf lint/breaking clean
…rlapping registrations

Closes the gap ADR 0008 left open: workplace_positions accepted whatever
RegisterWorkplaceIntent sent, with no check that the position was on the map
or clear of another building.

- apply_intents rejects a RegisterWorkplace intent that is off the map or
  within WORKPLACE_MIN_SPACING_MILLI of another building's position, on
  both insert and update
- rejection is a new WorkplaceRegistrationRejected DomainEvent — not a Kafka
  fact (rule 2: Kafka is for facts many independent consumers care about,
  this concerns only whoever misconfigured a position), so
  crates/server routes it to a tracing::warn! and a new
  pipsim.sim.workplace_registration_rejected OTel counter instead
- 3 new tests in crates/sim covering off-map, overlap-on-insert and
  overlap-on-update
…nership

# Conflicts:
#	infra/helm/world-gateway/templates/deployment.yaml
#	infra/helm/world-gateway/values.yaml
#	services/sim-core/crates/sim/src/lib.rs
@teceer
teceer merged commit d567127 into main Aug 7, 2026
7 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