task-store-stress.test.mjs
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠ breaking
10 days ago
| 1 | /** |
| 2 | * Tier 4 — STRESS: list cap at MAX_TASK_SUMMARIES with truncated flag. |
| 3 | * |
| 4 | * @see docs/TASK-STORE-CONTRACT-2G.md §9 |
| 5 | */ |
| 6 | import { describe, it, beforeEach, afterEach } from 'node:test'; |
| 7 | import assert from 'node:assert/strict'; |
| 8 | import fs from 'node:fs'; |
| 9 | import path from 'node:path'; |
| 10 | import { fileURLToPath } from 'node:url'; |
| 11 | import { listTasks, MAX_TASK_SUMMARIES } from '../lib/task/task-store.mjs'; |
| 12 | import { saveFlowStore } from '../lib/flow/flow-store.mjs'; |
| 13 | |
| 14 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 15 | const tmpRoot = path.join(__dirname, 'fixtures', 'tmp-task-stress'); |
| 16 | |
| 17 | describe('Task store — stress', () => { |
| 18 | const dataDir = path.join(tmpRoot, 'data'); |
| 19 | const vaultId = 'default'; |
| 20 | |
| 21 | beforeEach(() => { |
| 22 | fs.rmSync(tmpRoot, { recursive: true, force: true }); |
| 23 | fs.mkdirSync(dataDir, { recursive: true }); |
| 24 | const tasks = []; |
| 25 | for (let i = 0; i < MAX_TASK_SUMMARIES; i += 1) { |
| 26 | const id = `task_stress_${String(i).padStart(6, '0')}`; |
| 27 | tasks.push({ |
| 28 | schema: 'knowtation.task/v0', |
| 29 | task_id: id, |
| 30 | kind: 'personal', |
| 31 | scope: 'personal', |
| 32 | status: 'pending', |
| 33 | title: id, |
| 34 | workspace_id: 'ws-personal', |
| 35 | due_at: `2026-06-${String((i % 28) + 1).padStart(2, '0')}T00:00:00Z`, |
| 36 | assignee_ref: null, |
| 37 | assigner_ref: null, |
| 38 | run_ref: null, |
| 39 | artifact_links: [], |
| 40 | created: '2026-06-01T00:00:00Z', |
| 41 | updated: '2026-06-01T00:00:00Z', |
| 42 | truncated: false, |
| 43 | }); |
| 44 | } |
| 45 | saveFlowStore(dataDir, { |
| 46 | vaults: { |
| 47 | [vaultId]: { flows: [], steps: [], runs: [], candidates: [], projections: [], tasks }, |
| 48 | }, |
| 49 | }); |
| 50 | }); |
| 51 | |
| 52 | afterEach(() => { |
| 53 | fs.rmSync(tmpRoot, { recursive: true, force: true }); |
| 54 | }); |
| 55 | |
| 56 | it('list returns MAX_TASK_SUMMARIES rows with truncated:true when capped', () => { |
| 57 | const result = listTasks(dataDir, vaultId, { |
| 58 | filterScopes: new Set(['personal']), |
| 59 | effectiveScope: 'personal', |
| 60 | limit: MAX_TASK_SUMMARIES - 1, |
| 61 | }); |
| 62 | assert.equal(result.tasks.length, MAX_TASK_SUMMARIES - 1); |
| 63 | assert.equal(result.truncated, true); |
| 64 | }); |
| 65 | |
| 66 | it('list at exact cap is not truncated', () => { |
| 67 | const result = listTasks(dataDir, vaultId, { |
| 68 | filterScopes: new Set(['personal']), |
| 69 | effectiveScope: 'personal', |
| 70 | limit: MAX_TASK_SUMMARIES, |
| 71 | }); |
| 72 | assert.equal(result.tasks.length, MAX_TASK_SUMMARIES); |
| 73 | assert.equal(result.truncated, false); |
| 74 | }); |
| 75 | }); |
File History
1 commit
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠
10 days ago