@toloka-platform/sdk 0.1.0-preview.6 → 0.1.0-preview.7

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.
Files changed (101) hide show
  1. package/README.md +7 -11
  2. package/dist/cli/toloka.js +208 -123
  3. package/dist/cli/toloka.js.jsc +0 -0
  4. package/dist/cli/toloka.js.jsc.sha256 +1 -1
  5. package/dist/cli/toloka.js.sha256 +1 -1
  6. package/docs/authoring.md +17 -4
  7. package/docs/cli-v2.md +3 -3
  8. package/docs/cli.md +29 -16
  9. package/docs/getting-started.md +7 -12
  10. package/docs/limitations.md +6 -6
  11. package/docs/testing-examples.md +248 -0
  12. package/docs/testing.md +115 -0
  13. package/examples/face-image-collection/README.md +7 -1
  14. package/examples/face-image-collection/fields.ts +20 -8
  15. package/examples/face-image-collection/nodes/annotate-faces/node.ts +1 -9
  16. package/examples/face-image-collection/nodes/order-faces/node.ts +1 -1
  17. package/examples/face-image-collection/pipeline.browser.integration.spec.ts +78 -0
  18. package/examples/video-pair-rating/README.md +14 -6
  19. package/examples/video-pair-rating/nodes/adjudicate/node.ts +1 -3
  20. package/examples/video-pair-rating/nodes/adjudicate_op/node.ts +1 -3
  21. package/examples/video-pair-rating/nodes/overall_preference_pick/node.ts +1 -1
  22. package/examples/video-pair-rating/nodes/rate_pair/node.ts +1 -1
  23. package/examples/video-pair-rating/pipeline.browser.integration.spec.ts +267 -0
  24. package/openapi/gen/api.ts +48 -11
  25. package/openapi/gen/models/createDatasetExportBody.ts +3 -3
  26. package/openapi/gen/models/createDatasetExportBodyOneOf.ts +6 -0
  27. package/openapi/gen/models/createDatasetExportBodyOneOfFormat.ts +2 -0
  28. package/openapi/gen/models/createDatasetExportBodyOneOfThree.ts +10 -0
  29. package/openapi/gen/models/createDatasetExportBodyOneOfThreeContract.ts +2 -0
  30. package/openapi/gen/models/createDatasetExportBodyOneOfThreeFormat.ts +2 -0
  31. package/openapi/gen/models/createDatasetExportBodyOneOfThreeItemFilter.ts +9 -0
  32. package/openapi/gen/models/createDatasetExportBodyOneOfThreeItemFilterFieldSourcesItem.ts +6 -0
  33. package/openapi/gen/models/createDatasetExportBodyOneOfThreeItemFilterFieldSourcesItemSourcesItem.ts +4 -0
  34. package/openapi/gen/models/createDatasetExportBodyOneOfThreeItemFilterFieldSourcesItemSourcesItemOneOf.ts +5 -0
  35. package/openapi/gen/models/createDatasetExportBodyOneOfThreeItemFilterFieldSourcesItemSourcesItemOneOfTwo.ts +5 -0
  36. package/openapi/gen/models/createDatasetExportBodyOneOfThreeItemFilterFieldValuesItem.ts +12 -0
  37. package/openapi/gen/models/createDatasetExportBodyOneOfThreeItemFilterFieldValuesItemOperator.ts +2 -0
  38. package/openapi/gen/models/createDatasetExportBodyOneOfThreeItemFilterFieldValuesItemSourcesItem.ts +4 -0
  39. package/openapi/gen/models/createDatasetExportBodyOneOfThreeItemFilterFieldValuesItemSourcesItemOneOf.ts +5 -0
  40. package/openapi/gen/models/createDatasetExportBodyOneOfThreeItemFilterFieldValuesItemSourcesItemOneOfTwo.ts +5 -0
  41. package/openapi/gen/models/createDatasetExportBodyOneOfThreeItemFilterFieldValuesItemValue.ts +2 -0
  42. package/openapi/gen/models/datasetExportReport.ts +9 -0
  43. package/openapi/gen/models/datasetExportReportErrorsItem.ts +5 -0
  44. package/openapi/gen/models/datasetExportReportTokens.ts +7 -0
  45. package/openapi/gen/models/exportJob.ts +2 -0
  46. package/openapi/gen/models/exportJobReport.ts +3 -0
  47. package/openapi/gen/models/index.ts +48 -0
  48. package/openapi/gen/models/sampleDatasetItemsBody.ts +4 -0
  49. package/openapi/gen/models/sampleDatasetItemsBodyAnyOf.ts +8 -0
  50. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfItemFilter.ts +9 -0
  51. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfItemFilterFieldSourcesItem.ts +6 -0
  52. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfItemFilterFieldSourcesItemSourcesItem.ts +4 -0
  53. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfItemFilterFieldSourcesItemSourcesItemOneOf.ts +5 -0
  54. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfItemFilterFieldSourcesItemSourcesItemOneOfTwo.ts +5 -0
  55. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfItemFilterFieldValuesItem.ts +12 -0
  56. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfItemFilterFieldValuesItemOperator.ts +2 -0
  57. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfItemFilterFieldValuesItemSourcesItem.ts +4 -0
  58. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfItemFilterFieldValuesItemSourcesItemOneOf.ts +5 -0
  59. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfItemFilterFieldValuesItemSourcesItemOneOfTwo.ts +5 -0
  60. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfItemFilterFieldValuesItemValue.ts +2 -0
  61. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfOnethree.ts +8 -0
  62. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfOnethreeItemFilter.ts +9 -0
  63. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfOnethreeItemFilterFieldSourcesItem.ts +6 -0
  64. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfOnethreeItemFilterFieldSourcesItemSourcesItem.ts +4 -0
  65. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfOnethreeItemFilterFieldSourcesItemSourcesItemOneOf.ts +5 -0
  66. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfOnethreeItemFilterFieldSourcesItemSourcesItemOneOfTwo.ts +5 -0
  67. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfOnethreeItemFilterFieldValuesItem.ts +12 -0
  68. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfOnethreeItemFilterFieldValuesItemOperator.ts +2 -0
  69. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfOnethreeItemFilterFieldValuesItemSourcesItem.ts +4 -0
  70. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfOnethreeItemFilterFieldValuesItemSourcesItemOneOf.ts +5 -0
  71. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfOnethreeItemFilterFieldValuesItemSourcesItemOneOfTwo.ts +5 -0
  72. package/openapi/gen/models/sampleDatasetItemsBodyAnyOfOnethreeItemFilterFieldValuesItemValue.ts +2 -0
  73. package/openapi/gen/models/sampleJob.ts +13 -0
  74. package/openapi/gen/models/sampleJobStatus.ts +2 -0
  75. package/openapi/gen/models/sampleResult.ts +5 -0
  76. package/package.json +23 -2
  77. package/skills/catalog.json +14 -6
  78. package/skills/toloka-build/SKILL.md +34 -12
  79. package/skills/toloka-build/references/node-semantics.md +27 -24
  80. package/skills/toloka-build/references/workflow-and-cli.md +55 -26
  81. package/skills/toloka-report-issue/references/report-template.md +1 -1
  82. package/src/checks/ast.ts +32 -0
  83. package/src/checks/index.ts +14 -0
  84. package/src/checks/postprocess-collisions.ts +145 -0
  85. package/src/checks/task-ui-declarations.generated.ts +19 -0
  86. package/src/checks/task-ui-typecheck.ts +345 -0
  87. package/src/checks/typescript-vfs.d.ts +26 -0
  88. package/src/checks/typescript-vfs.js +5 -0
  89. package/src/cli/analytics.ts +1 -0
  90. package/src/cli/check.ts +977 -0
  91. package/src/cli/program.ts +147 -19
  92. package/src/cli/project-context.ts +14 -4
  93. package/src/cli/runs.ts +21 -11
  94. package/src/cli/skill.ts +17 -6
  95. package/src/testing/code-node.ts +160 -0
  96. package/src/testing/index.ts +15 -0
  97. package/src/testing/task-ui-browser.ts +120 -0
  98. package/src/testing/task-ui-validation.ts +135 -0
  99. package/src/testing/task-ui.ts +557 -0
  100. package/src/testing/test-evidence.ts +170 -0
  101. package/src/testing/types.ts +141 -0
