@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/trial-env.ts
CHANGED
|
@@ -5,9 +5,12 @@ import type { Gathered, Refused } from "./trial-file";
|
|
|
5
5
|
|
|
6
6
|
/** The environment variables the lab sets for a trial's `awf run`. */
|
|
7
7
|
export const TRIAL_ENV = {
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* The built case folder: the data folder's `shared/`, or what the key's `shared` names of it,
|
|
10
|
+
* and the case's `input/`. No key.
|
|
11
|
+
*/
|
|
9
12
|
case: "AWF_LAB_CASE",
|
|
10
|
-
/** The trial file `
|
|
13
|
+
/** The trial file `defineTarget` appends to. */
|
|
11
14
|
trial: "AWF_LAB_TRIAL",
|
|
12
15
|
/** The trial's empty scratch folder, also the run's `--cwd`. */
|
|
13
16
|
scratch: "AWF_LAB_SCRATCH",
|
|
@@ -23,7 +26,7 @@ export const TRIAL_ENV = {
|
|
|
23
26
|
|
|
24
27
|
/** The files of a grade folder, as the lab writes them and `gradeCase()` reads them. */
|
|
25
28
|
export const GRADE_FILES = {
|
|
26
|
-
/** `grade.json`, `kind: awf.
|
|
29
|
+
/** `grade.json`, `kind: awf.lab-grade/1`. */
|
|
27
30
|
grade: "grade.json",
|
|
28
31
|
/** The built case folder. */
|
|
29
32
|
case: "case",
|
|
@@ -40,15 +43,15 @@ export const GRADE_FILES = {
|
|
|
40
43
|
previous: "previous.json",
|
|
41
44
|
} as const;
|
|
42
45
|
|
|
43
|
-
/** From `
|
|
46
|
+
/** From `target.ts`, resolved by the lab. */
|
|
44
47
|
export type TrialSettings = {
|
|
45
48
|
dataset: string;
|
|
46
49
|
/** The eval folder, whose files are never the workflow's source. */
|
|
47
50
|
datasetDir?: string;
|
|
48
51
|
/** `limits.setup`, in ms. */
|
|
49
52
|
setupMs: number;
|
|
50
|
-
/** `limits.
|
|
51
|
-
|
|
53
|
+
/** `limits.workflow`, the workflow's limit, in ms. */
|
|
54
|
+
workflowMs: number;
|
|
52
55
|
/** `limits.after`, `evidence`'s and cleanup's, in ms. */
|
|
53
56
|
afterMs: number;
|
|
54
57
|
/** Hosts the workflow's code may reach for real: `sandbox.network.code` and the engine's own. */
|
package/src/help/awf-lab.txt
CHANGED
|
@@ -13,7 +13,7 @@ Run and grade
|
|
|
13
13
|
run the workflow on the cases, graded
|
|
14
14
|
score [{run}] a run's kept trials graded again, with no trial run
|
|
15
15
|
report [{run}] a run's report again, or a loop's, or one case in full
|
|
16
|
-
label {trial id} your
|
|
16
|
+
label {trial id} your mark on a trial
|
|
17
17
|
|
|
18
18
|
Improve
|
|
19
19
|
loop run {name} start or go on with a loop
|
package/src/help/case.txt
CHANGED
|
@@ -4,9 +4,10 @@ usage: awf-lab [-C {folder}] case new {dataset}/{case}
|
|
|
4
4
|
awf-lab [-C {folder}] case pin {trial id} [--replace]
|
|
5
5
|
awf-lab [-C {folder}] case check [--dataset {name}] [--cases {a,b}] [--tags {a,b}] [--json]
|
|
6
6
|
|
|
7
|
-
case new: a case folder, its input/ and its key
|
|
8
|
-
|
|
9
|
-
evals
|
|
7
|
+
case new: a case folder, its input/ and its key, in the dataset's data folder; the key carries its
|
|
8
|
+
marker and draft: true, so no grader runs on it until you write it and remove that line. For a
|
|
9
|
+
new dataset, also the folder evals/{dataset}/ with stub target.ts and grading.ts, and
|
|
10
|
+
awf-lab.local.json in evals/.gitignore
|
|
10
11
|
case capture: a case from a trial, by its id, from the case it ran; or from a real run, by its awf
|
|
11
12
|
run id, through the dataset's capture.ts; its key a draft to finish. With --good, a case from a
|
|
12
13
|
trial also keeps the trial's record as its known good record
|
|
@@ -31,7 +32,7 @@ case check: every case, held out and drafts too: its key reads and carries its m
|
|
|
31
32
|
--cases {a,b} check only these cases, in whichever dataset holds them
|
|
32
33
|
--tags {a,b} check only the cases whose key lists one of these tags; with --cases, those
|
|
33
34
|
of them that do
|
|
34
|
-
--json case check's result as JSON, awf.
|
|
35
|
+
--json case check's result as JSON, awf.lab-check/1: a list of datasets, each with
|
|
35
36
|
its cases that failed or have a known good record
|
|
36
37
|
|
|
37
38
|
exit: 0 done, every case checked passed; 1 case check: a key or a known good record failed;
|
package/src/help/config.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
usage: awf-lab [-C {folder}] config [--dataset {name}] [--case {name}] [--loop {name}] [--json]
|
|
2
2
|
|
|
3
3
|
loads and checks every file the lab reads: evals/awf-lab.config.ts, evals/awf-lab.local.json, and
|
|
4
|
-
each eval folder's
|
|
4
|
+
each eval folder's target.ts and grading.ts, and every loop entry and its globs; then lists every
|
|
5
5
|
dataset and loop and the files that define each
|
|
6
6
|
|
|
7
7
|
-C {folder} run as if started in {folder}
|
|
@@ -9,6 +9,6 @@ dataset and loop and the files that define each
|
|
|
9
9
|
--case {name} one case's values from its key too
|
|
10
10
|
--loop {name} every value of one loop's entry, and the file it came from, the files every
|
|
11
11
|
loop is denied included
|
|
12
|
-
--json the listing, or the values, as JSON, awf.
|
|
12
|
+
--json the listing, or the values, as JSON, awf.lab-config/1
|
|
13
13
|
|
|
14
14
|
exit: 0 done, 2 refused, 4 the lab broke
|
package/src/help/label.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
usage: awf-lab [-C {folder}] label {trial id} (--good | --needs-work "{note}" | --clear)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
agreement with it
|
|
3
|
+
your mark on a trial, good or needs work, by its id (report --case lists them); the report
|
|
4
|
+
gives the lab's agreement with it
|
|
5
5
|
|
|
6
6
|
-C {folder} run as if started in {folder}
|
|
7
7
|
--good the trial went well
|
package/src/help/loop.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
usage: awf-lab [-C {folder}] loop run {name} --budget {usd} [--new] [--
|
|
1
|
+
usage: awf-lab [-C {folder}] loop run {name} --budget {usd} [--new] [--tries {n}]
|
|
2
2
|
[--allowance {pct|off}] [--concurrency {n}] [--dry-run]
|
|
3
3
|
[--json]
|
|
4
4
|
awf-lab [-C {folder}] loop final {name} --budget {usd} [--concurrency {n}] [--dry-run]
|
|
@@ -9,12 +9,12 @@ a loop is an entry of loops in evals/awf-lab.config.ts or the local file, and th
|
|
|
9
9
|
its dataset, its brief, the files a try may edit (edit's allow, less deny), its proposer, trials,
|
|
10
10
|
params, cases, tags and spread; awf-lab config --loop {name} shows it resolved
|
|
11
11
|
loop run: a proposer changes a copy of the code from the tuning cases' feedback, the copy runs
|
|
12
|
-
against the
|
|
13
|
-
better. A try that edits a file edit doesn't allow, or anything under evals/, an
|
|
14
|
-
git ignores, or a key's text copied into code, is refused before it runs. The
|
|
15
|
-
loop from your checkout and records its entry; again, it goes on with the
|
|
16
|
-
entry, refused when the entry changed since. The tuning cases' known good
|
|
17
|
-
first
|
|
12
|
+
against the best version so far case by case until the dataset's compare stops it, and it is kept
|
|
13
|
+
only when better. A try that edits a file edit doesn't allow, or anything under evals/, an
|
|
14
|
+
install, a file git ignores, or a key's text copied into code, is refused before it runs. The
|
|
15
|
+
first run starts a loop from your checkout and records its entry; again, it goes on with the
|
|
16
|
+
newest loop of the entry, refused when the entry changed since. The tuning cases' known good
|
|
17
|
+
records are checked first
|
|
18
18
|
loop final: the newest loop's kept code against its start on the held-out cases, once, under the
|
|
19
19
|
loop's params and trials, their known good records checked first
|
|
20
20
|
loop patch: the newest loop's kept code against its start, as a patch; report --loop {id} reads an
|
|
@@ -29,14 +29,14 @@ loop run and loop final print their plan and an estimate from earlier trials, an
|
|
|
29
29
|
loop keeps no budget of its own; report --loop gives its total so far
|
|
30
30
|
--new a new loop from the entry as it is now; the one before it is kept, and shares
|
|
31
31
|
no trial with it
|
|
32
|
-
--
|
|
32
|
+
--tries {n} the tries this command makes; 1 by default
|
|
33
33
|
--allowance {pct|off}
|
|
34
34
|
wait while a plan window the loop's agents draw on is this far used; the
|
|
35
35
|
local file's allowance, or 90
|
|
36
36
|
--concurrency {n} trials at once, over the local file's concurrency; 1 by default
|
|
37
37
|
--dry-run print the plan, and run nothing; --budget may be left out
|
|
38
|
-
--json the loop's report as JSON, awf.
|
|
39
|
-
awf.
|
|
38
|
+
--json the loop's report as JSON, awf.lab-loop-report/1; with --dry-run, the plan,
|
|
39
|
+
awf.lab-plan/1
|
|
40
40
|
|
|
41
41
|
exit: 0 done, whatever was decided, a stall included; 1 loop final or loop patch: nothing kept to
|
|
42
42
|
check or patch; 2 refused: an unknown flag, a changed entry, a failing known good record, or the
|
package/src/help/report.txt
CHANGED
|
@@ -7,7 +7,7 @@ the estimates so far
|
|
|
7
7
|
|
|
8
8
|
-C {folder} run as if started in {folder}
|
|
9
9
|
--case {name} one case in full: each trial, its id, facts and grades
|
|
10
|
-
--json the report as JSON, awf.
|
|
10
|
+
--json the report as JSON, awf.lab-report/1; with --loop, awf.lab-loop-report/1
|
|
11
11
|
--md the report as Markdown, to paste into a pull request or an issue
|
|
12
12
|
--loop {name or id}
|
|
13
13
|
a loop's report: by its name, the newest loop of that name; by its id, from
|
package/src/help/run.txt
CHANGED
|
@@ -8,7 +8,7 @@ the workflow, as it is in your checkout, on each case, each trial in a throwaway
|
|
|
8
8
|
against its key. It prints the plan and an estimate from earlier trials, then asks on a terminal
|
|
9
9
|
|
|
10
10
|
-C {folder} run as if started in {folder}
|
|
11
|
-
--dataset {name} the dataset: a folder of evals/ with
|
|
11
|
+
--dataset {name} the dataset: a folder of evals/ with target.ts and cases/, or one the config or
|
|
12
12
|
the local file names; needed only when there is more than one
|
|
13
13
|
--cases {a,b} only these cases
|
|
14
14
|
--tags {a,b} only the cases whose key lists one of these tags; with --cases, those of them
|
|
@@ -23,23 +23,23 @@ against its key. It prints the plan and an estimate from earlier trials, then as
|
|
|
23
23
|
then trial 2
|
|
24
24
|
--against {folder}
|
|
25
25
|
also run the cases on the code in another checkout of the project, as a column
|
|
26
|
-
beside yours; repeatable. Its
|
|
27
|
-
sandbox and limits; its cases, keys and graders are never read. Its
|
|
26
|
+
beside yours; repeatable. Its target.ts and code run, under that target's
|
|
27
|
+
sandbox and limits; its cases, keys and graders are never read. Its target's
|
|
28
28
|
version must differ from every other column's in major, minor or pre-release
|
|
29
29
|
tag
|
|
30
30
|
--param {name}={value}
|
|
31
|
-
a parameter
|
|
31
|
+
a parameter target.ts declares, for every trial, which it reads as trial.params
|
|
32
32
|
and graders as params; repeatable, over its default and the dataset entry's; a
|
|
33
33
|
value is a string
|
|
34
34
|
--vary {name}={a,b}
|
|
35
35
|
a column for each value, each folder; repeatable, every combination run. The
|
|
36
36
|
reference column is your checkout under each --vary's first value: the exit
|
|
37
37
|
code, history and --failed are its. For many named settings, one parameter
|
|
38
|
-
that
|
|
38
|
+
that target.ts looks up in a table: --vary variant=lenses,fork
|
|
39
39
|
--limit {phase}={duration}
|
|
40
|
-
a phase's limit for every column, over
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
a phase's limit for every column, over target.ts's limits: setup, workflow or
|
|
41
|
+
after (evidence and cleanup), such as --limit workflow=1h; repeatable, each
|
|
42
|
+
phase once. The limits are target settings, so a trial kept under others
|
|
43
43
|
isn't reused; 60s and 1m are the same
|
|
44
44
|
--fresh run every trial anew; without it, a trial kept from an earlier run stands in
|
|
45
45
|
while its version, the agentswf and lab versions, the parameters, the
|
|
@@ -50,8 +50,9 @@ against its key. It prints the plan and an estimate from earlier trials, then as
|
|
|
50
50
|
--budget {usd} stop starting trials once their estimates reach it: exit 3; the trials already
|
|
51
51
|
running finish
|
|
52
52
|
--yes no question before the run; there is none when the input isn't a terminal
|
|
53
|
-
--json the report as JSON, awf.
|
|
54
|
-
awf.
|
|
53
|
+
--json the report as JSON, awf.lab-report/1; with --dry-run, the plan,
|
|
54
|
+
awf.lab-plan/1; with no case to run, as under --failed, an empty plan whose
|
|
55
|
+
nothing says why
|
|
55
56
|
|
|
56
57
|
exit: 0 every case that must pass passed; 1 a case that must pass failed; 2 refused before any
|
|
57
58
|
work; 3 a case flaky or unclear, a partial run, a budget stop, a stop on preconditions with no
|
package/src/help/runs.txt
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
usage: awf-lab [-C {folder}] runs [--dataset {name}] [--json]
|
|
2
2
|
|
|
3
|
-
the runs and loops kept, newest first: each run's id, dataset, cases,
|
|
4
|
-
|
|
3
|
+
the runs and loops kept, newest first: each run's id, dataset, cases, trials across its columns,
|
|
4
|
+
how it ended, a stop included, and its verdicts as its report counts them; each loop's id, tries
|
|
5
|
+
and the try it keeps. A loop's own runs are in report --loop
|
|
5
6
|
|
|
6
7
|
-C {folder} run as if started in {folder}
|
|
7
8
|
--dataset {name} only this dataset's runs and loops
|
|
8
|
-
--json the list as JSON, awf.
|
|
9
|
+
--json the list as JSON, awf.lab-runs/1
|
|
9
10
|
|
|
10
11
|
exit: 0 done, 2 refused, 4 the lab broke
|
package/src/help/score.txt
CHANGED
|
@@ -4,7 +4,8 @@ usage: awf-lab [-C {folder}] score [{run}] [--grader {name}] [--cases {a,b}] [--
|
|
|
4
4
|
|
|
5
5
|
grade a run's kept trials again without running one: each grader whose version, settings or facts
|
|
6
6
|
changed, or that errored. The run is named by its id or last 4 characters; without one, the
|
|
7
|
-
newest run that no loop made. It prints the plan and an estimate, then asks on a terminal
|
|
7
|
+
newest run that no loop made. It prints the plan and an estimate, then asks on a terminal; with
|
|
8
|
+
nothing to grade, it says so, without the report, and exits with the run's code
|
|
8
9
|
|
|
9
10
|
-C {folder} run as if started in {folder}
|
|
10
11
|
--cases {a,b} grade only the trials of these cases of the run
|
|
@@ -17,8 +18,8 @@ newest run that no loop made. It prints the plan and an estimate, then asks on a
|
|
|
17
18
|
--dry-run print the plan, and grade nothing
|
|
18
19
|
--budget {usd} stop before an agent grader once the grades' estimates reach it: exit 3
|
|
19
20
|
--yes no question before grading; there is none when the input isn't a terminal
|
|
20
|
-
--json the report as JSON, awf.
|
|
21
|
-
the plan, awf.
|
|
21
|
+
--json the report as JSON, awf.lab-report/1, with what was graded; with --dry-run,
|
|
22
|
+
or with nothing to grade, the plan, awf.lab-plan/1
|
|
22
23
|
|
|
23
24
|
exit: 0 every case that must pass passed; 1 a case that must pass failed; 2 refused before any
|
|
24
25
|
work; 3 a case flaky or unclear, a partial run, a budget stop, a stop on preconditions with no
|
package/src/lab/blame.ts
CHANGED
|
@@ -133,7 +133,7 @@ export function blame(allLines: readonly TrialLine[], ending: RunEnding): Blamed
|
|
|
133
133
|
}
|
|
134
134
|
if (workflowError) return { ...base, workflowError: workflowError.reason, erred: "body" };
|
|
135
135
|
if (lines.length === 0 && ending.outcome !== "completed") {
|
|
136
|
-
// Died before
|
|
136
|
+
// Died before defineTarget wrote anything: target.ts or what it imports statically, the fix is there.
|
|
137
137
|
const said = tail(ending.stderr) || ending.reason || "awf run printed nothing";
|
|
138
138
|
return dataset("setup", "threw", said);
|
|
139
139
|
}
|
package/src/lab/box.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { join, relative } from "node:path";
|
|
|
3
3
|
import type { ResolvedNetwork } from "../format/settings";
|
|
4
4
|
import { type CaseWorkspace, ignored, inside, recordsFolders } from "./workspace";
|
|
5
5
|
|
|
6
|
-
// The "lab" box: a whole trial, `awf run --in` with
|
|
6
|
+
// The "lab" box: a whole trial, `awf run --in` with target.ts, the workflow's code and its agents
|
|
7
7
|
// inside, so code an agent wrote reads no key. awf makes the box and carries the logins in; the
|
|
8
8
|
// lab decides only what it reaches: these paths, and the hosts the case's code reaches.
|
|
9
9
|
|
|
@@ -69,8 +69,9 @@ const GRADING_FILES = ["grading.ts", "graders", "capture.ts", "brief.md"];
|
|
|
69
69
|
* its history), every dataset's keys, the records folders, `ignore`'s files, and the store and the
|
|
70
70
|
* lab's home but `keep`, the box's own folder there, such as a loop's copy of the code. The home
|
|
71
71
|
* folder is denied whole by the box. A trial's box, given its `trial`, hides every case and data
|
|
72
|
-
* folder but its own case's `input
|
|
73
|
-
*
|
|
72
|
+
* folder but its own case's `input/`, every eval folder's grading files, the loops' briefs, the
|
|
73
|
+
* config and the local file too. Its dataset's `shared/` is hidden as well: the trial reads what
|
|
74
|
+
* its case names of it in the built case folder.
|
|
74
75
|
*/
|
|
75
76
|
export function hiddenOf(
|
|
76
77
|
root: string,
|
|
@@ -127,9 +128,10 @@ export function hiddenOf(
|
|
|
127
128
|
// srt denies a folder over a path allowed inside it: the other cases, one by one.
|
|
128
129
|
if (existsSync(cases))
|
|
129
130
|
hidden.push(...hiddenAround(realOf(cases), [realOf(join(dir, input))]));
|
|
130
|
-
} else {
|
|
131
|
-
hidden.push(
|
|
131
|
+
} else if (existsSync(cases)) {
|
|
132
|
+
hidden.push(cases);
|
|
132
133
|
}
|
|
134
|
+
if (existsSync(join(dir, "shared"))) hidden.push(join(dir, "shared"));
|
|
133
135
|
}
|
|
134
136
|
for (const dir of evalDirs) {
|
|
135
137
|
hidden.push(...GRADING_FILES.map((name) => join(dir, name)).filter((path) => existsSync(path)));
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
import { type DatasetInfo, folderDigest, GOOD_RECORD, INPUT_DIR, readCases } from "./dataset";
|
|
26
26
|
import { buildCase } from "./folders";
|
|
27
27
|
import { unpinnable, writeGood } from "./good";
|
|
28
|
-
import { appendLabel } from "./labels";
|
|
28
|
+
import { appendLabel, readLabels } from "./labels";
|
|
29
29
|
import { factsOf } from "./outcome";
|
|
30
30
|
import { writeLabels } from "./record-copies";
|
|
31
31
|
import { Refusal } from "./refusal";
|
|
@@ -33,7 +33,7 @@ import type { StoredTrial } from "./store";
|
|
|
33
33
|
import { afterMsOf } from "./trial-settings";
|
|
34
34
|
import { type CaseWorkspace, recordsOf } from "./workspace";
|
|
35
35
|
|
|
36
|
-
// `case capture`, `case pin` and `label`:
|
|
36
|
+
// `case capture`, `case pin` and `label`: your mark on a trial, a case made from a trial
|
|
37
37
|
// or a real run, and a trial's record kept as its case's known good record.
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -105,9 +105,9 @@ async function captureLocked(
|
|
|
105
105
|
if (mark.mark === "good") writeGood(dir, trial);
|
|
106
106
|
say(
|
|
107
107
|
dir,
|
|
108
|
-
`from trial ${trial.record.trial} of case ${trial.record.case} in run ${trial.record.
|
|
108
|
+
`from trial ${trial.record.trial} of case ${trial.record.case} in run ${trial.record.labRun}${mark.mark === "good" ? ", its record the known good record" : ""}`,
|
|
109
109
|
);
|
|
110
|
-
// The case says what a good result is; the trial it came from keeps the person's
|
|
110
|
+
// The case says what a good result is; the trial it came from keeps the person's mark.
|
|
111
111
|
labelTrial(
|
|
112
112
|
workspace,
|
|
113
113
|
trial,
|
|
@@ -189,7 +189,7 @@ function folderDigestOfCase(info: DatasetInfo, name: string, under: string): str
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
|
-
* `label`:
|
|
192
|
+
* `label`: your mark on one trial, found by its trial id, as `capture` finds
|
|
193
193
|
* it. A coding agent the person told what was wrong runs it too, and a web interface would.
|
|
194
194
|
*/
|
|
195
195
|
export function label(context: Context, names: readonly string[]): number {
|
|
@@ -216,6 +216,10 @@ export function label(context: Context, names: readonly string[]): number {
|
|
|
216
216
|
);
|
|
217
217
|
}
|
|
218
218
|
const mark = options.good ? "good" : options.clear ? "cleared" : "needs-work";
|
|
219
|
+
if (mark === "cleared" && !readLabels(workspace.store, trial.record.dataset).has(trialId)) {
|
|
220
|
+
context.stdout(`${trialId} had no label`);
|
|
221
|
+
return 0;
|
|
222
|
+
}
|
|
219
223
|
labelTrial(
|
|
220
224
|
workspace,
|
|
221
225
|
trial,
|
|
@@ -267,7 +271,7 @@ export async function casePin(context: Context, names: readonly string[]): Promi
|
|
|
267
271
|
const file = writeGood(found.dir, trial);
|
|
268
272
|
labelTrial(workspace, trial, "good", undefined, context.environment.now ?? (() => new Date()));
|
|
269
273
|
context.stdout(
|
|
270
|
-
`wrote ${relative(context.cwd, file) || file}, trial ${record.trial} of case ${record.case} in run ${record.
|
|
274
|
+
`wrote ${relative(context.cwd, file) || file}, trial ${record.trial} of case ${record.case} in run ${record.labRun}, and labeled the trial good`,
|
|
271
275
|
);
|
|
272
276
|
if (folderDigestOfCase(info, record.case, tmpOf(context)) !== record.input) {
|
|
273
277
|
context.stderr(
|
|
@@ -287,7 +291,7 @@ function labelTrial(
|
|
|
287
291
|
): void {
|
|
288
292
|
appendLabel(workspace.store, trial.record.dataset, {
|
|
289
293
|
kind: LABEL_KIND,
|
|
290
|
-
|
|
294
|
+
trialId: trial.record.trialId!,
|
|
291
295
|
case: trial.record.case,
|
|
292
296
|
mark,
|
|
293
297
|
...(note ? { note } : {}),
|
package/src/lab/capture.ts
CHANGED
|
@@ -45,7 +45,7 @@ export type CapturedCase = Type.Static<typeof CasesSchema>[number];
|
|
|
45
45
|
/** The trial whose workflow run had this id, in any run of the store. */
|
|
46
46
|
export function findTrial(store: string, trialId: string): StoredTrial | undefined {
|
|
47
47
|
for (const { trials } of readableRuns(store, { newest: true })) {
|
|
48
|
-
const found = trials.find((t) => t.record.
|
|
48
|
+
const found = trials.find((t) => t.record.trialId === trialId);
|
|
49
49
|
if (found) return found;
|
|
50
50
|
}
|
|
51
51
|
return undefined;
|
package/src/lab/check-command.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { CHECK_KIND, type LabCheck, LabCheckSchema } from "../format/output";
|
|
2
2
|
import { checkSchema, describeProblems } from "../shared/validate";
|
|
3
3
|
import {
|
|
4
4
|
type Context,
|
|
@@ -157,7 +157,7 @@ export async function caseCheck(context: Context, names: readonly string[]): Pro
|
|
|
157
157
|
const checked = await checkCases(context);
|
|
158
158
|
const failed = checked.reduce((n, d) => n + d.failing.length, 0);
|
|
159
159
|
if (context.options.json) {
|
|
160
|
-
const json:
|
|
160
|
+
const json: LabCheck = {
|
|
161
161
|
kind: CHECK_KIND,
|
|
162
162
|
datasets: checked.map((d) => ({
|
|
163
163
|
dataset: d.dataset,
|
|
@@ -167,7 +167,7 @@ export async function caseCheck(context: Context, names: readonly string[]): Pro
|
|
|
167
167
|
cases: d.cases.map((c) => ({ case: c.case, passed: c.passed, said: c.line })),
|
|
168
168
|
})),
|
|
169
169
|
};
|
|
170
|
-
const valid = checkSchema(
|
|
170
|
+
const valid = checkSchema(LabCheckSchema, json);
|
|
171
171
|
if (!valid.ok) throw new Error(describeProblems("case check --json", valid.problems));
|
|
172
172
|
context.stdout(JSON.stringify(json, null, 2));
|
|
173
173
|
} else {
|
package/src/lab/cli.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
workspaceOf,
|
|
12
12
|
} from "./command-context";
|
|
13
13
|
import { config } from "./config-command";
|
|
14
|
-
import {
|
|
14
|
+
import { TARGET_FILE } from "./eval-files";
|
|
15
15
|
import { gitTop } from "./git";
|
|
16
16
|
import { loopCommand, loopReport } from "./loop-command";
|
|
17
17
|
import { Refusal } from "./refusal";
|
|
@@ -153,10 +153,10 @@ function parse(argv: readonly string[]): {
|
|
|
153
153
|
options.budget = usd;
|
|
154
154
|
break;
|
|
155
155
|
}
|
|
156
|
-
case "--
|
|
156
|
+
case "--tries": {
|
|
157
157
|
const text = value(arg);
|
|
158
|
-
if (!/^[1-9][0-9]*$/.test(text)) throw new Refusal("--
|
|
159
|
-
options.
|
|
158
|
+
if (!/^[1-9][0-9]*$/.test(text)) throw new Refusal("--tries is a whole number from 1");
|
|
159
|
+
options.tries = Number(text);
|
|
160
160
|
break;
|
|
161
161
|
}
|
|
162
162
|
case "--allowance": {
|
|
@@ -314,11 +314,12 @@ async function caseCommand(context: Context, names: readonly string[]): Promise<
|
|
|
314
314
|
const made = newCase(evals, address, found ? workspaceOf(context) : undefined);
|
|
315
315
|
const shown = (file: string) => relative(context.cwd, file) || file;
|
|
316
316
|
for (const file of made.written) context.stdout(`wrote ${shown(file)}`);
|
|
317
|
-
const
|
|
317
|
+
for (const dir of made.made) context.stdout(`made ${shown(dir)}/`);
|
|
318
|
+
const targetScript = made.written.find((file) => basename(file) === TARGET_FILE);
|
|
318
319
|
context.stdout(
|
|
319
|
-
|
|
320
|
-
? `next: fill ${shown(
|
|
321
|
-
: `case ${shown(made.caseDir)}:
|
|
320
|
+
targetScript
|
|
321
|
+
? `next: fill ${shown(targetScript)} and delete its first line, then the case's input/ and its key's expect, and remove the key's draft: true`
|
|
322
|
+
: `case ${shown(made.caseDir)}: fill its input/ and key.md, then remove the key's draft: true`,
|
|
322
323
|
);
|
|
323
324
|
return 0;
|
|
324
325
|
}
|
package/src/lab/columns.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Column, PARAM_NAME, type Params, type RunRecord } from "../format/records";
|
|
2
2
|
import { type DatasetInfo, declaredList } from "./dataset";
|
|
3
|
-
import {
|
|
3
|
+
import { TARGET_FILE } from "./eval-files";
|
|
4
4
|
import { Refusal } from "./refusal";
|
|
5
5
|
|
|
6
6
|
/** `--param` and `--vary`, read: the values every column shares, and each varied name's values. */
|
|
@@ -54,12 +54,12 @@ export function combinations({ fixed, varied }: ParamPlan): Params[] {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
* Each combination over the dataset's parameters: `
|
|
58
|
-
* under the flags'. A name `
|
|
57
|
+
* Each combination over the dataset's parameters: `target.ts`'s defaults under its entries' values,
|
|
58
|
+
* under the flags'. A name `target.ts` doesn't declare is refused, and so is a required one that
|
|
59
59
|
* nothing gives.
|
|
60
60
|
*/
|
|
61
61
|
export function withDeclared(info: DatasetInfo, combos: readonly Params[]): Params[] {
|
|
62
|
-
const file = `${info.evalDir}/${
|
|
62
|
+
const file = `${info.evalDir}/${TARGET_FILE}`;
|
|
63
63
|
return combos.map((combo) => {
|
|
64
64
|
const params: Params = {};
|
|
65
65
|
for (const [name, { value }] of Object.entries(info.params)) {
|
|
@@ -68,7 +68,7 @@ export function withDeclared(info: DatasetInfo, combos: readonly Params[]): Para
|
|
|
68
68
|
for (const [name, value] of Object.entries(combo)) {
|
|
69
69
|
if (!(name in info.params)) {
|
|
70
70
|
throw new Refusal(
|
|
71
|
-
`parameter ${name} is not one ${file} declares${declaredList(info.params)}: declare it in
|
|
71
|
+
`parameter ${name} is not one ${file} declares${declaredList(info.params)}: declare it in defineTarget's params`,
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
params[name] = value;
|
|
@@ -2,7 +2,7 @@ import { realpathSync } from "node:fs";
|
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { isAbsolute, join, relative } from "node:path";
|
|
4
4
|
import { createInterface } from "node:readline/promises";
|
|
5
|
-
import { type
|
|
5
|
+
import { type LabPlan, LabPlanSchema } from "../format/output";
|
|
6
6
|
import type { RunRecord } from "../format/records";
|
|
7
7
|
import { type AllowanceSource, awfAllowance } from "../shared/allowance";
|
|
8
8
|
import {
|
|
@@ -58,7 +58,7 @@ export type CasesEnvironment = {
|
|
|
58
58
|
/** The environment trials start from. */
|
|
59
59
|
env?: Readonly<Record<string, string | undefined>>;
|
|
60
60
|
/** The checks of a folder before the first trial; absent, the real ones. */
|
|
61
|
-
inspect?: (root: string,
|
|
61
|
+
inspect?: (root: string, targetScript: string) => Promise<FolderSetup>;
|
|
62
62
|
/** `awf allowance --json`, for a loop's wait; absent, the operator's, unless the runner is scripted. */
|
|
63
63
|
allowance?: AllowanceSource;
|
|
64
64
|
/** Graders a test adds after `expect`, before the dataset's own. */
|
|
@@ -97,7 +97,7 @@ export type Options = {
|
|
|
97
97
|
budget?: number;
|
|
98
98
|
json: boolean;
|
|
99
99
|
help: boolean;
|
|
100
|
-
|
|
100
|
+
tries?: number;
|
|
101
101
|
allowance?: number | "off";
|
|
102
102
|
/** `--concurrency {n}`: trials or grader workflows at once, over the local file's. */
|
|
103
103
|
concurrency?: number;
|
|
@@ -289,8 +289,8 @@ export async function withLock<T>(
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
/** `--dry-run --json`: the plan, checked against its schema before it is printed. */
|
|
292
|
-
export function printPlan(context: Context, plan:
|
|
293
|
-
const checked = checkSchema(
|
|
292
|
+
export function printPlan(context: Context, plan: LabPlan): void {
|
|
293
|
+
const checked = checkSchema(LabPlanSchema, plan);
|
|
294
294
|
if (!checked.ok) throw new Error(describeProblems("--dry-run --json", checked.problems));
|
|
295
295
|
context.stdout(JSON.stringify(plan, null, 2));
|
|
296
296
|
}
|
|
@@ -302,11 +302,11 @@ export const budgetExit = (stopped: boolean, exit: number) => (stopped && exit =
|
|
|
302
302
|
export function checkoutFolder(
|
|
303
303
|
context: Context,
|
|
304
304
|
workspace: CaseWorkspace,
|
|
305
|
-
|
|
305
|
+
targetScript: () => string,
|
|
306
306
|
): () => Promise<FolderSetup> {
|
|
307
307
|
let inspected: Promise<FolderSetup> | undefined;
|
|
308
308
|
return () =>
|
|
309
|
-
(inspected ??= (context.environment.inspect ?? inspectFolder)(workspace.root,
|
|
309
|
+
(inspected ??= (context.environment.inspect ?? inspectFolder)(workspace.root, targetScript()));
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
/** A trial's id, its workflow run's: `20261119T054028Z-c13b6e75`. */
|
package/src/lab/compare.ts
CHANGED
|
@@ -2,14 +2,14 @@ import { mkdtempSync, rmSync } from "node:fs";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import type { ComparedTrial, Room } from "../env/compare";
|
|
4
4
|
import type { RunRecord } from "../format/records";
|
|
5
|
-
import type {
|
|
5
|
+
import type { Decision } from "../shared/compare";
|
|
6
6
|
import { runHelper } from "./code-graders";
|
|
7
7
|
import { newestEntries, trialOutcome } from "./outcome";
|
|
8
8
|
import type { CaseBar } from "./runs";
|
|
9
9
|
import type { StoredTrial } from "./store";
|
|
10
10
|
|
|
11
11
|
/** What `compare` said of one column against the reference, or why it couldn't say. */
|
|
12
|
-
export type
|
|
12
|
+
export type ColumnDecision = Decision | { error: string };
|
|
13
13
|
|
|
14
14
|
/** A stored trial as a comparison sees it; an errored or leaked one is left out, as missing. */
|
|
15
15
|
export function comparedTrial(
|
|
@@ -53,7 +53,7 @@ export async function compareColumns(args: {
|
|
|
53
53
|
tmp: string;
|
|
54
54
|
env: Record<string, string>;
|
|
55
55
|
timeoutMs: number;
|
|
56
|
-
}): Promise<
|
|
56
|
+
}): Promise<ColumnDecision[] | undefined> {
|
|
57
57
|
const file = args.gradingFile;
|
|
58
58
|
if (args.run.columns.length < 2 || file === undefined) return undefined;
|
|
59
59
|
const of = (column: number) =>
|
|
@@ -63,7 +63,7 @@ export async function compareColumns(args: {
|
|
|
63
63
|
const reference = of(0);
|
|
64
64
|
const work = mkdtempSync(join(args.tmp, "awf-lab-compare-"));
|
|
65
65
|
try {
|
|
66
|
-
const
|
|
66
|
+
const decisions: ColumnDecision[] = [];
|
|
67
67
|
for (let column = 1; column < args.run.columns.length; column++) {
|
|
68
68
|
let answer: Record<string, unknown>;
|
|
69
69
|
try {
|
|
@@ -76,14 +76,14 @@ export async function compareColumns(args: {
|
|
|
76
76
|
{ root: args.root, work, env: args.env, timeoutMs: args.timeoutMs, name: "compare" },
|
|
77
77
|
);
|
|
78
78
|
} catch (error) {
|
|
79
|
-
|
|
79
|
+
decisions.push({ error: (error as Error).message });
|
|
80
80
|
continue;
|
|
81
81
|
}
|
|
82
82
|
if (answer.none) return undefined;
|
|
83
|
-
if (typeof answer.error === "string")
|
|
84
|
-
else
|
|
83
|
+
if (typeof answer.error === "string") decisions.push({ error: answer.error });
|
|
84
|
+
else decisions.push(answer.decision as Decision);
|
|
85
85
|
}
|
|
86
|
-
return
|
|
86
|
+
return decisions;
|
|
87
87
|
} finally {
|
|
88
88
|
rmSync(work, { recursive: true, force: true });
|
|
89
89
|
}
|