Commit Graph
121 Commits
Author SHA1 Message Date
josh f37014fad9 Merge branch 'main' of https://gitea.thewrightserver.net/josh/electric-cherry 2026-09-17 16:57:13 -04:00
josh a611850649 new destruction flow 2026-09-17 16:57:08 -04:00
josh 5c2df6d652 Update README.md 2026-09-17 16:55:27 -04:00
josh e688283210 Update README.md 2026-09-17 16:54:14 -04:00
josh 5f8e03c693 Remove campaigns helper text from deployments page 2026-09-17 16:45:10 -04:00
josh 6f83700161 Separate campaigns from server deployment lifecycle tracking 2026-09-17 16:42:37 -04:00
josh 6c6e63fa80 Fix Scripts page to list only scripts 2026-09-17 16:25:26 -04:00
josh 60e44636aa Fix initial artifact deployment and drift file replacement 2026-09-17 16:15:47 -04:00
josh e8e7332365 Automatically deploy the lowest available lobby with exact ID preview 2026-09-17 15:59:29 -04:00
josh ae173517b6 Persist Plutonium keys by server ID and add key management 2026-09-17 15:54:10 -04:00
josh e4505a3be8 Set telemetry server ID when creating Komodo servers 2026-09-17 15:28:23 -04:00
josh bbb1639184 debug 2 2026-09-17 15:09:27 -04:00
josh 85c238fceb debug 2026-09-17 15:01:39 -04:00
josh 858704bb10 adds round telemetry support 2026-09-17 14:35:42 -04:00
josh 8e04a190b3 Roll deployment restarts through a shared fleet-wide recovery limit 2026-09-17 11:25:06 -04:00
josh 3f0d6dd87d Apply selected server maps automatically without config overlays 2026-09-17 11:05:01 -04:00
josh 1cd4eb6f09 Use UpdateResourceMeta to apply Komodo deployment tags 2026-09-17 09:45:18 -04:00
josh 516dfeb4c3 Fix Komodo tag IDs in Mongo Extended JSON responses 2026-09-17 09:41:27 -04:00
josh e6b5705478 Probe tagged-union ListTags shape + surface raw bodies on miss
read/ListTags with an empty body was returning something we couldn't
parse, so every tag lookup silently missed and the CreateTag duplicate
fallback dead-ended with no diagnostic.

Now the tag lookup tries two request styles in order — the per-endpoint
`read/ListTags {}` used by the rest of this file, then the tagged-union
`read {type: "ListTags", params: {}}` used by mbecker20/komodo's
canonical API. If both fail to yield a match, both raw response bodies
get logged so the actual Komodo shape is diagnosable on the next run
without another commit-and-deploy cycle.
2026-09-17 09:26:07 -04:00
josh 66f70cd9f3 Handle Komodo tag response shape variance + duplicate recovery
Two real-world Komodo responses broke the first pass:

1. read/ListTags didn't surface tag "t5" in a matchable shape, so we
   fell through to CreateTag and got HTTP 500 "duplicate key: t5".
2. write/CreateTag returned 200 with an id field named "id" (not "_id"),
   which the parser rejected as an unexpected shape even on success.

Fixes:
- extractTagId accepts either "id" or "_id"
- unwrapTagList peels back common list wrappers (bare array, {tags},
  {data}, {results}, {items}) instead of requiring a top-level array
- CreateTag duplicate-key error triggers a re-list so the existing tag
  can be resolved to its id instead of failing the whole tag pass
- Both ListTags and CreateTag branches log the raw body when parsing
  fails, so the next unfamiliar shape is diagnosable at a glance
2026-09-17 09:20:20 -04:00
josh 5c674615d3 Tag Komodo deployments with game + canonical map name
New deployments get two tags attached (e.g. "t5" and "zombie_pentagon")
so operators can filter the Komodo deployment list by game and by map.
Tags are ensured via read/ListTags + write/CreateTag fallback, then
attached with write/UpdateTagsOnResource against the deployment name.

