feat: extract reusable experiences from supervisor stories

This commit is contained in:
mesalogo
2026-10-02 16:21:53 +08:00
parent bf6c4a91a2
commit 983cdd4e05
21 changed files with 798 additions and 29 deletions
+7 -2
View File
@@ -10,9 +10,12 @@ export const supervisionReviewSettingsSchema = z.object({
// Off: an event can only join knowledge already seen in the same project.
crossProject: z.boolean().optional(),
// A feature splits into sub-threads only once it holds at least this many events.
storyThreadEvents: z.number().int().min(4).max(500).optional()
storyThreadEvents: z.number().int().min(4).max(500).optional(),
// A story is offered to experience extraction only once it holds at least this many events.
experienceMinEvents: z.number().int().min(2).max(200).optional()
}).strict()
export const defaultStoryThreadEvents = 20
export const defaultExperienceMinEvents = 5
export type SupervisionReviewSettings = z.infer<typeof supervisionReviewSettingsSchema>
export const defaultSupervisionReviewSettings = supervisionReviewSettingsSchema.parse({})
export const supervisionReviewIdSchema = z.object({ runId: z.string().uuid() }).strict()
@@ -37,7 +40,9 @@ export type SupervisionReviewProgress = {
phase?: 'collecting' | 'extracting' | 'summarizing' | 'saving'
navigationNodes?: number
/** Story assignment after publication. A failure leaves the published review intact. */
stories?: { status: 'running' | 'completed' | 'failed'; error?: string; calls?: number; assigned?: number; unassigned?: number; created?: number }
stories?: { status: 'running' | 'completed' | 'failed'; error?: string; calls?: number; assigned?: number; unassigned?: number; created?: number
/** Experience extraction after story assignment; its failure leaves the stories intact and is retried with them. */
experiences?: { status: 'completed' | 'failed'; error?: string; calls?: number; candidates?: number; created?: number; applied?: number } }
settings?: SupervisionReviewSettings & { timeoutSeconds: number; concurrency: number }
}
export type SupervisionReviewBatch = {
+29 -2
View File
@@ -21,7 +21,29 @@ export type SupervisionStory = {
export type SupervisionStoryEvent = { id: string; title: string; projectId: string | null; startedAt: string; endedAt: string; primary: boolean; userSet: boolean }
export type SupervisionStoryView = { stories: SupervisionStory[]; unassigned: number; canUndo: boolean }
/** An experience (W) distilled from stories: usable as soon as it is extracted, editable by the user. */
export type SupervisionExperience = {
id: string
statement: string
conditions: string
boundaries: string
userEdited: boolean
/** `formed`: evidence events; `applied`: later events where it was used, with the outcome. */
events: SupervisionExperienceEvent[]
}
export type SupervisionExperienceEvent = {
id: string
role: 'formed' | 'applied'
note: string
title: string
projectId: string | null
at: string
storyId: string | null
storyName: string | null
}
export type SupervisionStoryView = { stories: SupervisionStory[]; experiences: SupervisionExperience[]; unassigned: number; canUndo: boolean }
export const supervisionStoryListSchema = z.object({ scope: heartbeatScopeSchema }).strict()
export type SupervisionStoryListRequest = z.infer<typeof supervisionStoryListSchema>
@@ -31,6 +53,11 @@ export const supervisionStoryActionSchema = z.discriminatedUnion('action', [
z.object({ action: z.literal('merge'), storyId: z.string().uuid(), intoId: z.string().uuid() }).strict(),
z.object({ action: z.literal('remove'), storyId: z.string().uuid() }).strict(),
z.object({ action: z.literal('move'), eventId: z.string().min(1).max(256), storyId: z.string().uuid().nullable() }).strict(),
z.object({ action: z.literal('undo') }).strict()
z.object({ action: z.literal('undo') }).strict(),
z.object({ action: z.literal('experience-edit'), experienceId: z.string().uuid(), statement: z.string().trim().min(1).max(200),
conditions: z.string().trim().max(400), boundaries: z.string().trim().max(400) }).strict(),
z.object({ action: z.literal('experience-merge'), experienceId: z.string().uuid(), intoId: z.string().uuid() }).strict(),
z.object({ action: z.literal('experience-remove'), experienceId: z.string().uuid() }).strict()
])
export type SupervisionStoryAction = z.infer<typeof supervisionStoryActionSchema>
export type SupervisionExperienceAction = Extract<SupervisionStoryAction, { action: `experience-${string}` }>