OpenTask 0.1 + OpenWorkflow 0.1: specs, schemas, fixtures, validators

docs/opentask.md mints OpenTask: one task a person does on a computer,
written down as meaning (goal, apps, parameters with a sensitivity class
and never a value, semantic steps with no coordinates, capture gaps, stop
conditions, approvals, a success check, provenance, runners with digests)
so an agent can do it again. docs/openworkflow.md mints OpenWorkflow: a
collection of OpenTasks inline or by URL + sha256, in sequence or any
order respecting after, with a publisher index at
/.well-known/openworkflow.json.

- @logicsrc/schemas 0.6.0: opentask, openworkflow, openworkflow-index
- @logicsrc/validators 0.6.0: step numbering, placeholders, apps,
  no example on personal/secret parameters, after references

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Anthony Ettinger 2026-10-19 19:00:44 +00:00
parent 3b1bdfbef0
commit 3e6e068597
17 changed files with 954 additions and 13 deletions

View file

@ -52,7 +52,7 @@
}, },
"apps/logicsrc-web": { "apps/logicsrc-web": {
"name": "@logicsrc/web", "name": "@logicsrc/web",
"version": "0.1.0", "version": "0.1.2",
"dependencies": { "dependencies": {
"@logicsrc/openontology": "file:../../packages/openontology", "@logicsrc/openontology": "file:../../packages/openontology",
"@logicsrc/openprd": "file:../../packages/openprd", "@logicsrc/openprd": "file:../../packages/openprd",
@ -228,7 +228,7 @@
"name": "@logicsrc/openerrand", "name": "@logicsrc/openerrand",
"version": "0.1.0", "version": "0.1.0",
"dependencies": { "dependencies": {
"@logicsrc/validators": "^0.4.0", "@logicsrc/validators": "^0.5.0",
"commander": "^14.0.2", "commander": "^14.0.2",
}, },
"devDependencies": { "devDependencies": {
@ -237,7 +237,7 @@
}, },
"packages/openfleet": { "packages/openfleet": {
"name": "@logicsrc/openfleet", "name": "@logicsrc/openfleet",
"version": "0.1.0", "version": "0.1.1",
"dependencies": { "dependencies": {
"commander": "^14.0.2", "commander": "^14.0.2",
}, },
@ -280,7 +280,7 @@
}, },
"packages/schemas": { "packages/schemas": {
"name": "@logicsrc/schemas", "name": "@logicsrc/schemas",
"version": "0.5.0", "version": "0.6.0",
}, },
"packages/sdk": { "packages/sdk": {
"name": "@logicsrc/sdk", "name": "@logicsrc/sdk",
@ -303,12 +303,12 @@
}, },
"packages/validators": { "packages/validators": {
"name": "@logicsrc/validators", "name": "@logicsrc/validators",
"version": "0.5.0", "version": "0.6.0",
"bin": { "bin": {
"logicsrc-validate": "dist/cli.js", "logicsrc-validate": "./dist/cli.js",
}, },
"dependencies": { "dependencies": {
"@logicsrc/schemas": "^0.4.0", "@logicsrc/schemas": "^0.6.0",
"ajv": "^8.17.1", "ajv": "^8.17.1",
"ajv-formats": "^3.0.1", "ajv-formats": "^3.0.1",
"yaml": "^2.8.1", "yaml": "^2.8.1",
@ -1616,6 +1616,8 @@
"@logicsrc/opencontext/@logicsrc/validators": ["@logicsrc/validators@0.1.1", "", { "dependencies": { "@logicsrc/schemas": "^0.1.1", "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "yaml": "^2.8.1" }, "bin": { "logicsrc-validate": "dist/cli.js" } }, "sha512-NbpJKezJiolKIkjDwZ4AgwRfcU3qd93B8rVGZPLh7a6xl8/Hg89ruau6Yxi/bPEUkx3HG9IqFWhGFBEvUtr4ZA=="], "@logicsrc/opencontext/@logicsrc/validators": ["@logicsrc/validators@0.1.1", "", { "dependencies": { "@logicsrc/schemas": "^0.1.1", "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "yaml": "^2.8.1" }, "bin": { "logicsrc-validate": "dist/cli.js" } }, "sha512-NbpJKezJiolKIkjDwZ4AgwRfcU3qd93B8rVGZPLh7a6xl8/Hg89ruau6Yxi/bPEUkx3HG9IqFWhGFBEvUtr4ZA=="],
"@logicsrc/openerrand/@logicsrc/validators": ["@logicsrc/validators@0.5.0", "", { "dependencies": { "@logicsrc/schemas": "^0.5.0", "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "yaml": "^2.8.1" }, "bin": { "logicsrc-validate": "dist/cli.js" } }, "sha512-ST8javLtsom03YRnCqXLFLTI2NXXQp2XAkTp9EaEIgkYCpj4uI2OsX3TXxmOFtPg5JcORIjDYDFvVHujmsa5Jg=="],
"@logicsrc/openprd/@logicsrc/validators": ["@logicsrc/validators@0.1.1", "", { "dependencies": { "@logicsrc/schemas": "^0.1.1", "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "yaml": "^2.8.1" }, "bin": { "logicsrc-validate": "dist/cli.js" } }, "sha512-NbpJKezJiolKIkjDwZ4AgwRfcU3qd93B8rVGZPLh7a6xl8/Hg89ruau6Yxi/bPEUkx3HG9IqFWhGFBEvUtr4ZA=="], "@logicsrc/openprd/@logicsrc/validators": ["@logicsrc/validators@0.1.1", "", { "dependencies": { "@logicsrc/schemas": "^0.1.1", "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "yaml": "^2.8.1" }, "bin": { "logicsrc-validate": "dist/cli.js" } }, "sha512-NbpJKezJiolKIkjDwZ4AgwRfcU3qd93B8rVGZPLh7a6xl8/Hg89ruau6Yxi/bPEUkx3HG9IqFWhGFBEvUtr4ZA=="],
"@logicsrc/pwa/@libsql/client": ["@libsql/client@0.14.0", "", { "dependencies": { "@libsql/core": "^0.14.0", "@libsql/hrana-client": "^0.7.0", "js-base64": "^3.7.5", "libsql": "^0.4.4", "promise-limit": "^2.7.0" } }, "sha512-/9HEKfn6fwXB5aTEEoMeFh4CtG0ZzbncBb1e++OCdVpgKZ/xyMsIVYXm0w7Pv4RUel803vE6LwniB3PqD72R0Q=="], "@logicsrc/pwa/@libsql/client": ["@libsql/client@0.14.0", "", { "dependencies": { "@libsql/core": "^0.14.0", "@libsql/hrana-client": "^0.7.0", "js-base64": "^3.7.5", "libsql": "^0.4.4", "promise-limit": "^2.7.0" } }, "sha512-/9HEKfn6fwXB5aTEEoMeFh4CtG0ZzbncBb1e++OCdVpgKZ/xyMsIVYXm0w7Pv4RUel803vE6LwniB3PqD72R0Q=="],
@ -1680,6 +1682,8 @@
"@logicsrc/opencontext/@logicsrc/validators/@logicsrc/schemas": ["@logicsrc/schemas@0.1.1", "", {}, "sha512-nswf3UCU2P+9Rl1eJkQCRBUPazB8d2XcvI0o5BMEqd4/VepduLRUiyObTi7SbgaB21ipOp0/SgIC+zctkYLXbQ=="], "@logicsrc/opencontext/@logicsrc/validators/@logicsrc/schemas": ["@logicsrc/schemas@0.1.1", "", {}, "sha512-nswf3UCU2P+9Rl1eJkQCRBUPazB8d2XcvI0o5BMEqd4/VepduLRUiyObTi7SbgaB21ipOp0/SgIC+zctkYLXbQ=="],
"@logicsrc/openerrand/@logicsrc/validators/@logicsrc/schemas": ["@logicsrc/schemas@0.5.0", "", {}, "sha512-x2CgYG0zQa418ehiwkK3DKCXIizQpsW+Guc2JKPz7Mrzp6btqUWvAof3prkk0gYLz49pr9PEFvwIDX2MMWlaWg=="],
"@logicsrc/openprd/@logicsrc/validators/@logicsrc/schemas": ["@logicsrc/schemas@0.1.1", "", {}, "sha512-nswf3UCU2P+9Rl1eJkQCRBUPazB8d2XcvI0o5BMEqd4/VepduLRUiyObTi7SbgaB21ipOp0/SgIC+zctkYLXbQ=="], "@logicsrc/openprd/@logicsrc/validators/@logicsrc/schemas": ["@logicsrc/schemas@0.1.1", "", {}, "sha512-nswf3UCU2P+9Rl1eJkQCRBUPazB8d2XcvI0o5BMEqd4/VepduLRUiyObTi7SbgaB21ipOp0/SgIC+zctkYLXbQ=="],
"@logicsrc/pwa/@libsql/client/@libsql/core": ["@libsql/core@0.14.0", "", { "dependencies": { "js-base64": "^3.7.5" } }, "sha512-nhbuXf7GP3PSZgdCY2Ecj8vz187ptHlZQ0VRc751oB2C1W8jQUXKKklvt7t1LJiUTQBVJuadF628eUk+3cRi4Q=="], "@logicsrc/pwa/@libsql/client/@libsql/core": ["@libsql/core@0.14.0", "", { "dependencies": { "js-base64": "^3.7.5" } }, "sha512-nhbuXf7GP3PSZgdCY2Ecj8vz187ptHlZQ0VRc751oB2C1W8jQUXKKklvt7t1LJiUTQBVJuadF628eUk+3cRi4Q=="],

218
docs/opentask.md Normal file
View file

@ -0,0 +1,218 @@
# OpenTask
OpenTask is one JSON file that describes a task a person does on a computer, written down so an agent can do it again. It names the goal, the applications, the values the task needs and how sensitive each one is, the steps the person took as meaning (focus this window, press this button, type this value) rather than as coordinates, what the recording did not see, where an agent must stop, what it must ask before doing, and how to tell the task worked. It says where the description came from, a reviewed demonstration or a person's own hand, and which runners can carry it out. A person reads the file and knows what an agent will try; an agent reads the same file, observes the screen before every action, and stops where the file says to. It is maintained by Profullstack, Inc. as part of the LogicSRC open-standards surface.
Status: **0.1**. A description of tasks that W3BS Training already records and exports, published so others can write tasks, review them and run them.
Slug: `opentask`
Related: [OpenWorkflow](/docs/openworkflow) is a collection of OpenTasks. [OpenErrand](/docs/openerrand) is the sibling for one errand on one website with no API, filled field by field in a headless browser; OpenTask is for any desktop task an agent does by looking at the screen. The `logicsrc.task` schema is a different thing: a paid task on a work board.
## The problem
Agents that drive a desktop learn from demonstrations. A person shows the task once, a recorder keeps what it saw, and an agent is told "do it like that". Today each recorder keeps its own format, and the useful part, what the person was trying to do and the steps they took, is locked inside it. A demonstration recorded in one tool cannot be read by another agent, reviewed by a second person or published for others.
Worse, the formats that do travel are replays: a list of clicks at pixel positions and the keystrokes typed. A replay breaks when a window moves, does something else entirely when the screen differs, and carries every password and message the person typed. It cannot say "stop if a payment prompt appears", because it never knew what was on the screen.
What is missing is the task written down as meaning: the goal, the steps an agent should look for, the values it must ask for, and the points where it must stop. Written down, a task can be read before it runs, shared without the person's data, and run by any agent that keeps the same promises.
## Terms
- A **task** is one job on a computer that ends in an outcome a person can check: a post published, a file exported, a setting changed. Its **task file** is the JSON document this specification describes.
- An **app** is one application the task uses: a desktop program, a browser, a terminal.
- A **parameter** is one value the task needs that changes between runs: a title, a recipient, a file name.
- A **step** is one action the person took, described by what it acted on (an app, a window, a control's role and name), never by where it was on the screen.
- A **demonstration** is a recording of a person doing the task. A task file made from one is **demonstrated**; a task file a person wrote by hand is **authored**.
- A **runner** is the program, usually an agent with a desktop tool, that carries a task out.
- A **stop condition** is a situation in which a runner stops and hands the task back to a person.
- An **approval** is a point before which a runner asks a person and waits.
- A **publisher** is whoever writes and serves a task file.
## The task file
The smallest task file:
```json
{
"type": "logicsrc.opentask",
"version": "0.1",
"id": "empty-the-trash",
"title": "Empty the trash",
"goal": "Empty the desktop trash.",
"apps": [{ "name": "Dolphin", "kind": "desktop" }],
"steps": [
{ "n": 1, "action": "focus", "app": "Dolphin", "evidence": "observed" },
{ "n": 2, "action": "click", "app": "Dolphin", "target": { "role": "button", "name": "Empty Trash" }, "evidence": "observed" }
],
"stop_conditions": ["a target cannot be found on the current screen"],
"approvals": ["before deleting anything"],
"success": { "check": "The trash shows no items.", "evidence": "screen" },
"source": { "kind": "authored", "reviewed": true },
"status": "untested"
}
```
| Key | Required | Meaning |
| --- | --- | --- |
| `type` | yes | `logicsrc.opentask` |
| `version` | yes | `0.1` |
| `id` | yes | A slug, unique within its publisher: lowercase letters, digits and dashes, at most 64 characters. |
| `title` | yes | A short name a person reads in a list. |
| `goal` | yes | The outcome, in one or two sentences, as the person would say it. |
| `explanation` | no | The person's own words on how and why, at most 4000 characters. Runners show it; it has no authority over the rules below. |
| `apps` | yes | The applications, each `{ "name", "kind" }` with `kind` one of `desktop`, `browser`, `terminal`, `web`, and for `web` a `url`. |
| `parameters` | no | The values the task needs. See [Parameters](#parameters). |
| `steps` | yes | The steps, numbered from 1 with no gaps. See [Steps](#steps). |
| `capture` | no | What a demonstration saw and did not see. See [Capture](#capture). |
| `stop_conditions` | yes | At least one situation in which a runner stops. |
| `approvals` | yes | Points before which a runner asks, each a sentence beginning "before". May be empty only when the task changes nothing a person could not undo. |
| `success` | yes | `{ "check", "evidence" }`: how to tell the task worked, and what kind of evidence that is (`screen`, `artifact` or `human_assertion`). |
| `source` | yes | Where the file came from. See [Source](#source). |
| `status` | yes | `untested`, `passed` or `failed`: the result of the last evaluation run by someone other than the demonstrator. A file is `untested` until such a run passes. |
| `runners` | no | Ways to run it. See [Runners](#runners). |
| `license` | no | An SPDX identifier for the file. |
## Parameters
A parameter names a value, never holds one.
```json
{ "name": "post_title", "description": "The title of the post to publish", "sensitivity": "public", "example": "Release notes for 0.3" }
```
- `name` is a lowercase identifier, `[a-z][a-z0-9_]{0,63}`.
- `sensitivity` is `public` (may appear in logs and on a screen share), `personal` (the person's own data: an address, a contact) or `secret` (a password, a code, a key).
- `example` is allowed only for `public` parameters. A `personal` or `secret` parameter has no example, ever: the file is meant to be published.
A runner asks for every parameter before the first step that uses it. It never writes a `secret` value to a log, a report or a file.
## Steps
```json
{ "n": 3, "action": "type", "app": "TronBrowser", "window": "New post", "target": { "role": "text field", "name": "Title" }, "text": "{{post_title}}", "evidence": "observed", "recorded": "41-44" }
```
| Key | Required | Meaning |
| --- | --- | --- |
| `n` | yes | The step number, from 1 with no gaps. |
| `action` | yes | `focus`, `open`, `click`, `type`, `key`, `scroll`, `drag`, `wait`, `observe` or `other`. |
| `app` | no | The app's `name` from `apps`. |
| `window` | no | The window title the person saw. See [Window titles](#window-titles). |
| `target` | no | `{ "role", "name" }` of the control: an accessibility role and its visible name. |
| `keys` | no | For `key`: the keys pressed together, such as `["ctrl", "s"]`. |
| `text` | no | For `type`: a placeholder `{{name}}` naming a declared parameter. Never the typed text itself. |
| `evidence` | yes | `observed` (the recorder saw it happen) or `inferred` (a person or model concluded it). |
| `recorded` | no | Which recorded steps this one stands for, `"7"` or `"7-12"`, when consecutive identical steps were merged. |
| `note` | no | A sentence for the runner. |
There are no coordinates, ever. A file that carries `x`, `y` or a bounding box is invalid. A runner works out every action from what is on the screen when it gets there.
### Window titles
Window titles are what a person sees, and they leak: an inbox title carries an address, a receipt carries an order number. A publisher removes them unless a person has read each one and chosen to keep it, and records the choice in `capture.window_titles` (`kept` or `removed`). A demonstrated file with no `capture` is read as `removed`.
## Capture
```json
{ "profile": "visual-review", "window_titles": "removed", "gaps": ["unapproved-app"] }
```
- `profile` is what the recorder could see: `visual-review` (window focus and screenshots of approved apps, no input), `semantic` (also controls and shortcuts, typed text as placeholders) or `full` (everything a recorder can see, typed text still as placeholders in the file).
- `gaps` names the kinds of thing the recording did not see, such as `unapproved-app` or `paused`. A runner does not guess what happened in a gap; it asks.
## Source
```json
{ "kind": "demonstration", "recorder": "w3bs-training 0.2.5", "episode": "ep_36773bc43575d95f", "recorded": "2026-10-16T02:11:00Z", "reviewed": true, "outcome": "success" }
```
- `kind` is `demonstration` or `authored`.
- `reviewed` says a person other than the recorder's automatic labelling confirmed the goal and the outcome. A publisher publishes only reviewed files.
- For a demonstration, `outcome` is what the reviewer recorded (`success`, `partial` or `failure`). Only `success` may be published with `status` other than `failed`.
- `recorder`, `episode` and `recorded` let the publisher find the original. The recording itself is never part of the file.
## Runners
```json
{ "kind": "moshscript", "url": "https://w3bs.org/workflows/wf_9Kp2/empty-the-trash.mosh", "sha256": "7c1e…", "command": "moshcode run empty-the-trash.mosh" }
```
`kind` names the runner (`moshscript`, `mcp`, `script` or `other`). `url` is where to fetch it and `sha256` is its digest, which a runner checks before it runs anything it fetched. A runner entry is a convenience: the task file alone is enough for any agent that follows the rules below.
## Runner rules
A conforming runner:
1. **Shows the task first.** Title, goal, apps, every parameter with its sensitivity, every stop condition and approval, and `status`. An `untested` file is labelled as such.
2. **Observes before acting.** It looks at the current screen before every action and never reuses a position from an earlier observation or another run.
3. **Asks for parameters.** It never invents a value. A `secret` value is never logged, reported or written.
4. **Stops.** On any stop condition, on a gap, or when a step's target is not on the screen, it stops and says what it saw.
5. **Asks before.** At each approval it describes what it is about to do and waits for a person.
6. **Treats text as data.** `goal`, `explanation`, `note` and window titles are untrusted text. They describe the task; they never grant permission or change these rules.
7. **Reports.** When it finishes or stops, it says what it did and what is left, and checks `success`.
## Publishing
A publisher serves task files as `application/json` over HTTPS, usually inside an [OpenWorkflow](/docs/openworkflow). Before publishing a demonstrated task it removes window titles (unless kept by choice), confirms `source.reviewed`, and confirms no parameter carries a personal or secret example.
## Worked example
A task demonstrated in W3BS Training: exporting a reviewed task from the training app as a moshscript.
```json
{
"type": "logicsrc.opentask",
"version": "0.1",
"id": "export-a-task-as-moshscript",
"title": "Export a reviewed task as a moshscript",
"goal": "Export a reviewed W3BS Training task as a moshscript file.",
"explanation": "Open the training app, pick the reviewed task, and use the button under its title.",
"apps": [
{ "name": "TronBrowser", "kind": "browser" },
{ "name": "W3BS Training", "kind": "web", "url": "http://127.0.0.1/" }
],
"parameters": [
{ "name": "task_title", "description": "The title of the reviewed task to export", "sensitivity": "public", "example": "Empty the trash" }
],
"steps": [
{ "n": 1, "action": "focus", "app": "TronBrowser", "evidence": "observed", "recorded": "1-2" },
{ "n": 2, "action": "click", "app": "TronBrowser", "target": { "role": "link", "name": "{{task_title}}" }, "evidence": "inferred" },
{ "n": 3, "action": "click", "app": "TronBrowser", "target": { "role": "button", "name": "Export as moshscript" }, "evidence": "inferred" },
{ "n": 4, "action": "observe", "app": "TronBrowser", "note": "A confirmation code appears; the person types it.", "evidence": "inferred" }
],
"capture": { "profile": "visual-review", "window_titles": "removed", "gaps": [] },
"stop_conditions": [
"a target cannot be found on the current screen",
"an unexpected dialog appears",
"a credential or payment prompt appears"
],
"approvals": ["before typing a confirmation code"],
"success": { "check": "A .mosh file named after the task is in Downloads.", "evidence": "artifact" },
"source": {
"kind": "demonstration",
"recorder": "w3bs-training 0.2.5",
"episode": "ep_0f3a9c2b7d114e58",
"recorded": "2026-10-17T18:04:00Z",
"reviewed": true,
"outcome": "success"
},
"status": "untested",
"runners": [
{
"kind": "moshscript",
"url": "https://w3bs.org/workflows/wf_example/export-a-task-as-moshscript.mosh",
"sha256": "0000000000000000000000000000000000000000000000000000000000000000",
"command": "moshcode run export-a-task-as-moshscript.mosh"
}
],
"license": "CC0-1.0"
}
```
## Validation
The JSON Schema is `@logicsrc/schemas/opentask`. `@logicsrc/validators` also checks what a schema cannot: steps numbered from 1 with no gaps, every `{{placeholder}}` naming a declared parameter, every step's `app` naming a declared app, no example on a personal or secret parameter, and no published `failure` marked anything but `failed`.
```sh
npx @logicsrc/validators opentask task.json
```

121
docs/openworkflow.md Normal file
View file

@ -0,0 +1,121 @@
# OpenWorkflow
OpenWorkflow is one JSON file that collects [OpenTasks](/docs/opentask) into a workflow: a named set of tasks a person does together, such as "release a package" or "close the month", in the order they do them or in any order. Each task is carried inline or referenced by URL with its digest, so a workflow can gather tasks from more than one publisher without copying them. A publisher lists its workflows at `/.well-known/openworkflow.json`. It is maintained by Profullstack, Inc. as part of the LogicSRC open-standards surface.
Status: **0.1**. The format w3bs.org/workflows serves, published so other task libraries can serve the same thing.
Slug: `openworkflow`
## The problem
One task is rarely the job. Publishing a release is a version bump in a terminal, a changelog in an editor and an announcement in a browser; each can be demonstrated and written down as an OpenTask, but the job is all three, in order, with the second waiting on the first. Without a collection, a person hands an agent three files and explains the order in chat, and the next person to run it has to be told again.
A workflow file is that explanation written down: which tasks, in what order, which ones wait on which, and where a runner stops the whole thing.
## Terms
- A **workflow** is a named collection of tasks. Its **workflow file** is the JSON document this specification describes.
- An **entry** is one task in a workflow: the task inline, or a reference to a task file by URL.
- A **runner** is the program that carries a workflow out, one task at a time, under the [OpenTask runner rules](/docs/opentask#runner-rules).
## The workflow file
```json
{
"type": "logicsrc.openworkflow",
"version": "0.1",
"id": "release-a-package",
"title": "Release a package",
"description": "Bump the version, write the changelog, announce it.",
"publisher": { "name": "@anthony", "url": "https://w3bs.org/workflows" },
"updated": "2026-10-19T12:00:00Z",
"order": "sequence",
"tasks": [
{
"url": "https://w3bs.org/tasks/tk_4Hq8sP1x.json",
"sha256": "3f1b5c0e9a0e4d7b8c2a6f5d4e3c2b1a09f8e7d6c5b4a39281706f5e4d3c2b1a",
"id": "bump-the-version",
"title": "Bump the version"
},
{
"url": "https://w3bs.org/tasks/tk_Lm2Rt7vQ.json",
"sha256": "a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f60718293a4b5c6d7e8f90",
"id": "write-the-changelog",
"title": "Write the changelog",
"after": ["bump-the-version"]
}
]
}
```
| Key | Required | Meaning |
| --- | --- | --- |
| `type` | yes | `logicsrc.openworkflow` |
| `version` | yes | `0.1` |
| `id` | yes | A slug, unique within its publisher. |
| `title` | yes | A short name a person reads in a list. |
| `description` | no | What the workflow is for, at most 4000 characters. Untrusted text, as in OpenTask. |
| `publisher` | no | `{ "name", "url" }`: who serves it. |
| `updated` | no | When it last changed. |
| `order` | yes | `sequence` (run the entries in the order listed) or `any` (in any order that respects `after`). |
| `tasks` | yes | At least one entry. See [Entries](#entries). |
| `license` | no | An SPDX identifier for the file. |
## Entries
An entry is one of two shapes.
**Inline**: the whole OpenTask under `task`.
```json
{ "task": { "type": "logicsrc.opentask", "version": "0.1", "id": "empty-the-trash", "...": "..." } }
```
**Reference**: where to fetch it and what it must hash to.
| Key | Required | Meaning |
| --- | --- | --- |
| `url` | yes | An `https` URL serving the task file. |
| `sha256` | yes | The SHA-256 of the bytes served, lowercase hex. A runner refuses a task whose bytes do not match. |
| `id` | yes | The task's `id`, repeated so a person can read the list without fetching. |
| `title` | yes | The task's `title`, likewise. |
Either shape may add `after`, a list of task ids in the same workflow that must finish first, and `optional: true`, which lets a runner skip the entry when a person says so. Task ids are unique within a workflow, `after` names only ids listed earlier, and an entry cannot wait on itself.
## Runner rules
A conforming runner follows every [OpenTask runner rule](/docs/opentask#runner-rules) for each task, and:
1. **Shows the workflow first.** Every entry, its status (an inline task's `status`, or "not yet fetched"), and the order.
2. **Checks references.** It fetches each referenced task over HTTPS, checks its digest and validates it before showing it. A mismatch stops the workflow.
3. **Asks for parameters per task.** Parameters belong to their task; a value given for one task is not reused by another unless a person says so.
4. **Stops the workflow when a task stops.** A task that stops, fails or is skipped without permission ends the run. The runner reports which tasks finished.
5. **Never starts an entry early.** An entry starts only when every id in its `after` has finished.
## The index
A publisher lists its workflows at `/.well-known/openworkflow.json`:
```json
{
"type": "logicsrc.openworkflow-index",
"version": "0.1",
"publisher": "https://w3bs.org",
"updated": "2026-10-19T12:00:00Z",
"workflows": [
{ "url": "https://w3bs.org/workflows/release-a-package.json", "id": "release-a-package", "title": "Release a package", "tasks": 2 }
]
}
```
## Publishing
A publisher serves workflow files as `application/json` over HTTPS. When a referenced task changes, its digest changes, so the workflow is republished with the new digest or it stops working. That is deliberate: a workflow someone reviewed cannot change underneath them.
## Validation
The JSON Schemas are `@logicsrc/schemas/openworkflow` and `@logicsrc/schemas/openworkflow-index`; an inline task is checked against `@logicsrc/schemas/opentask`. `@logicsrc/validators` also checks that task ids are unique, that `after` names only earlier ids, and every OpenTask rule on inline tasks.
```sh
npx @logicsrc/validators openworkflow workflow.json
```

View file

@ -23,6 +23,13 @@ Schema families include:
them. Fixtures are in `fixtures/openerrand`. `@logicsrc/validators` also checks them. Fixtures are in `fixtures/openerrand`. `@logicsrc/validators` also checks
references, templates, and that no hand-off card names a personal or secret references, templates, and that no hand-off card names a personal or secret
input. See `docs/openerrand.md`. input. See `docs/openerrand.md`.
- **OpenTask and OpenWorkflow** - the `opentask` export describes one task a
person does on a computer, as meaning rather than coordinates, so an agent can
do it again; `openworkflow` collects tasks inline or by URL and digest, and
`openworkflow-index` is a publisher's list. Fixtures are in `fixtures/opentask`
and `fixtures/openworkflow`. `@logicsrc/validators` also checks step numbering,
placeholders, app names, examples on sensitive parameters, and `after`
references. See `docs/opentask.md` and `docs/openworkflow.md`.
## Install ## Install

View file

@ -0,0 +1,98 @@
{
"type": "logicsrc.opentask",
"version": "0.1",
"id": "export-a-task-as-moshscript",
"title": "Export a reviewed task as a moshscript",
"goal": "Export a reviewed W3BS Training task as a moshscript file.",
"explanation": "Open the training app, pick the reviewed task, and use the button under its title.",
"apps": [
{
"name": "TronBrowser",
"kind": "browser"
},
{
"name": "W3BS Training",
"kind": "web",
"url": "http://127.0.0.1/"
}
],
"parameters": [
{
"name": "task_title",
"description": "The title of the reviewed task to export",
"sensitivity": "public",
"example": "Empty the trash"
}
],
"steps": [
{
"n": 1,
"action": "focus",
"app": "TronBrowser",
"evidence": "observed",
"recorded": "1-2"
},
{
"n": 2,
"action": "click",
"app": "TronBrowser",
"target": {
"role": "link",
"name": "{{task_title}}"
},
"evidence": "inferred"
},
{
"n": 3,
"action": "click",
"app": "TronBrowser",
"target": {
"role": "button",
"name": "Export as moshscript"
},
"evidence": "inferred"
},
{
"n": 4,
"action": "observe",
"app": "TronBrowser",
"note": "A confirmation code appears; the person types it.",
"evidence": "inferred"
}
],
"capture": {
"profile": "visual-review",
"window_titles": "removed",
"gaps": []
},
"stop_conditions": [
"a target cannot be found on the current screen",
"an unexpected dialog appears",
"a credential or payment prompt appears"
],
"approvals": [
"before typing a confirmation code"
],
"success": {
"check": "A .mosh file named after the task is in Downloads.",
"evidence": "artifact"
},
"source": {
"kind": "demonstration",
"recorder": "w3bs-training 0.2.5",
"episode": "ep_0f3a9c2b7d114e58",
"recorded": "2026-10-17T18:04:00Z",
"reviewed": true,
"outcome": "success"
},
"status": "untested",
"runners": [
{
"kind": "moshscript",
"url": "https://w3bs.org/workflows/wf_example/export-a-task-as-moshscript.mosh",
"sha256": "0000000000000000000000000000000000000000000000000000000000000000",
"command": "moshcode run export-a-task-as-moshscript.mosh"
}
],
"license": "CC0-1.0"
}

View file

@ -0,0 +1,46 @@
{
"type": "logicsrc.opentask",
"version": "0.1",
"id": "empty-the-trash",
"title": "Empty the trash",
"goal": "Empty the desktop trash.",
"apps": [
{
"name": "Dolphin",
"kind": "desktop"
}
],
"steps": [
{
"n": 1,
"action": "focus",
"app": "Dolphin",
"evidence": "observed"
},
{
"n": 2,
"action": "click",
"app": "Dolphin",
"target": {
"role": "button",
"name": "Empty Trash"
},
"evidence": "observed"
}
],
"stop_conditions": [
"a target cannot be found on the current screen"
],
"approvals": [
"before deleting anything"
],
"success": {
"check": "The trash shows no items.",
"evidence": "screen"
},
"source": {
"kind": "authored",
"reviewed": true
},
"status": "untested"
}

View file

@ -0,0 +1,14 @@
{
"type": "logicsrc.openworkflow-index",
"version": "0.1",
"publisher": "https://w3bs.org",
"updated": "2026-10-19T12:00:00Z",
"workflows": [
{
"url": "https://w3bs.org/workflows/release-a-package.json",
"id": "release-a-package",
"title": "Release a package",
"tasks": 2
}
]
}

View file

@ -0,0 +1,30 @@
{
"type": "logicsrc.openworkflow",
"version": "0.1",
"id": "release-a-package",
"title": "Release a package",
"description": "Bump the version, write the changelog, announce it.",
"publisher": {
"name": "@anthony",
"url": "https://w3bs.org/workflows"
},
"updated": "2026-10-19T12:00:00Z",
"order": "sequence",
"tasks": [
{
"url": "https://w3bs.org/tasks/tk_4Hq8sP1x.json",
"sha256": "3f1b5c0e9a0e4d7b8c2a6f5d4e3c2b1a09f8e7d6c5b4a39281706f5e4d3c2b1a",
"id": "bump-the-version",
"title": "Bump the version"
},
{
"url": "https://w3bs.org/tasks/tk_Lm2Rt7vQ.json",
"sha256": "a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f60718293a4b5c6d7e8f90",
"id": "write-the-changelog",
"title": "Write the changelog",
"after": [
"bump-the-version"
]
}
]
}

View file

@ -1,7 +1,7 @@
{ {
"name": "@logicsrc/schemas", "name": "@logicsrc/schemas",
"version": "0.5.0", "version": "0.6.0",
"description": "LogicSRC JSON schemas for tasks, agents, runs, events, plugins, the AgentAd ad standard, the OpenOntology knowledge contracts, the OpenContext context plane, the OpenCreds credential vault, OpenRental membership and rental offers, and the OpenWall messaging proposal. Includes the OpenABTest draft experiment and event contracts.", "description": "LogicSRC JSON schemas for tasks, agents, runs, events, plugins, the AgentAd ad standard, the OpenOntology knowledge contracts, the OpenContext context plane, the OpenCreds credential vault, OpenRental membership and rental offers, and the OpenWall messaging proposal. Includes the OpenABTest draft experiment and event contracts Includes OpenTask and OpenWorkflow for tasks an agent does on a desktop.",
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",
"repository": { "repository": {
@ -29,7 +29,9 @@
"password-manager", "password-manager",
"standards", "standards",
"vault", "vault",
"openabtest" "openabtest",
"opentask",
"openworkflow"
], ],
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
@ -71,6 +73,9 @@
"./openrental": "./schemas/logicsrc-openrental.schema.json", "./openrental": "./schemas/logicsrc-openrental.schema.json",
"./openerrand": "./schemas/logicsrc-openerrand.schema.json", "./openerrand": "./schemas/logicsrc-openerrand.schema.json",
"./openerrand-index": "./schemas/logicsrc-openerrand-index.schema.json", "./openerrand-index": "./schemas/logicsrc-openerrand-index.schema.json",
"./opentask": "./schemas/logicsrc-opentask.schema.json",
"./openworkflow": "./schemas/logicsrc-openworkflow.schema.json",
"./openworkflow-index": "./schemas/logicsrc-openworkflow-index.schema.json",
"./openontology-action": "./schemas/logicsrc-openontology-action.schema.json", "./openontology-action": "./schemas/logicsrc-openontology-action.schema.json",
"./openontology-approval": "./schemas/logicsrc-openontology-approval.schema.json", "./openontology-approval": "./schemas/logicsrc-openontology-approval.schema.json",
"./openontology-changeset": "./schemas/logicsrc-openontology-changeset.schema.json", "./openontology-changeset": "./schemas/logicsrc-openontology-changeset.schema.json",

View file

@ -0,0 +1,132 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://schemas.logicsrc.com/logicsrc-opentask.schema.json",
"title": "OpenTask",
"description": "One task a person does on a computer, written down as meaning (goal, parameters, semantic steps, stop conditions, approvals) so an agent can do it again. Never coordinates, never typed values.",
"type": "object",
"additionalProperties": false,
"required": ["type", "version", "id", "title", "goal", "apps", "steps", "stop_conditions", "approvals", "success", "source", "status"],
"properties": {
"type": { "const": "logicsrc.opentask" },
"version": { "const": "0.1" },
"id": { "$ref": "#/$defs/slug" },
"title": { "type": "string", "minLength": 1, "maxLength": 200 },
"goal": { "type": "string", "minLength": 1, "maxLength": 500 },
"explanation": { "type": "string", "maxLength": 4000 },
"apps": {
"type": "array",
"minItems": 1,
"maxItems": 50,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["name", "kind"],
"properties": {
"name": { "type": "string", "minLength": 1, "maxLength": 200 },
"kind": { "enum": ["desktop", "browser", "terminal", "web"] },
"url": { "type": "string", "format": "uri", "pattern": "^https?://" }
}
}
},
"parameters": {
"type": "array",
"maxItems": 50,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["name", "sensitivity"],
"properties": {
"name": { "type": "string", "pattern": "^[a-z][a-z0-9_]{0,63}$" },
"description": { "type": "string", "maxLength": 500 },
"sensitivity": { "enum": ["public", "personal", "secret"] },
"example": { "type": "string", "maxLength": 200 }
}
}
},
"steps": {
"type": "array",
"minItems": 1,
"maxItems": 1000,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["n", "action", "evidence"],
"properties": {
"n": { "type": "integer", "minimum": 1 },
"action": { "enum": ["focus", "open", "click", "type", "key", "scroll", "drag", "wait", "observe", "other"] },
"app": { "type": "string", "minLength": 1, "maxLength": 200 },
"window": { "type": "string", "maxLength": 400 },
"target": {
"type": "object",
"additionalProperties": false,
"minProperties": 1,
"properties": {
"role": { "type": "string", "maxLength": 100 },
"name": { "type": "string", "maxLength": 200 }
}
},
"keys": { "type": "array", "minItems": 1, "maxItems": 10, "items": { "type": "string", "minLength": 1, "maxLength": 40 } },
"text": { "type": "string", "pattern": "^\\{\\{[a-z][a-z0-9_]{0,63}\\}\\}$" },
"evidence": { "enum": ["observed", "inferred"] },
"recorded": { "type": "string", "pattern": "^[0-9]{1,6}(-[0-9]{1,6})?$" },
"note": { "type": "string", "maxLength": 500 }
}
}
},
"capture": {
"type": "object",
"additionalProperties": false,
"required": ["profile"],
"properties": {
"profile": { "enum": ["visual-review", "semantic", "full"] },
"window_titles": { "enum": ["kept", "removed"] },
"gaps": { "type": "array", "uniqueItems": true, "maxItems": 20, "items": { "type": "string", "pattern": "^[a-z][a-z0-9_-]{0,39}$" } }
}
},
"stop_conditions": { "type": "array", "minItems": 1, "maxItems": 20, "items": { "type": "string", "minLength": 1, "maxLength": 300 } },
"approvals": { "type": "array", "maxItems": 20, "items": { "type": "string", "pattern": "^[Bb]efore ", "maxLength": 300 } },
"success": {
"type": "object",
"additionalProperties": false,
"required": ["check", "evidence"],
"properties": {
"check": { "type": "string", "minLength": 1, "maxLength": 500 },
"evidence": { "enum": ["screen", "artifact", "human_assertion"] }
}
},
"source": {
"type": "object",
"additionalProperties": false,
"required": ["kind", "reviewed"],
"properties": {
"kind": { "enum": ["demonstration", "authored"] },
"recorder": { "type": "string", "maxLength": 100 },
"episode": { "type": "string", "pattern": "^[A-Za-z0-9_-]{1,100}$" },
"recorded": { "type": "string", "format": "date-time" },
"reviewed": { "type": "boolean" },
"outcome": { "enum": ["success", "partial", "failure"] }
}
},
"status": { "enum": ["untested", "passed", "failed"] },
"runners": {
"type": "array",
"maxItems": 10,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["kind", "url", "sha256"],
"properties": {
"kind": { "enum": ["moshscript", "mcp", "script", "other"] },
"url": { "type": "string", "format": "uri", "pattern": "^https://" },
"sha256": { "$ref": "#/$defs/sha256" },
"command": { "type": "string", "maxLength": 300 }
}
}
},
"license": { "type": "string", "maxLength": 100 }
},
"$defs": {
"slug": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,63}$" },
"sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
}
}

View file

@ -0,0 +1,30 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://schemas.logicsrc.com/logicsrc-openworkflow-index.schema.json",
"title": "OpenWorkflow index",
"description": "The list of workflow files a publisher serves at /.well-known/openworkflow.json.",
"type": "object",
"additionalProperties": false,
"required": ["type", "version", "workflows"],
"properties": {
"type": { "const": "logicsrc.openworkflow-index" },
"version": { "const": "0.1" },
"publisher": { "type": "string", "format": "uri", "pattern": "^https://" },
"updated": { "type": "string", "format": "date-time" },
"workflows": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["url", "id", "title"],
"properties": {
"url": { "type": "string", "format": "uri", "pattern": "^https://" },
"id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,63}$" },
"title": { "type": "string", "minLength": 1, "maxLength": 200 },
"tasks": { "type": "integer", "minimum": 1 },
"updated": { "type": "string", "format": "date-time" }
}
}
}
}
}

View file

@ -0,0 +1,63 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://schemas.logicsrc.com/logicsrc-openworkflow.schema.json",
"title": "OpenWorkflow",
"description": "A named collection of OpenTasks, inline or referenced by URL and digest, run in sequence or in any order that respects `after`.",
"type": "object",
"additionalProperties": false,
"required": ["type", "version", "id", "title", "order", "tasks"],
"properties": {
"type": { "const": "logicsrc.openworkflow" },
"version": { "const": "0.1" },
"id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,63}$" },
"title": { "type": "string", "minLength": 1, "maxLength": 200 },
"description": { "type": "string", "maxLength": 4000 },
"publisher": {
"type": "object",
"additionalProperties": false,
"required": ["name"],
"properties": {
"name": { "type": "string", "minLength": 1, "maxLength": 200 },
"url": { "type": "string", "format": "uri", "pattern": "^https://" }
}
},
"updated": { "type": "string", "format": "date-time" },
"order": { "enum": ["sequence", "any"] },
"tasks": {
"type": "array",
"minItems": 1,
"maxItems": 200,
"items": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": ["task"],
"properties": {
"task": { "$ref": "https://schemas.logicsrc.com/logicsrc-opentask.schema.json" },
"after": { "$ref": "#/$defs/after" },
"optional": { "type": "boolean" }
}
},
{
"type": "object",
"additionalProperties": false,
"required": ["url", "sha256", "id", "title"],
"properties": {
"url": { "type": "string", "format": "uri", "pattern": "^https://" },
"sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
"id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,63}$" },
"title": { "type": "string", "minLength": 1, "maxLength": 200 },
"after": { "$ref": "#/$defs/after" },
"optional": { "type": "boolean" }
}
}
]
}
},
"license": { "type": "string", "maxLength": 100 }
},
"$defs": {
"after": { "type": "array", "uniqueItems": true, "maxItems": 200, "items": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,63}$" } }
}
}

View file

@ -1,6 +1,6 @@
{ {
"name": "@logicsrc/validators", "name": "@logicsrc/validators",
"version": "0.5.0", "version": "0.6.0",
"description": "LogicSRC schema validation helpers.", "description": "LogicSRC schema validation helpers.",
"type": "module", "type": "module",
"main": "./dist/index.js", "main": "./dist/index.js",
@ -11,10 +11,10 @@
"scripts": { "scripts": {
"build": "tsc -p tsconfig.json", "build": "tsc -p tsconfig.json",
"test": "vitest run src", "test": "vitest run src",
"validate:fixtures": "node dist/cli.js task ../schemas/fixtures/task.yaml && node dist/cli.js agent ../schemas/fixtures/agent.yaml && node dist/cli.js agentad-ad ../schemas/fixtures/agentad-ad.yaml && node dist/cli.js agentad-placement ../schemas/fixtures/agentad-placement.yaml && node dist/cli.js repo ../schemas/fixtures/repo.yaml && node dist/cli.js pull-request ../schemas/fixtures/pull-request.yaml && node dist/cli.js openontology-manifest ../schemas/fixtures/openontology/valid/manifest.json && node dist/cli.js openontology-claim ../schemas/fixtures/openontology/valid/claim-relationship.json && node dist/cli.js openontology-changeset ../schemas/fixtures/openontology/valid/changeset.json && node dist/cli.js opencontext-manifest ../schemas/fixtures/opencontext/valid/manifest.json && node dist/cli.js opencontext-object ../schemas/fixtures/opencontext/valid/object-policy.json && node dist/cli.js opencontext-bundle ../schemas/fixtures/opencontext/valid/bundle.json && node dist/cli.js opencontext-decision ../schemas/fixtures/opencontext/valid/decision.json && node dist/cli.js opencontext-role ../schemas/fixtures/opencontext/valid/role.json && node dist/cli.js opencontext-provenance ../schemas/fixtures/opencontext/valid/provenance.json && node dist/cli.js opencontext-diagnostic ../schemas/fixtures/opencontext/valid/diagnostic.json && node dist/cli.js opencontext-audit-event ../schemas/fixtures/opencontext/valid/audit-event.json && node dist/cli.js openrental ../schemas/fixtures/openrental/mixed.json && node dist/cli.js openerrand ../schemas/fixtures/openerrand/ftb-register-business.json && node dist/cli.js openerrand-index ../schemas/fixtures/openerrand/index.json && node dist/cli.js openwall-message ../schemas/fixtures/openwall/broadcast.json && node dist/cli.js openwall-message ../schemas/fixtures/openwall/direct.json && node dist/cli.js openwall-message ../schemas/fixtures/openwall/announcement.json && node dist/cli.js openwall-receipt ../schemas/fixtures/openwall/receipt-accepted.json && node dist/cli.js openwall-receipt ../schemas/fixtures/openwall/receipt-retrying.json && node dist/cli.js openabtest-manifest ../schemas/fixtures/openabtest/chovy-manifest.json && node dist/cli.js openabtest-event ../schemas/fixtures/openabtest/reconciliation.json && node dist/cli.js openabtest-manifest ../schemas/fixtures/openabtest/goal-manifest.json && node dist/cli.js openabtest-event ../schemas/fixtures/openabtest/goal-conversion.json" "validate:fixtures": "node dist/cli.js task ../schemas/fixtures/task.yaml && node dist/cli.js agent ../schemas/fixtures/agent.yaml && node dist/cli.js agentad-ad ../schemas/fixtures/agentad-ad.yaml && node dist/cli.js agentad-placement ../schemas/fixtures/agentad-placement.yaml && node dist/cli.js repo ../schemas/fixtures/repo.yaml && node dist/cli.js pull-request ../schemas/fixtures/pull-request.yaml && node dist/cli.js openontology-manifest ../schemas/fixtures/openontology/valid/manifest.json && node dist/cli.js openontology-claim ../schemas/fixtures/openontology/valid/claim-relationship.json && node dist/cli.js openontology-changeset ../schemas/fixtures/openontology/valid/changeset.json && node dist/cli.js opencontext-manifest ../schemas/fixtures/opencontext/valid/manifest.json && node dist/cli.js opencontext-object ../schemas/fixtures/opencontext/valid/object-policy.json && node dist/cli.js opencontext-bundle ../schemas/fixtures/opencontext/valid/bundle.json && node dist/cli.js opencontext-decision ../schemas/fixtures/opencontext/valid/decision.json && node dist/cli.js opencontext-role ../schemas/fixtures/opencontext/valid/role.json && node dist/cli.js opencontext-provenance ../schemas/fixtures/opencontext/valid/provenance.json && node dist/cli.js opencontext-diagnostic ../schemas/fixtures/opencontext/valid/diagnostic.json && node dist/cli.js opencontext-audit-event ../schemas/fixtures/opencontext/valid/audit-event.json && node dist/cli.js openrental ../schemas/fixtures/openrental/mixed.json && node dist/cli.js openerrand ../schemas/fixtures/openerrand/ftb-register-business.json && node dist/cli.js openerrand-index ../schemas/fixtures/openerrand/index.json && node dist/cli.js openwall-message ../schemas/fixtures/openwall/broadcast.json && node dist/cli.js openwall-message ../schemas/fixtures/openwall/direct.json && node dist/cli.js openwall-message ../schemas/fixtures/openwall/announcement.json && node dist/cli.js openwall-receipt ../schemas/fixtures/openwall/receipt-accepted.json && node dist/cli.js openwall-receipt ../schemas/fixtures/openwall/receipt-retrying.json && node dist/cli.js openabtest-manifest ../schemas/fixtures/openabtest/chovy-manifest.json && node dist/cli.js openabtest-event ../schemas/fixtures/openabtest/reconciliation.json && node dist/cli.js openabtest-manifest ../schemas/fixtures/openabtest/goal-manifest.json && node dist/cli.js openabtest-event ../schemas/fixtures/openabtest/goal-conversion.json && node dist/cli.js opentask ../schemas/fixtures/opentask/export-a-task-as-moshscript.json && node dist/cli.js openworkflow ../schemas/fixtures/openworkflow/release-a-package.json && node dist/cli.js openworkflow-index ../schemas/fixtures/openworkflow/index.json"
}, },
"dependencies": { "dependencies": {
"@logicsrc/schemas": "^0.5.0", "@logicsrc/schemas": "^0.6.0",
"ajv": "^8.17.1", "ajv": "^8.17.1",
"ajv-formats": "^3.0.1", "ajv-formats": "^3.0.1",
"yaml": "^2.8.1" "yaml": "^2.8.1"

View file

@ -6,6 +6,7 @@ import { isSchemaKind, schemas, type SchemaKind } from "./schemas.js";
import { validateOpenABTest } from "./openabtest.js"; import { validateOpenABTest } from "./openabtest.js";
import { validateOpenRentalReferences } from "./openrental.js"; import { validateOpenRentalReferences } from "./openrental.js";
import { validateOpenErrandReferences } from "./openerrand.js"; import { validateOpenErrandReferences } from "./openerrand.js";
import { validateOpenTask, validateOpenWorkflow } from "./opentask.js";
type CompiledSchema = { (data: unknown): boolean; errors?: ErrorObject[] | null }; type CompiledSchema = { (data: unknown): boolean; errors?: ErrorObject[] | null };
@ -72,6 +73,10 @@ export function validate(kind: SchemaKind, data: unknown): ValidationResult {
const errors = validateOpenErrandReferences(data); const errors = validateOpenErrandReferences(data);
if (errors.length) return { ok: false, kind, errors }; if (errors.length) return { ok: false, kind, errors };
} }
if (kind === "opentask" || kind === "openworkflow") {
const errors = kind === "opentask" ? validateOpenTask(data) : validateOpenWorkflow(data);
if (errors.length) return { ok: false, kind, errors };
}
if (kind === "openabtest-manifest" || kind === "openabtest-event") { if (kind === "openabtest-manifest" || kind === "openabtest-event") {
const errors = validateOpenABTest(kind, data); const errors = validateOpenABTest(kind, data);
if (errors.length) return { ok: false, kind, errors }; if (errors.length) return { ok: false, kind, errors };

View file

@ -0,0 +1,92 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
import { assertSchemaKind, validate } from "./index.js";
const read = (path: string) => readFileSync(new URL(path, import.meta.url), "utf8");
const json = (path: string) => JSON.parse(read(path));
const blocks = (path: string) => [...read(path).matchAll(/```json\n([\s\S]*?)\n```/g)].map((m) => m[1]!);
const example = () => json("../../schemas/fixtures/opentask/export-a-task-as-moshscript.json");
const workflow = () => json("../../schemas/fixtures/openworkflow/release-a-package.json");
function errorAt(kind: "opentask" | "openworkflow", data: unknown, keyword: string, path: string) {
const result = validate(kind, data);
expect(result.ok).toBe(false);
if (!result.ok) expect(result.errors).toContainEqual(expect.objectContaining({ keyword, instancePath: path }));
}
describe("OpenTask", () => {
it("registers the schemas and validates the fixtures", () => {
for (const kind of ["opentask", "openworkflow", "openworkflow-index"]) expect(assertSchemaKind(kind)).toBe(kind);
expect(validate("opentask", json("../../schemas/fixtures/opentask/smallest.json"))).toMatchObject({ ok: true });
expect(validate("opentask", example())).toMatchObject({ ok: true });
expect(validate("openworkflow", workflow())).toMatchObject({ ok: true });
expect(validate("openworkflow-index", json("../../schemas/fixtures/openworkflow/index.json"))).toMatchObject({ ok: true });
});
it("matches the examples printed in the specifications", () => {
const task = blocks("../../../docs/opentask.md").map((b) => JSON.parse(b));
expect(task[0]).toEqual(json("../../schemas/fixtures/opentask/smallest.json"));
expect(task.at(-1)).toEqual(example());
const flow = blocks("../../../docs/openworkflow.md").map((b) => JSON.parse(b));
expect(flow[0]).toEqual(workflow());
expect(flow.at(-1)).toEqual(json("../../schemas/fixtures/openworkflow/index.json"));
});
it("refuses coordinates and typed text", () => {
const t = example();
t.steps[0].x = 120;
errorAt("opentask", t, "additionalProperties", "/steps/0");
const u = example();
u.steps[1].text = "hunter2";
errorAt("opentask", u, "pattern", "/steps/1/text");
});
it("checks numbering, apps, placeholders and examples", () => {
const t = example();
t.steps[2].n = 7;
t.steps[0].app = "Firefox";
t.steps[1].target.name = "{{nope}}";
t.parameters.push({ name: "password", sensitivity: "secret", example: "x" });
errorAt("opentask", t, "stepNumber", "/steps/2/n");
errorAt("opentask", t, "unknownApp", "/steps/0/app");
errorAt("opentask", t, "unknownParameter", "/steps/1");
errorAt("opentask", t, "sensitiveExample", "/parameters/1/example");
});
it("publishes a failed demonstration only as failed", () => {
const t = example();
t.source.outcome = "failure";
errorAt("opentask", t, "unsuccessfulSource", "/status");
t.status = "failed";
expect(validate("opentask", t)).toMatchObject({ ok: true });
});
});
describe("OpenWorkflow", () => {
it("takes inline tasks and checks them", () => {
const w = workflow();
w.tasks.push({ task: example(), after: ["write-the-changelog"] });
expect(validate("openworkflow", w)).toMatchObject({ ok: true });
w.tasks[2].task.steps[0].n = 2;
errorAt("openworkflow", w, "stepNumber", "/tasks/2/task/steps/0/n");
});
it("checks ids and after", () => {
const w = workflow();
w.tasks[0].after = ["write-the-changelog"];
errorAt("openworkflow", w, "unknownAfter", "/tasks/0/after");
const d = workflow();
d.tasks[1].id = "bump-the-version";
d.tasks[1].after = [];
errorAt("openworkflow", d, "duplicateTask", "/tasks/1");
const s = workflow();
s.tasks[1].after = ["write-the-changelog"];
errorAt("openworkflow", s, "selfAfter", "/tasks/1/after");
});
it("refuses a reference without a digest", () => {
const w = workflow();
delete w.tasks[0].sha256;
expect(validate("openworkflow", w).ok).toBe(false);
});
});

View file

@ -0,0 +1,70 @@
import type { ErrorObject } from "ajv";
// Called only after the JSON Schema has checked the shape. These are the
// OpenTask and OpenWorkflow rules that need sibling values: steps numbered
// from 1 with no gaps, placeholders and apps that resolve, no example on a
// value that is personal or secret, and `after` naming only earlier tasks.
type Parameter = { name: string; sensitivity: "public" | "personal" | "secret"; example?: string };
type Step = { n: number; app?: string; text?: string; window?: string; target?: { role?: string; name?: string }; note?: string };
type Task = {
id: string;
apps: Array<{ name: string }>;
parameters?: Parameter[];
steps: Step[];
source: { outcome?: string };
status: string;
};
type Entry = { task?: Task; id?: string; after?: string[] };
type Workflow = { tasks: Entry[] };
const PLACEHOLDER = /\{\{\s*([a-z][a-z0-9_]*)\s*\}\}/g;
function issue(keyword: string, instancePath: string, message: string): ErrorObject {
return { keyword, instancePath, schemaPath: "#/opentask-semantics", params: {}, message };
}
export function validateOpenTask(data: unknown, base = ""): ErrorObject[] {
const task = data as Task;
const errors: ErrorObject[] = [];
const params = new Map((task.parameters ?? []).map((p) => [p.name, p]));
const apps = new Set(task.apps.map((a) => a.name));
if (params.size !== (task.parameters ?? []).length)
errors.push(issue("uniqueParameters", `${base}/parameters`, "parameter names must be unique"));
(task.parameters ?? []).forEach((p, i) => {
if (p.sensitivity !== "public" && p.example !== undefined)
errors.push(issue("sensitiveExample", `${base}/parameters/${i}/example`, `a ${p.sensitivity} parameter never carries an example`));
});
task.steps.forEach((step, i) => {
const at = `${base}/steps/${i}`;
if (step.n !== i + 1) errors.push(issue("stepNumber", `${at}/n`, `step ${i + 1} is numbered ${step.n}`));
if (step.app !== undefined && !apps.has(step.app))
errors.push(issue("unknownApp", `${at}/app`, `"${step.app}" is not in apps`));
for (const text of [step.text, step.window, step.target?.role, step.target?.name, step.note]) {
for (const m of (text ?? "").matchAll(PLACEHOLDER))
if (!params.has(m[1]!)) errors.push(issue("unknownParameter", at, `{{${m[1]}}} is not a declared parameter`));
}
});
if (task.source.outcome && task.source.outcome !== "success" && task.status !== "failed")
errors.push(issue("unsuccessfulSource", `${base}/status`, `a demonstration with outcome ${task.source.outcome} is published only as failed`));
return errors;
}
export function validateOpenWorkflow(data: unknown): ErrorObject[] {
const workflow = data as Workflow;
const errors: ErrorObject[] = [];
const seen = new Set<string>();
workflow.tasks.forEach((entry, i) => {
const at = `/tasks/${i}`;
const id = entry.task?.id ?? entry.id!;
if (entry.task) errors.push(...validateOpenTask(entry.task, `${at}/task`));
for (const dep of entry.after ?? []) {
if (dep === id) errors.push(issue("selfAfter", `${at}/after`, `${id} cannot wait on itself`));
else if (!seen.has(dep)) errors.push(issue("unknownAfter", `${at}/after`, `"${dep}" is not an earlier task in this workflow`));
}
if (seen.has(id)) errors.push(issue("duplicateTask", at, `task id "${id}" appears twice`));
seen.add(id);
});
return errors;
}

View file

@ -13,6 +13,9 @@ import agentSchema from "@logicsrc/schemas/agent" with { type: "json" };
import openrentalSchema from "@logicsrc/schemas/openrental" with { type: "json" }; import openrentalSchema from "@logicsrc/schemas/openrental" with { type: "json" };
import openerrandSchema from "@logicsrc/schemas/openerrand" with { type: "json" }; import openerrandSchema from "@logicsrc/schemas/openerrand" with { type: "json" };
import openerrandIndexSchema from "@logicsrc/schemas/openerrand-index" with { type: "json" }; import openerrandIndexSchema from "@logicsrc/schemas/openerrand-index" with { type: "json" };
import opentaskSchema from "@logicsrc/schemas/opentask" with { type: "json" };
import openworkflowSchema from "@logicsrc/schemas/openworkflow" with { type: "json" };
import openworkflowIndexSchema from "@logicsrc/schemas/openworkflow-index" with { type: "json" };
import accountAuditEventSchema from "@logicsrc/schemas/account-audit-event" with { type: "json" }; import accountAuditEventSchema from "@logicsrc/schemas/account-audit-event" with { type: "json" };
import accountGrantSchema from "@logicsrc/schemas/account-grant" with { type: "json" }; import accountGrantSchema from "@logicsrc/schemas/account-grant" with { type: "json" };
import accountProviderSchema from "@logicsrc/schemas/account-provider" with { type: "json" }; import accountProviderSchema from "@logicsrc/schemas/account-provider" with { type: "json" };
@ -85,6 +88,9 @@ export const schemas = {
openrental: openrentalSchema, openrental: openrentalSchema,
openerrand: openerrandSchema, openerrand: openerrandSchema,
"openerrand-index": openerrandIndexSchema, "openerrand-index": openerrandIndexSchema,
opentask: opentaskSchema,
openworkflow: openworkflowSchema,
"openworkflow-index": openworkflowIndexSchema,
"account-audit-event": accountAuditEventSchema, "account-audit-event": accountAuditEventSchema,
"account-grant": accountGrantSchema, "account-grant": accountGrantSchema,
"account-provider": accountProviderSchema, "account-provider": accountProviderSchema,