Skip to content

fix(workflow-code): json-text input mappings, wiring beside blocks, source find - #10442

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/workflow-code-large-workflows
Nov 26, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/workflow-code-large-workflows

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes a bug where large or API-built workflows failed the source check after an edit, and makes large workflow sources easier to navigate. A benchmark of a 192-block workflow found both problems.

1. JSON-text inputMapping broke check/apply after any edit (bug)

  • A Workflow block's inputMapping stored as JSON text (operations apply stores a string as given) printed as t`{...}`. That fails TS2322 against InputMapping.
  • An untouched directory passed source check only because check deliberately ignores type errors a file already had when get wrote it. That suppression is right: the declarations can lag the stored workflow. But one edit anywhere in workflow.ts surfaced the error on the untouched line.
  • Root cause is the print, so the suppression stays.
  • Canonicalize now decodes JSON text in the field types whose runtime parses both forms: input-mapping and workflow-input-mapper, listed once as JSON_TEXT_CONTAINER_TYPES. The workflow handler and tool runners parseJSON a string mapping. Materialize keeps the stored text encoding, and text that is not JSON (a whole-mapping reference) stays text with no warning.
  • Sweep: other container fields stored as text are left as stored, because their runtime reads only one form. Examples: agent messages stored as text in a landing template, and a Jina checkbox list's readUrlOptions (the serializer reads only native objects). Decoding those would change what runs, so they keep their KNOWN_UNTYPED entries.
  • The corpus KNOWN_UNTYPED entry :workflow_input: ("an input mapping stored as JSON text") is removed, and the full corpus type-check passes without it.
  • Lockless parity (O2): a workflow created from source stores the mapping natively. Deploy-change detection (canonicalizeSubBlockValue) treats the two encodings as one value for the same field types only. Every other field compares as stored, which lib/workflows/canonical/json-text-encoding.test.ts pins in both directions. The diff view still shows encoding changes.
  • A stored workflow with a JSON-text input mapping fingerprints differently once (its canonical form now holds the object), so an existing checkout of such a workflow reads stale once.

2. Wiring printed beside its blocks
Each .to() / .onError() statement now prints right under the last-declared block it names, instead of in one section at the end of the scope. Compile accepts statements in any order, so only the layout changes. Measured on the benchmark sources, reprinted with the old and new printer through the same pipeline:

workflow blocks median lines to read one block + its edges (old → new) p90 (old → new) file lines (old → new)
task6 signup-intake 4 18.5 → 12 23 → 15 38 → 37
task5 13 27 → 9 51 → 24 74 → 73
task3 31 69 → 16 150 → 30 230 → 227
k3 62 230 → 14 360 → 48 475 → 473
task8 (192-block hub) 200 802 → 15 1336 → 49 1652 → 1650
k19 302 1238 → 15 2012 → 48 2491 → 2489
  • Only one block gets worse: the 13-way Route Category condition, whose branch statements now sit under each branch head (window 1404 → 1447 at 192 blocks, 2152 → 2292 at 297).
  • Edit diffs on the 192-block source (rename, param change, add an error path, insert a block) are the same size or smaller. Adding an error path goes from 2 hunks to 1.
  • All 13 fixtures reprint idempotently.
  • The goldens are regenerated. A new locality test fails on the old printer.
  • Two integration tests (apply-workflow-source.integration.ts) edited printed wiring text assuming the old layout. Their edits now follow the interleaved layout; the expectations are unchanged.

Options considered and rejected:

  • A name → line index header: every insertion rewrites every later entry, which hurts diff stability.
  • Per-branch files: a large format change for the same gain.

3. sim workflows source find <block>

  • Offline, from the directory alone.
  • Prints the block's declaration with line numbers, its function file, its incoming and outgoing wiring as file:line, and every block that reads its outputs.
  • Each edge is reported at its own wiring statement, using the new CompileResult.edgeSpans.
  • Function-file references are read the way compile reads them: the shared codeFileRefs combines parsed chains with stored tags, in the file's own language.
  • Takes a name, key or identifier. A partial name prints every match (at most 20). An unknown name suggests the closest.
  • Documented in .sim/AGENTS.md, the coding-agents doc and the generated CLI reference. The docs compatibility baseline takes the new CLI reference code examples.

