Skip to content

operations Specification

Purpose

The operation catalog: Virtufin's operations by name, each with a description, an input schema and a kind (read or write), shared by every operator client's scripts and AI assistant, with writes through the write gate.

Requirements

Requirement: Script Form Choices

A text or some-of field MAY offer choices with x-options (script-form.v1.schema.json): a fixed values list, or from a catalog read operation whose result gives values and labels by JSON Pointer. With free false (the default) a value SHALL be one of the loaded choices; with free true any value passing the text checks SHALL be accepted. Clients SHALL pass the choice vectors in scripts/validation.yaml (domain-devkit).

Scenario: Choices from an operation

  • WHEN a form has worker with x-options {"from": {"operation": "workers.list", "value": "/id", "label": "/name"}}
  • THEN the client SHALL offer each worker's name and pass its id

Scenario: A strict value outside the choices

  • WHEN the user enters a worker id that workers.list did not return, and free is not set
  • THEN the script SHALL not run, and the field SHALL say the value is not one of the choices

Scenario: A free value

  • WHEN a topic field has choices from topics.list and free: true, and the user types a topic not in them
  • THEN the script SHALL run with the typed topic

Requirement: Reading Script Form Choices

A client SHALL read a field's choices from its operation when the form is shown and again when a field its input refers to ({"field": "<key>"}) changes, leaving that input out while the field is empty. It SHALL refuse a write or people-only operation as a source for that field, while the rest of the form keeps working.

Scenario: Dependent choices

  • WHEN a field's from.input is {"prefix": {"field": "prefix"}} and the user changes prefix
  • THEN the client SHALL read the choices again with the new prefix, and leave prefix out while that field is empty

Scenario: A write as the source

  • WHEN a field's from.operation is workers.stop
  • THEN the client SHALL not call it, and that field SHALL say a write cannot give choices

Requirement: Operation Catalog

A client SHALL offer its operations on the active context as one catalog: each operation has a name (<group>.<action>, e.g. workers.start), a description, an input JSON Schema and a kind, read or write. Scripts and the AI assistant SHALL reach the platform only through the catalog.

Scenario: A malformed input

  • WHEN a script calls workers.start with no id
  • THEN the call SHALL fail naming the operation and the path of each problem, and nothing SHALL be sent

Requirement: Operations the Catalog Covers

The catalog SHALL cover workers (list, create from the registry, start, stop, delete, tag, upgrade), the worker registry, feed definitions (list, save, connect, disconnect), triggers, scenarios (list, add, set status, halt, resume, delete), the kill switch, strategies (list, compose), state (get, keys) and topics (list, read the next events).

Scenario: The published catalog

  • WHEN a client's catalog document is read
  • THEN it SHALL list operations of each of these groups, e.g. workers.upgrade, scenarios.halt and topics.read

Requirement: Writes Through the Write Gate

A write operation SHALL run as one pass of the client's write gate (only admins; a protected context asks first, once for the whole operation); a declined write SHALL change nothing and fail as declined. The kill switch SHALL be marked for people only and SHALL NOT be offered to the AI assistant.

Scenario: Declined on a protected context

  • WHEN a script calls scenarios.halt on a protected context and the user says no
  • THEN no halt SHALL be written and the call SHALL fail as declined

Requirement: Catalog Document

The catalog SHALL be one JSON document ({$id, version, operations: [{name, description, kind, peopleOnly?, input}]}) shipped by domain-devkit (Python and TypeScript), the contract every client implements: each client SHALL implement every operation it lists, with its input schema, and SHALL check its catalog against it in its tests. The web app generates the same document from its typed operations and publishes it at /schemas/operations.v1.json.

Scenario: A new operation

  • WHEN an operation is added to the document
  • THEN a client that does not implement it, or implements it with another input schema, SHALL fail its tests

Requirement: Scripts

A client SHALL let a user write and run scripts against the active context that reach the platform only through the operation catalog. The client SHALL show the output, the result or error, and every operation the script called, writes marked. A script's writes SHALL ask exactly as the views' do.

Scenario: A script tries the network

  • WHEN a script calls fetch on the app server
  • THEN the call SHALL fail, and the script SHALL reach nothing but the catalog

Scenario: A declined write

  • WHEN a script calls scenarios.halt on a protected context and the user says no
  • THEN the script SHALL get a declined error, and the list of operations called SHALL show it failed

Requirement: Scripts in the Web App Sandbox

The web app's scripts SHALL be TypeScript or JavaScript run in a sandbox with no network and no access to the page (vf.<group>.<action>(input) calls an operation; print and console write the output; return gives the result), stoppable and stopped after 10 minutes.

Scenario: A script that runs too long

  • WHEN a script still runs after 10 minutes
  • THEN it SHALL be stopped, and the client SHALL say it timed out

Requirement: AI Assistant

A client's AI assistant SHALL act only through the operation catalog: its tools are the catalog's operations (people-only ones left out; write operations only for users who may write), each tool call SHALL run as the operation would for a script (writes through the write gate, asked of the user), and a failed or refused call SHALL go back to the model as a result, never as a crash. A question SHALL take at most 5 model turns.

