Store SCUM facts in typed platform tables

Run pushes typed SCUM facts through POST /api/v1/run/scum/facts, but the
production router rejected that path before the signature middleware because
runServiceRequest listed individual Run channel prefixes, and MySQL kept SCUM
rows inside the whole metadata snapshot instead of platform tables.

- /api/v1/run/ is now the signed machine channel space while
  /api/v1/run/endpoints keeps normal bearer/admin authorization.
- MySQL gets real scum_user, scum_user_trajectory, scum_vehicle,
  scum_vehicle_trajectory and scum_vehicle_lock tables with parameterized
  per-row repositories instead of full snapshot rewrites. Snapshot-shaped
  tables from the unreleased interim build are replaced, and SCUM rows still
  inside a metadata snapshot are migrated once.
- Facts ingest verifies the target server plugin type and converges stale
  online users to offline after SCUMUserOfflineAfter.
- The plugin page and browser read one bounded /scum/surface response instead
  of five list calls per refresh.

Call-count budget for one server: per 5s facts batch, one SELECT plus one
INSERT/UPDATE per reported user and vehicle, one INSERT per moved trajectory
sample or new lock row, one bounded stale-user SELECT, and a trajectory
retention DELETE at most once per hour. One browser refresh issues one surface
request every 15s instead of five list requests.
This commit is contained in:
npc0-hue
2026-09-15 12:12:11 +08:00
parent 63e2340db7
commit a822e9250a
20 changed files with 1288 additions and 72 deletions
+12 -1
View File
@@ -45,7 +45,10 @@ type SCUMUserFilter struct {
SteamID string
Online *bool
ChangedAfter time.Time
Limit int
// StaleBefore matches users whose latest activity is older than the given
// instant. It backs the offline convergence query for stale online users.
StaleBefore time.Time
Limit int
}
type SCUMUserTrajectory struct {
@@ -137,6 +140,14 @@ type SCUMVehicleLockFilter struct {
Limit int
}
type SCUMSurface struct {
Users []SCUMUser
Vehicles []SCUMVehicle
UserTrajectories []SCUMUserTrajectory
VehicleTrajectories []SCUMVehicleTrajectory
VehicleLocks []SCUMVehicleLock
}
type SCUMFactIngest struct {
RunEndpointID string
SessionToken string