Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .claude/skills/security-audit/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ warn about them.

The fleet's hosts are not in the code. They come from the gitignored `.env`:

| Variable | Holds |
| ------------- | ------------------------------------------------------------------------------------------ |
| `FM_HOST_IPS` | one comma-separated list of five IPv4 addresses: meleys, vermithor, caraxes, syrax, vhagar |
| `FM_SSH_USER` | the ssh account on those hosts |
| `WZ_NAS_HOST` | optional `user@host` override for the NAS; otherwise built from the two above |
| Variable | Holds |
| ------------- | --------------------------------------------------------------------------------------------------- |
| `FM_HOST_IPS` | one comma-separated list of six IPv4 addresses: meleys, vermithor, caraxes, syrax, vhagar, balerion |
| `FM_SSH_USER` | the ssh account on those hosts |
| `WZ_NAS_HOST` | optional `user@host` override for the NAS; otherwise built from the two above |

`scripts/nas-host.sh [host]` turns those into an ssh target for the skills' scripts, and
the fleet monitor refuses to boot if `FM_HOST_IPS` is missing, the wrong length, or holds
Expand Down
8 changes: 4 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ FM_SUPABASE_URL=https://<project>.supabase.co
FM_ADMIN_ALLOWED_EMAILS=you@example.com

# --- 3b. Fleet hosts --------------------------------------------------------
# The unprivileged account the collector SSHes into all five hosts as.
# The unprivileged account the collector SSHes into all six hosts as.
# Required: the monitor refuses to boot without it.
FM_SSH_USER=
# The fleet's addresses, one list, in this order: meleys, vermithor, caraxes,
# syrax, vhagar. Required, exactly five IPv4 addresses; the monitor refuses to
# boot on anything else. scripts/nas-host.sh reads this same list (plus
# FM_SSH_USER) to build the NAS SSH target for every skill script.
# syrax, vhagar, balerion. Required, exactly six IPv4 addresses; the monitor
# refuses to boot on anything else. scripts/nas-host.sh reads this same list
# (plus FM_SSH_USER) to build the NAS SSH target for every skill script.
FM_HOST_IPS=

# --- 3c. Play history -------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion apps/admin-portal/src/lib/fleetApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ vi.mock('@/lib/supabaseClient', () => ({
// percent, dividing load by a hardcoded four, comparing disk against a warn
// threshold, regex-parsing container names out of metric keys - moved to the
// side that owns those facts, and is tested there.
// A TEST-NET-1 address (RFC 5737): reserved for examples, never a real host.
const HOST_IP = '192.0.2.3'

