Files
Socrates/phase-0/src/generate/json-schema.ts
dtoro f1c4566576 Initial commit — design docs + Phase 0 validation harness
Sets up the Socrata project repo with:

docs/ — strategy and design documents
  - idea.md: full product vision
  - implementation-plan.md: Phase 0 + Phase 1 MVP plan
  - phase-0-validation.md: 2-week validation experiment strategy
  - phase-0-plan.md: concrete Phase 0 build plan
  - phase-0-results.md: Phase 0 gate outcome — GO for MVP
  - sysml-modeling.md: metamodel + SE discipline + validation rules
  - socrates.md: agent character, surfaces, modes, prompts, lifecycle
  - sync.md: bidirectional text↔diagram sync engineering
  - design-source/: HTML/CSS/JS handoff bundle from Claude Design

phase-0/ — validated harness (CLI, no UI, no DB)
  - LM Studio (local OpenAI-compatible) generation + detection + judge
  - PlantUML rendering for SysML model visualization
  - 10-seed corpus (8 working + 2 holdouts)
  - 5 corpus runs with iteration history in reports/
  - Final gate: 10/10 pass, mean 4.32/5, holdouts validated

Phase 1 MVP scope and milestones documented in implementation-plan.md.
2026-04-28 22:07:38 +02:00

104 lines
3.6 KiB
TypeScript

// 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;