Summary
Bring three idiom classes in line with the project's own stated migration (see RUBY_ERGONOMICS_MIGRATION.md and .rubocop.yml):
(a) @ivar reads outside initialize → reader methods;
(b) leading-underscore "private" methods → real private/protected;
(c) ||= memoization → return @x if defined?(@x).
Where
Enumerate; line numbers drift:
- (a)
grep -nE '@[a-z_]+' lib/signalwire/agent/agent_base.rb; also relay/client.rb, relay/call.rb, and stateful skills (web_search.rb, datasphere.rb, weather_api.rb, joke.rb, wikipedia_search.rb).
- (b)
grep -rn 'def _' lib/ (e.g. in agent_base.rb, server/agent_server.rb, rest/http_client.rb).
- (c)
grep -rn '||=' lib/ (e.g. server/agent_server.rb, swml/service.rb, contexts/context_builder.rb, skills/builtin/wikipedia_search.rb).
Directive
Apply each transformation mechanically, one concern per commit (and ideally one file per commit for (a)).
For (a) add private attr_readers; leave @ivar assignments and genuinely-mutable concurrency state (mutexes/sockets/@state) alone.
For (b) make true internals private (protected for cross-instance helpers) and drop the redundant underscore.
For (c) convert to the defined? form.
Guardrails
Must not add any PUBLIC method (surface gate) or change behavior/wire output. Don't touch the get_/set_/has_ accessor names.
Acceptance
Verify
rake test · bundle exec rubocop on changed files.
Summary
Bring three idiom classes in line with the project's own stated migration (see
RUBY_ERGONOMICS_MIGRATION.mdand.rubocop.yml):(a)
@ivarreads outsideinitialize→ reader methods;(b) leading-underscore "private" methods → real
private/protected;(c)
||=memoization →return @x if defined?(@x).Where
Enumerate; line numbers drift:
grep -nE '@[a-z_]+' lib/signalwire/agent/agent_base.rb; alsorelay/client.rb,relay/call.rb, and stateful skills (web_search.rb,datasphere.rb,weather_api.rb,joke.rb,wikipedia_search.rb).grep -rn 'def _' lib/(e.g. inagent_base.rb,server/agent_server.rb,rest/http_client.rb).grep -rn '||=' lib/(e.g.server/agent_server.rb,swml/service.rb,contexts/context_builder.rb,skills/builtin/wikipedia_search.rb).Directive
Apply each transformation mechanically, one concern per commit (and ideally one file per commit for (a)).
For (a) add private
attr_readers; leave@ivarassignments and genuinely-mutable concurrency state (mutexes/sockets/@state) alone.For (b) make true internals
private(protectedfor cross-instance helpers) and drop the redundant underscore.For (c) convert to the
defined?form.Guardrails
Must not add any PUBLIC method (surface gate) or change behavior/wire output. Don't touch the
get_/set_/has_accessor names.Acceptance
@ivarreads outsideinitializein the listed files (excluding deliberate mutable state)private/protectedsuffices||=lazy-init remainsrake testgreenVerify
rake test·bundle exec rubocopon changed files.