feat(FN-1982): merge fusion/fn-1982
This commit is contained in:
@@ -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(36);
|
||||
expect(db.getSchemaVersion()).toBe(37);
|
||||
|
||||
const index = db
|
||||
.prepare(
|
||||
|
||||
@@ -46,8 +46,8 @@ describe("board", () => {
|
||||
expect(canTransition("triage", "in-progress")).toBe(false);
|
||||
// todo cannot skip to in-review
|
||||
expect(canTransition("todo", "in-review")).toBe(false);
|
||||
// in-progress cannot skip to done
|
||||
expect(canTransition("in-progress", "done")).toBe(false);
|
||||
// Note: in-progress can transition to done for mission validation tasks
|
||||
// so we don't test that case here
|
||||
});
|
||||
});
|
||||
|
||||
@@ -75,7 +75,7 @@ describe("board", () => {
|
||||
});
|
||||
|
||||
it("returns correct transitions for in-progress", () => {
|
||||
expect(getValidTransitions("in-progress")).toEqual(["in-review", "todo", "triage"]);
|
||||
expect(getValidTransitions("in-progress")).toEqual(["in-review", "todo", "triage", "done"]);
|
||||
});
|
||||
|
||||
it("returns correct transitions for in-review", () => {
|
||||
|
||||
@@ -119,7 +119,7 @@ describe("Database", () => {
|
||||
});
|
||||
|
||||
it("seeds schema version", () => {
|
||||
expect(db.getSchemaVersion()).toBe(36);
|
||||
expect(db.getSchemaVersion()).toBe(37);
|
||||
});
|
||||
|
||||
it("seeds lastModified", () => {
|
||||
@@ -142,7 +142,7 @@ describe("Database", () => {
|
||||
|
||||
it("is idempotent - calling init() twice does not fail", () => {
|
||||
expect(() => db.init()).not.toThrow();
|
||||
expect(db.getSchemaVersion()).toBe(36);
|
||||
expect(db.getSchemaVersion()).toBe(37);
|
||||
});
|
||||
|
||||
it("does not overwrite existing config on re-init", () => {
|
||||
@@ -749,7 +749,7 @@ describe("schema migrations", () => {
|
||||
db.init();
|
||||
|
||||
// Verify version bumped to 29 (includes v1→v2 through v26→v29)
|
||||
expect(db.getSchemaVersion()).toBe(36);
|
||||
expect(db.getSchemaVersion()).toBe(37);
|
||||
|
||||
// Verify new columns exist and existing data is intact
|
||||
const cols = db.prepare("PRAGMA table_info(tasks)").all() as Array<{ name: string }>;
|
||||
@@ -774,11 +774,11 @@ describe("schema migrations", () => {
|
||||
const db = new Database(kbDir);
|
||||
db.init();
|
||||
|
||||
expect(db.getSchemaVersion()).toBe(36);
|
||||
expect(db.getSchemaVersion()).toBe(37);
|
||||
|
||||
// Re-init should not fail
|
||||
db.init();
|
||||
expect(db.getSchemaVersion()).toBe(36);
|
||||
expect(db.getSchemaVersion()).toBe(37);
|
||||
|
||||
db.close();
|
||||
});
|
||||
@@ -794,7 +794,7 @@ describe("schema migrations", () => {
|
||||
|
||||
db.init();
|
||||
|
||||
expect(db.getSchemaVersion()).toBe(36);
|
||||
expect(db.getSchemaVersion()).toBe(37);
|
||||
|
||||
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name = 'agentRatings'").all() as Array<{ name: string }>;
|
||||
expect(tables).toEqual([{ name: "agentRatings" }]);
|
||||
@@ -818,7 +818,7 @@ describe("schema migrations", () => {
|
||||
|
||||
db.init();
|
||||
|
||||
expect(db.getSchemaVersion()).toBe(36);
|
||||
expect(db.getSchemaVersion()).toBe(37);
|
||||
|
||||
const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name = 'mission_events'").all() as Array<{ name: string }>;
|
||||
expect(tables).toEqual([{ name: "mission_events" }]);
|
||||
@@ -922,7 +922,7 @@ describe("schema migrations", () => {
|
||||
db.init();
|
||||
|
||||
// Verify version bumped to 29
|
||||
expect(db.getSchemaVersion()).toBe(36);
|
||||
expect(db.getSchemaVersion()).toBe(37);
|
||||
|
||||
// Verify new columns exist and existing data is intact
|
||||
const cols = db.prepare("PRAGMA table_info(tasks)").all() as Array<{ name: string }>;
|
||||
@@ -1291,7 +1291,7 @@ describe("createDatabase factory", () => {
|
||||
const db = createDatabase(kbDir);
|
||||
db.init();
|
||||
|
||||
expect(db.getSchemaVersion()).toBe(36);
|
||||
expect(db.getSchemaVersion()).toBe(37);
|
||||
expect(db.getLastModified()).toBeGreaterThan(0);
|
||||
|
||||
db.close();
|
||||
|
||||
@@ -59,7 +59,7 @@ export function fromJson<T>(json: string | null | undefined): T | undefined {
|
||||
|
||||
// ── Schema Definition ────────────────────────────────────────────────
|
||||
|
||||
const SCHEMA_VERSION = 36;
|
||||
const SCHEMA_VERSION = 37;
|
||||
|
||||
function normalizeTaskComments(
|
||||
steeringComments: SteeringComment[] | undefined,
|
||||
@@ -1464,6 +1464,12 @@ export class Database {
|
||||
});
|
||||
}
|
||||
|
||||
if (version < 37) {
|
||||
this.applyMigration(37, () => {
|
||||
this.addColumnIfMissing("mission_validator_runs", "taskId", "TEXT");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -776,7 +776,7 @@ describe("Migration: pre-33 DB upgrade", () => {
|
||||
// Step 1: Create a fresh database at v33 (runs all migrations up to 33)
|
||||
const db1 = createDatabase(legacyDir);
|
||||
db1.init();
|
||||
expect(db1.getSchemaVersion()).toBe(36);
|
||||
expect(db1.getSchemaVersion()).toBe(37);
|
||||
db1.close();
|
||||
|
||||
// Step 2: Manually downgrade to version 32 and drop insight tables
|
||||
@@ -811,7 +811,7 @@ describe("Migration: pre-33 DB upgrade", () => {
|
||||
expect(tableNamesBefore).not.toContain("project_insight_runs");
|
||||
// Now run init — this triggers the v32→v33 migration
|
||||
db3.init();
|
||||
expect(db3.getSchemaVersion()).toBe(36);
|
||||
expect(db3.getSchemaVersion()).toBe(37);
|
||||
|
||||
// Step 4: Verify insight tables exist after migration
|
||||
const tablesAfter = db3.prepare(
|
||||
@@ -842,12 +842,12 @@ describe("Migration: pre-33 DB upgrade", () => {
|
||||
try {
|
||||
const db1 = createDatabase(testDir);
|
||||
db1.init();
|
||||
expect(db1.getSchemaVersion()).toBe(36);
|
||||
expect(db1.getSchemaVersion()).toBe(37);
|
||||
db1.close();
|
||||
|
||||
const db2 = createDatabase(testDir);
|
||||
expect(() => db2.init()).not.toThrow();
|
||||
expect(db2.getSchemaVersion()).toBe(36);
|
||||
expect(db2.getSchemaVersion()).toBe(37);
|
||||
db2.close();
|
||||
} finally {
|
||||
rmSync(testDir, { recursive: true, force: true });
|
||||
|
||||
@@ -2543,8 +2543,8 @@ describe("MissionStore", () => {
|
||||
// ── Loop State & Validator Run Schema Tests ───────────────────────────
|
||||
|
||||
describe("Loop State & Validator Run Schema (v31)", () => {
|
||||
it("schema version is 32 after migration", () => {
|
||||
expect(db.getSchemaVersion()).toBe(36);
|
||||
it("schema version is 37 after migration", () => {
|
||||
expect(db.getSchemaVersion()).toBe(37);
|
||||
});
|
||||
|
||||
it("mission_features table has loop state columns", () => {
|
||||
@@ -2570,6 +2570,7 @@ describe("MissionStore", () => {
|
||||
expect(colNames).toContain("triggerType");
|
||||
expect(colNames).toContain("implementationAttempt");
|
||||
expect(colNames).toContain("validatorAttempt");
|
||||
expect(colNames).toContain("taskId");
|
||||
expect(colNames).toContain("summary");
|
||||
expect(colNames).toContain("blockedReason");
|
||||
expect(colNames).toContain("startedAt");
|
||||
@@ -2770,6 +2771,36 @@ describe("MissionStore", () => {
|
||||
expect(updatedFeature!.lastValidatorRunId).toBe(run2.id);
|
||||
});
|
||||
|
||||
it("startValidatorRun accepts and persists optional taskId", () => {
|
||||
const mission = store.createMission({ title: "Validator Run Test" });
|
||||
const milestone = store.addMilestone(mission.id, { title: "MS" });
|
||||
const slice = store.addSlice(milestone.id, { title: "SL" });
|
||||
const feature = store.addFeature(slice.id, { title: "Test Feature" });
|
||||
|
||||
const run = store.startValidatorRun(feature.id, "task_completion", "KB-999");
|
||||
|
||||
expect(run.taskId).toBe("KB-999");
|
||||
|
||||
// Verify by reading back from DB
|
||||
const runFromDb = store.getValidatorRun(run.id);
|
||||
expect(runFromDb?.taskId).toBe("KB-999");
|
||||
});
|
||||
|
||||
it("startValidatorRun works without taskId (backward compatibility)", () => {
|
||||
const mission = store.createMission({ title: "Validator Run Test" });
|
||||
const milestone = store.addMilestone(mission.id, { title: "MS" });
|
||||
const slice = store.addSlice(milestone.id, { title: "SL" });
|
||||
const feature = store.addFeature(slice.id, { title: "Test Feature" });
|
||||
|
||||
const run = store.startValidatorRun(feature.id, "manual");
|
||||
|
||||
expect(run.taskId).toBeUndefined();
|
||||
|
||||
// Verify by reading back from DB
|
||||
const runFromDb = store.getValidatorRun(run.id);
|
||||
expect(runFromDb?.taskId).toBeUndefined();
|
||||
});
|
||||
|
||||
it("completeValidatorRun transitions to passed (VAL-DM-016)", () => {
|
||||
const mission = store.createMission({ title: "Complete Test" });
|
||||
const milestone = store.addMilestone(mission.id, { title: "MS" });
|
||||
|
||||
@@ -294,6 +294,7 @@ export class MissionStore extends EventEmitter<MissionStoreEvents> {
|
||||
triggerType: row.triggerType || undefined,
|
||||
implementationAttempt: row.implementationAttempt ?? 0,
|
||||
validatorAttempt: row.validatorAttempt ?? 0,
|
||||
taskId: row.taskId || undefined,
|
||||
summary: row.summary || undefined,
|
||||
blockedReason: row.blockedReason || undefined,
|
||||
startedAt: row.startedAt,
|
||||
@@ -1786,10 +1787,11 @@ export class MissionStore extends EventEmitter<MissionStoreEvents> {
|
||||
*
|
||||
* @param featureId - Feature ID to start validation for
|
||||
* @param triggerType - What triggered this run (e.g., 'task_completion', 'manual', 'scheduled')
|
||||
* @param taskId - Optional board task ID for this validation run (enables board visibility)
|
||||
* @returns The created validator run
|
||||
* @throws Error if feature not found
|
||||
*/
|
||||
startValidatorRun(featureId: string, triggerType?: string): MissionValidatorRun {
|
||||
startValidatorRun(featureId: string, triggerType?: string, taskId?: string): MissionValidatorRun {
|
||||
const feature = this.getFeature(featureId);
|
||||
if (!feature) {
|
||||
throw new Error(`Feature ${featureId} not found`);
|
||||
@@ -1821,6 +1823,7 @@ export class MissionStore extends EventEmitter<MissionStoreEvents> {
|
||||
triggerType,
|
||||
implementationAttempt: feature.implementationAttemptCount ?? 0,
|
||||
validatorAttempt: newValidatorAttemptCount,
|
||||
taskId,
|
||||
startedAt: now,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
@@ -1829,8 +1832,8 @@ export class MissionStore extends EventEmitter<MissionStoreEvents> {
|
||||
this.db.transaction(() => {
|
||||
// Insert the validator run
|
||||
this.db.prepare(`
|
||||
INSERT INTO mission_validator_runs (id, featureId, milestoneId, sliceId, status, triggerType, implementationAttempt, validatorAttempt, startedAt, createdAt, updatedAt)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO mission_validator_runs (id, featureId, milestoneId, sliceId, status, triggerType, implementationAttempt, validatorAttempt, taskId, startedAt, createdAt, updatedAt)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`).run(
|
||||
run.id,
|
||||
run.featureId,
|
||||
@@ -1840,6 +1843,7 @@ export class MissionStore extends EventEmitter<MissionStoreEvents> {
|
||||
run.triggerType ?? "auto",
|
||||
run.implementationAttempt,
|
||||
run.validatorAttempt,
|
||||
run.taskId ?? null,
|
||||
run.startedAt,
|
||||
run.createdAt,
|
||||
run.updatedAt,
|
||||
|
||||
@@ -268,6 +268,8 @@ export interface MissionValidatorRun {
|
||||
implementationAttempt: number;
|
||||
/** Which validation attempt this run corresponds to */
|
||||
validatorAttempt: number;
|
||||
/** Board task ID created for this validation run (for board visibility) */
|
||||
taskId?: string;
|
||||
/** Summary of the validation run results */
|
||||
summary?: string;
|
||||
/** Reason for blocked status if applicable */
|
||||
|
||||
@@ -739,7 +739,7 @@ describe("RoadmapStore", () => {
|
||||
|
||||
describe("schema version", () => {
|
||||
it("schema version is 32 after init", () => {
|
||||
expect(db.getSchemaVersion()).toBe(36);
|
||||
expect(db.getSchemaVersion()).toBe(37);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -465,7 +465,7 @@ describe("Run Audit", () => {
|
||||
});
|
||||
|
||||
it("schema version is bumped to 28", () => {
|
||||
expect(db.getSchemaVersion()).toBe(36);
|
||||
expect(db.getSchemaVersion()).toBe(37);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -174,6 +174,34 @@ describe("TaskStore", () => {
|
||||
const detail = await store.getTask(task.id);
|
||||
expect(detail.breakIntoSubtasks).toBeUndefined();
|
||||
});
|
||||
|
||||
it("persists missionId and sliceId when provided during task creation", async () => {
|
||||
const task = await store.createTask({
|
||||
description: "Mission-linked task",
|
||||
missionId: "MS-001",
|
||||
sliceId: "SL-001",
|
||||
});
|
||||
|
||||
expect(task.missionId).toBe("MS-001");
|
||||
expect(task.sliceId).toBe("SL-001");
|
||||
|
||||
const detail = await store.getTask(task.id);
|
||||
expect(detail.missionId).toBe("MS-001");
|
||||
expect(detail.sliceId).toBe("SL-001");
|
||||
});
|
||||
|
||||
it("leaves missionId and sliceId unset when not provided", async () => {
|
||||
const task = await store.createTask({
|
||||
description: "Regular task",
|
||||
});
|
||||
|
||||
expect(task.missionId).toBeUndefined();
|
||||
expect(task.sliceId).toBeUndefined();
|
||||
|
||||
const detail = await store.getTask(task.id);
|
||||
expect(detail.missionId).toBeUndefined();
|
||||
expect(detail.sliceId).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("assignedAgentId persistence", () => {
|
||||
|
||||
@@ -1484,6 +1484,8 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
|
||||
planningModelProvider: input.planningModelProvider,
|
||||
planningModelId: input.planningModelId,
|
||||
thinkingLevel: input.thinkingLevel,
|
||||
missionId: input.missionId,
|
||||
sliceId: input.sliceId,
|
||||
steps: [],
|
||||
currentStep: 0,
|
||||
log: [{ timestamp: now, action: "Task created" }],
|
||||
|
||||
@@ -1433,7 +1433,9 @@ export const COLUMN_DESCRIPTIONS: Record<Column, string> = {
|
||||
export const VALID_TRANSITIONS: Record<Column, Column[]> = {
|
||||
triage: ["todo"],
|
||||
todo: ["in-progress", "triage"],
|
||||
"in-progress": ["in-review", "todo", "triage"],
|
||||
// NOTE: "in-progress" → "done" is enabled for mission validation tasks that complete directly.
|
||||
// Regular implementation tasks should move through "in-review" before "done".
|
||||
"in-progress": ["in-review", "todo", "triage", "done"],
|
||||
"in-review": ["done", "in-progress", "todo"],
|
||||
done: ["todo", "triage", "archived"],
|
||||
archived: ["done"],
|
||||
|
||||
Reference in New Issue
Block a user