From 73486aeb20c0aaecdba263728e6be62c9fd75545 Mon Sep 17 00:00:00 2001 From: ghptc Date: Tue, 27 Oct 2026 20:18:57 -0300 Subject: [PATCH 1/6] feat(promod): add military naming and native S&D objective integration --- bots/promod_ai.gsc | 22 ++++++ bots/sd_objectives.gsc | 82 +++++++++++++++++++++ docs/promod-military-sd.md | 84 ++++++++++++++++++++++ src/sv_bot_manager.c | 57 ++++++++++++++- src/sv_bot_names.h | 35 +++++++++ tests/run_sd_native.py | 118 +++++++++++++++++++++++++++++++ tests/sd_native.gsc | 137 ++++++++++++++++++++++++++++++++++++ tests/sd_navigation.gsc | 44 ++++++++++++ tests/test_bot_names.py | 39 ++++++++++ tests/test_sd_objectives.py | 50 +++++++++++++ tools/bots/prepare.py | 81 ++++++++++++++++++++- 11 files changed, 745 insertions(+), 4 deletions(-) create mode 100644 bots/sd_objectives.gsc create mode 100644 docs/promod-military-sd.md create mode 100644 src/sv_bot_names.h create mode 100644 tests/run_sd_native.py create mode 100644 tests/sd_native.gsc create mode 100644 tests/sd_navigation.gsc create mode 100644 tests/test_bot_names.py create mode 100644 tests/test_sd_objectives.py diff --git a/bots/promod_ai.gsc b/bots/promod_ai.gsc index 460d93ad..21198889 100644 --- a/bots/promod_ai.gsc +++ b/bots/promod_ai.gsc @@ -136,6 +136,13 @@ on_round_end() { level waittill("game_ended"); setdvar("bot_ai_ready", 0); + players = getentarray("player", "classname"); + for (i = 0; i < players.size; i++) + if (players[i].isbot) + { + players[i] notify("bot_use"); + players[i] BotBuiltinBotAction("-activate"); + } } attach() @@ -148,6 +155,7 @@ attach() self.promod_ai_core_spawned = undefined; self maps\mp\bots\_bot_internal::added(); self thread difficulty_control(); + self thread objective_spawns(); self maps\mp\bots\_bot_internal::connected(); self thread model_ready(); self thread weapon_selection(); @@ -337,3 +345,17 @@ bot_trace(message) if (getdvarint("bot_debug")) logprint(message + "\n"); } + +// Start only after the existing combat core announces each native spawn. +objective_spawns() +{ + self endon("disconnect"); + self endon("promod_ai_reset"); + level endon("game_ended"); + for (;;) + { + self thread maps\mp\bots\sd_objectives::start(); + self waittill("bot_spawned"); + wait 0.05; + } +} diff --git a/bots/sd_objectives.gsc b/bots/sd_objectives.gsc new file mode 100644 index 00000000..6afdb98b --- /dev/null +++ b/bots/sd_objectives.gsc @@ -0,0 +1,82 @@ +// Promod-specific glue for the derived Bot Warfare S&D routines. +// Mod asset terms and attribution: docs/third-party-bots.md. + +start() +{ + self endon("disconnect"); + self endon("death"); + self endon("promod_ai_reset"); + level endon("game_ended"); + self waittill("bot_spawned"); + if (!getdvarint("bot_sd_objectives") || !self.isbot) + return; + if (getdvarint("bot_debug")) logprint("PMBOT SD_START slot=" + self getentitynumber() + "\n"); + self.bot_lock_goal = false; + self thread cleanup_on_death(); + self thread bot_sd_attackers(); + self thread bot_sd_defenders(); +} + +cleanup_on_death() +{ + self endon("disconnect"); + self endon("promod_ai_reset"); + level endon("game_ended"); + self waittill("death"); + self notify("bot_use"); + self BotBuiltinBotAction("-activate"); +} + +carries_bomb() +{ + return isdefined(level.sdbomb) && isdefined(self.carryobject) && + self.carryobject == level.sdbomb; +} + +objective_goal(origin, radius) +{ + if (getdvarint("bot_debug")) logprint("PMBOT SD_GOAL slot=" + self getentitynumber() + " origin=" + origin + "\n"); + self SetScriptGoal(origin, radius); + self thread goal_deadline(level.bombplanted); +} + +goal_deadline(planted) +{ + self endon("disconnect"); + self endon("death"); + self endon("promod_ai_reset"); + self endon("new_goal"); + self endon("goal"); + self endon("bad_path"); + level endon("game_ended"); + deadline = gettime() + 45000; + while (gettime() < deadline && getdvarint("bot_sd_objectives") && + !level.gameended && planted == level.bombplanted) + wait 0.1; + self notify("bad_path"); +} + +wait_stop_move() +{ + deadline = gettime() + 2000; + while (gettime() < deadline && (!self isonground() || lengthsquared(self getvelocity()) > 1)) + wait 0.05; +} + +hold_objective_use(duration) +{ + if (getdvarint("bot_debug")) logprint("PMBOT SD_USE slot=" + self getentitynumber() + "\n"); + planted = level.bombplanted; + deadline = gettime() + int(duration * 1000); + while (gettime() < deadline && getdvarint("bot_sd_objectives") && + !level.gameended && planted == level.bombplanted && + !level.bombdefused && !level.bombexploded && !self HasThreat()) + { + // Short renewable native input leases: interruption cannot leave use held. + // The native game object validates contact, team and ownership every tick. + self thread BotPressUse(0.1); + wait 0.05; + } + self notify("bot_use"); + self BotBuiltinBotAction("-activate"); +} diff --git a/docs/promod-military-sd.md b/docs/promod-military-sd.md new file mode 100644 index 00000000..1b673919 --- /dev/null +++ b/docs/promod-military-sd.md @@ -0,0 +1,84 @@ +# Final feature candidate: military names and native S&D + +Status: candidate implementation, **not gameplay certified**. Feature freeze +resumes after this focused delivery; no unrelated development is authorized. +No production/homologation runtime, deployment policy or RCON bridge is changed. +Owner approval is required for merges and a separate supervised homologation. + +## Ownership and behavior + +Engine population management consumes Bot Warfare's existing root +`scriptdata/botnames.txt` convention when `bot_use_names=1`. Configuration owns +the 15-name military pool; the workspace copies it and includes its content in +the configuration fingerprint. Assignment happens only in `BotAddOne`, before +`SV_AddBotClient`. Existing bots and humans are never renamed. Round restarts +retain native client userinfo. Subsequent admissions take the first unused name, +including collision checks against humans after native name cleaning, ignoring +case. Missing, invalid, oversized or exhausted pools use unique numbered Promod +fallbacks. Name input is bounded to 8192 bytes and 31 ASCII display bytes per +line; overlong and unsafe lines are rejected rather than truncated. Blank lines +are ignored; allowed characters are letters, numbers, spaces, dots and hyphens. +Zombies uses its existing naming path. Changing the pool affects new bots only. + +`bot_sd_objectives=1` starts the pinned Bot Warfare S&D routines after the +existing combat core's `bot_spawned` event. Enabling it midround takes effect +on the next spawn. Disabling cancels held input and outstanding navigation +within the 100ms goal watchdog; controllers remain idle/retry until the next +spawn. `bots_play_obj` stays zero because the stock all-gametype initializer and +its callback replacements are not installed. + +Preparation extracts only S&D routines and their helpers. It removes the stock +preplant defender lookup of the dropped bomb, and reactions to remote enemy +plant/defuse activity. Navigation uses public sites and the announced planted +bomb; teammate carrier ownership remains normal. Bad paths have bounded waits +and the attacker retries another site. Promod exposes its existing defuse object +through a reference; native creation, callbacks, timers and outcomes are intact. +Carrier tests use authoritative `carryObject`, not Bot Warfare's absent flag. +Use input passes through the existing Bot Warfare adapter and native player +button path. Native Promod validates ownership, team, contact, health and the +full hold timer. Short renewable input leases release on interruption; death +and round end explicitly clear use. No production code teleports, grants bombs, +invokes plant/defuse callbacks, sets bomb outcomes or reads enemy carrier data. + +Pinned inputs are unchanged: Bot Warfare v2.2.0 at +`7b52b462e40fa68287b9e54602e52da83b17766c`, Promod LIVE V2.20 EU and all +eight header hashes in `bots/dependencies.json`. Licensed extracted/generated +scripts stay private. Source terms and credits: [third-party-bots.md](third-party-bots.md). +The preserved PoC remains read-only. + +## Evidence and remaining gates + +Local engine build passes. Existing and focused parser/overlay Python tests, +native population policy, rotation and voting harnesses pass. Workspace packaging +and operation mocks are run without SSH or service changes. Hosted mandatory CI +must pass on final PR heads; existing workflows are retained without changes. + +`tests/run_sd_native.py` creates a new loopback process and verifies pinned +Promod/header identities. Its native fixture uses **test-only positioning** to +exercise legitimate pickup, interrupted plant/defuse and real native completion. +Accepted Crash evidence: `/tmp/cod4x-sd-native-vffuwzhm/results.json` shows plant +5150ms, defuse 7100ms, both interruptions, pure=1 and all 12 requested active +names. It does not prove autonomous navigation or real-client gameplay. +Rejected runs are retained privately and are not qualification evidence. + +The separate `--scenario navigation` fixture observes actual AI navigation/use, +with combat suppressed solely in the test fixture; no positioning is used. +Neither synthetic fixture certifies combat decisions, HUD, human bomb priority, +interruption under fire, every supported map or a full competitive match. +Death/drop, names across rounds/admission collisions, bot administration, +Promod/Zombies gameplay regressions and the supported-map matrix must be recorded +before qualification approval. Independent Principal architecture/security review +is provisional until these gates and final CI are complete. Do not promote this +candidate based only on connected/active bots or prepared waypoint coverage. + +## Rollback and freeze + +Revert the focused engine, catalog and workspace changes together and rebuild +the prior reviewed artifact. Preserve the previous immutable artifact and config +hash for operational rollback. There is no data migration. Setting +`bot_sd_objectives=0`/`bot_use_names=0` stops new objective/name activation but +is not an approved replacement for exact-artifact rollback. No merges, +deployments, bridge activation or production promotion are performed here. +After approved merges, prepare one pinned homologation candidate, obtain owner +deployment approval, supervise real-client gameplay and exact-artifact rollback, +then request qualification approval before proposing production promotion. diff --git a/src/sv_bot_manager.c b/src/sv_bot_manager.c index fde88bab..d6250e4e 100644 --- a/src/sv_bot_manager.c +++ b/src/sv_bot_manager.c @@ -6,11 +6,12 @@ #include "qcommon.h" #include "qcommon_io.h" #include "sv_bot_policy.h" +#include "sv_bot_names.h" #include "g_sv_shared.h" #include "filesystem.h" static cvar_t *bot_enable, *bot_ai_ready, *bot_fill_limit, *bot_skill; -static cvar_t *btd_allies_enable, *btd_allies_limit; +static cvar_t *btd_allies_enable, *btd_allies_limit, *bot_use_names; static bot_fill_state_t fill_state = BOT_FILL_ACTIVE; static int next_fill; @@ -51,10 +52,58 @@ static qboolean BotQueueWaiting(void) return qfalse; } +/* Names are assigned once, never by renaming an existing player. Include humans + * in collision checks without modifying their names. Re-read the small local + * pool on admission so editing it affects only newly created Promod bots. */ +static qboolean BotNameUsed(const char *name) +{ + int i; + for (i = 0; i < sv_maxclients->integer; ++i) { + char clean[BOT_NAME_BYTES]; + client_t *cl = &svs.clients[i]; + if (cl->state < CS_CONNECTED) continue; + ClientCleanName(Info_ValueForKey(cl->userinfo, "name"), clean, sizeof(clean), qfalse); + if (!Q_stricmp(clean, name)) return qtrue; + } + return qfalse; +} + +static qboolean BotPoolName(char name[BOT_NAME_BYTES]) +{ + fileHandle_t file; + char data[BOT_NAMES_BYTES], candidate[BOT_NAME_BYTES]; + const char *cursor = data; + int length = FS_SV_FOpenFileRead("scriptdata/botnames.txt", &file); + if (!file) return qfalse; + if (length <= 0 || length > sizeof(data)) { + FS_FCloseFile(file); + return qfalse; + } + if (FS_Read(data, length, file) != length) { + FS_FCloseFile(file); + return qfalse; + } + FS_FCloseFile(file); + while (BotName_Next(&cursor, data + length, candidate)) { + ClientCleanName(candidate, name, BOT_NAME_BYTES, qfalse); + if (!BotNameUsed(name)) return qtrue; + } + return qfalse; +} + static qboolean BotAddOne(void) { - char name[32]; - Com_sprintf(name, sizeof(name), "[BOT] %s %02d", BotAlliedMode() ? "Ally" : "Promod", BotCount() + 1); + char name[BOT_NAME_BYTES]; + int number; + if (BotAlliedMode()) { + Com_sprintf(name, sizeof(name), "[BOT] Ally %02d", BotCount() + 1); + } else if (!bot_use_names->boolean || !BotPoolName(name)) { + /* Pigeonhole bound: with N slots at most N names can be occupied. */ + for (number = 1; number <= sv_maxclients->integer + 1; ++number) { + Com_sprintf(name, sizeof(name), "[BOT] Promod %02d", number); + if (!BotNameUsed(name)) break; + } + } return SV_AddBotClient(name) != NULL; } @@ -197,6 +246,8 @@ void SV_BotManagerInit(void) bot_skill = Cvar_RegisterInt("bot_skill", -1, -1, 7, 0, "Bot skill: -1 original fixed profile, 0 mixed, 1..7 Bot Warfare tiers"); btd_allies_enable = Cvar_RegisterBool("btd_allies_enable", qtrue, 0, "Enable the isolated BTD allied controller"); btd_allies_limit = Cvar_RegisterInt("btd_allies_limit", 5, 0, 12, 0, "Maximum allied BTD bots"); + bot_use_names = Cvar_RegisterBool("bot_use_names", qfalse, 0, "Use Bot Warfare scriptdata/botnames.txt for new Promod bots"); + Cvar_RegisterBool("bot_sd_objectives", qfalse, 0, "Enable native Promod S&D objective navigation and use input"); Cvar_RegisterBool("bot_debug", qfalse, 0, "Write bot gameplay evidence to the game log"); Cmd_AddPCommand("bot_kickall", BotKickAll, 80); Cmd_AddPCommand("bot_killall", BotKillAll, 80); diff --git a/src/sv_bot_names.h b/src/sv_bot_names.h new file mode 100644 index 00000000..e2edfeea --- /dev/null +++ b/src/sv_bot_names.h @@ -0,0 +1,35 @@ +/* Bounded Bot Warfare botnames.txt parsing. AGPL-3.0-or-later. */ +#ifndef SV_BOT_NAMES_H +#define SV_BOT_NAMES_H +#include +#define BOT_NAMES_BYTES 8192 +#define BOT_NAME_BYTES 32 +/* Only plain ASCII display names: no colors, controls or userinfo delimiters. + * Reject overlong lines instead of truncating two distinct names into one. */ +static int BotName_Next(const char **cursor, const char *end, char name[BOT_NAME_BYTES]) +{ + while (*cursor < end) { + const char *start = *cursor, *stop; + size_t length, i; + int valid = 1; + while (*cursor < end && **cursor != '\n') ++*cursor; + stop = *cursor; + if (*cursor < end) ++*cursor; + if (stop > start && stop[-1] == '\r') --stop; + while (start < stop && *start == ' ') ++start; + while (stop > start && stop[-1] == ' ') --stop; + length = (size_t)(stop - start); + if (!length || length >= BOT_NAME_BYTES) continue; + for (i = 0; i < length; ++i) { + unsigned char c = (unsigned char)start[i]; + if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || + (c >= '0' && c <= '9') || c == ' ' || c == '.' || c == '-')) valid = 0; + } + if (!valid) continue; + for (i = 0; i < length; ++i) name[i] = start[i]; + name[length] = 0; + return 1; + } + return 0; +} +#endif diff --git a/tests/run_sd_native.py b/tests/run_sd_native.py new file mode 100644 index 00000000..b4dcd606 --- /dev/null +++ b/tests/run_sd_native.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 +"""Native interaction evidence in a NEW loopback-only disposable process. +Fixture positioning is not bot navigation or real-client qualification. +""" +import argparse +import json +import hashlib +from pathlib import Path +import re +import secrets +import shutil +import socket +import subprocess +import tempfile +import time + +ROOT = Path(__file__).resolve().parents[1] +p = argparse.ArgumentParser(description=__doc__) +p.add_argument('--runtime', required=True, type=Path) +p.add_argument('--game', required=True, type=Path) +p.add_argument('--names', required=True, type=Path) +p.add_argument('--scenario', choices=('native', 'navigation'), default='native') +p.add_argument('--map', default='mp_crash') +a = p.parse_args() +assert a.map in json.loads((a.runtime / 'inputs.json').read_text())['maps'] +assert (a.runtime / '.bot-test-runtime').is_file() +home = Path(tempfile.mkdtemp(prefix='cod4x-sd-native-')) +for name in ('mods', 'integrity'): + shutil.copytree(a.runtime / name, home / name) +for name in ('main', 'zone'): + (home / name).symlink_to((a.game / name).resolve(), target_is_directory=True) +shutil.copy2(ROOT / 'bin/cod4x18_dedrun', home / 'cod4x18_dedrun') +(home / 'scriptdata').mkdir() +shutil.copy2(a.names, home / 'scriptdata/botnames.txt') +mod = home / 'mods/pml220' +lock = json.loads((ROOT / 'bots/dependencies.json').read_text()) +for directory, expected in [(mod, lock['promod']['files']), + (home / 'integrity/addiwdheaders', lock['integrity_headers'])]: + for name, sha in expected.items(): + assert hashlib.sha256((directory / name).read_bytes()).hexdigest() == sha +fixture = 'sd_native' if a.scenario == 'native' else 'sd_navigation' +shutil.copy2(ROOT / ('tests/' + fixture + '.gsc'), mod / ('maps/mp/bots/' + fixture + '.gsc')) +for wrapper in (mod / 'maps/mp').glob('mp_*.gsx'): + wrapper.write_text(wrapper.read_text().replace('main(){', + 'main(){level thread maps\\mp\\bots\\' + fixture + '::init();', 1)) +password = secrets.token_hex(20) +(mod / 'qualification.cfg').write_text(f'''set rcon_password "{password}" +set promod_mode "custom_public" +set promod_allow_no_punkbuster "1" +set bot_enable "1" +set bot_use_names "1" +set bot_sd_objectives "{int(a.scenario == "navigation")}" +set bot_debug "1" +set sv_mapRotation "gametype sd map {a.map}" +''') +with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as channel: + channel.bind(('127.0.0.1', 0)); port = channel.getsockname()[1] +output = (home / 'console.log').open('w') +cmd = [str(home / 'cod4x18_dedrun'), '+set', 'dedicated', '1', '+set', 'net_ip', '127.0.0.1', + '+set', 'net_port', str(port), '+set', 'fs_homepath', str(home), '+set', 'fs_basepath', str(home), + '+set', 'fs_game', 'mods/pml220', '+set', 'sv_pure', '1', '+set', 'sv_maxclients', '12', + '+set', 'fs_localizedHeadersPath', str(home / 'integrity'), '+exec', 'qualification.cfg', '+map_rotate'] +proc = subprocess.Popen(cmd, cwd=home, stdin=subprocess.PIPE, stdout=output, stderr=subprocess.STDOUT) +result = {'map': a.map, 'scenario': a.scenario, 'fixture_positioning': a.scenario == 'native', 'real_client_qualified': False} +def rcon(command): + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as channel: + channel.settimeout(2) + channel.sendto(b'\xff' * 4 + f'rcon {password} {command}'.encode(), ('127.0.0.1', port)) + packets = [channel.recv(65535)] + channel.settimeout(.1) + while True: + try: packets.append(channel.recv(65535)) + except TimeoutError: break + return re.sub(r'\^[0-9]', '', b''.join(packets).decode(errors='replace')) +try: + deadline = time.monotonic() + (65 if a.scenario == "native" else 240) + while time.monotonic() < deadline: + if proc.poll() is not None: raise AssertionError('engine exited') + try: + value = rcon('sd_test_result') if a.scenario == 'native' else rcon('sd_navigation_defuses') + if a.scenario == 'navigation' and re.search(r' is: "[1-9][0-9]*"', value): break + except TimeoutError: value = '' + if '"passed"' in value: break + if re.search(r'"(?:missing_|pickup_failed|plant_interrupt_failed|defuse_interrupt_failed|death_drop_failed|defuse_death_failed|native_).*"', value): + raise AssertionError(value + rcon('sd_test_debug')) + time.sleep(.5) + else: raise AssertionError('fixture timeout') + for key in (() if a.scenario == 'navigation' else ('pickup', 'plant_interrupted', 'planted', 'defuse_interrupted', 'death_drop', 'defuse_death', 'plant_elapsed', 'defuse_elapsed')): + value = rcon('sd_test_' + key) + found = re.search(r' is: "(\d+)"', value) + assert found, value + result[key] = int(found[1]) + result['pure'] = '"1"' in rcon('sv_pure') + assert result['pure'], 'purity lost' + result['status'] = rcon('status') + names = a.names.read_text().splitlines() + active_names = [name for name in names if name in result['status']] + assert len(active_names) == 12, 'requested active names missing' + result['requested_names'] = active_names + if a.scenario == 'native': + deadline = time.monotonic() + 20 + while time.monotonic() < deadline: + if ' is: "2"' in rcon('sd_test_rounds'): break + time.sleep(.2) + else: raise AssertionError('native next round did not start') + assert ' is: "1"' in rcon('sd_test_round_reset') + after = rcon('status') + assert all(name in after for name in active_names), 'names changed across round' + result['round_reset_and_names_preserved'] = True + result['passed'] = True +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() + output.close() + (home / 'results.json').write_text(json.dumps(result, indent=2) + '\n') + print(home, flush=True) diff --git a/tests/sd_native.gsc b/tests/sd_native.gsc new file mode 100644 index 00000000..f9a64e66 --- /dev/null +++ b/tests/sd_native.gsc @@ -0,0 +1,137 @@ +// Test-only native interaction fixture. Never installed by preparation. +// setorigin is fixture arrangement, NOT navigation/gameplay evidence. +#include maps\mp\bots\_bot_utility; +init() +{ + level endon("game_ended"); + wait 1; + setdvar("sd_test_rounds", getdvarint("sd_test_rounds") + 1); + setdvar("sd_test_round_reset", int(!level.bombplanted && !level.bombdefused && !level.bombexploded)); + wait 13; + players = getentarray("player", "classname"); + attacker = undefined; + defender = undefined; + for (i = 0; i < players.size; i++) + { + player = players[i]; + player notify("promod_ai_reset"); + player botstop(); + if (player.pers["team"] == game["attackers"] && !isdefined(attacker)) attacker = player; + if (player.pers["team"] == game["defenders"] && !isdefined(defender)) defender = player; + } + if (!isdefined(attacker) || !isdefined(defender) || !isdefined(level.sdbomb)) + { + setdvar("sd_test_result", "missing_players_or_bomb"); + return; + } + if (isdefined(level.sdbomb.carrier)) attacker = level.sdbomb.carrier; + attacker setorigin(level.sdbomb.trigger.origin); + wait 1; + if (!isdefined(attacker.carryobject) || attacker.carryobject != level.sdbomb) + { + setdvar("sd_test_result", "pickup_failed"); + return; + } + setdvar("sd_test_pickup", 1); + plant = level.bombzones[0]; + attacker setorigin(plant.curorigin + (50,50,5)); + wait 0.5; + attacker botaction("+activate"); + wait 1; + attacker botaction("-activate"); + wait 0.3; + if (level.bombplanted || attacker.isplanting) + { + setdvar("sd_test_result", "plant_interrupt_failed"); + return; + } + setdvar("sd_test_plant_interrupted", 1); + attacker.throwingGrenade = false; + attacker suicide(); + wait 0.3; + if (isdefined(level.sdbomb.carrier) || level.bombplanted) + { + setdvar("sd_test_result", "death_drop_failed"); + return; + } + setdvar("sd_test_death_drop", 1); + for (i = 0; i < players.size; i++) + if (players[i].pers["team"] == game["attackers"] && isalive(players[i])) + { attacker = players[i]; break; } + if (isdefined(level.sdbomb.carrier)) attacker = level.sdbomb.carrier; + attacker setorigin(level.sdbomb.trigger.origin); + wait 0.5; + if (!isdefined(attacker.carryobject) || attacker.carryobject != level.sdbomb) + { + setdvar("sd_test_result", "pickup_failed"); + return; + } + attacker setorigin(plant.curorigin + (50,50,5)); + wait 0.5; + began = gettime(); + attacker botaction("+activate"); + while (!level.bombplanted && gettime() - began < 10000) wait 0.05; + attacker botaction("-activate"); + setdvar("sd_test_plant_elapsed", gettime() - began); + setdvar("sd_test_debug", "planted=" + int(level.bombplanted) + " time=" + (gettime() - began) + " required=" + plant.usetime + " touching=" + int(attacker istouching(plant.trigger)) + " onground=" + int(attacker isonground())); + if (!level.bombplanted || gettime() - began < plant.usetime - 100) + { + setdvar("sd_test_result", "native_plant_failed"); + return; + } + setdvar("sd_test_planted", 1); + wait 0.2; + defuse = level.defuseobject; + defender setorigin(defuse.curorigin + (0,0,5)); + wait 0.5; + defender botaction("+activate"); + wait 1; + defender botaction("-activate"); + wait 0.3; + if (level.bombdefused || defender.isdefusing) + { + setdvar("sd_test_result", "defuse_interrupt_failed"); + return; + } + setdvar("sd_test_defuse_interrupted", 1); + defender botaction("+activate"); + wait 1; + defender.throwingGrenade = false; + defender suicide(); + wait 0.3; + if (level.bombdefused) + { + setdvar("sd_test_result", "defuse_death_failed"); + return; + } + setdvar("sd_test_defuse_death", 1); + for (i = 0; i < players.size; i++) + if (players[i].pers["team"] == game["defenders"] && isalive(players[i])) + { defender = players[i]; break; } + defender setorigin(defuse.curorigin + (0,0,5)); + wait 0.5; + began = gettime(); + level thread record_defuse(defender, defuse, began); + defender botaction("+activate"); + while (!level.bombdefused && gettime() - began < 12000) wait 0.05; + defender botaction("-activate"); + setdvar("sd_test_defuse_elapsed", gettime() - began); + if (!level.bombdefused || gettime() - began < defuse.usetime - 100) + { + setdvar("sd_test_result", "native_defuse_failed"); + return; + } + setdvar("sd_test_result", "passed"); +} + +record_defuse(defender, object, began) +{ + level waittill("bomb_defused"); + defender botaction("-activate"); + elapsed = gettime() - began; + setdvar("sd_test_defuse_elapsed", elapsed); + if (level.bombdefused && elapsed >= object.usetime - 100) + setdvar("sd_test_result", "passed"); + else + setdvar("sd_test_result", "native_defuse_failed"); +} diff --git a/tests/sd_navigation.gsc b/tests/sd_navigation.gsc new file mode 100644 index 00000000..70446648 --- /dev/null +++ b/tests/sd_navigation.gsc @@ -0,0 +1,44 @@ +// Test-only no-teleport navigation observation. Combat disabled to isolate objectives. +init() +{ + level endon("game_ended"); + wait 1; + setdvar("bots_play_fire", 0); + ticks = 0; + planted = false; + defused = false; + for (;;) + { + wait 0.05; + // Remove combat perception only in this fixture so enemies cannot hold + // each other in an endless firefight while firing is disabled. + players = getentarray("player", "classname"); + for (i = 0; i < players.size; i++) + if (isdefined(players[i].bot)) + { + players[i].bot_model_fix = undefined; + players[i].bot.targets = []; + players[i].bot.target = undefined; + players[i].bot.prio_objective = true; + } + ticks++; + if (ticks % 20 == 0 && isdefined(level.sdbomb) && isdefined(level.sdbomb.carrier)) + { + carrier = level.sdbomb.carrier; + touching = 0; + for (i = 0; i < level.bombzones.size; i++) + if (carrier istouching(level.bombzones[i].trigger)) touching++; + logprint("SD_NAV carrier=" + carrier getentitynumber() + " origin=" + carrier.origin + " touching=" + touching + " goal=" + carrier.bot.script_goal + "\n"); + } + if (isdefined(level.bombplanted) && level.bombplanted && !planted) + { + planted = true; + setdvar("sd_navigation_plants", getdvarint("sd_navigation_plants") + 1); + } + if (isdefined(level.bombdefused) && level.bombdefused && !defused) + { + defused = true; + setdvar("sd_navigation_defuses", getdvarint("sd_navigation_defuses") + 1); + } + } +} diff --git a/tests/test_bot_names.py b/tests/test_bot_names.py new file mode 100644 index 00000000..50e7abcf --- /dev/null +++ b/tests/test_bot_names.py @@ -0,0 +1,39 @@ +"""Compile and exercise the exact bounded native name parser.""" +from pathlib import Path +import subprocess +import tempfile +import unittest + +ROOT = Path(__file__).resolve().parents[1] + + +class BotNames(unittest.TestCase): + def test_native_parser_boundaries_and_userinfo_characters(self): + source = r''' +#include +#include +#include "sv_bot_names.h" +int main(void) { + const char data[] = "\n Capt. Price \r\nSoap MacTavish\nBad\\name\nBad;name\nBad\"name\n^1Red\nBad\tname\n01234567890123456789012345678901\nGaz"; + const char *cursor = data; + char name[BOT_NAME_BYTES]; + assert(BotName_Next(&cursor, data + sizeof(data)-1, name)); + assert(!strcmp(name, "Capt. Price")); + assert(BotName_Next(&cursor, data + sizeof(data)-1, name)); + assert(!strcmp(name, "Soap MacTavish")); + assert(BotName_Next(&cursor, data + sizeof(data)-1, name)); + assert(!strcmp(name, "Gaz")); + assert(!BotName_Next(&cursor, data + sizeof(data)-1, name)); + { const char bounded[] = {'G','a','z','X'}; cursor = bounded; + assert(BotName_Next(&cursor, bounded+3, name)); assert(!strcmp(name,"Gaz")); } + { const char embedded[] = {'x',0,'y','\n','G','a','z'}; cursor=embedded; + assert(BotName_Next(&cursor, embedded+7, name)); assert(!strcmp(name,"Gaz")); } + return 0; +} +''' + with tempfile.TemporaryDirectory() as directory: + path = Path(directory) + (path / 'names.c').write_text(source) + subprocess.run(['cc', '-std=c99', '-Wall', '-Wextra', '-Werror', '-I', str(ROOT / 'src'), + str(path / 'names.c'), '-o', str(path / 'names')], check=True) + subprocess.run([str(path / 'names')], check=True) diff --git a/tests/test_sd_objectives.py b/tests/test_sd_objectives.py new file mode 100644 index 00000000..33eef071 --- /dev/null +++ b/tests/test_sd_objectives.py @@ -0,0 +1,50 @@ +"""Fail-closed native overlay changes; runtime evidence uses run_sd_native.py.""" +import importlib.util +from pathlib import Path +import unittest + +ROOT = Path(__file__).resolve().parents[1] +spec = importlib.util.spec_from_file_location('prepare_sd', ROOT / 'tools/bots/prepare.py') +prepare = importlib.util.module_from_spec(spec) +spec.loader.exec_module(prepare) + + +class SDObjectives(unittest.TestCase): + def test_only_publishes_existing_native_object(self): + source = 'originalOwnership();defuseObject.label=label;originalCallbacksAndTimers();' + result = prepare.publish_defuse_object(source) + self.assertEqual(result.replace('level.defuseObject=defuseObject;', ''), source) + for bad in ('unknown_revision', source + source): + with self.assertRaises(ValueError): prepare.publish_defuse_object(bad) + + def test_unknown_objective_source_cannot_prepare(self): + with self.assertRaises(ValueError): prepare.sd_objective_source('unknown_revision') + + def test_derivation_removes_hidden_information_and_retries_another_site(self): + # Minimal original interfaces, no licensed gameplay source in this fixture. + helpers = ['BotRandomStance', 'bot_inc_bots', 'bot_get_obj', 'bot_go_plant', + 'bot_go_defuse', 'bot_array_nearest_curorigin', 'bot_sd_defenders', + 'bot_sd_attackers'] + script = '\n'.join(name + '(){}' for name in helpers) + script += '\nbot_escort_obj(){if(carrier == obj.carrier)return;}\n' + script += ('bot_sd_defenders_loop(data){\n' + '\t\ttimeleft = stockTimer();\n\t\t// check for a bomb carrier\n' + '\t\thiddenDroppedBombPosition();\n\t\t// pick a site to protect\n' + '\t\tif ( site isInUse() ) { hiddenEnemyPlant(); }\n' + '\t\t// else hang around the site\npublicSites();}\n') + script += ('bot_sd_attackers_loop(data){\n' + '\t\tif ( site isInUse() ) { hiddenEnemyDefuse(); }\n' + '\t\t// else hang around the site\npublicPlantedBomb();\n' + '\t// check if to plant\nstockRandomDelay();\n' + '\tif ( !isdefined( level.bombzones ) )return;\n' + 'sites[ sites.size ] = level.bombzones[ i ];\n' + 'if ( !sites.size )\n\t{\n\t\treturn;\n\t}\n' + 'event = self waittill_any_return( "goal", "bad_path", "new_goal" );\n' + 'self isBombCarrier();\nself bot_wait_stop_move();\n' + 'self thread BotPressUse( waitTime );\n\twait waitTime;\n}\n') + result = prepare.sd_objective_source(script) + for hidden in ('hiddenDroppedBombPosition', 'hiddenEnemyPlant', 'hiddenEnemyDefuse', 'stockRandomDelay'): + self.assertNotIn(hidden, result) + for required in ('publicSites()', 'publicPlantedBomb()', 'data.failed_site = plant', + 'self carries_bomb()', 'self hold_objective_use( waitTime )'): + self.assertIn(required, result) diff --git a/tools/bots/prepare.py b/tools/bots/prepare.py index ad324707..7c97f021 100644 --- a/tools/bots/prepare.py +++ b/tools/bots/prepare.py @@ -40,6 +40,79 @@ def difficulty_source(internal, script): 'reset_profile() {\n' + defaults + '\n}\n') +def sd_objective_source(script): + """Reuse pinned Bot Warfare S&D only, without stock callback replacement. + + Public site positions and planted-bomb state are shared objectives. Enemy + carrier positions and remote planting/defusing activity are not AI inputs. + """ + names = ['BotRandomStance', 'bot_inc_bots', 'bot_escort_obj', 'bot_get_obj', 'bot_go_plant', + 'bot_go_defuse', 'bot_array_nearest_curorigin', + 'bot_sd_defenders_loop', 'bot_sd_defenders', + 'bot_sd_attackers_loop', 'bot_sd_attackers'] + blocks = {name: source_block(script, '^' + name + r'\([^)]*\)') for name in names} + defender = blocks['bot_sd_defenders_loop'] + start = defender.index('\t\ttimeleft =') + stop = defender.index('\t\t// pick a site to protect', start) + defender = defender[:start] + defender[stop:] + # Never react to enemy use activity without perception. Ordinary perception + # remains in the combat core; these branches bypass it in the stock AI. + start = defender.index('\t\tif ( site isInUse() )') + stop = defender.index('\t\t// else hang around the site', start) + blocks['bot_sd_defenders_loop'] = defender[:start] + defender[stop:] + attacker = blocks['bot_sd_attackers_loop'] + start = attacker.index('\t\tif ( site isInUse() )') + stop = attacker.index('\t\t// else hang around the site', start) + attacker = attacker[:start] + attacker[stop:] + # Do not randomly delay a carrier for most of a short competitive round. + start = attacker.index('\t// check if to plant') + stop = attacker.index('\tif ( !isdefined( level.bombzones )', start) + attacker = attacker[:start] + attacker[stop:] + attacker = replace_once(attacker, + 'sites[ sites.size ] = level.bombzones[ i ];', + 'if (!isdefined(data.failed_site) || data.failed_site != level.bombzones[i])\n' + '\t\t\tsites[sites.size] = level.bombzones[i];') + attacker = replace_once(attacker, 'if ( !sites.size )\n\t{\n\t\treturn;', + 'if ( !sites.size )\n\t{\n\t\tdata.failed_site = undefined;\n\t\treturn;') + attacker = replace_once(attacker, + 'event = self waittill_any_return( "goal", "bad_path", "new_goal" );', + 'event = self waittill_any_return( "goal", "bad_path", "new_goal" );\n' + '\tif (event == "bad_path") data.failed_site = plant;') + blocks['bot_sd_attackers_loop'] = attacker + blocks['bot_escort_obj'] = replace_once(blocks['bot_escort_obj'], + 'carrier == obj.carrier', 'carrier != obj.carrier') + result = '\n\n'.join(blocks.values()) + # Uses native ownership, which Promod already enforces for human players. + result = result.replace('self isBombCarrier()', 'self carries_bomb()') + result = re.sub(r'^.*maps\\mp\\gametypes\\_globallogic::gettime(?:remaining|passed)\(\).*\n', '', result, flags=re.M) + # Guard helper threads that already have disconnect lifetime handling. + # bot_inc_bots cleans up via its original event wait. + result = result.replace('self endon( "disconnect" );', + 'self endon( "disconnect" );\n\tself endon( "promod_ai_reset" );\n\tlevel endon( "game_ended" );') + # Uniform bounded goal watcher handles configuration changes and plant-state + # changes while waiting, including helpers that upstream left unbounded. + result = result.replace('self SetScriptGoal( origin,', 'self objective_goal( origin,') + result = result.replace('self SetScriptGoal( self.origin, 64 );', + 'self objective_goal( self.origin, 64 );') + result = result.replace('self bot_wait_stop_move();', 'self wait_stop_move();') + result = result.replace('self thread BotPressUse( waitTime );\n\twait waitTime;', + 'self hold_objective_use( waitTime );') + return ('// Derived 2026-10-27 from pinned Bot Warfare S&D routines.\n' + '// INeedGames/INeedBots, PeZBOT and contributors; see docs/third-party-bots.md.\n' + '#include common_scripts\\utility;\n#include maps\\mp\\_utility;\n' + '#include maps\\mp\\gametypes\\_hud_util;\n' + '#include maps\\mp\\bots\\_bot_utility;\n' + result + '\n' + + (ROOT / 'bots/sd_objectives.gsc').read_text()) + + +def publish_defuse_object(source): + # Only publishes the native objective. The original creation, ownership, + # callbacks, native hold durations and round outcome logic stay unchanged. + return replace_once(source, + 'defuseObject.label=label;', + 'defuseObject.label=label;level.defuseObject=defuseObject;') + + def digest(path): with path.open('rb') as stream: return hashlib.file_digest(stream, 'sha256').hexdigest() @@ -192,6 +265,8 @@ def main(): internal = (vendor / 'maps/mp/bots/_bot_internal.gsc').read_text() difficulty = difficulty_source(internal, (vendor / 'maps/mp/bots/_bot_script.gsc').read_text()) (target / 'difficulty.gsc').write_text(difficulty) + (target / 'sd_objectives.gsc').write_text(sd_objective_source( + (vendor / 'maps/mp/bots/_bot_script.gsc').read_text())) internal = internal.replace('maps\\mp\\gametypes\\_missions::getweaponclass', 'maps\\mp\\bots\\_bot_utility::getweaponclass') internal = internal.replace('self endon( "disconnect" );', 'self endon( "disconnect" );\n\tself endon( "promod_ai_reset" );\n\tlevel endon( "game_ended" );') @@ -230,7 +305,8 @@ def main(): vote_policy.unlink() for name, transform in [('maps/mp/gametypes/_promod', human_class_limits), ('maps/mp/gametypes/_globallogic', match_end_rotation), - ('promod/readyup', bot_readyup)]: + ('promod/readyup', bot_readyup), + ('maps/mp/gametypes/sd', publish_defuse_object)]: output = mod / (name + '.gsx') output.parent.mkdir(parents=True, exist_ok=True) output.write_text('// Private derived gameplay correction; original rules retained.\n' + @@ -256,6 +332,9 @@ def main(): 'human_class_limits_overlay': True, 'match_end_rotation_overlay': True, 'bot_readyup_overlay': True, + 'sd_objectives_overlay': True, + 'sd_objectives_sha256': digest(target / 'sd_objectives.gsc'), + 'sd_native_overlay_sha256': digest(mod / 'maps/mp/gametypes/sd.gsx'), 'ai_source_sha256': digest(ROOT / 'bots/promod_ai.gsc'), 'dependency_lock_sha256': digest(ROOT / 'bots/dependencies.json'), 'promod': lock['promod']['files'], 'headers': lock['integrity_headers']} From a4e6c5f29ba81bfd7ce3de51f86048bb818cbccf Mon Sep 17 00:00:00 2001 From: ghptc Date: Tue, 27 Oct 2026 20:19:57 -0300 Subject: [PATCH 2/6] fix(promod): release objective input on reset and idle disabled controllers --- bots/sd_objectives.gsc | 12 ++++++++++++ docs/promod-military-sd.md | 14 ++++++++------ tools/bots/prepare.py | 3 +++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/bots/sd_objectives.gsc b/bots/sd_objectives.gsc index 6afdb98b..a5ba1f6e 100644 --- a/bots/sd_objectives.gsc +++ b/bots/sd_objectives.gsc @@ -13,6 +13,7 @@ start() if (getdvarint("bot_debug")) logprint("PMBOT SD_START slot=" + self getentitynumber() + "\n"); self.bot_lock_goal = false; self thread cleanup_on_death(); + self thread cleanup_on_reset(); self thread bot_sd_attackers(); self thread bot_sd_defenders(); } @@ -27,6 +28,17 @@ cleanup_on_death() self BotBuiltinBotAction("-activate"); } +cleanup_on_reset() +{ + self endon("disconnect"); + self endon("death"); + level endon("game_ended"); + self waittill("promod_ai_reset"); + self notify("bot_use"); + self notify("new_goal"); + self BotBuiltinBotAction("-activate"); +} + carries_bomb() { return isdefined(level.sdbomb) && isdefined(self.carryobject) && diff --git a/docs/promod-military-sd.md b/docs/promod-military-sd.md index 1b673919..72253d5e 100644 --- a/docs/promod-military-sd.md +++ b/docs/promod-military-sd.md @@ -56,19 +56,21 @@ must pass on final PR heads; existing workflows are retained without changes. `tests/run_sd_native.py` creates a new loopback process and verifies pinned Promod/header identities. Its native fixture uses **test-only positioning** to exercise legitimate pickup, interrupted plant/defuse and real native completion. -Accepted Crash evidence: `/tmp/cod4x-sd-native-vffuwzhm/results.json` shows plant -5150ms, defuse 7100ms, both interruptions, pure=1 and all 12 requested active -names. It does not prove autonomous navigation or real-client gameplay. +Accepted Crash evidence: `/tmp/cod4x-sd-native-qakidgli/results.json` shows plant +5150ms, defuse 7100ms, both interruptions, carrier death/drop/recovery, death during defuse, native +round reset, pure=1 and all 12 requested names retained across the round. Strike +(`/tmp/cod4x-sd-native-tuz9t_ot`), Winter Crash (`4hrkqryt`) and Backlot +(`v4up0t8v`, with the same `/tmp/cod4x-sd-native-` prefix) also passed. It does not prove autonomous navigation or real-client gameplay. Rejected runs are retained privately and are not qualification evidence. The separate `--scenario navigation` fixture observes actual AI navigation/use, with combat suppressed solely in the test fixture; no positioning is used. Neither synthetic fixture certifies combat decisions, HUD, human bomb priority, interruption under fire, every supported map or a full competitive match. -Death/drop, names across rounds/admission collisions, bot administration, +Admission collisions/overflow, bot administration, Promod/Zombies gameplay regressions and the supported-map matrix must be recorded -before qualification approval. Independent Principal architecture/security review -is provisional until these gates and final CI are complete. Do not promote this +before qualification approval. Independent Principal source architecture/security review approved draft review +on 2026-10-27; gameplay/qualification approval and final CI remain pending. Do not promote this candidate based only on connected/active bots or prepared waypoint coverage. ## Rollback and freeze diff --git a/tools/bots/prepare.py b/tools/bots/prepare.py index 7c97f021..3f84ac34 100644 --- a/tools/bots/prepare.py +++ b/tools/bots/prepare.py @@ -79,6 +79,9 @@ def sd_objective_source(script): 'event = self waittill_any_return( "goal", "bad_path", "new_goal" );\n' '\tif (event == "bad_path") data.failed_site = plant;') blocks['bot_sd_attackers_loop'] = attacker + for name in ('bot_sd_attackers_loop', 'bot_sd_defenders_loop'): + blocks[name] = blocks[name].replace('{', + '{\n\tif (!getdvarint("bot_sd_objectives")) { wait 1; return; }', 1) blocks['bot_escort_obj'] = replace_once(blocks['bot_escort_obj'], 'carrier == obj.carrier', 'carrier != obj.carrier') result = '\n\n'.join(blocks.values()) From 8c6084f8d36fd41f174499d782012eb50a184f01 Mon Sep 17 00:00:00 2001 From: ghptc Date: Tue, 27 Oct 2026 20:29:07 -0300 Subject: [PATCH 3/6] test(promod): qualify native objectives, names and supported map interactions --- docs/promod-military-sd.md | 52 ++++++++++++++++++++++++++++++-------- tests/run_sd_native.py | 30 ++++++++++++++++++++-- tests/sd_native.gsc | 27 +++++++++++++++++--- tests/sd_navigation.gsc | 15 ++++++----- 4 files changed, 102 insertions(+), 22 deletions(-) diff --git a/docs/promod-military-sd.md b/docs/promod-military-sd.md index 72253d5e..e326f48d 100644 --- a/docs/promod-military-sd.md +++ b/docs/promod-military-sd.md @@ -44,7 +44,11 @@ Pinned inputs are unchanged: Bot Warfare v2.2.0 at `7b52b462e40fa68287b9e54602e52da83b17766c`, Promod LIVE V2.20 EU and all eight header hashes in `bots/dependencies.json`. Licensed extracted/generated scripts stay private. Source terms and credits: [third-party-bots.md](third-party-bots.md). -The preserved PoC remains read-only. +The preserved PoC remains read-only. Final native build 1291 SHA-256: +`e5278dd552ad3fd486fbc3d295ed680804a272327185f4848ab2915893c20584`. +Final reviewed preparation manifest SHA-256: +`bf0ff97b01490d20316f1bc2c563f0bd837fff69b389dbe3b1b5ee3946ca2d63`. +Its private `inputs.json` binds both S&D overlay identities and pinned assets. ## Evidence and remaining gates @@ -63,15 +67,43 @@ round reset, pure=1 and all 12 requested names retained across the round. Strike (`v4up0t8v`, with the same `/tmp/cod4x-sd-native-` prefix) also passed. It does not prove autonomous navigation or real-client gameplay. Rejected runs are retained privately and are not qualification evidence. -The separate `--scenario navigation` fixture observes actual AI navigation/use, -with combat suppressed solely in the test fixture; no positioning is used. -Neither synthetic fixture certifies combat decisions, HUD, human bomb priority, -interruption under fire, every supported map or a full competitive match. -Admission collisions/overflow, bot administration, -Promod/Zombies gameplay regressions and the supported-map matrix must be recorded -before qualification approval. Independent Principal source architecture/security review approved draft review -on 2026-10-27; gameplay/qualification approval and final CI remain pending. Do not promote this -candidate based only on connected/active bots or prepared waypoint coverage. +The final-source no-positioning navigation fixture passed on Crash at +`/tmp/cod4x-sd-native-8b_azzwk/results.json`: Soap picked up and navigated to a +site, held use at 0:56, native `P_P` occurred at 1:01; Thompson held use at 1:05, +native `P_D` at 1:12. Combat fire and enemy perception are suppressed only in +this disposable fixture. This demonstrates autonomous navigation and native +objective interactions, not behavior under combat or real-client certification. +Earlier polling observers missed a real defuse before round end; those runs +remain rejected, and the runner now observes the native `bomb_defused` event. + +Native interaction/lifecycle fixtures passed on all 21 configured S&D maps +(first site on each, using fixture positioning). The private matrix is +`/tmp/cod4-final-map-matrix.json`; it contains 16 passes plus an initial Bog +fixture grounding rejection. Bog's traced grounded placement then passed in +`/tmp/cod4x-sd-native-4avuq1fj`; Crash/Strike/Winter Crash/Backlot are the four +separate passes listed above. This is not a 21-map autonomous route/combat test. + +`/tmp/cod4x-sd-native-vm05fp72/results.json` passed duplicate/unsafe name-pool +rejection, exhausted-pool numbered fallback, case-insensitive collision handling, +round preservation, and a synthetic human retaining Capt. Price while native +`bot_kick 3`/`bot_add 3` removed/recreated the other bots. Twelve unique names +remained, with one human and eleven bots. Human priority/Ready Up/authentication +remain covered by existing regressions; synthetic peers do not replace clients. + +Local totals: 83 engine Python tests (one existing optional skip), two catalog +tests, 52 workspace tests, native population policy/rotation/voting and the +workspace operations mocks pass. Existing hosted Configuration/Operations and +engine Linux/Windows CI passed on the initial draft heads; required checks must +also pass on the final heads. No workflow or protection was changed. + +Independent Principal source architecture/security review approved draft review +on 2026-10-27. Source review is bound to engine `a4e6c5f` and coordinated catalog +`ca71c9d` / workspace `815cd89`; subsequent changes concern fixture observation +and evidence documentation. Full qualification approval remains pending. +Supervised real-client combat, both sites/routes across supported maps, human +bomb ownership/HUD, full matches, and exact-artifact homologation/rollback must +be qualified before promotion. Existing Zombies native regression is also run +with the new binary; see the final PR validation record for its result. ## Rollback and freeze diff --git a/tests/run_sd_native.py b/tests/run_sd_native.py index b4dcd606..ef122b25 100644 --- a/tests/run_sd_native.py +++ b/tests/run_sd_native.py @@ -20,6 +20,7 @@ p.add_argument('--game', required=True, type=Path) p.add_argument('--names', required=True, type=Path) p.add_argument('--scenario', choices=('native', 'navigation'), default='native') +p.add_argument('--allocation-fixture', action='store_true') p.add_argument('--map', default='mp_crash') a = p.parse_args() assert a.map in json.loads((a.runtime / 'inputs.json').read_text())['maps'] @@ -32,6 +33,13 @@ shutil.copy2(ROOT / 'bin/cod4x18_dedrun', home / 'cod4x18_dedrun') (home / 'scriptdata').mkdir() shutil.copy2(a.names, home / 'scriptdata/botnames.txt') +if a.allocation_fixture: + (home / 'scriptdata/botnames.txt').write_text( + 'Capt. Price\ncapt. price\nCapt. Price\nSoap MacTavish\nGaz\n' + 'Bad;quit\nBad\\name\n^1Color\n' + 'x' * 32 + '\n') + (home / 'plugins').mkdir() + subprocess.run(['cc', '-m32', '-shared', '-fPIC', str(ROOT / 'tests/promod_runtime_plugin.c'), + '-o', str(home / 'plugins/runtime_test.so')], check=True) mod = home / 'mods/pml220' lock = json.loads((ROOT / 'bots/dependencies.json').read_text()) for directory, expected in [(mod, lock['promod']['files']), @@ -61,7 +69,11 @@ '+set', 'fs_game', 'mods/pml220', '+set', 'sv_pure', '1', '+set', 'sv_maxclients', '12', '+set', 'fs_localizedHeadersPath', str(home / 'integrity'), '+exec', 'qualification.cfg', '+map_rotate'] proc = subprocess.Popen(cmd, cwd=home, stdin=subprocess.PIPE, stdout=output, stderr=subprocess.STDOUT) -result = {'map': a.map, 'scenario': a.scenario, 'fixture_positioning': a.scenario == 'native', 'real_client_qualified': False} +result = {'engine_revision': subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=ROOT, text=True).strip(), + 'binary_sha256': hashlib.sha256((home / 'cod4x18_dedrun').read_bytes()).hexdigest(), + 'dependency_lock_sha256': hashlib.sha256((ROOT / 'bots/dependencies.json').read_bytes()).hexdigest(), + 'prepared_inputs': json.loads((a.runtime / 'inputs.json').read_text()), + 'map': a.map, 'scenario': a.scenario, 'fixture_positioning': a.scenario == 'native', 'real_client_qualified': False} def rcon(command): with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as channel: channel.settimeout(2) @@ -93,7 +105,9 @@ def rcon(command): result['pure'] = '"1"' in rcon('sv_pure') assert result['pure'], 'purity lost' result['status'] = rcon('status') - names = a.names.read_text().splitlines() + names = (['Capt. Price', 'Soap MacTavish', 'Gaz'] + + [f'[BOT] Promod {n:02d}' for n in range(1, 10)] + if a.allocation_fixture else a.names.read_text().splitlines()) active_names = [name for name in names if name in result['status']] assert len(active_names) == 12, 'requested active names missing' result['requested_names'] = active_names @@ -107,6 +121,18 @@ def rcon(command): after = rcon('status') assert all(name in after for name in active_names), 'names changed across round' result['round_reset_and_names_preserved'] = True + if a.allocation_fixture: + assert all(after.lower().count(name.lower()) == 1 for name in names) + rcon('loadplugin runtime_test'); time.sleep(.3) + rcon('runtime_fixture 0 human') + rcon('bot_kick 3'); time.sleep(.3) + rcon('bot_add 3'); time.sleep(1) + after = rcon('status') + assert all(after.lower().count(name.lower()) == 1 for name in names), after + status = rcon('bot_status') + assert 'humans=1' in status and 'bots=11' in status, status + result['duplicate_overflow_human_collision_and_admin'] = True + rcon('runtime_fixture 0 bot') result['passed'] = True finally: if proc.poll() is None: diff --git a/tests/sd_native.gsc b/tests/sd_native.gsc index f9a64e66..2dd215c7 100644 --- a/tests/sd_native.gsc +++ b/tests/sd_native.gsc @@ -34,7 +34,7 @@ init() } setdvar("sd_test_pickup", 1); plant = level.bombzones[0]; - attacker setorigin(plant.curorigin + (50,50,5)); + attacker fixture_place(plant); wait 0.5; attacker botaction("+activate"); wait 1; @@ -66,7 +66,7 @@ init() setdvar("sd_test_result", "pickup_failed"); return; } - attacker setorigin(plant.curorigin + (50,50,5)); + attacker fixture_place(plant); wait 0.5; began = gettime(); attacker botaction("+activate"); @@ -82,7 +82,7 @@ init() setdvar("sd_test_planted", 1); wait 0.2; defuse = level.defuseobject; - defender setorigin(defuse.curorigin + (0,0,5)); + defender fixture_place(defuse); wait 0.5; defender botaction("+activate"); wait 1; @@ -108,7 +108,7 @@ init() for (i = 0; i < players.size; i++) if (players[i].pers["team"] == game["defenders"] && isalive(players[i])) { defender = players[i]; break; } - defender setorigin(defuse.curorigin + (0,0,5)); + defender fixture_place(defuse); wait 0.5; began = gettime(); level thread record_defuse(defender, defuse, began); @@ -135,3 +135,22 @@ record_defuse(defender, object, began) else setdvar("sd_test_result", "native_defuse_failed"); } + +// Find grounded trigger contact for fixture setup without altering native state. +fixture_place(object) +{ + offsets = []; + offsets[0] = (50,50,0); + offsets[1] = (0,0,0); + offsets[2] = (-50,-50,0); + offsets[3] = (-50,50,0); + offsets[4] = (50,-50,0); + for (i = 0; i < offsets.size; i++) + { + origin = object.curorigin + offsets[i]; + trace = bullettrace(origin + (0,0,128), origin - (0,0,512), false, self); + self setorigin(trace["position"] + (0,0,4)); + wait 0.5; + if (self isonground() && self istouching(object.trigger)) return; + } +} diff --git a/tests/sd_navigation.gsc b/tests/sd_navigation.gsc index 70446648..cfff4bf2 100644 --- a/tests/sd_navigation.gsc +++ b/tests/sd_navigation.gsc @@ -6,7 +6,7 @@ init() setdvar("bots_play_fire", 0); ticks = 0; planted = false; - defused = false; + level thread record_defused(); for (;;) { wait 0.05; @@ -35,10 +35,13 @@ init() planted = true; setdvar("sd_navigation_plants", getdvarint("sd_navigation_plants") + 1); } - if (isdefined(level.bombdefused) && level.bombdefused && !defused) - { - defused = true; - setdvar("sd_navigation_defuses", getdvarint("sd_navigation_defuses") + 1); - } + } } + +record_defused() +{ + level endon("game_ended"); + level waittill("bomb_defused"); + setdvar("sd_navigation_defuses", getdvarint("sd_navigation_defuses") + 1); +} From 2cfc55881d678c92d6e3392f5568758de00c842c Mon Sep 17 00:00:00 2001 From: ghptc Date: Tue, 27 Oct 2026 20:52:26 -0300 Subject: [PATCH 4/6] fix(promod): rotate unused military names across bot admissions --- docs/promod-military-sd.md | 4 ++-- src/sv_bot_manager.c | 28 +++++++++++++++++++++++++--- tests/run_sd_native.py | 7 +++++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/docs/promod-military-sd.md b/docs/promod-military-sd.md index e326f48d..62e3802f 100644 --- a/docs/promod-military-sd.md +++ b/docs/promod-military-sd.md @@ -12,7 +12,7 @@ Engine population management consumes Bot Warfare's existing root the 15-name military pool; the workspace copies it and includes its content in the configuration fingerprint. Assignment happens only in `BotAddOne`, before `SV_AddBotClient`. Existing bots and humans are never renamed. Round restarts -retain native client userinfo. Subsequent admissions take the first unused name, +retain native client userinfo. Subsequent admissions rotate through the unused names using a process cursor (reset on process restart), including collision checks against humans after native name cleaning, ignoring case. Missing, invalid, oversized or exhausted pools use unique numbered Promod fallbacks. Name input is bounded to 8192 bytes and 31 ASCII display bytes per @@ -91,7 +91,7 @@ remained, with one human and eleven bots. Human priority/Ready Up/authentication remain covered by existing regressions; synthetic peers do not replace clients. Local totals: 83 engine Python tests (one existing optional skip), two catalog -tests, 52 workspace tests, native population policy/rotation/voting and the +tests, 53 workspace tests, native population policy/rotation/voting and the workspace operations mocks pass. Existing hosted Configuration/Operations and engine Linux/Windows CI passed on the initial draft heads; required checks must also pass on the final heads. No workflow or protection was changed. diff --git a/src/sv_bot_manager.c b/src/sv_bot_manager.c index d6250e4e..648841e8 100644 --- a/src/sv_bot_manager.c +++ b/src/sv_bot_manager.c @@ -14,6 +14,7 @@ static cvar_t *bot_enable, *bot_ai_ready, *bot_fill_limit, *bot_skill; static cvar_t *btd_allies_enable, *btd_allies_limit, *bot_use_names; static bot_fill_state_t fill_state = BOT_FILL_ACTIVE; static int next_fill; +static unsigned int next_name_index; static int BotCount(void) { @@ -71,7 +72,9 @@ static qboolean BotNameUsed(const char *name) static qboolean BotPoolName(char name[BOT_NAME_BYTES]) { fileHandle_t file; - char data[BOT_NAMES_BYTES], candidate[BOT_NAME_BYTES]; + char data[BOT_NAMES_BYTES], candidate[BOT_NAME_BYTES], fallback[BOT_NAME_BYTES]; + unsigned int count = 0, index = 0, start, fallback_index = 0; + qboolean have_fallback = qfalse; const char *cursor = data; int length = FS_SV_FOpenFileRead("scriptdata/botnames.txt", &file); if (!file) return qfalse; @@ -84,11 +87,30 @@ static qboolean BotPoolName(char name[BOT_NAME_BYTES]) return qfalse; } FS_FCloseFile(file); + while (BotName_Next(&cursor, data + length, candidate)) ++count; + if (!count) return qfalse; + start = next_name_index % count; + cursor = data; while (BotName_Next(&cursor, data + length, candidate)) { ClientCleanName(candidate, name, BOT_NAME_BYTES, qfalse); - if (!BotNameUsed(name)) return qtrue; + if (!BotNameUsed(name)) { + if (index >= start) { + next_name_index = index + 1; + return qtrue; + } + if (!have_fallback) { + Q_strncpyz(fallback, name, sizeof(fallback)); + fallback_index = index; + have_fallback = qtrue; + } + } + ++index; } - return qfalse; + if (have_fallback) { + Q_strncpyz(name, fallback, BOT_NAME_BYTES); + next_name_index = fallback_index + 1; + } + return have_fallback; } static qboolean BotAddOne(void) diff --git a/tests/run_sd_native.py b/tests/run_sd_native.py index ef122b25..ab85156d 100644 --- a/tests/run_sd_native.py +++ b/tests/run_sd_native.py @@ -133,6 +133,13 @@ def rcon(command): assert 'humans=1' in status and 'bots=11' in status, status result['duplicate_overflow_human_collision_and_admin'] = True rcon('runtime_fixture 0 bot') + else: + rcon('bot_kick 3'); time.sleep(.3) + rcon('bot_add 3'); time.sleep(1) + after = rcon('status') + assert all(after.lower().count(name.lower()) == 1 for name in names[3:15]), after + assert all(name not in after for name in names[:3]), after + result['all_fifteen_names_rotate_across_admissions'] = True result['passed'] = True finally: if proc.poll() is None: From 02430bd706b88e147b6c7370143574cd69a652e0 Mon Sep 17 00:00:00 2001 From: ghptc Date: Tue, 27 Oct 2026 20:56:44 -0300 Subject: [PATCH 5/6] docs(promod): record qualification evidence, limits and feature freeze --- docs/promod-military-sd.md | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/docs/promod-military-sd.md b/docs/promod-military-sd.md index 62e3802f..aec868c7 100644 --- a/docs/promod-military-sd.md +++ b/docs/promod-military-sd.md @@ -44,7 +44,7 @@ Pinned inputs are unchanged: Bot Warfare v2.2.0 at `7b52b462e40fa68287b9e54602e52da83b17766c`, Promod LIVE V2.20 EU and all eight header hashes in `bots/dependencies.json`. Licensed extracted/generated scripts stay private. Source terms and credits: [third-party-bots.md](third-party-bots.md). -The preserved PoC remains read-only. Final native build 1291 SHA-256: +The preserved PoC remains read-only. Objective qualification build 1291 SHA-256: `e5278dd552ad3fd486fbc3d295ed680804a272327185f4848ab2915893c20584`. Final reviewed preparation manifest SHA-256: `bf0ff97b01490d20316f1bc2c563f0bd837fff69b389dbe3b1b5ee3946ca2d63`. @@ -97,13 +97,27 @@ engine Linux/Windows CI passed on the initial draft heads; required checks must also pass on the final heads. No workflow or protection was changed. Independent Principal source architecture/security review approved draft review -on 2026-10-27. Source review is bound to engine `a4e6c5f` and coordinated catalog -`ca71c9d` / workspace `815cd89`; subsequent changes concern fixture observation -and evidence documentation. Full qualification approval remains pending. +on 2026-10-27. Objective source review is bound to engine `a4e6c5f`; independent review also +approved the final name-cursor delta committed as `2cfc558`. Coordinated catalog +`ca71c9d` and workspace `6d92b98` retain independent source approval. Final naming +qualification build 1293 SHA-256 is +`84294d91a62c3dbfeab7ec3eb86cd1a2b39d8be529877fb0a68c9bcea5dae64c`. +`/tmp/cod4x-sd-native-csvkxixf` passes full native lifecycle, names across rounds +and rotation through all fifteen names across replacement admissions; +`/tmp/cod4x-sd-native-kc8psw70` repeats duplicate/unsafe/overflow/human-collision +and administration qualification with that same binary. Full qualification approval remains pending. Supervised real-client combat, both sites/routes across supported maps, human bomb ownership/HUD, full matches, and exact-artifact homologation/rollback must -be qualified before promotion. Existing Zombies native regression is also run -with the new binary; see the final PR validation record for its result. +be qualified before promotion. Zombies regression must not be silently certified: two build-1291 runs +(`/tmp/btd-five-allies-vja6233l` and `n_tk7kgw` with the same prefix) passed 51/52, +failing only `five_allies_native_engagement`. The unchanged fixture using the +previously qualified binary `2aac8c013b234a4dee8272bcb8e3fc09f5df3e35a7f8f936ccf0bb464e607b70` +passed 52/52 at `/tmp/btd-five-allies-8q8wczc9`. Purity, headers, native hits, +lifecycle, human priority, administration and script-error checks passed in the +51/52 runs. A prior wrong-baseline run without the existing Killhouse repair was +rejected separately. Thresholds and Zombies source are unchanged; preserve all +candidate/control evidence and keep the gameplay gate open. The final build-1293 +run is recorded in the final PR validation update. ## Rollback and freeze @@ -116,3 +130,6 @@ deployments, bridge activation or production promotion are performed here. After approved merges, prepare one pinned homologation candidate, obtain owner deployment approval, supervise real-client gameplay and exact-artifact rollback, then request qualification approval before proposing production promotion. + +Development is frozen across the three repositories outside focused qualification +and remediation of this final candidate. No additional features are authorized. From 09db2f4e74a9064c8a70e08a2c41ebda39f8f64f Mon Sep 17 00:00:00 2001 From: ghptc Date: Tue, 27 Oct 2026 21:04:47 -0300 Subject: [PATCH 6/6] docs(promod): finalize regression evidence and precommit artifact provenance --- docs/promod-military-sd.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/promod-military-sd.md b/docs/promod-military-sd.md index aec868c7..699d1f04 100644 --- a/docs/promod-military-sd.md +++ b/docs/promod-military-sd.md @@ -117,7 +117,17 @@ lifecycle, human priority, administration and script-error checks passed in the 51/52 runs. A prior wrong-baseline run without the existing Killhouse repair was rejected separately. Thresholds and Zombies source are unchanged; preserve all candidate/control evidence and keep the gameplay gate open. The final build-1293 -run is recorded in the final PR validation update. +run passed all 52 checks at `/tmp/btd-five-allies-e8pcoy76/results.json`. +The independent Principal reviewer accepted that local regression pass while +retaining the earlier engagement failures as a supervised-gameplay concern. +Operator gameplay and balance flags remain false. + +Build 1293 was compiled with the reviewed naming-cursor working-tree delta before +its `2cfc558` commit. Its embedded/base evidence revision is `8c6084f`; it must +not be described as a clean build of that revision. The exact binary SHA above, +reviewed cursor delta and preserved fixture outputs bind this precommit local +run. A fresh exact-revision artifact and supervised qualification are required +after approved merges. ## Rollback and freeze