// Hand-written JSON Schema mirroring GeneratedModelLean from schema.ts. // // LM Studio's response_format requires `json_schema` for our model; this is // the schema we hand the server. We mirror the Zod definition exactly so // that constrained generation produces something Zod can also validate. // // Keep this in sync with src/generate/schema.ts. export const generatedModelLeanJsonSchema = { type: 'object', additionalProperties: false, properties: { systemOfInterestId: { type: 'string' }, blocks: { type: 'array', items: { type: 'object', additionalProperties: false, properties: { id: { type: 'string', minLength: 1 }, label: { type: 'string', minLength: 1 }, kind: { type: 'string', enum: ['system', 'actor', 'block'] }, properties: { type: 'array', items: { type: 'object', additionalProperties: false, properties: { name: { type: 'string', minLength: 1 }, type: { type: 'object', // Tagged union by `kind`. Any kind is accepted; for `enum` we also // require `values`. The model occasionally adds extra fields; allow // them rather than failing the whole response. properties: { kind: { type: 'string', enum: ['string', 'number', 'boolean', 'enum'] }, values: { type: 'array', items: { type: 'string' } }, }, required: ['kind'], }, }, required: ['name', 'type'], }, }, confidence: { type: 'number', minimum: 0, maximum: 1 }, }, required: ['id', 'label', 'kind', 'confidence'], }, }, associations: { type: 'array', items: { type: 'object', additionalProperties: false, properties: { id: { type: 'string', minLength: 1 }, fromBlockId: { type: 'string', minLength: 1 }, toBlockId: { type: 'string', minLength: 1 }, label: { type: 'string' }, kind: { type: 'string', enum: ['association', 'composition', 'aggregation', 'generalization', 'constraintApplies'], }, confidence: { type: 'number', minimum: 0, maximum: 1 }, }, required: ['id', 'fromBlockId', 'toBlockId', 'kind', 'confidence'], }, }, constraints: { type: 'array', items: { type: 'object', additionalProperties: false, properties: { id: { type: 'string', minLength: 1 }, label: { type: 'string', minLength: 1 }, expression: { type: 'string' }, appliesTo: { type: 'array', items: { type: 'string' } }, confidence: { type: 'number', minimum: 0, maximum: 1 }, }, required: ['id', 'label', 'confidence'], }, }, requirements: { type: 'array', items: { type: 'object', additionalProperties: false, properties: { id: { type: 'string', minLength: 1 }, tag: { type: 'string', minLength: 1 }, text: { type: 'string', minLength: 1 }, satisfiedBy: { type: 'array', items: { type: 'string' } }, confidence: { type: 'number', minimum: 0, maximum: 1 }, }, required: ['id', 'tag', 'text', 'confidence'], }, }, overallConfidence: { type: 'number', minimum: 0, maximum: 1 }, notes: { type: 'string' }, }, required: ['blocks', 'overallConfidence'], } as const;