const host: FleetHost = {
name: 'vermithor',
ip: '192.0.2.3',
ip: HOST_IP,
has_gpu: true,
has_docker: true,
console: { name: 'DiskStation Manager', url: `http://${HOST_IP}:5000/` },
collected: true,
status: 'ok',
cores: 4,
Expand Down
9 changes: 0 additions & 9 deletions apps/admin-portal/src/lib/fleetApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ export const plural = ({ count, unit }: { count: number; unit: string }): string

/** A metric age in words. "unknown" for an absent age, because a host that was
never measured has no age at all, and rendering it as 0 would read as fresh. */
/* DiskStation Manager's own port. Every box answers on both 5000 (http) and
5001 (https, self-signed), checked 2026-11-07; the plain port opens straight
to the login page instead of behind a certificate warning, and DSM encrypts
the password itself before it leaves the browser. */
const DSM_PORT = 5000

/** A host's DSM login page, which its card on the Fleet page links to. */
export const dsmUrl = ({ ip }: { ip: string }): string => `http://${ip}:${DSM_PORT}/`

export const formatAge = (seconds: number | null): string => {
if (seconds === null || !Number.isFinite(seconds) || seconds < 0) return 'unknown'
const unit = AGE_UNITS.find((candidate) => seconds >= candidate.seconds)
Expand Down
18 changes: 16 additions & 2 deletions apps/admin-portal/src/pages/Fleet/Fleet.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ import {
useFleetPrefsStore,
} from '@/stores/fleetPrefsStore'

// A TEST-NET-1 address (RFC 5737): reserved for examples, never a real host.
const HOST_IP = '192.0.2.3'

// What a card is rendered from: one /fleet host, read as the wire sends it.
const card: FleetHost = {
name: 'vermithor',
ip: '192.0.2.3',
ip: HOST_IP,
has_gpu: true,
has_docker: true,
console: { name: 'DiskStation Manager', url: `http://${HOST_IP}:5000/` },
collected: true,
status: 'warn',
cores: 4,
Expand All @@ -38,9 +42,10 @@ const card: FleetHost = {

const host: FleetHost = {
name: 'vermithor',
ip: '192.0.2.3',
ip: HOST_IP,
has_gpu: true,
has_docker: true,
console: { name: 'DiskStation Manager', url: `http://${HOST_IP}:5000/` },
collected: true,
status: 'ok',
cores: 4,
Expand Down Expand Up @@ -258,6 +263,15 @@ test('HostCard opens its DSM login page in a new tab', () => {
expect(link).toHaveAccessibleDescription('Opens DiskStation Manager in a new tab')
})

test('HostCard links to whichever console the monitor names', () => {
const ugos = { name: 'UGOS', url: 'http://192.0.2.7:9999/' }
render(<HostCard host={{ ...card, name: 'balerion', status: 'ok', console: ugos }} />)

const link = screen.getByRole('link', { name: 'balerion' })
expect(link).toHaveAttribute('href', ugos.url)
expect(link).toHaveAccessibleDescription('Opens UGOS in a new tab')
})

/* A warn host prints no status word at all: the finding is the disk and load
figures the monitor judged, not a phrase summarising them over the name. */
test('HostCard prints no status line on a warn host', () => {
Expand Down
8 changes: 4 additions & 4 deletions apps/admin-portal/src/pages/Fleet/HostCard.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
translate 180ms ease-out;

&:hover,
&:has(.dsmLink:focus-visible) {
&:has(.consoleLink:focus-visible) {
border-color: color-mix(
in oklab,
var(--series-color, var(--color-border)) 70%,
Expand All @@ -53,7 +53,7 @@
}
}

&:has(.dsmLink:focus-visible) {
&:has(.consoleLink:focus-visible) {
outline: 2px solid var(--color-accent);
outline-offset: 2px;
}
Expand All @@ -62,7 +62,7 @@
/* The host name, and through its overlay the whole card. Inherits the name's
colour rather than link blue: the card's lift and the mark beside the name
are what say it opens something. */
.dsmLink {
.consoleLink {
display: inline-grid;
align-items: center;
grid-auto-flow: column;
Expand All @@ -85,7 +85,7 @@
}

// Says "opens elsewhere" without words; the words are in the hidden span.
.dsmMark {
.consoleMark {
color: var(--color-muted);
transition: color 180ms ease-out;

Expand Down
21 changes: 10 additions & 11 deletions apps/admin-portal/src/pages/Fleet/HostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Icon, type IconName } from '@/components/Icon/Icon'
import { IconTile, type IconTileTone } from '@/components/IconTile/IconTile'
import {
formatAge,
dsmUrl,
formatBytes,
type FleetContainer,
type FleetHost,
Expand Down Expand Up @@ -239,7 +238,7 @@ export const HostCard = ({ host, className }: HostCardProps) => {
const coreContext =
host.cores === null ? '' : `${host.cores} ${host.cores === 1 ? 'core' : 'cores'}`
const hasFooter = host.has_gpu || host.has_docker
const dsmHintId = useId()
const consoleHintId = useId()

return (
<article
Expand All @@ -249,24 +248,24 @@ export const HostCard = ({ host, className }: HostCardProps) => {
<header className={styles.header}>
<h3 className={styles.name}>
{/* The whole card is the link: the anchor's overlay stretches over the
card, so a click anywhere opens DSM, while the name stays the one
focusable, announced element. The containers disclosure sits above
the overlay and keeps its own click. */}
card, so a click anywhere opens the host's console, while the name
stays the one focusable, announced element. The containers
disclosure sits above the overlay and keeps its own click. */}
<a
className={styles.dsmLink}
href={dsmUrl({ ip: host.ip })}
className={styles.consoleLink}
href={host.console.url}
target="_blank"
rel="noopener noreferrer"
/* a description rather than part of the name, so the heading and
the link are both still called just the host's name */
aria-describedby={dsmHintId}
aria-describedby={consoleHintId}
>
{host.name}
<Icon name="external" size={14} className={styles.dsmMark} />
<Icon name="external" size={14} className={styles.consoleMark} />
</a>
</h3>
<span id={dsmHintId} className={styles.srOnly}>
Opens DiskStation Manager in a new tab
<span id={consoleHintId} className={styles.srOnly}>
Opens {host.console.name} in a new tab
</span>
<p className={styles.ip}>{host.ip}</p>
{/* status is stated in text, never by color alone: the tile restates
Expand Down
4 changes: 4 additions & 0 deletions apps/admin-portal/src/pages/Fleet/series.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@
.series5 {
--series-color: var(--color-series-5);
}

.series6 {
--series-color: var(--color-series-6);
}
1 change: 1 addition & 0 deletions apps/admin-portal/src/pages/Fleet/seriesPalette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const SERIES_CLASSES = [
styles.series3,
styles.series4,
styles.series5,
styles.series6,
] as const

/** The class binding one host position to its colour, or '' past the palette. */
Expand Down
3 changes: 2 additions & 1 deletion apps/admin-portal/src/styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
/* Chart series identity, one slot per fleet host, always paired with the
host's name in text. The order is the colourblind-safety mechanism, not a
mood: this exact sequence passes the dataviz palette validator against
--color-surface (worst adjacent CVD ΔE 8.4, normal-vision 19.3), so never
--color-surface (worst adjacent CVD ΔE 8.4, normal-vision 17.4), so never
reorder or restep a slot without re-running it. Slots 2 and 5 sit just
under 3:1 on the surface, which is why the chart ships a table view. */
--color-series-1: #3987e5;
--color-series-2: #d95926;
--color-series-3: #199e70;
--color-series-4: #c98500;
--color-series-5: #d55181;
--color-series-6: #9b7be0;

/* Play types on the plays tables, always beside the type's name. Hues the
series palette leaves alone, so a type never reads as a server. Each
Expand Down
4 changes: 2 additions & 2 deletions apps/fleet-monitor/src/api/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ describe('the fleet API', () => {
const body = await fleet()

expect(new Set(body.hosts.map((host) => host.name))).toEqual(
new Set(['vermithor', 'meleys', 'syrax', 'vhagar', 'caraxes']),
new Set(['vermithor', 'meleys', 'syrax', 'vhagar', 'caraxes', 'balerion']),
)
const vermithor = hostNamed(body, 'vermithor')
expect(vermithor.metrics['load.1m']).toBe(0.46)
Expand Down Expand Up @@ -761,7 +761,7 @@ describe('the fleet API', () => {
const wide = await history('/fleet/cpu?minutes=30')

expect(narrow.window_minutes).toBe(5)
expect(narrow.hosts.map((host) => host.points)).toEqual([[], [], [], [], []])
expect(narrow.hosts.map((host) => host.points)).toEqual([[], [], [], [], [], []])
expect(values(wide.hosts[0].points)).toEqual([25.0])
})

Expand Down
52 changes: 40 additions & 12 deletions apps/fleet-monitor/src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
dbPath,
fleetHosts,
host,
hostConsole,
hostIps,
MAX_ROUND_SECONDS,
PLEX_HISTORY_INTERVAL,
Expand Down Expand Up @@ -30,11 +31,11 @@ describe('config', () => {
})

it('configures every fleet host', () => {
expect(names(HOSTS)).toEqual(['caraxes', 'meleys', 'syrax', 'vermithor', 'vhagar'])
expect(names(HOSTS)).toEqual(['balerion', 'caraxes', 'meleys', 'syrax', 'vermithor', 'vhagar'])
})

it('gives only vermithor and vhagar a render node', () => {
// measured 2026-08-10: meleys is AMD, syrax is Atom, caraxes is ARM
// measured 2026-08-10: meleys is AMD, syrax is Atom, caraxes is ARM; balerion is unprobed
expect(names(HOSTS.filter(({ has_gpu }) => has_gpu))).toEqual(['vermithor', 'vhagar'])
})

Expand All @@ -56,30 +57,38 @@ describe('config', () => {
caraxes: '192.0.2.4',
syrax: '192.0.2.5',
vhagar: '192.0.2.6',
balerion: '192.0.2.7',
})
})

it.each([
['is unset', undefined],
['is empty', ''],
['is one address short', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5'],
['has one address too many', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.6,192.0.2.7'],
['holds a hostname', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,nas.example.com'],
['holds an octet over 255', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.256'],
['is one address short', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.6'],
[
'has one address too many',
'192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.6,192.0.2.7,192.0.2.8',
],
['holds a hostname', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.6,nas.example.com'],
['holds an octet over 255', '192.0.2.2,192.0.2.3,192.0.2.4,192.0.2.5,192.0.2.6,192.0.2.256'],
])('refuses a fleet list that %s', (_label, value) => {
vi.stubEnv('FM_HOST_IPS', value)
expect(() => hostIps()).toThrow(/FM_HOST_IPS must list 5/)
expect(() => hostIps()).toThrow(/FM_HOST_IPS must list 6/)
expect(() => fleetHosts()).toThrow(/FM_HOST_IPS/)
})

it('trims whitespace around each address', () => {
vi.stubEnv('FM_HOST_IPS', ' 192.0.2.12 , 192.0.2.13,192.0.2.14 ,192.0.2.15,192.0.2.16')
vi.stubEnv(
'FM_HOST_IPS',
' 192.0.2.12 , 192.0.2.13,192.0.2.14 ,192.0.2.15,192.0.2.16,192.0.2.17',
)
expect(fleetHosts().map(({ ip }) => ip)).toEqual([
'192.0.2.12',
'192.0.2.13',
'192.0.2.14',
'192.0.2.15',
'192.0.2.16',
'192.0.2.17',
])
})

Expand Down Expand Up @@ -125,14 +134,32 @@ describe('config', () => {
expect(MAX_ROUND_SECONDS).toBe((VITALS_TIMEOUT + SLOW_TIMEOUT) * CAPTURE_FACTOR)
})

it('gives every host a plex url', () => {
// Plex runs natively on all five boxes (measured 2026-09-18), so an empty
// url here would silently drop a server from every play-history view
it('links balerion to UGOS and every other host to DSM', () => {
expect(Object.fromEntries(fleetHosts().map((each) => [each.name, hostConsole(each)]))).toEqual({
meleys: { name: 'DiskStation Manager', url: 'http://192.0.2.2:5000/' },
vermithor: { name: 'DiskStation Manager', url: 'http://192.0.2.3:5000/' },
caraxes: { name: 'DiskStation Manager', url: 'http://192.0.2.4:5000/' },
syrax: { name: 'DiskStation Manager', url: 'http://192.0.2.5:5000/' },
vhagar: { name: 'DiskStation Manager', url: 'http://192.0.2.6:5000/' },
balerion: { name: 'UGOS', url: 'http://192.0.2.7:9999/' },
})
})

it('gives every host that runs plex a plex url', () => {
/* Plex runs natively on the five Synology boxes (measured 2026-09-18), so an
empty url here would silently drop a server from every play-history view;
balerion is the media store and runs none */
expect(names(plexHosts())).toEqual(['caraxes', 'meleys', 'syrax', 'vermithor', 'vhagar'])
})

it('keeps plex hosts in config order', () => {
expect(plexHosts().map(({ name }) => name)).toEqual(HOSTS.map(({ name }) => name))
expect(plexHosts().map(({ name }) => name)).toEqual([
'meleys',
'vermithor',
'caraxes',
'syrax',
'vhagar',
])
})

it('addresses the two secure-only servers over https', () => {
Expand All @@ -145,6 +172,7 @@ describe('config', () => {
caraxes: 'http://192.0.2.4:32400',
syrax: 'http://192.0.2.5:32400',
vhagar: 'https://192.0.2.6:32400',
balerion: '',
})
})

Expand Down
Loading
Loading