Skip to content

fix(workflow-code): release review follow-ups for the knowledge download cap, regex hardening and skill docs - #10304

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/workflow-code-release-review
Nov 22, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/workflow-code-release-review

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Follow-ups for the review threads on #10299 that cover workflows-as-code code.

Fixed

  • Knowledge download cap (cubic): GET /api/v2/knowledge/{kb}/documents/{doc}/content inherited the 25 MiB text-extraction cap, so originals between 25 and 100 MiB answered 413. The route now passes MAX_KNOWLEDGE_DOCUMENT_FILE_SIZE (100 MiB, the stored-document limit and the shared buffered-read ceiling). readOriginalKnowledgeDocument accepts up to that limit but keeps the 25 MiB default, which the parsing caller (files read in the agent CLI) relies on.
  • Skill docs (cubic ×2): add-column-type now names apps/sim/lib/workspace-source/.../codec.test.ts and valueType(). The same stale columnType() in .claude/rules/sim-workflow-code.md is fixed, and the Cursor projection was regenerated.
  • Polynomial regexes (CodeQL ×3): all three were quadratic in Node, shown with timing repros.
    • filterForms (sim-cli): trailing slashes are now stripped with stripTrailingSlashes.
    • splitVerb (workflow-code): matches /^[a-z]*/ and slices the rest, where the old /^([a-z]+)(.*)$/ failed on a newline.
    • referencedBuilders (workflow-sdk): matches the dotted chain greedily and then checks for ( with a sticky regex. The old \s*\( tail made every character of a call-less chain a retry point, so a long string literal in a workflow file cost seconds to minutes.
    • Output is identical to the old regex: fuzzed over 300k random sources, in Bun and Node.
  • Regex injection (CodeQL): the name is now escaped with escapeRegExp. The name is always an SDK core export or special builder, so this was not exploitable; escaping just makes the pattern literal by construction.

Declined

  • bun.lock in the publish trigger (cubic): recorded in the workflow comment. 10 of the last 100 staging merges touched the lockfile, and almost none of those moved a package the CLI bundles. Watched packages change about 5 times a day, so a bundle-relevant lock bump ships with the next one anyway. An audit runs on PRs and can only fail them; it cannot cause a publish.
  • Biased crypto random (CodeQL): a false positive. backoffWithJitter already supplies the jitter, and the flagged division and rounding is Math.ceil(waitMs / 1000) in a stderr notice.

Tests

  • The three regex fixes have expectLinearGrowth cases in sim-cli/.../source-status.test.ts, workflow-code/.../compile/scaling.test.ts and workflow-sdk/.../codegen/generate.test.ts. On the pre-fix code they fail at 55x–66x growth against a 20x bound.
  • apps/sim/lib/knowledge/__integration__/original-download.integration.ts runs the real route with a real workspace API key, Postgres and storage. It serves a 26 MiB original byte-for-byte, and still answers 413 past 100 MiB. On the pre-fix code it fails: reverting the route gives 413, reverting the use case gives 400.
  • sim-cli and workflow-sdk now depend on @sim/testing. That brings sim-cli under check:test-patterns, so four sim-cli tests now use its jsonResponse and utils-helpers mock instead of local copies.

Follow-up: the download still buffers the whole original. Streaming it through downloadFileStream would bound memory per request.

…oad cap, regex hardening and skill docs

- v2 knowledge document download serves originals up to the 100 MiB stored-document
  limit instead of the 25 MiB text-extraction cap; parsing reads keep the 25 MiB default
- rewrite three polynomial-backtracking regexes linearly: the CLI path filter's trailing
  slashes (stripTrailingSlashes), suggestBuilder's verb split, and referencedBuilders'
  call scan (the `(` is checked after a greedy chain match)
- escape the core declaration name interpolated into a RegExp
- add-column-type skill and workflow-code rule: apps/sim/ path prefix, valueType() name
- record why publish-sim-cli does not watch bun.lock
- sim-cli and workflow-sdk depend on @sim/testing for expectLinearGrowth; sim-cli tests
  adopt its jsonResponse helper and utils-helpers mock
@waleedlatif1
waleedlatif1 requested a review from a team as a code owner November 22, 2026 11:22
@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
docs Ready Ready Preview Nov 22, 2026 11:26am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge, with no actionable issues found.

Summary

This PR lets raw knowledge-document downloads use the 100 MiB stored-file limit while keeping the lower default for parsing reads.

  • Knowledge downloads can return originals up to 100 MiB.
  • Sim CLI path filters handle long slash runs without repeated regex work.
  • Workflow compiler hints split long unknown method names without regex backtracking.
  • Workflow SDK source scans find builder calls without retrying through long names.
  • Workflow SDK declaration lookups treat export names as literal text.
  • Workflow-code guidance and CLI tests use current names and shared helpers.

Explicitly acknowledged by waleedlatif1:

  • Whole-original buffering remains deferred; streaming would bound memory per request.
  • Omitting bun.lock from publish triggers is intentional; relevant lockfile changes ship with the next watched-package change.
  • The flagged random-number calculation is intentional: backoffWithJitter supplies jitter, while Math.ceil(waitMs / 1000) formats a notice.

Reviews (1) · Last reviewed commit: "fix(workflow-code): release review follo..." · 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.

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

@waleedlatif1
waleedlatif1 merged commit cdac23d into staging Nov 22, 2026
164 of 166 checks passed

This branch was successfully deployed

1 active deployment
Preview — 38ec675d Deployed Nov 22, 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