Skip to content

Test the settler state machine, births and designation clamping - #20

Merged
dmccoystephenson merged 1 commit into
mainfrom
feat/tasks-state-machine-tests
Oct 30, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feat/tasks-state-machine-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle: no open issues existed at triage, so this cycle was spent adding characterization tests to the colony rules in src/colony/systems.cpp. The tests cover paths that no test exercised directly. Only tests/test_systems.cpp is changed. No production code, schema, fingerprint or save-path file is touched.

New sections in tests/test_systems.cpp:

  • Returning settler delivers stone and berries. systems::tasks adds stone to globals.stone and berries to globals.food, clears the load and resets the settler to Idle with zero patience. Until now only wood delivery was covered.
  • Gathering. A settler stops at Rules::kCarryMax and then switches to Return. A settler that reaches an empty tile with nothing carried goes Idle.
  • Patience en route. At exactly kGiveUpToResource the settler is still en route. One tick later it gives up, goes Idle and starts a -kWanderCooldown cooldown. While cooling down it ignores resources, and once the cooldown ends it targets one.
  • Arrival and return give-up. Arriving at the target starts Gather and resets patience. A returning settler that gives up keeps its load and stays in Return while it wanders.
  • Starving settler skipped. A settler at kStarveAt is not moved and uses no random draw, which matters for determinism.
  • systems::growth. Births happen only on kBirthEvery ticks and only with at least kBirthFood food. globals.maxSettlers caps births even when the housing cap is higher.
  • designate() clamping. Off-map and reversed rectangles are clamped to the grid. A rectangle wholly off the map changes nothing.

These are characterization tests: they assert the current behaviour and change none of it. No apparent bugs were found while writing them.

Verification

  • Local build/test: UNVERIFIED-locally. The dispatch sandbox did not allow cmake or a compiler to run. The CI rules jobs (gcc-13, clang-18, asan-ubsan, msvc) on the PR head SHA are the anchor.
  • Save integrity: no CHECK was removed from any test file, and the pinned fingerprint in tests/test_determinism.cpp is unchanged.

Test plan

  • rules (gcc-13), rules (clang-18), rules (asan-ubsan) and rules (msvc) are green on the PR head, with test_systems reporting ALL PASSED
  • game on Strata (saves soak, headless smoke) is green

No tracking issue: the coverage gap was found during triage, and the backlog was empty.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

Characterise systems::tasks paths no test reached directly: stone and
berry deliveries, the carry limit, give-up and wandering cooldowns on
both the outbound and return legs, arrival, and skipping a starving
settler. Also pin systems::growth's birth-tick, food and maxSettlers
gates and designate()'s clamping of off-map rectangles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (scored against the diff and CI on head feat/tasks-state-machine-tests):

  • Scope: PASS. git diff --stat origin/main...HEAD shows a single file, tests/test_systems.cpp, with +141/-0. No production code changed.
  • Tests-new: PASS (not applicable). No new public function was added. The added tests target systems::tasks, systems::growth and designate(), none of which had direct coverage of these paths before.
  • Tests-fix: N/A. This is a characterization-only Stage B cycle with no bug fix, so there is no fix to revert.
  • Sibling structure: PASS. The new sections follow the existing SECTION(...) + tiny() pattern in the same file. They use hand-built colonies rather than seed 42, as the convention requires.
  • Sibling renames: N/A. Nothing was renamed.
  • Docs: PASS. The Phase 7 table rows were checked: README.md, src/mods/manifest.h, src/colony/schema.h, content/prefabs.usda, mods/*/mod.toml and LICENSE. A test-only change alters no documented behaviour, control, flag, rule or mod key, so no row needed a correction.
  • Issue resolution: N/A. The backlog was empty at triage, so there is no Closes #N.
  • CI: PASS. All jobs are green on the PR head: rules (gcc-13), rules (clang-18), rules (asan-ubsan), rules (msvc), game on Strata (saves soak, headless smoke), game on Strata (Windows, MSVC) and Web build and smoke test. The gcc-13 log shows Test #2: systems ... Passed, and 100% tests passed, 0 tests failed out of 5.
  • Privacy: PASS. The text names no employer and no private repository, and RFCs are not cited. The only repository named besides this one is the Gardener link the dispatch required. The gh api ... -q .private check on it could not run in this sandbox, so that link is included at the dispatch's direction.
  • Save integrity: PASS. The diff has no deletions, so no CHECK was removed from test_saves.cpp, test_determinism.cpp or test_systems.cpp. The saves soak job is green.
  • Fingerprint: PASS. tests/test_determinism.cpp is untouched.
  • Schema untouched: PASS. The diff touches neither src/colony/schema.h nor strata.ref.
  • Layering: PASS. No pxr/ or strata/ include was added. Only a test file changed.
  • Docs follow the change: N/A. No new control, flag, rule or mod key was added.

Findings that need judgment:

  • tests/test_systems.cpp: the "starving settler is skipped" section checks that rng.state is unchanged. That pins an implementation detail, namely that no random draw is spent on a dying settler. It was kept on purpose, because that detail feeds the pinned fingerprint and save-replay determinism.
  • Local build/test was UNVERIFIED-locally because the dispatch sandbox blocked cmake and the compiler. CI on the exact head SHA is the anchor.

No Copilot review request registered (reviewRequests: []), so this rubric serves as the review of record.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 32619c1 into main Oct 30, 2026
7 checks passed
@dmccoystephenson
dmccoystephenson deleted the feat/tasks-state-machine-tests branch October 30, 2026 03:06
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