@@ -1,25 +1,31 @@
1
1
  ---
2
2
  name: toloka-build
3
- description: Build, inspect, and change Toloka platform pipeline projects as TypeScript source with @toloka-platform/sdk and toloka. Use when the user wants to create, adopt, inspect, plan, or apply a pipeline project as code.
3
+ description: Onboard users and build, test, inspect, or change Toloka platform pipeline projects as TypeScript source with @toloka-platform/sdk, toloka check, and toloka apply. Use when the user wants to get started, create, adopt, inspect, plan, apply, test, check, or run a pipeline project as code.
4
4
  ---
5
5
 
6
6
  # Build Toloka pipelines as code
7
7
 
8
8
  This SDK is Preview software. The authoring API, the CLI, and generated source can change. Do not invent helpers or flags that are not in the installed package.
9
9
 
10
- Use this skill when the user wants to create, inspect, or change a Toloka pipeline project as code. Work in the project source tree; do not translate the request into direct platform API calls.
10
+ Use this skill when the user wants to get started or to create, inspect, test, or change a Toloka pipeline project as code. Work in the project source tree; do not translate the request into direct platform API calls.
11
+
12
+ ## Guide a first-time user
13
+
14
+ When the user asks to get started or points to `https://platform.toloka.ai/onboarding.md`, read that guide before acting. The guide owns the session order and its user checkpoints. This skill owns authoring semantics, local test requirements, recovery, and evidence reporting.
15
+
16
+ Do not replace the guide's quick demo with another example, and do not run the demo when the user chooses their own task. Never cross its API-key, project-creation, plan, or run-cost checkpoint without the user's required action or approval.
11
17
 
12
18
  ## Follow the reconciliation loop
13
19
 
14
20
  1. Read `toloka.json` when present, then read the relevant `pipelines/**/pipeline.ts` module and everything it imports.
15
21
  2. Edit the TypeScript source. Treat it as authoritative desired state.
16
- 3. Run the project's typecheck, then validate each changed pipeline against the platform:
22
+ 3. Run the complete local gate, then validate each changed pipeline against the platform:
17
23
  ```sh
18
- bunx tsc --noEmit
24
+ toloka check
19
25
  toloka validate
20
26
  ```
21
27
  4. Run `toloka plan`. Read the complete diff and resolve every conflict or missing prerequisite.
22
- 5. Run `toloka apply`. Apply only after the plan matches the request.
28
+ 5. Run `toloka apply`. Apply reruns the complete local gate and proceeds only when it passes. Apply only after the plan matches the request.
23
29
  6. Run `toloka plan` again and require `No changes.`
24
30
 
25
31
  The CLI reads source, compares it with live state, and reconciles the platform. Edit files; never mutate a pipeline through raw HTTP, SDK client methods, or internal platform tool calls. Do not make a live edit and then reverse-engineer it into source.
@@ -28,17 +34,23 @@ The CLI reads source, compares it with live state, and reconciles the platform.
28
34
 
29
35
  Use the directory containing `toloka.json` as the source root. Commands default to the current directory; use `--source-root <directory>` from elsewhere.
30
36
 
31
- - If `toloka.json` exists, read it as CLI-managed identity state. It maps the project, pipeline source directories, and dataset names to live IDs. Do not hand-edit it.
32
- - If it is absent and the user is adopting an existing project, run `toloka project add <alias> <projectId>`, then `toloka import` in the intended source root. Import refuses an existing `pipelines/` directory unless you pass `--force`.
33
- - If it is absent and the user is authoring from scratch, run `toloka project create <alias>`. Create `pipelines/<name>/pipeline.ts`, then run `toloka plan` and `toloka apply`.
37
+ - If `toloka.json` exists, read it as CLI-managed identity state and confirm its `projectId` matches `toloka project current` before any plan or apply. It maps the project, pipeline source directories, and dataset names to live IDs. Do not hand-edit it.
38
+ - If it is absent and the user is adopting an existing project, run `toloka project add <alias> <projectId>`, then run `toloka import <projectId>` in the intended source root before `toloka init`. Import refuses an existing `pipelines/` directory unless you pass `--force`.
39
+ - After importing an existing project, run `toloka plan` before editing and require `No changes.`. Resolve importer or live-state drift separately so it cannot be mistaken for your change.
40
+ - If it is absent and the user is authoring from scratch, run `toloka project create <alias>` before `toloka init`. Confirm `toloka project current` and the generated `toloka.json` name the new project before authoring.
41
+
42
+ If `toloka project current` reports `from toloka.json` for a project you did not select in this checkout, stop: project create/add/switch does not rebind an existing checkout. A newly generated state file with empty `pipelines` and `datasets` can be removed before selecting the intended project and rerunning `toloka init`; any state file with live bindings may be someone else's checkout and must not be deleted without user approval.
34
43
 
35
44
  Never assume a project ID from conversation context. Resolve it from `--project-id`, `TOLOKA_PROJECT_ID` / `POTATO_PROJECT_ID`, `toloka.json`, or `toloka project current`.
36
45
 
46
+ `project create`, `project add`, and `project switch` also change the machine-level current-project registry used outside a source root. For temporary or evaluation projects, record the previous alias and restore it before finishing. If create requires `--team-id`, use the team from `toloka status --project-id <authorized-project>` only when that project is known to share the intended owner; state the assumption and confirm the new project's team in `toloka project url`. With no such project, ask the user for the team ID.
47
+
37
48
  ## Author with the typed graph API
38
49
 
39
50
  Import authoring helpers from `@toloka-platform/sdk`.
40
51
 
41
52
  - Declare every data contract once with `field(name, jsonSchema)`.
53
+ - Do not invent enum, length, range, format, label-precedence, tie-break, default, exact-phrase, or conditional-requiredness rules absent from the request or observed data. Before apply, list every authored rule the request did not fix—including criteria, quiz answers, and UI validation—as an assumption; choose the least surprising option and carry that list into the final report.
42
54
  - Use exactly these constructors: `root`, `code`, `generation`, `match`, and `quorum`.
43
55
  - Connect typed ports with `connect(from, to)`: `started`, `completed`, `input`, `output`, `matchNode.matched(0)`, and `default`.
44
56
  - Export a default `definePipeline({ dataset, fields, nodes, connections })` from every `pipelines/**/pipeline.ts`.
@@ -54,19 +66,24 @@ These are server rules that `definePipeline` does not check. Each one costs an a
54
66
 
