Skip to main content
← Back to list
01Issue
BugShippedSwamp CLIPublic
Assigneeszack

Relationships

#4682 Workflow guard does not see data written by an earlier step in the same run (data.latest evaluates empty)

Opened by owonwo · 11/12/2026· Shipped 11/12/2026

Workflow guard does not see data written by an earlier step in the same run

Summary

Per the docs (references/workflow/reference.md, "When Expressions Resolve"), a guard resolves at step time and sees "Data written by earlier steps in this run". Empirically, in a scan step -> guarded notify step workflow, the guard evaluates false even though the scan step just wrote the resource and a plain data query finds it with isLatest: true.

Minimal repro (same data, same engine, minutes apart):

  • Unguarded step whose input reads size(data.latest("inspace-doctor", "doctor").?attributes.?needsHuman.orValue([])) → evaluated 38. Notification delivered.
  • Guarded step with guard size(data.latest("inspace-doctor", "doctor").?attributes.?needsHuman.orValue([])) > 0 → skipped: "guard evaluated false". No scan step in that probe workflow, no other data writer in between.

Same expression, same data stream (38 needsHuman items, versions=11 — also confirmed via data.listVersions in an unguarded step). The only difference is guard vs step-input evaluation.

Real-world impact: the pattern step A writes resource -> step B guarded on size(data.latest("A", "res").attributes.x) > 0`` never fires for findings produced by the current sweep. In production this caused a health-check workflow to silently never alert: with a sliding 90-minute lookback window, a failure found by sweep N is outside sweep N+1's window, and sweep N's notify read sweep N-1's (clean) data — so transient failures could never ship, for days, while every run reported SUCCEEDED.

Steps to reproduce

  1. Behavior method writes a resource (writeResource("doctor", "doctor", {...needsHuman: [..38 strings..]})).
  2. Workflow: step 1 runs the method; step 2 (any task type) with guard: ${{ size(data.latest("<behavior-name>", "doctor").attributes.needsHuman) > 0 }}, dependsOn step 1.
  3. Run the workflow while the resource's latest version is non-empty.
  4. Step 2 is skipped with "guard evaluated false"; an unguarded step reading the same expression in a separate workflow sees the data fine.

Expected

Guard expressions at step time see data written by earlier steps in the same run (or at minimum see the pre-run latest version), per the documented resolution table.

Workaround

Move the notification into the behavior method itself (it already has the findings in hand), instead of a guarded follow-up step.

Environment

  • swamp 20261111.234122.0-sha.cd35f58c, macOS (darwin-aarch64), local repo (no serve)
  • Engine notes that may matter: the step's data write appears to commit asynchronously ~70-400ms after step completion status flips; the guard evaluated ~74ms after the scan step reported success.
02Bog Flow
✓OPEN✓TRIAGED✓IN PROGRESS✓SHIPPED+ 1 MOREASSIGNED+ 5 MOREREVIEW+ 6 MOREPR_LINKED+ 2 MORESESSION_SUMMARIZED

Shipped

11/12/2026, 7:57:24 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
zack assigned zack11/12/2026, 7:23:02 PM
Editable. Press Enter to edit.

zack commented 11/12/2026, 7:57:25 PM

Thanks @owonwo for reporting this! We shipped: Show what a guard returned on the log-mode skipped-step line, so a guarded skip reads as a truthy guard instead of looking like a guard that failed to see data. Presentation-only: guard semantics, JSON output and the run record are unchanged.. The fix has been merged and a release is on its way. We appreciate your contribution to swamp.

zack commented 11/12/2026, 8:11:28 PM

The guard actually evaluated true here, and things are working as expected. I added some more to the log output so that this is more clear to humans and machines

Sign in to post a ripple.