OKHAM.org Documentación EnglishCastellano

OFR · Open Function Registry

An Open Function Registry (OFR) is a catalogue of operations that a system offers to callers. Each entry requires an identifier, a human-readable name and an intent that describes the requested use. It can also name the values a caller supplies, the values it can expect back, and observable effects such as writing a record. A workflow or an agent can use that description to select an operation without having to know its implementation language or where its code runs.

Scope and invocation

The publisher describes the operation from the caller's point of view. If the publisher omits the input or output list, that part of the signature is unspecified. A parameter name identifies a value in the call or result. Its type refers to a shared definition that the caller and the implementation can both interpret. An operation identifier can therefore be reused in several workflows, while the implementation remains a choice for the system handling the call. See the type contract.

Listing an operation makes it discoverable. To run it, a host must resolve the identifier to an implementation and check whether the caller is authorised. The registry's intent and side-effect declarations help the caller choose an operation. Permission to perform it and evidence of what happened on a particular call come from the host. A publisher who also wants to distribute source code can use the snippet registry.

Field reference

Read each table within its named object. A required field must be present whenever that object is supplied. Brackets ([]) denote one array entry. Each object in the tables accepts additional properties.

Document

Field JSON type Required Meaning and constraints
ofr object Yes Registry envelope. It holds the format version and the operations offered to callers.

ofr

Field JSON type Required Meaning and constraints
version string Yes Format version used by this registry. The schema accepts a string.
operations array of objects Yes Operations offered by the registry. An empty list is valid.

ofr.operations[]

Field JSON type Required Meaning and constraints
id string Yes Stable identifier the caller uses to request this operation. Use at least four dot-separated segments. Each starts with a lowercase letter and continues with lowercase letters or digits.
name string Yes Name displayed to the caller.
intent string Yes Intended use of the operation, such as execute. The host interprets this value.
description string No What the operation does and when to use it.
inputs array of objects No Parameters the caller can supply.
outputs array of objects No Values the caller can expect back.
sideEffects array of strings No Observable effects such as writing a record. An empty list declares none. Omission leaves the effects unspecified.
version string No Version of the operation, independent of the registry format.

ofr.operations[].inputs[], ofr.operations[].outputs[]

Field JSON type Required Meaning and constraints
name string Yes Name used to pass or retrieve the value.
type string Yes Identifier of the OTC type used to interpret the value.
required boolean No Whether the value must be present when the operation is called. Schema default: true.

Example: classifying a save request in OKHAM Memory

Before storing a record, Memory classifies the request and passes the result to the next step. This shortened entry shows the signature of that classifier. Here intent is execute. The schema accepts a string and leaves the vocabulary of intents to the consumer. The caller supplies request. The classifier returns handoff for the next step.

{
  "ofr": {
    "version": "0.1.0",
    "operations": [
      {
        "id": "okham.memory.operation.save.classify",
        "name": "classify typed save",
        "intent": "execute",
        "inputs": [
          {"name": "request", "type": "okham.memory.type.save.request"}
        ],
        "outputs": [
          {"name": "handoff", "type": "okham.memory.type.save.classified"}
        ],
        "sideEffects": []
      }
    ]
  }
}

The registry, operations and parameters accept extra properties. In the full example, metadata.hostBinding names the adapter used by Memory. This adapter name is specific to the Memory host.

Edition 0.2.0 · JSON Schema · Full example

Ver especificación en GitHub