task-loop-store-e2e.test.mjs
sha256:baa800aedf841dbf32081aa7b2befa288ac33dfc7175ac55014c55c4d8c742f9
docs: move durable-auth freeze/evidence to local developmen…
Human
10 days ago
| 1 | /** |
| 2 | * Tier 3 — E2E: School-trip fixture graph seed → instance task with loop_ref. |
| 3 | * |
| 4 | * @see docs/TASK-LOOP-STORE-CONTRACT-2G-c.md §6 — I-T-LOOP-01 |
| 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 { getRepoRoot } from '../lib/repo-root.mjs'; |
| 12 | import { listTaskLoops } from '../lib/task/task-loop-store.mjs'; |
| 13 | import { listTasks, getTask } from '../lib/task/task-store.mjs'; |
| 14 | |
| 15 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 16 | const tmpRoot = path.join(__dirname, 'fixtures', 'tmp-task-loop-e2e'); |
| 17 | const loopStarterDir = path.join(getRepoRoot(), 'task-loops/starter'); |
| 18 | const graphStarterDir = path.join(getRepoRoot(), 'orchestrator-graphs/starter'); |
| 19 | const instancesDir = path.join(getRepoRoot(), 'task-loops/starter/instances'); |
| 20 | const vaultId = 'vault-loop-e2e'; |
| 21 | |
| 22 | describe('Task loop store — e2e school-trip graph', () => { |
| 23 | beforeEach(() => { |
| 24 | fs.rmSync(tmpRoot, { recursive: true, force: true }); |
| 25 | fs.mkdirSync(tmpRoot, { recursive: true }); |
| 26 | }); |
| 27 | |
| 28 | afterEach(() => { |
| 29 | fs.rmSync(tmpRoot, { recursive: true, force: true }); |
| 30 | }); |
| 31 | |
| 32 | it('seeds loops + graph + instance; getTask returns loop_ref and occurrence_key', () => { |
| 33 | const dataDir = path.join(tmpRoot, 'data'); |
| 34 | fs.mkdirSync(dataDir, { recursive: true }); |
| 35 | |
| 36 | const loopList = listTaskLoops(dataDir, vaultId, { |
| 37 | visibleScopes: new Set(['personal']), |
| 38 | filterScopes: new Set(['personal']), |
| 39 | effectiveScope: 'personal', |
| 40 | starterDir: loopStarterDir, |
| 41 | graphsDir: graphStarterDir, |
| 42 | instancesDir, |
| 43 | }); |
| 44 | |
| 45 | assert.equal(loopList.loops.length, 6); |
| 46 | assert.ok(loopList.loops.some((l) => l.loop_id === 'loop_school_trip')); |
| 47 | |
| 48 | const taskList = listTasks(dataDir, vaultId, { |
| 49 | visibleScopes: new Set(['personal']), |
| 50 | filterScopes: new Set(['personal']), |
| 51 | effectiveScope: 'personal', |
| 52 | loopRef: 'loop_school_trip', |
| 53 | starterDir: instancesDir, |
| 54 | }); |
| 55 | |
| 56 | assert.equal(taskList.tasks.length, 1); |
| 57 | assert.equal(taskList.tasks[0].task_id, 'task_school_trip_2026_w25'); |
| 58 | |
| 59 | const task = getTask(dataDir, vaultId, 'task_school_trip_2026_w25', { |
| 60 | visibleScopes: new Set(['personal']), |
| 61 | starterDir: instancesDir, |
| 62 | }); |
| 63 | |
| 64 | assert.ok(task); |
| 65 | assert.equal(task.loop_ref, 'loop_school_trip'); |
| 66 | assert.equal(task.occurrence_key, '2026-W25'); |
| 67 | assert.equal(task.run_ref, null); |
| 68 | }); |
| 69 | }); |
File History
1 commit
sha256:baa800aedf841dbf32081aa7b2befa288ac33dfc7175ac55014c55c4d8c742f9
docs: move durable-auth freeze/evidence to local developmen…
Human
10 days ago