The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(storage-schema): cover per-crate owner grouping in lint fixtures
Steven Enamakeld75451660dc3
diff --git a/scripts/__tests__/check-storage-schema.test.mjs b/scripts/__tests__/check-storage-schema.test.mjsindex da5ecc2244..7d67d56cc6 100644--- a/scripts/__tests__/check-storage-schema.test.mjs+++ b/scripts/__tests__/check-storage-schema.test.mjs@@ -9,39 +9,40 @@ const collection = (name, extra = {}) => ({...extra,});-test('a well-formed schema is clean', () => {+test('a well-formed per-crate schema is clean', () => {const dump = {- collections: [- collection('cron.jobs', {+ owners: [{+ crate: 'tinyflows-scheduler',+ collections: [collection('cron.jobs', {indexes: [{ name: 'by_time', fields: ['next_run_ms'], unique: false }],ttl_field: 'expires_ms',search: { fields: ['name', 'description'] },- }),- ],+ })],+ }],};assert.deepEqual(lint(dump), []);});test('collection names must be <owner>.<entity> in snake_case', () => {const problems = lint({- collections: [+ owners: [{ crate: 'openhuman', collections: [collection('jobs'),collection('Cron.Jobs'),collection('flows.runs-v2'),- ],+ ] }],});assert.equal(problems.length, 3, problems.join('\n'));});test('known legacy migration collections remain inventoried', () => {assert.deepEqual(lint({- collections: [collection('remix_markers'), collection('tinymemes_documents')],+ owners: [{ crate: 'openhuman', collections: [collection('remix_markers'), collection('tinymemes_documents')] }],}), []);});-test('duplicate collection and index names are refused', () => {+test('duplicate collection and index names are refused within one crate', () => {const problems = lint({- collections: [+ owners: [{ crate: 'tinyflows-scheduler', collections: [collection('cron.jobs', {indexes: [{ name: 'by_time', fields: ['created_ms'] },@@ -49,7 +50,7 @@ test('duplicate collection and index names are refused', () => {],}),collection('cron.jobs'),- ],+ ] }],});assert.ok(problems.some(p => p.includes('collection "cron.jobs" is declared more than once')));assert.ok(problems.some(p => p.includes('index name "by_time" is empty or duplicated')));@@ -57,34 +58,34 @@ test('duplicate collection and index names are refused', () => {test('indexed time fields must be epoch milliseconds', () => {const problems = lint({- collections: [collection('cron.jobs', {+ owners: [{ crate: 'tinyflows-scheduler', collections: [collection('cron.jobs', {indexes: [{ name: 'by_time', fields: ['created_at', 'next_run_ms'] }],ttl_field: 'expires_at',- })],+ })] }],});assert.equal(problems.length, 2);assert.match(problems[0], /created_at/);assert.match(problems[1], /expires_at/);});-test('the rendering is stable and inventories CollectionSpecs by owner namespace', () => {+test('the rendering keeps CollectionSpecs grouped by their declaring crate', () => {const dump = {- collections: [- collection('a.y', {+ owners: [+ { crate: 'tinyagents-session', collections: [collection('a.y', {indexes: [{ name: 'by_created', fields: ['created_ms'], unique: true }],search: { fields: ['title'] },- }),- collection('b.x'),- collection('a.z', { ttl_field: 'expires_ms' }),- collection('remix_markers'),+ }), collection('a.z', { ttl_field: 'expires_ms' })] },+ { crate: 'openhuman', collections: [collection('a.y'), collection('remix_markers')] },+ { crate: 'tinyflows', collections: [collection('b.x')] },],};const text = render(dump);- assert.ok(text.indexOf('`a.y`') < text.indexOf('`b.x`'));- assert.ok(text.indexOf('`a.y`') < text.indexOf('`a.z`'));- assert.match(text, /## a\n/);- assert.match(text, /## b\n/);- assert.match(text, /## legacy \(unqualified names\)\n/);+ assert.ok(text.indexOf('## openhuman') < text.indexOf('## tinyagents-session'));+ assert.ok(text.indexOf('## tinyagents-session') < text.indexOf('## tinyflows'));+ assert.match(text, /## tinyagents-session\n/);+ assert.match(text, /## tinyflows\n/);+ assert.match(text, /## openhuman\n/);+ assert.equal((text.match(/\| `a\.y` \|/g) ?? []).length, 2);assert.doesNotMatch(text, /composed registry/i);assert.match(text, /by_created/);assert.match(text, /`expires_ms`/);@@ -104,9 +105,9 @@ test('the dump example builds with web3 by default and with an override that keeenv: { STORAGE_SCHEMA_FEATURES: 'core-product' },run: (_cmd, argv) => {args = argv;- return { status: 0, stdout: '{"collections":[]}', stderr: '' };+ return { status: 0, stdout: '{"owners":[]}', stderr: '' };},});- assert.deepEqual(dump, { collections: [] });+ assert.deepEqual(dump, { owners: [] });assert.equal(args[args.indexOf('--features') + 1], product);});