@toloka-platform/sdk 0.17.2 → 0.19.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/dist/cli/toloka.js +152 -152
- package/dist/cli/toloka.js.jsc +0 -0
- package/dist/cli/toloka.js.jsc.sha256 +1 -1
- package/dist/cli/toloka.js.sha256 +1 -1
- package/docs/cli.md +3 -1
- package/docs/limitations.md +2 -2
- package/openapi/gen/api.schemas.ts +7 -0
- package/package.json +2 -2
- package/skills/catalog.json +6 -6
- package/skills/toloka-build/SKILL.md +1 -1
- package/skills/toloka-build/references/human-work.md +14 -2
- package/skills/toloka-build/references/workflow-and-cli.md +3 -3
- package/src/cli/check.ts +1 -1
- package/src/cli/project.ts +30 -13
- package/src/graph-rules.json +4 -1
- package/src/validate.ts +185 -2
package/dist/cli/toloka.js.jsc
CHANGED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
04aed695bf540451fb62ec4f4c40034a2e24d3b55f65d0b6cdaada4a7d25880e toloka.js.jsc
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
9edbb8add956099bf362cea5c124a6474fcffa1b18ae75b5a785e37f244936ad toloka.js
|
package/docs/cli.md
CHANGED
|
@@ -296,7 +296,7 @@ Runs the complete local gate without platform credentials.
|
|
|
296
296
|
toloka check [pipeline] [--node <name-or-id>] [--json] [--watch]
|
|
297
297
|
```
|
|
298
298
|
|
|
299
|
-
The command loads authored source, runs the project's TypeScript compiler, typechecks every Task UI against declarations bundled with the installed SDK, runs Vitest, and compares passing typed test evidence with every code node, human-work node, and pipeline. Statuses distinguish `missing`, `failed`, `partial`, `warning`, and `infrastructure_error`. `partial` marks a Task UI whose upload or recording fields the headless browser could not exercise; it is reported but does not fail the gate. `warning` marks a `platform-rules` result: nodes connected to the root that break a rule the platform enforces on write. It does not fail the gate, but `toloka apply` refuses to write that pipeline until it is fixed. Exit code `0` means all required checks passed, `1` means source, types, tests, or required coverage failed, and `2` means a required checker could not run.
|
|
299
|
+
The command loads authored source, runs the project's TypeScript compiler, typechecks every Task UI against declarations bundled with the installed SDK, runs Vitest, and compares passing typed test evidence with every code node, human-work node, and pipeline. Statuses distinguish `missing`, `failed`, `partial`, `warning`, and `infrastructure_error`. `partial` marks a Task UI whose upload or recording fields the headless browser could not exercise; it is reported but does not fail the gate. `warning` marks a `platform-rules` result: nodes connected to the root that break a rule the platform enforces on write (node names, quality criteria, Human QA review time, price, data collection media, exam limits, Training structure and block contents, and the 150,000-character limit of one node setting), each named with its node and setting path. It does not fail the gate, but `toloka apply` refuses to write that pipeline until it is fixed. Exit code `0` means all required checks passed, `1` means source, types, tests, or required coverage failed, and `2` means a required checker could not run.
|
|
300
300
|
|
|
301
301
|
Use `test.code`, `test.ui`, and `test.pipeline` from `@toloka-platform/sdk/testing` to produce required evidence. Plain Vitest tests still run and can fail the command, but do not satisfy graph coverage. A focused check accepts a pipeline plus `--node`; `--watch` serializes reruns after relevant file changes.
|
|
302
302
|
|
|
@@ -312,6 +312,8 @@ toloka apply
|
|
|
312
312
|
|
|
313
313
|
Checks run before credentials are resolved or any platform request is made. A failed or missing required check exits `1`; a checker infrastructure error exits `2`. After a pass, the preflight refuses before any write when a pipeline or dataset is removed from source, a project secret is missing, or a dataset field schema conflicts. On success it prints `No changes.` or reports both the number of approved planned changes and the lower-level platform writes used to apply them.
|
|
314
314
|
|
|
315
|
+
Apply imports each new pipeline first, without its dataset, so the platform validates the graph before any dataset or field is created; then it creates the missing datasets and fields and binds each new pipeline's dataset. When the platform rejects a new pipeline's graph, no dataset or field was created, although pipelines imported earlier in the same apply remain. When a later step fails, the next apply finds the imported pipeline by name and binds its dataset. For a pipeline that already exists, apply adds new dataset fields before it writes the graph, and a created field cannot be changed. A rejected graph lists each error on its own line as `- node <name>, <setting path>: <reason>`, at most 100 of them followed by `- …and <n> more`.
|
|
316
|
+
|
|
315
317
|
## secret set
|
|
316
318
|
|
|
317
319
|
Sets a secret value without writing it to disk.
|
package/docs/limitations.md
CHANGED
|
@@ -12,11 +12,11 @@ The standalone CLI supports macOS and glibc Linux on ARM64 and x64. Native Windo
|
|
|
12
12
|
|
|
13
13
|
`toloka check` is the required credential-free local gate. It runs project TypeScript, automatic Task UI typechecking, Vitest, and typed node and pipeline-flow coverage. `toloka apply` reruns it before any platform write.
|
|
14
14
|
|
|
15
|
-
`toloka validate` separately posts each bound graph to the platform and reports spec errors, warnings, and the latest matching Remote Node Check jobs. It does not write the graph. A passing local gate and platform validation are still not proof that the pipeline can launch:
|
|
15
|
+
`toloka check` also reports, as `platform-rules` warnings, the rules the platform enforces on write that it can check offline, including Training structure and block contents and the 150,000-character limit of one node setting; `toloka apply` refuses a pipeline that breaks one. `toloka validate` separately posts each bound graph to the platform and reports spec errors, warnings, and the latest matching Remote Node Check jobs. It does not write the graph. A passing local gate and platform validation are still not proof that the pipeline can launch:
|
|
16
16
|
|
|
17
17
|
| gate | where it is enforced | what the CLI tells you |
|
|
18
18
|
| ------------------------------------------------- | -------------------- | ---------------------- |
|
|
19
|
-
| Training
|
|
19
|
+
| Training examples run against the task UI | platform validation | nothing |
|
|
20
20
|
| labeler UI validation receipt | platform validation | nothing |
|
|
21
21
|
|
|
22
22
|
The typed client can list, start, and poll Remote Node Checks. `toloka check` does not start them: it validates the authored source and its local tests. A `not_ran_node_check` or `running_node_check` warning from `toloka validate` describes remote state rather than missing local evidence.
|
|
@@ -2304,6 +2304,12 @@ export type RunItemStateOutput = {
|
|
|
2304
2304
|
fieldProxyRevisions: RunItemStateOutputFieldProxyRevisions;
|
|
2305
2305
|
} | null;
|
|
2306
2306
|
|
|
2307
|
+
export type RunItemStatePartialOutputFieldProxyRevisions = {[key: string]: string};
|
|
2308
|
+
|
|
2309
|
+
export type RunItemStatePartialOutput = {
|
|
2310
|
+
fieldProxyRevisions: RunItemStatePartialOutputFieldProxyRevisions;
|
|
2311
|
+
} | null;
|
|
2312
|
+
|
|
2307
2313
|
export interface RunItemState {
|
|
2308
2314
|
status: RunItemStateStatus;
|
|
2309
2315
|
startedAt: string | null;
|
|
@@ -2311,6 +2317,7 @@ export interface RunItemState {
|
|
|
2311
2317
|
error?: string | null;
|
|
2312
2318
|
input: RunItemStateInput;
|
|
2313
2319
|
output: RunItemStateOutput;
|
|
2320
|
+
partialOutput: RunItemStatePartialOutput;
|
|
2314
2321
|
}
|
|
2315
2322
|
|
|
2316
2323
|
export interface RunItem {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toloka-platform/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build, inspect, and operate Toloka pipeline projects as TypeScript source. The public API may change between minor versions before 1.0.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -77,6 +77,6 @@
|
|
|
77
77
|
"bun": ">=1.4.0"
|
|
78
78
|
},
|
|
79
79
|
"tolokaBuild": {
|
|
80
|
-
"commit": "
|
|
80
|
+
"commit": "d5dcfe5a5c49fef069ef9c9e3c8c265eca73f752"
|
|
81
81
|
}
|
|
82
82
|
}
|
package/skills/catalog.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"testing",
|
|
12
12
|
"checks"
|
|
13
13
|
],
|
|
14
|
-
"version": "0.
|
|
15
|
-
"digest": "
|
|
14
|
+
"version": "0.19.0",
|
|
15
|
+
"digest": "b68151cdf572a7a1ddbf27399044ecd4a35109771b3e1fc710a23c60b0a55462",
|
|
16
16
|
"files": [
|
|
17
17
|
"SKILL.md",
|
|
18
18
|
"references/human-work.md",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"bug",
|
|
34
34
|
"report"
|
|
35
35
|
],
|
|
36
|
-
"version": "0.
|
|
36
|
+
"version": "0.19.0",
|
|
37
37
|
"digest": "70f0bd2c80b32f87896aeb27c363b8a2d37f40e22424f57fe1aad142e125ad67",
|
|
38
38
|
"files": [
|
|
39
39
|
"SKILL.md",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"getting-started",
|
|
51
51
|
"agent"
|
|
52
52
|
],
|
|
53
|
-
"version": "0.
|
|
53
|
+
"version": "0.19.0",
|
|
54
54
|
"digest": "2278adeb46a792356579395fcf73c42322cb23bcd0c61e20856ccabdad6762d1",
|
|
55
55
|
"files": [
|
|
56
56
|
"SKILL.md"
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"sft",
|
|
68
68
|
"models"
|
|
69
69
|
],
|
|
70
|
-
"version": "0.
|
|
70
|
+
"version": "0.19.0",
|
|
71
71
|
"digest": "3ce10dee5d3c283d8b5fdea15134a58fc738c7af2c1bb19eb5a0bf70ea0bca13",
|
|
72
72
|
"files": [
|
|
73
73
|
"SKILL.md"
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"prompt",
|
|
85
85
|
"models"
|
|
86
86
|
],
|
|
87
|
-
"version": "0.
|
|
87
|
+
"version": "0.19.0",
|
|
88
88
|
"digest": "be8bce8d9cf7241ccb60d2b2a9b7cc07d7755a76e8ff8ec1b0847c49efbb3469",
|
|
89
89
|
"files": [
|
|
90
90
|
"SKILL.md"
|
|
@@ -80,7 +80,7 @@ Let constructors mint IDs for new declarations. Preserve `id` options generated
|
|
|
80
80
|
|
|
81
81
|
`definePipeline` and typed ports check local declaration and connection invariants. The published JSON contract is still available as `validate(graph)` for importer and fixture tests; it makes no server call.
|
|
82
82
|
|
|
83
|
-
`toloka check` is the required local gate. It runs the project TypeScript compiler, typechecks every authored Task UI against declarations bundled with this SDK version, runs Vitest, and requires passing typed `test.code`, `test.ui`, and `test.pipeline` evidence for every checkable node and pipeline. Use `toloka check <pipeline> --node <name-or-id>` while iterating, where `<name-or-id>` is the node's name or ID, not the name of the TypeScript constant that holds it, then run the unfiltered command before plan or run. Status `missing` means required test evidence does not exist; `failed` means a check ran and failed; `infrastructure_error` means the checker could not run. All three block apply. `partial` means a Task UI has upload or recording fields the headless browser cannot exercise; it does not block apply, but tell the user to try the task on a real device before launching a run. `warning` on `platform-rules` lists nodes connected to the root that break a platform rule (names, quality elements, thresholds, review time, price, data collection media, exam limits): check still passes, but apply refuses to write that pipeline until they are fixed, so fix them before apply.
|
|
83
|
+
`toloka check` is the required local gate. It runs the project TypeScript compiler, typechecks every authored Task UI against declarations bundled with this SDK version, runs Vitest, and requires passing typed `test.code`, `test.ui`, and `test.pipeline` evidence for every checkable node and pipeline. Use `toloka check <pipeline> --node <name-or-id>` while iterating, where `<name-or-id>` is the node's name or ID, not the name of the TypeScript constant that holds it, then run the unfiltered command before plan or run. Status `missing` means required test evidence does not exist; `failed` means a check ran and failed; `infrastructure_error` means the checker could not run. All three block apply. `partial` means a Task UI has upload or recording fields the headless browser cannot exercise; it does not block apply, but tell the user to try the task on a real device before launching a run. `warning` on `platform-rules` lists nodes connected to the root that break a platform rule (names, quality elements, thresholds, review time, price, data collection media, exam limits, Training structure, and the 150,000-character limit for one node setting): check still passes, but apply refuses to write that pipeline until they are fixed, so fix them before apply.
|
|
84
84
|
|
|
85
85
|
`toloka validate` posts each bound graph to the platform and prints one status per pipeline. It exits 1 when any pipeline is `invalid` or `checks-running`, otherwise 0.
|
|
86
86
|
|
|
@@ -65,7 +65,19 @@ Use `audienceType: 'synthetic'` only when the user explicitly asks for model-gen
|
|
|
65
65
|
|
|
66
66
|
#### Training, Exam, UI, and advanced settings
|
|
67
67
|
|
|
68
|
-
Treat `onboarding` as the node's Training course. It has `enabled`, `steps`, and `info` (`estimatedTime`, `role`, `goal`, `successCriteria`). Give every new human node a real course built from the instruction, criteria, UI, edge cases, and verified examples; the constructor's placeholder is not one. While it is enabled, validation requires non-empty `info.role`, `info.goal`, and `info.successCriteria`, three to six steps, and at least one quiz block; a course uses either a practice block or an examples block, not both, and an examples block needs a built UI. A practice block together with an enabled Exam draws a warning, because the Exam already tests experts on real tasks. Preserve an explicit `enabled: false`. Never invent golden answers or media URLs. Training teaches with retries; it is not an admission gate.
|
|
68
|
+
Treat `onboarding` as the node's Training course. It has `enabled`, `steps`, and `info` (`estimatedTime`, `role`, `goal`, `successCriteria`). Give every new human node a real course built from the instruction, criteria, UI, edge cases, and verified examples; the constructor's placeholder, one text step without a quiz, is not one and fails the rules below. While it is enabled, validation requires non-empty `info.role`, `info.goal`, and `info.successCriteria`, three to six steps, and at least one quiz block; a course uses either a practice block or an examples block, not both, and an examples block needs a built UI. A practice block together with an enabled Exam draws a warning, because the Exam already tests experts on real tasks. Preserve an explicit `enabled: false`. Never invent golden answers or media URLs. Training teaches with retries; it is not an admission gate.
|
|
69
|
+
|
|
70
|
+
Each step holds `blocks`, and every block needs its content:
|
|
71
|
+
|
|
72
|
+
- `text`: markdown in `content[0].value`.
|
|
73
|
+
- `quiz`: `questions[0]` with a `question`, at least two `options` with labels, and a `correctAnswer` that is one of the option values (an array for `multiple-choice`).
|
|
74
|
+
- `practice`: a free-text exercise, not an ungraded note. `content[0].value` is the task; an LLM grades every answer against `validators[0].criteria`, which is required.
|
|
75
|
+
- `examples`: real task inputs shown in the built task UI, each with at least one check (`exact` with `path`, `golden`, and `hint`; `code` with `code` and `hint`; or `llm` with `paths` and `criteria`).
|
|
76
|
+
- `consent`: an agreement the expert must accept, labeled by `consentLabel`.
|
|
77
|
+
|
|
78
|
+
All text in `onboarding` counts together against the platform limit of 150,000 characters for one node setting; `instruction`, `ui`, and the other settings each have the same limit. A course teaches the task; it is not a copy of long source material. When the user asks to carry long material over verbatim, measure it before building: if it would not fit, say so in the plan and ask what to condense or drop.
|
|
79
|
+
|
|
80
|
+
`toloka check` reports every rule above as a `platform-rules` warning that names the node and the setting path, such as `onboarding/steps/2/blocks/0/validators/0/criteria`, and `toloka apply` refuses to write the pipeline until it is fixed.
|
|
69
81
|
|
|
70
82
|
Treat `exam` as the optional one-attempt pass/fail gate after Training and before production. Configure it before finalizing Training. `tasksPerExpert` is 1–10; `passThreshold` is a count from 1 through `tasksPerExpert`. Each `gradedEntities` entry targets an output `Field` and sets `mode: 'ground_truth' | 'quality_criteria' | 'not_graded'`, `groundTruthType: 'direct' | 'custom'`, `customInstruction` (at least 10 characters for custom ground truth, otherwise `''`), and `disabledCriterionIds` (`[]` to keep every criterion). Exact labels favor direct ground truth; free-form work with criteria favors quality criteria; structured comparisons that need tolerance favor custom ground truth. `goldenDatasetId` is a live dataset ID and cannot be derived from a dataset name by the authoring helper; only preserve an imported ID or obtain a real one. Never fabricate one. With `verifiedExperts: false`, the exam also limits how many experts can join the node. Deploy sizes that limit from the tasks the run estimate expects at this node (its expected items, times the overlap on a `quorum` node), the per-expert cap, and the measured exam pass rate, between 100 and 10,000. Behind a `match` router the estimate splits items evenly across the branches, so each branch gets a limit for its share, not for the whole run.
|
|
71
83
|
|
|
@@ -149,7 +161,7 @@ When a requirement depends on one of these capabilities, state the gap instead o
|
|
|
149
161
|
- Audience discovery beyond specializations has no SDK or CLI path: valid-language/country suggestions, audience-size statistics for a composed filter, and recommended-rate calculation. `toloka validate` does report an audience that matches no experts, and states the allowed range when `pricePerTask` falls outside it. Specializations and their expert counts come from `toloka audience specialization list`.
|
|
150
162
|
- Audience-reuse candidate discovery has no SDK or CLI path. Source can store a known cross-pipeline pointer, but cannot search candidates.
|
|
151
163
|
- Smart Search rendering, source-fingerprint computation, and stale-profile diagnosis have no SDK or CLI path. Source can carry the public profile; it cannot generate the server-owned fingerprint or preview rendered sourcing documents.
|
|
152
|
-
- Training's examples playbooks and automatic course authoring have no SDK/CLI path. Source can set `onboarding`, but cannot request geometry/numeric check templates or
|
|
164
|
+
- Training's examples playbooks and automatic course authoring have no SDK/CLI path. Source can set `onboarding`, but cannot request geometry/numeric check templates or run hands-on examples against the task UI locally; `toloka check` validates only their structure.
|
|
153
165
|
- Exam golden-dataset discovery, creation by symbolic dataset name, dataset lint execution, and generated-golden confirmation flow have no high-level SDK authoring path. `exam.goldenDatasetId` requires a real ID.
|
|
154
166
|
- Generation's platform-controlled redo cap, appeal behavior, payment retry, and exact terminal handling are intentionally not configurable SDK settings.
|
|
155
167
|
- Dynamic quorum and per-item overlap are unsupported by both surfaces; this is a platform limitation, not missing TypeScript syntax.
|
|
@@ -100,7 +100,7 @@ Treat every plan line as evidence of what apply will attempt. `toloka plan --jso
|
|
|
100
100
|
|
|
101
101
|
Apply preserves the canvas position of existing nodes and the root's live item filter. Do not add either to authored source; SKILL.md says where the server places new nodes. For graph replacement, apply reads the live graph version and sends it as `expectedVersion`; never put a version in source or state yourself.
|
|
102
102
|
|
|
103
|
-
On first apply, the CLI creates each missing named dataset, adds fields required by the authored graphs,
|
|
103
|
+
On first apply, the CLI imports each missing pipeline without its dataset, so the platform validates the graph before anything else is created; then it creates each missing named dataset, adds fields required by the authored graphs, attaches each new pipeline's dataset, and records the resolved IDs. Two pipelines that name the same dataset contribute the union of their required fields.
|
|
104
104
|
|
|
105
105
|
## Add dataset rows
|
|
106
106
|
|
|
@@ -165,7 +165,7 @@ toloka pipeline results <runId> --failed
|
|
|
165
165
|
toloka pipeline cancel <runId> [--accept-without-review]
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
-
By default, `toloka pipeline cancel` keeps the items that wait for Human QA in Human QA, and they end with the review result; after 14 days on the node, they are accepted without review. Add `--accept-without-review` only when the user asks to end these items now without review; the user pays for them as for completed items.
|
|
168
|
+
By default, `toloka pipeline cancel` keeps the items that wait for Human QA in Human QA, and they end with the review result; after 14 days on the node, they are accepted without review. Add `--accept-without-review` only when the user asks to end these items now without review; the user pays for them as for completed items. A cancel does not refund work already done: each canceled item pays for the work recorded until it ends on its node, such as the LLM QA calls of a rejected item, and the rest of its reserved cost returns to the balance.
|
|
169
169
|
|
|
170
170
|
`toloka pipeline runs` lists ids and timestamps. `toloka pipeline status` reports the latest run. `toloka status` (no prefix) is project health. When a listing is capped it says so; report the cap rather than presenting a page as the whole picture.
|
|
171
171
|
|
|
@@ -212,7 +212,7 @@ Object settings preserve omitted live keys, but list-valued settings such as con
|
|
|
212
212
|
|
|
213
213
|
### Server 400 after a clean validate
|
|
214
214
|
|
|
215
|
-
A new pipeline is skipped by `toloka validate` until it exists remotely
|
|
215
|
+
A new pipeline is skipped by `toloka validate` until it exists remotely. Apply imports it before creating any dataset or field, so when its import returns a 400, no dataset or field was created, although pipelines imported earlier in the same apply remain: fix the reported path or reason, then run plan again. If a later step of that apply fails, the pipeline already exists without its dataset, and the next apply finds it by name and binds the dataset; do not recreate or rename resources already created. For a pipeline that already exists, apply adds new dataset fields before it writes the graph, so a rejected graph write can leave those fields behind. If the rejection means a newly created field schema is wrong, that field is already immutable: follow the field schema conflict rule, prefer the option that preserves names the request fixes, and report the orphaned field instead of deleting it. Check connection endpoints, duplicate or unknown imported IDs, field references, and accidentally authored layout. Never bypass reconciliation with a raw API call.
|
|
216
216
|
|
|
217
217
|
### Platform connection lost
|
|
218
218
|
|
package/src/cli/check.ts
CHANGED
package/src/cli/project.ts
CHANGED
|
@@ -807,9 +807,9 @@ export async function projectStatus(
|
|
|
807
807
|
|
|
808
808
|
const applyPipeline = async (
|
|
809
809
|
client: PotatoClient,
|
|
810
|
-
projectId: string,
|
|
811
810
|
pipelineInspection: PipelineInspection,
|
|
812
811
|
datasetIds: ReadonlyMap<string, string>,
|
|
812
|
+
importedPipelineId: string | undefined,
|
|
813
813
|
): Promise<{ readonly pipelineId: string; readonly writes: number }> => {
|
|
814
814
|
const datasetName = pipelineInspection.source.definition.dataset;
|
|
815
815
|
const datasetId = datasetName === undefined ? undefined : datasetIds.get(datasetName);
|
|
@@ -818,20 +818,20 @@ const applyPipeline = async (
|
|
|
818
818
|
`Dataset ${datasetName} has no resolved ID.`,
|
|
819
819
|
{ hint: REPORT_HINT },
|
|
820
820
|
);
|
|
821
|
+
if (importedPipelineId !== undefined) {
|
|
822
|
+
if (datasetId === undefined) return { pipelineId: importedPipelineId, writes: 0 };
|
|
823
|
+
await client.pipelines.attachDataset({ pipelineId: importedPipelineId, datasetId });
|
|
824
|
+
return { pipelineId: importedPipelineId, writes: 1 };
|
|
825
|
+
}
|
|
826
|
+
assertCli(
|
|
827
|
+
pipelineInspection.pipeline,
|
|
828
|
+
`Pipeline ${pipelineInspection.source.sourceDirectory} has no live pipeline.`,
|
|
829
|
+
{ hint: REPORT_HINT },
|
|
830
|
+
);
|
|
821
831
|
const desiredGraph = resolvePipelineDefinition(
|
|
822
832
|
pipelineInspection.source.definition,
|
|
823
833
|
datasetId === undefined ? {} : { datasetId },
|
|
824
834
|
);
|
|
825
|
-
if (pipelineInspection.pipeline === undefined) {
|
|
826
|
-
const pipeline = await client.pipelines.import({
|
|
827
|
-
projectId,
|
|
828
|
-
name: pipelineInspection.source.name,
|
|
829
|
-
graph: desiredGraph,
|
|
830
|
-
});
|
|
831
|
-
if (datasetId === undefined) return { pipelineId: pipeline.id, writes: 1 };
|
|
832
|
-
await client.pipelines.attachDataset({ pipelineId: pipeline.id, datasetId });
|
|
833
|
-
return { pipelineId: pipeline.id, writes: 2 };
|
|
834
|
-
}
|
|
835
835
|
const pipelineId = pipelineInspection.pipeline.id;
|
|
836
836
|
if (pipelineInspection.graphChanges.length === 0) return { pipelineId, writes: 0 };
|
|
837
837
|
const snapshot = pipelineInspection.snapshot;
|
|
@@ -890,7 +890,7 @@ export async function applyProject(
|
|
|
890
890
|
.filter((pipeline) => pipeline.pipeline === undefined || pipeline.graphChanges.length > 0)
|
|
891
891
|
.flatMap((pipeline) =>
|
|
892
892
|
platformRuleIssues(pipeline.source.definition.graph).map(
|
|
893
|
-
(issue) => `- ${pipeline.source.sourceDirectory}, node ${issue.node}: ${issue.reason}`,
|
|
893
|
+
(issue) => `- ${pipeline.source.sourceDirectory}, node ${issue.node}, ${issue.setting}: ${issue.reason}`,
|
|
894
894
|
),
|
|
895
895
|
);
|
|
896
896
|
assertCli(
|
|
@@ -900,6 +900,18 @@ export async function applyProject(
|
|
|
900
900
|
);
|
|
901
901
|
|
|
902
902
|
let writes = 0;
|
|
903
|
+
const importedPipelineIds = new Map<string, string>();
|
|
904
|
+
for (const pipelineInspection of inspection.pipelines) {
|
|
905
|
+
if (pipelineInspection.pipeline !== undefined) continue;
|
|
906
|
+
const imported = await client.pipelines.import({
|
|
907
|
+
projectId: inspection.projectId,
|
|
908
|
+
name: pipelineInspection.source.name,
|
|
909
|
+
graph: resolvePipelineDefinition(pipelineInspection.source.definition, {}),
|
|
910
|
+
});
|
|
911
|
+
importedPipelineIds.set(pipelineInspection.source.sourceDirectory, imported.id);
|
|
912
|
+
writes += 1;
|
|
913
|
+
}
|
|
914
|
+
|
|
903
915
|
const datasetIds = new Map<string, string>();
|
|
904
916
|
for (const datasetInspection of inspection.datasets) {
|
|
905
917
|
let dataset = datasetInspection.dataset;
|
|
@@ -925,7 +937,12 @@ export async function applyProject(
|
|
|
925
937
|
|
|
926
938
|
const pipelineIds = new Map<string, string>();
|
|
927
939
|
for (const pipelineInspection of inspection.pipelines) {
|
|
928
|
-
const applied = await applyPipeline(
|
|
940
|
+
const applied = await applyPipeline(
|
|
941
|
+
client,
|
|
942
|
+
pipelineInspection,
|
|
943
|
+
datasetIds,
|
|
944
|
+
importedPipelineIds.get(pipelineInspection.source.sourceDirectory),
|
|
945
|
+
);
|
|
929
946
|
pipelineIds.set(pipelineInspection.source.sourceDirectory, applied.pipelineId);
|
|
930
947
|
writes += applied.writes;
|
|
931
948
|
}
|
package/src/graph-rules.json
CHANGED
|
@@ -7,5 +7,8 @@
|
|
|
7
7
|
"humanQaSecondsPerQualityCriterion": 3,
|
|
8
8
|
"minQualityThresholdLength": 10,
|
|
9
9
|
"maxExamTasksPerExpert": 10,
|
|
10
|
-
"mediaUploadComponentPattern": "<Field\\.(?:Video(?:Upload|Record)|FileUpload)\\b"
|
|
10
|
+
"mediaUploadComponentPattern": "<Field\\.(?:Video(?:Upload|Record)|FileUpload)\\b",
|
|
11
|
+
"nodeSettingMaxCharacters": 150000,
|
|
12
|
+
"minTrainingSteps": 3,
|
|
13
|
+
"maxTrainingSteps": 6
|
|
11
14
|
}
|
package/src/validate.ts
CHANGED
|
@@ -212,15 +212,197 @@ const examIssues = (settings: HumanWorkSettings, prefix: string): PipelineGraphV
|
|
|
212
212
|
return issues;
|
|
213
213
|
};
|
|
214
214
|
|
|
215
|
+
type Training = HumanWorkSettings['onboarding'];
|
|
216
|
+
type TrainingBlock = NonNullable<Training['steps'][number]['blocks']>[number];
|
|
217
|
+
type TrainingExamples = Extract<TrainingBlock, { type: 'examples' }>;
|
|
218
|
+
|
|
219
|
+
const isBlank = (value: string | undefined) => (value ?? '').trim() === '';
|
|
220
|
+
|
|
221
|
+
const quizIssues = ({ questions: [question] }: Extract<TrainingBlock, { type: 'quiz' }>, path: string) => {
|
|
222
|
+
if (question === undefined) return [{ path: `${path}/questions`, reason: 'Question text is required' }];
|
|
223
|
+
const questionPath = `${path}/questions/0`;
|
|
224
|
+
const issues: PipelineGraphValidationIssue[] = [];
|
|
225
|
+
if (isBlank(question.question)) {
|
|
226
|
+
issues.push({ path: `${questionPath}/question`, reason: 'Question text is required' });
|
|
227
|
+
}
|
|
228
|
+
if (question.options.length < 2) {
|
|
229
|
+
issues.push({ path: `${questionPath}/options`, reason: 'At least 2 options are required' });
|
|
230
|
+
} else if (question.options.some(({ label }) => isBlank(label))) {
|
|
231
|
+
issues.push({ path: `${questionPath}/options`, reason: 'Option label is required' });
|
|
232
|
+
}
|
|
233
|
+
const correctAnswers = [question.correctAnswer].flat().filter((answer) => answer !== '');
|
|
234
|
+
if (correctAnswers.length === 0) {
|
|
235
|
+
issues.push({ path: `${questionPath}/correctAnswer`, reason: 'At least one correct answer must be selected' });
|
|
236
|
+
} else if (correctAnswers.some((answer) => !question.options.some(({ value }) => value === answer))) {
|
|
237
|
+
issues.push({ path: `${questionPath}/correctAnswer`, reason: 'Correct answer must be one of the options' });
|
|
238
|
+
}
|
|
239
|
+
return issues;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
type TrainingExampleCheck = TrainingExamples['examples'][number]['checks'][number];
|
|
243
|
+
|
|
244
|
+
const exactCheckIssues = (
|
|
245
|
+
{ path: checkPath, golden }: Extract<TrainingExampleCheck, { type: 'exact' }>,
|
|
246
|
+
path: string,
|
|
247
|
+
): PipelineGraphValidationIssue[] => [
|
|
248
|
+
...(isBlank(checkPath) ? [{ path: `${path}/path`, reason: 'Check path is required' }] : []),
|
|
249
|
+
...(golden === undefined || golden === null || (typeof golden === 'string' && isBlank(golden))
|
|
250
|
+
? [{ path: `${path}/golden`, reason: 'Check golden is required' }]
|
|
251
|
+
: []),
|
|
252
|
+
];
|
|
253
|
+
|
|
254
|
+
const exampleCheckIssues = (check: TrainingExampleCheck, path: string): PipelineGraphValidationIssue[] => {
|
|
255
|
+
const issues: PipelineGraphValidationIssue[] = check.type === 'exact' ? exactCheckIssues(check, path) : [];
|
|
256
|
+
if (check.type === 'code' && isBlank(check.code)) {
|
|
257
|
+
issues.push({ path: `${path}/code`, reason: 'Check code is required' });
|
|
258
|
+
}
|
|
259
|
+
if (check.type === 'llm') {
|
|
260
|
+
if (check.paths.every(isBlank)) issues.push({ path: `${path}/paths`, reason: 'Check paths are required' });
|
|
261
|
+
if (isBlank(check.criteria)) issues.push({ path: `${path}/criteria`, reason: 'Check criteria is required' });
|
|
262
|
+
}
|
|
263
|
+
if (check.type !== 'llm' && isBlank(check.hint)) {
|
|
264
|
+
issues.push({ path: `${path}/hint`, reason: 'Check hint is required' });
|
|
265
|
+
}
|
|
266
|
+
return issues;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const examplesIssues = ({ examples }: TrainingExamples, path: string): PipelineGraphValidationIssue[] =>
|
|
270
|
+
examples.length === 0
|
|
271
|
+
? [{ path: `${path}/examples`, reason: 'An examples block must have at least one example' }]
|
|
272
|
+
: examples.flatMap(({ checks }, exampleIndex) => {
|
|
273
|
+
const examplePath = `${path}/examples/${exampleIndex}`;
|
|
274
|
+
return checks.length === 0
|
|
275
|
+
? [{ path: `${examplePath}/checks`, reason: 'An example must have at least one check' }]
|
|
276
|
+
: checks.flatMap((check, checkIndex) => exampleCheckIssues(check, `${examplePath}/checks/${checkIndex}`));
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
const practiceIssues = (
|
|
280
|
+
{ content, validators }: Extract<TrainingBlock, { type: 'practice' }>,
|
|
281
|
+
path: string,
|
|
282
|
+
): PipelineGraphValidationIssue[] => [
|
|
283
|
+
...(isBlank(content?.[0]?.value) ? [{ path: `${path}/content`, reason: 'Task description is required' }] : []),
|
|
284
|
+
...(isBlank(validators?.[0]?.criteria)
|
|
285
|
+
? [
|
|
286
|
+
{
|
|
287
|
+
path: `${path}/validators/0/criteria`,
|
|
288
|
+
reason: 'LLM instruction is required: an LLM grades every practice answer against validators[0].criteria',
|
|
289
|
+
},
|
|
290
|
+
]
|
|
291
|
+
: []),
|
|
292
|
+
];
|
|
293
|
+
|
|
294
|
+
const trainingBlockIssues = (block: TrainingBlock, path: string): PipelineGraphValidationIssue[] => {
|
|
295
|
+
switch (block.type) {
|
|
296
|
+
case 'info':
|
|
297
|
+
return [];
|
|
298
|
+
case 'text':
|
|
299
|
+
return isBlank(block.content?.[0]?.value) ? [{ path: `${path}/content`, reason: 'Content is required' }] : [];
|
|
300
|
+
case 'consent':
|
|
301
|
+
return isBlank(block.consentLabel) ? [{ path: `${path}/consentLabel`, reason: 'Consent label is required' }] : [];
|
|
302
|
+
case 'practice':
|
|
303
|
+
return practiceIssues(block, path);
|
|
304
|
+
case 'quiz':
|
|
305
|
+
return quizIssues(block, path);
|
|
306
|
+
case 'examples':
|
|
307
|
+
return examplesIssues(block, path);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
const trainingIssues = (settings: HumanWorkSettings, prefix: string): PipelineGraphValidationIssue[] => {
|
|
312
|
+
const { onboarding, ui } = settings;
|
|
313
|
+
if (!onboarding.enabled || isSynthetic(settings)) return [];
|
|
314
|
+
const path = `${prefix}/onboarding`;
|
|
315
|
+
const issues = (['role', 'goal', 'successCriteria'] as const)
|
|
316
|
+
.filter((key) => isBlank(onboarding.info[key]))
|
|
317
|
+
.map((key) => ({ path: `${path}/info/${key}`, reason: `info.${key} is required` }));
|
|
318
|
+
const { steps } = onboarding;
|
|
319
|
+
if (steps.length < graphRules.minTrainingSteps || steps.length > graphRules.maxTrainingSteps) {
|
|
320
|
+
issues.push({
|
|
321
|
+
path: `${path}/steps`,
|
|
322
|
+
reason: `Training must have ${graphRules.minTrainingSteps} to ${graphRules.maxTrainingSteps} steps`,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
const blocks = steps.flatMap((step) => step.blocks ?? []);
|
|
326
|
+
const hasBlock = (type: TrainingBlock['type']) => blocks.some((block) => block.type === type);
|
|
327
|
+
if (!hasBlock('quiz')) {
|
|
328
|
+
issues.push({ path: `${path}/steps`, reason: 'Training must include at least one quiz block' });
|
|
329
|
+
}
|
|
330
|
+
if (hasBlock('practice') && hasBlock('examples')) {
|
|
331
|
+
issues.push({
|
|
332
|
+
path: `${path}/steps`,
|
|
333
|
+
reason: 'Training must use either a practice block or an examples block, not both',
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
if (hasBlock('examples') && ['', '<></>'].includes(ui.code.trim())) {
|
|
337
|
+
issues.push({ path: `${path}/steps`, reason: 'A Training examples block requires the task UI to be built first' });
|
|
338
|
+
}
|
|
339
|
+
return [
|
|
340
|
+
...issues,
|
|
341
|
+
...steps.flatMap(({ blocks: stepBlocks = [] }, stepIndex) => {
|
|
342
|
+
const stepPath = `${path}/steps/${stepIndex}`;
|
|
343
|
+
return stepBlocks.length === 0
|
|
344
|
+
? [{ path: `${stepPath}/blocks`, reason: 'Step must have at least one block' }]
|
|
345
|
+
: stepBlocks.flatMap((block, blockIndex) => trainingBlockIssues(block, `${stepPath}/blocks/${blockIndex}`));
|
|
346
|
+
}),
|
|
347
|
+
];
|
|
348
|
+
};
|
|
349
|
+
|
|
215
350
|
const humanWorkIssues = ({ settings }: HumanWorkNode, prefix: string): PipelineGraphValidationIssue[] => [
|
|
216
351
|
...thresholdIssues(settings.qualityCriteria, prefix),
|
|
217
352
|
...qualityElementIssues(settings.qualityCriteria, prefix),
|
|
218
353
|
...humanQaIssues(settings, prefix),
|
|
219
354
|
...humanAudienceIssues(settings, prefix),
|
|
220
355
|
...examIssues(settings, prefix),
|
|
356
|
+
...trainingIssues(settings, prefix),
|
|
221
357
|
];
|
|
222
358
|
|
|
223
|
-
|
|
359
|
+
const SIZE_LIMITED_SETTINGS = new Set([
|
|
360
|
+
'audienceAndPricing',
|
|
361
|
+
'code',
|
|
362
|
+
'conditions',
|
|
363
|
+
'entities',
|
|
364
|
+
'envVars',
|
|
365
|
+
'exam',
|
|
366
|
+
'fieldProxies',
|
|
367
|
+
'instruction',
|
|
368
|
+
'offboardingRules',
|
|
369
|
+
'onboarding',
|
|
370
|
+
'overlap',
|
|
371
|
+
'qualityAssurance',
|
|
372
|
+
'qualityCriteria',
|
|
373
|
+
'ui',
|
|
374
|
+
]);
|
|
375
|
+
|
|
376
|
+
const textLength = (value: unknown): number =>
|
|
377
|
+
typeof value === 'string'
|
|
378
|
+
? value.length
|
|
379
|
+
: typeof value === 'object' && value !== null
|
|
380
|
+
? Object.values(value).reduce<number>((total, child) => total + textLength(child), 0)
|
|
381
|
+
: 0;
|
|
382
|
+
|
|
383
|
+
const SYNTHETIC_UNUSED_SETTINGS = new Set(['exam', 'onboarding']);
|
|
384
|
+
|
|
385
|
+
const settingSizeIssues = (node: Exclude<RuleNode, { type: 'root' }>, prefix: string) => {
|
|
386
|
+
const { settings } = node;
|
|
387
|
+
const unused = node.type === 'generation' && isSynthetic(node.settings) ? SYNTHETIC_UNUSED_SETTINGS : new Set();
|
|
388
|
+
const sizedSettings: [string, unknown][] = [
|
|
389
|
+
['about/description', settings.about.description],
|
|
390
|
+
...Object.entries(settings).filter(([setting]) => SIZE_LIMITED_SETTINGS.has(setting) && !unused.has(setting)),
|
|
391
|
+
];
|
|
392
|
+
return sizedSettings.flatMap(([setting, value]) => {
|
|
393
|
+
const length = textLength(value);
|
|
394
|
+
return length > graphRules.nodeSettingMaxCharacters
|
|
395
|
+
? [
|
|
396
|
+
{
|
|
397
|
+
path: `${prefix}/${setting}`,
|
|
398
|
+
reason: `This setting holds ${length} characters of text; the platform allows at most ${graphRules.nodeSettingMaxCharacters} in one node setting`,
|
|
399
|
+
},
|
|
400
|
+
]
|
|
401
|
+
: [];
|
|
402
|
+
});
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
export type PlatformRuleIssue = PipelineGraphValidationIssue & { readonly node: string; readonly setting: string };
|
|
224
406
|
|
|
225
407
|
export const platformRuleIssues = (graph: RuleGraph): PlatformRuleIssue[] => {
|
|
226
408
|
const inUse = nodesInUse(graph);
|
|
@@ -230,8 +412,9 @@ export const platformRuleIssues = (graph: RuleGraph): PlatformRuleIssue[] => {
|
|
|
230
412
|
const label = node.type === 'root' || node.settings.about.name === '' ? node.id : node.settings.about.name;
|
|
231
413
|
return [
|
|
232
414
|
...nodeNameIssues(graph, node, prefix),
|
|
415
|
+
...(node.type === 'root' ? [] : settingSizeIssues(node, prefix)),
|
|
233
416
|
...(node.type === 'generation' || node.type === 'quorum' ? humanWorkIssues(node, prefix) : []),
|
|
234
|
-
].map((issue) => ({ ...issue, node: label }));
|
|
417
|
+
].map((issue) => ({ ...issue, node: label, setting: issue.path.slice(prefix.length + 1) }));
|
|
235
418
|
});
|
|
236
419
|
};
|
|
237
420
|
|