Skip to content

Latest commit

 

History

History
210 lines (171 loc) · 16.5 KB

global-migration.md

File metadata and controls

210 lines (171 loc) · 16.5 KB

GLOBAL → PoPunkouterSoftware

The _CODEMATT/global folder was a non-repo hub beside every Po app: it crawled the fleet, generated static HTML pages, held the UNITE creature prefabs, and ran a local Blazor command centre. This app now owns that functionality. The owner approved the move and the sign-in boundary on 2026-11-27.

What lives where now

GLOBAL thing Now
UNITE/ (rules, contract schema, 6 prefabs, tools, runs) docs/unite/ — data and prose, prefabs referenced by path
station/scripts/ crawlers (fleet, lessons) scripts/global/ — data only, no HTML
rl_training/scripts/ crawler + history recorder scripts/global/
station/*.html (fleet health, briefing, vault, showroom, ship board, lessons, disk, incubator) Blazor pages under /global
rl_training/*.html (overview, progress over time) /global/rl — the same reports, built by GLOBAL's own generators (scripts/global/rl_reports, vendored)
index.html hub, RUN_ME.bat /global and scripts/global/refresh_and_push.ps1 (crawl, commit, push)
station/automation/station_server.py (the :5050 launcher) scripts/global/local_helper.py — same port, no file serving, token + origin checked
rl_training/gpu_queue/run_gpu_queue.ps1 + gpu_queue.html scripts/global/run_gpu_queue.ps1, launched from /global/queue
BENCHMARK.bat / BENCHMARK.ps1 scripts/global/run_benchmarks.ps1, launched from /global/pc
rl_training/standards/vault_import.py scripts/global/vault_import.py, run from /global/pc (check first, then copy)
blazor_apps/ and rl_training/ standards + prompts docs/global-standards/, shown at /global/standards
the 07:00 task "CODEMATT Morning Briefing" same task, now refresh_and_push.ps1 (scripts/global/register_daily_refresh.ps1)
station/config/*.json src/PoPunkouterSoftware.Api/App_Data/global/config/

The _CODEMATT/global folder was deleted on 2026-11-28 after a file-by-file check against this repo. A backup is in _CODEMATT/GLOBAL-archive-20261128.zip (301 files). PoBasketball and PoRaceUnreal now read UNITE from ../PoPunkouterSoftware/docs/unite.

The Unite workflow: six steps, then Contract and More

Since 2026-12-01 the header calls /global Unite (it opens Step 1) and a numbered stepper (GlobalTabs.razor, steps in UniteStepper.cs) follows a model and its training from start to finish, one page per step. The picks ride in the URL (?model=<creature id>&behaviour=<behaviour id>) and every step link keeps them, so any step opens directly; a step whose pick is missing shows a short link back to the step that picks it. UNITE Contract (/global/contract) and More are small links beside the stepper; More's views are the pages in the table below.

Every UNITE model with a contract.json can be trained (owner, 2026-12-01): a behaviour stores its creature (picked when it is added, then fixed; the server checks it is in unite.json or the creatures folder), the trainer gets --creature <id>, and a finished run is checked against that creature's own contract (U1, U2).

Step Route What it shows
1 Pick model /global/discover Every UNITE model as a card (contract version, rig, "train here" when it has a contract, behaviour counts); Pick opens Step 2 with ?model=
2 Pick behaviour /global/behaviours The picked model's behaviours (every model's when none is picked); Add (preset to the model) / Edit in the drawer; Pick opens Step 3. The old ?train=<id> link redirects to Step 3
3 Start training /global/start BehaviourTrainingPanel for ?behaviour=: start, stop, continue (laptop or Google Cloud), Preview, Export now, Improve; below it the live training monitor (TrainingStatus: Google Cloud VMs and local queue runs)
4 Training status /global/training Only the finished behaviours: runs that ended with a brain that plays (2026-12-03), with their log's numbers, refreshed every 30 s, narrowed to the picked model / behaviour. Picking one opens Step 5 with ?run=
5 View finished behaviour /global/results?run= (the old viewer URL /global/unite/live lands here too) The one finished run picked on Step 4 (a visit without ?run= goes back to Step 4; locked in the stepper until then): its training (steps, time, last return, falls, mean-return curve), its 10 environments (each opens the 3D player there, on this page), Watch in 3D (the player, no model or brain picker) and Mark Complete
6 Export to repos /global/export The Complete brains with Export to repo (POST /api/global/brains/{name}/export-to-repo: brains.py fetch into the chosen repo's unite/brains/<brain>/ (every UNITE consumer repo uses that one folder); PC only, stored brains only, copies files only)

More: fifteen pages

The station's fourteen pages, plus the brain store, are the views of More (they were seven tabs until 2026-12-01; the "Tab" column below is that old grouping). Every page keeps its own URL, so old links still work.

Tab Views (route) What it shows
Hub /global Data freshness, three linked numbers (CI not passing and uncommitted work open Fleet pre-filtered with ?filter=ci / ?filter=dirty; brains open the vault) with change since the last crawl, needs attention (broken items; the rest folded), and folded: control panel and glossary (the reports and standards are the RL and Reference tabs)
Fleet Health /global/fleet Per repo: branch, dirty/ahead/behind, last commit, CI conclusion, brains, models, disk, live URL
What changed /global/briefing Changes between the last two crawls (commits, new brains, disk movement, CI flips, working-tree churn), plus the fleet trend over time
Disk /global/disk Space per repo and folder type, heaviest folders, how safe each is to delete
Training Queue /global/queue Only UNITE jobs that run from this repo (GlobalDataStore.UniteOnly): the PC jobs from config/train_jobs.json with what the crawl found missing, this repo's cloud jobs, tonight's multi-job queue (folded) and past runs. Running training is on Progress /global/training; R1 behaviours start from Behaviours
This PC /global/pc Refresh and push the snapshot, run benchmarks, copy a brain, drive the cloud GPU VM
RL /global/rl Four views: Summary (default, native) is what to train next, each repo's brains in the vault with the newest one's UNITE status, and four totals; Full report and History are GLOBAL's two RL reports, framed only when chosen (?view=full, ?view=history; the old overview / progress keys still work); Benchmarks is the one home of benchmark numbers
Brains UNITE /global/unite The brains that count (portable, in the store: docs/unite/brains.json), Adoption by repo ("N of M RL repos on UNITE", then per RL repo its class and the RULES.md section 5 checks as ticks with the file each found; unite_adoption.json, step adoption, /api/global/unite-adoption), the 6 UNITE prefabs and the rules
Brains /global/brains One page, three views (UI audit 2026-12-01): UNITE store (every brain in docs/unite/brains.json with tier, portable, 10-corner pass count, sha and date; creature filter, default the R1; copy into a repo through the helper), Gallery (/global/unite/gallery) and All .onnx files (/global/vault). The R1 skills backlog moved to Behaviours
(view of Brains) /global/vault Every .onnx by interface (obs → act; 131 → 28 is the UNITE standard), UNITE brains first with an "All brains" switch, starred brains, every MJCF body; ?repo= filters (and shows all of that repo)
Training reports /global/reports One plain-language page per training run (docs/unite/tools/run_report.py); /global/rl?view=runs redirects here
Apps Ship board /global/readiness Prototype → Shipped, six-point checklist, suggested stage with a reason
Showroom /global/showroom Newest captures per repo as small WebP thumbnails made at crawl time (showroom_thumbs.py, /api/global/showroom/{name}); the lightbox opens the original on GitHub
Reference Standards /global/standards The Blazor and RL standards, the portability contract and the saved prompts
Lessons /global/lessons Traps and rules harvested from every repo's docs, with search, repo and kind filters
New idea /global/incubator Five questions → which repo to start from, brains to bring, clone command

On a phone the stepper and the view chips each scroll sideways inside themselves; the page never does.

How the data gets there

scripts/global/build_global_data.py
        │  crawls ../Po* (read-only) and docs/unite
        ▼
src/PoPunkouterSoftware.Api/App_Data/global/*.json     (committed)
        │  GlobalDataStore (timestamp-cached, degrades to empty)
        ▼
/api/global/*        (owner sign-in required, like /azure and /users)
        ▼
/global/*            (Blazor WASM pages)

App_Data sits under the content root, so it is never served as a static file — the API is the only way in. That matters: the snapshot names local paths, uncommitted files and commit hashes.

The crawler writes snake_case; the API answers camelCase. Two source-generated JsonSerializerContexts cover the two shapes (GlobalCrawlerJsonContext for the files, GlobalJsonContext for the wire), so nothing depends on reflection in the trimmed Release build.

Refreshing the snapshot

python scripts/global/build_global_data.py            # ~2 min: fleet crawl + disk sizes + gh
python scripts/global/build_global_data.py --only rl  # just the training facts

Then commit App_Data/global (the RLS and fleet data are the product) and reload /global.

App_Data/global/history/snapshots/ and App_Data/global/rl/snapshots/ are not committed — they are the full per-run archive and only the compact timelines are needed for the briefing and the RL chart. See .gitignore.

Who can see it

Only the owner. MicrosoftAuth:OwnerEmail names the one account that can complete Microsoft sign-in (Host/OwnerAccess.cs); any other account is refused before a session exists, so the header links to Azure, Users and Fleet never render for anyone else. With no owner configured, Production refuses everybody. One-time setup: pwsh ./scripts/setup-microsoft-signin.ps1 -OwnerEmail <owner address>.

Actions on the PC (the local helper)

The site runs in Azure and cannot reach the owner's PC, so everything that has to happen there goes from the browser straight to scripts/global/local_helper.py on http://127.0.0.1:5050:

signed-in /global page (browser on the PC)
        │  fetch, with the token from this browser's localStorage
        ▼
local_helper.py on 127.0.0.1:5050     (start: scripts\global\start_local_helper.bat)
        │  fixed list of actions; commands come from the catalogs, never from the page
        ▼
VS Code / Explorer / Unity / Unreal · run_gpu_queue.ps1 · run_benchmarks.ps1 ·
vault_import.py · refresh_and_push.ps1 · scripts/gcp/gcp_queue.py
Where Buttons
/global/fleet per repo: Code, Folder, Status (git), Engine (Unity / Unreal)
/global/queue tick jobs + hours → Dry run / Start on this PC; Recent runs; per cloud job: Dry run / Send to the cloud GPU
/global/brains per brain: target repo → Check (copies nothing) / Copy… → Yes, fetch it (helper brain_fetch: brains.py fetch <sha> into <repo>/unite_brains/<name>/); Copy command works without the helper
/global/pc Crawl only / Crawl, commit and push; Benchmarks; Copy a brain (check fit, then copy); cloud VM Status / Check setup / Start / Stop

Rules the helper enforces (tested in scripts/global/test_local_helper.py):

  • listens on 127.0.0.1 only, and refuses a request whose Host is not that address;
  • a browser request must carry this site's Origin (the live site or localhost:8000);
  • every action needs the token it prints on start (scripts/global/.local/helper_token.txt, git-ignored). The owner pastes it once on the site; it stays in that browser;
  • the page sends names only — a repo, job ids, hours. Repos must be git folders in the workspace, job ids must be in train_jobs.json / cloud_jobs.json, and the command is always the catalog's;
  • brain_fetch takes only a full policy_sha256 that is in docs/unite/brains.json (legacy brains refused) and a Po repo; it downloads into .local/fetch/ first (brains.py re-hashes and re-verifies the sidecar), then moves the folder to <repo>/unite_brains/<name>/, which must not exist yet, and commits nothing;
  • it serves no files and deletes nothing.

Away from the PC, or with the helper stopped, the pages still read and the buttons are not rendered. Anything that starts real work (training, a cloud run, the cloud VM, a brain copy) takes a second, explicit click that says what will happen; cloud actions say they cost money. The site's CSP allows exactly http://127.0.0.1:5050 in connect-src for this.

Local state — the token, saved queues, queue runs, benchmark logs, refresh log — lives in scripts/global/.local/ and is never committed.

The daily refresh

scripts/global/refresh_and_push.ps1 crawls, commits only App_Data/global when it changed, rebases onto origin/master and pushes (which deploys). The Windows task "CODEMATT Morning Briefing" runs it at 07:00; point the task at this repo with powershell -ExecutionPolicy Bypass -File scripts\global\register_daily_refresh.ps1.

Not carried over

  • Editing the ship-board stage and the vault's gold stars from a page (save_config). Both files were empty in GLOBAL; edit App_Data/global/config/readiness.json and vault_gold.json by hand.
  • quick_transfer_actions.py, train_next_explorer.py and the HTML generators: they only produced static pages the app now renders itself.

The recorded history did come across: history/station_timeline.jsonl and rl/rl_timeline.jsonl start with GLOBAL's 16 fleet crawls and 15 RL records.

Tests

  • Unit: tests/PoPunkouterSoftware.Unit/GlobalDataStoreTests.cs — parses the real committed snapshot (so a crawler/API drift fails the build), plus missing-file, corrupt-file, briefing-delta, socket grouping, gold stars and readiness-suggestion cases.
  • Helper: python -m unittest scripts/global/test_local_helper.py — who may call it, and that a page can never supply a command (15 tests; nothing is started on the PC).
  • UNITE adoption: python -m pytest -q scripts/global/test_unite_adoption.py — the adoption step on fake repo trees (15 tests); tests/PoPunkouterSoftware.Unit/GlobalAdoptionTests.cs covers the loader's null guards and the section's headline, tones and tick titles.
  • Brain store: python -m pytest -q scripts/global/test_brains.py — the brains step's statuses and corner counts, and brain_fetch's refusals (15 tests, in a temporary workspace; nothing is downloaded). tests/PoPunkouterSoftware.Unit/GlobalBrainsTests.cs covers the loader's null guards and the page's filter.
  • Browser: tests/PoPunkouterSoftware.E2EUI/GlobalUiTests.cs — the PC buttons appear only when the helper is connected, a start needs a confirmation, and only ids and hours are sent (the helper is a Playwright route, so nothing runs).
  • Integration: tests/PoPunkouterSoftware.Integration/GlobalEndpointsTests.cs — every route 401s anonymously, answers signed in, and the snapshot is deployed beside the app.

Deliberate deviations

Deviation Why
snake_case file naming on the API's raw-read context the crawlers are unchanged Python tools; rewriting every key would risk the crawl for cosmetics
Screenshots and GIFs load from raw.githubusercontent.com (all Po repos are public; CSP img-src allows it) no second copy of 900 captures; a capture that is not pushed yet does not show
The two RL reports are GLOBAL's generated HTML in a sandboxed frame, not Blazor ~2,500 lines of hand-written analysis carried over intact; the response has its own CSP (no network but GitHub images, sandbox, frame-ancestors 'self')
scripts/global/rl_reports is excluded from ruff vendored as written so it can be diffed against GLOBAL's originals
No scheduled crawl F1 has no Always On; the owner runs the crawl and commits, as with every other snapshot in this repo
docs/unite/tools/ sits beside the prefabs the tools resolve creatures/ relative to themselves; moving them to scripts/ would need path surgery in ten files