55
67
  - **Do not pair `projectType: 'general'` with `verifiedExperts: false`.** The server answers `General projects require an ID-verified audience`. Specializations also require a verified audience.
56
68
  - **Training is part of the node, not extra.** A quorum node requires `onboarding`, and while it is enabled the platform wants at least three steps and at least one quiz block. Preserve an explicit `enabled: false` that a user or `toloka import` put there; never switch Training on to satisfy your own sense of completeness.
69
+ - **Do not author placeholder optional settings.** Omit `exam`, non-default QA, audience reuse, and smart-search blocks unless the user requested them or imported source already controls them. An empty disabled block is still authored state.
57
70
  - **Run scope belongs to the platform.** `itemFilter` and `itemLimit` on the root node are set from the platform, and apply preserves whatever is live unless source declares its own value. Do not add an item limit to source to "restore" one you saw in the UI.
58
71
 
59
72
  ## Know the validation boundary
60
73
 
61
74
  `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.
62
75
 
63
- `toloka validate` posts each bound pipeline graph to `POST /pipelines/:pipelineId/graph/validate`. That is the platform's spec validation plus the latest matching check jobs. It does not write the graph. Pipelines that have not been applied yet are skipped until `toloka apply` creates them.
76
+ `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, 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; `partial` means hardware-backed behavior remains unverified; `infrastructure_error` means the checker could not run. All four block apply.
64
77
 
65
- A successful `toloka validate` is necessary, not proof the pipeline can be launched. The labeler UI on a human-work node still needs a fresh successful validation receipt after every UI edit, and some per-node checks must be started separately. When apply succeeds but deployment is refused, stop and hand off to the platform UI for that node instead of editing source in circles.
78
+ `toloka validate` posts each bound graph to the platform. Treat source/spec errors as blocking and warnings as informational. `not_ran_node_check` concerns a separate Remote Node Check and does not invalidate a passing Local Check Gate. A pipeline not yet on the platform is skipped until `toloka apply` creates it. When a reviewed plan adds a dataset field already bound by an existing live pipeline, pre-apply validation can report that exact field as missing; apply only the reviewed additive plan, then require post-apply validation to clear source/spec errors. Never rewrite valid source for a missing Remote Node Check.
79
+
80
+ Before choosing Task UI components, call `ui.componentDocumentation()` from a local `@toloka-platform/sdk/testing` scenario. A component's usable contract is the returned `propsType` plus its returned `valueType` and `example`; shared `Field` props such as `path`, `label`, `hint`, and `validation` can be confirmed from any current `Field.*` example, but do not invent any other prop. For structured or array-valued Fields, derive the dataset field schema from `valueType`, then feed the documented example value through `setValue`, `getValue`, and `submit` in the UI scenario so upstream contract drift fails locally. Never translate undocumented property names or replace missing values with defaults. Every identifier in `ui.code` must be a returned component or documented `actions` API, and JSX must have one root element. Register each required UI scenario with `test.ui(pipeline, node, name, callback)` and submit through its bound `render` helper. Run `toloka check <pipeline> --node <name-or-id>` after every Task UI edit; require passing UI types, empty browser validation errors, valid postprocessed entity output, and visual inspection where relevant. Never weaken authored validation merely to make a test pass.
81
+
82
+ Register code behavior with `test.code(pipeline, node, name, callback)` and execute the bound `run` helper. Add at least one `test.pipeline(pipeline, name, callback)` scenario. When a local dataset file is available, use its first row as the initial item state; redact sensitive values while preserving field names, nesting, optionality, and media/value shapes. Use synthetic input only when no local row exists. Treat the fixture as `root.started` item state, execute connected nodes in order with the callback's bound code and UI helpers, merge only each node's declared outputs, and assert the final `root.completed` fields. One scenario is appropriate for a linear happy path; use separate scenarios for different match branches, optional paths, and failures.
66
83
 
67
84
  ## Keep data and credentials out of source
68
85
 
69
- - Never put dataset items in pipeline source or `toloka.json`. After apply has created or resolved the dataset, upload `.json`, `.jsonl`, or `.csv` rows with `toloka dataset upload <dataset> <file>`. If a later upload fails as schema-incompatible, run `toloka dataset fields <dataset>` and copy the printed `field()` declarations into source.
86
+ - Never put dataset items in pipeline source or `toloka.json`. After apply has created or resolved the dataset, upload `.json`, `.jsonl`, or `.csv` rows with `toloka dataset upload <dataset> <file>`. If a later upload fails as schema-incompatible, inspect `toloka dataset fields <dataset>` for stored names and base types, but preserve stricter authored constraints; the printed inference can omit enum, length, range, and format constraints.
70
87
  - Put secret references in node settings, but never secret values. Set values through stdin with `toloka secret set <name>`, or use `toloka secret set <name> --from-env <variable>`.
71
88
 
72
89
  ## Credentials
@@ -82,13 +99,18 @@ Anonymous command telemetry is on by default; set `TOLOKA_TELEMETRY=0` or `DO_NO
82
99
  - **Dataset field schema conflict:** Stop trying to edit the field. Dataset fields are immutable after creation: they can be added, never altered or removed. Declare a new column name with the wanted schema, or bind the pipeline to a new dataset, then plan again.
83
100
  - **Missing secret:** Set every name listed by plan with `toloka secret set <name>`, keep the value out of files and shell arguments, then rerun plan and apply.
84
101
  - **409 stale version:** Another writer changed the graph after it was read. Do not retry blindly. Run `toloka plan` to re-read live state, review the new diff, preserve intentional remote changes in source when needed, then run `toloka apply` again.
102
+ - **Server 400 after partial apply:** Dataset and field writes can land before pipeline import is rejected. Fix the source and run `toloka plan` again. Continue from the remaining diff; do not recreate resources that remain valid. If the rejection means a newly created field schema is wrong, that field is already immutable: apply the field-conflict rule by choosing a new column name or a new dataset, prefer the option that preserves names fixed by the request, and report the orphan instead of deleting it.
85
103
 
86
104
  ## Run a deployed pipeline
87
105
 
106
+ Before starting a run, require a passing `toloka check` and no blocking source/spec error from `toloka validate`. Do not block on `not_ran_node_check`, which concerns separate Remote Node Checks. Run `toloka pipeline cost <name>` when pricing evidence is needed; if it skips a billed node, report the authored rate and a labeled labor floor instead of presenting `$0.00` as the price.
107
+
88
108
  Start a run with `toloka pipeline run <name> --wait --timeout <ms>`, then read its exit code: `0` succeeded, `1` reached a failed terminal state, `2` still running when the window closed. Without `--wait`, exit `0` only means the run was accepted. Nothing reports back later, so never describe a started run as a finished one. Name the live pipeline; there is no implicit only-pipeline.
89
109
 
90
110
  Always bound the wait. A queue with no one working it stays in progress indefinitely, so an unbounded poll loop ends with you killed and reporting nothing. On exit `2`, stop waiting and report what you observed: item counts, current states, and that the run had not finished. A bounded honest report beats an unbounded silent wait. Use `toloka pipeline status <name>` and `toloka pipeline results <runId> --failed` for counts, states, and errors. `toloka status` (no prefix) is project health, not the latest run.
91
111
 
112
+ ## Report with evidence
113
+
92
114
  Deliver that report in the same reply that does the work. There is no later turn and no background poller that will speak for you: if you end by promising to report once a window closes, the observation is lost and the work counts for nothing. Poll in the foreground, then state what you saw before you finish.
93
115
 
94
- Read [workflow and CLI recipes](references/workflow-and-cli.md) for source layout, configuration precedence, adoption, scratch authoring, upload, secret, run, multi-project, and recovery details.
116
+ For an autonomous or audited platform change, save stdout, stderr, and exit status for skill discovery and every networked mutation, check, and project-registry change outside authored source, then cite those records for counts, exit codes, and convergence claims. If skill installation fails, record the failure and identify the exact skill path and version or digest followed instead. Every reported defect or guidance gap must cite a saved record or be labeled `unrecorded`; mark recurrences from earlier work. Classify each as a skill rule, a rule present but not followed, a documentation gap, or a CLI/platform defect; use the bundled `toloka-report-issue` skill for product defects instead of teaching a workaround as normal workflow. Report every authored rule not fixed by the request as an assumption. For visual evidence, list every saved screenshot as inspected or uninspected and limit appearance claims to the inspected set.
@@ -20,21 +20,21 @@ Choose by behavior, not by the data format:
20
20
 
21
21
  Use the typed node properties; never write handle strings yourself:
22
22
 
23
- | Node | Input | Output |
24
- | --- | --- | --- |
25
- | `root` | `collection.completed` | `collection.started` |
26
- | `code` | `transform.input` | `transform.output` |
27
- | `generation` | `annotate.input` | `annotate.output` |
28
- | `quorum` | `rate.input` | `rate.output` |
29
- | `match` | `route.input` | `route.matched(0)`, `route.matched(1)`, …, `route.default` |
23
+ | Node | Input | Output |
24
+ | ------------ | ---------------------- | ---------------------------------------------------------- |
25
+ | `root` | `collection.completed` | `collection.started` |
26
+ | `code` | `transform.input` | `transform.output` |
27
+ | `generation` | `annotate.input` | `annotate.output` |
28
+ | `quorum` | `rate.input` | `rate.output` |
29
+ | `match` | `route.input` | `route.matched(0)`, `route.matched(1)`, …, `route.default` |
30
30
 
31
31
  Connect them in the direction of data flow:
32
32
 
33
33
  ```ts
