97 lines
24 KiB
Plaintext
97 lines
24 KiB
Plaintext
[2026-05-14T18:40:30.135Z] RESULT
|
|
============================================================
|
|
{
|
|
"success": true,
|
|
"output": "Now I have a complete picture. Here's the analysis:\n\n---\n\n## Test Coverage Analysis: `/home/code/infinite`\n\n### Current State\n\n**0 source files. 0 test files. 0% coverage.**\n\nThis project is a runtime configuration for the `agentic-flow` framework. The only testable artifacts are:\n\n| Artifact | Path | Testable Surface |\n|---|---|---|\n| DB Schema | `data/memory/schema.sql` | Constraints, enums, indexes, defaults |\n| Runtime Config | `claude-flow.config.json` | Schema validation, value ranges, cross-field consistency |\n| Package manifest | `package.json` | Dependency resolution |\n\n---\n\n### Gap 1 — SQLite Schema Constraint Enforcement\n\n**Risk: Critical.** The schema defines CHECK constraints and enums that SQLite only enforces at insert/update time. None are verified.\n\nNotable: bug #1947 is already documented in the schema (vector dimension mismatch). A regression test would prevent it from silently recurring.\n\n```js\n// tests/schema/constraints.test.js\nimport Database from 'better-sqlite3';\nimport { readFileSync } from 'fs';\n\ndescribe('memory_entries constraints', () => {\n let db;\n beforeAll(() => {\n db = new Database(':memory:');\n db.exec(readFileSync('data/memory/schema.sql', 'utf8'));\n });\n\n test('rejects invalid type value', () => {\n expect(() =>\n db.prepare(\"INSERT INTO memory_entries (id,key,content,type) VALUES ('1','k','c','invalid')\")\n .run()\n ).toThrow();\n });\n\n test('enforces namespace+key uniqueness', () => {\n db.prepare(\"INSERT INTO memory_entries (id,key,namespace,content) VALUES ('a','dup','ns','x')\").run();\n expect(() =>\n db.prepare(\"INSERT INTO memory_entries (id,key,namespace,content) VALUES ('b','dup','ns','y')\").run()\n ).toThrow(/UNIQUE/);\n });\n\n test('rejects invalid status', () => {\n expect(() =>\n db.prepare(\"INSERT INTO memory_entries (id,key,content,status) VALUES ('2','k2','c','gone')\").run()\n ).toThrow();\n });\n});\n```\n\n---\n\n### Gap 2 — Vector Dimension Consistency (bug #1947 regression guard)\n\n**Risk: Critical.** The schema default `vector_indexes.dimensions = 384` and `claude-flow.config.json` `memory.vectorDimension = 384` must agree. No test catches a drift.\n\n```js\n// tests/schema/vector-dimensions.test.js\nimport Database from 'better-sqlite3';\nimport config from '../../claude-flow.config.json' assert { type: 'json' };\nimport { readFileSync } from 'fs';\n\ndescribe('vector dimension consistency (#1947)', () => {\n let db;\n beforeAll(() => {\n db = new Database(':memory:');\n db.exec(readFileSync('data/memory/schema.sql', 'utf8'));\n });\n\n test('default vector index uses 384 dimensions', () => {\n const row = db.prepare(\"SELECT dimensions FROM vector_indexes WHERE id='default'\").get();\n expect(row.dimensions).toBe(384);\n });\n\n test('patterns index uses 384 dimensions', () => {\n const row = db.prepare(\"SELECT dimensions FROM vector_indexes WHERE id='patterns'\").get();\n expect(row.dimensions).toBe(384);\n });\n\n test('config vectorDimension matches schema default', () => {\n expect(config.memory.vectorDimension).toBe(384);\n });\n});\n```\n\n---\n\n### Gap 3 — Pattern Confidence Bounds\n\n**Risk: High.** The `patterns.confidence` column is typed `REAL DEFAULT 0.5` but has no CHECK constraint — values outside `[0.0, 1.0]` are accepted silently.\n\n```js\n// tests/schema/patterns.test.js\ndescribe('patterns table', () => {\n test('confidence defaults to 0.5', () => {\n db.prepare(`INSERT INTO patterns (id,name,pattern_type,condition,action)\n VALUES ('p1','test','task-routing','.*','noop')`).run();\n const row = db.prepare(\"SELECT confidence FROM patterns WHERE id='p1'\").get();\n expect(row.confidence).toBe(0.5);\n });\n\n test('rejects invalid pattern_type', () => {\n expect(() =>\n db.prepare(`INSERT INTO patterns (id,name,pattern_type,condition,action)\n VALUES ('p2','bad','unknown-type','.*','noop')`).run()\n ).toThrow();\n });\n\n test('pattern_history FK enforced', () => {\n expect(() =>\n db.prepare(`INSERT INTO pattern_history (pattern_id,version,change_type)\n VALUES ('nonexistent',1,'created')`).run()\n ).toThrow(/FOREIGN KEY/);\n });\n});\n\n// Suggested schema fix — add CHECK to catch this at the DB layer:\n// confidence REAL DEFAULT 0.5 CHECK(confidence >= 0.0 AND confidence <= 1.0),\n```\n\n---\n\n### Gap 4 — Runtime Config Validation\n\n**Risk: High.** `claude-flow.config.json` has no validation. Invalid values (negative timeouts, wrong topology strings, port conflicts) are silently accepted.\n\n```js\n// tests/config/schema-validation.test.js\nimport Ajv from 'ajv';\nimport config from '../../claude-flow.config.json' assert { type: 'json' };\n\nconst schema = {\n type: 'object',\n required: ['version', 'agents', 'swarm', 'memory', 'mcp'],\n properties: {\n memory: {\n properties: {\n vectorDimension: { type: 'integer', minimum: 1 },\n backend: { type: 'string', enum: ['hybrid', 'sqlite', 'in-memory'] },\n },\n required: ['vectorDimension', 'backend'],\n },\n swarm: {\n properties: {\n topology: { type: 'string', enum: ['hierarchical', 'mesh', 'ring', 'star'] },\n maxAgents: { type: 'integer', minimum: 1, maximum: 100 },\n },\n },\n agents: {\n properties: {\n maxConcurrent: { type: 'integer', minimum: 1 },\n timeout: { type: 'integer', minimum: 0 },\n },\n },\n mcp: {\n properties: {\n serverPort: { type: 'integer', minimum: 1, maximum: 65535 },\n },\n },\n },\n};\n\ntest('config passes schema validation', () => {\n const ajv = new Ajv();\n expect(ajv.validate(schema, config)).toBe(true);\n});\n\ntest('maxConcurrent matches swarm.maxAgents', () => {\n expect(config.agents.maxConcurrent).toBe(config.swarm.maxAgents);\n});\n```\n\n---\n\n### Gap 5 — Session and Migration State Transitions\n\n**Risk: Medium.** Both `sessions` and `migration_state` tables have status enums with defined lifecycle transitions. No test verifies the enums or that FK cascades behave correctly.\n\n```js\n// tests/schema/sessions.test.js\ndescribe('sessions status enum', () => {\n test('rejects unknown status', () => {\n expect(() =>\n db.prepare(\"INSERT INTO sessions (id,state,status) VALUES ('s1','{}','unknown')\").run()\n ).toThrow();\n });\n\n test('accepts all valid statuses', () => {\n ['active', 'paused', 'completed', 'expired'].forEach((status, i) => {\n expect(() =>\n db.prepare(`INSERT INTO sessions (id,state,status) VALUES ('s${i}','{}','${status}')`).run()\n ).not.toThrow();\n });\n });\n});\n\ndescribe('migration_state transitions', () => {\n test('rejects invalid status', () => {\n expect(() =>\n db.prepare(`INSERT INTO migration_state (id,migration_type,status) VALUES ('m1','v2-to-v3','broken')`).run()\n ).toThrow();\n });\n});\n```\n\n---\n\n### Gap 6 — WAL Mode and PRAGMA Enforcement\n\n**Risk: Medium.** The schema sets `PRAGMA foreign_keys = ON` and `PRAGMA journal_mode = WAL` — but these are session-level in SQLite and must be re-applied on every connection. No integration test verifies they are active.\n\n```js\n// tests/schema/pragmas.test.js\ntest('foreign keys are enforced after schema load', () => {\n const row = db.prepare('PRAGMA foreign_keys').get();\n expect(row.foreign_keys).toBe(1);\n});\n\ntest('WAL journal mode is active', () => {\n const row = db.prepare('PRAGMA journal_mode').get();\n expect(row.journal_mode).toBe('wal');\n});\n```\n\n---\n\n### Setup Required\n\nTo run these tests, add to `package.json`:\n\n```json\n{\n \"scripts\": {\n \"test\": \"jest --runInBand\"\n },\n \"devDependencies\": {\n \"jest\": \"^29\",\n \"better-sqlite3\": \"^9\",\n \"ajv\": \"^8\"\n }\n}\n```\n\n---\n\n### Summary\n\n| Gap | Severity | File to create |\n|---|---|---|\n| Constraint enforcement (type/status enums, UNIQUE) | Critical | `tests/schema/constraints.test.js` |\n| Vector dimension consistency — bug #1947 regression | Critical | `tests/schema/vector-dimensions.test.js` |\n| Pattern confidence bounds + FK | High | `tests/schema/patterns.test.js` |\n| Config schema validation + cross-field consistency | High | `tests/config/schema-validation.test.js` |\n| Session/migration status transitions | Medium | `tests/schema/sessions.test.js` |\n| PRAGMA enforcement per connection | Medium | `tests/schema/pragmas.test.js` |\n\nThe most impactful starting point is the **vector dimension regression test** — it directly guards bug #1947 and would have caught the mismatch at the DB layer before it reached runtime.\n",
|
|
"parsedOutput": {
|
|
"sections": [
|
|
{
|
|
"title": "Test Coverage Analysis: `/home/code/infinite`",
|
|
"content": "\n",
|
|
"level": 2
|
|
},
|
|
{
|
|
"title": "Current State",
|
|
"content": "\n**0 source files. 0 test files. 0% coverage.**\n\nThis project is a runtime configuration for the `agentic-flow` framework. The only testable artifacts are:\n\n| Artifact | Path | Testable Surface |\n|---|---|---|\n| DB Schema | `data/memory/schema.sql` | Constraints, enums, indexes, defaults |\n| Runtime Config | `claude-flow.config.json` | Schema validation, value ranges, cross-field consistency |\n| Package manifest | `package.json` | Dependency resolution |\n\n---\n\n",
|
|
"level": 3
|
|
},
|
|
{
|
|
"title": "Gap 1 — SQLite Schema Constraint Enforcement",
|
|
"content": "\n**Risk: Critical.** The schema defines CHECK constraints and enums that SQLite only enforces at insert/update time. None are verified.\n\nNotable: bug #1947 is already documented in the schema (vector dimension mismatch). A regression test would prevent it from silently recurring.\n\n```js\n// tests/schema/constraints.test.js\nimport Database from 'better-sqlite3';\nimport { readFileSync } from 'fs';\n\ndescribe('memory_entries constraints', () => {\n let db;\n beforeAll(() => {\n db = new Database(':memory:');\n db.exec(readFileSync('data/memory/schema.sql', 'utf8'));\n });\n\n test('rejects invalid type value', () => {\n expect(() =>\n db.prepare(\"INSERT INTO memory_entries (id,key,content,type) VALUES ('1','k','c','invalid')\")\n .run()\n ).toThrow();\n });\n\n test('enforces namespace+key uniqueness', () => {\n db.prepare(\"INSERT INTO memory_entries (id,key,namespace,content) VALUES ('a','dup','ns','x')\").run();\n expect(() =>\n db.prepare(\"INSERT INTO memory_entries (id,key,namespace,content) VALUES ('b','dup','ns','y')\").run()\n ).toThrow(/UNIQUE/);\n });\n\n test('rejects invalid status', () => {\n expect(() =>\n db.prepare(\"INSERT INTO memory_entries (id,key,content,status) VALUES ('2','k2','c','gone')\").run()\n ).toThrow();\n });\n});\n```\n\n---\n\n",
|
|
"level": 3
|
|
},
|
|
{
|
|
"title": "Gap 2 — Vector Dimension Consistency (bug #1947 regression guard)",
|
|
"content": "\n**Risk: Critical.** The schema default `vector_indexes.dimensions = 384` and `claude-flow.config.json` `memory.vectorDimension = 384` must agree. No test catches a drift.\n\n```js\n// tests/schema/vector-dimensions.test.js\nimport Database from 'better-sqlite3';\nimport config from '../../claude-flow.config.json' assert { type: 'json' };\nimport { readFileSync } from 'fs';\n\ndescribe('vector dimension consistency (#1947)', () => {\n let db;\n beforeAll(() => {\n db = new Database(':memory:');\n db.exec(readFileSync('data/memory/schema.sql', 'utf8'));\n });\n\n test('default vector index uses 384 dimensions', () => {\n const row = db.prepare(\"SELECT dimensions FROM vector_indexes WHERE id='default'\").get();\n expect(row.dimensions).toBe(384);\n });\n\n test('patterns index uses 384 dimensions', () => {\n const row = db.prepare(\"SELECT dimensions FROM vector_indexes WHERE id='patterns'\").get();\n expect(row.dimensions).toBe(384);\n });\n\n test('config vectorDimension matches schema default', () => {\n expect(config.memory.vectorDimension).toBe(384);\n });\n});\n```\n\n---\n\n",
|
|
"level": 3
|
|
},
|
|
{
|
|
"title": "Gap 3 — Pattern Confidence Bounds",
|
|
"content": "\n**Risk: High.** The `patterns.confidence` column is typed `REAL DEFAULT 0.5` but has no CHECK constraint — values outside `[0.0, 1.0]` are accepted silently.\n\n```js\n// tests/schema/patterns.test.js\ndescribe('patterns table', () => {\n test('confidence defaults to 0.5', () => {\n db.prepare(`INSERT INTO patterns (id,name,pattern_type,condition,action)\n VALUES ('p1','test','task-routing','.*','noop')`).run();\n const row = db.prepare(\"SELECT confidence FROM patterns WHERE id='p1'\").get();\n expect(row.confidence).toBe(0.5);\n });\n\n test('rejects invalid pattern_type', () => {\n expect(() =>\n db.prepare(`INSERT INTO patterns (id,name,pattern_type,condition,action)\n VALUES ('p2','bad','unknown-type','.*','noop')`).run()\n ).toThrow();\n });\n\n test('pattern_history FK enforced', () => {\n expect(() =>\n db.prepare(`INSERT INTO pattern_history (pattern_id,version,change_type)\n VALUES ('nonexistent',1,'created')`).run()\n ).toThrow(/FOREIGN KEY/);\n });\n});\n\n// Suggested schema fix — add CHECK to catch this at the DB layer:\n// confidence REAL DEFAULT 0.5 CHECK(confidence >= 0.0 AND confidence <= 1.0),\n```\n\n---\n\n",
|
|
"level": 3
|
|
},
|
|
{
|
|
"title": "Gap 4 — Runtime Config Validation",
|
|
"content": "\n**Risk: High.** `claude-flow.config.json` has no validation. Invalid values (negative timeouts, wrong topology strings, port conflicts) are silently accepted.\n\n```js\n// tests/config/schema-validation.test.js\nimport Ajv from 'ajv';\nimport config from '../../claude-flow.config.json' assert { type: 'json' };\n\nconst schema = {\n type: 'object',\n required: ['version', 'agents', 'swarm', 'memory', 'mcp'],\n properties: {\n memory: {\n properties: {\n vectorDimension: { type: 'integer', minimum: 1 },\n backend: { type: 'string', enum: ['hybrid', 'sqlite', 'in-memory'] },\n },\n required: ['vectorDimension', 'backend'],\n },\n swarm: {\n properties: {\n topology: { type: 'string', enum: ['hierarchical', 'mesh', 'ring', 'star'] },\n maxAgents: { type: 'integer', minimum: 1, maximum: 100 },\n },\n },\n agents: {\n properties: {\n maxConcurrent: { type: 'integer', minimum: 1 },\n timeout: { type: 'integer', minimum: 0 },\n },\n },\n mcp: {\n properties: {\n serverPort: { type: 'integer', minimum: 1, maximum: 65535 },\n },\n },\n },\n};\n\ntest('config passes schema validation', () => {\n const ajv = new Ajv();\n expect(ajv.validate(schema, config)).toBe(true);\n});\n\ntest('maxConcurrent matches swarm.maxAgents', () => {\n expect(config.agents.maxConcurrent).toBe(config.swarm.maxAgents);\n});\n```\n\n---\n\n",
|
|
"level": 3
|
|
},
|
|
{
|
|
"title": "Gap 5 — Session and Migration State Transitions",
|
|
"content": "\n**Risk: Medium.** Both `sessions` and `migration_state` tables have status enums with defined lifecycle transitions. No test verifies the enums or that FK cascades behave correctly.\n\n```js\n// tests/schema/sessions.test.js\ndescribe('sessions status enum', () => {\n test('rejects unknown status', () => {\n expect(() =>\n db.prepare(\"INSERT INTO sessions (id,state,status) VALUES ('s1','{}','unknown')\").run()\n ).toThrow();\n });\n\n test('accepts all valid statuses', () => {\n ['active', 'paused', 'completed', 'expired'].forEach((status, i) => {\n expect(() =>\n db.prepare(`INSERT INTO sessions (id,state,status) VALUES ('s${i}','{}','${status}')`).run()\n ).not.toThrow();\n });\n });\n});\n\ndescribe('migration_state transitions', () => {\n test('rejects invalid status', () => {\n expect(() =>\n db.prepare(`INSERT INTO migration_state (id,migration_type,status) VALUES ('m1','v2-to-v3','broken')`).run()\n ).toThrow();\n });\n});\n```\n\n---\n\n",
|
|
"level": 3
|
|
},
|
|
{
|
|
"title": "Gap 6 — WAL Mode and PRAGMA Enforcement",
|
|
"content": "\n**Risk: Medium.** The schema sets `PRAGMA foreign_keys = ON` and `PRAGMA journal_mode = WAL` — but these are session-level in SQLite and must be re-applied on every connection. No integration test verifies they are active.\n\n```js\n// tests/schema/pragmas.test.js\ntest('foreign keys are enforced after schema load', () => {\n const row = db.prepare('PRAGMA foreign_keys').get();\n expect(row.foreign_keys).toBe(1);\n});\n\ntest('WAL journal mode is active', () => {\n const row = db.prepare('PRAGMA journal_mode').get();\n expect(row.journal_mode).toBe('wal');\n});\n```\n\n---\n\n",
|
|
"level": 3
|
|
},
|
|
{
|
|
"title": "Setup Required",
|
|
"content": "\nTo run these tests, add to `package.json`:\n\n```json\n{\n \"scripts\": {\n \"test\": \"jest --runInBand\"\n },\n \"devDependencies\": {\n \"jest\": \"^29\",\n \"better-sqlite3\": \"^9\",\n \"ajv\": \"^8\"\n }\n}\n```\n\n---\n\n",
|
|
"level": 3
|
|
},
|
|
{
|
|
"title": "Summary",
|
|
"content": "| Gap | Severity | File to create |\n|---|---|---|\n| Constraint enforcement (type/status enums, UNIQUE) | Critical | `tests/schema/constraints.test.js` |\n| Vector dimension consistency — bug #1947 regression | Critical | `tests/schema/vector-dimensions.test.js` |\n| Pattern confidence bounds + FK | High | `tests/schema/patterns.test.js` |\n| Config schema validation + cross-field consistency | High | `tests/config/schema-validation.test.js` |\n| Session/migration status transitions | Medium | `tests/schema/sessions.test.js` |\n| PRAGMA enforcement per connection | Medium | `tests/schema/pragmas.test.js` |\n\nThe most impactful starting point is the **vector dimension regression test** — it directly guards bug #1947 and would have caught the mismatch at the DB layer before it reached runtime.",
|
|
"level": 3
|
|
}
|
|
],
|
|
"codeBlocks": [
|
|
{
|
|
"language": "js",
|
|
"code": "// tests/schema/constraints.test.js\nimport Database from 'better-sqlite3';\nimport { readFileSync } from 'fs';\n\ndescribe('memory_entries constraints', () => {\n let db;\n beforeAll(() => {\n db = new Database(':memory:');\n db.exec(readFileSync('data/memory/schema.sql', 'utf8'));\n });\n\n test('rejects invalid type value', () => {\n expect(() =>\n db.prepare(\"INSERT INTO memory_entries (id,key,content,type) VALUES ('1','k','c','invalid')\")\n .run()\n ).toThrow();\n });\n\n test('enforces namespace+key uniqueness', () => {\n db.prepare(\"INSERT INTO memory_entries (id,key,namespace,content) VALUES ('a','dup','ns','x')\").run();\n expect(() =>\n db.prepare(\"INSERT INTO memory_entries (id,key,namespace,content) VALUES ('b','dup','ns','y')\").run()\n ).toThrow(/UNIQUE/);\n });\n\n test('rejects invalid status', () => {\n expect(() =>\n db.prepare(\"INSERT INTO memory_entries (id,key,content,status) VALUES ('2','k2','c','gone')\").run()\n ).toThrow();\n });\n});"
|
|
},
|
|
{
|
|
"language": "js",
|
|
"code": "// tests/schema/vector-dimensions.test.js\nimport Database from 'better-sqlite3';\nimport config from '../../claude-flow.config.json' assert { type: 'json' };\nimport { readFileSync } from 'fs';\n\ndescribe('vector dimension consistency (#1947)', () => {\n let db;\n beforeAll(() => {\n db = new Database(':memory:');\n db.exec(readFileSync('data/memory/schema.sql', 'utf8'));\n });\n\n test('default vector index uses 384 dimensions', () => {\n const row = db.prepare(\"SELECT dimensions FROM vector_indexes WHERE id='default'\").get();\n expect(row.dimensions).toBe(384);\n });\n\n test('patterns index uses 384 dimensions', () => {\n const row = db.prepare(\"SELECT dimensions FROM vector_indexes WHERE id='patterns'\").get();\n expect(row.dimensions).toBe(384);\n });\n\n test('config vectorDimension matches schema default', () => {\n expect(config.memory.vectorDimension).toBe(384);\n });\n});"
|
|
},
|
|
{
|
|
"language": "js",
|
|
"code": "// tests/schema/patterns.test.js\ndescribe('patterns table', () => {\n test('confidence defaults to 0.5', () => {\n db.prepare(`INSERT INTO patterns (id,name,pattern_type,condition,action)\n VALUES ('p1','test','task-routing','.*','noop')`).run();\n const row = db.prepare(\"SELECT confidence FROM patterns WHERE id='p1'\").get();\n expect(row.confidence).toBe(0.5);\n });\n\n test('rejects invalid pattern_type', () => {\n expect(() =>\n db.prepare(`INSERT INTO patterns (id,name,pattern_type,condition,action)\n VALUES ('p2','bad','unknown-type','.*','noop')`).run()\n ).toThrow();\n });\n\n test('pattern_history FK enforced', () => {\n expect(() =>\n db.prepare(`INSERT INTO pattern_history (pattern_id,version,change_type)\n VALUES ('nonexistent',1,'created')`).run()\n ).toThrow(/FOREIGN KEY/);\n });\n});\n\n// Suggested schema fix — add CHECK to catch this at the DB layer:\n// confidence REAL DEFAULT 0.5 CHECK(confidence >= 0.0 AND confidence <= 1.0),"
|
|
},
|
|
{
|
|
"language": "js",
|
|
"code": "// tests/config/schema-validation.test.js\nimport Ajv from 'ajv';\nimport config from '../../claude-flow.config.json' assert { type: 'json' };\n\nconst schema = {\n type: 'object',\n required: ['version', 'agents', 'swarm', 'memory', 'mcp'],\n properties: {\n memory: {\n properties: {\n vectorDimension: { type: 'integer', minimum: 1 },\n backend: { type: 'string', enum: ['hybrid', 'sqlite', 'in-memory'] },\n },\n required: ['vectorDimension', 'backend'],\n },\n swarm: {\n properties: {\n topology: { type: 'string', enum: ['hierarchical', 'mesh', 'ring', 'star'] },\n maxAgents: { type: 'integer', minimum: 1, maximum: 100 },\n },\n },\n agents: {\n properties: {\n maxConcurrent: { type: 'integer', minimum: 1 },\n timeout: { type: 'integer', minimum: 0 },\n },\n },\n mcp: {\n properties: {\n serverPort: { type: 'integer', minimum: 1, maximum: 65535 },\n },\n },\n },\n};\n\ntest('config passes schema validation', () => {\n const ajv = new Ajv();\n expect(ajv.validate(schema, config)).toBe(true);\n});\n\ntest('maxConcurrent matches swarm.maxAgents', () => {\n expect(config.agents.maxConcurrent).toBe(config.swarm.maxAgents);\n});"
|
|
},
|
|
{
|
|
"language": "js",
|
|
"code": "// tests/schema/sessions.test.js\ndescribe('sessions status enum', () => {\n test('rejects unknown status', () => {\n expect(() =>\n db.prepare(\"INSERT INTO sessions (id,state,status) VALUES ('s1','{}','unknown')\").run()\n ).toThrow();\n });\n\n test('accepts all valid statuses', () => {\n ['active', 'paused', 'completed', 'expired'].forEach((status, i) => {\n expect(() =>\n db.prepare(`INSERT INTO sessions (id,state,status) VALUES ('s${i}','{}','${status}')`).run()\n ).not.toThrow();\n });\n });\n});\n\ndescribe('migration_state transitions', () => {\n test('rejects invalid status', () => {\n expect(() =>\n db.prepare(`INSERT INTO migration_state (id,migration_type,status) VALUES ('m1','v2-to-v3','broken')`).run()\n ).toThrow();\n });\n});"
|
|
},
|
|
{
|
|
"language": "js",
|
|
"code": "// tests/schema/pragmas.test.js\ntest('foreign keys are enforced after schema load', () => {\n const row = db.prepare('PRAGMA foreign_keys').get();\n expect(row.foreign_keys).toBe(1);\n});\n\ntest('WAL journal mode is active', () => {\n const row = db.prepare('PRAGMA journal_mode').get();\n expect(row.journal_mode).toBe('wal');\n});"
|
|
},
|
|
{
|
|
"language": "json",
|
|
"code": "{\n \"scripts\": {\n \"test\": \"jest --runInBand\"\n },\n \"devDependencies\": {\n \"jest\": \"^29\",\n \"better-sqlite3\": \"^9\",\n \"ajv\": \"^8\"\n }\n}"
|
|
}
|
|
]
|
|
},
|
|
"durationMs": 128965,
|
|
"model": "sonnet",
|
|
"sandboxMode": "permissive",
|
|
"workerType": "testgaps",
|
|
"timestamp": "2026-05-14T18:40:30.135Z",
|
|
"executionId": "testgaps_1778783901170_4mrg3s"
|
|
}
|