Files
XC_VM/tools
Claude 488c923972 fix(build): strip stale LB manifest paths and gate stale/routed entries
The LB strip lists still named files by their pre-PSR-4 www/ paths, so
those entries matched nothing and the files kept shipping under Public/:
Public/admin/api.php, Public/admin/proxy_api.php, Public/stream/auth.php
and Public/stream/probe.php reached every LB. auth.php and probe.php are
routed by the LB nginx but fatal there on the stripped Domain/User.
LB_DIRS still listed the removed resources/ and www/ trees, and
LB_DIRS_TO_REMOVE listed the non-existent Domain/Auth. The gate never
noticed, because it only checked the SENSITIVE prefixes.

Makefile:
- Drop the dead entries (resources, www, Domain/Auth, GeoLite2-City.mmdb,
  the nine www/* files).
- Strip the MAIN-only files that no LB route or LB code needs: the four
  endpoints above, PlayerV2, AdminAPIWrapper, ResellerAPIWrapper,
  ActiveCodeApiController, ResellerApiDispatcher, ResellerTableRenderer,
  Cli/migration_logic.php and DbMigrateCommand (on an LB it would run
  MAIN's schema migrations). The viewer-API controllers still ship
  because the LB nginx still routes them; they go later with the routes.
- lb_delete_files_list now always writes the LB deleted_files.txt as the
  LB-scoped git deletions plus every stripped code file (Cli, Core,
  Domain, Infrastructure, Public, Streaming; never bin/config/content).
  An update only deletes listed files, so without this the files newly
  stripped here would stay on LBs that are already installed. The
  retired resources/ and www/ trees stay in the git-deletion scope
  (LB_RETIRED_DIRS), so their old entries are still applied.

lb_configs/nginx.conf: stop routing /stream/auth, /stream/probe and
/probe.php. They now get nginx's 404 instead of a PHP fatal. MAIN nginx
is unchanged.

verify-lb-archive.sh now also fails when:
- an LB_* entry matches no tracked path (STALE);
- a script the LB nginx executes is stripped (MISSING): every
  SCRIPT_FILENAME, and Public/<scope>/<handler>.php for each handler the
  /stream/ and /admin/ gateway locations accept.
SENSITIVE covers the new strips, CacheHandlerCommand and
CacheEngineCronJob. The manifest lookups now use here-strings, because
under pipefail an early `grep -q` exit could SIGPIPE the writer and hide
a leak. LbArchiveGateTest runs the real script with each failure mode
injected through MAKEFLAGS.

Behaviour: the LB archive loses 26 files that no LB route reaches (or
that fatal there today), and the next LB update deletes them. It also
deletes any lingering Domain/User or Domain/Device files. Fresh LBs
never had those, so an older LB that still carries them loses rtmp and
viewer-API paths that only worked because of them, just like a fresh LB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TQHeypQpfAXTdCysmi7b6a
2026-09-25 01:14:19 +00:00
..

tools/ — development, CI & panel-test utilities

Support tooling for the XC_VM panel. Nothing here ships to production — these are CI gates, static-analysis helpers, and manual test/QA utilities written to exercise the panel. Some are wired into the Makefile / CI; others are run by hand during testing. Each is listed below with its purpose and how to run it.

CI gates (run by make gates, enforced in CI)

Tool Purpose
ci/check_procedural_use.php Every non-namespaced procedural/view file must use-import the migrated XcVm\ classes it references (PHP use is positional — a short name without an import faults at runtime).
ci/check-vendor-prod-only.sh The committed src/vendor/ must be production-only — no dev package is tracked or listed in installed.json (checked against the git index).
ci/verify-lb-archive.sh The load-balancer archive must exclude privileged code (admin/reseller/player UI, user/device domain, install/root cron jobs).

Static analysis (PHPStan) support

Tool Purpose
phpstan/phpstan-bootstrap.php PHPStan bootstrap — defines the global constants (e.g. MAIN_HOME) the code sets at runtime, so constant-dependent analysis stays accurate. A bootstrapFile in build/phpstan.dist.neon.
phpstan/constants.stub.php Auto-generated stub of the ~131 runtime define() constants PHPStan cannot see via static scanning. A bootstrapFile. Do not hand-edit — regenerate it.
phpstan/gen-constants-stub.php Regenerates constants.stub.php by scanning src/ for define()s. Run via make phpstan-stub when runtime constants change.

Run the analysis with make phpstan (needs dev tools: make dev-tools).

Tests runner

The committed PHPUnit 10.5 runner now lives with the suite at tests/phpunit.phar: php tests/phpunit.phar -c tests/phpunit.xml.dist.

Panel test / QA utilities (manual)

Written to test the running panel end-to-end; run by hand as needed.

Tool Purpose
test_player_api.sh HTTP smoke-test of every PlayerApiController endpoint — checks status, Content-Type and JSON shape. ./tools/test_player_api.sh <base_url> <username> <password>. (Note: the password is passed as an argv arg, so it is visible in ps/shell history — use on a local/trusted shell.)
stream-check/ Dependency-free stream tool (stream_check.py) — checks MPEG-TS /ts and HLS queue integrity (single URL or whole .m3u playlist → JSON) and renders the JSON as SVG charts. Subcommands: check, playlist, graph. See its README.md and docs/*/development/streaming-subsystem.md.
test-stream-generator/ Generates a synthetic moving test pattern (stopwatch + wall-clock, no input file), served as a HTTP "live" stream to paste into the panel as a source — end-to-end pipeline testing, incl. LLOD (src/Cli/Commands/LlodCommand.php). See its README.md.
test-install/ Docker-based end-to-end install test of the built release archive — unpacks XC_VM.zip, runs the installer with scripted answers, and checks the key installed files. See its README.md. Referenced from docs/*/builds/updates_checklist.md.

Repo maintenance

Tool Purpose
update_top_contributors.py Regenerates the contributors table in CONTRIBUTORS.md from the GitHub Contributors + Pulls APIs. Optional GITHUB_TOKEN env var to avoid rate limits.