api: accept the host's own tier label in a report

The report schema pinned each box's tier to our size enum, but hosts name
a box's shape by resolution (1080p). Every report naming a box was a 400,
so stop reasons never reached the run. Placement already stores the size;
the reported label is free text and is not stored.
This commit is contained in:
Wanjohi
2026-10-08 12:14:46 +03:00
parent 56e64d4ba8
commit 4445f4836e
2 changed files with 14 additions and 4 deletions
+1 -1
View File
@@ -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' }
]
});
+13 -3
View File
@@ -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()