Skip to content

Day 4 fix #1: Rails product-slug rename (DB collision)#9

Merged
dadachi merged 1 commit intomainfrom
feat/day4-rails-product-rename
Apr 21, 2026
Merged

Day 4 fix #1: Rails product-slug rename (DB collision)#9
dadachi merged 1 commit intomainfrom
feat/day4-rails-product-rename

Conversation

@dadachi
Copy link
Copy Markdown
Contributor

@dadachi dadachi commented Apr 21, 2026

Summary

Day-3a's rename handled the domain entities (Shop → Clinic, etc.) but left product-name references (the Nativeapptemplateapi Rails module, NativeAppTemplate brand, their flat/SCREAMING variants) untouched. Net effect: every generated project pointed at the substrate's actual dev/test databases, and my Tuesday-evening smoke probe accidentally dropped them on cleanup.

Fix

  • src/agents/workers/rails.ts — synthesize two product-rename pairs from the slug and prepend them to the planner's domain plan:
    • { from: "Nativeapptemplateapi", to: "<Slug>Api" } — scopes the Rails module, DB names, render config
    • { from: "NativeAppTemplate", to: "<Slug>" } — handles brand/URL references in settings.yml, openapi.yaml, environment configs
  • scripts/ruby/rename.rb — add flat-lowercase patterns (e.g. nativeapptemplate) that don't appear as a snake-case variant of their PascalCase source (NativeAppTemplate → snake native_app_template, flat nativeapptemplate). Flat patterns run after snake so single-word rename pairs where flat == snake (e.g. Shop/shop) can't clobber snake's replacement.

Verified

clinic-queue (adapt, 4-pair plan)

  • config/application.rbmodule ClinicQueueApi
  • config/database.ymlclinic_queue_api_development, _test, etc.
  • config/settings.ymlname: ClinicQueue, support@clinicqueue.com, com.yourdomain.clinicqueue
  • Zero leftover NativeAppTemplate / Nativeapptemplateapi / nativeapptemplate / nativeapptemplateapi tokens across .rb/.yml/.yaml

task-tracker (replace, 5-pair plan)

  • module TaskTrackerApi, task_tracker_api_development
  • Zero leftovers

Full boot + test suite

Against generated out/clinic-queue/rails, after bundle install + db:prepare:

Finished in 5.03s, 80.58 runs/s, 161.96 assertions/s.
405 runs, 814 assertions, 0 failures, 0 errors, 0 skips

Substrate databases confirmed untouched this time.

Known gap (not in this PR)

  • iOS product rename (NativeAppTemplate bundle, pbxproj app name) — symmetric Day-4 follow-up
  • Android product rename (com.nativeapptemplate.nativeapptemplatefree package) — same
  • Ruby version pin handling (substrate pins 4.0.2, user machine had 4.0.1) — I manually relaxed in the local smoke; agent-level handling is a separate Day-5 concern

Test plan

  • npm run ci — 5/5 green under stub
  • clinic-queue end-to-end — module ClinicQueueApi, clinic_queue_api_development, zero product leftovers
  • task-tracker end-to-end — same, slug-scoped
  • Full bin/rails test on generated project → 405/0/0
  • Substrate DBs preserved (not touched this run)

Day-3a's lexical rename handled the domain entities (Shop->Clinic etc.)
but left the substrate's product-name references (Nativeapptemplateapi
module, NativeAppTemplate brand) intact. Generated projects reused
the substrate's actual dev/test databases because config/database.yml
still said `nativeapptemplateapi_development`. Tue-evening probe
accidentally dropped the user's substrate DBs on cleanup.

Fix:
- src/agents/workers/rails.ts: synthesize two product-rename pairs
  from the slug and prepend them to the planner's domain plan.
  {Nativeapptemplateapi -> <Slug>Api} scopes the Rails module, DB
  names, render config. {NativeAppTemplate -> <Slug>} handles
  brand/URL references in settings/openapi/envs.
- scripts/ruby/rename.rb: add flat-lowercase patterns for tokens
  that don't re-appear in snake form (e.g. `nativeapptemplate.com`,
  `com.yourdomain.nativeapptemplate`). Runs AFTER snake so single-
  word rename pairs where flat == snake (e.g. `shop`) can't win
  over snake's replacement.

Verified on both specs:
  clinic-queue: module ClinicQueueApi, database
    clinic_queue_api_development, zero leftover
    NativeAppTemplate/nativeapptemplate/Nativeapptemplateapi tokens.
  task-tracker: module TaskTrackerApi, database
    task_tracker_api_development.

Full `bin/rails test` on generated clinic-queue project:
  405 runs, 814 assertions, 0 failures, 0 errors, 0 skips.
Substrate databases NOT touched (confirmed post-run).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dadachi dadachi merged commit 013e4b3 into main Apr 21, 2026
1 check passed
@dadachi dadachi deleted the feat/day4-rails-product-rename branch April 21, 2026 09:03
dadachi added a commit that referenced this pull request Apr 21, 2026
)

* Day 4 fix: iOS + Android product-slug rename (symmetric with Rails)

Extends PR #9's Rails fix to the mobile workers. iOS generated
project now ships with slug-scoped bundle ID + Xcode target +
product name; Android generated project ships with slug-scoped
applicationId, namespace, and Kotlin package path.

- src/slug.ts: extract slugToPascal() — pure function, used by
  all three workers' buildProductRenamePairs.
- src/agents/workers/rails.ts: import slugToPascal from ../../slug.
- src/agents/workers/ios.ts: synthesize product pairs
  {NativeAppTemplateFree -> <Slug>Free, NativeAppTemplate -> <Slug>}
  and prepend to the domain plan. `NativeAppTemplateFree` runs first
  so `com.nativeapptemplate.nativeapptemplatefree`'s longer token
  gets replaced before the shorter prefix.
- src/agents/workers/android.ts: same pair set (iOS and Android both
  have the `NativeAppTemplateFree` package suffix).

Verified on clinic-queue spec:
  iOS:
    xcodeproj: ClinicQueue.xcodeproj
    bundle: com.clinicqueue.ClinicQueueFree.ios...
    product name: ClinicQueue
    zero NativeAppTemplate / nativeapptemplate leftovers
  Android:
    namespace + applicationId: com.clinicqueue.clinicqueuefree
    package dirs: app/src/main/kotlin/com/clinicqueue/clinicqueuefree/
    zero leftovers

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Switch mobile product suffix Free -> App

"Free" was a vestige of the substrate being the MIT free edition;
the generated project has no paid counterpart so the suffix added
no information. `App` matches the standard `com.org.app` Android
package convention and reads naturally in iOS bundle IDs.

Verified on clinic-queue:
  iOS bundle: com.clinicqueue.ClinicQueueApp.ios...
  Android:    applicationId/namespace com.clinicqueue.clinicqueueapp
              package dir .../com/clinicqueue/clinicqueueapp/

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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