Tag application runs fire-and-forget after CreateDeployment: any failure
logs a warning and the server creation proceeds. Tags are cosmetic
organization inside Komodo, not a correctness requirement.
2026-09-17 09:15:00 -04:00
josh 5142a672ee Default test-server selection to none on beta open 2026-09-14 21:16:26 -04:00
josh 0fcdd18136 Fix HTTP 413 (redux): BODY_SIZE_LIMIT="Infinity", not "0"
The adapter treats "0" as "block anything > 0 bytes" rather than
"unlimited" — SvelteKit's own error message says: "To disable body size
limits, specify Infinity rather than 0." Previous commit set "0", which
kept the 413 in place.
2026-09-14 21:14:38 -04:00
josh e9dcc058eb Fix HTTP 413 on plugin upload: lift BODY_SIZE_LIMIT
SvelteKit's Node adapter caps request bodies at 512KB by default, which
rejects real-world plugin .dll uploads with HTTP 413. Same trust
boundary as the CSRF disable (LAN-only), so 0 = unlimited is fine.
2026-09-14 21:02:24 -04:00
josh a2d4a38925 Redesign UI with new token system, primitives, and motion
Restraint-first design language: neutral gray surfaces + one blue accent
(cyan/amber/red reserved for state), 8pt spacing, softer radii, one
ambient + one raised shadow, standardized motion tokens. Alfa Slab One
demoted to BrandMark only; Inter carries all page copy.

New primitives (Button, Card, Badge, Stat, SectionHeader, Skeleton,
EmptyState, Tabs, Breadcrumbs, StatusPip, Field, Input, Select, Textarea)
plus motion utilities (tweenNumber, viewTransition) and a global toast
system. All eight route surfaces rewritten on top: Fleet gains an
overview hero, Server detail restructures into tabs, Deployments gets a
collapsible drift summary + per-server pipeline visual, and the
scripts/configs/plugins/betas flows adopt the new form primitives.

Sticky translucent nav with backdrop blur, view-transition cross-fades
between routes, staggered card entrance on Fleet, breathing status pip
halo, tabular-numeric player counts. Gmail-style g-key nav shortcuts.
Mobile stacks below 720px; prefers-reduced-motion neutralizes durations.
Legacy tokens preserved as aliases so any un-migrated code still renders.
2026-09-14 19:48:48 -04:00
josh efd4a4fa66 Fix game timer: cycle-key tracking, wall-clock only, active gate
games_sp.log is not wiped on restart, so old J; lines from prior
sessions were poisoning the anchor. Now the scanner walks the tail
backward to the LATEST InitGame and only considers lines after it,
returning an opaque cycle key (the first J; line) plus a state. The
worker stamps game_started_at/ended_at with Date.now() at observation
time instead of inferring from the log's own timestamps. Same-players
game restarts produce a new key and cleanly re-anchor. When the server
transitions to 0 players, game state is cleared server-side and the
UI also gates the timer display on activeSince.

Adds servers.game_cycle_key column with additive migration.
2026-09-13 22:47:03 -04:00
josh 8186bb1ccc Anchor game timer to first player join, not InitGame
An idle map load emits InitGame in games_sp.log without anyone joining,
which was falsely surfacing the game timer on empty servers. Track the
first `J;<guid>;<slot>;<name>` line inside each InitGame cycle instead
and back-compute the wall-clock start from that line's in-game MM:SS.
Removes the coarse client-side activeSince gate since the scanner is
now the source of truth.
2026-09-13 21:55:05 -04:00
josh 3d111880d3 Add active/inactive/game-time timers to fleet + server pages
Fleet cards and the per-server detail hero now show three live-ticking
timers: Active (since players > 0), Inactive (since server emptied), and
Game (since InitGame in games_sp.log, back-computed from the log's own
MM:SS prefix so it stays accurate across restarts). Anchors are
persisted on `servers` and fanned out via the SSE bus; a single 1s
ticker feeds every card. Idle map cycles are filtered out so the game
timer doesn't flicker.
2026-09-13 21:45:54 -04:00
josh 79b2ba1464 corrected map aliases 2026-09-13 19:30:17 -04:00
joshandClaude Opus 4.7 be9cf10e02 Wait for container teardown before deleting Komodo deployment entity
execute/DestroyDeployment queues the container removal and returns before
it actually completes. write/DeleteDeployment refuses while a container
still exists for the deployment, so the entity survived every teardown.

Poll komodoInspectHealthy between the two calls until it stops reporting
a running container (up to 30s), then delete the entity.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-13 19:01:13 -04:00
joshandClaude Opus 4.7 58f48c6906 Fix container port mapping to match host port
PLUTAINER_PORT sets the port the container listens on, so the mapping
should be <port>:<port>, not <port>:28960 — otherwise the container is
bound to a port nothing inside is listening on.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-13 18:47:24 -04:00
joshandClaude Opus 4.7 21d9b54953 Fix deploy modal closing when opening the map dropdown
The bounding-rect click-outside check treated native <select> option clicks
(which render below the dialog) as backdrop clicks. Switch to the standard
e.target === dialog check — only clicks on the dialog element itself close.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-13 18:44:34 -04:00
joshandClaude Opus 4.7 13a29e5ace Add deploy + destroy server flow; migrate to t5_<mode>_<slug>_<n> naming
Full server lifecycle management from Electric Cherry: pick game/mode/map/pluto
key in the Fleet page, EC provisions the deployment via Komodo, allocates a
port in 28960-28980, creates the 0o777 host dir, and starts the container.
Destroy button tears everything down (Komodo Destroy+Delete, rm -rf host dir,
transactional DB cleanup) and surfaces any partial-failure warnings inline.

Same phase cuts over to the new naming scheme (t5_zombie_cosmodrome_1 etc.).
Komodo entity names now match EC server names 1:1 (no more _/- transform), and
the map catalog carries friendly/slug/canonical for each of the 11 t5 zombie
maps. Server rows gain game_mode, map_slug, host_dir, config_file, game_id,
image, created_by, and destroyed_at columns for provisioning + audit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-13 18:38:42 -04:00
joshandClaude Opus 4.7 8c15cae80d Replace -beta sidecar and .OLD backup with DB snapshots
Beta deploys used to rename foo.gsc -> foo.OLD and write beta bytes to
a foo-beta.gsc sidecar, forcing the mod loader to know the naming
convention. Now the beta content lives at the actual target filename
(same as configs already did) and the pre-beta bytes are captured in
a new beta_file_snapshots table for rollback.

- schema.sql: new beta_file_snapshots(beta_id, server, rel_path,
  prior_content BLOB, prior_sha256, prior_size). Handles scripts,
  plugins, and the composed dedicated_sp.cfg uniformly.
- db/index.ts: assertSnapshotSchemeSafe boot guard refuses to start
  if a legacy running/ready-promote beta is present on first upgrade.
  A settings sentinel (snapshots_v1) makes it one-shot.
- beta.ts openBeta: read prior bytes, insert snapshot, overwrite
  target directly.
- beta.ts rollbackBeta: restore from snapshot if had_original, else
  delete the fresh file. Drop snapshot rows after restore.
- beta.ts promoteBeta: no more rm -beta / rm .OLD calls, pull prior
  content from the snapshot table for the deployment audit, drop
  snapshots after promote.
- files.ts: delete betaFile() and oldFile().
- drift.ts: docstring updated; no special-casing needed since beta
  bytes and inventory now agree on the target rel_path.
- servers/[name]/+page.svelte: drop dead -beta/.OLD row filters.
- tests: plugin write asserts the target filename; unused
  betaFile/oldFile tests removed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-13 17:57:43 -04:00
joshandClaude Opus 4.7 30b0d1d4da Fix delete FK exhaustively; unset-scope surfaces as drift
deleteScript: previous fix missed beta_servers.prior_version_id,
beta_server_scripts.prior_version_id, and deployments.beta_id. Cascade
from betas.script_id -> beta_servers/beta_server_scripts left dangling
prior_version_id refs, and deletions of cascaded betas dangled
deployments.beta_id. Now nulls every NO ACTION reference before the
DELETE inside a single transaction.

Scope unset no longer touches disk from the API. Instead it detaches
inventory rows for scripts/plugins so drift Pass 1 flags the on-disk
copies as untracked; configs rely on drift Pass 2's compose-diff, which
already handles scope=null naturally. The operator reconciles from
/deployments using the existing rescan + reconcile buttons — same
visible flow as any other drift, no more silent synchronous file
removal.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-12 23:59:43 -04:00
joshandClaude Opus 4.7 34dc2ff00f Fix delete-script FK error; trigger drift on scope change
- deleteScript: null out deployments.script_id/script_version_id/prior_version_id
  and deployment_scripts.prior_version_id inside a transaction before the
  cascade. These are historical audit FKs (NO ACTION), so the cascade from
  script_versions was blowing up any delete of a promoted script.
- Scope endpoint fires runDriftDeployment in the background after any scope
  mutation so orphan/missing files from the change get reconciled.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-12 23:46:56 -04:00
joshandClaude Opus 4.7 f716036d89 Small UI cleanup, auto-refresh, and per-kind artifact routes
- Remove redundant "manage scripts" button and pipeline sidebar from Fleet page
- Bump log tail default 200 -> 1000 lines
- Auto-refresh (5s) on deployments list/detail, betas list, server detail, and artifact detail
- Drift ignores dedicated.cfg (Plutonium MP config; regenerates if deleted)
- Extract ArtifactDetail component; mount under /scripts/[id], /configs/[id], /plugins/[id] so configs and plugins no longer land on /scripts URLs

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-12 23:30:04 -04:00
josh f10f0cefef drift update 2026-09-12 23:15:14 -04:00
josh bb1e5c6a95 fix config 2026-09-12 19:41:13 -04:00
josh b86b3d5cc1 config upload fix 2026-09-12 19:34:25 -04:00
josh 6ae9004ed2 Drift now covers all three destinations 2026-09-12 19:16:14 -04:00
josh 8c40bbeff1 config and plugin 2026-09-12 19:11:44 -04:00
josh 85bcb05a7d multi script beta 2026-09-12 18:23:56 -04:00
joshandClaude Opus 4.7 30e59c900c Read-only script detail; move beta creation to /betas
The script detail page is now an informational card (target, scope, matched
servers, current + latest version) with edit-scope and upload-new-version
behind native <dialog> modals. The Open Beta panel is gone from the script
page entirely.