34
- connect(collection.started, transform.input)
35
- connect(transform.output, route.input)
36
- connect(route.matched(0), annotate.input)
37
- connect(annotate.output, collection.completed)
34
+ connect(collection.started, transform.input);
35
+ connect(transform.output, route.input);
36
+ connect(route.matched(0), annotate.input);
37
+ connect(annotate.output, collection.completed);
38
38
  ```
39
39
 
40
40
  `match.matched(index)` corresponds by index to `settings.conditions[index]`. The first matching condition wins; `default` receives items that match none.
@@ -52,14 +52,13 @@ The public authoring shape is `RootAuthoringSettings`:
52
52
  - Each entry can be a `Field` or `{ field, optional }`; a bare `Field` is required.
53
53
  - `itemLimit` exists in both `RootNodeSettings` and `RootAuthoringSettings`. Do not invent a limit; author one only when the user explicitly requests a bounded test or batch. Apply preserves a live `itemLimit` unless source declares its own.
54
54
 
55
-
56
55
  The dataset name belongs in `definePipeline({ dataset: 'name', ... })`, not in the root settings. `toloka apply` resolves or creates the named dataset and supplies its ID.
57
56
 
58
57
  ### Traps
59
58
 
60
59
  - Do not author `datasetId` or `itemFilter`; `RootAuthoringSettings` omits both. `toloka apply` binds the dataset and preserves the live `itemFilter` and `itemLimit` unless source declares its own `itemLimit`. Do not add a limit to source to restore one you saw in the UI.
61
60
 
62
- - Do not put a field in `completed` unless the final connected branch actually produces it.
61
+ - `completed` may contain any declared field carried on the incoming branch, whether it originated at root input or an upstream output. Never list a field no upstream node provides. Until a run produces results, write-back of a pass-through input is unobserved and must be reported that way.
63
62
  - Declare every referenced `Field` in `definePipeline({ fields })`.
64
63
  - Dataset fields are immutable after creation. You may add a column, never alter or remove one. On a schema conflict, use a new column name or a new dataset.
65
64
 
@@ -143,16 +142,18 @@ An authored entity uses `field`, not `fieldProxyId`. Set `entityType`, `optional
143
142
  - `dynamic: false` means one value in one annotation; use a path without `[*]` and omit `maxEntities`.
144
143
  - `dynamic: true` means repeated values inside one annotation; use exactly one `[*]` in `jsonPath` and set `maxEntities` from 1 through 50.
145
144
  - Use `allowedLabels: [{ label, value }]` for fixed choices. Use `SINGLE_LABEL` for exactly one stored value and `MULTI_LABEL` for multiple values.
146
- - Set both `minDurationSeconds` and `maxDurationSeconds` on `VIDEO` entities.
145
+ - Set media duration bounds only when the expert produces the media through an upload or recording output. Input media used for annotation does not require duration bounds.
147
146
  - Give every output entity at least one relation to the input it uses: `{ field, rel_type: 'context' | 'references' | 'depends_on' | 'evaluates' }`, or a conditional relation supported by the public type.
148
147
 
148
+ `entityType` is a closed platform vocabulary even where a generated TypeScript shape is currently broad. Use `CONTEXT` for any non-media input the expert reads, including text, numbers, and objects. Use `SHORT_ANSWER` for short produced text, `RESPONSE` for long produced text, and `EXPLANATION` only for reasoning about another value. Use `SINGLE_LABEL` or `MULTI_LABEL` for fixed choices and the matching media or annotation type for those values. Never invent `TEXT` or another natural-language type name; consult the documented vocabulary when these categories do not fit.
149
+
149
150
  Entities enforce format, not meaning. Put types, ranges, cardinality, requiredness, and labels in the field schema and entity. Put accuracy, correctness, completeness, and clarity in quality criteria.
150
151
 
151
- For video `data_collection`, the upload or recorder returns an array even when one video is requested. Use an output `VIDEO` entity with `dynamic: true`, `maxEntities: 1`, and a `jsonPath` ending in `[*]`; align its duration bounds with the UI component.
152
+ For any single-item upload or recording control, the component value is still an array. Declare the output field as a top-level array with `minItems: 1` and `maxItems: 1`, the output entity as `dynamic: true` with `maxEntities: 1` and a `jsonPath` ending in `[*]`, and use the matching media or document entity type. Map the component's documented completed-value link field in `postprocess`. For video, also set both entity duration bounds and align them with the UI component.
152
153
 
153
154
  #### Quality and instructions
154
155
 
155
- Write at least one criterion for every output entity. Each criterion needs an authored UUID `id`, `qualityElement`, mutually exclusive and exhaustive `thresholds.pass` and `thresholds.fail`, and `targetEntity: outputField`. Invert the task into an observable check: “tag every car” becomes “every visible car has exactly one tag.” Keep format validation out of criteria.
156
+ Write at least one criterion for every output entity. Each criterion needs an authored UUID `id`, `qualityElement`, mutually exclusive and exhaustive `thresholds.pass` and `thresholds.fail`, and `targetEntity: outputField`. Every criterion must resolve to pass or fail for every item; express edge cases as conditional clauses inside an always-applicable criterion. Criteria judge meaning, not an exact phrase you authored unless the request fixes that phrase. Before apply, walk every sample row through the instruction and all criteria: each criterion must yield one verdict, and no two authored rules may demand different values for the same row. Invert the task into an observable check: “tag every car” becomes “every visible car has exactly one tag.” Keep format validation out of criteria.
156
157
 
