Convert the plugins that do not use Zeitwerk to Zeitwerk autoloading, with os-sdlc as the template #800
Labels
No labels
P0
P1
P2
P3
bug
category/code-change
category/cross-repo
category/eval-run
category/investigation
category/no-test-target
category/owner-ruling
category/prose-artifact
category/recurring-chore
category/structure
category/umbrella
crc-refactor
create
delete
enhancement
filed-by/agent
filed-by/user
frozen
lint-rule
needs-info
needs-triage
next
plugin/cc-architect
plugin/os
plugin/os-adr
plugin/os-aidd-lint
plugin/os-backlog
plugin/os-context
plugin/os-doc-hygiene
plugin/os-sdlc
plugin/os-vault
project/cc-os
ready-for-agent
ready-for-human
recurring
review
rule-proposal
update
waiting
wayfinder:grilling
wayfinder:map
wayfinder:map
wayfinder:research
wayfinder:task
wayfinder:task
wontfix
worklist/deviations
worklist/lint-rule
worklist/new-implement-build
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jared/cc-os#800
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Eight of the nine
os-*plugins load their code by hand-writtenrequire_relativechains instead of Zeitwerk. A missing require in that scheme surfaces only when a file happens to run inside a preload that already requires the missing constant, not when the file runs alone.plugins/os/tests/all.rbhid exactly this gap:plugins/os/tests/worktree/start_command_test.rbraisedNameError: SerializedChdirwhen run by itself, and 3 other files failed the same way, until #533 gave every test file its ownrequire_relative "test_helper".plugins/os-sdlcdoes not have this class of failure. It loads production code throughZeitwerk::Loaderinplugins/os-sdlc/lib/os_sdlc.rb(ADR-0194) and bootstraps its tests throughplugins/os-sdlc/tests/test_helper.rb, which also loads itstests/support/fixtures through a secondZeitwerk::Loader. Grep confirms the split:plugins/os-sdlcis the only plugin underplugins/*whoseGemfileorlib/referenceszeitwerk;plugins/cc-architect,plugins/os,plugins/os-adr,plugins/os-aidd-lint,plugins/os-backlog,plugins/os-context,plugins/os-doc-hygiene, andplugins/os-vaultall still hand-wire requires.Approach
Required work:
cc-architect,os,os-adr,os-aidd-lint,os-backlog,os-context,os-doc-hygiene,os-vault), give it aZeitwerk::Loaderentry point shaped likeplugins/os-sdlc/lib/os_sdlc.rb, and bootstrap its tests through atests/test_helper.rbthat also loadstests/support/viaZeitwerk::Loader, shaped likeplugins/os-sdlc/tests/test_helper.rb— check:for f in $(find plugins/<name>/tests -name '*_test.rb'); do ruby "$f" || echo FAIL "$f"; doneRejected: converting all eight plugins in this one ticket — too large a diff for one reviewable increment; left to the implementing agent to slice.
Acceptance criteria
tests/all.rb), then it passes without aNameErrorfor a missing constant.lib/directory, when its entry-point file loads, then it registers aZeitwerk::Loaderthe wayplugins/os-sdlc/lib/os_sdlc.rbdoes.Owner sketch
Non-goals
Converting
plugins/os-sdlcitself — it already uses Zeitwerk. Changing the runtime behavior of any converted plugin's commands.Origin
cd plugins/os && ruby tests/worktree/start_command_test.rbraisedNameError: uninitialized constant SerializedChdir, fixed in #533 by adding a per-filetests/test_helper.rbrequire.plugins/os; this ticket generalizes the fix to the other seven affected plugins.plugins/os-sdlcadopted Zeitwerk under ADR-0194; the rest were never migrated.Work started on branch worktree-ticket-800 (session aa699ebb). Pilot on plugins/os first, then the other seven in parallel, one commit per plugin.
Resolution
Done: Converted every Ruby plugin (os, os-adr, os-aidd-lint, os-backlog) from hand-written require_relative chains to Zeitwerk autoloading shaped like os-sdlc: one loader over lib/ with a cli=>CLI inflection, tests/test_helper.rb eager-loads a second loader over tests/support/, and a zeitwerk_eager_load_test.rb per plugin enforces file-to-constant naming. ADR-0241 records the convention. cc-architect, os-context, os-doc-hygiene, and os-vault have no Ruby lib/ and were not touched; the ticket's count of eight was wrong, four Ruby plugins existed.
Evidence: main
e5716bb4(fast-forward). Every _test.rb run alone across the four plugins: 27+7+53+53 files, 0 failures, run twice. Suites: os 32 runs, os-adr 51, os-aidd-lint 503, os-backlog 269, all 0 failures. Bins boot: worktree, adr-, aidd-lint, os-backlog. Conversion exposed two latent stdlib gaps (YAML, JSON, Time, Date used without require; order-dependent under lazy loading) fixed in test_helper. Plugin cache refreshed.Follow-ups: none