OSS-first docs

These docs teach the open system first: contracts, generated surfaces, runtimes, governance, and incremental adoption. Studio shows up as the operating layer on top, not as the source of truth.

workflow.instance.cancel

Cancel a workflow instance.

  • Type: operation (command)
  • Version: 1.0.0
  • Stability: stable
  • Owners: @example.workflow-system
  • Tags: workflow, instance, cancel
  • File: packages/examples/workflow-system/src/instance/instance.operations.ts
  • field.key.label
    workflow.instance.cancel
    field.version.label
    1.0.0
    field.type.label
    operation (command)
    field.title.label
    workflow.instance.cancel
    field.description.label

    Cancel a workflow instance.

  • Type: operation (command)
  • Version: 1.0.0
  • Stability: stable
  • Owners: @example.workflow-system
  • Tags: workflow, instance, cancel
  • File: packages/examples/workflow-system/src/instance/instance.operations.ts
  • field.tags.label
    workflow,instance,cancel
    field.owners.label
    @example.workflow-system
    field.stability.label
    stable

    Cancel a workflow instance.

    Goal

    Terminate workflow without completion.

    Context

    User request, system cancellation.

    Emitted Events

    `workflow.instance.cancelled` (v1.0.0)

    Source Definition

    import {
    	defineCommand,
    	defineQuery,
    } from '@lssm-tech/lib.contracts-spec/operations';
    import { defineSchemaModel, ScalarTypeEnum } from '@lssm-tech/lib.schema';
    import { InstanceStatusEnum } from './instance.enum';
    import {
    	StartWorkflowInputModel,
    	TransitionInputModel,
    	TransitionResultModel,
    	WorkflowInstanceModel,
    } from './instance.schema';
    
    export const CancelWorkflowContract = defineCommand({
    	meta: {
    		key: 'workflow.instance.cancel',
    		version: '1.0.0',
    		stability: 'stable',
    		owners: ['@example.workflow-system'],
    		tags: ['workflow', 'instance', 'cancel'],
    		description: 'Cancel a workflow instance.',
    		goal: 'Terminate workflow without completion.',
    		context: 'User request, system cancellation.',
    	},
    	io: {
    		input: defineSchemaModel({
    			name: 'CancelWorkflowInput',
    			fields: {
    				instanceId: {
    					type: ScalarTypeEnum.String_unsecure(),
    					isOptional: false,
    				},
    				reason: {
    					type: ScalarTypeEnum.String_unsecure(),
    					isOptional: false,
    				},
    			},
    		}),
    		output: WorkflowInstanceModel,
    	},
    	policy: { auth: 'user' },
    	sideEffects: {
    		emits: [
    			{
    				key: 'workflow.instance.cancelled',
    				version: '1.0.0',
    				when: 'Workflow is cancelled',
    				payload: WorkflowInstanceModel,
    			},
    		],
    		audit: ['workflow.instance.cancelled'],
    	},
    	acceptance: {
    		scenarios: [
    			{
    				key: 'cancel-workflow-happy-path',
    				given: ['Workflow is running'],
    				when: ['User cancels workflow'],
    				then: ['Instance status becomes CANCELLED'],
    			},
    		],
    		examples: [
    			{
    				key: 'cancel-mistake',
    				input: { instanceId: 'inst-456', reason: 'Created by mistake' },
    				output: { id: 'inst-456', status: 'cancelled' },
    			},
    		],
    	},
    });