157
158
  Use `llmQaInstruction` only when the evaluator needs a specific verification method, authoritative source, tool, or pinned edge case beyond the thresholds. It is evaluator guidance, not labeler guidance, and has no effect in `human_only` mode.
158
159
 
@@ -162,7 +163,7 @@ Keep `instruction` actionable and in English. Include the workflow, concepts, qu
162
163
 
163
164
  #### Audience and pricing
164
165
 
165
- For humans, set `audienceType: 'human'`, `verifiedExperts`, all three audience filters, `pricePerTask`, and `timeForTask`. The public shapes differ by filter: languages use `{ type: 'and' | 'or', values: [{ value: 'English' }] }`; specializations use `{ type: 'and' | 'or', values: [{ value, qualificationId }] }`; countries use `{ type: 'or', values: ['United States'] }`. Start unspecified filters with English, no specializations, and no countries. Do not put specializations on an unverified audience. A specialization's `qualificationId` is platform identity: preserve an imported value, and do not invent one when the SDK cannot discover it.
166
+ For humans, set `audienceType: 'human'`, `verifiedExperts`, all three audience filters, `pricePerTask`, and `timeForTask`. The public shapes differ by filter: languages use `{ type: 'and' | 'or', values: [{ value: 'English' }] }`; specializations use `{ type: 'and' | 'or', values: [{ value, qualificationId }] }`; countries use ISO 3166-1 alpha-2 codes, for example `{ type: 'or', values: ['US'] }`. Verify every country value matches `/^[A-Z]{2}$/`; apply currently accepts arbitrary strings that can match no experts. Start unspecified filters with English, no specializations, and no countries. Do not put specializations on an unverified audience. A specialization's `qualificationId` is platform identity: preserve an imported value, and do not invent one when the SDK cannot discover it.
166
167
 
167
168
  Start with `$0.20` and 120 seconds when the task gives no stronger signal, then change them only for an explicit rate or clearly longer work. The per-expert cap is normally off. For `data_collection`, use a cap of 50 by default; use 1 for one-response-per-expert collection.
168
169
 
@@ -185,10 +186,10 @@ Use `reuseAudienceWithNodeId` only with real imported `{ pipelineId, nodeId }` v
185
186
  - Do not add fields, explanations, comments, or labor the task does not require.
186
187
  - Do not choose synthetic generation merely because a model could do the task; require an explicit request.
187
188
  - Do not treat the constructor's generated placeholder Training or blank UI as production-ready configuration.
188
- - Do not pair `projectType: 'general'` with `verifiedExperts: false`. General projects require an ID-verified audience, and the server rejects the graph with `General projects require an ID-verified audience`. `data_collection` supports both modes but requires a media upload component (`VideoUpload`, `VideoRecord`, or `FileUpload`) in the `ui` code. An annotation task with an unverified audience therefore cannot be expressed: `general` demands verified experts and `data_collection` demands an upload widget the task has no use for. When a request asks for one, say so and let the requester choose, rather than quietly flipping a setting.
189
+ - Do not pair `projectType: 'general'` with `verifiedExperts: false`. General projects require an ID-verified audience, and the server rejects the graph with `General projects require an ID-verified audience`. `data_collection` supports both modes but requires a hardware upload or recording component supported by the current UI catalog. An annotation task with an unverified audience therefore cannot be expressed: `general` demands verified experts and `data_collection` demands an upload control the task has no use for. When a request asks for one, say so and let the requester choose, rather than quietly flipping a setting.
189
190
  - Do not omit `ui.constants`. It is required alongside `code`, `data`, `preprocess`, and `postprocess`; `'{}'` is the right value when there is nothing to pass. Omitting it fails validation with `must have required property 'constants'`, usually reported together with a misleading `type must be equal to constant` from the failed node discrimination.
190
191
  - Do not ship a generation node without Training. `onboarding` is mandatory: at least three `steps`, of which at least one carries a `quiz` block. The server rejects fewer with `Onboarding must have at least 3 steps` and `Onboarding must include at least one quiz block`.
191
- - Do not treat the server's materialized defaults as your configuration. A deployed node reports `qualityAssurance`, `exam`, `reuseAudienceWithNodeId`, and `smartSearch` even when source never set them. Leave them out of source unless you mean to control them; `plan` compares only what source declares.
192
+ - Do not treat the server's materialized defaults as your configuration. A deployed node reports `qualityAssurance`, `exam`, `reuseAudienceWithNodeId`, and `smartSearch` even when source never set them. Leave them out unless you mean to control them. Omitted top-level object keys are preserved, but defaults materialized inside list elements can still cause drift; use the generic import-and-diff recovery flow.
192
193
 
193
194
  ## `quorum`
194
195
 
@@ -213,6 +214,8 @@ Quorum is human-only in the current public shape; its `audienceAndPricing.audien
213
214
 
214
215
  Configure entities for one labeler's contribution, not for the outer array. A single label per person therefore uses `dynamic: false` and `jsonPath: '$.label'`, while the declared output field is `{ type: 'array', items: { type: 'string' } }`. `dynamic: true` means an array inside each labeler's contribution and therefore produces an array of arrays. Build the UI to submit one value at `$.label`, never `$.label[0]`; the platform assembles the outer array.
215
216
 
217
+ When a quorum output entity is `optional: true`, its outer field's `items` schema must also accept `null`, for example `{ type: 'array', items: { type: ['string', 'null'] } }`. The platform reserves a null annotation slot when that labeler omits the value and rejects an optional entity backed by non-nullable items.
218
+
216
219
  Quorum does not aggregate. It writes all raw annotations back, including rejected ones. Add a downstream `code` node only when the user asks for one consensus value, and make it tolerate arrays longer than `overlap`.
217
220
 
218
221
  #### Explanation-driven quality
@@ -257,7 +260,7 @@ Set `MatchAuthoringSettings`, derived from `MatchNodeSettings`, through `match(n
257
260
 
258
261
  - `about`: `name`, optional `description`, optional `projectType`.
259
262
  - `fieldProxies.input`: every declared `Field` referenced by a predicate, each with `optional`.
260
- - `conditions`: ordered branches. Each has `name`, optional `logic: 'and' | 'or'`, and `predicates`.
263
+ - `conditions`: ordered branches with optional `logic: 'and' | 'or'` and required `predicates`.
261
264
  - Each authored predicate uses `field`, `jsonPath`, `operator`, and scalar `value`.
262
265
 
263
266
  The current public type accepts only `operator: 'text_eq' | 'text_neq'` and `value: string | number | boolean | null`. Do not copy broader internal operator lists into source. Use `jsonPath: '$'` for the whole scalar or a restricted path into an object.
@@ -278,14 +281,14 @@ When the requirement depends on one of these capabilities, state the gap instead
278
281
  - Audience discovery and validation helpers have no SDK or CLI path: valid-language/country/specialization suggestions, audience-size statistics, and recommended-rate calculation.
279
282
  - Audience-reuse candidate discovery has no SDK or CLI path. Source can store a known cross-pipeline pointer, but cannot search candidates.
280
283
  - 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.
281
- - The interactive task-interface toolkit has no SDK/CLI testing path for component discovery, component documentation, rendered tree/value inspection, screenshots, TypeScript reports, or submission validation. Source can set `ui`; final UI verification remains server/UI work.
284
+ - The `@toloka-platform/sdk/testing` entry point provides typed `test.code`, `test.ui`, and `test.pipeline` wrappers. `toloka check` runs their evidence with project TypeScript and automatic Task UI typechecking. Missing Remote Node Checks remain separate from this local gate.
282
285
  - 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 validate hands-on examples locally beyond the public graph schema.
283
286
  - 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.
284
- - Per-node strict validation is not exposed separately. `definePipeline` and offline `validate(graph)` check the public contract; `toloka validate` runs platform spec validation and reports the latest matching check jobs without writing the graph.
285
- - Stored checks can be represented in settings and the low-level client can list/start pipeline checks, but `toloka` has no command that discovers check contracts, configures check cases, starts each required lint/test, waits, and explains reports.
287
+ - Per-node platform validation is not exposed separately. `definePipeline` and `toloka check` enforce local contracts; `toloka validate` runs platform spec validation and reports the latest matching Remote Node Check jobs without writing the graph.
288
+ - Stored Remote Node Checks can be represented in settings and the low-level client can list/start them. `toloka check` deliberately runs local source and authored tests; it does not configure or start platform check jobs.
286
289
  - Project rename and runtime item-filter authoring have no `toloka` source path. The CLI preserves the live item filter and a live `itemLimit` unless source declares its own limit.
287
290
 
288
291
  - Generation's platform-controlled redo cap, appeal behavior, payment retry, and exact terminal handling are intentionally not configurable SDK settings.
289
292
  - Dynamic quorum and per-item overlap are unsupported by both surfaces; this is a platform limitation, not missing TypeScript syntax.
290
293
 
291
- For every representable change above, edit the node's source file, run `toloka validate`, inspect `toloka plan`, and apply with `toloka apply`.
294
+ For every representable change above, edit the node's source file, run `toloka validate`, inspect `toloka plan`, and apply with `toloka apply`.
@@ -26,14 +26,17 @@ Treat the three layers differently:
26
26
 
27
27
  ## Initialize the source root
28
28
 
29
- Install the SDK in the project, then initialize the directory before selecting a platform project:
29
+ For a first-time guided session, read `https://platform.toloka.ai/onboarding.md` first. Keep its stage order and checkpoints; use this reference for the commands and source-first invariants inside those stages.
30
+
31
+ Install the SDK before invoking project commands:
30
32
 
31
33
  ```sh
32
34
  bun add --dev @toloka-platform/sdk
33
- toloka init
34
35
  ```
35
36
 
36
- `init` does not require a selected project. It checks that `@toloka-platform/sdk` is declared in `dependencies` or `devDependencies`, then maintains one `<toloka>` Agent Bootstrap block in `AGENTS.md` and writes minimal pointers to it: a Claude skill at `.claude/skills/toloka-bootstrap/SKILL.md` when `.claude/` exists (or when no agent configuration exists at all) and an always-applied Cursor rule at `.cursor/rules/toloka-bootstrap.mdc` when `.cursor/rules/` exists. If a project is already selected through `--project-id`, `TOLOKA_PROJECT_ID` / `POTATO_PROJECT_ID`, `toloka.json`, or the machine registry, it also writes `toloka.json` when missing.
37
+ Select or create the intended platform project before `toloka init` when the checkout should be bound immediately; follow the adoption or scratch recipe below. Running `init` without explicit or checkout-local project identity installs only the agent entry points and never adopts the machine registry's current project.
38
+
39
+ `toloka init` checks that `@toloka-platform/sdk` is declared in `dependencies` or `devDependencies`, then maintains one `<toloka>` Agent Bootstrap block in `AGENTS.md` and writes minimal pointers to it: a Claude skill at `.claude/skills/toloka-bootstrap/SKILL.md` when `.claude/` exists (or when no agent configuration exists at all) and an always-applied Cursor rule at `.cursor/rules/toloka-bootstrap.mdc` when `.cursor/rules/` exists. It writes `toloka.json` only from an explicit project flag/environment value or an existing checkout binding.
37
40
 
38
41
  The bootstrap is small: it tells an agent to run `toloka --help`, search the bundled Skill Catalog with `toloka skill search <query>`, install the match with `toloka skill install <skill-id>`, and read `.agents/skills/<skill-id>/SKILL.md`. This skill is that installed copy. Commands warn on stderr when a generated legacy entry point is still present or the recorded bootstrap version differs from the installed SDK. Help, `init`, `report`, `project url`, and version invocations skip this checkout-dependent warning. The warning never blocks a command; re-run `toloka init` to refresh the bootstrap and its pointers.
39
42
 
@@ -84,7 +87,7 @@ toloka --version
84
87
  toloka login
85
88
  toloka logout
86
89
  toloka auth-status
87
- toloka project list
90
+ toloka project list [--limit <n>]
88
91
  toloka project add [alias] [projectId]
89
92
  toloka project switch <alias>
90
93
  toloka project current
@@ -93,6 +96,7 @@ toloka project remove <alias>
93
96
  toloka project create [alias] [--name <name>] [--team-id <id>]
94
97
  toloka init
95
98
  toloka import [projectId]
99
+ toloka check [pipeline] [--node <name-or-id>] [--json] [--watch]
96
100
  toloka validate
97
101
  toloka plan
98
102
  toloka apply
@@ -102,7 +106,7 @@ toloka dataset list
102
106
  toloka dataset fields <name>
103
107
  toloka dataset load <name> --out <file> [--limit <n>] [--timeout <ms>]
104
108
  toloka dataset upload <name> <file>
105
- toloka pipeline list
109
+ toloka pipeline list [--limit <n>]
106
110
  toloka pipeline run [name] [--wait] [--timeout <ms>]
107
111
  toloka pipeline status [name]
108
112
  toloka pipeline runs [name] [--limit <n>]
@@ -122,11 +126,11 @@ toloka skill install <skill-id> [--force]
122
126
  toloka report <markdown> [--authored-by human|agent] [--confirm]
123
127
  ```
124
128
 
125
- Select the platform project with `toloka project add` or `toloka project create` before `import`, `plan`, or `apply`. `init` may run first, and `import` uses the selected project when the id is omitted.
129
+ Select the platform project with `toloka project add` or `toloka project create` before `import`, `plan`, or `apply`. For `init`, `toloka --project-id <id> init`, `TOLOKA_PROJECT_ID`, and `POTATO_PROJECT_ID` bind an empty checkout directly without changing the machine registry. `project create` also writes `toloka.json`; `project add` changes only the machine registry, so follow it with `import <projectId>` for an existing project or an explicit project ID on `init` for an empty one. Confirm `toloka project current` and `toloka.json` resolve to the intended ID before authoring.
126
130
 
127
131
  `toloka project url` prints only the selected project's platform UI URL. Use it when the user needs a working link to inspect the live project.
128
132
 
129
- `toloka pipeline cost [name] [--item-limit <n>]` forecasts what a run of a live pipeline would bill. It does not start a run and does not change the graph. Name the live pipeline or id; a TTY may pick among several. The typed client equivalent is `client.pipelines.estimateCost({ pipelineId, itemLimit? })`.
133
+ `toloka pipeline cost [name] [--item-limit <n>]` forecasts what a run of a live, validated pipeline would bill. It does not start a run or change the graph. If any billed node is marked `skipped`, the displayed total is incomplete and must not be presented as the pipeline price. Compute and label a labor floor for each skipped billed node as `items × pricePerTask × annotations per item`, using `1` for generation and `overlap` for quorum. Also report `maxEntities`, quality-criteria count, and only exclusions applicable to the authored QA and workflow. Apply accepting a rate does not prove its final billed value.
130
134
 
131
135
  ## Manage model checkpoints
132
136
 
@@ -134,39 +138,44 @@ The global Base Model Catalog is read-only and uses `toloka base-model`. `base-m
134
138
 
135
139
  ## Adopt an existing live project
136
140
 
137
- 1. Run `toloka init` in the intended source root if the agent entry points are not installed yet.
138
- 2. Run `toloka project add <alias> <projectId>`.
139
- 3. Run `toloka import`.
140
- 4. Inspect `toloka.json` and every generated `pipelines/**/pipeline.ts` dependency before editing.
141
- 5. Preserve generated constructor `id` options. They bind imported source to the existing graph; never copy them to unrelated declarations or invent replacements.
142
- 6. Make the smallest source change, validate offline, plan, apply, and plan again.
141
+ 1. Install `@toloka-platform/sdk` in the intended source root.
142
+ 2. Run `toloka project add <alias> <projectId>`, or `toloka project switch <alias>` when the project is already registered.
143
+ 3. Run `toloka import` into the empty source root.
144
+ 4. Run `toloka init` to install or refresh the agent entry points without rebinding project identity.
145
+ 5. Confirm `toloka.json.projectId` equals `toloka project current`, then run `toloka plan` before editing and require `No changes.`. A non-empty baseline is importer or live-state drift to understand separately from your change.
146
+ 6. Inspect every generated `pipelines/**/pipeline.ts` dependency, preserve constructor `id` options that bind source to the existing graph, and make the smallest source change.
147
+ 7. Validate offline, plan, apply, and plan again. Never copy imported IDs to unrelated declarations or invent replacements.
143
148
 
144
149
  Import refuses an existing `pipelines/` directory. Pass `--force` to replace it with the live graph as TypeScript. Never use `--force` as a harmless refresh over uncommitted source work.
145
150
 
146
151
  ## Author against a project from scratch
147
152
 
148
- 1. Run `toloka init` in the intended source root if the agent entry points are not installed yet.
149
- 2. Run `toloka project create <alias>` or `toloka project add <alias> <projectId>`.
153
+ 1. Run `toloka project create <alias>` for a new project, or `toloka project add <alias> <projectId>` for an existing empty project.
154
+ 2. Run `toloka init` after creation. For an existing empty project, run `toloka --project-id <projectId> init`. Then require `toloka project current` and `toloka.json` to name the same project.
150
155
  3. Create `pipelines/<name>/pipeline.ts` and its imported modules.
151
156
  4. Default-export `definePipeline({ dataset, fields, nodes, connections })`.
152
- 5. Run `toloka validate`.
153
- 6. Run `toloka plan`.
154
- 7. Resolve missing secrets and immutable-field conflicts.
155
- 8. Run `toloka apply`.
157
+ 5. Add typed node and pipeline-flow tests, then run `toloka check`.
158
+ 6. Run `toloka validate`; a not-yet-created pipeline is reported as skipped, not server-validated.
159
+ 7. Run `toloka plan` and resolve missing secrets or immutable-field conflicts.
160
+ 8. Run `toloka apply`; it reruns `toloka check` before any platform write.
156
161
  9. Require a final `toloka plan` to print `No changes.`
157
162
 
158
163
  On first apply, the CLI creates each missing named dataset, adds fields required by the authored graphs, creates each missing pipeline, attaches its dataset, and records the resolved IDs. Two pipelines that name the same dataset contribute the union of their required fields.
159
164
 
160
- ## Validate against the platform
165
+ ## Check locally and validate against the platform
161
166
 
162
- Run the project typecheck first. Then validate every bound pipeline:
167
+ Run the complete local gate first, then validate every bound pipeline remotely:
163
168
 
164
169
  ```sh
165
- bunx tsc --noEmit
170
+ toloka check
166
171
  toloka validate
167
172
  ```
168
173
 
169
- `toloka validate` posts each authored graph to the platform. It reports spec errors, warnings, and the latest matching check jobs. It does not write the graph. A pipeline that is not on the platform yet is skipped until `toloka apply` creates it.
174
+ `toloka check` requires no credentials or live pipeline. It loads source, runs the project TypeScript compiler, typechecks every Task UI against the SDK's bundled declarations, runs Vitest, and compares passing typed test evidence with every checkable node and pipeline. Use `toloka check <pipeline> --node <name-or-id>` for a focused edit loop, `--watch` for serialized reruns, and `--json` for automation. `missing` means required evidence was not produced; `failed` means a check ran and failed; `partial` means hardware-backed behavior remains unverified; `infrastructure_error` means a required tool, browser, or launcher could not run. All four block apply.
175
+
176
+ With `--watch --json`, each completed rerun writes one JSON line. Do not start another watcher while one is active.
177
+
178
+ `toloka validate` posts each authored graph to the platform. Distinguish source/spec errors, which require source changes; `not_ran_node_check`, which describes a separate Remote Node Check; and warnings. It does not write the graph. A pipeline that is not on the platform yet is skipped until `toloka apply` creates it. When plan adds a dataset field used by an already-live pipeline, pre-apply validation can report that exact field as `misconfigured_node_form_component` because the column is not live yet. Treat it as expected only when the reviewed plan adds the same field, then require post-apply validation to clear the source/spec error.
170
179
 
171
180
  The authored API still supplies extra local safety:
172
181
 
@@ -175,7 +184,7 @@ The authored API still supplies extra local safety:
175
184
  - It rejects a `connect()` endpoint whose node is absent from `nodes`.
176
185
  - Typed ports prevent reversing input and output handles.
177
186
 
178
- These checks do not replace `toloka validate`. Plan compares source with live resources but does not submit the desired graph for acceptance. Apply is where the backend can reject graph-wide references, layout identity, or concurrent-version assumptions.
187
+ `toloka apply` runs the full Local Check Gate again before resolving credentials or writing platform state. Plan compares source with live resources but does not submit the desired graph for acceptance. Apply can still expose graph-wide references, layout identity, or concurrent-version assumptions that only the backend owns.
179
188
 
180
189
  ## Read and apply a plan
181
190
 
@@ -189,6 +198,20 @@ Treat every plan line as evidence of what apply will attempt.
189
198
 
190
199
  Apply preserves existing live layout and the root's live item filter. Do not add either to authored source. For graph replacement, apply reads the live graph version and sends it as `expectedVersion`; never put a version in source or state yourself.
191
200
 
201
+ ## Test pipeline nodes locally
202
+
203
+ Register every code-node behavior with `test.code(pipeline, node, name, callback)`. Its callback receives a bound `run(inputs, options?)` helper with the same Python execution contract as `runCodeNode`; the test counts only after the bound executor runs, an assertion executes, and the callback passes.
204
+
205
+ Before choosing component names or props, call `ui.componentDocumentation()` in a local `@toloka-platform/sdk/testing` scenario. A component's contract is its returned `propsType`, `valueType`, and `example`. For structured or array-valued Fields, derive the dataset field schema from `valueType`, then feed the documented example value through `setValue`, `getValue`, and `submit`; never translate undocumented property names or replace missing values with defaults. Register required human-work behavior with `test.ui(pipeline, node, name, callback)`. Its callback receives bound `render(options?)`; the test counts only after a successful `submit`, at least one assertion, and a passing callback.
206
+
207
+ Register the representative connected flow with `test.pipeline(pipeline, name, callback)`. When a local dataset file is available, use its first row as the initial item state; redact sensitive values while preserving field names, nesting, optionality, and media/value shapes. Use synthetic input only when no local row exists. Use the callback's bound `runCode` and `renderUi` helpers, merge only declared node outputs, and assert the final `root.completed` fields. Keep a linear happy path in one test; use separate scenarios for match branches, optional routes, and failures.
208
+
209
+ ```sh
210
+ toloka check
211
+ ```
212
+
213
+ Plain Vitest tests still run and can fail the command, but only typed Toloka wrappers satisfy required node and pipeline coverage. Use synthetic or redacted data. `preprocess` and `postprocess` remain runtime JavaScript function bodies, not TypeScript.
214
+
192
215
  ## Add dataset rows
193
216
 
194
217
  Declare the fields in source, then upload rows:
@@ -197,6 +220,8 @@ Declare the fields in source, then upload rows:
197
220
  toloka dataset upload <dataset> <file>
198
221
  ```
199
222
 
223
+ The upload file path resolves from the command process's working directory, not from `--source-root`. Use an absolute path when the command runs elsewhere.
224
+
200
225
  The CLI infers the input format from its extension and uploads the original bytes without conversion: `.json` is an array of row objects, `.jsonl` has one object per non-empty line, and `.csv` uses its header row as field names with every value ingested as a string. JSONL is validated locally before upload. If transfer or finalization fails, the CLI cancels the started upload before returning the error, so another upload can start immediately and may reuse the same filename. The dataset does not have to exist yet: when a pipeline in source binds it, upload creates it and declares that pipeline's columns, so rows land in real columns rather than in the raw `uploaded` blob. Upload refuses when no pipeline in source declares a name because it would have no column names to map onto. An id-shaped argument is never created; upload fails when that dataset id does not exist in the project. Upload appends items; applying source never deletes them.
201
226
 
202
227
  If a later upload fails with a schema-incompatibility error, inspect the inferred schema from the first successful upload:
@@ -205,7 +230,7 @@ If a later upload fails with a schema-incompatibility error, inspect the inferre
205
230
  toloka dataset fields <dataset>
206
231
  ```
207
232
 
208
- That prints `field()` declarations for the top-level inferred columns. Copy them into source when you want authored fields to match the stored inference. It does not write source or mutate the dataset.
233
+ That prints `field()` declarations for the top-level inferred columns. Use the output to recover stored names and base types, but do not copy it wholesale over stricter source schemas: inference can omit enum, length, range, and format constraints. It does not write source or mutate the dataset.
209
234
 
210
235
  Keep item files outside the source tree or gitignored. Never embed sample or production rows in `pipeline.ts` to make reconciliation create them.
211
236
 
@@ -269,9 +294,13 @@ Use the exact name reported by plan. Set it with `toloka secret set`, rerun plan
269
294
 
270
295
  A 409 means live graph state changed after apply read it. Run plan again, compare the new live diff with the source, incorporate intentional live changes into source when required, and apply once more. Never add `expectedVersion` to source and never loop retries.
271
296
 
297
+ ### Unexplained node drift after apply
298
+
299
+ Object settings preserve omitted live keys, but list-valued settings such as conditions, predicates, entities, steps, and rules can be compared as whole values after the server adds defaults inside an element. If plan reports an unnamed node change after a clean apply, run `toloka import` into a scratch directory outside the source root, compare that node with source, and declare only the materialized key needed for convergence. Delete the scratch directory afterward and never re-apply blindly.
300
+
272
301
  ### Server 400 after a clean validate
273
302
 
274
- Read the returned path and reason. Check connection endpoints, duplicate or unknown IDs preserved from imported source, field references, and any accidentally authored layout. Fix source, rerun `toloka validate`, plan, and apply. Do not bypass reconciliation with a raw API call.
303
+ A new pipeline is skipped by `toloka validate` until it exists remotely, and apply can create its dataset and fields before pipeline import returns a 400. Fix the reported path or reason, then run plan again. If only the pipeline addition remains, continue from that diff; do not recreate or rename resources already created. Check connection endpoints, duplicate or unknown imported IDs, field references, and accidentally authored layout. Never bypass reconciliation with a raw API call.
275
304
 
276
305
  ## Use the shipped example
277
306
 
@@ -26,7 +26,7 @@ The CLI exits 1 with `Potato API request failed with status 500`. The same comma
26
26
 
27
27
  ## Environment
28
28
 
29
- - toloka CLI 0.1.0-preview.6 (`toloka --version`), Bun 1.4.0, macOS 15
29
+ - toloka CLI 0.1.0-preview.7 (`toloka --version`), Bun 1.4.0, macOS 15
30
30
  - Platform: https://platform.toloka.ai
31
31
 
32
32
  ## Redactions
@@ -0,0 +1,32 @@
1
+ import type { JSXAttribute } from "oxc-parser";
2
+ import { parseSync } from "oxc-parser";
3
+
4
+ // Sources are parsed with the same wrapping buildCompositeSource (task-ui-typecheck.ts) injects — if that
5
+ // wrapping changes, change parseProgram's callers with it.
6
+ export const parseProgram = (filename: string, source: string, lang: "ts" | "tsx") => {
7
+ const result = parseSync(filename, source, { lang, preserveParens: false });
8
+
9
+ return result.errors.some((error) => error.severity === "Error") ? null : result.program;
10
+ };
11
+
12
+ export const resolveAttributeString = (attribute: JSXAttribute | undefined): string | null => {
13
+ const value = attribute?.value;
14
+
15
+ if (!value) return null;
16
+
17
+ if (value.type === "Literal") return typeof value.value === "string" ? value.value : null;
18
+
19
+ if (value.type === "JSXExpressionContainer") {
20
+ const expression = value.expression;
21
+
22
+ if (expression.type === "Literal" && typeof expression.value === "string") {
23
+ return expression.value;
24
+ }
25
+
26
+ if (expression.type === "TemplateLiteral" && expression.expressions.length === 0) {
27
+ return expression.quasis[0]?.value.cooked ?? null;
28
+ }
29
+ }
30
+
31
+ return null;
32
+ };
@@ -0,0 +1,14 @@
1
+ export { findPostprocessKeyCollisions } from "./postprocess-collisions";
2
+ export {
3
+ createBundledTaskUiTypechecker,
4
+ createTaskUiTypechecker,
5
+ taskUiDeclarationSnapshot,
6
+ } from "./task-ui-typecheck";
7
+ export type {
8
+ TaskUiBlockKey,
9
+ TaskUiDeclarationSource,
10
+ TaskUiDiagnostic,
11
+ TaskUiDiagnosticsReport,
12
+ TaskUiSource,
13
+ TaskUiTypechecker,
14
+ } from "./task-ui-typecheck";