Skip to content

feat(workflow): authoring, persistence & structured returns (#312 Bolt 2)#326

Open
fanhongy wants to merge 3 commits into
mainfrom
feat/cao-workflow-authoring
Open

feat(workflow): authoring, persistence & structured returns (#312 Bolt 2)#326
fanhongy wants to merge 3 commits into
mainfrom
feat/cao-workflow-authoring

Conversation

@fanhongy

Copy link
Copy Markdown
Contributor

Summary

Bolt 2 of #312 (cao workflow): the authoring → persist surface plus structured step returns. Stacks on Bolt 1 (#320, merged).

  • Spec authoring CLI + endpointscao workflow validate / list / get / delete, backed by /workflows*. YAML spec files on disk are the single source of truth; the workflow_index SQLite table is a derived, droppable projection rebuilt byte-identically from the files (idempotent migration, covered by a migration test).
  • Structured step returns — the workflow_return MCP tool + in-memory StepOutputStore. A schema-invalid output is stored and returned as 200 / validated=False / COMPLETED_UNVALIDATED — never collapsed into an error or a claim that the step ran (honesty discipline; the reprompt loop is Bolt 3).
  • Scope discipline — ships only author/persist. run / cancel / run-status and the implicit-upsert-on-run trigger land in Bolt 3 with the engine (N5). Reserved constructs validate-and-store but never render as executing.

Review

Reviewed by a sub-agent against the PR #320 finding-classes to prevent recurrence. Findings fixed in this branch:

  • Never-raise contract (FR-1.3) — a parseable spec with a non-string YAML key (1: foo) no longer leaks a TypeError as an unhandled 500; it surfaces as a clean fail / 400. Pinned by service- and endpoint-level regression tests.
  • Module layering — Bolt 2 runtime DTOs (ReturnAck / StepOutputRecord / WorkflowIndexRow / StepState) moved to a light models/workflow_runtime.py so the MCP server consumes ReturnAck without pulling jsonschema/yaml onto the HTTP seam (workflow.py re-exports them — no call-site churn).
  • Cause chaindelete_workflow's OSError → ValueError now uses raise ... from e.

Project rules honored: single HTTP seam (CLI + MCP talk only HTTP); shared path/name validators reused (no ad-hoc regex); core services raise narrow exceptions, API maps to HTTPException; best-effort index/store never raise into the success path; constants centralized.

Test plan

  • uv run pytest test/ --ignore=test/e2e --ignore=test/providers/test_q_cli_integration.py → green (the 7 kiro_cli integration errors are pre-existing, require a live authenticated CLI, CI-ignored).
  • black (line-length 100) + isort clean; mypy clean on all touched files.

Refs #312

🤖 Generated with Claude Code

fanhongy added 2 commits June 23, 2026 17:18
N2 spec-service + workflow_index migration + cao workflow CLI (validate/list/get/delete),
N3-auth workflow-author skill + workflow-scout profile, N4 structured-return MCP tool +
endpoint + in-memory output store. run/cancel/status deferred to Bolt 3 engine. 47 tests.

Refs #312
Rebased onto the #320-fixed foundations head. Relocate Bolt 2 runtime DTOs
(ReturnAck/StepOutputRecord/WorkflowIndexRow/StepState) to a light
workflow_runtime module so the MCP server no longer pulls jsonschema/yaml.
Add non-string-key never-raise regression tests; chain delete OSError cause.
Refs #312
Comment thread src/cli_agent_orchestrator/services/workflow_spec_service.py Fixed
Comment thread src/cli_agent_orchestrator/services/workflow_spec_service.py Fixed
Comment thread src/cli_agent_orchestrator/services/workflow_spec_service.py Fixed
Add _safe_spec_path: realpath-normalize a spec file path then assert it lives
inside its policy-checked directory (startswith containment) before any
stat/open. Route load_and_validate / validate_only / get_workflow through it;
get_workflow stats only path-like args via the guard, never raw input.
Rejects blocked dirs and symlink escapes. Refs #312
@fanhongy fanhongy added the feature New feature or capability label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants