moving
Some checks failed
Installer Smoke / installer-smoke (push) Has been cancelled

This commit is contained in:
Oleg Maslov
2026-09-02 10:10:29 +02:00
commit 0c3e2ead3b
3841 changed files with 970576 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
import { describe, it, expect } from 'vitest';
import { Ontology, validateEntity } from '../src/mind/ontology.js';
describe('Ontology Grounding', () => {
function makeOntology(): Ontology {
const ont = new Ontology();
ont.define('Person', {
required: ['name', 'email'],
optional: ['age', 'bio'],
});
ont.define('Project', {
required: ['title'],
optional: ['description', 'status'],
});
return ont;
}
it('valid entity passes validation', () => {
const ont = makeOntology();
const result = validateEntity(ont, {
type: 'Person',
properties: { name: 'Alice', email: 'alice@example.com', age: 30 },
});
expect(result.valid).toBe(true);
expect(result.issues).toHaveLength(0);
});
it('unknown type fails with issue', () => {
const ont = makeOntology();
const result = validateEntity(ont, {
type: 'Animal',
properties: { species: 'cat' },
});
expect(result.valid).toBe(false);
expect(result.issues).toContain('Unknown entity type: Animal');
});
it('unknown/unexpected properties get flagged', () => {
const ont = makeOntology();
const result = validateEntity(ont, {
type: 'Person',
properties: { name: 'Bob', email: 'bob@test.com', favoriteColor: 'blue' },
});
expect(result.valid).toBe(false);
expect(result.issues).toContain('Unknown property: favoriteColor');
});
it('missing required = invalid, missing optional = still valid', () => {
const ont = makeOntology();
// Missing required 'email'
const missing = validateEntity(ont, {
type: 'Person',
properties: { name: 'Charlie' },
});
expect(missing.valid).toBe(false);
expect(missing.issues).toContain('Missing required property: email');
// All required present, no optional — still valid
const minimal = validateEntity(ont, {
type: 'Project',
properties: { title: 'Waggle' },
});
expect(minimal.valid).toBe(true);
expect(minimal.issues).toHaveLength(0);
});
});