Skip to content

fix(workflow): reject incompatible resume definitions - #923

Merged
getappz merged 1 commit into
masterfrom
task/754-safer-workflow-resume
Oct 19, 2026
Merged

getappz merged 1 commit into
masterfrom
task/754-safer-workflow-resume

Conversation

@getappz

@getappz getappz commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

A saved JSON workflow could resume after its prompt, model, arguments or steps changed under the same workflow name. Journal replay then reused results from the old definition while running the current one.

Persist an execution identity in the existing workflow state and compare it before lease acquisition and journal replay, including a fresh-state recheck. JSON compilation supplies the typed definition and captures its absolute working directory. Both normal and start-once creation preserve the identity; duplicate start receipts retain their existing behavior. This adapts Harness2's configuration identity guard without adding a runner, store, dependency or completion-marker layer.

Compatibility: legacy JSON runs without identity require a new run. Unversioned Rust workflows retain existing behavior; Rust callers can opt in with an explicit revision identity. Repository contents, inherited environment, executable/agent defaults and persona-file contents are outside this identity.

Validation: regression reproduced the unsafe resume before the fix; all 134 flare-workflow tests pass, including six new resume tests. cargo fmt --check, git diff --check and independent source review pass. Local Clippy passes with all targets/features and warnings denied. Hosted CI passed: workspace tests/builds on Linux and Windows, Clippy, formatting, audit, cargo-deny, hakari, CodeQL and CI Green. Windows tests used a command-only per-package debug=0 override after a PDB/disk-space link failure; no repository build settings changed.

The experimental refinement loop remains in draft PR #920 and is not included here.


Opened by codex on i-flare-c997d745ae66 (flared:c997d745ae66) for item #754 via agentflare.

Summary by CodeRabbit

  • New Features
    • Workflow resumes now verify that the saved run matches its workflow definition and execution directory. Mismatched runs are rejected before replay; recovery skips incompatible runs and continues with compatible ones.
    • Equivalent JSON configurations can resume even when formatting or key order differs. Rust-defined workflows can opt into the same identity checks.
  • Documentation
    • Clarified which workflow settings determine resume compatibility and which environment details are not included.
    • Documented that legacy JSON runs without a saved identity cannot resume against a newly compiled JSON definition.

Agentflare-Branch: task/754-safer-workflow-resume
Agentflare-Item: 754
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: getappz/agentflare/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 6eac6677-f059-40ed-add2-508f49de3d2c
📥 Commits

Reviewing files that changed from the base of the PR and between a109e43 and 32a3129.

📒 Files selected for processing: 8
  • crates/flare-workflow/README.md
  • crates/flare-workflow/src/definition.rs
  • crates/flare-workflow/src/engine.rs
  • crates/flare-workflow/src/engine_lease.rs
  • crates/flare-workflow/src/engine_start_once.rs
  • crates/flare-workflow/src/json.rs
  • crates/flare-workflow/src/types.rs
  • crates/flare-workflow/tests/resume_identity_test.rs

Included review availability: This review used your included allowance. 3 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.

📝 Walkthrough

Workflow definitions and saved runs now carry optional resume identities. JSON compilation derives an identity from the workflow configuration and absolute working directory. Resume rejects identity mismatches before driving a run, and recovery can continue past incompatible runs.

Changes: Workflow resume identity

Layer / File(s) Summary
Define and compute resume identity
crates/flare-workflow/src/types.rs, crates/flare-workflow/src/definition.rs, crates/flare-workflow/src/json.rs, crates/flare-workflow/README.md
Definitions and workflow state now support optional resume identities. JSON compilation captures an absolute working directory and includes it with the workflow configuration in the identity. The documentation describes identity matching and legacy-run behavior.
Store identity on new runs
crates/flare-workflow/src/engine.rs, crates/flare-workflow/src/engine_start_once.rs
New runs copy the registered definition’s resume identity into workflow state.
Check identity during resume
crates/flare-workflow/src/engine_lease.rs, crates/flare-workflow/tests/resume_identity_test.rs
Resume checks identity before claiming a run and again during the lease update. Integration tests cover identity mismatches, compatible and legacy runs, recovery, and start-once behavior.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant WorkflowEngine
  participant StateStore
  Caller->>WorkflowEngine: resume_run
  WorkflowEngine->>StateStore: Read saved workflow state
  StateStore-->>WorkflowEngine: Return saved state and identity
  WorkflowEngine->>WorkflowEngine: Compare saved and registered identities
  WorkflowEngine->>StateStore: Check identity during lease update
  StateStore-->>WorkflowEngine: Return update result
  WorkflowEngine-->>Caller: Resume run or return ResumeIdentityMismatch
Loading
Merge Risk: ⚪ Minimal · up to 32a31

The change makes workflow resume reject incompatible definitions before replay. No actionable merge-blocking risk was found in the supplied changes.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 7 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: rejecting incompatible workflow resume definitions.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description explains the problem, implementation, compatibility behavior, exclusions, and validation results. It does not use the exact template headings or checklist format, but it provides the r…
Full details: Description check

Explanation

The description explains the problem, implementation, compatibility behavior, exclusions, and validation results. It does not use the exact template headings or checklist format, but it provides the required information and is sufficiently complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 7 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

CI annotation context is incomplete: annotation collection unavailable or limited

Comment @coderabbitai help to get the list of available commands.

@getappz
getappz merged commit 2eab037 into master Oct 19, 2026
20 checks passed
@getappz
getappz deleted the task/754-safer-workflow-resume branch October 19, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant