fix(serve): triggers run the published version, not the draft (1.5.1) - #51
Merged
Conversation
The flow server's /flows/:name/run loaded the draft file directly, so every off-box caller — external webhooks, HTTP triggers, dashboard runs — executed whatever was last written to workspace/flows/<name>.json and ignored published versions entirely. Only the in-gateway flow_run tool honored them. That made "publish" meaningless for the paths customers actually trigger, and inverted the safety story the surface promises: saving a draft silently changed production while the CLI/docs said drafts aren't live. loadFlow now resolves like flow_run does — latest published version first, draft only when nothing has been published (so an unpublished flow still runs the moment it's written, and no existing trigger breaks). The resolved source is logged with the run line. startFlowServer takes the workspace explicitly; the plugin passes the same one its flow_* tools use. Test: publish v1, corrupt the draft, POST /run — 202 proves the draft was never read. Verified it fails against the old loadFlow.
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.
Problem
POST /flows/:name/runon the flow server loaded the draft file directly:No version lookup. So every off-box caller ignored published versions:
clawnifyAPIwebhooks.ts)trg_tokens)Only the in-gateway
flow_runtool honored.clawflow/versions/. Net effect:flow_publishwas a no-op for the paths customers actually trigger, and editing a draft silently changed production — the inverse of what the CLI and docs promise ("drafts aren't live until you publish").Fix
loadFlowresolves exactly likeflow_run: latest published version first, draft only when nothing is published. The fallback keeps unpublished flows working, so no existing trigger breaks.startFlowServertakesworkspaceexplicitly (defaults to$OPENCLAW_WORKSPACE→ cwd, same as before); the plugin passes the same workspace itsflow_*tools use, so the two can't drift.v3vsdraft (no published versions)).skills/clawflow/SKILL.mdstates the trigger-side rule.Test
tests/manage.test.ts— publish v1, corrupt the draft to invalid JSON,POST /run. A 202 proves the draft was never read; a 404 (old behavior) proves it was. Plus a fallback case and the existing no-flow 404.Confirmed non-vacuous: the new test fails against the old
loadFlowand passes with the fix. Full suite 173/173,tsc --noEmitclean.