fix(monitoring): report observed research and paper readiness (O02)
This commit is contained in:
parent
70d173a908
commit
8c858b9d5c
23 changed files with 1340 additions and 319 deletions
72
apps/stock/config/src/contracts/diagnostics.ts
Normal file
72
apps/stock/config/src/contracts/diagnostics.ts
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/** Read-only operational snapshots, never execution authority or resume tokens. */
|
||||
import { z } from 'zod';
|
||||
import { canonicalBuildIdentitySchema } from './canonical-research';
|
||||
import { paperReadinessSchema } from './paper-deployments';
|
||||
|
||||
export const researchSlotSchema = z
|
||||
.object({
|
||||
runId: z.string().nullable(),
|
||||
backtestId: z.string().nullable(),
|
||||
attemptId: z.string().nullable(),
|
||||
strategyVersionId: z.string().nullable(),
|
||||
phase: z.enum(['idle', 'preparing', 'executing', 'persisting']),
|
||||
})
|
||||
.strict();
|
||||
export const researchRuntimeSchema = z
|
||||
.object({
|
||||
accepting: z.boolean(),
|
||||
capacity: z.number().int().positive(),
|
||||
slots: z.array(researchSlotSchema),
|
||||
})
|
||||
.strict();
|
||||
export const paperDiagnosticSchema = paperReadinessSchema
|
||||
.pick({
|
||||
configured: true,
|
||||
ready: true,
|
||||
active: true,
|
||||
connected: true,
|
||||
operatorHalted: true,
|
||||
reasons: true,
|
||||
lastReceivedAt: true,
|
||||
lastAvailableAt: true,
|
||||
requiresHistoricalRecovery: true,
|
||||
})
|
||||
.strip();
|
||||
export const orchestratorDiagnosticSchema = z
|
||||
.object({
|
||||
service: z.literal('orchestrator'),
|
||||
observedAt: z.string().datetime(),
|
||||
research: researchRuntimeSchema.nullable(),
|
||||
build: canonicalBuildIdentitySchema.nullable(),
|
||||
// A readable artifact is not proof that a fresh native child can execute it.
|
||||
nativeExecution: z.literal('unverified-until-run'),
|
||||
paper: paperDiagnosticSchema.nullable(),
|
||||
live: z.literal('disabled'),
|
||||
})
|
||||
.strict();
|
||||
export const monitoringReadinessSchema = z
|
||||
.object({
|
||||
observedAt: z.string().datetime(),
|
||||
postgres: z.enum(['connected', 'unavailable']),
|
||||
queue: z
|
||||
.object({
|
||||
connected: z.boolean(),
|
||||
workers: z.number().int().nonnegative().nullable(),
|
||||
paused: z.boolean().nullable(),
|
||||
})
|
||||
.strict(),
|
||||
leases: z
|
||||
.array(
|
||||
z
|
||||
.object({ runId: z.string(), attemptId: z.string().nullable(), expired: z.boolean() })
|
||||
.strict()
|
||||
)
|
||||
.nullable(),
|
||||
orchestrator: orchestratorDiagnosticSchema.nullable(),
|
||||
research: z
|
||||
.object({ status: z.enum(['unavailable', 'unknown']), reasons: z.array(z.string()) })
|
||||
.strict(),
|
||||
live: z.literal('disabled'),
|
||||
})
|
||||
.strict();
|
||||
export type MonitoringReadiness = z.infer<typeof monitoringReadinessSchema>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue