Workflow Versioning
CaseSolo now has metadata-backed workflow version controls for draft snapshots, dry-run tests, approval requests, publish, rollback, audit history, and run-step trace output.
Source Of Truth
src/lib/workflow/versioning.tsowns version metadata parsing, snapshot creation, approval records, dry-run step traces, rollback state, and run-log normalization.src/app/api/workflows/[workflowId]/versions/route.tsexposes workflow version actions.src/app/api/workflows/[workflowId]/runs/route.tsnow returnsstepTracefor each run.src/app/(dashboard)/workflows/[workflowId]/page.tsxexposes draft, dry-test, approval, publish, and rollback controls.
Version Actions
GET /api/workflows/[workflowId]/versions
- Returns the current workflow versioning state for the current firm.
POST /api/workflows/[workflowId]/versions
create_draft: stores a draft snapshot and marks the workflow inactive/draft.request_approval: records an approval request for the draft version.approve/reject: admin-only approval review actions.test: records a non-mutating dry-run step trace.publish: admin-only action that activates the workflow and stores a published snapshot.rollback: admin-only action that restores nodes, edges, trigger config, and activation state from a saved version.
Security Notes
- All version actions are firm-scoped.
- Publish, rollback, approve, and reject are admin-only.
- Updates use
updateMany({ where: { id, firmId } })to avoid cross-tenant writes. - Every action writes an immutable audit event through
auditLog. - Dry-run tests do not execute live workflow nodes or mutate cases, tasks, notes, notifications, or documents.
Known Limits
This implementation intentionally avoids a schema migration. Versions, approvals, tests, and audit history are stored in Workflow.metadata.workflowVersioning. Future Command Graph work should move versions, approvals, and run steps to first-class tables.
Verification
npm run test:run -- workflow-versions: 1 file, 6 tests passing.npx tsc --noEmit --pretty false: passing for this worktree snapshot.npx eslint src/lib/workflow/versioning.ts src/app/api/workflows/'[workflowId]'/versions/route.ts src/app/api/workflows/'[workflowId]'/runs/route.ts src/app/'(dashboard)'/workflows/'[workflowId]'/page.tsx src/__tests__/api/workflow-versions.test.ts: passing.