os-adr: Repository owns the ADR file-name rule and Adr.slugify #934

Open
opened 2026-10-04 17:14:34 +00:00 by jared · 1 comment
Owner

Problem

Adr.slugify still lives on the namespace root in the loader file plugins/os-adr/lib/adr.rb, while the file-name rule "#{id}-#{Adr.slugify(title)}.md" lives in Adr::Repository#path_for (plugins/os-adr/lib/adr/repository.rb:96). The duplicate copy in the record creator is gone: plugins/os-adr/lib/adr/record/creation.rb:54 already calls @repository.path_for. What remains is the slug rule sitting in the loader file instead of with its only owner.

Approach

Adr::Repository (plugins/os-adr/lib/adr/repository.rb) owns the slug rule.

Required work:

  1. Move Adr.slugify out of plugins/os-adr/lib/adr.rb into Adr::Repository, updating every caller (grep plugins/os-adr) — check: absent slugify in plugins/os-adr/lib/adr.rb

Acceptance criteria

  1. Given the refactored code, when ruby plugins/os-adr/tests/all.rb runs, then the suite passes with the same run count.
  2. Given the refactored Repository, when bin/adr-new creates an ADR, then it writes the same file names as before.
  3. Given plugins/os-adr/lib/adr.rb, when inspected, then it only boots the loader (no slugify definition).

Owner sketch

class Adr::Repository
  def file_name(id, title)
    "#{id}-#{slugify(title)}.md"
  end

  private

  def slugify(title)
    # slug implementation moved from Adr.slugify
  end
end

class Adr::Record::Creation
  def initialize(repository)
    @repository = repository
  end

  def file_name(id, title)
    @repository.file_name(id, title)
  end
end

Non-goals

Changing the slug algorithm or file-name format.

Origin

  • Trigger: crc-refactor run on plugins/os-adr, worktree crc-os-adr-2026-10-04
  • Improvised this session: none
  • Chain: structure-only refactor decided to defer slugify move to follow-up ← ADR-0271 (Proposed) and ruling R17 (option A: slugify belongs to Repository)
  • Root candidate: none (this is the root)
  • Where: plugins/os-adr/lib/adr/command/record/creation.rb and plugins/os-adr/lib/adr/adapter/repository.rb
  • Session: a20defa9-036a-415a-9dde-2ed833c727cb
  • Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os--claude-worktrees-crc-refactor-docs/a20defa9-036a-415a-9dde-2ed833c727cb.jsonl

VERDICT: CREATE. Recorded decision R17 (option A) provides provenance. The file-name rule exists in two copies, so this is real duplication that a ruling chose to fix. The Origin chain ends in a ruling, not an IMPROVISATION.

Note

Rewritten 2026-10-16 for the A15 domain-first layout (9e416b0f); the creation.rb duplicate no longer exists.

## Problem `Adr.slugify` still lives on the namespace root in the loader file plugins/os-adr/lib/adr.rb, while the file-name rule `"#{id}-#{Adr.slugify(title)}.md"` lives in `Adr::Repository#path_for` (plugins/os-adr/lib/adr/repository.rb:96). The duplicate copy in the record creator is gone: plugins/os-adr/lib/adr/record/creation.rb:54 already calls `@repository.path_for`. What remains is the slug rule sitting in the loader file instead of with its only owner. ## Approach `Adr::Repository` (plugins/os-adr/lib/adr/repository.rb) owns the slug rule. Required work: 1. Move `Adr.slugify` out of plugins/os-adr/lib/adr.rb into `Adr::Repository`, updating every caller (grep plugins/os-adr) — check: absent `slugify` in `plugins/os-adr/lib/adr.rb` ## Acceptance criteria 1. Given the refactored code, when ruby plugins/os-adr/tests/all.rb runs, then the suite passes with the same run count. 2. Given the refactored Repository, when bin/adr-new creates an ADR, then it writes the same file names as before. 3. Given plugins/os-adr/lib/adr.rb, when inspected, then it only boots the loader (no slugify definition). ## Owner sketch ```ruby class Adr::Repository def file_name(id, title) "#{id}-#{slugify(title)}.md" end private def slugify(title) # slug implementation moved from Adr.slugify end end class Adr::Record::Creation def initialize(repository) @repository = repository end def file_name(id, title) @repository.file_name(id, title) end end ``` ## Non-goals Changing the slug algorithm or file-name format. ## Origin - Trigger: crc-refactor run on plugins/os-adr, worktree crc-os-adr-2026-10-04 - Improvised this session: none - Chain: structure-only refactor decided to defer slugify move to follow-up ← ADR-0271 (Proposed) and ruling R17 (option A: slugify belongs to Repository) - Root candidate: none (this is the root) - Where: plugins/os-adr/lib/adr/command/record/creation.rb and plugins/os-adr/lib/adr/adapter/repository.rb - Session: a20defa9-036a-415a-9dde-2ed833c727cb - Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os--claude-worktrees-crc-refactor-docs/a20defa9-036a-415a-9dde-2ed833c727cb.jsonl VERDICT: CREATE. Recorded decision R17 (option A) provides provenance. The file-name rule exists in two copies, so this is real duplication that a ruling chose to fix. The Origin chain ends in a ruling, not an IMPROVISATION. ## Note Rewritten 2026-10-16 for the A15 domain-first layout (9e416b0f); the creation.rb duplicate no longer exists.
Author
Owner

Body rewritten 2026-10-16 with current A15 paths: the duplicate file-name rule in record/creation.rb is already gone (it calls Repository#path_for); only Adr.slugify in plugins/os-adr/lib/adr.rb remains to move into Repository.

Body rewritten 2026-10-16 with current A15 paths: the duplicate file-name rule in record/creation.rb is already gone (it calls Repository#path_for); only Adr.slugify in plugins/os-adr/lib/adr.rb remains to move into Repository.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jared/cc-os#934
No description provided.