Commit graph

5 commits

Author SHA1 Message Date
Rasmus Widing
e7efc4155e fix: address review findings for on_reject and capture_response
- emit workflow_cancelled event + SSE notification on max-attempts exhaustion
  in executeApprovalNode (dag-executor.ts)
- add missing Record<string, unknown> type annotation on metadataUpdate in
  orchestrator-agent.ts
- wrap CLI hasOnReject DB calls in try/catch matching the else-branch pattern
- add tests for $REJECTION_REASON substitution in executor-shared.test.ts
- add tests for command-handler reject on_reject branch and captureResponse
  approve behavior
- add tests for API approve/reject endpoints (on_reject routing, max attempts,
  captureResponse, 404/400 error cases)
- add tests for workflowRejectCommand (on_reject, working_path guard, max
  attempts, plain cancel)
- add approvalOnRejectSchema validation tests (empty prompt, out-of-range
  max_attempts)
- update docs/approval-nodes.md: capture_response opt-in behavior, new fields
  table, conditional rejection behavior, on_reject lifecycle section
- update docs/authoring-workflows.md: add $REJECTION_REASON and $LOOP_USER_INPUT
  to variable table, update Human-in-the-Loop pattern
- add $REJECTION_REASON to CLAUDE.md variable substitution list
2026-04-02 12:15:10 +03:00
Rasmus Widing
9a930435df simplify: remove redundant JSDoc tag and fix misleading test input
Remove @returns tag from detectCreditExhaustion — the return type and
behavior are already clear from the signature and body. Fix the
"credit balance" test case which used an input that matched both
"credit balance" and "insufficient credit" patterns; use an input that
matches only the intended pattern.
2026-04-02 10:34:44 +03:00
Rasmus Widing
cbfb15c9f6 fix(workflows): remove over-broad SDK error gate for credit exhaustion detection
The `startsWith('error_')` check would misclassify any SDK error whose
subtype begins with `error_` (e.g. `error_max_turns`, `error_max_tokens`)
as credit exhaustion, giving users misleading "wait for credits" guidance.

The SDK returns credit exhaustion as assistant text anyway, so
`detectCreditExhaustion(nodeOutputText)` is the correct and complete
detection path. Remove the speculative SDK flag path and its associated
local variables.

Also adds an independent test for the 'insufficient credit' pattern in
CREDIT_EXHAUSTION_OUTPUT_PATTERNS, which was previously only incidentally
covered by the 'credit balance' test string.
2026-04-02 10:32:34 +03:00
Rasmus Widing
0f894d07b4 fix(workflows): detect credit exhaustion in node output and fail instead of completing (#940)
When Claude credits run out mid-workflow, the SDK returns the error as
normal assistant text rather than throwing. The DAG executor was marking
these nodes as completed with garbage output, preventing resume from
re-running them.

Changes:
- Add isError/errorSubtype to MessageChunk and WorkflowMessageChunk result types
- Propagate is_error/subtype from Claude SDK result message
- Add detectCreditExhaustion() to executor-shared for text pattern matching
- Gate node_completed in dag-executor with credit exhaustion check
- Mark credit-exhausted nodes as failed so resume re-runs them

Fixes #940
2026-04-02 10:18:30 +03:00
Rasmus Widing
ef04321eef
refactor(workflows)!: remove sequential execution mode, DAG becomes sole format (#805)
* refactor(workflows)!: remove sequential execution mode, DAG becomes sole format

Remove the steps-based (sequential) workflow execution mode entirely.
All workflows now use the nodes-based (DAG) format exclusively.

- Convert 8 sequential default workflows to DAG format
- Delete archon-fix-github-issue sequential (DAG version absorbs triggers)
- Remove SingleStep, ParallelBlock, StepWorkflow types and guards
- Gut executor.ts from ~2200 to ~730 lines (remove sequential loop)
- Remove step_started/completed/failed and parallel_agent_* events
- Remove logStepStart/Complete and logParallelBlockStart/Complete
- Delete SequentialEditor, StepProgress, ParallelBlockView components
- Remove sequential mode from workflow builder and execution views
- Delete executor.test.ts (4395 lines), update ~45 test fixtures
- Update CLAUDE.md and docs to reflect DAG-only format

BREAKING CHANGE: Workflows using `steps:` format are no longer supported.
Convert to `nodes:` (DAG) format. The loader provides a clear error message
directing users to the migration guide.

* fix: address review findings — guard errors, remove dead code, add tests

- Guard logNodeSkip/logWorkflowError against filesystem errors in dag-executor
- Move mkdir(artifactsDir) inside try-catch with user-friendly error
- Remove startFromStep dead parameter from executeWorkflow signature
- Remove isDagWorkflow() tautology and all callers (20+ sites)
- Remove dead BuilderMode/mode state from frontend components
- Remove vestigial isLoop, selectedStep, stepIndex, step_index fields
- Remove "DAG" prefix from user-facing resume/error messages
- Fix 5 stale docs (README, getting-started, authoring-commands, web adapter)
- Update event-emitter tests to use node events instead of removed step events
- Add executor-shared.test.ts (12 tests) for substituteWorkflowVariables
- Add executor.test.ts (11 tests) for concurrent-run, model resolution, resume

* fix(workflows): add migration guide, port preamble tests, improve error message

- Add docs/sequential-dag-migration-guide.md with 3 conversion patterns
  (single step, chain with clearContext, parallel block) and a Claude Code
  migration command for automated conversion
- Update loader error message to point to migration guide and include
  ready-to-run claude command
- Port 8 preamble tests from deleted executor.test.ts to new
  executor-preamble.test.ts: staleness detection (3), concurrent-run
  guard (3), DAG resume (2)

Addresses review feedback from #805.

* fix(workflows): update loader test to match new error message wording

* fix: address review findings — fail stuck runs, remove dead code, fix docs

- Mark workflow run as failed when artifacts mkdir fails (prevents
  15-min concurrent-run guard block)
- Remove vestigial totalSteps from WorkflowStartedEvent and executor
- Delete dead WorkflowToolbar.tsx (369 lines, no importers)
- Remove stepIndex prop from StepLogs (always 0, label now "Node logs")
- Restore cn() in StatusBar for consistent conditional classes
- Promote resume-check log to error, add errorType to failure logs
- Remove ghost $PLAN/$IMPLEMENTATION_SUMMARY from docs (never implemented)
- Update workflows.md rules to DAG-only format
- Fix migration guide trigger_rule example
- Clean up blank-line residues and stale comments

* fix: resolve rebase conflicts with #729 (forkSession) and #730 (dashboard)

- Remove sequential forkSession/persistSession code from #729 (dead after
  sequential removal)
- Fix loader type narrowing for DagNode context field
- Update dashboard components from #730 to use dagNodes instead of steps
- Remove WorkflowStepEvent/ParallelAgentEvent from dashboard SSE hook
2026-03-26 11:27:34 +02:00