Scenario: A reader asks for a write

  • WHEN a user who may only read asks the assistant to halt a scenario
  • THEN the assistant SHALL have no halt tool, a forged call SHALL be refused as no such tool, and nothing SHALL be written

Requirement: AI Providers

The provider SHALL be OpenAI-compatible (base URL, model, key), chosen per user. A user's API key SHALL never reach a browser after it was given (the web app's server keeps it sealed and relays the chat), and a user's base URL SHALL be https and SHALL NOT reach a private or local address.

Scenario: A local base URL

  • WHEN a user saves a provider whose base URL is http://127.0.0.1:11434/v1
  • THEN it SHALL be refused, naming the rule

Requirement: Reflected Operations

A client's scripts SHALL also offer one operation per unary method the gateway lists for each backend, named <service>.<method>, with its input schema from the method's schema and its kind from ListMethods. They SHALL run through Gateway.InvokeJson, be shown apart from the hand-written operations and marked as reflected, and SHALL NOT be offered to the AI assistant or listed in the catalog document.

Scenario: A backend method

  • WHEN the gateway lists workmanager with ListWorkers
  • THEN scripts SHALL offer the reflected read workmanager.ListWorkers in the group of reflected operations, with an input schema for ListWorkersRequest

Scenario: Reflected writes

  • WHEN a script calls a reflected write on a protected context
  • THEN it SHALL pass the write gate like any other write: it asks first and is recorded in the change log

Scenario: Streaming methods

  • WHEN a backend method streams from the client (client-streaming or bidirectional)
  • THEN it SHALL NOT be offered as an operation; a server-streaming method SHALL be offered as a reflected streaming operation

Requirement: Script Form Format

A script MAY carry a form, which SHALL be a JSON Schema object within script-form.v1.schema.json (domain-devkit): flat properties of the kinds, checks and x- hints that file lists (design.md has the table), shown in the order of properties, each only while its x-visibleIf holds.

Scenario: A form outside the subset

  • WHEN a form has a property of type object
  • THEN the client SHALL refuse the form and say that property is not supported, never drawing it in part

Requirement: Running a Script with a Form

A client SHALL show a script's form before running it and SHALL not run it while a visible field fails a check, saying which and why. The script SHALL get one object: each visible field's value typed as the schema says, an empty field absent. Both clients SHALL pass the conformance vectors in domain-devkit scripts/validation.yaml.

Scenario: A hidden field

  • WHEN a form has code visible only if source is code, and the user picks url
  • THEN code SHALL be neither checked nor passed

Scenario: Typed values

  • WHEN the user enters 5 in an integer field and ticks a boolean field
  • THEN the script SHALL get the number 5 and true, not strings

Requirement: Script Templates

A client SHALL start a new script from a template that shows how to call an operation, read the form's values, write the output and return a result, and SHALL offer its shipped examples, at least one with a form, as starting points that are copied, never changed in place.

Scenario: New script

  • WHEN the user creates a new script
  • THEN it SHALL open with the template's code, unsaved, under a name the user can change

Requirement: Documentation Operations

The catalog SHALL hold docs.search (a query, answering the best matching documentation sections with site, title, link and snippet) and docs.read (a section's link, answering its text), both reads over the documentation in the client's scope.

Scenario: Search the docs

  • WHEN docs.search runs with "feed preset"
  • THEN it SHALL answer sections with links, the market-data-devkit's among them

Requirement: Streaming Operations

An operation MAY stream. In a script a streaming operation SHALL return an async iterable of its messages; leaving the loop, stopping the script or the script's time limit SHALL cancel the call. A streaming write SHALL pass the write gate once, when the call starts, and be recorded once. Streaming operations SHALL NOT be offered to the AI assistant. The catalog SHALL include a streaming read that follows a topic's events through Pubsub.Subscribe.

Scenario: Following a topic

  • WHEN a script loops over the streaming operation that follows a topic
  • THEN it SHALL receive each event published to the topic while it loops

Scenario: Leaving the loop

  • WHEN a script breaks out of the loop over a streaming operation
  • THEN the call SHALL be canceled, and the backend SHALL stop sending

Scenario: A streaming write

  • WHEN a script starts a streaming write on a protected context
  • THEN it SHALL ask once before the call starts and record the call once in the change log

Requirement: Reflected Streaming Operations

A client's scripts SHALL offer each server-streaming method the gateway lists for a backend as a reflected streaming operation, named and marked like the other reflected operations, run through Gateway.InvokeJsonStream. Client-streaming and bidirectional methods SHALL NOT be offered.

Scenario: A server-streaming backend method

  • WHEN the gateway lists a backend's server-streaming method Watch
  • THEN scripts SHALL offer <service>.Watch as a reflected streaming operation

Scenario: A bidirectional method

  • WHEN a backend method streams in both directions
  • THEN it SHALL NOT be offered as an operation