4. operations apply 200-operation cap

  • The cap is deliberate: it bounds one request, one transaction and the report an atomic batch writes.
  • The error now says how to split the edit: batches applied in turn, atomic covers one batch, and later batches name new blocks by the ids in mintedBlockIds.
  • The ticket-audit-2 key after seed8.sh --force is correct dedup, not a bug. Key allocation on read never reuses a key still bound to an archived workflow, so a restore keeps its key and an old source's childWorkflow('ticket-audit') is never silently pointed at a different workflow. A source that declares the key rebinds it on purpose (claimResourceKey). table('accounts-2') is the same case.

Not done: workflows outline --block/--match for the regular arm. It needs a v2 contract change and regenerated CLI artifacts, so it is not cheap.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Red → green:
    • api-built-source.test.ts: the printed source of an operations-stored JSON-text mapping type-checks after an edit, and the edited mapping is stored as text. It fails with TS2322 on the old canonicalize. The encoding assertion fails if materialize writes the object.
    • json-text-encoding.test.ts: deploy-change detection reports a checkbox list moving between text and object, and not an input mapping.
    • print/scaling.test.ts: a locality test that fails on the old printer.
    • workflow-source-find.test.ts: per-edge lines, and Python and JS-tag readers; it fails on the previous head.
  • The full corpus type-check passes without the workflow_input exemption. The round-trip corpus (P0–P7, O1–O3) passes. apply-workflow-source.integration.ts passes locally (92 tests).
  • Local gate: bun run generate, lint, type-check, check:audits, the block registry check, the affected unit suites, and docs compatibility.
  • Reviewers: focus on canonicalize/params.ts (which fields decode) and the canonicalizeSubBlockValue change.

Mothership impact: none in generated catalogs. The printed layout of every workflow changes once on its next print, and .sim/AGENTS.md lists source find.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…de its blocks, add source find

- A Workflow block's inputMapping (and any native object/list field) stored as JSON text by the
  operations route printed as a t`` template that never type-checks; an untouched directory
  passed only because check suppresses errors in files still as get wrote them. Canonicalize
  now decodes the container and materialize keeps the stored text encoding. Deploy-change
  detection treats the two encodings as one value.
- The printer emits each wiring statement under the last-declared block it names, so a block's
  edges sit next to it instead of ~1000 lines away in a 192-block workflow.
- New `sim workflows source find <block>`: a block's code with line numbers, function file,
  incoming/outgoing wiring and readers, offline.
- The operations batch cap error says how to split a larger edit.
@vercel

vercel Bot commented Nov 26, 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 26, 2026 8:44pm UTC

Request Review

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

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

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; the three previously reported problems are fixed.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the three previously reported problems are fixed.

Summary

The PR fixes JSON-text input mappings, moves printed wiring beside block declarations, adds offline source find, and clarifies how to split large operation batches.

The latest changes address all three previous review threads:

  • JSON-text input mappings stay typeable after a source edit.
  • Workflow wiring now sits beside the blocks it connects.
  • The CLI finds a block and its connections from a workflow directory.
  • Oversized operations batches explain how to split an edit.

No new actionable issues or repository-rule violations were found. Tests were inspected but not rerun.

Reviews (2) · Last reviewed commit: "fix(workflow-code): exact JSON-text equi..." · Reviewed by Greptile

…ons, layout-aware tests

- Decode JSON text, and treat it as unchanged in deploy-change detection, only for
  input-mapping fields, whose runtime parses both forms (JSON_TEXT_CONTAINER_TYPES). Other
  container fields such as a checkbox list compare as stored again.
- Compile records where each edge is written (edgeSpans), and `source find` reports every
  edge at its own statement.
- `source find` reads function-file references the way compile does (codeFileRefs: parsed
  chains plus stored tags) in the file's own language.
- Integration edits follow the interleaved wiring layout; docs baseline takes the new CLI
  reference code examples.
@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 Nov 26, 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 53 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 successfully deployed

1 active deployment
Preview — b1f4fbb8 Deployed Nov 26, 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