Boot-time env report + fix the env reference

The bot is spawned by the server/GUI, so it inherits the SERVER's
environment. The user could not tell whether their exports reached the
bot, so print a one-shot greppable report at boot:

  grep '^\[env\]' /tmp/modularbot_stdout.log

Section A prints every TR_*/GUN_* this process actually received, the
count vs the total env size, a loud warning when nothing matched, and
the process identity (pid/ppid, cwd, self command line, and the PARENT
command line) so the spawn trap is obvious. Section B prints the
resolved effective value of every documented knob with its source
(env|default), including clamps and the rack's empty-set fallback.
Build identity (NimVersion, compile date/time, binary path/size/mtime)
pins the exact artifact. Suppress with TR_ENV_REPORT=0.

docs/env_reference.md: add the missing GUN_SHOTLOG_PATH,
GUN_SELECTOR_MINOBS/FLOOR/POOL/RANK/SHRINK/SEED, TR_ENV_REPORT and
-d:TM_NCLAUSES; record the measured TR_TMHORIZON_WINDOW verdict; and
add a prominent 'Did my env vars actually reach the bot?' section with
the boot report, the /proc/PID/environ no-code check, the correct GUI
launch recipe, and how to prove the trap deliberately.
This commit is contained in:
2026-09-23 08:21:25 +02:00
parent 7f6ccfb015
commit 9bf3005850
3 changed files with 453 additions and 1 deletions
+20
View File
@@ -36,6 +36,7 @@ import movement_harness/virtual_bodies as mvb
import movement_harness/bullet_shadows
import targeting/enemy_tracker
import targeting/target_selector
import env_report
const botJsonPath = currentSourcePath().parentDir / "ModularBot.json"
const DebugVBullets = false
@@ -1261,4 +1262,23 @@ when isMainModule:
# Must run AFTER the gun constructors (Tsetlin/TMSelector call randomize()
# unconditionally) so the explicit seed override is the value that survives.
seedSelectorRng()
# Boot-time environment report (once per process, stdout). Prints what env
# this process actually inherited, the resolved effective value of every
# documented knob, and the build identity behind `grep '^\[env\]'`.
printEnvReport(EnvReportContext(
movementName: MovementName,
vBulletAdmitOnly: VBulletAdmitOnly,
recordWorldState: RecordWorldState,
radarForceSpin: RadarForceSpin,
radarScanLog: RadarScanLog,
radarScanLogPath: RadarScanLogPath,
trackerProbe: TrackerProbe,
trackerProbePath: TrackerProbePath,
powerLog: PowerLog,
gunStatsPath: GunStatsPath,
shotLogPath: ShotLogPath,
disabledGuns: DisabledGuns,
tmHorizon: bot.tmHorizon,
patternMatcher: bot.patternMatcher,
))
start(bot, botJsonPath)