Skip to content

Contracts and validation

Validating by hand

npx initiative-plugin validate manifest.json   # a manifest, or a served manifest document
npx initiative-plugin schema                   # the JSON Schema it checks against

validateManifest runs the bundled JSON Schema, then the checks a schema cannot express: features against the blocks present, ids that must name something the manifest declares, connection, vendor setup and schedule rules, what a part's nodes, a list field's element actions and an action's params name, the placeholders in a part's text, a part's size and depth, and every term the contract does not declare (a deployment discards those without saying so), and a tool plug-in's terms. The deployment also enforces byte-size caps.

The contract

manifest.contract.json is the one hand-written statement of what a manifest may say. schemas/plugin-manifest.json and src/contract.ts (its types) are generated from it with npm run generate; npm run check:generated fails when either is stale. Initiative vendors the contract from this repository's tags.

The registry's listing schema

The registry decides what a listing may say, in registry/schema/listing.schema.json in beyonders-studio/initiative-developer. schemas/registry-listing.json is a copy of it, never edited here, so build --registry checks a listing with the registry's rules rather than a restatement of them that can fall behind. Take it again when the registry's schema changes:

npm run sync:registry-schema                                  # from the registry's main
npm run sync:registry-schema -- --from ../initiative-developer/registry/schema/listing.schema.json

npm run check:generated compares the copy with the registry's main and fails when they differ, so a change to the registry's schema shows up in this repository's CI until the copy is taken and released.

The plug-in API contract

A plug-in and Initiative release on their own schedules. What they share is one file this package publishes, schemas/plugin-api.json, exported as initiative-plugin-sdk/plugin-api.json: the OpenAPI document of every route a plug-in may call, as Initiative describes it. A plug-in depends on an SDK version and nothing else.

  • The contract version is this package's version. The file's info.version is the SDK's version, and info["x-initiative-source"] names the Initiative release and commit the document was taken from. A minor release adds operations, fields or optional parameters; removing or changing anything is a major release.
  • Every client comes from the file. src/plugin-api.generated.ts, behind client.api, is generated from schemas/plugin-api.json, never from Initiative directly. A plug-in in another language generates its own client from the same file, at the SDK version it targets.
  • A deployment serves the contract it vendors. Initiative carries a copy of this file from an SDK release, serves that SDK version as its plug-in API version, and checks in its own CI that what it serves still holds every route, parameter and response field the copy has. It may serve more.
  • A plug-in names the oldest contract it needs, as min_plugin_api ("MAJOR.MINOR") in its manifest. A deployment serving contract S runs a plug-in needing N when they share a major version and S's minor is at least N's. A manifest without the field runs on any contract. Initiative, the registry and the SDK decide with the same rule, exported as pluginApiCompatible:
import { pluginApiCompatible } from "initiative-plugin-sdk/manifest";

pluginApiCompatible("4.3.2", "4.1"); // true
pluginApiCompatible("5.0.0", "4.1"); // false: another major
pluginApiCompatible("4.3.2", undefined); // true: no claim

The file is never edited by hand. Take it again when Initiative's plug-in API grows, from a checkout, a release or a running deployment; this rewrites the file at the package's version and then the client from it:

npm run generate:plugin-api -- --checkout ../initiative   # runs its export with uv
npm run generate:plugin-api -- --release v0.75.0
npm run generate:plugin-api -- --url https://initiative.example.com

With no source, npm run generate:plugin-api regenerates the client from the file and restamps its info.version with the package's; the Promote workflow does this when it bumps the version. npm run check:generated fails when either the file's version or the client is stale.