feat(FN-2383): persist task priority across core storage

- Add task-priority contract, normalization helpers, and exports in @fusion/core types/index
- Store task priority in SQLite and migrate existing databases with default values
- Update task store behavior and sorting tests to preserve and order by persisted priority
- Add migration/regression coverage for archived tasks and refresh storage/task-management docs
This commit is contained in:
Fusion
2026-04-24 03:48:37 -07:00
committed by gsxdsm
parent a07cb53e1d
commit 52168d7f2c
18 changed files with 387 additions and 30 deletions

View File

@@ -1,5 +1,6 @@
import { describe, it, expect, beforeEach, afterEach } from "vitest";
import { TaskStore } from "../store.js";
import { sortTasksByPriorityThenAgeAndId } from "../task-priority.js";
import { rm } from "node:fs/promises";
import { join } from "node:path";
import { mkdtempSync } from "node:fs";
@@ -52,4 +53,16 @@ describe("TaskStore.listTasks() sort order", () => {
expect(nums[i]).toBeGreaterThan(nums[i - 1]);
}
});
it("provides deterministic helper ordering by priority then age then id", () => {
const sorted = sortTasksByPriorityThenAgeAndId([
{ id: "FN-010", createdAt: "2026-01-02T00:00:00Z", priority: "normal" },
{ id: "FN-001", createdAt: "2026-01-01T00:00:00Z", priority: "high" },
{ id: "FN-002", createdAt: "2026-01-01T00:00:00Z", priority: "high" },
{ id: "FN-003", createdAt: "2026-01-01T00:00:00Z" },
{ id: "FN-004", createdAt: "2026-01-01T00:00:00Z", priority: "urgent" },
]);
expect(sorted.map((task) => task.id)).toEqual(["FN-004", "FN-001", "FN-002", "FN-003", "FN-010"]);
});
});

View File

@@ -51,7 +51,7 @@ describe("TaskStore task documents", () => {
expect(tableNames.has("task_documents")).toBe(true);
expect(tableNames.has("task_document_revisions")).toBe(true);
expect(db.getSchemaVersion()).toBe(42);
expect(db.getSchemaVersion()).toBe(43);
const index = db
.prepare(