Repository navigation
Conversation
- Fix the cancellation/deadline race: a cancellation requested before the deadline now stays cancelled even if the deadline fires during the abort grace, and a deadline that fires first stays timed_out. - Project step results conservatively: only proven outcomes become completed; uncertain or interrupted work is recorded unknown and never replayed. - Enforce run, retry, concurrency, tab, source and intermediate-result bounds, including Evidence Mode tab accounting across resumes. - Refuse a run with no pending steps so a pre-completed checkpoint can never report zero-step success, and expose per-step provenance plus whether this run executed the step. - Add regression tests for races, recovery, budgets and provenance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bounded, declarative workflow execution engine for Zen MCP. It executes a saved
WorkflowStorecheckpoint by dispatching each allowlisted step through the same guarded tool path as a direct MCP call, so policy, read-only mode, consent, Pause and audit stay authoritative for every step. The checkpoint ledger remains the durable source of truth; the executor adds dependency-aware scheduling, resource bounds, cancellation and safe resume.Base:
origin/mainatc9681b250119c5dc4c00933db1901c6df9eeb36b.Branch:
phase7/workflow-execution-engine-20261203.HEAD:
e703a0d9761d3e58f2b790afc4f429704fd448b9(on top of1417a6aandbc29824).What changed
src/zen/workflow-executor.ts): schedules steps whose dependencies are all settled, respectsmaxConcurrency,maxSteps,maxDurationMs, per-step and workflow-wide retry budgets, tab/source budgets and a cap on intermediate result size. It never talks to the browser directly; an injected invoker runs each step through the guarded path.src/zen/workflows.ts): persisted run state (outcome, stop reason, counts, limits) with optimistic revisions and strict transition validation.src/zen/workflow-projection.ts,src/zen/workflow-values.ts): only proven, allowlisted, bounded fields become step results; URLs, page text and raw tool output are never stored.src/mcp/server.ts,catalog.ts,guard.ts,policy.ts): one new mutating tool,zen_workflow_run(actionsrun/cancel), wired into the capability policy and mutating-tool guard. Unknown tool errors are attributed insrc/mcp/tool-error-attribution.ts.Checkpoint and recovery semantics
pending → runningis persisted before a step is dispatched, so an abrupt exit leaves a detectablerunningcheckpoint.completedonly when the invoker proves the outcome. Every other settled-but-unverified result becomesunknown.recoveryRequiredblocks a new run until uncertain steps are explicitly resolved withzen_workflow_save; completed steps are never replayed.completed. Each step in a run result now carriesstatusProvenance: "agent_reported"and anexecutedflag, so pre-existing state is observable rather than implied verified.Cancellation / deadline race fix
The reviewed race fix is included: a cancellation requested before the deadline stays
cancelledeven if the deadline fires during the abort grace, and a deadline that fires first staystimed_out. Cancellation wakes the scheduler immediately rather than waiting formaxDurationMs; in-flight work is aborted where supported and recordedunknownwhen its settlement is not observed. There is no rollback claim.Unknown outcomes and no automatic replay
Uncertain, interrupted or cancelled-in-flight work is recorded
unknown, neverfailedby the executor and never replayed. A denial proven to happen before dispatch (policy, Pause, consent, capability, invalid arguments) leaves the steppendingand stops the run asblocked, which is not a recovery case.Resource and retry limits
Run bounds may tighten but never widen the workflow's fixed limits:
maxSteps,maxConcurrency,maxDurationMs,maxRetriesPerStep,maxTotalRetries,maxTabsCreated,maxSourcesCollected,maxIntermediateResultBytes.maxCheckpointBytesis fixed at workflow creation. Retries apply only to proven non-application, and each retry or resume spends the per-step and workflow-wide budgets, which include earlier runs.Evidence Mode accounting
Evidence Mode tabs and research sources are charged against the run's tab/source budgets, including across resumes, so repeated resumes cannot exceed the declared allowance.
Validation performed (Windows, Node 22.15.1)
npm run typecheck— passed.npm run build— passed.npm test— 722 tests, 707 passed, 15 skipped, 0 failed.npm run context:check— passed (61 tools; budget met).npm run check:skill— passed (1,970 / 2,000 tokens).git diff --check— clean.Remaining limitations
Not done here
No merge, no release, and no push to
main.mainwas not modified.