Skip to content

fix(workflow-code): leave out stored edges every save drops, so get then apply is a no-op - #10563

Open
waleedlatif1 wants to merge 4 commits into
stagingfrom
fix/wac-stored-structural-edges
Open

waleedlatif1 wants to merge 4 commits into
stagingfrom
fix/wac-stored-structural-edges

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

An unchanged source get → source apply no longer refuses a workflow because it stores an edge that every save already drops.

  • What changed: canonicalize now leaves out the three kinds of stored edge that validateEdges (run by prepareWorkflowStateForPersistence on every save, and by the editor and realtime) drops:

    • an edge into a trigger block, including the legacy starter
    • an edge from or to a note
    • an edge that crosses a loop or parallel boundary

    Each one gets a W_CANON_EDGE_DROPPED warning that names its kind. Before this change, compile refused them (E_TARGET_TRIGGER, E_EDGE_NOTE, E_CANON_EDGE_SCOPE), so the code path refused workflows the editor saves without complaint.

  • What source get returns: it no longer prints these edges and returns the warning, so an unchanged apply diffs as a no-op and writes nothing.

  • What an apply that does write does: it repeats the warning and counts the edge in diff.edges.removed, because the save drops it.

  • A new edge of these kinds written in source is still refused with the same E_* code.

  • One shared rule: getWorkflowEdgeDropKind in @sim/workflow-types now holds it. validateEdges and canonicalize both use it, so they can't drift apart.

    • Compile's trigger check used to miss the legacy starter, so an edge into it compiled and was then dropped silently on save.
  • Locked blocks: the stored-graph comparisons in the apply gates (findLockedBlockRefusals) and in assertLockedBlocksPreserved now use the saved edge set.

    • Before, a no-op touching a locked block was refused.
    • Before, a write whose dropped edge pointed into a locked block returned a 500.
  • Empty branch lists: a Condition or Router that stores an empty branch list ([] or '[]') keeps it through an unchanged apply. Compile used to write null over it. This case used to be hidden behind the refusal.

  • Code removed: E_CANON_EDGE_SCOPE. The docs (SYNTAX.md, diagnostics and syntax pages) and the OpenAPI document are regenerated.

Type of Change

  • Bug fix

Testing

  • Corpus:
    • generateDroppedEdgeCorpus (replaces the rejected-edge corpus) covers a loop child's error edge leaving the loop, an edge into Start, an edge into the legacy starter, and an edge out of a note.
    • For each case, the stored edge produces a warning, no errors, a no-op diff, and a written state equal to the stored state minus that edge. All of these failed before the change.
    • The same edge written anew in source is still the E_* code. Before the change this already held for every case except starter.
  • New stored-shapes cases for an empty branch list on condition and router_v2, stored as [] and as '[]'. All four failed P0/P1/P2/P6/P7 before the fix.
  • Integration, against real Postgres:
    • An unchanged apply of a workflow whose edge goes into a locked trigger is a no-op.
    • An apply that writes reports the removed edge.
    • Each guard was reverted on its own (gates.ts, source-commit.ts, finalize.ts, canonicalize/edges.ts), and its test then failed.
  • The round-trip property check (P0–P7, O1–O3, plus create and reapply) passes over a broad sample of existing workflow shapes:
    • Unchanged-apply refusals drop from about 2.2% to about 0.01%.
    • No property that passed before now fails, apart from two cases where a loop prints its declarations in a different order (cosmetic, already present before).
  • workflow-code 835, workspace-code 164 and sim-cli 1353 tests pass. The apps/sim lib/workflows/{code,application,editing,persistence}, stores/workflows and lib/workspace-source suites pass (1200 tests).
  • bun run generate, type-check, lint:check and check:api-validation:strict pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes

…hen apply is a no-op

Stored edges into a trigger, to or from a note, or across a loop or parallel
boundary made an unchanged source get then apply refuse (E_TARGET_TRIGGER,
E_EDGE_NOTE, E_EDGE_SCOPE), though every save already drops them
(validateEdges in prepareWorkflowStateForPersistence).

- One rule for both: getWorkflowEdgeDropKind in @sim/workflow-types, called by
  validateEdges and by canonicalize. Canonicalize now leaves these edges out
  with W_CANON_EDGE_DROPPED (replacing E_CANON_EDGE_SCOPE), so get never prints
  them and an unchanged apply is a true no-op that writes nothing.
- Compile's trigger check matches persistence (legacy starter included); a new
  edge of these kinds written in source is still refused.
- Apply gates and the locked-block assert judge the stored graph as a save
  keeps it, so a dropped edge next to a locked block neither refuses a no-op
  nor fails the commit.
- An apply that writes counts the edges the save removes in diff.edges.removed
  and repeats the warning.
- generateRejectedCorpus becomes generateDroppedEdgeCorpus: each kind, stored
  (warning, no refusal, no-op, written state) and written anew (still E_*).
…ged apply

A condition or router storing an empty branch list ([] or '[]') printed with
no entries, compiled to rows: null and materialized null over the stored list,
so an unchanged get then apply wrote. Compile now keeps the stored empty list
when the source writes no entries for a block that continues one. Registry
corpus gains empty-list and empty-list-text branch cases for both blocks.
@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Dec 1, 2026 9:42am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; the protected-block merge no longer restores dropped connections.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the protected-block merge no longer restores dropped connections.

Summary

The PR leaves out stored connections that every save drops, so unchanged source can apply without changing the workflow.

  • Workflow source leaves out stored edges that every save drops.
  • Unchanged Condition and Router blocks keep their empty branch lists.

No new actionable issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Stored[Stored graph] --> Filter[Remove edges a save drops]
  Filter --> Merge[Keep protected blocks and valid connections]
  Submitted[Submitted graph] --> Merge
  Merge --> Prepare[Prepare the final graph]
  Prepare --> Save[Save]
Loading

Reviews (2) · Last reviewed commit: "fix(workflows): keep the protected-block..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 20 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

… every save drops

A write that moved a block into the scope of a locked block could bring back a stored edge every save drops: the protected-block merge restored it from the unfiltered stored graph, and once both ends shared a scope the save kept it. The merge now starts from the stored edges a save keeps.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 21 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

This branch was previously deployed

1 inactive deployment
Preview — 4dc02b5d Deployed Dec 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant