@agentswf/lab 0.3.0 → 0.4.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/package.json +4 -4
- package/schema/{case-check.schema.json → lab-check.schema.json} +1 -1
- package/schema/{case-config.schema.json → lab-config.schema.json} +1 -1
- package/schema/{case-final.schema.json → lab-final.schema.json} +6 -6
- package/schema/{case-grade.schema.json → lab-grade.schema.json} +1 -1
- package/schema/{case-key.schema.json → lab-key.schema.json} +7 -0
- package/schema/{case-label.schema.json → lab-label.schema.json} +3 -3
- package/schema/{case-loop-report.schema.json → lab-loop-report.schema.json} +26 -15
- package/schema/{case-loop.schema.json → lab-loop.schema.json} +1 -1
- package/schema/{case-plan.schema.json → lab-plan.schema.json} +14 -3
- package/schema/{case-proposal.schema.json → lab-proposal.schema.json} +3 -3
- package/schema/{case-report.schema.json → lab-report.schema.json} +272 -36
- package/schema/{case-run.schema.json → lab-run.schema.json} +4 -4
- package/schema/{case-runs.schema.json → lab-runs.schema.json} +8 -1
- package/schema/{case-score.schema.json → lab-score.schema.json} +2 -2
- package/schema/{case-spread.schema.json → lab-spread.schema.json} +6 -6
- package/schema/{case-trial.schema.json → lab-trial.schema.json} +9 -9
- package/schema/{case-try.schema.json → lab-try.schema.json} +6 -6
- package/schema/local.json +3 -3
- package/src/env/capture.ts +1 -1
- package/src/env/compare.ts +7 -7
- package/src/env/fetch.ts +1 -1
- package/src/env/files.ts +14 -14
- package/src/env/grade-helper.ts +15 -15
- package/src/env/grader.ts +5 -2
- package/src/env/index.ts +18 -18
- package/src/env/trial.ts +5 -2
- package/src/format/key.ts +24 -0
- package/src/format/loop.ts +20 -19
- package/src/format/output.ts +120 -59
- package/src/format/records.ts +23 -20
- package/src/format/schema-files.ts +30 -30
- package/src/format/settings.ts +20 -13
- package/src/format/trial-env.ts +9 -6
- package/src/help/awf-lab.txt +1 -1
- package/src/help/case.txt +5 -4
- package/src/help/config.txt +2 -2
- package/src/help/label.txt +2 -2
- package/src/help/loop.txt +10 -10
- package/src/help/report.txt +1 -1
- package/src/help/run.txt +11 -10
- package/src/help/runs.txt +4 -3
- package/src/help/score.txt +4 -3
- package/src/lab/blame.ts +1 -1
- package/src/lab/box.ts +7 -5
- package/src/lab/capture-command.ts +11 -7
- package/src/lab/capture.ts +1 -1
- package/src/lab/check-command.ts +3 -3
- package/src/lab/cli.ts +9 -8
- package/src/lab/columns.ts +5 -5
- package/src/lab/command-context.ts +7 -7
- package/src/lab/compare.ts +8 -8
- package/src/lab/config-command.ts +25 -20
- package/src/lab/dataset.ts +37 -18
- package/src/lab/eval-files.ts +27 -16
- package/src/lab/folders.ts +26 -7
- package/src/lab/good.ts +1 -1
- package/src/lab/grading-stub.txt +2 -2
- package/src/lab/inspect.ts +13 -12
- package/src/lab/labels.ts +16 -11
- package/src/lab/loop-command.ts +68 -64
- package/src/lab/loop-records.ts +5 -5
- package/src/lab/loop.ts +105 -100
- package/src/lab/rates.ts +11 -6
- package/src/lab/record-copies.ts +1 -1
- package/src/lab/report-command.ts +8 -7
- package/src/lab/report.ts +172 -74
- package/src/lab/reuse.ts +29 -21
- package/src/lab/run-command.ts +304 -199
- package/src/lab/run-report.ts +49 -22
- package/src/lab/runs-command.ts +35 -27
- package/src/lab/scaffold.ts +19 -16
- package/src/lab/score-command.ts +72 -64
- package/src/lab/score.ts +1 -1
- package/src/lab/store.ts +3 -3
- package/src/lab/{trial-stub.txt → target-stub.txt} +3 -3
- package/src/lab/trial-settings.ts +17 -12
- package/src/lab/trial.ts +19 -23
- package/src/lab/usage.ts +1 -0
- package/src/lab/workflow-graders.ts +4 -1
- package/src/lab/workspace.ts +16 -9
- package/src/loop/propose.workflow.ts +1 -1
- package/src/shared/compare/index.ts +2 -2
- package/src/shared/compare/paired.ts +20 -20
- package/src/shared/compare/types.ts +4 -4
- package/src/write-schemas.ts +3 -3
- /package/schema/{case-good-record.schema.json → lab-good-record.schema.json} +0 -0
- /package/schema/{case-previous.schema.json → lab-previous.schema.json} +0 -0
package/src/format/output.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { ResolvedLimitsSchema, ResolvedSandboxSchema } from "./settings";
|
|
|
4
4
|
|
|
5
5
|
// What each command's `--json` prints, each its own kind, named in the command's help.
|
|
6
6
|
|
|
7
|
-
export const REPORT_KIND = "awf.
|
|
8
|
-
export const PLAN_KIND = "awf.
|
|
9
|
-
export const CHECK_KIND = "awf.
|
|
10
|
-
export const RUNS_KIND = "awf.
|
|
11
|
-
export const CONFIG_KIND = "awf.
|
|
12
|
-
export const LOOP_REPORT_KIND = "awf.
|
|
7
|
+
export const REPORT_KIND = "awf.lab-report/1";
|
|
8
|
+
export const PLAN_KIND = "awf.lab-plan/1";
|
|
9
|
+
export const CHECK_KIND = "awf.lab-check/1";
|
|
10
|
+
export const RUNS_KIND = "awf.lab-runs/1";
|
|
11
|
+
export const CONFIG_KIND = "awf.lab-config/1";
|
|
12
|
+
export const LOOP_REPORT_KIND = "awf.lab-loop-report/1";
|
|
13
13
|
|
|
14
14
|
const Text = Type.String({ minLength: 1 });
|
|
15
15
|
const Tally = Type.Object(
|
|
@@ -52,15 +52,67 @@ const PooledSchema = Type.Union([
|
|
|
52
52
|
Type.Object({ values: Type.Array(Type.Number()) }, { additionalProperties: false }),
|
|
53
53
|
]);
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
/**
|
|
56
|
+
* A column's trials in time and money: the medians of the trials that ran, left out when none did,
|
|
57
|
+
* and its estimates summed, reused trials' and grading's included.
|
|
58
|
+
*/
|
|
59
|
+
const TrialSumsSchema = Type.Object(
|
|
60
|
+
{
|
|
61
|
+
msMedian: Type.Optional(Type.Number({ minimum: 0 })),
|
|
62
|
+
estimateMedian: Type.Optional(Type.Number({ minimum: 0 })),
|
|
63
|
+
/** Every trial's estimate, reused ones' included, and the grades'. */
|
|
64
|
+
estimate: Type.Number({ minimum: 0 }),
|
|
65
|
+
/** Of it, the reused trials', run before. */
|
|
66
|
+
reusedEstimate: Type.Number({ minimum: 0 }),
|
|
67
|
+
/** Of it, the grades'. */
|
|
68
|
+
gradingEstimate: Type.Number({ minimum: 0 }),
|
|
69
|
+
/** A trial ran agents the lab couldn't price. */
|
|
70
|
+
unpriced: Type.Boolean(),
|
|
71
|
+
},
|
|
72
|
+
{ additionalProperties: false },
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
/** Where a column's code was: its folder, git state and the version its trials ran under. */
|
|
76
|
+
const CodeFields = {
|
|
77
|
+
path: Text,
|
|
78
|
+
branch: Type.Union([Text, Type.Null()]),
|
|
79
|
+
commit: Type.Union([Text, Type.Null()]),
|
|
80
|
+
dirty: Type.Boolean(),
|
|
81
|
+
/** The version its trials ran under: its `target.ts`'s, or a loop's id of its code. */
|
|
82
|
+
version: Text,
|
|
83
|
+
/** The sandbox and limits its trials ran under, from its own `target.ts`. */
|
|
84
|
+
sandbox: ResolvedSandboxSchema,
|
|
85
|
+
limits: ResolvedLimitsSchema,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const VerdictSchema = Type.Union([
|
|
89
|
+
Type.Enum(["passed", "failed", "flaky", "unclear"] as const),
|
|
90
|
+
Type.Null(),
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
export const LabReportSchema = Type.Object(
|
|
56
94
|
{
|
|
57
95
|
kind: Type.Literal(REPORT_KIND),
|
|
58
|
-
|
|
96
|
+
labRun: RunId,
|
|
59
97
|
dataset: Text,
|
|
60
98
|
partial: Type.Boolean(),
|
|
99
|
+
/** Why the run stopped starting trials, and how many of those asked it never ran. */
|
|
100
|
+
stop: Type.Optional(
|
|
101
|
+
Type.Object(
|
|
102
|
+
{
|
|
103
|
+
why: Type.Enum(["budget", "compare", "precondition", "stage"] as const),
|
|
104
|
+
notRun: Type.Integer({ minimum: 0 }),
|
|
105
|
+
},
|
|
106
|
+
{ additionalProperties: false },
|
|
107
|
+
),
|
|
108
|
+
),
|
|
61
109
|
exit: Type.Integer({ minimum: 0, maximum: 5 }),
|
|
62
110
|
/** The reference column's parameters: `--param` and each `--vary`'s first value. */
|
|
63
111
|
params: ParamsSchema,
|
|
112
|
+
/** The reference column's code. */
|
|
113
|
+
code: Type.Object(CodeFields, { additionalProperties: false }),
|
|
114
|
+
/** The reference column's trials in time and money. */
|
|
115
|
+
sums: TrialSumsSchema,
|
|
64
116
|
/** Trials copied from earlier runs, as nothing that shaped them changed. */
|
|
65
117
|
reused: Type.Integer({ minimum: 0 }),
|
|
66
118
|
/** The reference column's rates. */
|
|
@@ -81,14 +133,13 @@ export const CaseReportSchema = Type.Object(
|
|
|
81
133
|
Type.Object(
|
|
82
134
|
{
|
|
83
135
|
name: Text,
|
|
84
|
-
verdict:
|
|
85
|
-
Type.Enum(["passed", "failed", "flaky", "unclear"] as const),
|
|
86
|
-
Type.Null(),
|
|
87
|
-
]),
|
|
136
|
+
verdict: VerdictSchema,
|
|
88
137
|
/** A case with no verdict: why. */
|
|
89
138
|
none: Type.Optional(Type.Enum(["not graded", "graded by numbers"] as const)),
|
|
90
139
|
passed: Type.Integer({ minimum: 0 }),
|
|
91
140
|
trials: Type.Integer({ minimum: 0 }),
|
|
141
|
+
/** Its trials' ids in the reference column, a reused trial's its own run's. */
|
|
142
|
+
trialIds: Type.Array(Text),
|
|
92
143
|
knownFailing: Type.Boolean(),
|
|
93
144
|
outcomes: Type.Array(Type.Enum(OUTCOMES)),
|
|
94
145
|
why: Type.Optional(Type.String()),
|
|
@@ -165,15 +216,10 @@ export const CaseReportSchema = Type.Object(
|
|
|
165
216
|
Type.Union([
|
|
166
217
|
Type.Object(
|
|
167
218
|
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
reason: Type.String(),
|
|
173
|
-
metrics: Type.Array(Type.Unknown()),
|
|
174
|
-
},
|
|
175
|
-
{ additionalProperties: false },
|
|
176
|
-
),
|
|
219
|
+
decision: Type.Enum(["better", "worse", "tie", "undecided"] as const),
|
|
220
|
+
stop: Type.Boolean(),
|
|
221
|
+
reason: Type.String(),
|
|
222
|
+
metrics: Type.Array(Type.Unknown()),
|
|
177
223
|
},
|
|
178
224
|
{ additionalProperties: false },
|
|
179
225
|
),
|
|
@@ -196,28 +242,19 @@ export const CaseReportSchema = Type.Object(
|
|
|
196
242
|
{ additionalProperties: false },
|
|
197
243
|
),
|
|
198
244
|
),
|
|
199
|
-
|
|
200
|
-
branch: Type.Union([Text, Type.Null()]),
|
|
201
|
-
commit: Type.Union([Text, Type.Null()]),
|
|
202
|
-
dirty: Type.Boolean(),
|
|
245
|
+
...CodeFields,
|
|
203
246
|
params: ParamsSchema,
|
|
204
|
-
|
|
205
|
-
version: Text,
|
|
206
|
-
/** The sandbox and limits its trials ran under, from its own `trial.ts`. */
|
|
207
|
-
sandbox: ResolvedSandboxSchema,
|
|
208
|
-
limits: ResolvedLimitsSchema,
|
|
247
|
+
sums: TrialSumsSchema,
|
|
209
248
|
numbers: Type.Record(Text, Type.Record(Text, PooledSchema)),
|
|
210
249
|
numbersLeftOut: Type.Integer({ minimum: 0 }),
|
|
211
250
|
cases: Type.Array(
|
|
212
251
|
Type.Object(
|
|
213
252
|
{
|
|
214
253
|
name: Text,
|
|
215
|
-
verdict:
|
|
216
|
-
Type.Enum(["passed", "failed", "flaky", "unclear"] as const),
|
|
217
|
-
Type.Null(),
|
|
218
|
-
]),
|
|
254
|
+
verdict: VerdictSchema,
|
|
219
255
|
passed: Type.Integer({ minimum: 0 }),
|
|
220
256
|
trials: Type.Integer({ minimum: 0 }),
|
|
257
|
+
trialIds: Type.Array(Text),
|
|
221
258
|
},
|
|
222
259
|
{ additionalProperties: false },
|
|
223
260
|
),
|
|
@@ -244,18 +281,18 @@ export const CaseReportSchema = Type.Object(
|
|
|
244
281
|
},
|
|
245
282
|
{ additionalProperties: false, description: "awf-lab run, score and report --json." },
|
|
246
283
|
);
|
|
247
|
-
export type
|
|
284
|
+
export type LabReport = Type.Static<typeof LabReportSchema>;
|
|
248
285
|
|
|
249
286
|
const Usd = Type.Number({ minimum: 0 });
|
|
250
287
|
|
|
251
288
|
/** What `run`, `score`, `loop run` and `loop final` will do, before paid work: `--dry-run --json`. */
|
|
252
|
-
export const
|
|
289
|
+
export const LabPlanSchema = Type.Object(
|
|
253
290
|
{
|
|
254
291
|
kind: Type.Literal(PLAN_KIND),
|
|
255
292
|
command: Type.Enum(["run", "score", "loop run", "loop final"] as const),
|
|
256
293
|
dataset: Text,
|
|
257
|
-
/** `score`: the run it grades again. */
|
|
258
|
-
|
|
294
|
+
/** `score`: the lab run it grades again. */
|
|
295
|
+
labRun: Type.Optional(RunId),
|
|
259
296
|
/** The loop's name. */
|
|
260
297
|
loop: Type.Optional(Text),
|
|
261
298
|
/** The cases, each its trials: run in each column, or graded again. */
|
|
@@ -277,9 +314,16 @@ export const CasePlanSchema = Type.Object(
|
|
|
277
314
|
/** Graders with no earlier grade to price them by. */
|
|
278
315
|
unpriced: Type.Optional(Type.Array(Text)),
|
|
279
316
|
/** `loop run`: the tries it makes at most, and whether the start runs twice first. */
|
|
280
|
-
|
|
317
|
+
tries: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
281
318
|
spread: Type.Optional(Type.Boolean()),
|
|
282
|
-
/**
|
|
319
|
+
/**
|
|
320
|
+
* Why nothing runs or is graded, when nothing is: `run` with no case to run or every trial
|
|
321
|
+
* reused, `score` with every grade current, `loop final` with nothing kept.
|
|
322
|
+
*/
|
|
323
|
+
nothing: Type.Optional(Text),
|
|
324
|
+
/** `run`: the columns with no earlier trials under their parameters and version, unpriced. */
|
|
325
|
+
unestimated: Type.Optional(Type.Array(Text)),
|
|
326
|
+
/** From earlier trials and grades, each column's from its own; absent when there were none. */
|
|
283
327
|
estimate: Type.Optional(
|
|
284
328
|
Type.Object(
|
|
285
329
|
{ usd: Type.Optional(Usd), upTo: Type.Optional(Usd), ms: Type.Optional(Usd) },
|
|
@@ -294,10 +338,10 @@ export const CasePlanSchema = Type.Object(
|
|
|
294
338
|
description: "awf-lab run, score, loop run and loop final --dry-run --json.",
|
|
295
339
|
},
|
|
296
340
|
);
|
|
297
|
-
export type
|
|
341
|
+
export type LabPlan = Type.Static<typeof LabPlanSchema>;
|
|
298
342
|
|
|
299
343
|
/** `case check --json`: each case that failed a check or has a known good record. */
|
|
300
|
-
export const
|
|
344
|
+
export const LabCheckSchema = Type.Object(
|
|
301
345
|
{
|
|
302
346
|
kind: Type.Literal(CHECK_KIND),
|
|
303
347
|
/** Each dataset checked: `--dataset`'s, or every one. */
|
|
@@ -327,16 +371,24 @@ export const CaseCheckSchema = Type.Object(
|
|
|
327
371
|
},
|
|
328
372
|
{ additionalProperties: false, description: "awf-lab case check --json." },
|
|
329
373
|
);
|
|
330
|
-
export type
|
|
374
|
+
export type LabCheck = Type.Static<typeof LabCheckSchema>;
|
|
331
375
|
|
|
332
376
|
const Count = Type.Optional(Type.Integer({ minimum: 1 }));
|
|
333
377
|
const VerdictCounts = Type.Object(
|
|
334
|
-
{
|
|
378
|
+
{
|
|
379
|
+
passed: Count,
|
|
380
|
+
failed: Count,
|
|
381
|
+
flaky: Count,
|
|
382
|
+
unclear: Count,
|
|
383
|
+
/** Known-failing cases, whatever their verdict, as the report counts them. */
|
|
384
|
+
knownFailing: Count,
|
|
385
|
+
none: Count,
|
|
386
|
+
},
|
|
335
387
|
{ additionalProperties: false },
|
|
336
388
|
);
|
|
337
389
|
|
|
338
390
|
/** `runs --json`: the runs and loops kept, newest first, and the runs whose records don't read. */
|
|
339
|
-
export const
|
|
391
|
+
export const LabRunsSchema = Type.Object(
|
|
340
392
|
{
|
|
341
393
|
kind: Type.Literal(RUNS_KIND),
|
|
342
394
|
runs: Type.Array(
|
|
@@ -345,10 +397,15 @@ export const CaseRunsSchema = Type.Object(
|
|
|
345
397
|
id: RunId,
|
|
346
398
|
dataset: Text,
|
|
347
399
|
cases: Type.Integer({ minimum: 0 }),
|
|
400
|
+
/** The trials it holds, in every column, reused ones included. */
|
|
348
401
|
trials: Type.Integer({ minimum: 0 }),
|
|
349
402
|
columns: Type.Integer({ minimum: 1 }),
|
|
350
403
|
state: Type.Enum(["finished", "partial", "broke"] as const),
|
|
351
|
-
/**
|
|
404
|
+
/** Why it stopped starting trials, as its record says. */
|
|
405
|
+
stopped: Type.Optional(
|
|
406
|
+
Type.Enum(["budget", "compare", "precondition", "stage"] as const),
|
|
407
|
+
),
|
|
408
|
+
/** The reference column's case verdicts, counted as its report does; `none` for a case with none. */
|
|
352
409
|
verdicts: VerdictCounts,
|
|
353
410
|
},
|
|
354
411
|
{ additionalProperties: false },
|
|
@@ -372,7 +429,7 @@ export const CaseRunsSchema = Type.Object(
|
|
|
372
429
|
},
|
|
373
430
|
{ additionalProperties: false, description: "awf-lab runs --json." },
|
|
374
431
|
);
|
|
375
|
-
export type
|
|
432
|
+
export type LabRuns = Type.Static<typeof LabRunsSchema>;
|
|
376
433
|
|
|
377
434
|
/** A resolved value and the file it came from, or `default`. */
|
|
378
435
|
const ValueRow = Type.Object(
|
|
@@ -381,7 +438,7 @@ const ValueRow = Type.Object(
|
|
|
381
438
|
);
|
|
382
439
|
|
|
383
440
|
/** `config --json`: every dataset and loop and where each is defined, or one's resolved values. */
|
|
384
|
-
export const
|
|
441
|
+
export const LabConfigSchema = Type.Object(
|
|
385
442
|
{
|
|
386
443
|
kind: Type.Literal(CONFIG_KIND),
|
|
387
444
|
project: Text,
|
|
@@ -414,7 +471,7 @@ export const CaseConfigSchema = Type.Object(
|
|
|
414
471
|
},
|
|
415
472
|
{ additionalProperties: false, description: "awf-lab config --json." },
|
|
416
473
|
);
|
|
417
|
-
export type
|
|
474
|
+
export type LabConfig = Type.Static<typeof LabConfigSchema>;
|
|
418
475
|
|
|
419
476
|
/** `report --loop --json`, and `loop run` and `loop final --json`: a loop's tries and checks. */
|
|
420
477
|
export const LoopReportSchema = Type.Object(
|
|
@@ -433,10 +490,10 @@ export const LoopReportSchema = Type.Object(
|
|
|
433
490
|
spread: Type.Union([
|
|
434
491
|
Type.Object(
|
|
435
492
|
{
|
|
436
|
-
|
|
437
|
-
|
|
493
|
+
labRun: RunId,
|
|
494
|
+
decision: Type.Union([Text, Type.Null()]),
|
|
438
495
|
unsteady: Type.Array(Text),
|
|
439
|
-
|
|
496
|
+
estimate: Usd,
|
|
440
497
|
},
|
|
441
498
|
{ additionalProperties: false },
|
|
442
499
|
),
|
|
@@ -448,12 +505,15 @@ export const LoopReportSchema = Type.Object(
|
|
|
448
505
|
{
|
|
449
506
|
n: Type.Integer({ minimum: 1 }),
|
|
450
507
|
parent: Type.Integer({ minimum: 0 }),
|
|
451
|
-
|
|
508
|
+
outcome: Text,
|
|
452
509
|
why: Type.String(),
|
|
453
510
|
change: Type.Optional(Type.String()),
|
|
454
511
|
changed: Type.Array(Text),
|
|
455
|
-
|
|
456
|
-
|
|
512
|
+
labRun: Type.Optional(RunId),
|
|
513
|
+
/** The dataset's `compare`, its decision on the try against its parent. */
|
|
514
|
+
decision: Type.Optional(Type.Union([Text, Type.Null()])),
|
|
515
|
+
/** The try's estimate in dollars: its proposer's and its trials', summed. */
|
|
516
|
+
estimate: Usd,
|
|
457
517
|
},
|
|
458
518
|
{ additionalProperties: false },
|
|
459
519
|
),
|
|
@@ -464,11 +524,12 @@ export const LoopReportSchema = Type.Object(
|
|
|
464
524
|
Type.Object(
|
|
465
525
|
{
|
|
466
526
|
k: Type.Integer({ minimum: 1 }),
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
527
|
+
/** The kept try checked against the start. */
|
|
528
|
+
kept: Type.Integer({ minimum: 1 }),
|
|
529
|
+
labRun: RunId,
|
|
530
|
+
decision: Type.Union([Text, Type.Null()]),
|
|
470
531
|
why: Type.String(),
|
|
471
|
-
|
|
532
|
+
estimate: Usd,
|
|
472
533
|
},
|
|
473
534
|
{ additionalProperties: false },
|
|
474
535
|
),
|
package/src/format/records.ts
CHANGED
|
@@ -7,11 +7,11 @@ import { DATASET_ERRORS, GatheredSchema, RefusedSchema } from "./trial-file";
|
|
|
7
7
|
// folder's `grade.json`. Each is checked against its schema before it is written and when it is
|
|
8
8
|
// read.
|
|
9
9
|
|
|
10
|
-
export const RUN_KIND = "awf.
|
|
11
|
-
export const TRIAL_KIND = "awf.
|
|
12
|
-
export const SCORE_KIND = "awf.
|
|
13
|
-
export const GRADE_KIND = "awf.
|
|
14
|
-
export const LABEL_KIND = "awf.
|
|
10
|
+
export const RUN_KIND = "awf.lab-run/1";
|
|
11
|
+
export const TRIAL_KIND = "awf.lab-trial/1";
|
|
12
|
+
export const SCORE_KIND = "awf.lab-score/1";
|
|
13
|
+
export const GRADE_KIND = "awf.lab-grade/1";
|
|
14
|
+
export const LABEL_KIND = "awf.lab-label/1";
|
|
15
15
|
|
|
16
16
|
const Text = Type.String({ minLength: 1 });
|
|
17
17
|
const Time = Type.String({ format: "date-time" });
|
|
@@ -27,13 +27,13 @@ export const FolderSchema = Type.Object(
|
|
|
27
27
|
commit: Type.Union([Text, Type.Null()]),
|
|
28
28
|
dirty: Type.Boolean(),
|
|
29
29
|
/**
|
|
30
|
-
* The version its trials ran under: its `
|
|
30
|
+
* The version its trials ran under: its `target.ts`'s, semver, or under a loop the lab's own id
|
|
31
31
|
* of the code, `loop {name} {started}` for the start and `… try {n}` for a try.
|
|
32
32
|
*/
|
|
33
33
|
version: Text,
|
|
34
|
-
/** The sandbox its trials ran under, from its own `
|
|
34
|
+
/** The sandbox its trials ran under, from its own `target.ts`, resolved. */
|
|
35
35
|
sandbox: ResolvedSandboxSchema,
|
|
36
|
-
/** The limits its trials ran under: `--limit` over its own `
|
|
36
|
+
/** The limits its trials ran under: `--limit` over its own `target.ts`'s over the defaults. */
|
|
37
37
|
limits: ResolvedLimitsSchema,
|
|
38
38
|
},
|
|
39
39
|
{ additionalProperties: false },
|
|
@@ -41,7 +41,7 @@ export const FolderSchema = Type.Object(
|
|
|
41
41
|
export type Folder = Type.Static<typeof FolderSchema>;
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* A parameter's name: plain words a `
|
|
44
|
+
* A parameter's name: plain words a `target.ts` declares and reads as `trial.params`. A dot is kept for the
|
|
45
45
|
* lab's own parameters.
|
|
46
46
|
*/
|
|
47
47
|
export const PARAM_NAME = /^[A-Za-z][A-Za-z0-9_-]*$/;
|
|
@@ -169,13 +169,13 @@ const ReachSchema = Type.Object(
|
|
|
169
169
|
export const TrialRecordSchema = Type.Object(
|
|
170
170
|
{
|
|
171
171
|
kind: Type.Literal(TRIAL_KIND),
|
|
172
|
-
|
|
172
|
+
labRun: RunId,
|
|
173
173
|
dataset: Text,
|
|
174
174
|
case: Text,
|
|
175
175
|
/** The column's index in the run's `columns`. */
|
|
176
176
|
column: Type.Integer({ minimum: 0 }),
|
|
177
177
|
trial: Type.Integer({ minimum: 1 }),
|
|
178
|
-
/** The column's parameters, as `
|
|
178
|
+
/** The column's parameters, as `target.ts` and the graders were given them. */
|
|
179
179
|
params: ParamsSchema,
|
|
180
180
|
/**
|
|
181
181
|
* The column's version, as its folder's: kept whole, though only its major, minor and
|
|
@@ -184,7 +184,7 @@ export const TrialRecordSchema = Type.Object(
|
|
|
184
184
|
version: Text,
|
|
185
185
|
/**
|
|
186
186
|
* What a later trial must match to stand in for this one, as one digest: the version's major,
|
|
187
|
-
* minor and pre-release tag, the `agentswf` and lab versions, the resolved
|
|
187
|
+
* minor and pre-release tag, the `agentswf` and lab versions, the resolved target settings and
|
|
188
188
|
* parameters, and the built case.
|
|
189
189
|
*/
|
|
190
190
|
reuse: Type.Optional(Digest),
|
|
@@ -195,7 +195,7 @@ export const TrialRecordSchema = Type.Object(
|
|
|
195
195
|
reused: Type.Optional(
|
|
196
196
|
Type.Object(
|
|
197
197
|
{
|
|
198
|
-
|
|
198
|
+
labRun: RunId,
|
|
199
199
|
column: Type.Integer({ minimum: 0 }),
|
|
200
200
|
trial: Type.Integer({ minimum: 1 }),
|
|
201
201
|
},
|
|
@@ -207,7 +207,7 @@ export const TrialRecordSchema = Type.Object(
|
|
|
207
207
|
input: Digest,
|
|
208
208
|
/** The column's sandbox as it resolved: `by: "lab"`, the lab's box around the whole trial. */
|
|
209
209
|
sandbox: ResolvedSandboxSchema,
|
|
210
|
-
/** The column's limits as they resolved, `--limit` over `
|
|
210
|
+
/** The column's limits as they resolved, `--limit` over `target.ts`'s over the defaults. */
|
|
211
211
|
limits: ResolvedLimitsSchema,
|
|
212
212
|
models: Type.Array(Text),
|
|
213
213
|
at: Time,
|
|
@@ -217,8 +217,11 @@ export const TrialRecordSchema = Type.Object(
|
|
|
217
217
|
{ additionalProperties: false },
|
|
218
218
|
),
|
|
219
219
|
),
|
|
220
|
-
/**
|
|
221
|
-
|
|
220
|
+
/**
|
|
221
|
+
* The trial's id: its workflow run's, as `awf` named it. Absent when the trial ended before
|
|
222
|
+
* one started (leaked, the lab).
|
|
223
|
+
*/
|
|
224
|
+
trialId: Type.Optional(Text),
|
|
222
225
|
runOutcome: Type.Optional(Text),
|
|
223
226
|
runReason: Type.Optional(Type.String()),
|
|
224
227
|
ms: Type.Number({ minimum: 0 }),
|
|
@@ -420,15 +423,15 @@ const MARKS = ["good", "needs-work", "cleared"] as const;
|
|
|
420
423
|
export type Mark = (typeof MARKS)[number];
|
|
421
424
|
|
|
422
425
|
/**
|
|
423
|
-
* A line of `{store}/labels/{dataset}.jsonl`: the person's
|
|
424
|
-
*
|
|
426
|
+
* A line of `{store}/labels/{dataset}.jsonl`: the person's mark on one trial, found by its
|
|
427
|
+
* trial id, so a reused copy keeps it. The newest line of a trial wins; `cleared` takes
|
|
425
428
|
* a label back.
|
|
426
429
|
*/
|
|
427
430
|
export const LabelRecordSchema = Type.Object(
|
|
428
431
|
{
|
|
429
432
|
kind: Type.Literal(LABEL_KIND),
|
|
430
|
-
/** The trial's workflow run
|
|
431
|
-
|
|
433
|
+
/** The trial's id, its workflow run's as `awf` named it: not the lab run's. */
|
|
434
|
+
trialId: Text,
|
|
432
435
|
case: Text,
|
|
433
436
|
mark: Type.Enum(MARKS),
|
|
434
437
|
/** Why it needs work. */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FinalSchema, LoopSchema, ProposalSchema, SpreadSchema, TrySchema } from "./loop";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
LabCheckSchema,
|
|
4
|
+
LabConfigSchema,
|
|
5
|
+
LabPlanSchema,
|
|
6
|
+
LabReportSchema,
|
|
7
|
+
LabRunsSchema,
|
|
8
8
|
LoopReportSchema,
|
|
9
9
|
} from "./output";
|
|
10
10
|
import {
|
|
@@ -20,45 +20,45 @@ import { KeySchema, LocalFileSchema } from "./settings";
|
|
|
20
20
|
|
|
21
21
|
const DRAFT = "https://json-schema.org/draft/2020-12/schema";
|
|
22
22
|
|
|
23
|
-
/** The
|
|
24
|
-
export const
|
|
23
|
+
/** The lab's published JSON Schemas, by file name under `packages/lab/schema/`. */
|
|
24
|
+
export const LAB_SCHEMA_FILES = {
|
|
25
25
|
"local.json": { title: "awf-lab's evals/awf-lab.local.json", schema: LocalFileSchema },
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
26
|
+
"lab-key.schema.json": { title: "awf-lab case key, its frontmatter", schema: KeySchema },
|
|
27
|
+
"lab-run.schema.json": { title: "awf-lab lab run", schema: RunRecordSchema },
|
|
28
|
+
"lab-trial.schema.json": { title: "awf-lab trial", schema: TrialRecordSchema },
|
|
29
|
+
"lab-score.schema.json": { title: "awf-lab trial score", schema: ScoreRecordSchema },
|
|
30
|
+
"lab-good-record.schema.json": {
|
|
31
31
|
title: "awf-lab case's known good record, key/good/record.json",
|
|
32
32
|
schema: GoodRecordSchema,
|
|
33
33
|
},
|
|
34
|
-
"
|
|
35
|
-
"
|
|
34
|
+
"lab-grade.schema.json": { title: "awf-lab grade folder's grade.json", schema: GradeFileSchema },
|
|
35
|
+
"lab-previous.schema.json": {
|
|
36
36
|
title: "awf-lab grade folder's previous.json",
|
|
37
37
|
schema: PreviousSchema,
|
|
38
38
|
},
|
|
39
|
-
"
|
|
39
|
+
"lab-report.schema.json": {
|
|
40
40
|
title: "awf-lab run, score and report --json",
|
|
41
|
-
schema:
|
|
41
|
+
schema: LabReportSchema,
|
|
42
42
|
},
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
43
|
+
"lab-plan.schema.json": { title: "awf-lab --dry-run --json", schema: LabPlanSchema },
|
|
44
|
+
"lab-check.schema.json": { title: "awf-lab case check --json", schema: LabCheckSchema },
|
|
45
|
+
"lab-runs.schema.json": { title: "awf-lab runs --json", schema: LabRunsSchema },
|
|
46
|
+
"lab-config.schema.json": { title: "awf-lab config --json", schema: LabConfigSchema },
|
|
47
|
+
"lab-loop-report.schema.json": {
|
|
48
48
|
title: "awf-lab report --loop --json",
|
|
49
49
|
schema: LoopReportSchema,
|
|
50
50
|
},
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
51
|
+
"lab-label.schema.json": { title: "awf-lab label", schema: LabelRecordSchema },
|
|
52
|
+
"lab-loop.schema.json": { title: "awf-lab loop's loop.json", schema: LoopSchema },
|
|
53
|
+
"lab-try.schema.json": { title: "awf-lab loop's try.json", schema: TrySchema },
|
|
54
|
+
"lab-proposal.schema.json": { title: "awf-lab loop's proposal.json", schema: ProposalSchema },
|
|
55
|
+
"lab-final.schema.json": { title: "awf-lab loop's final check", schema: FinalSchema },
|
|
56
|
+
"lab-spread.schema.json": { title: "awf-lab loop's spread.json", schema: SpreadSchema },
|
|
57
57
|
} as const;
|
|
58
58
|
|
|
59
|
-
export type
|
|
59
|
+
export type LabSchemaName = keyof typeof LAB_SCHEMA_FILES;
|
|
60
60
|
|
|
61
|
-
export function
|
|
62
|
-
const { title, schema } =
|
|
61
|
+
export function renderLabSchemaFile(name: LabSchemaName): string {
|
|
62
|
+
const { title, schema } = LAB_SCHEMA_FILES[name];
|
|
63
63
|
return `${JSON.stringify({ $schema: DRAFT, title, ...schema }, null, 2)}\n`;
|
|
64
64
|
}
|
package/src/format/settings.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { TurnRecord } from "@agentswf/contract/records";
|
|
|
2
2
|
import Type from "typebox";
|
|
3
3
|
import { SEMVER } from "../shared/version";
|
|
4
4
|
|
|
5
|
-
// The files a person writes: `
|
|
5
|
+
// The files a person writes: `target.ts`, `grading.ts`, `awf-lab.config.ts` and a case's `key.md`,
|
|
6
6
|
// with no format marker (story 044, principle 8), and the one JSON file, `awf-lab.local.json`,
|
|
7
7
|
// checked by its `$schema`. The TypeScript files are loaded in a helper process in your checkout,
|
|
8
8
|
// which hands their values over as JSON: a function as `{ "$function": true }`, a `required()`
|
|
@@ -67,7 +67,7 @@ export const NetworkSchema = Type.Object(
|
|
|
67
67
|
{ additionalProperties: false },
|
|
68
68
|
);
|
|
69
69
|
|
|
70
|
-
/** `
|
|
70
|
+
/** `target.ts`'s `sandbox`: who isolates a trial, with what, and where it may go. */
|
|
71
71
|
export const SandboxSchema = Type.Object(
|
|
72
72
|
{
|
|
73
73
|
by: Type.Optional(
|
|
@@ -87,14 +87,14 @@ export const SandboxSchema = Type.Object(
|
|
|
87
87
|
);
|
|
88
88
|
export type Sandbox = Type.Static<typeof SandboxSchema>;
|
|
89
89
|
|
|
90
|
-
export const LIMIT_PHASES = ["setup", "
|
|
90
|
+
export const LIMIT_PHASES = ["setup", "workflow", "after"] as const;
|
|
91
91
|
export type LimitPhase = (typeof LIMIT_PHASES)[number];
|
|
92
92
|
|
|
93
|
-
/** `
|
|
93
|
+
/** `target.ts`'s `limits`: each phase's, as a duration. */
|
|
94
94
|
export const LimitsSchema = Type.Object(
|
|
95
95
|
{
|
|
96
96
|
setup: Type.Optional({ ...DurationSchema, description: 'setup\'s limit; "10m" when absent.' }),
|
|
97
|
-
|
|
97
|
+
workflow: Type.Optional({
|
|
98
98
|
...DurationSchema,
|
|
99
99
|
description: 'The workflow\'s limit; "30m" when absent.',
|
|
100
100
|
}),
|
|
@@ -132,9 +132,9 @@ export const ResolvedSandboxSchema = Type.Union([
|
|
|
132
132
|
]);
|
|
133
133
|
export type ResolvedSandbox = Type.Static<typeof ResolvedSandboxSchema>;
|
|
134
134
|
|
|
135
|
-
/** The limits a trial ran under, resolved: every phase's, `--limit` over `
|
|
135
|
+
/** The limits a trial ran under, resolved: every phase's, `--limit` over `target.ts` over the defaults. */
|
|
136
136
|
export const ResolvedLimitsSchema = Type.Object(
|
|
137
|
-
{ setup: DurationSchema,
|
|
137
|
+
{ setup: DurationSchema, workflow: DurationSchema, after: DurationSchema },
|
|
138
138
|
{ additionalProperties: false },
|
|
139
139
|
);
|
|
140
140
|
export type ResolvedLimits = Type.Static<typeof ResolvedLimitsSchema>;
|
|
@@ -148,8 +148,8 @@ const FunctionSchema = Type.Object(
|
|
|
148
148
|
/** A dataset's or eval folder's name, and a case's. */
|
|
149
149
|
export const NameSchema = Type.String({ pattern: NAME_PATTERN });
|
|
150
150
|
|
|
151
|
-
/** `
|
|
152
|
-
export const
|
|
151
|
+
/** `target.ts`'s `defineTarget`: everything that shapes a trial. */
|
|
152
|
+
export const TargetFileSchema = Type.Object(
|
|
153
153
|
{
|
|
154
154
|
/** As declared, or as its function returned it in this checkout. */
|
|
155
155
|
version: VersionSchema,
|
|
@@ -174,7 +174,7 @@ export const TrialFileSchema = Type.Object(
|
|
|
174
174
|
{ additionalProperties: false },
|
|
175
175
|
);
|
|
176
176
|
|
|
177
|
-
export type
|
|
177
|
+
export type TargetFile = Type.Static<typeof TargetFileSchema>;
|
|
178
178
|
|
|
179
179
|
/** What a grader reads: the facts alone, or the trial's record and saved files too. */
|
|
180
180
|
const Reads = Type.Union([Type.Literal("facts"), Type.Literal("trial")]);
|
|
@@ -242,7 +242,7 @@ export const DatasetEntrySchema = Type.Object(
|
|
|
242
242
|
Type.String({
|
|
243
243
|
minLength: 1,
|
|
244
244
|
description:
|
|
245
|
-
"The eval folder, holding
|
|
245
|
+
"The eval folder, holding target.ts and grading.ts, relative to evals/; the folder of the dataset's name when absent.",
|
|
246
246
|
}),
|
|
247
247
|
),
|
|
248
248
|
data: Type.Optional(
|
|
@@ -254,7 +254,7 @@ export const DatasetEntrySchema = Type.Object(
|
|
|
254
254
|
),
|
|
255
255
|
params: Type.Optional(
|
|
256
256
|
Type.Record(Type.String({ pattern: PARAM_PATTERN }), Type.String({ minLength: 1 }), {
|
|
257
|
-
description: "Values over
|
|
257
|
+
description: "Values over target.ts's defaults, each a parameter it declares.",
|
|
258
258
|
}),
|
|
259
259
|
),
|
|
260
260
|
records: Type.Optional(
|
|
@@ -330,7 +330,8 @@ export const LoopEntrySchema = Type.Object(
|
|
|
330
330
|
),
|
|
331
331
|
params: Type.Optional(
|
|
332
332
|
Type.Record(Type.String({ pattern: PARAM_PATTERN }), Type.String({ minLength: 1 }), {
|
|
333
|
-
description:
|
|
333
|
+
description:
|
|
334
|
+
"Values over target.ts's and the dataset entry's, for every trial of the loop.",
|
|
334
335
|
}),
|
|
335
336
|
),
|
|
336
337
|
cases: Type.Optional(
|
|
@@ -513,6 +514,12 @@ export const KeySchema = Type.Object(
|
|
|
513
514
|
"Plain words the report groups cases by, and --tags picks them by; no grader reads them.",
|
|
514
515
|
}),
|
|
515
516
|
),
|
|
517
|
+
shared: Type.Optional(
|
|
518
|
+
Type.Array(Type.String(), {
|
|
519
|
+
description:
|
|
520
|
+
"The files and folders of the data folder's shared/ this case gets, relative to it, a folder whole; every one when absent, none when [].",
|
|
521
|
+
}),
|
|
522
|
+
),
|
|
516
523
|
captured: Type.Optional(
|
|
517
524
|
Type.Object(
|
|
518
525
|
{
|