File size: 4,076 Bytes
638c806
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
export type TaskType =
  | "long_document"
  | "coding_patch"
  | "research_synthesis"
  | "structured_extraction"
  | "strategic_memo"
  | "general";

export type EvalDimensionKey =
  | "input_adequacy"
  | "task_preservation"
  | "deliverable_completeness"
  | "format_clarity"
  | "grounding"
  | "verification"
  | "harness_portability"
  | "bloat_control";

export type EvidenceLevel = "strong_prior" | "moderate_prior" | "hypothesis";

export type ScoreSource = "prompt_shape_heuristic" | "judge" | "unscored";

export interface SuggestedScaffolding {
  inputs: string[];
  deliverables: string[];
  constraints: string[];
  successCriteria: string[];
}

export interface InputAdequacy {
  status: "blocked" | "needs_clarification" | "sufficient";
  score: number;
  reasons: string[];
  warnings: string[];
}

export interface TaskSpec {
  id: string;
  rawUserPrompt: string;
  taskType: TaskType;
  goal: string;
  inputs: string[];
  deliverables: string[];
  constraints: string[];
  successCriteria: string[];
  ambiguities: string[];
  forbiddenChanges: string[];
  suggestedScaffolding: SuggestedScaffolding;
  inputAdequacy: InputAdequacy;
}

export interface HarnessPolicy {
  id: string;
  label: string;
  runtimeAssumptions: string[];
  toolRules: string[];
  artifactRules: string[];
  verificationRules: string[];
  portabilityRules: string[];
}

export interface ModelAdapterProfile {
  id: string;
  label: string;
  family: string;
  evidence: EvidenceLevel;
  evidenceNote: string;
  summary: string;
  style: string;
  explicitness: number;
  examples: number;
  verification: number;
  harnessRules: number;
  adapterRules: string[];
  failureModes: string[];
  promptPattern: string;
}

export interface PromptSection {
  label: string;
  body: string;
}

export interface BoostedPrompt {
  id: string;
  rawUserPrompt: string;
  taskSpec: TaskSpec;
  harnessPolicy: HarnessPolicy;
  modelProfile: ModelAdapterProfile;
  sections: PromptSection[];
  prompt: string;
  evalPlan: EvalPlan;
  rationale: string[];
  score: PromptScore;
  inputAdequacy: InputAdequacy;
}

export interface EvalDimension {
  key: EvalDimensionKey;
  label: string;
  description: string;
  weight: number;
}

export interface EvalPlan {
  rubric: EvalDimension[];
  expectedFailureModes: string[];
  requiredChecks: string[];
  metadataFields: string[];
}

export interface PromptScoreDimension {
  key: EvalDimensionKey;
  label: string;
  value: number;
  evidence: string;
}

export interface PromptScore {
  overall: number;
  grade: "blocked" | "weak" | "usable" | "strong";
  source: ScoreSource;
  dimensions: PromptScoreDimension[];
  findings: string[];
}

export interface EvalCase {
  id: string;
  taskType: TaskType;
  rawUserPrompt: string;
  acceptanceCriteria: string[];
  context?: Record<string, unknown>;
  artifacts?: string[];
  expectedOutputShape?: string;
}

export interface PromptRunResult {
  output: string;
  metadata?: {
    runnerId?: string;
    runnerVersion?: string;
    harness?: string;
    model?: string;
    promptVersion?: string;
    costUsd?: number;
    durationMs?: number;
    tokensIn?: number;
    tokensOut?: number;
    observedFailureModes?: string[];
    blockedChecks?: string[];
    extra?: Record<string, unknown>;
  };
}

export interface PromptRunner {
  run(prompt: string, evalCase: EvalCase, boostedPrompt: BoostedPrompt): Promise<PromptRunResult>;
}

export interface JudgeRunner {
  judge(
    output: PromptRunResult,
    evalCase: EvalCase,
    boostedPrompt: BoostedPrompt
  ): Promise<PromptScore>;
}

export interface EvalResult {
  caseId: string;
  boostedPromptId: string;
  output: string;
  score: PromptScore;
  scoreSource: ScoreSource;
  durationMs: number;
  metadata: PromptRunResult["metadata"];
  judgeMetadata?: {
    judgeId?: string;
    judgeVersion?: string;
    blockedChecks?: string[];
    observedFailureModes?: string[];
    extra?: Record<string, unknown>;
  };
}

export interface GenerateOptions {
  taskType?: TaskType;
  modelProfileId?: string;
  harnessPolicyId?: string;
}