diff --git a/apps/api/test/report.test.ts b/apps/api/test/report.test.ts index 39550997..b0d35084 100644 --- a/apps/api/test/report.test.ts +++ b/apps/api/test/report.test.ts @@ -75,7 +75,7 @@ describe('POST /machine/report', () => { boxesKnown: 2, boxesRunning: 1, boxes: [ - { boxId: running.id, tier: 'sm', state: 'running', pid: 1234, uptimeS: 45 }, + { boxId: running.id, tier: '1080p', state: 'running', pid: 1234, uptimeS: 45 }, { boxId: idle.id, tier: 'sm', state: 'created' } ] }); diff --git a/packages/core/src/box/index.ts b/packages/core/src/box/index.ts index 1d90675f..5c416fac 100644 --- a/packages/core/src/box/index.ts +++ b/packages/core/src/box/index.ts @@ -235,22 +235,32 @@ export namespace Box { * kept and already trustworthy. Storing a plausible number instead of a * measured one is how a scheduler learns to trust a field nobody produced. */ + /** + * The host's own name for a box's shape, such as `1080p`. + * + * Free text, and never stored: placement already wrote this box's size on + * its row. Pinning it to our size enum turned every report from a host + * that names shapes by resolution into a 400, and with it every stop + * reason the report carries. + */ + const ReportedTier = z.string(); + export const Reported = z.discriminatedUnion('state', [ z.object({ boxId: z.string(), - tier: z.enum(BoxTier.enumValues), + tier: ReportedTier, state: z.literal('created') }), z.object({ boxId: z.string(), - tier: z.enum(BoxTier.enumValues), + tier: ReportedTier, state: z.literal('running'), pid: z.number().int().optional(), uptimeS: z.number().int() }), z.object({ boxId: z.string(), - tier: z.enum(BoxTier.enumValues), + tier: ReportedTier, state: z.literal('stopped'), reason: z.string(), clean: z.boolean()