Author a routine
Build an action-graph workflow definition, validate and dry-run it, then publish it as an immutable version
Goal
Take a routine from an unpublished draft through validation, a dry-run preview, and human-approved publication as an immutable version, using the real action-dispatcher binding table rather than a self-reported honor system.
Before you start
- An initialized project (
strata19.initialize_project) and, for any step that queries the code graph, a built local index. - Know which
actionKinds your routine needs and whether each one really dispatches. Callstrata19.automation_authoractiondry_runon your specific draft rather than assuming — an action kind's name does not by itself tell you whether it runs. - Decide up front which steps are human gates.
request_approval,ask_question,request_form_input,create_commit,merge_candidate, andpush_branchall dispatch only through the run operation's human-gate chokepoint, and only with a real persisted approval or an active grant — an agent can never satisfy its own gate. - This page covers authoring a routine live, in your own project — no plugin rebuild is needed. Bundling a routine so every install ships it by default is a separate, heavier path covered at the end of this page.
Steps
Create an unpublished draft
Call: strata19.automation_author action draft_create
workflowKey: "routine.my-new-routine"
definition: { actions: [...], edges: [...] }A draft is not an execution — nothing runs yet. A real bundled definition, for shape reference (src/automation/routines/test-impact.ts):
export const testImpactRoutine: WorkflowDefinitionV1 = {
workflowKey: 'routine.test-impact',
version: 1,
projectKey: 'strata19-core',
name: 'Test Impact Analysis',
description:
'Analyze the impact of changes on tests by computing change impact, ' +
'verifying the implementation, and creating work items to track test updates.',
actions: [
{ actionId: 'step-change-impact', actionKind: 'compute_change_impact', label: 'Compute Change Impact' },
{ actionId: 'step-verify', actionKind: 'verify_implementation', label: 'Verify Implementation' },
{ actionId: 'step-work-item', actionKind: 'create_or_update_work_item', label: 'Create Work Item' },
],
edges: [
{ source: 'step-change-impact', target: 'step-verify' },
{ source: 'step-verify', target: 'step-work-item' },
],
triggers: [{ type: 'manual' }],
autonomyMode: 'review',
}actionId/actionKind/label per action node; source/target per edge (WorkflowActionNodeV1/WorkflowEdgeV1, packages/shared-types/src/plugin/workflow.ts). autonomyMode is one of 'shadow' | 'suggest' | 'review' | 'automate'.
Update the draft until it's structurally sound
Call: strata19.automation_author action draft_update
Call: strata19.automation_author action validate_draftvalidate_draft checks unique action ids, every edge endpoint resolves, no unreachable node, no start-node recursion, a bounded graph size, and every action's declared required input keys are present. Errors name the offending node or edge directly. Re-validate after every edit — a stale expectedVersion on draft_update is a typed conflict, never a silent clobber.
Dry-run before publishing
Call: strata19.automation_author action dry_runReports, per action, whether it would dispatch to a real implementation or report a typed unsupported, and which actions would require a human approval gate — without executing or triggering anything. Treat unsupported as a real, typed outcome to design around, not an error to paper over: several unsupported kinds have a real implementation elsewhere but are blocked for a specific, named reason (tenant scope, no network/unattended runtime in the local executor, or a contract conflict with the action's own requiresNetwork: false) — the response's reasonCode says which.
Grant an approval, if a gated step needs one
Call: strata19.automation_approvals action grantOnly when a human has decided to pre-authorize a gated step for a specific actor and routine version. The grant store refuses a grant whose target actor resolves to the granting session's own identity — an agent cannot pre-authorize itself. revoke removes a grant before it expires; a revoked grant can never be reactivated.
Publish
Call: strata19.automation_author action publish_draftPublishing records an immutable version — it does not start anything. An agent proposing publication cannot supply the approving decision; publication is a human decision, by design, every time. A published version never mutates: create a new draft and a new version for any behavioral change.
Start, drive, and read back the run
Call: strata19.automation_run action start
Call: strata19.automation_run action get_next_action
Call: strata19.automation_run action submit_action_result
Call: strata19.automation_run action pause # before disconnecting
Call: strata19.automation_run action get_receiptsA caller-supplied result is not proof of anything — the engine re-derives the real output by calling the real tool itself and attests it (tool name, output digest, dispatch id). A hand-crafted output cannot produce a success receipt. A run is complete when its required receipts exist, not when a step returns and not when you say so.
Bundling a routine into every install
The steps above create a project-local, durable definition (SQLite) that only your project can run. To ship a routine as one every installed plugin offers by default, add a file under src/automation/routines/ exporting a WorkflowDefinitionV1 (the shape above) and add it to BUNDLED_ROUTINES in src/automation/routines/index.ts. That module is imported by src/mcp/facade/routine-registry.ts and workflow-local-adapter.ts — both part of the façade pnpm build:plugin bundles into facade-stdio.js — so this change needs the full release loop (version bump, rebuild, commit, reinstall) before an installed host sees it. See Interface and packaging for the exact steps.
Note the .strata19/extensions/<name>/strata19-extension.json project-local format also accepts a routines contribution tier. It is schema-validated and stored with provenance, but nothing in this build wires it to register a runnable routine — treat it as a declared intent, not a way to ship a working routine today.
Verify
Call: strata19.automation_run action get_receiptsEvery receipt for the execution, including its server-computed attestation when present — receipts are not write-only. A routine is verified done when the receipts you expect exist for every step, not when the last call returned without error.
For a bundled routine, confirm the built artifact actually carries it:
node ./server/facade-stdio.js # from plugins/strata19/, after pnpm build:pluginthen call strata19.automation_author action list_definitions against that process and confirm your workflowKey appears.
If it doesn't work
validate_draftfails on a specific node or edge. Fix that node — the error already names it; do not restructure the whole graph.- A step reports
unsupported. Read thereasonCode(requires_tenant_context,requires_network_or_unattended_runtime, orrequires_contract_redesign) rather than assuming the capability is simply missing — severalunsupportedkinds have a real implementation elsewhere and are blocked for a specific reason. publish_draftor a human-gated step is rejected. Publication and gated actions require a real human decision or an active grant issued by someone other than the calling session — an agent can never satisfy its own gate. This is enforced, not advisory.- A step fails partway through a run. Earlier successful steps' receipts and canonical outputs remain visible; re-running converges on the same identities rather than duplicating them. After a restart, resume from the pending step rather than starting a new run.
- You bundled a routine in source but an installed host doesn't offer it. The plugin cache is version-keyed; editing source and running
pnpm build:pluginchanges nothing a running session sees until the version is bumped and the plugin is reinstalled — see Interface and packaging.
Related
- Interface and packaging — the release loop a bundled routine needs to reach an installed host.
- Add an MCP tool — when a routine needs an
actionKindthat doesn't dispatch to anything yet. - Package a skill — for teaching a workflow over existing tools without the validation/approval/receipt machinery a routine gets.
reference/routines— the catalog of routines this install bundles today.