Day 3a: Rails worker — real substrate copy + Ruby AST rename#6
Merged
Conversation
- scripts/ruby/rename.rb: takes a rename plan + root on stdin, rewrites
file contents AND renames files/dirs for PascalCase / snake_case /
plural / SCREAMING variants. Uses a letter-aware boundary
`(?<![A-Za-z])...(?![A-Za-z])` instead of \\b because Ruby treats `_`
as a word char and \\b misses inside snake_case.
- src/ruby.ts: thin execFile wrapper per CLAUDE.md convention; JSON on
stdin/stdout, propagates non-zero exit codes with stderr tail.
- src/agents/workers/rails.ts: substrate -> ./out/<slug>/rails via
fs.cp with recursive filter (skips .git, node_modules, tmp, log,
vendor/bundle, sockets/FIFOs); invokes rename.rb; runs
`git init -q -b main` on the result. isStub("rails") gates the
existing stub path for CI.
Verified against walk-in clinic queue spec (stub planner for
determinism): 305 files scanned, 125 changed, 2220 substitutions,
49 file/dir renames. ruby -c confirms syntax validity on renamed
models; routes.rb, migrations, controllers, policies, serializers
all rename coherently. No leftover Shop/Shopkeeper tokens.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/agents/workers/rails.ts— real implementation: copy\$NATEMPLATE_API→./out/<slug>/rails(filtered: no.git,node_modules,tmp,log,vendor/bundle, sockets/FIFOs), invokerename.rb, rungit init -q -b main. Stub path preserved behindisStub("rails").scripts/ruby/rename.rb— takes{renamePlan, root}on stdin, rewrites file contents AND renames paths (deepest-first) for PascalCase / snake_case / plural / SCREAMING variants.src/ruby.ts— thinexecFilewrapper per CLAUDE.md convention; JSON on stdin/stdout, propagates non-zero exit codes with stderr tail.Tricky bit worth flagging
Ruby's
\btreats_as a word char, so\bshops\bsilently fails to match insideshops_controlleroraccounts_shopkeeper. First attempt left 10+ files unrenamed. Fix: letter-aware boundary(?<![A-Za-z])...(?![A-Za-z])— treats_,., digits, punctuation as boundaries; only letters block a match. After the fix, 2220 substitutions vs 1334 before.Verified against clinic-queue (stub planner for determinism)
Shop/Shopkeepertokensruby -con renamed modelschange_vet_foreign_keys_to_nullify_on_delete.rb/class ChangeVetForeignKeysToNullifyOnDelete)config/routes.rbresources :clinics,namespace :vet_auth,accounts_vetsWhat this doesn't do (deferred)
bin/devboot verification — that's Layer 2 (Day 5 morning).acts_as_tenant/devise_token_authdeeper semantic edits — rename is complete; any missing wiring surfaces when Day 5 Layer 2 boots the server.Test plan
npm run ci— green (stub path still used in tests underNATEMPLATE_STUB_ALL=1)NATEMPLATE_STUB_PLANNER=1 npm run dev -- "a walk-in clinic queue..."— real copy + rename runs, no errorsgrep -rln '\\bshop\\|\\bshopkeeper\\|shops_\\|shopkeepers_' out/clinic-queue/railsreturns emptyruby -con 3 renamed model files — all Syntax OKbin/devboot — deferred to Day 5 Layer 2 validation