From 7889163659d700813ba53e3dc4d4e595b4bca0c6 Mon Sep 17 00:00:00 2001 From: ghptc Date: Wed, 28 Oct 2026 20:53:57 -0300 Subject: [PATCH 1/2] fix(zombies): require reviewed ammo override in every package --- docs/zombies-ammo-finalization-20261028.md | 71 ++++++++++++++++++++++ scripts/modes.py | 13 +++- tests/test_modes.py | 33 +++++++++- 3 files changed, 111 insertions(+), 6 deletions(-) create mode 100644 docs/zombies-ammo-finalization-20261028.md diff --git a/docs/zombies-ammo-finalization-20261028.md b/docs/zombies-ammo-finalization-20261028.md new file mode 100644 index 0000000..64bb013 --- /dev/null +++ b/docs/zombies-ammo-finalization-20261028.md @@ -0,0 +1,71 @@ +# 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`. +- 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. diff --git a/scripts/modes.py b/scripts/modes.py index 060f8fc..e023050 100644 --- a/scripts/modes.py +++ b/scripts/modes.py @@ -7,6 +7,8 @@ import re import shutil +BTD_AMMO_SHA256 = '2b06adeb720eb54320313d0ab85b1e08bfe61baca79da8c413097e93617b2bb0' + ID = r'[a-z][a-z0-9-]*' FS_GAME = r'(?:mods/[A-Za-z0-9_-]+)?' SETTING = re.compile(r'set ([A-Za-z_][A-Za-z0-9_]*) "([^"\\;\x00-\x1f\x7f]*)"') @@ -151,7 +153,8 @@ def package(root, mode_id, runtime, engine_revision, config_revision, bot_revisi path = destination / name if path.is_symlink() or digest(path) != expected: raise ValueError(f'BTD asset identity mismatch: {name}') - overlay_names = {'maps/mp/gametypes/_globallogic.gsx', + overlay_names = {'btd_general/_ammo_drops.gsx', + 'maps/mp/gametypes/_globallogic.gsx', 'btd_gametypes/survival/_survival_spawns.gsx'} if 'navigation_source_sha256' in record: # The navigation overlay is generated from this pinned private BTD @@ -178,7 +181,7 @@ def package(root, mode_id, runtime, engine_revision, config_revision, bot_revisi overlay_names.update({'btd_allies.gsx', 'btd_gametypes/survival/_survival_logic.gsx', 'k3/_zombie.gsx', 'btd_general/_ammo_drops.gsx'}) - elif any(name in record for name in ('allied_survival_source_sha256', 'allied_zombie_source_sha256', 'allied_ammo_source_sha256')): + elif any(name in record for name in ('allied_survival_source_sha256', 'allied_zombie_source_sha256')): raise ValueError('Undeclared BTD allied source identities') # Extra source files can override fastfile scripts even when omitted from # the manifest. Do not package undeclared code or follow private links. @@ -187,9 +190,13 @@ def package(root, mode_id, runtime, engine_revision, config_revision, bot_revisi raise ValueError('Symlinked BTD runtime entry') if path.is_file() and path.suffix.lower() in ('.gsc', '.gsx') and str(path.relative_to(destination)) not in overlay_names: raise ValueError('Undeclared BTD source overlay') + if record.get('allied_ammo_source_sha256') != '545021b1444b643d270db77fad21767368b94c439a560dd739ed6de6d321b7ad': + raise ValueError('Verified BTD ammo safety source identity required') overlays = record.get('overlays', {}) + if overlays.get('btd_general/_ammo_drops.gsx') != BTD_AMMO_SHA256: + raise ValueError('Reviewed BTD ammo safety override hash required') if set(overlays) != overlay_names: - raise ValueError('Verified BTD death, spawn and declared navigation overlays required') + raise ValueError('Verified BTD death, spawn, ammo and declared navigation overlays required') for name, expected in overlays.items(): overlay = destination / name if overlay.is_symlink() or not overlay.is_file() or any( diff --git a/tests/test_modes.py b/tests/test_modes.py index ba3ca80..6cbf761 100644 --- a/tests/test_modes.py +++ b/tests/test_modes.py @@ -7,6 +7,7 @@ import sys import tempfile import unittest +from unittest.mock import patch sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'scripts')) import modes @@ -118,6 +119,7 @@ def test_hash_binds_all_three_cfgs(self): class PackagingTests(unittest.TestCase): setUp = CatalogTests.setUp + @patch.object(modes, 'BTD_AMMO_SHA256', hashlib.sha256(b'ammo first-use safety fixture').hexdigest()) def test_btd_packaging_and_rejection(self): self.metadata.write_text('set fs_game "mods/btd_alpha_001"\n') original_server = self.server.read_text() @@ -133,10 +135,12 @@ def test_btd_packaging_and_rejection(self): 'allied_missing_ammo', 'allied_tampered_ammo', 'allied_missing_ammo_manifest', 'allied_bad_death_hash', 'allied_bad_spawn_hash', 'allied_missing_adapter', 'allied_missing_survival', 'allied_missing_zombie', - 'allied_tampered_adapter', 'allied_tampered_survival', 'allied_tampered_zombie', + 'allied_rehashed_ammo', 'allied_tampered_adapter', 'allied_tampered_survival', 'allied_tampered_zombie', 'allied_undeclared_source', 'allied_extra_manifest', 'allied_symlink_adapter'} cases = ('valid', 'tampered', 'path', 'missing', 'wrong_recipe', 'missing_overlay', 'tampered_overlay', 'extra_overlay', 'undeclared_source', 'legacy_killhouse', + 'missing_ammo', 'tampered_ammo', 'bad_ammo_source', 'missing_ammo_source', + 'missing_ammo_overlay', 'rehashed_ammo', 'symlink_ammo', 'symlink_ammo_parent', *sorted(navigation_cases | allied_cases)) for case in cases: with self.subTest(case=case): @@ -160,8 +164,11 @@ def test_btd_packaging_and_rejection(self): spawn = mod / 'btd_gametypes/survival/_survival_spawns.gsx' spawn.parent.mkdir(parents=True) spawn.write_bytes(b'initialized angles fixture') + ammo = mod / 'btd_general/_ammo_drops.gsx' + ammo.parent.mkdir() + ammo.write_bytes(b'ammo first-use safety fixture') (output / 'cod4x18_dedrun').write_bytes(b'engine') - record = {'maps': ['mp_crash', 'mp_strike', 'mp_killhouse'], 'asset_type': 'btd-alpha-001', + record = {'allied_ammo_source_sha256': '545021b1444b643d270db77fad21767368b94c439a560dd739ed6de6d321b7ad', 'maps': ['mp_crash', 'mp_strike', 'mp_killhouse'], 'asset_type': 'btd-alpha-001', 'fs_game': 'mods/btd_alpha_001', 'binary_sha256': modes.digest(output / 'cod4x18_dedrun'), 'headers': {n: modes.digest(headers / n) for n in names}, @@ -169,6 +176,23 @@ def test_btd_packaging_and_rejection(self): 'default_cfgs': ['btd_settings.cfg'], 'overlays': {'maps/mp/gametypes/_globallogic.gsx': modes.digest(overlay), 'btd_gametypes/survival/_survival_spawns.gsx': modes.digest(spawn)}} + record['overlays']['btd_general/_ammo_drops.gsx'] = modes.digest(ammo) + if case == 'missing_ammo': ammo.unlink() + if case == 'tampered_ammo': ammo.write_bytes(b'changed') + if case == 'rehashed_ammo': + ammo.write_bytes(b'changed') + record['overlays']['btd_general/_ammo_drops.gsx'] = modes.digest(ammo) + if case == 'symlink_ammo': + target = output / 'external-ammo' + ammo.rename(target) + ammo.symlink_to(target) + if case == 'symlink_ammo_parent': + target = output / 'external-ammo-directory' + ammo.parent.rename(target) + ammo.parent.symlink_to(target, target_is_directory=True) + if case == 'bad_ammo_source': record['allied_ammo_source_sha256'] = '0' * 64 + if case == 'missing_ammo_source': record.pop('allied_ammo_source_sha256') + if case == 'missing_ammo_overlay': record['overlays'].pop('btd_general/_ammo_drops.gsx') if case in navigation_cases | allied_cases: navigation = mod / 'svr/pezbot.gsx' navigation.parent.mkdir() @@ -199,7 +223,7 @@ def test_btd_packaging_and_rejection(self): for name in allied_paths.values(): path = mod / name path.parent.mkdir(parents=True, exist_ok=True) - path.write_bytes(b'private allied fixture') + path.write_bytes(b'ammo first-use safety fixture' if name == allied_paths['ammo'] else b'private allied fixture') record['overlays'][name] = modes.digest(path) record.update(allied_bots=True, death_callback_source_sha256='b6ca82d2d1f8dcd0c454d5e193f54ce1c1147619d547cba4472bbe00bfa60861', @@ -237,6 +261,9 @@ def test_btd_packaging_and_rejection(self): path = mod / name if case == 'allied_missing_' + short: path.unlink() if case == 'allied_tampered_' + short: path.write_bytes(b'changed') + if case == 'allied_rehashed_ammo': + ammo.write_bytes(b'changed') + record['overlays'][allied_paths['ammo']] = modes.digest(ammo) if case == 'allied_symlink_adapter': path = mod / allied_paths['adapter'] target = output / 'external-adapter' From 508ab3b3f9b5568cd2d0f5c472e4111bdfcf8e7b Mon Sep 17 00:00:00 2001 From: ghptc Date: Wed, 28 Oct 2026 20:54:49 -0300 Subject: [PATCH 2/2] docs(zombies): record final allied compatibility evidence --- docs/zombies-ammo-finalization-20261028.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/zombies-ammo-finalization-20261028.md b/docs/zombies-ammo-finalization-20261028.md index 64bb013..d52cc42 100644 --- a/docs/zombies-ammo-finalization-20261028.md +++ b/docs/zombies-ammo-finalization-20261028.md @@ -47,6 +47,9 @@ Fresh validation: `/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`.