feat(FN-1184): add agent rating persistence and summary APIs
- Add AgentRating, AgentRatingSummary, and AgentRatingInput types and re-export them from @fusion/core - Bump core schema to v14 with an agentRatings table plus agentId/createdAt indexes - Implement AgentStore rating methods for add/list/filter/summary/delete with score validation and rating:added events - Extend database and agent-store tests to cover migration, rating CRUD behavior, filtering, limits, and trend calculation
This commit is contained in:
@@ -59,7 +59,7 @@ export function fromJson<T>(json: string | null | undefined): T | undefined {
|
||||
|
||||
// ── Schema Definition ────────────────────────────────────────────────
|
||||
|
||||
const SCHEMA_VERSION = 13;
|
||||
const SCHEMA_VERSION = 14;
|
||||
|
||||
function normalizeTaskComments(
|
||||
steeringComments: SteeringComment[] | undefined,
|
||||
@@ -451,9 +451,6 @@ export class Database {
|
||||
});
|
||||
}
|
||||
|
||||
// Future migrations go here:
|
||||
// if (version < 14) { this.applyMigration(14, () => { ... }); }
|
||||
|
||||
if (version < 10) {
|
||||
this.applyMigration(10, () => {
|
||||
this.addColumnIfMissing("missions", "autopilotEnabled", "INTEGER DEFAULT 0");
|
||||
@@ -498,6 +495,27 @@ export class Database {
|
||||
this.db.exec(`CREATE INDEX IF NOT EXISTS idxTasksAssignedAgentId ON tasks(assignedAgentId)`);
|
||||
});
|
||||
}
|
||||
|
||||
if (version < 14) {
|
||||
this.applyMigration(14, () => {
|
||||
this.db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS agentRatings (
|
||||
id TEXT PRIMARY KEY,
|
||||
agentId TEXT NOT NULL,
|
||||
raterType TEXT NOT NULL,
|
||||
raterId TEXT,
|
||||
score INTEGER NOT NULL CHECK(score BETWEEN 1 AND 5),
|
||||
category TEXT,
|
||||
comment TEXT,
|
||||
runId TEXT,
|
||||
taskId TEXT,
|
||||
createdAt TEXT NOT NULL
|
||||
)
|
||||
`);
|
||||
this.db.exec(`CREATE INDEX IF NOT EXISTS idxAgentRatingsAgentId ON agentRatings(agentId)`);
|
||||
this.db.exec(`CREATE INDEX IF NOT EXISTS idxAgentRatingsCreatedAt ON agentRatings(createdAt)`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user