Module: ClaudeMemory::Deprecations
- Defined in:
- lib/claude_memory/deprecations.rb
Overview
Soft-rename / soft-removal mechanism for public-API surfaces. Used to mark an old name (CLI flag, MCP tool, Ruby method, hook field, predicate) as deprecated in ‘N.x.0` releases while keeping it functional for at least one minor cycle, with explicit removal no earlier than `(N+1).0.0`. This deprecation policy is documented in `docs/api_stability.md`.
Two suppression mechanisms keep deprecation noise manageable:
-
**Per-call-site dedupe**: same (name, caller_file:line) pair only emits once per process. Prevents tight loops or repeated callers from drowning the terminal.
-
**Env var opt-out**: ‘CLAUDE_MEMORY_NO_DEPRECATIONS=1` silences everything. Recommended for test fixtures and CI runs that knowingly exercise legacy paths.
Constant Summary collapse
- ENV_OPT_OUT =
"CLAUDE_MEMORY_NO_DEPRECATIONS"
Class Method Summary collapse
-
.reset! ⇒ Object
Wipe the per-call-site dedupe state.
-
.warn(name:, replacement: nil, removed_in: nil, message: nil, caller_location: nil, output: $stderr) ⇒ Boolean
Emit a deprecation warning to ‘output` (stderr by default).
Class Method Details
.reset! ⇒ Object
Wipe the per-call-site dedupe state. Test-only — production callers should rely on the per-process behavior.
80 81 82 |
# File 'lib/claude_memory/deprecations.rb', line 80 def reset! @mutex.synchronize { @emitted.clear } end |
.warn(name:, replacement: nil, removed_in: nil, message: nil, caller_location: nil, output: $stderr) ⇒ Boolean
Emit a deprecation warning to ‘output` (stderr by default).
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/claude_memory/deprecations.rb', line 61 def warn(name:, replacement: nil, removed_in: nil, message: nil, caller_location: nil, output: $stderr) return false if suppressed? location = caller_location || derive_caller_location key = "#{name}@#{location}" @mutex.synchronize do return false if @emitted[key] @emitted[key] = true end output.puts(format_warning(name: name, replacement: replacement, removed_in: removed_in, message: , location: location)) true end |