Repository navigation
Freeze era definition structs - #27
Conversation
The containing arrays were frozen but the Era structs inside were not, so a caller mutating an era returned by find_era or ERA_BY_NAME could corrupt process-wide state. Freeze them at definition time; this covers every lookup path without per-call copies. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q1Pf4Mrtd7zB8Lrjc499t9
There was a problem hiding this comment.
Code Review
This pull request ensures that era definitions and individual Era objects are frozen to prevent unintended modifications. Specifically, it freezes the Era instances assigned to ERA_BY_NAME in lib/wareki/common.rb, freezes each Era object inside the definition arrays in lib/wareki/era_def.rb, and adds a unit test in spec/utils_spec.rb to verify that these definitions are indeed frozen. There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Summary
Follow-up to a Copilot review comment on #24: the
ERA_DEFS/ERA_NORTH_DEFSarrays were frozen but theErastructs inside were not, so a caller mutating an era returned byUtils.find_eraorERA_BY_NAMEcould corrupt process-wide era definitions. This freezes the structs at definition time (including the ad-hoc 皇紀/西暦 entries), which covers every lookup path without adding per-call copies on the conversion hot path.The
ERA_JD_LOOKUPbuilder keeps working as-is since itdups entries before adjusting them (dupof a frozen struct is unfrozen); this also stays correct if #24 (which removes that builder) merges in either order.Test plan
find_eraresults are frozen, confirmed failing firstbundle exec rspec: 66 examples, 0 failures; RuboCop: no offenses🤖 Generated with Claude Code
https://claude.ai/code/session_01Q1Pf4Mrtd7zB8Lrjc499t9