Skip to content

fix(workflow-code): bound lock parsing and rename inference, and close check/server parity gaps - #10285

Merged
waleedlatif1 merged 29 commits into
stagingfrom
fix/workflow-code-qa6-perf
Nov 21, 2026
Merged

waleedlatif1 merged 29 commits into
stagingfrom
fix/workflow-code-qa6-perf

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

What

Fixes from the QA6 compiler and server review of workflows as code:

  • Lock parsing. Parent cycles are now found in linear time. A lock may hold at most SOURCE_LIMITS.maxBlocks blocks and variables, enforced in both parseWorkflowLock (E_LOCK_SHAPE, checked before reading) and the contract schema.
  • Rename inference (identity rule 4). Referrers are computed once and edges are indexed by endpoint. Candidate pairs come from settings, neighbour-prefix and reference indexes instead of comparing every pair. A new block stops at its second signal, and rivals are checked only for blocks that would pair.
  • Lazy hints. A W_ENV_UNKNOWN, former-block W_UNRESOLVED_REF or E_UNKNOWN_VARIABLE past the warning caps no longer computes its did-you-mean.
  • Check/server parity:
    • A literal <name.path> whose head names no block (and no renamed block) is now W_UNRESOLVED_REF. On a changed block it is refused as E_APPLY_UNRESOLVED_REF, as the server lint refuses it.
    • A new block() of an uncatalogued type gets the new W_UNKNOWN_BLOCK_TYPE, refused as E_APPLY_INVALID_BLOCK_TYPE. A block the stored workflow or lock already holds stays quiet.
  • Identity. A swap of two consts is the same edit as a swap of two display names, which the apply already treats as two renames, so the blocks keep following their idents. DESIGN.md rule 2 and lockIdentRenames now document this, along with the compile-side gap.
  • Variables. An apply keeps the stored order of the Variables panel.
  • Shared helper. There is now one canonicalJson, in @sim/utils/object, used by table cells and cursor binding.
  • Workspace source:
    • Managed table rows stop reading once the printable rows pass maxRowsBytes.
    • A deployment-kind plan reads deployment state only for keys the directory declares or the base records. A get reads deployments at concurrency 4 through readMany.

Why

A single apply or dry run could stall the app server's event loop for seconds to hours, and offline check passed things the server refuses.

Evidence (before → after)

Case Before After
Rename inference, 200 blocks, 20 refs each 103 s 5 ms
Rename inference, 2,000 blocks, 20 refs each hours 47–102 ms
Rename inference, 2,000 blocks off one shared hub (cubic) 56 ms
Former-block hints, 1,960 blocks, 78k dangling refs 1.9 s 174 ms
Lock parse, chained 20k blocks: 33 s capped at 2,000; linear

Tests

Each regression test below fails on the pre-fix code. The one marked as a guard covers the new candidate search, which staging does not have:

  • Scaling tests (expectLinearGrowth), with growth from n to 8n on the old code (the bound is 20x):
    • lock parent chain: 39.9x
    • rename inference with no signal: 494.8x
    • rename inference pairing by references: 481.6x
    • rename inference on a shared hub: 68.1x
    • env did-you-mean: 64.6x
    • former-block hint: 43.0x
  • Behaviour tests:
    • lock cap (parser and contract)
    • literal-tag refusal
    • uncatalogued-type refusal
    • a rename still pairs by its references when a referrer also names no block (a guard on the new candidate search)
    • variable order
  • Integration tests (real Postgres):
    • the rows byte cap skips the table with its own reason
    • a deployment plan reads only the declared workflow, where it used to read all 4
    • a dangling tag on a changed block is refused at compile as E_APPLY_UNRESOLVED_REF. The existing lint test is updated to match, since the server's E_APPLY_LINT no longer has to catch it.

🤖 Generated with Claude Code

… a literal tag naming no block

A capped W_ENV_UNKNOWN or former-block W_UNRESOLVED_REF no longer computes its hint. A literal
<name.path> whose head names no block (and no renamed block) is W_UNRESOLVED_REF, refused on a
changed block as E_APPLY_UNRESOLVED_REF, matching the server lint's E_APPLY_LINT.
…ay-name swap

The swap of two consts is the same edit as a swap of two display names, which the apply
intends as two renames (apply-workflow-source.integration.ts). Document the rule and the
compile-side gap instead.
@vercel

vercel Bot commented Nov 21, 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 Nov 21, 2026 11:09am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues remain from this review.

Summary

The PR bounds lock parsing and rename inference, brings offline checks closer to server checks, and limits workspace reads.

  • Workflow source checks cap lock sizes and narrow costly searches.
  • Offline checks now flag references and block types apply cannot accept.
  • Workflow edits keep block identities and variable order stable.
  • Workspace source reads deployment settings only for needed workflows.
  • Workspace source stops reading managed rows past its byte limit.
  • Table cells and cursor binding now share one canonical JSON helper.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Save table edit] --> B[Read saved rows]
  B --> C{Rows exceed a limit?}
  C -->|No| D[Return saved rows and fresh base]
  C -->|Yes| E[Keep submitted rows and prior rows base]
  E --> F[Return success with warning]
Loading

Reviews (4) · Last reviewed commit: "test(workspace-source): a table edit who..." · Reviewed by Greptile

Comment thread packages/workflow-code/src/lock.ts Resolved

@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 36 files

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

Turn on auto-fix | Re-trigger cubic

Comment thread packages/utils/src/object.ts Resolved
… of the blocks lacking it, not a scan of every block
…nly for existing blocks, refused on an edit as the placement gate refuses it
…mpile, the get check and the lock, so a returned lock always applies back
…ompile, and share pushTo and strings from records
…tays below the cap

At the cap the linear walk measured 11x against the quadratic walk's 42x; at 64 to 512 blocks, 9x against 57x.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

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

…qa6-perf

# Conflicts:
#	packages/workflow-code/src/compile/scaling.test.ts

@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 48 files

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

Turn on auto-fix | Re-trigger cubic

Comment thread packages/workflow-code/src/lock.ts Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

@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 48 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

…ows pass the source limits as saved

After a table update commits, reading its managed rows back could pass the row or byte cap and
fail the apply, leaving the caller on the old base though the edit was saved. The write now
reprints the rows file as the directory declared it, keeps the base's rows entry, and warns
(W_SERVER_CHANGED) that the rows were not read back.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

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

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

@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 49 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

@waleedlatif1
waleedlatif1 merged commit 93555ff into staging Nov 21, 2026
95 checks passed

This branch was previously deployed

1 inactive deployment
Preview — 83618459 Deployed Nov 21, 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