Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions docs/p0-ammo-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Zombies ammo recurrence finalization — 2026-10-28

The preserved incident is `.state/incidents/ammo-recurrence-20261028/` in
`ec2-workspace`. Its patches are the source of this change; original evidence
and candidate archives remain untouched. Final Principal Reviewer is the owner.
Historical review is evidence only, not approval of these final PR revisions.

Normal Zombies preparation previously omitted the ammo safety override unless
`--allies` was selected. The existing correction is now generated unconditionally:
initialize undefined first-use eligibility to true, preserve a defined false
cooldown, and cancel both delayed callbacks on disconnect. Vendor grants,
health caps and timings remain unchanged. Allies remain explicitly optional.

The original `mod.ff` remains byte-identical, SHA-256
`50911fdd0273b50e26983723619881acfaed4aa65f4d91a799a341464c2224a6`.
Pinned ammo source SHA-256 is
`545021b1444b643d270db77fad21767368b94c439a560dd739ed6de6d321b7ad`.
Mandatory `btd_general/_ammo_drops.gsx` SHA-256 is
`2b06adeb720eb54320313d0ab85b1e08bfe61baca79da8c413097e93617b2bb0`.
The updated dependency lock SHA-256 is
`dd4b03f81b082e0570f67fb57040cf95a5bfc929e23831ab16ad03f0a5e202f9`.
`src/scr_vm_main.c` tries GSX before GSC. The native ammo regression uses
`--artifact-ammo` to retain packaged override bytes, exercising that precedence.
Companion workspace packaging requires the source and reviewed output hash,
including for non-allied builds, and rejects absent, altered or symlinked code.

Finalization is based on engine master
`b59eb898a9400425d81a61d2db57e1c826b9f6ed` and workspace master `512e1cb`.
Native tests use that preserved engine binary, SHA-256
`65972a1014a76e0e20c7288a50312c8554cb75463674c4ca3f01039e22644390`,
and exact configuration `4296d214070056eed28c5f923b989bbdd6c7ecef` recovered
from packaged files and verified against all three recorded source hashes.
No engine binary source or security policy changes are part of this fix.

Fresh validation:

- Engine suite: 90 tests, one optional public-client source test skipped.
- Workspace suite: 75 tests and complete mocked Operations suite passed.
- Fresh private preparation and packaging pass with and without allies;
both produce the exact ammo override above and retain eight headers.
- All 25 declared files in the extracted preserved candidate match their hashes.
- Native packaged ammo: 15 assertions, process and UDP remain healthy;
`/tmp/btd-death-regression-1t3hxcid`.
- Native lifecycle: respawn, zombie spawning, waves, two UDP admissions and map
transitions pass; `/tmp/btd-death-regression-x91phq4e`.
- Native expression, death and classic camping checks pass;
`/tmp/btd-death-regression-ety4jf7e`, `/tmp/btd-death-regression-3yaggqzl`,
`/tmp/btd-death-regression-8aqy2o2k`.
- Killhouse navigation: 12 checks pass; `/tmp/btd-navigation-dwo6jlbg`.
- Allied native gameplay: all 52 checks pass (native fire/hits, melee, waves,
human admission/reconnect, map transitions and restart);
`/tmp/btd-five-allies-b4l5cuw8`.
- Full Zombies startup/integration: 73 checks, 16 maps and restart pass;
`/tmp/cod4-btd-qualified-9optyvv4`.

Native fixtures use synthetic clients, inject disposable startup logic and
shorten fixture cooldowns. They do not qualify real human multiplayer.
Licensed assets, generated derivatives, binaries and full logs stay outside Git.

Require final owner Principal review of both exact PR heads, mandatory green CI
and operator-approved manual merges. Only after both merges prepare a **new**
immutable local homologation image from exact approved engine/workspace/config
revisions, record all identities/hashes and obtain fresh artifact review. Do not
reuse any old image or approval record. Do not deploy automatically.

A separately authorized homologation session must first capture its current
image/config/mounts and select an independently healthy rollback artifact. With
at least two human graphical clients validate concurrent real vendor-drop
pickups, repeated/cross-drop pickups, full/depleted ammo, death before first
pickup, respawn, disconnect/reconnect during cooldown, waves and map changes.
Record actual ammo/health changes, effective GSX hash/precedence, clean script
logs and sustained UDP health. Production promotion requires separate approval
of that exact image and gameplay evidence. The vulnerable Zombies image is
never an acceptable rollback target; reverting source reintroduces the defect.
137 changes: 137 additions & 0 deletions tests/btd_ammo.gsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// Authored disposable fixture: calls the real pinned vendor pickup handler.
main()
{
wait 4;
level.grace_time = 120;
a = survivor("AmmoA");
b = survivor("AmmoB");
// Let the vendor wave loop enter its long grace wait before shortening
// only subsequent pickup cooldown waits in this disposable fixture.
wait 6;
level.grace_time = 5;
a freezecontrols(true);
b freezecontrols(true);
a setorigin((500, 500, 100));
b setorigin((700, 700, 100));
drop = spawn("trigger_radius", (0, 0, -9000), 0, 120, 120);
other = spawn("trigger_radius", (0, 0, -9500), 0, 120, 120);
drop thread btd_general\_ammo_drops::ammodrop();
other thread btd_general\_ammo_drops::ammodrop();
wait 0.1;
weapon = a getcurrentweapon();
a setweaponammostock(weapon, 0);
bweapon = b getcurrentweapon();
b setweaponammostock(bweapon, 0);
a.health = 50;
b.health = 60;
check(!isdefined(a.hasntfullammo), "first_use_uninitialized");
// Exercise the vendor main loop: it creates the model, HUD and radius
// trigger in response to the actual inter-wave event. No replacement
// pickup handler or scripted trigger notification is used here.
level notify("wave_end");
wait 0.3;
models = getentarray("script_model", "classname");
wave_drops = [];
for (i = 0; i < models.size; i++)
if (isdefined(models[i].trigger) && isdefined(models[i].marker))
wave_drops[wave_drops.size] = models[i];
check(wave_drops.size == 2, "vendor_wave_created_two_drops");
if (wave_drops.size != 2) return;
a setorigin(wave_drops[0].origin);
b setorigin(wave_drops[1].origin);
wait 0.3;
a setorigin((500, 500, 100));
b setorigin((700, 700, 100));
check(a getweaponammostock(weapon) > 0 && b getweaponammostock(bweapon) > 0, "two_players_refilled");
check(a.health == 60 && b.health == 70, "health_increment");
check(!a.hasntfullammo && !b.hasntfullammo, "cooldown_started");
a setweaponammostock(weapon, 0);
other notify("trigger", a);
wait 0.1;
check(a.health == 60 && a getweaponammostock(weapon) == 0, "rapid_cross_drop_throttled");
wait 0.8;
other notify("trigger", a);
wait 0.1;
check(a.health == 70 && a getweaponammostock(weapon) == 0, "false_cooldown_preserved");
// A dead player must not receive ammo or health.
b suicide();
wait 0.1;
deadhealth = b.health;
drop notify("trigger", b);
wait 0.1;
check(b.health == deadhealth, "dead_player_ignored");
// Disconnect while both delayed callbacks are pending.
c = survivor("AmmoDisconnect");
c freezecontrols(true);
c setorigin((900, 900, 100));
drop notify("trigger", c);
wait 0.1;
kick(c getentitynumber());
wait 6;
check(a.hasntfullammo, "cooldown_expired");
drop notify("trigger", a);
wait 0.1;
check(a getweaponammostock(weapon) > 0, "refill_after_cooldown");
// Await the normal vendor respawn, then re-enter the same handler.
for (i = 0; i < 200; i++)
{
if (isalive(b) && b.sessionstate == "playing") break;
wait 0.1;
}
check(isalive(b) && b.sessionstate == "playing", "respawn");
bweapon = b getcurrentweapon();
b setweaponammostock(bweapon, 0);
drop notify("trigger", b);
wait 0.1;
check(b getweaponammostock(bweapon) > 0, "respawn_refilled");
d = survivor("AmmoReconnect");
d freezecontrols(true);
d setorigin((1100, 1100, 100));
check(!isdefined(d.hasntfullammo), "new_entity_uninitialized");
drop notify("trigger", d);
wait 0.1;
check(isdefined(d.hasntfullammo) && !d.hasntfullammo, "new_entity_pickup");
wait 0.8;
dweapon = d getcurrentweapon();
d setweaponammostock(dweapon, 0);
d.hasntfullammo = true;
d.health = d.maxhealth - 5;
physical = spawn("trigger_radius", d.origin, 0, 120, 120);
physical thread btd_general\_ammo_drops::ammodrop();
wait 0.3;
check(d getweaponammostock(dweapon) > 0 && d.health == d.maxhealth, "physical_radius_pickup_and_health_cap");
level notify("wave_start");
wait 0.1;
drop delete();
other delete();
physical delete();
if (getdvar("btd_ammo_failed") == "") setdvar("btd_test_result", "ammo_pass");
}

