-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfeedback-loop.zod.ts
More file actions
63 lines (54 loc) · 1.91 KB
/
feedback-loop.zod.ts
File metadata and controls
63 lines (54 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { z } from 'zod';
import { ChangeSetSchema } from '../system/migration.zod';
// Identifying the source of truth
export const MetadataSourceSchema = z.object({
file: z.string().optional(),
line: z.number().optional(),
column: z.number().optional(),
// Logic references
package: z.string().optional(),
object: z.string().optional(),
field: z.string().optional(),
component: z.string().optional() // specific UI component or flow node
});
// The Runtime Issue
export const IssueSchema = z.object({
id: z.string(),
severity: z.enum(['critical', 'error', 'warning', 'info']),
message: z.string(),
stackTrace: z.string().optional(),
timestamp: z.string().datetime(),
userId: z.string().optional(),
// Context snapshot
context: z.record(z.string(), z.unknown()).optional(),
// The suspected metadata culprit
source: MetadataSourceSchema.optional()
});
// The AI's proposed resolution
export const ResolutionSchema = z.object({
issueId: z.string(),
reasoning: z.string().describe('Explanation of why this fix is needed'),
confidence: z.number().min(0).max(1),
// Actionable change to fix the issue
fix: z.discriminatedUnion('type', [
z.object({
type: z.literal('metadata_change'),
changeSet: ChangeSetSchema
}),
z.object({
type: z.literal('manual_intervention'),
instructions: z.string()
})
])
});
// Complete Feedback Loop Record
export const FeedbackLoopSchema = z.object({
issue: IssueSchema,
analysis: z.string().optional().describe('AI analysis of the root cause'),
resolutions: z.array(ResolutionSchema).optional(),
status: z.enum(['open', 'analyzing', 'resolved', 'ignored']).default('open')
});
export type FeedbackLoop = z.infer<typeof FeedbackLoopSchema>;
export type Issue = z.infer<typeof IssueSchema>;
export type Resolution = z.infer<typeof ResolutionSchema>;