/betas gains an Open a beta section at the top. Its script dropdown filters
to entries that actually have something to test (unpromoted latest version,
no active beta), and pre-populates version + servers on script pick.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-12 14:40:56 -04:00
joshandClaude Opus 4.7 c78d0c62fd Drop trigger option from beta detail; stack remaining opts vertically
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-12 14:28:28 -04:00
joshandClaude Opus 4.7 1afdfddc87 Promote as a real deployment; version state and scope dropdowns
Turns promotion into a first-class deployment (action='promote') so it lands
in the deployments UI with before/after content, per-server restart tracking,
and one-click rollback. Non-beta matching-scope servers get restart_state=
pending so the existing sweep drains and restarts them the same way drift does.

Also adds a per-version state (untested/tested/test-failed) so the upload
flow can visibly signal that a beta must land before promotion, and swaps
the scope-value text box for game/map dropdowns populated from the fleet.
Beta rollback at ready-promote is now labelled Reject and marks the version
test-failed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-12 14:24:35 -04:00
joshandClaude Opus 4.7 3f934fd579 Disable SvelteKit CSRF origin check for multipart uploads
SvelteKit's built-in cross-site POST guard was blocking legitimate
multipart uploads from our own UI (HTTP 403 'Cross-site POST form
submissions are forbidden') whenever the operator reaches the app via
a hostname/port that doesn't match the browser's Origin header — LAN
IPs, reverse proxies, and .local hostnames all trip it. This tool is
scoped to private networks and has no cross-origin surface to defend
against, so the guard is more friction than protection here.

If Electric Cherry ever gets exposed to the public internet, do
per-route origin checks in hooks.server.ts instead of re-enabling
this blanket rule.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-12 13:55:29 -04:00
joshandClaude Opus 4.7 11e47b2a3f Widen Komodo health probe: try container endpoints, snippet on failure
GetDeployment returns config, not runtime state, so the health check was
always coming back with 'no container state found in response'. For
deployment-type servers the probe now tries GetDeploymentContainer,
InspectDeploymentContainer, and GetDeploymentStatus first, falling back
to GetDeployment only if those aren't available. The extractor also
recognizes more shapes (Health.Status, container_state, deployment_state,
etc.) and accepts more healthy strings (running, healthy, ok, started,
up).

When nothing matches, the truncated raw response snippet rides along in
the error field so the deployment/beta UI shows exactly which field to
teach the extractor next time.

Currently-stuck deployment_server rows are still 'pending', so the sweep
will retry them on its next 15s tick — no manual reset needed. Once one
of the widened endpoints resolves, those rows advance to 'done'
automatically.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-12 13:51:04 -04:00
joshandClaude Opus 4.7 edfe4dfc09 Add drift detection and removal as a real deployment
A drift deployment scans each server's sp/ tree for files not in the
server_scripts inventory (untracked scripts left over from before EC was
managing the fleet), deletes them, and records the removed bytes in
deployment_files for audit. The existing sweep then runs the standard
wait-for-empty → Komodo restart cycle on each affected server.

To make that cycle safer, the sweep now has a second phase: after Komodo
restart succeeds we wait for komodoInspectHealthy + RCON to both come
back green before marking the deployment_server row 'done'. If either
stays broken the row stays pending and keeps retrying.

New: /api/drift (GET scan, POST run), drift panel on /deployments.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-12 13:44:52 -04:00
joshandClaude Opus 4.7 590f803d93 Auto-derive server.game and server.map from the server name
Server folders encode the game and map (e.g. t5_ascension_1 = game t5, map
alias ascension, lobby 1). A T5_MAP_ALIASES table translates the friendly
alias to the canonical mapname RCON reports (ascension → zombie_cosmodrome),
covering every base + Rezurrection map. seedServerRegistry now populates
game and map at insert time and backfills existing NULL rows on every boot;
unknown aliases log a warning so we know when to add them.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-12 13:35:43 -04:00