Skip to content

test(coop): cover a SHARED production unit reaching the client mid-batch and at month end - #232

Merged
NonPolynomialTim merged 1 commit into
mainfrom
claude/fix-134-shared-manufacture-1199af
Nov 5, 2026
Merged

NonPolynomialTim merged 1 commit into
mainfrom
claude/fix-134-shared-manufacture-1199af

Conversation

@NonPolynomialTim

Copy link
Copy Markdown
Collaborator

Refers to #134. Test-only: no product change.

Symptom

On 2026-08-02 test_shared_month_run failed 2 of 3 runs after month end #1 with .bases[0].items.STR_LASER_PISTOL: 1 != <absent on client>. The first finished unit of a running 40x STR_LASER_PISTOL job reached the host's stores but never the client's.

Cause

On that build (#166), a SHARED production sent the client nothing until the whole batch finished: GeoscapeState called hostProductionDone only when the production completed. A unit finished mid-batch existed only on the host until a world resync repaired it. #212 added a per-unit prod_fx message that carries the base's stores to the client in the hour the host makes each unit.

Evidence on current main:

  • test_shared_month_run passed 10/10 (2 at a time). Its engine logs hold no prod_fx line. At about 170 game hours against the pistol's 300, no unit finishes inside that test any more, so it no longer exercises this path.
  • The new test below passes on main. On a local build with the per-unit message switched off (prodFx forced false in GeoscapeState, the behaviour before feat(coop): rewrite the co-op battlescape on a host-authoritative battle #212), it fails 3/3 with the issue's signature. The month-roll row also fails the same way when run on its own:
mid_batch: the finished unit never reached the client: host {'STR_LASER_PISTOL': 1, 'funds': 4116000, ...} != client {'STR_LASER_PISTOL': 0, 'funds': 4116000, ...} after 3.0 s with no resync
month_end: the finished unit never reached the client: host {'STR_LASER_PISTOL': 1, 'funds': 7542000, ...} != client {'STR_LASER_PISTOL': 0, 'funds': 7542000, ...} after 3.0 s with no resync

Fix

No product change is needed: #212 fixed it. This PR adds test_shared_production_unit_sync.py. It drives the issue's exact job (the client starts 40x STR_LASER_PISTOL at 1 engineer through the real ManufactureInfoState) and checks two hourly steps:

  • mid_batch: unit 1 finishes on an ordinary hour.
  • month_end: unit 2 finishes in the step that rolls the month. This is the timing the original failure hit.

Each row:

  1. Seeds the production's progress on both machines.
  2. Rolls at speed 1 until the host has the unit. Any popup other than the monthly report is closed during the roll, because a popup stops the shared clock.
  3. Holds the host on the Soldiers screen. Off the geoscape the host sends no heartbeat, so a missed unit cannot be repaired by a checksum resync. It has to arrive by its own message.
  4. Asserts that the client's stores, funds and production match within 3 s.
  5. Asserts that the client made no resync request during the hold or for 4 s after it.

The test ends with full world equality and the zero-disk check.

test_production_effects.py covers the same message with a test mod. This test adds the vanilla rule, the client-started 40x job and the month-roll step.

Tests

  • New test on 395cc44fd: 20/20 pass, 2 at a time. The first 20-run attempt failed once in its first 9 runs: a UFO-detected popup opened on both machines during the month-end roll and stopped the clock for the whole roll. The engine logs show it pushed at 14:17:09.9 and still open at teardown. The roll now closes such popups, and the count was restarted. One of the final 20 runs hit that popup and passed.
  • New test with the per-unit message switched off: 3/3 fail, as shown above. That switch was a local build only and is not in this PR.
  • test_shared_month_run: 10/10 pass on d906ebd67 and 2/2 on 395cc44fd.
  • Registered in tools/ci/test_weights.json at 36 s (measured 33-34 s). That is under the 180 s default budget, so slow_test_exceptions.json needs no entry. A row was added to the SHARED table in tools/coop_test/README.md.

…tch and at month end

Drives the issue #134 job (the client starts 40x STR_LASER_PISTOL at 1 engineer) and checks that a unit finished on an ordinary hour, and one finished in the month-roll step, reach the client's stores while the host is held off the geoscape, so no checksum resync can repair a miss. Fails 3/3 with the per-unit prod_fx message switched off; passes 20/20 on main.
@NonPolynomialTim
NonPolynomialTim enabled auto-merge (squash) November 5, 2026 19:29
@NonPolynomialTim
NonPolynomialTim merged commit f063b13 into main Nov 5, 2026
11 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