Skip to content

fix(planner): sync entity names when --rename overrides a target#82

Merged
dadachi merged 1 commit into
mainfrom
fix/rename-override-entity-sync
May 22, 2026
Merged

fix(planner): sync entity names when --rename overrides a target#82
dadachi merged 1 commit into
mainfrom
fix/rename-override-entity-sync

Conversation

@dadachi
Copy link
Copy Markdown
Contributor

@dadachi dadachi commented May 22, 2026

What

Follow-up to #81. When --rename overrode a planner target, the validation report contradicted itself: the rename plan correctly showed Shopkeeper → Resident, but the entity card still read "Monitor (replaces Shopkeeper)".

Cause: the override updated domain.renamePlan but not domain.entities[].name. The planner names each entity after its rename target (it emits both Shopkeeper → Monitor and an entity Monitor that replaces Shopkeeper), so changing only the plan desynced the two.

How

New pure syncEntityNames(entities, outcomes) in src/rename-overrides.ts: for each changed outcome, rename any entity whose replaces matches the override's source and whose name still equals the planner's old target. An entity deliberately named differently is left alone (conservative). Wired into dispatch() right after applyRenameOverrides.

before:  rename plan: Shopkeeper → Resident   entity card: Monitor (replaces Shopkeeper)
after:   rename plan: Shopkeeper → Resident   entity card: Resident (replaces Shopkeeper)

Scope: report-metadata coherence only. Code generation keys off renamePlan, not entities — so generated code was already correct. Verified on a real sentova run: 108 files use the override target (Resident), zero use the planner's old Monitor (the 37 "Monitor" hits were all unrelated vendor/bundle gem code).

Testing

  • npm run build clean; npm run test70/70 (2 new: rename, divergent-name left-alone, no-op outcomes, no-match).

Not included

  • Pre-existing brand-token leak in 3 non-source asset/config files (site.webmanifest, social-preview.svg, .swiftformat) — separate, older rename.rb-scope gap, deferred.

🤖 Generated with Claude Code

The planner names each entity after its rename target (it emits both
`Shopkeeper -> Monitor` and an entity `Monitor` that replaces Shopkeeper).
A --rename override updated renamePlan but not domain.entities[].name, so
the validation report contradicted itself — rename plan showed
`Shopkeeper -> Resident` while the entity card still read
"Monitor (replaces Shopkeeper)".

Add syncEntityNames(): for each "changed" override outcome, rename any
entity whose `replaces` matches the override's source AND whose name still
equals the planner's old target (an entity deliberately named differently
is left alone). Wired into dispatch right after applyRenameOverrides.

Report-metadata coherence only — code generation keys off renamePlan, not
entities, so generated code was already correct (verified on a real
sentova run: 108 files use the override target, zero use the old one).

- src/rename-overrides.ts: syncEntityNames (pure)
- src/dispatch.ts: call it alongside the renamePlan override
- tests: 2 new covering rename, divergent-name, no-op, and no-match

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dadachi dadachi merged commit 2649617 into main May 22, 2026
1 check passed
@dadachi dadachi deleted the fix/rename-override-entity-sync branch May 22, 2026 23:34
@dadachi dadachi mentioned this pull request May 23, 2026
dadachi added a commit that referenced this pull request May 23, 2026
Cut a release so the naming-override work reaches npx users — the
registry still serves pre-flag 0.1.2.

Since 0.1.2:
- feat: --rename From=To and --slug=<kebab> naming overrides (CLI + MCP) (#81)
- fix: sync entity names when --rename overrides a target (#82)
- fix: rename scope covers .webmanifest / .svg / .swiftformat (#83)
- fix: rename skips compiled build output (app/assets/builds, public/assets) (#84)

Minor bump: additive features, no breaking changes. Verified the
tarball ships scripts/ruby/rename.rb + dist/ via `npm pack --dry-run`.

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