@under18dev/veritas-improvement 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +12 -2
- package/dist/apply.d.ts +29 -0
- package/dist/apply.d.ts.map +1 -0
- package/dist/apply.js +403 -0
- package/dist/apply.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/oracle.d.ts +33 -0
- package/dist/oracle.d.ts.map +1 -0
- package/dist/oracle.js +130 -0
- package/dist/oracle.js.map +1 -0
- package/dist/plan.d.ts +26 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +550 -0
- package/dist/plan.js.map +1 -0
- package/dist/render.d.ts +10 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +52 -0
- package/dist/render.js.map +1 -0
- package/dist/schema.d.ts +331 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +115 -0
- package/dist/schema.js.map +1 -0
- package/dist/store.d.ts +27 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +79 -0
- package/dist/store.js.map +1 -0
- package/dist/validate.d.ts +11 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +83 -0
- package/dist/validate.js.map +1 -0
- package/dist/vitest.d.ts +19 -0
- package/dist/vitest.d.ts.map +1 -0
- package/dist/vitest.js +77 -0
- package/dist/vitest.js.map +1 -0
- package/dist/workspace.d.ts +27 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +166 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +29 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,MAAM,UAAU,GAAG,4BAA4B,CAAC;AAEhD,MAA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J,CAAC;IAED,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,WAAW,CAAC,KAAkB;IAC5C,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEpG,OAAO;YACL,eAAe;YACf,SAAS,CAAC,CAAC,IAAI,EAAE;YACjB,cAAc,KAAK,CAAC,MAAM,KAAK;YAC/B,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;SAC7B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** A planner outcome: `planned` when a plan is ready for approval, otherwise why the loop stopped. */
|
|
3
|
+
export declare const PlanOutcome: z.ZodUnion<readonly [z.ZodLiteral<"planned">, z.ZodEnum<{
|
|
4
|
+
error: "error";
|
|
5
|
+
improved: "improved";
|
|
6
|
+
no_safe_improvement: "no_safe_improvement";
|
|
7
|
+
needs_spec_decision: "needs_spec_decision";
|
|
8
|
+
blocked: "blocked";
|
|
9
|
+
}>]>;
|
|
10
|
+
export type PlanOutcome = z.infer<typeof PlanOutcome>;
|
|
11
|
+
/** Scalar input/expected values: integers as decimal strings (exact), booleans as booleans. */
|
|
12
|
+
export declare const ScalarValue: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>;
|
|
13
|
+
export type ScalarValue = z.infer<typeof ScalarValue>;
|
|
14
|
+
/**
|
|
15
|
+
* One file operation of a patch. Only `add` is ever produced by the planner; the other operations exist so a
|
|
16
|
+
* tampered plan is parsed and then rejected by validation instead of being silently reinterpreted.
|
|
17
|
+
*/
|
|
18
|
+
export declare const PatchFile: z.ZodObject<{
|
|
19
|
+
operation: z.ZodEnum<{
|
|
20
|
+
add: "add";
|
|
21
|
+
modify: "modify";
|
|
22
|
+
delete: "delete";
|
|
23
|
+
}>;
|
|
24
|
+
path: z.ZodString;
|
|
25
|
+
content: z.ZodString;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type PatchFile = z.infer<typeof PatchFile>;
|
|
28
|
+
/** A concrete test case whose expected value was computed from the specification model only. */
|
|
29
|
+
export declare const ProposedTest: z.ZodObject<{
|
|
30
|
+
id: z.ZodString;
|
|
31
|
+
propertyId: z.ZodString;
|
|
32
|
+
symbol: z.ZodString;
|
|
33
|
+
exportName: z.ZodString;
|
|
34
|
+
module: z.ZodString;
|
|
35
|
+
params: z.ZodArray<z.ZodString>;
|
|
36
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
37
|
+
expected: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>;
|
|
38
|
+
origin: z.ZodEnum<{
|
|
39
|
+
survived_mutant: "survived_mutant";
|
|
40
|
+
boundary: "boundary";
|
|
41
|
+
}>;
|
|
42
|
+
mutantId: z.ZodOptional<z.ZodString>;
|
|
43
|
+
claimId: z.ZodOptional<z.ZodString>;
|
|
44
|
+
findingId: z.ZodOptional<z.ZodString>;
|
|
45
|
+
citations: z.ZodArray<z.ZodString>;
|
|
46
|
+
derivation: z.ZodString;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export type ProposedTest = z.infer<typeof ProposedTest>;
|
|
49
|
+
/** A planned test that fails against the current implementation. It is never added and never adjusted. */
|
|
50
|
+
export declare const SpecViolationCandidate: z.ZodObject<{
|
|
51
|
+
id: z.ZodString;
|
|
52
|
+
test: z.ZodObject<{
|
|
53
|
+
id: z.ZodString;
|
|
54
|
+
propertyId: z.ZodString;
|
|
55
|
+
symbol: z.ZodString;
|
|
56
|
+
exportName: z.ZodString;
|
|
57
|
+
module: z.ZodString;
|
|
58
|
+
params: z.ZodArray<z.ZodString>;
|
|
59
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
60
|
+
expected: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>;
|
|
61
|
+
origin: z.ZodEnum<{
|
|
62
|
+
survived_mutant: "survived_mutant";
|
|
63
|
+
boundary: "boundary";
|
|
64
|
+
}>;
|
|
65
|
+
mutantId: z.ZodOptional<z.ZodString>;
|
|
66
|
+
claimId: z.ZodOptional<z.ZodString>;
|
|
67
|
+
findingId: z.ZodOptional<z.ZodString>;
|
|
68
|
+
citations: z.ZodArray<z.ZodString>;
|
|
69
|
+
derivation: z.ZodString;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
actual: z.ZodString;
|
|
72
|
+
reason: z.ZodString;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
export type SpecViolationCandidate = z.infer<typeof SpecViolationCandidate>;
|
|
75
|
+
/** Separate artifact: the implementation, not the test, probably needs to change (or the spec needs a decision). */
|
|
76
|
+
export declare const ImplementationFixProposal: z.ZodObject<{
|
|
77
|
+
id: z.ZodString;
|
|
78
|
+
kind: z.ZodLiteral<"implementation_fix_proposal">;
|
|
79
|
+
propertyId: z.ZodString;
|
|
80
|
+
symbol: z.ZodString;
|
|
81
|
+
module: z.ZodString;
|
|
82
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
83
|
+
expectedBySpecification: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>;
|
|
84
|
+
actualByImplementation: z.ZodString;
|
|
85
|
+
citations: z.ZodArray<z.ZodString>;
|
|
86
|
+
explanation: z.ZodArray<z.ZodString>;
|
|
87
|
+
candidateId: z.ZodString;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
export type ImplementationFixProposal = z.infer<typeof ImplementationFixProposal>;
|
|
90
|
+
/** A planned input that was dropped, with the reason (kept so nothing disappears silently). */
|
|
91
|
+
export declare const SkippedTarget: z.ZodObject<{
|
|
92
|
+
propertyId: z.ZodNullable<z.ZodString>;
|
|
93
|
+
mutantId: z.ZodOptional<z.ZodString>;
|
|
94
|
+
input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>>;
|
|
95
|
+
reason: z.ZodString;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
export type SkippedTarget = z.infer<typeof SkippedTarget>;
|
|
98
|
+
/** Everything `apply` needs, persisted as `.veritas/improvements/<planId>/plan.json`. */
|
|
99
|
+
export declare const PlanDocument: z.ZodObject<{
|
|
100
|
+
planId: z.ZodString;
|
|
101
|
+
runId: z.ZodString;
|
|
102
|
+
outcome: z.ZodUnion<readonly [z.ZodLiteral<"planned">, z.ZodEnum<{
|
|
103
|
+
error: "error";
|
|
104
|
+
improved: "improved";
|
|
105
|
+
no_safe_improvement: "no_safe_improvement";
|
|
106
|
+
needs_spec_decision: "needs_spec_decision";
|
|
107
|
+
blocked: "blocked";
|
|
108
|
+
}>]>;
|
|
109
|
+
plan: z.ZodNullable<z.ZodObject<{
|
|
110
|
+
id: z.ZodString;
|
|
111
|
+
goal: z.ZodString;
|
|
112
|
+
targetedPropertyIds: z.ZodArray<z.ZodString>;
|
|
113
|
+
observedGaps: z.ZodArray<z.ZodObject<{
|
|
114
|
+
findingId: z.ZodString;
|
|
115
|
+
description: z.ZodString;
|
|
116
|
+
}, z.core.$strip>>;
|
|
117
|
+
proposedTestCases: z.ZodArray<z.ZodObject<{
|
|
118
|
+
file: z.ZodString;
|
|
119
|
+
name: z.ZodString;
|
|
120
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
121
|
+
rationale: z.ZodString;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
patchPreview: z.ZodString;
|
|
124
|
+
expectedImpact: z.ZodArray<z.ZodString>;
|
|
125
|
+
risks: z.ZodArray<z.ZodString>;
|
|
126
|
+
commands: z.ZodArray<z.ZodString>;
|
|
127
|
+
budget: z.ZodObject<{
|
|
128
|
+
maxIterations: z.ZodNumber;
|
|
129
|
+
maxPatchFiles: z.ZodNumber;
|
|
130
|
+
maxTestRetries: z.ZodNumber;
|
|
131
|
+
timeBudgetMs: z.ZodNumber;
|
|
132
|
+
tokenBudget: z.ZodNumber;
|
|
133
|
+
solverTimeoutMs: z.ZodNumber;
|
|
134
|
+
}, z.core.$strip>;
|
|
135
|
+
touchesProductionCode: z.ZodBoolean;
|
|
136
|
+
createdAt: z.ZodISODateTime;
|
|
137
|
+
}, z.core.$strip>>;
|
|
138
|
+
files: z.ZodArray<z.ZodObject<{
|
|
139
|
+
operation: z.ZodEnum<{
|
|
140
|
+
add: "add";
|
|
141
|
+
modify: "modify";
|
|
142
|
+
delete: "delete";
|
|
143
|
+
}>;
|
|
144
|
+
path: z.ZodString;
|
|
145
|
+
content: z.ZodString;
|
|
146
|
+
}, z.core.$strip>>;
|
|
147
|
+
tests: z.ZodArray<z.ZodObject<{
|
|
148
|
+
id: z.ZodString;
|
|
149
|
+
propertyId: z.ZodString;
|
|
150
|
+
symbol: z.ZodString;
|
|
151
|
+
exportName: z.ZodString;
|
|
152
|
+
module: z.ZodString;
|
|
153
|
+
params: z.ZodArray<z.ZodString>;
|
|
154
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
155
|
+
expected: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>;
|
|
156
|
+
origin: z.ZodEnum<{
|
|
157
|
+
survived_mutant: "survived_mutant";
|
|
158
|
+
boundary: "boundary";
|
|
159
|
+
}>;
|
|
160
|
+
mutantId: z.ZodOptional<z.ZodString>;
|
|
161
|
+
claimId: z.ZodOptional<z.ZodString>;
|
|
162
|
+
findingId: z.ZodOptional<z.ZodString>;
|
|
163
|
+
citations: z.ZodArray<z.ZodString>;
|
|
164
|
+
derivation: z.ZodString;
|
|
165
|
+
}, z.core.$strip>>;
|
|
166
|
+
specViolationCandidates: z.ZodArray<z.ZodObject<{
|
|
167
|
+
id: z.ZodString;
|
|
168
|
+
test: z.ZodObject<{
|
|
169
|
+
id: z.ZodString;
|
|
170
|
+
propertyId: z.ZodString;
|
|
171
|
+
symbol: z.ZodString;
|
|
172
|
+
exportName: z.ZodString;
|
|
173
|
+
module: z.ZodString;
|
|
174
|
+
params: z.ZodArray<z.ZodString>;
|
|
175
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
176
|
+
expected: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>;
|
|
177
|
+
origin: z.ZodEnum<{
|
|
178
|
+
survived_mutant: "survived_mutant";
|
|
179
|
+
boundary: "boundary";
|
|
180
|
+
}>;
|
|
181
|
+
mutantId: z.ZodOptional<z.ZodString>;
|
|
182
|
+
claimId: z.ZodOptional<z.ZodString>;
|
|
183
|
+
findingId: z.ZodOptional<z.ZodString>;
|
|
184
|
+
citations: z.ZodArray<z.ZodString>;
|
|
185
|
+
derivation: z.ZodString;
|
|
186
|
+
}, z.core.$strip>;
|
|
187
|
+
actual: z.ZodString;
|
|
188
|
+
reason: z.ZodString;
|
|
189
|
+
}, z.core.$strip>>;
|
|
190
|
+
implementationFixProposals: z.ZodArray<z.ZodObject<{
|
|
191
|
+
id: z.ZodString;
|
|
192
|
+
kind: z.ZodLiteral<"implementation_fix_proposal">;
|
|
193
|
+
propertyId: z.ZodString;
|
|
194
|
+
symbol: z.ZodString;
|
|
195
|
+
module: z.ZodString;
|
|
196
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
197
|
+
expectedBySpecification: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>;
|
|
198
|
+
actualByImplementation: z.ZodString;
|
|
199
|
+
citations: z.ZodArray<z.ZodString>;
|
|
200
|
+
explanation: z.ZodArray<z.ZodString>;
|
|
201
|
+
candidateId: z.ZodString;
|
|
202
|
+
}, z.core.$strip>>;
|
|
203
|
+
skipped: z.ZodArray<z.ZodObject<{
|
|
204
|
+
propertyId: z.ZodNullable<z.ZodString>;
|
|
205
|
+
mutantId: z.ZodOptional<z.ZodString>;
|
|
206
|
+
input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>>;
|
|
207
|
+
reason: z.ZodString;
|
|
208
|
+
}, z.core.$strip>>;
|
|
209
|
+
reasons: z.ZodArray<z.ZodString>;
|
|
210
|
+
budget: z.ZodObject<{
|
|
211
|
+
maxIterations: z.ZodNumber;
|
|
212
|
+
maxPatchFiles: z.ZodNumber;
|
|
213
|
+
maxTestRetries: z.ZodNumber;
|
|
214
|
+
timeBudgetMs: z.ZodNumber;
|
|
215
|
+
tokenBudget: z.ZodNumber;
|
|
216
|
+
solverTimeoutMs: z.ZodNumber;
|
|
217
|
+
}, z.core.$strip>;
|
|
218
|
+
projectHash: z.ZodString;
|
|
219
|
+
includeProposed: z.ZodDefault<z.ZodBoolean>;
|
|
220
|
+
configHash: z.ZodString;
|
|
221
|
+
runSourceHash: z.ZodString;
|
|
222
|
+
}, z.core.$strip>;
|
|
223
|
+
export type PlanDocument = z.infer<typeof PlanDocument>;
|
|
224
|
+
/** Who approved applying a plan, when, and through which entry point. The token itself is not stored. */
|
|
225
|
+
export declare const ImprovementApproval: z.ZodObject<{
|
|
226
|
+
approvalId: z.ZodString;
|
|
227
|
+
planId: z.ZodString;
|
|
228
|
+
tokenSha256: z.ZodString;
|
|
229
|
+
actor: z.ZodString;
|
|
230
|
+
actorSource: z.ZodEnum<{
|
|
231
|
+
option: "option";
|
|
232
|
+
env: "env";
|
|
233
|
+
git: "git";
|
|
234
|
+
claimed_by_client: "claimed_by_client";
|
|
235
|
+
}>;
|
|
236
|
+
approvedAt: z.ZodISODateTime;
|
|
237
|
+
via: z.ZodEnum<{
|
|
238
|
+
cli: "cli";
|
|
239
|
+
mcp: "mcp";
|
|
240
|
+
api: "api";
|
|
241
|
+
}>;
|
|
242
|
+
}, z.core.$strip>;
|
|
243
|
+
export type ImprovementApproval = z.infer<typeof ImprovementApproval>;
|
|
244
|
+
export declare const PlanResult: z.ZodObject<{
|
|
245
|
+
planId: z.ZodString;
|
|
246
|
+
runId: z.ZodString;
|
|
247
|
+
outcome: z.ZodUnion<readonly [z.ZodLiteral<"planned">, z.ZodEnum<{
|
|
248
|
+
error: "error";
|
|
249
|
+
improved: "improved";
|
|
250
|
+
no_safe_improvement: "no_safe_improvement";
|
|
251
|
+
needs_spec_decision: "needs_spec_decision";
|
|
252
|
+
blocked: "blocked";
|
|
253
|
+
}>]>;
|
|
254
|
+
plan: z.ZodNullable<z.ZodObject<{
|
|
255
|
+
id: z.ZodString;
|
|
256
|
+
goal: z.ZodString;
|
|
257
|
+
targetedPropertyIds: z.ZodArray<z.ZodString>;
|
|
258
|
+
observedGaps: z.ZodArray<z.ZodObject<{
|
|
259
|
+
findingId: z.ZodString;
|
|
260
|
+
description: z.ZodString;
|
|
261
|
+
}, z.core.$strip>>;
|
|
262
|
+
proposedTestCases: z.ZodArray<z.ZodObject<{
|
|
263
|
+
file: z.ZodString;
|
|
264
|
+
name: z.ZodString;
|
|
265
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
266
|
+
rationale: z.ZodString;
|
|
267
|
+
}, z.core.$strip>>;
|
|
268
|
+
patchPreview: z.ZodString;
|
|
269
|
+
expectedImpact: z.ZodArray<z.ZodString>;
|
|
270
|
+
risks: z.ZodArray<z.ZodString>;
|
|
271
|
+
commands: z.ZodArray<z.ZodString>;
|
|
272
|
+
budget: z.ZodObject<{
|
|
273
|
+
maxIterations: z.ZodNumber;
|
|
274
|
+
maxPatchFiles: z.ZodNumber;
|
|
275
|
+
maxTestRetries: z.ZodNumber;
|
|
276
|
+
timeBudgetMs: z.ZodNumber;
|
|
277
|
+
tokenBudget: z.ZodNumber;
|
|
278
|
+
solverTimeoutMs: z.ZodNumber;
|
|
279
|
+
}, z.core.$strip>;
|
|
280
|
+
touchesProductionCode: z.ZodBoolean;
|
|
281
|
+
createdAt: z.ZodISODateTime;
|
|
282
|
+
}, z.core.$strip>>;
|
|
283
|
+
approvalToken: z.ZodNullable<z.ZodString>;
|
|
284
|
+
specViolationCandidates: z.ZodArray<z.ZodObject<{
|
|
285
|
+
id: z.ZodString;
|
|
286
|
+
test: z.ZodObject<{
|
|
287
|
+
id: z.ZodString;
|
|
288
|
+
propertyId: z.ZodString;
|
|
289
|
+
symbol: z.ZodString;
|
|
290
|
+
exportName: z.ZodString;
|
|
291
|
+
module: z.ZodString;
|
|
292
|
+
params: z.ZodArray<z.ZodString>;
|
|
293
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
294
|
+
expected: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>;
|
|
295
|
+
origin: z.ZodEnum<{
|
|
296
|
+
survived_mutant: "survived_mutant";
|
|
297
|
+
boundary: "boundary";
|
|
298
|
+
}>;
|
|
299
|
+
mutantId: z.ZodOptional<z.ZodString>;
|
|
300
|
+
claimId: z.ZodOptional<z.ZodString>;
|
|
301
|
+
findingId: z.ZodOptional<z.ZodString>;
|
|
302
|
+
citations: z.ZodArray<z.ZodString>;
|
|
303
|
+
derivation: z.ZodString;
|
|
304
|
+
}, z.core.$strip>;
|
|
305
|
+
actual: z.ZodString;
|
|
306
|
+
reason: z.ZodString;
|
|
307
|
+
}, z.core.$strip>>;
|
|
308
|
+
implementationFixProposals: z.ZodArray<z.ZodObject<{
|
|
309
|
+
id: z.ZodString;
|
|
310
|
+
kind: z.ZodLiteral<"implementation_fix_proposal">;
|
|
311
|
+
propertyId: z.ZodString;
|
|
312
|
+
symbol: z.ZodString;
|
|
313
|
+
module: z.ZodString;
|
|
314
|
+
input: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
|
|
315
|
+
expectedBySpecification: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>;
|
|
316
|
+
actualByImplementation: z.ZodString;
|
|
317
|
+
citations: z.ZodArray<z.ZodString>;
|
|
318
|
+
explanation: z.ZodArray<z.ZodString>;
|
|
319
|
+
candidateId: z.ZodString;
|
|
320
|
+
}, z.core.$strip>>;
|
|
321
|
+
skipped: z.ZodArray<z.ZodObject<{
|
|
322
|
+
propertyId: z.ZodNullable<z.ZodString>;
|
|
323
|
+
mutantId: z.ZodOptional<z.ZodString>;
|
|
324
|
+
input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>>;
|
|
325
|
+
reason: z.ZodString;
|
|
326
|
+
}, z.core.$strip>>;
|
|
327
|
+
reasons: z.ZodArray<z.ZodString>;
|
|
328
|
+
planFile: z.ZodString;
|
|
329
|
+
}, z.core.$strip>;
|
|
330
|
+
export type PlanResult = z.infer<typeof PlanResult>;
|
|
331
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sGAAsG;AACtG,eAAO,MAAM,WAAW;;;;;;IAAsD,CAAC;AAC/E,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,+FAA+F;AAC/F,eAAO,MAAM,WAAW,kDAAsD,CAAC;AAC/E,MAAM,MAA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C,CAAC;AAEtE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAarB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Id, ImprovementBudget, ImprovementOutcome, ImprovementPlan, Sha256 } from '@under18dev/veritas-core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/** A planner outcome: `planned` when a plan is ready for approval, otherwise why the loop stopped. */
|
|
4
|
+
export const PlanOutcome = z.union([z.literal('planned'), ImprovementOutcome]);
|
|
5
|
+
/** Scalar input/expected values: integers as decimal strings (exact), booleans as booleans. */
|
|
6
|
+
export const ScalarValue = z.union([z.string().regex(/^-?\d+$/), z.boolean()]);
|
|
7
|
+
/**
|
|
8
|
+
* One file operation of a patch. Only `add` is ever produced by the planner; the other operations exist so a
|
|
9
|
+
* tampered plan is parsed and then rejected by validation instead of being silently reinterpreted.
|
|
10
|
+
*/
|
|
11
|
+
export const PatchFile = z.object({
|
|
12
|
+
operation: z.enum(['add', 'modify', 'delete']),
|
|
13
|
+
path: z.string(),
|
|
14
|
+
content: z.string(),
|
|
15
|
+
});
|
|
16
|
+
/** A concrete test case whose expected value was computed from the specification model only. */
|
|
17
|
+
export const ProposedTest = z.object({
|
|
18
|
+
id: Id,
|
|
19
|
+
propertyId: Id,
|
|
20
|
+
symbol: z.string(),
|
|
21
|
+
exportName: z.string(),
|
|
22
|
+
/** Project-relative module of the function under test. */
|
|
23
|
+
module: z.string(),
|
|
24
|
+
params: z.array(z.string()),
|
|
25
|
+
input: z.record(z.string(), ScalarValue),
|
|
26
|
+
expected: ScalarValue,
|
|
27
|
+
/** Why this input: a distinguishing input of a survived mutant or a boundary of the property. */
|
|
28
|
+
origin: z.enum(['survived_mutant', 'boundary']),
|
|
29
|
+
mutantId: Id.optional(),
|
|
30
|
+
claimId: Id.optional(),
|
|
31
|
+
findingId: Id.optional(),
|
|
32
|
+
citations: z.array(z.string()),
|
|
33
|
+
/** How the expected value was derived (property, clause, recorded assumptions). */
|
|
34
|
+
derivation: z.string(),
|
|
35
|
+
});
|
|
36
|
+
/** A planned test that fails against the current implementation. It is never added and never adjusted. */
|
|
37
|
+
export const SpecViolationCandidate = z.object({
|
|
38
|
+
id: Id,
|
|
39
|
+
test: ProposedTest,
|
|
40
|
+
/** What the implementation returned in the sandbox, as text. */
|
|
41
|
+
actual: z.string(),
|
|
42
|
+
reason: z.string(),
|
|
43
|
+
});
|
|
44
|
+
/** Separate artifact: the implementation, not the test, probably needs to change (or the spec needs a decision). */
|
|
45
|
+
export const ImplementationFixProposal = z.object({
|
|
46
|
+
id: Id,
|
|
47
|
+
kind: z.literal('implementation_fix_proposal'),
|
|
48
|
+
propertyId: Id,
|
|
49
|
+
symbol: z.string(),
|
|
50
|
+
module: z.string(),
|
|
51
|
+
input: z.record(z.string(), ScalarValue),
|
|
52
|
+
expectedBySpecification: ScalarValue,
|
|
53
|
+
actualByImplementation: z.string(),
|
|
54
|
+
citations: z.array(z.string()),
|
|
55
|
+
explanation: z.array(z.string()).min(1),
|
|
56
|
+
candidateId: Id,
|
|
57
|
+
});
|
|
58
|
+
/** A planned input that was dropped, with the reason (kept so nothing disappears silently). */
|
|
59
|
+
export const SkippedTarget = z.object({
|
|
60
|
+
propertyId: Id.nullable(),
|
|
61
|
+
mutantId: Id.optional(),
|
|
62
|
+
input: z.record(z.string(), ScalarValue).optional(),
|
|
63
|
+
reason: z.string(),
|
|
64
|
+
});
|
|
65
|
+
/** Everything `apply` needs, persisted as `.veritas/improvements/<planId>/plan.json`. */
|
|
66
|
+
export const PlanDocument = z.object({
|
|
67
|
+
planId: Id,
|
|
68
|
+
runId: Id,
|
|
69
|
+
outcome: PlanOutcome,
|
|
70
|
+
plan: ImprovementPlan.nullable(),
|
|
71
|
+
files: z.array(PatchFile),
|
|
72
|
+
tests: z.array(ProposedTest),
|
|
73
|
+
specViolationCandidates: z.array(SpecViolationCandidate),
|
|
74
|
+
implementationFixProposals: z.array(ImplementationFixProposal),
|
|
75
|
+
skipped: z.array(SkippedTarget),
|
|
76
|
+
reasons: z.array(z.string()),
|
|
77
|
+
budget: ImprovementBudget,
|
|
78
|
+
/** Hash of every project file (excluding node_modules, .git, .veritas, .mutator) when the plan was made. */
|
|
79
|
+
projectHash: Sha256,
|
|
80
|
+
/** Whether proposed (not accepted) properties were explicitly allowed as the oracle. */
|
|
81
|
+
includeProposed: z.boolean().default(false),
|
|
82
|
+
configHash: Sha256,
|
|
83
|
+
/** The run artifacts' source hash, for traceability. */
|
|
84
|
+
runSourceHash: Sha256,
|
|
85
|
+
});
|
|
86
|
+
/** Who approved applying a plan, when, and through which entry point. The token itself is not stored. */
|
|
87
|
+
export const ImprovementApproval = z.object({
|
|
88
|
+
approvalId: Id,
|
|
89
|
+
planId: Id,
|
|
90
|
+
/** SHA-256 of the approval token, so the record names exactly the plan content that was approved. */
|
|
91
|
+
tokenSha256: Sha256,
|
|
92
|
+
actor: z.string().min(1),
|
|
93
|
+
/**
|
|
94
|
+
* Where the name comes from: `--actor`, `VERITAS_ACTOR`, the git user, or an MCP client's own claim. None of
|
|
95
|
+
* these is authenticated; they record who the operator said approved.
|
|
96
|
+
*/
|
|
97
|
+
actorSource: z.enum(['option', 'env', 'git', 'claimed_by_client']),
|
|
98
|
+
approvedAt: z.iso.datetime({ offset: true }),
|
|
99
|
+
via: z.enum(['cli', 'mcp', 'api']),
|
|
100
|
+
});
|
|
101
|
+
export const PlanResult = z.object({
|
|
102
|
+
planId: Id,
|
|
103
|
+
runId: Id,
|
|
104
|
+
outcome: PlanOutcome,
|
|
105
|
+
plan: ImprovementPlan.nullable(),
|
|
106
|
+
/** sha256 of the canonical plan content; `null` when there is nothing to apply. */
|
|
107
|
+
approvalToken: Sha256.nullable(),
|
|
108
|
+
specViolationCandidates: z.array(SpecViolationCandidate),
|
|
109
|
+
implementationFixProposals: z.array(ImplementationFixProposal),
|
|
110
|
+
skipped: z.array(SkippedTarget),
|
|
111
|
+
reasons: z.array(z.string()),
|
|
112
|
+
/** Project-relative path of the persisted plan. */
|
|
113
|
+
planFile: z.string(),
|
|
114
|
+
});
|
|
115
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAC9G,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sGAAsG;AACtG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAG/E,+FAA+F;AAC/F,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAG/E;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC9C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAGH,gGAAgG;AAChG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,EAAE,EAAE,EAAE;IACN,UAAU,EAAE,EAAE;IACd,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MAAM,EAAE,CAAC;IAC5B,mDAAmD;IACnD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAC"}
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import { PlanDocument } from './schema.js';
|
|
3
|
+
export declare const IMPROVEMENTS_DIR: string;
|
|
4
|
+
export declare const PLAN_ID: RegExp;
|
|
5
|
+
export declare function assertPlanId(planId: string): void;
|
|
6
|
+
/** Absolute directory of a plan, confined to the project root. */
|
|
7
|
+
export declare function planDir(root: string, planId: string): string;
|
|
8
|
+
export interface StoreContext {
|
|
9
|
+
runId: string;
|
|
10
|
+
configHash: string;
|
|
11
|
+
sourceHash: string;
|
|
12
|
+
gitCommit: string | null;
|
|
13
|
+
}
|
|
14
|
+
/** Validate, redact and write an artifact envelope atomically under the plan directory. */
|
|
15
|
+
export declare function writePlanArtifact<S extends z.ZodType>(root: string, planId: string, name: string, schema: S, data: z.input<S>, context: StoreContext,
|
|
16
|
+
/** Fail with EEXIST instead of replacing an existing file (used to claim attempt numbers). */
|
|
17
|
+
options?: {
|
|
18
|
+
exclusive?: boolean;
|
|
19
|
+
}): string;
|
|
20
|
+
export declare function readPlan(root: string, planId: string): PlanDocument;
|
|
21
|
+
/**
|
|
22
|
+
* The approval token: sha256 of the canonical plan content. Timestamps are left out so the same plan always
|
|
23
|
+
* has the same token; any change to tests, files, expected values or budgets changes it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function approvalTokenFor(doc: PlanDocument): string;
|
|
26
|
+
export declare function attemptCount(root: string, planId: string): number;
|
|
27
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,eAAO,MAAM,gBAAgB,QAAwC,CAAC;AACtE,eAAO,MAAM,OAAO,QAAsB,CAAC;AAE3C,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAIjD;AAED,kEAAkE;AAClE,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAI5D;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,2FAA2F;AAC3F,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EACnD,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAChB,OAAO,EAAE,YAAY;AACrB,8FAA8F;AAC9F,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GACpC,MAAM,CA0CR;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAanE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAK1D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMjE"}
|
package/dist/store.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { existsSync, linkSync, mkdirSync, readdirSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { hashValue, readEnvelope, redactDeep, resolveInsideRoot, SCHEMA_VERSION, TOOL_VERSION, VeritasError, } from '@under18dev/veritas-core';
|
|
5
|
+
import { PlanDocument } from './schema.js';
|
|
6
|
+
export const IMPROVEMENTS_DIR = path.join('.veritas', 'improvements');
|
|
7
|
+
export const PLAN_ID = /^IP-[0-9a-f]{12}$/;
|
|
8
|
+
export function assertPlanId(planId) {
|
|
9
|
+
if (!PLAN_ID.test(planId)) {
|
|
10
|
+
throw new VeritasError('user', 'PLAN_ID_INVALID', `invalid plan id: ${JSON.stringify(planId)}`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Absolute directory of a plan, confined to the project root. */
|
|
14
|
+
export function planDir(root, planId) {
|
|
15
|
+
assertPlanId(planId);
|
|
16
|
+
return resolveInsideRoot(root, path.join(IMPROVEMENTS_DIR, planId));
|
|
17
|
+
}
|
|
18
|
+
/** Validate, redact and write an artifact envelope atomically under the plan directory. */
|
|
19
|
+
export function writePlanArtifact(root, planId, name, schema, data, context,
|
|
20
|
+
/** Fail with EEXIST instead of replacing an existing file (used to claim attempt numbers). */
|
|
21
|
+
options = {}) {
|
|
22
|
+
const parsed = schema.safeParse(data);
|
|
23
|
+
if (!parsed.success) {
|
|
24
|
+
throw new VeritasError('tool', 'ARTIFACT_INVALID', `improvement artifact ${name} does not match its schema`, undefined, parsed.error.issues);
|
|
25
|
+
}
|
|
26
|
+
assertPlanId(planId);
|
|
27
|
+
if (!/^[a-z0-9-]+\.json$/.test(name)) {
|
|
28
|
+
throw new VeritasError('tool', 'ARTIFACT_NAME_INVALID', `invalid improvement artifact name: ${name}`);
|
|
29
|
+
}
|
|
30
|
+
const file = resolveInsideRoot(root, path.join(IMPROVEMENTS_DIR, planId, name));
|
|
31
|
+
const meta = {
|
|
32
|
+
schemaVersion: SCHEMA_VERSION,
|
|
33
|
+
runId: context.runId,
|
|
34
|
+
createdAt: new Date().toISOString(),
|
|
35
|
+
toolVersion: TOOL_VERSION,
|
|
36
|
+
gitCommit: context.gitCommit,
|
|
37
|
+
configHash: context.configHash,
|
|
38
|
+
sourceHash: context.sourceHash,
|
|
39
|
+
};
|
|
40
|
+
mkdirSync(path.dirname(file), { recursive: true });
|
|
41
|
+
// A unique temporary name: concurrent writers in one process or several never share it.
|
|
42
|
+
const tmp = `${file}.${process.pid}.${randomBytes(6).toString('hex')}.tmp`;
|
|
43
|
+
writeFileSync(tmp, `${JSON.stringify({ meta, data: redactDeep(parsed.data) }, null, 2)}\n`);
|
|
44
|
+
if (options.exclusive) {
|
|
45
|
+
// link fails atomically when the name is taken, so two writers can never both claim it.
|
|
46
|
+
try {
|
|
47
|
+
linkSync(tmp, file);
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
unlinkSync(tmp);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else
|
|
54
|
+
renameSync(tmp, file);
|
|
55
|
+
return path.relative(root, file).split(path.sep).join('/');
|
|
56
|
+
}
|
|
57
|
+
export function readPlan(root, planId) {
|
|
58
|
+
const file = path.join(planDir(root, planId), 'plan.json');
|
|
59
|
+
if (!existsSync(file)) {
|
|
60
|
+
throw new VeritasError('user', 'PLAN_MISSING', `no plan ${planId} in ${IMPROVEMENTS_DIR}`, 'run `veritas improve --dry-run` first');
|
|
61
|
+
}
|
|
62
|
+
return readEnvelope(file, PlanDocument).data;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The approval token: sha256 of the canonical plan content. Timestamps are left out so the same plan always
|
|
66
|
+
* has the same token; any change to tests, files, expected values or budgets changes it.
|
|
67
|
+
*/
|
|
68
|
+
export function approvalTokenFor(doc) {
|
|
69
|
+
const { plan, ...rest } = doc;
|
|
70
|
+
// hashValue hashes canonical JSON (sorted keys, undefined dropped).
|
|
71
|
+
return hashValue({ ...rest, plan: plan ? { ...plan, createdAt: undefined } : null });
|
|
72
|
+
}
|
|
73
|
+
export function attemptCount(root, planId) {
|
|
74
|
+
const dir = planDir(root, planId);
|
|
75
|
+
if (!existsSync(dir))
|
|
76
|
+
return 0;
|
|
77
|
+
return readdirSync(dir).filter((f) => /^attempt-\d+\.json$/.test(f)).length;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC9G,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAEL,SAAS,EACT,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,YAAY,GACb,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;AACtE,MAAM,CAAC,MAAM,OAAO,GAAG,mBAAmB,CAAC;AAE3C,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,YAAY,CAAC,MAAM,EAAE,iBAAiB,EAAE,oBAAoB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAClG,CAAC;AACH,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,MAAc;IAClD,YAAY,CAAC,MAAM,CAAC,CAAC;IAErB,OAAO,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC;AACtE,CAAC;AASD,2FAA2F;AAC3F,MAAM,UAAU,iBAAiB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EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACvF,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,MAAc;IACvD,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAElC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IAE/B,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PatchFile } from './schema.js';
|
|
2
|
+
export interface PatchRules {
|
|
3
|
+
testInclude: string[];
|
|
4
|
+
maxPatchFiles: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Mechanical safety check of a patch before anything is written, even into the isolated workspace.
|
|
8
|
+
* Returns the list of violations; an empty list means the patch only adds new test files inside `root`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function validatePatch(root: string, files: PatchFile[], rules: PatchRules): string[];
|
|
11
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AA4BD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE,CAgE3F"}
|