Skip to content

fix: generated workflows now typecheck, and --all runs - #45

Merged
arnaub merged 1 commit into
mainfrom
fix/workflow-generator-override
Sep 2, 2026
Merged

arnaub merged 1 commit into
mainfrom
fix/workflow-generator-override

Conversation

@arnaub

@arnaub arnaub commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Two bugs in the workflow generator, both introduced or exposed by #44.

1. Generated classes did not typecheck

#44 added include Ai::Workflow to the template but left the call sig without override..
Sorbet rejects an implementation of an abstract method that does not declare it, so every
regenerated class failed in the consumer:

Method `Ai::Workflows::…#call` implements an abstract method
`Ai::Workflow::ClassMethods#call` but is not declared with `override.`   Sorbet 5051

override. is not decoration — it is what makes Sorbet verify the signature is a legal
implementation of the abstract method.

2. --all never worked

workflow_names = workflow_names   # assigns the nil local to itself
if workflow_names.empty?          # undefined method `empty?' for nil

Ruby binds the local as soon as it parses the assignment, so the right-hand side resolves to
the local being defined, not to #workflow_names. The local is renamed to names.

Only --name worked before, which is why this went unnoticed — the existing generated classes
were all produced one at a time.

Tests

Five examples covering both. Each was verified to fail with its fix reverted. The template
assertions also pin the include and the header forwarding, so a future template edit cannot
quietly drop them again.

Note for anyone extending these specs: generate_all_workflows calls exit 1 when a
workflow fails. Driving the whole method under test tears down the RSpec process and silently
truncates the run — it looked like passing tests with examples missing. Test the pieces instead.
That exit 1 is worth revisiting separately; a generator that kills its caller is hard to use
from anything but a terminal.

Checks

rspec 111 examples, 0 failures. rubocop 40 files, no offenses. srb tc no errors.
Version 0.8.0 → 0.8.1.

Two bugs in the workflow generator, both introduced or exposed by #44.

The template gained `include Ai::Workflow` but its `call` sig did not say
`override.`. Sorbet rejects an implementation of an abstract method
without it, so every regenerated class failed to typecheck in the
consumer with error 5051. `override.` is not decoration: it is what makes
Sorbet verify the signature is a legal implementation.

`generate_all_workflows` read `workflow_names = workflow_names`. Ruby
binds the local as soon as it parses the assignment, so the right-hand
side resolved to the nil local being defined rather than to the method,
and `--all` always died with "undefined method `empty?' for nil". The
local is renamed. Only `--name` worked before, which is why this went
unnoticed.

Specs cover both, and assert the template keeps the include, the
override and the header forwarding.

Note for anyone extending these specs: `generate_all_workflows` calls
`exit 1` when a workflow fails, which tears down the RSpec process and
silently truncates the run. Test the pieces, not the whole method.
@arnaub
arnaub requested a review from a team as a code owner September 2, 2026 12:36
@arnaub
arnaub merged commit c3f8d65 into main Sep 2, 2026
1 check passed
@arnaub
arnaub deleted the fix/workflow-generator-override branch September 2, 2026 14:17
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.

2 participants