survivor(name)
{
p = addtestclient(name);
p.pers["isBot"] = true;
wait 0.5;
p maps\mp\gametypes\_globallogic::menuAllies();
wait 0.5;
p maps\mp\gametypes\_globallogic::menuClass("specops_mp,0");
for (i = 0; i < 150; i++)
{
if (isalive(p) && p.sessionstate == "playing") return p;
wait 0.1;
}
check(false, "spawn");
return p;
}

check(ok, name)
{
if (!ok)
{
setdvar("btd_ammo_failed", name);
setdvar("btd_test_result", "ammo_failed");
println("AMMO_CHECK_FAILED " + name);
}
else println("AMMO_CHECK_PASS " + name);
}
39 changes: 32 additions & 7 deletions tests/run_btd_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
for name in ('runtime', 'game', 'binary'):
p.add_argument('--' + name, required=True, type=Path)
p.add_argument('--fixed', action='store_true')
p.add_argument('--artifact-ammo', action='store_true', help='Use packaged ammo bytes unchanged; never synthesize the correction')
p.add_argument('--reproduce-spawn-defect', action='store_true', help='Apply death guard only, expect the native missing-angle failure')
p.add_argument('--scenario', choices=('expression', 'death', 'lifecycle', 'classic'), required=True)
p.add_argument('--scenario', choices=('expression', 'death', 'lifecycle', 'classic', 'ammo'), required=True)
p.add_argument('--classic-control', choices=('timer', 'teleport'),
help='Negative control: restore one original anti-camping mechanism')
a = p.parse_args()
Expand Down Expand Up @@ -50,7 +51,18 @@
spawn = mod / btd.SPAWN_SCRIPT.replace('.gsc', '.gsx')
spawn.parent.mkdir(parents=True, exist_ok=True)
spawn.write_bytes(btd.spawn_overlay(ff.read_bytes(), lock['spawn_points_source_sha256']))
if a.scenario == 'ammo' and not a.artifact_ammo:
ammo = (btd.ammo_overlay(ff.read_bytes(), lock['allied_ammo_source_sha256']) if a.fixed else
btd.raw_source(ff.read_bytes(), btd.ALLIED_AMMO_SCRIPT, lock['allied_ammo_source_sha256']).encode())
target = mod / btd.ALLIED_AMMO_SCRIPT.replace('.gsc', '.gsx')
target.parent.mkdir(parents=True, exist_ok=True)
target.write_bytes(ammo)
shutil.copy2(ROOT / 'tests/btd_ammo.gsc', mod / 'btd_ammo.gsc')
if a.scenario == 'ammo' and a.artifact_ammo:
shutil.copy2(ROOT / 'tests/btd_ammo.gsc', mod / 'btd_ammo.gsc')
fixture = (ROOT / 'tests/btd_regression.gsc').read_text()
if a.scenario == 'ammo':
fixture = 'main() { btd_ammo::main(); }\n'
condition = btd.SAFE_DEATH_CONDITION if a.fixed else btd.DEATH_CONDITION
fixture = fixture.replace('BTD_TEST_CONDITION', condition.replace('eInflictor', 'fixture'))
(mod / 'btd_regression.gsc').write_text(fixture)
Expand Down Expand Up @@ -97,13 +109,13 @@ def admit(attempt):
with logpath.open('w') as log:
proc = subprocess.Popen(cmd, cwd=home, stdin=subprocess.PIPE, stdout=log, stderr=subprocess.STDOUT)
try:
until = time.monotonic() + (130 if a.scenario == 'lifecycle' else 35)
until = time.monotonic() + (130 if a.scenario == 'lifecycle' else 65 if a.scenario == 'ammo' else 35)
while time.monotonic() < until and proc.poll() is None:
time.sleep(.25)
text = re.sub(r'\^[0-9]', '', logpath.read_text(errors='replace'))
if 'script runtime error' in text or 'script compile error' in text: break
proc.stdin.write(b'btd_test_result\nbtd_test_respawn\nbtd_test_zombie_spawn\nbtd_test_wave\n'); proc.stdin.flush()
success = {'expression': 'expression_pass', 'death': 'death_callback_survived', 'lifecycle': 'lifecycle_pass', 'classic': 'classic_pass'}[a.scenario]
success = {'expression': 'expression_pass', 'death': 'death_callback_survived', 'lifecycle': 'lifecycle_pass', 'classic': 'classic_pass', 'ammo': 'ammo_pass'}[a.scenario]
if '"'+success+'"' in text or re.search(r'"(?:spawn|respawn|zombie_spawn|wave)_failed"|"classic_[a-z_]+(?:failed|enabled)"', text): break
if a.scenario == 'lifecycle' and '"lifecycle_pass"' in text and not a.reproduce_spawn_defect:
time.sleep(2)
Expand All @@ -116,14 +128,21 @@ def admit(attempt):
values=status()
assert values[b'mapname']==mapname.encode() and values[b'fs_game']==b'mods/btd_alpha_001' and values[b'g_gametype']==b'war' and values[b'sv_pure']==b'1'
network_checks['map_'+mapname]=True
if a.scenario == 'ammo':
network_checks['process_alive_after_scenario'] = proc.poll() is None
try:
values = status()
network_checks['udp_available_after_scenario'] = values.get(b'sv_pure') == b'1'
except socket.timeout:
network_checks['udp_available_after_scenario'] = False
finally:
if proc.poll() is None:
proc.stdin.write(b'quit\n'); proc.stdin.flush()
try: proc.wait(timeout=8)
except subprocess.TimeoutExpired: proc.kill(); proc.wait()
text = re.sub(r'\^[0-9]', '', logpath.read_text(errors='replace'))
error = bool(re.search(r'script (?:runtime|compile) error', text))
result = {'evidence': str(home), 'scenario': a.scenario, 'fixed': a.fixed,
result = {'evidence': str(home), 'scenario': a.scenario, 'fixed': a.fixed, 'artifact_ammo': a.artifact_ammo, 'input_binary_sha256': hashlib.sha256(a.binary.read_bytes()).hexdigest(), 'input_fastfile_sha256': hashlib.sha256(ff.read_bytes()).hexdigest(),
'runtime_error': error, 'gameplay_qualified': False, 'network_checks': network_checks,
'expression_pass': '"expression_pass"' in text,
'death_callback_survived': '"death_callback_survived"' in text,
Expand All @@ -134,13 +153,19 @@ def admit(attempt):
'classic_pass': '"classic_pass"' in text,
'classic_control': a.classic_control,
'classic_control_detected': bool(a.classic_control and '"classic_'+a.classic_control+'_enabled"' in text),
'lifecycle_pass': '"lifecycle_pass"' in text}
'lifecycle_pass': '"lifecycle_pass"' in text, 'ammo_pass': '"ammo_pass"' in text}
(home/'results.json').write_text(json.dumps(result, indent=2)+'\n')
print(json.dumps(result, indent=2))
expected = result[{'expression':'expression_pass','death':'death_callback_survived','lifecycle':'lifecycle_pass','classic':'classic_pass'}[a.scenario]]
expected = result[{'expression':'expression_pass','death':'death_callback_survived','lifecycle':'lifecycle_pass','classic':'classic_pass','ammo':'ammo_pass'}[a.scenario]]
if a.classic_control:
assert not error and result['classic_control_detected'], 'Negative control not detected: '+str(home)
elif a.reproduce_spawn_defect:
assert error and 'type undefined is not a vector' in text, 'Spawn defect not reproduced: '+str(home)
elif a.fixed: assert not error and expected, 'Fixed regression failed: '+str(home)
elif a.scenario == 'ammo' and not a.fixed:
assert error and 'cannot cast undefined to bool' in text and 'player.hasntfullammo' in text, 'Ammo failure not reproduced: '+str(home)
assert network_checks['process_alive_after_scenario'] and not network_checks['udp_available_after_scenario'], 'Shutdown symptom not reproduced'
elif a.fixed:
assert not error and expected, 'Fixed regression failed: '+str(home)
if a.scenario == 'ammo':
assert all(network_checks.values()), 'Fixed ammo service unavailable: '+str(home)
else: assert error and "has unmatching types 'undefined' and 'string'" in text, 'Expected failure not reproduced: '+str(home)
Loading
Loading